diff --git "a/train.txt" "b/train.txt" new file mode 100644--- /dev/null +++ "b/train.txt" @@ -0,0 +1,334088 @@ +.\" copyright (c) 2008 michael kerrisk +.\" +.\" %%%license_start(gplv2+_sw_3_para) +.\" this program is free software; you can redistribute it and/or modify +.\" it under the terms of the gnu general public license as published by +.\" the free software foundation; either version 2 of the license, or +.\" (at your option) any later version. +.\" +.\" this program 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th timerfd_create 2 2021-03-22 linux "linux programmer's manual" +.sh name +timerfd_create, timerfd_settime, timerfd_gettime \- +timers that notify via file descriptors +.sh synopsis +.nf +.b #include +.pp +.bi "int timerfd_create(int " clockid ", int " flags ); +.pp +.bi "int timerfd_settime(int " fd ", int " flags , +.bi " const struct itimerspec *" new_value , +.bi " struct itimerspec *" old_value ); +.bi "int timerfd_gettime(int " fd ", struct itimerspec *" curr_value ); +.fi +.sh description +these system calls create and operate on a timer +that delivers timer expiration notifications via a file descriptor. +they provide an alternative to the use of +.br setitimer (2) +or +.br timer_create (2), +with the advantage that the file descriptor may be monitored by +.br select (2), +.br poll (2), +and +.br epoll (7). +.pp +the use of these three system calls is analogous to the use of +.br timer_create (2), +.br timer_settime (2), +and +.br timer_gettime (2). +(there is no analog of +.br timer_getoverrun (2), +since that functionality is provided by +.br read (2), +as described below.) +.\" +.ss timerfd_create() +.br timerfd_create () +creates a new timer object, +and returns a file descriptor that refers to that timer. +the +.i clockid +argument specifies the clock that is used to mark the progress +of the timer, and must be one of the following: +.tp +.b clock_realtime +a settable system-wide real-time clock. +.tp +.b clock_monotonic +a nonsettable monotonically increasing clock that measures time +from some unspecified point in the past that does not change +after system startup. +.tp +.br clock_boottime " (since linux 3.15)" +.\" commit 4a2378a943f09907fb1ae35c15de917f60289c14 +like +.br clock_monotonic , +this is a monotonically increasing clock. +however, whereas the +.br clock_monotonic +clock does not measure the time while a system is suspended, the +.br clock_boottime +clock does include the time during which the system is suspended. +this is useful for applications that need to be suspend-aware. +.br clock_realtime +is not suitable for such applications, since that clock is affected +by discontinuous changes to the system clock. +.tp +.br clock_realtime_alarm " (since linux 3.11)" +.\" commit 11ffa9d6065f344a9bd769a2452f26f2f671e5f8 +this clock is like +.br clock_realtime , +but will wake the system if it is suspended. +the caller must have the +.b cap_wake_alarm +capability in order to set a timer against this clock. +.tp +.br clock_boottime_alarm " (since linux 3.11)" +.\" commit 11ffa9d6065f344a9bd769a2452f26f2f671e5f8 +this clock is like +.br clock_boottime , +but will wake the system if it is suspended. +the caller must have the +.b cap_wake_alarm +capability in order to set a timer against this clock. +.pp +see +.br clock_getres (2) +for some further details on the above clocks. +.pp +the current value of each of these clocks can be retrieved using +.br clock_gettime (2). +.pp +starting with linux 2.6.27, the following values may be bitwise ored in +.ir flags +to change the behavior of +.br timerfd_create (): +.tp 14 +.b tfd_nonblock +set the +.br o_nonblock +file status flag on the open file description (see +.br open (2)) +referred to by the new file descriptor. +using this flag saves extra calls to +.br fcntl (2) +to achieve the same result. +.tp +.b tfd_cloexec +set the close-on-exec +.rb ( fd_cloexec ) +flag on the new file descriptor. +see the description of the +.b o_cloexec +flag in +.br open (2) +for reasons why this may be useful. +.pp +in linux versions up to and including 2.6.26, +.i flags +must be specified as zero. +.ss timerfd_settime() +.br timerfd_settime () +arms (starts) or disarms (stops) +the timer referred to by the file descriptor +.ir fd . +.pp +the +.i new_value +argument specifies the initial expiration and interval for the timer. +the +.i itimerspec +structure used for this argument contains two fields, +each of which is in turn a structure of type +.ir timespec : +.pp +.in +4n +.ex +struct timespec { + time_t tv_sec; /* seconds */ + long tv_nsec; /* nanoseconds */ +}; + +struct itimerspec { + struct timespec it_interval; /* interval for periodic timer */ + struct timespec it_value; /* initial expiration */ +}; +.ee +.in +.pp +.i new_value.it_value +specifies the initial expiration of the timer, +in seconds and nanoseconds. +setting either field of +.i new_value.it_value +to a nonzero value arms the timer. +setting both fields of +.i new_value.it_value +to zero disarms the timer. +.pp +setting one or both fields of +.i new_value.it_interval +to nonzero values specifies the period, in seconds and nanoseconds, +for repeated timer expirations after the initial expiration. +if both fields of +.i new_value.it_interval +are zero, the timer expires just once, at the time specified by +.ir new_value.it_value . +.pp +by default, +the initial expiration time specified in +.i new_value +is interpreted relative to the current time +on the timer's clock at the time of the call (i.e., +.i new_value.it_value +specifies a time relative to the current value of the clock specified by +.ir clockid ). +an absolute timeout can be selected via the +.i flags +argument. +.pp +the +.i flags +argument is a bit mask that can include the following values: +.tp +.b tfd_timer_abstime +interpret +.i new_value.it_value +as an absolute value on the timer's clock. +the timer will expire when the value of the timer's +clock reaches the value specified in +.ir new_value.it_value . +.tp +.br tfd_timer_cancel_on_set +if this flag is specified along with +.b tfd_timer_abstime +and the clock for this timer is +.br clock_realtime +or +.br clock_realtime_alarm , +then mark this timer as cancelable if the real-time clock +undergoes a discontinuous change +.rb ( settimeofday (2), +.br clock_settime (2), +or similar). +when such changes occur, a current or future +.br read (2) +from the file descriptor will fail with the error +.br ecanceled . +.pp +if the +.i old_value +argument is not null, then the +.i itimerspec +structure that it points to is used to return the setting of the timer +that was current at the time of the call; +see the description of +.br timerfd_gettime () +following. +.\" +.ss timerfd_gettime() +.br timerfd_gettime () +returns, in +.ir curr_value , +an +.ir itimerspec +structure that contains the current setting of the timer +referred to by the file descriptor +.ir fd . +.pp +the +.i it_value +field returns the amount of time +until the timer will next expire. +if both fields of this structure are zero, +then the timer is currently disarmed. +this field always contains a relative value, regardless of whether the +.br tfd_timer_abstime +flag was specified when setting the timer. +.pp +the +.i it_interval +field returns the interval of the timer. +if both fields of this structure are zero, +then the timer is set to expire just once, at the time specified by +.ir curr_value.it_value . +.ss operating on a timer file descriptor +the file descriptor returned by +.br timerfd_create () +supports the following additional operations: +.tp +.br read (2) +if the timer has already expired one or more times since +its settings were last modified using +.br timerfd_settime (), +or since the last successful +.br read (2), +then the buffer given to +.br read (2) +returns an unsigned 8-byte integer +.ri ( uint64_t ) +containing the number of expirations that have occurred. +(the returned value is in host byte order\(emthat is, +the native byte order for integers on the host machine.) +.ip +if no timer expirations have occurred at the time of the +.br read (2), +then the call either blocks until the next timer expiration, +or fails with the error +.b eagain +if the file descriptor has been made nonblocking +(via the use of the +.br fcntl (2) +.b f_setfl +operation to set the +.b o_nonblock +flag). +.ip +a +.br read (2) +fails with the error +.b einval +if the size of the supplied buffer is less than 8 bytes. +.ip +if the associated clock is either +.br clock_realtime +or +.br clock_realtime_alarm , +the timer is absolute +.rb ( tfd_timer_abstime ), +and the flag +.br tfd_timer_cancel_on_set +was specified when calling +.br timerfd_settime (), +then +.br read (2) +fails with the error +.br ecanceled +if the real-time clock undergoes a discontinuous change. +(this allows the reading application to discover +such discontinuous changes to the clock.) +.ip +if the associated clock is either +.br clock_realtime +or +.br clock_realtime_alarm , +the timer is absolute +.rb ( tfd_timer_abstime ), +and the flag +.br tfd_timer_cancel_on_set +was +.i not +specified when calling +.br timerfd_settime (), +then a discontinuous negative change to the clock (e.g., +.br clock_settime (2)) +may cause +.br read (2) +to unblock, but return a value of 0 (i.e., no bytes read), +if the clock change occurs after the time expired, +but before the +.br read (2) +on the file descriptor. +.tp +.br poll "(2), " select "(2) (and similar)" +the file descriptor is readable +(the +.br select (2) +.i readfds +argument; the +.br poll (2) +.b pollin +flag) +if one or more timer expirations have occurred. +.ip +the file descriptor also supports the other file-descriptor +multiplexing apis: +.br pselect (2), +.br ppoll (2), +and +.br epoll (7). +.tp +.br ioctl (2) +the following timerfd-specific command is supported: +.rs +.tp +.br tfd_ioc_set_ticks " (since linux 3.17)" +.\" commit 5442e9fbd7c23172a1c9bc736629cd123a9923f0 +adjust the number of timer expirations that have occurred. +the argument is a pointer to a nonzero 8-byte integer +.ri ( uint64_t *) +containing the new number of expirations. +once the number is set, any waiter on the timer is woken up. +the only purpose of this command is to restore the expirations +for the purpose of checkpoint/restore. +this operation is available only if the kernel was configured with the +.br config_checkpoint_restore +option. +.re +.tp +.br close (2) +when the file descriptor is no longer required it should be closed. +when all file descriptors associated with the same timer object +have been closed, +the timer is disarmed and its resources are freed by the kernel. +.\" +.ss fork(2) semantics +after a +.br fork (2), +the child inherits a copy of the file descriptor created by +.br timerfd_create (). +the file descriptor refers to the same underlying +timer object as the corresponding file descriptor in the parent, +and +.br read (2)s +in the child will return information about +expirations of the timer. +.\" +.ss execve(2) semantics +a file descriptor created by +.br timerfd_create () +is preserved across +.br execve (2), +and continues to generate timer expirations if the timer was armed. +.sh return value +on success, +.br timerfd_create () +returns a new file descriptor. +on error, \-1 is returned and +.i errno +is set to indicate the error. +.pp +.br timerfd_settime () +and +.br timerfd_gettime () +return 0 on success; +on error they return \-1, and set +.i errno +to indicate the error. +.sh errors +.br timerfd_create () +can fail with the following errors: +.tp +.b einval +the +.i clockid +is not valid. +.tp +.b einval +.i flags +is invalid; +or, in linux 2.6.26 or earlier, +.i flags +is nonzero. +.tp +.b emfile +the per-process limit on the number of open file descriptors has been reached. +.tp +.b enfile +the system-wide limit on the total number of open files has been +reached. +.tp +.b enodev +could not mount (internal) anonymous inode device. +.tp +.b enomem +there was insufficient kernel memory to create the timer. +.tp +.b eperm +.i clockid +was +.br clock_realtime_alarm +or +.br clock_boottime_alarm +but the caller did not have the +.br cap_wake_alarm +capability. +.pp +.br timerfd_settime () +and +.br timerfd_gettime () +can fail with the following errors: +.tp +.b ebadf +.i fd +is not a valid file descriptor. +.tp +.b efault +.ir new_value , +.ir old_value , +or +.i curr_value +is not valid a pointer. +.tp +.b einval +.i fd +is not a valid timerfd file descriptor. +.pp +.br timerfd_settime () +can also fail with the following errors: +.tp +.b ecanceled +see notes. +.tp +.b einval +.i new_value +is not properly initialized (one of the +.i tv_nsec +falls outside the range zero to 999,999,999). +.tp +.b einval +.\" this case only checked since 2.6.29, and 2.2.2[78].some-stable-version. +.\" in older kernel versions, no check was made for invalid flags. +.i flags +is invalid. +.sh versions +these system calls are available on linux since kernel 2.6.25. +library support is provided by glibc since version 2.8. +.sh conforming to +these system calls are linux-specific. +.sh notes +suppose the following scenario for +.br clock_realtime +or +.br clock_realtime_alarm +timer that was created with +.br timerfd_create (): +.ip (a) 4 +the timer has been started +.rb ( timerfd_settime ()) +with the +.br tfd_timer_abstime +and +.br tfd_timer_cancel_on_set +flags; +.ip (b) +a discontinuous change (e.g., +.br settimeofday (2)) +is subsequently made to the +.br clock_realtime +clock; and +.ip (c) +the caller once more calls +.br timerfd_settime () +to rearm the timer (without first doing a +.br read (2) +on the file descriptor). +.pp +in this case the following occurs: +.ip \(bu 2 +the +.br timerfd_settime () +returns \-1 with +.i errno +set to +.br ecanceled . +(this enables the caller to know that the previous timer was affected +by a discontinuous change to the clock.) +.ip \(bu +the timer +.i "is successfully rearmed" +with the settings provided in the second +.br timerfd_settime () +call. +(this was probably an implementation accident, but won't be fixed now, +in case there are applications that depend on this behaviour.) +.sh bugs +currently, +.\" 2.6.29 +.br timerfd_create () +supports fewer types of clock ids than +.br timer_create (2). +.sh examples +the following program creates a timer and then monitors its progress. +the program accepts up to three command-line arguments. +the first argument specifies the number of seconds for +the initial expiration of the timer. +the second argument specifies the interval for the timer, in seconds. +the third argument specifies the number of times the program should +allow the timer to expire before terminating. +the second and third command-line arguments are optional. +.pp +the following shell session demonstrates the use of the program: +.pp +.in +4n +.ex +.rb "$" " a.out 3 1 100" +0.000: timer started +3.000: read: 1; total=1 +4.000: read: 1; total=2 +.br "\(haz " " # type control\-z to suspend the program" +[1]+ stopped ./timerfd3_demo 3 1 100 +.rb "$ " "fg" " # resume execution after a few seconds" +a.out 3 1 100 +9.660: read: 5; total=7 +10.000: read: 1; total=8 +11.000: read: 1; total=9 +.br "\(hac " " # type control\-c to suspend the program" +.ee +.in +.ss program source +\& +.ex +.\" the commented out code here is what we currently need until +.\" the required stuff is in glibc +.\" +.\" +.\"/* link with \-lrt */ +.\"#define _gnu_source +.\"#include +.\"#include +.\"#include +.\"#if defined(__i386__) +.\"#define __nr_timerfd_create 322 +.\"#define __nr_timerfd_settime 325 +.\"#define __nr_timerfd_gettime 326 +.\"#endif +.\" +.\"static int +.\"timerfd_create(int clockid, int flags) +.\"{ +.\" return syscall(__nr_timerfd_create, clockid, flags); +.\"} +.\" +.\"static int +.\"timerfd_settime(int fd, int flags, struct itimerspec *new_value, +.\" struct itimerspec *curr_value) +.\"{ +.\" return syscall(__nr_timerfd_settime, fd, flags, new_value, +.\" curr_value); +.\"} +.\" +.\"static int +.\"timerfd_gettime(int fd, struct itimerspec *curr_value) +.\"{ +.\" return syscall(__nr_timerfd_gettime, fd, curr_value); +.\"} +.\" +.\"#define tfd_timer_abstime (1 << 0) +.\" +.\"//////////////////////////////////////////////////////////// +#include +#include +#include +#include /* definition of priu64 */ +#include +#include +#include /* definition of uint64_t */ + +#define handle_error(msg) \e + do { perror(msg); exit(exit_failure); } while (0) + +static void +print_elapsed_time(void) +{ + static struct timespec start; + struct timespec curr; + static int first_call = 1; + int secs, nsecs; + + if (first_call) { + first_call = 0; + if (clock_gettime(clock_monotonic, &start) == \-1) + handle_error("clock_gettime"); + } + + if (clock_gettime(clock_monotonic, &curr) == \-1) + handle_error("clock_gettime"); + + secs = curr.tv_sec \- start.tv_sec; + nsecs = curr.tv_nsec \- start.tv_nsec; + if (nsecs < 0) { + secs\-\-; + nsecs += 1000000000; + } + printf("%d.%03d: ", secs, (nsecs + 500000) / 1000000); +} + +int +main(int argc, char *argv[]) +{ + struct itimerspec new_value; + int max_exp, fd; + struct timespec now; + uint64_t exp, tot_exp; + ssize_t s; + + if ((argc != 2) && (argc != 4)) { + fprintf(stderr, "%s init\-secs [interval\-secs max\-exp]\en", + argv[0]); + exit(exit_failure); + } + + if (clock_gettime(clock_realtime, &now) == \-1) + handle_error("clock_gettime"); + + /* create a clock_realtime absolute timer with initial + expiration and interval as specified in command line. */ + + new_value.it_value.tv_sec = now.tv_sec + atoi(argv[1]); + new_value.it_value.tv_nsec = now.tv_nsec; + if (argc == 2) { + new_value.it_interval.tv_sec = 0; + max_exp = 1; + } else { + new_value.it_interval.tv_sec = atoi(argv[2]); + max_exp = atoi(argv[3]); + } + new_value.it_interval.tv_nsec = 0; + + fd = timerfd_create(clock_realtime, 0); + if (fd == \-1) + handle_error("timerfd_create"); + + if (timerfd_settime(fd, tfd_timer_abstime, &new_value, null) == \-1) + handle_error("timerfd_settime"); + + print_elapsed_time(); + printf("timer started\en"); + + for (tot_exp = 0; tot_exp < max_exp;) { + s = read(fd, &exp, sizeof(uint64_t)); + if (s != sizeof(uint64_t)) + handle_error("read"); + + tot_exp += exp; + print_elapsed_time(); + printf("read: %" priu64 "; total=%" priu64 "\en", exp, tot_exp); + } + + exit(exit_success); +} +.ee +.sh see also +.br eventfd (2), +.br poll (2), +.br read (2), +.br select (2), +.br setitimer (2), +.br signalfd (2), +.br timer_create (2), +.br timer_gettime (2), +.br timer_settime (2), +.br epoll (7), +.br time (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2002 andries brouwer (aeb@cwi.nl) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" inspired by a page written by walter harms. +.\" +.th getfsent 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +getfsent, getfsspec, getfsfile, setfsent, endfsent \- handle fstab entries +.sh synopsis +.nf +.b #include +.pp +.b "int setfsent(void);" +.b "struct fstab *getfsent(void);" +.b "void endfsent(void);" +.pp +.bi "struct fstab *getfsfile(const char *" mount_point ); +.bi "struct fstab *getfsspec(const char *" special_file ); +.fi +.sh description +these functions read from the file +.ir /etc/fstab . +the +.ir "struct fstab" +is defined by: +.pp +.in +4n +.ex +struct fstab { + char *fs_spec; /* block device name */ + char *fs_file; /* mount point */ + char *fs_vfstype; /* filesystem type */ + char *fs_mntops; /* mount options */ + const char *fs_type; /* rw/rq/ro/sw/xx option */ + int fs_freq; /* dump frequency, in days */ + int fs_passno; /* pass number on parallel dump */ +}; +.ee +.in +.pp +here the field +.i fs_type +contains (on a *bsd system) +one of the five strings "rw", "rq", "ro", "sw", "xx" +(read-write, read-write with quota, read-only, swap, ignore). +.pp +the function +.br setfsent () +opens the file when required and positions it at the first line. +.pp +the function +.br getfsent () +parses the next line from the file. +(after opening it when required.) +.pp +the function +.br endfsent () +closes the file when required. +.pp +the function +.br getfsspec () +searches the file from the start and returns the first entry found +for which the +.i fs_spec +field matches the +.i special_file +argument. +.pp +the function +.br getfsfile () +searches the file from the start and returns the first entry found +for which the +.i fs_file +field matches the +.i mount_point +argument. +.sh return value +upon success, the functions +.br getfsent (), +.br getfsfile (), +and +.br getfsspec () +return a pointer to a +.ir "struct fstab" , +while +.br setfsent () +returns 1. +upon failure or end-of-file, these functions return null and 0, respectively. +.\" .sh history +.\" the +.\" .br getfsent () +.\" function appeared in 4.0bsd; the other four functions appeared in 4.3bsd. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lb lb lbx +l l l. +interface attribute value +t{ +.br endfsent (), +.br setfsent () +t} thread safety t{ +mt-unsafe race:fsent +t} +t{ +.br getfsent (), +.br getfsspec (), +.br getfsfile () +t} thread safety t{ +mt-unsafe race:fsent locale +t} +.te +.hy +.ad +.sp 1 +.sh conforming to +these functions are not in posix.1. +several operating systems have them, for example, +*bsd, sunos, digital unix, aix (which also has a +.br getfstype ()). +hp-ux has functions of the same names, +that however use a +.ir "struct checklist" +instead of a +.ir "struct fstab" , +and calls these functions obsolete, superseded by +.br getmntent (3). +.sh notes +these functions are not thread-safe. +.pp +since linux allows mounting a block special device in several places, +and since several devices can have the same mount point, where the +last device with a given mount point is the interesting one, +while +.br getfsfile () +and +.br getfsspec () +only return the first occurrence, these two functions are not suitable +for use under linux. +.sh see also +.br getmntent (3), +.br fstab (5) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/ctime.3 + +.\" copyright (c) 2017, michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th pthread_spin_lock 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +pthread_spin_lock, pthread_spin_trylock, pthread_spin_unlock \- +lock and unlock a spin lock +.sh synopsis +.nf +.b #include +.pp +.bi "int pthread_spin_lock(pthread_spinlock_t *" lock ); +.bi "int pthread_spin_trylock(pthread_spinlock_t *" lock ); +.bi "int pthread_spin_unlock(pthread_spinlock_t *" lock ); +.fi +.pp +compile and link with \fi\-pthread\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br pthread_spin_lock (), +.br pthread_spin_trylock (): +.nf + _posix_c_source >= 200112l +.fi +.sh description +the +.br pthread_spin_lock () +function locks the spin lock referred to by +.ir lock . +if the spin lock is currently unlocked, +the calling thread acquires the lock immediately. +if the spin lock is currently locked by another thread, +the calling thread spins, testing the lock until it becomes available, +at which point the calling thread acquires the lock. +.pp +calling +.br pthread_spin_lock () +on a lock that is already held by the caller +or a lock that has not been initialized with +.br pthread_spin_init (3) +results in undefined behavior. +.pp +the +.br pthread_spin_trylock () +function is like +.br pthread_spin_lock (), +except that if the spin lock referred to by +.i lock +is currently locked, +then, instead of spinning, the call returns immediately with the error +.br ebusy . +.pp +the +.br pthread_spin_unlock () +function unlocks the spin lock referred to +.ir lock . +if any threads are spinning on the lock, +one of those threads will then acquire the lock. +.pp +calling +.br pthread_spin_unlock () +on a lock that is not held by the caller results in undefined behavior. +.sh return value +on success, these functions return zero. +on failure, they return an error number. +.sh errors +.br pthread_spin_lock () +may fail with the following errors: +.tp +.b edeadlock +.\" not detected in glibc +the system detected a deadlock condition. +.pp +.br pthread_spin_trylock () +fails with the following errors: +.tp +.b ebusy +the spin lock is currently locked by another thread. +.sh versions +these functions first appeared in glibc in version 2.2. +.sh conforming to +posix.1-2001. +.sh notes +applying any of the functions described on this page to +an uninitialized spin lock results in undefined behavior. +.pp +carefully read notes in +.br pthread_spin_init (3). +.sh see also +.ad l +.nh +.\" fixme . .br pthread_mutex_lock (3), +.br pthread_spin_destroy (3), +.br pthread_spin_init (3), +.br pthreads (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/stailq.3 + +.so man2/process_vm_readv.2 + +.so man3/ctime.3 + +.\" copyright (c) 1992 drew eckhardt (drew@cs.colorado.edu), march 28, 1992 +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified by michael haardt +.\" modified 1993-07-24 by rik faith +.\" modified 1996-10-22 by eric s. raymond +.\" modified 2004-06-23 by michael kerrisk +.\" modified 2005-01-09 by aeb +.\" +.th uselib 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +uselib \- load shared library +.sh synopsis +.nf +.b #include +.pp +.bi "int uselib(const char *" library ); +.fi +.pp +.ir note : +no declaration of this system call is provided in glibc headers; see notes. +.sh description +the system call +.br uselib () +serves to load +a shared library to be used by the calling process. +it is given a pathname. +the address where to load is found +in the library itself. +the library can have any recognized +binary format. +.sh return value +on success, zero is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +in addition to all of the error codes returned by +.br open (2) +and +.br mmap (2), +the following may also be returned: +.tp +.b eacces +the library specified by +.i library +does not have read or execute permission, or the caller does not have +search permission for one of the directories in the path prefix. +(see also +.br path_resolution (7).) +.tp +.b enfile +the system-wide limit on the total number of open files has been reached. +.tp +.b enoexec +the file specified by +.i library +is not an executable of a known type; +for example, it does not have the correct magic numbers. +.sh conforming to +.br uselib () +is linux-specific, and should not be used in programs +intended to be portable. +.sh notes +this obsolete system call is not supported by glibc. +no declaration is provided in glibc headers, but, through a quirk of history, +glibc versions before 2.23 did export an abi for this system call. +therefore, in order to employ this system call, +it was sufficient to manually declare the interface in your code; +alternatively, you could invoke the system call using +.br syscall (2). +.pp +in ancient libc versions (before glibc 2.0), +.br uselib () +was used to load +the shared libraries with names found in an array of names +in the binary. +.\" .pp +.\" .\" libc 4.3.1f - changelog 1993-03-02 +.\" since libc 4.3.2, startup code tries to prefix these names +.\" with "/usr/lib", "/lib" and "" before giving up. +.\" .\" libc 4.3.4 - changelog 1993-04-21 +.\" in libc 4.3.4 and later these names are looked for in the directories +.\" found in +.\" .br ld_library_path , +.\" and if not found there, +.\" prefixes "/usr/lib", "/lib" and "/" are tried. +.\" .pp +.\" from libc 4.4.4 on only the library "/lib/ld.so" is loaded, +.\" so that this dynamic library can load the remaining libraries needed +.\" (again using this call). +.\" this is also the state of affairs in libc5. +.\" .pp +.\" glibc2 does not use this call. +.pp +since linux 3.15, +.\" commit 69369a7003735d0d8ef22097e27a55a8bad9557a +this system call is available only when the kernel is configured with the +.b config_uselib +option. +.sh see also +.br ar (1), +.br gcc (1), +.br ld (1), +.br ldd (1), +.br mmap (2), +.br open (2), +.br dlopen (3), +.br capabilities (7), +.br ld.so (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/pthread_mutexattr_setrobust.3 + +.\" copyright 2001 john levon +.\" based on mkstemp(3), copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" and gnu libc documentation +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.th mkdtemp 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +mkdtemp \- create a unique temporary directory +.sh synopsis +.nf +.b #include +.pp +.bi "char *mkdtemp(char *" template ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br mkdtemp (): +.nf + /* since glibc 2.19: */ _default_source + || /* glibc 2.19 and earlier: */ _bsd_source + || /* since glibc 2.10: */ _posix_c_source >= 200809l +.fi +.sh description +the +.br mkdtemp () +function generates a uniquely named temporary +directory from \fitemplate\fp. +the last six characters of \fitemplate\fp +must be xxxxxx and these are replaced with a string that makes the +directory name unique. +the directory is then created with +permissions 0700. +since it will be modified, +.i template +must not be a string constant, but should be declared as a character array. +.sh return value +the +.br mkdtemp () +function returns a pointer to the modified template +string on success, and null on failure, in which case +.i errno +is set to indicate the error. +.sh errors +.tp +.b einval +the last six characters of \fitemplate\fp were not xxxxxx. +now \fitemplate\fp is unchanged. +.pp +also see +.br mkdir (2) +for other possible values for \fierrno\fp. +.sh versions +available since glibc 2.1.91. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br mkdtemp () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2008. +this function is present on the bsds. +.\" as at 2006, this function is being considered for a revision of posix.1 +.\" also in netbsd 1.4. +.sh see also +.br mktemp (1), +.br mkdir (2), +.br mkstemp (3), +.br mktemp (3), +.br tempnam (3), +.br tmpfile (3), +.br tmpnam (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/unimplemented.2 + +.so man3/printf.3 + +.\" copyright (c) 2006 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th sem_overview 7 2020-06-09 "linux" "linux programmer's manual" +.sh name +sem_overview \- overview of posix semaphores +.sh description +posix semaphores allow processes and threads to synchronize their actions. +.pp +a semaphore is an integer whose value is never allowed to fall below zero. +two operations can be performed on semaphores: +increment the semaphore value by one +.rb ( sem_post (3)); +and decrement the semaphore value by one +.rb ( sem_wait (3)). +if the value of a semaphore is currently zero, then a +.br sem_wait (3) +operation will block until the value becomes greater than zero. +.pp +posix semaphores come in two forms: named semaphores and +unnamed semaphores. +.tp +.b named semaphores +a named semaphore is identified by a name of the form +.ir /somename ; +that is, a null-terminated string of up to +.bi name_max \-4 +(i.e., 251) characters consisting of an initial slash, +.\" glibc allows the initial slash to be omitted, and makes +.\" multiple initial slashes equivalent to a single slash. +.\" this differs from the implementation of posix message queues. +followed by one or more characters, none of which are slashes. +.\" glibc allows subdirectory components in the name, in which +.\" case the subdirectory tree must exist under /dev/shm, and +.\" the fist subdirectory component must exist as the name +.\" sem.name, and all of the subdirectory components must allow the +.\" required permissions if a user wants to create a semaphore +.\" object in a subdirectory. +two processes can operate on the same named semaphore by passing +the same name to +.br sem_open (3). +.ip +the +.br sem_open (3) +function creates a new named semaphore or opens an existing +named semaphore. +after the semaphore has been opened, it can be operated on using +.br sem_post (3) +and +.br sem_wait (3). +when a process has finished using the semaphore, it can use +.br sem_close (3) +to close the semaphore. +when all processes have finished using the semaphore, +it can be removed from the system using +.br sem_unlink (3). +.tp +.b unnamed semaphores (memory-based semaphores) +an unnamed semaphore does not have a name. +instead the semaphore is placed in a region of memory that +is shared between multiple threads (a +.ir "thread-shared semaphore" ) +or processes (a +.ir "process-shared semaphore" ). +a thread-shared semaphore is placed in an area of memory shared +between the threads of a process, for example, a global variable. +a process-shared semaphore must be placed in a shared memory region +(e.g., a system v shared memory segment created using +.br shmget (2), +or a posix shared memory object built created using +.br shm_open (3)). +.ip +before being used, an unnamed semaphore must be initialized using +.br sem_init (3). +it can then be operated on using +.br sem_post (3) +and +.br sem_wait (3). +when the semaphore is no longer required, +and before the memory in which it is located is deallocated, +the semaphore should be destroyed using +.br sem_destroy (3). +.pp +the remainder of this section describes some specific details +of the linux implementation of posix semaphores. +.ss versions +prior to kernel 2.6, linux supported only unnamed, +thread-shared semaphores. +on a system with linux 2.6 and a glibc that provides the nptl +threading implementation, +a complete implementation of posix semaphores is provided. +.ss persistence +posix named semaphores have kernel persistence: +if not removed by +.br sem_unlink (3), +a semaphore will exist until the system is shut down. +.ss linking +programs using the posix semaphores api must be compiled with +.i cc \-pthread +to link against the real-time library, +.ir librt . +.ss accessing named semaphores via the filesystem +on linux, named semaphores are created in a virtual filesystem, +normally mounted under +.ir /dev/shm , +with names of the form +.ir \fbsem.\fpsomename . +(this is the reason that semaphore names are limited to +.bi name_max \-4 +rather than +.b name_max +characters.) +.pp +since linux 2.6.19, acls can be placed on files under this directory, +to control object permissions on a per-user and per-group basis. +.sh notes +system v semaphores +.rb ( semget (2), +.br semop (2), +etc.) are an older semaphore api. +posix semaphores provide a simpler, and better designed interface than +system v semaphores; +on the other hand posix semaphores are less widely available +(especially on older systems) than system v semaphores. +.sh examples +an example of the use of various posix semaphore functions is shown in +.br sem_wait (3). +.sh see also +.br sem_close (3), +.br sem_destroy (3), +.br sem_getvalue (3), +.br sem_init (3), +.br sem_open (3), +.br sem_post (3), +.br sem_unlink (3), +.br sem_wait (3), +.br pthreads (7), +.br shm_overview (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man7/iso_8859-11.7 + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" iso/iec 9899:1999 +.\" +.th iswcntrl 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +iswcntrl \- test for control wide character +.sh synopsis +.nf +.b #include +.pp +.bi "int iswcntrl(wint_t " wc ); +.fi +.sh description +the +.br iswcntrl () +function is the wide-character equivalent of the +.br iscntrl (3) +function. +it tests whether +.i wc +is a wide character +belonging to the wide-character class "cntrl". +.pp +the wide-character class "cntrl" is disjoint from the wide-character class +"print" and therefore also disjoint from its subclasses "graph", "alpha", +"upper", "lower", "digit", "xdigit", "punct". +.pp +for an unsigned char +.ir c , +.i iscntrl(c) +implies +.ir iswcntrl(btowc(c)) , +but not vice versa. +.sh return value +the +.br iswcntrl () +function returns nonzero if +.i wc +is a +wide character belonging to the wide-character class "cntrl". +otherwise, it returns zero. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br iswcntrl () +t} thread safety mt-safe locale +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh notes +the behavior of +.br iswcntrl () +depends on the +.b lc_ctype +category of the +current locale. +.sh see also +.br iscntrl (3), +.br iswctype (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/getcwd.3 + +.so man3/sigvec.3 + +.so man3/exec.3 + +.\" copyright (c) 2016 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th signal-safety 7 2021-03-22 "linux" "linux programmer's manual" +.sh name +signal-safety \- async-signal-safe functions +.sh description +an +.i async-signal-safe +function is one that can be safely called from within a signal handler. +many functions are +.i not +async-signal-safe. +in particular, +nonreentrant functions are generally unsafe to call from a signal handler. +.pp +the kinds of issues that render a function +unsafe can be quickly understood when one considers +the implementation of the +.i stdio +library, all of whose functions are not async-signal-safe. +.pp +when performing buffered i/o on a file, the +.i stdio +functions must maintain a statically allocated data buffer +along with associated counters and indexes (or pointers) +that record the amount of data and the current position in the buffer. +suppose that the main program is in the middle of a call to a +.i stdio +function such as +.br printf (3) +where the buffer and associated variables have been partially updated. +if, at that moment, +the program is interrupted by a signal handler that also calls +.br printf (3), +then the second call to +.br printf (3) +will operate on inconsistent data, with unpredictable results. +.pp +to avoid problems with unsafe functions, there are two possible choices: +.ip 1. 3 +ensure that +(a) the signal handler calls only async-signal-safe functions, +and +(b) the signal handler itself is reentrant +with respect to global variables in the main program. +.ip 2. +block signal delivery in the main program when calling functions +that are unsafe or operating on global data that is also accessed +by the signal handler. +.pp +generally, the second choice is difficult in programs of any complexity, +so the first choice is taken. +.pp +posix.1 specifies a set of functions that an implementation +must make async-signal-safe. +(an implementation may provide safe implementations of additional functions, +but this is not required by the standard and other implementations +may not provide the same guarantees.) +.pp +in general, a function is async-signal-safe either because it is reentrant +or because it is atomic with respect to signals +(i.e., its execution can't be interrupted by a signal handler). +.pp +the set of functions required to be async-signal-safe by posix.1 +is shown in the following table. +the functions not otherwise noted were required to be async-signal-safe +in posix.1-2001; +the table details changes in the subsequent standards. +.pp +.ts +lb lb +l l. +function notes +\fbabort\fp(3) added in posix.1-2001 tc1 +\fbaccept\fp(2) +\fbaccess\fp(2) +\fbaio_error\fp(3) +\fbaio_return\fp(3) +\fbaio_suspend\fp(3) see notes below +\fbalarm\fp(2) +\fbbind\fp(2) +\fbcfgetispeed\fp(3) +\fbcfgetospeed\fp(3) +\fbcfsetispeed\fp(3) +\fbcfsetospeed\fp(3) +\fbchdir\fp(2) +\fbchmod\fp(2) +\fbchown\fp(2) +\fbclock_gettime\fp(2) +\fbclose\fp(2) +\fbconnect\fp(2) +\fbcreat\fp(2) +\fbdup\fp(2) +\fbdup2\fp(2) +\fbexecl\fp(3) t{ +added in posix.1-2008; see notes below +t} +\fbexecle\fp(3) see notes below +\fbexecv\fp(3) added in posix.1-2008 +\fbexecve\fp(2) +\fb_exit\fp(2) +\fb_exit\fp(2) +\fbfaccessat\fp(2) added in posix.1-2008 +\fbfchdir\fp(2) added in posix.1-2008 tc1 +\fbfchmod\fp(2) +\fbfchmodat\fp(2) added in posix.1-2008 +\fbfchown\fp(2) +\fbfchownat\fp(2) added in posix.1-2008 +\fbfcntl\fp(2) +\fbfdatasync\fp(2) +\fbfexecve\fp(3) added in posix.1-2008 +\fbffs\fp(3) added in posix.1-2008 tc2 +\fbfork\fp(2) see notes below +\fbfstat\fp(2) +\fbfstatat\fp(2) added in posix.1-2008 +\fbfsync\fp(2) +\fbftruncate\fp(2) +\fbfutimens\fp(3) added in posix.1-2008 +\fbgetegid\fp(2) +\fbgeteuid\fp(2) +\fbgetgid\fp(2) +\fbgetgroups\fp(2) +\fbgetpeername\fp(2) +\fbgetpgrp\fp(2) +\fbgetpid\fp(2) +\fbgetppid\fp(2) +\fbgetsockname\fp(2) +\fbgetsockopt\fp(2) +\fbgetuid\fp(2) +\fbhtonl\fp(3) added in posix.1-2008 tc2 +\fbhtons\fp(3) added in posix.1-2008 tc2 +\fbkill\fp(2) +\fblink\fp(2) +\fblinkat\fp(2) added in posix.1-2008 +\fblisten\fp(2) +\fblongjmp\fp(3) t{ +added in posix.1-2008 tc2; see notes below +t} +\fblseek\fp(2) +\fblstat\fp(2) +\fbmemccpy\fp(3) added in posix.1-2008 tc2 +\fbmemchr\fp(3) added in posix.1-2008 tc2 +\fbmemcmp\fp(3) added in posix.1-2008 tc2 +\fbmemcpy\fp(3) added in posix.1-2008 tc2 +\fbmemmove\fp(3) added in posix.1-2008 tc2 +\fbmemset\fp(3) added in posix.1-2008 tc2 +\fbmkdir\fp(2) +\fbmkdirat\fp(2) added in posix.1-2008 +\fbmkfifo\fp(3) +\fbmkfifoat\fp(3) added in posix.1-2008 +\fbmknod\fp(2) added in posix.1-2008 +\fbmknodat\fp(2) added in posix.1-2008 +\fbntohl\fp(3) added in posix.1-2008 tc2 +\fbntohs\fp(3) added in posix.1-2008 tc2 +\fbopen\fp(2) +\fbopenat\fp(2) added in posix.1-2008 +\fbpause\fp(2) +\fbpipe\fp(2) +\fbpoll\fp(2) +\fbposix_trace_event\fp(3) +\fbpselect\fp(2) +\fbpthread_kill\fp(3) added in posix.1-2008 tc1 +\fbpthread_self\fp(3) added in posix.1-2008 tc1 +\fbpthread_sigmask\fp(3) added in posix.1-2008 tc1 +\fbraise\fp(3) +\fbread\fp(2) +\fbreadlink\fp(2) +\fbreadlinkat\fp(2) added in posix.1-2008 +\fbrecv\fp(2) +\fbrecvfrom\fp(2) +\fbrecvmsg\fp(2) +\fbrename\fp(2) +\fbrenameat\fp(2) added in posix.1-2008 +\fbrmdir\fp(2) +\fbselect\fp(2) +\fbsem_post\fp(3) +\fbsend\fp(2) +\fbsendmsg\fp(2) +\fbsendto\fp(2) +\fbsetgid\fp(2) +\fbsetpgid\fp(2) +\fbsetsid\fp(2) +\fbsetsockopt\fp(2) +\fbsetuid\fp(2) +\fbshutdown\fp(2) +\fbsigaction\fp(2) +\fbsigaddset\fp(3) +\fbsigdelset\fp(3) +\fbsigemptyset\fp(3) +\fbsigfillset\fp(3) +\fbsigismember\fp(3) +\fbsiglongjmp\fp(3) t{ +added in posix.1-2008 tc2; see notes below +t} +\fbsignal\fp(2) +\fbsigpause\fp(3) +\fbsigpending\fp(2) +\fbsigprocmask\fp(2) +\fbsigqueue\fp(2) +\fbsigset\fp(3) +\fbsigsuspend\fp(2) +\fbsleep\fp(3) +\fbsockatmark\fp(3) added in posix.1-2001 tc2 +\fbsocket\fp(2) +\fbsocketpair\fp(2) +\fbstat\fp(2) +\fbstpcpy\fp(3) added in posix.1-2008 tc2 +\fbstpncpy\fp(3) added in posix.1-2008 tc2 +\fbstrcat\fp(3) added in posix.1-2008 tc2 +\fbstrchr\fp(3) added in posix.1-2008 tc2 +\fbstrcmp\fp(3) added in posix.1-2008 tc2 +\fbstrcpy\fp(3) added in posix.1-2008 tc2 +\fbstrcspn\fp(3) added in posix.1-2008 tc2 +\fbstrlen\fp(3) added in posix.1-2008 tc2 +\fbstrncat\fp(3) added in posix.1-2008 tc2 +\fbstrncmp\fp(3) added in posix.1-2008 tc2 +\fbstrncpy\fp(3) added in posix.1-2008 tc2 +\fbstrnlen\fp(3) added in posix.1-2008 tc2 +\fbstrpbrk\fp(3) added in posix.1-2008 tc2 +\fbstrrchr\fp(3) added in posix.1-2008 tc2 +\fbstrspn\fp(3) added in posix.1-2008 tc2 +\fbstrstr\fp(3) added in posix.1-2008 tc2 +\fbstrtok_r\fp(3) added in posix.1-2008 tc2 +\fbsymlink\fp(2) +\fbsymlinkat\fp(2) added in posix.1-2008 +\fbtcdrain\fp(3) +\fbtcflow\fp(3) +\fbtcflush\fp(3) +\fbtcgetattr\fp(3) +\fbtcgetpgrp\fp(3) +\fbtcsendbreak\fp(3) +\fbtcsetattr\fp(3) +\fbtcsetpgrp\fp(3) +\fbtime\fp(2) +\fbtimer_getoverrun\fp(2) +\fbtimer_gettime\fp(2) +\fbtimer_settime\fp(2) +\fbtimes\fp(2) +\fbumask\fp(2) +\fbuname\fp(2) +\fbunlink\fp(2) +\fbunlinkat\fp(2) added in posix.1-2008 +\fbutime\fp(2) +\fbutimensat\fp(2) added in posix.1-2008 +\fbutimes\fp(2) added in posix.1-2008 +\fbwait\fp(2) +\fbwaitpid\fp(2) +\fbwcpcpy\fp(3) added in posix.1-2008 tc2 +\fbwcpncpy\fp(3) added in posix.1-2008 tc2 +\fbwcscat\fp(3) added in posix.1-2008 tc2 +\fbwcschr\fp(3) added in posix.1-2008 tc2 +\fbwcscmp\fp(3) added in posix.1-2008 tc2 +\fbwcscpy\fp(3) added in posix.1-2008 tc2 +\fbwcscspn\fp(3) added in posix.1-2008 tc2 +\fbwcslen\fp(3) added in posix.1-2008 tc2 +\fbwcsncat\fp(3) added in posix.1-2008 tc2 +\fbwcsncmp\fp(3) added in posix.1-2008 tc2 +\fbwcsncpy\fp(3) added in posix.1-2008 tc2 +\fbwcsnlen\fp(3) added in posix.1-2008 tc2 +\fbwcspbrk\fp(3) added in posix.1-2008 tc2 +\fbwcsrchr\fp(3) added in posix.1-2008 tc2 +\fbwcsspn\fp(3) added in posix.1-2008 tc2 +\fbwcsstr\fp(3) added in posix.1-2008 tc2 +\fbwcstok\fp(3) added in posix.1-2008 tc2 +\fbwmemchr\fp(3) added in posix.1-2008 tc2 +\fbwmemcmp\fp(3) added in posix.1-2008 tc2 +\fbwmemcpy\fp(3) added in posix.1-2008 tc2 +\fbwmemmove\fp(3) added in posix.1-2008 tc2 +\fbwmemset\fp(3) added in posix.1-2008 tc2 +\fbwrite\fp(2) +.te +.pp +notes: +.ip * 3 +posix.1-2001 and posix.1-2001 tc2 required the functions +.br fpathconf (3), +.br pathconf (3), +and +.br sysconf (3) +to be async-signal-safe, but this requirement was removed in posix.1-2008. +.ip * +if a signal handler interrupts the execution of an unsafe function, +and the handler terminates via a call to +.br longjmp (3) +or +.br siglongjmp (3) +and the program subsequently calls an unsafe function, +then the behavior of the program is undefined. +.ip * +posix.1-2001 tc1 clarified +that if an application calls +.br fork (2) +from a signal handler and any of the fork handlers registered by +.br pthread_atfork (3) +calls a function that is not async-signal-safe, the behavior is undefined. +a future revision of the standard +.\" http://www.opengroup.org/austin/aardvark/latest/xshbug3.txt +is likely to remove +.br fork (2) +from the list of async-signal-safe functions. +.\" +.ip * 3 +asynchronous signal handlers that call functions which are cancellation +points and nest over regions of deferred cancellation may trigger +cancellation whose behavior is as if asynchronous cancellation had +occurred and may cause application state to become inconsistent. +.\" +.ss errno +fetching and setting the value of +.i errno +is async-signal-safe provided that the signal handler saves +.i errno +on entry and restores its value before returning. +.\" +.ss deviations in the gnu c library +the following known deviations from the standard occur in +the gnu c library: +.ip * 3 +before glibc 2.24, +.br execl (3) +and +.br execle (3) +employed +.br realloc (3) +internally and were consequently not async-signal-safe. +.\" https://sourceware.org/bugzilla/show_bug.cgi?id=19534 +this was fixed in glibc 2.24. +.ip * +.\" fixme . https://sourceware.org/bugzilla/show_bug.cgi?id=13172 +the glibc implementation of +.br aio_suspend (3) +is not async-signal-safe because it uses +.br pthread_mutex_lock (3) +internally. +.sh see also +.br sigaction (2), +.br signal (7), +.br standards (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/circleq.3 + +.\" copyright (c) 1995 martin schulze +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" 1995-10-18 martin schulze +.\" * first released +.\" 2002-09-22 seth w. klein +.\" * protocol numbers are now assigned by the iana +.\" +.th protocols 5 2012-08-05 "linux" "linux programmer's manual" +.sh name +protocols \- protocols definition file +.sh description +this file is a plain ascii file, describing the various darpa internet +protocols that are available from the tcp/ip subsystem. +it should be +consulted instead of using the numbers in the arpa include files, or, +even worse, just guessing them. +these numbers will occur in the +protocol field of any ip header. +.pp +keep this file untouched since changes would result in incorrect ip +packages. +protocol numbers and names are specified by the iana +(internet assigned numbers authority). +.\" .. by the ddn network information center. +.pp +each line is of the following format: +.pp +.rs +.i protocol number aliases ... +.re +.pp +where the fields are delimited by spaces or tabs. +empty lines are ignored. +if a line contains a hash mark (#), the hash mark and the part +of the line following it are ignored. +.pp +the field descriptions are: +.tp +.i protocol +the native name for the protocol. +for example +.ir ip , +.ir tcp , +or +.ir udp . +.tp +.i number +the official number for this protocol as it will appear within the ip +header. +.tp +.i aliases +optional aliases for the protocol. +.pp +this file might be distributed over a network using a network-wide +naming service like yellow pages/nis or bind/hesiod. +.sh files +.tp +.i /etc/protocols +the protocols definition file. +.sh see also +.br getprotoent (3) +.pp +.ur http://www.iana.org\:/assignments\:/protocol\-numbers +.ue +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" iso/iec 9899:1999 +.\" +.th mbsrtowcs 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +mbsrtowcs \- convert a multibyte string to a wide-character string +.sh synopsis +.nf +.b #include +.pp +.bi "size_t mbsrtowcs(wchar_t *restrict " dest ", const char **restrict " src , +.bi " size_t " len ", mbstate_t *restrict " ps ); +.fi +.sh description +if +.i dest +is not null, the +.br mbsrtowcs () +function converts the +multibyte string +.i *src +to a wide-character string starting at +.ir dest . +at most +.i len +wide characters are written to +.ir dest . +the shift state +.i *ps +is updated. +the conversion is effectively performed by repeatedly +calling +.i "mbrtowc(dest, *src, n, ps)" +where +.i n +is some +positive number, as long as this call succeeds, and then incrementing +.i dest +by one and +.i *src +by the number of bytes consumed. +the conversion can stop for three reasons: +.ip 1. 3 +an invalid multibyte sequence has been encountered. +in this case, +.i *src +is left pointing to the invalid multibyte sequence, +.i (size_t)\ \-1 +is returned, +and +.i errno +is set to +.br eilseq . +.ip 2. +.i len +non-l\(aq\e0\(aq wide characters have been stored at +.ir dest . +in this case, +.i *src +is left pointing to the next +multibyte sequence to be converted, +and the number of wide characters written to +.i dest +is returned. +.ip 3. +the multibyte string has been completely converted, including the +terminating null wide character (\(aq\e0\(aq), which has the side +effect of bringing back +.i *ps +to the +initial state. +in this case, +.i *src +is set to null, and the number of wide +characters written to +.ir dest , +excluding the terminating null wide character, is returned. +.pp +if +.ir dest +is null, +.i len +is ignored, +and the conversion proceeds as above, +except that the converted wide characters are not written out to memory, +and that no length limit exists. +.pp +in both of the above cases, +if +.i ps +is null, a static anonymous +state known only to the +.br mbsrtowcs () +function is used instead. +.pp +the programmer must ensure that there is room for at least +.i len +wide +characters at +.ir dest . +.sh return value +the +.br mbsrtowcs () +function returns the number of wide characters that make +up the converted part of the wide-character string, not including the +terminating null wide character. +if an invalid multibyte sequence was +encountered, +.i (size_t)\ \-1 +is returned, and +.i errno +set to +.br eilseq . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lb lb lbx +l l l. +interface attribute value +t{ +.br mbsrtowcs () +t} thread safety t{ +mt-unsafe race:mbsrtowcs/!ps +t} +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh notes +the behavior of +.br mbsrtowcs () +depends on the +.b lc_ctype +category of the +current locale. +.pp +passing null as +.i ps +is not multithread safe. +.sh see also +.br iconv (3), +.br mbrtowc (3), +.br mbsinit (3), +.br mbsnrtowcs (3), +.br mbstowcs (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2006 red hat, inc. all rights reserved. +.\" written by david howells (dhowells@redhat.com) +.\" and copyright (c) 2016 michael kerrisk +.\" +.\" %%%license_start(gplv2+_sw_onepara) +.\" this program is free software; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license +.\" as published by the free software foundation; either version +.\" 2 of the license, or (at your option) any later version. +.\" %%%license_end +.\" +.th request_key 2 2021-08-27 linux "linux key management calls" +.sh name +request_key \- request a key from the kernel's key management facility +.sh synopsis +.nf +.b #include +.pp +.bi "key_serial_t request_key(const char *" type ", const char *" description , +.bi " const char *" callout_info , +.bi " key_serial_t " dest_keyring ");" +.fi +.pp +.ir note : +there is no glibc wrapper for this system call; see notes. +.sh description +.br request_key () +attempts to find a key of the given +.i type +with a description (name) that matches the specified +.ir description . +if such a key could not be found, then the key is optionally created. +if the key is found or created, +.br request_key () +attaches it to the keyring whose id is specified in +.i dest_keyring +and returns the key's serial number. +.pp +.br request_key () +first recursively searches for a matching key in all of the keyrings +attached to the calling process. +the keyrings are searched in the order: thread-specific keyring, +process-specific keyring, and then session keyring. +.pp +if +.br request_key () +is called from a program invoked by +.br request_key () +on behalf of some other process to generate a key, then the keyrings of that +other process will be searched next, +using that other process's user id, group id, +supplementary group ids, and security context to determine access. +.\" david howells: we can then have an arbitrarily long sequence +.\" of "recursive" request-key upcalls. there is no limit, other +.\" than number of pids, etc. +.pp +the search of the keyring tree is breadth-first: +the keys in each keyring searched are checked for a match before any child +keyrings are recursed into. +only keys for which the caller has +.i search +permission be found, and only keyrings for which the caller has +.i search +permission may be searched. +.pp +if the key is not found and +.i callout +is null, then the call fails with the error +.br enokey . +.pp +if the key is not found and +.i callout +is not null, then the kernel attempts to invoke a user-space +program to instantiate the key. +the details are given below. +.pp +the +.i dest_keyring +serial number may be that of a valid keyring for which the caller has +.i write +permission, or it may be one of the following special keyring ids: +.tp +.b key_spec_thread_keyring +this specifies the caller's thread-specific keyring (see +.br thread\-keyring (7)). +.tp +.b key_spec_process_keyring +this specifies the caller's process-specific keyring (see +.br process\-keyring (7)). +.tp +.b key_spec_session_keyring +this specifies the caller's session-specific keyring (see +.br session\-keyring (7)). +.tp +.b key_spec_user_keyring +this specifies the caller's uid-specific keyring (see +.br user\-keyring (7)). +.tp +.b key_spec_user_session_keyring +this specifies the caller's uid-session keyring (see +.br user\-session\-keyring (7)). +.pp +when the +.i dest_keyring +is specified as 0 +and no key construction has been performed, +then no additional linking is done. +.pp +otherwise, if +.i dest_keyring +is 0 and a new key is constructed, the new key will be linked +to the "default" keyring. +more precisely, when the kernel tries to determine to which keyring the +newly constructed key should be linked, +it tries the following keyrings, +beginning with the keyring set via the +.br keyctl (2) +.br keyctl_set_reqkey_keyring +operation and continuing in the order shown below +until it finds the first keyring that exists: +.ip \(bu 3 +.\" 8bbf4976b59fc9fc2861e79cab7beb3f6d647640 +the requestor keyring +.rb ( key_reqkey_defl_requestor_keyring , +since linux 2.6.29). +.\" fixme +.\" actually, is the preceding point correct? +.\" if i understand correctly, we'll only get here if +.\" 'dest_keyring' is zero, in which case key_reqkey_defl_requestor_keyring +.\" won't refer to a keyring. have i misunderstood? +.ip \(bu +the thread-specific keyring +.rb ( key_reqkey_defl_thread_keyring ; +see +.br thread\-keyring (7)). +.ip \(bu +the process-specific keyring +.rb ( key_reqkey_defl_process_keyring ; +see +.br process\-keyring (7)). +.ip \(bu +the session-specific keyring +.rb ( key_reqkey_defl_session_keyring ; +see +.br session\-keyring (7)). +.ip \(bu +the session keyring for the process's user id +.rb ( key_reqkey_defl_user_session_keyring ; +see +.br user\-session\-keyring (7)). +this keyring is expected to always exist. +.ip \(bu +the uid-specific keyring +.rb ( key_reqkey_defl_user_keyring ; +see +.br user\-keyring (7)). +this keyring is also expected to always exist. +.\" mtk: are there circumstances where the user sessions and uid-specific +.\" keyrings do not exist? +.\" +.\" david howells: +.\" the uid keyrings don't exist until someone tries to access them - +.\" at which point they're both created. when you log in, pam_keyinit +.\" creates a link to your user keyring in the session keyring it just +.\" created, thereby creating the user and user-session keyrings. +.\" +.\" and david elaborated that "access" means: +.\" +.\" it means lookup_user_key() was passed key_lookup_create. so: +.\" +.\" add_key() - destination keyring +.\" request_key() - destination keyring +.\" keyctl_get_keyring_id - if create arg is true +.\" keyctl_clear +.\" keyctl_link - both args +.\" keyctl_search - destination keyring +.\" keyctl_chown +.\" keyctl_setperm +.\" keyctl_set_timeout +.\" keyctl_instantiate - destination keyring +.\" keyctl_instantiate_iov - destination keyring +.\" keyctl_negate - destination keyring +.\" keyctl_reject - destination keyring +.\" keyctl_get_persistent - destination keyring +.\" +.\" will all create a keyring under some circumstances. whereas the rest, +.\" such as keyctl_get_security, keyctl_read and keyctl_revoke, won't. +.pp +if the +.br keyctl (2) +.br keyctl_set_reqkey_keyring +operation specifies +.br key_reqkey_defl_default +(or no +.br keyctl_set_reqkey_keyring +operation is performed), +then the kernel looks for a keyring +starting from the beginning of the list. +.\" +.ss requesting user-space instantiation of a key +if the kernel cannot find a key matching +.ir type +and +.ir description , +and +.i callout +is not null, then the kernel attempts to invoke a user-space +program to instantiate a key with the given +.ir type +and +.ir description . +in this case, the following steps are performed: +.ip a) 4 +the kernel creates an uninstantiated key, u, with the requested +.i type +and +.ir description . +.ip b) +the kernel creates an authorization key, v, +.\" struct request_key_auth, defined in security/keys/internal.h +that refers to the key u and records the facts that the caller of +.br request_key () +is: +.rs +.ip (1) 4 +the context in which the key u should be instantiated and secured, and +.ip (2) +the context from which associated key requests may be satisfied. +.re +.ip +the authorization key is constructed as follows: +.rs +.ip * 3 +the key type is +.ir """.request_key_auth""" . +.ip * +the key's uid and gid are the same as the corresponding filesystem ids +of the requesting process. +.ip * +the key grants +.ir view , +.ir read , +and +.ir search +permissions to the key possessor as well as +.ir view +permission for the key user. +.ip * +the description (name) of the key is the hexadecimal +string representing the id of the key that is to be instantiated +in the requesting program. +.ip * +the payload of the key is taken from the data specified in +.ir callout_info . +.ip * +internally, the kernel also records the pid of the process that called +.br request_key (). +.re +.ip c) +the kernel creates a process that executes a user-space service such as +.br request\-key (8) +with a new session keyring that contains a link to the authorization key, v. +.\" the request\-key(8) program can be invoked in circumstances *other* than +.\" when triggered by request_key(2). for example, upcalls from places such +.\" as the dns resolver. +.ip +this program is supplied with the following command-line arguments: +.rs +.ip [0] 4 +the string +.ir """/sbin/request\-key""" . +.ip [1] +the string +.i """create""" +(indicating that a key is to be created). +.ip [2] +the id of the key that is to be instantiated. +.ip [3] +the filesystem uid of the caller of +.br request_key (). +.ip [4] +the filesystem gid of the caller of +.br request_key (). +.ip [5] +the id of the thread keyring of the caller of +.br request_key (). +this may be zero if that keyring hasn't been created. +.ip [6] +the id of the process keyring of the caller of +.br request_key (). +this may be zero if that keyring hasn't been created. +.ip [7] +the id of the session keyring of the caller of +.br request_key (). +.re +.ip +.ir note : +each of the command-line arguments that is a key id is encoded in +.ir decimal +(unlike the key ids shown in +.ir /proc/keys , +which are shown as hexadecimal values). +.ip d) +the program spawned in the previous step: +.rs +.ip * 3 +assumes the authority to instantiate the key u using the +.br keyctl (2) +.br keyctl_assume_authority +operation (typically via the +.br keyctl_assume_authority (3) +function). +.ip * +obtains the callout data from the payload of the authorization key v +(using the +.br keyctl (2) +.br keyctl_read +operation (or, more commonly, the +.br keyctl_read (3) +function) with a key id value of +.br key_spec_reqkey_auth_key ). +.ip * +instantiates the key +(or execs another program that performs that task), +specifying the payload and destination keyring. +(the destination keyring that the requestor specified when calling +.br request_key () +can be accessed using the special key id +.br key_spec_requestor_keyring .) +.\" should an instantiating program be using key_spec_requestor_keyring? +.\" i couldn't find a use in the keyutils git repo. +.\" according to david howells: +.\" * this feature is provided, but not used at the moment. +.\" * a key added to that ring is then owned by the requester +instantiation is performed using the +.br keyctl (2) +.br keyctl_instantiate +operation (or, more commonly, the +.br keyctl_instantiate (3) +function). +at this point, the +.br request_key () +call completes, and the requesting program can continue execution. +.re +.pp +if these steps are unsuccessful, then an +.br enokey +error will be returned to the caller of +.br request_key () +and a temporary, negatively instantiated key will be installed +in the keyring specified by +.ir dest_keyring . +this will expire after a few seconds, but will cause subsequent calls to +.br request_key () +to fail until it does. +the purpose of this negatively instantiated key is to prevent +(possibly different) processes making repeated requests +(that require expensive +.br request\-key (8) +upcalls) for a key that can't (at the moment) be positively instantiated. +.pp +once the key has been instantiated, the authorization key +.rb ( key_spec_reqkey_auth_key ) +is revoked, and the destination keyring +.rb ( key_spec_requestor_keyring ) +is no longer accessible from the +.br request\-key (8) +program. +.pp +if a key is created, then\(emregardless of whether it is a valid key or +a negatively instantiated key\(emit will displace any other key with +the same type and description from the keyring specified in +.ir dest_keyring . +.sh return value +on success, +.br request_key () +returns the serial number of the key it found or caused to be created. +on error, \-1 is returned and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eacces +the keyring wasn't available for modification by the user. +.tp +.b edquot +the key quota for this user would be exceeded by creating this key or linking +it to the keyring. +.tp +.b efault +one of +.ir type , +.ir description , +or +.ir callout_info +points outside the process's accessible address space. +.tp +.b eintr +the request was interrupted by a signal; see +.br signal (7). +.tp +.b einval +the size of the string (including the terminating null byte) specified in +.i type +or +.i description +exceeded the limit (32 bytes and 4096 bytes respectively). +.tp +.b einval +the size of the string (including the terminating null byte) specified in +.i callout_info +exceeded the system page size. +.tp +.b ekeyexpired +an expired key was found, but no replacement could be obtained. +.tp +.b ekeyrejected +the attempt to generate a new key was rejected. +.tp +.b ekeyrevoked +a revoked key was found, but no replacement could be obtained. +.tp +.b enokey +no matching key was found. +.tp +.b enomem +insufficient memory to create a key. +.tp +.b eperm +the +.i type +argument started with a period (\(aq.\(aq). +.sh versions +this system call first appeared in linux 2.6.10. +the ability to instantiate keys upon request was added +.\" commit 3e30148c3d524a9c1c63ca28261bc24c457eb07a +in linux 2.6.13. +.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. +(the accompanying package provides the +.i +header file.) +when employing the wrapper in that library, link with +.ir \-lkeyutils . +.sh examples +the program below demonstrates the use of +.br request_key (). +the +.ir type , +.ir description , +and +.ir callout_info +arguments for the system call are taken from the values +supplied in the command-line arguments. +the call specifies the session keyring as the target keyring. +.pp +in order to demonstrate this program, +we first create a suitable entry in the file +.ir /etc/request\-key.conf . +.pp +.in +4n +.ex +$ sudo sh +# \fbecho \(aqcreate user mtk:* * /bin/keyctl instantiate %k %c %s\(aq \e\fp + \fb> /etc/request\-key.conf\fp +# \fbexit\fp +.ee +.in +.pp +this entry specifies that when a new "user" key with the prefix +"mtk:" must be instantiated, that task should be performed via the +.br keyctl (1) +command's +.b instantiate +operation. +the arguments supplied to the +.b instantiate +operation are: +the id of the uninstantiated key +.ri ( %k ); +the callout data supplied to the +.br request_key () +call +.ri ( %c ); +and the session keyring +.ri ( %s ) +of the requestor (i.e., the caller of +.br request_key ()). +see +.br request\-key.conf (5) +for details of these +.i % +specifiers. +.pp +then we run the program and check the contents of +.ir /proc/keys +to verify that the requested key has been instantiated: +.pp +.in +4n +.ex +$ \fb./t_request_key user mtk:key1 "payload data"\fp +$ \fbgrep \(aq2dddaf50\(aq /proc/keys\fp +2dddaf50 i\-\-q\-\-\- 1 perm 3f010000 1000 1000 user mtk:key1: 12 +.ee +.in +.pp +for another example of the use of this program, see +.br keyctl (2). +.ss program source +\& +.ex +/* t_request_key.c */ + +#include +#include +#include +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + key_serial_t key; + + if (argc != 4) { + fprintf(stderr, "usage: %s type description callout\-data\en", + argv[0]); + exit(exit_failure); + } + + key = request_key(argv[1], argv[2], argv[3], + key_spec_session_keyring); + if (key == \-1) { + perror("request_key"); + exit(exit_failure); + } + + printf("key id is %jx\en", (uintmax_t) key); + + exit(exit_success); +} +.ee +.sh see also +.ad l +.nh +.br keyctl (1), +.br add_key (2), +.br keyctl (2), +.br keyctl (3), +.br capabilities (7), +.br keyrings (7), +.br keyutils (7), +.br persistent\-keyring (7), +.br process\-keyring (7), +.br session\-keyring (7), +.br thread\-keyring (7), +.br user\-keyring (7), +.br user\-session\-keyring (7), +.br request\-key (8) +.pp +the kernel source files +.ir documentation/security/keys/core.rst +and +.ir documentation/keys/request\-key.rst +(or, before linux 4.13, in the files +.\" commit b68101a1e8f0263dbc7b8375d2a7c57c6216fb76 +.ir documentation/security/keys.txt +and +.\" commit 3db38ed76890565772fcca3279cc8d454ea6176b +.ir documentation/security/keys\-request\-key.txt ). +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/gethostbyname.3 + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" iso/iec 9899:1999 +.\" +.th iswprint 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +iswprint \- test for printing wide character +.sh synopsis +.nf +.b #include +.pp +.bi "int iswprint(wint_t " wc ); +.fi +.sh description +the +.br iswprint () +function is the wide-character equivalent of the +.br isprint (3) +function. +it tests whether +.i wc +is a wide character +belonging to the wide-character class "print". +.pp +the wide-character class "print" is disjoint from the wide-character class +"cntrl". +.pp +the wide-character class "print" contains the wide-character class "graph". +.sh return value +the +.br iswprint () +function returns nonzero if +.i wc +is a +wide character belonging to the wide-character class "print". +otherwise, it returns zero. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br iswprint () +t} thread safety mt-safe locale +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh notes +the behavior of +.br iswprint () +depends on the +.b lc_ctype +category of the +current locale. +.sh see also +.br isprint (3), +.br iswctype (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/getgid.2 + +.so man2/rename.2 + +.\" copyright (c) 2006 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th sem_getvalue 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +sem_getvalue \- get the value of a semaphore +.sh synopsis +.nf +.b #include +.pp +.bi "int sem_getvalue(sem_t *restrict " sem ", int *restrict " sval ); +.fi +.pp +link with \fi\-pthread\fp. +.sh description +.br sem_getvalue () +places the current value of the semaphore pointed to +.i sem +into the integer pointed to by +.ir sval . +.pp +if one or more processes or threads are blocked +waiting to lock the semaphore with +.br sem_wait (3), +posix.1 permits two possibilities for the value returned in +.ir sval : +either 0 is returned; +or a negative number whose absolute value is the count +of the number of processes and threads currently blocked in +.br sem_wait (3). +linux adopts the former behavior. +.sh return value +.br sem_getvalue () +returns 0 on success; +on error, \-1 is returned and +.i errno +is set to indicate the error. +.sh errors +.tp +.b einval +.i sem +is not a valid semaphore. +(the glibc implementation currently does not check whether +.i sem +is valid.) +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br sem_getvalue () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +the value of the semaphore may already have changed by the time +.br sem_getvalue () +returns. +.sh see also +.br sem_post (3), +.br sem_wait (3), +.br sem_overview (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2006 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th mq_close 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +mq_close \- close a message queue descriptor +.sh synopsis +.nf +.b #include +.pp +.bi "int mq_close(mqd_t " mqdes ); +.fi +.pp +link with \fi\-lrt\fp. +.sh description +.br mq_close () +closes the message queue descriptor +.ir mqdes . +.pp +if the calling process has attached a notification request (see +.rb ( mq_notify (3)) +to this message queue via +.ir mqdes , +then this request is removed, +and another process can now attach a notification request. +.sh return value +on success +.br mq_close () +returns 0; on error, \-1 is returned, with +.i errno +set to indicate the error. +.sh errors +.tp +.b ebadf +the message queue descriptor specified in +.i mqdes +is invalid. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br mq_close () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +all open message queues are automatically closed on process termination, +or upon +.br execve (2). +.sh see also +.br mq_getattr (3), +.br mq_notify (3), +.br mq_open (3), +.br mq_receive (3), +.br mq_send (3), +.br mq_unlink (3), +.br mq_overview (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/des_crypt.3 + +.\" this man page is copyright (c) 1999 andi kleen , +.\" copyright (c) 2008-2014, michael kerrisk , +.\" and copyright (c) 2016, heinrich schuchardt +.\" +.\" %%%license_start(verbatim_one_para) +.\" permission is granted to distribute possibly modified copies +.\" of this page provided the header is included verbatim, +.\" and in case of nontrivial modification author and date +.\" of the modification is added to the header. +.\" %%%license_end +.\" +.\" modified, 2003-12-02, michael kerrisk, +.\" modified, 2003-09-23, adam langley +.\" modified, 2004-05-27, michael kerrisk, +.\" added sock_seqpacket +.\" 2008-05-27, mtk, provide a clear description of the three types of +.\" address that can appear in the sockaddr_un structure: pathname, +.\" unnamed, and abstract. +.\" +.th unix 7 2021-03-22 "linux" "linux programmer's manual" +.sh name +unix \- sockets for local interprocess communication +.sh synopsis +.nf +.b #include +.b #include +.pp +.ib unix_socket " = socket(af_unix, type, 0);" +.ib error " = socketpair(af_unix, type, 0, int *" sv ");" +.fi +.sh description +the +.b af_unix +(also known as +.br af_local ) +socket family is used to communicate between processes on the same machine +efficiently. +traditionally, unix domain sockets can be either unnamed, +or bound to a filesystem pathname (marked as being of type socket). +linux also supports an abstract namespace which is independent of the +filesystem. +.pp +valid socket types in the unix domain are: +.br sock_stream , +for a stream-oriented socket; +.br sock_dgram , +for a datagram-oriented socket that preserves message boundaries +(as on most unix implementations, unix domain datagram +sockets are always reliable and don't reorder datagrams); +and (since linux 2.6.4) +.br sock_seqpacket , +for a sequenced-packet socket that is connection-oriented, +preserves message boundaries, +and delivers messages in the order that they were sent. +.pp +unix domain sockets support passing file descriptors or process credentials +to other processes using ancillary data. +.ss address format +a unix domain socket address is represented in the following structure: +.pp +.in +4n +.ex +.\" #define unix_path_max 108 +.\" +struct sockaddr_un { + sa_family_t sun_family; /* af_unix */ + char sun_path[108]; /* pathname */ +}; +.ee +.in +.pp +the +.i sun_family +field always contains +.br af_unix . +on linux, +.i sun_path +is 108 bytes in size; see also notes, below. +.pp +various systems calls (for example, +.br bind (2), +.br connect (2), +and +.br sendto (2)) +take a +.i sockaddr_un +argument as input. +some other system calls (for example, +.br getsockname (2), +.br getpeername (2), +.br recvfrom (2), +and +.br accept (2)) +return an argument of this type. +.pp +three types of address are distinguished in the +.i sockaddr_un +structure: +.ip * 3 +.ir pathname : +a unix domain socket can be bound to a null-terminated +filesystem pathname using +.br bind (2). +when the address of a pathname socket is returned +(by one of the system calls noted above), +its length is +.ip + offsetof(struct sockaddr_un, sun_path) + strlen(sun_path) + 1 +.ip +and +.i sun_path +contains the null-terminated pathname. +(on linux, the above +.br offsetof () +expression equates to the same value as +.ir sizeof(sa_family_t) , +but some other implementations include other fields before +.ir sun_path , +so the +.br offsetof () +expression more portably describes the size of the address structure.) +.ip +for further details of pathname sockets, see below. +.ip * +.ir unnamed : +a stream socket that has not been bound to a pathname using +.br bind (2) +has no name. +likewise, the two sockets created by +.br socketpair (2) +are unnamed. +when the address of an unnamed socket is returned, +its length is +.ir "sizeof(sa_family_t)" , +and +.i sun_path +should not be inspected. +.\" there is quite some variation across implementations: freebsd +.\" says the length is 16 bytes, hp-ux 11 says it's zero bytes. +.ip * +.ir abstract : +an abstract socket address is distinguished (from a pathname socket) +by the fact that +.ir sun_path[0] +is a null byte (\(aq\e0\(aq). +the socket's address in this namespace is given by the additional +bytes in +.ir sun_path +that are covered by the specified length of the address structure. +(null bytes in the name have no special significance.) +the name has no connection with filesystem pathnames. +when the address of an abstract socket is returned, +the returned +.i addrlen +is greater than +.ir "sizeof(sa_family_t)" +(i.e., greater than 2), and the name of the socket is contained in +the first +.ir "(addrlen \- sizeof(sa_family_t))" +bytes of +.ir sun_path . +.ss pathname sockets +when binding a socket to a pathname, a few rules should be observed +for maximum portability and ease of coding: +.ip * 3 +the pathname in +.i sun_path +should be null-terminated. +.ip * +the length of the pathname, including the terminating null byte, +should not exceed the size of +.ir sun_path . +.ip * +the +.i addrlen +argument that describes the enclosing +.i sockaddr_un +structure should have a value of at least: +.ip +.nf + offsetof(struct sockaddr_un, sun_path)+strlen(addr.sun_path)+1 +.fi +.ip +or, more simply, +.i addrlen +can be specified as +.ir "sizeof(struct sockaddr_un)" . +.pp +there is some variation in how implementations handle unix domain +socket addresses that do not follow the above rules. +for example, some (but not all) implementations +.\" linux does this, including for the case where the supplied path +.\" is 108 bytes +append a null terminator if none is present in the supplied +.ir sun_path . +.pp +when coding portable applications, +keep in mind that some implementations +.\" hp-ux +have +.i sun_path +as short as 92 bytes. +.\" modern bsds generally have 104, tru64 and aix have 104, +.\" solaris and irix have 108 +.pp +various system calls +.rb ( accept (2), +.br recvfrom (2), +.br getsockname (2), +.br getpeername (2)) +return socket address structures. +when applied to unix domain sockets, the value-result +.i addrlen +argument supplied to the call should be initialized as above. +upon return, the argument is set to indicate the +.i actual +size of the address structure. +the caller should check the value returned in this argument: +if the output value exceeds the input value, +then there is no guarantee that a null terminator is present in +.ir sun_path . +(see bugs.) +.\" +.ss pathname socket ownership and permissions +in the linux implementation, +pathname sockets honor the permissions of the directory they are in. +creation of a new socket fails if the process does not have write and +search (execute) permission on the directory in which the socket is created. +.pp +on linux, +connecting to a stream socket object requires write permission on that socket; +sending a datagram to a datagram socket likewise +requires write permission on that socket. +posix does not make any statement about the effect of the permissions +on a socket file, and on some systems (e.g., older bsds), +the socket permissions are ignored. +portable programs should not rely on +this feature for security. +.pp +when creating a new socket, the owner and group of the socket file +are set according to the usual rules. +the socket file has all permissions enabled, +other than those that are turned off by the process +.br umask (2). +.pp +the owner, group, and permissions of a pathname socket can be changed (using +.br chown (2) +and +.br chmod (2)). +.\" however, fchown() and fchmod() do not seem to have an effect +.\" +.ss abstract sockets +socket permissions have no meaning for abstract sockets: +the process +.br umask (2) +has no effect when binding an abstract socket, +and changing the ownership and permissions of the object (via +.br fchown (2) +and +.br fchmod (2)) +has no effect on the accessibility of the socket. +.pp +abstract sockets automatically disappear when all open references +to the socket are closed. +.pp +the abstract socket namespace is a nonportable linux extension. +.\" +.ss socket options +for historical reasons, these socket options are specified with a +.b sol_socket +type even though they are +.b af_unix +specific. +they can be set with +.br setsockopt (2) +and read with +.br getsockopt (2) +by specifying +.b sol_socket +as the socket family. +.tp +.b so_passcred +enabling this socket option causes receipt of the credentials of +the sending process in an +.b scm_credentials ancillary +message in each subsequently received message. +the returned credentials are those specified by the sender using +.br scm_credentials , +or a default that includes the sender's pid, real user id, and real group id, +if the sender did not specify +.b scm_credentials +ancillary data. +.ip +when this option is set and the socket is not yet connected, +a unique name in the abstract namespace will be generated automatically. +.ip +the value given as an argument to +.br setsockopt (2) +and returned as the result of +.br getsockopt (2) +is an integer boolean flag. +.tp +.b so_passsec +enables receiving of the selinux security label of the peer socket +in an ancillary message of type +.br scm_security +(see below). +.ip +the value given as an argument to +.br setsockopt (2) +and returned as the result of +.br getsockopt (2) +is an integer boolean flag. +.ip +the +.b so_passsec +option is supported for unix domain datagram sockets +.\" commit 877ce7c1b3afd69a9b1caeb1b9964c992641f52a +since linux 2.6.18; +support for unix domain stream sockets was added +.\" commit 37a9a8df8ce9de6ea73349c9ac8bdf6ba4ec4f70 +in linux 4.2. +.tp +.br so_peek_off +see +.br socket (7). +.tp +.b so_peercred +this read-only socket option returns the +credentials of the peer process connected to this socket. +the returned credentials are those that were in effect at the time +of the call to +.br connect (2) +or +.br socketpair (2). +.ip +the argument to +.br getsockopt (2) +is a pointer to a +.i ucred +structure; define the +.b _gnu_source +feature test macro to obtain the definition of that structure from +.ir . +.ip +the use of this option is possible only for connected +.b af_unix +stream sockets and for +.b af_unix +stream and datagram socket pairs created using +.br socketpair (2). +.tp +.b so_peersec +this read-only socket option returns the +security context of the peer socket connected to this socket. +by default, this will be the same as the security context of +the process that created the peer socket unless overridden +by the policy or by a process with the required permissions. +.ip +the argument to +.br getsockopt (2) +is a pointer to a buffer of the specified length in bytes +into which the security context string will be copied. +if the buffer length is less than the length of the security +context string, then +.br getsockopt (2) +returns \-1, sets +.i errno +to +.br erange , +and returns the required length via +.ir optlen . +the caller should allocate at least +.br name_max +bytes for the buffer initially, although this is not guaranteed +to be sufficient. +resizing the buffer to the returned length +and retrying may be necessary. +.ip +the security context string may include a terminating null character +in the returned length, but is not guaranteed to do so: a security +context "foo" might be represented as either {'f','o','o'} of length 3 +or {'f','o','o','\\0'} of length 4, which are considered to be +interchangeable. +the string is printable, does not contain non-terminating null characters, +and is in an unspecified encoding (in particular, it +is not guaranteed to be ascii or utf-8). +.ip +the use of this option for sockets in the +.b af_unix +address family is supported since linux 2.6.2 for connected stream sockets, +and since linux 4.18 +.\" commit 0b811db2cb2aabc910e53d34ebb95a15997c33e7 +also for stream and datagram socket pairs created using +.br socketpair (2). +.\" +.ss autobind feature +if a +.br bind (2) +call specifies +.i addrlen +as +.ir sizeof(sa_family_t) , +.\" i.e., sizeof(short) +or the +.br so_passcred +socket option was specified for a socket that was +not explicitly bound to an address, +then the socket is autobound to an abstract address. +the address consists of a null byte +followed by 5 bytes in the character set +.ir [0\-9a\-f] . +thus, there is a limit of 2^20 autobind addresses. +(from linux 2.1.15, when the autobind feature was added, +8 bytes were used, and the limit was thus 2^32 autobind addresses. +the change to 5 bytes came in linux 2.3.15.) +.ss sockets api +the following paragraphs describe domain-specific details and +unsupported features of the sockets api for unix domain sockets on linux. +.pp +unix domain sockets do not support the transmission of +out-of-band data (the +.b msg_oob +flag for +.br send (2) +and +.br recv (2)). +.pp +the +.br send (2) +.b msg_more +flag is not supported by unix domain sockets. +.pp +before linux 3.4, +.\" commit 9f6f9af7694ede6314bed281eec74d588ba9474f +the use of +.b msg_trunc +in the +.i flags +argument of +.br recv (2) +was not supported by unix domain sockets. +.pp +the +.b so_sndbuf +socket option does have an effect for unix domain sockets, but the +.b so_rcvbuf +option does not. +for datagram sockets, the +.b so_sndbuf +value imposes an upper limit on the size of outgoing datagrams. +this limit is calculated as the doubled (see +.br socket (7)) +option value less 32 bytes used for overhead. +.ss ancillary messages +ancillary data is sent and received using +.br sendmsg (2) +and +.br recvmsg (2). +for historical reasons, the ancillary message types listed below +are specified with a +.b sol_socket +type even though they are +.b af_unix +specific. +to send them, set the +.i cmsg_level +field of the struct +.i cmsghdr +to +.b sol_socket +and the +.i cmsg_type +field to the type. +for more information, see +.br cmsg (3). +.tp +.b scm_rights +send or receive a set of open file descriptors from another process. +the data portion contains an integer array of the file descriptors. +.ip +commonly, this operation is referred to as "passing a file descriptor" +to another process. +however, more accurately, +what is being passed is a reference to an open file description (see +.br open (2)), +and in the receiving process it is likely that a different +file descriptor number will be used. +semantically, this operation is equivalent to duplicating +.rb ( dup (2)) +a file descriptor into the file descriptor table of another process. +.ip +if the buffer used to receive the ancillary data containing +file descriptors is too small (or is absent), +then the ancillary data is truncated (or discarded) +and the excess file descriptors are automatically closed +in the receiving process. +.ip +if the number of file descriptors received in the ancillary data would +cause the process to exceed its +.b rlimit_nofile +resource limit (see +.br getrlimit (2)), +the excess file descriptors are automatically closed +in the receiving process. +.ip +the kernel constant +.br scm_max_fd +defines a limit on the number of file descriptors in the array. +attempting to send an array larger than this limit causes +.br sendmsg (2) +to fail with the error +.br einval . +.br scm_max_fd +has the value 253 +(or 255 in kernels +.\" commit bba14de98753cb6599a2dae0e520714b2153522d +before 2.6.38). +.tp +.b scm_credentials +send or receive unix credentials. +this can be used for authentication. +the credentials are passed as a +.i struct ucred +ancillary message. +this structure is defined in +.i +as follows: +.ip +.in +4n +.ex +struct ucred { + pid_t pid; /* process id of the sending process */ + uid_t uid; /* user id of the sending process */ + gid_t gid; /* group id of the sending process */ +}; +.ee +.in +.ip +since glibc 2.8, the +.b _gnu_source +feature test macro must be defined (before including +.i any +header files) in order to obtain the definition +of this structure. +.ip +the credentials which the sender specifies are checked by the kernel. +a privileged process is allowed to specify values that do not match its own. +the sender must specify its own process id (unless it has the capability +.br cap_sys_admin , +in which case the pid of any existing process may be specified), +its real user id, effective user id, or saved set-user-id (unless it has +.br cap_setuid ), +and its real group id, effective group id, or saved set-group-id +(unless it has +.br cap_setgid ). +.ip +to receive a +.i struct ucred +message, the +.b so_passcred +option must be enabled on the socket. +.tp +.b scm_security +receive the selinux security context (the security label) +of the peer socket. +the received ancillary data is a null-terminated string containing +the security context. +the receiver should allocate at least +.br name_max +bytes in the data portion of the ancillary message for this data. +.ip +to receive the security context, the +.b so_passsec +option must be enabled on the socket (see above). +.pp +when sending ancillary data with +.br sendmsg (2), +only one item of each of the above types may be included in the sent message. +.pp +at least one byte of real data should be sent when sending ancillary data. +on linux, this is required to successfully send ancillary data over +a unix domain stream socket. +when sending ancillary data over a unix domain datagram socket, +it is not necessary on linux to send any accompanying real data. +however, portable applications should also include at least one byte +of real data when sending ancillary data over a datagram socket. +.pp +when receiving from a stream socket, +ancillary data forms a kind of barrier for the received data. +for example, suppose that the sender transmits as follows: +.pp +.rs +.pd 0 +.ip 1. 3 +.br sendmsg (2) +of four bytes, with no ancillary data. +.ip 2. +.br sendmsg (2) +of one byte, with ancillary data. +.ip 3. +.br sendmsg (2) +of four bytes, with no ancillary data. +.pd +.re +.pp +suppose that the receiver now performs +.br recvmsg (2) +calls each with a buffer size of 20 bytes. +the first call will receive five bytes of data, +along with the ancillary data sent by the second +.br sendmsg (2) +call. +the next call will receive the remaining four bytes of data. +.pp +if the space allocated for receiving incoming ancillary data is too small +then the ancillary data is truncated to the number of headers +that will fit in the supplied buffer (or, in the case of an +.br scm_rights +file descriptor list, the list of file descriptors may be truncated). +if no buffer is provided for incoming ancillary data (i.e., the +.i msg_control +field of the +.i msghdr +structure supplied to +.br recvmsg (2) +is null), +then the incoming ancillary data is discarded. +in both of these cases, the +.br msg_ctrunc +flag will be set in the +.i msg.msg_flags +value returned by +.br recvmsg (2). +.\" +.ss ioctls +the following +.br ioctl (2) +calls return information in +.ir value . +the correct syntax is: +.pp +.rs +.nf +.bi int " value"; +.ib error " = ioctl(" unix_socket ", " ioctl_type ", &" value ");" +.fi +.re +.pp +.i ioctl_type +can be: +.tp +.b siocinq +for +.b sock_stream +sockets, this call returns the number of unread bytes in the receive buffer. +the socket must not be in listen state, otherwise an error +.rb ( einval ) +is returned. +.b siocinq +is defined in +.ir . +.\" fixme . http://sources.redhat.com/bugzilla/show_bug.cgi?id=12002, +.\" filed 2010-09-10, may cause siocinq to be defined in glibc headers +alternatively, +you can use the synonymous +.br fionread , +defined in +.ir . +.\" siocoutq also has an effect for unix domain sockets, but not +.\" quite what userland might expect. it seems to return the number +.\" of bytes allocated for buffers containing pending output. +.\" that number is normally larger than the number of bytes of pending +.\" output. since this info is, from userland's point of view, imprecise, +.\" and it may well change, probably best not to document this now. +for +.b sock_dgram +sockets, +the returned value is the same as +for internet domain datagram sockets; +see +.br udp (7). +.sh errors +.tp +.b eaddrinuse +the specified local address is already in use or the filesystem socket +object already exists. +.tp +.b ebadf +this error can occur for +.br sendmsg (2) +when sending a file descriptor as ancillary data over +a unix domain socket (see the description of +.br scm_rights , +above), and indicates that the file descriptor number that +is being sent is not valid (e.g., it is not an open file descriptor). +.tp +.b econnrefused +the remote address specified by +.br connect (2) +was not a listening socket. +this error can also occur if the target pathname is not a socket. +.tp +.b econnreset +remote socket was unexpectedly closed. +.tp +.b efault +user memory address was not valid. +.tp +.b einval +invalid argument passed. +a common cause is that the value +.b af_unix +was not specified in the +.i sun_type +field of passed addresses, or the socket was in an +invalid state for the applied operation. +.tp +.b eisconn +.br connect (2) +called on an already connected socket or a target address was +specified on a connected socket. +.tp +.b enoent +the pathname in the remote address specified to +.br connect (2) +did not exist. +.tp +.b enomem +out of memory. +.tp +.b enotconn +socket operation needs a target address, but the socket is not connected. +.tp +.b eopnotsupp +stream operation called on non-stream oriented socket or tried to +use the out-of-band data option. +.tp +.b eperm +the sender passed invalid credentials in the +.ir "struct ucred" . +.tp +.b epipe +remote socket was closed on a stream socket. +if enabled, a +.b sigpipe +is sent as well. +this can be avoided by passing the +.b msg_nosignal +flag to +.br send (2) +or +.br sendmsg (2). +.tp +.b eprotonosupport +passed protocol is not +.br af_unix . +.tp +.b eprototype +remote socket does not match the local socket type +.rb ( sock_dgram +versus +.br sock_stream ). +.tp +.b esocktnosupport +unknown socket type. +.tp +.b esrch +while sending an ancillary message containing credentials +.rb ( scm_credentials ), +the caller specified a pid that does not match any existing process. +.tp +.b etoomanyrefs +this error can occur for +.br sendmsg (2) +when sending a file descriptor as ancillary data over +a unix domain socket (see the description of +.br scm_rights , +above). +it occurs if the number of "in-flight" file descriptors exceeds the +.b rlimit_nofile +resource limit and the caller does not have the +.br cap_sys_resource +capability. +an in-flight file descriptor is one that has been sent using +.br sendmsg (2) +but has not yet been accepted in the recipient process using +.br recvmsg (2). +.ip +this error is diagnosed since mainline linux 4.5 +(and in some earlier kernel versions where the fix has been backported). +.\" commit 712f4aad406bb1ed67f3f98d04c044191f0ff593 +in earlier kernel versions, +it was possible to place an unlimited number of file descriptors in flight, +by sending each file descriptor with +.br sendmsg (2) +and then closing the file descriptor so that it was not accounted against the +.b rlimit_nofile +resource limit. +.pp +other errors can be generated by the generic socket layer or +by the filesystem while generating a filesystem socket object. +see the appropriate manual pages for more information. +.sh versions +.b scm_credentials +and the abstract namespace were introduced with linux 2.2 and should not +be used in portable programs. +(some bsd-derived systems also support credential passing, +but the implementation details differ.) +.sh notes +binding to a socket with a filename creates a socket +in the filesystem that must be deleted by the caller when it is no +longer needed (using +.br unlink (2)). +the usual unix close-behind semantics apply; the socket can be unlinked +at any time and will be finally removed from the filesystem when the last +reference to it is closed. +.pp +to pass file descriptors or credentials over a +.br sock_stream +socket, you must +send or receive at least one byte of nonancillary data in the same +.br sendmsg (2) +or +.br recvmsg (2) +call. +.pp +unix domain stream sockets do not support the notion of out-of-band data. +.\" +.sh bugs +when binding a socket to an address, +linux is one of the implementations that appends a null terminator +if none is supplied in +.ir sun_path . +in most cases this is unproblematic: +when the socket address is retrieved, +it will be one byte longer than that supplied when the socket was bound. +however, there is one case where confusing behavior can result: +if 108 non-null bytes are supplied when a socket is bound, +then the addition of the null terminator takes the length of +the pathname beyond +.ir sizeof(sun_path) . +consequently, when retrieving the socket address +(for example, via +.br accept (2)), +.\" the behavior on solaris is quite similar. +if the input +.i addrlen +argument for the retrieving call is specified as +.ir "sizeof(struct sockaddr_un)" , +then the returned address structure +.i won't +have a null terminator in +.ir sun_path . +.pp +in addition, some implementations +.\" i.e., traditional bsd +don't require a null terminator when binding a socket (the +.i addrlen +argument is used to determine the length of +.ir sun_path ) +and when the socket address is retrieved on these implementations, +there is no null terminator in +.ir sun_path . +.pp +applications that retrieve socket addresses can (portably) code +to handle the possibility that there is no null terminator in +.ir sun_path +by respecting the fact that the number of valid bytes in the pathname is: +.pp + strnlen(addr.sun_path, addrlen \- offsetof(sockaddr_un, sun_path)) +.\" the following patch to amend kernel behavior was rejected: +.\" http://thread.gmane.org/gmane.linux.kernel.api/2437 +.\" subject: [patch] fix handling of overlength pathname in af_unix sun_path +.\" 2012-04-17 +.\" and there was a related discussion in the austin list: +.\" http://thread.gmane.org/gmane.comp.standards.posix.austin.general/5735 +.\" subject: having a sun_path with no null terminator +.\" 2012-04-18 +.\" +.\" fixme . track http://austingroupbugs.net/view.php?id=561 +.pp +alternatively, an application can retrieve +the socket address by allocating a buffer of size +.i "sizeof(struct sockaddr_un)+1" +that is zeroed out before the retrieval. +the retrieving call can specify +.i addrlen +as +.ir "sizeof(struct sockaddr_un)" , +and the extra zero byte ensures that there will be +a null terminator for the string returned in +.ir sun_path : +.pp +.in +4n +.ex +void *addrp; + +addrlen = sizeof(struct sockaddr_un); +addrp = malloc(addrlen + 1); +if (addrp == null) + /* handle error */ ; +memset(addrp, 0, addrlen + 1); + +if (getsockname(sfd, (struct sockaddr *) addrp, &addrlen)) == \-1) + /* handle error */ ; + +printf("sun_path = %s\en", ((struct sockaddr_un *) addrp)\->sun_path); +.ee +.in +.pp +this sort of messiness can be avoided if it is guaranteed +that the applications that +.i create +pathname sockets follow the rules outlined above under +.ir "pathname sockets" . +.sh examples +the following code demonstrates the use of sequenced-packet +sockets for local interprocess communication. +it consists of two programs. +the server program waits for a connection from the client program. +the client sends each of its command-line arguments in separate messages. +the server treats the incoming messages as integers and adds them up. +the client sends the command string "end". +the server sends back a message containing the sum of the client's integers. +the client prints the sum and exits. +the server waits for the next client to connect. +to stop the server, the client is called with the command-line argument "down". +.pp +the following output was recorded while running the server in the background +and repeatedly executing the client. +execution of the server program ends when it receives the "down" command. +.ss example output +.in +4n +.ex +$ \fb./server &\fp +[1] 25887 +$ \fb./client 3 4\fp +result = 7 +$ \fb./client 11 \-5\fp +result = 6 +$ \fb./client down\fp +result = 0 +[1]+ done ./server +$ +.ee +.in +.ss program source +\& +.ex +/* + * file connection.h + */ + +#define socket_name "/tmp/9lq7bnbnbycd6nxy.socket" +#define buffer_size 12 + +/* + * file server.c + */ + +#include +#include +#include +#include +#include +#include +#include "connection.h" + +int +main(int argc, char *argv[]) +{ + struct sockaddr_un name; + int down_flag = 0; + int ret; + int connection_socket; + int data_socket; + int result; + char buffer[buffer_size]; + + /* create local socket. */ + + connection_socket = socket(af_unix, sock_seqpacket, 0); + if (connection_socket == \-1) { + perror("socket"); + exit(exit_failure); + } + + /* + * for portability clear the whole structure, since some + * implementations have additional (nonstandard) fields in + * the structure. + */ + + memset(&name, 0, sizeof(name)); + + /* bind socket to socket name. */ + + name.sun_family = af_unix; + strncpy(name.sun_path, socket_name, sizeof(name.sun_path) \- 1); + + ret = bind(connection_socket, (const struct sockaddr *) &name, + sizeof(name)); + if (ret == \-1) { + perror("bind"); + exit(exit_failure); + } + + /* + * prepare for accepting connections. the backlog size is set + * to 20. so while one request is being processed other requests + * can be waiting. + */ + + ret = listen(connection_socket, 20); + if (ret == \-1) { + perror("listen"); + exit(exit_failure); + } + + /* this is the main loop for handling connections. */ + + for (;;) { + + /* wait for incoming connection. */ + + data_socket = accept(connection_socket, null, null); + if (data_socket == \-1) { + perror("accept"); + exit(exit_failure); + } + + result = 0; + for (;;) { + + /* wait for next data packet. */ + + ret = read(data_socket, buffer, sizeof(buffer)); + if (ret == \-1) { + perror("read"); + exit(exit_failure); + } + + /* ensure buffer is 0\-terminated. */ + + buffer[sizeof(buffer) \- 1] = 0; + + /* handle commands. */ + + if (!strncmp(buffer, "down", sizeof(buffer))) { + down_flag = 1; + break; + } + + if (!strncmp(buffer, "end", sizeof(buffer))) { + break; + } + + /* add received summand. */ + + result += atoi(buffer); + } + + /* send result. */ + + sprintf(buffer, "%d", result); + ret = write(data_socket, buffer, sizeof(buffer)); + if (ret == \-1) { + perror("write"); + exit(exit_failure); + } + + /* close socket. */ + + close(data_socket); + + /* quit on down command. */ + + if (down_flag) { + break; + } + } + + close(connection_socket); + + /* unlink the socket. */ + + unlink(socket_name); + + exit(exit_success); +} + +/* + * file client.c + */ + +#include +#include +#include +#include +#include +#include +#include +#include "connection.h" + +int +main(int argc, char *argv[]) +{ + struct sockaddr_un addr; + int ret; + int data_socket; + char buffer[buffer_size]; + + /* create local socket. */ + + data_socket = socket(af_unix, sock_seqpacket, 0); + if (data_socket == \-1) { + perror("socket"); + exit(exit_failure); + } + + /* + * for portability clear the whole structure, since some + * implementations have additional (nonstandard) fields in + * the structure. + */ + + memset(&addr, 0, sizeof(addr)); + + /* connect socket to socket address. */ + + addr.sun_family = af_unix; + strncpy(addr.sun_path, socket_name, sizeof(addr.sun_path) \- 1); + + ret = connect(data_socket, (const struct sockaddr *) &addr, + sizeof(addr)); + if (ret == \-1) { + fprintf(stderr, "the server is down.\en"); + exit(exit_failure); + } + + /* send arguments. */ + + for (int i = 1; i < argc; ++i) { + ret = write(data_socket, argv[i], strlen(argv[i]) + 1); + if (ret == \-1) { + perror("write"); + break; + } + } + + /* request result. */ + + strcpy(buffer, "end"); + ret = write(data_socket, buffer, strlen(buffer) + 1); + if (ret == \-1) { + perror("write"); + exit(exit_failure); + } + + /* receive result. */ + + ret = read(data_socket, buffer, sizeof(buffer)); + if (ret == \-1) { + perror("read"); + exit(exit_failure); + } + + /* ensure buffer is 0\-terminated. */ + + buffer[sizeof(buffer) \- 1] = 0; + + printf("result = %s\en", buffer); + + /* close socket. */ + + close(data_socket); + + exit(exit_success); +} +.ee +.pp +for examples of the use of +.br scm_rights , +see +.br cmsg (3) +and +.br seccomp_unotify (2). +.sh see also +.br recvmsg (2), +.br sendmsg (2), +.br socket (2), +.br socketpair (2), +.br cmsg (3), +.br capabilities (7), +.br credentials (7), +.br socket (7), +.br udp (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2008, 2014, michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" created sat aug 21 1995 thomas k. dyas +.\" modified tue oct 22 22:09:03 1996 by eric s. raymond +.\" 2008-06-26, mtk, added some more detail on the work done by sigreturn() +.\" 2014-12-05, mtk, rewrote all of the rest of the original page +.\" +.th sigreturn 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +sigreturn, rt_sigreturn \- return from signal handler and cleanup stack frame +.sh synopsis +.nf +.bi "int sigreturn(...);" +.fi +.sh description +if the linux kernel determines that an unblocked +signal is pending for a process, then, +at the next transition back to user mode in that process +(e.g., upon return from a system call or +when the process is rescheduled onto the cpu), +it creates a new frame on the user-space stack where it +saves various pieces of process context +(processor status word, registers, signal mask, and signal stack settings). +.\" see arch/x86/kernel/signal.c::__setup_frame() [in 3.17 source code] +.pp +the kernel also arranges that, during the transition back to user mode, +the signal handler is called, and that, upon return from the handler, +control passes to a piece of user-space code commonly called +the "signal trampoline". +the signal trampoline code in turn calls +.br sigreturn (). +.pp +this +.br sigreturn () +call undoes everything that was +done\(emchanging the process's signal mask, switching signal stacks (see +.br sigaltstack "(2))\(emin" +order to invoke the signal handler. +using the information that was earlier saved on the user-space stack +.br sigreturn () +restores the process's signal mask, switches stacks, +and restores the process's context +(processor flags and registers, +including the stack pointer and instruction pointer), +so that the process resumes execution +at the point where it was interrupted by the signal. +.sh return value +.br sigreturn () +never returns. +.sh conforming to +many unix-type systems have a +.br sigreturn () +system call or near equivalent. +however, this call is not specified in posix, +and details of its behavior vary across systems. +.sh notes +.br sigreturn () +exists only to allow the implementation of signal handlers. +it should +.b never +be called directly. +(indeed, a simple +.br sigreturn () +.\" see sysdeps/unix/sysv/linux/sigreturn.c and +.\" signal/sigreturn.c in the glibc source +wrapper in the gnu c library simply returns \-1, with +.i errno +set to +.br enosys .) +details of the arguments (if any) passed to +.br sigreturn () +vary depending on the architecture. +(on some architectures, such as x86-64, +.br sigreturn () +takes no arguments, since all of the information that it requires +is available in the stack frame that was previously created by the +kernel on the user-space stack.) +.pp +once upon a time, unix systems placed the signal trampoline code +onto the user stack. +nowadays, pages of the user stack are protected so as to +disallow code execution. +thus, on contemporary linux systems, depending on the architecture, +the signal trampoline code lives either in the +.br vdso (7) +or in the c library. +in the latter case, +.\" see, for example, sysdeps/unix/sysv/linux/i386/sigaction.c and +.\" sysdeps/unix/sysv/linux/x86_64/sigaction.c in the glibc (2.20) source. +the c library's +.br sigaction (2) +wrapper function informs the kernel of the location of the trampoline code +by placing its address in the +.i sa_restorer +field of the +.i sigaction +structure, +and sets the +.br sa_restorer +flag in the +.ir sa_flags +field. +.pp +the saved process context information is placed in a +.i ucontext_t +structure (see +.ir ). +that structure is visible within the signal handler +as the third argument of a handler established via +.br sigaction (2) +with the +.br sa_siginfo +flag. +.pp +on some other unix systems, +the operation of the signal trampoline differs a little. +in particular, on some systems, upon transitioning back to user mode, +the kernel passes control to the trampoline (rather than the signal handler), +and the trampoline code calls the signal handler (and then calls +.br sigreturn () +once the handler returns). +.\" +.ss c library/kernel differences +the original linux system call was named +.br sigreturn (). +however, with the addition of real-time signals in linux 2.2, +a new system call, +.br rt_sigreturn () +was added to support an enlarged +.ir sigset_t +type. +the gnu c library +hides these details from us, transparently employing +.br rt_sigreturn () +when the kernel provides it. +.\" +.sh see also +.br kill (2), +.br restart_syscall (2), +.br sigaltstack (2), +.br signal (2), +.br getcontext (3), +.br signal (7), +.br vdso (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/outb.2 + +.so man3/malloc_hook.3 + +.\" %%%license_start(public_domain) +.\" this page is in the public domain +.\" %%%license_end +.\" +.th zdump 8 2020-04-27 "" "linux system administration" +.sh name +zdump \- timezone dumper +.sh synopsis +.b zdump +[ +.i option +\&... ] [ +.i timezone +\&... ] +.sh description +.ie '\(lq'' .ds lq \&"\" +.el .ds lq \(lq\" +.ie '\(rq'' .ds rq \&"\" +.el .ds rq \(rq\" +.de q +\\$3\*(lq\\$1\*(rq\\$2 +.. +.ie \n(.g .ds - \f(cw-\fp +.el ds - \- +the +.b zdump +program prints the current time in each +.i timezone +named on the command line. +.sh options +.tp +.b \*-\*-version +output version information and exit. +.tp +.b \*-\*-help +output short usage message and exit. +.tp +.b \*-i +output a description of time intervals. for each +.i timezone +on the command line, output an interval-format description of the +timezone. see +.q "interval format" +below. +.tp +.b \*-v +output a verbose description of time intervals. +for each +.i timezone +on the command line, +print the time at the lowest possible time value, +the time one day after the lowest possible time value, +the times both one second before and exactly at +each detected time discontinuity, +the time at one day less than the highest possible time value, +and the time at the highest possible time value. +each line is followed by +.bi isdst= d +where +.i d +is positive, zero, or negative depending on whether +the given time is daylight saving time, standard time, +or an unknown time type, respectively. +each line is also followed by +.bi gmtoff= n +if the given local time is known to be +.i n +seconds east of greenwich. +.tp +.b \*-v +like +.br \*-v , +except omit the times relative to the extreme time values. +this generates output that is easier to compare to that of +implementations with different time representations. +.tp +.bi "\*-c " \fr[\filoyear , \fr]\fihiyear +cut off interval output at the given year(s). +cutoff times are computed using the proleptic gregorian calendar with year 0 +and with universal time (ut) ignoring leap seconds. +cutoffs are at the start of each year, where the lower-bound +timestamp is exclusive and the upper is inclusive; for example, +.b "\*-c 1970,2070" +selects transitions after 1970-01-01 00:00:00 utc +and on or before 2070-01-01 00:00:00 utc. +the default cutoff is +.br \*-500,2500 . +.tp +.bi "\*-t " \fr[\filotime , \fr]\fihitime +cut off interval output at the given time(s), +given in decimal seconds since 1970-01-01 00:00:00 +coordinated universal time (utc). +the +.i timezone +determines whether the count includes leap seconds. +as with +.br \*-c , +the cutoff's lower bound is exclusive and its upper bound is inclusive. +.sh "interval format" +the interval format is a compact text representation that is intended +to be both human- and machine-readable. it consists of an empty line, +then a line +.q "tz=\fistring\fp" +where +.i string +is a double-quoted string giving the timezone, a second line +.q "\*- \*- \fiinterval\fp" +describing the time interval before the first transition if any, and +zero or more following lines +.q "\fidate time interval\fp", +one line for each transition time and following interval. fields are +separated by single tabs. +.pp +dates are in +.ir yyyy - mm - dd +format and times are in 24-hour +.ir hh : mm : ss +format where +.ir hh <24. +times are in local time immediately after the transition. a +time interval description consists of a ut offset in signed +.ri \(+- hhmmss +format, a time zone abbreviation, and an isdst flag. an abbreviation +that equals the ut offset is omitted; other abbreviations are +double-quoted strings unless they consist of one or more alphabetic +characters. an isdst flag is omitted for standard time, and otherwise +is a decimal integer that is unsigned and positive (typically 1) for +daylight saving time and negative for unknown. +.pp +in times and in ut offsets with absolute value less than 100 hours, +the seconds are omitted if they are zero, and +the minutes are also omitted if they are also zero. positive ut +offsets are east of greenwich. the ut offset \*-00 denotes a ut +placeholder in areas where the actual offset is unspecified; by +convention, this occurs when the ut offset is zero and the time zone +abbreviation begins with +.q "\*-" +or is +.q "zzz". +.pp +in double-quoted strings, escape sequences represent unusual +characters. the escape sequences are \es for space, and \e", \e\e, +\ef, \en, \er, \et, and \ev with their usual meaning in the c +programming language. e.g., the double-quoted string +\*(lq"cet\es\e"\e\e"\*(rq represents the character sequence \*(lqcet +"\e\*(rq.\"" +.pp +.ne 9 +here is an example of the output, with the leading empty line omitted. +(this example is shown with tab stops set far enough apart so that the +tabbed columns line up.) +.nf +.sp +.if \n(.g .ft cw +.if t .in +.5i +.if n .in +2 +.nr w \w'1896-01-13 'u+\n(.i +.ta \w'1896-01-13 'u +\w'12:01:26 'u +\w'-103126 'u +\w'hwt 'u +tz="pacific/honolulu" +- - -103126 lmt +1896-01-13 12:01:26 -1030 hst +1933-04-30 03 -0930 hdt 1 +1933-05-21 11 -1030 hst +1942-02-09 03 -0930 hwt 1 +1945-08-14 13:30 -0930 hpt 1 +1945-09-30 01 -1030 hst +1947-06-08 02:30 -10 hst +.in +.if \n(.g .ft +.sp +.fi +here, local time begins 10 hours, 31 minutes and 26 seconds west of +ut, and is a standard time abbreviated lmt. immediately after the +first transition, the date is 1896-01-13 and the time is 12:01:26, and +the following time interval is 10.5 hours west of ut, a standard time +abbreviated hst. immediately after the second transition, the date is +1933-04-30 and the time is 03:00:00 and the following time interval is +9.5 hours west of ut, is abbreviated hdt, and is daylight saving time. +immediately after the last transition the date is 1947-06-08 and the +time is 02:30:00, and the following time interval is 10 hours west of +ut, a standard time abbreviated hst. +.pp +.ne 10 +here are excerpts from another example: +.nf +.sp +.if \n(.g .ft cw +.if t .in +.5i +.if n .in +2 +tz="europe/astrakhan" +- - +031212 lmt +1924-04-30 23:47:48 +03 +1930-06-21 01 +04 +1981-04-01 01 +05 1 +1981-09-30 23 +04 +\&... +2014-10-26 01 +03 +2016-03-27 03 +04 +.in +.if \n(.g .ft +.sp +.fi +this time zone is east of ut, so its ut offsets are positive. also, +many of its time zone abbreviations are omitted since they duplicate +the text of the ut offset. +.sh limitations +time discontinuities are found by sampling the results returned by localtime +at twelve-hour intervals. +this works in all real-world cases; +one can construct artificial time zones for which this fails. +.pp +in the +.b \*-v +and +.b \*-v +output, +.q "ut" +denotes the value returned by +.br gmtime (3), +which uses utc for modern timestamps and some other ut flavor for +timestamps that predate the introduction of utc. +no attempt is currently made to have the output use +.q "utc" +for newer and +.q "ut" +for older timestamps, partly because the exact date of the +introduction of utc is problematic. +.sh see also +.br tzfile (5), +.br zic (8) +.\" this file is in the public domain, so clarified as of +.\" 2009-05-17 by arthur david olson. +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1990, 1991 the regents of the university of california. +.\" all rights reserved. +.\" +.\" this code is derived from software contributed to berkeley by +.\" chris torek and the american national standards committee x3, +.\" on information processing systems. +.\" +.\" %%%license_start(bsd_4_clause_ucb) +.\" redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. all advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" this product includes software developed by the university of +.\" california, berkeley and its contributors. +.\" 4. neither the name of the university nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" this software is provided by the regents and contributors ``as is'' and +.\" any express or implied warranties, including, but not limited to, the +.\" implied warranties of merchantability and fitness for a particular purpose +.\" are disclaimed. in no event shall the regents or contributors be liable +.\" for any direct, indirect, incidental, special, exemplary, or consequential +.\" damages (including, but not limited to, procurement of substitute goods +.\" or services; loss of use, data, or profits; or business interruption) +.\" however caused and on any theory of liability, whether in contract, strict +.\" liability, or tort (including negligence or otherwise) arising in any way +.\" out of the use of this software, even if advised of the possibility of +.\" such damage. +.\" %%%license_end +.\" +.\" @(#)fclose.3 6.7 (berkeley) 6/29/91 +.\" +.\" converted for linux, mon nov 29 15:19:14 1993, faith@cs.unc.edu +.\" +.\" modified 2000-07-22 by nicolás lichtmaier +.\" +.th fclose 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +fclose \- close a stream +.sh synopsis +.nf +.b #include +.pp +.bi "int fclose(file *" stream ); +.fi +.sh description +the +.br fclose () +function flushes the stream pointed to by +.i stream +(writing any buffered output data using +.br fflush (3)) +and closes the underlying file descriptor. +.sh return value +upon successful completion, 0 is returned. +otherwise, +.b eof +is returned and +.i errno +is set to indicate the error. +in either case, any further access +(including another call to +.br fclose ()) +to the stream results in undefined behavior. +.sh errors +.tp +.b ebadf +the file descriptor underlying +.i stream +is not valid. +.\" this error cannot occur unless you are mixing ansi c stdio operations and +.\" low-level file operations on the same stream. if you do get this error, +.\" you must have closed the stream's low-level file descriptor using +.\" something like close(fileno(stream)). +.pp +the +.br fclose () +function may also fail and set +.i errno +for any of the errors specified for the routines +.br close (2), +.br write (2), +or +.br fflush (3). +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br fclose () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c89, c99. +.sh notes +note that +.br fclose () +flushes only the user-space buffers provided by the +c library. +to ensure that the data is physically stored +on disk the kernel buffers must be flushed too, for example, with +.br sync (2) +or +.br fsync (2). +.sh see also +.br close (2), +.br fcloseall (3), +.br fflush (3), +.br fileno (3), +.br fopen (3), +.br setbuf (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 2012 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" see also https://lwn.net/articles/519085/ +.\" +.th getauxval 3 2021-08-27 "gnu" "linux programmer's manual" +.sh name +getauxval \- retrieve a value from the auxiliary vector +.sh synopsis +.nf +.b #include +.pp +.bi "unsigned long getauxval(unsigned long " type ); +.fi +.sh description +the +.br getauxval () +function retrieves values from the auxiliary vector, +a mechanism that the kernel's elf binary loader +uses to pass certain information to +user space when a program is executed. +.pp +each entry in the auxiliary vector consists of a pair of values: +a type that identifies what this entry represents, +and a value for that type. +given the argument +.ir type , +.br getauxval () +returns the corresponding value. +.pp +the value returned for each +.i type +is given in the following list. +not all +.i type +values are present on all architectures. +.tp +.br at_base +the base address of the program interpreter (usually, the dynamic linker). +.tp +.br at_base_platform +a pointer to a string (powerpc and mips only). +on powerpc, this identifies the real platform; may differ from +.br at_platform "." +on mips, +.\" commit e585b768da111f2c2d413de6214e83bbdfee8f22 +this identifies the isa level (since linux 5.7). +.tp +.br at_clktck +the frequency with which +.br times (2) +counts. +this value can also be obtained via +.ir sysconf(_sc_clk_tck) . +.tp +.br at_dcachebsize +the data cache block size. +.tp +.br at_egid +the effective group id of the thread. +.tp +.br at_entry +the entry address of the executable. +.tp +.br at_euid +the effective user id of the thread. +.tp +.br at_execfd +file descriptor of program. +.tp +.br at_execfn +a pointer to a string containing the pathname used to execute the program. +.tp +.br at_flags +flags (unused). +.tp +.br at_fpucw +used fpu control word (superh architecture only). +this gives some information about the fpu initialization +performed by the kernel. +.tp +.br at_gid +the real group id of the thread. +.tp +.br at_hwcap +an architecture and abi dependent bit-mask whose settings +indicate detailed processor capabilities. +the contents of the bit mask are hardware dependent +(for example, see the kernel source file +.ir arch/x86/include/asm/cpufeature.h +for details relating to the intel x86 architecture; the value +returned is the first 32-bit word of the array described there). +a human-readable version of the same information is available via +.ir /proc/cpuinfo . +.tp +.br at_hwcap2 " (since glibc 2.18)" +further machine-dependent hints about processor capabilities. +.tp +.br at_icachebsize +the instruction cache block size. +.\" .tp +.\" .br at_ignore +.\" .tp +.\" .br at_ignoreppc +.\" .tp +.\" .br at_notelf +.tp +.\" kernel commit 98a5f361b8625c6f4841d6ba013bbf0e80d08147 +.br at_l1d_cachegeometry +geometry of the l1 data cache, encoded with the cache line size in bytes +in the bottom 16 bits and the cache associativity in the next 16 bits. +the associativity is such that if n is the 16-bit value, +the cache is n-way set associative. +.tp +.br at_l1d_cachesize +the l1 data cache size. +.tp +.br at_l1i_cachegeometry +geometry of the l1 instruction cache, encoded as for +.br at_l1d_cachegeometry . +.tp +.br at_l1i_cachesize +the l1 instruction cache size. +.tp +.br at_l2_cachegeometry +geometry of the l2 cache, encoded as for +.br at_l1d_cachegeometry . +.tp +.br at_l2_cachesize +the l2 cache size. +.tp +.br at_l3_cachegeometry +geometry of the l3 cache, encoded as for +.br at_l1d_cachegeometry . +.tp +.br at_l3_cachesize +the l3 cache size. +.tp +.br at_pagesz +the system page size (the same value returned by +.ir sysconf(_sc_pagesize) ). +.tp +.br at_phdr +the address of the program headers of the executable. +.tp +.br at_phent +the size of program header entry. +.tp +.br at_phnum +the number of program headers. +.tp +.br at_platform +a pointer to a string that identifies the hardware platform +that the program is running on. +the dynamic linker uses this in the interpretation of +.ir rpath +values. +.tp +.br at_random +the address of sixteen bytes containing a random value. +.tp +.br at_secure +has a nonzero value if this executable should be treated securely. +most commonly, a nonzero value indicates that the process is +executing a set-user-id or set-group-id binary +(so that its real and effective uids or gids differ from one another), +or that it gained capabilities by executing +a binary file that has capabilities (see +.br capabilities (7)). +alternatively, +a nonzero value may be triggered by a linux security module. +when this value is nonzero, +the dynamic linker disables the use of certain environment variables (see +.br ld\-linux.so (8)) +and glibc changes other aspects of its behavior. +(see also +.br secure_getenv (3).) +.tp +.br at_sysinfo +the entry point to the system call function in the vdso. +not present/needed on all architectures (e.g., absent on x86-64). +.tp +.br at_sysinfo_ehdr +the address of a page containing the virtual dynamic shared object (vdso) +that the kernel creates in order to provide fast implementations of +certain system calls. +.tp +.br at_ucachebsize +the unified cache block size. +.tp +.br at_uid +the real user id of the thread. +.sh return value +on success, +.br getauxval () +returns the value corresponding to +.ir type . +if +.i type +is not found, 0 is returned. +.sh errors +.tp +.br enoent " (since glibc 2.19)" +.\" commit b9ab448f980e296eac21ac65f53783967cc6037b +no entry corresponding to +.ir type +could be found in the auxiliary vector. +.sh versions +the +.br getauxval () +function was added to glibc in version 2.16. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br getauxval () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +this function is a nonstandard glibc extension. +.sh notes +the primary consumer of the information in the auxiliary vector +is the dynamic linker, +.br ld\-linux.so (8). +the auxiliary vector is a convenient and efficient shortcut +that allows the kernel to communicate a certain set of standard +information that the dynamic linker usually or always needs. +in some cases, the same information could be obtained by system calls, +but using the auxiliary vector is cheaper. +.pp +the auxiliary vector resides just above the argument list and +environment in the process address space. +the auxiliary vector supplied to a program can be viewed by setting the +.b ld_show_auxv +environment variable when running a program: +.pp +.in +4n +.ex +$ ld_show_auxv=1 sleep 1 +.ee +.in +.pp +the auxiliary vector of any process can (subject to file permissions) +be obtained via +.ir /proc/[pid]/auxv ; +see +.br proc (5) +for more information. +.sh bugs +before the addition of the +.b enoent +error in glibc 2.19, +there was no way to unambiguously distinguish the case where +.i type +could not be found from the case where the value corresponding to +.i type +was zero. +.sh see also +.br execve (2), +.br secure_getenv (3), +.br vdso (7), +.br ld\-linux.so (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man7/iso_8859-13.7 + +.\" copyright 1995 yggdrasil computing, incorporated. +.\" written by adam j. richter (adam@yggdrasil.com), +.\" with typesetting help from daniel quinlan (quinlan@yggdrasil.com). +.\" and copyright 2003, 2015 michael kerrisk +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" modified by david a. wheeler 2000-11-28. +.\" applied patch by terran melconian, aeb, 2001-12-14. +.\" modified by hacksaw 2003-03-13. +.\" modified by matt domsch, 2003-04-09: _init and _fini obsolete +.\" modified by michael kerrisk 2003-05-16. +.\" modified by walter harms: dladdr, dlvsym +.\" modified by petr baudis , 2008-12-04: dladdr caveat +.\" +.th dlopen 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +dlclose, dlopen, dlmopen \- +open and close a shared object +.sh synopsis +.nf +.b #include +.pp +.bi "void *dlopen(const char *" filename ", int " flags ); +.bi "int dlclose(void *" handle ); +.pp +.b #define _gnu_source +.br +.b #include +.pp +.bi "void *dlmopen(lmid_t " lmid ", const char *" filename ", int " flags ); +.fi +.pp +link with \fi\-ldl\fp. +.sh description +.ss dlopen() +the function +.br dlopen () +loads the dynamic shared object (shared library) +file named by the null-terminated +string +.i filename +and returns an opaque "handle" for the loaded object. +this handle is employed with other functions in the dlopen api, such as +.br dlsym (3), +.br dladdr (3), +.br dlinfo (3), +and +.br dlclose (). +.pp +if +.i filename +.\" fixme on solaris, when handle is null, we seem to get back +.\" a handle for (something like) the root of the namespace. +.\" the point here is that if we do a dlmopen(lm_id_newlm), then +.\" the filename==null case returns a different handle than +.\" in the initial namespace. but, on glibc, the same handle is +.\" returned. this is probably a bug in glibc. +.\" +is null, then the returned handle is for the main program. +if +.i filename +contains a slash ("/"), then it is interpreted as a (relative +or absolute) pathname. +otherwise, the dynamic linker searches for the object as follows +(see +.br ld.so (8) +for further details): +.ip o 4 +(elf only) if the calling object +(i.e., the shared library or executable from which +.br dlopen () +is called) +contains a dt_rpath tag, and does not contain a dt_runpath tag, +then the directories listed in the dt_rpath tag are searched. +.ip o +if, at the time that the program was started, the environment variable +.b ld_library_path +was defined to contain a colon-separated list of directories, +then these are searched. +(as a security measure, this variable is ignored for set-user-id and +set-group-id programs.) +.ip o +(elf only) if the calling object +contains a dt_runpath tag, then the directories listed in that tag +are searched. +.ip o +the cache file +.i /etc/ld.so.cache +(maintained by +.br ldconfig (8)) +is checked to see whether it contains an entry for +.ir filename . +.ip o +the directories +.i /lib +and +.i /usr/lib +are searched (in that order). +.pp +if the object specified by +.i filename +has dependencies on other shared objects, +then these are also automatically loaded by the dynamic linker +using the same rules. +(this process may occur recursively, +if those objects in turn have dependencies, and so on.) +.pp +one of the following two values must be included in +.ir flags : +.tp +.b rtld_lazy +perform lazy binding. +resolve symbols only as the code that references them is executed. +if the symbol is never referenced, then it is never resolved. +(lazy binding is performed only for function references; +references to variables are always immediately bound when +the shared object is loaded.) +since glibc 2.1.1, +.\" commit 12b5b6b7f78ea111e89bbf638294a5413c791072 +this flag is overridden by the effect of the +.b ld_bind_now +environment variable. +.tp +.b rtld_now +if this value is specified, or the environment variable +.b ld_bind_now +is set to a nonempty string, +all undefined symbols in the shared object are resolved before +.br dlopen () +returns. +if this cannot be done, an error is returned. +.pp +zero or more of the following values may also be ored in +.ir flags : +.tp +.b rtld_global +the symbols defined by this shared object will be +made available for symbol resolution of subsequently loaded shared objects. +.tp +.b rtld_local +this is the converse of +.br rtld_global , +and the default if neither flag is specified. +symbols defined in this shared object are not made available to resolve +references in subsequently loaded shared objects. +.tp +.br rtld_nodelete " (since glibc 2.2)" +do not unload the shared object during +.br dlclose (). +consequently, the object's static and global variables are not reinitialized +if the object is reloaded with +.br dlopen () +at a later time. +.tp +.br rtld_noload " (since glibc 2.2)" +don't load the shared object. +this can be used to test if the object is already resident +.rb ( dlopen () +returns null if it is not, or the object's handle if it is resident). +this flag can also be used to promote the flags on a shared object +that is already loaded. +for example, a shared object that was previously loaded with +.b rtld_local +can be reopened with +.br rtld_noload\ |\ rtld_global . +.\" +.tp +.br rtld_deepbind " (since glibc 2.3.4)" +.\" inimitably described by ud in +.\" http://sources.redhat.com/ml/libc-hacker/2004-09/msg00083.html. +place the lookup scope of the symbols in this +shared object ahead of the global scope. +this means that a self-contained object will use +its own symbols in preference to global symbols with the same name +contained in objects that have already been loaded. +.pp +if +.i filename +is null, then the returned handle is for the main program. +when given to +.br dlsym (3), +this handle causes a search for a symbol in the main program, +followed by all shared objects loaded at program startup, +and then all shared objects loaded by +.br dlopen () +with the flag +.br rtld_global . +.pp +symbol references in the shared object are resolved using (in order): +symbols in the link map of objects loaded for the main program and its +dependencies; +symbols in shared objects (and their dependencies) +that were previously opened with +.br dlopen () +using the +.br rtld_global +flag; +and definitions in the shared object itself +(and any dependencies that were loaded for that object). +.pp +any global symbols in the executable that were placed into +its dynamic symbol table by +.br ld (1) +can also be used to resolve references in a dynamically loaded shared object. +symbols may be placed in the dynamic symbol table +either because the executable was linked with the flag "\-rdynamic" +(or, synonymously, "\-\-export\-dynamic"), which causes all of +the executable's global symbols to be placed in the dynamic symbol table, +or because +.br ld (1) +noted a dependency on a symbol in another object during static linking. +.pp +if the same shared object is opened again with +.br dlopen (), +the same object handle is returned. +the dynamic linker maintains reference +counts for object handles, so a dynamically loaded shared object is not +deallocated until +.br dlclose () +has been called on it as many times as +.br dlopen () +has succeeded on it. +constructors (see below) are called only when the object is actually loaded +into memory (i.e., when the reference count increases to 1). +.pp +a subsequent +.br dlopen () +call that loads the same shared object with +.b rtld_now +may force symbol resolution for a shared object earlier loaded with +.br rtld_lazy . +similarly, an object that was previously opened with +.br rtld_local +can be promoted to +.br rtld_global +in a subsequent +.br dlopen (). +.pp +if +.br dlopen () +fails for any reason, it returns null. +.\" +.ss dlmopen() +this function performs the same task as +.br dlopen ()\(emthe +.i filename +and +.i flags +arguments, as well as the return value, are the same, +except for the differences noted below. +.pp +the +.br dlmopen () +function differs from +.br dlopen () +primarily in that it accepts an additional argument, +.ir lmid , +that specifies the link-map list (also referred to as a +.ir namespace ) +in which the shared object should be loaded. +(by comparison, +.br dlopen () +adds the dynamically loaded shared object to the same namespace as +the shared object from which the +.br dlopen () +call is made.) +the +.i lmid_t +type is an opaque handle that refers to a namespace. +.pp +the +.i lmid +argument is either the id of an existing namespace +.\" fixme: is using dlinfo() rtld_di_lmid the right technique? +(which can be obtained using the +.br dlinfo (3) +.b rtld_di_lmid +request) or one of the following special values: +.tp +.b lm_id_base +load the shared object in the initial namespace +(i.e., the application's namespace). +.tp +.b lm_id_newlm +create a new namespace and load the shared object in that namespace. +the object must have been correctly linked +to reference all of the other shared objects that it requires, +since the new namespace is initially empty. +.pp +if +.i filename +is null, then the only permitted value for +.i lmid +is +.br lm_id_base . +.ss dlclose() +the function +.br dlclose () +decrements the reference count on the +dynamically loaded shared object referred to by +.ir handle . +.pp +if the object's reference count drops to zero +and no symbols in this object are required by other objects, +then the object is unloaded +after first calling any destructors defined for the object. +(symbols in this object might be required in another object +because this object was opened with the +.br rtld_global +flag and one of its symbols satisfied a relocation in another object.) +.pp +all shared objects that were automatically loaded when +.br dlopen () +was invoked on the object referred to by +.i handle +are recursively closed in the same manner. +.pp +a successful return from +.br dlclose () +does not guarantee that the symbols associated with +.i handle +are removed from the caller's address space. +in addition to references resulting from explicit +.br dlopen () +calls, a shared object may have been implicitly loaded +(and reference counted) because of dependencies in other shared objects. +only when all references have been released can the shared object +be removed from the address space. +.sh return value +on success, +.br dlopen () +and +.br dlmopen () +return a non-null handle for the loaded object. +on error +(file could not be found, was not readable, had the wrong format, +or caused errors during loading), +these functions return null. +.pp +on success, +.br dlclose () +returns 0; on error, it returns a nonzero value. +.pp +errors from these functions can be diagnosed using +.br dlerror (3). +.sh versions +.br dlopen () +and +.br dlclose () +are present in glibc 2.0 and later. +.br dlmopen () +first appeared in glibc 2.3.4. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br dlopen (), +.br dlmopen (), +.br dlclose () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001 describes +.br dlclose () +and +.br dlopen (). +the +.br dlmopen () +function is a gnu extension. +.pp +the +.br rtld_noload , +.br rtld_nodelete , +and +.br rtld_deepbind +flags are gnu extensions; +the first two of these flags are also present on solaris. +.sh notes +.ss dlmopen() and namespaces +a link-map list defines an isolated namespace for the +resolution of symbols by the dynamic linker. +within a namespace, +dependent shared objects are implicitly loaded according to the usual rules, +and symbol references are likewise resolved according to the usual rules, +but such resolution is confined to the definitions provided by the +objects that have been (explicitly and implicitly) loaded into the namespace. +.pp +the +.br dlmopen () +function permits object-load isolation\(emthe ability +to load a shared object in a new namespace without +exposing the rest of the application to the symbols +made available by the new object. +note that the use of the +.b rtld_local +flag is not sufficient for this purpose, +since it prevents a shared object's symbols from being available to +.i any +other shared object. +in some cases, +we may want to make the symbols provided by a dynamically +loaded shared object available to (a subset of) other shared objects +without exposing those symbols to the entire application. +this can be achieved by using a separate namespace and the +.b rtld_global +flag. +.pp +the +.br dlmopen () +function also can be used to provide better isolation than the +.br rtld_local +flag. +in particular, shared objects loaded with +.br rtld_local +may be promoted to +.br rtld_global +if they are dependencies of another shared object loaded with +.br rtld_global . +thus, +.br rtld_local +is insufficient to isolate a loaded shared object except in the (uncommon) +case where one has explicit control over all shared object dependencies. +.pp +possible uses of +.br dlmopen () +are plugins where the author of the plugin-loading framework +can't trust the plugin authors and does not wish +any undefined symbols from the plugin framework to be resolved to plugin +symbols. +another use is to load the same object more than once. +without the use of +.br dlmopen (), +this would require the creation of distinct copies of the shared object file. +using +.br dlmopen (), +this can be achieved by loading the same shared object file into +different namespaces. +.pp +the glibc implementation supports a maximum of +.\" dl_nns +16 namespaces. +.\" +.ss initialization and finalization functions +shared objects may export functions using the +.b __attribute__((constructor)) +and +.b __attribute__((destructor)) +function attributes. +constructor functions are executed before +.br dlopen () +returns, and destructor functions are executed before +.br dlclose () +returns. +a shared object may export multiple constructors and destructors, +and priorities can be associated with each function +to determine the order in which they are executed. +see the +.br gcc +info pages (under "function attributes") +.\" info gcc "c extensions" "function attributes" +for further information. +.pp +an older method of (partially) achieving the same result is via the use of +two special symbols recognized by the linker: +.b _init +and +.br _fini . +if a dynamically loaded shared object exports a routine named +.br _init (), +then that code is executed after loading a shared object, before +.br dlopen () +returns. +if the shared object exports a routine named +.br _fini (), +then that routine is called just before the object is unloaded. +in this case, one must avoid linking against the system startup files, +which contain default versions of these files; +this can be done by using the +.br gcc (1) +.i \-nostartfiles +command-line option. +.pp +use of +.b _init +and +.br _fini +is now deprecated in favor of the aforementioned +constructors and destructors, +which among other advantages, +permit multiple initialization and finalization functions to be defined. +.\" +.\" using these routines, or the gcc +.\" .b \-nostartfiles +.\" or +.\" .b \-nostdlib +.\" options, is not recommended. +.\" their use may result in undesired behavior, +.\" since the constructor/destructor routines will not be executed +.\" (unless special measures are taken). +.\" .\" void _init(void) __attribute__((constructor)); +.\" .\" void _fini(void) __attribute__((destructor)); +.\" +.pp +since glibc 2.2.3, +.br atexit (3) +can be used to register an exit handler that is automatically +called when a shared object is unloaded. +.ss history +these functions are part of the dlopen api, derived from sunos. +.sh bugs +as at glibc 2.24, specifying the +.br rtld_global +flag when calling +.br dlmopen () +.\" dlerror(): "invalid mode" +generates an error. +furthermore, specifying +.br rtld_global +when calling +.br dlopen () +results in a program crash +.rb ( sigsegv ) +.\" https://sourceware.org/bugzilla/show_bug.cgi?id=18684 +if the call is made from any object loaded in a +namespace other than the initial namespace. +.sh examples +the program below loads the (glibc) math library, +looks up the address of the +.br cos (3) +function, and prints the cosine of 2.0. +the following is an example of building and running the program: +.pp +.in +4n +.ex +$ \fbcc dlopen_demo.c \-ldl\fp +$ \fb./a.out\fp +\-0.416147 +.ee +.in +.ss program source +\& +.ex +#include +#include +#include +#include /* defines libm_so (which will be a + string such as "libm.so.6") */ +int +main(void) +{ + void *handle; + double (*cosine)(double); + char *error; + + handle = dlopen(libm_so, rtld_lazy); + if (!handle) { + fprintf(stderr, "%s\en", dlerror()); + exit(exit_failure); + } + + dlerror(); /* clear any existing error */ + + cosine = (double (*)(double)) dlsym(handle, "cos"); + + /* according to the iso c standard, casting between function + pointers and \(aqvoid *\(aq, as done above, produces undefined results. + posix.1\-2001 and posix.1\-2008 accepted this state of affairs and + proposed the following workaround: + + *(void **) (&cosine) = dlsym(handle, "cos"); + + this (clumsy) cast conforms with the iso c standard and will + avoid any compiler warnings. + + the 2013 technical corrigendum 1 to posix.1\-2008 improved matters + by requiring that conforming implementations support casting + \(aqvoid *\(aq to a function pointer. nevertheless, some compilers + (e.g., gcc with the \(aq\-pedantic\(aq option) may complain about the + cast used in this program. */ +.\" http://pubs.opengroup.org/onlinepubs/009695399/functions/dlsym.html#tag_03_112_08 +.\" http://pubs.opengroup.org/onlinepubs/9699919799/functions/dlsym.html#tag_16_96_07 +.\" http://austingroupbugs.net/view.php?id=74 + + error = dlerror(); + if (error != null) { + fprintf(stderr, "%s\en", error); + exit(exit_failure); + } + + printf("%f\en", (*cosine)(2.0)); + dlclose(handle); + exit(exit_success); +} +.ee +.sh see also +.br ld (1), +.br ldd (1), +.br pldd (1), +.br dl_iterate_phdr (3), +.br dladdr (3), +.br dlerror (3), +.br dlinfo (3), +.br dlsym (3), +.br rtld\-audit (7), +.br ld.so (8), +.br ldconfig (8) +.pp +gcc info pages, ld info pages +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man7/iso_8859-2.7 + +.\" copyright (c) 2020 stephen kitt +.\" and copyright (c) 2021 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th close_range 2 2021-08-27 "linux" "linux programmer's manual" +.sh name +close_range \- close all file descriptors in a given range +.sh synopsis +.nf +.b #include +.pp +.bi "int close_range(unsigned int " first ", unsigned int " last , +.bi " unsigned int " flags ); +.fi +.sh description +the +.br close_range () +system call closes all open file descriptors from +.i first +to +.i last +(included). +.pp +errors closing a given file descriptor are currently ignored. +.pp +.i flags +is a bit mask containing 0 or more of the following: +.tp +.br close_range_cloexec " (since linux 5.11)" +set the close-on-exec flag on the specified file descriptors, +rather than immediately closing them. +.tp +.b close_range_unshare +unshare the specified file descriptors from any other processes +before closing them, +avoiding races with other threads sharing the file descriptor table. +.sh return value +on success, +.br close_range () +returns 0. +on error, \-1 is returned and +.i errno +is set to indicate the error. +.sh errors +.tp +.b einval +.i flags +is not valid, or +.i first +is greater than +.ir last . +.pp +the following can occur with +.b close_range_unshare +(when constructing the new descriptor table): +.tp +.b emfile +the number of open file descriptors exceeds the limit specified in +.ir /proc/sys/fs/nr_open +(see +.br proc (5)). +this error can occur in situations where that limit was lowered before +a call to +.br close_range () +where the +.b close_range_unshare +flag is specified. +.tp +.b enomem +insufficient kernel memory was available. +.sh versions +.br close_range () +first appeared in linux 5.9. +library support was added in glibc in version 2.34. +.sh conforming to +.br close_range () +is a nonstandard function that is also present on freebsd. +.sh notes +.ss closing all open file descriptors +.\" 278a5fbaed89dacd04e9d052f4594ffd0e0585de +to avoid blindly closing file descriptors +in the range of possible file descriptors, +this is sometimes implemented (on linux) +by listing open file descriptors in +.i /proc/self/fd/ +and calling +.br close (2) +on each one. +.br close_range () +can take care of this without requiring +.i /proc +and within a single system call, +which provides significant performance benefits. +.ss closing file descriptors before exec +.\" 60997c3d45d9a67daf01c56d805ae4fec37e0bd8 +file descriptors can be closed safely using +.pp +.in +4n +.ex +/* we don't want anything past stderr here */ +close_range(3, ~0u, close_range_unshare); +execve(....); +.ee +.in +.pp +.b close_range_unshare +is conceptually equivalent to +.pp +.in +4n +.ex +unshare(clone_files); +close_range(first, last, 0); +.ee +.in +.pp +but can be more efficient: +if the unshared range extends past +the current maximum number of file descriptors allocated +in the caller's file descriptor table +(the common case when +.i last +is ~0u), +the kernel will unshare a new file descriptor table for the caller up to +.ir first , +copying as few file descriptors as possible. +this avoids subsequent +.br close (2) +calls entirely; +the whole operation is complete once the table is unshared. +.ss closing files on \fbexec\fp +.\" 582f1fb6b721facf04848d2ca57f34468da1813e +this is particularly useful in cases where multiple +.rb pre- exec +setup steps risk conflicting with each other. +for example, setting up a +.br seccomp (2) +profile can conflict with a +.br close_range () +call: +if the file descriptors are closed before the +.br seccomp (2) +profile is set up, +the profile setup can't use them itself, +or control their closure; +if the file descriptors are closed afterwards, +the seccomp profile can't block the +.br close_range () +call or any fallbacks. +using +.b close_range_cloexec +avoids this: +the descriptors can be marked before the +.br seccomp (2) +profile is set up, +and the profile can control access to +.br close_range () +without affecting the calling process. +.sh examples +the program shown below opens the files named in its command-line arguments, +displays the list of files that it has opened +(by iterating through the entries in +.ir /proc/pid/fd ), +uses +.br close_range () +to close all file descriptors greater than or equal to 3, +and then once more displays the process's list of open files. +the following example demonstrates the use of the program: +.pp +.in +4n +.ex +$ \fbtouch /tmp/a /tmp/b /tmp/c\fp +$ \fb./a.out /tmp/a /tmp/b /tmp/c\fp +/tmp/a opened as fd 3 +/tmp/b opened as fd 4 +/tmp/c opened as fd 5 +/proc/self/fd/0 ==> /dev/pts/1 +/proc/self/fd/1 ==> /dev/pts/1 +/proc/self/fd/2 ==> /dev/pts/1 +/proc/self/fd/3 ==> /tmp/a +/proc/self/fd/4 ==> /tmp/b +/proc/self/fd/5 ==> /tmp/b +/proc/self/fd/6 ==> /proc/9005/fd +========= about to call close_range() ======= +/proc/self/fd/0 ==> /dev/pts/1 +/proc/self/fd/1 ==> /dev/pts/1 +/proc/self/fd/2 ==> /dev/pts/1 +/proc/self/fd/3 ==> /proc/9005/fd +.ee +.in +.pp +note that the lines showing the pathname +.i /proc/9005/fd +result from the calls to +.br opendir (3). +.ss program source +\& +.ex +#define _gnu_source +#include +#include +#include +#include +#include +#include +#include +#include + +/* show the contents of the symbolic links in /proc/self/fd */ + +static void +show_fds(void) +{ + dir *dirp = opendir("/proc/self/fd"); + if (dirp == null) { + perror("opendir"); + exit(exit_failure); + } + + for (;;) { + struct dirent *dp = readdir(dirp); + if (dp == null) + break; + + if (dp\->d_type == dt_lnk) { + char path[path_max], target[path_max]; + snprintf(path, sizeof(path), "/proc/self/fd/%s", + dp\->d_name); + + ssize_t len = readlink(path, target, sizeof(target)); + printf("%s ==> %.*s\en", path, (int) len, target); + } + } + + closedir(dirp); +} + +int +main(int argc, char *argv[]) +{ + for (int j = 1; j < argc; j++) { + int fd = open(argv[j], o_rdonly); + if (fd == \-1) { + perror(argv[j]); + exit(exit_failure); + } + printf("%s opened as fd %d\en", argv[j], fd); + } + + show_fds(); + + printf("========= about to call close_range() =======\en"); + + if (syscall(__nr_close_range, 3, \(ti0u, 0) == \-1) { + perror("close_range"); + exit(exit_failure); + } + + show_fds(); + exit(exit_failure); +} +.ee +.sh see also +.br close (2) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/sigset.3 + +.so man3/fmod.3 + +.so man3/toupper.3 + +.so man3/sigset.3 + +.so man3/getspnam.3 + +.so man3/lgamma.3 + +.\" copyright 2001 andries brouwer . +.\" and copyright 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th lround 3 2021-03-22 "" "linux programmer's manual" +.sh name +lround, lroundf, lroundl, llround, llroundf, llroundl \- round to +nearest integer +.sh synopsis +.nf +.b #include +.pp +.bi "long lround(double " x ); +.bi "long lroundf(float " x ); +.bi "long lroundl(long double " x ); +.pp +.bi "long long llround(double " x ); +.bi "long long llroundf(float " x ); +.bi "long long llroundl(long double " x ); +.fi +.pp +link with \fi\-lm\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +all functions shown above: +.nf + _isoc99_source || _posix_c_source >= 200112l +.fi +.sh description +these functions round their argument to the nearest integer value, +rounding halfway cases away from zero, +regardless of the current rounding direction (see +.br fenv (3)). +.pp +note that unlike the +.br round (3) +and +.br ceil (3), +functions, the return type of these functions differs from +that of their arguments. +.sh return value +these functions return the rounded integer value. +.pp +if +.i x +is a nan or an infinity, +or the rounded value is too large to be stored in a +.i long +.ri ( "long long" +in the case of the +.b ll* +functions), +then a domain error occurs, and the return value is unspecified. +.\" the return value is -(long_max - 1) or -(llong_max -1) +.sh errors +see +.br math_error (7) +for information on how to determine whether an error has occurred +when calling these functions. +.pp +the following errors can occur: +.tp +domain error: \fix\fp is a nan or infinite, or the rounded value is too large +.\" .i errno +.\" is set to +.\" .br edom . +an invalid floating-point exception +.rb ( fe_invalid ) +is raised. +.pp +these functions do not set +.ir errno . +.\" fixme . is it intentional that these functions do not set errno? +.\" bug raised: http://sources.redhat.com/bugzilla/show_bug.cgi?id=6797 +.sh versions +these functions first appeared in glibc in version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br lround (), +.br lroundf (), +.br lroundl (), +.br llround (), +.br llroundf (), +.br llroundl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.sh see also +.br ceil (3), +.br floor (3), +.br lrint (3), +.br nearbyint (3), +.br rint (3), +.br round (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/tailq.3 + +.\" copyright (c) 1993 by thomas koenig (ig25@rz.uni-karlsruhe.de) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified sat jul 24 19:51:06 1993 by rik faith (faith@cs.unc.edu) +.th ctermid 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +ctermid \- get controlling terminal name +.sh synopsis +.nf +.b #include +.\" posix also requires this function to be declared in , +.\" and glibc does so if suitable feature test macros are defined. +.pp +.bi "char *ctermid(char *" "s" ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br ctermid (): +.nf + _posix_c_source +.fi +.sh description +.br ctermid () +returns a string which is the pathname for the current +controlling terminal for this process. +if +.i s +is null, +a static buffer is used, otherwise +.i s +points to a buffer used to hold the terminal pathname. +the symbolic constant +.b l_ctermid +is the maximum number of characters in the returned pathname. +.sh return value +the pointer to the pathname. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br ctermid () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, svr4. +.sh bugs +the returned pathname may not uniquely identify the controlling +terminal; it may, for example, be +.ir /dev/tty . +.pp +it is not assured that the program can open the terminal. +.\" in glibc 2.3.x, x >= 4, the glibc headers threw an error +.\" if ctermid() was given an argument; fixed in 2.4. +.sh see also +.br ttyname (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" this manpage is copyright (c) 2006 jens axboe +.\" and copyright (c) 2006 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th tee 2 2020-06-09 "linux" "linux programmer's manual" +.sh name +tee \- duplicating pipe content +.sh synopsis +.nf +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "ssize_t tee(int " fd_in ", int " fd_out ", size_t " len \ +", unsigned int " flags ); +.fi +.\" return type was long before glibc 2.7 +.sh description +.\" example programs http://brick.kernel.dk/snaps +.\" +.\" +.\" add a "tee(in, out1, out2)" system call that duplicates the pages +.\" (again, incrementing their reference count, not copying the data) from +.\" one pipe to two other pipes. +.br tee () +duplicates up to +.i len +bytes of data from the pipe referred to by the file descriptor +.i fd_in +to the pipe referred to by the file descriptor +.ir fd_out . +it does not consume the data that is duplicated from +.ir fd_in ; +therefore, that data can be copied by a subsequent +.br splice (2). +.pp +.i flags +is a bit mask that is composed by oring together +zero or more of the following values: +.tp 1.9i +.b splice_f_move +currently has no effect for +.br tee (); +see +.br splice (2). +.tp +.b splice_f_nonblock +do not block on i/o; see +.br splice (2) +for further details. +.tp +.b splice_f_more +currently has no effect for +.br tee (), +but may be implemented in the future; see +.br splice (2). +.tp +.b splice_f_gift +unused for +.br tee (); +see +.br vmsplice (2). +.sh return value +upon successful completion, +.br tee () +returns the number of bytes that were duplicated between the input +and output. +a return value of 0 means that there was no data to transfer, +and it would not make sense to block, because there are no +writers connected to the write end of the pipe referred to by +.ir fd_in . +.pp +on error, +.br tee () +returns \-1 and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eagain +.b splice_f_nonblock +was specified in +.ir flags +or one of the file descriptors had been marked as nonblocking +.rb ( o_nonblock ) , +and the operation would block. +.tp +.b einval +.i fd_in +or +.i fd_out +does not refer to a pipe; or +.i fd_in +and +.i fd_out +refer to the same pipe. +.tp +.b enomem +out of memory. +.sh versions +the +.br tee () +system call first appeared in linux 2.6.17; +library support was added to glibc in version 2.5. +.sh conforming to +this system call is linux-specific. +.sh notes +conceptually, +.br tee () +copies the data between the two pipes. +in reality no real data copying takes place though: +under the covers, +.br tee () +assigns data to the output by merely grabbing +a reference to the input. +.sh examples +the example below implements a basic +.br tee (1) +program using the +.br tee () +system call. +here is an example of its use: +.pp +.in +4n +.ex +$ \fbdate |./a.out out.log | cat\fp +tue oct 28 10:06:00 cet 2014 +$ \fbcat out.log\fp +tue oct 28 10:06:00 cet 2014 +.ee +.in +.ss program source +\& +.ex +#define _gnu_source +#include +#include +#include +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + int fd; + int len, slen; + + if (argc != 2) { + fprintf(stderr, "usage: %s \en", argv[0]); + exit(exit_failure); + } + + fd = open(argv[1], o_wronly | o_creat | o_trunc, 0644); + if (fd == \-1) { + perror("open"); + exit(exit_failure); + } + + do { + /* + * tee stdin to stdout. + */ + len = tee(stdin_fileno, stdout_fileno, + int_max, splice_f_nonblock); + + if (len < 0) { + if (errno == eagain) + continue; + perror("tee"); + exit(exit_failure); + } else + if (len == 0) + break; + + /* + * consume stdin by splicing it to a file. + */ + while (len > 0) { + slen = splice(stdin_fileno, null, fd, null, + len, splice_f_move); + if (slen < 0) { + perror("splice"); + break; + } + len \-= slen; + } + } while (1); + + close(fd); + exit(exit_success); +} +.ee +.sh see also +.br splice (2), +.br vmsplice (2), +.br pipe (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/gethostbyname.3 + +.so man3/memchr.3 + +.so man2/getxattr.2 + +.so man3/rint.3 + +.\" copyright (c) 2013, peter schiffer +.\" and copyright (c) 2014, michael kerrisk +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.th memusage 1 2021-03-22 "gnu" "linux user manual" +.sh name +memusage \- profile memory usage of a program +.sh synopsis +.nf +.br memusage " [\fioption\fr]... \fiprogram\fr [\fiprogramoption\fr]..." +.fi +.sh description +.b memusage +is a bash script which profiles memory usage of the program, +.ir program . +it preloads the +.b libmemusage.so +library into the caller's environment (via the +.b ld_preload +environment variable; see +.br ld.so (8)). +the +.b libmemusage.so +library traces memory allocation by intercepting calls to +.br malloc (3), +.br calloc (3), +.br free (3), +and +.br realloc (3); +optionally, calls to +.br mmap (2), +.br mremap (2), +and +.br munmap (2) +can also be intercepted. +.pp +.b memusage +can output the collected data in textual form, or it can use +.br memusagestat (1) +(see the +.b \-p +option, below) +to create a png file containing graphical representation +of the collected data. +.ss memory usage summary +the "memory usage summary" line output by +.b memusage +contains three fields: +.rs 4 +.tp +\fbheap total\fr +sum of \fisize\fr arguments of all +.br malloc (3) +calls, +products of arguments (\finmemb\fr*\fisize\fr) of all +.br calloc (3) +calls, +and sum of \filength\fr arguments of all +.br mmap (2) +calls. +in the case of +.br realloc (3) +and +.br mremap (2), +if the new size of an allocation is larger than the previous size, +the sum of all such differences (new size minus old size) is added. +.tp +.b "heap peak" +maximum of all \fisize\fr arguments of +.br malloc (3), +all products of \finmemb\fr*\fisize\fr of +.br calloc (3), +all \fisize\fr arguments of +.br realloc (3), +.i length +arguments of +.br mmap (2), +and +\finew_size\fr arguments of +.br mremap (2). +.tp +.b "stack peak" +before the first call to any monitored function, +the stack pointer address (base stack pointer) is saved. +after each function call, the actual stack pointer address is read and +the difference from the base stack pointer computed. +the maximum of these differences is then the stack peak. +.re +.pp +immediately following this summary line, a table shows the number calls, +total memory allocated or deallocated, +and number of failed calls for each intercepted function. +for +.br realloc (3) +and +.br mremap (2), +the additional field "nomove" shows reallocations that +changed the address of a block, +and the additional "dec" field shows reallocations that +decreased the size of the block. +for +.br realloc (3), +the additional field "free" shows reallocations that +caused a block to be freed (i.e., the reallocated size was 0). +.pp +the "realloc/total memory" of the table output by +.b memusage +does not reflect cases where +.br realloc (3) +is used to reallocate a block of memory +to have a smaller size than previously. +this can cause sum of all "total memory" cells (excluding "free") +to be larger than the "free/total memory" cell. +.ss histogram for block sizes +the "histogram for block sizes" provides a breakdown of memory +allocations into various bucket sizes. +.sh options +.tp +.bi \-n\ name \fr,\ \fb\-\-progname= name +name of the program file to profile. +.tp +.bi \-p\ file \fr,\ \fb\-\-png= file +generate png graphic and store it in +.ir file . +.tp +.bi \-d\ file \fr,\ \fb\-\-data= file +generate binary data file and store it in +.ir file . +.tp +.b \-u\fr,\ \fb\-\-unbuffered +do not buffer output. +.tp +.bi \-b\ size \fr,\ \fb\-\-buffer= size +collect +.i size +entries before writing them out. +.tp +.b \-\-no\-timer +disable timer-based +.rb ( sigprof ) +sampling of stack pointer value. +.tp +.b \-m\fr,\ \fb\-\-mmap +also trace +.br mmap (2), +.br mremap (2), +and +.br munmap (2). +.tp +.b \-?\fr,\ \fb\-\-help +print help and exit. +.tp +.b \-\-usage +print a short usage message and exit. +.tp +.b \-v\fr,\ \fb\-\-version +print version information and exit. +.tp +the following options apply only when generating graphical output: +.tp +.b \-t\fr,\ \fb\-\-time\-based +use time (rather than number of function calls) as the scale for the x axis. +.tp +.b \-t\fr,\ \fb\-\-total +also draw a graph of total memory use. +.tp +.bi \fb\-\-title= name +use +.i name +as the title of the graph. +.tp +.bi \-x\ size \fr,\ \fb\-\-x\-size= size +make the graph +.i size +pixels wide. +.tp +.bi \-y\ size \fr,\ \fb\-\-y\-size= size +make the graph +.i size +pixels high. +.sh exit status +the exit status of +.br memusage +is equal to the exit status of the profiled program. +.sh bugs +to report bugs, see +.ur http://www.gnu.org/software/libc/bugs.html +.ue +.sh examples +below is a simple program that reallocates a block of +memory in cycles that rise to a peak before then cyclically +reallocating the memory in smaller blocks that return to zero. +after compiling the program and running the following commands, +a graph of the memory usage of the program can be found in the file +.ir memusage.png : +.pp +.in +4n +.ex +$ \fbmemusage \-\-data=memusage.dat ./a.out\fp +\&... +memory usage summary: heap total: 45200, heap peak: 6440, stack peak: 224 + total calls total memory failed calls + malloc| 1 400 0 +realloc| 40 44800 0 (nomove:40, dec:19, free:0) + calloc| 0 0 0 + free| 1 440 +histogram for block sizes: + 192\-207 1 2% ================ +\&... + 2192\-2207 1 2% ================ + 2240\-2255 2 4% ================================= + 2832\-2847 2 4% ================================= + 3440\-3455 2 4% ================================= + 4032\-4047 2 4% ================================= + 4640\-4655 2 4% ================================= + 5232\-5247 2 4% ================================= + 5840\-5855 2 4% ================================= + 6432\-6447 1 2% ================ +$ \fbmemusagestat memusage.dat memusage.png\fp +.ee +.in +.ss program source +.ex +#include +#include + +#define cycles 20 + +int +main(int argc, char *argv[]) +{ + int i, j; + size_t size; + int *p; + + size = sizeof(*p) * 100; + printf("malloc: %zu\en", size); + p = malloc(size); + + for (i = 0; i < cycles; i++) { + if (i < cycles / 2) + j = i; + else + j\-\-; + + size = sizeof(*p) * (j * 50 + 110); + printf("realloc: %zu\en", size); + p = realloc(p, size); + + size = sizeof(*p) * ((j + 1) * 150 + 110); + printf("realloc: %zu\en", size); + p = realloc(p, size); + } + + free(p); + exit(exit_success); +} +.ee +.sh see also +.br memusagestat (1), +.br mtrace (1), +.br ld.so (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/circleq.3 + +.so man7/system_data_types.7 + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" +.th mbsnrtowcs 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +mbsnrtowcs \- convert a multibyte string to a wide-character string +.sh synopsis +.nf +.b #include +.pp +.bi "size_t mbsnrtowcs(wchar_t *restrict " dest ", const char **restrict " src , +.bi " size_t " nms ", size_t " len \ +", mbstate_t *restrict " ps ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br mbsnrtowcs (): +.nf + since glibc 2.10: + _posix_c_source >= 200809l + before glibc 2.10: + _gnu_source +.fi +.sh description +the +.br mbsnrtowcs () +function is like the +.br mbsrtowcs (3) +function, except that +the number of bytes to be converted, starting at +.ir *src , +is limited to at most +.ir nms +bytes. +.pp +if +.i dest +is not null, the +.br mbsnrtowcs () +function converts at +most +.i nms +bytes from the +multibyte string +.i *src +to a wide-character string starting at +.ir dest . +at most +.i len +wide characters are written to +.ir dest . +the shift state +.i *ps +is updated. +the conversion is effectively performed by repeatedly +calling +.i "mbrtowc(dest, *src, n, ps)" +where +.i n +is some +positive number, as long as this call succeeds, and then incrementing +.i dest +by one and +.i *src +by the number of bytes consumed. +the +conversion can stop for three reasons: +.ip 1. 3 +an invalid multibyte sequence has been encountered. +in this case, +.i *src +is left pointing to the invalid multibyte sequence, +.i (size_t)\ \-1 +is returned, +and +.i errno +is set to +.br eilseq . +.ip 2. +the +.i nms +limit forces a stop, +or +.i len +non-l\(aq\e0\(aq wide characters +have been stored at +.ir dest . +in this case, +.i *src +is left pointing to the +next multibyte sequence to be converted, and the number of wide characters +written to +.i dest +is returned. +.ip 3. +the multibyte string has been completely converted, including the +terminating null wide character (\(aq\e0\(aq) +(which has the side effect of bringing back +.i *ps +to the +initial state). +in this case, +.i *src +is set to null, and the number of wide +characters written to +.ir dest , +excluding the terminating null wide character, +is returned. +.pp +according to posix.1, +if the input buffer ends with an incomplete character, +it is unspecified whether conversion stops at the end of +the previous character (if any), or at the end of the input buffer. +the glibc implementation adopts the former behavior. +.pp +if +.ir dest +is null, +.i len +is ignored, and the conversion proceeds as +above, except that the converted wide characters +are not written out to memory, +and that no destination length limit exists. +.pp +in both of the above cases, if +.i ps +is null, a static anonymous +state known only to the +.br mbsnrtowcs () +function is used instead. +.pp +the programmer must ensure that there is room for at least +.i len +wide +characters at +.ir dest . +.sh return value +the +.br mbsnrtowcs () +function returns the number of wide characters +that make up the converted part of the wide-character string, +not including the terminating null wide character. +if an invalid multibyte sequence was +encountered, +.i (size_t)\ \-1 +is returned, and +.i errno +set to +.br eilseq . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lb lb lbx +l l l. +interface attribute value +t{ +.br mbsnrtowcs () +t} thread safety t{ +mt-unsafe race:mbsnrtowcs/!ps +t} +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2008. +.sh notes +the behavior of +.br mbsnrtowcs () +depends on the +.b lc_ctype +category of the +current locale. +.pp +passing null as +.i ps +is not multithread safe. +.sh see also +.br iconv (3), +.br mbrtowc (3), +.br mbsinit (3), +.br mbsrtowcs (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" this manpage is copyright (c) 1992 drew eckhardt; +.\" and copyright (c) 1993 michael haardt, ian jackson. +.\" and copyright (c) 2009-2015 michael kerrisk, +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified sat jul 24 00:06:00 1993 by rik faith +.\" modified wed jan 17 16:02:32 1996 by michael haardt +.\" +.\" modified thu apr 11 19:26:35 1996 by andries brouwer +.\" modified sun jul 21 18:59:33 1996 by andries brouwer +.\" modified fri jan 31 16:47:33 1997 by eric s. raymond +.\" modified sat jul 12 20:45:39 1997 by michael haardt +.\" +.\" +.th read 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +read \- read from a file descriptor +.sh synopsis +.nf +.b #include +.pp +.bi "ssize_t read(int " fd ", void *" buf ", size_t " count ); +.fi +.sh description +.br read () +attempts to read up to +.i count +bytes from file descriptor +.i fd +into the buffer starting at +.ir buf . +.pp +on files that support seeking, +the read operation commences at the file offset, +and the file offset is incremented by the number of bytes read. +if the file offset is at or past the end of file, +no bytes are read, and +.br read () +returns zero. +.pp +if +.i count +is zero, +.br read () +.i may +detect the errors described below. +in the absence of any errors, +or if +.br read () +does not check for errors, a +.br read () +with a +.i count +of 0 returns zero and has no other effects. +.pp +according to posix.1, if +.i count +is greater than +.br ssize_max , +the result is implementation-defined; +see notes for the upper limit on linux. +.sh return value +on success, the number of bytes read is returned (zero indicates end of +file), and the file position is advanced by this number. +it is not an error if this number is smaller than the number of bytes +requested; this may happen for example because fewer bytes are actually +available right now (maybe because we were close to end-of-file, or +because we are reading from a pipe, or from a terminal), or because +.br read () +was interrupted by a signal. +see also notes. +.pp +on error, \-1 is returned, and +.i errno +is set to indicate the error. +in this case, it is left unspecified whether +the file position (if any) changes. +.sh errors +.tp +.b eagain +the file descriptor +.i fd +refers to a file other than a socket and has been marked nonblocking +.rb ( o_nonblock ), +and the read would block. +see +.br open (2) +for further details on the +.br o_nonblock +flag. +.tp +.br eagain " or " ewouldblock +.\" actually eagain on linux +the file descriptor +.i fd +refers to a socket and has been marked nonblocking +.rb ( o_nonblock ), +and the read would block. +posix.1-2001 allows either error to be returned for this case, +and does not require these constants to have the same value, +so a portable application should check for both possibilities. +.tp +.b ebadf +.i fd +is not a valid file descriptor or is not open for reading. +.tp +.b efault +.i buf +is outside your accessible address space. +.tp +.b eintr +the call was interrupted by a signal before any data was read; see +.br signal (7). +.tp +.b einval +.i fd +is attached to an object which is unsuitable for reading; +or the file was opened with the +.b o_direct +flag, and either the address specified in +.ir buf , +the value specified in +.ir count , +or the file offset is not suitably aligned. +.tp +.b einval +.i fd +was created via a call to +.br timerfd_create (2) +and the wrong size buffer was given to +.br read (); +see +.br timerfd_create (2) +for further information. +.tp +.b eio +i/o error. +this will happen for example when the process is in a +background process group, tries to read from its controlling terminal, +and either it is ignoring or blocking +.b sigttin +or its process group +is orphaned. +it may also occur when there is a low-level i/o error +while reading from a disk or tape. +a further possible cause of +.b eio +on networked filesystems is when an advisory lock had been taken +out on the file descriptor and this lock has been lost. +see the +.i "lost locks" +section of +.br fcntl (2) +for further details. +.tp +.b eisdir +.i fd +refers to a directory. +.pp +other errors may occur, depending on the object connected to +.ir fd . +.sh conforming to +svr4, 4.3bsd, posix.1-2001. +.sh notes +the types +.i size_t +and +.i ssize_t +are, respectively, +unsigned and signed integer data types specified by posix.1. +.pp +on linux, +.br read () +(and similar system calls) will transfer at most +0x7ffff000 (2,147,479,552) bytes, +returning the number of bytes actually transferred. +.\" commit e28cc71572da38a5a12c1cfe4d7032017adccf69 +(this is true on both 32-bit and 64-bit systems.) +.pp +on nfs filesystems, reading small amounts of data will update the +timestamp only the first time, subsequent calls may not do so. +this is caused +by client side attribute caching, because most if not all nfs clients +leave +.i st_atime +(last file access time) +updates to the server, and client side reads satisfied from the +client's cache will not cause +.i st_atime +updates on the server as there are no +server-side reads. +unix semantics can be obtained by disabling client-side attribute caching, +but in most situations this will substantially +increase server load and decrease performance. +.sh bugs +according to posix.1-2008/susv4 section xsi 2.9.7 +("thread interactions with regular file operations"): +.pp +.rs 4 +all of the following functions shall be atomic with respect to +each other in the effects specified in posix.1-2008 when they +operate on regular files or symbolic links: ... +.re +.pp +among the apis subsequently listed are +.br read () +and +.br readv (2). +and among the effects that should be atomic across threads (and processes) +are updates of the file offset. +however, on linux before version 3.14, +this was not the case: if two processes that share +an open file description (see +.br open (2)) +perform a +.br read () +(or +.br readv (2)) +at the same time, then the i/o operations were not atomic +with respect updating the file offset, +with the result that the reads in the two processes +might (incorrectly) overlap in the blocks of data that they obtained. +this problem was fixed in linux 3.14. +.\" http://thread.gmane.org/gmane.linux.kernel/1649458 +.\" from: michael kerrisk (man-pages gmail.com> +.\" subject: update of file offset on write() etc. is non-atomic with i/o +.\" date: 2014-02-17 15:41:37 gmt +.\" newsgroups: gmane.linux.kernel, gmane.linux.file-systems +.\" commit 9c225f2655e36a470c4f58dbbc99244c5fc7f2d4 +.\" author: linus torvalds +.\" date: mon mar 3 09:36:58 2014 -0800 +.\" +.\" vfs: atomic f_pos accesses as per posix +.sh see also +.br close (2), +.br fcntl (2), +.br ioctl (2), +.br lseek (2), +.br open (2), +.br pread (2), +.br readdir (2), +.br readlink (2), +.br readv (2), +.br select (2), +.br write (2), +.br fread (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1993 rickard e. faith (faith@cs.unc.edu) and +.\" and copyright 2002 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified fri jan 31 16:26:07 1997 by eric s. raymond +.\" modified fri dec 11 17:57:27 1998 by jamie lokier +.\" modified 24 apr 2002 by michael kerrisk +.\" substantial rewrites and additions +.\" 2005-05-10 mtk, noted that lock conversions are not atomic. +.\" +.\" fixme maybe document lock_mand, lock_rw, lock_read, lock_write +.\" which only have effect for samba. +.\" +.th flock 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +flock \- apply or remove an advisory lock on an open file +.sh synopsis +.nf +.b #include +.pp +.bi "int flock(int " fd ", int " operation ); +.fi +.sh description +apply or remove an advisory lock on the open file specified by +.ir fd . +the argument +.i operation +is one of the following: +.rs 4 +.tp 9 +.b lock_sh +place a shared lock. +more than one process may hold a shared lock for a given file +at a given time. +.tp +.b lock_ex +place an exclusive lock. +only one process may hold an exclusive lock for a given +file at a given time. +.tp +.b lock_un +remove an existing lock held by this process. +.re +.pp +a call to +.br flock () +may block if an incompatible lock is held by another process. +to make a nonblocking request, include +.b lock_nb +(by oring) +with any of the above operations. +.pp +a single file may not simultaneously have both shared and exclusive locks. +.pp +locks created by +.br flock () +are associated with an open file description (see +.br open (2)). +this means that duplicate file descriptors (created by, for example, +.br fork (2) +or +.br dup (2)) +refer to the same lock, and this lock may be modified +or released using any of these file descriptors. +furthermore, the lock is released either by an explicit +.b lock_un +operation on any of these duplicate file descriptors, or when all +such file descriptors have been closed. +.pp +if a process uses +.br open (2) +(or similar) to obtain more than one file descriptor for the same file, +these file descriptors are treated independently by +.br flock (). +an attempt to lock the file using one of these file descriptors +may be denied by a lock that the calling process has +already placed via another file descriptor. +.pp +a process may hold only one type of lock (shared or exclusive) +on a file. +subsequent +.br flock () +calls on an already locked file will convert an existing lock to the new +lock mode. +.pp +locks created by +.br flock () +are preserved across an +.br execve (2). +.pp +a shared or exclusive lock can be placed on a file regardless of the +mode in which the file was opened. +.sh return value +on success, zero is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b ebadf +.i fd +is not an open file descriptor. +.tp +.b eintr +while waiting to acquire a lock, the call was interrupted by +delivery of a signal caught by a handler; see +.br signal (7). +.tp +.b einval +.i operation +is invalid. +.tp +.b enolck +the kernel ran out of memory for allocating lock records. +.tp +.b ewouldblock +the file is locked and the +.b lock_nb +flag was selected. +.sh conforming to +4.4bsd (the +.br flock () +call first appeared in 4.2bsd). +a version of +.br flock (), +possibly implemented in terms of +.br fcntl (2), +appears on most unix systems. +.sh notes +since kernel 2.0, +.br flock () +is implemented as a system call in its own right rather +than being emulated in the gnu c library as a call to +.br fcntl (2). +with this implementation, +there is no interaction between the types of lock +placed by +.br flock () +and +.br fcntl (2), +and +.br flock () +does not detect deadlock. +(note, however, that on some systems, such as the modern bsds, +.\" e.g., according to the flock(2) man page, freebsd since at least 5.3 +.br flock () +and +.br fcntl (2) +locks +.i do +interact with one another.) +.pp +.br flock () +places advisory locks only; given suitable permissions on a file, +a process is free to ignore the use of +.br flock () +and perform i/o on the file. +.pp +.br flock () +and +.br fcntl (2) +locks have different semantics with respect to forked processes and +.br dup (2). +on systems that implement +.br flock () +using +.br fcntl (2), +the semantics of +.br flock () +will be different from those described in this manual page. +.pp +converting a lock +(shared to exclusive, or vice versa) is not guaranteed to be atomic: +the existing lock is first removed, and then a new lock is established. +between these two steps, +a pending lock request by another process may be granted, +with the result that the conversion either blocks, or fails if +.b lock_nb +was specified. +(this is the original bsd behavior, +and occurs on many other implementations.) +.\" kernel 2.5.21 changed things a little: during lock conversion +.\" it is now the highest priority process that will get the lock -- mtk +.ss nfs details +in linux kernels up to 2.6.11, +.br flock () +does not lock files over nfs +(i.e., the scope of locks was limited to the local system). +instead, one could use +.br fcntl (2) +byte-range locking, which does work over nfs, +given a sufficiently recent version of +linux and a server which supports locking. +.pp +since linux 2.6.12, nfs clients support +.br flock () +locks by emulating them as +.br fcntl (2) +byte-range locks on the entire file. +this means that +.br fcntl (2) +and +.br flock () +locks +.i do +interact with one another over nfs. +it also means that in order to place an exclusive lock, +the file must be opened for writing. +.pp +since linux 2.6.37, +.\" commit 5eebde23223aeb0ad2d9e3be6590ff8bbfab0fc2 +the kernel supports a compatibility mode that allows +.br flock () +locks (and also +.br fcntl (2) +byte region locks) to be treated as local; +see the discussion of the +.i "local_lock" +option in +.br nfs (5). +.ss cifs details +in linux kernels up to 5.4, +.br flock () +is not propagated over smb. +a file with such locks will not appear locked for remote clients. +.pp +since linux 5.5, +.br flock () +locks are emulated with smb byte-range locks on the entire file. +similarly to nfs, this means that +.br fcntl (2) +and +.br flock () +locks interact with one another. +another important side-effect is that the locks are not advisory anymore: +any io on a locked file will always fail with +.br eacces +when done from a separate file descriptor. +this difference originates from the design of locks in the smb protocol, +which provides mandatory locking semantics. +.pp +remote and mandatory locking semantics may vary with smb protocol, mount options and server type. +see +.br mount.cifs (8) +for additional information. +.sh see also +.br flock (1), +.br close (2), +.br dup (2), +.br execve (2), +.br fcntl (2), +.br fork (2), +.br open (2), +.br lockf (3), +.br lslocks (8) +.pp +.i documentation/filesystems/locks.txt +in the linux kernel source tree +.ri ( documentation/locks.txt +in older kernels) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/isalpha.3 + +.\" copyright (c) 1993 by thomas koenig (ig25@rz.uni-karlsruhe.de) +.\" and copyright i2007, 2012, 2018, michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified sat jul 24 19:00:59 1993 by rik faith (faith@cs.unc.edu) +.\" clarification concerning realloc, iwj10@cus.cam.ac.uk (ian jackson), 950701 +.\" documented malloc_check_, wolfram gloger (wmglo@dent.med.uni-muenchen.de) +.\" 2007-09-15 mtk: added notes on malloc()'s use of sbrk() and mmap(). +.\" +.\" fixme . review http://austingroupbugs.net/view.php?id=374 +.\" to see what changes are required on this page. +.\" +.th malloc 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +malloc, free, calloc, realloc, reallocarray \- allocate and free dynamic memory +.sh synopsis +.nf +.b #include +.pp +.bi "void *malloc(size_t " "size" ); +.bi "void free(void " "*ptr" ); +.bi "void *calloc(size_t " "nmemb" ", size_t " "size" ); +.bi "void *realloc(void " "*ptr" ", size_t " "size" ); +.bi "void *reallocarray(void " "*ptr" ", size_t " nmemb ", size_t " "size" ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br reallocarray (): +.nf + since glibc 2.29: + _default_source + glibc 2.28 and earlier: + _gnu_source +.fi +.sh description +the +.br malloc () +function allocates +.i size +bytes and returns a pointer to the allocated memory. +.ir "the memory is not initialized" . +if +.i size +is 0, then +.br malloc () +returns either null, +.\" glibc does this: +or a unique pointer value that can later be successfully passed to +.br free (). +.pp +the +.br free () +function frees the memory space pointed to by +.ir ptr , +which must have been returned by a previous call to +.br malloc (), +.br calloc (), +or +.br realloc (). +otherwise, or if +.i free(ptr) +has already been called before, undefined behavior occurs. +if +.i ptr +is null, no operation is performed. +.pp +the +.br calloc () +function allocates memory for an array of +.i nmemb +elements of +.i size +bytes each and returns a pointer to the allocated memory. +the memory is set to zero. +if +.i nmemb +or +.i size +is 0, then +.br calloc () +returns either null, +.\" glibc does this: +or a unique pointer value that can later be successfully passed to +.br free (). +if the multiplication of +.i nmemb +and +.i size +would result in integer overflow, then +.br calloc () +returns an error. +by contrast, +an integer overflow would not be detected in the following call to +.br malloc (), +with the result that an incorrectly sized block of memory would be allocated: +.pp +.in +4n +.ex +malloc(nmemb * size); +.ee +.in +.pp +the +.br realloc () +function changes the size of the memory block pointed to by +.i ptr +to +.i size +bytes. +the contents will be unchanged in the range from the start of the region +up to the minimum of the old and new sizes. +if the new size is larger than the old size, the added memory will +.i not +be initialized. +if +.i ptr +is null, then the call is equivalent to +.ir malloc(size) , +for all values of +.ir size ; +if +.i size +is equal to zero, +and +.i ptr +is not null, then the call is equivalent to +.i free(ptr) +(this behavior is nonportable; see notes). +unless +.i ptr +is null, it must have been returned by an earlier call to +.br malloc (), +.br calloc (), +or +.br realloc (). +if the area pointed to was moved, a +.i free(ptr) +is done. +.pp +the +.br reallocarray () +function changes the size of the memory block pointed to by +.i ptr +to be large enough for an array of +.i nmemb +elements, each of which is +.i size +bytes. +it is equivalent to the call +.pp +.in +4n + realloc(ptr, nmemb * size); +.in +.pp +however, unlike that +.br realloc () +call, +.br reallocarray () +fails safely in the case where the multiplication would overflow. +if such an overflow occurs, +.br reallocarray () +returns null, sets +.i errno +to +.br enomem , +and leaves the original block of memory unchanged. +.sh return value +the +.br malloc () +and +.br calloc () +functions return a pointer to the allocated memory, +which is suitably aligned for any built-in type. +on error, these functions return null. +null may also be returned by a successful call to +.br malloc () +with a +.i size +of zero, +or by a successful call to +.br calloc () +with +.i nmemb +or +.i size +equal to zero. +.pp +the +.br free () +function returns no value. +.pp +the +.br realloc () +function returns a pointer to the newly allocated memory, which is suitably +aligned for any built-in type, or null if the request failed. +the returned pointer may be the same as +.ir ptr +if the allocation was not moved +(e.g., there was room to expand the allocation in-place), or different from +.ir ptr +if the allocation was moved to a new address. +if +.i size +was equal to 0, either null or a pointer suitable to be passed to +.br free () +is returned. +if +.br realloc () +fails, the original block is left untouched; it is not freed or moved. +.pp +on success, the +.br reallocarray () +function returns a pointer to the newly allocated memory. +on failure, +it returns null and the original block of memory is left untouched. +.sh errors +.br calloc (), +.br malloc (), +.br realloc (), +and +.br reallocarray () +can fail with the following error: +.tp +.b enomem +out of memory. +possibly, the application hit the +.br rlimit_as +or +.br rlimit_data +limit described in +.br getrlimit (2). +.sh versions +.br reallocarray () +first appeared in glibc in version 2.26. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br malloc (), +.br free (), +.br calloc (), +.br realloc () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +.br malloc (), +.br free (), +.br calloc (), +.br realloc (): +posix.1-2001, posix.1-2008, c89, c99. +.pp +.br reallocarray () +is a nonstandard extension that first appeared in openbsd 5.6 and freebsd 11.0. +.sh notes +by default, linux follows an optimistic memory allocation strategy. +this means that when +.br malloc () +returns non-null there is no guarantee that the memory really +is available. +in case it turns out that the system is out of memory, +one or more processes will be killed by the oom killer. +for more information, see the description of +.ir /proc/sys/vm/overcommit_memory +and +.ir /proc/sys/vm/oom_adj +in +.br proc (5), +and the linux kernel source file +.ir documentation/vm/overcommit\-accounting.rst . +.pp +normally, +.br malloc () +allocates memory from the heap, and adjusts the size of the heap +as required, using +.br sbrk (2). +when allocating blocks of memory larger than +.b mmap_threshold +bytes, the glibc +.br malloc () +implementation allocates the memory as a private anonymous mapping using +.br mmap (2). +.b mmap_threshold +is 128\ kb by default, but is adjustable using +.br mallopt (3). +prior to linux 4.7 +allocations performed using +.br mmap (2) +were unaffected by the +.b rlimit_data +resource limit; +since linux 4.7, this limit is also enforced for allocations performed using +.br mmap (2). +.pp +to avoid corruption in multithreaded applications, +mutexes are used internally to protect the memory-management +data structures employed by these functions. +in a multithreaded application in which threads simultaneously +allocate and free memory, +there could be contention for these mutexes. +to scalably handle memory allocation in multithreaded applications, +glibc creates additional +.ir "memory allocation arenas" +if mutex contention is detected. +each arena is a large region of memory that is internally allocated +by the system +(using +.br brk (2) +or +.br mmap (2)), +and managed with its own mutexes. +.pp +susv2 requires +.br malloc (), +.br calloc (), +and +.br realloc () +to set +.i errno +to +.b enomem +upon failure. +glibc assumes that this is done +(and the glibc versions of these routines do this); if you +use a private malloc implementation that does not set +.ir errno , +then certain library routines may fail without having +a reason in +.ir errno . +.pp +crashes in +.br malloc (), +.br calloc (), +.br realloc (), +or +.br free () +are almost always related to heap corruption, such as overflowing +an allocated chunk or freeing the same pointer twice. +.pp +the +.br malloc () +implementation is tunable via environment variables; see +.br mallopt (3) +for details. +.ss nonportable behavior +the behavior of +.br realloc () +when +.i size +is equal to zero, +and +.i ptr +is not null, +is glibc specific; +other implementations may return null, and set +.ir errno . +portable posix programs should avoid it. +see +.br realloc (3p). +.sh see also +.\" http://g.oswego.edu/dl/html/malloc.html +.\" a memory allocator - by doug lea +.\" +.\" http://www.bozemanpass.com/info/linux/malloc/linux_heap_contention.html +.\" linux heap, contention in free() - david boreham +.\" +.\" http://www.citi.umich.edu/projects/linux-scalability/reports/malloc.html +.\" malloc() performance in a multithreaded linux environment - +.\" check lever, david boreham +.\" +.ad l +.nh +.br valgrind (1), +.br brk (2), +.br mmap (2), +.br alloca (3), +.br malloc_get_state (3), +.br malloc_info (3), +.br malloc_trim (3), +.br malloc_usable_size (3), +.br mallopt (3), +.br mcheck (3), +.br mtrace (3), +.br posix_memalign (3) +.pp +for details of the gnu c library implementation, see +.ur https://sourceware.org/glibc/wiki/mallocinternals +.ue . +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1993 michael haardt (michael@cantor.informatik.rwth-aachen.de), +.\" fri apr 2 11:32:09 met dst 1993 +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" modified 1993-07-25 by rik faith (faith@cs.unc.edu) +.\" modified 1995-02-26 by michael haardt +.\" modified 1996-07-20 by michael haardt +.\" modified 1997-07-02 by nicolás lichtmaier +.\" modified 2004-10-31 by aeb, following gwenole beauchesne +.th utmp 5 2021-03-22 "linux" "linux programmer's manual" +.sh name +utmp, wtmp \- login records +.sh synopsis +.nf +.b #include +.fi +.sh description +the +.i utmp +file allows one to discover information about who is currently using the +system. +there may be more users currently using the system, because not +all programs use utmp logging. +.pp +.b warning: +.i utmp +must not be writable by the user class "other", +because many system programs (foolishly) +depend on its integrity. +you risk faked system logfiles and +modifications of system files if you leave +.i utmp +writable to any user other than the owner and group owner of the file. +.pp +the file is a sequence of +.i utmp +structures, +declared as follows in +.ir +(note that this is only one of several definitions +around; details depend on the version of libc): +.pp +.in +4n +.ex +/* values for ut_type field, below */ + +#define empty 0 /* record does not contain valid info + (formerly known as ut_unknown on linux) */ +#define run_lvl 1 /* change in system run\-level (see + \fbinit\fp(1)) */ +#define boot_time 2 /* time of system boot (in \fiut_tv\fp) */ +#define new_time 3 /* time after system clock change + (in \fiut_tv\fp) */ +#define old_time 4 /* time before system clock change + (in \fiut_tv\fp) */ +#define init_process 5 /* process spawned by \fbinit\fp(1) */ +#define login_process 6 /* session leader process for user login */ +#define user_process 7 /* normal process */ +#define dead_process 8 /* terminated process */ +#define accounting 9 /* not implemented */ + +#define ut_linesize 32 +#define ut_namesize 32 +#define ut_hostsize 256 + +struct exit_status { /* type for ut_exit, below */ + short e_termination; /* process termination status */ + short e_exit; /* process exit status */ +}; + +struct utmp { + short ut_type; /* type of record */ + pid_t ut_pid; /* pid of login process */ + char ut_line[ut_linesize]; /* device name of tty \- "/dev/" */ + char ut_id[4]; /* terminal name suffix, + or inittab(5) id */ + char ut_user[ut_namesize]; /* username */ + char ut_host[ut_hostsize]; /* hostname for remote login, or + kernel version for run\-level + messages */ + struct exit_status ut_exit; /* exit status of a process + marked as dead_process; not + used by linux init(1) */ + /* the ut_session and ut_tv fields must be the same size when + compiled 32\- and 64\-bit. this allows data files and shared + memory to be shared between 32\- and 64\-bit applications. */ +#if __wordsize == 64 && defined __wordsize_compat32 + int32_t ut_session; /* session id (\fbgetsid\fp(2)), + used for windowing */ + struct { + int32_t tv_sec; /* seconds */ + int32_t tv_usec; /* microseconds */ + } ut_tv; /* time entry was made */ +#else + long ut_session; /* session id */ + struct timeval ut_tv; /* time entry was made */ +#endif + + int32_t ut_addr_v6[4]; /* internet address of remote + host; ipv4 address uses + just ut_addr_v6[0] */ + char __unused[20]; /* reserved for future use */ +}; + +/* backward compatibility hacks */ +#define ut_name ut_user +#ifndef _no_ut_time +#define ut_time ut_tv.tv_sec +#endif +#define ut_xtime ut_tv.tv_sec +#define ut_addr ut_addr_v6[0] +.ee +.in +.pp +this structure gives the name of the special file associated with the +user's terminal, the user's login name, and the time of login in the form +of +.br time (2). +string fields are terminated by a null byte (\(aq\e0\(aq) +if they are shorter than the size +of the field. +.pp +the first entries ever created result from +.br init (1) +processing +.br inittab (5). +before an entry is processed, though, +.br init (1) +cleans up utmp by setting \fiut_type\fp to \fbdead_process\fp, clearing +\fiut_user\fp, \fiut_host\fp, and \fiut_time\fp with null bytes for each +record which \fiut_type\fp is not \fbdead_process\fp or \fbrun_lvl\fp +and where no process with pid \fiut_pid\fp exists. +if no empty record +with the needed \fiut_id\fp can be found, +.br init (1) +creates a new one. +it sets \fiut_id\fp from the inittab, \fiut_pid\fp and \fiut_time\fp to the +current values, and \fiut_type\fp to \fbinit_process\fp. +.pp +.br mingetty (8) +(or +.br agetty (8)) +locates the entry by the pid, changes \fiut_type\fp to +\fblogin_process\fp, changes \fiut_time\fp, sets \fiut_line\fp, and waits +for connection to be established. +.br login (1), +after a user has been +authenticated, changes \fiut_type\fp to \fbuser_process\fp, changes +\fiut_time\fp, and sets \fiut_host\fp and \fiut_addr\fp. +depending on +.br mingetty (8) +(or +.br agetty (8)) +and +.br login (1), +records may be located by +\fiut_line\fp instead of the preferable \fiut_pid\fp. +.pp +when +.br init (1) +finds that a process has exited, it locates its utmp entry by +.ir ut_pid , +sets +.i ut_type +to +.br dead_process , +and clears +.ir ut_user , +.ir ut_host , +and +.i ut_time +with null bytes. +.pp +.br xterm (1) +and other terminal emulators directly create a +\fbuser_process\fp record and generate the \fiut_id\fp by using the +string that suffix part of the terminal name (the characters +following \fi/dev/[pt]ty\fp). +if they find a \fbdead_process\fp for this id, +they recycle it, otherwise they create a new entry. +if they can, they +will mark it as \fbdead_process\fp on exiting and it is advised that +they null \fiut_line\fp, \fiut_time\fp, \fiut_user\fp, and \fiut_host\fp +as well. +.pp +.br telnetd (8) +sets up a \fblogin_process\fp entry and leaves the rest to +.br login (1) +as usual. +after the telnet session ends, +.br telnetd (8) +cleans up utmp in the described way. +.pp +the \fiwtmp\fp file records all logins and logouts. +its format is exactly like \fiutmp\fp except that a null username +indicates a logout +on the associated terminal. +furthermore, the terminal name \fb\(ti\fp +with username \fbshutdown\fp or \fbreboot\fp indicates a system +shutdown or reboot and the pair of terminal names \fb|\fp/\fb}\fp +logs the old/new system time when +.br date (1) +changes it. +\fiwtmp\fp is maintained by +.br login (1), +.br init (1), +and some versions of +.br getty (8) +(e.g., +.br mingetty (8) +or +.br agetty (8)). +none of these programs creates the file, so if it is +removed, record-keeping is turned off. +.sh files +.i /var/run/utmp +.br +.i /var/log/wtmp +.sh conforming to +posix.1 does not specify a +.i utmp +structure, but rather one named +.ir utmpx , +with specifications for the fields +.ir ut_type , +.ir ut_pid , +.ir ut_line , +.ir ut_id , +.ir ut_user , +and +.ir ut_tv . +posix.1 does not specify the lengths of the +.i ut_line +and +.i ut_user +fields. +.pp +linux defines the +.i utmpx +structure to be the same as the +.i utmp +structure. +.ss comparison with historical systems +linux utmp entries conform neither to v7/bsd nor to system v; they are a +mix of the two. +.pp +v7/bsd has fewer fields; most importantly it lacks +\fiut_type\fp, which causes native v7/bsd-like programs to display (for +example) dead or login entries. +further, there is no configuration file +which allocates slots to sessions. +bsd does so because it lacks \fiut_id\fp fields. +.pp +in linux (as in system v), the \fiut_id\fp field of a +record will never change once it has been set, which reserves that slot +without needing a configuration file. +clearing \fiut_id\fp may result +in race conditions leading to corrupted utmp entries and potential +security holes. +clearing the abovementioned fields by filling them +with null bytes is not required by system v semantics, +but makes it possible to run +many programs which assume bsd semantics and which do not modify utmp. +linux uses the bsd conventions for line contents, as documented above. +.pp +.\" mtk: what is the referrent of "them" in the following sentence? +.\" system v only uses the type field to mark them and logs +.\" informative messages such as \fb"new time"\fp in the line field. +system v has no \fiut_host\fp or \fiut_addr_v6\fp fields. +.sh notes +unlike various other +systems, where utmp logging can be disabled by removing the file, utmp +must always exist on linux. +if you want to disable +.br who (1), +then do not make utmp world readable. +.pp +the file format is machine-dependent, so it is recommended that it be +processed only on the machine architecture where it was created. +.pp +note that on \fibiarch\fp platforms, that is, systems which can run both +32-bit and 64-bit applications (x86-64, ppc64, s390x, etc.), +\fiut_tv\fp is the same size in 32-bit mode as in 64-bit mode. +the same goes for \fiut_session\fp and \fiut_time\fp if they are present. +this allows data files and shared memory to be shared between +32-bit and 64-bit applications. +this is achieved by changing the type of +.i ut_session +to +.ir int32_t , +and that of +.i ut_tv +to a struct with two +.i int32_t +fields +.i tv_sec +and +.ir tv_usec . +since \fiut_tv\fp may not be the same as \fistruct timeval\fp, +then instead of the call: +.pp +.in +4n +.ex +gettimeofday((struct timeval *) &ut.ut_tv, null); +.ee +.in +.pp +the following method of setting this field is recommended: +.pp +.in +4n +.ex +struct utmp ut; +struct timeval tv; + +gettimeofday(&tv, null); +ut.ut_tv.tv_sec = tv.tv_sec; +ut.ut_tv.tv_usec = tv.tv_usec; +.ee +.in +.\" .pp +.\" note that the \fiutmp\fp struct from libc5 has changed in libc6. +.\" because of this, +.\" binaries using the old libc5 struct will corrupt +.\" .ir /var/run/utmp " and/or " /var/log/wtmp . +.\" .sh bugs +.\" this man page is based on the libc5 one, things may work differently now. +.sh see also +.br ac (1), +.br date (1), +.br init (1), +.br last (1), +.br login (1), +.br logname (1), +.br lslogins (1), +.br users (1), +.br utmpdump (1), +.br who (1), +.br getutent (3), +.br getutmp (3), +.br login (3), +.br logout (3), +.br logwtmp (3), +.br updwtmp (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2005 robert love +.\" and copyright, 2006 michael kerrisk +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" 2005-07-19 robert love - initial version +.\" 2006-02-07 mtk, various changes +.\" +.th inotify_add_watch 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +inotify_add_watch \- add a watch to an initialized inotify instance +.sh synopsis +.nf +.b #include +.pp +.bi "int inotify_add_watch(int " fd ", const char *" pathname ", uint32_t " mask ); +.fi +.sh description +.br inotify_add_watch () +adds a new watch, or modifies an existing watch, +for the file whose location is specified in +.ir pathname ; +the caller must have read permission for this file. +the +.i fd +argument is a file descriptor referring to the +inotify instance whose watch list is to be modified. +the events to be monitored for +.i pathname +are specified in the +.i mask +bit-mask argument. +see +.br inotify (7) +for a description of the bits that can be set in +.ir mask . +.pp +a successful call to +.br inotify_add_watch () +returns a unique watch descriptor for this inotify instance, +for the filesystem object (inode) that corresponds to +.ir pathname . +if the filesystem object +was not previously being watched by this inotify instance, +then the watch descriptor is newly allocated. +if the filesystem object was already being watched +(perhaps via a different link to the same object), then the descriptor +for the existing watch is returned. +.pp +the watch descriptor is returned by later +.br read (2)s +from the inotify file descriptor. +these reads fetch +.i inotify_event +structures (see +.br inotify (7)) +indicating filesystem events; +the watch descriptor inside this structure identifies +the object for which the event occurred. +.sh return value +on success, +.br inotify_add_watch () +returns a watch descriptor (a nonnegative integer). +on error, \-1 is returned and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eacces +read access to the given file is not permitted. +.tp +.b ebadf +the given file descriptor is not valid. +.tp +.b eexist +.i mask +contains +.b in_mask_create +and +.i pathname +refers to a file already being watched by the same +.ir fd . +.tp +.b efault +.i pathname +points outside of the process's accessible address space. +.tp +.b einval +the given event mask contains no valid events; or +.i mask +contains both +.b in_mask_add +and +.br in_mask_create ; +or +.i fd +is not an inotify file descriptor. +.tp +.b enametoolong +.i pathname +is too long. +.tp +.b enoent +a directory component in +.i pathname +does not exist or is a dangling symbolic link. +.tp +.b enomem +insufficient kernel memory was available. +.tp +.b enospc +the user limit on the total number of inotify watches was reached or the +kernel failed to allocate a needed resource. +.tp +.b enotdir +.i mask +contains +.b in_onlydir +and +.i pathname +is not a directory. +.sh versions +inotify was merged into the 2.6.13 linux kernel. +.sh conforming to +this system call is linux-specific. +.sh examples +see +.br inotify (7). +.sh see also +.br inotify_init (2), +.br inotify_rm_watch (2), +.br inotify (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" and copyright 2015 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sun jul 25 10:41:09 1993 by rik faith (faith@cs.unc.edu) +.th memcpy 3 2021-03-22 "" "linux programmer's manual" +.sh name +memcpy \- copy memory area +.sh synopsis +.nf +.b #include +.pp +.bi "void *memcpy(void *restrict " dest ", const void *restrict " src \ +", size_t " n ); +.fi +.sh description +the +.br memcpy () +function copies \fin\fp bytes from memory area +\fisrc\fp to memory area \fidest\fp. +the memory areas must not overlap. +use +.br memmove (3) +if the memory areas do overlap. +.sh return value +the +.br memcpy () +function returns a pointer to \fidest\fp. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br memcpy () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c89, c99, svr4, 4.3bsd. +.sh notes +failure to observe the requirement that the memory areas +do not overlap has been the source of significant bugs. +(posix and the c standards are explicit that employing +.br memcpy () +with overlapping areas produces undefined behavior.) +most notably, in glibc 2.13 +.\" glibc commit 6fb8cbcb58a29fff73eb2101b34caa19a7f88eba +a performance optimization of +.br memcpy () +on some platforms (including x86-64) included changing the order +.\" from forward copying to backward copying +in which bytes were copied from +.i src +to +.ir dest . +.pp +this change revealed breakages in a number of applications that performed +copying with overlapping areas. +.\" adobe flash player was the highest profile example: +.\" https://bugzilla.redhat.com/show_bug.cgi?id=638477 +.\" reported: 2010-09-29 02:35 edt by jchuynh +.\" bug 638477 - strange sound on mp3 flash website +.\" +.\" https://sourceware.org/bugzilla/show_bug.cgi?id=12518 +.\" bug 12518 - memcpy acts randomly (and differently) with overlapping areas +.\" reported: 2011-02-25 02:26 utc by linus torvalds +.\" +under the previous implementation, +the order in which the bytes were copied had fortuitously hidden the bug, +which was revealed when the copying order was reversed. +in glibc 2.14, +.\" glibc commit 0354e355014b7bfda32622e0255399d859862fcd +a versioned symbol was added so that old binaries +(i.e., those linked against glibc versions earlier than 2.14) +employed a +.br memcpy () +implementation that safely handles the overlapping buffers case +(by providing an "older" +.br memcpy () +implementation that was aliased to +.br memmove (3)). +.sh see also +.br bcopy (3), +.br bstring (3), +.br memccpy (3), +.br memmove (3), +.br mempcpy (3), +.br strcpy (3), +.br strncpy (3), +.br wmemcpy (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/nextup.3 + +.\" copyright (c) tom bjorkholm & markus kuhn, 1996 +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" 1996-04-01 tom bjorkholm +.\" first version written +.\" 1996-04-10 markus kuhn +.\" revision +.\" modified 2004-05-27 by michael kerrisk +.\" +.th sched_setparam 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +sched_setparam, sched_getparam \- set and get scheduling parameters +.sh synopsis +.nf +.b #include +.pp +.bi "int sched_setparam(pid_t " pid ", const struct sched_param *" param ); +.bi "int sched_getparam(pid_t " pid ", struct sched_param *" param ); +.pp +\fbstruct sched_param { + ... + int \fisched_priority\fb; + ... +}; +.fi +.sh description +.br sched_setparam () +sets the scheduling parameters associated with the scheduling policy +for the thread whose thread id is specified in \fipid\fp. +if \fipid\fp is zero, then +the parameters of the calling thread are set. +the interpretation of +the argument \fiparam\fp depends on the scheduling +policy of the thread identified by +.ir pid . +see +.br sched (7) +for a description of the scheduling policies supported under linux. +.pp +.br sched_getparam () +retrieves the scheduling parameters for the +thread identified by \fipid\fp. +if \fipid\fp is zero, then the parameters +of the calling thread are retrieved. +.pp +.br sched_setparam () +checks the validity of \fiparam\fp for the scheduling policy of the +thread. +the value \fiparam\->sched_priority\fp must lie within the +range given by +.br sched_get_priority_min (2) +and +.br sched_get_priority_max (2). +.pp +for a discussion of the privileges and resource limits related to +scheduling priority and policy, see +.br sched (7). +.pp +posix systems on which +.br sched_setparam () +and +.br sched_getparam () +are available define +.b _posix_priority_scheduling +in \fi\fp. +.sh return value +on success, +.br sched_setparam () +and +.br sched_getparam () +return 0. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b einval +invalid arguments: +.i param +is null or +.i pid +is negative +.tp +.b einval +.rb ( sched_setparam ()) +the argument \fiparam\fp does not make sense for the current +scheduling policy. +.tp +.b eperm +.rb ( sched_setparam ()) +the caller does not have appropriate privileges +(linux: does not have the +.b cap_sys_nice +capability). +.tp +.b esrch +the thread whose id is \fipid\fp could not be found. +.sh conforming to +posix.1-2001, posix.1-2008. +.sh see also +.ad l +.nh +.br getpriority (2), +.br gettid (2), +.br nice (2), +.br sched_get_priority_max (2), +.br sched_get_priority_min (2), +.br sched_getaffinity (2), +.br sched_getscheduler (2), +.br sched_setaffinity (2), +.br sched_setattr (2), +.br sched_setscheduler (2), +.br setpriority (2), +.br capabilities (7), +.br sched (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/getgrnam.3 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sat jul 24 18:55:27 1993 by rik faith (faith@cs.unc.edu) +.th memcmp 3 2021-03-22 "" "linux programmer's manual" +.sh name +memcmp \- compare memory areas +.sh synopsis +.nf +.b #include +.pp +.bi "int memcmp(const void *" s1 ", const void *" s2 ", size_t " n ); +.fi +.sh description +the +.br memcmp () +function compares the first \fin\fp bytes (each interpreted as +.ir "unsigned char" ) +of the memory areas \fis1\fp and \fis2\fp. +.sh return value +the +.br memcmp () +function returns an integer less than, equal to, or +greater than zero if the first \fin\fp bytes of \fis1\fp is found, +respectively, to be less than, to match, or be greater than the first +\fin\fp bytes of \fis2\fp. +.pp +for a nonzero return value, the sign is determined by the sign of +the difference between the first pair of bytes (interpreted as +.ir "unsigned char" ) +that differ in +.i s1 +and +.ir s2 . +.pp +if +.i n +is zero, the return value is zero. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br memcmp () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c89, c99, svr4, 4.3bsd. +.sh notes +do not use +.br memcmp () +to compare security critical data, such as cryptographic secrets, +because the required cpu time depends on the number of equal bytes. +instead, a function that performs comparisons in constant time is required. +some operating systems provide such a function (e.g., netbsd's +.br consttime_memequal ()), +but no such function is specified in posix. +on linux, it may be necessary to implement such a function oneself. +.sh see also +.br bcmp (3), +.br bstring (3), +.br strcasecmp (3), +.br strcmp (3), +.br strcoll (3), +.br strncasecmp (3), +.br strncmp (3), +.br wmemcmp (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1992 drew eckhardt (drew@cs.colorado.edu), march 28, 1992 +.\" and copyright (c) 1998 andries brouwer (aeb@cwi.nl) +.\" and copyright (c) 2006, 2007, 2008, 2014 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified by michael haardt +.\" modified 1993-07-21 by rik faith +.\" modified 1996-07-09 by andries brouwer +.\" modified 1996-11-06 by eric s. raymond +.\" modified 1997-05-18 by michael haardt +.\" modified 2004-06-23 by michael kerrisk +.\" 2007-07-08, mtk, added an example program; updated synopsis +.\" 2008-05-08, mtk, describe rules governing ownership of new files +.\" (bsdgroups versus sysvgroups, and the effect of the parent +.\" directory's set-group-id mode bit). +.\" +.th chown 2 2021-08-27 "linux" "linux programmer's manual" +.sh name +chown, fchown, lchown, fchownat \- change ownership of a file +.sh synopsis +.nf +.b #include +.pp +.bi "int chown(const char *" pathname ", uid_t " owner ", gid_t " group ); +.bi "int fchown(int " fd ", uid_t " owner ", gid_t " group ); +.bi "int lchown(const char *" pathname ", uid_t " owner ", gid_t " group ); +.pp +.br "#include " "/* definition of at_* constants */" +.b #include +.pp +.bi "int fchownat(int " dirfd ", const char *" pathname , +.bi " uid_t " owner ", gid_t " group ", int " flags ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br fchown (), +.br lchown (): +.nf + /* since glibc 2.12: */ _posix_c_source >= 200809l + || _xopen_source >= 500 +.\" || _xopen_source && _xopen_source_extended + || /* glibc <= 2.19: */ _bsd_source +.fi +.pp +.br fchownat (): +.nf + since glibc 2.10: + _posix_c_source >= 200809l + before glibc 2.10: + _atfile_source +.fi +.sh description +these system calls change the owner and group of a file. +the +.br chown (), +.br fchown (), +and +.br lchown () +system calls differ only in how the file is specified: +.ip * 2 +.br chown () +changes the ownership of the file specified by +.ir pathname , +which is dereferenced if it is a symbolic link. +.ip * +.br fchown () +changes the ownership of the file referred to by the open file descriptor +.ir fd . +.ip * +.br lchown () +is like +.br chown (), +but does not dereference symbolic links. +.pp +only a privileged process (linux: one with the +.b cap_chown +capability) may change the owner of a file. +the owner of a file may change the group of the file +to any group of which that owner is a member. +a privileged process (linux: with +.br cap_chown ) +may change the group arbitrarily. +.pp +if the +.i owner +or +.i group +is specified as \-1, then that id is not changed. +.pp +when the owner or group of an executable file is +changed by an unprivileged user, the +.b s_isuid +and +.b s_isgid +mode bits are cleared. +posix does not specify whether +this also should happen when root does the +.br chown (); +the linux behavior depends on the kernel version, +and since linux 2.2.13, root is treated like other users. +.\" in linux 2.0 kernels, superuser was like everyone else +.\" in 2.2, up to 2.2.12, these bits were not cleared for superuser. +.\" since 2.2.13, superuser is once more like everyone else. +in case of a non-group-executable file (i.e., one for which the +.b s_ixgrp +bit is not set) the +.b s_isgid +bit indicates mandatory locking, and is not cleared by a +.br chown (). +.pp +when the owner or group of an executable file is changed (by any user), +all capability sets for the file are cleared. +.\" +.ss fchownat() +the +.br fchownat () +system call operates in exactly the same way as +.br chown (), +except for the differences described here. +.pp +if the pathname given in +.i pathname +is relative, then it is interpreted relative to the directory +referred to by the file descriptor +.i dirfd +(rather than relative to the current working directory of +the calling process, as is done by +.br chown () +for a relative pathname). +.pp +if +.i pathname +is relative and +.i dirfd +is the special value +.br at_fdcwd , +then +.i pathname +is interpreted relative to the current working +directory of the calling process (like +.br chown ()). +.pp +if +.i pathname +is absolute, then +.i dirfd +is ignored. +.pp +the +.i flags +argument is a bit mask created by oring together +0 or more of the following values; +.tp +.br at_empty_path " (since linux 2.6.39)" +.\" commit 65cfc6722361570bfe255698d9cd4dccaf47570d +if +.i pathname +is an empty string, operate on the file referred to by +.ir dirfd +(which may have been obtained using the +.br open (2) +.b o_path +flag). +in this case, +.i dirfd +can refer to any type of file, not just a directory. +if +.i dirfd +is +.br at_fdcwd , +the call operates on the current working directory. +this flag is linux-specific; define +.b _gnu_source +.\" before glibc 2.16, defining _atfile_source sufficed +to obtain its definition. +.tp +.b at_symlink_nofollow +if +.i pathname +is a symbolic link, do not dereference it: +instead operate on the link itself, like +.br lchown (). +(by default, +.br fchownat () +dereferences symbolic links, like +.br chown ().) +.pp +see +.br openat (2) +for an explanation of the need for +.br fchownat (). +.sh return value +on success, zero is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +depending on the filesystem, +errors other than those listed below can be returned. +.pp +the more general errors for +.br chown () +are listed below. +.tp +.b eacces +search permission is denied on a component of the path prefix. +(see also +.br path_resolution (7).) +.tp +.b ebadf +.rb ( fchown ()) +.i fd +is not a valid open file descriptor. +.tp +.b ebadf +.rb ( fchownat ()) +.i pathname +is relative but +.i dirfd +is neither +.b at_fdcwd +nor a valid file descriptor. +.tp +.b efault +.i pathname +points outside your accessible address space. +.tp +.b einval +.rb ( fchownat ()) +invalid flag specified in +.ir flags . +.tp +.b eio +.rb ( fchown ()) +a low-level i/o error occurred while modifying the inode. +.tp +.b eloop +too many symbolic links were encountered in resolving +.ir pathname . +.tp +.b enametoolong +.i pathname +is too long. +.tp +.b enoent +the file does not exist. +.tp +.b enomem +insufficient kernel memory was available. +.tp +.b enotdir +a component of the path prefix is not a directory. +.tp +.b enotdir +.rb ( fchownat ()) +.i pathname +is relative and +.i dirfd +is a file descriptor referring to a file other than a directory. +.tp +.b eperm +the calling process did not have the required permissions +(see above) to change owner and/or group. +.tp +.b eperm +the file is marked immutable or append-only. +(see +.br ioctl_iflags (2).) +.tp +.b erofs +the named file resides on a read-only filesystem. +.sh versions +.br fchownat () +was added to linux in kernel 2.6.16; +library support was added to glibc in version 2.4. +.sh conforming to +.br chown (), +.br fchown (), +.br lchown (): +4.4bsd, svr4, posix.1-2001, posix.1-2008. +.pp +the 4.4bsd version can be +used only by the superuser (that is, ordinary users cannot give away files). +.\" chown(): +.\" svr4 documents einval, eintr, enolink and emultihop returns, but no +.\" enomem. posix.1 does not document enomem or eloop error conditions. +.\" fchown(): +.\" svr4 documents additional einval, eio, eintr, and enolink +.\" error conditions. +.pp +.br fchownat (): +posix.1-2008. +.sh notes +.ss ownership of new files +when a new file is created (by, for example, +.br open (2) +or +.br mkdir (2)), +its owner is made the same as the filesystem user id of the +creating process. +the group of the file depends on a range of factors, +including the type of filesystem, +the options used to mount the filesystem, +and whether or not the set-group-id mode bit is enabled +on the parent directory. +if the filesystem supports the +.b "\-o\ grpid" +(or, synonymously +.br "\-o\ bsdgroups" ) +and +.b "\-o\ nogrpid" +(or, synonymously +.br "\-o\ sysvgroups" ) +.br mount (8) +options, then the rules are as follows: +.ip * 2 +if the filesystem is mounted with +.br "\-o\ grpid" , +then the group of a new file is made +the same as that of the parent directory. +.ip * +if the filesystem is mounted with +.br "\-o\ nogrpid" +and the set-group-id bit is disabled on the parent directory, +then the group of a new file is made the same as the +process's filesystem gid. +.ip * +if the filesystem is mounted with +.br "\-o\ nogrpid" +and the set-group-id bit is enabled on the parent directory, +then the group of a new file is made +the same as that of the parent directory. +.pp +as at linux 4.12, +the +.br "\-o\ grpid" +and +.br "\-o\ nogrpid" +mount options are supported by ext2, ext3, ext4, and xfs. +filesystems that don't support these mount options follow the +.br "\-o\ nogrpid" +rules. +.ss glibc notes +on older kernels where +.br fchownat () +is unavailable, the glibc wrapper function falls back to the use of +.br chown () +and +.br lchown (). +when +.i pathname +is a relative pathname, +glibc constructs a pathname based on the symbolic link in +.ir /proc/self/fd +that corresponds to the +.ir dirfd +argument. +.ss nfs +the +.br chown () +semantics are deliberately violated on nfs filesystems +which have uid mapping enabled. +additionally, the semantics of all system +calls which access the file contents are violated, because +.br chown () +may cause immediate access revocation on already open files. +client side +caching may lead to a delay between the time where ownership have +been changed to allow access for a user and the time where the file can +actually be accessed by the user on other clients. +.ss historical details +the original linux +.br chown (), +.br fchown (), +and +.br lchown () +system calls supported only 16-bit user and group ids. +subsequently, linux 2.4 added +.br chown32 (), +.br fchown32 (), +and +.br lchown32 (), +supporting 32-bit ids. +the glibc +.br chown (), +.br fchown (), +and +.br lchown () +wrapper functions transparently deal with the variations across kernel versions. +.pp +in versions of linux prior to 2.1.81 (and distinct from 2.1.46), +.br chown () +did not follow symbolic links. +since linux 2.1.81, +.br chown () +does follow symbolic links, and there is a new system call +.br lchown () +that does not follow symbolic links. +since linux 2.1.86, this new call (that has the same semantics +as the old +.br chown ()) +has got the same syscall number, and +.br chown () +got the newly introduced number. +.sh examples +the following program changes the ownership of the file named in +its second command-line argument to the value specified in its +first command-line argument. +the new owner can be specified either as a numeric user id, +or as a username (which is converted to a user id by using +.br getpwnam (3) +to perform a lookup in the system password file). +.ss program source +.ex +#include +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + uid_t uid; + struct passwd *pwd; + char *endptr; + + if (argc != 3 || argv[1][0] == \(aq\e0\(aq) { + fprintf(stderr, "%s \en", argv[0]); + exit(exit_failure); + } + + uid = strtol(argv[1], &endptr, 10); /* allow a numeric string */ + + if (*endptr != \(aq\e0\(aq) { /* was not pure numeric string */ + pwd = getpwnam(argv[1]); /* try getting uid for username */ + if (pwd == null) { + perror("getpwnam"); + exit(exit_failure); + } + + uid = pwd\->pw_uid; + } + + if (chown(argv[2], uid, \-1) == \-1) { + perror("chown"); + exit(exit_failure); + } + + exit(exit_success); +} +.ee +.sh see also +.br chgrp (1), +.br chown (1), +.br chmod (2), +.br flock (2), +.br path_resolution (7), +.br symlink (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2009 intel corporation, author andi kleen +.\" some sentences copied from comments in arch/x86/kernel/msr.c +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th msr 4 2021-03-22 "linux" "linux programmer's manual" +.sh name +msr \- x86 cpu msr access device +.sh description +.i /dev/cpu/cpunum/msr +provides an interface to read and write the model-specific +registers (msrs) of an x86 cpu. +.i cpunum +is the number of the cpu to access as listed in +.ir /proc/cpuinfo . +.pp +the register access is done by opening the file and seeking +to the msr number as offset in the file, and then +reading or writing in chunks of 8 bytes. +an i/o transfer of more than 8 bytes means multiple reads or writes +of the same register. +.pp +this file is protected so that it can be read and written only by the user +.ir root , +or members of the group +.ir root . +.sh notes +the +.i msr +driver is not auto-loaded. +on modular kernels you might need to use the following command +to load it explicitly before use: +.pp +.in +4n +.ex +$ modprobe msr +.ee +.in +.sh see also +intel corporation intel 64 and ia-32 architectures +software developer's manual volume 3b appendix b, +for an overview of the intel cpu msrs. +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/fopen.3 + +.so man3/rpc.3 + +.\" copyright 1993 giorgio ciucci +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" added correction due to nick duffek , aeb, 960426 +.\" modified wed nov 6 04:00:31 1996 by eric s. raymond +.\" modified, 8 jan 2003, michael kerrisk, +.\" removed eidrm from errors - that can't happen... +.\" modified, 27 may 2004, michael kerrisk +.\" added notes on capability requirements +.\" modified, 11 nov 2004, michael kerrisk +.\" language and formatting clean-ups +.\" added notes on /proc files +.\" +.th msgget 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +msgget \- get a system v message queue identifier +.sh synopsis +.nf +.b #include +.pp +.bi "int msgget(key_t " key ", int " msgflg ); +.fi +.sh description +the +.br msgget () +system call returns the system\ v message queue identifier associated +with the value of the +.i key +argument. +it may be used either to obtain the identifier of a previously created +message queue (when +.i msgflg +is zero and +.i key +does not have the value +.br ipc_private ), +or to create a new set. +.pp +a new message queue is created if +.i key +has the value +.b ipc_private +or +.i key +isn't +.br ipc_private , +no message queue with the given key +.i key +exists, and +.b ipc_creat +is specified in +.ir msgflg . +.pp +if +.i msgflg +specifies both +.b ipc_creat +and +.b ipc_excl +and a message queue already exists for +.ir key , +then +.br msgget () +fails with +.i errno +set to +.br eexist . +(this is analogous to the effect of the combination +.b o_creat | o_excl +for +.br open (2).) +.pp +upon creation, the least significant bits of the argument +.i msgflg +define the permissions of the message queue. +these permission bits have the same format and semantics +as the permissions specified for the +.i mode +argument of +.br open (2). +(the execute permissions are not used.) +.pp +if a new message queue is created, +then its associated data structure +.i msqid_ds +(see +.br msgctl (2)) +is initialized as follows: +.ip \(bu 2 +.i msg_perm.cuid +and +.i msg_perm.uid +are set to the effective user id of the calling process. +.ip \(bu +.i msg_perm.cgid +and +.i msg_perm.gid +are set to the effective group id of the calling process. +.ip \(bu +the least significant 9 bits of +.i msg_perm.mode +are set to the least significant 9 bits of +.ir msgflg . +.ip \(bu +.ir msg_qnum , +.ir msg_lspid , +.ir msg_lrpid , +.ir msg_stime , +and +.i msg_rtime +are set to 0. +.ip \(bu +.i msg_ctime +is set to the current time. +.ip \(bu +.i msg_qbytes +is set to the system limit +.br msgmnb . +.pp +if the message queue already exists the permissions are +verified, and a check is made to see if it is marked for +destruction. +.sh return value +on success, +.br msgget () +returns the message queue identifier (a nonnegative integer). +on failure, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eacces +a message queue exists for +.ir key , +but the calling process does not have permission to access the queue, +and does not have the +.b cap_ipc_owner +capability in the user namespace that governs its ipc namespace. +.tp +.b eexist +.b ipc_creat +and +.br ipc_excl +were specified in +.ir msgflg , +but a message queue already exists for +.ir key . +.tp +.b enoent +no message queue exists for +.i key +and +.i msgflg +did not specify +.br ipc_creat . +.tp +.b enomem +a message queue has to be created but the system does not have enough +memory for the new data structure. +.tp +.b enospc +a message queue has to be created but the system limit for the maximum +number of message queues +.rb ( msgmni ) +would be exceeded. +.sh conforming to +posix.1-2001, posix.1-2008, svr4. +.sh notes +.b ipc_private +isn't a flag field but a +.i key_t +type. +if this special value is used for +.ir key , +the system call ignores everything but the least significant 9 bits of +.i msgflg +and creates a new message queue (on success). +.pp +the following is a system limit on message queue resources affecting a +.br msgget () +call: +.tp +.b msgmni +system-wide limit on the number of message queues. +before linux 3.19, +.\" commit 0050ee059f7fc86b1df2527aaa14ed5dc72f9973 +the default value for this limit was calculated using a formula +based on available system memory. +since linux 3.19, the default value is 32,000. +on linux, this limit can be read and modified via +.ir /proc/sys/kernel/msgmni . +.ss linux notes +until version 2.3.20, linux would return +.b eidrm +for a +.br msgget () +on a message queue scheduled for deletion. +.sh bugs +the name choice +.b ipc_private +was perhaps unfortunate, +.b ipc_new +would more clearly show its function. +.sh see also +.br msgctl (2), +.br msgrcv (2), +.br msgsnd (2), +.br ftok (3), +.br capabilities (7), +.br mq_overview (7), +.br sysvipc (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2014, red hat, inc +.\" written by alexandre oliva +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.th attributes 7 2021-03-22 "linux" "linux programmer's manual" +.sh name +attributes \- posix safety concepts +.sh description +.\" +.\" +.ir note : +the text of this man page is based on the material taken from +the "posix safety concepts" section of the gnu c library manual. +further details on the topics described here can be found in that +manual. +.pp +various function manual pages include a section attributes +that describes the safety of calling the function in various contexts. +this section annotates functions with the following safety markings: +.tp +.i mt-safe +.i mt-safe +or +thread-safe functions are safe to call in the presence +of other threads. +mt, in mt-safe, stands for multi thread. +.ip +being mt-safe does not imply a function is atomic, nor that it uses any +of the memory synchronization mechanisms posix exposes to users. +it is even possible that calling mt-safe functions in sequence +does not yield an mt-safe combination. +for example, having a thread call two mt-safe +functions one right after the other does not guarantee behavior +equivalent to atomic execution of a combination of both functions, +since concurrent calls in other threads may interfere in a destructive way. +.ip +whole-program optimizations that could inline functions across library +interfaces may expose unsafe reordering, and so performing inlining +across the gnu c library interface is not recommended. +the documented +mt-safety status is not guaranteed under whole-program optimization. +however, functions defined in user-visible headers are designed to be +safe for inlining. +.\" .tp +.\" .i as-safe +.\" .i as-safe +.\" or async-signal-safe functions are safe to call from +.\" asynchronous signal handlers. +.\" as, in as-safe, stands for asynchronous signal. +.\" +.\" many functions that are as-safe may set +.\" .ir errno , +.\" or modify the floating-point environment, +.\" because their doing so does not make them +.\" unsuitable for use in signal handlers. +.\" however, programs could misbehave should asynchronous signal handlers +.\" modify this thread-local state, +.\" and the signal handling machinery cannot be counted on to +.\" preserve it. +.\" therefore, signal handlers that call functions that may set +.\" .i errno +.\" or modify the floating-point environment +.\" .i must +.\" save their original values, and restore them before returning. +.\" .tp +.\" .i ac-safe +.\" .i ac-safe +.\" or async-cancel-safe functions are safe to call when +.\" asynchronous cancellation is enabled. +.\" ac in ac-safe stands for asynchronous cancellation. +.\" +.\" the posix standard defines only three functions to be ac-safe, namely +.\" .br pthread_cancel (3), +.\" .br pthread_setcancelstate (3), +.\" and +.\" .br pthread_setcanceltype (3). +.\" at present the gnu c library provides no +.\" guarantees beyond these three functions, +.\" but does document which functions are presently ac-safe. +.\" this documentation is provided for use +.\" by the gnu c library developers. +.\" +.\" just like signal handlers, cancellation cleanup routines must configure +.\" the floating point environment they require. +.\" the routines cannot assume a floating point environment, +.\" particularly when asynchronous cancellation is enabled. +.\" if the configuration of the floating point +.\" environment cannot be performed atomically then it is also possible that +.\" the environment encountered is internally inconsistent. +.tp +.ir mt-unsafe \" ", " as-unsafe ", " ac-unsafe +.ir mt-unsafe \" ", " as-unsafe ", " ac-unsafe +functions are not safe to call in a multithreaded programs. +.\" functions are not +.\" safe to call within the safety contexts described above. +.\" calling them +.\" within such contexts invokes undefined behavior. +.\" +.\" functions not explicitly documented as safe in a safety context should +.\" be regarded as unsafe. +.\" .tp +.\" .i preliminary +.\" .i preliminary +.\" safety properties are documented, indicating these +.\" properties may +.\" .i not +.\" be counted on in future releases of +.\" the gnu c library. +.\" +.\" such preliminary properties are the result of an assessment of the +.\" properties of our current implementation, +.\" rather than of what is mandated and permitted +.\" by current and future standards. +.\" +.\" although we strive to abide by the standards, in some cases our +.\" implementation is safe even when the standard does not demand safety, +.\" and in other cases our implementation does not meet the standard safety +.\" requirements. +.\" the latter are most likely bugs; the former, when marked +.\" as +.\" .ir preliminary , +.\" should not be counted on: future standards may +.\" require changes that are not compatible with the additional safety +.\" properties afforded by the current implementation. +.\" +.\" furthermore, +.\" the posix standard does not offer a detailed definition of safety. +.\" we assume that, by "safe to call", posix means that, +.\" as long as the program does not invoke undefined behavior, +.\" the "safe to call" function behaves as specified, +.\" and does not cause other functions to deviate from their specified behavior. +.\" we have chosen to use its loose +.\" definitions of safety, not because they are the best definitions to use, +.\" but because choosing them harmonizes this manual with posix. +.\" +.\" please keep in mind that these are preliminary definitions and annotations, +.\" and certain aspects of the definitions are still under +.\" discussion and might be subject to clarification or change. +.\" +.\" over time, +.\" we envision evolving the preliminary safety notes into stable commitments, +.\" as stable as those of our interfaces. +.\" as we do, we will remove the +.\" .i preliminary +.\" keyword from safety notes. +.\" as long as the keyword remains, however, +.\" they are not to be regarded as a promise of future behavior. +.pp +other keywords that appear in safety notes are defined in subsequent sections. +.\" +.\" +.\" .ss unsafe features +.\" functions that are unsafe to call in certain contexts are annotated with +.\" keywords that document their features that make them unsafe to call. +.\" as-unsafe features in this section indicate the functions are never safe +.\" to call when asynchronous signals are enabled. +.\" ac-unsafe features +.\" indicate they are never safe to call when asynchronous cancellation is +.\" .\" enabled. +.\" there are no mt-unsafe marks in this section. +.\" .tp +.\" .\" .i code +.\" functions marked with +.\" .i lock +.\" as an as-unsafe feature may be +.\" .\" interrupted by a signal while holding a non-recursive lock. +.\" if the signal handler calls another such function that takes the same lock, +.\" the result is a deadlock. +.\" +.\" functions annotated with +.\" .i lock +.\" as an ac-unsafe feature may, if canceled asynchronously, +.\" fail to release a lock that would have been released if their execution +.\" had not been interrupted by asynchronous thread cancellation. +.\" once a lock is left taken, +.\" attempts to take that lock will block indefinitely. +.\" .tp +.\" .i corrupt +.\" functions marked with +.\" .\" .i corrupt +.\" as an as-unsafe feature may corrupt +.\" data structures and misbehave when they interrupt, +.\" or are interrupted by, another such function. +.\" unlike functions marked with +.\" .ir lock , +.\" these take recursive locks to avoid mt-safety problems, +.\" but this is not enough to stop a signal handler from observing +.\" a partially-updated data structure. +.\" further corruption may arise from the interrupted function's +.\" failure to notice updates made by signal handlers. +.\" +.\" functions marked with +.\" .i corrupt +.\" as an ac-unsafe feature may leave +.\" data structures in a corrupt, partially updated state. +.\" subsequent uses of the data structure may misbehave. +.\" +.\" .\" a special case, probably not worth documenting separately, involves +.\" .\" reallocing, or even freeing pointers. any case involving free could +.\" .\" be easily turned into an ac-safe leak by resetting the pointer before +.\" .\" releasing it; i don't think we have any case that calls for this sort +.\" .\" of fixing. fixing the realloc cases would require a new interface: +.\" .\" instead of @code{ptr=realloc(ptr,size)} we'd have to introduce +.\" .\" @code{acsafe_realloc(&ptr,size)} that would modify ptr before +.\" .\" releasing the old memory. the ac-unsafe realloc could be implemented +.\" .\" in terms of an internal interface with this semantics (say +.\" .\" __acsafe_realloc), but since realloc can be overridden, the function +.\" .\" we call to implement realloc should not be this internal interface, +.\" .\" but another internal interface that calls __acsafe_realloc if realloc +.\" .\" was not overridden, and calls the overridden realloc with async +.\" .\" cancel disabled. --lxoliva +.\" .tp +.\" .i heap +.\" functions marked with +.\" .i heap +.\" may call heap memory management functions from the +.\" .br malloc (3)/ free (3) +.\" family of functions and are only as safe as those functions. +.\" this note is thus equivalent to: +.\" +.\" | as-unsafe lock | ac-unsafe lock fd mem | +.\" .\" @sampsafety{@asunsafe{@asulock{}}@acunsafe{@aculock{} @acsfd{} @acsmem{}}} +.\" .\" +.\" .\" check for cases that should have used plugin instead of or in +.\" .\" addition to this. then, after rechecking gettext, adjust i18n if +.\" .\" needed. +.\" .tp +.\" .i dlopen +.\" functions marked with +.\" .i dlopen +.\" use the dynamic loader to load +.\" shared libraries into the current execution image. +.\" this involves opening files, mapping them into memory, +.\" allocating additional memory, resolving symbols, +.\" applying relocations and more, +.\" all of this while holding internal dynamic loader locks. +.\" +.\" the locks are enough for these functions to be as-unsafe and ac-unsafe, +.\" but other issues may arise. +.\" at present this is a placeholder for all +.\" potential safety issues raised by +.\" .br dlopen (3). +.\" +.\" .\" dlopen runs init and fini sections of the module; does this mean +.\" .\" dlopen always implies plugin? +.\" .tp +.\" .i plugin +.\" functions annotated with +.\" .i plugin +.\" may run code from plugins that +.\" may be external to the gnu c library. +.\" such plugin functions are assumed to be +.\" mt-safe, as-unsafe and ac-unsafe. +.\" examples of such plugins are stack unwinding libraries, +.\" name service switch (nss) and character set conversion (iconv) back-ends. +.\" +.\" although the plugins mentioned as examples are all brought in by means +.\" of dlopen, the +.\" .i plugin +.\" keyword does not imply any direct +.\" involvement of the dynamic loader or the +.\" .i libdl +.\" interfaces, +.\" those are covered by +.\" .ir dlopen . +.\" for example, if one function loads a module and finds the addresses +.\" of some of its functions, +.\" while another just calls those already-resolved functions, +.\" the former will be marked with +.\" .ir dlopen , +.\" whereas the latter will get the +.\" .ir plugin . +.\" when a single function takes all of these actions, then it gets both marks. +.\" .tp +.\" .i i18n +.\" functions marked with +.\" .i i18n +.\" may call internationalization +.\" functions of the +.\" .br gettext (3) +.\" family and will be only as safe as those +.\" functions. +.\" this note is thus equivalent to: +.\" +.\" | mt-safe env | as-unsafe corrupt heap dlopen | ac-unsafe corrupt | +.\" +.\" .\" @sampsafety{@mtsafe{@mtsenv{}}@asunsafe{@asucorrupt{} @ascuheap{} @ascudlopen{}}@acunsafe{@acucorrupt{}}} +.\" .tp +.\" .i timer +.\" functions marked with +.\" .i timer +.\" use the +.\" .br alarm (3) +.\" function or +.\" similar to set a time-out for a system call or a long-running operation. +.\" in a multi-threaded program, there is a risk that the time-out signal +.\" will be delivered to a different thread, +.\" thus failing to interrupt the intended thread. +.\" besides being mt-unsafe, such functions are always +.\" as-unsafe, because calling them in signal handlers may interfere with +.\" timers set in the interrupted code, and ac-unsafe, +.\" because there is no safe way to guarantee an earlier timer +.\" will be reset in case of asynchronous cancellation. +.\" +.\" +.ss conditionally safe features +for some features that make functions unsafe to call in certain contexts, +there are known ways to avoid the safety problem other than +refraining from calling the function altogether. +the keywords that follow refer to such features, +and each of their definitions indicates +how the whole program needs to be constrained in order to remove the +safety problem indicated by the keyword. +only when all the reasons that +make a function unsafe are observed and addressed, +by applying the documented constraints, +does the function become safe to call in a context. +.tp +.i init +functions marked with +.i init +as an mt-unsafe feature perform +mt-unsafe initialization when they are first called. +.ip +calling such a function at least once in single-threaded mode removes +this specific cause for the function to be regarded as mt-unsafe. +if no other cause for that remains, +the function can then be safely called after other threads are started. +.\" +.\" functions marked with +.\" .i init +.\" as an as-unsafe or ac-unsafe feature use the gnu c library internal +.\" .i libc_once +.\" machinery or similar to initialize internal data structures. +.\" +.\" if a signal handler interrupts such an initializer, +.\" and calls any function that also performs +.\" .i libc_once +.\" initialization, it will deadlock if the thread library has been loaded. +.\" +.\" furthermore, if an initializer is partially complete before it is canceled +.\" or interrupted by a signal whose handler requires the same initialization, +.\" some or all of the initialization may be performed more than once, +.\" leaking resources or even resulting in corrupt internal data. +.\" +.\" applications that need to call functions marked with +.\" .i init +.\" as an as-safety or ac-unsafe feature should ensure +.\" the initialization is performed +.\" before configuring signal handlers or enabling cancellation, +.\" so that the as-safety and ac-safety issues related with +.\" .i libc_once +.\" do not arise. +.\" +.\" .\" we may have to extend the annotations to cover conditions in which +.\" .\" initialization may or may not occur, since an initial call in a safe +.\" .\" context is no use if the initialization doesn't take place at that +.\" .\" time: it doesn't remove the risk for later calls. +.tp +.i race +functions annotated with +.i race +as an mt-safety issue operate on +objects in ways that may cause data races or similar forms of +destructive interference out of concurrent execution. +in some cases, +the objects are passed to the functions by users; +in others, they are used by the functions to return values to users; +in others, they are not even exposed to users. +.\" +.\" we consider access to objects passed as (indirect) arguments to +.\" functions to be data race free. +.\" the assurance of data race free objects +.\" is the caller's responsibility. +.\" we will not mark a function as mt-unsafe or as-unsafe +.\" if it misbehaves when users fail to take the measures required by +.\" posix to avoid data races when dealing with such objects. +.\" as a general rule, if a function is documented as reading from +.\" an object passed (by reference) to it, or modifying it, +.\" users ought to use memory synchronization primitives +.\" to avoid data races just as they would should they perform +.\" the accesses themselves rather than by calling the library function. +.\" standard i/o +.\" .ri ( "file *" ) +.\" streams are the exception to the general rule, +.\" in that posix mandates the library to guard against data races +.\" in many functions that manipulate objects of this specific opaque type. +.\" we regard this as a convenience provided to users, +.\" rather than as a general requirement whose expectations +.\" should extend to other types. +.\" +.\" in order to remind users that guarding certain arguments is their +.\" responsibility, we will annotate functions that take objects of certain +.\" types as arguments. +.\" we draw the line for objects passed by users as follows: +.\" objects whose types are exposed to users, +.\" and that users are expected to access directly, +.\" such as memory buffers, strings, +.\" and various user-visible structured types, do +.\" .i not +.\" give reason for functions to be annotated with +.\" .ir race . +.\" it would be noisy and redundant with the general requirement, +.\" and not many would be surprised by the library's lack of internal +.\" guards when accessing objects that can be accessed directly by users. +.\" +.\" as for objects that are opaque or opaque-like, +.\" in that they are to be manipulated only by passing them +.\" to library functions (e.g., +.\" .ir file , +.\" .ir dir , +.\" .ir obstack , +.\" .ir iconv_t ), +.\" there might be additional expectations as to internal coordination +.\" of access by the library. +.\" we will annotate, with +.\" .i race +.\" followed by a colon and the argument name, +.\" functions that take such objects but that do not take +.\" care of synchronizing access to them by default. +.\" for example, +.\" .i file +.\" stream +.\" .i unlocked +.\" functions +.\" .rb ( unlocked_stdio (3)) +.\" will be annotated, +.\" but those that perform implicit locking on +.\" .i file +.\" streams by default will not, +.\" even though the implicit locking may be disabled on a per-stream basis. +.\" +.\" in either case, we will not regard as mt-unsafe functions that may +.\" access user-supplied objects in unsafe ways should users fail to ensure +.\" the accesses are well defined. +.\" the notion prevails that users are expected to safeguard against +.\" data races any user-supplied objects that the library accesses +.\" on their behalf. +.\" +.\" .\" the above describes @mtsrace; @mtasurace is described below. +.\" +.\" this user responsibility does not apply, however, +.\" to objects controlled by the library itself, +.\" such as internal objects and static buffers used +.\" to return values from certain calls. +.\" when the library doesn't guard them against concurrent uses, +.\" these cases are regarded as mt-unsafe and as-unsafe (although the +.\" .i race +.\" mark under as-unsafe will be omitted +.\" as redundant with the one under mt-unsafe). +.\" as in the case of user-exposed objects, +.\" the mark may be followed by a colon and an identifier. +.\" the identifier groups all functions that operate on a +.\" certain unguarded object; users may avoid the mt-safety issues related +.\" with unguarded concurrent access to such internal objects by creating a +.\" non-recursive mutex related with the identifier, +.\" and always holding the mutex when calling any function marked +.\" as racy on that identifier, +.\" as they would have to should the identifier be +.\" an object under user control. +.\" the non-recursive mutex avoids the mt-safety issue, +.\" but it trades one as-safety issue for another, +.\" so use in asynchronous signals remains undefined. +.\" +.\" when the identifier relates to a static buffer used to hold return values, +.\" the mutex must be held for as long as the buffer remains in use +.\" by the caller. +.\" many functions that return pointers to static buffers offer reentrant +.\" variants that store return values in caller-supplied buffers instead. +.\" in some cases, such as +.\" .br tmpname (3), +.\" the variant is chosen not by calling an alternate entry point, +.\" but by passing a non-null pointer to the buffer in which the +.\" returned values are to be stored. +.\" these variants are generally preferable in multi-threaded programs, +.\" although some of them are not mt-safe because of other internal buffers, +.\" also documented with +.\" .i race +.\" notes. +.tp +.i const +functions marked with +.i const +as an mt-safety issue non-atomically +modify internal objects that are better regarded as constant, +because a substantial portion of the gnu c library accesses them without +synchronization. +unlike +.ir race , +which causes both readers and +writers of internal objects to be regarded as mt-unsafe,\" and as-unsafe, +this mark is applied to writers only. +writers remain\" equally +mt-unsafe\" and as-unsafe +to call, +but the then-mandatory constness of objects they +modify enables readers to be regarded as mt-safe\" and as-safe +(as long as no other reasons for them to be unsafe remain), +since the lack of synchronization is not a problem when the +objects are effectively constant. +.ip +the identifier that follows the +.i const +mark will appear by itself as a safety note in readers. +programs that wish to work around this safety issue, +so as to call writers, may use a non-recursive +read-write lock +associated with the identifier, and guard +.i all +calls to functions marked with +.i const +followed by the identifier with a write lock, and +.i all +calls to functions marked with the identifier +by itself with a read lock. +.\" the non-recursive locking removes the mt-safety problem, +.\" but it trades one as-safety problem for another, +.\" so use in asynchronous signals remains undefined. +.\" +.\" .\" but what if, instead of marking modifiers with const:id and readers +.\" .\" with just id, we marked writers with race:id and readers with ro:id? +.\" .\" instead of having to define each instance of 'id', we'd have a +.\" .\" general pattern governing all such 'id's, wherein race:id would +.\" .\" suggest the need for an exclusive/write lock to make the function +.\" .\" safe, whereas ro:id would indicate 'id' is expected to be read-only, +.\" .\" but if any modifiers are called (while holding an exclusive lock), +.\" .\" then ro:id-marked functions ought to be guarded with a read lock for +.\" .\" safe operation. ro:env or ro:locale, for example, seems to convey +.\" .\" more clearly the expectations and the meaning, than just env or +.\" .\" locale. +.tp +.i sig +functions marked with +.i sig +as a mt-safety issue +.\" (that implies an identical as-safety issue, omitted for brevity) +may temporarily install a signal handler for internal purposes, +which may interfere with other uses of the signal, +identified after a colon. +.ip +this safety problem can be worked around by ensuring that no other uses +of the signal will take place for the duration of the call. +holding a non-recursive mutex while calling all functions that use the same +temporary signal; +blocking that signal before the call and resetting its +handler afterwards is recommended. +.\" +.\" there is no safe way to guarantee the original signal handler is +.\" restored in case of asynchronous cancellation, +.\" therefore so-marked functions are also ac-unsafe. +.\" +.\" .\" fixme: at least deferred cancellation should get it right, and would +.\" .\" obviate the restoring bit below, and the qualifier above. +.\" +.\" besides the measures recommended to work around the +.\" mt-safety and as-safety problem, +.\" in order to avert the cancellation problem, +.\" disabling asynchronous cancellation +.\" .i and +.\" installing a cleanup handler to restore the signal to the desired state +.\" and to release the mutex are recommended. +.tp +.i term +functions marked with +.i term +as an mt-safety issue may change the +terminal settings in the recommended way, namely: call +.br tcgetattr (3), +modify some flags, and then call +.br tcsetattr (3), +this creates a window in which changes made by other threads are lost. +thus, functions marked with +.i term +are mt-unsafe. +.\" the same window enables changes made by asynchronous signals to be lost. +.\" these functions are also as-unsafe, +.\" but the corresponding mark is omitted as redundant. +.ip +it is thus advisable for applications using the terminal to avoid +concurrent and reentrant interactions with it, +by not using it in signal handlers or blocking signals that might use it, +and holding a lock while calling these functions and interacting +with the terminal. +this lock should also be used for mutual exclusion with +functions marked with +.ir race:tcattr(fd) , +where +.i fd +is a file descriptor for the controlling terminal. +the caller may use a single mutex for simplicity, +or use one mutex per terminal, +even if referenced by different file descriptors. +.\" +.\" functions marked with +.\" .i term +.\" as an ac-safety issue are supposed to +.\" restore terminal settings to their original state, +.\" after temporarily changing them, but they may fail to do so if canceled. +.\" +.\" .\" fixme: at least deferred cancellation should get it right, and would +.\" .\" obviate the restoring bit below, and the qualifier above. +.\" +.\" besides the measures recommended to work around the +.\" mt-safety and as-safety problem, +.\" in order to avert the cancellation problem, +.\" disabling asynchronous cancellation +.\" .i and +.\" installing a cleanup handler to +.\" restore the terminal settings to the original state and to release the +.\" mutex are recommended. +.\" +.\" +.ss other safety remarks +additional keywords may be attached to functions, +indicating features that do not make a function unsafe to call, +but that may need to be taken into account in certain classes of programs: +.tp +.i locale +functions annotated with +.i locale +as an mt-safety issue read from +the locale object without any form of synchronization. +functions +annotated with +.i locale +called concurrently with locale changes may +behave in ways that do not correspond to any of the locales active +during their execution, but an unpredictable mix thereof. +.ip +we do not mark these functions as mt-unsafe,\" or as-unsafe, +however, +because functions that modify the locale object are marked with +.i const:locale +and regarded as unsafe. +being unsafe, the latter are not to be called when multiple threads +are running or asynchronous signals are enabled, +and so the locale can be considered effectively constant +in these contexts, +which makes the former safe. +.\" should the locking strategy suggested under @code{const} be used, +.\" failure to guard locale uses is not as fatal as data races in +.\" general: unguarded uses will @emph{not} follow dangling pointers or +.\" access uninitialized, unmapped or recycled memory. each access will +.\" read from a consistent locale object that is or was active at some +.\" point during its execution. without synchronization, however, it +.\" cannot even be assumed that, after a change in locale, earlier +.\" locales will no longer be used, even after the newly-chosen one is +.\" used in the thread. nevertheless, even though unguarded reads from +.\" the locale will not violate type safety, functions that access the +.\" locale multiple times may invoke all sorts of undefined behavior +.\" because of the unexpected locale changes. +.tp +.i env +functions marked with +.i env +as an mt-safety issue access the +environment with +.br getenv (3) +or similar, without any guards to ensure +safety in the presence of concurrent modifications. +.ip +we do not mark these functions as mt-unsafe,\" or as-unsafe, +however, +because functions that modify the environment are all marked with +.i const:env +and regarded as unsafe. +being unsafe, the latter are not to be called when multiple threads +are running or asynchronous signals are enabled, +and so the environment can be considered +effectively constant in these contexts, +which makes the former safe. +.tp +.i hostid +the function marked with +.i hostid +as an mt-safety issue reads from the system-wide data structures that +hold the "host id" of the machine. +these data structures cannot generally be modified atomically. +since it is expected that the "host id" will not normally change, +the function that reads from it +.rb ( gethostid (3)) +is regarded as safe, +whereas the function that modifies it +.rb ( sethostid (3)) +is marked with +.ir const:hostid , +indicating it may require special care if it is to be called. +in this specific case, +the special care amounts to system-wide +(not merely intra-process) coordination. +.tp +.i sigintr +functions marked with +.i sigintr +as an mt-safety issue access the +gnu c library +.i _sigintr +internal data structure without any guards to ensure +safety in the presence of concurrent modifications. +.ip +we do not mark these functions as mt-unsafe,\" or as-unsafe, +however, +because functions that modify this data structure are all marked with +.i const:sigintr +and regarded as unsafe. +being unsafe, +the latter are not to be called when multiple threads are +running or asynchronous signals are enabled, +and so the data structure can be considered +effectively constant in these contexts, +which makes the former safe. +.\" .tp +.\" .i fd +.\" functions annotated with +.\" .i fd +.\" as an ac-safety issue may leak file +.\" descriptors if asynchronous thread cancellation interrupts their +.\" execution. +.\" +.\" functions that allocate or deallocate file descriptors will generally be +.\" marked as such. +.\" even if they attempted to protect the file descriptor +.\" allocation and deallocation with cleanup regions, +.\" allocating a new descriptor and storing its number where the cleanup region +.\" could release it cannot be performed as a single atomic operation. +.\" similarly, +.\" releasing the descriptor and taking it out of the data structure +.\" normally responsible for releasing it cannot be performed atomically. +.\" there will always be a window in which the descriptor cannot be released +.\" because it was not stored in the cleanup handler argument yet, +.\" or it was already taken out before releasing it. +.\" .\" it cannot be taken out after release: +.\" an open descriptor could mean either that the descriptor still +.\" has to be closed, +.\" or that it already did so but the descriptor was +.\" reallocated by another thread or signal handler. +.\" +.\" such leaks could be internally avoided, with some performance penalty, +.\" by temporarily disabling asynchronous thread cancellation. +.\" however, +.\" since callers of allocation or deallocation functions would have to do +.\" this themselves, to avoid the same sort of leak in their own layer, +.\" it makes more sense for the library to assume they are taking care of it +.\" than to impose a performance penalty that is redundant when the problem +.\" is solved in upper layers, and insufficient when it is not. +.\" +.\" this remark by itself does not cause a function to be regarded as +.\" ac-unsafe. +.\" however, cumulative effects of such leaks may pose a +.\" problem for some programs. +.\" if this is the case, +.\" suspending asynchronous cancellation for the duration of calls +.\" to such functions is recommended. +.\" .tp +.\" .i mem +.\" functions annotated with +.\" .i mem +.\" as an ac-safety issue may leak +.\" memory if asynchronous thread cancellation interrupts their execution. +.\" +.\" the problem is similar to that of file descriptors: there is no atomic +.\" interface to allocate memory and store its address in the argument to a +.\" cleanup handler, +.\" or to release it and remove its address from that argument, +.\" without at least temporarily disabling asynchronous cancellation, +.\" which these functions do not do. +.\" +.\" this remark does not by itself cause a function to be regarded as +.\" generally ac-unsafe. +.\" however, cumulative effects of such leaks may be +.\" severe enough for some programs that disabling asynchronous cancellation +.\" for the duration of calls to such functions may be required. +.tp +.i cwd +functions marked with +.i cwd +as an mt-safety issue may temporarily +change the current working directory during their execution, +which may cause relative pathnames to be resolved in unexpected ways in +other threads or within asynchronous signal or cancellation handlers. +.ip +this is not enough of a reason to mark so-marked functions as mt-unsafe, +.\" or as-unsafe, +but when this behavior is optional (e.g., +.br nftw (3) +with +.br ftw_chdir ), +avoiding the option may be a good alternative to +using full pathnames or file descriptor-relative (e.g., +.br openat (2)) +system calls. +.\" .tp +.\" .i !posix +.\" this remark, as an mt-safety, as-safety or ac-safety +.\" note to a function, +.\" indicates the safety status of the function is known to differ +.\" from the specified status in the posix standard. +.\" for example, posix does not require a function to be safe, +.\" but our implementation is, or vice-versa. +.\" +.\" for the time being, the absence of this remark does not imply the safety +.\" properties we documented are identical to those mandated by posix for +.\" the corresponding functions. +.tp +.i :identifier +annotations may sometimes be followed by identifiers, +intended to group several functions that, for example, +access the data structures in an unsafe way, as in +.i race +and +.ir const , +or to provide more specific information, +such as naming a signal in a function marked with +.ir sig . +it is envisioned that it may be applied to +.i lock +and +.i corrupt +as well in the future. +.ip +in most cases, the identifier will name a set of functions, +but it may name global objects or function arguments, +or identifiable properties or logical components associated with them, +with a notation such as, for example, +.i :buf(arg) +to denote a buffer associated with the argument +.ir arg , +or +.i :tcattr(fd) +to denote the terminal attributes of a file descriptor +.ir fd . +.ip +the most common use for identifiers is to provide logical groups of +functions and arguments that need to be protected by the same +synchronization primitive in order to ensure safe operation in a given +context. +.tp +.i /condition +some safety annotations may be conditional, +in that they only apply if a boolean expression involving arguments, +global variables or even the underlying kernel evaluates to true. +.\" such conditions as +.\" .i /hurd +.\" or +.\" .i /!linux!bsd +.\" indicate the preceding marker only +.\" applies when the underlying kernel is the hurd, +.\" or when it is neither linux nor a bsd kernel, respectively. +for example, +.i /!ps +and +.i /one_per_line +indicate the preceding marker only applies when argument +.i ps +is null, or global variable +.i one_per_line +is nonzero. +.ip +when all marks that render a function unsafe are +adorned with such conditions, +and none of the named conditions hold, +then the function can be regarded as safe. +.sh see also +.br pthreads (7), +.br signal\-safety (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/getdomainname.2 + +.so man2/listxattr.2 + +.so man3/stdarg.3 + +.\" this man page is copyright (c) 1999 claus fischer. +.\" +.\" %%%license_start(verbatim_one_para) +.\" permission is granted to distribute possibly modified copies +.\" of this page provided the header is included verbatim, +.\" and in case of nontrivial modification author and date +.\" of the modification is added to the header. +.\" %%%license_end +.\" +.\" 990620 - page created - aeb@cwi.nl +.\" +.th fifo 7 2017-11-26 "linux" "linux programmer's manual" +.sh name +fifo \- first-in first-out special file, named pipe +.sh description +a fifo special file (a named pipe) is similar to a pipe, +except that it is accessed as part of the filesystem. +it can be opened by multiple processes for reading or +writing. +when processes are exchanging data via the fifo, +the kernel passes all data internally without writing it +to the filesystem. +thus, the fifo special file has no +contents on the filesystem; the filesystem entry merely +serves as a reference point so that processes can access +the pipe using a name in the filesystem. +.pp +the kernel maintains exactly one pipe object for each +fifo special file that is opened by at least one process. +the fifo must be opened on both ends (reading and writing) +before data can be passed. +normally, opening the fifo blocks +until the other end is opened also. +.pp +a process can open a fifo in nonblocking mode. +in this +case, opening for read-only succeeds even if no one has +opened on the write side yet and opening for write-only +fails with +.b enxio +(no such device or address) unless the other +end has already been opened. +.pp +under linux, opening a fifo for read and write will succeed +both in blocking and nonblocking mode. +posix leaves this +behavior undefined. +this can be used to open a fifo for +writing while there are no readers available. +a process +that uses both ends of the connection in order to communicate +with itself should be very careful to avoid deadlocks. +.sh notes +for details of the semantics of i/o on fifos, see +.br pipe (7). +.pp +when a process tries to write to a fifo that is not opened +for read on the other side, the process is sent a +.b sigpipe +signal. +.pp +fifo special files can be created by +.br mkfifo (3), +and are indicated by +.ir "ls\ \-l" +with the file type \(aqp\(aq. +.sh see also +.br mkfifo (1), +.br open (2), +.br pipe (2), +.br sigaction (2), +.br signal (2), +.br socketpair (2), +.br mkfifo (3), +.br pipe (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/__ppc_set_ppr_med.3 + +.so man3/rint.3 + +.\" copyright (c) 1983, 1991 the regents of the university of california. +.\" all rights reserved. +.\" +.\" %%%license_start(bsd_4_clause_ucb) +.\" redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. all advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" this product includes software developed by the university of +.\" california, berkeley and its contributors. +.\" 4. neither the name of the university nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" this software is provided by the regents and contributors ``as is'' and +.\" any express or implied warranties, including, but not limited to, the +.\" implied warranties of merchantability and fitness for a particular purpose +.\" are disclaimed. in no event shall the regents or contributors be liable +.\" for any direct, indirect, incidental, special, exemplary, or consequential +.\" damages (including, but not limited to, procurement of substitute goods +.\" or services; loss of use, data, or profits; or business interruption) +.\" however caused and on any theory of liability, whether in contract, strict +.\" liability, or tort (including negligence or otherwise) arising in any way +.\" out of the use of this software, even if advised of the possibility of +.\" such damage. +.\" %%%license_end +.\" +.\" $id: getsockopt.2,v 1.1 1999/05/24 14:57:04 freitag exp $ +.\" +.\" modified sat jul 24 16:19:32 1993 by rik faith (faith@cs.unc.edu) +.\" modified mon apr 22 02:29:06 1996 by martin schulze (joey@infodrom.north.de) +.\" modified tue aug 27 10:52:51 1996 by andries brouwer (aeb@cwi.nl) +.\" modified thu jan 23 13:29:34 1997 by andries brouwer (aeb@cwi.nl) +.\" modified sun mar 28 21:26:46 1999 by andries brouwer (aeb@cwi.nl) +.\" modified 1999 by andi kleen . +.\" removed most stuff because it is in socket.7 now. +.\" +.th getsockopt 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +getsockopt, setsockopt \- get and set options on sockets +.sh synopsis +.nf +.b #include +.pp +.bi "int getsockopt(int " sockfd ", int " level ", int " optname , +.bi " void *restrict " optval ", socklen_t *restrict " optlen ); +.bi "int setsockopt(int " sockfd ", int " level ", int " optname , +.bi " const void *" optval ", socklen_t " optlen ); +.fi +.sh description +.br getsockopt () +and +.br setsockopt () +manipulate options for the socket referred to by the file descriptor +.ir sockfd . +options may exist at multiple +protocol levels; they are always present at the uppermost +socket level. +.pp +when manipulating socket options, the level at which the +option resides and the name of the option must be specified. +to manipulate options at the sockets api level, +.i level +is specified as +.br sol_socket . +to manipulate options at any +other level the protocol number of the appropriate protocol +controlling the option is supplied. +for example, +to indicate that an option is to be interpreted by the +.b tcp +protocol, +.i level +should be set to the protocol number of +.br tcp ; +see +.br getprotoent (3). +.pp +the arguments +.i optval +and +.i optlen +are used to access option values for +.br setsockopt (). +for +.br getsockopt () +they identify a buffer in which the value for the +requested option(s) are to be returned. +for +.br getsockopt (), +.i optlen +is a value-result argument, initially containing the +size of the buffer pointed to by +.ir optval , +and modified on return to indicate the actual size of +the value returned. +if no option value is to be supplied or returned, +.i optval +may be null. +.pp +.i optname +and any specified options are passed uninterpreted to the appropriate +protocol module for interpretation. +the include file +.i +contains definitions for socket level options, described below. +options at +other protocol levels vary in format and name; consult the appropriate +entries in section 4 of the manual. +.pp +most socket-level options utilize an +.i int +argument for +.ir optval . +for +.br setsockopt (), +the argument should be nonzero to enable a boolean option, or zero if the +option is to be disabled. +.pp +for a description of the available socket options see +.br socket (7) +and the appropriate protocol man pages. +.sh return value +on success, zero is returned for the standard options. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.pp +netfilter allows the programmer +to define custom socket options with associated handlers; for such +options, the return value on success is the value returned by the handler. +.sh errors +.tp +.b ebadf +the argument +.i sockfd +is not a valid file descriptor. +.tp +.b efault +the address pointed to by +.i optval +is not in a valid part of the process address space. +for +.br getsockopt (), +this error may also be returned if +.i optlen +is not in a valid part of the process address space. +.tp +.b einval +.i optlen +invalid in +.br setsockopt (). +in some cases this error can also occur for an invalid value in +.ir optval +(e.g., for the +.b ip_add_membership +option described in +.br ip (7)). +.tp +.b enoprotoopt +the option is unknown at the level indicated. +.tp +.b enotsock +the file descriptor +.i sockfd +does not refer to a socket. +.sh conforming to +posix.1-2001, posix.1-2008, +svr4, 4.4bsd (these system calls first appeared in 4.2bsd). +.\" svr4 documents additional enomem and enosr error codes, but does +.\" not document the +.\" .br so_sndlowat ", " so_rcvlowat ", " so_sndtimeo ", " so_rcvtimeo +.\" options +.sh notes +for background on the +.i socklen_t +type, see +.br accept (2). +.sh bugs +several of the socket options should be handled at lower levels of the +system. +.sh see also +.br ioctl (2), +.br socket (2), +.br getprotoent (3), +.br protocols (5), +.br ip (7), +.br packet (7), +.br socket (7), +.br tcp (7), +.br udp (7), +.br unix (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 2003 walter harms, andries brouwer +.\" and copyright 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under gpl +.\" %%%license_end +.\" +.th fdim 3 2021-03-22 "" "linux programmer's manual" +.sh name +fdim, fdimf, fdiml \- positive difference +.sh synopsis +.nf +.b #include +.pp +.bi "double fdim(double " x ", double " y ); +.bi "float fdimf(float " x ", float " y ); +.bi "long double fdiml(long double " x ", long double " y ); +.fi +.pp +link with \fi\-lm\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br fdimf (), +.br fdiml (): +.nf + _isoc99_source || _posix_c_source >= 200112l +.fi +.sh description +these functions return the positive difference, max(\fix\fp-\fiy\fp,0), +between their arguments. +.sh return value +on success, these functions return the positive difference. +.pp +if +.i x +or +.i y +is a nan, a nan is returned. +.pp +if the result overflows, +a range error occurs, +and the functions return +.br huge_val , +.br huge_valf , +or +.br huge_vall , +respectively. +.sh errors +see +.br math_error (7) +for information on how to determine whether an error has occurred +when calling these functions. +.pp +the following errors can occur: +.tp +range error: result overflow +.i errno +is set to +.br erange . +an overflow floating-point exception +.rb ( fe_overflow ) +is raised. +.sh versions +these functions first appeared in glibc in version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br fdim (), +.br fdimf (), +.br fdiml () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.sh bugs +before glibc version 2.24 +.\" https://www.sourceware.org/bugzilla/show_bug.cgi?id=6796 +on certain architectures (e.g., x86, but not x86_64) +these functions did not set +.ir errno . +.sh see also +.br fmax (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 2003 walter harms (walter.harms@informatik.uni-oldenburg.de) +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under gpl +.\" %%%license_end +.\" +.\" modified 2003-04-04 walter harms +.\" +.\" +.\" slightly polished, aeb, 2003-04-06 +.\" +.th rtime 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +rtime \- get time from a remote machine +.sh synopsis +.nf +.b "#include " +.pp +.bi "int rtime(struct sockaddr_in *" addrp ", struct rpc_timeval *" timep , +.bi " struct rpc_timeval *" timeout ); +.fi +.sh description +this function uses the time server protocol as described in +rfc\ 868 to obtain the time from a remote machine. +.pp +the time server protocol gives the time in seconds since +00:00:00 utc, 1 jan 1900, +and this function subtracts the appropriate constant in order to +convert the result to seconds since the +epoch, 1970-01-01 00:00:00 +0000 (utc). +.pp +when +.i timeout +is non-null, the udp/time socket (port 37) is used. +otherwise, the tcp/time socket (port 37) is used. +.sh return value +on success, 0 is returned, and the obtained 32-bit time value is stored in +.ir timep\->tv_sec . +in case of error \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +all errors for underlying functions +.rb ( sendto (2), +.br poll (2), +.br recvfrom (2), +.br connect (2), +.br read (2)) +can occur. +moreover: +.tp +.b eio +the number of returned bytes is not 4. +.tp +.b etimedout +the waiting time as defined in timeout has expired. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br rtime () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh notes +only ipv4 is supported. +.pp +some +.i in.timed +versions support only tcp. +try the example program with +.i use_tcp +set to 1. +.\" .pp +.\" libc5 uses the prototype +.\" .pp +.\" .nf +.\" int rtime(struct sockaddr_in *, struct timeval *, struct timeval *); +.\" .fi +.\" .pp +.\" and requires +.\" .i +.\" instead of +.\" .ir . +.sh bugs +.br rtime () +in glibc 2.2.5 and earlier does not work properly on 64-bit machines. +.sh examples +this example requires that port 37 is up and open. +you may check +that the time entry within +.i /etc/inetd.conf +is not commented out. +.pp +the program connects to a computer called "linux". +using "localhost" does not work. +the result is the localtime of the computer "linux". +.pp +.ex +#include +#include +#include +#include +#include +#include +#include + +static int use_tcp = 0; +static char *servername = "linux"; + +int +main(void) +{ + struct sockaddr_in name; + struct rpc_timeval time1 = {0,0}; + struct rpc_timeval timeout = {1,0}; + struct hostent *hent; + int ret; + + memset(&name, 0, sizeof(name)); + sethostent(1); + hent = gethostbyname(servername); + memcpy(&name.sin_addr, hent\->h_addr, hent\->h_length); + + ret = rtime(&name, &time1, use_tcp ? null : &timeout); + if (ret < 0) + perror("rtime error"); + else { + time_t t = time1.tv_sec; + printf("%s\en", ctime(&t)); + } + + exit(exit_success); +} +.ee +.sh see also +.\" .br netdate (1), +.br ntpdate (1), +.\" .br rdate (1), +.br inetd (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2014 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th isfdtype 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +isfdtype \- test file type of a file descriptor +.sh synopsis +.nf +.b #include +.b #include +.pp +.bi "int isfdtype(int " fd ", int " fdtype ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br isfdtype (): +.nf + since glibc 2.20: + _default_source + before glibc 2.20: + _bsd_source || _svid_source +.fi +.sh description +the +.br isfdtype () +function tests whether the file descriptor +.i fd +refers to a file of type +.ir fdtype . +the +.i fdtype +argument specifies one of the +.b s_if* +constants defined in +.i +and documented in +.br stat (2) +(e.g., +.br s_ifreg ). +.sh return value +the +.br isfdtype () +function returns 1 if the file descriptor +.i fd +is of type +.ir fdtype +and 0 if it is not. +on failure, \-1 is returned and +.i errno +is set to indicate the error. +.sh errors +the +.br isfdtype () +function can fail with any of the same errors as +.br fstat (2). +.sh conforming to +the +.br isfdtype () +function is not specified in any standard, +but did appear in the draft posix.1g standard. +it is present on openbsd and tru64 unix +(where the required header file in both cases is just +.ir , +as shown in the posix.1g draft), +and possibly other systems. +.sh notes +portable applications should use +.br fstat (2) +instead. +.sh see also +.br fstat (2) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1983, 1991 the regents of the university of california. +.\" all rights reserved. +.\" +.\" %%%license_start(bsd_4_clause_ucb) +.\" redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. all advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" this product includes software developed by the university of +.\" california, berkeley and its contributors. +.\" 4. neither the name of the university nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" this software is provided by the regents and contributors ``as is'' and +.\" any express or implied warranties, including, but not limited to, the +.\" implied warranties of merchantability and fitness for a particular purpose +.\" are disclaimed. in no event shall the regents or contributors be liable +.\" for any direct, indirect, incidental, special, exemplary, or consequential +.\" damages (including, but not limited to, procurement of substitute goods +.\" or services; loss of use, data, or profits; or business interruption) +.\" however caused and on any theory of liability, whether in contract, strict +.\" liability, or tort (including negligence or otherwise) arising in any way +.\" out of the use of this software, even if advised of the possibility of +.\" such damage. +.\" %%%license_end +.\" +.\" $id: socket.2,v 1.4 1999/05/13 11:33:42 freitag exp $ +.\" +.\" modified 1993-07-24 by rik faith +.\" modified 1996-10-22 by eric s. raymond +.\" modified 1998, 1999 by andi kleen +.\" modified 2002-07-17 by michael kerrisk +.\" modified 2004-06-17 by michael kerrisk +.\" +.th socket 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +socket \- create an endpoint for communication +.sh synopsis +.nf +.b #include +.pp +.bi "int socket(int " domain ", int " type ", int " protocol ); +.fi +.sh description +.br socket () +creates an endpoint for communication and returns a file descriptor +that refers to that endpoint. +the file descriptor returned by a successful call will be +the lowest-numbered file descriptor not currently open for the process. +.pp +the +.i domain +argument specifies a communication domain; this selects the protocol +family which will be used for communication. +these families are defined in +.ir . +the formats currently understood by the linux kernel include: +.ts +tab(:); +l1 lw40 l. +name:purpose:man page +t{ +.br af_unix +t}:t{ +local communication +t}:t{ +.br unix (7) +t} +t{ +.b af_local +t}:t{ +synonym for +.b af_unix +t}:t{ +t} +t{ +.b af_inet +t}:ipv4 internet protocols:t{ +.br ip (7) +t} +t{ +.b af_ax25 +t}:t{ +amateur radio ax.25 protocol +t}:t{ +.\" part of ax25-tools +.br ax25 (4) +t} +t{ +.b af_ipx +t}:ipx \- novell protocols: +t{ +.b af_appletalk +t}:appletalk:t{ +.br ddp (7) +t} +t{ +.b af_x25 +t}:itu-t x.25 / iso-8208 protocol:t{ +.br x25 (7) +t} +t{ +.b af_inet6 +t}:ipv6 internet protocols:t{ +.br ipv6 (7) +t} +t{ +.b af_decnet +t}:t{ +decet protocol sockets +t} +t{ +.b af_key +t}:t{ +key management protocol, originally developed for usage with ipsec +t} +t{ +.b af_netlink +t}:t{ +kernel user interface device +t}:t{ +.br netlink (7) +t} +t{ +.b af_packet +t}:t{ +low-level packet interface +t}:t{ +.br packet (7) +t} +t{ +.b af_rds +t}:t{ +.\" commit: 639b321b4d8f4e412bfbb2a4a19bfebc1e68ace4 +reliable datagram sockets (rds) protocol +t}:t{ +.\" rds-tools: https://github.com/oracle/rds-tools/blob/master/rds.7 +.\" rds-tools: https://github.com/oracle/rds-tools/blob/master/rds-rdma.7 +.br rds (7) +.br +.br rds\-rdma (7) +t} +t{ +.b af_pppox +t}:t{ +generic ppp transport layer, for setting up l2 tunnels +(l2tp and pppoe) +t} +t{ +.b af_llc +t}:t{ +.\" linux-history commit: 34beb106cde7da233d4df35dd3d6cf4fee937caa +logical link control (ieee 802.2 llc) protocol +t} +t{ +.b af_ib +t}:t{ +.\" commits: 8d36eb01da5d371f..ce117ffac2e93334 +infiniband native addressing +t} +t{ +.b af_mpls +t}:t{ +.\" commits: 0189197f441602acdca3f97750d392a895b778fd +multiprotocol label switching +t} +t{ +.b af_can +t}:t{ +.\" commits: 8dbde28d9711475a..5423dd67bd0108a1 +controller area network automotive bus protocol +t} +t{ +.b af_tipc +t}:t{ +.\" commits: b97bf3fd8f6a16966d4f18983b2c40993ff937d4 +tipc, "cluster domain sockets" protocol +t} +t{ +.b af_bluetooth +t}:t{ +.\" commits: 8d36eb01da5d371f..ce117ffac2e93334 +bluetooth low-level socket protocol +t} +t{ +.b af_alg +t}:t{ +.\" commit: 03c8efc1ffeb6b82a22c1af8dd908af349563314 +interface to kernel crypto api +t} +t{ +.b af_vsock +t}:t{ +.\" commit: d021c344051af91f42c5ba9fdedc176740cbd238 +vsock (originally "vmware vsockets") protocol +for hypervisor-guest communication +t}:t{ +.br vsock (7) +t} +t{ +.b af_kcm +t}:t{ +.\" commit: 03c8efc1ffeb6b82a22c1af8dd908af349563314 +kcm (kernel connection multiplexer) interface +t} +t{ +.b af_xdp +t}:t{ +.\" commit: c0c77d8fb787cfe0c3fca689c2a30d1dad4eaba7 +xdp (express data path) interface +t} +.te +.pp +further details of the above address families, +as well as information on several other address families, can be found in +.br address_families (7). +.pp +the socket has the indicated +.ir type , +which specifies the communication semantics. +currently defined types +are: +.tp 16 +.b sock_stream +provides sequenced, reliable, two-way, connection-based byte streams. +an out-of-band data transmission mechanism may be supported. +.tp +.b sock_dgram +supports datagrams (connectionless, unreliable messages of a fixed +maximum length). +.tp +.b sock_seqpacket +provides a sequenced, reliable, two-way connection-based data +transmission path for datagrams of fixed maximum length; a consumer is +required to read an entire packet with each input system call. +.tp +.b sock_raw +provides raw network protocol access. +.tp +.b sock_rdm +provides a reliable datagram layer that does not guarantee ordering. +.tp +.b sock_packet +obsolete and should not be used in new programs; +see +.br packet (7). +.pp +some socket types may not be implemented by all protocol families. +.pp +since linux 2.6.27, the +.i type +argument serves a second purpose: +in addition to specifying a socket type, +it may include the bitwise or of any of the following values, +to modify the behavior of +.br socket (): +.tp 16 +.b sock_nonblock +set the +.br o_nonblock +file status flag on the open file description (see +.br open (2)) +referred to by the new file descriptor. +using this flag saves extra calls to +.br fcntl (2) +to achieve the same result. +.tp +.b sock_cloexec +set the close-on-exec +.rb ( fd_cloexec ) +flag on the new file descriptor. +see the description of the +.b o_cloexec +flag in +.br open (2) +for reasons why this may be useful. +.pp +the +.i protocol +specifies a particular protocol to be used with the socket. +normally only a single protocol exists to support a particular +socket type within a given protocol family, in which case +.i protocol +can be specified as 0. +however, it is possible that many protocols may exist, in +which case a particular protocol must be specified in this manner. +the protocol number to use is specific to the \*(lqcommunication domain\*(rq +in which communication is to take place; see +.br protocols (5). +see +.br getprotoent (3) +on how to map protocol name strings to protocol numbers. +.pp +sockets of type +.b sock_stream +are full-duplex byte streams. +they do not preserve +record boundaries. +a stream socket must be in +a +.i connected +state before any data may be sent or received on it. +a connection to +another socket is created with a +.br connect (2) +call. +once connected, data may be transferred using +.br read (2) +and +.br write (2) +calls or some variant of the +.br send (2) +and +.br recv (2) +calls. +when a session has been completed a +.br close (2) +may be performed. +out-of-band data may also be transmitted as described in +.br send (2) +and received as described in +.br recv (2). +.pp +the communications protocols which implement a +.b sock_stream +ensure that data is not lost or duplicated. +if a piece of data for which +the peer protocol has buffer space cannot be successfully transmitted +within a reasonable length of time, then the connection is considered +to be dead. +when +.b so_keepalive +is enabled on the socket the protocol checks in a protocol-specific +manner if the other end is still alive. +a +.b sigpipe +signal is raised if a process sends or receives +on a broken stream; this causes naive processes, +which do not handle the signal, to exit. +.b sock_seqpacket +sockets employ the same system calls as +.b sock_stream +sockets. +the only difference is that +.br read (2) +calls will return only the amount of data requested, +and any data remaining in the arriving packet will be discarded. +also all message boundaries in incoming datagrams are preserved. +.pp +.b sock_dgram +and +.b sock_raw +sockets allow sending of datagrams to correspondents named in +.br sendto (2) +calls. +datagrams are generally received with +.br recvfrom (2), +which returns the next datagram along with the address of its sender. +.pp +.b sock_packet +is an obsolete socket type to receive raw packets directly from the +device driver. +use +.br packet (7) +instead. +.pp +an +.br fcntl (2) +.b f_setown +operation can be used to specify a process or process group to receive a +.b sigurg +signal when the out-of-band data arrives or +.b sigpipe +signal when a +.b sock_stream +connection breaks unexpectedly. +this operation may also be used to set the process or process group +that receives the i/o and asynchronous notification of i/o events via +.br sigio . +using +.b f_setown +is equivalent to an +.br ioctl (2) +call with the +.b fiosetown +or +.b siocspgrp +argument. +.pp +when the network signals an error condition to the protocol module (e.g., +using an icmp message for ip) the pending error flag is set for the socket. +the next operation on this socket will return the error code of the pending +error. +for some protocols it is possible to enable a per-socket error queue +to retrieve detailed information about the error; see +.b ip_recverr +in +.br ip (7). +.pp +the operation of sockets is controlled by socket level +.ir options . +these options are defined in +.ir . +the functions +.br setsockopt (2) +and +.br getsockopt (2) +are used to set and get options. +.sh return value +on success, a file descriptor for the new socket is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eacces +permission to create a socket of the specified type and/or protocol +is denied. +.tp +.b eafnosupport +the implementation does not support the specified address family. +.tp +.b einval +unknown protocol, or protocol family not available. +.tp +.b einval +.\" since linux 2.6.27 +invalid flags in +.ir type . +.tp +.b emfile +the per-process limit on the number of open file descriptors has been reached. +.tp +.b enfile +the system-wide limit on the total number of open files has been reached. +.tp +.br enobufs " or " enomem +insufficient memory is available. +the socket cannot be +created until sufficient resources are freed. +.tp +.b eprotonosupport +the protocol type or the specified protocol is not +supported within this domain. +.pp +other errors may be generated by the underlying protocol modules. +.sh conforming to +posix.1-2001, posix.1-2008, 4.4bsd. +.pp +the +.b sock_nonblock +and +.b sock_cloexec +flags are linux-specific. +.pp +.br socket () +appeared in 4.2bsd. +it is generally portable to/from +non-bsd systems supporting clones of the bsd socket layer (including +system\ v variants). +.sh notes +the manifest constants used under 4.x bsd for protocol families +are +.br pf_unix , +.br pf_inet , +and so on, while +.br af_unix , +.br af_inet , +and so on are used for address +families. +however, already the bsd man page promises: "the protocol +family generally is the same as the address family", and subsequent +standards use af_* everywhere. +.sh examples +an example of the use of +.br socket () +is shown in +.br getaddrinfo (3). +.sh see also +.br accept (2), +.br bind (2), +.br close (2), +.br connect (2), +.br fcntl (2), +.br getpeername (2), +.br getsockname (2), +.br getsockopt (2), +.br ioctl (2), +.br listen (2), +.br read (2), +.br recv (2), +.br select (2), +.br send (2), +.br shutdown (2), +.br socketpair (2), +.br write (2), +.br getprotoent (3), +.br address_families (7), +.br ip (7), +.br socket (7), +.br tcp (7), +.br udp (7), +.br unix (7) +.pp +\(lqan introductory 4.3bsd interprocess communication tutorial\(rq +and +\(lqbsd interprocess communication tutorial\(rq, +reprinted in +.i unix programmer's supplementary documents volume 1. +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1995 jim van zandt +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" modified 2001-12-13, martin schulze +.\" added ttyname_r, aeb, 2002-07-20 +.\" +.th ttyname 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +ttyname, ttyname_r \- return name of a terminal +.sh synopsis +.nf +.b #include +.pp +.bi "char *ttyname(int " fd ); +.bi "int ttyname_r(int " fd ", char *" buf ", size_t " buflen ); +.fi +.sh description +the function +.br ttyname () +returns a pointer to the null-terminated pathname of the terminal device +that is open on the file descriptor \fifd\fp, or null on error +(for example, if \fifd\fp is not connected to a terminal). +the return value may point to static data, possibly overwritten by the +next call. +the function +.br ttyname_r () +stores this pathname in the buffer +.i buf +of length +.ir buflen . +.sh return value +the function +.br ttyname () +returns a pointer to a pathname on success. +on error, null is returned, and +.i errno +is set to indicate the error. +the function +.br ttyname_r () +returns 0 on success, and an error number upon error. +.sh errors +.tp +.b ebadf +bad file descriptor. +.tp +.\" glibc commit 15e9a4f378c8607c2ae1aa465436af4321db0e23 +.b enodev +.i fd +refers to a slave pseudoterminal device +but the corresponding pathname could not be found (see notes). +.tp +.b enotty +.i fd +does not refer to a terminal device. +.tp +.b erange +.rb ( ttyname_r ()) +.i buflen +was too small to allow storing the pathname. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br ttyname () +t} thread safety mt-unsafe race:ttyname +t{ +.br ttyname_r () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, 4.2bsd. +.sh notes +a process that keeps a file descriptor that refers to a +.br pts (4) +device open when switching to another mount namespace that uses a different +.i /dev/ptmx +instance may still accidentally find that a device path of the same name +for that file descriptor exists. +however, this device path refers to a different device and thus +can't be used to access the device that the file descriptor refers to. +calling +.br ttyname () +or +.br ttyname_r () +on the file descriptor in the new mount namespace will cause these +functions to return null and set +.i errno +to +.br enodev . +.sh see also +.br tty (1), +.br fstat (2), +.br ctermid (3), +.br isatty (3), +.br pts (4) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/capget.2 + +.\" copyright (c) 2007 by michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th sgetmask 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +sgetmask, ssetmask \- manipulation of signal mask (obsolete) +.sh synopsis +.nf +.br "#include " " /* definition of " sys_* " constants */" +.b #include +.pp +.b "long syscall(sys_sgetmask, void);" +.bi "long syscall(sys_ssetmask, long " newmask ); +.fi +.pp +.ir note : +glibc provides no wrappers for these functions, +necessitating the use of +.br syscall (2). +.sh description +these system calls are obsolete. +.ir "do not use them" ; +use +.br sigprocmask (2) +instead. +.pp +.br sgetmask () +returns the signal mask of the calling process. +.pp +.br ssetmask () +sets the signal mask of the calling process to the value given in +.ir newmask . +the previous signal mask is returned. +.pp +the signal masks dealt with by these two system calls +are plain bit masks (unlike the +.i sigset_t +used by +.br sigprocmask (2)); +use +.br sigmask (3) +to create and inspect these masks. +.sh return value +.br sgetmask () +always successfully returns the signal mask. +.br ssetmask () +always succeeds, and returns the previous signal mask. +.sh errors +these system calls always succeed. +.sh versions +since linux 3.16, +.\" f6187769dae48234f3877df3c4d99294cc2254fa +support for these system calls is optional, +depending on whether the kernel was built with the +.b config_sgetmask_syscall +option. +.sh conforming to +these system calls are linux-specific. +.sh notes +these system calls are unaware of signal numbers greater than 31 +(i.e., real-time signals). +.pp +these system calls do not exist on x86-64. +.pp +it is not possible to block +.b sigstop +or +.br sigkill . +.sh see also +.br sigprocmask (2), +.br signal (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2002 andries brouwer +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" this replaces an earlier man page written by walter harms +.\" . +.\" +.th ttyslot 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +ttyslot \- find the slot of the current user's terminal in some file +.sh synopsis +.nf +.br "#include " " /* see notes */" +.pp +.b "int ttyslot(void);" +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br ttyslot (): +.nf + since glibc 2.24: + _default_source + from glibc 2.20 to 2.23: + _default_source || (_xopen_source && _xopen_source < 500) + glibc 2.19 and earlier: + _bsd_source || (_xopen_source && _xopen_source < 500) +.fi +.sh description +the legacy function +.br ttyslot () +returns the index of the current user's entry in some file. +.pp +now "what file?" you ask. +well, let's first look at some history. +.ss ancient history +there used to be a file +.i /etc/ttys +in unix\ v6, that was read by the +.br init (1) +program to find out what to do with each terminal line. +each line consisted of three characters. +the first character was either \(aq0\(aq or \(aq1\(aq, +where \(aq0\(aq meant "ignore". +the second character denoted the terminal: \(aq8\(aq stood for "/dev/tty8". +the third character was an argument to +.br getty (8) +indicating the sequence of line speeds to try (\(aq\-\(aq was: start trying +110 baud). +thus a typical line was "18\-". +a hang on some line was solved by changing the \(aq1\(aq to a \(aq0\(aq, +signaling init, changing back again, and signaling init again. +.pp +in unix\ v7 the format was changed: here the second character +was the argument to +.br getty (8) +indicating the sequence of line speeds to try (\(aq0\(aq was: cycle through +300-1200-150-110 baud; \(aq4\(aq was for the on-line console decwriter) +while the rest of the line contained the name of the tty. +thus a typical line was "14console". +.pp +later systems have more elaborate syntax. +system v-like systems have +.i /etc/inittab +instead. +.ss ancient history (2) +on the other hand, there is the file +.i /etc/utmp +listing the people currently logged in. +it is maintained by +.br login (1). +it has a fixed size, and the appropriate index in the file was +determined by +.br login (1) +using the +.br ttyslot () +call to find the number of the line in +.i /etc/ttys +(counting from 1). +.ss the semantics of ttyslot +thus, the function +.br ttyslot () +returns the index of the controlling terminal of the calling process +in the file +.ir /etc/ttys , +and that is (usually) the same as the index of the entry for the +current user in the file +.ir /etc/utmp . +bsd still has the +.i /etc/ttys +file, but system v-like systems do not, and hence cannot refer to it. +thus, on such systems the documentation says that +.br ttyslot () +returns the current user's index in the user accounting data base. +.sh return value +if successful, this function returns the slot number. +on error (e.g., if none of the file descriptors 0, 1, or 2 is +associated with a terminal that occurs in this data base) +it returns 0 on unix\ v6 and v7 and bsd-like systems, +but \-1 on system v-like systems. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br ttyslot () +t} thread safety mt-unsafe +.te +.hy +.ad +.sp 1 +.sh conforming to +susv1; marked as legacy in susv2; removed in posix.1-2001. +susv2 requires \-1 on error. +.sh notes +the utmp file is found in various places on various systems, such as +.ir /etc/utmp , +.ir /var/adm/utmp , +.ir /var/run/utmp . +.pp +the glibc2 implementation of this function reads the file +.br _path_ttys , +defined in +.i +as "/etc/ttys". +it returns 0 on error. +since linux systems do not usually have "/etc/ttys", it will +always return 0. +.pp +on bsd-like systems and linux, the declaration of +.br ttyslot () +is provided by +.ir . +on system v-like systems, the declaration is provided by +.ir . +since glibc 2.24, +.i +also provides the declaration with the following +feature test macro definitions: +.pp +.in +4n +.ex +(_xopen_source >= 500 || + (_xopen_source && _xopen_source_extended)) + && ! (_posix_c_source >= 200112l || _xopen_source >= 600) +.ee +.in +.pp +minix also has +.ir fttyslot ( fd ). +.\" .sh history +.\" .br ttyslot () +.\" appeared in unix v7. +.sh see also +.br getttyent (3), +.br ttyname (3), +.br utmp (5) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/posix_fadvise.2 + +.\" this manpage is copyright (c) 2004, michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" 2004-05-40 created by michael kerrisk +.\" 2004-10-05 aeb, minor correction +.\" +.th readahead 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +readahead \- initiate file readahead into page cache +.sh synopsis +.nf +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "ssize_t readahead(int " fd ", off64_t " offset ", size_t " count ); +.fi +.sh description +.br readahead () +initiates readahead on a file so that subsequent reads from that file will +be satisfied from the cache, and not block on disk i/o +(assuming the readahead was initiated early enough and that other activity +on the system did not in the meantime flush pages from the cache). +.pp +the +.i fd +argument is a file descriptor identifying the file which is +to be read. +the +.i offset +argument specifies the starting point from which data is to be read +and +.i count +specifies the number of bytes to be read. +i/o is performed in whole pages, so that +.i offset +is effectively rounded down to a page boundary +and bytes are read up to the next page boundary greater than or +equal to +.ir "(offset+count)" . +.br readahead () +does not read beyond the end of the file. +the file offset of the open file description referred to by the file descriptor +.i fd +is left unchanged. +.sh return value +on success, +.br readahead () +returns 0; on failure, \-1 is returned, with +.i errno +set to indicate the error. +.sh errors +.tp +.b ebadf +.i fd +is not a valid file descriptor or is not open for reading. +.tp +.b einval +.i fd +does not refer to a file type to which +.br readahead () +can be applied. +.sh versions +the +.br readahead () +system call appeared in linux 2.4.13; +glibc support has been provided since version 2.3. +.sh conforming to +the +.br readahead () +system call is linux-specific, and its use should be avoided +in portable applications. +.sh notes +on some 32-bit architectures, +the calling signature for this system call differs, +for the reasons described in +.br syscall (2). +.sh bugs +.br readahead () +attempts to schedule the reads in the background and return immediately. +however, it may block while it reads the filesystem metadata needed +to locate the requested blocks. +this occurs frequently with ext[234] on large files +using indirect blocks instead of extents, +giving the appearance that the call blocks until the requested data has +been read. +.sh see also +.br lseek (2), +.br madvise (2), +.br mmap (2), +.br posix_fadvise (2), +.br read (2) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/cexp.3 + +.so man3/strsignal.3 + +.so man2/fchown.2 + +.so man2/unimplemented.2 + +.\" copyright 1993 ulrich drepper (drepper@karlsruhe.gmd.de) +.\" and copyright 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" references consulted: +.\" sunos 4.1.1 man pages +.\" modified sat sep 30 21:52:01 1995 by jim van zandt +.\" remarks from dhw@gamgee.acad.emich.edu fri jun 19 06:46:31 1998 +.\" modified 2001-12-26, 2003-11-28, 2004-05-20, aeb +.\" 2008-09-02, mtk: various additions and rewrites +.\" 2008-09-03, mtk, restructured somewhat, in part after suggestions from +.\" timothy s. nelson +.\" +.th hsearch 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +hcreate, hdestroy, hsearch, hcreate_r, hdestroy_r, +hsearch_r \- hash table management +.sh synopsis +.nf +.b #include +.pp +.bi "int hcreate(size_t " nel ); +.b "void hdestroy(void);" +.pp +.bi "entry *hsearch(entry " item ", action " action ); +.pp +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "int hcreate_r(size_t " nel ", struct hsearch_data *" htab ); +.bi "void hdestroy_r(struct hsearch_data *" htab ); +.pp +.bi "int hsearch_r(entry " item ", action " action ", entry **" retval , +.bi " struct hsearch_data *" htab ); +.fi +.sh description +the three functions +.br hcreate (), +.br hsearch (), +and +.br hdestroy () +allow the caller to create and manage a hash search table +containing entries consisting of a key (a string) and associated data. +using these functions, only one hash table can be used at a time. +.pp +the three functions +.br hcreate_r (), +.br hsearch_r (), +.br hdestroy_r () +are reentrant versions that allow a program to use +more than one hash search table at the same time. +the last argument, +.ir htab , +points to a structure that describes the table +on which the function is to operate. +the programmer should treat this structure as opaque +(i.e., do not attempt to directly access or modify +the fields in this structure). +.pp +first a hash table must be created using +.br hcreate (). +the argument \finel\fp specifies the maximum number of entries +in the table. +(this maximum cannot be changed later, so choose it wisely.) +the implementation may adjust this value upward to improve the +performance of the resulting hash table. +.\" e.g., in glibc it is raised to the next higher prime number +.pp +the +.br hcreate_r () +function performs the same task as +.br hcreate (), +but for the table described by the structure +.ir *htab . +the structure pointed to by +.i htab +must be zeroed before the first call to +.br hcreate_r (). +.pp +the function +.br hdestroy () +frees the memory occupied by the hash table that was created by +.br hcreate (). +after calling +.br hdestroy (), +a new hash table can be created using +.br hcreate (). +the +.br hdestroy_r () +function performs the analogous task for a hash table described by +.ir *htab , +which was previously created using +.br hcreate_r (). +.pp +the +.br hsearch () +function searches the hash table for an +item with the same key as \fiitem\fp (where "the same" is determined using +.br strcmp (3)), +and if successful returns a pointer to it. +.pp +the argument \fiitem\fp is of type \fientry\fp, which is defined in +\fi\fp as follows: +.pp +.in +4n +.ex +typedef struct entry { + char *key; + void *data; +} entry; +.ee +.in +.pp +the field \fikey\fp points to a null-terminated string which is the +search key. +the field \fidata\fp points to data that is associated with that key. +.pp +the argument \fiaction\fp determines what +.br hsearch () +does after an unsuccessful search. +this argument must either have the value +.br enter , +meaning insert a copy of +.ir item +(and return a pointer to the new hash table entry as the function result), +or the value +.br find , +meaning that null should be returned. +(if +.i action +is +.br find , +then +.i data +is ignored.) +.pp +the +.br hsearch_r () +function is like +.br hsearch () +but operates on the hash table described by +.ir *htab . +the +.br hsearch_r () +function differs from +.br hsearch () +in that a pointer to the found item is returned in +.ir *retval , +rather than as the function result. +.sh return value +.br hcreate () +and +.br hcreate_r () +return nonzero on success. +they return 0 on error, with +.i errno +set to indicate the error. +.pp +on success, +.br hsearch () +returns a pointer to an entry in the hash table. +.br hsearch () +returns null on error, that is, +if \fiaction\fp is \fbenter\fp and +the hash table is full, or \fiaction\fp is \fbfind\fp and \fiitem\fp +cannot be found in the hash table. +.br hsearch_r () +returns nonzero on success, and 0 on error. +in the event of an error, these two functions set +.i errno +to indicate the error. +.sh errors +.br hcreate_r () +and +.br hdestroy_r () +can fail for the following reasons: +.tp +.b einval +.i htab +is null. +.pp +.br hsearch () +and +.br hsearch_r () +can fail for the following reasons: +.tp +.b enomem +.i action +was +.br enter , +.i key +was not found in the table, +and there was no room in the table to add a new entry. +.tp +.b esrch +.i action +was +.br find , +and +.i key +was not found in the table. +.pp +posix.1 specifies only the +.\" prox.1-2001, posix.1-2008 +.b enomem +error. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br hcreate (), +.br hsearch (), +.br hdestroy () +t} thread safety mt-unsafe race:hsearch +t{ +.br hcreate_r (), +.br hsearch_r (), +.br hdestroy_r () +t} thread safety mt-safe race:htab +.te +.hy +.ad +.sp 1 +.sh conforming to +the functions +.br hcreate (), +.br hsearch (), +and +.br hdestroy () +are from svr4, and are described in posix.1-2001 and posix.1-2008. +.pp +the functions +.br hcreate_r (), +.br hsearch_r (), +and +.br hdestroy_r () +are gnu extensions. +.sh notes +hash table implementations are usually more efficient when the +table contains enough free space to minimize collisions. +typically, this means that +.i nel +should be at least 25% larger than the maximum number of elements +that the caller expects to store in the table. +.pp +the +.br hdestroy () +and +.br hdestroy_r () +functions do not free the buffers pointed to by the +.i key +and +.i data +elements of the hash table entries. +(it can't do this because it doesn't know +whether these buffers were allocated dynamically.) +if these buffers need to be freed (perhaps because the program +is repeatedly creating and destroying hash tables, +rather than creating a single table whose lifetime +matches that of the program), +then the program must maintain bookkeeping data structures that +allow it to free them. +.sh bugs +svr4 and posix.1-2001 specify that \fiaction\fp +is significant only for unsuccessful searches, so that an \fbenter\fp +should not do anything for a successful search. +in libc and glibc (before version 2.3), the +implementation violates the specification, +updating the \fidata\fp for the given \fikey\fp in this case. +.pp +individual hash table entries can be added, but not deleted. +.sh examples +the following program inserts 24 items into a hash table, then prints +some of them. +.pp +.ex +#include +#include +#include + +static char *data[] = { "alpha", "bravo", "charlie", "delta", + "echo", "foxtrot", "golf", "hotel", "india", "juliet", + "kilo", "lima", "mike", "november", "oscar", "papa", + "quebec", "romeo", "sierra", "tango", "uniform", + "victor", "whisky", "x\-ray", "yankee", "zulu" +}; + +int +main(void) +{ + entry e; + entry *ep; + + hcreate(30); + + for (int i = 0; i < 24; i++) { + e.key = data[i]; + /* data is just an integer, instead of a + pointer to something */ + e.data = (void *) i; + ep = hsearch(e, enter); + /* there should be no failures */ + if (ep == null) { + fprintf(stderr, "entry failed\en"); + exit(exit_failure); + } + } + + for (int i = 22; i < 26; i++) { + /* print two entries from the table, and + show that two are not in the table */ + e.key = data[i]; + ep = hsearch(e, find); + printf("%9.9s \-> %9.9s:%d\en", e.key, + ep ? ep\->key : "null", ep ? (int)(ep\->data) : 0); + } + hdestroy(); + exit(exit_success); +} +.ee +.sh see also +.br bsearch (3), +.br lsearch (3), +.br malloc (3), +.br tsearch (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/finite.3 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" and copyright 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified 1993-07-24 by rik faith (faith@cs.unc.edu) +.\" modified 1995-08-14 by arnt gulbrandsen +.\" modified 2002-07-27 by walter harms +.\" (walter.harms@informatik.uni-oldenburg.de) +.\" +.th log2 3 2021-03-22 "" "linux programmer's manual" +.sh name +log2, log2f, log2l \- base-2 logarithmic function +.sh synopsis +.nf +.b #include +.pp +.bi "double log2(double " x ); +.bi "float log2f(float " x ); +.bi "long double log2l(long double " x ); +.fi +.pp +link with \fi\-lm\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br log2 (), +.br log2f (), +.br log2l (): +.nf + _isoc99_source || _posix_c_source >= 200112l +.fi +.sh description +these functions return the base 2 logarithm of +.ir x . +.sh return value +on success, these functions return the base 2 logarithm of +.ir x . +.pp +for special cases, including where +.i x +is 0, 1, negative, infinity, or nan, see +.br log (3). +.sh errors +see +.br math_error (7) +for information on how to determine whether an error has occurred +when calling these functions. +.pp +for a discussion of the errors that can occur for these functions, see +.br log (3). +.sh versions +these functions first appeared in glibc in version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br log2 (), +.br log2f (), +.br log2l () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.pp +the variant returning +.i double +also conforms to +svr4, 4.3bsd. +.sh see also +.br cbrt (3), +.br clog2 (3), +.br log (3), +.br log10 (3), +.br sqrt (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/fenv.3 + +.so man2/shmop.2 + +.so man3/tzset.3 + +.so man3/fenv.3 + +.so man7/system_data_types.7 + +.so man7/iso_8859-3.7 + +.so man3/div.3 + +.\" copyright 2003 walter harms (walter.harms@informatik.uni-oldenburg.de) +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under gpl +.\" %%%license_end +.\" +.\" polished a bit, added a little, aeb +.\" +.th setaliasent 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +setaliasent, endaliasent, getaliasent, getaliasent_r, +getaliasbyname, getaliasbyname_r \- read an alias entry +.sh synopsis +.nf +.b #include +.pp +.b "void setaliasent(void);" +.b "void endaliasent(void);" +.pp +.b "struct aliasent *getaliasent(void);" +.bi "int getaliasent_r(struct aliasent *restrict " result , +.bi " char *restrict " buffer ", size_t " buflen , +.bi " struct aliasent **restrict " res ); +.pp +.bi "struct aliasent *getaliasbyname(const char *" name ); +.bi "int getaliasbyname_r(const char *restrict " name , +.bi " struct aliasent *restrict " result , +.bi " char *restrict " buffer ", size_t " buflen , +.bi " struct aliasent **restrict " res ); +.fi +.sh description +one of the databases available with the name service switch (nss) +is the aliases database, that contains mail aliases. +(to find out which databases are supported, try +.ir "getent \-\-help" .) +six functions are provided to access the aliases database. +.pp +the +.br getaliasent () +function returns a pointer to a structure containing +the group information from the aliases database. +the first time it is called it returns the first entry; +thereafter, it returns successive entries. +.pp +the +.br setaliasent () +function rewinds the file pointer to the beginning of the +aliases database. +.pp +the +.br endaliasent () +function closes the aliases database. +.pp +.br getaliasent_r () +is the reentrant version of the previous function. +the requested structure +is stored via the first argument but the programmer needs to fill the other +arguments also. +not providing enough space causes the function to fail. +.pp +the function +.br getaliasbyname () +takes the name argument and searches the aliases database. +the entry is returned as a pointer to a +.ir "struct aliasent" . +.pp +.br getaliasbyname_r () +is the reentrant version of the previous function. +the requested structure +is stored via the second argument but the programmer needs to fill the other +arguments also. +not providing enough space causes the function to fail. +.pp +the +.i "struct aliasent" +is defined in +.ir : +.pp +.in +4n +.ex +struct aliasent { + char *alias_name; /* alias name */ + size_t alias_members_len; + char **alias_members; /* alias name list */ + int alias_local; +}; +.ee +.in +.sh return value +the functions +.br getaliasent_r () +and +.br getaliasbyname_r () +return a nonzero value on error. +.sh files +the default alias database is the file +.ir /etc/aliases . +this can be changed in the +.i /etc/nsswitch.conf +file. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br setaliasent (), +.br endaliasent (), +.br getaliasent_r (), +.br getaliasbyname_r () +t} thread safety mt-safe locale +t{ +.br getaliasent (), +.br getaliasbyname () +t} thread safety mt-unsafe +.te +.hy +.ad +.sp 1 +.sh conforming to +these routines are glibc-specific. +the next system has similar routines: +.pp +.in +4n +.ex +#include + +void alias_setent(void); +void alias_endent(void); +alias_ent *alias_getent(void); +alias_ent *alias_getbyname(char *name); +.ee +.in +.sh examples +the following example compiles with +.ir "gcc example.c \-o example" . +it will dump all names in the alias database. +.pp +.ex +#include +#include +#include +#include + +int +main(void) +{ + struct aliasent *al; + setaliasent(); + for (;;) { + al = getaliasent(); + if (al == null) + break; + printf("name: %s\en", al\->alias_name); + } + if (errno) { + perror("reading alias"); + exit(exit_failure); + } + endaliasent(); + exit(exit_success); +} +.ee +.sh see also +.br getgrent (3), +.br getpwent (3), +.br getspent (3), +.br aliases (5) +.\" +.\" /etc/sendmail/aliases +.\" yellow pages +.\" newaliases, postalias +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/rpc.3 + +.so man3/toupper.3 + +.so man2/tkill.2 + +.\" copyright (c) 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" a few pieces remain from an earlier version written in +.\" 2002 by walter harms (walter.harms@informatik.uni-oldenburg.de) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th getgrouplist 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +getgrouplist \- get list of groups to which a user belongs +.sh synopsis +.nf +.b #include +.pp +.bi "int getgrouplist(const char *" user ", gid_t " group , +.bi " gid_t *" groups ", int *" ngroups ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br getgrouplist (): +.nf + since glibc 2.19: + _default_source + glibc 2.19 and earlier: + _bsd_source +.fi +.sh description +the +.br getgrouplist () +function scans the group database (see +.br group (5)) +to obtain the list of groups that +.i user +belongs to. +up to +.i *ngroups +of these groups are returned in the array +.ir groups . +.pp +if it was not among the groups defined for +.i user +in the group database, then +.i group +is included in the list of groups returned by +.br getgrouplist (); +typically this argument is specified as the group id from +the password record for +.ir user . +.pp +the +.i ngroups +argument is a value-result argument: +on return it always contains the number of groups found for +.ir user , +including +.ir group ; +this value may be greater than the number of groups stored in +.ir groups . +.sh return value +if the number of groups of which +.i user +is a member is less than or equal to +.ir *ngroups , +then the value +.i *ngroups +is returned. +.pp +if the user is a member of more than +.i *ngroups +groups, then +.br getgrouplist () +returns \-1. +in this case, the value returned in +.ir *ngroups +can be used to resize the buffer passed to a further call +.br getgrouplist (). +.sh versions +this function is present since glibc 2.2.4. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br getgrouplist () +t} thread safety mt-safe locale +.te +.hy +.ad +.sp 1 +.sh conforming to +this function is nonstandard; it appears on most bsds. +.sh bugs +in glibc versions before 2.3.3, +the implementation of this function contains a buffer-overrun bug: +it returns the complete list of groups for +.ir user +in the array +.ir groups , +even when the number of groups exceeds +.ir *ngroups . +.sh examples +the program below displays the group list for the user named in its +first command-line argument. +the second command-line argument specifies the +.i ngroups +value to be supplied to +.br getgrouplist (). +the following shell session shows examples of the use of this program: +.pp +.in +4n +.ex +.rb "$" " ./a.out cecilia 0" +getgrouplist() returned \-1; ngroups = 3 +.rb "$" " ./a.out cecilia 3" +ngroups = 3 +16 (dialout) +33 (video) +100 (users) +.ee +.in +.ss program source +\& +.ex +#include +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + int ngroups; + struct passwd *pw; + struct group *gr; + + if (argc != 3) { + fprintf(stderr, "usage: %s \en", argv[0]); + exit(exit_failure); + } + + ngroups = atoi(argv[2]); + + gid_t *groups = malloc(sizeof(*groups) * ngroups); + if (groups == null) { + perror("malloc"); + exit(exit_failure); + } + + /* fetch passwd structure (contains first group id for user). */ + + pw = getpwnam(argv[1]); + if (pw == null) { + perror("getpwnam"); + exit(exit_success); + } + + /* retrieve group list. */ + + if (getgrouplist(argv[1], pw\->pw_gid, groups, &ngroups) == \-1) { + fprintf(stderr, "getgrouplist() returned \-1; ngroups = %d\en", + ngroups); + exit(exit_failure); + } + + /* display list of retrieved groups, along with group names. */ + + fprintf(stderr, "ngroups = %d\en", ngroups); + for (int j = 0; j < ngroups; j++) { + printf("%d", groups[j]); + gr = getgrgid(groups[j]); + if (gr != null) + printf(" (%s)", gr\->gr_name); + printf("\en"); + } + + exit(exit_success); +} +.ee +.sh see also +.br getgroups (2), +.br setgroups (2), +.br getgrent (3), +.br group_member (3), +.br group (5), +.br passwd (5) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/lround.3 + +.\" copyright (c) 2008 linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th pthread_tryjoin_np 3 2021-08-27 "linux" "linux programmer's manual" +.sh name +pthread_tryjoin_np, pthread_timedjoin_np \- try to join with a +terminated thread +.sh synopsis +.nf +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "int pthread_tryjoin_np(pthread_t " thread ", void **" retval ); +.bi "int pthread_timedjoin_np(pthread_t " thread ", void **" retval , +.bi " const struct timespec *" abstime ); +.fi +.pp +compile and link with \fi\-pthread\fp. +.sh description +these functions operate in the same way as +.br pthread_join (3), +except for the differences described on this page. +.pp +the +.br pthread_tryjoin_np () +function performs a nonblocking join with the thread +.ir thread , +returning the exit status of the thread in +.ir *retval . +if +.i thread +has not yet terminated, then instead of blocking, as is done by +.br pthread_join (3), +the call returns an error. +.pp +the +.br pthread_timedjoin_np () +function performs a join-with-timeout. +if +.i thread +has not yet terminated, +then the call blocks until a maximum time, specified in +.ir abstime , +measured against the +.br clock_realtime +clock. +if the timeout expires before +.i thread +terminates, +the call returns an error. +the +.i abstime +argument is a structure of the following form, +specifying an absolute time measured since the epoch (see +.br time (2)): +.pp +.in +4n +.ex +struct timespec { + time_t tv_sec; /* seconds */ + long tv_nsec; /* nanoseconds */ +}; +.ee +.in +.sh return value +on success, +these functions return 0; +on error, they return an error number. +.sh errors +these functions can fail with the same errors as +.br pthread_join (3). +.br pthread_tryjoin_np () +can in addition fail with the following error: +.tp +.b ebusy +.i thread +had not yet terminated at the time of the call. +.pp +.br pthread_timedjoin_np () +can in addition fail with the following errors: +.tp +.br einval +.i abstime +value is invalid +.ri ( tv_sec +is less than 0 or +.ir tv_nsec +is greater than 1e9). +.tp +.br etimedout +the call timed out before +.i thread +terminated. +.pp +.br pthread_timedjoin_np () +never returns the error +.br eintr . +.sh versions +these functions first appeared in glibc in version 2.3.3. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br pthread_tryjoin_np (), +.br pthread_timedjoin_np () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +these functions are nonstandard gnu extensions; +hence the suffix "_np" (nonportable) in the names. +.sh bugs +the +.br pthread_timedjoin_np () +function measures time by internally calculating a relative sleep interval +that is then measured against the +.br clock_monotonic +clock instead of the +.br clock_realtime +clock. +consequently, the timeout is unaffected by discontinuous changes to the +.br clock_realtime +clock. +.sh examples +the following code waits to join for up to 5 seconds: +.pp +.in +4n +.ex +struct timespec ts; +int s; + +\&... + +if (clock_gettime(clock_realtime, &ts) == \-1) { + /* handle error */ +} + +ts.tv_sec += 5; + +s = pthread_timedjoin_np(thread, null, &ts); +if (s != 0) { + /* handle error */ +} +.ee +.in +.sh see also +.br clock_gettime (2), +.br pthread_exit (3), +.br pthread_join (3), +.br pthreads (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man7/system_data_types.7 + +.so man3/tanh.3 + +.so man3/inet.3 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" and copyright 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified 1993-07-24 by rik faith (faith@cs.unc.edu) +.\" modified 1995-08-14 by arnt gulbrandsen +.\" modified 2002-07-27 by walter harms +.\" (walter.harms@informatik.uni-oldenburg.de) +.th exp10 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +exp10, exp10f, exp10l \- base-10 exponential function +.sh synopsis +.nf +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "double exp10(double " x ); +.bi "float exp10f(float " x ); +.bi "long double exp10l(long double " x ); +.fi +.pp +link with \fi\-lm\fp. +.sh description +these functions return the value of 10 +raised to the power of +.ir x . +.sh return value +on success, these functions return the base-10 exponential value of +.ir x . +.pp +for various special cases, including the handling of infinity and nan, +as well as overflows and underflows, see +.br exp (3). +.sh errors +see +.br math_error (7) +for information on how to determine whether an error has occurred +when calling these functions. +.pp +for a discussion of the errors that can occur for these functions, see +.br exp (3). +.sh versions +these functions first appeared in glibc in version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br exp10 (), +.br exp10f (), +.br exp10l () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +these functions are gnu extensions. +.sh bugs +prior to version 2.19, the glibc implementation of these functions did not set +.i errno +to +.b erange +when an underflow error occurred. +.\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=6787 +.sh see also +.br cbrt (3), +.br exp (3), +.br exp2 (3), +.br log10 (3), +.br sqrt (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1993 by thomas koenig (ig25@rz.uni-karlsruhe.de) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified sat jul 24 17:51:42 1993 by rik faith (faith@cs.unc.edu) +.\" modified tue aug 17 11:42:20 1999 by ariel scolnicov (ariels@compugen.co.il) +.th sysconf 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +sysconf \- get configuration information at run time +.sh synopsis +.nf +.b #include +.pp +.bi "long sysconf(int " "name" ); +.fi +.sh description +posix allows an application to test at compile or run time +whether certain options are supported, or what the value is +of certain configurable constants or limits. +.pp +at compile time this is done by including +.i +and/or +.i +and testing the value of certain macros. +.pp +at run time, one can ask for numerical values using the present function +.br sysconf (). +one can ask for numerical values that may depend +on the filesystem in which a file resides using +.br fpathconf (3) +and +.br pathconf (3). +one can ask for string values using +.br confstr (3). +.pp +the values obtained from these functions are system configuration constants. +they do not change during the lifetime of a process. +.\" except that sysconf(_sc_open_max) may change answer after a call +.\" to setrlimit( ) which changes the rlimit_nofile soft limit +.pp +for options, typically, there is a constant +.b _posix_foo +that may be defined in +.ir . +if it is undefined, one should ask at run time. +if it is defined to \-1, then the option is not supported. +if it is defined to 0, then relevant functions and headers exist, +but one has to ask at run time what degree of support is available. +if it is defined to a value other than \-1 or 0, then the option is +supported. +usually the value (such as 200112l) indicates the year and month +of the posix revision describing the option. +glibc uses the value 1 +to indicate support as long as the posix revision has not been published yet. +.\" and 999 to indicate support for options no longer present in the latest +.\" standard. (?) +the +.br sysconf () +argument will be +.br _sc_foo . +for a list of options, see +.br posixoptions (7). +.pp +for variables or limits, typically, there is a constant +.br _foo , +maybe defined in +.ir , +or +.br _posix_foo , +maybe defined in +.ir . +the constant will not be defined if the limit is unspecified. +if the constant is defined, it gives a guaranteed value, and +a greater value might actually be supported. +if an application wants to take advantage of values which may change +between systems, a call to +.br sysconf () +can be made. +the +.br sysconf () +argument will be +.br _sc_foo . +.ss posix.1 variables +we give the name of the variable, the name of the +.br sysconf () +argument used to inquire about its value, +and a short description. +.pp +first, the posix.1 compatible values. +.\" [for the moment: only the things that are unconditionally present] +.\" .tp +.\" .br aio_listio_max " - " _sc_aio_listio_max +.\" (if _posix_asynchronous_io) +.\" maximum number of i/o operations in a single list i/o call. +.\" must not be less than _posix_aio_listio_max. +.\" .tp +.\" .br aio_max " - " _sc_aio_max +.\" (if _posix_asynchronous_io) +.\" maximum number of outstanding asynchronous i/o operations. +.\" must not be less than _posix_aio_max. +.\" .tp +.\" .br aio_prio_delta_max " - " _sc_aio_prio_delta_max +.\" (if _posix_asynchronous_io) +.\" the maximum amount by which a process can decrease its +.\" asynchronous i/o priority level from its own scheduling priority. +.\" must be nonnegative. +.tp +.br arg_max " - " _sc_arg_max +the maximum length of the arguments to the +.br exec (3) +family of functions. +must not be less than +.b _posix_arg_max +(4096). +.tp +.br child_max " - " _sc_child_max +the maximum number of simultaneous processes per user id. +must not be less than +.b _posix_child_max +(25). +.tp +.br host_name_max " - " _sc_host_name_max +maximum length of a hostname, not including the terminating null byte, +as returned by +.br gethostname (2). +must not be less than +.b _posix_host_name_max +(255). +.tp +.br login_name_max " - " _sc_login_name_max +maximum length of a login name, including the terminating null byte. +must not be less than +.b _posix_login_name_max +(9). +.tp +.br ngroups_max " - " _sc_ngroups_max +maximum number of supplementary group ids. +.tp +.br "" "clock ticks - " _sc_clk_tck +the number of clock ticks per second. +the corresponding variable is obsolete. +it was of course called +.br clk_tck . +(note: the macro +.b clocks_per_sec +does not give information: it must equal 1000000.) +.tp +.br open_max " - " _sc_open_max +the maximum number of files that a process can have open at any time. +must not be less than +.b _posix_open_max +(20). +.tp +.br pagesize " - " _sc_pagesize +size of a page in bytes. +must not be less than 1. +.tp +.br page_size " - " _sc_page_size +a synonym for +.br pagesize / _sc_pagesize . +(both +.br pagesize +and +.br page_size +are specified in posix.) +.tp +.br re_dup_max " - " _sc_re_dup_max +the number of repeated occurrences of a bre permitted by +.br regexec (3) +and +.br regcomp (3). +must not be less than +.b _posix2_re_dup_max +(255). +.tp +.br stream_max " - " _sc_stream_max +the maximum number of streams that a process can have open at any +time. +if defined, it has the same value as the standard c macro +.br fopen_max . +must not be less than +.b _posix_stream_max +(8). +.tp +.br symloop_max " - " _sc_symloop_max +the maximum number of symbolic links seen in a pathname before resolution +returns +.br eloop . +must not be less than +.b _posix_symloop_max +(8). +.tp +.br tty_name_max " - " _sc_tty_name_max +the maximum length of terminal device name, +including the terminating null byte. +must not be less than +.b _posix_tty_name_max +(9). +.tp +.br tzname_max " - " _sc_tzname_max +the maximum number of bytes in a timezone name. +must not be less than +.b _posix_tzname_max +(6). +.tp +.br _posix_version " - " _sc_version +indicates the year and month the posix.1 standard was approved in the +format +.br yyyymml ; +the value +.b 199009l +indicates the sept. 1990 revision. +.ss posix.2 variables +next, the posix.2 values, giving limits for utilities. +.tp +.br bc_base_max " - " _sc_bc_base_max +indicates the maximum +.i obase +value accepted by the +.br bc (1) +utility. +.tp +.br bc_dim_max " - " _sc_bc_dim_max +indicates the maximum value of elements permitted in an array by +.br bc (1). +.tp +.br bc_scale_max " - " _sc_bc_scale_max +indicates the maximum +.i scale +value allowed by +.br bc (1). +.tp +.br bc_string_max " - " _sc_bc_string_max +indicates the maximum length of a string accepted by +.br bc (1). +.tp +.br coll_weights_max " - " _sc_coll_weights_max +indicates the maximum numbers of weights that can be assigned to an +entry of the +.b lc_collate order +keyword in the locale definition file. +.tp +.br expr_nest_max " - " _sc_expr_nest_max +is the maximum number of expressions which can be nested within +parentheses by +.br expr (1). +.tp +.br line_max " - " _sc_line_max +the maximum length of a utility's input line, either from +standard input or from a file. +this includes space for a trailing +newline. +.tp +.br re_dup_max " - " _sc_re_dup_max +the maximum number of repeated occurrences of a regular expression when +the interval notation +.b \e{m,n\e} +is used. +.tp +.br posix2_version " - " _sc_2_version +indicates the version of the posix.2 standard in the format of +yyyymml. +.tp +.br posix2_c_dev " - " _sc_2_c_dev +indicates whether the posix.2 c language development facilities are +supported. +.tp +.br posix2_fort_dev " - " _sc_2_fort_dev +indicates whether the posix.2 fortran development utilities are +supported. +.tp +.br posix2_fort_run " - " _sc_2_fort_run +indicates whether the posix.2 fortran run-time utilities are supported. +.tp +.br _posix2_localedef " - " _sc_2_localedef +indicates whether the posix.2 creation of locales via +.br localedef (1) +is supported. +.tp +.br posix2_sw_dev " - " _sc_2_sw_dev +indicates whether the posix.2 software development utilities option is +supported. +.pp +these values also exist, but may not be standard. +.tp +.br "" " - " _sc_phys_pages +the number of pages of physical memory. +note that it is possible +for the product of this value and the value of +.b _sc_pagesize +to overflow. +.tp +.br "" " - " _sc_avphys_pages +the number of currently available pages of physical memory. +.tp +.br "" " - " _sc_nprocessors_conf +the number of processors configured. +see also +.br get_nprocs_conf (3). +.tp +.br "" " - " _sc_nprocessors_onln +the number of processors currently online (available). +see also +.br get_nprocs_conf (3). +.sh return value +the return value of +.br sysconf () +is one of the following: +.ip * 3 +on error, \-1 is returned and +.i errno +is set to indicate the error +(for example, +.br einval , +indicating that +.i name +is invalid). +.ip * +if +.i name +corresponds to a maximum or minimum limit, and that limit is indeterminate, +\-1 is returned and +.i errno +is not changed. +(to distinguish an indeterminate limit from an error, set +.i errno +to zero before the call, and then check whether +.i errno +is nonzero when \-1 is returned.) +.ip * +if +.i name +corresponds to an option, +a positive value is returned if the option is supported, +and \-1 is returned if the option is not supported. +.ip * +otherwise, +the current value of the option or limit is returned. +this value will not be more restrictive than +the corresponding value that was described to the application in +.i +or +.i +when the application was compiled. +.sh errors +.tp +.b einval +.i name +is invalid. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br sysconf () +t} thread safety mt-safe env +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh bugs +it is difficult to use +.b arg_max +because it is not specified how much of the argument space for +.br exec (3) +is consumed by the user's environment variables. +.pp +some returned values may be huge; they are not suitable for allocating +memory. +.sh see also +.br bc (1), +.br expr (1), +.br getconf (1), +.br locale (1), +.br confstr (3), +.br fpathconf (3), +.br pathconf (3), +.br posixoptions (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/mcheck.3 + +.\" copyright 1993 giorgio ciucci (giorgio@crcc.it) +.\" and copyright 2004, 2005 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified tue oct 22 17:53:56 1996 by eric s. raymond +.\" modified fri jun 19 10:59:15 1998 by andries brouwer +.\" modified sun feb 18 01:59:29 2001 by andries brouwer +.\" modified 20 dec 2001, michael kerrisk +.\" modified 21 dec 2001, aeb +.\" modified 27 may 2004, michael kerrisk +.\" added notes on cap_ipc_owner requirement +.\" modified 17 jun 2004, michael kerrisk +.\" added notes on cap_sys_admin requirement for ipc_set and ipc_rmid +.\" modified, 11 nov 2004, michael kerrisk +.\" language and formatting clean-ups +.\" rewrote semun text +.\" added semid_ds and ipc_perm structure definitions +.\" 2005-08-02, mtk: added ipc_info, sem_info, sem_stat descriptions. +.\" 2018-03-20, dbueso: added sem_stat_any description. +.\" +.th semctl 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +semctl \- system v semaphore control operations +.sh synopsis +.nf +.b #include +.pp +.bi "int semctl(int " semid ", int " semnum ", int " cmd ", ...);" +.fi +.sh description +.br semctl () +performs the control operation specified by +.i cmd +on the system\ v semaphore set identified by +.ir semid , +or on the +.ir semnum -th +semaphore of that set. +(the semaphores in a set are numbered starting at 0.) +.pp +this function has three or four arguments, depending on +.ir cmd . +when there are four, the fourth has the type +.ir "union semun" . +the \ficalling program\fp must define this union as follows: +.pp +.in +4n +.ex +union semun { + int val; /* value for setval */ + struct semid_ds *buf; /* buffer for ipc_stat, ipc_set */ + unsigned short *array; /* array for getall, setall */ + struct seminfo *__buf; /* buffer for ipc_info + (linux\-specific) */ +}; +.ee +.in +.pp +the +.i semid_ds +data structure is defined in \fi\fp as follows: +.pp +.in +4n +.ex +struct semid_ds { + struct ipc_perm sem_perm; /* ownership and permissions */ + time_t sem_otime; /* last semop time */ + time_t sem_ctime; /* creation time/time of last + modification via semctl() */ + unsigned long sem_nsems; /* no. of semaphores in set */ +}; +.ee +.in +.pp +the fields of the +.i semid_ds +structure are as follows: +.tp 11 +.i sem_perm +this is an +.i ipc_perm +structure (see below) that specifies the access permissions on the semaphore +set. +.tp +.i sem_otime +time of last +.br semop (2) +system call. +.tp +.i sem_ctime +time of creation of semaphore set or time of last +.br semctl () +.br ipcset , +.br setval , +or +.br setall +operation. +.tp +.i sem_nsems +number of semaphores in the set. +each semaphore of the set is referenced by a nonnegative integer +ranging from +.b 0 +to +.ir sem_nsems\-1 . +.pp +the +.i ipc_perm +structure is defined as follows +(the highlighted fields are settable using +.br ipc_set ): +.pp +.in +4n +.ex +struct ipc_perm { + key_t __key; /* key supplied to semget(2) */ + uid_t \fbuid\fp; /* effective uid of owner */ + gid_t \fbgid\fp; /* effective gid of owner */ + uid_t cuid; /* effective uid of creator */ + gid_t cgid; /* effective gid of creator */ + unsigned short \fbmode\fp; /* permissions */ + unsigned short __seq; /* sequence number */ +}; +.ee +.in +.pp +the least significant 9 bits of the +.i mode +field of the +.i ipc_perm +structure define the access permissions for the shared memory segment. +the permission bits are as follows: +.ts +l l. +0400 read by user +0200 write by user +0040 read by group +0020 write by group +0004 read by others +0002 write by others +.te +.pp +in effect, "write" means "alter" for a semaphore set. +bits 0100, 0010, and 0001 (the execute bits) are unused by the system. +.pp +valid values for +.i cmd +are: +.tp +.b ipc_stat +copy information from the kernel data structure associated with +.i semid +into the +.i semid_ds +structure pointed to by +.ir arg.buf . +the argument +.i semnum +is ignored. +the calling process must have read permission on the semaphore set. +.tp +.b ipc_set +write the values of some members of the +.i semid_ds +structure pointed to by +.i arg.buf +to the kernel data structure associated with this semaphore set, +updating also its +.i sem_ctime +member. +.ip +the following members of the structure are updated: +.ir sem_perm.uid , +.ir sem_perm.gid , +and (the least significant 9 bits of) +.ir sem_perm.mode . +.ip +the effective uid of the calling process must match the owner +.ri ( sem_perm.uid ) +or creator +.ri ( sem_perm.cuid ) +of the semaphore set, or the caller must be privileged. +the argument +.i semnum +is ignored. +.tp +.b ipc_rmid +immediately remove the semaphore set, +awakening all processes blocked in +.br semop (2) +calls on the set (with an error return and +.i errno +set to +.br eidrm ). +the effective user id of the calling process must +match the creator or owner of the semaphore set, +or the caller must be privileged. +the argument +.i semnum +is ignored. +.tp +.br ipc_info " (linux\-specific)" +return information about system-wide semaphore limits and +parameters in the structure pointed to by +.ir arg.__buf . +this structure is of type +.ir seminfo , +defined in +.i +if the +.b _gnu_source +feature test macro is defined: +.ip +.in +4n +.ex +struct seminfo { + int semmap; /* number of entries in semaphore + map; unused within kernel */ + int semmni; /* maximum number of semaphore sets */ + int semmns; /* maximum number of semaphores in all + semaphore sets */ + int semmnu; /* system\-wide maximum number of undo + structures; unused within kernel */ + int semmsl; /* maximum number of semaphores in a + set */ + int semopm; /* maximum number of operations for + semop(2) */ + int semume; /* maximum number of undo entries per + process; unused within kernel */ + int semusz; /* size of struct sem_undo */ + int semvmx; /* maximum semaphore value */ + int semaem; /* max. value that can be recorded for + semaphore adjustment (sem_undo) */ +}; +.ee +.in +.ip +the +.ir semmsl , +.ir semmns , +.ir semopm , +and +.i semmni +settings can be changed via +.ir /proc/sys/kernel/sem ; +see +.br proc (5) +for details. +.tp +.br sem_info " (linux-specific)" +return a +.i seminfo +structure containing the same information as for +.br ipc_info , +except that the following fields are returned with information +about system resources consumed by semaphores: the +.i semusz +field returns the number of semaphore sets that currently exist +on the system; and the +.i semaem +field returns the total number of semaphores in all semaphore sets +on the system. +.tp +.br sem_stat " (linux-specific)" +return a +.i semid_ds +structure as for +.br ipc_stat . +however, the +.i semid +argument is not a semaphore identifier, but instead an index into +the kernel's internal array that maintains information about +all semaphore sets on the system. +.tp +.br sem_stat_any " (linux-specific, since linux 4.17)" +return a +.i semid_ds +structure as for +.br sem_stat . +however, +.i sem_perm.mode +is not checked for read access for +.ir semid +meaning that any user can employ this operation (just as any user may read +.ir /proc/sysvipc/sem +to obtain the same information). +.tp +.b getall +return +.b semval +(i.e., the current value) +for all semaphores of the set into +.ir arg.array . +the argument +.i semnum +is ignored. +the calling process must have read permission on the semaphore set. +.tp +.b getncnt +return the +.b semncnt +value for the +.ir semnum \-th +semaphore of the set +(i.e., the number of processes waiting for the semaphore's value to increase). +the calling process must have read permission on the semaphore set. +.tp +.b getpid +return the +.b sempid +value for the +.ir semnum \-th +semaphore of the set. +this is the pid of the process that last performed an operation on +that semaphore (but see notes). +the calling process must have read permission on the semaphore set. +.tp +.b getval +return +.b semval +(i.e., the semaphore value) for the +.ir semnum \-th +semaphore of the set. +the calling process must have read permission on the semaphore set. +.tp +.b getzcnt +return the +.b semzcnt +value for the +.ir semnum \-th +semaphore of the set +(i.e., the number of processes waiting for the semaphore value to become 0). +the calling process must have read permission on the semaphore set. +.tp +.b setall +set the +.b semval +values for all semaphores of the set using +.ir arg.array , +updating also the +.i sem_ctime +member of the +.i semid_ds +structure associated with the set. +undo entries (see +.br semop (2)) +are cleared for altered semaphores in all processes. +if the changes to semaphore values would permit blocked +.br semop (2) +calls in other processes to proceed, then those processes are woken up. +the argument +.i semnum +is ignored. +the calling process must have alter (write) permission on +the semaphore set. +.tp +.b setval +set the semaphore value +.rb ( semval ) +to +.i arg.val +for the +.ir semnum \-th +semaphore of the set, updating also the +.i sem_ctime +member of the +.i semid_ds +structure associated with the set. +undo entries are cleared for altered semaphores in all processes. +if the changes to semaphore values would permit blocked +.br semop (2) +calls in other processes to proceed, then those processes are woken up. +the calling process must have alter permission on the semaphore set. +.sh return value +on success, +.br semctl () +returns a nonnegative value depending on +.i cmd +as follows: +.tp +.b getncnt +the value of +.br semncnt . +.tp +.b getpid +the value of +.br sempid . +.tp +.b getval +the value of +.br semval . +.tp +.b getzcnt +the value of +.br semzcnt . +.tp +.b ipc_info +the index of the highest used entry in the +kernel's internal array recording information about all +semaphore sets. +(this information can be used with repeated +.b sem_stat +or +.b sem_stat_any +operations to obtain information about all semaphore sets on the system.) +.tp +.b sem_info +as for +.br ipc_info . +.tp +.b sem_stat +the identifier of the semaphore set whose index was given in +.ir semid . +.tp +.b sem_stat_any +as for +.br sem_stat . +.pp +all other +.i cmd +values return 0 on success. +.pp +on failure, +.br semctl () +returns \-1 and sets +.i errno +to indicate the error. +.sh errors +.tp +.b eacces +the argument +.i cmd +has one of the values +.br getall , +.br getpid , +.br getval , +.br getncnt , +.br getzcnt , +.br ipc_stat , +.br sem_stat , +.br sem_stat_any , +.br setall , +or +.b setval +and the calling process does not have the required +permissions on the semaphore set and does not have the +.b cap_ipc_owner +capability in the user namespace that governs its ipc namespace. +.tp +.b efault +the address pointed to by +.i arg.buf +or +.i arg.array +isn't accessible. +.tp +.b eidrm +the semaphore set was removed. +.tp +.b einval +invalid value for +.i cmd +or +.ir semid . +or: for a +.b sem_stat +operation, the index value specified in +.i semid +referred to an array slot that is currently unused. +.tp +.b eperm +the argument +.i cmd +has the value +.b ipc_set +or +.b ipc_rmid +but the effective user id of the calling process is not the creator +(as found in +.ir sem_perm.cuid ) +or the owner +(as found in +.ir sem_perm.uid ) +of the semaphore set, +and the process does not have the +.b cap_sys_admin +capability. +.tp +.b erange +the argument +.i cmd +has the value +.b setall +or +.b setval +and the value to which +.b semval +is to be set (for some semaphore of the set) is less than 0 +or greater than the implementation limit +.br semvmx . +.sh conforming to +posix.1-2001, posix.1-2008, svr4. +.\" svr4 documents more error conditions einval and eoverflow. +.pp +posix.1 specifies the +.\" posix.1-2001, posix.1-2008 +.i sem_nsems +field of the +.i semid_ds +structure as having the type +.ir "unsigned\ short" , +and the field is so defined on most other systems. +it was also so defined on linux 2.2 and earlier, +but, since linux 2.4, the field has the type +.ir "unsigned\ long" . +.sh notes +the +.br ipc_info , +.br sem_stat , +and +.b sem_info +operations are used by the +.br ipcs (1) +program to provide information on allocated resources. +in the future these may modified or moved to a +.i /proc +filesystem interface. +.pp +various fields in a \fistruct semid_ds\fp were typed as +.i short +under linux 2.2 +and have become +.i long +under linux 2.4. +to take advantage of this, +a recompilation under glibc-2.1.91 or later should suffice. +(the kernel distinguishes old and new calls by an +.b ipc_64 +flag in +.ir cmd .) +.pp +in some earlier versions of glibc, the +.i semun +union was defined in \fi\fp, but posix.1 requires +.\" posix.1-2001, posix.1-2008 +that the caller define this union. +on versions of glibc where this union is \finot\fp defined, +the macro +.b _sem_semun_undefined +is defined in \fi\fp. +.pp +the following system limit on semaphore sets affects a +.br semctl () +call: +.tp +.b semvmx +maximum value for +.br semval : +implementation dependent (32767). +.pp +for greater portability, it is best to always call +.br semctl () +with four arguments. +.\" +.ss the sempid value +posix.1 defines +.i sempid +as the "process id of [the] last operation" on a semaphore, +and explicitly notes that this value is set by a successful +.br semop (2) +call, with the implication that no other interface affects the +.i sempid +value. +.pp +while some implementations conform to the behavior specified in posix.1, +others do not. +(the fault here probably lies with posix.1 inasmuch as it likely failed +to capture the full range of existing implementation behaviors.) +various other implementations +.\" at least opensolaris (and, one supposes, older solaris) and darwin +also update +.i sempid +for the other operations that update the value of a semaphore: the +.b setval +and +.b setall +operations, as well as the semaphore adjustments performed +on process termination as a consequence of the use of the +.b sem_undo +flag (see +.br semop (2)). +.pp +linux also updates +.i sempid +for +.br setval +operations and semaphore adjustments. +however, somewhat inconsistently, up to and including linux 4.5, +the kernel did not update +.i sempid +for +.br setall +operations. +this was rectified +.\" commit a5f4db877177d2a3d7ae62a7bac3a5a27e083d7f +in linux 4.6. +.sh examples +see +.br shmop (2). +.sh see also +.br ipc (2), +.br semget (2), +.br semop (2), +.br capabilities (7), +.br sem_overview (7), +.br sysvipc (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/fenv.3 + +.so man7/system_data_types.7 + +.\" copyright (c) 2016 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th bswap 3 2021-06-20 "linux" "linux programmer's manual" +.sh name +bswap_16, bswap_32, bswap_64 \- reverse order of bytes +.sh synopsis +.nf +.b #include +.pp +.bi "uint16_t bswap_16(uint16_t " x ); +.bi "uint32_t bswap_32(uint32_t " x ); +.bi "uint64_t bswap_64(uint64_t " x ); +.fi +.sh description +these functions return a value in which the order of the bytes +in their 2-, 4-, or 8-byte arguments is reversed. +.sh return value +these functions return the value of their argument with the bytes reversed. +.sh errors +these functions always succeed. +.sh conforming to +these functions are gnu extensions. +.sh examples +the program below swaps the bytes of the 8-byte integer supplied as +its command-line argument. +the following shell session demonstrates the use of the program: +.pp +.in +4n +.ex +$ \fb./a.out 0x0123456789abcdef\fp +0x123456789abcdef ==> 0xefcdab8967452301 +.ee +.in +.ss program source +\& +.ex +#include +#include +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + uint64_t x; + + if (argc != 2) { + fprintf(stderr, "usage: %s \en", argv[0]); + exit(exit_failure); + } + + x = strtoull(argv[1], null, 0); + printf("%#" prix64 " ==> %#" prix64 "\en", x, bswap_64(x)); + + exit(exit_success); +} +.ee +.sh see also +.br byteorder (3), +.br endian (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de) +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under gpl +.\" %%%license_end +.\" +.\" based on glibc infopages +.\" +.\" corrections by aeb +.\" +.th nan 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +nan, nanf, nanl \- return 'not a number' +.sh synopsis +.nf +.b #include +.pp +.bi "double nan(const char *" tagp ); +.bi "float nanf(const char *" tagp ); +.bi "long double nanl(const char *" tagp ); +.fi +.pp +link with \fi\-lm\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br nan (), +.br nanf (), +.br nanl (): +.nf + _isoc99_source || _posix_c_source >= 200112l +.fi +.sh description +these functions return a representation (determined by +.ir tagp ) +of a quiet nan. +if the implementation does not support +quiet nans, these functions return zero. +.pp +the call +.i nan("char\-sequence") +is equivalent to: +.pp +.in +4n +.ex +strtod("nan(char\-sequence)", null); +.ee +.in +.pp +similarly, calls to +.br nanf () +and +.br nanl () +are equivalent to analogous calls to +.br strtof (3) +and +.br strtold (3). +.pp +the argument +.i tagp +is used in an unspecified manner. +on ieee 754 systems, there are many representations of nan, and +.i tagp +selects one. +on other systems it may do nothing. +.sh versions +these functions first appeared in glibc in version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br nan (), +.br nanf (), +.br nanl () +t} thread safety mt-safe locale +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +see also iec 559 and the appendix with +recommended functions in ieee 754/ieee 854. +.sh see also +.br isnan (3), +.br strtod (3), +.br math_error (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2000 lars brinkhoff +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" modified, thu jan 27 19:16:19 cet 2000, lars@nocrew.org +.\" +.th dsp56k 4 2021-03-22 "linux" "linux programmer's manual" +.sh name +dsp56k \- dsp56001 interface device +.sh synopsis +.nf +.b #include +.pp +.bi "ssize_t read(int " fd ", void *" data ", size_t " length ); +.bi "ssize_t write(int " fd ", void *" data ", size_t " length ); +.pp +.bi "int ioctl(int " fd ", dsp56k_upload, struct dsp56k_upload *" program ); +.bi "int ioctl(int " fd ", dsp56k_set_tx_wsize, int " wsize ); +.bi "int ioctl(int " fd ", dsp56k_set_rx_wsize, int " wsize ); +.bi "int ioctl(int " fd ", dsp56k_host_flags, struct dsp56k_host_flags *" flags ); +.bi "int ioctl(int " fd ", dsp56k_host_cmd, int " cmd ); +.fi +.sh configuration +the +.b dsp56k +device is a character device with major number 55 and minor +number 0. +.sh description +the motorola dsp56001 is a fully programmable 24-bit digital signal +processor found in atari falcon030-compatible computers. +the \fidsp56k\fp special file is used to control the dsp56001, and +to send and receive data using the bidirectional handshaked host +port. +.pp +to send a data stream to the signal processor, use +.br write (2) +to the +device, and +.br read (2) +to receive processed data. +the data can be sent or +received in 8, 16, 24, or 32-bit quantities on the host side, but will +always be seen as 24-bit quantities in the dsp56001. +.pp +the following +.br ioctl (2) +calls are used to control the +\fidsp56k\fp device: +.ip \fbdsp56k_upload\fp +resets the dsp56001 and uploads a program. +the third +.br ioctl (2) +argument must be a pointer to a \fistruct dsp56k_upload\fp with members +\fibin\fp pointing to a dsp56001 binary program, and \filen\fp set to +the length of the program, counted in 24-bit words. +.ip \fbdsp56k_set_tx_wsize\fp +sets the transmit word size. +allowed values are in the range 1 to 4, +and is the number of bytes that will be sent at a time to the +dsp56001. +these data quantities will either be padded with bytes containing zero, +or truncated to fit the native 24-bit data format of the +dsp56001. +.ip \fbdsp56k_set_rx_wsize\fp +sets the receive word size. +allowed values are in the range 1 to 4, +and is the number of bytes that will be received at a time from the +dsp56001. +these data quantities will either truncated, or padded with +a null byte (\(aq\e0\(aq) to fit the native 24-bit data format of the dsp56001. +.ip \fbdsp56k_host_flags\fp +read and write the host flags. +the host flags are four +general-purpose bits that can be read by both the hosting computer and +the dsp56001. +bits 0 and 1 can be written by the host, and bits 2 and +3 can be written by the dsp56001. +.ip +to access the host flags, the third +.br ioctl (2) +argument must be a pointer +to a \fistruct dsp56k_host_flags\fp. +if bit 0 or 1 is set in the +\fidir\fp member, the corresponding bit in \fiout\fp will be written +to the host flags. +the state of all host flags will be returned in +the lower four bits of the \fistatus\fp member. +.ip \fbdsp56k_host_cmd\fp +sends a host command. +allowed values are in the range 0 to 31, and is a +user-defined command handled by the program running in the dsp56001. +.sh files +.i /dev/dsp56k +.\" .sh authors +.\" fredrik noring , lars brinkhoff , +.\" tomas berndtsson . +.sh see also +.ir linux/include/asm\-m68k/dsp56k.h , +.ir linux/drivers/char/dsp56k.c , +.ur http://dsp56k.nocrew.org/ +.ue , +dsp56000/dsp56001 digital signal processor user's manual +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man7/system_data_types.7 + +.so man7/system_data_types.7 + +.\" copyright (c) 2008 linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th pthread_join 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +pthread_join \- join with a terminated thread +.sh synopsis +.nf +.b #include +.pp +.bi "int pthread_join(pthread_t " thread ", void **" retval ); +.fi +.pp +compile and link with \fi\-pthread\fp. +.sh description +the +.br pthread_join () +function waits for the thread specified by +.ir thread +to terminate. +if that thread has already terminated, then +.br pthread_join () +returns immediately. +the thread specified by +.i thread +must be joinable. +.pp +if +.i retval +is not null, then +.br pthread_join () +copies the exit status of the target thread +(i.e., the value that the target thread supplied to +.br pthread_exit (3)) +into the location pointed to by +.ir retval . +if the target thread was canceled, then +.b pthread_canceled +is placed in the location pointed to by +.ir retval . +.pp +if multiple threads simultaneously try to join with the same thread, +the results are undefined. +if the thread calling +.br pthread_join () +is canceled, then the target thread will remain joinable +(i.e., it will not be detached). +.sh return value +on success, +.br pthread_join () +returns 0; +on error, it returns an error number. +.sh errors +.tp +.b edeadlk +a deadlock was detected +.\" the following verified by testing on glibc 2.8/nptl: +(e.g., two threads tried to join with each other); +or +.\" the following verified by testing on glibc 2.8/nptl: +.i thread +specifies the calling thread. +.tp +.b einval +.i thread +is not a joinable thread. +.tp +.b einval +another thread is already waiting to join with this thread. +.\" posix.1-2001 does not specify this error case. +.tp +.b esrch +no thread with the id +.i thread +could be found. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br pthread_join () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +after a successful call to +.br pthread_join (), +the caller is guaranteed that the target thread has terminated. +the caller may then choose to do any clean-up that is required +after termination of the thread (e.g., freeing memory or other +resources that were allocated to the target thread). +.pp +joining with a thread that has previously been joined results in +undefined behavior. +.pp +failure to join with a thread that is joinable +(i.e., one that is not detached), +produces a "zombie thread". +avoid doing this, +since each zombie thread consumes some system resources, +and when enough zombie threads have accumulated, +it will no longer be possible to create new threads (or processes). +.pp +there is no pthreads analog of +.ir "waitpid(\-1,\ &status,\ 0)" , +that is, "join with any terminated thread". +if you believe you need this functionality, +you probably need to rethink your application design. +.pp +all of the threads in a process are peers: +any thread can join with any other thread in the process. +.sh examples +see +.br pthread_create (3). +.sh see also +.br pthread_cancel (3), +.br pthread_create (3), +.br pthread_detach (3), +.br pthread_exit (3), +.br pthread_tryjoin_np (3), +.br pthreads (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/strerror.3 + +.so man3/err.3 + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" iso/iec 9899:1999 +.\" +.th wcscpy 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +wcscpy \- copy a wide-character string +.sh synopsis +.nf +.b #include +.pp +.bi "wchar_t *wcscpy(wchar_t *restrict " dest \ +", const wchar_t *restrict " src ); +.fi +.sh description +the +.br wcscpy () +function is the wide-character equivalent +of the +.br strcpy (3) +function. +it copies the wide-character string pointed to by +.ir src , +including the terminating null wide character (l\(aq\e0\(aq), +to the array pointed to by +.ir dest . +.pp +the strings may not overlap. +.pp +the programmer must ensure that there is +room for at least +.ir "wcslen(src)+1" +wide characters at +.ir dest . +.sh return value +.br wcscpy () +returns +.ir dest . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br wcscpy () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh see also +.br strcpy (3), +.br wcpcpy (3), +.br wcscat (3), +.br wcsdup (3), +.br wmemcpy (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2008, michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th acct 5 2021-03-22 "linux" "linux programmer's manual" +.sh name +acct \- process accounting file +.sh synopsis +.nf +.b #include +.fi +.sh description +if the kernel is built with the process accounting option enabled +.rb ( config_bsd_process_acct ), +then calling +.br acct (2) +starts process accounting, for example: +.pp +.in +4n +acct("/var/log/pacct"); +.in +.pp +when process accounting is enabled, the kernel writes a record +to the accounting file as each process on the system terminates. +this record contains information about the terminated process, +and is defined in +.i +as follows: +.pp +.in +4n +.ex +#define acct_comm 16 + +typedef u_int16_t comp_t; + +struct acct { + char ac_flag; /* accounting flags */ + u_int16_t ac_uid; /* accounting user id */ + u_int16_t ac_gid; /* accounting group id */ + u_int16_t ac_tty; /* controlling terminal */ + u_int32_t ac_btime; /* process creation time + (seconds since the epoch) */ + comp_t ac_utime; /* user cpu time */ + comp_t ac_stime; /* system cpu time */ + comp_t ac_etime; /* elapsed time */ + comp_t ac_mem; /* average memory usage (kb) */ + comp_t ac_io; /* characters transferred (unused) */ + comp_t ac_rw; /* blocks read or written (unused) */ + comp_t ac_minflt; /* minor page faults */ + comp_t ac_majflt; /* major page faults */ + comp_t ac_swaps; /* number of swaps (unused) */ + u_int32_t ac_exitcode; /* process termination status + (see wait(2)) */ + char ac_comm[acct_comm+1]; + /* command name (basename of last + executed command; null\-terminated) */ + char ac_pad[\fix\fp]; /* padding bytes */ +}; + +enum { /* bits that may be set in ac_flag field */ + afork = 0x01, /* has executed fork, but no exec */ + asu = 0x02, /* used superuser privileges */ + acore = 0x08, /* dumped core */ + axsig = 0x10 /* killed by a signal */ +}; +.ee +.in +.pp +the +.i comp_t +data type is a floating-point value consisting of a 3-bit, base-8 exponent, +and a 13-bit mantissa. +a value, +.ir c , +of this type can be converted to a (long) integer as follows: +.pp +.nf + v = (c & 0x1fff) << (((c >> 13) & 0x7) * 3); +.fi +.pp +the +.ir ac_utime , +.ir ac_stime , +and +.i ac_etime +fields measure time in "clock ticks"; divide these values by +.i sysconf(_sc_clk_tck) +to convert them to seconds. +.ss version 3 accounting file format +since kernel 2.6.8, +an optional alternative version of the accounting file can be produced +if the +.b config_bsd_process_acct_v3 +option is set when building the kernel. +with this option is set, +the records written to the accounting file contain additional fields, +and the width of +.i c_uid +and +.i ac_gid +fields is widened from 16 to 32 bits +(in line with the increased size of uid and gids in linux 2.4 and later). +the records are defined as follows: +.pp +.in +4n +.ex +struct acct_v3 { + char ac_flag; /* flags */ + char ac_version; /* always set to acct_version (3) */ + u_int16_t ac_tty; /* controlling terminal */ + u_int32_t ac_exitcode; /* process termination status */ + u_int32_t ac_uid; /* real user id */ + u_int32_t ac_gid; /* real group id */ + u_int32_t ac_pid; /* process id */ + u_int32_t ac_ppid; /* parent process id */ + u_int32_t ac_btime; /* process creation time */ + float ac_etime; /* elapsed time */ + comp_t ac_utime; /* user cpu time */ + comp_t ac_stime; /* system time */ + comp_t ac_mem; /* average memory usage (kb) */ + comp_t ac_io; /* characters transferred (unused) */ + comp_t ac_rw; /* blocks read or written + (unused) */ + comp_t ac_minflt; /* minor page faults */ + comp_t ac_majflt; /* major page faults */ + comp_t ac_swaps; /* number of swaps (unused) */ + char ac_comm[acct_comm]; /* command name */ +}; +.ee +.in +.sh versions +the +.i acct_v3 +structure is defined in glibc since version 2.6. +.sh conforming to +process accounting originated on bsd. +although it is present on most systems, it is not standardized, +and the details vary somewhat between systems. +.sh notes +records in the accounting file are ordered by termination time of +the process. +.pp +in kernels up to and including 2.6.9, +a separate accounting record is written for each thread created using +the nptl threading library; +since linux 2.6.10, +a single accounting record is written for the entire process +on termination of the last thread in the process. +.pp +the +.i /proc/sys/kernel/acct +file, described in +.br proc (5), +defines settings that control the behavior of process accounting +when disk space runs low. +.sh see also +.br lastcomm (1), +.br acct (2), +.br accton (8), +.br sa (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2015 alexei starovoitov +.\" and copyright (c) 2015 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th bpf 2 2021-08-27 "linux" "linux programmer's manual" +.sh name +bpf \- perform a command on an extended bpf map or program +.sh synopsis +.nf +.b #include +.pp +.bi "int bpf(int " cmd ", union bpf_attr *" attr ", unsigned int " size ); +.fi +.sh description +the +.br bpf () +system call performs a range of operations related to extended +berkeley packet filters. +extended bpf (or ebpf) is similar to +the original ("classic") bpf (cbpf) used to filter network packets. +for both cbpf and ebpf programs, +the kernel statically analyzes the programs before loading them, +in order to ensure that they cannot harm the running system. +.pp +ebpf extends cbpf in multiple ways, including the ability to call +a fixed set of in-kernel helper functions +.\" see 'enum bpf_func_id' in include/uapi/linux/bpf.h +(via the +.b bpf_call +opcode extension provided by ebpf) +and access shared data structures such as ebpf maps. +.\" +.ss extended bpf design/architecture +ebpf maps are a generic data structure for storage of different data types. +data types are generally treated as binary blobs, so a user just specifies +the size of the key and the size of the value at map-creation time. +in other words, a key/value for a given map can have an arbitrary structure. +.pp +a user process can create multiple maps (with key/value-pairs being +opaque bytes of data) and access them via file descriptors. +different ebpf programs can access the same maps in parallel. +it's up to the user process and ebpf program to decide what they store +inside maps. +.pp +there's one special map type, called a program array. +this type of map stores file descriptors referring to other ebpf programs. +when a lookup in the map is performed, the program flow is +redirected in-place to the beginning of another ebpf program and does not +return back to the calling program. +the level of nesting has a fixed limit of 32, +.\" defined by the kernel constant max_tail_call_cnt in include/linux/bpf.h +so that infinite loops cannot be crafted. +at run time, the program file descriptors stored in the map can be modified, +so program functionality can be altered based on specific requirements. +all programs referred to in a program-array map must +have been previously loaded into the kernel via +.br bpf (). +if a map lookup fails, the current program continues its execution. +see +.b bpf_map_type_prog_array +below for further details. +.pp +generally, ebpf programs are loaded by the user process and automatically +unloaded when the process exits. +in some cases, for example, +.br tc\-bpf (8), +the program will continue to stay alive inside the kernel even after the +process that loaded the program exits. +in that case, +the tc subsystem holds a reference to the ebpf program after the +file descriptor has been closed by the user-space program. +thus, whether a specific program continues to live inside the kernel +depends on how it is further attached to a given kernel subsystem +after it was loaded via +.br bpf (). +.pp +each ebpf program is a set of instructions that is safe to run until +its completion. +an in-kernel verifier statically determines that the ebpf program +terminates and is safe to execute. +during verification, the kernel increments reference counts for each of +the maps that the ebpf program uses, +so that the attached maps can't be removed until the program is unloaded. +.pp +ebpf programs can be attached to different events. +these events can be the arrival of network packets, tracing +events, classification events by network queueing disciplines +(for ebpf programs attached to a +.br tc (8) +classifier), and other types that may be added in the future. +a new event triggers execution of the ebpf program, which +may store information about the event in ebpf maps. +beyond storing data, ebpf programs may call a fixed set of +in-kernel helper functions. +.pp +the same ebpf program can be attached to multiple events and different +ebpf programs can access the same map: +.pp +.in +4n +.ex +tracing tracing tracing packet packet packet +event a event b event c on eth0 on eth1 on eth2 + | | | | | \(ha + | | | | v | + \-\-> tracing <\-\- tracing socket tc ingress tc egress + prog_1 prog_2 prog_3 classifier action + | | | | prog_4 prog_5 + |\-\-\- \-\-\-\-\-| |\-\-\-\-\-\-| map_3 | | + map_1 map_2 \-\-| map_4 |\-\- +.ee +.in +.\" +.ss arguments +the operation to be performed by the +.br bpf () +system call is determined by the +.i cmd +argument. +each operation takes an accompanying argument, +provided via +.ir attr , +which is a pointer to a union of type +.i bpf_attr +(see below). +the +.i size +argument is the size of the union pointed to by +.ir attr . +.pp +the value provided in +.i cmd +is one of the following: +.tp +.b bpf_map_create +create a map and return a file descriptor that refers to the map. +the close-on-exec file descriptor flag (see +.br fcntl (2)) +is automatically enabled for the new file descriptor. +.tp +.b bpf_map_lookup_elem +look up an element by key in a specified map and return its value. +.tp +.b bpf_map_update_elem +create or update an element (key/value pair) in a specified map. +.tp +.b bpf_map_delete_elem +look up and delete an element by key in a specified map. +.tp +.b bpf_map_get_next_key +look up an element by key in a specified map and return the key +of the next element. +.tp +.b bpf_prog_load +verify and load an ebpf program, +returning a new file descriptor associated with the program. +the close-on-exec file descriptor flag (see +.br fcntl (2)) +is automatically enabled for the new file descriptor. +.ip +the +.i bpf_attr +union consists of various anonymous structures that are used by different +.br bpf () +commands: +.pp +.in +4n +.ex +union bpf_attr { + struct { /* used by bpf_map_create */ + __u32 map_type; + __u32 key_size; /* size of key in bytes */ + __u32 value_size; /* size of value in bytes */ + __u32 max_entries; /* maximum number of entries + in a map */ + }; + + struct { /* used by bpf_map_*_elem and bpf_map_get_next_key + commands */ + __u32 map_fd; + __aligned_u64 key; + union { + __aligned_u64 value; + __aligned_u64 next_key; + }; + __u64 flags; + }; + + struct { /* used by bpf_prog_load */ + __u32 prog_type; + __u32 insn_cnt; + __aligned_u64 insns; /* \(aqconst struct bpf_insn *\(aq */ + __aligned_u64 license; /* \(aqconst char *\(aq */ + __u32 log_level; /* verbosity level of verifier */ + __u32 log_size; /* size of user buffer */ + __aligned_u64 log_buf; /* user supplied \(aqchar *\(aq + buffer */ + __u32 kern_version; + /* checked when prog_type=kprobe + (since linux 4.1) */ +.\" commit 2541517c32be2531e0da59dfd7efc1ce844644f5 + }; +} __attribute__((aligned(8))); +.ee +.in +.\" +.ss ebpf maps +maps are a generic data structure for storage of different types of data. +they allow sharing of data between ebpf kernel programs, +and also between kernel and user-space applications. +.pp +each map type has the following attributes: +.ip * 3 +type +.ip * +maximum number of elements +.ip * +key size in bytes +.ip * +value size in bytes +.pp +the following wrapper functions demonstrate how various +.br bpf () +commands can be used to access the maps. +the functions use the +.i cmd +argument to invoke different operations. +.tp +.b bpf_map_create +the +.b bpf_map_create +command creates a new map, +returning a new file descriptor that refers to the map. +.ip +.in +4n +.ex +int +bpf_create_map(enum bpf_map_type map_type, + unsigned int key_size, + unsigned int value_size, + unsigned int max_entries) +{ + union bpf_attr attr = { + .map_type = map_type, + .key_size = key_size, + .value_size = value_size, + .max_entries = max_entries + }; + + return bpf(bpf_map_create, &attr, sizeof(attr)); +} +.ee +.in +.ip +the new map has the type specified by +.ir map_type , +and attributes as specified in +.ir key_size , +.ir value_size , +and +.ir max_entries . +on success, this operation returns a file descriptor. +on error, \-1 is returned and +.i errno +is set to +.br einval , +.br eperm , +or +.br enomem . +.ip +the +.i key_size +and +.i value_size +attributes will be used by the verifier during program loading +to check that the program is calling +.br bpf_map_*_elem () +helper functions with a correctly initialized +.i key +and to check that the program doesn't access the map element +.i value +beyond the specified +.ir value_size . +for example, when a map is created with a +.i key_size +of 8 and the ebpf program calls +.ip +.in +4n +.ex +bpf_map_lookup_elem(map_fd, fp \- 4) +.ee +.in +.ip +the program will be rejected, +since the in-kernel helper function +.ip +.in +4n +.ex +bpf_map_lookup_elem(map_fd, void *key) +.ee +.in +.ip +expects to read 8 bytes from the location pointed to by +.ir key , +but the +.i fp\ \-\ 4 +(where +.i fp +is the top of the stack) +starting address will cause out-of-bounds stack access. +.ip +similarly, when a map is created with a +.i value_size +of 1 and the ebpf program contains +.ip +.in +4n +.ex +value = bpf_map_lookup_elem(...); +*(u32 *) value = 1; +.ee +.in +.ip +the program will be rejected, since it accesses the +.i value +pointer beyond the specified 1 byte +.i value_size +limit. +.ip +currently, the following values are supported for +.ir map_type : +.ip +.in +4n +.ex +enum bpf_map_type { + bpf_map_type_unspec, /* reserve 0 as invalid map type */ + bpf_map_type_hash, + bpf_map_type_array, + bpf_map_type_prog_array, + bpf_map_type_perf_event_array, + bpf_map_type_percpu_hash, + bpf_map_type_percpu_array, + bpf_map_type_stack_trace, + bpf_map_type_cgroup_array, + bpf_map_type_lru_hash, + bpf_map_type_lru_percpu_hash, + bpf_map_type_lpm_trie, + bpf_map_type_array_of_maps, + bpf_map_type_hash_of_maps, + bpf_map_type_devmap, + bpf_map_type_sockmap, + bpf_map_type_cpumap, + bpf_map_type_xskmap, + bpf_map_type_sockhash, + bpf_map_type_cgroup_storage, + bpf_map_type_reuseport_sockarray, + bpf_map_type_percpu_cgroup_storage, + bpf_map_type_queue, + bpf_map_type_stack, + /* see /usr/include/linux/bpf.h for the full list. */ +}; +.ee +.in +.ip +.i map_type +selects one of the available map implementations in the kernel. +.\" fixme we need an explanation of why one might choose each of +.\" these map implementations +for all map types, +ebpf programs access maps with the same +.br bpf_map_lookup_elem () +and +.br bpf_map_update_elem () +helper functions. +further details of the various map types are given below. +.tp +.b bpf_map_lookup_elem +the +.b bpf_map_lookup_elem +command looks up an element with a given +.i key +in the map referred to by the file descriptor +.ir fd . +.ip +.in +4n +.ex +int +bpf_lookup_elem(int fd, const void *key, void *value) +{ + union bpf_attr attr = { + .map_fd = fd, + .key = ptr_to_u64(key), + .value = ptr_to_u64(value), + }; + + return bpf(bpf_map_lookup_elem, &attr, sizeof(attr)); +} +.ee +.in +.ip +if an element is found, +the operation returns zero and stores the element's value into +.ir value , +which must point to a buffer of +.i value_size +bytes. +.ip +if no element is found, the operation returns \-1 and sets +.i errno +to +.br enoent . +.tp +.b bpf_map_update_elem +the +.b bpf_map_update_elem +command +creates or updates an element with a given +.i key/value +in the map referred to by the file descriptor +.ir fd . +.ip +.in +4n +.ex +int +bpf_update_elem(int fd, const void *key, const void *value, + uint64_t flags) +{ + union bpf_attr attr = { + .map_fd = fd, + .key = ptr_to_u64(key), + .value = ptr_to_u64(value), + .flags = flags, + }; + + return bpf(bpf_map_update_elem, &attr, sizeof(attr)); +} +.ee +.in +.ip +the +.i flags +argument should be specified as one of the following: +.rs +.tp +.b bpf_any +create a new element or update an existing element. +.tp +.b bpf_noexist +create a new element only if it did not exist. +.tp +.b bpf_exist +update an existing element. +.re +.ip +on success, the operation returns zero. +on error, \-1 is returned and +.i errno +is set to +.br einval , +.br eperm , +.br enomem , +or +.br e2big . +.b e2big +indicates that the number of elements in the map reached the +.i max_entries +limit specified at map creation time. +.b eexist +will be returned if +.i flags +specifies +.b bpf_noexist +and the element with +.i key +already exists in the map. +.b enoent +will be returned if +.i flags +specifies +.b bpf_exist +and the element with +.i key +doesn't exist in the map. +.tp +.b bpf_map_delete_elem +the +.b bpf_map_delete_elem +command +deletes the element whose key is +.i key +from the map referred to by the file descriptor +.ir fd . +.ip +.in +4n +.ex +int +bpf_delete_elem(int fd, const void *key) +{ + union bpf_attr attr = { + .map_fd = fd, + .key = ptr_to_u64(key), + }; + + return bpf(bpf_map_delete_elem, &attr, sizeof(attr)); +} +.ee +.in +.ip +on success, zero is returned. +if the element is not found, \-1 is returned and +.i errno +is set to +.br enoent . +.tp +.b bpf_map_get_next_key +the +.b bpf_map_get_next_key +command looks up an element by +.i key +in the map referred to by the file descriptor +.i fd +and sets the +.i next_key +pointer to the key of the next element. +.ip +.in +4n +.ex +int +bpf_get_next_key(int fd, const void *key, void *next_key) +{ + union bpf_attr attr = { + .map_fd = fd, + .key = ptr_to_u64(key), + .next_key = ptr_to_u64(next_key), + }; + + return bpf(bpf_map_get_next_key, &attr, sizeof(attr)); +} +.ee +.in +.ip +if +.i key +is found, the operation returns zero and sets the +.i next_key +pointer to the key of the next element. +if +.i key +is not found, the operation returns zero and sets the +.i next_key +pointer to the key of the first element. +if +.i key +is the last element, \-1 is returned and +.i errno +is set to +.br enoent . +other possible +.i errno +values are +.br enomem , +.br efault , +.br eperm , +and +.br einval . +this method can be used to iterate over all elements in the map. +.tp +.b close(map_fd) +delete the map referred to by the file descriptor +.ir map_fd . +when the user-space program that created a map exits, all maps will +be deleted automatically (but see notes). +.\" +.ss ebpf map types +the following map types are supported: +.tp +.b bpf_map_type_hash +.\" commit 0f8e4bd8a1fc8c4185f1630061d0a1f2d197a475 +hash-table maps have the following characteristics: +.rs +.ip * 3 +maps are created and destroyed by user-space programs. +both user-space and ebpf programs +can perform lookup, update, and delete operations. +.ip * +the kernel takes care of allocating and freeing key/value pairs. +.ip * +the +.br map_update_elem () +helper will fail to insert new element when the +.i max_entries +limit is reached. +(this ensures that ebpf programs cannot exhaust memory.) +.ip * +.br map_update_elem () +replaces existing elements atomically. +.re +.ip +hash-table maps are +optimized for speed of lookup. +.tp +.b bpf_map_type_array +.\" commit 28fbcfa08d8ed7c5a50d41a0433aad222835e8e3 +array maps have the following characteristics: +.rs +.ip * 3 +optimized for fastest possible lookup. +in the future the verifier/jit compiler +may recognize lookup() operations that employ a constant key +and optimize it into constant pointer. +it is possible to optimize a non-constant +key into direct pointer arithmetic as well, since pointers and +.i value_size +are constant for the life of the ebpf program. +in other words, +.br array_map_lookup_elem () +may be 'inlined' by the verifier/jit compiler +while preserving concurrent access to this map from user space. +.ip * +all array elements pre-allocated and zero initialized at init time +.ip * +the key is an array index, and must be exactly four bytes. +.ip * +.br map_delete_elem () +fails with the error +.br einval , +since elements cannot be deleted. +.ip * +.br map_update_elem () +replaces elements in a +.b nonatomic +fashion; +for atomic updates, a hash-table map should be used instead. +there is however one special case that can also be used with arrays: +the atomic built-in +.b __sync_fetch_and_add() +can be used on 32 and 64 bit atomic counters. +for example, it can be +applied on the whole value itself if it represents a single counter, +or in case of a structure containing multiple counters, it could be +used on individual counters. +this is quite often useful for aggregation and accounting of events. +.re +.ip +among the uses for array maps are the following: +.rs +.ip * 3 +as "global" ebpf variables: an array of 1 element whose key is (index) 0 +and where the value is a collection of 'global' variables which +ebpf programs can use to keep state between events. +.ip * +aggregation of tracing events into a fixed set of buckets. +.ip * +accounting of networking events, for example, number of packets and packet +sizes. +.re +.tp +.br bpf_map_type_prog_array " (since linux 4.2)" +a program array map is a special kind of array map whose map values +contain only file descriptors referring to other ebpf programs. +thus, both the +.i key_size +and +.i value_size +must be exactly four bytes. +this map is used in conjunction with the +.br bpf_tail_call () +helper. +.ip +this means that an ebpf program with a program array map attached to it +can call from kernel side into +.ip +.in +4n +.ex +void bpf_tail_call(void *context, void *prog_map, + unsigned int index); +.ee +.in +.ip +and therefore replace its own program flow with the one from the program +at the given program array slot, if present. +this can be regarded as kind of a jump table to a different ebpf program. +the invoked program will then reuse the same stack. +when a jump into the new program has been performed, +it won't return to the old program anymore. +.ip +if no ebpf program is found at the given index of the program array +(because the map slot doesn't contain a valid program file descriptor, +the specified lookup index/key is out of bounds, +or the limit of 32 +.\" max_tail_call_cnt +nested calls has been exceed), +execution continues with the current ebpf program. +this can be used as a fall-through for default cases. +.ip +a program array map is useful, for example, in tracing or networking, to +handle individual system calls or protocols in their own subprograms and +use their identifiers as an individual map index. +this approach may result in performance benefits, +and also makes it possible to overcome the maximum +instruction limit of a single ebpf program. +in dynamic environments, +a user-space daemon might atomically replace individual subprograms +at run-time with newer versions to alter overall program behavior, +for instance, if global policies change. +.\" +.ss ebpf programs +the +.b bpf_prog_load +command is used to load an ebpf program into the kernel. +the return value for this command is a new file descriptor associated +with this ebpf program. +.pp +.in +4n +.ex +char bpf_log_buf[log_buf_size]; + +int +bpf_prog_load(enum bpf_prog_type type, + const struct bpf_insn *insns, int insn_cnt, + const char *license) +{ + union bpf_attr attr = { + .prog_type = type, + .insns = ptr_to_u64(insns), + .insn_cnt = insn_cnt, + .license = ptr_to_u64(license), + .log_buf = ptr_to_u64(bpf_log_buf), + .log_size = log_buf_size, + .log_level = 1, + }; + + return bpf(bpf_prog_load, &attr, sizeof(attr)); +} +.ee +.in +.pp +.i prog_type +is one of the available program types: +.ip +.in +4n +.ex +enum bpf_prog_type { + bpf_prog_type_unspec, /* reserve 0 as invalid + program type */ + bpf_prog_type_socket_filter, + bpf_prog_type_kprobe, + bpf_prog_type_sched_cls, + bpf_prog_type_sched_act, + bpf_prog_type_tracepoint, + bpf_prog_type_xdp, + bpf_prog_type_perf_event, + bpf_prog_type_cgroup_skb, + bpf_prog_type_cgroup_sock, + bpf_prog_type_lwt_in, + bpf_prog_type_lwt_out, + bpf_prog_type_lwt_xmit, + bpf_prog_type_sock_ops, + bpf_prog_type_sk_skb, + bpf_prog_type_cgroup_device, + bpf_prog_type_sk_msg, + bpf_prog_type_raw_tracepoint, + bpf_prog_type_cgroup_sock_addr, + bpf_prog_type_lwt_seg6local, + bpf_prog_type_lirc_mode2, + bpf_prog_type_sk_reuseport, + bpf_prog_type_flow_dissector, + /* see /usr/include/linux/bpf.h for the full list. */ +}; +.ee +.in +.pp +for further details of ebpf program types, see below. +.pp +the remaining fields of +.i bpf_attr +are set as follows: +.ip * 3 +.i insns +is an array of +.i "struct bpf_insn" +instructions. +.ip * +.i insn_cnt +is the number of instructions in the program referred to by +.ir insns . +.ip * +.i license +is a license string, which must be gpl compatible to call helper functions +marked +.ir gpl_only . +(the licensing rules are the same as for kernel modules, +so that also dual licenses, such as "dual bsd/gpl", may be used.) +.ip * +.i log_buf +is a pointer to a caller-allocated buffer in which the in-kernel +verifier can store the verification log. +this log is a multi-line string that can be checked by +the program author in order to understand how the verifier came to +the conclusion that the ebpf program is unsafe. +the format of the output can change at any time as the verifier evolves. +.ip * +.i log_size +size of the buffer pointed to by +.ir log_buf . +if the size of the buffer is not large enough to store all +verifier messages, \-1 is returned and +.i errno +is set to +.br enospc . +.ip * +.i log_level +verbosity level of the verifier. +a value of zero means that the verifier will not provide a log; +in this case, +.i log_buf +must be a null pointer, and +.i log_size +must be zero. +.pp +applying +.br close (2) +to the file descriptor returned by +.b bpf_prog_load +will unload the ebpf program (but see notes). +.pp +maps are accessible from ebpf programs and are used to exchange data between +ebpf programs and between ebpf programs and user-space programs. +for example, +ebpf programs can process various events (like kprobe, packets) and +store their data into a map, +and user-space programs can then fetch data from the map. +conversely, user-space programs can use a map as a configuration mechanism, +populating the map with values checked by the ebpf program, +which then modifies its behavior on the fly according to those values. +.\" +.\" +.ss ebpf program types +the ebpf program type +.ri ( prog_type ) +determines the subset of kernel helper functions that the program +may call. +the program type also determines the program input (context)\(emthe +format of +.i "struct bpf_context" +(which is the data blob passed into the ebpf program as the first argument). +.\" +.\" fixme +.\" somewhere in this page we need a general introduction to the +.\" bpf_context. for example, how does a bpf program access the +.\" context? +.pp +for example, a tracing program does not have the exact same +subset of helper functions as a socket filter program +(though they may have some helpers in common). +similarly, +the input (context) for a tracing program is a set of register values, +while for a socket filter it is a network packet. +.pp +the set of functions available to ebpf programs of a given type may increase +in the future. +.pp +the following program types are supported: +.tp +.br bpf_prog_type_socket_filter " (since linux 3.19)" +currently, the set of functions for +.b bpf_prog_type_socket_filter +is: +.ip +.in +4n +.ex +bpf_map_lookup_elem(map_fd, void *key) + /* look up key in a map_fd */ +bpf_map_update_elem(map_fd, void *key, void *value) + /* update key/value */ +bpf_map_delete_elem(map_fd, void *key) + /* delete key in a map_fd */ +.ee +.in +.ip +the +.i bpf_context +argument is a pointer to a +.ir "struct __sk_buff" . +.\" fixme: we need some text here to explain how the program +.\" accesses __sk_buff. +.\" see 'struct __sk_buff' and commit 9bac3d6d548e5 +.\" +.\" alexei commented: +.\" actually now in case of socket_filter, sched_cls, sched_act +.\" the program can now access skb fields. +.\" +.tp +.br bpf_prog_type_kprobe " (since linux 4.1)" +.\" commit 2541517c32be2531e0da59dfd7efc1ce844644f5 +[to be documented] +.\" fixme document this program type +.\" describe allowed helper functions for this program type +.\" describe bpf_context for this program type +.\" +.\" fixme we need text here to describe 'kern_version' +.tp +.br bpf_prog_type_sched_cls " (since linux 4.1)" +.\" commit 96be4325f443dbbfeb37d2a157675ac0736531a1 +.\" commit e2e9b6541dd4b31848079da80fe2253daaafb549 +[to be documented] +.\" fixme document this program type +.\" describe allowed helper functions for this program type +.\" describe bpf_context for this program type +.tp +.br bpf_prog_type_sched_act " (since linux 4.1)" +.\" commit 94caee8c312d96522bcdae88791aaa9ebcd5f22c +.\" commit a8cb5f556b567974d75ea29c15181c445c541b1f +[to be documented] +.\" fixme document this program type +.\" describe allowed helper functions for this program type +.\" describe bpf_context for this program type +.ss events +once a program is loaded, it can be attached to an event. +various kernel subsystems have different ways to do so. +.pp +since linux 3.19, +.\" commit 89aa075832b0da4402acebd698d0411dcc82d03e +the following call will attach the program +.i prog_fd +to the socket +.ir sockfd , +which was created by an earlier call to +.br socket (2): +.pp +.in +4n +.ex +setsockopt(sockfd, sol_socket, so_attach_bpf, + &prog_fd, sizeof(prog_fd)); +.ee +.in +.pp +since linux 4.1, +.\" commit 2541517c32be2531e0da59dfd7efc1ce844644f5 +the following call may be used to attach +the ebpf program referred to by the file descriptor +.i prog_fd +to a perf event file descriptor, +.ir event_fd , +that was created by a previous call to +.br perf_event_open (2): +.pp +.in +4n +.ex +ioctl(event_fd, perf_event_ioc_set_bpf, prog_fd); +.ee +.in +.\" +.\" +.sh return value +for a successful call, the return value depends on the operation: +.tp +.b bpf_map_create +the new file descriptor associated with the ebpf map. +.tp +.b bpf_prog_load +the new file descriptor associated with the ebpf program. +.tp +all other commands +zero. +.pp +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b e2big +the ebpf program is too large or a map reached the +.i max_entries +limit (maximum number of elements). +.tp +.b eacces +for +.br bpf_prog_load , +even though all program instructions are valid, the program has been +rejected because it was deemed unsafe. +this may be because it may have +accessed a disallowed memory region or an uninitialized stack/register or +because the function constraints don't match the actual types or because +there was a misaligned memory access. +in this case, it is recommended to call +.br bpf () +again with +.i log_level = 1 +and examine +.i log_buf +for the specific reason provided by the verifier. +.tp +.b ebadf +.i fd +is not an open file descriptor. +.tp +.b efault +one of the pointers +.ri ( key +or +.i value +or +.i log_buf +or +.ir insns ) +is outside the accessible address space. +.tp +.b einval +the value specified in +.i cmd +is not recognized by this kernel. +.tp +.b einval +for +.br bpf_map_create , +either +.i map_type +or attributes are invalid. +.tp +.b einval +for +.b bpf_map_*_elem +commands, +some of the fields of +.i "union bpf_attr" +that are not used by this command +are not set to zero. +.tp +.b einval +for +.br bpf_prog_load , +indicates an attempt to load an invalid program. +ebpf programs can be deemed +invalid due to unrecognized instructions, the use of reserved fields, jumps +out of range, infinite loops or calls of unknown functions. +.tp +.b enoent +for +.b bpf_map_lookup_elem +or +.br bpf_map_delete_elem , +indicates that the element with the given +.i key +was not found. +.tp +.b enomem +cannot allocate sufficient memory. +.tp +.b eperm +the call was made without sufficient privilege +(without the +.b cap_sys_admin +capability). +.sh versions +the +.br bpf () +system call first appeared in linux 3.18. +.sh conforming to +the +.br bpf () +system call is linux-specific. +.sh notes +prior to linux 4.4, all +.br bpf () +commands require the caller to have the +.b cap_sys_admin +capability. +from linux 4.4 onwards, +.\" commit 1be7f75d1668d6296b80bf35dcf6762393530afc +an unprivileged user may create limited programs of type +.br bpf_prog_type_socket_filter +and associated maps. +however they may not store kernel pointers within +the maps and are presently limited to the following helper functions: +.\" [linux 5.6] mtk: the list of available functions is, i think, governed +.\" by the check in net/core/filter.c::bpf_base_func_proto(). +.ip * 3 +get_random +.pd 0 +.ip * +get_smp_processor_id +.ip * +tail_call +.ip * +ktime_get_ns +.pd 1 +.pp +unprivileged access may be blocked by writing the value 1 to the file +.ir /proc/sys/kernel/unprivileged_bpf_disabled . +.pp +ebpf objects (maps and programs) can be shared between processes. +for example, after +.br fork (2), +the child inherits file descriptors referring to the same ebpf objects. +in addition, file descriptors referring to ebpf objects can be +transferred over unix domain sockets. +file descriptors referring to ebpf objects can be duplicated +in the usual way, using +.br dup (2) +and similar calls. +an ebpf object is deallocated only after all file descriptors +referring to the object have been closed. +.pp +ebpf programs can be written in a restricted c that is compiled (using the +.b clang +compiler) into ebpf bytecode. +various features are omitted from this restricted c, such as loops, +global variables, variadic functions, floating-point numbers, +and passing structures as function arguments. +some examples can be found in the +.i samples/bpf/*_kern.c +files in the kernel source tree. +.\" there are also examples for the tc classifier, in the iproute2 +.\" project, in examples/bpf +.pp +the kernel contains a just-in-time (jit) compiler that translates +ebpf bytecode into native machine code for better performance. +in kernels before linux 4.15, +the jit compiler is disabled by default, +but its operation can be controlled by writing one of the +following integer strings to the file +.ir /proc/sys/net/core/bpf_jit_enable : +.ip 0 3 +disable jit compilation (default). +.ip 1 +normal compilation. +.ip 2 +debugging mode. +the generated opcodes are dumped in hexadecimal into the kernel log. +these opcodes can then be disassembled using the program +.i tools/net/bpf_jit_disasm.c +provided in the kernel source tree. +.pp +since linux 4.15, +.\" commit 290af86629b25ffd1ed6232c4e9107da031705cb +the kernel may configured with the +.b config_bpf_jit_always_on +option. +in this case, the jit compiler is always enabled, and the +.i bpf_jit_enable +is initialized to 1 and is immutable. +(this kernel configuration option was provided as a mitigation for +one of the spectre attacks against the bpf interpreter.) +.pp +the jit compiler for ebpf is currently +.\" last reviewed in linux 4.18-rc by grepping for bpf_alu64 in arch/ +.\" and by checking the documentation for bpf_jit_enable in +.\" documentation/sysctl/net.txt +available for the following architectures: +.ip * 3 +x86-64 (since linux 3.18; cbpf since linux 3.0); +.\" commit 0a14842f5a3c0e88a1e59fac5c3025db39721f74 +.pd 0 +.ip * +arm32 (since linux 3.18; cbpf since linux 3.4); +.\" commit ddecdfcea0ae891f782ae853771c867ab51024c2 +.ip * +sparc 32 (since linux 3.18; cbpf since linux 3.5); +.\" commit 2809a2087cc44b55e4377d7b9be3f7f5d2569091 +.ip * +arm-64 (since linux 3.18); +.\" commit e54bcde3d69d40023ae77727213d14f920eb264a +.ip * +s390 (since linux 4.1; cbpf since linux 3.7); +.\" commit c10302efe569bfd646b4c22df29577a4595b4580 +.ip * +powerpc 64 (since linux 4.8; cbpf since linux 3.1); +.\" commit 0ca87f05ba8bdc6791c14878464efc901ad71e99 +.\" commit 156d0e290e969caba25f1851c52417c14d141b24 +.ip * +sparc 64 (since linux 4.12); +.\" commit 7a12b5031c6b947cc13918237ae652b536243b76 +.ip * +x86-32 (since linux 4.18); +.\" commit 03f5781be2c7b7e728d724ac70ba10799cc710d7 +.ip * +mips 64 (since linux 4.18; cbpf since linux 3.16); +.\" commit c6610de353da5ca6eee5b8960e838a87a90ead0c +.\" commit f381bf6d82f032b7410185b35d000ea370ac706b +.ip * +riscv (since linux 5.1). +.\" commit 2353ecc6f91fd15b893fa01bf85a1c7a823ee4f2 +.pd +.sh examples +.ex +/* bpf+sockets example: + * 1. create array map of 256 elements + * 2. load program that counts number of packets received + * r0 = skb\->data[eth_hlen + offsetof(struct iphdr, protocol)] + * map[r0]++ + * 3. attach prog_fd to raw socket via setsockopt() + * 4. print number of received tcp/udp packets every second + */ +int +main(int argc, char *argv[]) +{ + int sock, map_fd, prog_fd, key; + long long value = 0, tcp_cnt, udp_cnt; + + map_fd = bpf_create_map(bpf_map_type_array, sizeof(key), + sizeof(value), 256); + if (map_fd < 0) { + printf("failed to create map \(aq%s\(aq\en", strerror(errno)); + /* likely not run as root */ + return 1; + } + + struct bpf_insn prog[] = { + bpf_mov64_reg(bpf_reg_6, bpf_reg_1), /* r6 = r1 */ + bpf_ld_abs(bpf_b, eth_hlen + offsetof(struct iphdr, protocol)), + /* r0 = ip\->proto */ + bpf_stx_mem(bpf_w, bpf_reg_10, bpf_reg_0, \-4), + /* *(u32 *)(fp \- 4) = r0 */ + bpf_mov64_reg(bpf_reg_2, bpf_reg_10), /* r2 = fp */ + bpf_alu64_imm(bpf_add, bpf_reg_2, \-4), /* r2 = r2 \- 4 */ + bpf_ld_map_fd(bpf_reg_1, map_fd), /* r1 = map_fd */ + bpf_call_func(bpf_func_map_lookup_elem), + /* r0 = map_lookup(r1, r2) */ + bpf_jmp_imm(bpf_jeq, bpf_reg_0, 0, 2), + /* if (r0 == 0) goto pc+2 */ + bpf_mov64_imm(bpf_reg_1, 1), /* r1 = 1 */ + bpf_xadd(bpf_dw, bpf_reg_0, bpf_reg_1, 0, 0), + /* lock *(u64 *) r0 += r1 */ +.\" == atomic64_add + bpf_mov64_imm(bpf_reg_0, 0), /* r0 = 0 */ + bpf_exit_insn(), /* return r0 */ + }; + + prog_fd = bpf_prog_load(bpf_prog_type_socket_filter, prog, + sizeof(prog) / sizeof(prog[0]), "gpl"); + + sock = open_raw_sock("lo"); + + assert(setsockopt(sock, sol_socket, so_attach_bpf, &prog_fd, + sizeof(prog_fd)) == 0); + + for (;;) { + key = ipproto_tcp; + assert(bpf_lookup_elem(map_fd, &key, &tcp_cnt) == 0); + key = ipproto_udp; + assert(bpf_lookup_elem(map_fd, &key, &udp_cnt) == 0); + printf("tcp %lld udp %lld packets\en", tcp_cnt, udp_cnt); + sleep(1); + } + + return 0; +} +.ee +.pp +some complete working code can be found in the +.i samples/bpf +directory in the kernel source tree. +.sh see also +.br seccomp (2), +.br bpf\-helpers (7), +.br socket (7), +.br tc (8), +.br tc\-bpf (8) +.pp +both classic and extended bpf are explained in the kernel source file +.ir documentation/networking/filter.txt . +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/erfc.3 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sat jul 24 18:12:45 1993 by rik faith (faith@cs.unc.edu) +.th strcasecmp 3 2021-03-22 "" "linux programmer's manual" +.sh name +strcasecmp, strncasecmp \- compare two strings ignoring case +.sh synopsis +.nf +.b #include +.pp +.bi "int strcasecmp(const char *" s1 ", const char *" s2 ); +.bi "int strncasecmp(const char *" s1 ", const char *" s2 ", size_t " n ); +.fi +.sh description +the +.br strcasecmp () +function performs a byte-by-byte comparison of the strings +.i s1 +and +.ir s2 , +ignoring the case of the characters. +it returns an integer +less than, equal to, or greater than zero if +.i s1 +is found, +respectively, to be less than, to match, or be greater than +.ir s2 . +.pp +the +.br strncasecmp () +function is similar, except that it compares +no more than +.i n +bytes of +.ir s1 +and +.ir s2 . +.sh return value +the +.br strcasecmp () +and +.br strncasecmp () +functions return +an integer less than, equal to, or greater than zero if +.i s1 +is, after ignoring case, found to be +less than, to match, or be greater than +.ir s2 , +respectively. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br strcasecmp (), +.br strncasecmp () +t} thread safety mt-safe locale +.te +.hy +.ad +.sp 1 +.sh conforming to +4.4bsd, posix.1-2001, posix.1-2008. +.sh notes +the +.br strcasecmp () +and +.br strncasecmp () +functions first appeared in 4.4bsd, where they were declared in +.ir . +thus, for reasons of historical compatibility, the glibc +.i +header file also declares these functions, if the +.b _default_source +(or, in glibc 2.19 and earlier, +.br _bsd_source ) +feature test macro is defined. +.pp +the posix.1-2008 standard says of these functions: +.pp +.rs +when the +.b lc_ctype +category of the locale being used is from the posix locale, +these functions shall behave as if the strings had been converted +to lowercase and then a byte comparison performed. +otherwise, the results are unspecified. +.re +.sh see also +.br bcmp (3), +.br memcmp (3), +.br strcmp (3), +.br strcoll (3), +.br string (3), +.br strncmp (3), +.br wcscasecmp (3), +.br wcsncasecmp (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/pow.3 + +.\" copyright (c) 1992, 1993, 1994 +.\" the regents of the university of california. all rights reserved. +.\" and copyright (c) 2008, 2014 michael kerrisk +.\" +.\" %%%license_start(bsd_3_clause_ucb) +.\" redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 4. neither the name of the university nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" this software is provided by the regents and contributors ``as is'' and +.\" any express or implied warranties, including, but not limited to, the +.\" implied warranties of merchantability and fitness for a particular purpose +.\" are disclaimed. in no event shall the regents or contributors be liable +.\" for any direct, indirect, incidental, special, exemplary, or consequential +.\" damages (including, but not limited to, procurement of substitute goods +.\" or services; loss of use, data, or profits; or business interruption) +.\" however caused and on any theory of liability, whether in contract, strict +.\" liability, or tort (including negligence or otherwise) arising in any way +.\" out of the use of this software, even if advised of the possibility of +.\" such damage. +.\" %%%license_end +.\" +.\" @(#)symlink.7 8.3 (berkeley) 3/31/94 +.\" $freebsd: src/bin/ln/symlink.7,v 1.30 2005/02/13 22:25:09 ru exp $ +.\" +.\" 2008-06-11, mtk, taken from freebsd 6.2 and heavily edited for +.\" specific linux details, improved readability, and man-pages style. +.\" +.th symlink 7 2021-03-22 "linux" "linux programmer's manual" +.sh name +symlink \- symbolic link handling +.sh description +symbolic links are files that act as pointers to other files. +to understand their behavior, you must first understand how hard links +work. +.pp +a hard link to a file is indistinguishable from the original file because +it is a reference to the object underlying the original filename. +(to be precise: each of the hard links to a file is a reference to +the same +.ir "inode number" , +where an inode number is an index into the inode table, +which contains metadata about all files on a filesystem. +see +.br stat (2).) +changes to a file are independent of the name used to reference the file. +hard links may not refer to directories +(to prevent the possibility of loops within the filesystem tree, +which would confuse many programs) +and may not refer to files on different filesystems +(because inode numbers are not unique across filesystems). +.pp +a symbolic link is a special type of file whose contents are a string +that is the pathname of another file, the file to which the link refers. +(the contents of a symbolic link can be read using +.br readlink (2).) +in other words, a symbolic link is a pointer to another name, +and not to an underlying object. +for this reason, symbolic links may refer to directories and may cross +filesystem boundaries. +.pp +there is no requirement that the pathname referred to by a symbolic link +should exist. +a symbolic link that refers to a pathname that does not exist is said +to be a +.ir "dangling link" . +.pp +because a symbolic link and its referenced object coexist in the filesystem +name space, confusion can arise in distinguishing between the link itself +and the referenced object. +on historical systems, +commands and system calls adopted their own link-following +conventions in a somewhat ad-hoc fashion. +rules for a more uniform approach, +as they are implemented on linux and other systems, +are outlined here. +it is important that site-local applications also conform to these rules, +so that the user interface can be as consistent as possible. +.\" +.ss magic links +there is a special class of symbolic-link-like objects +known as "magic links", which +can be found in certain pseudofilesystems such as +.br proc (5) +(examples include +.ir /proc/[pid]/exe " and " /proc/[pid]/fd/* ). +unlike normal symbolic links, magic links are not resolved through +pathname-expansion, but instead act as direct references to the kernel's own +representation of a file handle. +as such, these magic links allow users to +access files which cannot be referenced with normal paths (such as unlinked +files still referenced by a running program ). +.pp +because they can bypass ordinary +.br mount_namespaces (7)-based +restrictions, +magic links have been used as attack vectors in various exploits. +.\" +.ss symbolic link ownership, permissions, and timestamps +the owner and group of an existing symbolic link can be changed +using +.br lchown (2). +the only time that the ownership of a symbolic link matters is +when the link is being removed or renamed in a directory that +has the sticky bit set (see +.br stat (2)). +.pp +the last access and last modification timestamps +of a symbolic link can be changed using +.br utimensat (2) +or +.br lutimes (3). +.pp +.\" linux does not currently implement an lchmod(2). +on linux, the permissions of an ordinary symbolic link are not used in any +operations; the permissions are always 0777 (read, write, and execute for all +user categories), and can't be changed. +.pp +however, magic links do not follow this rule. +they can have a non-0777 mode, +though this mode is not currently used in any permission checks. +.\" .pp +.\" the +.\" 4.4bsd +.\" system differs from historical +.\" 4bsd +.\" systems in that the system call +.\" .br chown (2) +.\" has been changed to follow symbolic links. +.\" the +.\" .br lchown (2) +.\" system call was added later when the limitations of the new +.\" .br chown (2) +.\" became apparent. +.ss obtaining a file descriptor that refers to a symbolic link +using the combination of the +.b o_path +and +.br o_nofollow +flags to +.br open (2) +yields a file descriptor that can be passed as the +.ir dirfd +argument in system calls such as +.br fstatat (2), +.br fchownat (2), +.br fchmodat (2), +.br linkat (2), +and +.br readlinkat (2), +in order to operate on the symbolic link itself +(rather than the file to which it refers). +.pp +by default +(i.e., if the +.br at_symlink_follow +flag is not specified), if +.br name_to_handle_at (2) +is applied to a symbolic link, it yields a handle for the symbolic link +(rather than the file to which it refers). +one can then obtain a file descriptor for the symbolic link +(rather than the file to which it refers) +by specifying the +.b o_path +flag in a subsequent call to +.br open_by_handle_at (2). +again, that file descriptor can be used in the +aforementioned system calls to operate on the symbolic link itself. +.ss handling of symbolic links by system calls and commands +symbolic links are handled either by operating on the link itself, +or by operating on the object referred to by the link. +in the latter case, +an application or system call is said to +.i follow +the link. +symbolic links may refer to other symbolic links, +in which case the links are dereferenced until an object that is +not a symbolic link is found, +a symbolic link that refers to a file which does not exist is found, +or a loop is detected. +(loop detection is done by placing an upper limit on the number of +links that may be followed, and an error results if this limit is +exceeded.) +.pp +there are three separate areas that need to be discussed. +they are as follows: +.ip 1. 3 +symbolic links used as filename arguments for system calls. +.ip 2. +symbolic links specified as command-line arguments to utilities that +are not traversing a file tree. +.ip 3. +symbolic links encountered by utilities that are traversing a file tree +(either specified on the command line or encountered as part of the +file hierarchy walk). +.pp +before describing the treatment of symbolic links by system calls and commands, +we require some terminology. +given a pathname of the form +.ir a/b/c , +the part preceding the final slash (i.e., +.ir a/b ) +is called the +.i dirname +component, and the part following the final slash (i.e., +.ir c ) +is called the +.ir basename +component. +.\" +.ss treatment of symbolic links in system calls +the first area is symbolic links used as filename arguments for +system calls. +.pp +the treatment of symbolic links within a pathname passed to +a system call is as follows: +.ip 1. 3 +within the dirname component of a pathname, +symbolic links are always followed in nearly every system call. +(this is also true for commands.) +the one exception is +.br openat2 (2), +which provides flags that can be used to explicitly +prevent following of symbolic links in the dirname component. +.ip 2. +except as noted below, +all system calls follow symbolic links +in the basename component of a pathname. +for example, if there were a symbolic link +.i slink +which pointed to a file named +.ir afile , +the system call +.i "open(""slink"" ...\&)" +would return a file descriptor referring to the file +.ir afile . +.pp +various system calls do not follow links in +the basename component of a pathname, +and operate on the symbolic link itself. +they are: +.br lchown (2), +.br lgetxattr (2), +.br llistxattr (2), +.br lremovexattr (2), +.br lsetxattr (2), +.br lstat (2), +.br readlink (2), +.br rename (2), +.br rmdir (2), +and +.br unlink (2). +.pp +certain other system calls optionally follow symbolic links +in the basename component of a pathname. +they are: +.br faccessat (2), +.\" maybe one day: .br fchownat (2) +.br fchownat (2), +.br fstatat (2), +.br linkat (2), +.br name_to_handle_at (2), +.br open (2), +.br openat (2), +.br open_by_handle_at (2), +and +.br utimensat (2); +see their manual pages for details. +because +.br remove (3) +is an alias for +.br unlink (2), +that library function also does not follow symbolic links. +when +.br rmdir (2) +is applied to a symbolic link, it fails with the error +.br enotdir . +.pp +.br link (2) +warrants special discussion. +posix.1-2001 specifies that +.br link (2) +should dereference +.i oldpath +if it is a symbolic link. +however, linux does not do this. +(by default, solaris is the same, +but the posix.1-2001 specified behavior can be obtained with +suitable compiler options.) +posix.1-2008 changed the specification to allow +either behavior in an implementation. +.ss commands not traversing a file tree +the second area is symbolic links, specified as command-line +filename arguments, to commands which are not traversing a file tree. +.pp +except as noted below, commands follow symbolic links named as +command-line arguments. +for example, if there were a symbolic link +.i slink +which pointed to a file named +.ir afile , +the command +.i "cat slink" +would display the contents of the file +.ir afile . +.pp +it is important to realize that this rule includes commands which may +optionally traverse file trees; for example, the command +.i "chown file" +is included in this rule, while the command +.ir "chown\ \-r file" , +which performs a tree traversal, is not. +(the latter is described in the third area, below.) +.pp +if it is explicitly intended that the command operate on the symbolic +link instead of following the symbolic link\(emfor example, it is desired that +.i "chown slink" +change the ownership of the file that +.i slink +is, whether it is a symbolic link or not\(emthen the +.i \-h +option should be used. +in the above example, +.i "chown root slink" +would change the ownership of the file referred to by +.ir slink , +while +.i "chown\ \-h root slink" +would change the ownership of +.i slink +itself. +.pp +there are some exceptions to this rule: +.ip * 2 +the +.br mv (1) +and +.br rm (1) +commands do not follow symbolic links named as arguments, +but respectively attempt to rename and delete them. +(note, if the symbolic link references a file via a relative path, +moving it to another directory may very well cause it to stop working, +since the path may no longer be correct.) +.ip * +the +.br ls (1) +command is also an exception to this rule. +for compatibility with historic systems (when +.br ls (1) +is not doing a tree walk\(emthat is, +.i \-r +option is not specified), +the +.br ls (1) +command follows symbolic links named as arguments if the +.i \-h +or +.i \-l +option is specified, +or if the +.ir \-f , +.ir \-d , +or +.i \-l +options are not specified. +(the +.br ls (1) +command is the only command where the +.i \-h +and +.i \-l +options affect its behavior even though it is not doing a walk of +a file tree.) +.ip * +the +.br file (1) +command is also an exception to this rule. +the +.br file (1) +command does not follow symbolic links named as argument by default. +the +.br file (1) +command does follow symbolic links named as argument if the +.i \-l +option is specified. +.\" +.\"the 4.4bsd system differs from historical 4bsd systems in that the +.\".br chown (1) +.\"and +.\".br chgrp (1) +.\"commands follow symbolic links specified on the command line. +.ss commands traversing a file tree +the following commands either optionally or always traverse file trees: +.br chgrp (1), +.br chmod (1), +.br chown (1), +.br cp (1), +.br du (1), +.br find (1), +.br ls (1), +.br pax (1), +.br rm (1), +and +.br tar (1). +.pp +it is important to realize that the following rules apply equally to +symbolic links encountered during the file tree traversal and symbolic +links listed as command-line arguments. +.pp +the \fifirst rule\fp applies to symbolic links that reference files other +than directories. +operations that apply to symbolic links are performed on the links +themselves, but otherwise the links are ignored. +.pp +the command +.i "rm\ \-r slink directory" +will remove +.ir slink , +as well as any symbolic links encountered in the tree traversal of +.ir directory , +because symbolic links may be removed. +in no case will +.br rm (1) +affect the file referred to by +.ir slink . +.pp +the \fisecond rule\fp applies to symbolic links that refer to directories. +symbolic links that refer to directories are never followed by default. +this is often referred to as a "physical" walk, as opposed to a "logical" +walk (where symbolic links that refer to directories are followed). +.pp +certain conventions are (should be) followed as consistently as +possible by commands that perform file tree walks: +.ip * 2 +a command can be made to follow +any symbolic links named on the command line, +regardless of the type of file they reference, by specifying the +.i \-h +(for "half-logical") flag. +this flag is intended to make the command-line name space look +like the logical name space. +(note, for commands that do not always do file tree traversals, the +.i \-h +flag will be ignored if the +.i \-r +flag is not also specified.) +.ip +for example, the command +.i "chown\ \-hr user slink" +will traverse the file hierarchy rooted in the file pointed to by +.ir slink . +note, the +.i \-h +is not the same as the previously discussed +.i \-h +flag. +the +.i \-h +flag causes symbolic links specified on the command line to be +dereferenced for the purposes of both the action to be performed +and the tree walk, and it is as if the user had specified the +name of the file to which the symbolic link pointed. +.ip * +a command can be made to +follow any symbolic links named on the command line, +as well as any symbolic links encountered during the traversal, +regardless of the type of file they reference, by specifying the +.i \-l +(for "logical") flag. +this flag is intended to make the entire name space look like +the logical name space. +(note, for commands that do not always do file tree traversals, the +.i \-l +flag will be ignored if the +.i \-r +flag is not also specified.) +.ip +for example, the command +.i "chown\ \-lr user slink" +will change the owner of the file referred to by +.ir slink . +if +.i slink +refers to a directory, +.b chown +will traverse the file hierarchy rooted in the directory that it +references. +in addition, if any symbolic links are encountered in any file tree that +.b chown +traverses, they will be treated in the same fashion as +.ir slink . +.ip * +a command can be made to +provide the default behavior by specifying the +.i \-p +(for "physical") flag. +this flag is intended to make the entire name space look like the +physical name space. +.pp +for commands that do not by default do file tree traversals, the +.ir \-h , +.ir \-l , +and +.i \-p +flags are ignored if the +.i \-r +flag is not also specified. +in addition, you may specify the +.ir \-h , +.ir \-l , +and +.i \-p +options more than once; +the last one specified determines the command's behavior. +this is intended to permit you to alias commands to behave one way +or the other, and then override that behavior on the command line. +.pp +the +.br ls (1) +and +.br rm (1) +commands have exceptions to these rules: +.ip * 2 +the +.br rm (1) +command operates on the symbolic link, and not the file it references, +and therefore never follows a symbolic link. +the +.br rm (1) +command does not support the +.ir \-h , +.ir \-l , +or +.i \-p +options. +.ip * +to maintain compatibility with historic systems, +the +.br ls (1) +command acts a little differently. +if you do not specify the +.ir \-f , +.ir \-d , +or +.i \-l +options, +.br ls (1) +will follow symbolic links specified on the command line. +if the +.i \-l +flag is specified, +.br ls (1) +follows all symbolic links, +regardless of their type, +whether specified on the command line or encountered in the tree walk. +.sh see also +.br chgrp (1), +.br chmod (1), +.br find (1), +.br ln (1), +.br ls (1), +.br mv (1), +.br namei (1), +.br rm (1), +.br lchown (2), +.br link (2), +.br lstat (2), +.br readlink (2), +.br rename (2), +.br symlink (2), +.br unlink (2), +.br utimensat (2), +.br lutimes (3), +.br path_resolution (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/strsignal.3 + +.so man3/fenv.3 + +.\" copyright 1993 rickard e. faith (faith@cs.unc.edu) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified 2002-04-15 by roger luethi and aeb +.\" +.th getdtablesize 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +getdtablesize \- get file descriptor table size +.sh synopsis +.nf +.b #include +.pp +.b int getdtablesize(void); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br getdtablesize (): +.nf + since glibc 2.20: + _default_source || ! (_posix_c_source >= 200112l) + glibc 2.12 to 2.19: + _bsd_source || ! (_posix_c_source >= 200112l) + before glibc 2.12: + _bsd_source || _xopen_source >= 500 +.\" || _xopen_source && _xopen_source_extended +.fi +.sh description +.br getdtablesize () +returns the maximum number of files a process can have open, +one more than the largest possible value for a file descriptor. +.sh return value +the current limit on the number of open files per process. +.sh errors +on linux, +.br getdtablesize () +can return any of the errors described for +.br getrlimit (2); +see notes below. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br getdtablesize () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +svr4, 4.4bsd (the +.br getdtablesize () +function first appeared in 4.2bsd). +it is not specified in posix.1; +portable applications should employ +.i sysconf(_sc_open_max) +instead of this call. +.sh notes +the glibc version of +.br getdtablesize () +calls +.br getrlimit (2) +and returns the current +.b rlimit_nofile +limit, or +.b open_max +when that fails. +.\" the libc4 and libc5 versions return +.\" .b open_max +.\" (set to 256 since linux 0.98.4). +.sh see also +.br close (2), +.br dup (2), +.br getrlimit (2), +.br open (2) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/rcmd.3 + +.\" copyright 2009 lefteris dimitroulakis (edimitro@tee.gr) +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th cp1251 7 2020-08-13 "linux" "linux programmer's manual" +.sh name +cp1251 \- cp\ 1251 character set encoded in octal, decimal, +and hexadecimal +.sh description +the windows code pages include several 8-bit extensions to the ascii +character set (also known as iso 646-irv). +cp\ 1251 encodes the +characters used in cyrillic scripts. +.ss cp\ 1251 characters +the following table displays the characters in cp\ 1251 that +are printable and unlisted in the +.br ascii (7) +manual page. +.ts +l l l c lp-1. +oct dec hex char description +_ +200 128 80 ђ cyrillic capital letter dje +201 129 81 ѓ cyrillic capital letter gje +202 130 82 ‚ single low-9 quotation mark +203 131 83 ѓ cyrillic small letter gje +204 132 84 „ double low-9 quotation mark +205 133 85 … horizontal ellipsis +206 134 86 † dagger +207 135 87 ‡ double dagger +210 136 88 € euro sign +211 137 89 ‰ per mille sign +212 138 8a љ cyrillic capital letter lje +213 139 8b ‹ single left-pointing angle quotation mark +214 140 8c њ cyrillic capital letter nje +215 141 8d ќ cyrillic capital letter kje +216 142 8e ћ cyrillic capital letter tshe +217 143 8f џ cyrillic capital letter dzhe +220 144 90 ђ cyrillic small letter dje +221 145 91 ‘ left single quotation mark +222 146 92 ’ right single quotation mark +223 147 93 “ left double quotation mark +224 148 94 ” right double quotation mark +225 149 95 • bullet +226 150 96 – en dash +227 151 97 — em dash +230 152 98 undefined +231 153 99 ™ trade mark sign +232 154 9a љ cyrillic small letter lje +233 155 9b › single right-pointing angle quotation mark +234 156 9c њ cyrillic small letter nje +235 157 9d ќ cyrillic small letter kje +236 158 9e ћ cyrillic small letter tshe +237 159 9f џ cyrillic small letter dzhe +240 160 a0   no-break space +241 161 a1 ў cyrillic capital letter short u +242 162 a2 ў cyrillic small letter short u +243 163 a3 ј cyrillic capital letter je +244 164 a4 ¤ currency sign +245 165 a5 ґ cyrillic capital letter ghe with upturn +246 166 a6 ¦ broken bar +247 167 a7 § section sign +250 168 a8 ё cyrillic capital letter io +251 169 a9 © copyright sign +252 170 aa є cyrillic capital letter ukrainian ie +253 171 ab « left-pointing double angle quotation mark +254 172 ac ¬ not sign +255 173 ad ­ soft hyphen +256 174 ae ® registered sign +257 175 af ї cyrillic capital letter yi +260 176 b0 ° degree sign +261 177 b1 ± plus-minus sign +262 178 b2 і t{ +cyrillic capital letter +.br +byelorussian-ukrainian i +t} +263 179 b3 і cyrillic small letter byelorussian-ukrainian i +264 180 b4 ґ cyrillic small letter ghe with upturn +265 181 b5 µ micro sign +266 182 b6 ¶ pilcrow sign +267 183 b7 · middle dot +270 184 b8 ё cyrillic small letter io +271 185 b9 № numero sign +272 186 ba є cyrillic small letter ukrainian ie +273 187 bb » right-pointing double angle quotation mark +274 188 bc ј cyrillic small letter je +275 189 bd ѕ cyrillic capital letter dze +276 190 be ѕ cyrillic small letter dze +277 191 bf ї cyrillic small letter yi +300 192 c0 а cyrillic capital letter a +301 193 c1 б cyrillic capital letter be +302 194 c2 в cyrillic capital letter ve +303 195 c3 г cyrillic capital letter ghe +304 196 c4 д cyrillic capital letter de +305 197 c5 е cyrillic capital letter ie +306 198 c6 ж cyrillic capital letter zhe +307 199 c7 з cyrillic capital letter ze +310 200 c8 и cyrillic capital letter i +311 201 c9 й cyrillic capital letter short i +312 202 ca к cyrillic capital letter ka +313 203 cb л cyrillic capital letter el +314 204 cc м cyrillic capital letter em +315 205 cd н cyrillic capital letter en +316 206 ce о cyrillic capital letter o +317 207 cf п cyrillic capital letter pe +320 208 d0 р cyrillic capital letter er +321 209 d1 с cyrillic capital letter es +322 210 d2 т cyrillic capital letter te +323 211 d3 у cyrillic capital letter u +324 212 d4 ф cyrillic capital letter ef +325 213 d5 х cyrillic capital letter ha +326 214 d6 ц cyrillic capital letter tse +327 215 d7 ч cyrillic capital letter che +330 216 d8 ш cyrillic capital letter sha +331 217 d9 щ cyrillic capital letter shcha +332 218 da ъ cyrillic capital letter hard sign +333 219 db ы cyrillic capital letter yeru +334 220 dc ь cyrillic capital letter soft sign +335 221 dd э cyrillic capital letter e +336 222 de ю cyrillic capital letter yu +337 223 df я cyrillic capital letter ya +340 224 e0 а cyrillic small letter a +341 225 e1 б cyrillic small letter be +342 226 e2 в cyrillic small letter ve +343 227 e3 г cyrillic small letter ghe +344 228 e4 д cyrillic small letter de +345 229 e5 е cyrillic small letter ie +346 230 e6 ж cyrillic small letter zhe +347 231 e7 з cyrillic small letter ze +350 232 e8 и cyrillic small letter i +351 233 e9 й cyrillic small letter short i +352 234 ea к cyrillic small letter ka +353 235 eb л cyrillic small letter el +354 236 ec м cyrillic small letter em +355 237 ed н cyrillic small letter en +356 238 ee о cyrillic small letter o +357 239 ef п cyrillic small letter pe +360 240 f0 р cyrillic small letter er +361 241 f1 с cyrillic small letter es +362 242 f2 т cyrillic small letter te +363 243 f3 у cyrillic small letter u +364 244 f4 ф cyrillic small letter ef +365 245 f5 х cyrillic small letter ha +366 246 f6 ц cyrillic small letter tse +367 247 f7 ч cyrillic small letter che +370 248 f8 ш cyrillic small letter sha +371 249 f9 щ cyrillic small letter shcha +372 250 fa ъ cyrillic small letter hard sign +373 251 fb ы cyrillic small letter yeru +374 252 fc ь cyrillic small letter soft sign +375 253 fd э cyrillic small letter e +376 254 fe ю cyrillic small letter yu +377 255 ff я cyrillic small letter ya +.te +.sh notes +cp\ 1251 is also known as windows cyrillic. +.sh see also +.br ascii (7), +.br charsets (7), +.br cp1252 (7), +.br iso_8859\-5 (7), +.br koi8\-r (7), +.br koi8\-u (7), +.br utf\-8 (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1997 martin schulze (joey@infodrom.north.de) +.\" much of the text is copied from the manpage of resolv+(8). +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" 2003-08-23 martin schulze updated according to glibc 2.3.2 +.th host.conf 5 2019-03-06 "linux" "linux system administration" +.sh name +host.conf \- resolver configuration file +.sh description +the file +.i /etc/host.conf +contains configuration information specific to the resolver library. +it should contain one configuration keyword per line, followed by +appropriate configuration information. +the following keywords are recognized: +.tp +.i trim +this keyword may be listed more than once. +each time it should be +followed by a list of domains, separated by colons (\(aq:\(aq), semicolons +(\(aq;\(aq) or commas (\(aq,\(aq), with the leading dot. +when set, the +resolver library will automatically trim the given domain name from the +end of any hostname resolved via dns. +this is intended for use with +local hosts and domains. +(related note: +.i trim +will not affect hostnames gathered via nis or the +.br hosts (5) +file. +care should be taken to +ensure that the first hostname for each entry in the hosts file is +fully qualified or unqualified, as appropriate for the local +installation.) +.tp +.i multi +valid values are +.ir on " and " off . +if set to +.ir on , +the resolver library will return all valid addresses for a host that +appears in the +.i /etc/hosts +file, +instead of only the first. +this is +.i off +by default, as it may cause a substantial performance loss at sites +with large hosts files. +.tp +.i reorder +valid values are +.ir on " and " off . +if set to +.ir on , +the resolver library +will attempt to reorder host addresses so that local addresses +(i.e., on the same subnet) are listed first when a +.br gethostbyname (3) +is performed. +reordering is done for all lookup methods. +the default value is +.ir off . +.sh environment +the following environment variables can be used to allow users to +override the behavior which is configured in +.ir /etc/host.conf : +.tp +.b resolv_host_conf +if set, this variable points to a file that should be read instead of +.ir /etc/host.conf . +.tp +.b resolv_multi +overrides the +.i multi +command. +.tp +.b resolv_reorder +overrides the +.i reorder +command. +.tp +.b resolv_add_trim_domains +a list of domains, separated by colons (\(aq:\(aq), semicolons (\(aq;\(aq), or +commas (\(aq,\(aq), with the leading dot, which will be added to the list of +domains that should be trimmed. +.tp +.b resolv_override_trim_domains +a list of domains, separated by colons (\(aq:\(aq), semicolons (\(aq;\(aq), or +commas (\(aq,\(aq), with the leading dot, which will replace the list of +domains that should be trimmed. +overrides the +.i trim +command. +.sh files +.tp +.i /etc/host.conf +resolver configuration file +.tp +.i /etc/resolv.conf +resolver configuration file +.tp +.i /etc/hosts +local hosts database +.sh notes +the following differences exist compared to the original implementation. +a new command +.i spoof +and a new environment variable +.b resolv_spoof_check +can take arguments like +.ir off ", " nowarn ", and " warn . +line comments can appear anywhere and not only at the beginning of a line. +.ss historical +the +.br nsswitch.conf (5) +file is the modern way of controlling the order of host lookups. +.pp +in glibc 2.4 and earlier, the following keyword is recognized: +.tp +.i order +this keyword specifies how host lookups are to be performed. +it should be followed by one or more lookup methods, separated by commas. +valid methods are +.ir bind ", " hosts ", and " nis . +.tp +.b resolv_serv_order +overrides the +.i order +command. +.pp +.\" commit 7d68cdaa4f748e87ee921f587ee2d483db624b3d +since glibc 2.0.7, and up through glibc 2.24, the following keywords and environment variable have +been recognized but never implemented: +.tp +.i nospoof +valid values are +.ir on " and " off . +if set to +.ir on , +the resolver library will attempt to prevent hostname spoofing to +enhance the security of +.br rlogin " and " rsh . +it works as follows: after performing a host address lookup, +the resolver library will perform a hostname lookup for that address. +if the two hostnames +do not match, the query fails. +the default value is +.ir off . +.tp +.i spoofalert +valid values are +.ir on " and " off . +if this option is set to +.i on +and the +.i nospoof +option is also set, +the resolver library will log a warning of the error via the +syslog facility. +the default value is +.ir off . +.tp +.i spoof +valid values are +.ir off ", " nowarn ", and " warn . +if this option is set to +.ir off , +spoofed addresses are permitted and no warnings will be emitted +via the syslog facility. +if this option is set to +.ir warn , +the resolver library will attempt to prevent hostname spoofing to +enhance the security and log a warning of the error via the syslog +facility. +if this option is set to +.ir nowarn , +the resolver library will attempt to prevent hostname spoofing to +enhance the security but not emit warnings via the syslog facility. +setting this option to anything else is equal to setting it to +.ir nowarn . +.tp +.b resolv_spoof_check +overrides the +.ir nospoof ", " spoofalert ", and " spoof +commands in the same way as the +.i spoof +command is parsed. +valid values are +.ir off ", " nowarn ", and " warn . +.sh see also +.br gethostbyname (3), +.br hosts (5), +.br nsswitch.conf (5), +.br resolv.conf (5), +.br hostname (7), +.br named (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1995 mark d. roth (roth@uiuc.edu) +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" solaris manpages +.\" +.\" modified thu jul 25 14:43:46 met dst 1996 by michael haardt +.\" +.\" +.th getutent 3 2021-03-22 "" "linux programmer's manual" +.sh name +getutent, getutid, getutline, pututline, setutent, endutent, +utmpname \- access utmp file entries +.sh synopsis +.nf +.b #include +.pp +.b struct utmp *getutent(void); +.bi "struct utmp *getutid(const struct utmp *" ut ); +.bi "struct utmp *getutline(const struct utmp *" ut ); +.pp +.bi "struct utmp *pututline(const struct utmp *" ut ); +.pp +.b void setutent(void); +.b void endutent(void); +.pp +.bi "int utmpname(const char *" file ); +.fi +.sh description +new applications should use the posix.1-specified "utmpx" versions of +these functions; see conforming to. +.pp +.br utmpname () +sets the name of the utmp-format file for the other utmp +functions to access. +if +.br utmpname () +is not used to set the filename +before the other functions are used, they assume \fb_path_utmp\fp, as +defined in \fi\fp. +.pp +.br setutent () +rewinds the file pointer to the beginning of the utmp file. +it is generally a good idea to call it before any of the other +functions. +.pp +.br endutent () +closes the utmp file. +it should be called when the user +code is done accessing the file with the other functions. +.pp +.br getutent () +reads a line from the current file position in the utmp file. +it returns a pointer to a structure containing the fields of +the line. +the definition of this structure is shown in +.br utmp (5). +.pp +.br getutid () +searches forward from the current file position in the utmp +file based upon \fiut\fp. +if \fiut\->ut_type\fp is one of \fbrun_lvl\fp, +\fbboot_time\fp, \fbnew_time\fp, or \fbold_time\fp, +.br getutid () +will +find the first entry whose \fiut_type\fp field matches \fiut\->ut_type\fp. +if \fiut\->ut_type\fp is one of \fbinit_process\fp, \fblogin_process\fp, +\fbuser_process\fp, or \fbdead_process\fp, +.br getutid () +will find the +first entry whose +.i ut_id +field matches \fiut\->ut_id\fp. +.pp +.br getutline () +searches forward from the current file position in the utmp file. +it scans entries whose +.i ut_type +is \fbuser_process\fp +or \fblogin_process\fp and returns the first one whose +.i ut_line +field +matches \fiut\->ut_line\fp. +.pp +.br pututline () +writes the +.i utmp +structure \fiut\fp into the utmp file. +it uses +.br getutid () +to search for the proper place in the file to insert +the new entry. +if it cannot find an appropriate slot for \fiut\fp, +.br pututline () +will append the new entry to the end of the file. +.sh return value +.br getutent (), +.br getutid (), +and +.br getutline () +return a pointer to a \fistruct utmp\fp on success, +and null on failure (which includes the "record not found" case). +this \fistruct utmp\fp is allocated in static storage, and may be +overwritten by subsequent calls. +.pp +on success +.br pututline () +returns +.ir ut ; +on failure, it returns null. +.pp +.br utmpname () +returns 0 if the new name was successfully stored, or \-1 on failure. +.pp +on failure, these functions +.i errno +set to indicate the error. +.sh errors +.tp +.b enomem +out of memory. +.tp +.b esrch +record not found. +.pp +.br setutent (), +.br pututline (), +and the +.br getut* () +functions can also fail for the reasons described in +.br open (2). +.sh files +.tp +.i /var/run/utmp +database of currently logged-in users +.tp +.i /var/log/wtmp +database of past user logins +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lb lb lbx +l l l. +interface attribute value +t{ +.br getutent () +t} thread safety t{ +mt-unsafe init race:utent +race:utentbuf sig:alrm timer +t} +t{ +.br getutid (), +.br getutline () +t} thread safety t{ +mt-unsafe init race:utent +sig:alrm timer +t} +t{ +.br pututline () +t} thread safety t{ +mt-unsafe race:utent +sig:alrm timer +t} +t{ +.br setutent (), +.br endutent (), +.br utmpname () +t} thread safety mt-unsafe race:utent +.te +.hy +.ad +.sp 1 +in the above table, +.i utent +in +.i race:utent +signifies that if any of the functions +.br setutent (), +.br getutent (), +.br getutid (), +.br getutline (), +.br pututline (), +.br utmpname (), +or +.br endutent () +are used in parallel in different threads of a program, +then data races could occur. +.sh conforming to +xpg2, svr4. +.pp +in xpg2 and svid 2 the function +.br pututline () +is documented to return void, and that is what it does on many systems +(aix, hp-ux). +hp-ux introduces a new function +.br _pututline () +with the prototype given above for +.br pututline (). +.pp +all these functions are obsolete now on non-linux systems. +posix.1-2001 and posix.1-2008, following susv1, +does not have any of these functions, but instead uses +.pp +.rs 4 +.ex +.b #include +.pp +.b struct utmpx *getutxent(void); +.b struct utmpx *getutxid(const struct utmpx *); +.b struct utmpx *getutxline(const struct utmpx *); +.b struct utmpx *pututxline(const struct utmpx *); +.b void setutxent(void); +.b void endutxent(void); +.ee +.re +.pp +these functions are provided by glibc, +and perform the same task as their equivalents without the "x", but use +.ir "struct utmpx" , +defined on linux to be the same as +.ir "struct utmp" . +for completeness, glibc also provides +.br utmpxname (), +although this function is not specified by posix.1. +.pp +on some other systems, +the \fiutmpx\fp structure is a superset of the \fiutmp\fp structure, +with additional fields, and larger versions of the existing fields, +and parallel files are maintained, often +.i /var/*/utmpx +and +.ir /var/*/wtmpx . +.pp +linux glibc on the other hand does not use a parallel \fiutmpx\fp file +since its \fiutmp\fp structure is already large enough. +the "x" functions listed above are just aliases for +their counterparts without the "x" (e.g., +.br getutxent () +is an alias for +.br getutent ()). +.sh notes +.ss glibc notes +the above functions are not thread-safe. +glibc adds reentrant versions +.pp +.nf +.b #include +.pp +.bi "int getutent_r(struct utmp *" ubuf ", struct utmp **" ubufp ); +.bi "int getutid_r(struct utmp *" ut , +.bi " struct utmp *" ubuf ", struct utmp **" ubufp ); +.bi "int getutline_r(struct utmp *" ut , +.bi " struct utmp *" ubuf ", struct utmp **" ubufp ); +.fi +.pp +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.pp +.br getutent_r (), +.br getutid_r (), +.br getutline_r (): +.nf + _gnu_source + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _svid_source || _bsd_source +.fi +.pp +these functions are gnu extensions, analogs of the functions of the +same name without the _r suffix. +the +.i ubuf +argument gives these functions a place to store their result. +on success, they return 0, and a pointer to the result is written in +.ir *ubufp . +on error, these functions return \-1. +there are no utmpx equivalents of the above functions. +(posix.1 does not specify such functions.) +.sh examples +the following example adds and removes a utmp record, assuming it is run +from within a pseudo terminal. +for usage in a real application, you +should check the return values of +.br getpwuid (3) +and +.br ttyname (3). +.pp +.ex +#include +#include +#include +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + struct utmp entry; + + system("echo before adding entry:;who"); + + entry.ut_type = user_process; + entry.ut_pid = getpid(); + strcpy(entry.ut_line, ttyname(stdin_fileno) + strlen("/dev/")); + /* only correct for ptys named /dev/tty[pqr][0\-9a\-z] */ + strcpy(entry.ut_id, ttyname(stdin_fileno) + strlen("/dev/tty")); + time(&entry.ut_time); + strcpy(entry.ut_user, getpwuid(getuid())\->pw_name); + memset(entry.ut_host, 0, ut_hostsize); + entry.ut_addr = 0; + setutent(); + pututline(&entry); + + system("echo after adding entry:;who"); + + entry.ut_type = dead_process; + memset(entry.ut_line, 0, ut_linesize); + entry.ut_time = 0; + memset(entry.ut_user, 0, ut_namesize); + setutent(); + pututline(&entry); + + system("echo after removing entry:;who"); + + endutent(); + exit(exit_success); +} +.ee +.sh see also +.br getutmp (3), +.br utmp (5) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" this man page is copyright (c) 1998 heiner eisen. +.\" +.\" %%%license_start(verbatim_one_para) +.\" permission is granted to distribute possibly modified copies +.\" of this page provided the header is included verbatim, +.\" and in case of nontrivial modification author and date +.\" of the modification is added to the header. +.\" %%%license_end +.\" +.\" $id: x25.7,v 1.4 1999/05/18 10:35:12 freitag exp $ +.\" +.th x25 7 2021-03-22 "linux" "linux programmer's manual" +.sh name +x25 \- itu-t x.25 / iso-8208 protocol interface +.sh synopsis +.nf +.b #include +.b #include +.pp +.b x25_socket = socket(af_x25, sock_seqpacket, 0); +.fi +.sh description +x25 sockets provide an interface to the x.25 packet layer protocol. +this allows applications to +communicate over a public x.25 data network as standardized by +international telecommunication union's recommendation x.25 +(x.25 dte-dce mode). +x25 sockets can also be used for communication +without an intermediate x.25 network (x.25 dte-dte mode) as described +in iso-8208. +.pp +message boundaries are preserved \(em a +.br read (2) +from a socket will +retrieve the same chunk of data as output with the corresponding +.br write (2) +to the peer socket. +when necessary, the kernel takes care +of segmenting and reassembling long messages by means of +the x.25 m-bit. +there is no hard-coded upper limit for the +message size. +however, reassembling of a long message might fail if +there is a temporary lack of system resources or when other constraints +(such as socket memory or buffer size limits) become effective. +if that +occurs, the x.25 connection will be reset. +.ss socket addresses +the +.b af_x25 +socket address family uses the +.i struct sockaddr_x25 +for representing network addresses as defined in itu-t +recommendation x.121. +.pp +.in +4n +.ex +struct sockaddr_x25 { + sa_family_t sx25_family; /* must be af_x25 */ + x25_address sx25_addr; /* x.121 address */ +}; +.ee +.in +.pp +.i sx25_addr +contains a char array +.i x25_addr[] +to be interpreted as a null-terminated string. +.i sx25_addr.x25_addr[] +consists of up to 15 (not counting the terminating null byte) ascii +characters forming the x.121 address. +only the decimal digit characters from \(aq0\(aq to \(aq9\(aq are allowed. +.ss socket options +the following x.25-specific socket options can be set by using +.br setsockopt (2) +and read with +.br getsockopt (2) +with the +.i level +argument set to +.br sol_x25 . +.tp +.b x25_qbitincl +controls whether the x.25 q-bit (qualified data bit) is accessible by the +user. +it expects an integer argument. +if set to 0 (default), +the q-bit is never set for outgoing packets and the q-bit of incoming +packets is ignored. +if set to 1, an additional first byte is prepended +to each message read from or written to the socket. +for data read from +the socket, a 0 first byte indicates that the q-bits of the corresponding +incoming data packets were not set. +a first byte with value 1 indicates +that the q-bit of the corresponding incoming data packets was set. +if the first byte of the data written to the socket is 1, the q-bit of the +corresponding outgoing data packets will be set. +if the first byte is 0, +the q-bit will not be set. +.sh versions +the af_x25 protocol family is a new feature of linux 2.2. +.sh bugs +plenty, as the x.25 plp implementation is +.br config_experimental . +.pp +this man page is incomplete. +.pp +there is no dedicated application programmer's header file yet; +you need to include the kernel header file +.ir . +.b config_experimental +might also imply that future versions of the +interface are not binary compatible. +.pp +x.25 n-reset events are not propagated to the user process yet. +thus, +if a reset occurred, data might be lost without notice. +.sh see also +.br socket (2), +.br socket (7) +.pp +jonathan simon naylor: +\(lqthe re-analysis and re-implementation of x.25.\(rq +the url is +.ur ftp://ftp.pspt.fi\:/pub\:/ham\:/linux\:/ax25\:/x25doc.tgz +.ue . +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2007 silicon graphics, inc. all rights reserved +.\" written by dave chinner +.\" +.\" %%%license_start(gplv2_oneline) +.\" may be distributed as per gnu general public license version 2. +.\" %%%license_end +.\" +.\" 2011-09-19: added falloc_fl_punch_hole +.\" 2011-09-19: substantial restructuring of the page +.\" +.th fallocate 2 2019-11-19 "linux" "linux programmer's manual" +.sh name +fallocate \- manipulate file space +.sh synopsis +.nf +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "int fallocate(int " fd ", int " mode ", off_t " offset \ +", off_t " len ");" +.fi +.sh description +this is a nonportable, linux-specific system call. +for the portable, posix.1-specified method of ensuring that space +is allocated for a file, see +.br posix_fallocate (3). +.pp +.br fallocate () +allows the caller to directly manipulate the allocated disk space +for the file referred to by +.i fd +for the byte range starting at +.i offset +and continuing for +.i len +bytes. +.pp +the +.i mode +argument determines the operation to be performed on the given range. +details of the supported operations are given in the subsections below. +.ss allocating disk space +the default operation (i.e., +.i mode +is zero) of +.br fallocate () +allocates the disk space within the range specified by +.i offset +and +.ir len . +the file size (as reported by +.br stat (2)) +will be changed if +.ir offset + len +is greater than the file size. +any subregion within the range specified by +.i offset +and +.ir len +that did not contain data before the call will be initialized to zero. +this default behavior closely resembles the behavior of the +.br posix_fallocate (3) +library function, +and is intended as a method of optimally implementing that function. +.pp +after a successful call, subsequent writes into the range specified by +.ir offset +and +.ir len +are guaranteed not to fail because of lack of disk space. +.pp +if the +.b falloc_fl_keep_size +flag is specified in +.ir mode , +the behavior of the call is similar, +but the file size will not be changed even if +.ir offset + len +is greater than the file size. +preallocating zeroed blocks beyond the end of the file in this manner +is useful for optimizing append workloads. +.pp +if the +.b falloc_fl_unshare_range +flag is specified in +.ir mode , +shared file data extents will be made private to the file to guarantee +that a subsequent write will not fail due to lack of space. +typically, this will be done by performing a copy-on-write operation on +all shared data in the file. +this flag may not be supported by all filesystems. +.pp +because allocation is done in block size chunks, +.br fallocate () +may allocate a larger range of disk space than was specified. +.ss deallocating file space +specifying the +.br falloc_fl_punch_hole +flag (available since linux 2.6.38) in +.i mode +deallocates space (i.e., creates a hole) +in the byte range starting at +.i offset +and continuing for +.i len +bytes. +within the specified range, partial filesystem blocks are zeroed, +and whole filesystem blocks are removed from the file. +after a successful call, +subsequent reads from this range will return zeros. +.pp +the +.br falloc_fl_punch_hole +flag must be ored with +.br falloc_fl_keep_size +in +.ir mode ; +in other words, even when punching off the end of the file, the file size +(as reported by +.br stat (2)) +does not change. +.pp +not all filesystems support +.br falloc_fl_punch_hole ; +if a filesystem doesn't support the operation, an error is returned. +the operation is supported on at least the following filesystems: +.ip * 3 +xfs (since linux 2.6.38) +.ip * +ext4 (since linux 3.0) +.\" commit a4bb6b64e39abc0e41ca077725f2a72c868e7622 +.ip * +btrfs (since linux 3.7) +.ip * +.br tmpfs (5) +(since linux 3.5) +.\" commit 83e4fa9c16e4af7122e31be3eca5d57881d236fe +.ip * +.br gfs2 (5) +(since linux 4.16) +.\" commit 4e56a6411fbce6f859566e17298114c2434391a4 +.ss collapsing file space +.\" commit 00f5e61998dd17f5375d9dfc01331f104b83f841 +specifying the +.br falloc_fl_collapse_range +flag (available since linux 3.15) in +.i mode +removes a byte range from a file, without leaving a hole. +the byte range to be collapsed starts at +.i offset +and continues for +.i len +bytes. +at the completion of the operation, +the contents of the file starting at the location +.i offset+len +will be appended at the location +.ir offset , +and the file will be +.i len +bytes smaller. +.pp +a filesystem may place limitations on the granularity of the operation, +in order to ensure efficient implementation. +typically, +.i offset +and +.i len +must be a multiple of the filesystem logical block size, +which varies according to the filesystem type and configuration. +if a filesystem has such a requirement, +.br fallocate () +fails with the error +.br einval +if this requirement is violated. +.pp +if the region specified by +.i offset +plus +.i len +reaches or passes the end of file, an error is returned; +instead, use +.br ftruncate (2) +to truncate a file. +.pp +no other flags may be specified in +.ir mode +in conjunction with +.br falloc_fl_collapse_range . +.pp +as at linux 3.15, +.b falloc_fl_collapse_range +is supported by +ext4 (only for extent-based files) +.\" commit 9eb79482a97152930b113b51dff530aba9e28c8e +and xfs. +.\" commit e1d8fb88a64c1f8094b9f6c3b6d2d9e6719c970d +.ss zeroing file space +specifying the +.br falloc_fl_zero_range +flag (available since linux 3.15) +.\" commit 409332b65d3ed8cfa7a8030f1e9d52f372219642 +in +.i mode +zeros space in the byte range starting at +.i offset +and continuing for +.i len +bytes. +within the specified range, blocks are preallocated for the regions +that span the holes in the file. +after a successful call, subsequent +reads from this range will return zeros. +.pp +zeroing is done within the filesystem preferably by converting the range into +unwritten extents. +this approach means that the specified range will not be physically zeroed +out on the device (except for partial blocks at the either end of the range), +and i/o is (otherwise) required only to update metadata. +.pp +if the +.b falloc_fl_keep_size +flag is additionally specified in +.ir mode , +the behavior of the call is similar, +but the file size will not be changed even if +.ir offset + len +is greater than the file size. +this behavior is the same as when preallocating space with +.b falloc_fl_keep_size +specified. +.pp +not all filesystems support +.br falloc_fl_zero_range ; +if a filesystem doesn't support the operation, an error is returned. +the operation is supported on at least the following filesystems: +.ip * 3 +xfs (since linux 3.15) +.\" commit 376ba313147b4172f3e8cf620b9fb591f3e8cdfa +.ip * +ext4, for extent-based files (since linux 3.15) +.\" commit b8a8684502a0fc852afa0056c6bb2a9273f6fcc0 +.ip * +smb3 (since linux 3.17) +.\" commit 30175628bf7f521e9ee31ac98fa6d6fe7441a556 +.ip * +btrfs (since linux 4.16) +.\" commit f27451f229966874a8793995b8e6b74326d125df +.ss increasing file space +specifying the +.br falloc_fl_insert_range +flag +(available since linux 4.1) +.\" commit dd46c787788d5bf5b974729d43e4c405814a4c7d +in +.i mode +increases the file space by inserting a hole within the file size without +overwriting any existing data. +the hole will start at +.i offset +and continue for +.i len +bytes. +when inserting the hole inside file, the contents of the file starting at +.i offset +will be shifted upward (i.e., to a higher file offset) by +.i len +bytes. +inserting a hole inside a file increases the file size by +.i len +bytes. +.pp +this mode has the same limitations as +.br falloc_fl_collapse_range +regarding the granularity of the operation. +if the granularity requirements are not met, +.br fallocate () +fails with the error +.br einval . +if the +.i offset +is equal to or greater than the end of file, an error is returned. +for such operations (i.e., inserting a hole at the end of file), +.br ftruncate (2) +should be used. +.pp +no other flags may be specified in +.ir mode +in conjunction with +.br falloc_fl_insert_range . +.pp +.b falloc_fl_insert_range +requires filesystem support. +filesystems that support this operation include +xfs (since linux 4.1) +.\" commit a904b1ca5751faf5ece8600e18cd3b674afcca1b +and ext4 (since linux 4.2). +.\" commit 331573febb6a224bc50322e3670da326cb7f4cfc +.\" f2fs also has support since linux 4.2 +.\" commit f62185d0e283e9d311e3ac1020f159d95f0aab39 +.sh return value +on success, +.br fallocate () +returns zero. +on error, \-1 is returned and +.i errno +is set to indicate the error. +.sh errors +.tp +.b ebadf +.i fd +is not a valid file descriptor, or is not opened for writing. +.tp +.b efbig +.ir offset + len +exceeds the maximum file size. +.tp +.b efbig +.i mode +is +.br falloc_fl_insert_range , +and the current file size+\filen\fp exceeds the maximum file size. +.tp +.b eintr +a signal was caught during execution; see +.br signal (7). +.tp +.b einval +.i offset +was less than 0, or +.i len +.\" fixme . (raise a kernel bug) probably the len==0 case should be +.\" a no-op, rather than an error. that would be consistent with +.\" similar apis for the len==0 case. +.\" see "re: [patch] fallocate.2: add falloc_fl_punch_hole flag definition" +.\" 21 sep 2012 +.\" http://thread.gmane.org/gmane.linux.file-systems/48331/focus=1193526 +was less than or equal to 0. +.tp +.b einval +.i mode +is +.br falloc_fl_collapse_range +and the range specified by +.i offset +plus +.i len +reaches or passes the end of the file. +.tp +.b einval +.i mode +is +.br falloc_fl_insert_range +and the range specified by +.i offset +reaches or passes the end of the file. +.tp +.b einval +.i mode +is +.br falloc_fl_collapse_range +or +.br falloc_fl_insert_range , +but either +.i offset +or +.i len +is not a multiple of the filesystem block size. +.tp +.b einval +.i mode +contains one of +.b falloc_fl_collapse_range +or +.b falloc_fl_insert_range +and also other flags; +no other flags are permitted with +.br falloc_fl_collapse_range +or +.br falloc_fl_insert_range . +.tp +.b einval +.i mode +is +.br falloc_fl_collapse_range +or +.br falloc_fl_zero_range +or +.br falloc_fl_insert_range , +but the file referred to by +.i fd +is not a regular file. +.\" there was an inconsistency in 3.15-rc1, that should be resolved so that all +.\" filesystems use this error for this case. (tytso says ex4 will change.) +.\" http://thread.gmane.org/gmane.comp.file-systems.xfs.general/60485/focus=5521 +.\" from: michael kerrisk (man-pages +.\" subject: re: [patch v5 10/10] manpage: update falloc_fl_collapse_range flag in fallocate +.\" newsgroups: gmane.linux.man, gmane.linux.file-systems +.\" date: 2014-04-17 13:40:05 gmt +.tp +.b eio +an i/o error occurred while reading from or writing to a filesystem. +.tp +.b enodev +.i fd +does not refer to a regular file or a directory. +(if +.i fd +is a pipe or fifo, a different error results.) +.tp +.b enospc +there is not enough space left on the device containing the file +referred to by +.ir fd . +.tp +.b enosys +this kernel does not implement +.br fallocate (). +.tp +.b eopnotsupp +the filesystem containing the file referred to by +.i fd +does not support this operation; +or the +.i mode +is not supported by the filesystem containing the file referred to by +.ir fd . +.tp +.b eperm +the file referred to by +.i fd +is marked immutable (see +.br chattr (1)). +.tp +.b eperm +.i mode +specifies +.br falloc_fl_punch_hole +or +.br falloc_fl_collapse_range +or +.br falloc_fl_insert_range +and +the file referred to by +.i fd +is marked append-only +(see +.br chattr (1)). +.tp +.b eperm +the operation was prevented by a file seal; see +.br fcntl (2). +.tp +.b espipe +.i fd +refers to a pipe or fifo. +.tp +.b etxtbsy +.i mode +specifies +.br falloc_fl_collapse_range +or +.br falloc_fl_insert_range , +but the file referred to by +.ir fd +is currently being executed. +.sh versions +.br fallocate () +is available on linux since kernel 2.6.23. +support is provided by glibc since version 2.10. +the +.br falloc_fl_* +flags are defined in glibc headers only since version 2.18. +.\" see http://sourceware.org/bugzilla/show_bug.cgi?id=14964 +.sh conforming to +.br fallocate () +is linux-specific. +.sh see also +.br fallocate (1), +.br ftruncate (2), +.br posix_fadvise (3), +.br posix_fallocate (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2002 andries brouwer +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" this replaces an earlier man page written by walter harms +.\" . +.\" +.th qecvt 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +qecvt, qfcvt, qgcvt \- convert a floating-point number to a string +.sh synopsis +.nf +.b #include +.pp +.bi "char *qecvt(long double " number ", int " ndigits \ +", int *restrict " decpt , +.bi " int *restrict " sign ); +.bi "char *qfcvt(long double " number ", int " ndigits \ +", int *restrict " decpt , +.bi " int *restrict " sign ); +.bi "char *qgcvt(long double " number ", int " ndigit ", char *" buf ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br qecvt (), +.br qfcvt (), +.br qgcvt (): +.nf + since glibc 2.19: + _default_source + in glibc up to and including 2.19: + _svid_source +.fi +.\" fixme . the full ftm picture looks to have been something like the +.\" following mess: +.\" glibc 2.20 onward +.\" _default_source +.\" glibc 2.18 to glibc 2.19 +.\" _bsd_source || _svid_source +.\" glibc 2.10 to glibc 2.17 +.\" _svid_source || (_xopen_source >= 500 || +.\" (_xopen_source && _xopen_source_extended) && +.\" ! (_posix_c_source >= 200809l)) +.\" before glibc 2.10: +.\" _svid_source || _xopen_source >= 500 || +.\" (_xopen_source && _xopen_source_extended) +.sh description +the functions +.br qecvt (), +.br qfcvt (), +and +.br qgcvt () +are identical to +.br ecvt (3), +.br fcvt (3), +and +.br gcvt (3) +respectively, except that they use a +.i "long double" +argument +.ir number . +see +.br ecvt (3) +and +.br gcvt (3). +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br qecvt () +t} thread safety mt-unsafe race:qecvt +t{ +.br qfcvt () +t} thread safety mt-unsafe race:qfcvt +t{ +.br qgcvt () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +svr4. +not seen in most common unix implementations, +but occurs in sunos. +.\" not supported by libc4 and libc5. +supported by glibc. +.sh notes +these functions are obsolete. +instead, +.br snprintf (3) +is recommended. +.sh see also +.br ecvt (3), +.br ecvt_r (3), +.br gcvt (3), +.br sprintf (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1993 by thomas koenig (ig25@rz.uni-karlsruhe.de) +.\" and copyright (c) 2014 by michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified sat jul 24 17:51:15 1993 by rik faith (faith@cs.unc.edu) +.\" modified 11 may 1998 by joseph s. myers (jsm28@cam.ac.uk) +.\" modified 14 may 2001, 23 sep 2001 by aeb +.\" 2004-12-20, mtk +.\" +.th system 3 2021-03-22 "" "linux programmer's manual" +.sh name +system \- execute a shell command +.sh synopsis +.nf +.b #include +.pp +.bi "int system(const char *" "command" ); +.fi +.sh description +the +.br system () +library function uses +.br fork (2) +to create a child process that executes the shell command specified in +.i command +using +.br execl (3) +as follows: +.pp +.in +4n +.ex +execl("/bin/sh", "sh", "\-c", command, (char *) null); +.ee +.in +.pp +.br system () +returns after the command has been completed. +.pp +during execution of the command, +.b sigchld +will be blocked, and +.b sigint +and +.b sigquit +will be ignored, in the process that calls +.br system (). +(these signals will be handled according to their defaults inside +the child process that executes +.ir command .) +.pp +if +.i command +is null, then +.br system () +returns a status indicating whether a shell is available on the system. +.sh return value +the return value of +.br system () +is one of the following: +.ip * 3 +if +.i command +is null, then a nonzero value if a shell is available, +or 0 if no shell is available. +.ip * +if a child process could not be created, +or its status could not be retrieved, +the return value is \-1 and +.i errno +is set to indicate the error. +.ip * +if a shell could not be executed in the child process, +then the return value is as though the child shell terminated by calling +.br _exit (2) +with the status 127. +.ip * +if all system calls succeed, +then the return value is the termination status of the child shell +used to execute +.ir command . +(the termination status of a shell is the termination status of +the last command it executes.) +.pp +in the last two cases, +the return value is a "wait status" that can be examined using +the macros described in +.br waitpid (2). +(i.e., +.br wifexited (), +.br wexitstatus (), +and so on). +.pp +.br system () +does not affect the wait status of any other children. +.sh errors +.br system () +can fail with any of the same errors as +.br fork (2). +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br system () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c89, c99. +.sh notes +.br system () +provides simplicity and convenience: +it handles all of the details of calling +.br fork (2), +.br execl (3), +and +.br waitpid (2), +as well as the necessary manipulations of signals; +in addition, +the shell performs the usual substitutions and i/o redirections for +.ir command . +the main cost of +.br system () +is inefficiency: +additional system calls are required to create the process that +runs the shell and to execute the shell. +.pp +if the +.b _xopen_source +feature test macro is defined +(before including +.i any +header files), +then the macros described in +.br waitpid (2) +.rb ( wexitstatus (), +etc.) are made available when including +.ir . +.pp +as mentioned, +.br system () +ignores +.b sigint +and +.br sigquit . +this may make programs that call it +from a loop uninterruptible, unless they take care themselves +to check the exit status of the child. +for example: +.pp +.in +4n +.ex +while (something) { + int ret = system("foo"); + + if (wifsignaled(ret) && + (wtermsig(ret) == sigint || wtermsig(ret) == sigquit)) + break; +} +.ee +.in +.pp +according to posix.1, it is unspecified whether handlers registered using +.br pthread_atfork (3) +are called during the execution of +.br system (). +in the glibc implementation, such handlers are not called. +.pp +in versions of glibc before 2.1.3, the check for the availability of +.i /bin/sh +was not actually performed if +.i command +was null; instead it was always assumed to be available, and +.br system () +always returned 1 in this case. +since glibc 2.1.3, this check is performed because, even though +posix.1-2001 requires a conforming implementation to provide +a shell, that shell may not be available or executable if +the calling program has previously called +.br chroot (2) +(which is not specified by posix.1-2001). +.pp +it is possible for the shell command to terminate with a status of 127, +which yields a +.br system () +return value that is indistinguishable from the case +where a shell could not be executed in the child process. +.\" +.ss caveats +do not use +.br system () +from a privileged program +(a set-user-id or set-group-id program, or a program with capabilities) +because strange values for some environment variables +might be used to subvert system integrity. +for example, +.br path +could be manipulated so that an arbitrary program +is executed with privilege. +use the +.br exec (3) +family of functions instead, but not +.br execlp (3) +or +.br execvp (3) +(which also use the +.b path +environment variable to search for an executable). +.pp +.br system () +will not, in fact, work properly from programs with set-user-id or +set-group-id privileges on systems on which +.i /bin/sh +is bash version 2: as a security measure, bash 2 drops privileges on startup. +(debian uses a different shell, +.br dash (1), +which does not do this when invoked as +.br sh .) +.pp +any user input that is employed as part of +.i command +should be +.i carefully +sanitized, to ensure that unexpected shell commands or command options +are not executed. +such risks are especially grave when using +.br system () +from a privileged program. +.sh bugs +.\" [bug 211029](https://bugzilla.kernel.org/show_bug.cgi?id=211029) +.\" [glibc bug](https://sourceware.org/bugzilla/show_bug.cgi?id=27143) +.\" [posix bug](https://www.austingroupbugs.net/view.php?id=1440) +if the command name starts with a hyphen, +.br sh (1) +interprets the command name as an option, +and the behavior is undefined. +(see the +.b \-c +option to +.br sh (1).) +to work around this problem, +prepend the command with a space as in the following call: +.pp +.in +4n +.ex + system(" \-unfortunate\-command\-name"); +.ee +.in +.sh see also +.br sh (1), +.br execve (2), +.br fork (2), +.br sigaction (2), +.br sigprocmask (2), +.br wait (2), +.br exec (3), +.br signal (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2003 davide libenzi +.\" davide libenzi +.\" and copyright 2009, 2014, 2016, 2018, 2019 michael kerrisk +.\" +.\" %%%license_start(gplv2+_sw_3_para) +.\" this program is free software; you can redistribute it and/or modify +.\" it under the terms of the gnu general public license as published by +.\" the free software foundation; either version 2 of the license, or +.\" (at your option) any later version. +.\" +.\" this program 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th epoll_ctl 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +epoll_ctl \- control interface for an epoll file descriptor +.sh synopsis +.nf +.b #include +.pp +.bi "int epoll_ctl(int " epfd ", int " op ", int " fd \ +", struct epoll_event *" event ); +.fi +.sh description +this system call is used to add, modify, or remove +entries in the interest list of the +.br epoll (7) +instance +referred to by the file descriptor +.ir epfd . +it requests that the operation +.i op +be performed for the target file descriptor, +.ir fd . +.pp +valid values for the +.i op +argument are: +.tp +.b epoll_ctl_add +add an entry to the interest list of the epoll file descriptor, +.ir epfd . +the entry includes the file descriptor, +.ir fd , +a reference to the corresponding open file description (see +.br epoll (7) +and +.br open (2)), +and the settings specified in +.ir event . +.tp +.b epoll_ctl_mod +change the settings associated with +.ir fd +in the interest list to the new settings specified in +.ir event . +.tp +.b epoll_ctl_del +remove (deregister) the target file descriptor +.i fd +from the interest list. +the +.i event +argument is ignored and can be null (but see bugs below). +.pp +the +.i event +argument describes the object linked to the file descriptor +.ir fd . +the +.i struct epoll_event +is defined as: +.pp +.in +4n +.ex +typedef union epoll_data { + void *ptr; + int fd; + uint32_t u32; + uint64_t u64; +} epoll_data_t; + +struct epoll_event { + uint32_t events; /* epoll events */ + epoll_data_t data; /* user data variable */ +}; +.ee +.in +.pp +the +.i data +member of the +.i epoll_event +structure specifies data that the kernel should save and then return (via +.br epoll_wait (2)) +when this file descriptor becomes ready. +.pp +the +.i events +member of the +.i epoll_event +structure is a bit mask composed by oring together zero or more of +the following available event types: +.tp +.b epollin +the associated file is available for +.br read (2) +operations. +.tp +.b epollout +the associated file is available for +.br write (2) +operations. +.tp +.br epollrdhup " (since linux 2.6.17)" +stream socket peer closed connection, +or shut down writing half of connection. +(this flag is especially useful for writing simple code to detect +peer shutdown when using edge-triggered monitoring.) +.tp +.b epollpri +there is an exceptional condition on the file descriptor. +see the discussion of +.b pollpri +in +.br poll (2). +.tp +.b epollerr +error condition happened on the associated file descriptor. +this event is also reported for the write end of a pipe when the read end +has been closed. +.ip +.br epoll_wait (2) +will always report for this event; it is not necessary to set it in +.ir events +when calling +.br epoll_ctl (). +.tp +.b epollhup +hang up happened on the associated file descriptor. +.ip +.br epoll_wait (2) +will always wait for this event; it is not necessary to set it in +.ir events +when calling +.br epoll_ctl (). +.ip +note that when reading from a channel such as a pipe or a stream socket, +this event merely indicates that the peer closed its end of the channel. +subsequent reads from the channel will return 0 (end of file) +only after all outstanding data in the channel has been consumed. +.tp +.b epollet +requests edge-triggered notification for the associated file descriptor. +the default behavior for +.b epoll +is level-triggered. +see +.br epoll (7) +for more detailed information about edge-triggered and +level-triggered notification. +.ip +this flag is an input flag for the +.i event.events +field when calling +.br epoll_ctl (); +it is never returned by +.br epoll_wait (2). +.tp +.br epolloneshot " (since linux 2.6.2)" +requests one-shot notification for the associated file descriptor. +this means that after an event notified for the file descriptor by +.br epoll_wait (2), +the file descriptor is disabled in the interest list and no other events +will be reported by the +.b epoll +interface. +the user must call +.br epoll_ctl () +with +.b epoll_ctl_mod +to rearm the file descriptor with a new event mask. +.ip +this flag is an input flag for the +.i event.events +field when calling +.br epoll_ctl (); +it is never returned by +.br epoll_wait (2). +.tp +.br epollwakeup " (since linux 3.5)" +.\" commit 4d7e30d98939a0340022ccd49325a3d70f7e0238 +if +.b epolloneshot +and +.b epollet +are clear and the process has the +.b cap_block_suspend +capability, +ensure that the system does not enter "suspend" or +"hibernate" while this event is pending or being processed. +the event is considered as being "processed" from the time +when it is returned by a call to +.br epoll_wait (2) +until the next call to +.br epoll_wait (2) +on the same +.br epoll (7) +file descriptor, +the closure of that file descriptor, +the removal of the event file descriptor with +.br epoll_ctl_del , +or the clearing of +.b epollwakeup +for the event file descriptor with +.br epoll_ctl_mod . +see also bugs. +.ip +this flag is an input flag for the +.i event.events +field when calling +.br epoll_ctl (); +it is never returned by +.br epoll_wait (2). +.tp +.br epollexclusive " (since linux 4.5)" +sets an exclusive wakeup mode for the epoll file descriptor that is being +attached to the target file descriptor, +.ir fd . +when a wakeup event occurs and multiple epoll file descriptors +are attached to the same target file using +.br epollexclusive , +one or more of the epoll file descriptors will receive an event with +.br epoll_wait (2). +the default in this scenario (when +.br epollexclusive +is not set) is for all epoll file descriptors to receive an event. +.br epollexclusive +is thus useful for avoiding thundering herd problems in certain scenarios. +.ip +if the same file descriptor is in multiple epoll instances, +some with the +.br epollexclusive +flag, and others without, then events will be provided to all epoll +instances that did not specify +.br epollexclusive , +and at least one of the epoll instances that did specify +.br epollexclusive . +.ip +the following values may be specified in conjunction with +.br epollexclusive : +.br epollin , +.br epollout , +.br epollwakeup , +and +.br epollet . +.br epollhup +and +.br epollerr +can also be specified, but this is not required: +as usual, these events are always reported if they occur, +regardless of whether they are specified in +.ir events . +attempts to specify other values in +.i events +yield the error +.br einval . +.ip +.b epollexclusive +may be used only in an +.b epoll_ctl_add +operation; attempts to employ it with +.b epoll_ctl_mod +yield an error. +if +.b epollexclusive +has been set using +.br epoll_ctl (), +then a subsequent +.b epoll_ctl_mod +on the same +.ir epfd ",\ " fd +pair yields an error. +a call to +.br epoll_ctl () +that specifies +.b epollexclusive +in +.i events +and specifies the target file descriptor +.i fd +as an epoll instance will likewise fail. +the error in all of these cases is +.br einval . +.ip +the +.br epollexclusive +flag is an input flag for the +.i event.events +field when calling +.br epoll_ctl (); +it is never returned by +.br epoll_wait (2). +.sh return value +when successful, +.br epoll_ctl () +returns zero. +when an error occurs, +.br epoll_ctl () +returns \-1 and +.i errno +is set to indicate the error. +.sh errors +.tp +.b ebadf +.i epfd +or +.i fd +is not a valid file descriptor. +.tp +.b eexist +.i op +was +.br epoll_ctl_add , +and the supplied file descriptor +.i fd +is already registered with this epoll instance. +.tp +.b einval +.i epfd +is not an +.b epoll +file descriptor, +or +.i fd +is the same as +.ir epfd , +or the requested operation +.i op +is not supported by this interface. +.tp +.b einval +an invalid event type was specified along with +.b epollexclusive +in +.ir events . +.tp +.b einval +.i op +was +.b epoll_ctl_mod +and +.ir events +included +.br epollexclusive . +.tp +.b einval +.i op +was +.b epoll_ctl_mod +and the +.br epollexclusive +flag has previously been applied to this +.ir epfd ",\ " fd +pair. +.tp +.b einval +.br epollexclusive +was specified in +.ir event +and +.i fd +refers to an epoll instance. +.tp +.b eloop +.i fd +refers to an epoll instance and this +.b epoll_ctl_add +operation would result in a circular loop of epoll instances +monitoring one another or a nesting depth of epoll instances +greater than 5. +.tp +.b enoent +.i op +was +.b epoll_ctl_mod +or +.br epoll_ctl_del , +and +.i fd +is not registered with this epoll instance. +.tp +.b enomem +there was insufficient memory to handle the requested +.i op +control operation. +.tp +.b enospc +the limit imposed by +.i /proc/sys/fs/epoll/max_user_watches +was encountered while trying to register +.rb ( epoll_ctl_add ) +a new file descriptor on an epoll instance. +see +.br epoll (7) +for further details. +.tp +.b eperm +the target file +.i fd +does not support +.br epoll . +this error can occur if +.i fd +refers to, for example, a regular file or a directory. +.sh versions +.br epoll_ctl () +was added to the kernel in version 2.6. +.\" to be precise: kernel 2.5.44. +.\" the interface should be finalized by linux kernel 2.5.66. +library support is provided in glibc starting with version 2.3.2. +.sh conforming to +.br epoll_ctl () +is linux-specific. +.sh notes +the +.b epoll +interface supports all file descriptors that support +.br poll (2). +.sh bugs +in kernel versions before 2.6.9, the +.b epoll_ctl_del +operation required a non-null pointer in +.ir event , +even though this argument is ignored. +since linux 2.6.9, +.i event +can be specified as null +when using +.br epoll_ctl_del . +applications that need to be portable to kernels before 2.6.9 +should specify a non-null pointer in +.ir event . +.pp +if +.b epollwakeup +is specified in +.ir flags , +but the caller does not have the +.br cap_block_suspend +capability, then the +.b epollwakeup +flag is +.ir "silently ignored" . +this unfortunate behavior is necessary because no validity +checks were performed on the +.ir flags +argument in the original implementation, and the addition of the +.b epollwakeup +with a check that caused the call to fail if the caller did not have the +.b cap_block_suspend +capability caused a breakage in at least one existing user-space +application that happened to randomly (and uselessly) specify this bit. +.\" commit a8159414d7e3af7233e7a5a82d1c5d85379bd75c (behavior change) +.\" https://lwn.net/articles/520198/ +a robust application should therefore double check that it has the +.b cap_block_suspend +capability if attempting to use the +.b epollwakeup +flag. +.sh see also +.br epoll_create (2), +.br epoll_wait (2), +.br poll (2), +.br epoll (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/csin.3 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified 1993-03-29, david metcalfe +.\" modified 1993-07-24, rik faith (faith@cs.unc.edu) +.\" modified 2003-10-25, walter harms +.\" +.th atexit 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +atexit \- register a function to be called at normal process termination +.sh synopsis +.nf +.b #include +.pp +.bi "int atexit(void (*" function )(void)); +.fi +.sh description +the +.br atexit () +function registers the given +.i function +to be +called at normal process termination, either via +.br exit (3) +or via return from the program's +.ir main (). +functions so registered are called in +the reverse order of their registration; no arguments are passed. +.pp +the same function may be registered multiple times: +it is called once for each registration. +.pp +posix.1 requires that an implementation allow at least +.\" posix.1-2001, posix.1-2008 +.b atexit_max +(32) such functions to be registered. +the actual limit supported by an implementation can be obtained using +.br sysconf (3). +.pp +when a child process is created via +.br fork (2), +it inherits copies of its parent's registrations. +upon a successful call to one of the +.br exec (3) +functions, +all registrations are removed. +.sh return value +the +.br atexit () +function returns the value 0 if successful; otherwise +it returns a nonzero value. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br atexit () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c89, c99, svr4, 4.3bsd. +.sh notes +functions registered using +.br atexit () +(and +.br on_exit (3)) +are not called if a process terminates abnormally because +of the delivery of a signal. +.pp +if one of the registered functions calls +.br _exit (2), +then any remaining functions are not invoked, +and the other process termination steps performed by +.br exit (3) +are not performed. +.pp +posix.1 says that the result of calling +.\" posix.1-2001, posix.1-2008 +.br exit (3) +more than once (i.e., calling +.br exit (3) +within a function registered using +.br atexit ()) +is undefined. +on some systems (but not linux), this can result in an infinite recursion; +.\" this can happen on openbsd 4.2 for example, and is documented +.\" as occurring on freebsd as well. +.\" glibc does "the right thing" -- invocation of the remaining +.\" exit handlers carries on as normal. +portable programs should not invoke +.br exit (3) +inside a function registered using +.br atexit (). +.pp +the +.br atexit () +and +.br on_exit (3) +functions register functions on the same list: +at normal process termination, +the registered functions are invoked in reverse order +of their registration by these two functions. +.pp +according to posix.1, the result is undefined if +.br longjmp (3) +is used to terminate execution of one of the functions registered using +.br atexit (). +.\" in glibc, things seem to be handled okay +.ss linux notes +since glibc 2.2.3, +.br atexit () +(and +.br on_exit (3)) +can be used within a shared library to establish functions +that are called when the shared library is unloaded. +.sh examples +.ex +#include +#include +#include + +void +bye(void) +{ + printf("that was all, folks\en"); +} + +int +main(void) +{ + long a; + int i; + + a = sysconf(_sc_atexit_max); + printf("atexit_max = %ld\en", a); + + i = atexit(bye); + if (i != 0) { + fprintf(stderr, "cannot set exit function\en"); + exit(exit_failure); + } + + exit(exit_success); +} +.ee +.sh see also +.br _exit (2), +.br dlopen (3), +.br exit (3), +.br on_exit (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" and copyright 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified 1993-07-24 by rik faith (faith@cs.unc.edu) +.\" modified 2002-07-27 by walter harms +.\" (walter.harms@informatik.uni-oldenburg.de) +.\" +.th tanh 3 2021-03-22 "" "linux programmer's manual" +.sh name +tanh, tanhf, tanhl \- hyperbolic tangent function +.sh synopsis +.nf +.b #include +.pp +.bi "double tanh(double " x ); +.bi "float tanhf(float " x ); +.bi "long double tanhl(long double " x ); +.fi +.pp +link with \fi\-lm\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br tanhf (), +.br tanhl (): +.nf + _isoc99_source || _posix_c_source >= 200112l + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.sh description +these functions return the hyperbolic tangent of +.ir x , +which +is defined mathematically as: +.pp +.nf + tanh(x) = sinh(x) / cosh(x) +.fi +.sh return value +on success, these functions return the hyperbolic tangent of +.ir x . +.pp +if +.i x +is a nan, a nan is returned. +.pp +if +.i x +is +0 (\-0), +0 (\-0) is returned. +.pp +if +.i x +is positive infinity (negative infinity), ++1 (\-1) is returned. +.\" +.\" posix.1-2001 documents an optional range error (underflow) +.\" for subnormal x; +.\" glibc 2.8 does not do this. +.sh errors +no errors occur. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br tanh (), +.br tanhf (), +.br tanhl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.pp +the variant returning +.i double +also conforms to +svr4, 4.3bsd, c89. +.sh see also +.br acosh (3), +.br asinh (3), +.br atanh (3), +.br cosh (3), +.br ctanh (3), +.br sinh (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +#!/bin/sh +# +# find_dot_no_parens.sh +# +# look for function names after /^.[bir]/ that aren't +# followed by "()". +# +# this script is designed to help with "by hand" tidy-ups after +# the automated changes made by add_parens_for_own_funcs.sh. +# +# the first argument to this script names a manual page directory where +# 'man2' and 'man3' subdirectories can be found. the pages names in +# these directories are used to generate a series of regular expressions +# that can be used to search the manual page files that are named in +# the remaining command-line arguments. +# +# example usage: +# +# cd man-pages-x.yy +# sh find_dots_no_parens.sh . man?/*.? > matches.log +# +###################################################################### +# +# (c) copyright 2005 & 2013, michael kerrisk +# this program is free software; you can redistribute it and/or +# modify it under the terms of the gnu general public license +# as published by the free software foundation; either version 2 +# of the license, or (at your option) any later version. +# +# this program 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 general public license for more details +# (http://www.gnu.org/licenses/gpl-2.0.html). +# + +if test $# -lt 2; then + echo "usage: $0 man-page-root-dir file file..." 1>&2 + exit 1 +fi + +dir=$1 + +if ! test -d $dir/man2 || ! test -d $dir/man3; then + echo "can't find man2 and man3 under $dir" 1>&2 + exit 1 +fi + +shift 1 + +echo "this will take probably a few moments..." 1>&2 + +awk_script_file=tmp.$0.awk +rm -f $awk_script_file + +# we grep out a few page names that are likely to generate false +# positives... + +echo '{' >> $awk_script_file +echo ' myvar = $2;' >> $awk_script_file +echo ' gsub("[^a-z_0-9]*$", "", myvar);' >> $awk_script_file +echo ' if ( myvar == "nomatchesforthis" || ' >> $awk_script_file + +for page in $( + + find $dir/man2/* $dir/man3/* -type f -name '*.[23]' | + egrep -v '/(stderr|stdin|stdout|errno|termios|string)\..$'); do + + base=$(basename $page | sed -e 's/\.[23]$//') + echo " myvar == \"$base\" ||" >> $awk_script_file + +done + +echo ' myvar == "nomatchesforthis" )' >> $awk_script_file +echo ' print $0' >> $awk_script_file +echo '}' >> $awk_script_file + +grep '^\.[bri][bri]* [a-za-z0-9_][a-za-z0-9_]*[^a-za-z_]*$' $* | + awk -f $awk_script_file | grep -v '([0-9]*)' + +rm -f $awk_script_file +exit 0 + +.so man3/rpc.3 + +.so man2/rt_sigqueueinfo.2 + +.\" copyright (c) 1997 andries brouwer (aeb@cwi.nl) +.\" and copyright (c) 2005, 2010, 2014, 2015, michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified, 2003-05-26, michael kerrisk, +.th setresuid 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +setresuid, setresgid \- set real, effective, and saved user or group id +.sh synopsis +.nf +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "int setresuid(uid_t " ruid ", uid_t " euid ", uid_t " suid ); +.bi "int setresgid(gid_t " rgid ", gid_t " egid ", gid_t " sgid ); +.fi +.sh description +.br setresuid () +sets the real user id, the effective user id, and the +saved set-user-id of the calling process. +.pp +an unprivileged process may change its real uid, +effective uid, and saved set-user-id, each to one of: +the current real uid, the current effective uid, or the +current saved set-user-id. +.pp +a privileged process (on linux, one having the \fbcap_setuid\fp capability) +may set its real uid, effective uid, and +saved set-user-id to arbitrary values. +.pp +if one of the arguments equals \-1, the corresponding value is not changed. +.pp +regardless of what changes are made to the real uid, effective uid, +and saved set-user-id, the filesystem uid is always set to the same +value as the (possibly new) effective uid. +.pp +completely analogously, +.br setresgid () +sets the real gid, effective gid, and saved set-group-id +of the calling process (and always modifies the filesystem gid +to be the same as the effective gid), +with the same restrictions for unprivileged processes. +.sh return value +on success, zero is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.pp +.ir note : +there are cases where +.br setresuid () +can fail even when the caller is uid 0; +it is a grave security error to omit checking for a failure return from +.br setresuid (). +.sh errors +.tp +.b eagain +the call would change the caller's real uid (i.e., +.i ruid +does not match the caller's real uid), +but there was a temporary failure allocating the +necessary kernel data structures. +.tp +.b eagain +.i ruid +does not match the caller's real uid and this call would +bring the number of processes belonging to the real user id +.i ruid +over the caller's +.b rlimit_nproc +resource limit. +since linux 3.1, this error case no longer occurs +(but robust applications should check for this error); +see the description of +.b eagain +in +.br execve (2). +.tp +.b einval +one or more of the target user or group ids +is not valid in this user namespace. +.tp +.b eperm +the calling process is not privileged (did not have the necessary +capability in its user namespace) +and tried to change the ids to values that are not permitted. +for +.br setresuid (), +the necessary capability is +.br cap_setuid ; +for +.br setresgid (), +it is +.br cap_setgid . +.sh versions +these calls are available under linux since linux 2.1.44. +.sh conforming to +these calls are nonstandard; +they also appear on hp-ux and some of the bsds. +.sh notes +under hp-ux and freebsd, the prototype is found in +.ir . +under linux, the prototype is provided by glibc since version 2.3.2. +.pp +the original linux +.br setresuid () +and +.br setresgid () +system calls supported only 16-bit user and group ids. +subsequently, linux 2.4 added +.br setresuid32 () +and +.br setresgid32 (), +supporting 32-bit ids. +the glibc +.br setresuid () +and +.br setresgid () +wrapper functions transparently deal with the variations across kernel versions. +.\" +.ss c library/kernel differences +at the kernel level, user ids and group ids are a per-thread attribute. +however, posix requires that all threads in a process +share the same credentials. +the nptl threading implementation handles the posix requirements by +providing wrapper functions for +the various system calls that change process uids and gids. +these wrapper functions (including those for +.br setresuid () +and +.br setresgid ()) +employ a signal-based technique to ensure +that when one thread changes credentials, +all of the other threads in the process also change their credentials. +for details, see +.br nptl (7). +.sh see also +.br getresuid (2), +.br getuid (2), +.br setfsgid (2), +.br setfsuid (2), +.br setreuid (2), +.br setuid (2), +.br capabilities (7), +.br credentials (7), +.br user_namespaces (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/drand48.3 + +.so man3/argz_add.3 + +.\" copyright (c) 1993 michael haardt (michael@moria.de), +.\" fri apr 2 11:32:09 met dst 1993 +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" tue jul 6 12:42:46 mdt 1993 +.\" added "calling directly" and supporting paragraphs +.\" +.\" modified sat jul 24 15:19:12 1993 by rik faith +.\" +.\" modified 21 aug 1994 by michael chastain : +.\" added explanation of arg stacking when 6 or more args. +.\" +.\" modified 10 june 1995 by andries brouwer +.\" +.\" 2007-10-23 mtk: created as a new page, by taking the content +.\" specific to the _syscall() macros from intro(2). +.\" +.th _syscall 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +_syscall \- invoking a system call without library support (obsolete) +.sh synopsis +.nf +.b #include +.pp +a _syscall macro +.pp +desired system call +.fi +.sh description +the important thing to know about a system call is its prototype. +you need to know how many arguments, their types, +and the function return type. +there are seven macros that make the actual call into the system easier. +they have the form: +.pp +.in +4n +.ex +.ri _syscall x ( type , name , type1 , arg1 , type2 , arg2 ,...) +.ee +.in +.pp +where +.ip +.i x +is 0\(en6, which are the number of arguments taken by the +system call +.ip +.i type +is the return type of the system call +.ip +.i name +is the name of the system call +.ip +.i typen +is the nth argument's type +.ip +.i argn +is the name of the nth argument +.pp +these macros create a function called +.i name +with the arguments you +specify. +once you include the _syscall() in your source file, +you call the system call by +.ir name . +.sh files +.i /usr/include/linux/unistd.h +.sh conforming to +the use of these macros is linux-specific, and deprecated. +.sh notes +starting around kernel 2.6.18, the _syscall macros were removed +from header files supplied to user space. +use +.br syscall (2) +instead. +(some architectures, notably ia64, never provided the _syscall macros; +on those architectures, +.br syscall (2) +was always required.) +.pp +the _syscall() macros +.i "do not" +produce a prototype. +you may have to +create one, especially for c++ users. +.pp +system calls are not required to return only positive or negative error +codes. +you need to read the source to be sure how it will return errors. +usually, it is the negative of a standard error code, +for example, +.ri \- eperm . +the _syscall() macros will return the result +.i r +of the system call +when +.i r +is nonnegative, but will return \-1 and set the variable +.i errno +to +.ri \- r +when +.i r +is negative. +for the error codes, see +.br errno (3). +.pp +when defining a system call, the argument types +.i must +be +passed by-value or by-pointer (for aggregates like structs). +.\" the preferred way to invoke system calls that glibc does not know +.\" about yet is via +.\" .br syscall (2). +.\" however, this mechanism can be used only if using a libc +.\" (such as glibc) that supports +.\" .br syscall (2), +.\" and if the +.\" .i +.\" header file contains the required sys_foo definition. +.\" otherwise, the use of a _syscall macro is required. +.\" +.sh examples +.ex +#include +#include +#include +#include /* for _syscallx macros/related stuff */ +#include /* for struct sysinfo */ + +_syscall1(int, sysinfo, struct sysinfo *, info); + +int +main(void) +{ + struct sysinfo s_info; + int error; + + error = sysinfo(&s_info); + printf("code error = %d\en", error); + printf("uptime = %lds\enload: 1 min %lu / 5 min %lu / 15 min %lu\en" + "ram: total %lu / free %lu / shared %lu\en" + "memory in buffers = %lu\enswap: total %lu / free %lu\en" + "number of processes = %d\en", + s_info.uptime, s_info.loads[0], + s_info.loads[1], s_info.loads[2], + s_info.totalram, s_info.freeram, + s_info.sharedram, s_info.bufferram, + s_info.totalswap, s_info.freeswap, + s_info.procs); + exit(exit_success); +} +.ee +.ss sample output +.ex +code error = 0 +uptime = 502034s +load: 1 min 13376 / 5 min 5504 / 15 min 1152 +ram: total 15343616 / free 827392 / shared 8237056 +memory in buffers = 5066752 +swap: total 27881472 / free 24698880 +number of processes = 40 +.ee +.sh see also +.br intro (2), +.br syscall (2), +.br errno (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" +.th wcpcpy 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +wcpcpy \- copy a wide-character string, returning a pointer to its end +.sh synopsis +.nf +.b #include +.pp +.bi "wchar_t *wcpcpy(wchar_t *restrict " dest \ +", const wchar_t *restrict " src ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br wcpcpy (): +.nf + since glibc 2.10: + _posix_c_source >= 200809l + before glibc 2.10: + _gnu_source +.fi +.sh description +the +.br wcpcpy () +function is the wide-character equivalent of the +.br stpcpy (3) +function. +it copies the wide-character string pointed to by +.ir src , +including the terminating null wide character (l\(aq\e0\(aq), +to the array pointed to by +.ir dest . +.pp +the strings may not overlap. +.pp +the programmer must ensure that there +is room for at least +.ir wcslen(src)+1 +wide characters at +.ir dest . +.sh return value +.br wcpcpy () +returns a pointer to the end of the wide-character string +.ir dest , +that is, a pointer to the terminating null wide character. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br wcpcpy () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2008. +.sh see also +.br strcpy (3), +.br wcscpy (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/getmntent.3 + +.so man3/getutmp.3 + +.so man3/login.3 + +.\" copyright 1995 michael chastain (mec@shell.portal.com), 15 april 1995. +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" updated, aeb, 980612 +.\" +.th unimplemented 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +afs_syscall, break, fattach, fdetach, ftime, getmsg, getpmsg, gtty, isastream, +lock, madvise1, mpx, prof, profil, putmsg, putpmsg, security, +stty, tuxcall, ulimit, vserver \- unimplemented system calls +.sh synopsis +.nf +unimplemented system calls. +.fi +.sh description +these system calls are not implemented in the linux kernel. +.sh return value +these system calls always return \-1 and set +.i errno +to +.br enosys . +.sh notes +note that +.br ftime (3), +.br profil (3), +and +.br ulimit (3) +are implemented as library functions. +.pp +some system calls, like +.br alloc_hugepages (2), +.br free_hugepages (2), +.br ioperm (2), +.br iopl (2), +and +.br vm86 (2) +exist only on certain architectures. +.pp +some system calls, like +.br ipc (2), +.br create_module (2), +.br init_module (2), +and +.br delete_module (2) +exist only when the linux kernel was built with support for them. +.sh see also +.br syscalls (2) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/syslog.3 + +.\" copyright (c) 1990, 1991 the regents of the university of california. +.\" and copyright (c) 2021 michael kerrisk +.\" all rights reserved. +.\" +.\" this code is derived from software contributed to berkeley by +.\" chris torek and the american national standards committee x3, +.\" on information processing systems. +.\" +.\" %%%license_start(bsd_4_clause_ucb) +.\" redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. all advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" this product includes software developed by the university of +.\" california, berkeley and its contributors. +.\" 4. neither the name of the university nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" this software is provided by the regents and contributors ``as is'' and +.\" any express or implied warranties, including, but not limited to, the +.\" implied warranties of merchantability and fitness for a particular purpose +.\" are disclaimed. in no event shall the regents or contributors be liable +.\" for any direct, indirect, incidental, special, exemplary, or consequential +.\" damages (including, but not limited to, procurement of substitute goods +.\" or services; loss of use, data, or profits; or business interruption) +.\" however caused and on any theory of liability, whether in contract, strict +.\" liability, or tort (including negligence or otherwise) arising in any way +.\" out of the use of this software, even if advised of the possibility of +.\" such damage. +.\" %%%license_end +.\" +.\" converted for linux, mon nov 29 14:24:40 1993, faith@cs.unc.edu +.\" added remark on ebadf for fileno, aeb, 2001-03-22 +.\" +.th fileno 3 2021-03-22 "" "linux programmer's manual" +.sh name +fileno \- obtain file descriptor of a stdio stream +.sh synopsis +.nf +.b #include +.pp +.bi "int fileno(file *" stream ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br fileno (): +.nf + _posix_c_source +.fi +.sh description +.pp +the function +.br fileno () +examines the argument +.i stream +and returns the integer file descriptor used to implement this stream. +the file descriptor is still owned by +.i stream +and will be closed when +.br fclose (3) +is called. +duplicate the file descriptor with +.br dup (2) +before passing it to code that might close it. +.pp +for the nonlocking counterpart, see +.br unlocked_stdio (3). +.sh return value +on success, +.br fileno () +returns the file descriptor associated with +.ir stream . +on failure, \-1 is returned and +.i errno +is set to indicate the error. +.sh errors +.tp +.b ebadf +.i stream +is not associated with a file. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br fileno () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +the function +.br fileno () +conforms to posix.1-2001 and posix.1-2008. +.sh see also +.br open (2), +.br fdopen (3), +.br stdio (3), +.br unlocked_stdio (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/argz_add.3 + +.so man3/termios.3 + +.so man3/setaliasent.3 + +.so man3/getopt.3 + +.so man3/getspnam.3 + +.\" copyright (c) 2007, 2008 michael kerrisk +.\" and copyright (c) 2006 ulrich drepper +.\" a few pieces of an earlier version remain: +.\" copyright 2000, sam varshavchik +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references: rfc 2553 +.\" +.\" 2005-08-09, mtk, added ai_all, ai_addrconfig, ai_v4mapped, +.\" and ai_numericserv. +.\" 2006-11-25, ulrich drepper +.\" add text describing internationalized domain name extensions. +.\" 2007-06-08, mtk: added example programs +.\" 2008-02-26, mtk; clarify discussion of null 'hints' argument; other +.\" minor rewrites. +.\" 2008-06-18, mtk: many parts rewritten +.\" 2008-12-04, petr baudis +.\" describe results ordering and reference /etc/gai.conf. +.\" +.\" fixme . glibc's 2.9 news file documents dccp and udp-lite support +.\" and is sctp support now also there? +.\" +.th getaddrinfo 3 2021-08-27 "gnu" "linux programmer's manual" +.sh name +getaddrinfo, freeaddrinfo, gai_strerror \- network address and +service translation +.sh synopsis +.nf +.b #include +.b #include +.b #include +.pp +.bi "int getaddrinfo(const char *restrict " node , +.bi " const char *restrict " service , +.bi " const struct addrinfo *restrict " hints , +.bi " struct addrinfo **restrict " res ); +.pp +.bi "void freeaddrinfo(struct addrinfo *" res ); +.pp +.bi "const char *gai_strerror(int " errcode ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br getaddrinfo (), +.br freeaddrinfo (), +.br gai_strerror (): +.nf + since glibc 2.22: + _posix_c_source >= 200112l + glibc 2.21 and earlier: + _posix_c_source +.fi +.sh description +given +.i node +and +.ir service , +which identify an internet host and a service, +.br getaddrinfo () +returns one or more +.i addrinfo +structures, each of which contains an internet address +that can be specified in a call to +.br bind (2) +or +.br connect (2). +the +.br getaddrinfo () +function combines the functionality provided by the +.\" .br getipnodebyname (3), +.\" .br getipnodebyaddr (3), +.br gethostbyname (3) +and +.br getservbyname (3) +functions into a single interface, but unlike the latter functions, +.br getaddrinfo () +is reentrant and allows programs to eliminate ipv4-versus-ipv6 dependencies. +.pp +the +.i addrinfo +structure used by +.br getaddrinfo () +contains the following fields: +.pp +.in +4n +.ex +struct addrinfo { + int ai_flags; + int ai_family; + int ai_socktype; + int ai_protocol; + socklen_t ai_addrlen; + struct sockaddr *ai_addr; + char *ai_canonname; + struct addrinfo *ai_next; +}; +.ee +.in +.pp +the +.i hints +argument points to an +.i addrinfo +structure that specifies criteria for selecting the socket address +structures returned in the list pointed to by +.ir res . +if +.i hints +is not null it points to an +.i addrinfo +structure whose +.ir ai_family , +.ir ai_socktype , +and +.i ai_protocol +specify criteria that limit the set of socket addresses returned by +.br getaddrinfo (), +as follows: +.tp +.i ai_family +this field specifies the desired address family for the returned addresses. +valid values for this field include +.br af_inet +and +.br af_inet6 . +the value +.b af_unspec +indicates that +.br getaddrinfo () +should return socket addresses for any address family +(either ipv4 or ipv6, for example) that can be used with +.i node +and +.ir service . +.tp +.i ai_socktype +this field specifies the preferred socket type, for example +.br sock_stream +or +.br sock_dgram . +specifying 0 in this field indicates that socket addresses of any type +can be returned by +.br getaddrinfo (). +.tp +.i ai_protocol +this field specifies the protocol for the returned socket addresses. +specifying 0 in this field indicates that socket addresses with +any protocol can be returned by +.br getaddrinfo (). +.tp +.i ai_flags +this field specifies additional options, described below. +multiple flags are specified by bitwise or-ing them together. +.pp +all the other fields in the structure pointed to by +.i hints +must contain either 0 or a null pointer, as appropriate. +.pp +specifying +.i hints +as null is equivalent to setting +.i ai_socktype +and +.i ai_protocol +to 0; +.i ai_family +to +.br af_unspec ; +and +.i ai_flags +to +.br "(ai_v4mapped\ |\ ai_addrconfig)" . +(posix specifies different defaults for +.ir ai_flags ; +see notes.) +.i node +specifies either a numerical network address +(for ipv4, numbers-and-dots notation as supported by +.br inet_aton (3); +for ipv6, hexadecimal string format as supported by +.br inet_pton (3)), +or a network hostname, whose network addresses are looked up and resolved. +if +.i hints.ai_flags +contains the +.b ai_numerichost +flag, then +.i node +must be a numerical network address. +the +.b ai_numerichost +flag suppresses any potentially lengthy network host address lookups. +.pp +if the +.b ai_passive +flag is specified in +.ir hints.ai_flags , +and +.i node +is null, +then the returned socket addresses will be suitable for +.br bind (2)ing +a socket that will +.br accept (2) +connections. +the returned socket address will contain the "wildcard address" +.rb ( inaddr_any +for ipv4 addresses, +.br in6addr_any_init +for ipv6 address). +the wildcard address is used by applications (typically servers) +that intend to accept connections on any of the host's network addresses. +if +.i node +is not null, then the +.b ai_passive +flag is ignored. +.pp +if the +.b ai_passive +flag is not set in +.ir hints.ai_flags , +then the returned socket addresses will be suitable for use with +.br connect (2), +.br sendto (2), +or +.br sendmsg (2). +if +.i node +is null, +then the network address will be set to the loopback interface address +.rb ( inaddr_loopback +for ipv4 addresses, +.br in6addr_loopback_init +for ipv6 address); +this is used by applications that intend to communicate +with peers running on the same host. +.pp +.i service +sets the port in each returned address structure. +if this argument is a service name (see +.br services (5)), +it is translated to the corresponding port number. +this argument can also be specified as a decimal number, +which is simply converted to binary. +if +.i service +is null, then the port number of the returned socket addresses +will be left uninitialized. +if +.b ai_numericserv +is specified in +.i hints.ai_flags +and +.i service +is not null, then +.i service +must point to a string containing a numeric port number. +this flag is used to inhibit the invocation of a name resolution service +in cases where it is known not to be required. +.pp +either +.i node +or +.ir service , +but not both, may be null. +.pp +the +.br getaddrinfo () +function allocates and initializes a linked list of +.i addrinfo +structures, one for each network address that matches +.i node +and +.ir service , +subject to any restrictions imposed by +.ir hints , +and returns a pointer to the start of the list in +.ir res . +the items in the linked list are linked by the +.i ai_next +field. +.pp +there are several reasons why +the linked list may have more than one +.i addrinfo +structure, including: the network host is multihomed, accessible +over multiple protocols (e.g., both +.br af_inet +and +.br af_inet6 ); +or the same service is available from multiple socket types (one +.b sock_stream +address and another +.b sock_dgram +address, for example). +normally, the application should try +using the addresses in the order in which they are returned. +the sorting function used within +.br getaddrinfo () +is defined in rfc\ 3484; the order can be tweaked for a particular +system by editing +.ir /etc/gai.conf +(available since glibc 2.5). +.pp +if +.i hints.ai_flags +includes the +.b ai_canonname +flag, then the +.i ai_canonname +field of the first of the +.i addrinfo +structures in the returned list is set to point to the +official name of the host. +.\" in glibc prior to 2.3.4, the ai_canonname of each addrinfo +.\" structure was set pointing to the canonical name; that was +.\" more than posix.1-2001 specified, or other implementations provided. +.\" mtk, aug 05 +.pp +the remaining fields of each returned +.i addrinfo +structure are initialized as follows: +.ip * 2 +the +.ir ai_family , +.ir ai_socktype , +and +.i ai_protocol +fields return the socket creation parameters (i.e., these fields have +the same meaning as the corresponding arguments of +.br socket (2)). +for example, +.i ai_family +might return +.b af_inet +or +.br af_inet6 ; +.i ai_socktype +might return +.b sock_dgram +or +.br sock_stream ; +and +.i ai_protocol +returns the protocol for the socket. +.ip * +a pointer to the socket address is placed in the +.i ai_addr +field, and the length of the socket address, in bytes, +is placed in the +.i ai_addrlen +field. +.pp +if +.i hints.ai_flags +includes the +.b ai_addrconfig +flag, then ipv4 addresses are returned in the list pointed to by +.i res +only if the local system has at least one +ipv4 address configured, and ipv6 addresses are returned +only if the local system has at least one ipv6 address configured. +the loopback address is not considered for this case as valid +as a configured address. +this flag is useful on, for example, +ipv4-only systems, to ensure that +.br getaddrinfo () +does not return ipv6 socket addresses that would always fail in +.br connect (2) +or +.br bind (2). +.pp +if +.i hints.ai_flags +specifies the +.b ai_v4mapped +flag, and +.i hints.ai_family +was specified as +.br af_inet6 , +and no matching ipv6 addresses could be found, +then return ipv4-mapped ipv6 addresses in the list pointed to by +.ir res . +if both +.b ai_v4mapped +and +.b ai_all +are specified in +.ir hints.ai_flags , +then return both ipv6 and ipv4-mapped ipv6 addresses +in the list pointed to by +.ir res . +.b ai_all +is ignored if +.b ai_v4mapped +is not also specified. +.pp +the +.br freeaddrinfo () +function frees the memory that was allocated +for the dynamically allocated linked list +.ir res . +.ss extensions to getaddrinfo() for internationalized domain names +starting with glibc 2.3.4, +.br getaddrinfo () +has been extended to selectively allow the incoming and outgoing +hostnames to be transparently converted to and from the +internationalized domain name (idn) format (see rfc 3490, +.ir "internationalizing domain names in applications (idna)" ). +four new flags are defined: +.tp +.b ai_idn +if this flag is specified, then the node name given in +.i node +is converted to idn format if necessary. +the source encoding is that of the current locale. +.ip +if the input name contains non-ascii characters, then the idn encoding +is used. +those parts of the node name (delimited by dots) that contain +non-ascii characters are encoded using ascii compatible encoding (ace) +before being passed to the name resolution functions. +.\" implementation detail: +.\" to minimize effects on system performance the implementation might +.\" want to check whether the input string contains any non-ascii +.\" characters. if there are none the idn step can be skipped completely. +.\" on systems which allow not-ascii safe encodings for a locale this +.\" might be a problem. +.tp +.b ai_canonidn +after a successful name lookup, and if the +.b ai_canonname +flag was specified, +.br getaddrinfo () +will return the canonical name of the +node corresponding to the +.i addrinfo +structure value passed back. +the return value is an exact copy of the value returned by the name +resolution function. +.ip +if the name is encoded using ace, then it will contain the +.i xn\-\- +prefix for one or more components of the name. +to convert these components into a readable form the +.b ai_canonidn +flag can be passed in addition to +.br ai_canonname . +the resulting string is encoded using the current locale's encoding. +.\" +.\"implementation detail: +.\"if no component of the returned name starts with xn\-\- the idn +.\"step can be skipped, therefore avoiding unnecessary slowdowns. +.tp +.br ai_idn_allow_unassigned ", " ai_idn_use_std3_ascii_rules +setting these flags will enable the +idna_allow_unassigned (allow unassigned unicode code points) and +idna_use_std3_ascii_rules (check output to make sure it is a std3 +conforming hostname) +flags respectively to be used in the idna handling. +.sh return value +.\" fixme glibc defines the following additional errors, some which +.\" can probably be returned by getaddrinfo(); they need to +.\" be documented. +.\" #ifdef __use_gnu +.\" #define eai_inprogress -100 /* processing request in progress. */ +.\" #define eai_canceled -101 /* request canceled. */ +.\" #define eai_notcanceled -102 /* request not canceled. */ +.\" #define eai_alldone -103 /* all requests done. */ +.\" #define eai_intr -104 /* interrupted by a signal. */ +.\" #define eai_idn_encode -105 /* idn encoding failed. */ +.\" #endif +.br getaddrinfo () +returns 0 if it succeeds, or one of the following nonzero error codes: +.tp +.b eai_addrfamily +.\" not in susv3 +the specified network host does not have any network addresses in the +requested address family. +.tp +.b eai_again +the name server returned a temporary failure indication. +try again later. +.tp +.b eai_badflags +.i hints.ai_flags +contains invalid flags; or, +.i hints.ai_flags +included +.b ai_canonname +and +.i name +was null. +.tp +.b eai_fail +the name server returned a permanent failure indication. +.tp +.b eai_family +the requested address family is not supported. +.tp +.b eai_memory +out of memory. +.tp +.b eai_nodata +.\" not in susv3 +the specified network host exists, but does not have any +network addresses defined. +.tp +.b eai_noname +the +.i node +or +.i service +is not known; or both +.i node +and +.i service +are null; or +.b ai_numericserv +was specified in +.i hints.ai_flags +and +.i service +was not a numeric port-number string. +.tp +.b eai_service +the requested service is not available for the requested socket type. +it may be available through another socket type. +for example, this error could occur if +.i service +was "shell" (a service available only on stream sockets), and either +.i hints.ai_protocol +was +.br ipproto_udp , +or +.i hints.ai_socktype +was +.br sock_dgram ; +or the error could occur if +.i service +was not null, and +.i hints.ai_socktype +was +.br sock_raw +(a socket type that does not support the concept of services). +.tp +.b eai_socktype +the requested socket type is not supported. +this could occur, for example, if +.i hints.ai_socktype +and +.i hints.ai_protocol +are inconsistent (e.g., +.br sock_dgram +and +.br ipproto_tcp , +respectively). +.tp +.b eai_system +other system error; +.i errno +is set to indicate the error. +.pp +the +.br gai_strerror () +function translates these error codes to a human readable string, +suitable for error reporting. +.sh files +.i /etc/gai.conf +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br getaddrinfo () +t} thread safety mt-safe env locale +t{ +.br freeaddrinfo (), +.br gai_strerror () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +the +.br getaddrinfo () +function is documented in rfc\ 2553. +.sh notes +.br getaddrinfo () +supports the +.ib address % scope-id +notation for specifying the ipv6 scope-id. +.pp +.br ai_addrconfig , +.br ai_all , +and +.b ai_v4mapped +are available since glibc 2.3.3. +.b ai_numericserv +is available since glibc 2.3.4. +.pp +according to posix.1, specifying +.\" posix.1-2001, posix.1-2008 +.i hints +as null should cause +.i ai_flags +to be assumed as 0. +the gnu c library instead assumes a value of +.br "(ai_v4mapped\ |\ ai_addrconfig)" +for this case, +since this value is considered an improvement on the specification. +.sh examples +.\" getnameinfo.3 refers to this example +.\" socket.2 refers to this example +.\" bind.2 refers to this example +.\" connect.2 refers to this example +.\" recvfrom.2 refers to this example +.\" sendto.2 refers to this example +the following programs demonstrate the use of +.br getaddrinfo (), +.br gai_strerror (), +.br freeaddrinfo (), +and +.br getnameinfo (3). +the programs are an echo server and client for udp datagrams. +.ss server program +\& +.ex +#include +#include +#include +#include +#include +#include +#include + +#define buf_size 500 + +int +main(int argc, char *argv[]) +{ + struct addrinfo hints; + struct addrinfo *result, *rp; + int sfd, s; + struct sockaddr_storage peer_addr; + socklen_t peer_addr_len; + ssize_t nread; + char buf[buf_size]; + + if (argc != 2) { + fprintf(stderr, "usage: %s port\en", argv[0]); + exit(exit_failure); + } + + memset(&hints, 0, sizeof(hints)); + hints.ai_family = af_unspec; /* allow ipv4 or ipv6 */ + hints.ai_socktype = sock_dgram; /* datagram socket */ + hints.ai_flags = ai_passive; /* for wildcard ip address */ + hints.ai_protocol = 0; /* any protocol */ + hints.ai_canonname = null; + hints.ai_addr = null; + hints.ai_next = null; + + s = getaddrinfo(null, argv[1], &hints, &result); + if (s != 0) { + fprintf(stderr, "getaddrinfo: %s\en", gai_strerror(s)); + exit(exit_failure); + } + + /* getaddrinfo() returns a list of address structures. + try each address until we successfully bind(2). + if socket(2) (or bind(2)) fails, we (close the socket + and) try the next address. */ + + for (rp = result; rp != null; rp = rp\->ai_next) { + sfd = socket(rp\->ai_family, rp\->ai_socktype, + rp\->ai_protocol); + if (sfd == \-1) + continue; + + if (bind(sfd, rp\->ai_addr, rp\->ai_addrlen) == 0) + break; /* success */ + + close(sfd); + } + + freeaddrinfo(result); /* no longer needed */ + + if (rp == null) { /* no address succeeded */ + fprintf(stderr, "could not bind\en"); + exit(exit_failure); + } + + /* read datagrams and echo them back to sender. */ + + for (;;) { + peer_addr_len = sizeof(peer_addr); + nread = recvfrom(sfd, buf, buf_size, 0, + (struct sockaddr *) &peer_addr, &peer_addr_len); + if (nread == \-1) + continue; /* ignore failed request */ + + char host[ni_maxhost], service[ni_maxserv]; + + s = getnameinfo((struct sockaddr *) &peer_addr, + peer_addr_len, host, ni_maxhost, + service, ni_maxserv, ni_numericserv); + if (s == 0) + printf("received %zd bytes from %s:%s\en", + nread, host, service); + else + fprintf(stderr, "getnameinfo: %s\en", gai_strerror(s)); + + if (sendto(sfd, buf, nread, 0, + (struct sockaddr *) &peer_addr, + peer_addr_len) != nread) + fprintf(stderr, "error sending response\en"); + } +} +.ee +.ss client program +\& +.ex +#include +#include +#include +#include +#include +#include +#include + +#define buf_size 500 + +int +main(int argc, char *argv[]) +{ + struct addrinfo hints; + struct addrinfo *result, *rp; + int sfd, s; + size_t len; + ssize_t nread; + char buf[buf_size]; + + if (argc < 3) { + fprintf(stderr, "usage: %s host port msg...\en", argv[0]); + exit(exit_failure); + } + + /* obtain address(es) matching host/port. */ + + memset(&hints, 0, sizeof(hints)); + hints.ai_family = af_unspec; /* allow ipv4 or ipv6 */ + hints.ai_socktype = sock_dgram; /* datagram socket */ + hints.ai_flags = 0; + hints.ai_protocol = 0; /* any protocol */ + + s = getaddrinfo(argv[1], argv[2], &hints, &result); + if (s != 0) { + fprintf(stderr, "getaddrinfo: %s\en", gai_strerror(s)); + exit(exit_failure); + } + + /* getaddrinfo() returns a list of address structures. + try each address until we successfully connect(2). + if socket(2) (or connect(2)) fails, we (close the socket + and) try the next address. */ + + for (rp = result; rp != null; rp = rp\->ai_next) { + sfd = socket(rp\->ai_family, rp\->ai_socktype, + rp\->ai_protocol); + if (sfd == \-1) + continue; + + if (connect(sfd, rp\->ai_addr, rp\->ai_addrlen) != \-1) + break; /* success */ + + close(sfd); + } + + freeaddrinfo(result); /* no longer needed */ + + if (rp == null) { /* no address succeeded */ + fprintf(stderr, "could not connect\en"); + exit(exit_failure); + } + + /* send remaining command\-line arguments as separate + datagrams, and read responses from server. */ + + for (int j = 3; j < argc; j++) { + len = strlen(argv[j]) + 1; + /* +1 for terminating null byte */ + + if (len > buf_size) { + fprintf(stderr, + "ignoring long message in argument %d\en", j); + continue; + } + + if (write(sfd, argv[j], len) != len) { + fprintf(stderr, "partial/failed write\en"); + exit(exit_failure); + } + + nread = read(sfd, buf, buf_size); + if (nread == \-1) { + perror("read"); + exit(exit_failure); + } + + printf("received %zd bytes: %s\en", nread, buf); + } + + exit(exit_success); +} +.ee +.sh see also +.\" .br getipnodebyaddr (3), +.\" .br getipnodebyname (3), +.br getaddrinfo_a (3), +.br gethostbyname (3), +.br getnameinfo (3), +.br inet (3), +.br gai.conf (5), +.br hostname (7), +.br ip (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sat jul 24 19:46:03 1993 by rik faith (faith@cs.unc.edu) +.th drand48 3 2021-03-22 "" "linux programmer's manual" +.sh name +drand48, erand48, lrand48, nrand48, mrand48, jrand48, srand48, seed48, +lcong48 \- generate uniformly distributed pseudo-random numbers +.sh synopsis +.nf +.b #include +.pp +.b double drand48(void); +.bi "double erand48(unsigned short " xsubi [3]); +.pp +.b long lrand48(void); +.bi "long nrand48(unsigned short " xsubi [3]); +.pp +.b long mrand48(void); +.bi "long jrand48(unsigned short " xsubi [3]); +.pp +.bi "void srand48(long " seedval ); +.bi "unsigned short *seed48(unsigned short " seed16v [3]); +.bi "void lcong48(unsigned short " param [7]); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +all functions shown above: +.\" .br drand48 (), +.\" .br erand48 (), +.\" .br lrand48 (), +.\" .br nrand48 (), +.\" .br mrand48 (), +.\" .br jrand48 (), +.\" .br srand48 (), +.\" .br seed48 (), +.\" .br lcong48 (): +.nf + _xopen_source + || /* glibc since 2.19: */ _default_source + || /* glibc <= 2.19: */ _svid_source +.fi +.sh description +these functions generate pseudo-random numbers using the linear congruential +algorithm and 48-bit integer arithmetic. +.pp +the +.br drand48 () +and +.br erand48 () +functions return nonnegative +double-precision floating-point values uniformly distributed over the interval +[0.0,\ 1.0). +.pp +the +.br lrand48 () +and +.br nrand48 () +functions return nonnegative +long integers uniformly distributed over the interval [0,\ 2^31). +.pp +the +.br mrand48 () +and +.br jrand48 () +functions return signed long +integers uniformly distributed over the interval [\-2^31,\ 2^31). +.pp +the +.br srand48 (), +.br seed48 (), +and +.br lcong48 () +functions are +initialization functions, one of which should be called before using +.br drand48 (), +.br lrand48 (), +or +.br mrand48 (). +the functions +.br erand48 (), +.br nrand48 (), +and +.br jrand48 () +do not require +an initialization function to be called first. +.pp +all the functions work by generating a sequence of 48-bit integers, +.ir xi , +according to the linear congruential formula: +.pp +.in +4n +.ex +.b xn+1 = (axn + c) mod m, where n >= 0 +.ee +.in +.pp +the parameter +.i m += 2^48, hence 48-bit integer arithmetic is performed. +unless +.br lcong48 () +is called, +.ir a +and +.i c +are given by: +.pp +.in +4n +.ex +.b a = 0x5deece66d +.b c = 0xb +.ee +.in +.pp +the value returned by any of the functions +.br drand48 (), +.br erand48 (), +.br lrand48 (), +.br nrand48 (), +.br mrand48 (), +or +.br jrand48 () +is +computed by first generating the next 48-bit +.i xi +in the sequence. +then the appropriate number of bits, according to the type of data item to +be returned, is copied from the high-order bits of +.i xi +and transformed +into the returned value. +.pp +the functions +.br drand48 (), +.br lrand48 (), +and +.br mrand48 () +store +the last 48-bit +.i xi +generated in an internal buffer. +the functions +.br erand48 (), +.br nrand48 (), +and +.br jrand48 () +require the calling +program to provide storage for the successive +.i xi +values in the array +argument +.ir xsubi . +the functions are initialized by placing the initial +value of +.i xi +into the array before calling the function for the first +time. +.pp +the initializer function +.br srand48 () +sets the high order 32-bits of +.i xi +to the argument +.ir seedval . +the low order 16-bits are set +to the arbitrary value 0x330e. +.pp +the initializer function +.br seed48 () +sets the value of +.i xi +to +the 48-bit value specified in the array argument +.ir seed16v . +the +previous value of +.i xi +is copied into an internal buffer and a +pointer to this buffer is returned by +.br seed48 (). +.pp +the initialization function +.br lcong48 () +allows the user to specify +initial values for +.ir xi , +.ir a , +and +.ir c . +array argument +elements +.i param[0\-2] +specify +.ir xi , +.i param[3\-5] +specify +.ir a , +and +.i param[6] +specifies +.ir c . +after +.br lcong48 () +has been called, a subsequent call to either +.br srand48 () +or +.br seed48 () +will restore the standard values of +.i a +and +.ir c . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br drand48 (), +.br erand48 (), +.br lrand48 (), +.br nrand48 (), +.br mrand48 (), +.br jrand48 (), +.br srand48 (), +.br seed48 (), +.br lcong48 () +t} thread safety t{ +mt-unsafe race:drand48 +t} +.te +.hy +.ad +.sp 1 +.pp +the above +functions record global state information for the random number generator, +so they are not thread-safe. +.sh conforming to +posix.1-2001, posix.1-2008, svr4. +.sh see also +.br rand (3), +.br random (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sat jul 24 19:23:25 1993 by rik faith (faith@cs.unc.edu) +.\" modified mon may 27 21:37:47 1996 by martin schulze (joey@linux.de) +.\" +.th getpw 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +getpw \- reconstruct password line entry +.sh synopsis +.nf +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b #include +.b #include +.pp +.bi "int getpw(uid_t " uid ", char *" buf ); +.fi +.sh description +the +.br getpw () +function reconstructs the password line entry for +the given user id \fiuid\fp in the buffer \fibuf\fp. +the returned buffer contains a line of format +.pp +.in +4n +.ex +.b name:passwd:uid:gid:gecos:dir:shell +.ee +.in +.pp +the \fipasswd\fp structure is defined in \fi\fp as follows: +.pp +.in +4n +.ex +struct passwd { + char *pw_name; /* username */ + char *pw_passwd; /* user password */ + uid_t pw_uid; /* user id */ + gid_t pw_gid; /* group id */ + char *pw_gecos; /* user information */ + char *pw_dir; /* home directory */ + char *pw_shell; /* shell program */ +}; +.ee +.in +.pp +for more information about the fields of this structure, see +.br passwd (5). +.sh return value +the +.br getpw () +function returns 0 on success; on error, it returns \-1, and +.i errno +is set to indicate the error. +.pp +if +.i uid +is not found in the password database, +.br getpw () +returns \-1, sets +.i errno +to 0, and leaves +.i buf +unchanged. +.sh errors +.tp +.br 0 " or " enoent +no user corresponding to +.ir uid . +.tp +.b einval +.i buf +is null. +.tp +.b enomem +insufficient memory to allocate +.i passwd +structure. +.sh files +.tp +.i /etc/passwd +password database file +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br getpw () +t} thread safety mt-safe locale +.te +.hy +.ad +.sp 1 +.sh conforming to +svr2. +.sh bugs +the +.br getpw () +function is dangerous as it may overflow the provided buffer +.ir buf . +it is obsoleted by +.br getpwuid (3). +.sh see also +.br endpwent (3), +.br fgetpwent (3), +.br getpwent (3), +.br getpwnam (3), +.br getpwuid (3), +.br putpwent (3), +.br setpwent (3), +.br passwd (5) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/ioctl_tty.2 +.\" link for old name of this page + +.\" copyright (c) 2013, heinrich schuchardt +.\" and copyright (c) 2014, michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of +.\" this manual under the conditions for verbatim copying, provided that +.\" the entire resulting derived work is distributed under the terms of +.\" a permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume. +.\" no responsibility for errors or omissions, or for damages resulting. +.\" from the use of the information contained herein. the author(s) may. +.\" not have taken the same level of care in the production of this. +.\" manual, which is licensed free of charge, as they might when working. +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.th fanotify 7 2021-08-27 "linux" "linux programmer's manual" +.sh name +fanotify \- monitoring filesystem events +.sh description +the fanotify api provides notification and interception of +filesystem events. +use cases include virus scanning and hierarchical storage management. +in the original fanotify api, only a limited set of events was supported. +in particular, there was no support for create, delete, and move events. +the support for those events was added in linux 5.1. +(see +.br inotify (7) +for details of an api that did notify those events pre linux 5.1.) +.pp +additional capabilities compared to the +.br inotify (7) +api include the ability to monitor all of the objects +in a mounted filesystem, +the ability to make access permission decisions, and the +possibility to read or modify files before access by other applications. +.pp +the following system calls are used with this api: +.br fanotify_init (2), +.br fanotify_mark (2), +.br read (2), +.br write (2), +and +.br close (2). +.ss fanotify_init(), fanotify_mark(), and notification groups +the +.br fanotify_init (2) +system call creates and initializes an fanotify notification group +and returns a file descriptor referring to it. +.pp +an fanotify notification group is a kernel-internal object that holds +a list of files, directories, filesystems, and mounts for which +events shall be created. +.pp +for each entry in an fanotify notification group, two bit masks exist: the +.i mark +mask and the +.i ignore +mask. +the mark mask defines file activities for which an event shall be created. +the ignore mask defines activities for which no event shall be generated. +having these two types of masks permits a filesystem, mount, or +directory to be marked for receiving events, while at the same time +ignoring events for specific objects under a mount or directory. +.pp +the +.br fanotify_mark (2) +system call adds a file, directory, filesystem, or mount to a +notification group and specifies which events +shall be reported (or ignored), or removes or modifies such an entry. +.pp +a possible usage of the ignore mask is for a file cache. +events of interest for a file cache are modification of a file and closing +of the same. +hence, the cached directory or mount is to be marked to receive these +events. +after receiving the first event informing that a file has been modified, +the corresponding cache entry will be invalidated. +no further modification events for this file are of interest until the file +is closed. +hence, the modify event can be added to the ignore mask. +upon receiving the close event, the modify event can be removed from the +ignore mask and the file cache entry can be updated. +.pp +the entries in the fanotify notification groups refer to files and +directories via their inode number and to mounts via their mount id. +if files or directories are renamed or moved within the same mount, +the respective entries survive. +if files or directories are deleted or moved to another mount or if +filesystems or mounts are unmounted, the corresponding entries are deleted. +.ss the event queue +as events occur on the filesystem objects monitored by a notification group, +the fanotify system generates events that are collected in a queue. +these events can then be read (using +.br read (2) +or similar) +from the fanotify file descriptor +returned by +.br fanotify_init (2). +.pp +two types of events are generated: +.i notification +events and +.i permission +events. +notification events are merely informative and require no action to be taken +by the receiving application with one exception: if a valid file descriptor +is provided within a generic event, the file descriptor must be closed. +permission events are requests to the receiving application to decide +whether permission for a file access shall be granted. +for these events, the recipient must write a response which decides whether +access is granted or not. +.pp +an event is removed from the event queue of the fanotify group +when it has been read. +permission events that have been read are kept in an internal list of the +fanotify group until either a permission decision has been taken by +writing to the fanotify file descriptor or the fanotify file descriptor +is closed. +.ss reading fanotify events +calling +.br read (2) +for the file descriptor returned by +.br fanotify_init (2) +blocks (if the flag +.b fan_nonblock +is not specified in the call to +.br fanotify_init (2)) +until either a file event occurs or the call is interrupted by a signal +(see +.br signal (7)). +.pp +the use of one of the flags +.br fan_report_fid , +.br fan_report_dir_fid +in +.br fanotify_init (2) +influences what data structures are returned to the event listener for each +event. +events reported to a group initialized with one of these flags will +use file handles to identify filesystem objects instead of file descriptors. +.pp +after a successful +.br read (2), +the read buffer contains one or more of the following structures: +.pp +.in +4n +.ex +struct fanotify_event_metadata { + __u32 event_len; + __u8 vers; + __u8 reserved; + __u16 metadata_len; + __aligned_u64 mask; + __s32 fd; + __s32 pid; +}; +.ee +.in +.pp +in case of an fanotify group that identifies filesystem objects by file +handles, you should also expect to receive one or more additional information +records of the structure detailed below following the generic +.i fanotify_event_metadata +structure within the read buffer: +.pp +.in +4n +.ex +struct fanotify_event_info_header { + __u8 info_type; + __u8 pad; + __u16 len; +}; + +struct fanotify_event_info_fid { + struct fanotify_event_info_header hdr; + __kernel_fsid_t fsid; + unsigned char file_handle[0]; +}; +.ee +.in +.pp +for performance reasons, it is recommended to use a large +buffer size (for example, 4096 bytes), +so that multiple events can be retrieved by a single +.br read (2). +.pp +the return value of +.br read (2) +is the number of bytes placed in the buffer, +or \-1 in case of an error (but see bugs). +.pp +the fields of the +.i fanotify_event_metadata +structure are as follows: +.tp +.i event_len +this is the length of the data for the current event and the offset +to the next event in the buffer. +unless the group identifies filesystem objects by file handles, the value of +.i event_len +is always +.br fan_event_metadata_len . +for a group that identifies filesystem objects by file handles, +.i event_len +also includes the variable length file identifier records. +.tp +.i vers +this field holds a version number for the structure. +it must be compared to +.b fanotify_metadata_version +to verify that the structures returned at run time match +the structures defined at compile time. +in case of a mismatch, the application should abandon trying to use the +fanotify file descriptor. +.tp +.i reserved +this field is not used. +.tp +.i metadata_len +this is the length of the structure. +the field was introduced to facilitate the implementation of +optional headers per event type. +no such optional headers exist in the current implementation. +.tp +.i mask +this is a bit mask describing the event (see below). +.tp +.i fd +this is an open file descriptor for the object being accessed, or +.b fan_nofd +if a queue overflow occurred. +with an fanotify group that identifies filesystem objects by file handles, +applications should expect this value to be set to +.b fan_nofd +for each event that is received. +the file descriptor can be used to access the contents +of the monitored file or directory. +the reading application is responsible for closing this file descriptor. +.ip +when calling +.br fanotify_init (2), +the caller may specify (via the +.i event_f_flags +argument) various file status flags that are to be set +on the open file description that corresponds to this file descriptor. +in addition, the (kernel-internal) +.b fmode_nonotify +file status flag is set on the open file description. +this flag suppresses fanotify event generation. +hence, when the receiver of the fanotify event accesses the notified file or +directory using this file descriptor, no additional events will be created. +.tp +.i pid +if flag +.b fan_report_tid +was set in +.br fanotify_init (2), +this is the tid of the thread that caused the event. +otherwise, this the pid of the process that caused the event. +.pp +a program listening to fanotify events can compare this pid +to the pid returned by +.br getpid (2), +to determine whether the event is caused by the listener itself, +or is due to a file access by another process. +.pp +the bit mask in +.i mask +indicates which events have occurred for a single filesystem object. +multiple bits may be set in this mask, +if more than one event occurred for the monitored filesystem object. +in particular, +consecutive events for the same filesystem object and originating from the +same process may be merged into a single event, with the exception that two +permission events are never merged into one queue entry. +.pp +the bits that may appear in +.i mask +are as follows: +.tp +.b fan_access +a file or a directory (but see bugs) was accessed (read). +.tp +.b fan_open +a file or a directory was opened. +.tp +.b fan_open_exec +a file was opened with the intent to be executed. +see notes in +.br fanotify_mark (2) +for additional details. +.tp +.b fan_attrib +a file or directory metadata was changed. +.tp +.b fan_create +a child file or directory was created in a watched parent. +.tp +.b fan_delete +a child file or directory was deleted in a watched parent. +.tp +.b fan_delete_self +a watched file or directory was deleted. +.tp +.b fan_moved_from +a file or directory has been moved from a watched parent directory. +.tp +.b fan_moved_to +a file or directory has been moved to a watched parent directory. +.tp +.b fan_move_self +a watched file or directory was moved. +.tp +.b fan_modify +a file was modified. +.tp +.b fan_close_write +a file that was opened for writing +.rb ( o_wronly +or +.br o_rdwr ) +was closed. +.tp +.b fan_close_nowrite +a file or directory that was opened read-only +.rb ( o_rdonly ) +was closed. +.tp +.b fan_q_overflow +the event queue exceeded the limit of 16384 entries. +this limit can be overridden by specifying the +.br fan_unlimited_queue +flag when calling +.br fanotify_init (2). +.tp +.b fan_access_perm +an application wants to read a file or directory, for example using +.br read (2) +or +.br readdir (2). +the reader must write a response (as described below) +that determines whether the permission to +access the filesystem object shall be granted. +.tp +.b fan_open_perm +an application wants to open a file or directory. +the reader must write a response that determines whether the permission to +open the filesystem object shall be granted. +.tp +.b fan_open_exec_perm +an application wants to open a file for execution. +the reader must write a response that determines whether the permission to +open the filesystem object for execution shall be granted. +see notes in +.br fanotify_mark (2) +for additional details. +.pp +to check for any close event, the following bit mask may be used: +.tp +.b fan_close +a file was closed. +this is a synonym for: +.ip + fan_close_write | fan_close_nowrite +.pp +to check for any move event, the following bit mask may be used: +.tp +.b fan_move +a file or directory was moved. +this is a synonym for: +.ip + fan_moved_from | fan_moved_to +.pp +the following bits may appear in +.i mask +only in conjunction with other event type bits: +.tp +.b fan_ondir +the events described in the +.i mask +have occurred on a directory object. +reporting events on directories requires setting this flag in the mark mask. +see +.br fanotify_mark (2) +for additional details. +the +.br fan_ondir +flag is reported in an event mask only if the fanotify group identifies +filesystem objects by file handles. +.pp +the fields of the +.i fanotify_event_info_fid +structure are as follows: +.tp +.i hdr +this is a structure of type +.ir fanotify_event_info_header . +it is a generic header that contains information used to describe an +additional information record attached to the event. +for example, when an fanotify file descriptor is created using +.br fan_report_fid , +a single information record is expected to be attached to the event with +.i info_type +field value of +.br fan_event_info_type_fid . +when an fanotify file descriptor is created using the combination of +.br fan_report_fid +and +.br fan_report_dir_fid , +there may be two information records attached to the event: +one with +.i info_type +field value of +.br fan_event_info_type_dfid , +identifying a parent directory object, and one with +.i info_type +field value of +.br fan_event_info_type_fid , +identifying a non-directory object. +the +.i fanotify_event_info_header +contains a +.i len +field. +the value of +.i len +is the size of the additional information record including the +.ir fanotify_event_info_header +itself. +the total size of all additional information records is not expected +to be bigger than +( +.ir event_len +\- +.ir metadata_len +). +.tp +.i fsid +this is a unique identifier of the filesystem containing the object +associated with the event. +it is a structure of type +.i __kernel_fsid_t +and contains the same value as +.i f_fsid +when calling +.br statfs (2). +.tp +.i file_handle +this is a variable length structure of type struct file_handle. +it is an opaque handle that corresponds to a specified object on a +filesystem as returned by +.br name_to_handle_at (2). +it can be used to uniquely identify a file on a filesystem and can be +passed as an argument to +.br open_by_handle_at (2). +note that for the directory entry modification events +.br fan_create , +.br fan_delete , +and +.br fan_move , +the +.ir file_handle +identifies the modified directory and not the created/deleted/moved child +object. +if the value of +.i info_type +field is +.br fan_event_info_type_dfid_name , +the file handle is followed by a null terminated string that identifies the +created/deleted/moved directory entry name. +for other events such as +.br fan_open , +.br fan_attrib , +.br fan_delete_self , +and +.br fan_move_self , +if the value of +.i info_type +field is +.br fan_event_info_type_fid , +the +.ir file_handle +identifies the object correlated to the event. +if the value of +.i info_type +field is +.br fan_event_info_type_dfid , +the +.ir file_handle +identifies the directory object correlated to the event or the parent directory +of a non-directory object correlated to the event. +if the value of +.i info_type +field is +.br fan_event_info_type_dfid_name , +the +.ir file_handle +identifies the same directory object that would be reported with +.br fan_event_info_type_dfid +and the file handle is followed by a null terminated string that identifies the +name of a directory entry in that directory, or '.' to identify the directory +object itself. +.pp +the following macros are provided to iterate over a buffer containing +fanotify event metadata returned by a +.br read (2) +from an fanotify file descriptor: +.tp +.b fan_event_ok(meta, len) +this macro checks the remaining length +.i len +of the buffer +.i meta +against the length of the metadata structure and the +.i event_len +field of the first metadata structure in the buffer. +.tp +.b fan_event_next(meta, len) +this macro uses the length indicated in the +.i event_len +field of the metadata structure pointed to by +.ir meta +to calculate the address of the next metadata structure that follows +.ir meta . +.i len +is the number of bytes of metadata that currently remain in the buffer. +the macro returns a pointer to the next metadata structure that follows +.ir meta , +and reduces +.i len +by the number of bytes in the metadata structure that +has been skipped over (i.e., it subtracts +.ir meta\->event_len +from +.ir len ). +.pp +in addition, there is: +.tp +.b fan_event_metadata_len +this macro returns the size (in bytes) of the structure +.ir fanotify_event_metadata . +this is the minimum size (and currently the only size) of any event metadata. +.\" +.ss monitoring an fanotify file descriptor for events +when an fanotify event occurs, the fanotify file descriptor indicates as +readable when passed to +.br epoll (7), +.br poll (2), +or +.br select (2). +.ss dealing with permission events +for permission events, the application must +.br write (2) +a structure of the following form to the +fanotify file descriptor: +.pp +.in +4n +.ex +struct fanotify_response { + __s32 fd; + __u32 response; +}; +.ee +.in +.pp +the fields of this structure are as follows: +.tp +.i fd +this is the file descriptor from the structure +.ir fanotify_event_metadata . +.tp +.i response +this field indicates whether or not the permission is to be granted. +its value must be either +.b fan_allow +to allow the file operation or +.b fan_deny +to deny the file operation. +.pp +if access is denied, the requesting application call will receive an +.br eperm +error. +additionally, if the notification group has been created with the +.b fan_enable_audit +flag, then the +.b fan_audit +flag can be set in the +.i response +field. +in that case, the audit subsystem will log information about the access +decision to the audit logs. +.\" +.ss closing the fanotify file descriptor +when all file descriptors referring to the fanotify notification group are +closed, the fanotify group is released and its resources +are freed for reuse by the kernel. +upon +.br close (2), +outstanding permission events will be set to allowed. +.ss /proc/[pid]/fdinfo +the file +.i /proc/[pid]/fdinfo/[fd] +contains information about fanotify marks for file descriptor +.i fd +of process +.ir pid . +see +.br proc (5) +for details. +.sh errors +in addition to the usual errors for +.br read (2), +the following errors can occur when reading from the +fanotify file descriptor: +.tp +.b einval +the buffer is too small to hold the event. +.tp +.b emfile +the per-process limit on the number of open files has been reached. +see the description of +.b rlimit_nofile +in +.br getrlimit (2). +.tp +.b enfile +the system-wide limit on the total number of open files has been reached. +see +.i /proc/sys/fs/file\-max +in +.br proc (5). +.tp +.b etxtbsy +this error is returned by +.br read (2) +if +.b o_rdwr +or +.b o_wronly +was specified in the +.i event_f_flags +argument when calling +.br fanotify_init (2) +and an event occurred for a monitored file that is currently being executed. +.pp +in addition to the usual errors for +.br write (2), +the following errors can occur when writing to the fanotify file descriptor: +.tp +.b einval +fanotify access permissions are not enabled in the kernel configuration +or the value of +.i response +in the response structure is not valid. +.tp +.b enoent +the file descriptor +.i fd +in the response structure is not valid. +this may occur when a response for the permission event has already been +written. +.sh versions +the fanotify api was introduced in version 2.6.36 of the linux kernel and +enabled in version 2.6.37. +fdinfo support was added in version 3.8. +.sh conforming to +the fanotify api is linux-specific. +.sh notes +the fanotify api is available only if the kernel was built with the +.b config_fanotify +configuration option enabled. +in addition, fanotify permission handling is available only if the +.b config_fanotify_access_permissions +configuration option is enabled. +.ss limitations and caveats +fanotify reports only events that a user-space program triggers through the +filesystem api. +as a result, +it does not catch remote events that occur on network filesystems. +.pp +the fanotify api does not report file accesses and modifications that +may occur because of +.br mmap (2), +.br msync (2), +and +.br munmap (2). +.pp +events for directories are created only if the directory itself is opened, +read, and closed. +adding, removing, or changing children of a marked directory does not create +events for the monitored directory itself. +.pp +fanotify monitoring of directories is not recursive: +to monitor subdirectories under a directory, +additional marks must be created. +the +.b fan_create +event can be used for detecting when a subdirectory has been created under +a marked directory. +an additional mark must then be set on the newly created subdirectory. +this approach is racy, because it can lose events that occurred inside the +newly created subdirectory, before a mark is added on that subdirectory. +monitoring mounts offers the capability to monitor a whole directory tree +in a race-free manner. +monitoring filesystems offers the capability to monitor changes made from +any mount of a filesystem instance in a race-free manner. +.pp +the event queue can overflow. +in this case, events are lost. +.sh bugs +before linux 3.19, +.br fallocate (2) +did not generate fanotify events. +since linux 3.19, +.\" commit 820c12d5d6c0890bc93dd63893924a13041fdc35 +calls to +.br fallocate (2) +generate +.b fan_modify +events. +.pp +as of linux 3.17, +the following bugs exist: +.ip * 3 +on linux, a filesystem object may be accessible through multiple paths, +for example, a part of a filesystem may be remounted using the +.ir \-\-bind +option of +.br mount (8). +a listener that marked a mount will be notified only of events that were +triggered for a filesystem object using the same mount. +any other event will pass unnoticed. +.ip * +.\" fixme . a patch was proposed. +when an event is generated, +no check is made to see whether the user id of the +receiving process has authorization to read or write the file +before passing a file descriptor for that file. +this poses a security risk, when the +.b cap_sys_admin +capability is set for programs executed by unprivileged users. +.ip * +if a call to +.br read (2) +processes multiple events from the fanotify queue and an error occurs, +the return value will be the total length of the events successfully +copied to the user-space buffer before the error occurred. +the return value will not be \-1, and +.i errno +will not be set. +thus, the reading application has no way to detect the error. +.sh examples +the two example programs below demonstrate the usage of the fanotify api. +.ss example program: fanotify_example.c +the first program is an example of fanotify being +used with its event object information passed in the form of a file +descriptor. +the program marks the mount passed as a command-line argument and +waits for events of type +.b fan_open_perm +and +.br fan_close_write . +when a permission event occurs, a +.b fan_allow +response is given. +.pp +the following shell session shows an example of +running this program. +this session involved editing the file +.ir /home/user/temp/notes . +before the file was opened, a +.b fan_open_perm +event occurred. +after the file was closed, a +.b fan_close_write +event occurred. +execution of the program ends when the user presses the enter key. +.pp +.in +4n +.ex +# \fb./fanotify_example /home\fp +press enter key to terminate. +listening for events. +fan_open_perm: file /home/user/temp/notes +fan_close_write: file /home/user/temp/notes + +listening for events stopped. +.ee +.in +.ss program source: fanotify_example.c +\& +.ex +#define _gnu_source /* needed to get o_largefile definition */ +#include +#include +#include +#include +#include +#include +#include +#include + +/* read all available fanotify events from the file descriptor \(aqfd\(aq. */ + +static void +handle_events(int fd) +{ + const struct fanotify_event_metadata *metadata; + struct fanotify_event_metadata buf[200]; + ssize_t len; + char path[path_max]; + ssize_t path_len; + char procfd_path[path_max]; + struct fanotify_response response; + + /* loop while events can be read from fanotify file descriptor. */ + + for (;;) { + + /* read some events. */ + + len = read(fd, buf, sizeof(buf)); + if (len == \-1 && errno != eagain) { + perror("read"); + exit(exit_failure); + } + + /* check if end of available data reached. */ + + if (len <= 0) + break; + + /* point to the first event in the buffer. */ + + metadata = buf; + + /* loop over all events in the buffer. */ + + while (fan_event_ok(metadata, len)) { + + /* check that run\-time and compile\-time structures match. */ + + if (metadata\->vers != fanotify_metadata_version) { + fprintf(stderr, + "mismatch of fanotify metadata version.\en"); + exit(exit_failure); + } + + /* metadata\->fd contains either fan_nofd, indicating a + queue overflow, or a file descriptor (a nonnegative + integer). here, we simply ignore queue overflow. */ + + if (metadata\->fd >= 0) { + + /* handle open permission event. */ + + if (metadata\->mask & fan_open_perm) { + printf("fan_open_perm: "); + + /* allow file to be opened. */ + + response.fd = metadata\->fd; + response.response = fan_allow; + write(fd, &response, sizeof(response)); + } + + /* handle closing of writable file event. */ + + if (metadata\->mask & fan_close_write) + printf("fan_close_write: "); + + /* retrieve and print pathname of the accessed file. */ + + snprintf(procfd_path, sizeof(procfd_path), + "/proc/self/fd/%d", metadata\->fd); + path_len = readlink(procfd_path, path, + sizeof(path) \- 1); + if (path_len == \-1) { + perror("readlink"); + exit(exit_failure); + } + + path[path_len] = \(aq\e0\(aq; + printf("file %s\en", path); + + /* close the file descriptor of the event. */ + + close(metadata\->fd); + } + + /* advance to next event. */ + + metadata = fan_event_next(metadata, len); + } + } +} + +int +main(int argc, char *argv[]) +{ + char buf; + int fd, poll_num; + nfds_t nfds; + struct pollfd fds[2]; + + /* check mount point is supplied. */ + + if (argc != 2) { + fprintf(stderr, "usage: %s mount\en", argv[0]); + exit(exit_failure); + } + + printf("press enter key to terminate.\en"); + + /* create the file descriptor for accessing the fanotify api. */ + + fd = fanotify_init(fan_cloexec | fan_class_content | fan_nonblock, + o_rdonly | o_largefile); + if (fd == \-1) { + perror("fanotify_init"); + exit(exit_failure); + } + + /* mark the mount for: + \- permission events before opening files + \- notification events after closing a write\-enabled + file descriptor. */ + + if (fanotify_mark(fd, fan_mark_add | fan_mark_mount, + fan_open_perm | fan_close_write, at_fdcwd, + argv[1]) == \-1) { + perror("fanotify_mark"); + exit(exit_failure); + } + + /* prepare for polling. */ + + nfds = 2; + + fds[0].fd = stdin_fileno; /* console input */ + fds[0].events = pollin; + + fds[1].fd = fd; /* fanotify input */ + fds[1].events = pollin; + + /* this is the loop to wait for incoming events. */ + + printf("listening for events.\en"); + + while (1) { + poll_num = poll(fds, nfds, \-1); + if (poll_num == \-1) { + if (errno == eintr) /* interrupted by a signal */ + continue; /* restart poll() */ + + perror("poll"); /* unexpected error */ + exit(exit_failure); + } + + if (poll_num > 0) { + if (fds[0].revents & pollin) { + + /* console input is available: empty stdin and quit. */ + + while (read(stdin_fileno, &buf, 1) > 0 && buf != \(aq\en\(aq) + continue; + break; + } + + if (fds[1].revents & pollin) { + + /* fanotify events are available. */ + + handle_events(fd); + } + } + } + + printf("listening for events stopped.\en"); + exit(exit_success); +} +.ee +.\" +.ss example program: fanotify_fid.c +the second program is an example of fanotify being used with a group that +identifies objects by file handles. +the program marks the filesystem object that is passed as +a command-line argument +and waits until an event of type +.b fan_create +has occurred. +the event mask indicates which type of filesystem object\(emeither +a file or a directory\(emwas created. +once all events have been read from the buffer and processed accordingly, +the program simply terminates. +.pp +the following shell sessions show two different invocations of +this program, with different actions performed on a watched object. +.pp +the first session shows a mark being placed on +.ir /home/user . +this is followed by the creation of a regular file, +.ir /home/user/testfile.txt . +this results in a +.b fan_create +event being generated and reported against the file's parent watched +directory object and with the created file name. +program execution ends once all events captured within the buffer have +been processed. +.pp +.in +4n +.ex +# \fb./fanotify_fid /home/user\fp +listening for events. +fan_create (file created): + directory /home/user has been modified. + entry \(aqtestfile.txt\(aq is not a subdirectory. +all events processed successfully. program exiting. + +$ \fbtouch /home/user/testfile.txt\fp # in another terminal +.ee +.in +.pp +the second session shows a mark being placed on +.ir /home/user . +this is followed by the creation of a directory, +.ir /home/user/testdir . +this specific action results in a +.b fan_create +event being generated and is reported with the +.b fan_ondir +flag set and with the created directory name. +.pp +.in +4n +.ex +# \fb./fanotify_fid /home/user\fp +listening for events. +fan_create | fan_ondir (subdirectory created): + directory /home/user has been modified. + entry \(aqtestdir\(aq is a subdirectory. +all events processed successfully. program exiting. + +$ \fbmkdir \-p /home/user/testdir\fp # in another terminal +.ee +.in +.ss program source: fanotify_fid.c +\& +.ex +#define _gnu_source +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define buf_size 256 + +int +main(int argc, char *argv[]) +{ + int fd, ret, event_fd, mount_fd; + ssize_t len, path_len; + char path[path_max]; + char procfd_path[path_max]; + char events_buf[buf_size]; + struct file_handle *file_handle; + struct fanotify_event_metadata *metadata; + struct fanotify_event_info_fid *fid; + const char *file_name; + struct stat sb; + + if (argc != 2) { + fprintf(stderr, "invalid number of command line arguments.\en"); + exit(exit_failure); + } + + mount_fd = open(argv[1], o_directory | o_rdonly); + if (mount_fd == \-1) { + perror(argv[1]); + exit(exit_failure); + } + + + /* create an fanotify file descriptor with fan_report_dfid_name as + a flag so that program can receive fid events with directory + entry name. */ + + fd = fanotify_init(fan_class_notif | fan_report_dfid_name, 0); + if (fd == \-1) { + perror("fanotify_init"); + exit(exit_failure); + } + + /* place a mark on the filesystem object supplied in argv[1]. */ + + ret = fanotify_mark(fd, fan_mark_add | fan_mark_onlydir, + fan_create | fan_ondir, + at_fdcwd, argv[1]); + if (ret == \-1) { + perror("fanotify_mark"); + exit(exit_failure); + } + + printf("listening for events.\en"); + + /* read events from the event queue into a buffer. */ + + len = read(fd, events_buf, sizeof(events_buf)); + if (len == \-1 && errno != eagain) { + perror("read"); + exit(exit_failure); + } + + /* process all events within the buffer. */ + + for (metadata = (struct fanotify_event_metadata *) events_buf; + fan_event_ok(metadata, len); + metadata = fan_event_next(metadata, len)) { + fid = (struct fanotify_event_info_fid *) (metadata + 1); + file_handle = (struct file_handle *) fid\->handle; + + /* ensure that the event info is of the correct type. */ + + if (fid\->hdr.info_type == fan_event_info_type_fid || + fid\->hdr.info_type == fan_event_info_type_dfid) { + file_name = null; + } else if (fid\->hdr.info_type == fan_event_info_type_dfid_name) { + file_name = file_handle\->f_handle + + file_handle\->handle_bytes; + } else { + fprintf(stderr, "received unexpected event info type.\en"); + exit(exit_failure); + } + + if (metadata\->mask == fan_create) + printf("fan_create (file created):\en"); + + if (metadata\->mask == (fan_create | fan_ondir)) + printf("fan_create | fan_ondir (subdirectory created):\en"); + + /* metadata\->fd is set to fan_nofd when the group identifies + objects by file handles. to obtain a file descriptor for + the file object corresponding to an event you can use the + struct file_handle that\(aqs provided within the + fanotify_event_info_fid in conjunction with the + open_by_handle_at(2) system call. a check for estale is + done to accommodate for the situation where the file handle + for the object was deleted prior to this system call. */ + + event_fd = open_by_handle_at(mount_fd, file_handle, o_rdonly); + if (event_fd == \-1) { + if (errno == estale) { + printf("file handle is no longer valid. " + "file has been deleted\en"); + continue; + } else { + perror("open_by_handle_at"); + exit(exit_failure); + } + } + + snprintf(procfd_path, sizeof(procfd_path), "/proc/self/fd/%d", + event_fd); + + /* retrieve and print the path of the modified dentry. */ + + path_len = readlink(procfd_path, path, sizeof(path) \- 1); + if (path_len == \-1) { + perror("readlink"); + exit(exit_failure); + } + + path[path_len] = \(aq\e0\(aq; + printf("\etdirectory \(aq%s\(aq has been modified.\en", path); + + if (file_name) { + ret = fstatat(event_fd, file_name, &sb, 0); + if (ret == \-1) { + if (errno != enoent) { + perror("fstatat"); + exit(exit_failure); + } + printf("\etentry \(aq%s\(aq does not exist.\en", file_name); + } else if ((sb.st_mode & s_ifmt) == s_ifdir) { + printf("\etentry \(aq%s\(aq is a subdirectory.\en", file_name); + } else { + printf("\etentry \(aq%s\(aq is not a subdirectory.\en", + file_name); + } + } + + /* close associated file descriptor for this event. */ + + close(event_fd); + } + + printf("all events processed successfully. program exiting.\en"); + exit(exit_success); +} +.ee +.sh see also +.ad l +.br fanotify_init (2), +.br fanotify_mark (2), +.br inotify (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/exec.3 + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" iso/iec 9899:1999 +.\" +.th wcsstr 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +wcsstr \- locate a substring in a wide-character string +.sh synopsis +.nf +.b #include +.pp +.bi "wchar_t *wcsstr(const wchar_t *" haystack ", const wchar_t *" needle ); +.fi +.sh description +the +.br wcsstr () +function is the wide-character equivalent of the +.br strstr (3) +function. +it searches for the first occurrence of the wide-character string +.i needle +(without its terminating null wide character (l\(aq\e0\(aq)) +as a substring in the wide-character string +.ir haystack . +.sh return value +the +.br wcsstr () +function returns a pointer to the first occurrence of +.i needle +in +.ir haystack . +it returns null if +.i needle +does not occur +as a substring in +.ir haystack . +.pp +note the special case: +if +.i needle +is the empty wide-character string, +the return value is always +.i haystack +itself. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br wcsstr () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh see also +.br strstr (3), +.br wcschr (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +import os +import glob +import random +import shutil + +# step 1: navigate to the directory +data_dir = '/media/external/man-pages-dataset/man-pages-5.13' +os.chdir(data_dir) + +# step 2: organize the data (in this example, we'll assume the data is already organized) + +# step 3: preprocess the text +def preprocess_text(file_path): + with open(file_path, 'r', encoding='utf-8') as file: + text = file.read() + # simple preprocessing (e.g., lowercase conversion) + text = text.lower() + return text + +# step 4: format the data for training +all_data = [] +for file_path in glob.glob('**/*.txt', recursive=true): + preprocessed_text = preprocess_text(file_path) + all_data.append(preprocessed_text) + +# step 5: split the data +random.shuffle(all_data) +train_size = int(0.8 * len(all_data)) +train_data, val_test_data = all_data[:train_size], all_data[train_size:] +val_size = int(0.5 * len(val_test_data)) +val_data, test_data = val_test_data[:val_size], val_test_data[val_size:] + +# step 6: save the preprocessed data +output_dir = os.path.join(data_dir, 'preprocessed_data') +os.makedirs(output_dir, exist_ok=true) +with open(os.path.join(output_dir, 'train.txt'), 'w', encoding='utf-8') as file: + file.write('\n'.join(train_data)) +with open(os.path.join(output_dir, 'val.txt'), 'w', encoding='utf-8') as file: + file.write('\n'.join(val_data)) +with open(os.path.join(output_dir, 'test.txt'), 'w', encoding='utf-8') as file: + file.write('\n'.join(test_data)) + +print(f'data preprocessing and splitting completed. preprocessed data saved to {output_dir}') + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified 1993-05-22, david metcalfe +.\" modified 1993-07-25, rik faith (faith@cs.unc.edu) +.\" modified 1997-02-16, andries brouwer (aeb@cwi.nl) +.\" modified 1998-12-21, andries brouwer (aeb@cwi.nl) +.\" modified 2000-08-12, andries brouwer (aeb@cwi.nl) +.\" modified 2001-05-19, andries brouwer (aeb@cwi.nl) +.\" modified 2002-08-05, michael kerrisk +.\" modified 2004-10-31, andries brouwer +.\" +.th gethostbyname 3 2021-03-22 "" "linux programmer's manual" +.sh name +gethostbyname, gethostbyaddr, sethostent, gethostent, endhostent, +h_errno, +herror, hstrerror, +gethostbyaddr_r, +gethostbyname2, gethostbyname2_r, gethostbyname_r, +gethostent_r \- get network host entry +.sh synopsis +.nf +.b #include +.pp +.b extern int h_errno; +.pp +.bi "struct hostent *gethostbyname(const char *" name ); +.bi "struct hostent *gethostbyaddr(const void *" addr , +.bi " socklen_t " len ", int " type ); +.pp +.bi "void sethostent(int " stayopen ); +.b void endhostent(void); +.pp +.bi "void herror(const char *" s ); +.bi "const char *hstrerror(int " err ); +.pp +/* system v/posix extension */ +.b struct hostent *gethostent(void); +.pp +/* gnu extensions */ +.bi "struct hostent *gethostbyname2(const char *" name ", int " af ); +.pp +.bi "int gethostent_r(struct hostent *restrict " ret , +.bi " char *restrict " buf ", size_t " buflen , +.bi " struct hostent **restrict " result , +.bi " int *restrict " h_errnop ); +.pp +.bi "int gethostbyaddr_r(const void *restrict " addr ", socklen_t " len \ +", int " type , +.bi " struct hostent *restrict " ret , +.bi " char *restrict " buf ", size_t " buflen , +.bi " struct hostent **restrict " result , +.bi " int *restrict " h_errnop ); +.bi "int gethostbyname_r(const char *restrict " name , +.bi " struct hostent *restrict " ret , +.bi " char *restrict " buf ", size_t " buflen , +.bi " struct hostent **restrict " result , +.bi " int *restrict " h_errnop ); +.bi "int gethostbyname2_r(const char *restrict " name ", int " af, +.bi " struct hostent *restrict " ret , +.bi " char *restrict " buf ", size_t " buflen , +.bi " struct hostent **restrict " result , +.bi " int *restrict " h_errnop ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br gethostbyname2 (), +.br gethostent_r (), +.br gethostbyaddr_r (), +.br gethostbyname_r (), +.br gethostbyname2_r (): +.nf + since glibc 2.19: + _default_source + glibc up to and including 2.19: + _bsd_source || _svid_source +.fi +.pp +.br herror (), +.br hstrerror (): +.nf + since glibc 2.19: + _default_source + glibc 2.8 to 2.19: + _bsd_source || _svid_source + before glibc 2.8: + none +.fi +.pp +.br h_errno : +.nf + since glibc 2.19 + _default_source || _posix_c_source < 200809l + glibc 2.12 to 2.19: + _bsd_source || _svid_source || _posix_c_source < 200809l + before glibc 2.12: + none +.fi +.sh description +the +.br gethostbyname* (), +.br gethostbyaddr* (), +.br herror (), +and +.br hstrerror () +functions are obsolete. +applications should use +.br getaddrinfo (3), +.br getnameinfo (3), +and +.br gai_strerror (3) +instead. +.pp +the +.br gethostbyname () +function returns a structure of type +.i hostent +for the given host +.ir name . +here +.i name +is either a hostname or an ipv4 address in standard dot notation (as for +.br inet_addr (3)). +if +.i name +is an ipv4 address, no lookup is performed and +.br gethostbyname () +simply copies +.i name +into the +.i h_name +field and its +.i struct in_addr +equivalent into the +.i h_addr_list[0] +field of the returned +.i hostent +structure. +if +.i name +doesn't end in a dot and the environment variable +.b hostaliases +is set, the alias file pointed to by +.b hostaliases +will first be searched for +.i name +(see +.br hostname (7) +for the file format). +the current domain and its parents are searched unless \finame\fp +ends in a dot. +.pp +the +.br gethostbyaddr () +function returns a structure of type \fihostent\fp +for the given host address \fiaddr\fp of length \filen\fp and address type +\fitype\fp. +valid address types are +.b af_inet +and +.br af_inet6 +(defined in +.ir ). +the host address argument is a pointer to a struct of a type depending +on the address type, for example a \fistruct in_addr *\fp (probably +obtained via a call to +.br inet_addr (3)) +for address type +.br af_inet . +.pp +the +.br sethostent () +function specifies, if \fistayopen\fp is true (1), +that a connected tcp socket should be used for the name server queries and +that the connection should remain open during successive queries. +otherwise, name server queries will use udp datagrams. +.pp +the +.br endhostent () +function ends the use of a tcp connection for name +server queries. +.pp +the (obsolete) +.br herror () +function prints the error message associated +with the current value of \fih_errno\fp on \fistderr\fp. +.pp +the (obsolete) +.br hstrerror () +function takes an error number +(typically \fih_errno\fp) and returns the corresponding message string. +.pp +the domain name queries carried out by +.br gethostbyname () +and +.br gethostbyaddr () +rely on the name service switch +.rb ( nsswitch.conf (5)) +configured sources or a local name server +.rb ( named (8)). +the default action is to query the name service switch +.rb ( nsswitch.conf (5)) +configured sources, failing that, a local name server +.rb ( named (8)). +.\" +.ss historical +the +.br nsswitch.conf (5) +file is the modern way of controlling the order of host lookups. +.pp +in glibc 2.4 and earlier, the +.i order +keyword was used to control the order of host lookups as defined in +.ir /etc/host.conf +.rb ( host.conf (5)). +.pp +the \fihostent\fp structure is defined in \fi\fp as follows: +.pp +.in +4n +.ex +struct hostent { + char *h_name; /* official name of host */ + char **h_aliases; /* alias list */ + int h_addrtype; /* host address type */ + int h_length; /* length of address */ + char **h_addr_list; /* list of addresses */ +} +#define h_addr h_addr_list[0] /* for backward compatibility */ +.ee +.in +.pp +the members of the \fihostent\fp structure are: +.tp +.i h_name +the official name of the host. +.tp +.i h_aliases +an array of alternative names for the host, terminated by a null pointer. +.tp +.i h_addrtype +the type of address; always +.b af_inet +or +.b af_inet6 +at present. +.tp +.i h_length +the length of the address in bytes. +.tp +.i h_addr_list +an array of pointers to network addresses for the host (in network byte +order), terminated by a null pointer. +.tp +.i h_addr +the first address in \fih_addr_list\fp for backward compatibility. +.sh return value +the +.br gethostbyname () +and +.br gethostbyaddr () +functions return the +.i hostent +structure or a null pointer if an error occurs. +on error, the +.i h_errno +variable holds an error number. +when non-null, the return value may point at static data, see the notes below. +.sh errors +the variable \fih_errno\fp can have the following values: +.tp +.b host_not_found +the specified host is unknown. +.tp +.br no_data +the requested name is valid but does not have an ip address. +another type of request to the name server for this domain +may return an answer. +the constant +.br no_address +is a synonym for +.br no_data . +.tp +.b no_recovery +a nonrecoverable name server error occurred. +.tp +.b try_again +a temporary error occurred on an authoritative name server. +try again later. +.sh files +.tp +.i /etc/host.conf +resolver configuration file +.tp +.i /etc/hosts +host database file +.tp +.i /etc/nsswitch.conf +name service switch configuration +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lb lb lbx +l l l. +interface attribute value +t{ +.br gethostbyname () +t} thread safety t{ +mt-unsafe race:hostbyname env +locale +t} +t{ +.br gethostbyaddr () +t} thread safety t{ +mt-unsafe race:hostbyaddr env +locale +t} +t{ +.br sethostent (), +.br endhostent (), +.br gethostent_r () +t} thread safety t{ +mt-unsafe race:hostent env +locale +t} +t{ +.br herror (), +.br hstrerror () +t} thread safety mt-safe +t{ +.br gethostent () +t} thread safety t{ +mt-unsafe race:hostent +race:hostentbuf env locale +t} +t{ +.br gethostbyname2 () +t} thread safety t{ +mt-unsafe race:hostbyname2 +env locale +t} +t{ +.br gethostbyaddr_r (), +.br gethostbyname_r (), +.br gethostbyname2_r () +t} thread safety mt-safe env locale +.te +.hy +.ad +.sp 1 +in the above table, +.i hostent +in +.i race:hostent +signifies that if any of the functions +.br sethostent (), +.br gethostent (), +.br gethostent_r (), +or +.br endhostent () +are used in parallel in different threads of a program, +then data races could occur. +.sh conforming to +posix.1-2001 specifies +.br gethostbyname (), +.br gethostbyaddr (), +.br sethostent (), +.br endhostent (), +.br gethostent (), +and +.ir h_errno ; +.br gethostbyname (), +.br gethostbyaddr (), +and +.ir h_errno +are marked obsolescent in that standard. +posix.1-2008 removes the specifications of +.br gethostbyname (), +.br gethostbyaddr (), +and +.ir h_errno , +recommending the use of +.br getaddrinfo (3) +and +.br getnameinfo (3) +instead. +.sh notes +the functions +.br gethostbyname () +and +.br gethostbyaddr () +may return pointers to static data, which may be overwritten by +later calls. +copying the +.i struct hostent +does not suffice, since it contains pointers; a deep copy is required. +.pp +in the original bsd implementation the +.i len +argument +of +.br gethostbyname () +was an +.ir int . +the susv2 standard is buggy and declares the +.i len +argument of +.br gethostbyaddr () +to be of type +.ir size_t . +(that is wrong, because it has to be +.ir int , +and +.i size_t +is not. +posix.1-2001 makes it +.ir socklen_t , +which is ok.) +see also +.br accept (2). +.pp +the bsd prototype for +.br gethostbyaddr () +uses +.i "const char\ *" +for the first argument. +.ss system v/posix extension +posix requires the +.br gethostent () +call, which should return the next entry in the host data base. +when using dns/bind this does not make much sense, but it may +be reasonable if the host data base is a file that can be read +line by line. +on many systems, a routine of this name reads +from the file +.ir /etc/hosts . +.\" e.g., linux, freebsd, unixware, hp-ux +it may be available only when the library was built without dns support. +.\" e.g., freebsd, aix +the glibc version will ignore ipv6 entries. +this function is not reentrant, +and glibc adds a reentrant version +.br gethostent_r (). +.ss gnu extensions +glibc2 also has a +.br gethostbyname2 () +that works like +.br gethostbyname (), +but permits to specify the address family to which the address must belong. +.pp +glibc2 also has reentrant versions +.br gethostent_r (), +.br gethostbyaddr_r (), +.br gethostbyname_r (), +and +.br gethostbyname2_r (). +the caller supplies a +.i hostent +structure +.i ret +which will be filled in on success, and a temporary work buffer +.i buf +of size +.ir buflen . +after the call, +.i result +will point to the result on success. +in case of an error +or if no entry is found +.i result +will be null. +the functions return 0 on success and a nonzero error number on failure. +in addition to the errors returned by the nonreentrant +versions of these functions, if +.i buf +is too small, the functions will return +.br erange , +and the call should be retried with a larger buffer. +the global variable +.i h_errno +is not modified, but the address of a variable in which to store error numbers +is passed in +.ir h_errnop . +.sh bugs +.br gethostbyname () +does not recognize components of a dotted ipv4 address string +that are expressed in hexadecimal. +.\" http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=482973 +.sh see also +.br getaddrinfo (3), +.\" .br getipnodebyaddr (3), +.\" .br getipnodebyname (3), +.br getnameinfo (3), +.br inet (3), +.br inet_ntop (3), +.br inet_pton (3), +.br resolver (3), +.br hosts (5), +.br nsswitch.conf (5), +.br hostname (7), +.br named (8) +.\" .br resolv+ (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1993 michael haardt (michael@moria.de), +.\" fri apr 2 11:32:09 met dst 1993 +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" modified sat jul 24 17:17:50 1993 by rik faith +.\" modified thu oct 19 21:25:21 met 1995 by martin schulze +.\" modified mon oct 21 17:47:19 edt 1996 by eric s. raymond +.\" xk +.th ttytype 5 2020-06-09 "linux" "linux programmer's manual" +.sh name +ttytype \- terminal device to default terminal type mapping +.sh description +the +.i /etc/ttytype +file associates +.br termcap (5)/ terminfo (5) +terminal type names +with tty lines. +each line consists of a terminal type, followed by +whitespace, followed by a tty name (a device name without the +.ir /dev/ ") prefix." +.pp +this association is used by the program +.br tset (1) +to set the environment variable +.b term +to the default terminal name for +the user's current tty. +.pp +this facility was designed for a traditional time-sharing environment +featuring character-cell terminals hardwired to a unix minicomputer. +it is little used on modern workstation and personal unix systems. +.sh files +.tp +.i /etc/ttytype +the tty definitions file. +.sh examples +a typical +.i /etc/ttytype +is: +.pp +.in +4n +.ex +con80x25 tty1 +vt320 ttys0 +.ee +.in +.sh see also +.br termcap (5), +.br terminfo (5), +.br agetty (8), +.br mingetty (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/mprotect.2 + +.\" this manpage has been automatically generated by docbook2man +.\" from a docbook document. this tool can be found at: +.\" +.\" please send any bug reports, improvements, comments, patches, +.\" etc. to steve cheng . +.\" +.\" %%%license_start(mit) +.\" this page is made available under the mit license. +.\" %%%license_end +.\" +.th futex 7 2017-09-15 "linux" "linux programmer's manual" +.sh name +futex \- fast user-space locking +.sh synopsis +.nf +.b #include +.fi +.sh description +the linux kernel provides futexes ("fast user-space mutexes") +as a building block for fast user-space +locking and semaphores. +futexes are very basic and lend themselves well for building higher-level +locking abstractions such as +mutexes, condition variables, read-write locks, barriers, and semaphores. +.pp +most programmers will in fact not be using futexes directly but will +instead rely on system libraries built on them, +such as the native posix thread library (nptl) (see +.br pthreads (7)). +.pp +a futex is identified by a piece of memory which can be +shared between processes or threads. +in these different processes, the futex need not have identical addresses. +in its bare form, a futex has semaphore semantics; +it is a counter that can be incremented and decremented atomically; +processes can wait for the value to become positive. +.pp +futex operation occurs entirely in user space for the noncontended case. +the kernel is involved only to arbitrate the contended case. +as any sane design will strive for noncontention, +futexes are also optimized for this situation. +.pp +in its bare form, a futex is an aligned integer which is +touched only by atomic assembler instructions. +this integer is four bytes long on all platforms. +processes can share this integer using +.br mmap (2), +via shared memory segments, or because they share memory space, +in which case the application is commonly called multithreaded. +.ss semantics +any futex operation starts in user space, +but it may be necessary to communicate with the kernel using the +.br futex (2) +system call. +.pp +to "up" a futex, execute the proper assembler instructions that +will cause the host cpu to atomically increment the integer. +afterward, check if it has in fact changed from 0 to 1, in which case +there were no waiters and the operation is done. +this is the noncontended case which is fast and should be common. +.pp +in the contended case, the atomic increment changed the counter +from \-1 (or some other negative number). +if this is detected, there are waiters. +user space should now set the counter to 1 and instruct the +kernel to wake up any waiters using the +.b futex_wake +operation. +.pp +waiting on a futex, to "down" it, is the reverse operation. +atomically decrement the counter and check if it changed to 0, +in which case the operation is done and the futex was uncontended. +in all other circumstances, the process should set the counter to \-1 +and request that the kernel wait for another process to up the futex. +this is done using the +.b futex_wait +operation. +.pp +the +.br futex (2) +system call can optionally be passed a timeout specifying how long +the kernel should +wait for the futex to be upped. +in this case, semantics are more complex and the programmer is referred +to +.br futex (2) +for +more details. +the same holds for asynchronous futex waiting. +.sh versions +initial futex support was merged in linux 2.5.7 +but with different semantics from those described above. +current semantics are available from linux 2.5.40 onward. +.sh notes +to reiterate, bare futexes are not intended as an easy-to-use +abstraction for end users. +implementors are expected to be assembly literate and to have read +the sources of the futex user-space library referenced +below. +.pp +this man page illustrates the most common use of the +.br futex (2) +primitives; it is by no means the only one. +.\" .sh authors +.\" .pp +.\" futexes were designed and worked on by hubertus franke +.\" (ibm thomas j. watson research center), +.\" matthew kirkwood, ingo molnar (red hat) and +.\" rusty russell (ibm linux technology center). +.\" this page written by bert hubert. +.sh see also +.br clone (2), +.br futex (2), +.br get_robust_list (2), +.br set_robust_list (2), +.br set_tid_address (2), +.br pthreads (7) +.pp +.ir "fuss, futexes and furwocks: fast userlevel locking in linux" +(proceedings of the ottawa linux symposium 2002), +futex example library, futex-*.tar.bz2 +.ur ftp://ftp.kernel.org\:/pub\:/linux\:/kernel\:/people\:/rusty/ +.ue . +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 2001 andries brouwer . +.\" and copyright 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th floor 3 2021-03-22 "" "linux programmer's manual" +.sh name +floor, floorf, floorl \- largest integral value not greater than argument +.sh synopsis +.nf +.b #include +.pp +.bi "double floor(double " x ); +.bi "float floorf(float " x ); +.bi "long double floorl(long double " x ); +.fi +.pp +link with \fi\-lm\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br floorf (), +.br floorl (): +.nf + _isoc99_source || _posix_c_source >= 200112l + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.sh description +these functions return the largest integral value that is not greater than +.ir x . +.pp +for example, +.ir floor(0.5) +is 0.0, and +.ir floor(\-0.5) +is \-1.0. +.sh return value +these functions return the floor of +.ir x . +.pp +if +.i x +is integral, +0, \-0, nan, or an infinity, +.i x +itself is returned. +.sh errors +no errors occur. +posix.1-2001 documents a range error for overflows, but see notes. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br floor (), +.br floorf (), +.br floorl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.pp +the variant returning +.i double +also conforms to +svr4, 4.3bsd, c89. +.sh notes +susv2 and posix.1-2001 contain text about overflow (which might set +.i errno +to +.br erange , +or raise an +.b fe_overflow +exception). +in practice, the result cannot overflow on any current machine, +so this error-handling stuff is just nonsense. +.\" the posix.1-2001 application usage section discusses this point. +(more precisely, overflow can happen only when the maximum value +of the exponent is smaller than the number of mantissa bits. +for the ieee-754 standard 32-bit and 64-bit floating-point numbers +the maximum value of the exponent is 128 (respectively, 1024), +and the number of mantissa bits is 24 (respectively, 53).) +.sh see also +.br ceil (3), +.br lrint (3), +.br nearbyint (3), +.br rint (3), +.br round (3), +.br trunc (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/access.2 + +.\" copyright (c) 1983, 1991 regents of the university of california. +.\" and copyright (c) 2007, michael kerrisk +.\" all rights reserved. +.\" +.\" %%%license_start(bsd_4_clause_ucb) +.\" redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. all advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" this product includes software developed by the university of +.\" california, berkeley and its contributors. +.\" 4. neither the name of the university nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" this software is provided by the regents and contributors ``as is'' and +.\" any express or implied warranties, including, but not limited to, the +.\" implied warranties of merchantability and fitness for a particular purpose +.\" are disclaimed. in no event shall the regents or contributors be liable +.\" for any direct, indirect, incidental, special, exemplary, or consequential +.\" damages (including, but not limited to, procurement of substitute goods +.\" or services; loss of use, data, or profits; or business interruption) +.\" however caused and on any theory of liability, whether in contract, strict +.\" liability, or tort (including negligence or otherwise) arising in any way +.\" out of the use of this software, even if advised of the possibility of +.\" such damage. +.\" %%%license_end +.\" +.\" @(#)getpgrp.2 6.4 (berkeley) 3/10/91 +.\" +.\" modified 1993-07-24 by rik faith +.\" modified 1995-04-15 by michael chastain : +.\" added 'getpgid'. +.\" modified 1996-07-21 by andries brouwer +.\" modified 1996-11-06 by eric s. raymond +.\" modified 1999-09-02 by michael haardt +.\" modified 2002-01-18 by michael kerrisk +.\" modified 2003-01-20 by andries brouwer +.\" 2007-07-25, mtk, fairly substantial rewrites and rearrangements +.\" of text. +.\" +.th setpgid 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +setpgid, getpgid, setpgrp, getpgrp \- set/get process group +.sh synopsis +.nf +.b #include +.pp +.bi "int setpgid(pid_t " pid ", pid_t " pgid ); +.bi "pid_t getpgid(pid_t " pid ); +.pp +.br "pid_t getpgrp(void);" " /* posix.1 version */" +.bi "pid_t getpgrp(pid_t " pid ");\fr /* bsd version */" +.pp +.br "int setpgrp(void);" " /* system v version */" +.bi "int setpgrp(pid_t " pid ", pid_t " pgid ");\fr /* bsd version */" +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br getpgid (): +.nf + _xopen_source >= 500 +.\" || _xopen_source && _xopen_source_extended + || /* since glibc 2.12: */ _posix_c_source >= 200809l +.fi +.pp +.br setpgrp "() (posix.1):" +.nf + _xopen_source >= 500 +.\" || _xopen_source && _xopen_source_extended + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _svid_source +.fi +.pp +.br setpgrp "() (bsd)," +.br getpgrp "() (bsd):" +.nf + [these are available only before glibc 2.19] + _bsd_source && + ! (_posix_source || _posix_c_source || _xopen_source + || _gnu_source || _svid_source) +.fi +.sh description +all of these interfaces are available on linux, +and are used for getting and setting the +process group id (pgid) of a process. +the preferred, posix.1-specified ways of doing this are: +.br getpgrp (void), +for retrieving the calling process's pgid; and +.br setpgid (), +for setting a process's pgid. +.pp +.br setpgid () +sets the pgid of the process specified by +.i pid +to +.ir pgid . +if +.i pid +is zero, then the process id of the calling process is used. +if +.i pgid +is zero, then the pgid of the process specified by +.i pid +is made the same as its process id. +if +.br setpgid () +is used to move a process from one process +group to another (as is done by some shells when creating pipelines), +both process groups must be part of the same session (see +.br setsid (2) +and +.br credentials (7)). +in this case, +the \fipgid\fp specifies an existing process group to be joined and the +session id of that group must match the session id of the joining process. +.pp +the posix.1 version of +.br getpgrp (), +which takes no arguments, +returns the pgid of the calling process. +.pp +.br getpgid () +returns the pgid of the process specified by +.ir pid . +if +.i pid +is zero, the process id of the calling process is used. +(retrieving the pgid of a process other than the caller is rarely +necessary, and the posix.1 +.br getpgrp () +is preferred for that task.) +.pp +the system\ v-style +.br setpgrp (), +which takes no arguments, is equivalent to +.ir "setpgid(0,\ 0)" . +.pp +the bsd-specific +.br setpgrp () +call, which takes arguments +.i pid +and +.ir pgid , +is a wrapper function that calls +.pp + setpgid(pid, pgid) +.pp +.\" the true bsd setpgrp() system call differs in allowing the pgid +.\" to be set to arbitrary values, rather than being restricted to +.\" pgids in the same session. +since glibc 2.19, the bsd-specific +.br setpgrp () +function is no longer exposed by +.ir ; +calls should be replaced with the +.br setpgid () +call shown above. +.pp +the bsd-specific +.br getpgrp () +call, which takes a single +.i pid +argument, is a wrapper function that calls +.pp + getpgid(pid) +.pp +since glibc 2.19, the bsd-specific +.br getpgrp () +function is no longer exposed by +.ir ; +calls should be replaced with calls to the posix.1 +.br getpgrp () +which takes no arguments (if the intent is to obtain the caller's pgid), +or with the +.br getpgid () +call shown above. +.sh return value +on success, +.br setpgid () +and +.br setpgrp () +return zero. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.pp +the posix.1 +.br getpgrp () +always returns the pgid of the caller. +.pp +.br getpgid (), +and the bsd-specific +.br getpgrp () +return a process group on success. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eacces +an attempt was made to change the process group id +of one of the children of the calling process and the child had +already performed an +.br execve (2) +.rb ( setpgid (), +.br setpgrp ()). +.tp +.b einval +.i pgid +is less than 0 +.rb ( setpgid (), +.br setpgrp ()). +.tp +.b eperm +an attempt was made to move a process into a process group in a +different session, or to change the process +group id of one of the children of the calling process and the +child was in a different session, or to change the process group id of +a session leader +.rb ( setpgid (), +.br setpgrp ()). +.tp +.b esrch +for +.br getpgid (): +.i pid +does not match any process. +for +.br setpgid (): +.i pid +is not the calling process and not a child of the calling process. +.sh conforming to +.br setpgid () +and the version of +.br getpgrp () +with no arguments +conform to posix.1-2001. +.pp +posix.1-2001 also specifies +.br getpgid () +and the version of +.br setpgrp () +that takes no arguments. +(posix.1-2008 marks this +.br setpgrp () +specification as obsolete.) +.pp +the version of +.br getpgrp () +with one argument and the version of +.br setpgrp () +that takes two arguments derive from 4.2bsd, +and are not specified by posix.1. +.sh notes +a child created via +.br fork (2) +inherits its parent's process group id. +the pgid is preserved across an +.br execve (2). +.pp +each process group is a member of a session and each process is a +member of the session of which its process group is a member. +(see +.br credentials (7).) +.pp +a session can have a controlling terminal. +at any time, one (and only one) of the process groups +in the session can be the foreground process group +for the terminal; +the remaining process groups are in the background. +if a signal is generated from the terminal (e.g., typing the +interrupt key to generate +.br sigint ), +that signal is sent to the foreground process group. +(see +.br termios (3) +for a description of the characters that generate signals.) +only the foreground process group may +.br read (2) +from the terminal; +if a background process group tries to +.br read (2) +from the terminal, then the group is sent a +.b sigttin +signal, which suspends it. +the +.br tcgetpgrp (3) +and +.br tcsetpgrp (3) +functions are used to get/set the foreground +process group of the controlling terminal. +.pp +the +.br setpgid () +and +.br getpgrp () +calls are used by programs such as +.br bash (1) +to create process groups in order to implement shell job control. +.pp +if the termination of a process causes a process group to become orphaned, +and if any member of the newly orphaned process group is stopped, then a +.b sighup +signal followed by a +.b sigcont +signal will be sent to each process +in the newly orphaned process group. +.\" exit.3 refers to the following text: +an orphaned process group is one in which the parent of +every member of process group is either itself also a member +of the process group or is a member of a process group +in a different session (see also +.br credentials (7)). +.sh see also +.br getuid (2), +.br setsid (2), +.br tcgetpgrp (3), +.br tcsetpgrp (3), +.br termios (3), +.br credentials (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2006 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th mq_getsetattr 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +mq_getsetattr \- get/set message queue attributes +.sh synopsis +.nf +.br "#include " " /* definition of " "struct mq_attr" " */" +.br "#include " " /* definition of " sys_* " constants */" +.b #include +.pp +.bi "int syscall(sys_mq_getsetattr, mqd_t " mqdes , +.bi " const struct mq_attr *" newattr ", struct mq_attr *" oldattr ); +.fi +.sh description +do not use this system call. +.pp +this is the low-level system call used to implement +.br mq_getattr (3) +and +.br mq_setattr (3). +for an explanation of how this system call operates, +see the description of +.br mq_setattr (3). +.sh conforming to +this interface is nonstandard; avoid its use. +.sh notes +never call it unless you are writing a c library! +.sh see also +.br mq_getattr (3), +.br mq_overview (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/resolver.3 + +.so man7/system_data_types.7 + +.\" copyright (c) 2008 linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th pthread_attr_setstackaddr 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +pthread_attr_setstackaddr, pthread_attr_getstackaddr \- +set/get stack address attribute in thread attributes object +.sh synopsis +.nf +.b #include +.pp +.bi "int pthread_attr_setstackaddr(pthread_attr_t *" attr \ +", void *" stackaddr ); +.bi "int pthread_attr_getstackaddr(const pthread_attr_t *restrict " attr , +.bi " void **restrict " stackaddr ); +.pp +compile and link with \fi\-pthread\fp. +.fi +.sh description +these functions are obsolete: +.b do not use them. +use +.br pthread_attr_setstack (3) +and +.br pthread_attr_getstack (3) +instead. +.pp +the +.br pthread_attr_setstackaddr () +function sets the stack address attribute of the +thread attributes object referred to by +.i attr +to the value specified in +.ir stackaddr . +this attribute specifies the location of the stack that should +be used by a thread that is created using the thread attributes object +.ir attr . +.pp +.i stackaddr +should point to a buffer of at least +.b pthread_stack_min +bytes that was allocated by the caller. +the pages of the allocated buffer should be both readable and writable. +.pp +the +.br pthread_attr_getstackaddr () +function returns the stack address attribute of the +thread attributes object referred to by +.i attr +in the buffer pointed to by +.ir stackaddr . +.sh return value +on success, these functions return 0; +on error, they return a nonzero error number. +.sh errors +no errors are defined +(but applications should nevertheless +handle a possible error return). +.sh versions +these functions are provided by glibc since version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br pthread_attr_setstackaddr (), +.br pthread_attr_getstackaddr () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001 specifies these functions but marks them as obsolete. +posix.1-2008 removes the specification of these functions. +.sh notes +.i do not use these functions! +they cannot be portably used, since they provide no way of specifying +the direction of growth or the range of the stack. +for example, on architectures with a stack that grows downward, +.i stackaddr +specifies the next address past the +.i highest +address of the allocated stack area. +however, on architectures with a stack that grows upward, +.i stackaddr +specifies the +.i lowest +address in the allocated stack area. +by contrast, the +.i stackaddr +used by +.br pthread_attr_setstack (3) +and +.br pthread_attr_getstack (3), +is always a pointer to the lowest address in the allocated stack area +(and the +.i stacksize +argument specifies the range of the stack). +.sh see also +.br pthread_attr_init (3), +.br pthread_attr_setstack (3), +.br pthread_attr_setstacksize (3), +.br pthread_create (3), +.br pthreads (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/clone.2 + +.so man3/getnetent.3 + +.\" copyright (c) 2019, microchip technology inc. and its subsidiaries +.\" copyright (c) 2016-2018, microsemi corporation +.\" copyright (c) 2016, pmc-sierra, inc. +.\" written by kevin barnett +.\" +.\" %%%license_start(gplv2_oneline) +.\" licensed under gnu general public license version 2 (gplv2) +.\" %%%license_end +.th smartpqi 4 2021-03-22 "linux" "linux programmer's manual" +.sh name +smartpqi \- microsemi smart family scsi driver +.sh synopsis +.sy "modprobe smartpqi" +.rb [ disable_device_id_wildcards= { 0 | 1 }] +.rb [ disable_heartbeat= { 0 | 1 }] +.rb [ disable_ctrl_shutdown= { 0 | 1 }] +.rb [ lockup_action= { none | reboot | panic }] +.rb [ expose_ld_first= { 0 | 1 }] +.rb [ hide_vsep= { 0 | 1 }] +.ys +.sh description +.b smartpqi +is a scsi driver for microsemi smart family controllers. +.ss supported \f[bi]ioctl\fp\/() operations +for compatibility with applications written for the +.br cciss (4) +and +.br hpsa (4) +drivers, many, but not all of the +.br ioctl (2) +operations supported by the +.b hpsa +driver are also supported by the +.b smartpqi +driver. +the data structures used by these operations +are described in the linux kernel source file +.ir include/linux/cciss_ioctl.h . +.tp +.br cciss_deregdisk ", " cciss_regnewdisk ", " cciss_regnewd +these operations +all do exactly the same thing, which is to cause the driver to re-scan +for new devices. +this does exactly the same thing as writing to the +.br smartpqi -specific +host +.i rescan +attribute. +.tp +.b cciss_getpciinfo +this operation returns the pci domain, bus, +device, and function and "board id" (pci subsystem id). +.tp +.b cciss_getdrivver +this operation returns the driver version in four bytes, encoded as: +.ip +.in +4n +.ex +(major_version << 28) | (minor_version << 24) | + (release << 16) | revision +.ee +.in +.tp +.b cciss_passthru +allows bmic and ciss commands to be passed through to the controller. +.ss boot options +.tp +.br disable_device_id_wildcards= { 0 | 1 } +disables support for device id wildcards. +the default value is 0. +.tp +.br disable_heartbeat= { 0 | 1 } +disables support for the controller's heartbeat check. +this parameter is used for debugging purposes. +the default value is 0, leaving the controller's heartbeat check active. +.tp +.br disable_ctrl_shutdown= { 0 | 1 } +disables support for shutting down the controller in the +event of a controller lockup. +the default value is 0. +.tp +.br lockup_action= { none | reboot | panic } +specifies the action the driver takes when a controller +lockup is detected. +the default action is +.br none . +.ts +l l +--- +l l. +parameter action +\fbnone\fp take controller offline only +\fbreboot\fp reboot the system +\fbpanic\fp panic the system +.te +.tp +.br expose_ld_first= { 0 | 1 } +this option enables support for exposing logical devices to +the operating system before physical devices. +the default value is 0. +.tp +.br hide_vsep= { 0 | 1 } +this option enables disabling exposure of the virtual sep to the host. +this is usually associated with direct attached drives. +the default value is 0. +.sh files +.ss device nodes +logical drives are accessed via the scsi disk driver +.ri ( sd ), +tape drives via the scsi tape driver +.ri ( st ), +and the raid controller via the scsi generic driver +.ri ( sg ), +with device nodes named +.ir /dev/sd *, +.ir /dev/st *, +and +.ir /dev/sg *, +respectively. +.ss smartpqi-specific host attribute files in \f[bi]/sys\fp +.tp +.ir /sys/class/scsi_host/host * /rescan +the host +.i rescan +attribute is a write-only attribute. +writing to this attribute will cause the driver to scan for new, +changed, or removed devices (e.g., hot-plugged tape drives, or newly +configured or deleted logical drives) and notify the scsi mid-layer of +any changes detected. +usually this action is triggered automatically by configuration +changes, so the user should not normally have to write to this file. +doing so may be useful when hot-plugging devices such as tape drives or +entire storage boxes containing pre-configured logical drives. +.tp +.ir /sys/class/scsi_host/host * /version +the host +.i version +attribute is a read-only attribute. +this attribute contains the driver version and the controller firmware +version. +.ip +for example: +.ip +.in +4n +.ex +$ \c +.b cat /sys/class/scsi_host/host1/version +driver: 1.1.2\-126 +firmware: 1.29\-112 +.ee +.in +.tp +.ir /sys/class/scsi_host/host * /lockup_action +the host +.i lockup_action +attribute is a read/write attribute. +this attribute will cause the driver to perform a specific action in the +unlikely event that a controller lockup has been detected. +see +.br options +above +for an explanation of the +.i lockup_action +values. +.tp +.ir /sys/class/scsi_host/host*/driver_version +the +.i driver_version +attribute is read-only. +this attribute contains the smartpqi driver version. +.ip +for example: +.ip +.in +4n +.ex +$ \c +.b cat /sys/class/scsi_host/host1/driver_version +1.1.2\-126 +.ee +.in +.tp +.ir /sys/class/scsi_host/host*/firmware_version +the +.i firmware_version +attribute is read-only. +this attribute contains the controller firmware version. +.ip +for example: +.ip +.in +4n +.ex +$ \c +.b cat /sys/class/scsi_host/host1/firmware_version +1.29\-112 +.ee +.in +.tp +.ir /sys/class/scsi_host/host*/model +the +.i model +attribute is read-only. +this attribute contains the product identification string of the controller. +.ip +for example: +.ip +.in +4n +.ex +$ \c +.b cat /sys/class/scsi_host/host1/model +1100\-16i +.ee +.in +.tp +.ir /sys/class/scsi_host/host*/serial_number +the +.i serial_number +attribute is read-only. +this attribute contains the unique identification number of the controller. +.ip +for example: +.ip +.in +4n +.ex +$ \c +.b cat /sys/class/scsi_host/host1/serial_number +6a316373777 +.ee +.in +.tp +.ir /sys/class/scsi_host/host*/vendor +the +.i vendor +attribute is read-only. +this attribute contains the vendor identification string of the controller. +.ip +for example: +.ip +.in +4n +.ex +$ \c +.b cat /sys/class/scsi_host/host1/vendor +adaptec +.ee +.in +.ss smartpqi-specific disk attribute files in \f[bi]/sys\fp +in the file specifications below, +.i c +stands for the number of the appropriate scsi controller, +.i b +is the bus number, +.i t +the target number, and +.i l +is the logical unit number (lun). +.tp +.ir /sys/class/scsi_disk/ c : b : t : l /device/raid_level +the +.i raid_level +attribute is read-only. +this attribute contains the raid level of each logical drive. +.ip +for example: +.ip +.in +4n +.ex +$ \c +.b cat /sys/class/scsi_disk/4:0:0:0/device/raid_level +raid 0 +.ee +.in +.tp +.ir /sys/class/scsi_disk/c : b : t : l/device/sas_address +the +.i sas_address +attribute is read-only. +this attribute contains the unique identifier of the disk. +.ip +for example: +.ip +.in +4n +.ex +$ \c +.b cat /sys/class/scsi_disk/1:0:3:0/device/sas_address +0x5001173d028543a2 +.ee +.in +.tp +.ir /sys/class/scsi_disk/c : b : t : l/device/ssd_smart_path_enabled +the +.i ssd_smart_path_enabled +attribute is read-only. +this attribute is for ioaccel-enabled volumes. +(ioaccel is an alternative driver submission path that allows the +driver to send i/o requests directly to backend scsi devices, +bypassing the controller firmware. +this results in an increase in performance. +this method is used for hba disks and for logical volumes comprised of ssds.) +contains 1 if ioaccel is enabled for the volume and 0 otherwise. +.ip +for example: +.ip +.in +4n +.ex +$ \c +.b cat /sys/class/scsi_disk/1:0:3:0/device/ssd_smart_path_enabled +0 +.ee +.in +.sh versions +the +.b smartpqi +driver was added in linux 4.9. +.sh notes +.ss configuration +to configure a microsemi smart family controller, +refer to the user guide for the controller, +which can be found by searching for the specific controller at +.ur https://storage.microsemi.com/ +.ue . +.sh see also +.br cciss (4), +.br hpsa (4), +.br sd (4), +.br st (4) +.pp +.i documentation/abi/testing/sysfs\-bus\-pci\-devices\-cciss +in the linux kernel source tree. +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/setpgid.2 + +.\" copyright (c) 2013, 2016, 2017 by michael kerrisk +.\" and copyright (c) 2012 by eric w. biederman +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" +.th namespaces 7 2021-08-27 "linux" "linux programmer's manual" +.sh name +namespaces \- overview of linux namespaces +.sh description +a namespace wraps a global system resource in an abstraction that +makes it appear to the processes within the namespace that they +have their own isolated instance of the global resource. +changes to the global resource are visible to other processes +that are members of the namespace, but are invisible to other processes. +one use of namespaces is to implement containers. +.pp +this page provides pointers to information on the various namespace types, +describes the associated +.i /proc +files, and summarizes the apis for working with namespaces. +.\" +.ss namespace types +the following table shows the namespace types available on linux. +the second column of the table shows the flag value that is used to specify +the namespace type in various apis. +the third column identifies the manual page that provides details +on the namespace type. +the last column is a summary of the resources that are isolated by +the namespace type. +.ad l +.nh +.ts +lb lb lb lb +l1 lb1 l1 l. +namespace flag page isolates +cgroup clone_newcgroup \fbcgroup_namespaces\fp(7) t{ +cgroup root directory +t} +ipc clone_newipc \fbipc_namespaces\fp(7) t{ +system v ipc, +posix message queues +t} +network clone_newnet \fbnetwork_namespaces\fp(7) t{ +network devices, +stacks, ports, etc. +t} +mount clone_newns \fbmount_namespaces\fp(7) mount points +pid clone_newpid \fbpid_namespaces\fp(7) process ids +time clone_newtime \fbtime_namespaces\fp(7) t{ +boot and monotonic +clocks +t} +user clone_newuser \fbuser_namespaces\fp(7) t{ +user and group ids +t} +uts clone_newuts \fbuts_namespaces\fp(7) t{ +hostname and nis +domain name +t} +.te +.hy +.ad +.\" +.\" ==================== the namespaces api ==================== +.\" +.ss the namespaces api +as well as various +.i /proc +files described below, +the namespaces api includes the following system calls: +.tp +.br clone (2) +the +.br clone (2) +system call creates a new process. +if the +.i flags +argument of the call specifies one or more of the +.b clone_new* +flags listed above, then new namespaces are created for each flag, +and the child process is made a member of those namespaces. +(this system call also implements a number of features +unrelated to namespaces.) +.tp +.br setns (2) +the +.br setns (2) +system call allows the calling process to join an existing namespace. +the namespace to join is specified via a file descriptor that refers to +one of the +.ir /proc/[pid]/ns +files described below. +.tp +.br unshare (2) +the +.br unshare (2) +system call moves the calling process to a new namespace. +if the +.i flags +argument of the call specifies one or more of the +.b clone_new* +flags listed above, then new namespaces are created for each flag, +and the calling process is made a member of those namespaces. +(this system call also implements a number of features +unrelated to namespaces.) +.tp +.br ioctl (2) +various +.br ioctl (2) +operations can be used to discover information about namespaces. +these operations are described in +.br ioctl_ns (2). +.pp +creation of new namespaces using +.br clone (2) +and +.br unshare (2) +in most cases requires the +.br cap_sys_admin +capability, since, in the new namespace, +the creator will have the power to change global resources +that are visible to other processes that are subsequently created in, +or join the namespace. +user namespaces are the exception: since linux 3.8, +no privilege is required to create a user namespace. +.\" +.\" ==================== the /proc/[pid]/ns/ directory ==================== +.\" +.ss the /proc/[pid]/ns/ directory +each process has a +.ir /proc/[pid]/ns/ +.\" see commit 6b4e306aa3dc94a0545eb9279475b1ab6209a31f +subdirectory containing one entry for each namespace that +supports being manipulated by +.br setns (2): +.pp +.in +4n +.ex +$ \fbls \-l /proc/$$/ns | awk \(aq{print $1, $9, $10, $11}\(aq\fp +total 0 +lrwxrwxrwx. cgroup \-> cgroup:[4026531835] +lrwxrwxrwx. ipc \-> ipc:[4026531839] +lrwxrwxrwx. mnt \-> mnt:[4026531840] +lrwxrwxrwx. net \-> net:[4026531969] +lrwxrwxrwx. pid \-> pid:[4026531836] +lrwxrwxrwx. pid_for_children \-> pid:[4026531834] +lrwxrwxrwx. time \-> time:[4026531834] +lrwxrwxrwx. time_for_children \-> time:[4026531834] +lrwxrwxrwx. user \-> user:[4026531837] +lrwxrwxrwx. uts \-> uts:[4026531838] +.ee +.in +.pp +bind mounting (see +.br mount (2)) +one of the files in this directory +to somewhere else in the filesystem keeps +the corresponding namespace of the process specified by +.i pid +alive even if all processes currently in the namespace terminate. +.pp +opening one of the files in this directory +(or a file that is bind mounted to one of these files) +returns a file handle for +the corresponding namespace of the process specified by +.ir pid . +as long as this file descriptor remains open, +the namespace will remain alive, +even if all processes in the namespace terminate. +the file descriptor can be passed to +.br setns (2). +.pp +in linux 3.7 and earlier, these files were visible as hard links. +since linux 3.8, +.\" commit bf056bfa80596a5d14b26b17276a56a0dcb080e5 +they appear as symbolic links. +if two processes are in the same namespace, +then the device ids and inode numbers of their +.ir /proc/[pid]/ns/xxx +symbolic links will be the same; an application can check this using the +.i stat.st_dev +.\" eric biederman: "i reserve the right for st_dev to be significant +.\" when comparing namespaces." +.\" https://lore.kernel.org/lkml/87poky5ca9.fsf@xmission.com/ +.\" re: documenting the ioctl interfaces to discover relationships... +.\" date: mon, 12 dec 2016 11:30:38 +1300 +and +.i stat.st_ino +fields returned by +.br stat (2). +the content of this symbolic link is a string containing +the namespace type and inode number as in the following example: +.pp +.in +4n +.ex +$ \fbreadlink /proc/$$/ns/uts\fp +uts:[4026531838] +.ee +.in +.pp +the symbolic links in this subdirectory are as follows: +.tp +.ir /proc/[pid]/ns/cgroup " (since linux 4.6)" +this file is a handle for the cgroup namespace of the process. +.tp +.ir /proc/[pid]/ns/ipc " (since linux 3.0)" +this file is a handle for the ipc namespace of the process. +.tp +.ir /proc/[pid]/ns/mnt " (since linux 3.8)" +.\" commit 8823c079ba7136dc1948d6f6dcb5f8022bde438e +this file is a handle for the mount namespace of the process. +.tp +.ir /proc/[pid]/ns/net " (since linux 3.0)" +this file is a handle for the network namespace of the process. +.tp +.ir /proc/[pid]/ns/pid " (since linux 3.8)" +.\" commit 57e8391d327609cbf12d843259c968b9e5c1838f +this file is a handle for the pid namespace of the process. +this handle is permanent for the lifetime of the process +(i.e., a process's pid namespace membership never changes). +.tp +.ir /proc/[pid]/ns/pid_for_children " (since linux 4.12)" +.\" commit eaa0d190bfe1ed891b814a52712dcd852554cb08 +this file is a handle for the pid namespace of +child processes created by this process. +this can change as a consequence of calls to +.br unshare (2) +and +.br setns (2) +(see +.br pid_namespaces (7)), +so the file may differ from +.ir /proc/[pid]/ns/pid . +the symbolic link gains a value only after the first child process +is created in the namespace. +(beforehand, +.br readlink (2) +of the symbolic link will return an empty buffer.) +.tp +.ir /proc/[pid]/ns/time " (since linux 5.6)" +this file is a handle for the time namespace of the process. +.tp +.ir /proc/[pid]/ns/time_for_children " (since linux 5.6)" +this file is a handle for the time namespace of +child processes created by this process. +this can change as a consequence of calls to +.br unshare (2) +and +.br setns (2) +(see +.br time_namespaces (7)), +so the file may differ from +.ir /proc/[pid]/ns/time . +.tp +.ir /proc/[pid]/ns/user " (since linux 3.8)" +.\" commit cde1975bc242f3e1072bde623ef378e547b73f91 +this file is a handle for the user namespace of the process. +.tp +.ir /proc/[pid]/ns/uts " (since linux 3.0)" +this file is a handle for the uts namespace of the process. +.pp +permission to dereference or read +.rb ( readlink (2)) +these symbolic links is governed by a ptrace access mode +.b ptrace_mode_read_fscreds +check; see +.br ptrace (2). +.\" +.\" ==================== the /proc/sys/user directory ==================== +.\" +.ss the /proc/sys/user directory +the files in the +.i /proc/sys/user +directory (which is present since linux 4.9) expose limits +on the number of namespaces of various types that can be created. +the files are as follows: +.tp +.ir max_cgroup_namespaces +the value in this file defines a per-user limit on the number of +cgroup namespaces that may be created in the user namespace. +.tp +.ir max_ipc_namespaces +the value in this file defines a per-user limit on the number of +ipc namespaces that may be created in the user namespace. +.tp +.ir max_mnt_namespaces +the value in this file defines a per-user limit on the number of +mount namespaces that may be created in the user namespace. +.tp +.ir max_net_namespaces +the value in this file defines a per-user limit on the number of +network namespaces that may be created in the user namespace. +.tp +.ir max_pid_namespaces +the value in this file defines a per-user limit on the number of +pid namespaces that may be created in the user namespace. +.tp +.ir max_time_namespaces " (since linux 5.7)" +.\" commit eeec26d5da8248ea4e240b8795bb4364213d3247 +the value in this file defines a per-user limit on the number of +time namespaces that may be created in the user namespace. +.tp +.ir max_user_namespaces +the value in this file defines a per-user limit on the number of +user namespaces that may be created in the user namespace. +.tp +.ir max_uts_namespaces +the value in this file defines a per-user limit on the number of +uts namespaces that may be created in the user namespace. +.pp +note the following details about these files: +.ip * 3 +the values in these files are modifiable by privileged processes. +.ip * +the values exposed by these files are the limits for the user namespace +in which the opening process resides. +.ip * +the limits are per-user. +each user in the same user namespace +can create namespaces up to the defined limit. +.ip * +the limits apply to all users, including uid 0. +.ip * +these limits apply in addition to any other per-namespace +limits (such as those for pid and user namespaces) that may be enforced. +.ip * +upon encountering these limits, +.br clone (2) +and +.br unshare (2) +fail with the error +.br enospc . +.ip * +for the initial user namespace, +the default value in each of these files is half the limit on the number +of threads that may be created +.ri ( /proc/sys/kernel/threads\-max ). +in all descendant user namespaces, the default value in each file is +.br maxint . +.ip * +when a namespace is created, the object is also accounted +against ancestor namespaces. +more precisely: +.rs +.ip + 3 +each user namespace has a creator uid. +.ip + +when a namespace is created, +it is accounted against the creator uids in each of the +ancestor user namespaces, +and the kernel ensures that the corresponding namespace limit +for the creator uid in the ancestor namespace is not exceeded. +.ip + +the aforementioned point ensures that creating a new user namespace +cannot be used as a means to escape the limits in force +in the current user namespace. +.re +.\" +.ss namespace lifetime +absent any other factors, +a namespace is automatically torn down when the last process in +the namespace terminates or leaves the namespace. +however, there are a number of other factors that may pin +a namespace into existence even though it has no member processes. +these factors include the following: +.ip * 3 +an open file descriptor or a bind mount exists for the corresponding +.ir /proc/[pid]/ns/* +file. +.ip * +the namespace is hierarchical (i.e., a pid or user namespace), +and has a child namespace. +.ip * +it is a user namespace that owns one or more nonuser namespaces. +.ip * +it is a pid namespace, +and there is a process that refers to the namespace via a +.ir /proc/[pid]/ns/pid_for_children +symbolic link. +.ip * +it is a time namespace, +and there is a process that refers to the namespace via a +.ir /proc/[pid]/ns/time_for_children +symbolic link. +.ip * +it is an ipc namespace, and a corresponding mount of an +.i mqueue +filesystem (see +.br mq_overview (7)) +refers to this namespace. +.ip * +it is a pid namespace, and a corresponding mount of a +.br proc (5) +filesystem refers to this namespace. +.sh examples +see +.br clone (2) +and +.br user_namespaces (7). +.sh see also +.br nsenter (1), +.br readlink (1), +.br unshare (1), +.br clone (2), +.br ioctl_ns (2), +.br setns (2), +.br unshare (2), +.br proc (5), +.br capabilities (7), +.br cgroup_namespaces (7), +.br cgroups (7), +.br credentials (7), +.br ipc_namespaces (7), +.br network_namespaces (7), +.br pid_namespaces (7), +.br user_namespaces (7), +.br uts_namespaces (7), +.br lsns (8), +.br switch_root (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/sigaltstack.2 +.\" no new programs should use sigstack(3). +.\" sigaltstack(2) briefly discusses sigstack(3), so point the user there. + +.so man3/finite.3 + +.\" copyright (c) 1993 by thomas koenig (ig25@rz.uni-karlsruhe.de) +.\" and copyright 2014 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified sat jul 24 17:45:39 1993 by rik faith (faith@cs.unc.edu) +.\" modified 2000-02-13 by nicolás lichtmaier +.th toupper 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +toupper, tolower, toupper_l, tolower_l \- convert uppercase or lowercase +.sh synopsis +.nf +.b #include +.pp +.bi "int toupper(int " "c" ); +.bi "int tolower(int " "c" ); +.pp +.bi "int toupper_l(int " c ", locale_t " locale ); +.bi "int tolower_l(int " c ", locale_t " locale ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br toupper_l (), +.br tolower_l (): +.nf + since glibc 2.10: + _xopen_source >= 700 + before glibc 2.10: + _gnu_source +.fi +.sh description +these functions convert lowercase letters to uppercase, and vice versa. +.pp +if +.i c +is a lowercase letter, +.br toupper () +returns its uppercase equivalent, +if an uppercase representation exists in the current locale. +otherwise, it returns +.ir c . +the +.br toupper_l () +function performs the same task, +but uses the locale referred to by the locale handle +.ir locale . +.pp +if +.i c +is an uppercase letter, +.br tolower () +returns its lowercase equivalent, +if a lowercase representation exists in the current locale. +otherwise, it returns +.ir c . +the +.br tolower_l () +function performs the same task, +but uses the locale referred to by the locale handle +.ir locale . +.pp +if +.i c +is neither an +.i "unsigned char" +value nor +.br eof , +the behavior of these functions +is undefined. +.pp +the behavior of +.br toupper_l () +and +.br tolower_l () +is undefined if +.i locale +is the special locale object +.b lc_global_locale +(see +.br duplocale (3)) +or is not a valid locale object handle. +.sh return value +the value returned is that of the converted letter, or +.i c +if the conversion was not possible. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br toupper (), +.br tolower (), +.br toupper_l (), +.br tolower_l () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +.br toupper (), +.br tolower (): +c89, c99, 4.3bsd, posix.1-2001, posix.1-2008. +.pp +.br toupper_l (), +.br tolower_l (): +posix.1-2008. +.sh notes +the standards require that the argument +.i c +for these functions is either +.b eof +or a value that is representable in the type +.ir "unsigned char" . +if the argument +.i c +is of type +.ir char , +it must be cast to +.ir "unsigned char" , +as in the following example: +.pp +.in +4n +.ex +char c; +\&... +res = toupper((unsigned char) c); +.ee +.in +.pp +this is necessary because +.i char +may be the equivalent +.ir "signed char" , +in which case a byte where the top bit is set would be sign extended when +converting to +.ir int , +yielding a value that is outside the range of +.ir "unsigned char" . +.pp +the details of what constitutes an uppercase or lowercase letter depend +on the locale. +for example, the default +.b """c""" +locale does not know about umlauts, so no conversion is done for them. +.pp +in some non-english locales, there are lowercase letters with no +corresponding uppercase equivalent; +.\" fixme one day the statement about "sharp s" needs to be reworked, +.\" since there is nowadays a capital "sharp s" that has a codepoint +.\" in unicode 5.0; see https://en.wikipedia.org/wiki/capital_%e1%ba%9e +the german sharp s is one example. +.sh see also +.br isalpha (3), +.br newlocale (3), +.br setlocale (3), +.br towlower (3), +.br towupper (3), +.br uselocale (3), +.br locale (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/ceil.3 + +.so man3/termios.3 + +.\" copyright (c) 2016 by michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th ntp_gettime 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +ntp_gettime, ntp_gettimex \- get time parameters (ntp daemon interface) +.sh synopsis +.nf +.b #include +.pp +.bi "int ntp_gettime(struct ntptimeval *" ntv ); +.bi "int ntp_gettimex(struct ntptimeval *" ntv ); +.fi +.sh description +both of these apis return information to the caller via the +.i ntv +argument, a structure of the following type: +.pp +.in +4n +.ex +struct ntptimeval { + struct timeval time; /* current time */ + long maxerror; /* maximum error */ + long esterror; /* estimated error */ + long tai; /* tai offset */ + + /* further padding bytes allowing for future expansion */ +}; +.ee +.in +.pp +the fields of this structure are as follows: +.tp +.i time +the current time, expressed as a +.i timeval +structure: +.ip +.in +4n +.ex +struct timeval { + time_t tv_sec; /* seconds since the epoch */ + suseconds_t tv_usec; /* microseconds */ +}; +.ee +.in +.tp +.i maxerror +maximum error, in microseconds. +this value can be initialized by +.br ntp_adjtime (3), +and is increased periodically (on linux: each second), +but is clamped to an upper limit (the kernel constant +.br ntp_phase_max , +with a value of 16,000). +.tp +.i esterror +estimated error, in microseconds. +this value can be set via +.br ntp_adjtime (3) +to contain an estimate of the difference between the system clock +and the true time. +this value is not used inside the kernel. +.tp +.i tai +tai (atomic international time) offset. +.pp +.br ntp_gettime () +returns an +.i ntptimeval +structure in which the +.ir time , +.ir maxerror , +and +.ir esterror +fields are filled in. +.pp +.br ntp_gettimex () +performs the same task as +.br ntp_gettime (), +but also returns information in the +.i tai +field. +.sh return value +the return values for +.br ntp_gettime () +and +.br ntp_gettimex () +are as for +.br adjtimex (2). +given a correct pointer argument, these functions always succeed. +.\" fixme . the info page incorrectly describes the return values. +.sh versions +the +.br ntp_gettime () +function is available since glibc 2.1. +the +.br ntp_gettimex () +function is available since glibc 2.12. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br ntp_gettime (), +.br ntp_gettimex () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +.br ntp_gettime () +is described in the ntp kernel application program interface. +.br ntp_gettimex () +is a gnu extension. +.sh see also +.br adjtimex (2), +.br ntp_adjtime (3), +.br time (7) +.pp +.ad l +.ur http://www.slac.stanford.edu/comp/unix/\:package/\:rtems/\:src/\:ssrlapps/\:ntpnanoclock/\:api.htm +ntp "kernel application program interface" +.ue +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/stdio_ext.3 + +.so man3/stailq.3 + +.so man3/sinh.3 + +.so man7/system_data_types.7 + +.so man2/getdents.2 + +.so man3/acosh.3 + +.so man3/pthread_attr_setdetachstate.3 + +.so man3/cpu_set.3 + +.so man3/fread.3 + +.\" copyright (c) 2005 michael kerrisk +.\" based on earlier work by faith@cs.unc.edu and +.\" mike battersby +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" 2005-09-15, mtk, created new page by splitting off from sigaction.2 +.\" +.th sigprocmask 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +sigprocmask, rt_sigprocmask \- examine and change blocked signals +.sh synopsis +.b #include +.pp +.nf +/* prototype for the glibc wrapper function */ +.bi "int sigprocmask(int " how ", const sigset_t *restrict " set , +.bi " sigset_t *restrict " oldset ); +.pp +.br "#include " " /* definition of " sig_* " constants */" +.br "#include " " /* definition of " sys_* " constants */" +.b #include +.pp +/* prototype for the underlying system call */ +.bi "int syscall(sys_rt_sigprocmask, int " how ", const kernel_sigset_t *" set , +.bi " kernel_sigset_t *" oldset ", size_t " sigsetsize ); +.pp +/* prototype for the legacy system call (deprecated) */ +.bi "int syscall(sys_sigprocmask, int " how ", const old_kernel_sigset_t *" set , +.bi " old_kernel_sigset_t *" oldset ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br sigprocmask (): +.nf + _posix_c_source +.fi +.sh description +.br sigprocmask () +is used to fetch and/or change the signal mask of the calling thread. +the signal mask is the set of signals whose delivery is currently +blocked for the caller +(see also +.br signal (7) +for more details). +.pp +the behavior of the call is dependent on the value of +.ir how , +as follows. +.tp +.b sig_block +the set of blocked signals is the union of the current set and the +.i set +argument. +.tp +.b sig_unblock +the signals in +.i set +are removed from the current set of blocked signals. +it is permissible to attempt to unblock a signal which is not blocked. +.tp +.b sig_setmask +the set of blocked signals is set to the argument +.ir set . +.pp +if +.i oldset +is non-null, the previous value of the signal mask is stored in +.ir oldset . +.pp +if +.i set +is null, then the signal mask is unchanged (i.e., +.i how +is ignored), +but the current value of the signal mask is nevertheless returned in +.i oldset +(if it is not null). +.pp +a set of functions for modifying and inspecting variables of type +.i sigset_t +("signal sets") is described in +.br sigsetops (3). +.pp +the use of +.br sigprocmask () +is unspecified in a multithreaded process; see +.br pthread_sigmask (3). +.sh return value +.br sigprocmask () +returns 0 on success. +on failure, \-1 is returned and +.i errno +is set to indicate the error. +.sh errors +.tp +.b efault +the +.i set +or +.i oldset +argument points outside the process's allocated address space. +.tp +.b einval +either the value specified in +.i how +was invalid or the kernel does not support the size passed in +.i sigsetsize. +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +it is not possible to block +.br sigkill " or " sigstop . +attempts to do so are silently ignored. +.pp +each of the threads in a process has its own signal mask. +.pp +a child created via +.br fork (2) +inherits a copy of its parent's signal mask; +the signal mask is preserved across +.br execve (2). +.pp +if +.br sigbus , +.br sigfpe , +.br sigill , +or +.b sigsegv +are generated +while they are blocked, the result is undefined, +unless the signal was generated by +.br kill (2), +.br sigqueue (3), +or +.br raise (3). +.pp +see +.br sigsetops (3) +for details on manipulating signal sets. +.pp +note that it is permissible (although not very useful) to specify both +.i set +and +.i oldset +as null. +.\" +.ss c library/kernel differences +the kernel's definition of +.ir sigset_t +differs in size from that used +by the c library. +in this manual page, the former is referred to as +.i kernel_sigset_t +(it is nevertheless named +.i sigset_t +in the kernel sources). +.pp +the glibc wrapper function for +.br sigprocmask () +silently ignores attempts to block the two real-time signals that +are used internally by the nptl threading implementation. +see +.br nptl (7) +for details. +.pp +the original linux system call was named +.br sigprocmask (). +however, with the addition of real-time signals in linux 2.2, +the fixed-size, 32-bit +.ir sigset_t +(referred to as +.ir old_kernel_sigset_t +in this manual page) +type supported by that system call was no longer fit for purpose. +consequently, a new system call, +.br rt_sigprocmask (), +was added to support an enlarged +.ir sigset_t +type +(referred to as +.ir kernel_sigset_t +in this manual page). +the new system call takes a fourth argument, +.ir "size_t sigsetsize" , +which specifies the size in bytes of the signal sets in +.ir set +and +.ir oldset . +this argument is currently required to have a fixed architecture specific value +(equal to +.ir sizeof(kernel_sigset_t) ). +.\" sizeof(kernel_sigset_t) == _nsig / 8, +.\" which equals to 8 on most architectures, but e.g. on mips it's 16. +.pp +the glibc +.br sigprocmask () +wrapper function hides these details from us, transparently calling +.br rt_sigprocmask () +when the kernel provides it. +.\" +.sh see also +.br kill (2), +.br pause (2), +.br sigaction (2), +.br signal (2), +.br sigpending (2), +.br sigsuspend (2), +.br pthread_sigmask (3), +.br sigqueue (3), +.br sigsetops (3), +.br signal (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/cacos.3 + +.so man3/qsort.3 + +.\" copyright (c) 2008 linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th pthread_testcancel 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +pthread_testcancel \- request delivery of any pending cancellation request +.sh synopsis +.nf +.b #include +.pp +.b void pthread_testcancel(void); +.pp +compile and link with \fi\-pthread\fp. +.fi +.sh description +calling +.br pthread_testcancel () +creates a cancellation point within the calling thread, +so that a thread that is otherwise executing code that contains +no cancellation points will respond to a cancellation request. +.pp +if cancelability is disabled (using +.br pthread_setcancelstate (3)), +or no cancellation request is pending, +then a call to +.br pthread_testcancel () +has no effect. +.sh return value +this function does not return a value. +if the calling thread is canceled as a consequence of a call +to this function, then the function does not return. +.sh errors +this function always succeeds. +.\" sh versions +.\" available since glibc 2.0 +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br pthread_testcancel () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh examples +see +.br pthread_cleanup_push (3). +.sh see also +.br pthread_cancel (3), +.br pthread_cleanup_push (3), +.br pthread_setcancelstate (3), +.br pthreads (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2011 by andi kleen +.\" and copyright (c) 2011 by michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" syscall added in following commit +.\" commit a2e2725541fad72416326798c2d7fa4dafb7d337 +.\" author: arnaldo carvalho de melo +.\" date: mon oct 12 23:40:10 2009 -0700 +.\" +.th recvmmsg 2 2020-11-01 "linux" "linux programmer's manual" +.sh name +recvmmsg \- receive multiple messages on a socket +.sh synopsis +.nf +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.bi "#include " +.pp +.bi "int recvmmsg(int " sockfd ", struct mmsghdr *" msgvec \ +", unsigned int " vlen "," +.bi " int " flags ", struct timespec *" timeout ");" +.fi +.sh description +the +.br recvmmsg () +system call is an extension of +.br recvmsg (2) +that allows the caller to receive multiple messages from a socket +using a single system call. +(this has performance benefits for some applications.) +a further extension over +.br recvmsg (2) +is support for a timeout on the receive operation. +.pp +the +.i sockfd +argument is the file descriptor of the socket to receive data from. +.pp +the +.i msgvec +argument is a pointer to an array of +.i mmsghdr +structures. +the size of this array is specified in +.ir vlen . +.pp +the +.i mmsghdr +structure is defined in +.i +as: +.pp +.in +4n +.ex +struct mmsghdr { + struct msghdr msg_hdr; /* message header */ + unsigned int msg_len; /* number of received bytes for header */ +}; +.ee +.in +.pp +the +.i msg_hdr +field is a +.i msghdr +structure, as described in +.br recvmsg (2). +the +.i msg_len +field is the number of bytes returned for the message in the entry. +this field has the same value as the return value of a single +.br recvmsg (2) +on the header. +.pp +the +.i flags +argument contains flags ored together. +the flags are the same as documented for +.br recvmsg (2), +with the following addition: +.tp +.br msg_waitforone " (since linux 2.6.34)" +turns on +.b msg_dontwait +after the first message has been received. +.pp +the +.i timeout +argument points to a +.i struct timespec +(see +.br clock_gettime (2)) +defining a timeout (seconds plus nanoseconds) for the receive operation +.ri ( "but see bugs!" ). +(this interval will be rounded up to the system clock granularity, +and kernel scheduling delays mean that the blocking interval +may overrun by a small amount.) +if +.i timeout +is null, then the operation blocks indefinitely. +.pp +a blocking +.br recvmmsg () +call blocks until +.i vlen +messages have been received +or until the timeout expires. +a nonblocking call reads as many messages as are available +(up to the limit specified by +.ir vlen ) +and returns immediately. +.pp +on return from +.br recvmmsg (), +successive elements of +.ir msgvec +are updated to contain information about each received message: +.i msg_len +contains the size of the received message; +the subfields of +.i msg_hdr +are updated as described in +.br recvmsg (2). +the return value of the call indicates the number of elements of +.i msgvec +that have been updated. +.sh return value +on success, +.br recvmmsg () +returns the number of messages received in +.ir msgvec ; +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +errors are as for +.br recvmsg (2). +in addition, the following error can occur: +.tp +.b einval +.i timeout +is invalid. +.pp +see also bugs. +.sh versions +the +.br recvmmsg () +system call was added in linux 2.6.33. +support in glibc was added in version 2.12. +.sh conforming to +.br recvmmsg () +is linux-specific. +.sh bugs +the +.i timeout +argument does not work as intended. +.\" fixme . https://bugzilla.kernel.org/show_bug.cgi?id=75371 +.\" http://thread.gmane.org/gmane.linux.man/5677 +the timeout is checked only after the receipt of each datagram, +so that if up to +.i vlen\-1 +datagrams are received before the timeout expires, +but then no further datagrams are received, the call will block forever. +.pp +if an error occurs after at least one message has been received, +the call succeeds, and returns the number of messages received. +the error code is expected to be returned on a subsequent call to +.br recvmmsg (). +in the current implementation, however, the error code can be overwritten +in the meantime by an unrelated network event on a socket, +for example an incoming icmp packet. +.sh examples +the following program uses +.br recvmmsg () +to receive multiple messages on a socket and stores +them in multiple buffers. +the call returns if all buffers are filled or if the +timeout specified has expired. +.pp +the following snippet periodically generates udp datagrams +containing a random number: +.pp +.in +4n +.ex +.rb "$" " while true; do echo $random > /dev/udp/127.0.0.1/1234;" +.b " sleep 0.25; done" +.ee +.in +.pp +these datagrams are read by the example application, which +can give the following output: +.pp +.in +4n +.ex +.rb "$" " ./a.out" +5 messages received +1 11782 +2 11345 +3 304 +4 13514 +5 28421 +.ee +.in +.ss program source +\& +.ex +#define _gnu_source +#include +#include +#include +#include +#include + +int +main(void) +{ +#define vlen 10 +#define bufsize 200 +#define timeout 1 + int sockfd, retval; + struct sockaddr_in addr; + struct mmsghdr msgs[vlen]; + struct iovec iovecs[vlen]; + char bufs[vlen][bufsize+1]; + struct timespec timeout; + + sockfd = socket(af_inet, sock_dgram, 0); + if (sockfd == \-1) { + perror("socket()"); + exit(exit_failure); + } + + addr.sin_family = af_inet; + addr.sin_addr.s_addr = htonl(inaddr_loopback); + addr.sin_port = htons(1234); + if (bind(sockfd, (struct sockaddr *) &addr, sizeof(addr)) == \-1) { + perror("bind()"); + exit(exit_failure); + } + + memset(msgs, 0, sizeof(msgs)); + for (int i = 0; i < vlen; i++) { + iovecs[i].iov_base = bufs[i]; + iovecs[i].iov_len = bufsize; + msgs[i].msg_hdr.msg_iov = &iovecs[i]; + msgs[i].msg_hdr.msg_iovlen = 1; + } + + timeout.tv_sec = timeout; + timeout.tv_nsec = 0; + + retval = recvmmsg(sockfd, msgs, vlen, 0, &timeout); + if (retval == \-1) { + perror("recvmmsg()"); + exit(exit_failure); + } + + printf("%d messages received\en", retval); + for (int i = 0; i < retval; i++) { + bufs[i][msgs[i].msg_len] = 0; + printf("%d %s", i+1, bufs[i]); + } + exit(exit_success); +} +.ee +.sh see also +.br clock_gettime (2), +.br recvmsg (2), +.br sendmmsg (2), +.br sendmsg (2), +.br socket (2), +.br socket (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1993 +.\" the regents of the university of california. all rights reserved. +.\" and copyright (c) 2020 by alejandro colomar +.\" +.\" %%%license_start(bsd_3_clause_ucb) +.\" redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. neither the name of the university nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" this software is provided by the regents and contributors ``as is'' and +.\" any express or implied warranties, including, but not limited to, the +.\" implied warranties of merchantability and fitness for a particular purpose +.\" are disclaimed. in no event shall the regents or contributors be liable +.\" for any direct, indirect, incidental, special, exemplary, or consequential +.\" damages (including, but not limited to, procurement of substitute goods +.\" or services; loss of use, data, or profits; or business interruption) +.\" however caused and on any theory of liability, whether in contract, strict +.\" liability, or tort (including negligence or otherwise) arising in any way +.\" out of the use of this software, even if advised of the possibility of +.\" such damage. +.\" %%%license_end +.\" +.\" +.th tailq 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +tailq_concat, +tailq_empty, +tailq_entry, +tailq_first, +tailq_foreach, +.\"tailq_foreach_from, +.\"tailq_foreach_from_safe, +tailq_foreach_reverse, +.\"tailq_foreach_reverse_from, +.\"tailq_foreach_reverse_from_safe, +.\"tailq_foreach_reverse_safe, +.\"tailq_foreach_safe, +tailq_head, +tailq_head_initializer, +tailq_init, +tailq_insert_after, +tailq_insert_before, +tailq_insert_head, +tailq_insert_tail, +tailq_last, +tailq_next, +tailq_prev, +tailq_remove +.\"tailq_swap +\- implementation of a doubly linked tail queue +.sh synopsis +.nf +.b #include +.pp +.b tailq_entry(type); +.pp +.b tailq_head(headname, type); +.bi "tailq_head tailq_head_initializer(tailq_head " head ); +.bi "void tailq_init(tailq_head *" head ); +.pp +.bi "int tailq_empty(tailq_head *" head ); +.pp +.bi "void tailq_insert_head(tailq_head *" head , +.bi " struct type *" elm ", tailq_entry " name ); +.bi "void tailq_insert_tail(tailq_head *" head , +.bi " struct type *" elm ", tailq_entry " name ); +.bi "void tailq_insert_before(struct type *" listelm , +.bi " struct type *" elm ", tailq_entry " name ); +.bi "void tailq_insert_after(tailq_head *" head ", struct type *" listelm , +.bi " struct type *" elm ", tailq_entry " name ); +.pp +.bi "struct type *tailq_first(tailq_head *" head ); +.bi "struct type *tailq_last(tailq_head *" head ", headname);" +.bi "struct type *tailq_prev(struct type *" elm ", headname, tailq_entry " name ); +.bi "struct type *tailq_next(struct type *" elm ", tailq_entry " name ); +.pp +.bi "tailq_foreach(struct type *" var ", tailq_head *" head , +.bi " tailq_entry " name ); +.\" .bi "tailq_foreach_from(struct type *" var ", tailq_head *" head , +.\" .bi " tailq_entry " name ); +.bi "tailq_foreach_reverse(struct type *" var ", tailq_head *" head ", headname," +.bi " tailq_entry " name ); +.\" .bi "tailq_foreach_reverse_from(struct type *" var ", tailq_head *" head ", headname," +.\" .bi " tailq_entry " name ); +.\" .pp +.\" .bi "tailq_foreach_safe(struct type *" var ", tailq_head *" head , +.\" .bi " tailq_entry " name , +.\" .bi " struct type *" temp_var ); +.\" .bi "tailq_foreach_from_safe(struct type *" var ", tailq_head *" head , +.\" .bi " tailq_entry " name , +.\" .bi " struct type *" temp_var ); +.\" .bi "tailq_foreach_reverse_safe(struct type *" var ", tailq_head *" head , +.\" .bi " headname, tailq_entry " name , +.\" .bi " struct type *" temp_var ); +.\" .bi "tailq_foreach_reverse_from_safe(struct type *" var ", tailq_head *" head , +.\" .bi " headname, tailq_entry " name , +.\" .bi " struct type *" temp_var ); +.pp +.bi "void tailq_remove(tailq_head *" head ", struct type *" elm , +.bi " tailq_entry " name ); +.pp +.bi "void tailq_concat(tailq_head *" head1 ", tailq_head *" head2 , +.bi " tailq_entry " name ); +.\" .bi "void tailq_swap(tailq_head *" head1 ", tailq_head *" head2 ", type," +.\" .bi " tailq_entry " name ); +.fi +.sh description +these macros define and operate on doubly linked tail queues. +.pp +in the macro definitions, +.i type +is the name of a user defined structure, +that must contain a field of type +.ir tailq_entry , +named +.ir name . +the argument +.i headname +is the name of a user defined structure that must be declared +using the macro +.br tailq_head (). +.ss creation +a tail queue is headed by a structure defined by the +.br tailq_head () +macro. +this structure contains a pair of pointers, +one to the first element in the queue +and the other to the last element in the queue. +the elements are doubly linked +so that an arbitrary element can be removed without traversing the queue. +new elements can be added to the queue +after an existing element, +before an existing element, +at the head of the queue, +or at the end of the queue. +a +.i tailq_head +structure is declared as follows: +.pp +.in +4 +.ex +tailq_head(headname, type) head; +.ee +.in +.pp +where +.i struct headname +is the structure to be defined, and +.i struct type +is the type of the elements to be linked into the queue. +a pointer to the head of the queue can later be declared as: +.pp +.in +4 +.ex +struct headname *headp; +.ee +.in +.pp +(the names +.i head +and +.i headp +are user selectable.) +.pp +.br tailq_entry () +declares a structure that connects the elements in the queue. +.pp +.br tailq_head_initializer () +evaluates to an initializer for the queue +.ir head . +.pp +.br tailq_init () +initializes the queue referenced by +.pp +.br tailq_empty () +evaluates to true if there are no items on the queue. +.ir head . +.ss insertion +.br tailq_insert_head () +inserts the new element +.i elm +at the head of the queue. +.pp +.br tailq_insert_tail () +inserts the new element +.i elm +at the end of the queue. +.pp +.br tailq_insert_before () +inserts the new element +.i elm +before the element +.ir listelm . +.pp +.br tailq_insert_after () +inserts the new element +.i elm +after the element +.ir listelm . +.ss traversal +.br tailq_first () +returns the first item on the queue, or null if the queue is empty. +.pp +.br tailq_last () +returns the last item on the queue. +if the queue is empty the return value is null. +.pp +.br tailq_prev () +returns the previous item on the queue, or null if this item is the first. +.pp +.br tailq_next () +returns the next item on the queue, or null if this item is the last. +.pp +.br tailq_foreach () +traverses the queue referenced by +.i head +in the forward direction, +assigning each element in turn to +.ir var . +.i var +is set to null if the loop completes normally, +or if there were no elements. +.\" .pp +.\" .br tailq_foreach_from () +.\" behaves identically to +.\" .br tailq_foreach () +.\" when +.\" .i var +.\" is null, else it treats +.\" .i var +.\" as a previously found tailq element and begins the loop at +.\" .i var +.\" instead of the first element in the tailq referenced by +.\" .ir head . +.pp +.br tailq_foreach_reverse () +traverses the queue referenced by +.i head +in the reverse direction, +assigning each element in turn to +.ir var . +.\" .pp +.\" .br tailq_foreach_reverse_from () +.\" behaves identically to +.\" .br tailq_foreach_reverse () +.\" when +.\" .i var +.\" is null, else it treats +.\" .i var +.\" as a previously found tailq element and begins the reverse loop at +.\" .i var +.\" instead of the last element in the tailq referenced by +.\" .ir head . +.\" .pp +.\" .br tailq_foreach_safe () +.\" and +.\" .br tailq_foreach_reverse_safe () +.\" traverse the list referenced by +.\" .i head +.\" in the forward or reverse direction respectively, +.\" assigning each element in turn to +.\" .ir var . +.\" however, unlike their unsafe counterparts, +.\" .br tailq_foreach () +.\" and +.\" .br tailq_foreach_reverse () +.\" permit to both remove +.\" .i var +.\" as well as free it from within the loop safely without interfering with the +.\" traversal. +.\" .pp +.\" .br tailq_foreach_from_safe () +.\" behaves identically to +.\" .br tailq_foreach_safe () +.\" when +.\" .i var +.\" is null, else it treats +.\" .i var +.\" as a previously found tailq element and begins the loop at +.\" .i var +.\" instead of the first element in the tailq referenced by +.\" .ir head . +.\" .pp +.\" .br tailq_foreach_reverse_from_safe () +.\" behaves identically to +.\" .br tailq_foreach_reverse_safe () +.\" when +.\" .i var +.\" is null, else it treats +.\" .i var +.\" as a previously found tailq element and begins the reverse loop at +.\" .i var +.\" instead of the last element in the tailq referenced by +.\" .ir head . +.ss removal +.br tailq_remove () +removes the element +.i elm +from the queue. +.ss other features +.\" .br tailq_swap () +.\" swaps the contents of +.\" .i head1 +.\" and +.\" .ir head2 . +.\" .pp +.br tailq_concat () +concatenates the queue headed by +.i head2 +onto the end of the one headed by +.i head1 +removing all entries from the former. +.sh return value +.br tailq_empty () +returns nonzero if the queue is empty, +and zero if the queue contains at least one entry. +.pp +.br tailq_first (), +.br tailq_last (), +.br tailq_prev (), +and +.br tailq_next () +return a pointer to the first, last, previous, or next +.i type +structure, respectively. +.pp +.br tailq_head_initializer () +returns an initializer that can be assigned to the queue +.ir head . +.sh conforming to +not in posix.1, posix.1-2001, or posix.1-2008. +present on the bsds. +(tailq functions first appeared in 4.4bsd). +.sh bugs +.br tailq_foreach () +and +.br tailq_foreach_reverse () +don't allow +.i var +to be removed or freed within the loop, +as it would interfere with the traversal. +.br tailq_foreach_safe () +and +.br tailq_foreach_reverse_safe (), +which are present on the bsds but are not present in glibc, +fix this limitation by allowing +.i var +to safely be removed from the list and freed from within the loop +without interfering with the traversal. +.sh examples +.ex +#include +#include +#include +#include + +struct entry { + int data; + tailq_entry(entry) entries; /* tail queue */ +}; + +tailq_head(tailhead, entry); + +int +main(void) +{ + struct entry *n1, *n2, *n3, *np; + struct tailhead head; /* tail queue head */ + int i; + + tailq_init(&head); /* initialize the queue */ + + n1 = malloc(sizeof(struct entry)); /* insert at the head */ + tailq_insert_head(&head, n1, entries); + + n1 = malloc(sizeof(struct entry)); /* insert at the tail */ + tailq_insert_tail(&head, n1, entries); + + n2 = malloc(sizeof(struct entry)); /* insert after */ + tailq_insert_after(&head, n1, n2, entries); + + n3 = malloc(sizeof(struct entry)); /* insert before */ + tailq_insert_before(n2, n3, entries); + + tailq_remove(&head, n2, entries); /* deletion */ + free(n2); + /* forward traversal */ + i = 0; + tailq_foreach(np, &head, entries) + np\->data = i++; + /* reverse traversal */ + tailq_foreach_reverse(np, &head, tailhead, entries) + printf("%i\en", np\->data); + /* tailq deletion */ + n1 = tailq_first(&head); + while (n1 != null) { + n2 = tailq_next(n1, entries); + free(n1); + n1 = n2; + } + tailq_init(&head); + + exit(exit_success); +} +.ee +.sh see also +.br insque (3), +.br queue (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/rpc.3 + +.so man3/setbuf.3 + +.so man3/argz_add.3 + +.so man3/ctime.3 + +.\" this manpage is copyright (c) 2006 jens axboe +.\" and copyright (c) 2006 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th vmsplice 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +vmsplice \- splice user pages to/from a pipe +.sh synopsis +.nf +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "ssize_t vmsplice(int " fd ", const struct iovec *" iov , +.bi " size_t " nr_segs ", unsigned int " flags ); +.fi +.\" return type was long before glibc 2.7 +.sh description +.\" linus: vmsplice() system call to basically do a "write to +.\" the buffer", but using the reference counting and vm traversal +.\" to actually fill the buffer. this means that the user needs to +.\" be careful not to reuse the user-space buffer it spliced into +.\" the kernel-space one (contrast this to "write()", which copies +.\" the actual data, and you can thus reuse the buffer immediately +.\" after a successful write), but that is often easy to do. +if +.i fd +is opened for writing, the +.br vmsplice () +system call maps +.i nr_segs +ranges of user memory described by +.i iov +into a pipe. +if +.i fd +is opened for reading, +.\" since linux 2.6.23 +.\" commit 6a14b90bb6bc7cd83e2a444bf457a2ea645cbfe7 +the +.br vmsplice () +system call fills +.i nr_segs +ranges of user memory described by +.i iov +from a pipe. +the file descriptor +.i fd +must refer to a pipe. +.pp +the pointer +.i iov +points to an array of +.i iovec +structures as defined in +.ir : +.pp +.in +4n +.ex +struct iovec { + void *iov_base; /* starting address */ + size_t iov_len; /* number of bytes */ +}; +.ee +.in +.pp +the +.i flags +argument is a bit mask that is composed by oring together +zero or more of the following values: +.tp +.b splice_f_move +unused for +.br vmsplice (); +see +.br splice (2). +.tp +.b splice_f_nonblock +.\" not used for vmsplice +.\" may be in the future -- therefore eagain +do not block on i/o; see +.br splice (2) +for further details. +.tp +.b splice_f_more +currently has no effect for +.br vmsplice (), +but may be implemented in the future; see +.br splice (2). +.tp +.b splice_f_gift +the user pages are a gift to the kernel. +the application may not modify this memory ever, +.\" fixme . explain the following line in a little more detail: +otherwise the page cache and on-disk data may differ. +gifting pages to the kernel means that a subsequent +.br splice (2) +.b splice_f_move +can successfully move the pages; +if this flag is not specified, then a subsequent +.br splice (2) +.b splice_f_move +must copy the pages. +data must also be properly page aligned, both in memory and length. +.\" fixme +.\" it looks like the page-alignment requirement went away with +.\" commit bd1a68b59c8e3bce45fb76632c64e1e063c3962d +.\" +.\" .... if we expect to later splice_f_move to the cache. +.sh return value +upon successful completion, +.br vmsplice () +returns the number of bytes transferred to the pipe. +on error, +.br vmsplice () +returns \-1 and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eagain +.b splice_f_nonblock +was specified in +.ir flags , +and the operation would block. +.tp +.b ebadf +.i fd +either not valid, or doesn't refer to a pipe. +.tp +.b einval +.i nr_segs +is greater than +.br iov_max ; +or memory not aligned if +.b splice_f_gift +set. +.tp +.b enomem +out of memory. +.sh versions +the +.br vmsplice () +system call first appeared in linux 2.6.17; +library support was added to glibc in version 2.5. +.sh conforming to +this system call is linux-specific. +.sh notes +.br vmsplice () +follows the other vectorized read/write type functions when it comes to +limitations on the number of segments being passed in. +this limit is +.b iov_max +as defined in +.ir . +currently, +.\" uio_maxiov in kernel source +this limit is 1024. +.pp +.\" commit 6a14b90bb6bc7cd83e2a444bf457a2ea645cbfe7 +.br vmsplice () +really supports true splicing only from user memory to a pipe. +in the opposite direction, it actually just copies the data to user space. +but this makes the interface nice and symmetric and enables people to build on +.br vmsplice () +with room for future improvement in performance. +.sh see also +.br splice (2), +.br tee (2), +.br pipe (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/endian.3 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified 1993-07-24 by rik faith (faith@cs.unc.edu) +.\" modified 2002-07-27 by walter harms +.\" (walter.harms@informatik.uni-oldenburg.de) +.\" +.th hypot 3 2021-03-22 "" "linux programmer's manual" +.sh name +hypot, hypotf, hypotl \- euclidean distance function +.sh synopsis +.nf +.b #include +.pp +.bi "double hypot(double " x ", double " y ); +.bi "float hypotf(float " x ", float " y ); +.bi "long double hypotl(long double " x ", long double " y ); +.fi +.pp +link with \fi\-lm\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br hypot (): +.nf + _isoc99_source || _posix_c_source >= 200112l + || _xopen_source + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.pp +.br hypotf (), +.br hypotl (): +.nf + _isoc99_source || _posix_c_source >= 200112l + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.sh description +these functions return +.ri sqrt( x * x + y * y ). +this is the length of the hypotenuse of a right-angled triangle +with sides of length +.i x +and +.ir y , +or the distance of the point +.ri ( x , y ) +from the origin. +.pp +the calculation is performed without undue overflow or underflow +during the intermediate steps of the calculation. +.\" e.g., hypot(dbl_min, dbl_min) does the right thing, as does, say +.\" hypot(dbl_max/2.0, dbl_max/2.0). +.sh return value +on success, these functions return the length of the hypotenuse of +a right-angled triangle +with sides of length +.i x +and +.ir y . +.pp +if +.i x +or +.i y +is an infinity, +positive infinity is returned. +.pp +if +.i x +or +.i y +is a nan, +and the other argument is not an infinity, +a nan is returned. +.pp +if the result overflows, +a range error occurs, +and the functions return +.br huge_val , +.br huge_valf , +or +.br huge_vall , +respectively. +.pp +if both arguments are subnormal, and the result is subnormal, +.\" actually, could the result not be subnormal if both arguments +.\" are subnormal? i think not -- mtk, jul 2008 +a range error occurs, +and the correct result is returned. +.sh errors +see +.br math_error (7) +for information on how to determine whether an error has occurred +when calling these functions. +.pp +the following errors can occur: +.tp +range error: result overflow +.i errno +is set to +.br erange . +an overflow floating-point exception +.rb ( fe_overflow ) +is raised. +.tp +range error: result underflow +an underflow floating-point exception +.rb ( fe_underflow ) +is raised. +.ip +these functions do not set +.ir errno +for this case. +.\" this is intentional; see +.\" https://www.sourceware.org/bugzilla/show_bug.cgi?id=6795 +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br hypot (), +.br hypotf (), +.br hypotl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.pp +the variant returning +.i double +also conforms to +svr4, 4.3bsd. +.sh see also +.br cabs (3), +.br sqrt (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2007 michael kerrisk +.\" and copyright (c) 2007 justin pryzby +.\" +.\" %%%license_start(permissive_misc) +.\" permission is hereby granted, free of charge, to any person obtaining +.\" a copy of this software and associated documentation files (the +.\" "software"), to deal in the software without restriction, including +.\" without limitation the rights to use, copy, modify, merge, publish, +.\" distribute, sublicense, and/or sell copies of the software, and to +.\" permit persons to whom the software is furnished to do so, subject to +.\" the following conditions: +.\" +.\" the above copyright notice and this permission notice shall be +.\" included in all copies or substantial portions of the software. +.\" +.\" the software is provided "as is", without warranty of any kind, +.\" express or implied, including but not limited to the warranties of +.\" merchantability, fitness for a particular purpose and noninfringement. +.\" in no event shall the authors or copyright holders be liable for any +.\" claim, damages or other liability, whether in an action of contract, +.\" tort or otherwise, arising from, out of or in connection with the +.\" software or the use or other dealings in the software. +.\" %%%license_end +.\" +.th getsubopt 3 2021-08-27 "gnu" "linux programmer's manual" +.sh name +getsubopt \- parse suboption arguments from a string +.sh synopsis +.nf +.b #include +.pp +.bi "int getsubopt(char **restrict " optionp ", char *const *restrict " tokens , +.bi " char **restrict " valuep ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br getsubopt (): +.nf + _xopen_source >= 500 +.\" || _xopen_source && _xopen_source_extended + || /* since glibc 2.12: */ _posix_c_source >= 200809l +.fi +.sh description +.br getsubopt () +parses the list of comma-separated suboptions provided in +.ir optionp . +(such a suboption list is typically produced when +.br getopt (3) +is used to parse a command line; +see for example the \fi\-o\fp option of +.br mount (8).) +each suboption may include an associated value, +which is separated from the suboption name by an equal sign. +the following is an example of the kind of string +that might be passed in +.ir optionp : +.pp +.in +4n +.ex +.b ro,name=xyz +.ee +.in +.pp +the +.i tokens +argument is a pointer to a null-terminated array of pointers to the tokens that +.br getsubopt () +will look for in +.ir optionp . +the tokens should be distinct, null-terminated strings containing at +least one character, with no embedded equal signs or commas. +.pp +each call to +.br getsubopt () +returns information about the next unprocessed suboption in +.ir optionp . +the first equal sign in a suboption (if any) is interpreted as a +separator between the name and the value of that suboption. +the value extends to the next comma, +or (for the last suboption) to the end of the string. +if the name of the suboption matches a known name from +.ir tokens , +and a value string was found, +.br getsubopt () +sets +.i *valuep +to the address of that string. +the first comma in +.i optionp +is overwritten with a null byte, so +.i *valuep +is precisely the "value string" for that suboption. +.pp +if the suboption is recognized, but no value string was found, +.i *valuep +is set to null. +.pp +when +.br getsubopt () +returns, +.i optionp +points to the next suboption, +or to the null byte (\(aq\e0\(aq) at the end of the +string if the last suboption was just processed. +.sh return value +if the first suboption in +.i optionp +is recognized, +.br getsubopt () +returns the index of the matching suboption element in +.ir tokens . +otherwise, \-1 is returned and +.i *valuep +is the entire +.ib name [= value ] +string. +.pp +since +.i *optionp +is changed, the first suboption before the call to +.br getsubopt () +is not (necessarily) the same as the first suboption after +.br getsubopt (). +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br getsubopt () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +since +.br getsubopt () +overwrites any commas it finds in the string +.ir *optionp , +that string must be writable; it cannot be a string constant. +.sh examples +the following program expects suboptions following a "\-o" option. +.pp +.ex +#define _xopen_source 500 +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + enum { + ro_opt = 0, + rw_opt, + name_opt + }; + char *const token[] = { + [ro_opt] = "ro", + [rw_opt] = "rw", + [name_opt] = "name", + null + }; + char *subopts; + char *value; + int opt; + + int readonly = 0; + int readwrite = 0; + char *name = null; + int errfnd = 0; + + while ((opt = getopt(argc, argv, "o:")) != \-1) { + switch (opt) { + case \(aqo\(aq: + subopts = optarg; + while (*subopts != \(aq\e0\(aq && !errfnd) { + + switch (getsubopt(&subopts, token, &value)) { + case ro_opt: + readonly = 1; + break; + + case rw_opt: + readwrite = 1; + break; + + case name_opt: + if (value == null) { + fprintf(stderr, "missing value for " + "suboption \(aq%s\(aq\en", token[name_opt]); + errfnd = 1; + continue; + } + + name = value; + break; + + default: + fprintf(stderr, "no match found " + "for token: /%s/\en", value); + errfnd = 1; + break; + } + } + if (readwrite && readonly) { + fprintf(stderr, "only one of \(aq%s\(aq and \(aq%s\(aq can be " + "specified\en", token[ro_opt], token[rw_opt]); + errfnd = 1; + } + break; + + default: + errfnd = 1; + } + } + + if (errfnd || argc == 1) { + fprintf(stderr, "\enusage: %s \-o \en", argv[0]); + fprintf(stderr, "suboptions are \(aqro\(aq, \(aqrw\(aq, " + "and \(aqname=\(aq\en"); + exit(exit_failure); + } + + /* remainder of program... */ + + exit(exit_success); +} +.ee +.sh see also +.br getopt (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/random_r.3 + +.\" copyright (c) andreas gruenbacher, february 2001 +.\" copyright (c) silicon graphics inc, september 2001 +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th removexattr 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +removexattr, lremovexattr, fremovexattr \- remove an extended attribute +.sh synopsis +.fam c +.nf +.b #include +.pp +.bi "int removexattr(const char\ *" path ", const char\ *" name ); +.bi "int lremovexattr(const char\ *" path ", const char\ *" name ); +.bi "int fremovexattr(int " fd ", const char\ *" name ); +.fi +.fam t +.sh description +extended attributes are +.ir name : value +pairs associated with inodes (files, directories, symbolic links, etc.). +they are extensions to the normal attributes which are associated +with all inodes in the system (i.e., the +.br stat (2) +data). +a complete overview of extended attributes concepts can be found in +.br xattr (7). +.pp +.br removexattr () +removes the extended attribute identified by +.i name +and associated with the given +.i path +in the filesystem. +.pp +.br lremovexattr () +is identical to +.br removexattr (), +except in the case of a symbolic link, where the extended attribute is +removed from the link itself, not the file that it refers to. +.pp +.br fremovexattr () +is identical to +.br removexattr (), +only the extended attribute is removed from the open file referred to by +.i fd +(as returned by +.br open (2)) +in place of +.ir path . +.pp +an extended attribute name is a null-terminated string. +the +.i name +includes a namespace prefix; there may be several, disjoint +namespaces associated with an individual inode. +.sh return value +on success, zero is returned. +on failure, \-1 is returned and +.i errno +is set to indicate the error. +.sh errors +.tp +.b enodata +the named attribute does not exist. +.\" .rb ( enoattr +.\" is defined to be a synonym for +.\" .br enodata +.\" in +.\" .ir .) +.tp +.b enotsup +extended attributes are not supported by the filesystem, or are disabled. +.pp +in addition, the errors documented in +.br stat (2) +can also occur. +.sh versions +these system calls have been available on linux since kernel 2.4; +glibc support is provided since version 2.3. +.sh conforming to +these system calls are linux-specific. +.\" .sh authors +.\" andreas gruenbacher, +.\" .ri < a.gruenbacher@computer.org > +.\" and the sgi xfs development team, +.\" .ri < linux-xfs@oss.sgi.com >. +.\" please send any bug reports or comments to these addresses. +.sh see also +.br getfattr (1), +.br setfattr (1), +.br getxattr (2), +.br listxattr (2), +.br open (2), +.br setxattr (2), +.br stat (2), +.br symlink (7), +.br xattr (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/mmap.2 + +.so man3/rpc.3 + +.so man3/flockfile.3 + +.\" copyright (c) 2006, michael kerrisk +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th standards 7 2020-11-01 "linux" "linux programmer's manual" +.sh name +standards \- c and unix standards +.sh description +the conforming to section that appears in many manual pages identifies +various standards to which the documented interface conforms. +the following list briefly describes these standards. +.tp +.b v7 +version 7 (also known as seventh edition) unix, +released by at&t/bell labs in 1979. +after this point, unix systems diverged into two main dialects: +bsd and system v. +.tp +.b 4.2bsd +this is an implementation standard defined by the 4.2 release +of the +.ir "berkeley software distribution", +released by the university of california at berkeley. +this was the first berkeley release that contained a tcp/ip +stack and the sockets api. +4.2bsd was released in 1983. +.ip +earlier major bsd releases included +.ir 3bsd +(1980), +.i 4bsd +(1980), +and +.i 4.1bsd +(1981). +.tp +.b 4.3bsd +the successor to 4.2bsd, released in 1986. +.tp +.b 4.4bsd +the successor to 4.3bsd, released in 1993. +this was the last major berkeley release. +.tp +.b system v +this is an implementation standard defined by at&t's milestone 1983 +release of its commercial system v (five) release. +the previous major at&t release was +.ir "system iii" , +released in 1981. +.tp +.b system v release 2 (svr2) +this was the next system v release, made in 1985. +the svr2 was formally described in the +.i "system v interface definition version 1" +.ri ( "svid 1" ) +published in 1985. +.tp +.b system v release 3 (svr3) +this was the successor to svr2, released in 1986. +this release was formally described in the +.i "system v interface definition version 2" +.ri ( "svid 2" ). +.tp +.b system v release 4 (svr4) +this was the successor to svr3, released in 1989. +this version of system v is described in the "programmer's reference +manual: operating system api (intel processors)" (prentice-hall +1992, isbn 0-13-951294-2) +this release was formally described in the +.i "system v interface definition version 3" +.ri ( "svid 3" ), +and is considered the definitive system v release. +.tp +.b svid 4 +system v interface definition version 4, issued in 1995. +available online at +.ur http://www.sco.com\:/developers\:/devspecs/ +.ue . +.tp +.b c89 +this was the first c language standard, ratified by ansi +(american national standards institute) in 1989 +.ri ( x3.159-1989 ). +sometimes this is known as +.ir "ansi c" , +but since c99 is also an +ansi standard, this term is ambiguous. +this standard was also ratified by +iso (international standards organization) in 1990 +.ri ( "iso/iec 9899:1990" ), +and is thus occasionally referred to as +.ir "iso c90" . +.tp +.b c99 +this revision of the c language standard was ratified by iso in 1999 +.ri ( "iso/iec 9899:1999" ). +available online at +.ur http://www.open\-std.org\:/jtc1\:/sc22\:/wg14\:/www\:/standards +.ue . +.tp +.b c11 +this revision of the c language standard was ratified by iso in 2011 +.ri ( "iso/iec 9899:2011" ). +.ip +.b lfs +the large file summit specification, completed in 1996. +this specification defined mechanisms that allowed 32-bit systems +to support the use of large files (i.e., 64-bit file offsets). +see +.ur https://www.opengroup.org\:/platform\:/lfs.html +.ue . +.tp +.b posix.1-1988 +this was the first posix standard, +ratified by ieee as ieee std 1003.1-1988, +and subsequently adopted (with minor revisions) as an iso standard in 1990. +the term "posix" was coined by richard stallman. +.tp +.b posix.1-1990 +"portable operating system interface for computing environments". +ieee 1003.1-1990 part 1, ratified by iso in 1990 +.ri ( "iso/iec 9945-1:1990" ). +.tp +.b posix.2 +ieee std 1003.2-1992, +describing commands and utilities, ratified by iso in 1993 +.ri ( "iso/iec 9945-2:1993" ). +.tp +.br posix.1b " (formerly known as \fiposix.4\fp)" +ieee std 1003.1b-1993, +describing real-time facilities +for portable operating systems, ratified by iso in 1996 +.ri ( "iso/iec 9945-1:1996" ). +.tp +.b posix.1c " (formerly known as \fiposix.4a\fp)" +ieee std 1003.1c-1995, which describes the posix threads interfaces. +.tp +.br posix.1d +ieee std 1003.1c-1999, which describes additional real-time extensions. +.tp +.b posix.1g +ieee std 1003.1g-2000, which describes networking apis (including sockets). +.tp +.b posix.1j +ieee std 1003.1j-2000, which describes advanced real-time extensions. +.tp +.b posix.1-1996 +a 1996 revision of posix.1 which incorporated posix.1b and posix.1c. +.tp +.b xpg3 +released in 1989, this was the first release of the x/open +portability guide to be based on a posix standard (posix.1-1988). +this multivolume guide was developed by the x/open group, +a multivendor consortium. +.tp +.b xpg4 +a revision of the x/open portability guide, released in 1992. +this revision incorporated posix.2. +.tp +.b xpg4v2 +a 1994 revision of xpg4. +this is also referred to as +.ir "spec 1170" , +where 1170 referred to the number of interfaces +defined by this standard. +.tp +.b "sus (susv1)" +single unix specification. +this was a repackaging of xpg4v2 and other x/open standards +(x/open curses issue 4 version 2, +x/open networking service (xns) issue 4). +systems conforming to this standard can be branded +.ir "unix 95" . +.tp +.b susv2 +single unix specification version 2. +sometimes also referred to (incorrectly) as +.ir xpg5 . +this standard appeared in 1997. +systems conforming to this standard can be branded +.ir "unix 98" . +see also +.ur http://www.unix.org\:/version2/ +.ue .) +.tp +.b posix.1-2001, susv3 +this was a 2001 revision and consolidation of the +posix.1, posix.2, and sus standards into a single document, +conducted under the auspices of the austin group +.ur http://www.opengroup.org\:/austin/ +.ue . +the standard is available online at +.ur http://www.unix.org\:/version3/ +.ue . +.ip +the standard defines two levels of conformance: +.ir "posix conformance" , +which is a baseline set of interfaces required of a conforming system; +and +.ir "xsi conformance", +which additionally mandates a set of interfaces +(the "xsi extension") which are only optional for posix conformance. +xsi-conformant systems can be branded +.ir "unix 03" . +.ip +the posix.1-2001 document is broken into four parts: +.ip +.br xbd : +definitions, terms, and concepts, header file specifications. +.ip +.br xsh : +specifications of functions (i.e., system calls and library +functions in actual implementations). +.ip +.br xcu : +specifications of commands and utilities +(i.e., the area formerly described by posix.2). +.ip +.br xrat : +informative text on the other parts of the standard. +.ip +posix.1-2001 is aligned with c99, so that all of the +library functions standardized in c99 are also +standardized in posix.1-2001. +.ip +the single unix specification version 3 (susv3) comprises the +base specifications containing xbd, xsh, xcu, and xrat as above, +plus x/open curses issue 4 version 2 as an extra volume that is +not in posix.1-2001. +.ip +two technical corrigenda (minor fixes and improvements) +of the original 2001 standard have occurred: +tc1 in 2003 +and tc2 in 2004. +.tp +.b posix.1-2008, susv4 +work on the next revision of posix.1/sus was completed and +ratified in 2008. +the standard is available online at +.ur http://www.unix.org\:/version4/ +.ue . +.ip +the changes in this revision are not as large as those +that occurred for posix.1-2001/susv3, +but a number of new interfaces are added +and various details of existing specifications are modified. +many of the interfaces that were optional in +posix.1-2001 become mandatory in the 2008 revision of the standard. +a few interfaces that are present in posix.1-2001 are marked +as obsolete in posix.1-2008, or removed from the standard altogether. +.ip +the revised standard is structured in the same way as its predecessor. +the single unix specification version 4 (susv4) comprises the +base specifications containing xbd, xsh, xcu, and xrat, +plus x/open curses issue 7 as an extra volume that is +not in posix.1-2008. +.ip +again there are two levels of conformance: the baseline +.ir "posix conformance" , +and +.ir "xsi conformance" , +which mandates an additional set of interfaces +beyond those in the base specification. +.ip +in general, where the conforming to section of a manual page +lists posix.1-2001, it can be assumed that the interface also +conforms to posix.1-2008, unless otherwise noted. +.ip +technical corrigendum 1 (minor fixes and improvements) +of this standard was released in 2013. +.ip +technical corrigendum 2 of this standard was released in 2016. +.ip +further information can be found on the austin group web site, +.ur http://www.opengroup.org\:/austin/ +.ue . +.tp +.b susv4 2016 edition +this is equivalent to posix.1-2008, with the addition of +technical corrigenda 1 and 2 and the xcurses specification. +.tp +.b posix.1-2017 +this revision of posix is technically identical to posix.1-2008 with +technical corrigenda 1 and 2 applied. +.tp +.b susv4 2018 edition +this is equivalent to posix.1-2017, with the addition of +the xcurses specification. +.pp +the interfaces documented in posix.1/sus are available as +manual pages under sections 0p (header files), 1p (commands), +and 3p (functions); +thus one can write "man 3p open". +.sh see also +.br getconf (1), +.br confstr (3), +.br pathconf (3), +.br sysconf (3), +.br attributes (7), +.br feature_test_macros (7), +.br libc (7), +.br posixoptions (7), +.br system_data_types (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1995 by jim van zandt +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" added bugs section, aeb, 950919 +.\" +.th toascii 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +toascii \- convert character to ascii +.sh synopsis +.nf +.b #include +.pp +.bi "int toascii(int " "c" ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br toascii (): +.nf + _xopen_source + || /* glibc since 2.19: */ _default_source + || /* glibc <= 2.19: */ _svid_source || _bsd_source +.fi +.sh description +.br toascii () +converts +.i c +to a 7-bit +.i "unsigned char" +value that fits into the ascii character set, by clearing the +high-order bits. +.sh return value +the value returned is that of the converted character. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br toascii () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +svr4, bsd, posix.1-2001. +posix.1-2008 marks +.br toascii () +as obsolete, +noting that it cannot be used portably in a localized application. +.sh bugs +many people will be unhappy if you use this function. +this function will convert accented letters into random characters. +.sh see also +.br isascii (3), +.br tolower (3), +.br toupper (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/pthread_attr_setstacksize.3 + +.so man2/dup.2 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" and copyright (c) 2007, 2012 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's "posix programmer's guide" (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sat jul 24 19:30:29 1993 by rik faith (faith@cs.unc.edu) +.\" modified fri feb 14 21:47:50 1997 by andries brouwer (aeb@cwi.nl) +.\" +.th getenv 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +getenv, secure_getenv \- get an environment variable +.sh synopsis +.nf +.b #include +.pp +.bi "char *getenv(const char *" name ); +.bi "char *secure_getenv(const char *" name ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br secure_getenv (): +.nf + _gnu_source +.fi +.sh description +the +.br getenv () +function searches the environment list to find the +environment variable +.ir name , +and returns a pointer to the corresponding +.i value +string. +.pp +the gnu-specific +.br secure_getenv () +function is just like +.br getenv () +except that it returns null in cases where "secure execution" is required. +secure execution is required if one of the following conditions +was true when the program run by the calling process was loaded: +.ip * 3 +the process's effective user id did not match its real user id or +the process's effective group id did not match its real group id +(typically this is the result of executing a set-user-id or +set-group-id program); +.ip * +the effective capability bit was set on the executable file; or +.ip * +the process has a nonempty permitted capability set. +.pp +secure execution may also be required if triggered +by some linux security modules. +.pp +the +.br secure_getenv () +function is intended for use in general-purpose libraries +to avoid vulnerabilities that could occur if +set-user-id or set-group-id programs accidentally +trusted the environment. +.sh return value +the +.br getenv () +function returns a pointer to the value in the +environment, or null if there is no match. +.sh versions +.br secure_getenv () +first appeared in glibc 2.17. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br getenv (), +.br secure_getenv () +t} thread safety mt-safe env +.te +.hy +.ad +.sp 1 +.sh conforming to +.br getenv (): +posix.1-2001, posix.1-2008, c89, c99, svr4, 4.3bsd. +.pp +.br secure_getenv () +is a gnu extension. +.sh notes +the strings in the environment list are of the form \finame=value\fp. +.pp +as typically implemented, +.br getenv () +returns a pointer to a string within the environment list. +the caller must take care not to modify this string, +since that would change the environment of the process. +.pp +the implementation of +.br getenv () +is not required to be reentrant. +the string pointed to by the return value of +.br getenv () +may be statically allocated, +and can be modified by a subsequent call to +.br getenv (), +.br putenv (3), +.br setenv (3), +or +.br unsetenv (3). +.pp +the "secure execution" mode of +.br secure_getenv () +is controlled by the +.b at_secure +flag contained in the auxiliary vector passed from the kernel to user space. +.sh see also +.br clearenv (3), +.br getauxval (3), +.br putenv (3), +.br setenv (3), +.br unsetenv (3), +.br capabilities (7), +.br environ (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/fts.3 + +.\" copyright (c) 2007 michael kerrisk +.\" with some input from stepan kasal +.\" +.\" some content retained from an earlier version of this page: +.\" copyright (c) 1998 andries brouwer (aeb@cwi.nl) +.\" modifications for 2.2 and 2.4 copyright (c) 2002 ian redfern +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th syscalls 2 2021-08-27 "linux" "linux programmer's manual" +.sh name +syscalls \- linux system calls +.sh synopsis +.nf +linux system calls. +.fi +.sh description +the system call is the fundamental interface between an application +and the linux kernel. +.ss system calls and library wrapper functions +system calls are generally not invoked directly, +but rather via wrapper functions in glibc (or perhaps some other library). +for details of direct invocation of a system call, see +.br intro (2). +often, but not always, the name of the wrapper function is the same +as the name of the system call that it invokes. +for example, glibc contains a function +.br chdir () +which invokes the underlying "chdir" system call. +.pp +often the glibc wrapper function is quite thin, doing little work +other than copying arguments to the right registers +before invoking the system call, +and then setting +.i errno +appropriately after the system call has returned. +(these are the same steps that are performed by +.br syscall (2), +which can be used to invoke system calls +for which no wrapper function is provided.) +note: system calls indicate a failure by returning a negative error +number to the caller on architectures without a separate error register/flag, +as noted in +.br syscall (2); +when this happens, +the wrapper function negates the returned error number +(to make it positive), copies it to +.ir errno , +and returns \-1 to the caller of the wrapper. +.pp +sometimes, however, the wrapper function does some extra work +before invoking the system call. +for example, nowadays there are (for reasons described below) two +related system calls, +.br truncate (2) +and +.br truncate64 (2), +and the glibc +.br truncate () +wrapper function checks which of those system calls +are provided by the kernel and determines which should be employed. +.ss system call list +below is a list of the linux system calls. +in the list, the +.i kernel +column indicates the kernel version +for those system calls that were new in linux 2.2, +or have appeared since that kernel version. +note the following points: +.ip * 3 +where no kernel version is indicated, +the system call appeared in kernel 1.0 or earlier. +.ip * +where a system call is marked "1.2" +this means the system call probably appeared in a 1.1.x kernel version, +and first appeared in a stable kernel with 1.2. +(development of the 1.2 kernel was initiated from a branch of kernel +1.0.6 via the 1.1.x unstable kernel series.) +.ip * +where a system call is marked "2.0" +this means the system call probably appeared in a 1.3.x kernel version, +and first appeared in a stable kernel with 2.0. +(development of the 2.0 kernel was initiated from a branch of kernel +1.2.x, somewhere around 1.2.10, +via the 1.3.x unstable kernel series.) +.\" was kernel 2.0 started from a branch of 1.2.10? +.\" at least from the timestamps of the tarballs of +.\" of 1.2.10 and 1.3.0, that's how it looks, but in +.\" fact the diff doesn't seem very clear, the +.\" 1.3.0 .tar.bz is much bigger (2.0 mb) than the +.\" 1.2.10 .tar.bz2 (1.8 mb), and aeb points out the +.\" timestamps of some files in 1.3.0 seem to be older +.\" than those in 1.2.10. all of this suggests +.\" that there might not have been a clean branch point. +.ip * +where a system call is marked "2.2" +this means the system call probably appeared in a 2.1.x kernel version, +and first appeared in a stable kernel with 2.2.0. +(development of the 2.2 kernel was initiated from a branch of kernel +2.0.21 via the 2.1.x unstable kernel series.) +.ip * +where a system call is marked "2.4" +this means the system call probably appeared in a 2.3.x kernel version, +and first appeared in a stable kernel with 2.4.0. +(development of the 2.4 kernel was initiated from a branch of +kernel 2.2.8 via the 2.3.x unstable kernel series.) +.ip * +where a system call is marked "2.6" +this means the system call probably appeared in a 2.5.x kernel version, +and first appeared in a stable kernel with 2.6.0. +(development of kernel 2.6 was initiated from a branch +of kernel 2.4.15 via the 2.5.x unstable kernel series.) +.ip * +starting with kernel 2.6.0, the development model changed, +and new system calls may appear in each 2.6.x release. +in this case, the exact version number where the system call appeared +is shown. +this convention continues with the 3.x kernel series, +which followed on from kernel 2.6.39; and the 4.x kernel series, +which followed on from kernel 3.19; and the 5.x kernel series, +which followed on from kernel 4.20. +.ip * +in some cases, a system call was added to a stable kernel +series after it branched from the previous stable kernel +series, and then backported into the earlier stable kernel series. +for example some system calls that appeared in 2.6.x were also backported +into a 2.4.x release after 2.4.15. +when this is so, the version where the system call appeared +in both of the major kernel series is listed. +.pp +the list of system calls that are available as at kernel 5.11 +(or in a few cases only on older kernels) is as follows: +.\" +.\" looking at scripts/checksyscalls.sh in the kernel source is +.\" instructive about x86 specifics. +.\" +.nh +.ad l +.ts +l2 le l +--- +l l l. +\fbsystem call\fp \fbkernel\fp \fbnotes\fp + +\fb_llseek\fp(2) 1.2 +\fb_newselect\fp(2) 2.0 +\fb_sysctl\fp(2) 2.0 removed in 5.5 +\fbaccept\fp(2) 2.0 t{ +see notes on \fbsocketcall\fp(2) +t} +\fbaccept4\fp(2) 2.6.28 +\fbaccess\fp(2) 1.0 +\fbacct\fp(2) 1.0 +\fbadd_key\fp(2) 2.6.10 +\fbadjtimex\fp(2) 1.0 +\fbalarm\fp(2) 1.0 +\fballoc_hugepages\fp(2) 2.5.36 removed in 2.5.44 +.\" 4adeefe161a74369e44cc8e663f240ece0470dc3 +\fbarc_gettls\fp(2) 3.9 arc only +\fbarc_settls\fp(2) 3.9 arc only +.\" 91e040a79df73d371f70792f30380d4e44805250 +\fbarc_usr_cmpxchg\fp(2) 4.9 arc only +.\" x86: 79170fda313ed5be2394f87aa2a00d597f8ed4a1 +\fbarch_prctl\fp(2) 2.6 t{ +x86_64, x86 since 4.12 +t} +.\" 9674cdc74d63f346870943ef966a034f8c71ee57 +\fbatomic_barrier\fp(2) 2.6.34 m68k only +\fbatomic_cmpxchg_32\fp(2) 2.6.34 m68k only +\fbbdflush\fp(2) 1.2 t{ +deprecated (does nothing) +since 2.6 +t} +\fbbind\fp(2) 2.0 t{ +see notes on \fbsocketcall\fp(2) +t} +\fbbpf\fp(2) 3.18 +\fbbrk\fp(2) 1.0 +\fbbreakpoint\fp(2) 2.2 t{ +arm oabi only, defined with +\fb__arm_nr\fp prefix +t} +\fbcacheflush\fp(2) 1.2 not on x86 +\fbcapget\fp(2) 2.2 +\fbcapset\fp(2) 2.2 +\fbchdir\fp(2) 1.0 +\fbchmod\fp(2) 1.0 +\fbchown\fp(2) 2.2 t{ +see \fbchown\fp(2) for +version details +t} +\fbchown32\fp(2) 2.4 +\fbchroot\fp(2) 1.0 +\fbclock_adjtime\fp(2) 2.6.39 +\fbclock_getres\fp(2) 2.6 +\fbclock_gettime\fp(2) 2.6 +\fbclock_nanosleep\fp(2) 2.6 +\fbclock_settime\fp(2) 2.6 +\fbclone2\fp(2) 2.4 ia-64 only +\fbclone\fp(2) 1.0 +\fbclone3\fp(2) 5.3 +\fbclose\fp(2) 1.0 +\fbclose_range\fp(2) 5.9 +.\" .\" dcef1f634657dabe7905af3ccda12cf7f0b6fcc1 +.\" .\" cc20d42986d5807cbe4f5c7c8e3dab2e59ea0db3 +.\" .\" db695c0509d6ec9046ee5e4c520a19fa17d9fce2 +.\" \fbcmpxchg\fp(2) 2.6.12 t{ +.\" arm, syscall constant never was +.\" exposed to user space, in-kernel +.\" definition had \fb__arm_nr\fp prefix, +.\" removed in 4.4 +.\" t} +.\" 867e359b97c970a60626d5d76bbe2a8fadbf38fb +.\" bb9d812643d8a121df7d614a2b9c60193a92deb0 +\fbconnect\fp(2) 2.0 t{ +see notes on \fbsocketcall\fp(2) +t} +\fbcopy_file_range\fp(2) 4.5 +\fbcreat\fp(2) 1.0 +\fbcreate_module\fp(2) 1.0 removed in 2.6 +\fbdelete_module\fp(2) 1.0 +.\" 1394f03221790a988afc3e4b3cb79f2e477246a9 +.\" 4ba66a9760722ccbb691b8f7116cad2f791cca7b +\fbdup\fp(2) 1.0 +\fbdup2\fp(2) 1.0 +\fbdup3\fp(2) 2.6.27 +\fbepoll_create\fp(2) 2.6 +\fbepoll_create1\fp(2) 2.6.27 +\fbepoll_ctl\fp(2) 2.6 +\fbepoll_pwait\fp(2) 2.6.19 +\fbepoll_pwait2\fp(2) 5.11 +\fbepoll_wait\fp(2) 2.6 +\fbeventfd\fp(2) 2.6.22 +\fbeventfd2\fp(2) 2.6.27 +\fbexecv\fp(2) 2.0 t{ +sparc/sparc64 only, for +compatibility with sunos +t} +\fbexecve\fp(2) 1.0 +\fbexecveat\fp(2) 3.19 +\fbexit\fp(2) 1.0 +\fbexit_group\fp(2) 2.6 +\fbfaccessat\fp(2) 2.6.16 +\fbfaccessat2\fp(2) 5.8 +\fbfadvise64\fp(2) 2.6 +.\" implements \fbposix_fadvise\fp(2) +\fbfadvise64_64\fp(2) 2.6 +\fbfallocate\fp(2) 2.6.23 +\fbfanotify_init\fp(2) 2.6.37 +\fbfanotify_mark\fp(2) 2.6.37 +.\" the fanotify calls were added in linux 2.6.36, +.\" but disabled while the api was finalized. +\fbfchdir\fp(2) 1.0 +\fbfchmod\fp(2) 1.0 +\fbfchmodat\fp(2) 2.6.16 +\fbfchown\fp(2) 1.0 +\fbfchown32\fp(2) 2.4 +\fbfchownat\fp(2) 2.6.16 +\fbfcntl\fp(2) 1.0 +\fbfcntl64\fp(2) 2.4 +\fbfdatasync\fp(2) 2.0 +\fbfgetxattr\fp(2) 2.6; 2.4.18 +\fbfinit_module\fp(2) 3.8 +\fbflistxattr\fp(2) 2.6; 2.4.18 +\fbflock\fp(2) 2.0 +\fbfork\fp(2) 1.0 +\fbfree_hugepages\fp(2) 2.5.36 removed in 2.5.44 +\fbfremovexattr\fp(2) 2.6; 2.4.18 +\fbfsconfig\fp(2) 5.2 +\fbfsetxattr\fp(2) 2.6; 2.4.18 +\fbfsmount\fp(2) 5.2 +\fbfsopen\fp(2) 5.2 +\fbfspick\fp(2) 5.2 +\fbfstat\fp(2) 1.0 +\fbfstat64\fp(2) 2.4 +\fbfstatat64\fp(2) 2.6.16 +\fbfstatfs\fp(2) 1.0 +\fbfstatfs64\fp(2) 2.6 +\fbfsync\fp(2) 1.0 +\fbftruncate\fp(2) 1.0 +\fbftruncate64\fp(2) 2.4 +\fbfutex\fp(2) 2.6 +\fbfutimesat\fp(2) 2.6.16 +\fbget_kernel_syms\fp(2) 1.0 removed in 2.6 +\fbget_mempolicy\fp(2) 2.6.6 +\fbget_robust_list\fp(2) 2.6.17 +\fbget_thread_area\fp(2) 2.6 +.\" 8fcd6c45f5a65621ec809b7866a3623e9a01d4ed +\fbget_tls\fp(2) 4.15 t{ +arm oabi only, has +\fb__arm_nr\fp prefix +t} +\fbgetcpu\fp(2) 2.6.19 +\fbgetcwd\fp(2) 2.2 +\fbgetdents\fp(2) 2.0 +\fbgetdents64\fp(2) 2.4 +.\" parisc: 863722e856e64dae0e252b6bb546737c6c5626ce +\fbgetdomainname\fp(2) 2.2 t{ +sparc, sparc64; available +as \fbosf_getdomainname\fp(2) +on alpha since linux 2.0 +t} +.\" ec98c6b9b47df6df1c1fa6cf3d427414f8c2cf16 +\fbgetdtablesize\fp(2) 2.0 t{ +sparc (removed in 2.6.26), +available on alpha as +\fbosf_getdtablesize\fp(2) +t} +\fbgetegid\fp(2) 1.0 +\fbgetegid32\fp(2) 2.4 +\fbgeteuid\fp(2) 1.0 +\fbgeteuid32\fp(2) 2.4 +\fbgetgid\fp(2) 1.0 +\fbgetgid32\fp(2) 2.4 +\fbgetgroups\fp(2) 1.0 +\fbgetgroups32\fp(2) 2.4 +.\" sparc removal: ec98c6b9b47df6df1c1fa6cf3d427414f8c2cf16 +\fbgethostname\fp(2) 2.0 t{ +alpha, was available on +sparc up to linux 2.6.26 +t} +\fbgetitimer\fp(2) 1.0 +\fbgetpeername\fp(2) 2.0 t{ +see notes on \fbsocketcall\fp(2) +t} +\fbgetpagesize\fp(2) 2.0 not on x86 +\fbgetpgid\fp(2) 1.0 +\fbgetpgrp\fp(2) 1.0 +\fbgetpid\fp(2) 1.0 +\fbgetppid\fp(2) 1.0 +\fbgetpriority\fp(2) 1.0 +\fbgetrandom\fp(2) 3.17 +\fbgetresgid\fp(2) 2.2 +\fbgetresgid32\fp(2) 2.4 +\fbgetresuid\fp(2) 2.2 +\fbgetresuid32\fp(2) 2.4 +\fbgetrlimit\fp(2) 1.0 +\fbgetrusage\fp(2) 1.0 +\fbgetsid\fp(2) 2.0 +\fbgetsockname\fp(2) 2.0 t{ +see notes on \fbsocketcall\fp(2) +t} +\fbgetsockopt\fp(2) 2.0 t{ +see notes on \fbsocketcall\fp(2) +t} +\fbgettid\fp(2) 2.4.11 +\fbgettimeofday\fp(2) 1.0 +\fbgetuid\fp(2) 1.0 +\fbgetuid32\fp(2) 2.4 +\fbgetunwind\fp(2) 2.4.8 t{ +ia-64 only; deprecated +t} +\fbgetxattr\fp(2) 2.6; 2.4.18 +\fbgetxgid\fp(2) 2.0 t{ +alpha only; see notes +t} +\fbgetxpid\fp(2) 2.0 t{ +alpha only; see notes +t} +\fbgetxuid\fp(2) 2.0 t{ +alpha only; see notes +t} +\fbinit_module\fp(2) 1.0 +\fbinotify_add_watch\fp(2) 2.6.13 +\fbinotify_init\fp(2) 2.6.13 +\fbinotify_init1\fp(2) 2.6.27 +\fbinotify_rm_watch\fp(2) 2.6.13 +\fbio_cancel\fp(2) 2.6 +\fbio_destroy\fp(2) 2.6 +\fbio_getevents\fp(2) 2.6 +\fbio_pgetevents\fp(2) 4.18 +\fbio_setup\fp(2) 2.6 +\fbio_submit\fp(2) 2.6 +\fbio_uring_enter\fp(2) 5.1 +\fbio_uring_register\fp(2) 5.1 +\fbio_uring_setup\fp(2) 5.1 +\fbioctl\fp(2) 1.0 +\fbioperm\fp(2) 1.0 +\fbiopl\fp(2) 1.0 +\fbioprio_get\fp(2) 2.6.13 +\fbioprio_set\fp(2) 2.6.13 +\fbipc\fp(2) 1.0 +.\" implements system v ipc calls +\fbkcmp\fp(2) 3.5 +\fbkern_features\fp(2) 3.7 sparc64 only +.\" fixme . document kern_features(): +.\" commit 517ffce4e1a03aea979fe3a18a3dd1761a24fafb +\fbkexec_file_load\fp(2) 3.17 +\fbkexec_load\fp(2) 2.6.13 +.\" the entry in the syscall table was reserved starting in 2.6.7 +.\" was named sys_kexec_load() from 2.6.7 to 2.6.16 +\fbkeyctl\fp(2) 2.6.10 +\fbkill\fp(2) 1.0 +\fblandlock_add_rule\fp(2) 5.13 +\fblandlock_create_ruleset\fp(2) 5.13 +\fblandlock_restrict_self\fp(2) 5.13 +\fblandlock_add_rule\fp(2) 5.13 +\fblchown\fp(2) 1.0 t{ +see \fbchown\fp(2) for +version details +t} +\fblchown32\fp(2) 2.4 +\fblgetxattr\fp(2) 2.6; 2.4.18 +\fblink\fp(2) 1.0 +\fblinkat\fp(2) 2.6.16 +\fblisten\fp(2) 2.0 t{ +see notes on \fbsocketcall\fp(2) +t} +\fblistxattr\fp(2) 2.6; 2.4.18 +\fbllistxattr\fp(2) 2.6; 2.4.18 +\fblookup_dcookie\fp(2) 2.6 +\fblremovexattr\fp(2) 2.6; 2.4.18 +\fblseek\fp(2) 1.0 +\fblsetxattr\fp(2) 2.6; 2.4.18 +\fblstat\fp(2) 1.0 +\fblstat64\fp(2) 2.4 +\fbmadvise\fp(2) 2.4 +\fbmbind\fp(2) 2.6.6 +\fbmemory_ordering\fp(2) 2.2 sparc64 only +.\" 26025bbfbba33a9425be1b89eccb4664ea4c17b6 +.\" bb6fb6dfcc17cddac11ac295861f7608194447a7 +\fbmembarrier\fp(2) 3.17 +\fbmemfd_create\fp(2) 3.17 +\fbmigrate_pages\fp(2) 2.6.16 +\fbmincore\fp(2) 2.4 +\fbmkdir\fp(2) 1.0 +\fbmkdirat\fp(2) 2.6.16 +\fbmknod\fp(2) 1.0 +\fbmknodat\fp(2) 2.6.16 +\fbmlock\fp(2) 2.0 +\fbmlock2\fp(2) 4.4 +\fbmlockall\fp(2) 2.0 +\fbmmap\fp(2) 1.0 +\fbmmap2\fp(2) 2.4 +\fbmodify_ldt\fp(2) 1.0 +\fbmount\fp(2) 1.0 +\fbmove_mount\fp(2) 5.2 +\fbmove_pages\fp(2) 2.6.18 +\fbmprotect\fp(2) 1.0 +\fbmq_getsetattr\fp(2) 2.6.6 +.\" implements \fbmq_getattr\fp(3) and \fbmq_setattr\fp(3) +\fbmq_notify\fp(2) 2.6.6 +\fbmq_open\fp(2) 2.6.6 +\fbmq_timedreceive\fp(2) 2.6.6 +\fbmq_timedsend\fp(2) 2.6.6 +\fbmq_unlink\fp(2) 2.6.6 +\fbmremap\fp(2) 2.0 +\fbmsgctl\fp(2) 2.0 t{ +see notes on \fbipc\fp(2) +t} +\fbmsgget\fp(2) 2.0 t{ +see notes on \fbipc\fp(2) +t} +\fbmsgrcv\fp(2) 2.0 t{ +see notes on \fbipc\fp(2) +t} +\fbmsgsnd\fp(2) 2.0 t{ +see notes on \fbipc\fp(2) +t} +\fbmsync\fp(2) 2.0 +.\" \fbmultiplexer\fp(2) ?? __nr_multiplexer reserved on +.\" powerpc, but unimplemented? +\fbmunlock\fp(2) 2.0 +\fbmunlockall\fp(2) 2.0 +\fbmunmap\fp(2) 1.0 +\fbname_to_handle_at\fp(2) 2.6.39 +\fbnanosleep\fp(2) 2.0 +.\" 5590ff0d5528b60153c0b4e7b771472b5a95e297 +\fbnewfstatat\fp(2) 2.6.16 see \fbstat\fp(2) +\fbnfsservctl\fp(2) 2.2 removed in 3.1 +\fbnice\fp(2) 1.0 +\fbold_adjtimex\fp(2) 2.0 t{ +alpha only; see notes +t} +\fbold_getrlimit\fp(2) 2.4 t{ +old variant of \fbgetrlimit\fp(2) +that used a different value +for \fbrlim_infinity\fp +t} +\fboldfstat\fp(2) 1.0 +\fboldlstat\fp(2) 1.0 +\fboldolduname\fp(2) 1.0 +\fboldstat\fp(2) 1.0 +\fboldumount\fp(2) 2.4.116 t{ +name of the old \fbumount\fp(2) +syscall on alpha +t} +\fbolduname\fp(2) 1.0 +\fbopen\fp(2) 1.0 +\fbopen_by_handle_at\fp(2) 2.6.39 +\fbopen_tree\fp(2) 5.2 +\fbopenat\fp(2) 2.6.16 +\fbopenat2\fp(2) 5.6 +.\" 9d02a4283e9ce4e9ca11ff00615bdacdb0515a1a +\fbor1k_atomic\fp(2) 3.1 t{ +openrisc 1000 only +t} +\fbpause\fp(2) 1.0 +\fbpciconfig_iobase\fp(2) 2.2.15; 2.4 not on x86 +.\" alpha, powerpc, arm; not x86 +\fbpciconfig_read\fp(2) 2.0.26; 2.2 not on x86 +.\" , powerpc, arm; not x86 +\fbpciconfig_write\fp(2) 2.0.26; 2.2 not on x86 +.\" , powerpc, arm; not x86 +\fbperf_event_open\fp(2) 2.6.31 t{ +was perf_counter_open() in +2.6.31; renamed in 2.6.32 +t} +\fbpersonality\fp(2) 1.2 +\fbperfctr\fp(2) 2.2 t{ +sparc only; removed in 2.6.34 +t} +.\" commit c7d5a0050773e98d1094eaa9f2a1a793fafac300 removed perfctr() +\fbperfmonctl\fp(2) 2.4 ia-64 only; removed in 5.10 +\fbpidfd_getfd\fp(2) 5.6 +\fbpidfd_send_signal\fp(2) 5.1 +\fbpidfd_open\fp(2) 5.3 +\fbpipe\fp(2) 1.0 +\fbpipe2\fp(2) 2.6.27 +\fbpivot_root\fp(2) 2.4 +\fbpkey_alloc\fp(2) 4.8 +\fbpkey_free\fp(2) 4.8 +\fbpkey_mprotect\fp(2) 4.8 +\fbpoll\fp(2) 2.0.36; 2.2 +\fbppoll\fp(2) 2.6.16 +\fbprctl\fp(2) 2.2 +\fbpread64\fp(2) t{ +added as "pread" in 2.2; +renamed "pread64" in 2.6 +t} +\fbpreadv\fp(2) 2.6.30 +\fbpreadv2\fp(2) 4.6 +\fbprlimit64\fp(2) 2.6.36 +\fbprocess_madvise\fp(2) 5.10 +\fbprocess_vm_readv\fp(2) 3.2 +\fbprocess_vm_writev\fp(2) 3.2 +\fbpselect6\fp(2) 2.6.16 +.\" implements \fbpselect\fp(2) +\fbptrace\fp(2) 1.0 +\fbpwrite64\fp(2) t{ +added as "pwrite" in 2.2; +renamed "pwrite64" in 2.6 +t} +\fbpwritev\fp(2) 2.6.30 +\fbpwritev2\fp(2) 4.6 +\fbquery_module\fp(2) 2.2 removed in 2.6 +\fbquotactl\fp(2) 1.0 +\fbquotactl_fd\fp(2) 5.14 +\fbread\fp(2) 1.0 +\fbreadahead\fp(2) 2.4.13 +\fbreaddir\fp(2) 1.0 +.\" supersedes \fbgetdents\fp(2) +\fbreadlink\fp(2) 1.0 +\fbreadlinkat\fp(2) 2.6.16 +\fbreadv\fp(2) 2.0 +\fbreboot\fp(2) 1.0 +\fbrecv\fp(2) 2.0 t{ +see notes on \fbsocketcall\fp(2) +t} +\fbrecvfrom\fp(2) 2.0 t{ +see notes on \fbsocketcall\fp(2) +t} +\fbrecvmsg\fp(2) 2.0 t{ +see notes on \fbsocketcall\fp(2) +t} +\fbrecvmmsg\fp(2) 2.6.33 +\fbremap_file_pages\fp(2) 2.6 t{ +deprecated since 3.16 +t} +\fbremovexattr\fp(2) 2.6; 2.4.18 +\fbrename\fp(2) 1.0 +\fbrenameat\fp(2) 2.6.16 +\fbrenameat2\fp(2) 3.15 +\fbrequest_key\fp(2) 2.6.10 +\fbrestart_syscall\fp(2) 2.6 +.\" 921ebd8f2c081b3cf6c3b29ef4103eef3ff26054 +\fbriscv_flush_icache\fp(2) 4.15 risc-v only +\fbrmdir\fp(2) 1.0 +\fbrseq\fp(2) 4.18 +\fbrt_sigaction\fp(2) 2.2 +\fbrt_sigpending\fp(2) 2.2 +\fbrt_sigprocmask\fp(2) 2.2 +\fbrt_sigqueueinfo\fp(2) 2.2 +\fbrt_sigreturn\fp(2) 2.2 +\fbrt_sigsuspend\fp(2) 2.2 +\fbrt_sigtimedwait\fp(2) 2.2 +\fbrt_tgsigqueueinfo\fp(2) 2.6.31 +\fbrtas\fp(2) 2.6.2 t{ +powerpc/powerpc64 only +t} +\fbs390_runtime_instr\fp(2) 3.7 s390 only +\fbs390_pci_mmio_read\fp(2) 3.19 s390 only +\fbs390_pci_mmio_write\fp(2) 3.19 s390 only +\fbs390_sthyi\fp(2) 4.15 s390 only +\fbs390_guarded_storage\fp(2) 4.12 s390 only +\fbsched_get_affinity\fp(2) 2.6 t{ +name of \fbsched_getaffinity\fp(2) +on sparc and sparc64 +t} +\fbsched_get_priority_max\fp(2) 2.0 +\fbsched_get_priority_min\fp(2) 2.0 +\fbsched_getaffinity\fp(2) 2.6 +\fbsched_getattr\fp(2) 3.14 +\fbsched_getparam\fp(2) 2.0 +\fbsched_getscheduler\fp(2) 2.0 +\fbsched_rr_get_interval\fp(2) 2.0 +\fbsched_set_affinity\fp(2) 2.6 t{ +name of \fbsched_setaffinity\fp(2) +on sparc and sparc64 +t} +\fbsched_setaffinity\fp(2) 2.6 +\fbsched_setattr\fp(2) 3.14 +\fbsched_setparam\fp(2) 2.0 +\fbsched_setscheduler\fp(2) 2.0 +\fbsched_yield\fp(2) 2.0 +\fbseccomp\fp(2) 3.17 +\fbselect\fp(2) 1.0 +\fbsemctl\fp(2) 2.0 t{ +see notes on \fbipc\fp(2) +t} +\fbsemget\fp(2) 2.0 t{ +see notes on \fbipc\fp(2) +t} +\fbsemop\fp(2) 2.0 t{ +see notes on \fbipc\fp(2) +t} +\fbsemtimedop\fp(2) 2.6; 2.4.22 +\fbsend\fp(2) 2.0 t{ +see notes on \fbsocketcall\fp(2) +t} +\fbsendfile\fp(2) 2.2 +\fbsendfile64\fp(2) 2.6; 2.4.19 +\fbsendmmsg\fp(2) 3.0 +\fbsendmsg\fp(2) 2.0 t{ +see notes on \fbsocketcall\fp(2) +t} +\fbsendto\fp(2) 2.0 t{ +see notes on \fbsocketcall\fp(2) +t} +\fbset_mempolicy\fp(2) 2.6.6 +\fbset_robust_list\fp(2) 2.6.17 +\fbset_thread_area\fp(2) 2.6 +\fbset_tid_address\fp(2) 2.6 +\fbset_tls\fp(2) 2.6.11 t{ +arm oabi/eabi only (constant +has \fb__arm_nr\fp prefix) +t} +.\" \fbsetaltroot\fp(2) 2.6.10 t{ +.\" removed in 2.6.11, exposed one +.\" of implementation details of +.\" \fbpersonality\fp(2) (creating an +.\" alternative root, precursor of +.\" mount namespaces) to user space. +.\" t} +.\" see http://lkml.org/lkml/2005/8/1/83 +.\" "[patch] remove sys_set_zone_reclaim()" +\fbsetdomainname\fp(2) 1.0 +\fbsetfsgid\fp(2) 1.2 +\fbsetfsgid32\fp(2) 2.4 +\fbsetfsuid\fp(2) 1.2 +\fbsetfsuid32\fp(2) 2.4 +\fbsetgid\fp(2) 1.0 +\fbsetgid32\fp(2) 2.4 +\fbsetgroups\fp(2) 1.0 +\fbsetgroups32\fp(2) 2.4 +.\" arch/alpha/include/asm/core_lca.h +\fbsethae\fp(2) 2.0 t{ +alpha only; see notes +t} +\fbsethostname\fp(2) 1.0 +\fbsetitimer\fp(2) 1.0 +\fbsetns\fp(2) 3.0 +\fbsetpgid\fp(2) 1.0 +\fbsetpgrp\fp(2) 2.0 t{ +alternative name for +\fbsetpgid\fp(2) on alpha +t} +\fbsetpriority\fp(2) 1.0 +\fbsetregid\fp(2) 1.0 +\fbsetregid32\fp(2) 2.4 +\fbsetresgid\fp(2) 2.2 +\fbsetresgid32\fp(2) 2.4 +\fbsetresuid\fp(2) 2.2 +\fbsetresuid32\fp(2) 2.4 +\fbsetreuid\fp(2) 1.0 +\fbsetreuid32\fp(2) 2.4 +\fbsetrlimit\fp(2) 1.0 +\fbsetsid\fp(2) 1.0 +\fbsetsockopt\fp(2) 2.0 t{ +see notes on \fbsocketcall\fp(2) +t} +\fbsettimeofday\fp(2) 1.0 +\fbsetuid\fp(2) 1.0 +\fbsetuid32\fp(2) 2.4 +\fbsetup\fp(2) 1.0 removed in 2.2 +\fbsetxattr\fp(2) 2.6; 2.4.18 +\fbsgetmask\fp(2) 1.0 +\fbshmat\fp(2) 2.0 t{ +see notes on \fbipc\fp(2) +t} +\fbshmctl\fp(2) 2.0 t{ +see notes on \fbipc\fp(2) +t} +\fbshmdt\fp(2) 2.0 t{ +see notes on \fbipc\fp(2) +t} +\fbshmget\fp(2) 2.0 t{ +see notes on \fbipc\fp(2) +t} +\fbshutdown\fp(2) 2.0 t{ +see notes on \fbsocketcall\fp(2) +t} +\fbsigaction\fp(2) 1.0 +\fbsigaltstack\fp(2) 2.2 +\fbsignal\fp(2) 1.0 +\fbsignalfd\fp(2) 2.6.22 +\fbsignalfd4\fp(2) 2.6.27 +\fbsigpending\fp(2) 1.0 +\fbsigprocmask\fp(2) 1.0 +\fbsigreturn\fp(2) 1.0 +\fbsigsuspend\fp(2) 1.0 +\fbsocket\fp(2) 2.0 t{ +see notes on \fbsocketcall\fp(2) +t} +\fbsocketcall\fp(2) 1.0 +.\" implements bsd socket calls +\fbsocketpair\fp(2) 2.0 t{ +see notes on \fbsocketcall\fp(2) +t} +.\" 5a0015d62668e64c8b6e02e360fbbea121bfd5e6 +\fbspill\fp(2) 2.6.13 xtensa only +\fbsplice\fp(2) 2.6.17 +\fbspu_create\fp(2) 2.6.16 t{ +powerpc/powerpc64 only +t} +\fbspu_run\fp(2) 2.6.16 t{ +powerpc/powerpc64 only +t} +\fbssetmask\fp(2) 1.0 +\fbstat\fp(2) 1.0 +\fbstat64\fp(2) 2.4 +\fbstatfs\fp(2) 1.0 +\fbstatfs64\fp(2) 2.6 +\fbstatx\fp(2) 4.11 +\fbstime\fp(2) 1.0 +\fbsubpage_prot\fp(2) 2.6.25 t{ +powerpc/powerpc64 only +t} +\fbswapcontext\fp(2) 2.6.3 t{ +powerpc/powerpc64 only +t} +.\" 529d235a0e190ded1d21ccc80a73e625ebcad09b +\fbswitch_endian\fp(2) 4.1 powerpc64 only +\fbswapoff\fp(2) 1.0 +\fbswapon\fp(2) 1.0 +\fbsymlink\fp(2) 1.0 +\fbsymlinkat\fp(2) 2.6.16 +\fbsync\fp(2) 1.0 +\fbsync_file_range\fp(2) 2.6.17 +\fbsync_file_range2\fp(2) 2.6.22 +.\" powerpc, arm, tile +.\" first appeared on arm, as arm_sync_file_range(), but later renamed +.\" \fbsys_debug_setcontext\fp(2) ??? powerpc if config_ppc32 +\fbsyncfs\fp(2) 2.6.39 +\fbsys_debug_setcontext\fp(2) 2.6.11 powerpc only +\fbsyscall\fp(2) 1.0 t{ +still available on arm oabi +and mips o32 abi +t} +\fbsysfs\fp(2) 1.2 +\fbsysinfo\fp(2) 1.0 +\fbsyslog\fp(2) 1.0 +.\" glibc interface is \fbklogctl\fp(3) +\fbsysmips\fp(2) 2.6.0 mips only +\fbtee\fp(2) 2.6.17 +\fbtgkill\fp(2) 2.6 +\fbtime\fp(2) 1.0 +\fbtimer_create\fp(2) 2.6 +\fbtimer_delete\fp(2) 2.6 +\fbtimer_getoverrun\fp(2) 2.6 +\fbtimer_gettime\fp(2) 2.6 +\fbtimer_settime\fp(2) 2.6 +.\" .\" b215e283992899650c4271e7385c79e26fb9a88e +.\" .\" 4d672e7ac79b5ec5cdc90e450823441e20464691 +.\" \fbtimerfd\fp(2) 2.6.22 t{ +.\" old timerfd interface, +.\" removed in 2.6.25 +.\" t} +\fbtimerfd_create\fp(2) 2.6.25 +\fbtimerfd_gettime\fp(2) 2.6.25 +\fbtimerfd_settime\fp(2) 2.6.25 +\fbtimes\fp(2) 1.0 +\fbtkill\fp(2) 2.6; 2.4.22 +\fbtruncate\fp(2) 1.0 +\fbtruncate64\fp(2) 2.4 +\fbugetrlimit\fp(2) 2.4 +\fbumask\fp(2) 1.0 +\fbumount\fp(2) 1.0 +.\" sys_oldumount() -- __nr_umount +\fbumount2\fp(2) 2.2 +.\" sys_umount() -- __nr_umount2 +\fbuname\fp(2) 1.0 +\fbunlink\fp(2) 1.0 +\fbunlinkat\fp(2) 2.6.16 +\fbunshare\fp(2) 2.6.16 +\fbuselib\fp(2) 1.0 +\fbustat\fp(2) 1.0 +\fbuserfaultfd\fp(2) 4.3 +\fbusr26\fp(2) 2.4.8.1 arm oabi only +\fbusr32\fp(2) 2.4.8.1 arm oabi only +\fbutime\fp(2) 1.0 +\fbutimensat\fp(2) 2.6.22 +\fbutimes\fp(2) 2.2 +\fbutrap_install\fp(2) 2.2 sparc64 only +.\" fixme . document utrap_install() +.\" there's a man page for solaris 5.11 +\fbvfork\fp(2) 2.2 +\fbvhangup\fp(2) 1.0 +\fbvm86old\fp(2) 1.0 t{ +was "vm86"; renamed in +2.0.28/2.2 +t} +\fbvm86\fp(2) 2.0.28; 2.2 +\fbvmsplice\fp(2) 2.6.17 +\fbwait4\fp(2) 1.0 +\fbwaitid\fp(2) 2.6.10 +\fbwaitpid\fp(2) 1.0 +\fbwrite\fp(2) 1.0 +\fbwritev\fp(2) 2.0 +.\" 5a0015d62668e64c8b6e02e360fbbea121bfd5e6 +\fbxtensa\fp(2) 2.6.13 xtensa only +.te +.ad +.hy +.pp +on many platforms, including x86-32, socket calls are all multiplexed +(via glibc wrapper functions) through +.br socketcall (2) +and similarly system\ v ipc calls are multiplexed through +.br ipc (2). +.pp +although slots are reserved for them in the system call table, +the following system calls are not implemented in the standard kernel: +.br afs_syscall (2), \" __nr_afs_syscall is 53 on linux 2.6.22/i386 +.br break (2), \" __nr_break is 17 on linux 2.6.22/i386 +.br ftime (2), \" __nr_ftime is 35 on linux 2.6.22/i386 +.br getpmsg (2), \" __nr_getpmsg is 188 on linux 2.6.22/i386 +.br gtty (2), \" __nr_gtty is 32 on linux 2.6.22/i386 +.br idle (2), \" __nr_idle is 112 on linux 2.6.22/i386 +.br lock (2), \" __nr_lock is 53 on linux 2.6.22/i386 +.br madvise1 (2), \" __nr_madvise1 is 219 on linux 2.6.22/i386 +.br mpx (2), \" __nr_mpx is 66 on linux 2.6.22/i386 +.br phys (2), \" slot has been reused +.br prof (2), \" __nr_prof is 44 on linux 2.6.22/i386 +.br profil (2), \" __nr_profil is 98 on linux 2.6.22/i386 +.br putpmsg (2), \" __nr_putpmsg is 189 on linux 2.6.22/i386 +.\" __nr_security is 223 on linux 2.4/i386; absent on 2.6/i386, present +.\" on a couple of 2.6 architectures +.br security (2), \" __nr_security is 223 on linux 2.4/i386 +.\" the security call is for future use. +.br stty (2), \" __nr_stty is 31 on linux 2.6.22/i386 +.br tuxcall (2), \" __nr_tuxcall is 184 on x86_64, also on ppc and alpha +.br ulimit (2), \" __nr_ulimit is 58 on linux 2.6.22/i386 +and +.br vserver (2) \" __nr_vserver is 273 on linux 2.6.22/i386 +(see also +.br unimplemented (2)). +however, +.br ftime (3), +.br profil (3), +and +.br ulimit (3) +exist as library routines. +the slot for +.br phys (2) +is in use since kernel 2.1.116 for +.br umount (2); +.br phys (2) +will never be implemented. +the +.br getpmsg (2) +and +.br putpmsg (2) +calls are for kernels patched to support streams, +and may never be in the standard kernel. +.pp +there was briefly +.br set_zone_reclaim (2), +added in linux 2.6.13, and removed in 2.6.16; +this system call was never available to user space. +.\" +.ss system calls on removed ports +some system calls only ever existed on linux architectures that have +since been removed from the kernel: +.tp +avr32 (port removed in linux 4.12) +.rs +.pd 0 +.ip * 2 +.br pread (2) +.ip * +.br pwrite (2) +.pd +.re +.tp +blackfin (port removed in linux 4.17) +.rs +.pd 0 +.ip * 2 +.br bfin_spinlock (2) +(added in linux 2.6.22) +.ip * +.br dma_memcpy (2) +(added in linux 2.6.22) +.ip * +.br pread (2) +(added in linux 2.6.22) +.ip * +.br pwrite (2) +(added in linux 2.6.22) +.ip * +.br sram_alloc (2) +(added in linux 2.6.22) +.ip * +.br sram_free (2) +(added in linux 2.6.22) +.pd +.re +.tp +metag (port removed in linux 4.17) +.rs +.pd 0 +.ip * 2 +.br metag_get_tls (2) +(add in linux 3.9) +.ip * +.br metag_set_fpu_flags (2) +(add in linux 3.9) +.ip * +.br metag_set_tls (2) +(add in linux 3.9) +.ip * +.br metag_setglobalbit (2) +(add in linux 3.9) +.pd +.re +.tp +tile (port removed in linux 4.17) +.rs +.pd 0 +.ip * 2 +.br cmpxchg_badaddr (2) +(added in linux 2.6.36) +.pd +.re +.sh notes +roughly speaking, the code belonging to the system call +with number __nr_xxx defined in +.i /usr/include/asm/unistd.h +can be found in the linux kernel source in the routine +.ir sys_xxx (). +there are many exceptions, however, mostly because +older system calls were superseded by newer ones, +and this has been treated somewhat unsystematically. +on platforms with +proprietary operating-system emulation, +such as sparc, sparc64, and alpha, +there are many additional system calls; mips64 also contains a full +set of 32-bit system calls. +.pp +over time, changes to the interfaces of some system calls have been +necessary. +one reason for such changes was the need to increase the size of +structures or scalar values passed to the system call. +because of these changes, certain architectures +(notably, longstanding 32-bit architectures such as i386) +now have various groups of related system calls (e.g., +.br truncate (2) +and +.br truncate64 (2)) +which perform similar tasks, but which vary in +details such as the size of their arguments. +(as noted earlier, applications are generally unaware of this: +the glibc wrapper functions do some work to ensure that the right +system call is invoked, and that abi compatibility is +preserved for old binaries.) +examples of systems calls that exist in multiple versions are +the following: +.ip * 3 +by now there are three different versions of +.br stat (2): +.ir sys_stat () +(slot +.ir __nr_oldstat ), +.ir sys_newstat () +(slot +.ir __nr_stat ), +and +.ir sys_stat64 () +(slot +.ir __nr_stat64 ), +with the last being the most current. +.\" e.g., on 2.6.22/i386: __nr_oldstat 18, __nr_stat 106, __nr_stat64 195 +.\" the stat system calls deal with three different data structures, +.\" defined in include/asm-i386/stat.h: __old_kernel_stat, stat, stat64 +a similar story applies for +.br lstat (2) +and +.br fstat (2). +.ip * +similarly, the defines +.ir __nr_oldolduname , +.ir __nr_olduname , +and +.i __nr_uname +refer to the routines +.ir sys_olduname (), +.ir sys_uname (), +and +.ir sys_newuname (). +.ip * +in linux 2.0, a new version of +.br vm86 (2) +appeared, with the old and the new kernel routines being named +.ir sys_vm86old () +and +.ir sys_vm86 (). +.ip * +in linux 2.4, a new version of +.br getrlimit (2) +appeared, with the old and the new kernel routines being named +.ir sys_old_getrlimit () +(slot +.ir __nr_getrlimit ) +and +.ir sys_getrlimit () +(slot +.ir __nr_ugetrlimit ). +.ip * +linux 2.4 increased the size of user and group ids from 16 to 32 bits. +.\" 64-bit off_t changes: ftruncate64, *stat64, +.\" fcntl64 (because of the flock structure), getdents64, *statfs64 +to support this change, a range of system calls were added +(e.g., +.br chown32 (2), +.br getuid32 (2), +.br getgroups32 (2), +.br setresuid32 (2)), +superseding earlier calls of the same name without the +"32" suffix. +.ip * +linux 2.4 added support for applications on 32-bit architectures +to access large files (i.e., files for which the sizes and +file offsets can't be represented in 32 bits.) +to support this change, replacements were required for system calls +that deal with file offsets and sizes. +thus the following system calls were added: +.br fcntl64 (2), +.br getdents64 (2), +.br stat64 (2), +.br statfs64 (2), +.br truncate64 (2), +and their analogs that work with file descriptors or +symbolic links. +these system calls supersede the older system calls +which, except in the case of the "stat" calls, +have the same name without the "64" suffix. +.ip +on newer platforms that only have 64-bit file access and 32-bit uids/gids +(e.g., alpha, ia64, s390x, x86-64), there is just a single version of +the uid/gid and file access system calls. +on platforms (typically, 32-bit platforms) where the *64 and *32 calls exist, +the other versions are obsolete. +.ip * +the +.i rt_sig* +calls were added in kernel 2.2 to support the addition +of real-time signals (see +.br signal (7)). +these system calls supersede the older system calls of the same +name without the "rt_" prefix. +.ip * +the +.br select (2) +and +.br mmap (2) +system calls use five or more arguments, +which caused problems in the way +argument passing on the i386 used to be set up. +thus, while other architectures have +.ir sys_select () +and +.ir sys_mmap () +corresponding to +.i __nr_select +and +.ir __nr_mmap , +on i386 one finds +.ir old_select () +and +.ir old_mmap () +(routines that use a pointer to an +argument block) instead. +these days passing five arguments +is not a problem any more, and there is a +.i __nr__newselect +.\" (used by libc 6) +that corresponds directly to +.ir sys_select () +and similarly +.ir __nr_mmap2 . +s390x is the only 64-bit architecture that has +.ir old_mmap (). +.\" .pp +.\" two system call numbers, +.\" .ir __nr__llseek +.\" and +.\" .ir __nr__sysctl +.\" have an additional underscore absent in +.\" .ir sys_llseek () +.\" and +.\" .ir sys_sysctl (). +.\" +.\" in kernel 2.1.81, +.\" .br lchown (2) +.\" and +.\" .br chown (2) +.\" were swapped; that is, +.\" .br lchown (2) +.\" was added with the semantics that were then current for +.\" .br chown (2), +.\" and the semantics of the latter call were changed to what +.\" they are today. +.\" +.\" +.ss "architecture-specific details: alpha" +.ip * 3 +.br getxgid (2) +returns a pair of gid and effective gid via registers +\fbr0\fp and \fbr20\fp; it is provided +instead of +\fbgetgid\fp(2) and \fbgetegid\fp(2). +.ip * +.br getxpid (2) +returns a pair of pid and parent pid via registers +\fbr0\fp and \fbr20\fp; it is provided instead of +\fbgetpid\fp(2) and \fbgetppid\fp(2). +.ip * +.br old_adjtimex (2) +is a variant of \fbadjtimex\fp(2) that uses \fistruct timeval32\fp, +for compatibility with osf/1. +.ip * +.br getxuid (2) +returns a pair of gid and effective gid via registers +\fbr0\fp and \fbr20\fp; it is provided instead of +\fbgetuid\fp(2) and \fbgeteuid\fp(2). +.ip * +.br sethae (2) +is used for configuring the host address extension register on +low-cost alphas in order to access address space beyond first 27 bits. +.sh see also +.br ausyscall (1) +.br intro (2), +.br syscall (2), +.br unimplemented (2), +.br errno (3), +.br libc (7), +.br vdso (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" this man page is copyright (c) 1999 andi kleen . +.\" +.\" %%%license_start(verbatim_one_para) +.\" permission is granted to distribute possibly modified copies +.\" of this page provided the header is included verbatim, +.\" and in case of nontrivial modification author and date +.\" of the modification is added to the header. +.\" %%%license_end +.\" +.\" $id: cmsg.3,v 1.8 2000/12/20 18:10:31 ak exp $ +.th cmsg 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +cmsg_align, cmsg_space, cmsg_nxthdr, cmsg_firsthdr \- access ancillary data +.sh synopsis +.nf +.b #include +.pp +.bi "struct cmsghdr *cmsg_firsthdr(struct msghdr *" msgh ); +.bi "struct cmsghdr *cmsg_nxthdr(struct msghdr *" msgh , +.br " struct cmsghdr *" cmsg ); +.bi "size_t cmsg_align(size_t " length ); +.bi "size_t cmsg_space(size_t " length ); +.bi "size_t cmsg_len(size_t " length ); +.bi "unsigned char *cmsg_data(struct cmsghdr *" cmsg ); +.fi +.sh description +these macros are used to create and access control messages (also called +ancillary data) that are not a part of the socket payload. +this control information may +include the interface the packet was received on, various rarely used header +fields, an extended error description, a set of file descriptors, or unix +credentials. +for instance, control messages can be used to send +additional header fields such as ip options. +ancillary data is sent by calling +.br sendmsg (2) +and received by calling +.br recvmsg (2). +see their manual pages for more information. +.pp +ancillary data is a sequence of +.i cmsghdr +structures with appended data. +see the specific protocol man pages for the available control message types. +the maximum ancillary buffer size allowed per socket can be set using +.ir /proc/sys/net/core/optmem_max ; +see +.br socket (7). +.pp +the +.i cmsghdr +structure is defined as follows: +.pp +.in +4n +.ex +struct cmsghdr { + size_t cmsg_len; /* data byte count, including header + (type is socklen_t in posix) */ + int cmsg_level; /* originating protocol */ + int cmsg_type; /* protocol\-specific type */ +/* followed by + unsigned char cmsg_data[]; */ +}; +.ee +.in +.pp +the sequence of +.i cmsghdr +structures should never be accessed directly. +instead, use only the following macros: +.ip * 3 +.br cmsg_firsthdr () +returns a pointer to the first +.i cmsghdr +in the ancillary +data buffer associated with the passed +.ir msghdr . +it returns null if there isn't enough space for a +.i cmsghdr +in the buffer. +.ip * +.br cmsg_nxthdr () +returns the next valid +.i cmsghdr +after the passed +.ir cmsghdr . +it returns null when there isn't enough space left in the buffer. +.ip +when initializing a buffer that will contain a series of +.i cmsghdr +structures (e.g., to be sent with +.br sendmsg (2)), +that buffer should first be zero-initialized +to ensure the correct operation of +.br cmsg_nxthdr (). +.ip * +.br cmsg_align (), +given a length, returns it including the required alignment. +this is a +constant expression. +.ip * +.br cmsg_space () +returns the number of bytes an ancillary element with payload of the +passed data length occupies. +this is a constant expression. +.ip * +.br cmsg_data () +returns a pointer to the data portion of a +.ir cmsghdr . +the pointer returned cannot be assumed to be suitably aligned for +accessing arbitrary payload data types. +applications should not cast it to a pointer type matching the payload, +but should instead use +.br memcpy (3) +to copy data to or from a suitably declared object. +.ip * +.br cmsg_len () +returns the value to store in the +.i cmsg_len +member of the +.i cmsghdr +structure, taking into account any necessary +alignment. +it takes the data length as an argument. +this is a constant +expression. +.pp +to create ancillary data, first initialize the +.i msg_controllen +member of the +.i msghdr +with the length of the control message buffer. +use +.br cmsg_firsthdr () +on the +.i msghdr +to get the first control message and +.br cmsg_nxthdr () +to get all subsequent ones. +in each control message, initialize +.i cmsg_len +(with +.br cmsg_len ()), +the other +.i cmsghdr +header fields, and the data portion using +.br cmsg_data (). +finally, the +.i msg_controllen +field of the +.i msghdr +should be set to the sum of the +.br cmsg_space () +of the length of +all control messages in the buffer. +for more information on the +.ir msghdr , +see +.br recvmsg (2). +.sh conforming to +this ancillary data model conforms to the posix.1g draft, 4.4bsd-lite, +the ipv6 advanced api described in rfc\ 2292 and susv2. +.br cmsg_firsthdr (), +.br cmsg_nxthdr (), +and +.br cmsg_data () +are specified in posix.1-2008. +.br cmsg_space () +and +.br cmsg_len () +.\" https://www.austingroupbugs.net/view.php?id=978#c3242 +will be included in the next posix release (issue 8). +.pp +.br cmsg_align () +is a linux extension. +.sh notes +for portability, ancillary data should be accessed using only the macros +described here. +.br cmsg_align () +is a linux extension and should not be used in portable programs. +.pp +in linux, +.br cmsg_len (), +.br cmsg_data (), +and +.br cmsg_align () +are constant expressions (assuming their argument is constant), +meaning that these values can be used to declare the size of global variables. +this may not be portable, however. +.sh examples +this code looks for the +.b ip_ttl +option in a received ancillary buffer: +.pp +.in +4n +.ex +struct msghdr msgh; +struct cmsghdr *cmsg; +int received_ttl; + +/* receive auxiliary data in msgh */ + +for (cmsg = cmsg_firsthdr(&msgh); cmsg != null; + cmsg = cmsg_nxthdr(&msgh, cmsg)) { + if (cmsg\->cmsg_level == ipproto_ip + && cmsg\->cmsg_type == ip_ttl) { + memcpy(&receive_ttl, cmsg_data(cmsg), sizeof(received_ttl)); + break; + } +} + +if (cmsg == null) { + /* error: ip_ttl not enabled or small buffer or i/o error */ +} +.ee +.in +.pp +the code below passes an array of file descriptors over a +unix domain socket using +.br scm_rights : +.pp +.in +4n +.ex +struct msghdr msg = { 0 }; +struct cmsghdr *cmsg; +int myfds[num_fd]; /* contains the file descriptors to pass */ +char iobuf[1]; +struct iovec io = { + .iov_base = iobuf, + .iov_len = sizeof(iobuf) +}; +union { /* ancillary data buffer, wrapped in a union + in order to ensure it is suitably aligned */ + char buf[cmsg_space(sizeof(myfds))]; + struct cmsghdr align; +} u; + +msg.msg_iov = &io; +msg.msg_iovlen = 1; +msg.msg_control = u.buf; +msg.msg_controllen = sizeof(u.buf); +cmsg = cmsg_firsthdr(&msg); +cmsg\->cmsg_level = sol_socket; +cmsg\->cmsg_type = scm_rights; +cmsg\->cmsg_len = cmsg_len(sizeof(myfds)); +memcpy(cmsg_data(cmsg), myfds, sizeof(myfds)); +.ee +.in +.pp +for a complete code example that shows passing of file descriptors +over a unix domain socket, see +.br seccomp_unotify (2). +.sh see also +.br recvmsg (2), +.br sendmsg (2) +.pp +rfc\ 2292 +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/getrlimit.2 + +.\" copyright (c) 2008 linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th pthread_detach 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +pthread_detach \- detach a thread +.sh synopsis +.nf +.b #include +.pp +.bi "int pthread_detach(pthread_t " thread ); +.fi +.pp +compile and link with \fi\-pthread\fp. +.sh description +the +.br pthread_detach () +function marks the thread identified by +.ir thread +as detached. +when a detached thread terminates, +its resources are automatically released back to the system without +the need for another thread to join with the terminated thread. +.pp +attempting to detach an already detached thread results +in unspecified behavior. +.sh return value +on success, +.br pthread_detach () +returns 0; +on error, it returns an error number. +.sh errors +.tp +.b einval +.i thread +is not a joinable thread. +.tp +.b esrch +no thread with the id +.i thread +could be found. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br pthread_detach () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +once a thread has been detached, it can't be joined with +.br pthread_join (3) +or be made joinable again. +.pp +a new thread can be created in a detached state using +.br pthread_attr_setdetachstate (3) +to set the detached attribute of the +.i attr +argument of +.br pthread_create (3). +.pp +the detached attribute merely determines the behavior of the system +when the thread terminates; +it does not prevent the thread from being terminated +if the process terminates using +.br exit (3) +(or equivalently, if the main thread returns). +.pp +either +.br pthread_join (3) +or +.br pthread_detach () +should be called for each thread that an application creates, +so that system resources for the thread can be released. +(but note that the resources of any threads for which one of these +actions has not been done will be freed when the process terminates.) +.sh examples +the following statement detaches the calling thread: +.pp + pthread_detach(pthread_self()); +.sh see also +.br pthread_attr_setdetachstate (3), +.br pthread_cancel (3), +.br pthread_create (3), +.br pthread_exit (3), +.br pthread_join (3), +.br pthreads (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/sync.2 + +.so man3/rpc.3 + +.so man3/getprotoent.3 + +.\" this manpage is copyright (c) 2006, michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th futimesat 2 2021-08-27 "linux" "linux programmer's manual" +.sh name +futimesat \- change timestamps of a file relative to a \ +directory file descriptor +.sh synopsis +.nf +.br "#include " " /* definition of " at_* " constants */" +.b #include +.pp +.bi "int futimesat(int " dirfd ", const char *" pathname , +.bi " const struct timeval " times [2]); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br futimesat (): +.nf + _gnu_source +.fi +.sh description +this system call is obsolete. +use +.br utimensat (2) +instead. +.pp +the +.br futimesat () +system call operates in exactly the same way as +.br utimes (2), +except for the differences described in this manual page. +.pp +if the pathname given in +.i pathname +is relative, then it is interpreted relative to the directory +referred to by the file descriptor +.i dirfd +(rather than relative to the current working directory of +the calling process, as is done by +.br utimes (2) +for a relative pathname). +.pp +if +.i pathname +is relative and +.i dirfd +is the special value +.br at_fdcwd , +then +.i pathname +is interpreted relative to the current working +directory of the calling process (like +.br utimes (2)). +.pp +if +.i pathname +is absolute, then +.i dirfd +is ignored. +(see +.br openat (2) +for an explanation of why the +.i dirfd +argument is useful.) +.sh return value +on success, +.br futimesat () +returns a 0. +on error, \-1 is returned and +.i errno +is set to indicate the error. +.sh errors +the same errors that occur for +.br utimes (2) +can also occur for +.br futimesat (). +the following additional errors can occur for +.br futimesat (): +.tp +.b ebadf +.i pathname +is relative but +.i dirfd +is neither +.b at_fdcwd +nor a valid file descriptor. +.tp +.b enotdir +.i pathname +is relative and +.i dirfd +is a file descriptor referring to a file other than a directory. +.sh versions +.br futimesat () +was added to linux in kernel 2.6.16; +library support was added to glibc in version 2.4. +.sh conforming to +this system call is nonstandard. +it was implemented from a specification that was proposed for posix.1, +but that specification was replaced by the one for +.br utimensat (2). +.pp +a similar system call exists on solaris. +.sh notes +.ss glibc notes +if +.i pathname +is null, then the glibc +.br futimesat () +wrapper function updates the times for the file referred to by +.ir dirfd . +.\" the solaris futimesat() also has this strangeness. +.sh see also +.br stat (2), +.br utimensat (2), +.br utimes (2), +.br futimes (3), +.br path_resolution (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sat jul 24 19:32:25 1993 by rik faith (faith@cs.unc.edu) +.th gcvt 3 2021-03-22 "" "linux programmer's manual" +.sh name +gcvt \- convert a floating-point number to a string +.sh synopsis +.nf +.b #include +.pp +.bi "char *gcvt(double " number ", int " ndigit ", char *" buf ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br gcvt (): +.nf + since glibc 2.17 + (_xopen_source >= 500 && ! (_posix_c_source >= 200809l)) + || /* glibc >= 2.20 */ _default_source + || /* glibc <= 2.19 */ _svid_source + glibc versions 2.12 to 2.16: + (_xopen_source >= 500 && ! (_posix_c_source >= 200112l)) + || _svid_source + before glibc 2.12: + _svid_source || _xopen_source >= 500 +.\" || _xopen_source && _xopen_source_extended +.fi +.sh description +the +.br gcvt () +function converts \finumber\fp to a minimal length null-terminated +ascii string and stores the result in \fibuf\fp. +it produces \findigit\fp significant digits in either +.br printf (3) +f format or e format. +.sh return value +the +.br gcvt () +function returns +\fibuf\fp. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br gcvt () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +marked as legacy in posix.1-2001. +posix.1-2008 removes the specification of +.br gcvt (), +recommending the use of +.br sprintf (3) +instead (though +.br snprintf (3) +may be preferable). +.sh see also +.br ecvt (3), +.br fcvt (3), +.br sprintf (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" this manpage is copyright (c) 1992 drew eckhardt; +.\" and copyright (c) 1993 michael haardt, ian jackson. +.\" and copyright (c) 2006, 2014 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified 1993-07-23 by rik faith +.\" modified 1994-08-21 by michael haardt +.\" modified 2004-06-23 by michael kerrisk +.\" modified 2005-04-04, as per suggestion by michael hardt for rename.2 +.\" +.th link 2 2021-08-27 "linux" "linux programmer's manual" +.sh name +link, linkat \- make a new name for a file +.sh synopsis +.nf +.b #include +.pp +.bi "int link(const char *" oldpath ", const char *" newpath ); +.pp +.br "#include " "/* definition of " at_* " constants */" +.b #include +.pp +.bi "int linkat(int " olddirfd ", const char *" oldpath , +.bi " int " newdirfd ", const char *" newpath ", int " flags ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br linkat (): +.nf + since glibc 2.10: + _posix_c_source >= 200809l + before glibc 2.10: + _atfile_source +.fi +.sh description +.br link () +creates a new link (also known as a hard link) to an existing file. +.pp +if +.i newpath +exists, it will +.i not +be overwritten. +.pp +this new name may be used exactly as the old one for any operation; +both names refer to the same file (and so have the same permissions +and ownership) and it is impossible to tell which name was the +"original". +.ss linkat() +the +.br linkat () +system call operates in exactly the same way as +.br link (), +except for the differences described here. +.pp +if the pathname given in +.i oldpath +is relative, then it is interpreted relative to the directory +referred to by the file descriptor +.i olddirfd +(rather than relative to the current working directory of +the calling process, as is done by +.br link () +for a relative pathname). +.pp +if +.i oldpath +is relative and +.i olddirfd +is the special value +.br at_fdcwd , +then +.i oldpath +is interpreted relative to the current working +directory of the calling process (like +.br link ()). +.pp +if +.i oldpath +is absolute, then +.i olddirfd +is ignored. +.pp +the interpretation of +.i newpath +is as for +.ir oldpath , +except that a relative pathname is interpreted relative +to the directory referred to by the file descriptor +.ir newdirfd . +.pp +the following values can be bitwise ored in +.ir flags : +.tp +.br at_empty_path " (since linux 2.6.39)" +.\" commit 11a7b371b64ef39fc5fb1b6f2218eef7c4d035e3 +if +.i oldpath +is an empty string, create a link to the file referenced by +.ir olddirfd +(which may have been obtained using the +.br open (2) +.b o_path +flag). +in this case, +.i olddirfd +can refer to any type of file except a directory. +this will generally not work if the file has a link count of zero (files +created with +.br o_tmpfile +and without +.br o_excl +are an exception). +the caller must have the +.br cap_dac_read_search +capability in order to use this flag. +this flag is linux-specific; define +.b _gnu_source +.\" before glibc 2.16, defining _atfile_source sufficed +to obtain its definition. +.tp +.br at_symlink_follow " (since linux 2.6.18)" +by default, +.br linkat (), +does not dereference +.i oldpath +if it is a symbolic link (like +.br link ()). +the flag +.b at_symlink_follow +can be specified in +.i flags +to cause +.i oldpath +to be dereferenced if it is a symbolic link. +if procfs is mounted, +this can be used as an alternative to +.br at_empty_path , +like this: +.ip +.in +4n +.ex +linkat(at_fdcwd, "/proc/self/fd/", newdirfd, + newname, at_symlink_follow); +.ee +.in +.pp +before kernel 2.6.18, the +.i flags +argument was unused, and had to be specified as 0. +.pp +see +.br openat (2) +for an explanation of the need for +.br linkat (). +.sh return value +on success, zero is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eacces +write access to the directory containing +.i newpath +is denied, or search permission is denied for one of the directories +in the path prefix of +.i oldpath +or +.ir newpath . +(see also +.br path_resolution (7).) +.tp +.b edquot +the user's quota of disk blocks on the filesystem has been exhausted. +.tp +.b eexist +.i newpath +already exists. +.tp +.b efault +.ir oldpath " or " newpath " points outside your accessible address space." +.tp +.b eio +an i/o error occurred. +.tp +.b eloop +too many symbolic links were encountered in resolving +.ir oldpath " or " newpath . +.tp +.b emlink +the file referred to by +.i oldpath +already has the maximum number of links to it. +for example, on an +.br ext4 (5) +filesystem that does not employ the +.i dir_index +feature, the limit on the number of hard links to a file is 65,000; on +.br btrfs (5), +the limit is 65,535 links. +.tp +.b enametoolong +.ir oldpath " or " newpath " was too long." +.tp +.b enoent +a directory component in +.ir oldpath " or " newpath +does not exist or is a dangling symbolic link. +.tp +.b enomem +insufficient kernel memory was available. +.tp +.b enospc +the device containing the file has no room for the new directory +entry. +.tp +.b enotdir +a component used as a directory in +.ir oldpath " or " newpath +is not, in fact, a directory. +.tp +.b eperm +.i oldpath +is a directory. +.tp +.b eperm +the filesystem containing +.ir oldpath " and " newpath +does not support the creation of hard links. +.tp +.br eperm " (since linux 3.6)" +the caller does not have permission to create a hard link to this file +(see the description of +.ir /proc/sys/fs/protected_hardlinks +in +.br proc (5)). +.tp +.b eperm +.i oldpath +is marked immutable or append-only. +(see +.br ioctl_iflags (2).) +.tp +.b erofs +the file is on a read-only filesystem. +.tp +.b exdev +.ir oldpath " and " newpath +are not on the same mounted filesystem. +(linux permits a filesystem to be mounted at multiple points, but +.br link () +does not work across different mounts, +even if the same filesystem is mounted on both.) +.pp +the following additional errors can occur for +.br linkat (): +.tp +.b ebadf +.i oldpath +.ri ( newpath ) +is relative but +.i olddirfd +.ri ( newdirfd ) +is neither +.b at_fdcwd +nor a valid file descriptor. +.tp +.b einval +an invalid flag value was specified in +.ir flags . +.tp +.b enoent +.b at_empty_path +was specified in +.ir flags , +but the caller did not have the +.b cap_dac_read_search +capability. +.tp +.b enoent +an attempt was made to link to the +.i /proc/self/fd/nn +file corresponding to a file descriptor created with +.ip +.in +4n +.ex +open(path, o_tmpfile | o_excl, mode); +.ee +.in +.ip +see +.br open (2). +.tp +.b enoent +an attempt was made to link to a +.i /proc/self/fd/nn +file corresponding to a file that has been deleted. +.tp +.b enoent +.i oldpath +is a relative pathname and +.i olddirfd +refers to a directory that has been deleted, +or +.i newpath +is a relative pathname and +.i newdirfd +refers to a directory that has been deleted. +.tp +.b enotdir +.i oldpath +is relative and +.i olddirfd +is a file descriptor referring to a file other than a directory; +or similar for +.i newpath +and +.i newdirfd +.tp +.b eperm +.br at_empty_path +was specified in +.ir flags , +.i oldpath +is an empty string, and +.ir olddirfd +refers to a directory. +.sh versions +.br linkat () +was added to linux in kernel 2.6.16; +library support was added to glibc in version 2.4. +.sh conforming to +.br link (): +svr4, 4.3bsd, posix.1-2001 (but see notes), posix.1-2008. +.\" svr4 documents additional enolink and +.\" emultihop error conditions; posix.1 does not document eloop. +.\" x/open does not document efault, enomem or eio. +.pp +.br linkat (): +posix.1-2008. +.sh notes +hard links, as created by +.br link (), +cannot span filesystems. +use +.br symlink (2) +if this is required. +.pp +posix.1-2001 says that +.br link () +should dereference +.i oldpath +if it is a symbolic link. +however, since kernel 2.0, +.\" more precisely: since kernel 1.3.56 +linux does not do so: if +.i oldpath +is a symbolic link, then +.i newpath +is created as a (hard) link to the same symbolic link file +(i.e., +.i newpath +becomes a symbolic link to the same file that +.i oldpath +refers to). +some other implementations behave in the same manner as linux. +.\" for example, the default solaris compilation environment +.\" behaves like linux, and contributors to a march 2005 +.\" thread in the austin mailing list reported that some +.\" other (system v) implementations did/do the same -- mtk, apr 05 +posix.1-2008 changes the specification of +.br link (), +making it implementation-dependent whether or not +.i oldpath +is dereferenced if it is a symbolic link. +for precise control over the treatment of symbolic links when +creating a link, use +.br linkat (). +.ss glibc notes +on older kernels where +.br linkat () +is unavailable, the glibc wrapper function falls back to the use of +.br link (), +unless the +.b at_symlink_follow +is specified. +when +.i oldpath +and +.i newpath +are relative pathnames, +glibc constructs pathnames based on the symbolic links in +.ir /proc/self/fd +that correspond to the +.i olddirfd +and +.ir newdirfd +arguments. +.sh bugs +on nfs filesystems, the return code may be wrong in case the nfs server +performs the link creation and dies before it can say so. +use +.br stat (2) +to find out if the link got created. +.sh see also +.br ln (1), +.br open (2), +.br rename (2), +.br stat (2), +.br symlink (2), +.br unlink (2), +.br path_resolution (7), +.br symlink (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1999 andries brouwer (aeb@cwi.nl), 1 nov 1999 +.\" and copyright 2006, 2012, 2017 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" 1999-11-10: merged text taken from the page contributed by +.\" reed h. petty (rhp@draper.net) +.\" +.th vfork 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +vfork \- create a child process and block parent +.sh synopsis +.nf +.b #include +.pp +.b pid_t vfork(void); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br vfork (): +.nf + since glibc 2.12: + (_xopen_source >= 500) && ! (_posix_c_source >= 200809l) + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source + before glibc 2.12: + _bsd_source || _xopen_source >= 500 +.\" || _xopen_source && _xopen_source_extended +.fi +.sh description +.ss standard description +(from posix.1) +the +.br vfork () +function has the same effect as +.br fork (2), +except that the behavior is undefined if the process created by +.br vfork () +either modifies any data other than a variable of type +.i pid_t +used to store the return value from +.br vfork (), +or returns from the function in which +.br vfork () +was called, or calls any other function before successfully calling +.br _exit (2) +or one of the +.br exec (3) +family of functions. +.ss linux description +.br vfork (), +just like +.br fork (2), +creates a child process of the calling process. +for details and return value and errors, see +.br fork (2). +.pp +.br vfork () +is a special case of +.br clone (2). +it is used to create new processes without copying the page tables of +the parent process. +it may be useful in performance-sensitive applications +where a child is created which then immediately issues an +.br execve (2). +.pp +.br vfork () +differs from +.br fork (2) +in that the calling thread is suspended until the child terminates +(either normally, +by calling +.br _exit (2), +or abnormally, after delivery of a fatal signal), +or it makes a call to +.br execve (2). +until that point, the child shares all memory with its parent, +including the stack. +the child must not return from the current function or call +.br exit (3) +(which would have the effect of calling exit handlers +established by the parent process and flushing the parent's +.br stdio (3) +buffers), but may call +.br _exit (2). +.pp +as with +.br fork (2), +the child process created by +.br vfork () +inherits copies of various of the caller's process attributes +(e.g., file descriptors, signal dispositions, and current working directory); +the +.br vfork () +call differs only in the treatment of the virtual address space, +as described above. +.pp +signals sent to the parent +arrive after the child releases the parent's memory +(i.e., after the child terminates +or calls +.br execve (2)). +.ss historic description +under linux, +.br fork (2) +is implemented using copy-on-write pages, so the only penalty incurred by +.br fork (2) +is the time and memory required to duplicate the parent's page tables, +and to create a unique task structure for the child. +however, in the bad old days a +.br fork (2) +would require making a complete copy of the caller's data space, +often needlessly, since usually immediately afterward an +.br exec (3) +is done. +thus, for greater efficiency, bsd introduced the +.br vfork () +system call, which did not fully copy the address space of +the parent process, but borrowed the parent's memory and thread +of control until a call to +.br execve (2) +or an exit occurred. +the parent process was suspended while the +child was using its resources. +the use of +.br vfork () +was tricky: for example, not modifying data +in the parent process depended on knowing which variables were +held in a register. +.sh conforming to +4.3bsd; posix.1-2001 (but marked obsolete). +posix.1-2008 removes the specification of +.br vfork (). +.pp +the requirements put on +.br vfork () +by the standards are weaker than those put on +.br fork (2), +so an implementation where the two are synonymous is compliant. +in particular, the programmer cannot rely on the parent +remaining blocked until the child either terminates or calls +.br execve (2), +and cannot rely on any specific behavior with respect to shared memory. +.\" in aixv3.1 vfork is equivalent to fork. +.sh notes +some consider the semantics of +.br vfork () +to be an architectural blemish, and the 4.2bsd man page stated: +"this system call will be eliminated when proper system sharing mechanisms +are implemented. +users should not depend on the memory sharing semantics of +.br vfork () +as it will, in that case, be made synonymous to +.br fork (2).\c +" +however, even though modern memory management hardware +has decreased the performance difference between +.br fork (2) +and +.br vfork (), +there are various reasons why linux and other systems have retained +.br vfork (): +.ip * 3 +some performance-critical applications require the small performance +advantage conferred by +.br vfork (). +.ip * +.br vfork () +can be implemented on systems that lack a memory-management unit (mmu), but +.br fork (2) +can't be implemented on such systems. +(posix.1-2008 removed +.br vfork () +from the standard; the posix rationale for the +.br posix_spawn (3) +function notes that that function, +which provides functionality equivalent to +.br fork (2)+ exec (3), +is designed to be implementable on systems that lack an mmu.) +.\" http://stackoverflow.com/questions/4259629/what-is-the-difference-between-fork-and-vfork +.\" http://developers.sun.com/solaris/articles/subprocess/subprocess.html +.\" http://mailman.uclinux.org/pipermail/uclinux-dev/2009-april/000684.html +.\" +.ip * +on systems where memory is constrained, +.br vfork () +avoids the need to temporarily commit memory (see the description of +.ir /proc/sys/vm/overcommit_memory +in +.br proc (5)) +in order to execute a new program. +(this can be especially beneficial where a large parent process wishes +to execute a small helper program in a child process.) +by contrast, using +.br fork (2) +in this scenario requires either committing an amount of memory equal +to the size of the parent process (if strict overcommitting is in force) +or overcommitting memory with the risk that a process is terminated +by the out-of-memory (oom) killer. +.\" +.ss caveats +the child process should take care not to modify the memory in unintended ways, +since such changes will be seen by the parent process once +the child terminates or executes another program. +in this regard, signal handlers can be especially problematic: +if a signal handler that is invoked in the child of +.br vfork () +changes memory, those changes may result in an inconsistent process state +from the perspective of the parent process +(e.g., memory changes would be visible in the parent, +but changes to the state of open file descriptors would not be visible). +.pp +when +.br vfork () +is called in a multithreaded process, +only the calling thread is suspended until the child terminates +or executes a new program. +this means that the child is sharing an address space with other running code. +this can be dangerous if another thread in the parent process +changes credentials (using +.br setuid (2) +or similar), +since there are now two processes with different privilege levels +running in the same address space. +as an example of the dangers, +suppose that a multithreaded program running as root creates a child using +.br vfork (). +after the +.br vfork (), +a thread in the parent process drops the process to an unprivileged user +in order to run some untrusted code +(e.g., perhaps via plug-in opened with +.br dlopen (3)). +in this case, attacks are possible where the parent process uses +.br mmap (2) +to map in code that will be executed by the privileged child process. +.\" +.ss linux notes +fork handlers established using +.br pthread_atfork (3) +are not called when a multithreaded program employing +the nptl threading library calls +.br vfork (). +fork handlers are called in this case in a program using the +linuxthreads threading library. +(see +.br pthreads (7) +for a description of linux threading libraries.) +.pp +a call to +.br vfork () +is equivalent to calling +.br clone (2) +with +.i flags +specified as: +.pp + clone_vm | clone_vfork | sigchld +.ss history +the +.br vfork () +system call appeared in 3.0bsd. +.\" in the release notes for 4.2bsd sam leffler wrote: `vfork: is still +.\" present, but definitely on its way out'. +in 4.4bsd it was made synonymous to +.br fork (2) +but netbsd introduced it again; +see +.ur http://www.netbsd.org\:/documentation\:/kernel\:/vfork.html +.ue . +in linux, it has been equivalent to +.br fork (2) +until 2.2.0-pre6 or so. +since 2.2.0-pre9 (on i386, somewhat later on +other architectures) it is an independent system call. +support was added in glibc 2.0.112. +.sh bugs +details of the signal handling are obscure and differ between systems. +the bsd man page states: +"to avoid a possible deadlock situation, processes that are children +in the middle of a +.br vfork () +are never sent +.b sigttou +or +.b sigttin +signals; rather, output or +.ir ioctl s +are allowed and input attempts result in an end-of-file indication." +.\" +.\" as far as i can tell, the following is not true in 2.6.19: +.\" currently (linux 2.3.25), +.\" .br strace (1) +.\" cannot follow +.\" .br vfork () +.\" and requires a kernel patch. +.sh see also +.br clone (2), +.br execve (2), +.br _exit (2), +.br fork (2), +.br unshare (2), +.br wait (2) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/kexec_load.2 + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" iso/iec 9899:1999 +.\" +.th wmemmove 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +wmemmove \- copy an array of wide-characters +.sh synopsis +.nf +.b #include +.pp +.bi "wchar_t *wmemmove(wchar_t *" dest ", const wchar_t *" src ", size_t " n ); +.fi +.sh description +the +.br wmemmove () +function is the wide-character equivalent of the +.br memmove (3) +function. +it copies +.i n +wide characters from the array +starting at +.i src +to the array starting at +.ir dest . +the arrays may +overlap. +.pp +the programmer must ensure that there is room for at least +.i n +wide +characters at +.ir dest . +.sh return value +.br wmemmove () +returns +.ir dest . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br wmemmove () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh see also +.br memmove (3), +.br wmemcpy (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de) +.\" and copyright (c) 2011 michael kerrisk +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under gpl +.\" %%%license_end +.\" +.th cacos 3 2021-03-22 "" "linux programmer's manual" +.sh name +cacos, cacosf, cacosl \- complex arc cosine +.sh synopsis +.nf +.b #include +.pp +.bi "double complex cacos(double complex " z ); +.bi "float complex cacosf(float complex " z ); +.bi "long double complex cacosl(long double complex " z ); +.pp +link with \fi\-lm\fp. +.fi +.sh description +these functions calculate the complex arc cosine of +.ir z . +if \fiy\ =\ cacos(z)\fp, then \fiz\ =\ ccos(y)\fp. +the real part of +.i y +is chosen in the interval [0,pi]. +.pp +one has: +.pp +.nf + cacos(z) = \-i * clog(z + i * csqrt(1 \- z * z)) +.fi +.sh versions +these functions first appeared in glibc in version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br cacos (), +.br cacosf (), +.br cacosl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.sh examples +.ex +/* link with "\-lm" */ + +#include +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + double complex z, c, f; + double complex i = i; + + if (argc != 3) { + fprintf(stderr, "usage: %s \en", argv[0]); + exit(exit_failure); + } + + z = atof(argv[1]) + atof(argv[2]) * i; + + c = cacos(z); + + printf("cacos() = %6.3f %6.3f*i\en", creal(c), cimag(c)); + + f = \-i * clog(z + i * csqrt(1 \- z * z)); + + printf("formula = %6.3f %6.3f*i\en", creal(f), cimag(f)); + + exit(exit_success); +} +.ee +.sh see also +.br ccos (3), +.br clog (3), +.br complex (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/setnetgrent.3 + +.so man3/sigvec.3 + +.so man2/setresuid.2 + +.so man3/posix_memalign.3 + +.so man3/pthread_rwlockattr_setkind_np.3 + +.\" copyright 1996 daniel quinlan (daniel.quinlan@linux.org) +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" 2007-12-14 mtk added reiserfs, xfs, jfs. +.\" +.th filesystems 5 2020-12-21 "linux" "linux programmer's manual" +.nh +.sh name +filesystems \- linux filesystem types: ext, ext2, ext3, ext4, hpfs, iso9660, +jfs, minix, msdos, ncpfs nfs, ntfs, proc, reiserfs, smb, sysv, umsdos, vfat, +xfs, xiafs +.sh description +when, as is customary, the +.b proc +filesystem is mounted on +.ir /proc , +you can find in the file +.i /proc/filesystems +which filesystems your kernel currently supports; +see +.br proc (5) +for more details. +there is also a legacy +.br sysfs (2) +system call (whose availability is controlled by the +.\" commit: 6af9f7bf3c399e0ab1eee048e13572c6d4e15fe9 +.b config_sysfs_syscall +kernel build configuration option since linux 3.15) +that enables enumeration of the currently available filesystem types +regardless of +.i /proc +availability and/or sanity. +.pp +if you need a currently unsupported filesystem, insert the corresponding +kernel module or recompile the kernel. +.pp +in order to use a filesystem, you have to +.i mount +it; see +.br mount (2) +and +.br mount (8). +.pp +the following list provides a +short description of the available or historically available +filesystems in the linux kernel. +see the kernel documentation for a comprehensive +description of all options and limitations. +.tp 10 +.b ext +is an elaborate extension of the +.b minix +filesystem. +it has been completely superseded by the second version +of the extended filesystem +.rb ( ext2 ) +and has been removed from the kernel (in 2.1.21). +.tp +.b ext2 +is the high performance disk filesystem used by linux for fixed disks +as well as removable media. +the second extended filesystem was designed as an extension of the +extended filesystem +.rb ( ext ). +see +.br ext2 (5). +.tp +.b ext3 +is a journaling version of the +.b ext2 +filesystem. +it is easy to +switch back and forth between +.b ext2 +and +.br ext3 . +see +.br ext3 (5). +.tp +.b ext4 +is a set of upgrades to +.b ext3 +including substantial performance and +reliability enhancements, +plus large increases in volume, file, and directory size limits. +see +.br ext4 (5). +.tp +.b hpfs +is the high performance filesystem, used in os/2. +this filesystem is +read-only under linux due to the lack of available documentation. +.tp +.b iso9660 +is a cd-rom filesystem type conforming to the iso 9660 standard. +.rs +.tp +.b "high sierra" +linux supports high sierra, the precursor to the iso 9660 standard for +cd-rom filesystems. +it is automatically recognized within the +.b iso9660 +filesystem support under linux. +.tp +.b "rock ridge" +linux also supports the system use sharing protocol records specified +by the rock ridge interchange protocol. +they are used to further describe the files in the +.b iso9660 +filesystem to a unix host, and provide information such as long +filenames, uid/gid, posix permissions, and devices. +it is automatically recognized within the +.b iso9660 +filesystem support under linux. +.re +.tp +.b jfs +is a journaling filesystem, developed by ibm, +that was integrated into linux in kernel 2.4.24. +.tp +.b minix +is the filesystem used in the minix operating system, the first to run +under linux. +it has a number of shortcomings, including a 64\ mb partition size +limit, short filenames, and a single timestamp. +it remains useful for floppies and ram disks. +.tp +.b msdos +is the filesystem used by dos, windows, and some os/2 computers. +.b msdos +filenames can be no longer than 8 characters, followed by an +optional period and 3 character extension. +.tp +.b ncpfs +is a network filesystem that supports the ncp protocol, +used by novell netware. +it was removed from the kernel in 4.17. +.ip +to use +.br ncpfs , +you need special programs, which can be found at +.ur ftp://ftp.gwdg.de\:/pub\:/linux\:/misc\:/ncpfs +.ue . +.tp +.b nfs +is the network filesystem used to access disks located on remote computers. +.tp +.b ntfs +is the filesystem native to microsoft windows nt, +supporting features like acls, journaling, encryption, and so on. +.tp +.b proc +is a pseudo filesystem which is used as an interface to kernel data +structures rather than reading and interpreting +.ir /dev/kmem . +in particular, its files do not take disk space. +see +.br proc (5). +.tp +.b reiserfs +is a journaling filesystem, designed by hans reiser, +that was integrated into linux in kernel 2.4.1. +.tp +.b smb +is a network filesystem that supports the smb protocol, used by +windows for workgroups, windows nt, and lan manager. +see +.ur https://www.samba.org\:/samba\:/smbfs/ +.ue . +.tp +.b sysv +is an implementation of the system v/coherent filesystem for linux. +it implements all of xenix fs, system v/386 fs, and coherent fs. +.tp +.b umsdos +is an extended dos filesystem used by linux. +it adds capability for +long filenames, uid/gid, posix permissions, and special files +(devices, named pipes, etc.) under the dos filesystem, without +sacrificing compatibility with dos. +.tp +.b tmpfs +is a filesystem whose contents reside in virtual memory. +since the files on such filesystems typically reside in ram, +file access is extremely fast. +see +.br tmpfs (5). +.tp +.b vfat +is an extended fat filesystem used by microsoft windows95 and windows nt. +.b vfat +adds the capability to use long filenames under the msdos filesystem. +.tp +.b xfs +is a journaling filesystem, developed by sgi, +that was integrated into linux in kernel 2.4.20. +.tp +.b xiafs +was designed and implemented to be a stable, safe filesystem by +extending the minix filesystem code. +it provides the basic most +requested features without undue complexity. +the +.b xiafs +filesystem is no longer actively developed or maintained. +it was removed from the kernel in 2.1.21. +.sh see also +.br fuse (4), +.br btrfs (5), +.br ext2 (5), +.br ext3 (5), +.br ext4 (5), +.br nfs (5), +.br proc (5), +.br sysfs (5), +.br tmpfs (5), +.br xfs (5), +.br fsck (8), +.br mkfs (8), +.br mount (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man7/system_data_types.7 + +.\" copyright (c) 2008 michael kerrisk +.\" starting from a version by davide libenzi +.\" +.\" %%%license_start(gplv2+_sw_3_para) +.\" this program is free software; you can redistribute it and/or modify +.\" it under the terms of the gnu general public license as published by +.\" the free software foundation; either version 2 of the license, or +.\" (at your option) any later version. +.\" +.\" this program 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" 2008-10-10, mtk: describe eventfd2(), and efd_nonblock and efd_cloexec +.\" +.th eventfd 2 2021-03-22 linux "linux programmer's manual" +.sh name +eventfd \- create a file descriptor for event notification +.sh synopsis +.nf +.b #include +.pp +.bi "int eventfd(unsigned int " initval ", int " flags ); +.fi +.sh description +.br eventfd () +creates an "eventfd object" that can be used as +an event wait/notify mechanism by user-space applications, +and by the kernel to notify user-space applications of events. +the object contains an unsigned 64-bit integer +.ri ( uint64_t ) +counter that is maintained by the kernel. +this counter is initialized with the value specified in the argument +.ir initval . +.pp +as its return value, +.br eventfd () +returns a new file descriptor that can be used to refer to the +eventfd object. +.pp +the following values may be bitwise ored in +.ir flags +to change the behavior of +.br eventfd (): +.tp +.br efd_cloexec " (since linux 2.6.27)" +set the close-on-exec +.rb ( fd_cloexec ) +flag on the new file descriptor. +see the description of the +.b o_cloexec +flag in +.br open (2) +for reasons why this may be useful. +.tp +.br efd_nonblock " (since linux 2.6.27)" +set the +.br o_nonblock +file status flag on the open file description (see +.br open (2)) +referred to by the new file descriptor. +using this flag saves extra calls to +.br fcntl (2) +to achieve the same result. +.tp +.br efd_semaphore " (since linux 2.6.30)" +provide semaphore-like semantics for reads from the new file descriptor. +see below. +.pp +in linux up to version 2.6.26, the +.i flags +argument is unused, and must be specified as zero. +.pp +the following operations can be performed on the file descriptor returned by +.br eventfd (): +.tp +.br read (2) +each successful +.br read (2) +returns an 8-byte integer. +a +.br read (2) +fails with the error +.b einval +if the size of the supplied buffer is less than 8 bytes. +.ip +the value returned by +.br read (2) +is in host byte order\(emthat is, +the native byte order for integers on the host machine. +.ip +the semantics of +.br read (2) +depend on whether the eventfd counter currently has a nonzero value +and whether the +.br efd_semaphore +flag was specified when creating the eventfd file descriptor: +.rs +.ip * 3 +if +.br efd_semaphore +was not specified and the eventfd counter has a nonzero value, then a +.br read (2) +returns 8 bytes containing that value, +and the counter's value is reset to zero. +.ip * +if +.br efd_semaphore +was specified and the eventfd counter has a nonzero value, then a +.br read (2) +returns 8 bytes containing the value 1, +and the counter's value is decremented by 1. +.ip * +if the eventfd counter is zero at the time of the call to +.br read (2), +then the call either blocks until the counter becomes nonzero +(at which time, the +.br read (2) +proceeds as described above) +or fails with the error +.b eagain +if the file descriptor has been made nonblocking. +.re +.tp +.br write (2) +a +.br write (2) +call adds the 8-byte integer value supplied in its +buffer to the counter. +the maximum value that may be stored in the counter is the largest +unsigned 64-bit value minus 1 (i.e., 0xfffffffffffffffe). +if the addition would cause the counter's value to exceed +the maximum, then the +.br write (2) +either blocks until a +.br read (2) +is performed on the file descriptor, +or fails with the error +.b eagain +if the file descriptor has been made nonblocking. +.ip +a +.br write (2) +fails with the error +.b einval +if the size of the supplied buffer is less than 8 bytes, +or if an attempt is made to write the value 0xffffffffffffffff. +.tp +.br poll "(2), " select "(2) (and similar)" +the returned file descriptor supports +.br poll (2) +(and analogously +.br epoll (7)) +and +.br select (2), +as follows: +.rs +.ip * 3 +the file descriptor is readable +(the +.br select (2) +.i readfds +argument; the +.br poll (2) +.b pollin +flag) +if the counter has a value greater than 0. +.ip * +the file descriptor is writable +(the +.br select (2) +.i writefds +argument; the +.br poll (2) +.b pollout +flag) +if it is possible to write a value of at least "1" without blocking. +.ip * +if an overflow of the counter value was detected, +then +.br select (2) +indicates the file descriptor as being both readable and writable, and +.br poll (2) +returns a +.b pollerr +event. +as noted above, +.br write (2) +can never overflow the counter. +however an overflow can occur if 2^64 +eventfd "signal posts" were performed by the kaio +subsystem (theoretically possible, but practically unlikely). +if an overflow has occurred, then +.br read (2) +will return that maximum +.i uint64_t +value (i.e., 0xffffffffffffffff). +.re +.ip +the eventfd file descriptor also supports the other file-descriptor +multiplexing apis: +.br pselect (2) +and +.br ppoll (2). +.tp +.br close (2) +when the file descriptor is no longer required it should be closed. +when all file descriptors associated with the same eventfd object +have been closed, the resources for object are freed by the kernel. +.pp +a copy of the file descriptor created by +.br eventfd () +is inherited by the child produced by +.br fork (2). +the duplicate file descriptor is associated with the same +eventfd object. +file descriptors created by +.br eventfd () +are preserved across +.br execve (2), +unless the close-on-exec flag has been set. +.sh return value +on success, +.br eventfd () +returns a new eventfd file descriptor. +on error, \-1 is returned and +.i errno +is set to indicate the error. +.sh errors +.tp +.b einval +an unsupported value was specified in +.ir flags . +.tp +.b emfile +the per-process limit on the number of open file descriptors has been reached. +.tp +.b enfile +the system-wide limit on the total number of open files has been +reached. +.tp +.b enodev +.\" note from davide: +.\" the enodev error is basically never going to happen if +.\" the kernel boots correctly. that error happen only if during +.\" the kernel initialization, some error occur in the anonymous +.\" inode source initialization. +could not mount (internal) anonymous inode device. +.tp +.b enomem +there was insufficient memory to create a new +eventfd file descriptor. +.sh versions +.br eventfd () +is available on linux since kernel 2.6.22. +working support is provided in glibc since version 2.8. +.\" eventfd() is in glibc 2.7, but reportedly does not build +the +.br eventfd2 () +system call (see notes) is available on linux since kernel 2.6.27. +since version 2.9, the glibc +.br eventfd () +wrapper will employ the +.br eventfd2 () +system call, if it is supported by the kernel. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br eventfd () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +.br eventfd () +and +.br eventfd2 () +are linux-specific. +.sh notes +applications can use an eventfd file descriptor instead of a pipe (see +.br pipe (2)) +in all cases where a pipe is used simply to signal events. +the kernel overhead of an eventfd file descriptor +is much lower than that of a pipe, +and only one file descriptor is +required (versus the two required for a pipe). +.pp +when used in the kernel, an eventfd +file descriptor can provide a bridge from kernel to user space, allowing, +for example, functionalities like kaio (kernel aio) +.\" or eventually syslets/threadlets +to signal to a file descriptor that some operation is complete. +.pp +a key point about an eventfd file descriptor is that it can be +monitored just like any other file descriptor using +.br select (2), +.br poll (2), +or +.br epoll (7). +this means that an application can simultaneously monitor the +readiness of "traditional" files and the readiness of other +kernel mechanisms that support the eventfd interface. +(without the +.br eventfd () +interface, these mechanisms could not be multiplexed via +.br select (2), +.br poll (2), +or +.br epoll (7).) +.pp +the current value of an eventfd counter can be viewed +via the entry for the corresponding file descriptor in the process's +.ir /proc/[pid]/fdinfo +directory. +see +.br proc (5) +for further details. +.\" +.ss c library/kernel differences +there are two underlying linux system calls: +.br eventfd () +and the more recent +.br eventfd2 (). +the former system call does not implement a +.i flags +argument. +the latter system call implements the +.i flags +values described above. +the glibc wrapper function will use +.br eventfd2 () +where it is available. +.ss additional glibc features +the gnu c library defines an additional type, +and two functions that attempt to abstract some of the details of +reading and writing on an eventfd file descriptor: +.pp +.in +4n +.ex +typedef uint64_t eventfd_t; + +int eventfd_read(int fd, eventfd_t *value); +int eventfd_write(int fd, eventfd_t value); +.ee +.in +.pp +the functions perform the read and write operations on an +eventfd file descriptor, +returning 0 if the correct number of bytes was transferred, +or \-1 otherwise. +.sh examples +the following program creates an eventfd file descriptor +and then forks to create a child process. +while the parent briefly sleeps, +the child writes each of the integers supplied in the program's +command-line arguments to the eventfd file descriptor. +when the parent has finished sleeping, +it reads from the eventfd file descriptor. +.pp +the following shell session shows a sample run of the program: +.pp +.in +4n +.ex +.rb "$" " ./a.out 1 2 4 7 14" +child writing 1 to efd +child writing 2 to efd +child writing 4 to efd +child writing 7 to efd +child writing 14 to efd +child completed write loop +parent about to read +parent read 28 (0x1c) from efd +.ee +.in +.ss program source +\& +.ex +#include +#include +#include /* definition of priu64 & prix64 */ +#include +#include +#include /* definition of uint64_t */ + +#define handle_error(msg) \e + do { perror(msg); exit(exit_failure); } while (0) + +int +main(int argc, char *argv[]) +{ + int efd; + uint64_t u; + ssize_t s; + + if (argc < 2) { + fprintf(stderr, "usage: %s ...\en", argv[0]); + exit(exit_failure); + } + + efd = eventfd(0, 0); + if (efd == \-1) + handle_error("eventfd"); + + switch (fork()) { + case 0: + for (int j = 1; j < argc; j++) { + printf("child writing %s to efd\en", argv[j]); + u = strtoull(argv[j], null, 0); + /* strtoull() allows various bases */ + s = write(efd, &u, sizeof(uint64_t)); + if (s != sizeof(uint64_t)) + handle_error("write"); + } + printf("child completed write loop\en"); + + exit(exit_success); + + default: + sleep(2); + + printf("parent about to read\en"); + s = read(efd, &u, sizeof(uint64_t)); + if (s != sizeof(uint64_t)) + handle_error("read"); + printf("parent read %"priu64" (%#"prix64") from efd\en", u, u); + exit(exit_success); + + case \-1: + handle_error("fork"); + } +} +.ee +.sh see also +.br futex (2), +.br pipe (2), +.br poll (2), +.br read (2), +.br select (2), +.br signalfd (2), +.br timerfd_create (2), +.br write (2), +.br epoll (7), +.br sem_overview (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2011, mark r. bannister +.\" copyright (c) 2015, robin h. johnson +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th getent 1 2021-03-22 "linux" "user commands" +.sh name +getent \- get entries from name service switch libraries +.sh synopsis +.nf +.b getent [\fioption\fp]... \fidatabase\fp \fikey\fp... +.fi +.sh description +the +.b getent +command displays entries from databases supported by the +name service switch libraries, +which are configured in +.ir /etc/nsswitch.conf . +if one or more +.i key +arguments are provided, +then only the entries that match the supplied keys will be displayed. +otherwise, if no +.i key +is provided, all entries will be displayed (unless the database does not +support enumeration). +.pp +the +.i database +may be any of those supported by the gnu c library, listed below: +.rs 3 +.tp 10 +.b ahosts +when no +.i key +is provided, use +.br sethostent (3), +.br gethostent (3), +and +.br endhostent (3) +to enumerate the hosts database. +this is identical to using +.br hosts . +when one or more +.i key +arguments are provided, pass each +.i key +in succession to +.br getaddrinfo (3) +with the address family +.br af_unspec , +enumerating each socket address structure returned. +.tp +.b ahostsv4 +same as +.br ahosts , +but use the address family +.br af_inet . +.tp +.b ahostsv6 +same as +.br ahosts , +but use the address family +.br af_inet6 . +the call to +.br getaddrinfo (3) +in this case includes the +.b ai_v4mapped +flag. +.tp +.b aliases +when no +.i key +is provided, use +.br setaliasent (3), +.br getaliasent (3), +and +.br endaliasent (3) +to enumerate the aliases database. +when one or more +.i key +arguments are provided, pass each +.i key +in succession to +.br getaliasbyname (3) +and display the result. +.tp +.b ethers +when one or more +.i key +arguments are provided, pass each +.i key +in succession to +.br ether_aton (3) +and +.br ether_hostton (3) +until a result is obtained, and display the result. +enumeration is not supported on +.br ethers , +so a +.i key +must be provided. +.tp +.b group +when no +.i key +is provided, use +.br setgrent (3), +.br getgrent (3), +and +.br endgrent (3) +to enumerate the group database. +when one or more +.i key +arguments are provided, pass each numeric +.i key +to +.br getgrgid (3) +and each nonnumeric +.i key +to +.br getgrnam (3) +and display the result. +.tp +.b gshadow +when no +.i key +is provided, use +.br setsgent (3), +.br getsgent (3), +and +.br endsgent (3) +to enumerate the gshadow database. +when one or more +.i key +arguments are provided, pass each +.i key +in succession to +.br getsgnam (3) +and display the result. +.tp +.b hosts +when no +.i key +is provided, use +.br sethostent (3), +.br gethostent (3), +and +.br endhostent (3) +to enumerate the hosts database. +when one or more +.i key +arguments are provided, pass each +.i key +to +.br gethostbyaddr (3) +or +.br gethostbyname2 (3), +depending on whether a call to +.br inet_pton (3) +indicates that the +.i key +is an ipv6 or ipv4 address or not, and display the result. +.tp +.b initgroups +when one or more +.i key +arguments are provided, pass each +.i key +in succession to +.br getgrouplist (3) +and display the result. +enumeration is not supported on +.br initgroups , +so a +.i key +must be provided. +.tp +.b netgroup +when one +.i key +is provided, pass the +.i key +to +.br setnetgrent (3) +and, using +.br getnetgrent (3) +display the resulting string triple +.ri ( hostname ", " username ", " domainname ). +alternatively, three +.i keys +may be provided, which are interpreted as the +.ir hostname , +.ir username , +and +.i domainname +to match to a netgroup name via +.br innetgr (3). +enumeration is not supported on +.br netgroup , +so either one or three +.i keys +must be provided. +.tp +.b networks +when no +.i key +is provided, use +.br setnetent (3), +.br getnetent (3), +and +.br endnetent (3) +to enumerate the networks database. +when one or more +.i key +arguments are provided, pass each numeric +.i key +to +.br getnetbyaddr (3) +and each nonnumeric +.i key +to +.br getnetbyname (3) +and display the result. +.tp +.b passwd +when no +.i key +is provided, use +.br setpwent (3), +.br getpwent (3), +and +.br endpwent (3) +to enumerate the passwd database. +when one or more +.i key +arguments are provided, pass each numeric +.i key +to +.br getpwuid (3) +and each nonnumeric +.i key +to +.br getpwnam (3) +and display the result. +.tp +.b protocols +when no +.i key +is provided, use +.br setprotoent (3), +.br getprotoent (3), +and +.br endprotoent (3) +to enumerate the protocols database. +when one or more +.i key +arguments are provided, pass each numeric +.i key +to +.br getprotobynumber (3) +and each nonnumeric +.i key +to +.br getprotobyname (3) +and display the result. +.tp +.b rpc +when no +.i key +is provided, use +.br setrpcent (3), +.br getrpcent (3), +and +.br endrpcent (3) +to enumerate the rpc database. +when one or more +.i key +arguments are provided, pass each numeric +.i key +to +.br getrpcbynumber (3) +and each nonnumeric +.i key +to +.br getrpcbyname (3) +and display the result. +.tp +.b services +when no +.i key +is provided, use +.br setservent (3), +.br getservent (3), +and +.br endservent (3) +to enumerate the services database. +when one or more +.i key +arguments are provided, pass each numeric +.i key +to +.br getservbynumber (3) +and each nonnumeric +.i key +to +.br getservbyname (3) +and display the result. +.tp +.b shadow +when no +.i key +is provided, use +.br setspent (3), +.br getspent (3), +and +.br endspent (3) +to enumerate the shadow database. +when one or more +.i key +arguments are provided, pass each +.i key +in succession to +.br getspnam (3) +and display the result. +.re +.sh options +.tp +.br \-s\ \fiservice\fp ", " \-\-service\ \fiservice\fp +.\" commit 9d0881aa76b399e6a025c5cf44bebe2ae0efa8af (glibc) +override all databases with the specified service. +(since glibc 2.2.5.) +.tp +.br \-s\ \fidatabase\fp:\fiservice\fp ", "\ +\-\-service\ \fidatabase\fp:\fiservice\fp +.\" commit b4f6f4be85d32b9c03361c38376e36f08100e3e8 (glibc) +override only specified databases with the specified service. +the option may be used multiple times, +but only the last service for each database will be used. +(since glibc 2.4.) +.tp +.br \-i ", " \-\-no\-idn +.\" commit a160f8d808cf8020b13bd0ef4a9eaf3c11f964ad (glibc) +disables idn encoding in lookups for +.br ahosts / getaddrinfo (3) +(since glibc-2.13.) +.tp +.br \-? ", " \-\-help +print a usage summary and exit. +.tp +.b "\-\-usage" +print a short usage summary and exit. +.tp +.br \-v ", " \-\-version +print the version number, license, and disclaimer of warranty for +.br getent . +.sh exit status +one of the following exit values can be returned by +.br getent : +.rs 3 +.tp +.b 0 +command completed successfully. +.tp +.b 1 +missing arguments, or +.i database +unknown. +.tp +.b 2 +one or more supplied +.i key +could not be found in the +.ir database . +.tp +.b 3 +enumeration not supported on this +.ir database . +.re +.sh see also +.br nsswitch.conf (5) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/asprintf.3 + +.\" copyright (c) 1992 drew eckhardt (drew@cs.colorado.edu), march 28, 1992 +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified by michael haardt +.\" modified 1993-07-21 by rik faith +.\" modified 1994-08-21 by michael chastain +.\" modified 1996-06-13 by aeb +.\" modified 1996-11-06 by eric s. raymond +.\" modified 1997-08-21 by joseph s. myers +.\" modified 2004-06-23 by michael kerrisk +.\" +.th chroot 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +chroot \- change root directory +.sh synopsis +.nf +.b #include +.pp +.bi "int chroot(const char *" path ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br chroot (): +.nf + since glibc 2.2.2: + _xopen_source && ! (_posix_c_source >= 200112l) + || /* since glibc 2.20: */ _default_source + || /* glibc <= 2.19: */ _bsd_source + before glibc 2.2.2: + none +.fi +.sh description +.br chroot () +changes the root directory of the calling process to that specified in +.ir path . +this directory will be used for pathnames beginning with \fi/\fp. +the root directory is inherited by all children of the calling process. +.pp +only a privileged process (linux: one with the +.b cap_sys_chroot +capability in its user namespace) may call +.br chroot (). +.pp +this call changes an ingredient in the pathname resolution process +and does nothing else. +in particular, it is not intended to be used +for any kind of security purpose, neither to fully sandbox a process nor +to restrict filesystem system calls. +in the past, +.br chroot () +has been used by daemons to restrict themselves prior to passing paths +supplied by untrusted users to system calls such as +.br open (2). +however, if a folder is moved out of the chroot directory, an attacker +can exploit that to get out of the chroot directory as well. +the easiest way to do that is to +.br chdir (2) +to the to-be-moved directory, wait for it to be moved out, then open a +path like ../../../etc/passwd. +.pp +.\" this is how the "slightly trickier variation" works: +.\" https://github.com/qubesos/qubes-secpack/blob/master/qsbs/qsb-014-2015.txt#l142 +a slightly +trickier variation also works under some circumstances if +.br chdir (2) +is not permitted. +if a daemon allows a "chroot directory" to be specified, +that usually means that if you want to prevent remote users from accessing +files outside the chroot directory, you must ensure that folders are never +moved out of it. +.pp +this call does not change the current working directory, +so that after the call \(aq\fi.\fp\(aq can +be outside the tree rooted at \(aq\fi/\fp\(aq. +in particular, the superuser can escape from a "chroot jail" +by doing: +.pp +.in +4n +.ex +mkdir foo; chroot foo; cd .. +.ee +.in +.pp +this call does not close open file descriptors, and such file +descriptors may allow access to files outside the chroot tree. +.sh return value +on success, zero is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +depending on the filesystem, other errors can be returned. +the more general errors are listed below: +.tp +.b eacces +search permission is denied on a component of the path prefix. +(see also +.br path_resolution (7).) +.\" also search permission is required on the final component, +.\" maybe just to guarantee that it is a directory? +.tp +.b efault +.i path +points outside your accessible address space. +.tp +.b eio +an i/o error occurred. +.tp +.b eloop +too many symbolic links were encountered in resolving +.ir path . +.tp +.b enametoolong +.i path +is too long. +.tp +.b enoent +the file does not exist. +.tp +.b enomem +insufficient kernel memory was available. +.tp +.b enotdir +a component of +.i path +is not a directory. +.tp +.b eperm +the caller has insufficient privilege. +.sh conforming to +svr4, 4.4bsd, susv2 (marked legacy). +this function is not part of posix.1-2001. +.\" svr4 documents additional eintr, enolink and emultihop error conditions. +.\" x/open does not document eio, enomem or efault error conditions. +.sh notes +a child process created via +.br fork (2) +inherits its parent's root directory. +the root directory is left unchanged by +.br execve (2). +.pp +the magic symbolic link, +.ir /proc/[pid]/root , +can be used to discover a process's root directory; see +.br proc (5) +for details. +.pp +freebsd has a stronger +.br jail () +system call. +.sh see also +.br chroot (1), +.br chdir (2), +.br pivot_root (2), +.br path_resolution (7), +.br switch_root (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/isgreater.3 + +.so man3/getservent.3 + +.so man3/pthread_spin_lock.3 + +.so man3/cmsg.3 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sun jul 25 10:40:44 1993 by rik faith (faith@cs.unc.edu) +.th strcoll 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +strcoll \- compare two strings using the current locale +.sh synopsis +.nf +.b #include +.pp +.bi "int strcoll(const char *" s1 ", const char *" s2 ); +.fi +.sh description +the +.br strcoll () +function compares the two strings +.i s1 +and +.ir s2 . +it returns an integer less than, equal to, or greater +than zero if +.i s1 +is found, respectively, to be less than, +to match, or be greater than +.ir s2 . +the comparison is based on +strings interpreted as appropriate for the program's current locale +for category +.br lc_collate . +(see +.br setlocale (3).) +.sh return value +the +.br strcoll () +function returns an integer less than, equal to, +or greater than zero if +.i s1 +is found, respectively, to be less +than, to match, or be greater than +.ir s2 , +when both are interpreted +as appropriate for the current locale. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br strcoll () +t} thread safety mt-safe locale +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c89, c99, svr4, 4.3bsd. +.sh notes +in the +.i "posix" +or +.i "c" +locales +.br strcoll () +is equivalent to +.br strcmp (3). +.sh see also +.br bcmp (3), +.br memcmp (3), +.br setlocale (3), +.br strcasecmp (3), +.br strcmp (3), +.br string (3), +.br strxfrm (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" +.\" modified sat jul 24 19:37:37 1993 by rik faith (faith@cs.unc.edu) +.\" modified mon may 27 22:40:48 1996 by martin schulze (joey@linux.de) +.\" +.th fgetpwent 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +fgetpwent \- get password file entry +.sh synopsis +.nf +.b #include +.b #include +.b #include +.pp +.bi "struct passwd *fgetpwent(file *" stream ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br fgetpwent (): +.nf + since glibc 2.19: + _default_source + glibc 2.19 and earlier: + _svid_source +.fi +.sh description +the +.br fgetpwent () +function returns a pointer to a structure containing +the broken out fields of a line in the file \fistream\fp. +the first time it is called it returns the first entry; +thereafter, it returns successive entries. +the file referred to by +.i stream +must have the same format as +.i /etc/passwd +(see +.br passwd (5)). +.pp +the \fipasswd\fp structure is defined in \fi\fp as follows: +.pp +.in +4n +.ex +struct passwd { + char *pw_name; /* username */ + char *pw_passwd; /* user password */ + uid_t pw_uid; /* user id */ + gid_t pw_gid; /* group id */ + char *pw_gecos; /* real name */ + char *pw_dir; /* home directory */ + char *pw_shell; /* shell program */ +}; +.ee +.in +.sh return value +the +.br fgetpwent () +function returns a pointer to a +.i passwd +structure, or null if +there are no more entries or an error occurs. +in the event of an error, +.i errno +is set to indicate the error. +.sh errors +.tp +.b enomem +insufficient memory to allocate +.i passwd +structure. +.sh files +.tp +.i /etc/passwd +password database file +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br fgetpwent () +t} thread safety mt-unsafe race:fgetpwent +.te +.hy +.ad +.sp 1 +.\" fixme: the marking is different from that in the glibc manual, +.\" which has: +.\" +.\" fgetpwent: mt-unsafe race:fpwent +.\" +.\" we think race:fpwent in glibc maybe hard for users to understand, +.\" and have sent a patch to the gnu libc community for changing it to +.\" race:fgetpwent, however, something about the copyright impeded the +.\" progress. +.sh conforming to +svr4. +.sh see also +.br endpwent (3), +.br fgetpwent_r (3), +.br fopen (3), +.br getpw (3), +.br getpwent (3), +.br getpwnam (3), +.br getpwuid (3), +.br putpwent (3), +.br setpwent (3), +.br passwd (5) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2012 by michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th mallopt 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +mallopt \- set memory allocation parameters +.sh synopsis +.nf +.b #include +.pp +.bi "int mallopt(int " param ", int " value ); +.fi +.sh description +the +.br mallopt () +function adjusts parameters that control the behavior of the +memory-allocation functions (see +.br malloc (3)). +the +.ir param +argument specifies the parameter to be modified, and +.i value +specifies the new value for that parameter. +.pp +the following values can be specified for +.ir param : +.tp +.br m_arena_max +if this parameter has a nonzero value, +it defines a hard limit on the maximum number of arenas that can be created. +an arena represents a pool of memory that can be used by +.br malloc (3) +(and similar) calls to service allocation requests. +arenas are thread safe and +therefore may have multiple concurrent memory requests. +the trade-off is between the number of threads and the number of arenas. +the more arenas you have, the lower the per-thread contention, +but the higher the memory usage. +.ip +the default value of this parameter is 0, +meaning that the limit on the number of arenas is determined +according to the setting of +.br m_arena_test . +.ip +this parameter has been available since glibc 2.10 via +.br \-\-enable\-experimental\-malloc , +and since glibc 2.15 by default. +in some versions of the allocator there was no limit on the number +of created arenas (e.g., centos 5, rhel 5). +.ip +when employing newer glibc versions, applications may in +some cases exhibit high contention when accessing arenas. +in these cases, it may be beneficial to increase +.b m_arena_max +to match the number of threads. +this is similar in behavior to strategies taken by tcmalloc and jemalloc +(e.g., per-thread allocation pools). +.tp +.br m_arena_test +this parameter specifies a value, in number of arenas created, +at which point the system configuration will be examined +to determine a hard limit on the number of created arenas. +(see +.b m_arena_max +for the definition of an arena.) +.ip +the computation of the arena hard limit is implementation-defined +and is usually calculated as a multiple of the number of available cpus. +once the hard limit is computed, the result is final and constrains +the total number of arenas. +.ip +the default value for the +.b m_arena_test +parameter is 2 on systems where +.ir sizeof(long) +is 4; otherwise the default value is 8. +.ip +this parameter has been available since glibc 2.10 via +.br \-\-enable\-experimental\-malloc , +and since glibc 2.15 by default. +.ip +the value of +.b m_arena_test +is not used when +.b m_arena_max +has a nonzero value. +.tp +.br m_check_action +setting this parameter controls how glibc responds when various kinds +of programming errors are detected (e.g., freeing the same pointer twice). +the 3 least significant bits (2, 1, and 0) of the value assigned +to this parameter determine the glibc behavior, as follows: +.rs +.tp +bit 0 +if this bit is set, then print a one-line message on +.i stderr +that provides details about the error. +the message starts with the string "***\ glibc detected\ ***", +followed by the program name, +the name of the memory-allocation function in which the error was detected, +a brief description of the error, +and the memory address where the error was detected. +.tp +bit 1 +if this bit is set, then, +after printing any error message specified by bit 0, +the program is terminated by calling +.br abort (3). +in glibc versions since 2.4, +if bit 0 is also set, +then, between printing the error message and aborting, +the program also prints a stack trace in the manner of +.br backtrace (3), +and prints the process's memory mapping in the style of +.ir /proc/[pid]/maps +(see +.br proc (5)). +.tp +bit 2 (since glibc 2.4) +this bit has an effect only if bit 0 is also set. +if this bit is set, +then the one-line message describing the error is simplified +to contain just the name of the function where the error +was detected and the brief description of the error. +.re +.ip +the remaining bits in +.i value +are ignored. +.ip +combining the above details, +the following numeric values are meaningful for +.br m_check_action : +.rs 12 +.ip 0 3 +ignore error conditions; continue execution (with undefined results). +.ip 1 +print a detailed error message and continue execution. +.ip 2 +abort the program. +.ip 3 +print detailed error message, stack trace, and memory mappings, +and abort the program. +.ip 5 +print a simple error message and continue execution. +.ip 7 +print simple error message, stack trace, and memory mappings, +and abort the program. +.re +.ip +since glibc 2.3.4, the default value for the +.br m_check_action +parameter is 3. +in glibc version 2.3.3 and earlier, the default value is 1. +.ip +using a nonzero +.b m_check_action +value can be useful because otherwise a crash may happen much later, +and the true cause of the problem is then very hard to track down. +.tp +.br m_mmap_max +.\" the following text adapted from comments in the glibc source: +this parameter specifies the maximum number of allocation requests that +may be simultaneously serviced using +.br mmap (2). +this parameter exists because some systems have a limited number +of internal tables for use by +.br mmap (2), +and using more than a few of them may degrade performance. +.ip +the default value is 65,536, +a value which has no special significance and +which serves only as a safeguard. +setting this parameter to 0 disables the use of +.br mmap (2) +for servicing large allocation requests. +.tp +.br m_mmap_threshold +for allocations greater than or equal to the limit specified (in bytes) by +.br m_mmap_threshold +that can't be satisfied from the free list, +the memory-allocation functions employ +.br mmap (2) +instead of increasing the program break using +.br sbrk (2). +.ip +allocating memory using +.br mmap (2) +has the significant advantage that the allocated memory blocks +can always be independently released back to the system. +(by contrast, +the heap can be trimmed only if memory is freed at the top end.) +on the other hand, there are some disadvantages to the use of +.br mmap (2): +deallocated space is not placed on the free list +for reuse by later allocations; +memory may be wasted because +.br mmap (2) +allocations must be page-aligned; +and the kernel must perform the expensive task of zeroing out +memory allocated via +.br mmap (2). +balancing these factors leads to a default setting of 128*1024 for the +.br m_mmap_threshold +parameter. +.ip +the lower limit for this parameter is 0. +the upper limit is +.br default_mmap_threshold_max : +512*1024 on 32-bit systems or +.ir 4*1024*1024*sizeof(long) +on 64-bit systems. +.ip +.ir note: +nowadays, glibc uses a dynamic mmap threshold by default. +the initial value of the threshold is 128*1024, +but when blocks larger than the current threshold and less than or equal to +.br default_mmap_threshold_max +are freed, +the threshold is adjusted upward to the size of the freed block. +when dynamic mmap thresholding is in effect, +the threshold for trimming the heap is also dynamically adjusted +to be twice the dynamic mmap threshold. +dynamic adjustment of the mmap threshold is disabled if any of the +.br m_trim_threshold , +.br m_top_pad , +.br m_mmap_threshold , +or +.br m_mmap_max +parameters is set. +.tp +.br m_mxfast " (since glibc 2.3)" +.\" the following text adapted from comments in the glibc sources: +set the upper limit for memory allocation requests that are satisfied +using "fastbins". +(the measurement unit for this parameter is bytes.) +fastbins are storage areas that hold deallocated blocks of memory +of the same size without merging adjacent free blocks. +subsequent reallocation of blocks of the same size can be handled +very quickly by allocating from the fastbin, +although memory fragmentation and the overall memory footprint +of the program can increase. +.ip +the default value for this parameter is +.ir "64*sizeof(size_t)/4" +(i.e., 64 on 32-bit architectures). +the range for this parameter is 0 to +.ir "80*sizeof(size_t)/4" . +setting +.b m_mxfast +to 0 disables the use of fastbins. +.tp +.br m_perturb " (since glibc 2.4)" +if this parameter is set to a nonzero value, +then bytes of allocated memory (other than allocations via +.br calloc (3)) +are initialized to the complement of the value +in the least significant byte of +.ir value , +and when allocated memory is released using +.br free (3), +the freed bytes are set to the least significant byte of +.ir value . +this can be useful for detecting errors where programs +incorrectly rely on allocated memory being initialized to zero, +or reuse values in memory that has already been freed. +.ip +the default value for this parameter is 0. +.tp +.br m_top_pad +this parameter defines the amount of padding to employ when calling +.br sbrk (2) +to modify the program break. +(the measurement unit for this parameter is bytes.) +this parameter has an effect in the following circumstances: +.rs +.ip * 3 +when the program break is increased, then +.br m_top_pad +bytes are added to the +.br sbrk (2) +request. +.ip * +when the heap is trimmed as a consequence of calling +.br free (3) +(see the discussion of +.br m_trim_threshold ) +this much free space is preserved at the top of the heap. +.re +.ip +in either case, +the amount of padding is always rounded to a system page boundary. +.ip +modifying +.br m_top_pad +is a trade-off between increasing the number of system calls +(when the parameter is set low) +and wasting unused memory at the top of the heap +(when the parameter is set high). +.ip +the default value for this parameter is 128*1024. +.\" default_top_pad in glibc source +.tp +.br m_trim_threshold +when the amount of contiguous free memory at the top of the heap +grows sufficiently large, +.br free (3) +employs +.br sbrk (2) +to release this memory back to the system. +(this can be useful in programs that continue to execute for +a long period after freeing a significant amount of memory.) +the +.br m_trim_threshold +parameter specifies the minimum size (in bytes) that +this block of memory must reach before +.br sbrk (2) +is used to trim the heap. +.ip +the default value for this parameter is 128*1024. +setting +.br m_trim_threshold +to \-1 disables trimming completely. +.ip +modifying +.br m_trim_threshold +is a trade-off between increasing the number of system calls +(when the parameter is set low) +and wasting unused memory at the top of the heap +(when the parameter is set high). +.\" +.ss environment variables +a number of environment variables can be defined +to modify some of the same parameters as are controlled by +.br mallopt (). +using these variables has the advantage that the source code +of the program need not be changed. +to be effective, these variables must be defined before the +first call to a memory-allocation function. +(if the same parameters are adjusted via +.br mallopt (), +then the +.br mallopt () +settings take precedence.) +for security reasons, +these variables are ignored in set-user-id and set-group-id programs. +.pp +the environment variables are as follows +(note the trailing underscore at the end of the name of some variables): +.tp +.br malloc_arena_max +controls the same parameter as +.br mallopt () +.br m_arena_max . +.tp +.br malloc_arena_test +controls the same parameter as +.br mallopt () +.br m_arena_test . +.tp +.br malloc_check_ +this environment variable controls the same parameter as +.br mallopt () +.br m_check_action . +if this variable is set to a nonzero value, +then a special implementation of the memory-allocation functions is used. +(this is accomplished using the +.br malloc_hook (3) +feature.) +this implementation performs additional error checking, +but is slower +.\" on glibc 2.12/x86, a simple malloc()+free() loop is about 70% slower +.\" when malloc_check_ was set. +than the standard set of memory-allocation functions. +(this implementation does not detect all possible errors; +memory leaks can still occur.) +.ip +the value assigned to this environment variable should be a single digit, +whose meaning is as described for +.br m_check_action . +any characters beyond the initial digit are ignored. +.ip +for security reasons, the effect of +.br malloc_check_ +is disabled by default for set-user-id and set-group-id programs. +however, if the file +.ir /etc/suid\-debug +exists (the content of the file is irrelevant), then +.br malloc_check_ +also has an effect for set-user-id and set-group-id programs. +.tp +.br malloc_mmap_max_ +controls the same parameter as +.br mallopt () +.br m_mmap_max . +.tp +.br malloc_mmap_threshold_ +controls the same parameter as +.br mallopt () +.br m_mmap_threshold . +.tp +.br malloc_perturb_ +controls the same parameter as +.br mallopt () +.br m_perturb . +.tp +.br malloc_trim_threshold_ +controls the same parameter as +.br mallopt () +.br m_trim_threshold . +.tp +.br malloc_top_pad_ +controls the same parameter as +.br mallopt () +.br m_top_pad . +.sh return value +on success, +.br mallopt () +returns 1. +on error, it returns 0. +.sh errors +on error, +.i errno +is +.i not +set. +.\" .sh versions +.\" available already in glibc 2.0, possibly earlier +.sh conforming to +this function is not specified by posix or the c standards. +a similar function exists on many system v derivatives, +but the range of values for +.ir param +varies across systems. +the svid defined options +.br m_mxfast , +.br m_nlblks , +.br m_grain , +and +.br m_keep , +but only the first of these is implemented in glibc. +.\" .sh notes +.sh bugs +specifying an invalid value for +.i param +does not generate an error. +.pp +a calculation error within the glibc implementation means that +a call of the form: +.\" fixme . this looks buggy: +.\" setting the m_mxfast limit rounds up: (s + size_sz) & ~malloc_align_mask) +.\" malloc requests are rounded up: +.\" (req) + size_sz + malloc_align_mask) & ~malloc_align_mask +.\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=12129 +.pp +.in +4n +.ex +mallopt(m_mxfast, n) +.ee +.in +.pp +does not result in fastbins being employed for all allocations of size up to +.ir n . +to ensure desired results, +.i n +should be rounded up to the next multiple greater than or equal to +.ir (2k+1)*sizeof(size_t) , +where +.i k +is an integer. +.\" bins are multiples of 2 * sizeof(size_t) + sizeof(size_t) +.pp +if +.br mallopt () +is used to set +.br m_perturb , +then, as expected, the bytes of allocated memory are initialized +to the complement of the byte in +.ir value , +and when that memory is freed, +the bytes of the region are initialized to the byte specified in +.ir value . +however, there is an +.ri off-by- sizeof(size_t) +error in the implementation: +.\" fixme . http://sources.redhat.com/bugzilla/show_bug.cgi?id=12140 +instead of initializing precisely the block of memory +being freed by the call +.ir free(p) , +the block starting at +.i p+sizeof(size_t) +is initialized. +.sh examples +the program below demonstrates the use of +.br m_check_action . +if the program is supplied with an (integer) command-line argument, +then that argument is used to set the +.br m_check_action +parameter. +the program then allocates a block of memory, +and frees it twice (an error). +.pp +the following shell session shows what happens when we run this program +under glibc, with the default value for +.br m_check_action : +.pp +.in +4n +.ex +$ \fb./a.out\fp +main(): returned from first free() call +*** glibc detected *** ./a.out: double free or corruption (top): 0x09d30008 *** +======= backtrace: ========= +/lib/libc.so.6(+0x6c501)[0x523501] +/lib/libc.so.6(+0x6dd70)[0x524d70] +/lib/libc.so.6(cfree+0x6d)[0x527e5d] +\&./a.out[0x80485db] +/lib/libc.so.6(__libc_start_main+0xe7)[0x4cdce7] +\&./a.out[0x8048471] +======= memory map: ======== +001e4000\-001fe000 r\-xp 00000000 08:06 1083555 /lib/libgcc_s.so.1 +001fe000\-001ff000 r\-\-p 00019000 08:06 1083555 /lib/libgcc_s.so.1 +[some lines omitted] +b7814000\-b7817000 rw\-p 00000000 00:00 0 +bff53000\-bff74000 rw\-p 00000000 00:00 0 [stack] +aborted (core dumped) +.ee +.in +.pp +the following runs show the results when employing other values for +.br m_check_action : +.pp +.in +4n +.ex +$ \fb./a.out 1\fp # diagnose error and continue +main(): returned from first free() call +*** glibc detected *** ./a.out: double free or corruption (top): 0x09cbe008 *** +main(): returned from second free() call +$ \fb./a.out 2\fp # abort without error message +main(): returned from first free() call +aborted (core dumped) +$ \fb./a.out 0\fp # ignore error and continue +main(): returned from first free() call +main(): returned from second free() call +.ee +.in +.pp +the next run shows how to set the same parameter using the +.b malloc_check_ +environment variable: +.pp +.in +4n +.ex +$ \fbmalloc_check_=1 ./a.out\fp +main(): returned from first free() call +*** glibc detected *** ./a.out: free(): invalid pointer: 0x092c2008 *** +main(): returned from second free() call +.ee +.in +.ss program source +\& +.ex +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + char *p; + + if (argc > 1) { + if (mallopt(m_check_action, atoi(argv[1])) != 1) { + fprintf(stderr, "mallopt() failed"); + exit(exit_failure); + } + } + + p = malloc(1000); + if (p == null) { + fprintf(stderr, "malloc() failed"); + exit(exit_failure); + } + + free(p); + printf("main(): returned from first free() call\en"); + + free(p); + printf("main(): returned from second free() call\en"); + + exit(exit_success); +} +.ee +.sh see also +.ad l +.nh +.br mmap (2), +.br sbrk (2), +.br mallinfo (3), +.br malloc (3), +.br malloc_hook (3), +.br malloc_info (3), +.br malloc_stats (3), +.br malloc_trim (3), +.br mcheck (3), +.br mtrace (3), +.br posix_memalign (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/fenv.3 + +.\" copyright (c) 2000 andries brouwer (aeb@cwi.nl) +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th getpass 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +getpass \- get a password +.sh synopsis +.nf +.b #include +.pp +.bi "char *getpass(const char *" prompt ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br getpass (): +.nf + since glibc 2.2.2: + _xopen_source && ! (_posix_c_source >= 200112l) + || /* glibc since 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source + before glibc 2.2.2: + none +.fi +.sh description +this function is obsolete. +do not use it. +if you want to read input without terminal echoing enabled, +see the description of the +.i echo +flag in +.br termios (3). +.pp +the +.br getpass () +function opens +.i /dev/tty +(the controlling terminal of the process), outputs the string +.ir prompt , +turns off echoing, reads one line (the "password"), +restores the terminal state and closes +.i /dev/tty +again. +.sh return value +the function +.br getpass () +returns a pointer to a static buffer containing (the first +.b pass_max +bytes of) the password without the trailing +newline, terminated by a null byte (\(aq\e0\(aq). +this buffer may be overwritten by a following call. +on error, the terminal state is restored, +.i errno +is set to indicate the error, and null is returned. +.sh errors +.tp +.b enxio +the process does not have a controlling terminal. +.sh files +.i /dev/tty +.\" .sh history +.\" a +.\" .br getpass () +.\" function appeared in version 7 at&t unix. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br getpass () +t} thread safety mt-unsafe term +.te +.hy +.ad +.sp 1 +.sh conforming to +present in susv2, but marked legacy. +removed in posix.1-2001. +.sh notes +.\" for libc4 and libc5, the prompt is not written to +.\" .i /dev/tty +.\" but to +.\" .ir stderr . +.\" moreover, if +.\" .i /dev/tty +.\" cannot be opened, the password is read from +.\" .ir stdin . +.\" the static buffer has length 128 so that only the first 127 +.\" bytes of the password are returned. +.\" while reading the password, signal generation +.\" .rb ( sigint , +.\" .br sigquit , +.\" .br sigstop , +.\" .br sigtstp ) +.\" is disabled and the corresponding characters +.\" (usually control-c, control-\e, control-z and control-y) +.\" are transmitted as part of the password. +.\" since libc 5.4.19 also line editing is disabled, so that also +.\" backspace and the like will be seen as part of the password. +. +in the gnu c library implementation, if +.i /dev/tty +cannot be opened, the prompt is written to +.i stderr +and the password is read from +.ir stdin . +there is no limit on the length of the password. +line editing is not disabled. +.pp +according to susv2, the value of +.b pass_max +must be defined in +.i +in case it is smaller than 8, and can in any case be obtained using +.ir sysconf(_sc_pass_max) . +however, posix.2 withdraws the constants +.b pass_max +and +.br _sc_pass_max , +and the function +.br getpass (). +.\" libc4 and libc5 have never supported +.\" .b pass_max +.\" or +.\" .br _sc_pass_max . +the glibc version accepts +.b _sc_pass_max +and returns +.b bufsiz +(e.g., 8192). +.sh bugs +the calling process should zero the password as soon as possible to avoid +leaving the cleartext password visible in the process's address space. +.sh see also +.br crypt (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/openpty.3 + +.so man3/rpc.3 + +.so man3/inet.3 + +.so man3/argz_add.3 + +.\" copyright (c) 2020 by michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th pidfd_getfd 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +pidfd_getfd \- obtain a duplicate of another process's file descriptor +.sh synopsis +.nf +.br "#include " " /* definition of " sys_* " constants */" +.b #include +.pp +.bi "int syscall(sys_pidfd_getfd, int " pidfd ", int " targetfd , +.bi " unsigned int " flags ); +.fi +.pp +.ir note : +glibc provides no wrapper for +.br pidfd_getfd (), +necessitating the use of +.br syscall (2). +.sh description +the +.br pidfd_getfd () +system call allocates a new file descriptor in the calling process. +this new file descriptor is a duplicate of an existing file descriptor, +.ir targetfd , +in the process referred to by the pid file descriptor +.ir pidfd . +.pp +the duplicate file descriptor refers to the same open file description (see +.br open (2)) +as the original file descriptor in the process referred to by +.ir pidfd . +the two file descriptors thus share file status flags and file offset. +furthermore, operations on the underlying file object +(for example, assigning an address to a socket object using +.br bind (2)) +can equally be performed via the duplicate file descriptor. +.pp +the close-on-exec flag +.rb ( fd_cloexec ; +see +.br fcntl (2)) +is set on the file descriptor returned by +.br pidfd_getfd (). +.pp +the +.i flags +argument is reserved for future use. +currently, it must be specified as 0. +.pp +permission to duplicate another process's file descriptor +is governed by a ptrace access mode +.b ptrace_mode_attach_realcreds +check (see +.br ptrace (2)). +.sh return value +on success, +.br pidfd_getfd () +returns a file descriptor (a nonnegative integer). +on error, \-1 is returned and +.i errno +is set to indicate the error. +.sh errors +.tp +.b ebadf +.i pidfd +is not a valid pid file descriptor. +.tp +.b ebadf +.i targetfd +is not an open file descriptor in the process referred to by +.ir pidfd . +.tp +.b einval +.i flags +is not 0. +.tp +.b emfile +the per-process limit on the number of open file descriptors has been reached +(see the description of +.br rlimit_nofile +in +.br getrlimit (2)). +.tp +.b enfile +the system-wide limit on the total number of open files has been reached. +.tp +.b eperm +the calling process did not have +.b ptrace_mode_attach_realcreds +permissions (see +.br ptrace (2)) +over the process referred to by +.ir pidfd . +.tp +.b esrch +the process referred to by +.i pidfd +does not exist +(i.e., it has terminated and been waited on). +.sh versions +.br pidfd_getfd () +first appeared in linux 5.6. +.\" commit 8649c322f75c96e7ced2fec201e123b2b073bf09 +.sh conforming to +.br pidfd_getfd () +is linux specific. +.sh notes +for a description of pid file descriptors, see +.br pidfd_open (2). +.pp +the effect of +.br pidfd_getfd () +is similar to the use of +.br scm_rights +messages described in +.br unix (7), +but differs in the following respects: +.ip \(bu 2 +in order to pass a file descriptor using an +.br scm_rights +message, +the two processes must first establish a unix domain socket connection. +.ip \(bu +the use of +.br scm_rights +requires cooperation on the part of the process whose +file descriptor is being copied. +by contrast, no such cooperation is necessary when using +.br pidfd_getfd (). +.ip \(bu +the ability to use +.br pidfd_getfd () +is restricted by a +.br ptrace_mode_attach_realcreds +ptrace access mode check. +.sh see also +.br clone3 (2), +.br dup (2), +.br kcmp (2), +.br pidfd_open (2) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" iso/iec 9899:1999 +.\" +.th iswxdigit 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +iswxdigit \- test for hexadecimal digit wide character +.sh synopsis +.nf +.b #include +.pp +.bi "int iswxdigit(wint_t " wc ); +.fi +.sh description +the +.br iswxdigit () +function is the wide-character equivalent of the +.br isxdigit (3) +function. +it tests whether +.i wc +is a wide character +belonging to the wide-character class "xdigit". +.pp +the wide-character class "xdigit" is a subclass of the wide-character class +"alnum", and therefore also a subclass of the wide-character class "graph" and +of the wide-character class "print". +.pp +being a subclass of the wide-character class "print", the wide-character class +"xdigit" is disjoint from the wide-character class "cntrl". +.pp +being a subclass of the wide-character class "graph", the wide-character class +"xdigit" is disjoint from the wide-character class "space" and its subclass +"blank". +.pp +being a subclass of the wide-character class "alnum", the wide-character class +"xdigit" is disjoint from the wide-character class "punct". +.pp +the wide-character class "xdigit" always contains at least the +letters \(aqa\(aq to \(aqf\(aq, \(aqa\(aq to \(aqf\(aq +and the digits \(aq0\(aq to \(aq9\(aq. +.sh return value +the +.br iswxdigit () +function returns nonzero if +.i wc +is a wide character +belonging to the wide-character class "xdigit". +otherwise, it returns zero. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br iswxdigit () +t} thread safety mt-safe locale +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh notes +the behavior of +.br iswxdigit () +depends on the +.b lc_ctype +category of the +current locale. +.sh see also +.br iswctype (3), +.br isxdigit (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/inotify_init.2 + +.\" copyright (c) 1998 andries brouwer (aeb@cwi.nl), 24 september 1998 +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified, 27 may 2004, michael kerrisk +.\" added notes on capability requirements +.\" +.th reboot 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +reboot \- reboot or enable/disable ctrl-alt-del +.sh synopsis +.nf +.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 " \ +"/* definition of " linux_reboot_* " constants */" +.br "#include " "/* definition of " sys_* " constants */" +.b #include +.pp +.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 +.rb " symbolic names " rb_* ", and the library call is a 1-argument" + wrapper around the system call: */ +.pp +.br "#include " "/* definition of " rb_* " constants */" +.b #include +.pp +.bi "int reboot(int " cmd ); +.fi +.sh description +the +.br reboot () +call reboots the system, or enables/disables the reboot keystroke +(abbreviated cad, since the default is ctrl-alt-delete; +it can be changed using +.br loadkeys (1)). +.pp +this system call fails (with the error +.br einval ) +unless +.i magic +equals +.b linux_reboot_magic1 +(that is, 0xfee1dead) and +.i magic2 +equals +.b linux_reboot_magic2 +(that is, 672274793). +however, since 2.1.17 also +.b linux_reboot_magic2a +(that is, 85072278) +and since 2.1.97 also +.b linux_reboot_magic2b +(that is, 369367448) +and since 2.5.71 also +.b linux_reboot_magic2c +(that is, 537993216) +are permitted as values for +.ir magic2 . +(the hexadecimal values of these constants are meaningful.) +.pp +the +.i cmd +argument can have the following values: +.tp +.b linux_reboot_cmd_cad_off +.rb ( rb_disable_cad , +0). +cad is disabled. +this means that the cad keystroke will cause a +.b sigint +signal to be +sent to init (process 1), whereupon this process may decide upon a +proper action (maybe: kill all processes, sync, reboot). +.tp +.b linux_reboot_cmd_cad_on +.rb ( rb_enable_cad , +0x89abcdef). +cad is enabled. +this means that the cad keystroke will immediately cause +the action associated with +.br linux_reboot_cmd_restart . +.tp +.b linux_reboot_cmd_halt +.rb ( rb_halt_system , +0xcdef0123; since linux 1.1.76). +the message "system halted." is printed, and the system is halted. +control is given to the rom monitor, if there is one. +if not preceded by a +.br sync (2), +data will be lost. +.tp +.br linux_reboot_cmd_kexec +.rb ( rb_kexec , +0x45584543, since linux 2.6.13). +execute a kernel that has been loaded earlier with +.br kexec_load (2). +this option is available only if the kernel was configured with +.br config_kexec . +.tp +.b linux_reboot_cmd_power_off +.rb ( rb_power_off , +0x4321fedc; since linux 2.1.30). +the message "power down." is printed, the system is stopped, +and all power is removed from the system, if possible. +if not preceded by a +.br sync (2), +data will be lost. +.tp +.b linux_reboot_cmd_restart +.rb ( rb_autoboot , +0x1234567). +the message "restarting system." is printed, and a default +restart is performed immediately. +if not preceded by a +.br sync (2), +data will be lost. +.tp +.b linux_reboot_cmd_restart2 +(0xa1b2c3d4; since linux 2.1.30). +the message "restarting system with command \(aq%s\(aq" is printed, +and a restart (using the command string given in +.ir arg ) +is performed immediately. +if not preceded by a +.br sync (2), +data will be lost. +.tp +.br linux_reboot_cmd_sw_suspend +.rb ( rb_sw_suspend , +0xd000fce1; since linux 2.5.18). +the system is suspended (hibernated) to disk. +this option is available only if the kernel was configured with +.br config_hibernation . +.pp +only the superuser may call +.br reboot (). +.pp +the precise effect of the above actions depends on the architecture. +for the i386 architecture, the additional argument does not do +anything at present (2.1.122), but the type of reboot can be +determined by kernel command-line arguments ("reboot=...") to be +either warm or cold, and either hard or through the bios. +.\" +.ss behavior inside pid namespaces +.\" commit cf3f89214ef6a33fad60856bc5ffd7bb2fc4709b +.\" see also commit 923c7538236564c46ee80c253a416705321f13e3 +since linux 3.4, +if +.br reboot () +is called +from a pid namespace other than the initial pid namespace +with one of the +.i cmd +values listed below, +it performs a "reboot" of that namespace: +the "init" process of the pid namespace is immediately terminated, +with the effects described in +.br pid_namespaces (7). +.pp +the values that can be supplied in +.i cmd +when calling +.br reboot () +in this case are as follows: +.tp +.br linux_reboot_cmd_restart ", " linux_reboot_cmd_restart2 +the "init" process is terminated, +and +.br wait (2) +in the parent process reports that the child was killed with a +.b sighup +signal. +.tp +.br linux_reboot_cmd_power_off ", " linux_reboot_cmd_halt +the "init" process is terminated, +and +.br wait (2) +in the parent process reports that the child was killed with a +.b sigint +signal. +.pp +for the other +.i cmd +values, +.br reboot () +returns \-1 and +.i errno +is set to +.br einval . +.sh return value +for the values of +.i cmd +that stop or restart the system, +a successful call to +.br reboot () +does not return. +for the other +.i cmd +values, zero is returned on success. +in all cases, \-1 is returned on failure, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b efault +problem with getting user-space data under +.br linux_reboot_cmd_restart2 . +.tp +.b einval +bad magic numbers or \ficmd\fp. +.tp +.b eperm +the calling process has insufficient privilege to call +.br reboot (); +the caller must have the +.b cap_sys_boot +inside its user namespace. +.sh conforming to +.br reboot () +is linux-specific, +and should not be used in programs intended to be portable. +.sh see also +.br systemctl (1), +.br systemd (1), +.br kexec_load (2), +.br sync (2), +.br bootparam (7), +.br capabilities (7), +.br ctrlaltdel (8), +.br halt (8), +.br shutdown (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/ccosh.3 + +.so man3/xdr.3 + +.so man3/rpc.3 + +.\" copyright 1993 rickard e. faith (faith@cs.unc.edu) +.\" portions extracted from linux/kernel/ioport.c (no copyright notice). +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified tue aug 1 16:47 1995 by jochen karrer +.\" +.\" modified tue oct 22 08:11:14 edt 1996 by eric s. raymond +.\" modified fri nov 27 14:50:36 cet 1998 by andries brouwer +.\" modified, 27 may 2004, michael kerrisk +.\" added notes on capability requirements +.\" +.th iopl 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +iopl \- change i/o privilege level +.sh synopsis +.nf +.b #include +.pp +.bi "int iopl(int " level ); +.fi +.sh description +.br iopl () +changes the i/o privilege level of the calling thread, +as specified by the two least significant bits in +.ir level . +.pp +the i/o privilege level for a normal thread is 0. +permissions are inherited from parents to children. +.pp +this call is deprecated, is significantly slower than +.br ioperm (2), +and is only provided for older x servers which require +access to all 65536 i/o ports. +it is mostly for the i386 architecture. +on many other architectures it does not exist or will always +return an error. +.sh return value +on success, zero is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b einval +.i level +is greater than 3. +.tp +.b enosys +this call is unimplemented. +.tp +.b eperm +the calling thread has insufficient privilege to call +.br iopl (); +the +.b cap_sys_rawio +capability is required to raise the i/o privilege level +above its current value. +.sh conforming to +.br iopl () +is linux-specific and should not be used in programs that are +intended to be portable. +.sh notes +.\" libc5 treats it as a system call and has a prototype in +.\" .ir . +.\" glibc1 does not have a prototype. +glibc2 has a prototype both in +.i +and in +.ir . +avoid the latter, it is available on i386 only. +.pp +prior to linux 5.5 +.br iopl () +allowed the thread to disable interrupts while running +at a higher i/o privilege level. +this will probably crash the system, and is not recommended. +.pp +prior to linux 3.7, +on some architectures (such as i386), permissions +.i were +inherited by the child produced by +.br fork (2) +and were preserved across +.br execve (2). +this behavior was inadvertently changed in linux 3.7, +and won't be reinstated. +.sh see also +.br ioperm (2), +.br outb (2), +.br capabilities (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 2003 abhijit menon-sen +.\" and copyright (c) 2010, 2015, 2017 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" 2005-04-08 mtk, noted kernel version and added bugs +.\" 2010-10-09, mtk, document arm_fadvise64_64() +.\" +.th posix_fadvise 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +posix_fadvise \- predeclare an access pattern for file data +.sh synopsis +.nf +.b #include +.pp +.bi "int posix_fadvise(int " fd ", off_t " offset ", off_t " len \ +", int " advice ");" +.fi +.pp +.ad l +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br posix_fadvise (): +.nf + _posix_c_source >= 200112l +.fi +.sh description +programs can use +.br posix_fadvise () +to announce an intention to access +file data in a specific pattern in the future, thus allowing the kernel +to perform appropriate optimizations. +.pp +the \fiadvice\fp applies to a (not necessarily existent) region starting +at \fioffset\fp and extending for \filen\fp bytes (or until the end of +the file if \filen\fp is 0) within the file referred to by \fifd\fp. +the \fiadvice\fp is not binding; +it merely constitutes an expectation on behalf of +the application. +.pp +permissible values for \fiadvice\fp include: +.tp +.b posix_fadv_normal +indicates that the application has no advice to give about its access +pattern for the specified data. +if no advice is given for an open file, +this is the default assumption. +.tp +.b posix_fadv_sequential +the application expects to access the specified data sequentially (with +lower offsets read before higher ones). +.tp +.b posix_fadv_random +the specified data will be accessed in random order. +.tp +.b posix_fadv_noreuse +the specified data will be accessed only once. +.ip +in kernels before 2.6.18, \fbposix_fadv_noreuse\fp had the +same semantics as \fbposix_fadv_willneed\fp. +this was probably a bug; since kernel 2.6.18, this flag is a no-op. +.tp +.b posix_fadv_willneed +the specified data will be accessed in the near future. +.ip +\fbposix_fadv_willneed\fp initiates a +nonblocking read of the specified region into the page cache. +the amount of data read may be decreased by the kernel depending +on virtual memory load. +(a few megabytes will usually be fully satisfied, +and more is rarely useful.) +.tp +.b posix_fadv_dontneed +the specified data will not be accessed in the near future. +.ip +\fbposix_fadv_dontneed\fp attempts to free cached pages associated with +the specified region. +this is useful, for example, while streaming large +files. +a program may periodically request the kernel to free cached data +that has already been used, so that more useful cached pages are not +discarded instead. +.ip +requests to discard partial pages are ignored. +it is preferable to preserve needed data than discard unneeded data. +if the application requires that data be considered for discarding, then +.i offset +and +.i len +must be page-aligned. +.ip +the implementation +.i may +attempt to write back dirty pages in the specified region, +but this is not guaranteed. +any unwritten dirty pages will not be freed. +if the application wishes to ensure that dirty pages will be released, +it should call +.br fsync (2) +or +.br fdatasync (2) +first. +.sh return value +on success, zero is returned. +on error, an error number is returned. +.sh errors +.tp +.b ebadf +the \fifd\fp argument was not a valid file descriptor. +.tp +.b einval +an invalid value was specified for \fiadvice\fp. +.tp +.b espipe +the specified file descriptor refers to a pipe or fifo. +.rb ( espipe +is the error specified by posix, +but before kernel version 2.6.16, +.\" commit 87ba81dba431232548ce29d5d224115d0c2355ac +linux returned +.b einval +in this case.) +.sh versions +kernel support first appeared in linux 2.5.60; +the underlying system call is called +.br fadvise64 (). +.\" of fadvise64_64() +library support has been provided since glibc version 2.2, +via the wrapper function +.br posix_fadvise (). +.pp +since linux 3.18, +.\" commit d3ac21cacc24790eb45d735769f35753f5b56ceb +support for the underlying system call is optional, +depending on the setting of the +.b config_advise_syscalls +configuration option. +.sh conforming to +posix.1-2001, posix.1-2008. +note that the type of the +.i len +argument was changed from +.i size_t +to +.i off_t +in posix.1-2001 tc1. +.sh notes +under linux, \fbposix_fadv_normal\fp sets the readahead window to the +default size for the backing device; \fbposix_fadv_sequential\fp doubles +this size, and \fbposix_fadv_random\fp disables file readahead entirely. +these changes affect the entire file, not just the specified region +(but other open file handles to the same file are unaffected). +.pp +the contents of the kernel buffer cache can be cleared via the +.ir /proc/sys/vm/drop_caches +interface described in +.br proc (5). +.pp +one can obtain a snapshot of which pages of a file are resident +in the buffer cache by opening a file, mapping it with +.br mmap (2), +and then applying +.br mincore (2) +to the mapping. +.ss c library/kernel differences +the name of the wrapper function in the c library is +.br posix_fadvise (). +the underlying system call is called +.br fadvise64 () +(or, on some architectures, +.br fadvise64_64 ()); +the difference between the two is that the former system call +assumes that the type of the \filen\fp argument is \fisize_t\fp, +while the latter expects \filoff_t\fp there. +.ss architecture-specific variants +some architectures require +64-bit arguments to be aligned in a suitable pair of registers (see +.br syscall (2) +for further detail). +on such architectures, the call signature of +.br posix_fadvise () +shown in the synopsis would force +a register to be wasted as padding between the +.i fd +and +.i offset +arguments. +therefore, these architectures define a version of the +system call that orders the arguments suitably, +but is otherwise exactly the same as +.br posix_fadvise (). +.pp +for example, since linux 2.6.14, arm has the following system call: +.pp +.in +4n +.ex +.bi "long arm_fadvise64_64(int " fd ", int " advice , +.bi " loff_t " offset ", loff_t " len ); +.ee +.in +.pp +these architecture-specific details are generally +hidden from applications by the glibc +.br posix_fadvise () +wrapper function, +which invokes the appropriate architecture-specific system call. +.sh bugs +in kernels before 2.6.6, if +.i len +was specified as 0, then this was interpreted literally as "zero bytes", +rather than as meaning "all bytes through to the end of the file". +.sh see also +.br fincore (1), +.br mincore (2), +.br readahead (2), +.br sync_file_range (2), +.br posix_fallocate (3), +.br posix_madvise (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/list.3 + +.\" copyright (c) 2012 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th delete_module 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +delete_module \- unload a kernel module +.sh synopsis +.nf +.br "#include " " /* definition of " o_* " constants */" +.br "#include " " /* definition of " sys_* " constants */" +.br "#include +.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 () +system call attempts to remove the unused loadable module entry +identified by +.ir name . +if the module has an +.i exit +function, then that function is executed before unloading the module. +the +.ir flags +argument is used to modify the behavior of the system call, +as described below. +this system call requires privilege. +.pp +module removal is attempted according to the following rules: +.ip 1. 4 +if there are other loaded modules that depend on +(i.e., refer to symbols defined in) this module, +then the call fails. +.ip 2. +otherwise, if the reference count for the module +(i.e., the number of processes currently using the module) +is zero, then the module is immediately unloaded. +.ip 3. +if a module has a nonzero reference count, +then the behavior depends on the bits set in +.ir flags . +in normal usage (see notes), the +.br o_nonblock +flag is always specified, and the +.br o_trunc +flag may additionally be specified. +.\" o_trunc == kmod_remove_force in kmod library +.\" o_nonblock == kmod_remove_nowait in kmod library +.ip +the various combinations for +.i flags +have the following effect: +.rs 4 +.tp +.b flags == o_nonblock +the call returns immediately, with an error. +.tp +.b flags == (o_nonblock | o_trunc) +the module is unloaded immediately, +regardless of whether it has a nonzero reference count. +.tp +.b (flags & o_nonblock) == 0 +if +.i flags +does not specify +.br o_nonblock , +the following steps occur: +.rs +.ip * 3 +the module is marked so that no new references are permitted. +.ip * +if the module's reference count is nonzero, +the caller is placed in an uninterruptible sleep state +.rb ( task_uninterruptible ) +until the reference count is zero, at which point the call unblocks. +.ip * +the module is unloaded in the usual way. +.re +.re +.pp +the +.b o_trunc +flag has one further effect on the rules described above. +by default, if a module has an +.i init +function but no +.i exit +function, then an attempt to remove the module fails. +however, if +.br o_trunc +was specified, this requirement is bypassed. +.pp +using the +.b o_trunc +flag is dangerous! +if the kernel was not built with +.br config_module_force_unload , +this flag is silently ignored. +(normally, +.br config_module_force_unload +is enabled.) +using this flag taints the kernel (taint_forced_rmmod). +.sh return value +on success, zero is returned. +on error, \-1 is returned and +.i errno +is set to indicate the error. +.sh errors +.tp +.b ebusy +the module is not "live" +(i.e., it is still being initialized or is already marked for removal); +or, the module has +an +.i init +function but has no +.i exit +function, and +.b o_trunc +was not specified in +.ir flags . +.tp +.b efault +.i name +refers to a location outside the process's accessible address space. +.tp +.b enoent +no module by that name exists. +.tp +.b eperm +the caller was not privileged +(did not have the +.b cap_sys_module +capability), +or module unloading is disabled +(see +.ir /proc/sys/kernel/modules_disabled +in +.br proc (5)). +.tp +.b ewouldblock +other modules depend on this module; +or, +.br o_nonblock +was specified in +.ir flags , +but the reference count of this module is nonzero and +.b o_trunc +was not specified in +.ir flags . +.sh conforming to +.br delete_module () +is linux-specific. +.sh notes +the +.br delete_module () +system call is not supported by glibc. +no declaration is provided in glibc headers, but, through a quirk of history, +glibc versions before 2.23 did export an abi for this system call. +therefore, in order to employ this system call, +it is (before glibc 2.23) sufficient to +manually declare the interface in your code; +alternatively, you can invoke the system call using +.br syscall (2). +.pp +the uninterruptible sleep that may occur if +.br o_nonblock +is omitted from +.ir flags +is considered undesirable, because the sleeping process is left +in an unkillable state. +as at linux 3.7, specifying +.br o_nonblock +is optional, but in future kernels it is likely to become mandatory. +.ss linux 2.4 and earlier +in linux 2.4 and earlier, the system call took only one argument: +.pp +.bi " int delete_module(const char *" name ); +.pp +if +.i name +is null, all unused modules marked auto-clean are removed. +.pp +some further details of differences in the behavior of +.br delete_module () +in linux 2.4 and earlier are +.i not +currently explained in this manual page. +.sh see also +.br create_module (2), +.br init_module (2), +.br query_module (2), +.br lsmod (8), +.br modprobe (8), +.br rmmod (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2003 andries brouwer (aeb@cwi.nl) +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th strtoimax 3 2021-03-22 "" "linux programmer's manual" +.sh name +strtoimax, strtoumax \- convert string to integer +.sh synopsis +.nf +.b #include +.pp +.bi "intmax_t strtoimax(const char *restrict " nptr ", char **restrict " endptr , +.bi " int " base ); +.bi "uintmax_t strtoumax(const char *restrict " nptr ", char **restrict " endptr , +.bi " int " base ); +.fi +.sh description +these functions are just like +.br strtol (3) +and +.br strtoul (3), +except that they return a value of type +.i intmax_t +and +.ir uintmax_t , +respectively. +.sh return value +on success, the converted value is returned. +if nothing was found to convert, zero is returned. +on overflow or underflow +.b intmax_max +or +.b intmax_min +or +.b uintmax_max +is returned, and +.i errno +is set to +.br erange . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br strtoimax (), +.br strtoumax () +t} thread safety mt-safe locale +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh see also +.br imaxabs (3), +.br imaxdiv (3), +.br strtol (3), +.br strtoul (3), +.br wcstoimax (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/ioprio_set.2 + +.so man3/strerror.3 + +.so man3/ptsname.3 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified mon apr 12 12:54:34 1993, david metcalfe +.\" modified sat jul 24 19:13:52 1993, rik faith (faith@cs.unc.edu) +.th index 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +index, rindex \- locate character in string +.sh synopsis +.nf +.b #include +.pp +.bi "char *index(const char *" s ", int " c ); +.bi "char *rindex(const char *" s ", int " c ); +.fi +.sh description +the +.br index () +function returns a pointer to the first occurrence +of the character \fic\fp in the string \fis\fp. +.pp +the +.br rindex () +function returns a pointer to the last occurrence +of the character \fic\fp in the string \fis\fp. +.pp +the terminating null byte (\(aq\e0\(aq) is considered to be a part of the +strings. +.sh return value +the +.br index () +and +.br rindex () +functions return a pointer to +the matched character or null if the character is not found. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br index (), +.br rindex () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +4.3bsd; marked as legacy in posix.1-2001. +posix.1-2008 removes the specifications of +.br index () +and +.br rindex (), +recommending +.br strchr (3) +and +.br strrchr (3) +instead. +.sh see also +.br memchr (3), +.br strchr (3), +.br string (3), +.br strpbrk (3), +.br strrchr (3), +.br strsep (3), +.br strspn (3), +.br strstr (3), +.br strtok (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/makedev.3 + +.\" copyright (c) 1990, 1993 +.\" the regents of the university of california. all rights reserved. +.\" +.\" %%%license_start(bsd_4_clause_ucb) +.\" redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. all advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" this product includes software developed by the university of +.\" california, berkeley and its contributors. +.\" 4. neither the name of the university nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" this software is provided by the regents and contributors ``as is'' and +.\" any express or implied warranties, including, but not limited to, the +.\" implied warranties of merchantability and fitness for a particular purpose +.\" are disclaimed. in no event shall the regents or contributors be liable +.\" for any direct, indirect, incidental, special, exemplary, or consequential +.\" damages (including, but not limited to, procurement of substitute goods +.\" or services; loss of use, data, or profits; or business interruption) +.\" however caused and on any theory of liability, whether in contract, strict +.\" liability, or tort (including negligence or otherwise) arising in any way +.\" out of the use of this software, even if advised of the possibility of +.\" such damage. +.\" %%%license_end +.\" +.\" @(#)dbopen.3 8.5 (berkeley) 1/2/94 +.\" +.th dbopen 3 2017-09-15 "" "linux programmer's manual" +.uc 7 +.sh name +dbopen \- database access methods +.sh synopsis +.nf +.b #include +.b #include +.b #include +.b #include +.pp +.bi "db *dbopen(const char *" file ", int " flags ", int " mode \ +", dbtype " type , +.bi " const void *" openinfo ); +.fi +.sh description +.ir "note well" : +this page documents interfaces provided in glibc up until version 2.1. +since version 2.2, glibc no longer provides these interfaces. +probably, you are looking for the apis provided by the +.i libdb +library instead. +.pp +.br dbopen () +is the library interface to database files. +the supported file formats are btree, hashed, and unix file oriented. +the btree format is a representation of a sorted, balanced tree structure. +the hashed format is an extensible, dynamic hashing scheme. +the flat-file format is a byte stream file with fixed or variable length +records. +the formats and file-format-specific information are described in detail +in their respective manual pages +.br btree (3), +.br hash (3), +and +.br recno (3). +.pp +.br dbopen () +opens +.i file +for reading and/or writing. +files never intended to be preserved on disk may be created by setting +the +.i file +argument to null. +.pp +the +.i flags +and +.i mode +arguments are as specified to the +.br open (2) +routine, however, only the +.br o_creat , +.br o_excl , +.br o_exlock , +.br o_nonblock , +.br o_rdonly , +.br o_rdwr , +.br o_shlock , +and +.b o_trunc +flags are meaningful. +(note, opening a database file +.b o_wronly +is not possible.) +.\"three additional options may be specified by oring +.\"them into the +.\".i flags +.\"argument. +.\".tp +.\"db_lock +.\"do the necessary locking in the database to support concurrent access. +.\"if concurrent access isn't needed or the database is read-only this +.\"flag should not be set, as it tends to have an associated performance +.\"penalty. +.\".tp +.\"db_shmem +.\"place the underlying memory pool used by the database in shared +.\"memory. +.\"necessary for concurrent access. +.\".tp +.\"db_txn +.\"support transactions in the database. +.\"the db_lock and db_shmem flags must be set as well. +.pp +the +.i type +argument is of type +.i dbtype +(as defined in the +.i +include file) and +may be set to +.br db_btree , +.br db_hash , +or +.br db_recno . +.pp +the +.i openinfo +argument is a pointer to an access-method-specific structure described +in the access method's manual page. +if +.i openinfo +is null, each access method will use defaults appropriate for the system +and the access method. +.pp +.br dbopen () +returns a pointer to a +.i db +structure on success and null on error. +the +.i db +structure is defined in the +.i +include file, and contains at +least the following fields: +.pp +.in +4n +.ex +typedef struct { + dbtype type; + int (*close)(const db *db); + int (*del)(const db *db, const dbt *key, unsigned int flags); + int (*fd)(const db *db); + int (*get)(const db *db, dbt *key, dbt *data, + unsigned int flags); + int (*put)(const db *db, dbt *key, const dbt *data, + unsigned int flags); + int (*sync)(const db *db, unsigned int flags); + int (*seq)(const db *db, dbt *key, dbt *data, + unsigned int flags); +} db; +.ee +.in +.pp +these elements describe a database type and a set of functions performing +various actions. +these functions take a pointer to a structure as returned by +.br dbopen (), +and sometimes one or more pointers to key/data structures and a flag value. +.tp +.i type +the type of the underlying access method (and file format). +.tp +.i close +a pointer to a routine to flush any cached information to disk, free any +allocated resources, and close the underlying file(s). +since key/data pairs may be cached in memory, failing to sync the file +with a +.i close +or +.i sync +function may result in inconsistent or lost information. +.i close +routines return \-1 on error (setting +.ir errno ) +and 0 on success. +.tp +.i del +a pointer to a routine to remove key/data pairs from the database. +.ip +the argument +.i flag +may be set to the following value: +.rs +.tp +.b r_cursor +delete the record referenced by the cursor. +the cursor must have previously been initialized. +.re +.ip +.i delete +routines return \-1 on error (setting +.ir errno ), +0 on success, and 1 if the specified +.i key +was not in the file. +.tp +.i fd +a pointer to a routine which returns a file descriptor representative +of the underlying database. +a file descriptor referencing the same file will be returned to all +processes which call +.br dbopen () +with the same +.i file +name. +this file descriptor may be safely used as an argument to the +.br fcntl (2) +and +.br flock (2) +locking functions. +the file descriptor is not necessarily associated with any of the +underlying files used by the access method. +no file descriptor is available for in memory databases. +.i fd +routines return \-1 on error (setting +.ir errno ), +and the file descriptor on success. +.tp +.i get +a pointer to a routine which is the interface for keyed retrieval from +the database. +the address and length of the data associated with the specified +.i key +are returned in the structure referenced by +.ir data . +.i get +routines return \-1 on error (setting +.ir errno ), +0 on success, and 1 if the +.i key +was not in the file. +.tp +.i put +a pointer to a routine to store key/data pairs in the database. +.ip +the argument +.i flag +may be set to one of the following values: +.rs +.tp +.b r_cursor +replace the key/data pair referenced by the cursor. +the cursor must have previously been initialized. +.tp +.b r_iafter +append the data immediately after the data referenced by +.ir key , +creating a new key/data pair. +the record number of the appended key/data pair is returned in the +.i key +structure. +(applicable only to the +.b db_recno +access method.) +.tp +.b r_ibefore +insert the data immediately before the data referenced by +.ir key , +creating a new key/data pair. +the record number of the inserted key/data pair is returned in the +.i key +structure. +(applicable only to the +.b db_recno +access method.) +.tp +.b r_nooverwrite +enter the new key/data pair only if the key does not previously exist. +.tp +.b r_setcursor +store the key/data pair, setting or initializing the position of the +cursor to reference it. +(applicable only to the +.b db_btree +and +.b db_recno +access methods.) +.re +.ip +.b r_setcursor +is available only for the +.b db_btree +and +.b db_recno +access +methods because it implies that the keys have an inherent order +which does not change. +.ip +.b r_iafter +and +.b r_ibefore +are available only for the +.b db_recno +access method because they each imply that the access method is able to +create new keys. +this is true only if the keys are ordered and independent, record numbers +for example. +.ip +the default behavior of the +.i put +routines is to enter the new key/data pair, replacing any previously +existing key. +.ip +.i put +routines return \-1 on error (setting +.ir errno ), +0 on success, and 1 if the +.b r_nooverwrite +.i flag +was set and the key already exists in the file. +.tp +.i seq +a pointer to a routine which is the interface for sequential +retrieval from the database. +the address and length of the key are returned in the structure +referenced by +.ir key , +and the address and length of the data are returned in the +structure referenced +by +.ir data . +.ip +sequential key/data pair retrieval may begin at any time, and the +position of the "cursor" is not affected by calls to the +.ir del , +.ir get , +.ir put , +or +.i sync +routines. +modifications to the database during a sequential scan will be reflected +in the scan, that is, +records inserted behind the cursor will not be returned +while records inserted in front of the cursor will be returned. +.ip +the flag value +.b must +be set to one of the following values: +.rs +.tp +.b r_cursor +the data associated with the specified key is returned. +this differs from the +.i get +routines in that it sets or initializes the cursor to the location of +the key as well. +(note, for the +.b db_btree +access method, the returned key is not necessarily an +exact match for the specified key. +the returned key is the smallest key greater than or equal to the specified +key, permitting partial key matches and range searches.) +.tp +.b r_first +the first key/data pair of the database is returned, and the cursor +is set or initialized to reference it. +.tp +.b r_last +the last key/data pair of the database is returned, and the cursor +is set or initialized to reference it. +(applicable only to the +.b db_btree +and +.b db_recno +access methods.) +.tp +.b r_next +retrieve the key/data pair immediately after the cursor. +if the cursor is not yet set, this is the same as the +.b r_first +flag. +.tp +.b r_prev +retrieve the key/data pair immediately before the cursor. +if the cursor is not yet set, this is the same as the +.b r_last +flag. +(applicable only to the +.b db_btree +and +.b db_recno +access methods.) +.re +.ip +.b r_last +and +.b r_prev +are available only for the +.b db_btree +and +.b db_recno +access methods because they each imply that the keys have an inherent +order which does not change. +.ip +.i seq +routines return \-1 on error (setting +.ir errno ), +0 on success and 1 if there are no key/data pairs less than or greater +than the specified or current key. +if the +.b db_recno +access method is being used, and if the database file +is a character special file and no complete key/data pairs are currently +available, the +.i seq +routines return 2. +.tp +.i sync +a pointer to a routine to flush any cached information to disk. +if the database is in memory only, the +.i sync +routine has no effect and will always succeed. +.ip +the flag value may be set to the following value: +.rs +.tp +.b r_recnosync +if the +.b db_recno +access method is being used, this flag causes +the sync routine to apply to the btree file which underlies the +recno file, not the recno file itself. +(see the +.i bfname +field of the +.br recno (3) +manual page for more information.) +.re +.ip +.i sync +routines return \-1 on error (setting +.ir errno ) +and 0 on success. +.ss key/data pairs +access to all file types is based on key/data pairs. +both keys and data are represented by the following data structure: +.pp +.in +4n +.ex +typedef struct { + void *data; + size_t size; +} dbt; +.ee +.in +.pp +the elements of the +.i dbt +structure are defined as follows: +.tp +.i data +a pointer to a byte string. +.tp +.i size +the length of the byte string. +.pp +key and data byte strings may reference strings of essentially unlimited +length although any two of them must fit into available memory at the same +time. +it should be noted that the access methods provide no guarantees about +byte string alignment. +.sh errors +the +.br dbopen () +routine may fail and set +.i errno +for any of the errors specified for the library routines +.br open (2) +and +.br malloc (3) +or the following: +.tp +.b eftype +a file is incorrectly formatted. +.tp +.b einval +a parameter has been specified (hash function, pad byte, etc.) that is +incompatible with the current file specification or which is not +meaningful for the function (for example, use of the cursor without +prior initialization) or there is a mismatch between the version +number of file and the software. +.pp +the +.i close +routines may fail and set +.i errno +for any of the errors specified for the library routines +.br close (2), +.br read (2), +.br write (2), +.br free (3), +or +.br fsync (2). +.pp +the +.ir del , +.ir get , +.ir put , +and +.i seq +routines may fail and set +.i errno +for any of the errors specified for the library routines +.br read (2), +.br write (2), +.br free (3), +or +.br malloc (3). +.pp +the +.i fd +routines will fail and set +.i errno +to +.b enoent +for in memory databases. +.pp +the +.i sync +routines may fail and set +.i errno +for any of the errors specified for the library routine +.br fsync (2). +.sh bugs +the typedef +.i dbt +is a mnemonic for "data base thang", and was used +because no one could think of a reasonable name that wasn't already used. +.pp +the file descriptor interface is a kludge and will be deleted in a +future version of the interface. +.pp +none of the access methods provide any form of concurrent access, +locking, or transactions. +.sh see also +.br btree (3), +.br hash (3), +.br mpool (3), +.br recno (3) +.pp +.ir "libtp: portable, modular transactions for unix" , +margo seltzer, michael olson, usenix proceedings, winter 1992. +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/getifaddrs.3 + +.so man3/gethostid.3 + +import os +import glob +import random + +# navigate to the directory +data_dir = '/media/external/man-pages-dataset/man-pages-5.13' +os.chdir(data_dir) + +# function to preprocess the text +def preprocess_text(file_path): + with open(file_path, 'r', encoding='utf-8') as file: + text = file.read() + # simple preprocessing (e.g., lowercase conversion) + text = text.lower() + return text + +# collect and preprocess the data +all_data = [] +file_paths = glob.glob('**/*.txt', recursive=true) +print(f'found {len(file_paths)} files.') + +for file_path in file_paths: + preprocessed_text = preprocess_text(file_path) + all_data.append(preprocessed_text) + +print(f'processed {len(all_data)} files.') + +# shuffle and split the data +random.shuffle(all_data) +train_size = int(0.8 * len(all_data)) +train_data, val_test_data = all_data[:train_size], all_data[train_size:] +val_size = int(0.5 * len(val_test_data)) +val_data, test_data = val_test_data[:val_size], val_test_data[val_size:] + +# save the preprocessed data +output_dir = os.path.join(data_dir, 'preprocessed_data') +os.makedirs(output_dir, exist_ok=true) + +with open(os.path.join(output_dir, 'train.txt'), 'w', encoding='utf-8') as file: + file.write('\n'.join(train_data)) +with open(os.path.join(output_dir, 'val.txt'), 'w', encoding='utf-8') as file: + file.write('\n'.join(val_data)) +with open(os.path.join(output_dir, 'test.txt'), 'w', encoding='utf-8') as file: + file.write('\n'.join(test_data)) + +print(f'data preprocessing and splitting completed. preprocessed data saved to {output_dir}') + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" and copyright 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified 1993-07-24 by rik faith (faith@cs.unc.edu) +.\" modified 1995-08-14 by arnt gulbrandsen +.\" modified 2002-07-27 by walter harms +.\" (walter.harms@informatik.uni-oldenburg.de) +.\" +.th exp 3 2021-03-22 "" "linux programmer's manual" +.sh name +exp, expf, expl \- base-e exponential function +.sh synopsis +.nf +.b #include +.pp +.bi "double exp(double " x ); +.bi "float expf(float " x ); +.bi "long double expl(long double " x ); +.fi +.pp +link with \fi\-lm\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br expf (), +.br expl (): +.nf + _isoc99_source || _posix_c_source >= 200112l + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.sh description +these functions return the value of e (the base of natural +logarithms) raised to the power of +.ir x . +.sh return value +on success, these functions return the exponential value of +.ir x . +.pp +if +.i x +is a nan, +a nan is returned. +.pp +if +.i x +is positive infinity, +positive infinity is returned. +.pp +if +.i x +is negative infinity, ++0 is returned. +.pp +if the result underflows, +a range error occurs, +and zero is returned. +.pp +if the result overflows, +a range error occurs, +and the functions return +.rb + huge_val , +.rb + huge_valf , +or +.rb + huge_vall , +respectively. +.sh errors +see +.br math_error (7) +for information on how to determine whether an error has occurred +when calling these functions. +.pp +the following errors can occur: +.tp +range error, overflow +.i errno +is set to +.br erange . +an overflow floating-point exception +.rb ( fe_overflow ) +is raised. +.tp +range error, underflow +.i errno +is set to +.br erange . +an underflow floating-point exception +.rb ( fe_underflow ) +is raised. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br exp (), +.br expf (), +.br expl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.pp +the variant returning +.i double +also conforms to +svr4, 4.3bsd, c89. +.sh see also +.br cbrt (3), +.br cexp (3), +.br exp10 (3), +.br exp2 (3), +.br expm1 (3), +.br sqrt (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/strtol.3 + +.\" copyright (c) 1992 drew eckhardt (drew@cs.colorado.edu), march 28, 1992 +.\" and copyright (c) 2006 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified by michael haardt +.\" modified 1993-07-21 by rik faith +.\" modified 1994-08-21 by michael chastain : +.\" modified 1997-01-31 by eric s. raymond +.\" modified 1999-11-12 by urs thuermann +.\" modified 2004-06-23 by michael kerrisk +.\" 2006-09-04 michael kerrisk +.\" added list of process attributes that are not preserved on exec(). +.\" 2007-09-14 ollie wild , mtk +.\" add text describing limits on command-line arguments + environment +.\" +.th execve 2 2021-08-27 "linux" "linux programmer's manual" +.sh name +execve \- execute program +.sh synopsis +.nf +.b #include +.pp +.bi "int execve(const char *" pathname ", char *const " argv [], +.bi " char *const " envp []); +.fi +.sh description +.br execve () +executes the program referred to by \fipathname\fp. +this causes the program that is currently being run by the calling process +to be replaced with a new program, with newly initialized stack, heap, +and (initialized and uninitialized) data segments. +.pp +\fipathname\fp must be either a binary executable, or a script +starting with a line of the form: +.pp +.in +4n +.ex +\fb#!\fp\fiinterpreter \fp[optional-arg] +.ee +.in +.pp +for details of the latter case, see "interpreter scripts" below. +.pp +\fiargv\fp is an array of pointers to strings passed to the new program +as its command-line arguments. +by convention, the first of these strings (i.e., +.ir argv[0] ) +should contain the filename associated with the file being executed. +the +.i argv +array must be terminated by a null pointer. +(thus, in the new program, +.ir argv[argc] +will be null.) +.pp +\fienvp\fp is an array of pointers to strings, conventionally of the form +\fbkey=value\fp, which are passed as the environment of the new program. +the +.i envp +array must be terminated by a null pointer. +.pp +the argument vector and environment can be accessed by the +new program's main function, when it is defined as: +.pp +.in +4n +.ex +int main(int argc, char *argv[], char *envp[]) +.ee +.in +.pp +note, however, that the use of a third argument to the main function +is not specified in posix.1; +according to posix.1, +the environment should be accessed via the external variable +.br environ (7). +.pp +.br execve () +does not return on success, and the text, initialized data, +uninitialized data (bss), and stack of the calling process are overwritten +according to the contents of the newly loaded program. +.pp +if the current program is being ptraced, a \fbsigtrap\fp signal is sent to it +after a successful +.br execve (). +.pp +if the set-user-id bit is set on the program file referred to by +\fipathname\fp, +then the effective user id of the calling process is changed +to that of the owner of the program file. +similarly, if the set-group-id bit is set on the program file, +then the effective group id of the calling +process is set to the group of the program file. +.pp +the aforementioned transformations of the effective ids are +.i not +performed (i.e., the set-user-id and set-group-id bits are ignored) +if any of the following is true: +.ip * 3 +the +.i no_new_privs +attribute is set for the calling thread (see +.br prctl (2)); +.ip * +the underlying filesystem is mounted +.i nosuid +(the +.b ms_nosuid +flag for +.br mount (2)); +or +.ip * +the calling process is being ptraced. +.pp +the capabilities of the program file (see +.br capabilities (7)) +are also ignored if any of the above are true. +.pp +the effective user id of the process is copied to the saved set-user-id; +similarly, the effective group id is copied to the saved set-group-id. +this copying takes place after any effective id changes that occur +because of the set-user-id and set-group-id mode bits. +.pp +the process's real uid and real gid, as well as its supplementary group ids, +are unchanged by a call to +.br execve (). +.pp +if the executable is an a.out dynamically linked +binary executable containing +shared-library stubs, the linux dynamic linker +.br ld.so (8) +is called at the start of execution to bring +needed shared objects into memory +and link the executable with them. +.pp +if the executable is a dynamically linked elf executable, the +interpreter named in the pt_interp segment is used to load the needed +shared objects. +this interpreter is typically +.i /lib/ld\-linux.so.2 +for binaries linked with glibc (see +.br ld\-linux.so (8)). +.\" +.ss effect on process attributes +all process attributes are preserved during an +.br execve (), +except the following: +.ip * 3 +the dispositions of any signals that are being caught are +reset to the default +.rb ( signal (7)). +.ip * +any alternate signal stack is not preserved +.rb ( sigaltstack (2)). +.ip * +memory mappings are not preserved +.rb ( mmap (2)). +.ip * +attached system\ v shared memory segments are detached +.rb ( shmat (2)). +.ip * +posix shared memory regions are unmapped +.rb ( shm_open (3)). +.ip * +open posix message queue descriptors are closed +.rb ( mq_overview (7)). +.ip * +any open posix named semaphores are closed +.rb ( sem_overview (7)). +.ip * +posix timers are not preserved +.rb ( timer_create (2)). +.ip * +any open directory streams are closed +.rb ( opendir (3)). +.ip * +memory locks are not preserved +.rb ( mlock (2), +.br mlockall (2)). +.ip * +exit handlers are not preserved +.rb ( atexit (3), +.br on_exit (3)). +.ip * +the floating-point environment is reset to the default (see +.br fenv (3)). +.pp +the process attributes in the preceding list are all specified +in posix.1. +the following linux-specific process attributes are also +not preserved during an +.br execve (): +.ip * 3 +the process's "dumpable" attribute is set to the value 1, +unless a set-user-id program, a set-group-id program, +or a program with capabilities is being executed, +in which case the dumpable flag may instead be reset to the value in +.ir /proc/sys/fs/suid_dumpable , +in the circumstances described under +.br pr_set_dumpable +in +.br prctl (2). +note that changes to the "dumpable" attribute may cause ownership +of files in the process's +.ir /proc/[pid] +directory to change to +.ir root:root , +as described in +.br proc (5). +.ip * +the +.br prctl (2) +.b pr_set_keepcaps +flag is cleared. +.ip * +(since linux 2.4.36 / 2.6.23) +if a set-user-id or set-group-id program is being executed, +then the parent death signal set by +.br prctl (2) +.b pr_set_pdeathsig +flag is cleared. +.ip * +the process name, as set by +.br prctl (2) +.b pr_set_name +(and displayed by +.ir "ps\ \-o comm" ), +is reset to the name of the new executable file. +.ip * +the +.b secbit_keep_caps +.i securebits +flag is cleared. +see +.br capabilities (7). +.ip * +the termination signal is reset to +.b sigchld +(see +.br clone (2)). +.ip * +the file descriptor table is unshared, undoing the effect of the +.b clone_files +flag of +.br clone (2). +.pp +note the following further points: +.ip * 3 +all threads other than the calling thread are destroyed during an +.br execve (). +mutexes, condition variables, and other pthreads objects are not preserved. +.ip * +the equivalent of \fisetlocale(lc_all, "c")\fp +is executed at program start-up. +.ip * +posix.1 specifies that the dispositions of any signals that +are ignored or set to the default are left unchanged. +posix.1 specifies one exception: if +.b sigchld +is being ignored, +then an implementation may leave the disposition unchanged or +reset it to the default; linux does the former. +.ip * +any outstanding asynchronous i/o operations are canceled +.rb ( aio_read (3), +.br aio_write (3)). +.ip * +for the handling of capabilities during +.br execve (), +see +.br capabilities (7). +.ip * +by default, file descriptors remain open across an +.br execve (). +file descriptors that are marked close-on-exec are closed; +see the description of +.b fd_cloexec +in +.br fcntl (2). +(if a file descriptor is closed, this will cause the release +of all record locks obtained on the underlying file by this process. +see +.br fcntl (2) +for details.) +posix.1 says that if file descriptors 0, 1, and 2 would +otherwise be closed after a successful +.br execve (), +and the process would gain privilege because the set-user-id or +set-group-id mode bit was set on the executed file, +then the system may open an unspecified file for each of these +file descriptors. +as a general principle, no portable program, whether privileged or not, +can assume that these three file descriptors will remain +closed across an +.br execve (). +.\" on linux it appears that these file descriptors are +.\" always open after an execve(), and it looks like +.\" solaris 8 and freebsd 6.1 are the same. -- mtk, 30 apr 2007 +.ss interpreter scripts +an interpreter script is a text file that has execute +permission enabled and whose first line is of the form: +.pp +.in +4n +.ex +\fb#!\fp\fiinterpreter \fp[optional-arg] +.ee +.in +.pp +the +.i interpreter +must be a valid pathname for an executable file. +.pp +if the +.i pathname +argument of +.br execve () +specifies an interpreter script, then +.i interpreter +will be invoked with the following arguments: +.pp +.in +4n +.ex +\fiinterpreter\fp [optional-arg] \fipathname\fp arg... +.ee +.in +.pp +where +.i pathname +is the pathname of the file specified as the first argument of +.br execve (), +and +.i arg... +is the series of words pointed to by the +.i argv +argument of +.br execve (), +starting at +.ir argv[1] . +note that there is no way to get the +.ir argv[0] +that was passed to the +.br execve () +call. +.\" see the p - preserve-argv[0] option. +.\" documentation/admin-guide/binfmt-misc.rst +.\" https://www.kernel.org/doc/html/latest/admin-guide/binfmt-misc.html +.pp +for portable use, +.i optional-arg +should either be absent, or be specified as a single word (i.e., it +should not contain white space); see notes below. +.pp +since linux 2.6.28, +.\" commit bf2a9a39639b8b51377905397a5005f444e9a892 +the kernel permits the interpreter of a script to itself be a script. +this permission is recursive, up to a limit of four recursions, +so that the interpreter may be a script which is interpreted by a script, +and so on. +.ss limits on size of arguments and environment +most unix implementations impose some limit on the total size +of the command-line argument +.ri ( argv ) +and environment +.ri ( envp ) +strings that may be passed to a new program. +posix.1 allows an implementation to advertise this limit using the +.b arg_max +constant (either defined in +.i +or available at run time using the call +.ir "sysconf(_sc_arg_max)" ). +.pp +on linux prior to kernel 2.6.23, the memory used to store the +environment and argument strings was limited to 32 pages +(defined by the kernel constant +.br max_arg_pages ). +on architectures with a 4-kb page size, +this yields a maximum size of 128\ kb. +.pp +on kernel 2.6.23 and later, most architectures support a size limit +derived from the soft +.b rlimit_stack +resource limit (see +.br getrlimit (2)) +that is in force at the time of the +.br execve () +call. +(architectures with no memory management unit are excepted: +they maintain the limit that was in effect before kernel 2.6.23.) +this change allows programs to have a much larger +argument and/or environment list. +.\" for some background on the changes to arg_max in kernels 2.6.23 and +.\" 2.6.25, see: +.\" http://sourceware.org/bugzilla/show_bug.cgi?id=5786 +.\" http://bugzilla.kernel.org/show_bug.cgi?id=10095 +.\" http://thread.gmane.org/gmane.linux.kernel/646709/focus=648101, +.\" checked into 2.6.25 as commit a64e715fc74b1a7dcc5944f848acc38b2c4d4ee2. +for these architectures, the total size is limited to 1/4 of the allowed +stack size. +(imposing the 1/4-limit +ensures that the new program always has some stack space.) +.\" ollie: that doesn't include the lists of pointers, though, +.\" so the actual usage is a bit higher (1 pointer per argument). +additionally, the total size is limited to 3/4 of the value +of the kernel constant +.b _stk_lim +(8 mib). +since linux 2.6.25, +the kernel also places a floor of 32 pages on this size limit, +so that, even when +.br rlimit_stack +is set very low, +applications are guaranteed to have at least as much argument and +environment space as was provided by linux 2.6.22 and earlier. +(this guarantee was not provided in linux 2.6.23 and 2.6.24.) +additionally, the limit per string is 32 pages (the kernel constant +.br max_arg_strlen ), +and the maximum number of strings is 0x7fffffff. +.sh return value +on success, +.br execve () +does not return, on error \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b e2big +the total number of bytes in the environment +.ri ( envp ) +and argument list +.ri ( argv ) +is too large. +.tp +.b eacces +search permission is denied on a component of the path prefix of +.i pathname +or the name of a script interpreter. +(see also +.br path_resolution (7).) +.tp +.b eacces +the file or a script interpreter is not a regular file. +.tp +.b eacces +execute permission is denied for the file or a script or elf interpreter. +.tp +.b eacces +the filesystem is mounted +.ir noexec . +.tp +.br eagain " (since linux 3.1)" +.\" commit 72fa59970f8698023045ab0713d66f3f4f96945c +having changed its real uid using one of the +.br set*uid () +calls, the caller was\(emand is now still\(emabove its +.br rlimit_nproc +resource limit (see +.br setrlimit (2)). +for a more detailed explanation of this error, see notes. +.tp +.b efault +.i pathname +or one of the pointers in the vectors +.i argv +or +.i envp +points outside your accessible address space. +.tp +.b einval +an elf executable had more than one pt_interp segment (i.e., tried to +name more than one interpreter). +.tp +.b eio +an i/o error occurred. +.tp +.b eisdir +an elf interpreter was a directory. +.tp +.b elibbad +an elf interpreter was not in a recognized format. +.tp +.b eloop +too many symbolic links were encountered in resolving +.i pathname +or the name of a script or elf interpreter. +.tp +.b eloop +the maximum recursion limit was reached during recursive script +interpretation (see "interpreter scripts", above). +before linux 3.8, +.\" commit d740269867021faf4ce38a449353d2b986c34a67 +the error produced for this case was +.br enoexec . +.tp +.b emfile +the per-process limit on the number of open file descriptors has been reached. +.tp +.b enametoolong +.i pathname +is too long. +.tp +.b enfile +the system-wide limit on the total number of open files has been reached. +.tp +.b enoent +the file +.i pathname +or a script or elf interpreter does not exist. +.tp +.b enoexec +an executable is not in a recognized format, is for the wrong +architecture, or has some other format error that means it cannot be +executed. +.tp +.b enomem +insufficient kernel memory was available. +.tp +.b enotdir +a component of the path prefix of +.i pathname +or a script or elf interpreter is not a directory. +.tp +.b eperm +the filesystem is mounted +.ir nosuid , +the user is not the superuser, +and the file has the set-user-id or set-group-id bit set. +.tp +.b eperm +the process is being traced, the user is not the superuser and the +file has the set-user-id or set-group-id bit set. +.tp +.b eperm +a "capability-dumb" applications would not obtain the full set of +permitted capabilities granted by the executable file. +see +.br capabilities (7). +.tp +.b etxtbsy +the specified executable was open for writing by one or more processes. +.sh conforming to +posix.1-2001, posix.1-2008, svr4, 4.3bsd. +posix does not document the #! behavior, but it exists +(with some variations) on other unix systems. +.\" svr4 documents additional error +.\" conditions eagain, eintr, elibacc, enolink, emultihop; posix does not +.\" document etxtbsy, eperm, efault, eloop, eio, enfile, emfile, einval, +.\" eisdir or elibbad error conditions. +.sh notes +one sometimes sees +.br execve () +(and the related functions described in +.br exec (3)) +described as "executing a +.i new +process" (or similar). +this is a highly misleading description: +there is no new process; +many attributes of the calling process remain unchanged +(in particular, its pid). +all that +.br execve () +does is arrange for an existing process (the calling process) +to execute a new program. +.pp +set-user-id and set-group-id processes can not be +.br ptrace (2)d. +.pp +the result of mounting a filesystem +.i nosuid +varies across linux kernel versions: +some will refuse execution of set-user-id and set-group-id +executables when this would +give the user powers they did not have already (and return +.br eperm ), +some will just ignore the set-user-id and set-group-id bits and +.br exec () +successfully. +.pp +on linux, +.i argv +and +.i envp +can be specified as null. +in both cases, this has the same effect as specifying the argument +as a pointer to a list containing a single null pointer. +.b "do not take advantage of this nonstandard and nonportable misfeature!" +on many other unix systems, specifying +.i argv +as null will result in an error +.rb ( efault ). +.i some +other unix systems treat the +.i envp==null +case the same as linux. +.\" e.g., efault on solaris 8 and freebsd 6.1; but +.\" hp-ux 11 is like linux -- mtk, apr 2007 +.\" bug filed 30 apr 2007: http://bugzilla.kernel.org/show_bug.cgi?id=8408 +.\" bug rejected (because fix would constitute an abi change). +.\" +.pp +posix.1 says that values returned by +.br sysconf (3) +should be invariant over the lifetime of a process. +however, since linux 2.6.23, if the +.br rlimit_stack +resource limit changes, then the value reported by +.b _sc_arg_max +will also change, +to reflect the fact that the limit on space for holding +command-line arguments and environment variables has changed. +.pp +in most cases where +.br execve () +fails, control returns to the original executable image, +and the caller of +.br execve () +can then handle the error. +however, in (rare) cases (typically caused by resource exhaustion), +failure may occur past the point of no return: +the original executable image has been torn down, +but the new image could not be completely built. +in such cases, the kernel kills the process with a +.\" commit 19d860a140beac48a1377f179e693abe86a9dac9 +.br sigsegv +.rb ( sigkill +until linux 3.17) +signal. +.\" +.ss interpreter scripts +the kernel imposes a maximum length on the text that follows the +"#!" characters at the start of a script; +characters beyond the limit are ignored. +before linux 5.1, the limit is 127 characters. +since linux 5.1, +.\" commit 6eb3c3d0a52dca337e327ae8868ca1f44a712e02 +the limit is 255 characters. +.pp +the semantics of the +.i optional-arg +argument of an interpreter script vary across implementations. +on linux, the entire string following the +.i interpreter +name is passed as a single argument to the interpreter, +and this string can include white space. +however, behavior differs on some other systems. +some systems +.\" e.g., solaris 8 +use the first white space to terminate +.ir optional-arg . +on some systems, +.\" e.g., freebsd before 6.0, but not freebsd 6.0 onward +an interpreter script can have multiple arguments, +and white spaces in +.i optional-arg +are used to delimit the arguments. +.pp +linux (like most other modern unix systems) +ignores the set-user-id and set-group-id bits on scripts. +.\" +.\" .sh bugs +.\" some linux versions have failed to check permissions on elf +.\" interpreters. this is a security hole, because it allows users to +.\" open any file, such as a rewinding tape device, for reading. some +.\" linux versions have also had other security holes in +.\" .br execve () +.\" that could be exploited for denial of service by a suitably crafted +.\" elf binary. there are no known problems with 2.0.34 or 2.2.15. +.ss execve() and eagain +a more detailed explanation of the +.br eagain +error that can occur (since linux 3.1) when calling +.br execve () +is as follows. +.pp +the +.br eagain +error can occur when a +.i preceding +call to +.br setuid (2), +.br setreuid (2), +or +.br setresuid (2) +caused the real user id of the process to change, +and that change caused the process to exceed its +.br rlimit_nproc +resource limit (i.e., the number of processes belonging +to the new real uid exceeds the resource limit). +from linux 2.6.0 to 3.0, this caused the +.br set*uid () +call to fail. +(prior to 2.6, +.\" commit 909cc4ae86f3380152a18e2a3c44523893ee11c4 +the resource limit was not imposed on processes that +changed their user ids.) +.pp +since linux 3.1, the scenario just described no longer causes the +.br set*uid () +call to fail, +because it too often led to security holes where buggy applications +didn't check the return status and assumed +that\(emif the caller had root privileges\(emthe call would always succeed. +instead, the +.br set*uid () +calls now successfully change the real uid, +but the kernel sets an internal flag, named +.br pf_nproc_exceeded , +to note that the +.br rlimit_nproc +resource limit has been exceeded. +if the +.br pf_nproc_exceeded +flag is set and the resource limit is still +exceeded at the time of a subsequent +.br execve () +call, that call fails with the error +.br eagain . +this kernel logic ensures that the +.br rlimit_nproc +resource limit is still enforced for the +common privileged daemon workflow\(emnamely, +.br fork (2) ++ +.br set*uid () ++ +.br execve (). +.pp +if the resource limit was not still exceeded at the time of the +.br execve () +call +(because other processes belonging to this real uid terminated between the +.br set*uid () +call and the +.br execve () +call), then the +.br execve () +call succeeds and the kernel clears the +.br pf_nproc_exceeded +process flag. +the flag is also cleared if a subsequent call to +.br fork (2) +by this process succeeds. +.ss historical +with unix\ v6, the argument list of an +.br exec () +call was ended by 0, +while the argument list of +.i main +was ended by \-1. +thus, this argument list was not directly usable in a further +.br exec () +call. +since unix\ v7, both are null. +.\" +.\" .sh bugs +.\" some linux versions have failed to check permissions on elf +.\" interpreters. this is a security hole, because it allows users to +.\" open any file, such as a rewinding tape device, for reading. some +.\" linux versions have also had other security holes in +.\" .br execve () +.\" that could be exploited for denial of service by a suitably crafted +.\" elf binary. there are no known problems with 2.0.34 or 2.2.15. +.sh examples +the following program is designed to be execed by the second program below. +it just echoes its command-line arguments, one per line. +.pp +.in +4n +.ex +/* myecho.c */ + +#include +#include + +int +main(int argc, char *argv[]) +{ + for (int j = 0; j < argc; j++) + printf("argv[%d]: %s\en", j, argv[j]); + + exit(exit_success); +} +.ee +.in +.pp +this program can be used to exec the program named in its command-line +argument: +.pp +.in +4n +.ex +/* execve.c */ + +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + char *newargv[] = { null, "hello", "world", null }; + char *newenviron[] = { null }; + + if (argc != 2) { + fprintf(stderr, "usage: %s \en", argv[0]); + exit(exit_failure); + } + + newargv[0] = argv[1]; + + execve(argv[1], newargv, newenviron); + perror("execve"); /* execve() returns only on error */ + exit(exit_failure); +} +.ee +.in +.pp +we can use the second program to exec the first as follows: +.pp +.in +4n +.ex +.rb "$" " cc myecho.c \-o myecho" +.rb "$" " cc execve.c \-o execve" +.rb "$" " ./execve ./myecho" +argv[0]: ./myecho +argv[1]: hello +argv[2]: world +.ee +.in +.pp +we can also use these programs to demonstrate the use of a script +interpreter. +to do this we create a script whose "interpreter" is our +.i myecho +program: +.pp +.in +4n +.ex +.rb "$" " cat > script" +.b #!./myecho script\-arg +.b \(had +.rb "$" " chmod +x script" +.ee +.in +.pp +we can then use our program to exec the script: +.pp +.in +4n +.ex +.rb "$" " ./execve ./script" +argv[0]: ./myecho +argv[1]: script\-arg +argv[2]: ./script +argv[3]: hello +argv[4]: world +.ee +.in +.sh see also +.br chmod (2), +.br execveat (2), +.br fork (2), +.br get_robust_list (2), +.br ptrace (2), +.br exec (3), +.br fexecve (3), +.br getauxval (3), +.br getopt (3), +.br system (3), +.br capabilities (7), +.br credentials (7), +.br environ (7), +.br path_resolution (7), +.br ld.so (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 2009 lefteris dimitroulakis (edimitro@tee.gr) +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th iso_8859-13 7 2020-08-13 "linux" "linux programmer's manual" +.sh name +iso_8859-13 \- iso 8859-13 character set encoded in octal, decimal, +and hexadecimal +.sh description +the iso 8859 standard includes several 8-bit extensions to the ascii +character set (also known as iso 646-irv). +iso 8859-13 encodes the +characters used in baltic rim languages. +.ss iso 8859 alphabets +the full set of iso 8859 alphabets includes: +.ts +l l. +iso 8859-1 west european languages (latin-1) +iso 8859-2 central and east european languages (latin-2) +iso 8859-3 southeast european and miscellaneous languages (latin-3) +iso 8859-4 scandinavian/baltic languages (latin-4) +iso 8859-5 latin/cyrillic +iso 8859-6 latin/arabic +iso 8859-7 latin/greek +iso 8859-8 latin/hebrew +iso 8859-9 latin-1 modification for turkish (latin-5) +iso 8859-10 lappish/nordic/eskimo languages (latin-6) +iso 8859-11 latin/thai +iso 8859-13 baltic rim languages (latin-7) +iso 8859-14 celtic (latin-8) +iso 8859-15 west european languages (latin-9) +iso 8859-16 romanian (latin-10) +.te +.ss iso 8859-13 characters +the following table displays the characters in iso 8859-13 that +are printable and unlisted in the +.br ascii (7) +manual page. +.ts +l l l c lp-1. +oct dec hex char description +_ +240 160 a0   no-break space +241 161 a1 ” right double quotation mark +242 162 a2 ¢ cent sign +243 163 a3 £ pound sign +244 164 a4 ¤ currency sign +245 165 a5 „ double low-9 quotation mark +246 166 a6 ¦ broken bar +247 167 a7 § section sign +250 168 a8 ø latin capital letter o with stroke +251 169 a9 © copyright sign +252 170 aa ŗ latin capital letter r with cedilla +253 171 ab « left-pointing double angle quotation mark +254 172 ac ¬ not sign +255 173 ad ­ soft hyphen +256 174 ae ® registered sign +257 175 af æ latin capital letter ae +260 176 b0 ° degree sign +261 177 b1 ± plus-minus sign +262 178 b2 ² superscript two +263 179 b3 ³ superscript three +264 180 b4 “ left double quotation mark +265 181 b5 µ micro sign +266 182 b6 ¶ pilcrow sign +267 183 b7 · middle dot +270 184 b8 ø latin small letter o with stroke +271 185 b9 ¹ superscript one +272 186 ba ŗ latin small letter r with cedilla +273 187 bb » right-pointing double angle quotation mark +274 188 bc ¼ vulgar fraction one quarter +275 189 bd ½ vulgar fraction one half +276 190 be ¾ vulgar fraction three quarters +277 191 bf æ latin small letter ae +300 192 c0 ą latin capital letter a with ogonek +301 193 c1 į latin capital letter i with ogonek +302 194 c2 ā latin capital letter a with macron +303 195 c3 ć latin capital letter c with acute +304 196 c4 ä latin capital letter a with diaeresis +305 197 c5 å latin capital letter a with ring above +306 198 c6 ę latin capital letter e with ogonek +307 199 c7 ē latin capital letter e with macron +310 200 c8 č latin capital letter c with caron +311 201 c9 é latin capital letter e with acute +312 202 ca ź latin capital letter z with acute +313 203 cb ė latin capital letter e with dot above +314 204 cc ģ latin capital letter g with cedilla +315 205 cd ķ latin capital letter k with cedilla +316 206 ce ī latin capital letter i with macron +317 207 cf ļ latin capital letter l with cedilla +320 208 d0 š latin capital letter s with caron +321 209 d1 ń latin capital letter n with acute +322 210 d2 ņ latin capital letter n with cedilla +323 211 d3 ó latin capital letter o with acute +324 212 d4 ō latin capital letter o with macron +325 213 d5 õ latin capital letter o with tilde +326 214 d6 ö latin capital letter o with diaeresis +327 215 d7 × multiplication sign +330 216 d8 ų latin capital letter u with ogonek +331 217 d9 ł latin capital letter l with stroke +332 218 da ś latin capital letter s with acute +333 219 db ū latin capital letter u with macron +334 220 dc ü latin capital letter u with diaeresis +335 221 dd ż latin capital letter z with dot above +336 222 de ž latin capital letter z with caron +337 223 df ß latin small letter sharp s +340 224 e0 ą latin small letter a with ogonek +341 225 e1 į latin small letter i with ogonek +342 226 e2 ā latin small letter a with macron +343 227 e3 ć latin small letter c with acute +344 228 e4 ä latin small letter a with diaeresis +345 229 e5 å latin small letter a with ring above +346 230 e6 ę latin small letter e with ogonek +347 231 e7 ē latin small letter e with macron +350 232 e8 č latin small letter c with caron +351 233 e9 é latin small letter e with acute +352 234 ea ź latin small letter z with acute +353 235 eb ė latin small letter e with dot above +354 236 ec ģ latin small letter g with cedilla +355 237 ed ķ latin small letter k with cedilla +356 238 ee ī latin small letter i with macron +357 239 ef ļ latin small letter l with cedilla +360 240 f0 š latin small letter s with caron +361 241 f1 ń latin small letter n with acute +362 242 f2 ņ latin small letter n with cedilla +363 243 f3 ó latin small letter o with acute +364 244 f4 ō latin small letter o with macron +365 245 f5 õ latin small letter o with tilde +366 246 f6 ö latin small letter o with diaeresis +367 247 f7 ÷ division sign +370 248 f8 ų latin small letter u with ogonek +371 249 f9 ł latin small letter l with stroke +372 250 fa ś latin small letter s with acute +373 251 fb ū latin small letter u with macron +374 252 fc ü latin small letter u with diaeresis +375 253 fd ż latin small letter z with dot above +376 254 fe ž latin small letter z with caron +377 255 ff ’ right single quotation mark +.te +.sh notes +iso 8859-13 is also known as latin-7. +.sh see also +.br ascii (7), +.br charsets (7), +.br utf\-8 (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2013 by michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" http://thread.gmane.org/gmane.linux.kernel/76552/focus=76803 +.\" from: linus torvalds transmeta.com> +.\" subject: re: [patch] compatibility syscall layer (lets try again) +.\" newsgroups: gmane.linux.kernel +.\" date: 2002-12-05 02:51:12 gmt +.\" +.\" see also section 11.3.3 of understanding the linux kernel, 3rd edition +.\" +.th restart_syscall 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +restart_syscall \- restart a system call after interruption by a stop signal +.sh synopsis +.nf +.b long restart_syscall(void); +.fi +.pp +.ir note : +there is no glibc wrapper for this system call; see notes. +.sh description +the +.br restart_syscall () +system call is used to restart certain system calls +after a process that was stopped by a signal (e.g., +.br sigstop +or +.br sigtstp ) +is later resumed after receiving a +.br sigcont +signal. +this system call is designed only for internal use by the kernel. +.pp +.br restart_syscall () +is used for restarting only those system calls that, +when restarted, should adjust their time-related parameters\(emnamely +.br poll (2) +(since linux 2.6.24), +.br nanosleep (2) +(since linux 2.6), +.br clock_nanosleep (2) +(since linux 2.6), +and +.br futex (2), +when employed with the +.br futex_wait +(since linux 2.6.22) +and +.br futex_wait_bitset +(since linux 2.6.31) +operations. +.\" these system calls correspond to the special internal errno value +.\" erestart_restartblock. each of the system calls has a "restart" +.\" helper function that is invoked by restart_syscall(). +.\" notable (as at linux 3.17) is that poll() has such a "restart" +.\" function, but ppoll(), select(), and pselect() do not. +.\" this means that the latter system calls do not take account of the +.\" time spent in the stopped state when restarting. +.br restart_syscall () +restarts the interrupted system call with a +time argument that is suitably adjusted to account for the +time that has already elapsed (including the time where the process +was stopped by a signal). +without the +.br restart_syscall () +mechanism, restarting these system calls would not correctly deduct the +already elapsed time when the process continued execution. +.sh return value +the return value of +.br restart_syscall () +is the return value of whatever system call is being restarted. +.sh errors +.i errno +is set as per the errors for whatever system call is being restarted by +.br restart_syscall (). +.sh versions +the +.br restart_syscall () +system call is present since linux 2.6. +.sh conforming to +this system call is linux-specific. +.sh notes +there is no glibc wrapper for this system call, +because it is intended for use only by the kernel and +should never be called by applications. +.pp +the kernel uses +.br restart_syscall () +to ensure that when a system call is restarted +after a process has been stopped by a signal and then resumed by +.br sigcont , +then the time that the process spent in the stopped state is counted +against the timeout interval specified in the original system call. +in the case of system calls that take a timeout argument and +automatically restart after a stop signal plus +.br sigcont , +but which do not have the +.br restart_syscall () +mechanism built in, then, after the process resumes execution, +the time that the process spent in the stop state is +.i not +counted against the timeout value. +notable examples of system calls that suffer this problem are +.br ppoll (2), +.br select (2), +and +.br pselect (2). +.pp +from user space, the operation of +.br restart_syscall () +is largely invisible: +to the process that made the system call that is restarted, +it appears as though that system call executed and +returned in the usual fashion. +.sh see also +.br sigaction (2), +.br sigreturn (2), +.br signal (7) +.\" fixme . ppoll(2), select(2), and pselect(2) +.\" should probably get the restart_syscall() treatment: +.\" if a select() call is suspended by stop-sig+sigcont, the time +.\" spent suspended is *not* deducted when the select() is restarted. +.\" fixme . check whether recvmmsg() handles stop-sig+sigcont properly. +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" iso/iec 9899:1999 +.\" +.th wcschr 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +wcschr \- search a wide character in a wide-character string +.sh synopsis +.nf +.b #include +.pp +.bi "wchar_t *wcschr(const wchar_t *" wcs ", wchar_t " wc ); +.fi +.sh description +the +.br wcschr () +function is the wide-character equivalent +of the +.br strchr (3) +function. +it searches the first occurrence of +.i wc +in the wide-character +string pointed to by +.ir wcs . +.sh return value +the +.br wcschr () +function returns a pointer to the first occurrence of +.i wc +in the wide-character string pointed to by +.ir wcs , +or null if +.i wc +does not occur in the string. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br wcschr () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh see also +.br strchr (3), +.br wcspbrk (3), +.br wcsrchr (3), +.br wcsstr (3), +.br wmemchr (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2013, heinrich schuchardt +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of +.\" this manual under the conditions for verbatim copying, provided that +.\" the entire resulting derived work is distributed under the terms of +.\" a permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume. +.\" no responsibility for errors or omissions, or for damages resulting. +.\" from the use of the information contained herein. the author(s) may. +.\" not have taken the same level of care in the production of this. +.\" manual, which is licensed free of charge, as they might when working. +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.th fanotify_mark 2 2021-08-27 "linux" "linux programmer's manual" +.sh name +fanotify_mark \- add, remove, or modify an fanotify mark on a filesystem +object +.sh synopsis +.nf +.b #include +.pp +.bi "int fanotify_mark(int " fanotify_fd ", unsigned int " flags , +.bi " uint64_t " mask ", int " dirfd \ +", const char *" pathname ); +.fi +.sh description +for an overview of the fanotify api, see +.br fanotify (7). +.pp +.br fanotify_mark () +adds, removes, or modifies an fanotify mark on a filesystem object. +the caller must have read permission on the filesystem object that +is to be marked. +.pp +the +.i fanotify_fd +argument is a file descriptor returned by +.br fanotify_init (2). +.pp +.i flags +is a bit mask describing the modification to perform. +it must include exactly one of the following values: +.tp +.b fan_mark_add +the events in +.i mask +will be added to the mark mask (or to the ignore mask). +.i mask +must be nonempty or the error +.b einval +will occur. +.tp +.b fan_mark_remove +the events in argument +.i mask +will be removed from the mark mask (or from the ignore mask). +.i mask +must be nonempty or the error +.b einval +will occur. +.tp +.b fan_mark_flush +remove either all marks for filesystems, all marks for mounts, or all +marks for directories and files from the fanotify group. +if +.i flags +contains +.br fan_mark_mount , +all marks for mounts are removed from the group. +if +.i flags +contains +.br fan_mark_filesystem , +all marks for filesystems are removed from the group. +otherwise, all marks for directories and files are removed. +no flag other than, and at most one of, the flags +.b fan_mark_mount +or +.b fan_mark_filesystem +can be used in conjunction with +.br fan_mark_flush . +.i mask +is ignored. +.pp +if none of the values above is specified, or more than one is specified, +the call fails with the error +.br einval . +.pp +in addition, +zero or more of the following values may be ored into +.ir flags : +.tp +.b fan_mark_dont_follow +if +.i pathname +is a symbolic link, mark the link itself, rather than the file to which it +refers. +(by default, +.br fanotify_mark () +dereferences +.i pathname +if it is a symbolic link.) +.tp +.b fan_mark_onlydir +if the filesystem object to be marked is not a directory, the error +.b enotdir +shall be raised. +.tp +.b fan_mark_mount +mark the mount specified by +.ir pathname . +if +.i pathname +is not itself a mount point, the mount containing +.i pathname +will be marked. +all directories, subdirectories, and the contained files of the mount +will be monitored. +the events which require that filesystem objects are identified by file handles, +such as +.br fan_create , +.br fan_attrib , +.br fan_move , +and +.br fan_delete_self , +cannot be provided as a +.ir mask +when +.i flags +contains +.br fan_mark_mount . +attempting to do so will result in the error +.b einval +being returned. +.tp +.br fan_mark_filesystem " (since linux 4.20)" +.\" commit d54f4fba889b205e9cd8239182ca5d27d0ac3bc2 +mark the filesystem specified by +.ir pathname . +the filesystem containing +.i pathname +will be marked. +all the contained files and directories of the filesystem from any mount +point will be monitored. +.tp +.b fan_mark_ignored_mask +the events in +.i mask +shall be added to or removed from the ignore mask. +.tp +.b fan_mark_ignored_surv_modify +the ignore mask shall survive modify events. +if this flag is not set, +the ignore mask is cleared when a modify event occurs +for the ignored file or directory. +.pp +.i mask +defines which events shall be listened for (or which shall be ignored). +it is a bit mask composed of the following values: +.tp +.b fan_access +create an event when a file or directory (but see bugs) is accessed (read). +.tp +.b fan_modify +create an event when a file is modified (write). +.tp +.b fan_close_write +create an event when a writable file is closed. +.tp +.b fan_close_nowrite +create an event when a read-only file or directory is closed. +.tp +.b fan_open +create an event when a file or directory is opened. +.tp +.br fan_open_exec " (since linux 5.0)" +.\" commit 9b076f1c0f4869b838a1b7aa0edb5664d47ec8aa +create an event when a file is opened with the intent to be executed. +see notes for additional details. +.tp +.br fan_attrib " (since linux 5.1)" +.\" commit 235328d1fa4251c6dcb32351219bb553a58838d2 +create an event when the metadata for a file or directory has changed. +an fanotify group that identifies filesystem objects by file handles +is required. +.tp +.br fan_create " (since linux 5.1)" +.\" commit 235328d1fa4251c6dcb32351219bb553a58838d2 +create an event when a file or directory has been created in a marked +parent directory. +an fanotify group that identifies filesystem objects by file handles +is required. +.tp +.br fan_delete " (since linux 5.1)" +.\" commit 235328d1fa4251c6dcb32351219bb553a58838d2 +create an event when a file or directory has been deleted in a marked +parent directory. +an fanotify group that identifies filesystem objects by file handles +is required. +.tp +.br fan_delete_self " (since linux 5.1)" +.\" commit 235328d1fa4251c6dcb32351219bb553a58838d2 +create an event when a marked file or directory itself is deleted. +an fanotify group that identifies filesystem objects by file handles +is required. +.tp +.br fan_moved_from " (since linux 5.1)" +.\" commit 235328d1fa4251c6dcb32351219bb553a58838d2 +create an event when a file or directory has been moved from a marked +parent directory. +an fanotify group that identifies filesystem objects by file handles +is required. +.tp +.br fan_moved_to " (since linux 5.1)" +.\" commit 235328d1fa4251c6dcb32351219bb553a58838d2 +create an event when a file or directory has been moved to a marked parent +directory. +an fanotify group that identifies filesystem objects by file handles +is required. +.tp +.br fan_move_self " (since linux 5.1)" +.\" commit 235328d1fa4251c6dcb32351219bb553a58838d2 +create an event when a marked file or directory itself has been moved. +an fanotify group that identifies filesystem objects by file handles +is required. +.tp +.b fan_open_perm +create an event when a permission to open a file or directory is requested. +an fanotify file descriptor created with +.b fan_class_pre_content +or +.b fan_class_content +is required. +.tp +.br fan_open_exec_perm " (since linux 5.0)" +.\" commit 66917a3130f218dcef9eeab4fd11a71cd00cd7c9 +create an event when a permission to open a file for execution is +requested. +an fanotify file descriptor created with +.b fan_class_pre_content +or +.b fan_class_content +is required. +see notes for additional details. +.tp +.b fan_access_perm +create an event when a permission to read a file or directory is requested. +an fanotify file descriptor created with +.b fan_class_pre_content +or +.b fan_class_content +is required. +.tp +.b fan_ondir +create events for directories\(emfor example, when +.br opendir (3), +.br readdir (3) +(but see bugs), and +.br closedir (3) +are called. +without this flag, events are created only for files. +in the context of directory entry events, such as +.br fan_create , +.br fan_delete , +.br fan_moved_from , +and +.br fan_moved_to , +specifying the flag +.br fan_ondir +is required in order to create events when subdirectory entries are +modified (i.e., +.br mkdir (2)/ +.br rmdir (2)). +.tp +.b fan_event_on_child +events for the immediate children of marked directories shall be created. +the flag has no effect when marking mounts and filesystems. +note that events are not generated for children of the subdirectories +of marked directories. +more specifically, the directory entry modification events +.br fan_create , +.br fan_delete , +.br fan_moved_from , +and +.br fan_moved_to +are not generated for any entry modifications performed inside subdirectories +of marked directories. +note that the events +.br fan_delete_self +and +.br fan_move_self +are not generated for children of marked directories. +to monitor complete directory trees it is necessary to mark the relevant +mount or filesystem. +.pp +the following composed values are defined: +.tp +.b fan_close +a file is closed +.rb ( fan_close_write | fan_close_nowrite ). +.tp +.b fan_move +a file or directory has been moved +.rb ( fan_moved_from | fan_moved_to ). +.pp +the filesystem object to be marked is determined by the file descriptor +.i dirfd +and the pathname specified in +.ir pathname : +.ip * 3 +if +.i pathname +is null, +.i dirfd +defines the filesystem object to be marked. +.ip * +if +.i pathname +is null, and +.i dirfd +takes the special value +.br at_fdcwd , +the current working directory is to be marked. +.ip * +if +.i pathname +is absolute, it defines the filesystem object to be marked, and +.i dirfd +is ignored. +.ip * +if +.i pathname +is relative, and +.i dirfd +does not have the value +.br at_fdcwd , +then the filesystem object to be marked is determined by interpreting +.i pathname +relative the directory referred to by +.ir dirfd . +.ip * +if +.i pathname +is relative, and +.i dirfd +has the value +.br at_fdcwd , +then the filesystem object to be marked is determined by interpreting +.i pathname +relative to the current working directory. +(see +.br openat (2) +for an explanation of why the +.i dirfd +argument is useful.) +.sh return value +on success, +.br fanotify_mark () +returns 0. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b ebadf +an invalid file descriptor was passed in +.ir fanotify_fd . +.tp +.b ebadf +.i pathname +is relative but +.i dirfd +is neither +.b at_fdcwd +nor a valid file descriptor. +.tp +.b einval +an invalid value was passed in +.ir flags +or +.ir mask , +or +.i fanotify_fd +was not an fanotify file descriptor. +.tp +.b einval +the fanotify file descriptor was opened with +.b fan_class_notif +or the fanotify group identifies filesystem objects by file handles +and mask contains a flag for permission events +.rb ( fan_open_perm +or +.br fan_access_perm ). +.tp +.b enodev +the filesystem object indicated by +.i pathname +is not associated with a filesystem that supports +.i fsid +(e.g., +.br tmpfs (5)). +this error can be returned only with an fanotify group that identifies +filesystem objects by file handles. +.tp +.b enoent +the filesystem object indicated by +.ir dirfd +and +.ir pathname +does not exist. +this error also occurs when trying to remove a mark from an object +which is not marked. +.tp +.b enomem +the necessary memory could not be allocated. +.tp +.b enospc +the number of marks exceeds the limit of 8192 and the +.b fan_unlimited_marks +flag was not specified when the fanotify file descriptor was created with +.br fanotify_init (2). +.tp +.b enosys +this kernel does not implement +.br fanotify_mark (). +the fanotify api is available only if the kernel was configured with +.br config_fanotify . +.tp +.b enotdir +.i flags +contains +.br fan_mark_onlydir , +and +.i dirfd +and +.i pathname +do not specify a directory. +.tp +.b eopnotsupp +the object indicated by +.i pathname +is associated with a filesystem that does not support the encoding of file +handles. +this error can be returned only with an fanotify group that identifies +filesystem objects by file handles. +.tp +.b exdev +the filesystem object indicated by +.i pathname +resides within a filesystem subvolume (e.g., +.br btrfs (5)) +which uses a different +.i fsid +than its root superblock. +this error can be returned only with an fanotify group that identifies +filesystem objects by file handles. +.sh versions +.br fanotify_mark () +was introduced in version 2.6.36 of the linux kernel and enabled in version +2.6.37. +.sh conforming to +this system call is linux-specific. +.sh notes +.ss fan_open_exec and fan_open_exec_perm +when using either +.b fan_open_exec +or +.b fan_open_exec_perm +within the +.ir mask , +events of these types will be returned only when the direct execution of a +program occurs. +more specifically, this means that events of these types will be generated +for files that are opened using +.br execve (2), +.br execveat (2), +or +.br uselib (2). +events of these types will not be raised in the situation where an +interpreter is passed (or reads) a file for interpretation. +.pp +additionally, if a mark has also been placed on the linux dynamic +linker, a user should also expect to receive an event for it when +an elf object has been successfully opened using +.br execve (2) +or +.br execveat (2). +.pp +for example, if the following elf binary were to be invoked and a +.br fan_open_exec +mark has been placed on /: +.pp +.in +4n +.ex +$ /bin/echo foo +.ee +.in +.pp +the listening application in this case would receive +.br fan_open_exec +events for both the elf binary and interpreter, respectively: +.pp +.in +4n +.ex +/bin/echo +/lib64/ld\-linux\-x86\-64.so.2 +.ee +.in +.sh bugs +the following bugs were present in linux kernels before version 3.16: +.ip * 3 +.\" fixed by commit 0a8dd2db579f7a0ac7033d6b857c3d5dbaa77563 +if +.i flags +contains +.br fan_mark_flush , +.ir dirfd , +and +.i pathname +must specify a valid filesystem object, even though this object is not used. +.ip * +.\" fixed by commit d4c7cf6cffb1bc711a833b5e304ba5bcfe76398b +.br readdir (2) +does not generate a +.b fan_access +event. +.ip * +.\" fixed by commit cc299a98eb13a9853675a9cbb90b30b4011e1406 +if +.br fanotify_mark () +is called with +.br fan_mark_flush , +.i flags +is not checked for invalid values. +.sh see also +.br fanotify_init (2), +.br fanotify (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2012 by michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th malloc_info 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +malloc_info \- export malloc state to a stream +.sh synopsis +.nf +.b #include +.pp +.bi "int malloc_info(int " options ", file *" stream ); +.fi +.sh description +the +.br malloc_info () +function exports an xml string that describes the current state +of the memory-allocation +implementation in the caller. +the string is printed on the file stream +.ir stream . +the exported string includes information about all arenas (see +.br malloc (3)). +.pp +as currently implemented, +.i options +must be zero. +.sh return value +on success, +.br malloc_info () +returns 0. +on failure, it returns \-1, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b einval +.i options +was nonzero. +.sh versions +.br malloc_info () +was added to glibc in version 2.10. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br malloc_info () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +this function is a gnu extension. +.sh notes +the memory-allocation information is provided as an xml string +(rather than a c structure) +because the information may change over time +(according to changes in the underlying implementation). +the output xml string includes a version field. +.pp +the +.br open_memstream (3) +function can be used to send the output of +.br malloc_info () +directly into a buffer in memory, rather than to a file. +.pp +the +.br malloc_info () +function is designed to address deficiencies in +.br malloc_stats (3) +and +.br mallinfo (3). +.sh examples +the program below takes up to four command-line arguments, +of which the first three are mandatory. +the first argument specifies the number of threads that +the program should create. +all of the threads, including the main thread, +allocate the number of blocks of memory specified by the second argument. +the third argument controls the size of the blocks to be allocated. +the main thread creates blocks of this size, +the second thread created by the program allocates blocks of twice this size, +the third thread allocates blocks of three times this size, and so on. +.pp +the program calls +.br malloc_info () +twice to display the memory-allocation state. +the first call takes place before any threads +are created or memory allocated. +the second call is performed after all threads have allocated memory. +.pp +in the following example, +the command-line arguments specify the creation of one additional thread, +and both the main thread and the additional thread +allocate 10000 blocks of memory. +after the blocks of memory have been allocated, +.br malloc_info () +shows the state of two allocation arenas. +.pp +.in +4n +.ex +.rb "$ " "getconf gnu_libc_version" +glibc 2.13 +.rb "$ " "./a.out 1 10000 100" +============ before allocating blocks ============ + + + + + + + + + + + + + + + + + + + +============ after allocating blocks ============ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +.ee +.in +.ss program source +.ex +#include +#include +#include +#include +#include + +static size_t blocksize; +static int numthreads, numblocks; + +#define errexit(msg) do { perror(msg); exit(exit_failure); \e + } while (0) + +static void * +thread_func(void *arg) +{ + int tn = (int) arg; + + /* the multiplier \(aq(2 + tn)\(aq ensures that each thread (including + the main thread) allocates a different amount of memory. */ + + for (int j = 0; j < numblocks; j++) + if (malloc(blocksize * (2 + tn)) == null) + errexit("malloc\-thread"); + + sleep(100); /* sleep until main thread terminates. */ + return null; +} + +int +main(int argc, char *argv[]) +{ + int sleeptime; + + if (argc < 4) { + fprintf(stderr, + "%s num\-threads num\-blocks block\-size [sleep\-time]\en", + argv[0]); + exit(exit_failure); + } + + numthreads = atoi(argv[1]); + numblocks = atoi(argv[2]); + blocksize = atoi(argv[3]); + sleeptime = (argc > 4) ? atoi(argv[4]) : 0; + + pthread_t *thr = calloc(numthreads, sizeof(*thr)); + if (thr == null) + errexit("calloc"); + + printf("============ before allocating blocks ============\en"); + malloc_info(0, stdout); + + /* create threads that allocate different amounts of memory. */ + + for (int tn = 0; tn < numthreads; tn++) { + errno = pthread_create(&thr[tn], null, thread_func, + (void *) tn); + if (errno != 0) + errexit("pthread_create"); + + /* if we add a sleep interval after the start\-up of each + thread, the threads likely won\(aqt contend for malloc + mutexes, and therefore additional arenas won\(aqt be + allocated (see malloc(3)). */ + + if (sleeptime > 0) + sleep(sleeptime); + } + + /* the main thread also allocates some memory. */ + + for (int j = 0; j < numblocks; j++) + if (malloc(blocksize) == null) + errexit("malloc"); + + sleep(2); /* give all threads a chance to + complete allocations. */ + + printf("\en============ after allocating blocks ============\en"); + malloc_info(0, stdout); + + exit(exit_success); +} +.ee +.sh see also +.br mallinfo (3), +.br malloc (3), +.br malloc_stats (3), +.br mallopt (3), +.br open_memstream (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de) +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under gpl +.\" %%%license_end +.\" +.th clog10 3 2021-03-22 "" "linux programmer's manual" +.sh name +clog10, clog10f, clog10l \- base-10 logarithm of a complex number +.sh synopsis +.nf +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "double complex clog10(double complex " z ); +.bi "float complex clog10f(float complex " z ); +.bi "long double complex clog10l(long double complex " z ); +.pp +link with \fi\-lm\fp. +.fi +.sh description +the call +.i clog10(z) +is equivalent to: +.pp + clog(z)/log(10) +.pp +or equally: +.pp + log10(cabs(c)) + i * carg(c) / log(10) +.pp +the other functions perform the same task for +.i float +and +.ir "long double" . +.pp +note that +.i z +close to zero will cause an overflow. +.sh versions +these functions first appeared in glibc in version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br clog10 (), +.br clog10f (), +.br clog10l () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +these functions are gnu extensions. +the identifiers are reserved for future use in c99 and c11. +.sh see also +.br cabs (3), +.br cexp (3), +.br clog (3), +.br clog2 (3), +.br complex (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/resolver.3 + +.so man3/remainder.3 + +.so man2/recv.2 + +.so man3/atoi.3 + +.\" copyright michael haardt (michael@cantor.informatik.rwth-aachen.de) +.\" sat aug 27 20:43:50 met dst 1994 +.\" and copyright (c) 2014, michael kerrisk +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" modified sun sep 11 19:19:05 1994 +.\" modified mon mar 25 10:19:00 1996 (merged a few +.\" tiny changes from a man page by charles livingston). +.\" modified sun jul 21 14:45:46 1996 +.\" +.th setsid 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +setsid \- creates a session and sets the process group id +.sh synopsis +.nf +.ad l +.b #include +.pp +.b pid_t setsid(void); +.ad b +.fi +.sh description +.br setsid () +creates a new session if the calling process is not a +process group leader. +the calling process is the leader of the new session +(i.e., its session id is made the same as its process id). +the calling process also becomes +the process group leader of a new process group in the session +(i.e., its process group id is made the same as its process id). +.pp +the calling process will be the only process in +the new process group and in the new session. +.pp +initially, the new session has no controlling terminal. +for details of how a session acquires a controlling terminal, see +.br credentials (7). +.sh return value +on success, the (new) session id of the calling process is returned. +on error, +.i "(pid_t)\ \-1" +is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eperm +the process group id of any process equals the pid of the calling process. +thus, in particular, +.br setsid () +fails if the calling process is already a process group leader. +.sh conforming to +posix.1-2001, posix.1-2008, svr4. +.sh notes +a child created via +.br fork (2) +inherits its parent's session id. +the session id is preserved across an +.br execve (2). +.pp +a process group leader is a process whose process group id equals its pid. +disallowing a process group leader from calling +.br setsid () +prevents the possibility that a process group leader places itself +in a new session while other processes in the process group remain +in the original session; +such a scenario would break the strict +two-level hierarchy of sessions and process groups. +in order to be sure that +.br setsid () +will succeed, call +.br fork (2) +and have the parent +.br _exit (2), +while the child (which by definition can't be a process group leader) calls +.br setsid (). +.pp +if a session has a controlling terminal, and the +.b clocal +flag for that terminal is not set, +and a terminal hangup occurs, then the session leader is sent a +.br sighup +signal. +.pp +if a process that is a session leader terminates, then a +.b sighup +signal is sent to each process in the foreground +process group of the controlling terminal. +.sh see also +.br setsid (1), +.br getsid (2), +.br setpgid (2), +.br setpgrp (2), +.br tcgetsid (3), +.br credentials (7), +.br sched (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/stdarg.3 + +.so man3/unlocked_stdio.3 + +.\" copyright (c) 2020 by alejandro colomar +.\" and copyright (c) 2020 by michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" +.th system_data_types 7 2021-03-22 "linux" "linux programmer's manual" +.sh name +system_data_types \- overview of system data types +.sh description +.\" layout: +.\" a list of type names (the struct/union keyword will be omitted). +.\" each entry will have the following parts: +.\" * include (see notes) +.\" +.\" * definition (no "definition" header) +.\" only struct/union types will have definition; +.\" typedefs will remain opaque. +.\" +.\" * description (no "description" header) +.\" a few lines describing the type. +.\" +.\" * versions (optional) +.\" +.\" * conforming to (see notes) +.\" format: cxy and later; posix.1-xxxx and later. +.\" +.\" * notes (optional) +.\" +.\" * bugs (if any) +.\" +.\" * see also +.\"------------------------------------- aiocb ------------------------/ +.tp +.i aiocb +.rs +.ir include : +.ir . +.pp +.ex +struct aiocb { + int aio_fildes; /* file descriptor */ + off_t aio_offset; /* file offset */ + volatile void *aio_buf; /* location of buffer */ + size_t aio_nbytes; /* length of transfer */ + int aio_reqprio; /* request priority offset */ + struct sigevent aio_sigevent; /* signal number and value */ + int aio_lio_opcode;/* operation to be performed */ +}; +.ee +.pp +for further information about this structure, see +.br aio (7). +.pp +.ir "conforming to" : +posix.1-2001 and later. +.pp +.ir "see also" : +.br aio_cancel (3), +.br aio_error (3), +.br aio_fsync (3), +.br aio_read (3), +.br aio_return (3), +.br aio_suspend (3), +.br aio_write (3), +.br lio_listio (3) +.re +.\"------------------------------------- blkcnt_t ---------------------/ +.tp +.i blkcnt_t +.rs +.ir include : +.ir . +alternatively, +.ir . +.pp +used for file block counts. +according to posix, +it shall be a signed integer type. +.pp +.ir "conforming to" : +posix.1-2001 and later. +.pp +.ir "see also" : +.br stat (2) +.re +.\"------------------------------------- blksize_t --------------------/ +.tp +.i blksize_t +.rs +.ir include : +.ir . +alternatively, +.ir . +.pp +used for file block sizes. +according to posix, +it shall be a signed integer type. +.pp +.ir "conforming to" : +posix.1-2001 and later. +.pp +.ir "see also" : +.br stat (2) +.re +.\"------------------------------------- cc_t -------------------------/ +.tp +.i cc_t +.rs +.ir include : +.ir . +.pp +used for terminal special characters. +according to posix, +it shall be an unsigned integer type. +.pp +.ir "conforming to" : +posix.1-2001 and later. +.pp +.ir "see also" : +.br termios (3) +.re +.\"------------------------------------- clock_t ----------------------/ +.tp +.i clock_t +.rs +.ir include : +.i +or +.ir . +alternatively, +.ir . +.pp +used for system time in clock ticks or +.b clocks_per_sec +(defined in +.ir ). +according to posix, +it shall be an integer type or a real-floating type. +.pp +.ir "conforming to" : +c99 and later; posix.1-2001 and later. +.pp +.ir "see also" : +.br times (2), +.br clock (3) +.re +.\"------------------------------------- clockid_t --------------------/ +.tp +.i clockid_t +.rs +.ir include : +.ir . +alternatively, +.ir . +.pp +used for clock id type in the clock and timer functions. +according to posix, +it shall be defined as an arithmetic type. +.pp +.ir "conforming to" : +posix.1-2001 and later. +.pp +.ir "see also" : +.br clock_adjtime (2), +.br clock_getres (2), +.br clock_nanosleep (2), +.br timer_create (2), +.br clock_getcpuclockid (3) +.re +.\"------------------------------------- dev_t ------------------------/ +.tp +.i dev_t +.rs +.ir include : +.ir . +alternatively, +.ir . +.pp +used for device ids. +according to posix, +it shall be an integer type. +for further details of this type, see +.br makedev (3). +.pp +.ir "conforming to" : +posix.1-2001 and later. +.pp +.ir "see also" : +.br mknod (2), +.br stat (2) +.re +.\"------------------------------------- div_t ------------------------/ +.tp +.i div_t +.rs +.ir include : +.ir . +.pp +.ex +typedef struct { + int quot; /* quotient */ + int rem; /* remainder */ +} div_t; +.ee +.pp +it is the type of the value returned by the +.br div (3) +function. +.pp +.ir "conforming to" : +c99 and later; posix.1-2001 and later. +.pp +.ir "see also" : +.br div (3) +.re +.\"------------------------------------- double_t ---------------------/ +.tp +.i double_t +.rs +.ir include : +.ir . +.pp +the implementation's most efficient floating type at least as wide as +.ir double . +its type depends on the value of the macro +.b flt_eval_method +(defined in +.ir ): +.tp +0 +.i double_t +is +.ir double . +.tp +1 +.i double_t +is +.ir double . +.tp +2 +.i double_t +is +.ir "long double" . +.pp +for other values of +.br flt_eval_method , +the type of +.i double_t +is implementation-defined. +.pp +.ir "conforming to" : +c99 and later; posix.1-2001 and later. +.pp +.ir "see also" : +the +.i float_t +type in this page. +.re +.\"------------------------------------- fd_set -----------------------/ +.tp +.i fd_set +.rs +.ir include : +.ir . +alternatively, +.ir . +.pp +a structure type that can represent a set of file descriptors. +according to posix, +the maximum number of file descriptors in an +.i fd_set +structure is the value of the macro +.br fd_setsize . +.pp +.ir "conforming to" : +posix.1-2001 and later. +.pp +.ir "see also" : +.br select (2) +.re +.\"------------------------------------- fenv_t -----------------------/ +.tp +.i fenv_t +.rs +.ir include : +.ir . +.pp +this type represents the entire floating-point environment, +including control modes and status flags; for further details, see +.br fenv (3). +.pp +.ir "conforming to" : +c99 and later; posix.1-2001 and later. +.pp +.ir "see also" : +.br fenv (3) +.re +.\"------------------------------------- fexcept_t --------------------/ +.tp +.i fexcept_t +.rs +.ir include : +.ir . +.pp +this type represents the floating-point status flags collectively; +for further details see +.br fenv (3). +.pp +.ir "conforming to" : +c99 and later; posix.1-2001 and later. +.pp +.ir "see also" : +.br fenv (3) +.re +.\"------------------------------------- file -------------------------/ +.tp +.i file +.rs +.ir include : +.ir . +alternatively, +.ir . +.pp +an object type used for streams. +.pp +.ir "conforming to" : +c99 and later; posix.1-2001 and later. +.pp +.ir "see also" : +.br fclose (3), +.br flockfile (3), +.br fopen (3), +.br fprintf (3), +.br fread (3), +.br fscanf (3), +.br stdin (3), +.br stdio (3) +.re +.\"------------------------------------- float_t ----------------------/ +.tp +.i float_t +.rs +.ir include : +.ir . +.pp +the implementation's most efficient floating type at least as wide as +.ir float . +its type depends on the value of the macro +.b flt_eval_method +(defined in +.ir ): +.tp +0 +.i float_t +is +.ir float . +.tp +1 +.i float_t +is +.ir double . +.tp +2 +.i float_t +is +.ir "long double" . +.pp +for other values of +.br flt_eval_method , +the type of +.i float_t +is implementation-defined. +.pp +.ir "conforming to" : +c99 and later; posix.1-2001 and later. +.pp +.ir "see also" : +the +.i double_t +type in this page. +.re +.\"------------------------------------- gid_t ------------------------/ +.tp +.i gid_t +.rs +.ir include : +.ir . +alternatively, +.ir , +.ir , +.ir , +.ir , +.ir , +.ir , +or +.ir . +.pp +a type used to hold group ids. +according to posix, +this shall be an integer type. +.pp +.ir "conforming to" : +posix.1-2001 and later. +.pp +.ir "see also" : +.br chown (2), +.br getgid (2), +.br getegid (2), +.br getgroups (2), +.br getresgid (2), +.br getgrnam (3), +.br credentials (7) +.re +.\"------------------------------------- id_t -------------------------/ +.tp +.i id_t +.rs +.ir include : +.ir . +alternatively, +.ir . +.pp +a type used to hold a general identifier. +according to posix, +this shall be an integer type that can be used to contain a +.ir pid_t , +.ir uid_t , +or +.ir gid_t . +.pp +.ir "conforming to" : +posix.1-2001 and later. +.pp +.ir "see also" : +.br getpriority (2), +.br waitid (2) +.re +.\"------------------------------------- imaxdiv_t --------------------/ +.tp +.i imaxdiv_t +.rs +.ir include : +.ir . +.pp +.ex +typedef struct { + intmax_t quot; /* quotient */ + intmax_t rem; /* remainder */ +} imaxdiv_t; +.ee +.pp +it is the type of the value returned by the +.br imaxdiv (3) +function. +.pp +.ir "conforming to" : +c99 and later; posix.1-2001 and later. +.pp +.ir "see also" : +.br imaxdiv (3) +.re +.\"------------------------------------- intmax_t ---------------------/ +.tp +.i intmax_t +.rs +.ir include : +.ir . +alternatively, +.ir . +.pp +a signed integer type +capable of representing any value of any signed integer type +supported by the implementation. +according to the c language standard, it shall be +capable of storing values in the range +.rb [ intmax_min , +.br intmax_max ]. +.pp +the macro +.br intmax_c () +.\" todo: document int*_c(3) +expands its argument to an integer constant of type +.ir intmax_t . +.pp +the length modifier for +.i intmax_t +for the +.br printf (3) +and the +.br scanf (3) +families of functions is +.br j ; +resulting commonly in +.b %jd +or +.b %ji +for printing +.i intmax_t +values. +.pp +.ir "conforming to" : +c99 and later; posix.1-2001 and later. +.pp +.ir bugs : +.i intmax_t +is not large enough to represent values of type +.i __int128 +in implementations where +.i __int128 +is defined and +.i long long +is less than 128 bits wide. +.pp +.ir "see also" : +the +.i uintmax_t +type in this page. +.re +.\"------------------------------------- intn_t -----------------------/ +.tp +.ir int n _t +.rs +.ir include : +.ir . +alternatively, +.ir . +.pp +.ir int8_t , +.ir int16_t , +.ir int32_t , +.i int64_t +.pp +a signed integer type +of a fixed width of exactly n bits, +n being the value specified in its type name. +according to the c language standard, they shall be +capable of storing values in the range +.rb [ int n _min , +.br int n _max ], +substituting n by the appropriate number. +.pp +according to posix, +.ir int8_t , +.ir int16_t , +and +.i int32_t +are required; +.i int64_t +is only required in implementations that provide integer types +with width 64; +and all other types of this form are optional. +.pp +the length modifiers for the +.ir int n _t +types for the +.br printf (3) +family of functions +are expanded by macros of the forms +.br prid n +and +.br prii n +(defined in +.ir ); +resulting for example in +.b %"prid64" +or +.b %"prii64" +for printing +.i int64_t +values. +the length modifiers for the +.ir int n _t +types for the +.br scanf (3) +family of functions +are expanded by macros of the forms +.br scnd n +and +.br scni n, +(defined in +.ir ); +resulting for example in +.b %"scnd8" +or +.b %"scni8" +for scanning +.i int8_t +values. +.pp +.ir "conforming to" : +c99 and later; posix.1-2001 and later. +.pp +.ir "see also" : +the +.ir intmax_t , +.ir uint n _t , +and +.i uintmax_t +types in this page. +.re +.\"------------------------------------- intptr_t ---------------------/ +.tp +.i intptr_t +.rs +.ir include : +.ir . +alternatively, +.ir . +.pp +a signed integer type +such that any valid +.ri ( "void *" ) +value can be converted to this type and back. +according to the c language standard, it shall be +capable of storing values in the range +.rb [ intptr_min , +.br intptr_max ]. +.pp +the length modifier for +.i intptr_t +for the +.br printf (3) +family of functions +is expanded by the macros +.b pridptr +and +.b priiptr +(defined in +.ir ); +resulting commonly in +.b %"pridptr" +or +.b %"priiptr" +for printing +.i intptr_t +values. +the length modifier for +.i intptr_t +for the +.br scanf (3) +family of functions +is expanded by the macros +.b scndptr +and +.b scniptr, +(defined in +.ir ); +resulting commonly in +.b %"scndptr" +or +.b %"scniptr" +for scanning +.i intptr_t +values. +.pp +.ir "conforming to" : +c99 and later; posix.1-2001 and later. +.pp +.ir "see also" : +the +.i uintptr_t +and +.i void * +types in this page. +.re +.\"------------------------------------- lconv ------------------------/ +.tp +.i lconv +.rs +.ir include : +.ir . +.pp +.ex +struct lconv { /* values in the "c" locale: */ + char *decimal_point; /* "." */ + char *thousands_sep; /* "" */ + char *grouping; /* "" */ + char *mon_decimal_point; /* "" */ + char *mon_thousands_sep; /* "" */ + char *mon_grouping; /* "" */ + char *positive_sign; /* "" */ + char *negative_sign; /* "" */ + char *currency_symbol; /* "" */ + char frac_digits; /* char_max */ + char p_cs_precedes; /* char_max */ + char n_cs_precedes; /* char_max */ + char p_sep_by_space; /* char_max */ + char n_sep_by_space; /* char_max */ + char p_sign_posn; /* char_max */ + char n_sign_posn; /* char_max */ + char *int_curr_symbol; /* "" */ + char int_frac_digits; /* char_max */ + char int_p_cs_precedes; /* char_max */ + char int_n_cs_precedes; /* char_max */ + char int_p_sep_by_space; /* char_max */ + char int_n_sep_by_space; /* char_max */ + char int_p_sign_posn; /* char_max */ + char int_n_sign_posn; /* char_max */ +}; +.ee +.pp +contains members related to the formatting of numeric values. +in the "c" locale, its members have the values +shown in the comments above. +.pp +.ir "conforming to" : +c11 and later; posix.1-2001 and later. +.pp +.ir "see also" : +.br setlocale (3), +.br localeconv (3), +.br charsets (7), +.br locale (7) +.re +.\"------------------------------------- ldiv_t -----------------------/ +.tp +.i ldiv_t +.rs +.ir include : +.ir . +.pp +.ex +typedef struct { + long quot; /* quotient */ + long rem; /* remainder */ +} ldiv_t; +.ee +.pp +it is the type of the value returned by the +.br ldiv (3) +function. +.pp +.ir "conforming to" : +c99 and later; posix.1-2001 and later. +.pp +.ir "see also" : +.br ldiv (3) +.re +.\"------------------------------------- lldiv_t ----------------------/ +.tp +.i lldiv_t +.rs +.ir include : +.ir . +.pp +.ex +typedef struct { + long long quot; /* quotient */ + long long rem; /* remainder */ +} lldiv_t; +.ee +.pp +it is the type of the value returned by the +.br lldiv (3) +function. +.pp +.ir "conforming to" : +c99 and later; posix.1-2001 and later. +.pp +.ir "see also" : +.br lldiv (3) +.re +.\"------------------------------------- mode_t -----------------------/ +.tp +.i mode_t +.rs +.ir include : +.ir . +alternatively, +.ir , +.ir , +.ir , +.ir , +.ir , +or +.ir . +.pp +used for some file attributes (e.g., file mode). +according to posix, +it shall be an integer type. +.pp +.ir "conforming to" : +posix.1-2001 and later. +.pp +.ir "see also" : +.br chmod (2), +.br mkdir (2), +.br open (2), +.br stat (2), +.br umask (2) +.re +.\"------------------------------------- off64_t ----------------------/ +.tp +.i off64_t +.rs +.ir include : +.ir . +.pp +used for file sizes. +it is a 64-bit signed integer type. +.pp +.ir "conforming to" : +present in glibc. +it is not standardized by the c language standard nor posix. +.pp +.ir notes : +the feature test macro +.b _largefile64_source +has to be defined for this type to be available. +.pp +.ir "see also" : +.br copy_file_range (2), +.br readahead (2), +.br sync_file_range (2), +.br lseek64 (3), +.br feature_test_macros (7) +.pp +see also the +.\" .i loff_t +.\" and +.i off_t +type in this page. +.re +.\"------------------------------------- off_t ------------------------/ +.tp +.i off_t +.rs +.ir include : +.ir . +alternatively, +.ir , +.ir , +.ir , +.ir , +.ir , +or +.ir . +.pp +used for file sizes. +according to posix, +this shall be a signed integer type. +.pp +.ir versions : +.i +and +.i +define +.i off_t +since posix.1-2008. +.pp +.ir "conforming to" : +posix.1-2001 and later. +.pp +.ir notes : +on some architectures, +the width of this type can be controlled with the feature test macro +.br _file_offset_bits . +.pp +.ir "see also" : +.\" .br fallocate (2), +.br lseek (2), +.br mmap (2), +.\" .br mmap2 (2), +.br posix_fadvise (2), +.br pread (2), +.\" .br preadv (2), +.br truncate (2), +.br fseeko (3), +.\" .br getdirentries (3), +.br lockf (3), +.br posix_fallocate (3), +.br feature_test_macros (7) +.pp +see also the +.\" .i loff_t +.\" and +.i off64_t +type in this page. +.re +.\"------------------------------------- pid_t ------------------------/ +.tp +.i pid_t +.rs +.ir include : +.ir . +alternatively, +.ir , +.ir , +.ir , +.ir , +.ir , +.ir , +.ir , +.ir , +.ir , +.ir , +.ir , +or +.ir . +.pp +this type is used for storing process ids, process group ids, and session ids. +according to posix, it shall be a signed integer type, +and the implementation shall support one or more programming environments +where the width of +.i pid_t +is no greater than the width of the type +.ir long . +.pp +.ir "conforming to" : +posix.1-2001 and later. +.pp +.ir "see also" : +.br fork (2), +.br getpid (2), +.br getppid (2), +.br getsid (2), +.br gettid (2), +.br getpgid (2), +.br kill (2), +.br pidfd_open (2), +.br sched_setscheduler (2), +.br waitpid (2), +.br sigqueue (3), +.br credentials (7), +.re +.\"------------------------------------- ptrdiff_t --------------------/ +.tp +.i ptrdiff_t +.rs +.ir include : +.ir . +.pp +used for a count of elements, and array indices. +it is the result of subtracting two pointers. +according to the c language standard, it shall be a signed integer type +capable of storing values in the range +.rb [ ptrdiff_min , +.br ptrdiff_max ]. +.pp +the length modifier for +.i ptrdiff_t +for the +.br printf (3) +and the +.br scanf (3) +families of functions is +.br t ; +resulting commonly in +.b %td +or +.b %ti +for printing +.i ptrdiff_t +values. +.pp +.ir "conforming to" : +c99 and later; posix.1-2001 and later. +.pp +.ir "see also" : +the +.i size_t +and +.i ssize_t +types in this page. +.re +.\"------------------------------------- regex_t ----------------------/ +.tp +.i regex_t +.rs +.ir include : +.ir . +.pp +.ex +typedef struct { + size_t re_nsub; /* number of parenthesized subexpressions */ +} regex_t; +.ee +.pp +this is a structure type used in regular expression matching. +it holds a compiled regular expression, compiled with +.br regcomp (3). +.pp +.ir "conforming to" : +posix.1-2001 and later. +.pp +.ir "see also" : +.br regex (3) +.re +.\"------------------------------------- regmatch_t -------------------/ +.tp +.i regmatch_t +.rs +.ir include : +.ir . +.pp +.ex +typedef struct { + regoff_t rm_so; /* byte offset from start of string + to start of substring */ + regoff_t rm_eo; /* byte offset from start of string of + the first character after the end of + substring */ +} regmatch_t; +.ee +.pp +this is a structure type used in regular expression matching. +.pp +.ir "conforming to" : +posix.1-2001 and later. +.pp +.ir "see also" : +.br regexec (3) +.re +.\"------------------------------------- regoff_t ---------------------/ +.tp +.i regoff_t +.rs +.ir include : +.ir . +.pp +according to posix, it shall be a signed integer type +capable of storing the largest value that can be stored in either a +.i ptrdiff_t +type or a +.i ssize_t +type. +.pp +.ir versions : +prior to posix.1-2008, the type was capable of storing +the largest value that can be stored in either an +.i off_t +type or a +.i ssize_t +type. +.pp +.ir "conforming to" : +posix.1-2001 and later. +.pp +.ir "see also" : +the +.i regmatch_t +structure and the +.i ptrdiff_t +and +.i ssize_t +types in this page. +.re +.\"------------------------------------- sigevent ---------------------/ +.tp +.i sigevent +.rs +.ir include : +.ir . +alternatively, +.ir , +.ir , +or +.ir . +.pp +.ex +struct sigevent { + int sigev_notify; /* notification type */ + int sigev_signo; /* signal number */ + union sigval sigev_value; /* signal value */ + void (*sigev_notify_function)(union sigval); + /* notification function */ + pthread_attr_t *sigev_notify_attributes; + /* notification attributes */ +}; +.ee +.pp +for further details about this type, see +.br sigevent (7). +.pp +.ir versions : +.i +and +.i +define +.i sigevent +since posix.1-2008. +.pp +.ir "conforming to" : +posix.1-2001 and later. +.pp +.ir "see also" : +.br timer_create (2), +.br getaddrinfo_a (3), +.br lio_listio (3), +.br mq_notify (3) +.pp +see also the +.i aiocb +structure in this page. +.re +.\"------------------------------------- siginfo_t --------------------/ +.tp +.i siginfo_t +.rs +.ir include : +.ir . +alternatively, +.ir . +.pp +.ex +typedef struct { + int si_signo; /* signal number */ + int si_code; /* signal code */ + pid_t si_pid; /* sending process id */ + uid_t si_uid; /* real user id of sending process */ + void *si_addr; /* address of faulting instruction */ + int si_status; /* exit value or signal */ + union sigval si_value; /* signal value */ +} siginfo_t; +.ee +.pp +information associated with a signal. +for further details on this structure +(including additional, linux-specific fields), see +.br sigaction (2). +.pp +.ir "conforming to" : +posix.1-2001 and later. +.pp +.ir "see also" : +.br pidfd_send_signal (2), +.br rt_sigqueueinfo (2), +.br sigaction (2), +.br sigwaitinfo (2), +.br psiginfo (3) +.re +.\"------------------------------------- sigset_t ---------------------/ +.tp +.i sigset_t +.rs +.ir include : +.ir . +alternatively, +.ir , +or +.ir . +.pp +this is a type that represents a set of signals. +according to posix, this shall be an integer or structure type. +.pp +.ir "conforming to" : +posix.1-2001 and later. +.pp +.ir "see also" : +.br epoll_pwait (2), +.br ppoll (2), +.br pselect (2), +.br sigaction (2), +.br signalfd (2), +.br sigpending (2), +.br sigprocmask (2), +.br sigsuspend (2), +.br sigwaitinfo (2), +.br signal (7) +.re +.\"------------------------------------- sigval -----------------------/ +.tp +.i sigval +.rs +.ir include : +.ir . +.pp +.ex +union sigval { + int sigval_int; /* integer value */ + void *sigval_ptr; /* pointer value */ +}; +.ee +.pp +data passed with a signal. +.pp +.ir "conforming to" : +posix.1-2001 and later. +.pp +.ir "see also" : +.br pthread_sigqueue (3), +.br sigqueue (3), +.br sigevent (7) +.pp +see also the +.i sigevent +structure +and the +.i siginfo_t +type +in this page. +.re +.\"------------------------------------- size_t -----------------------/ +.tp +.i size_t +.rs +.ir include : +.i +or +.ir . +alternatively, +.ir , +.ir , +.ir , +.ir , +.ir , +.ir , +.ir , +.ir , +.ir , +.ir , +.ir , +.ir , +.ir , +.ir , +.ir , +.ir , +.ir , +.ir , +.ir , +.ir , +.ir , +.ir , +.ir , +.ir , +or +.ir . +.pp +used for a count of bytes. +it is the result of the +.i sizeof +operator. +according to the c language standard, +it shall be an unsigned integer type +capable of storing values in the range [0, +.br size_max ]. +according to posix, +the implementation shall support one or more programming environments +where the width of +.i size_t +is no greater than the width of the type +.ir long . +.pp +the length modifier for +.i size_t +for the +.br printf (3) +and the +.br scanf (3) +families of functions is +.br z ; +resulting commonly in +.b %zu +or +.b %zx +for printing +.i size_t +values. +.pp +.ir versions : +.ir , +.ir , +.ir , +.ir , +.ir , +.ir , +.ir , +and +.i +define +.i size_t +since posix.1-2008. +.pp +.ir "conforming to" : +c99 and later; posix.1-2001 and later. +.pp +.ir "see also" : +.br read (2), +.br write (2), +.br fread (3), +.br fwrite (3), +.br memcmp (3), +.br memcpy (3), +.br memset (3), +.br offsetof (3) +.pp +see also the +.i ptrdiff_t +and +.i ssize_t +types in this page. +.re +.\"------------------------------------- sockaddr ---------------------/ +.tp +.i sockaddr +.rs +.ir include : +.ir . +.pp +.ex +struct sockaddr { + sa_family_t sa_family; /* address family */ + char sa_data[]; /* socket address */ +}; +.ee +.pp +describes a socket address. +.pp +.ir "conforming to" : +posix.1-2001 and later. +.pp +.ir "see also" : +.br accept (2), +.br getpeername (2), +.br getsockname (2), +.br socket (2) +.re +.\"------------------------------------- socklen_t --------------------/ +.tp +.i socklen_t +.rs +.ir include : +.ir . +alternatively, +.ir . +.pp +describes the length of a socket address. +according to posix, +this shall be an integer type of at least 32 bits. +.pp +.ir "conforming to" : +posix.1-2001 and later. +.pp +.ir "see also" : +.br accept (2), +.br bind (2), +.br connect (2), +.br gethostbyaddr (2), +.br getnameinfo (2), +.br socket (2) +.pp +see also the +.i sockaddr +structure in this page. +.re +.\"------------------------------------- ssize_t ----------------------/ +.tp +.i ssize_t +.rs +.ir include : +.ir . +alternatively, +.ir , +.ir , +.ir , +.ir , +.ir , +.ir , +.ir , +or +.ir . +.pp +used for a count of bytes or an error indication. +according to posix, it shall be a signed integer type +capable of storing values at least in the range [-1, +.br ssize_max ], +and the implementation shall support one or more programming environments +where the width of +.i ssize_t +is no greater than the width of the type +.ir long . +.pp +glibc and most other implementations provide a length modifier for +.i ssize_t +for the +.br printf (3) +and the +.br scanf (3) +families of functions, which is +.br z ; +resulting commonly in +.b %zd +or +.b %zi +for printing +.i ssize_t +values. +although +.b z +works for +.i ssize_t +on most implementations, +portable posix programs should avoid using it\(emfor example, +by converting the value to +.i intmax_t +and using its length modifier +.rb ( j ). +.pp +.ir "conforming to" : +posix.1-2001 and later. +.pp +.ir "see also" : +.br read (2), +.br readlink (2), +.br readv (2), +.br recv (2), +.br send (2), +.br write (2) +.pp +see also the +.i ptrdiff_t +and +.i size_t +types in this page. +.re +.\"------------------------------------- suseconds_t ------------------/ +.tp +.i suseconds_t +.rs +.ir include : +.ir . +alternatively, +.ir , +or +.ir . +.pp +used for time in microseconds. +according to posix, it shall be a signed integer type +capable of storing values at least in the range [-1, 1000000], +and the implementation shall support one or more programming environments +where the width of +.i suseconds_t +is no greater than the width of the type +.ir long . +.pp +.ir "conforming to" : +posix.1-2001 and later. +.pp +.ir "see also" : +the +.i timeval +structure in this page. +.re +.\"------------------------------------- time_t -----------------------/ +.tp +.i time_t +.rs +.ir include : +.i +or +.ir . +alternatively, +.ir , +.ir , +.ir , +.ir , +.ir , +.ir , +.ir , +or +.ir . +.pp +used for time in seconds. +according to posix, it shall be an integer type. +.\" in posix.1-2001, the type was specified as being either an integer +.\" type or a real-floating type. however, existing implementations +.\" used an integer type, and posix.1-2008 tightened the specification +.\" to reflect this. +.pp +.ir versions : +.i +defines +.i time_t +since posix.1-2008. +.pp +.ir "conforming to" : +c99 and later; posix.1-2001 and later. +.pp +.ir "see also" : +.br stime (2), +.br time (2), +.br ctime (3), +.br difftime (3) +.re +.\"------------------------------------- timer_t ----------------------/ +.tp +.i timer_t +.rs +.ir include : +.ir . +alternatively, +.ir . +.pp +used for timer id returned by +.br timer_create (2). +according to posix, +there are no defined comparison or assignment operators for this type. +.pp +.ir "conforming to" : +posix.1-2001 and later. +.pp +.ir "see also" : +.br timer_create (2), +.br timer_delete (2), +.br timer_getoverrun (2), +.br timer_settime (2) +.re +.\"------------------------------------- timespec ---------------------/ +.tp +.i timespec +.rs +.ir include : +.ir . +alternatively, +.ir , +.ir , +.ir , +.ir , +.ir , +or +.ir . +.pp +.ex +struct timespec { + time_t tv_sec; /* seconds */ + long tv_nsec; /* nanoseconds */ +}; +.ee +.pp +describes times in seconds and nanoseconds. +.pp +.ir "conforming to" : +c11 and later; posix.1-2001 and later. +.pp +.ir "see also" : +.br clock_gettime (2), +.br clock_nanosleep (2), +.br nanosleep (2), +.br timerfd_gettime (2), +.br timer_gettime (2) +.re +.\"------------------------------------- timeval ----------------------/ +.tp +.i timeval +.rs +.ir include : +.ir . +alternatively, +.ir , +.ir , +or +.ir . +.pp +.ex +struct timeval { + time_t tv_sec; /* seconds */ + suseconds_t tv_usec; /* microseconds */ +}; +.ee +.pp +describes times in seconds and microseconds. +.pp +.ir "conforming to" : +posix.1-2001 and later. +.pp +.ir "see also" : +.br gettimeofday (2), +.br select (2), +.br utimes (2), +.br adjtime (3), +.br futimes (3), +.br timeradd (3) +.re +.\"------------------------------------- uid_t ----------------------/ +.tp +.i uid_t +.rs +.ir include : +.ir . +alternatively, +.ir , +.ir , +.ir , +.ir , +.ir , +or +.ir . +.pp +a type used to hold user ids. +according to posix, +this shall be an integer type. +.pp +.ir "conforming to" : +posix.1-2001 and later. +.pp +.ir "see also" : +.br chown (2), +.br getuid (2), +.br geteuid (2), +.br getresuid (2), +.br getpwnam (3), +.br credentials (7) +.re +.\"------------------------------------- uintmax_t --------------------/ +.tp +.i uintmax_t +.rs +.ir include : +.ir . +alternatively, +.ir . +.pp +an unsigned integer type +capable of representing any value of any unsigned integer type +supported by the implementation. +according to the c language standard, it shall be +capable of storing values in the range [0, +.br uintmax_max ]. +.pp +the macro +.br uintmax_c () +.\" todo: document uint*_c(3) +expands its argument to an integer constant of type +.ir uintmax_t . +.pp +the length modifier for +.i uintmax_t +for the +.br printf (3) +and the +.br scanf (3) +families of functions is +.br j ; +resulting commonly in +.b %ju +or +.b %jx +for printing +.i uintmax_t +values. +.pp +.ir "conforming to" : +c99 and later; posix.1-2001 and later. +.pp +.ir bugs : +.i uintmax_t +is not large enough to represent values of type +.i unsigned __int128 +in implementations where +.i unsigned __int128 +is defined and +.i unsigned long long +is less than 128 bits wide. +.pp +.ir "see also" : +the +.i intmax_t +type in this page. +.re +.\"------------------------------------- uintn_t ----------------------/ +.tp +.ir uint n _t +.rs +.ir include : +.ir . +alternatively, +.ir . +.pp +.ir uint8_t , +.ir uint16_t , +.ir uint32_t , +.i uint64_t +.pp +an unsigned integer type +of a fixed width of exactly n bits, +n being the value specified in its type name. +according to the c language standard, they shall be +capable of storing values in the range [0, +.br uint n _max ], +substituting n by the appropriate number. +.pp +according to posix, +.ir uint8_t , +.ir uint16_t , +and +.i uint32_t +are required; +.i uint64_t +is only required in implementations that provide integer types +with width 64; +and all other types of this form are optional. +.pp +the length modifiers for the +.ir uint n _t +types for the +.br printf (3) +family of functions +are expanded by macros of the forms +.br priu n, +.br prio n, +.br prix n, +and +.br prix n +(defined in +.ir ); +resulting for example in +.b %"priu32" +or +.b %"prix32" +for printing +.i uint32_t +values. +the length modifiers for the +.ir uint n _t +types for the +.br scanf (3) +family of functions +are expanded by macros of the forms +.br scnu n, +.br scno n, +.br scnx n, +and +.br scnx n +(defined in +.ir ); +resulting for example in +.b %"scnu16" +or +.b %"scnx16" +for scanning +.i uint16_t +values. +.pp +.ir "conforming to" : +c99 and later; posix.1-2001 and later. +.pp +.ir "see also" : +the +.ir intmax_t , +.ir int n _t , +and +.ir uintmax_t +types in this page. +.re +.\"------------------------------------- uintptr_t --------------------/ +.tp +.i uintptr_t +.rs +.ir include : +.ir . +alternatively, +.ir . +.pp +an unsigned integer type +such that any valid +.ri ( "void *" ) +value can be converted to this type and back. +according to the c language standard, it shall be +capable of storing values in the range [0, +.br uintptr_max ]. +.pp +the length modifier for +.i uintptr_t +for the +.br printf (3) +family of functions +is expanded by the macros +.br priuptr , +.br prioptr , +.br prixptr , +and +.b prixptr +(defined in +.ir ); +resulting commonly in +.b %"priuptr" +or +.b %"prixptr" +for printing +.i uintptr_t +values. +the length modifier for +.i uintptr_t +for the +.br scanf (3) +family of functions +is expanded by the macros +.br scnuptr, +.br scnoptr, +.br scnxptr , +and +.b scnxptr +(defined in +.ir ); +resulting commonly in +.b %"scnuptr" +or +.b %"scnxptr" +for scanning +.i uintptr_t +values. +.pp +.ir "conforming to" : +c99 and later; posix.1-2001 and later. +.pp +.ir "see also" : +the +.i intptr_t +and +.i void * +types in this page. +.re +.\"------------------------------------- va_list ----------------------/ +.tp +.i va_list +.rs +.ir include : +.ir . +alternatively, +.ir , +or +.ir . +.pp +used by functions with a varying number of arguments of varying types. +the function must declare an object of type +.i va_list +which is used by the macros +.br va_start (3), +.br va_arg (3), +.br va_copy (3), +and +.br va_end (3) +to traverse the list of arguments. +.pp +.ir "conforming to" : +c99 and later; posix.1-2001 and later. +.pp +.ir "see also" : +.br va_start (3), +.br va_arg (3), +.br va_copy (3), +.br va_end (3) +.re +.\"------------------------------------- void * -----------------------/ +.tp +.i void * +.rs +according to the c language standard, +a pointer to any object type may be converted to a pointer to +.i void +and back. +posix further requires that any pointer, +including pointers to functions, +may be converted to a pointer to +.i void +and back. +.pp +conversions from and to any other pointer type are done implicitly, +not requiring casts at all. +note that this feature prevents any kind of type checking: +the programmer should be careful not to convert a +.i void * +value to a type incompatible to that of the underlying data, +because that would result in undefined behavior. +.pp +this type is useful in function parameters and return value +to allow passing values of any type. +the function will typically use some mechanism to know +the real type of the data being passed via a pointer to +.ir void . +.pp +a value of this type can't be dereferenced, +as it would give a value of type +.ir void , +which is not possible. +likewise, pointer arithmetic is not possible with this type. +however, in gnu c, pointer arithmetic is allowed +as an extension to the standard; +this is done by treating the size of a +.i void +or of a function as 1. +a consequence of this is that +.i sizeof +is also allowed on +.i void +and on function types, and returns 1. +.pp +the conversion specifier for +.i void * +for the +.br printf (3) +and the +.br scanf (3) +families of functions is +.br p . +.pp +.ir versions : +the posix requirement about compatibility between +.i void * +and function pointers was added in +posix.1-2008 technical corrigendum 1 (2013). +.pp +.ir "conforming to" : +c99 and later; posix.1-2001 and later. +.pp +.ir "see also" : +.br malloc (3), +.br memcmp (3), +.br memcpy (3), +.br memset (3) +.pp +see also the +.i intptr_t +and +.i uintptr_t +types in this page. +.re +.\"--------------------------------------------------------------------/ +.sh notes +the structures described in this manual page shall contain, +at least, the members shown in their definition, in no particular order. +.pp +most of the integer types described in this page don't have +a corresponding length modifier for the +.br printf (3) +and the +.br scanf (3) +families of functions. +to print a value of an integer type that doesn't have a length modifier, +it should be converted to +.i intmax_t +or +.i uintmax_t +by an explicit cast. +to scan into a variable of an integer type +that doesn't have a length modifier, +an intermediate temporary variable of type +.i intmax_t +or +.i uintmax_t +should be used. +when copying from the temporary variable to the destination variable, +the value could overflow. +if the type has upper and lower limits, +the user should check that the value is within those limits, +before actually copying the value. +the example below shows how these conversions should be done. +.ss conventions used in this page +in "conforming to" we only concern ourselves with +c99 and later and posix.1-2001 and later. +some types may be specified in earlier versions of one of these standards, +but in the interests of simplicity we omit details from earlier standards. +.pp +in "include", we first note the "primary" header(s) that +define the type according to either the c or posix.1 standards. +under "alternatively", we note additional headers that +the standards specify shall define the type. +.sh examples +the program shown below scans from a string and prints a value stored in +a variable of an integer type that doesn't have a length modifier. +the appropriate conversions from and to +.ir intmax_t , +and the appropriate range checks, +are used as explained in the notes section above. +.pp +.ex +#include +#include +#include +#include + +int +main (void) +{ + static const char *const str = "500000 us in half a second"; + suseconds_t us; + intmax_t tmp; + + /* scan the number from the string into the temporary variable. */ + + sscanf(str, "%jd", &tmp); + + /* check that the value is within the valid range of suseconds_t. */ + + if (tmp < \-1 || tmp > 1000000) { + fprintf(stderr, "scanned value outside valid range!\en"); + exit(exit_failure); + } + + /* copy the value to the suseconds_t variable \(aqus\(aq. */ + + us = tmp; + + /* even though suseconds_t can hold the value \-1, this isn\(aqt + a sensible number of microseconds. */ + + if (us < 0) { + fprintf(stderr, "scanned value shouldn\(aqt be negative!\en"); + exit(exit_failure); + } + + /* print the value. */ + + printf("there are %jd microseconds in half a second.\en", + (intmax_t) us); + + exit(exit_success); +} +.ee +.sh see also +.br feature_test_macros (7), +.br standards (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/getnetent_r.3 + +.\" copyright (c) 2015, 2016 ibm corporation. +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of +.\" this manual under the conditions for verbatim copying, provided that +.\" the entire resulting derived work is distributed under the terms of +.\" a permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume. +.\" no responsibility for errors or omissions, or for damages resulting. +.\" from the use of the information contained herein. the author(s) may. +.\" not have taken the same level of care in the production of this. +.\" manual, which is licensed free of charge, as they might when working. +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th __ppc_set_ppr_med 3 2021-03-22 "gnu c library" "linux\ +programmer's manual" +.sh name +__ppc_set_ppr_med, __ppc_set_ppr_very_low, __ppc_set_ppr_low, __ppc_set_ppr_med_low, __ppc_set_ppr_med_high \- +set the program priority register +.sh synopsis +.nf +.b #include +.pp +.b void __ppc_set_ppr_med(void); +.b void __ppc_set_ppr_very_low(void); +.b void __ppc_set_ppr_low(void); +.b void __ppc_set_ppr_med_low(void); +.b void __ppc_set_ppr_med_high(void); +.fi +.sh description +these functions provide access to the +.i program priority register +(ppr) on the power architecture. +.pp +the ppr is a 64-bit register that controls the program's priority. +by adjusting the ppr value the programmer may improve system +throughput by causing system resources to be used more +efficiently, especially in contention situations. +the available unprivileged states are covered by the following functions: +.ip * 3 +.br __ppc_set_ppr_med () +sets the program priority register value to +.ir medium +(default). +.ip * +.br __ppc_set_ppr_very_low () +sets the program priority register value to +.ir "very low" . +.ip * +.br __ppc_set_ppr_low () +sets the program priority register value to +.ir low . +.ip * +.br __ppc_set_ppr_med_low () +sets the program priority register value to +.ir "medium low" . +.pp +the privileged state +.ir "medium high" +may also be set during certain time intervals by problem-state (unprivileged) +programs, with the following function: +.ip * 3 +.br __ppc_set_ppr_med_high () +sets the program priority to +.ir "medium high" . +.pp +if the program priority is medium high when the time interval expires or if an +attempt is made to set the priority to medium high when it is not allowed, the +priority is set to medium. +.sh versions +the functions +.br __ppc_set_ppr_med (), +.br __ppc_set_ppr_low (), +and +.br __ppc_set_ppr_med_low () +are provided by glibc since version 2.18. +the functions +.br __ppc_set_ppr_very_low () +and +.br __ppc_set_ppr_med_high () +first appeared in glibc in version 2.23. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br __ppc_set_ppr_med (), +.br __ppc_set_ppr_very_low (), +.br __ppc_set_ppr_low (), +.br __ppc_set_ppr_med_low (), +.br __ppc_set_ppr_med_high () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +these functions are nonstandard gnu extensions. +.sh notes +the functions +.br __ppc_set_ppr_very_low () +and +.br __ppc_set_ppr_med_high () +will be defined by +.i +if +.b _arch_pwr8 +is defined. +availability of these functions can be tested using +.br "#ifdef _arch_pwr8" . +.sh see also +.br __ppc_yield (3) +.pp +.ir "power isa, book\ ii - section\ 3.1 (program priority registers)" +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/setreuid.2 + +.so man3/isalpha.3 + +.so man3/j0.3 + +.so man7/system_data_types.7 + +.so man2/getuid.2 + +.so man3/tailq.3 + +.so man5/proc.5 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" and copyright 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified 1993-07-24 by rik faith (faith@cs.unc.edu) +.\" modified 2002-07-27 by walter harms +.\" (walter.harms@informatik.uni-oldenburg.de) +.th sqrt 3 2021-03-22 "" "linux programmer's manual" +.sh name +sqrt, sqrtf, sqrtl \- square root function +.sh synopsis +.nf +.b #include +.pp +.bi "double sqrt(double " x ); +.bi "float sqrtf(float " x ); +.bi "long double sqrtl(long double " x ); +.fi +.pp +link with \fi\-lm\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br sqrtf (), +.br sqrtl (): +.nf + _isoc99_source || _posix_c_source >= 200112l + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.sh description +these functions return the nonnegative square root of +.ir x . +.sh return value +on success, these functions return the square root of +.ir x . +.pp +if +.i x +is a nan, a nan is returned. +.pp +if +.i x +is +0 (\-0), +0 (\-0) is returned. +.pp +if +.i x +is positive infinity, positive infinity is returned. +.pp +if +.i x +is less than \-0, +a domain error occurs, +and a nan is returned. +.sh errors +see +.br math_error (7) +for information on how to determine whether an error has occurred +when calling these functions. +.pp +the following errors can occur: +.tp +domain error: \fix\fp less than \-0 +.i errno +is set to +.br edom . +an invalid floating-point exception +.rb ( fe_invalid ) +is raised. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br sqrt (), +.br sqrtf (), +.br sqrtl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.pp +the variant returning +.i double +also conforms to +svr4, 4.3bsd, c89. +.sh see also +.br cbrt (3), +.br csqrt (3), +.br hypot (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/gettimeofday.2 + +.so man3/stailq.3 + +.so man2/setxattr.2 + +.\" copyright (c) 1995 andries brouwer (aeb@cwi.nl) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" written 11 june 1995 by andries brouwer +.\" modified 22 july 1995 by michael chastain : +.\" in 1.3.x, returns only one entry each time; return value is different. +.\" modified 2004-12-01, mtk, fixed headers listed in synopsis +.\" +.th readdir 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +readdir \- read directory entry +.sh synopsis +.nf +.br "#include " " /* definition of " sys_* " constants */" +.b #include +.pp +.bi "int syscall(sys_readdir, unsigned int " fd , +.bi " struct old_linux_dirent *" dirp ", unsigned int " count ); +.fi +.pp +.ir note : +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 +.br readdir (3) +for the posix conforming c library interface. +this page documents the bare kernel system call interface, +which is superseded by +.br getdents (2). +.pp +.br readdir () +reads one +.i old_linux_dirent +structure from the directory +referred to by the file descriptor +.i fd +into the buffer pointed to by +.ir dirp . +the argument +.i count +is ignored; at most one +.i old_linux_dirent +structure is read. +.pp +the +.i old_linux_dirent +structure is declared (privately in linux kernel file +.br fs/readdir.c ) +as follows: +.pp +.in +4n +.ex +struct old_linux_dirent { + unsigned long d_ino; /* inode number */ + unsigned long d_offset; /* offset to this \fiold_linux_dirent\fp */ + unsigned short d_namlen; /* length of this \fid_name\fp */ + char d_name[1]; /* filename (null\-terminated) */ +} +.ee +.in +.pp +.i d_ino +is an inode number. +.i d_offset +is the distance from the start of the directory to this +.ir old_linux_dirent . +.i d_reclen +is the size of +.ir d_name , +not counting the terminating null byte (\(aq\e0\(aq). +.i d_name +is a null-terminated filename. +.sh return value +on success, 1 is returned. +on end of directory, 0 is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b ebadf +invalid file descriptor +.ir fd . +.tp +.b efault +argument points outside the calling process's address space. +.tp +.b einval +result buffer is too small. +.tp +.b enoent +no such directory. +.tp +.b enotdir +file descriptor does not refer to a directory. +.sh conforming to +this system call is linux-specific. +.sh notes +you will need to define the +.i old_linux_dirent +structure yourself. +however, probably you should use +.br readdir (3) +instead. +.pp +this system call does not exist on x86-64. +.sh see also +.br getdents (2), +.br readdir (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/xdr.3 + +.so man3/getpwent_r.3 + +.\" copyright (c) 2014 red hat, inc. all rights reserved. +.\" written by david howells (dhowells@redhat.com) +.\" +.\" %%%license_start(gplv2+_sw_onepara) +.\" this program is free software; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license +.\" as published by the free software foundation; either version +.\" 2 of the license, or (at your option) any later version. +.\" %%%license_end +.\" +.th persistent-keyring 7 2020-08-13 linux "linux programmer's manual" +.sh name +persistent-keyring \- per-user persistent keyring +.sh description +the persistent keyring is a keyring used to anchor keys on behalf of a user. +each uid the kernel deals with has its own persistent keyring that +is shared between all threads owned by that uid. +the persistent keyring has a name (description) of the form +.i _persistent. +where +.i +is the user id of the corresponding user. +.pp +the persistent keyring may not be accessed directly, +even by processes with the appropriate uid. +.\" fixme the meaning of the preceding sentence isn't clear. what is meant? +instead, it must first be linked to one of a process's keyrings, +before that keyring can access the persistent keyring +by virtue of its possessor permits. +this linking is done with the +.br keyctl_get_persistent (3) +function. +.pp +if a persistent keyring does not exist when it is accessed by the +.br keyctl_get_persistent (3) +operation, it will be automatically created. +.pp +each time the +.br keyctl_get_persistent (3) +operation is performed, +the persistent key's expiration timer is reset to the value in: +.pp + /proc/sys/kernel/keys/persistent_keyring_expiry +.pp +should the timeout be reached, +the persistent keyring will be removed and +everything it pins can then be garbage collected. +the key will then be re-created on a subsequent call to +.br keyctl_get_persistent (3). +.pp +the persistent keyring is not directly searched by +.br request_key (2); +it is searched only if it is linked into one of the keyrings +that is searched by +.br request_key (2). +.pp +the persistent keyring is independent of +.br clone (2), +.br fork (2), +.br vfork (2), +.br execve (2), +and +.br _exit (2). +it persists until its expiration timer triggers, +at which point it is garbage collected. +this allows the persistent keyring to carry keys beyond the life of +the kernel's record of the corresponding uid +(the destruction of which results in the destruction of the +.br user\-keyring (7) +and the +.br user\-session\-keyring (7)). +the persistent keyring can thus be used to +hold authentication tokens for processes that run without user interaction, +such as programs started by +.br cron (8). +.pp +the persistent keyring is used to store uid-specific objects that +themselves have limited lifetimes (e.g., kerberos tokens). +if those tokens cease to be used +(i.e., the persistent keyring is not accessed), +then the timeout of the persistent keyring ensures that +the corresponding objects are automatically discarded. +.\" +.ss special operations +the +.i keyutils +library provides the +.br keyctl_get_persistent (3) +function for manipulating persistent keyrings. +(this function is an interface to the +.br keyctl (2) +.b keyctl_get_persistent +operation.) +this operation allows the calling thread to get the persistent keyring +corresponding to its own uid or, if the thread has the +.br cap_setuid +capability, the persistent keyring corresponding to some other uid +in the same user namespace. +.sh notes +each user namespace owns a keyring called +.ir .persistent_register +that contains links to all of the persistent keys in that namespace. +(the +.ir .persistent_register +keyring can be seen when reading the contents of the +.ir /proc/keys +file for the uid 0 in the namespace.) +the +.br keyctl_get_persistent (3) +operation looks for a key with a name of the form +.ir _persistent. +in that keyring, +creates the key if it does not exist, and links it into the keyring. +.sh see also +.ad l +.nh +.br keyctl (1), +.br keyctl (3), +.br keyctl_get_persistent (3), +.br keyrings (7), +.br process\-keyring (7), +.br session\-keyring (7), +.br thread\-keyring (7), +.br user\-keyring (7), +.br user\-session\-keyring (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/setaliasent.3 + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" +.th strnlen 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +strnlen \- determine the length of a fixed-size string +.sh synopsis +.nf +.b #include +.pp +.bi "size_t strnlen(const char *" s ", size_t " maxlen ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br strnlen (): +.nf + since glibc 2.10: + _posix_c_source >= 200809l + before glibc 2.10: + _gnu_source +.fi +.sh description +the +.br strnlen () +function returns the number of bytes in the string +pointed to by +.ir s , +excluding the terminating null byte (\(aq\e0\(aq), +but at most +.ir maxlen . +in doing this, +.br strnlen () +looks only at the first +.i maxlen +characters in the string pointed to by +.i s +and never beyond +.ir s[maxlen\-1] . +.sh return value +the +.br strnlen () +function returns +.ir strlen(s) , +if that is less than +.ir maxlen , +or +.i maxlen +if there is no null terminating (\(aq\e0\(aq) among the first +.i maxlen +characters pointed to by +.ir s . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br strnlen () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2008. +.sh see also +.br strlen (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2001 andries brouwer (aeb@cwi.nl) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" [should really be seteuid.3] +.\" modified, 27 may 2004, michael kerrisk +.\" added notes on capability requirements +.\" +.th seteuid 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +seteuid, setegid \- set effective user or group id +.sh synopsis +.nf +.b #include +.pp +.bi "int seteuid(uid_t " euid ); +.bi "int setegid(gid_t " egid ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br seteuid (), +.br setegid (): +.nf + _posix_c_source >= 200112l + || /* glibc <= 2.19: */ _bsd_source +.fi +.sh description +.br seteuid () +sets the effective user id of the calling process. +unprivileged processes may only set the effective user id to the +real user id, the effective user id or the saved set-user-id. +.pp +precisely the same holds for +.br setegid () +with "group" instead of "user". +.\" when +.\" .i euid +.\" equals \-1, nothing is changed. +.\" (this is an artifact of the implementation in glibc of seteuid() +.\" using setresuid(2).) +.sh return value +on success, zero is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.pp +.ir note : +there are cases where +.br seteuid () +can fail even when the caller is uid 0; +it is a grave security error to omit checking for a failure return from +.br seteuid (). +.sh errors +.tp +.b einval +the target user or group id is not valid in this user namespace. +.tp +.b eperm +in the case of +.br seteuid (): +the calling process is not privileged (does not have the +.br cap_setuid +capability in its user namespace) and +.i euid +does not match the current real user id, current effective user id, +or current saved set-user-id. +.ip +in the case of +.br setegid (): +the calling process is not privileged (does not have the +.br cap_setgid +capability in its user namespace) and +.i egid +does not match the current real group id, current effective group id, +or current saved set-group-id. +.sh conforming to +posix.1-2001, posix.1-2008, 4.3bsd. +.sh notes +setting the effective user (group) id to the +saved set-user-id (saved set-group-id) is +possible since linux 1.1.37 (1.1.38). +on an arbitrary system one should check +.br _posix_saved_ids . +.pp +under glibc 2.0, +.bi seteuid( euid ) +is equivalent to +.bi setreuid(\-1, " euid" ) +and hence may change the saved set-user-id. +under glibc 2.1 and later, it is equivalent to +.bi setresuid(\-1, " euid" ", \-1)" +and hence does not change the saved set-user-id. +analogous remarks hold for +.br setegid (), +with the difference that the change in implementation from +.bi setregid(\-1, " egid" ) +to +.bi setresgid(\-1, " egid" ", \-1)" +occurred in glibc 2.2 or 2.3 (depending on the hardware architecture). +.pp +according to posix.1, +.br seteuid () +.rb ( setegid ()) +need not permit +.i euid +.ri ( egid ) +to be the same value as the current effective user (group) id, +and some implementations do not permit this. +.ss c library/kernel differences +on linux, +.br seteuid () +and +.br setegid () +are implemented as library functions that call, respectively, +.br setreuid (2) +and +.br setregid (2). +.sh see also +.br geteuid (2), +.br setresuid (2), +.br setreuid (2), +.br setuid (2), +.br capabilities (7), +.br credentials (7), +.br user_namespaces (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" this man page is copyright (c) 1999 andi kleen . +.\" +.\" %%%license_start(verbatim_one_para) +.\" permission is granted to distribute possibly modified copies +.\" of this page provided the header is included verbatim, +.\" and in case of nontrivial modification author and date +.\" of the modification is added to the header. +.\" %%%license_end +.\" +.\" $id: ip.7,v 1.19 2000/12/20 18:10:31 ak exp $ +.\" +.\" fixme the following socket options are yet to be documented +.\" +.\" ip_xfrm_policy (2.5.48) +.\" needs cap_net_admin +.\" +.\" ip_ipsec_policy (2.5.47) +.\" needs cap_net_admin +.\" +.\" ip_minttl (2.6.34) +.\" commit d218d11133d888f9745802146a50255a4781d37a +.\" author: stephen hemminger +.\" +.\" mcast_join_group (2.4.22 / 2.6) +.\" +.\" mcast_block_source (2.4.22 / 2.6) +.\" +.\" mcast_unblock_source (2.4.22 / 2.6) +.\" +.\" mcast_leave_group (2.4.22 / 2.6) +.\" +.\" mcast_join_source_group (2.4.22 / 2.6) +.\" +.\" mcast_leave_source_group (2.4.22 / 2.6) +.\" +.\" mcast_msfilter (2.4.22 / 2.6) +.\" +.\" ip_unicast_if (3.4) +.\" commit 76e21053b5bf33a07c76f99d27a74238310e3c71 +.\" author: erich e. hoover +.\" +.th ip 7 2021-03-22 "linux" "linux programmer's manual" +.sh name +ip \- linux ipv4 protocol implementation +.sh synopsis +.nf +.b #include +.\" .b #include -- does not exist anymore +.\" .b #include -- never include +.b #include +.b #include \fr/* superset of previous */ +.pp +.ib tcp_socket " = socket(af_inet, sock_stream, 0);" +.ib udp_socket " = socket(af_inet, sock_dgram, 0);" +.ib raw_socket " = socket(af_inet, sock_raw, " protocol ");" +.fi +.sh description +linux implements the internet protocol, version 4, +described in rfc\ 791 and rfc\ 1122. +.b ip +contains a level 2 multicasting implementation conforming to rfc\ 1112. +it also contains an ip router including a packet filter. +.pp +the programming interface is bsd-sockets compatible. +for more information on sockets, see +.br socket (7). +.pp +an ip socket is created using +.br socket (2): +.pp + socket(af_inet, socket_type, protocol); +.pp +valid socket types include +.b sock_stream +to open a stream socket, +.b sock_dgram +to open a datagram socket, and +.b sock_raw +to open a +.br raw (7) +socket to access the ip protocol directly. +.pp +.i protocol +is the ip protocol in the ip header to be received or sent. +valid values for +.i protocol +include: +.ip \(bu 2 +0 and +.b ipproto_tcp +for +.br tcp (7) +stream sockets; +.ip \(bu +0 and +.b ipproto_udp +for +.br udp (7) +datagram sockets; +.ip \(bu +.b ipproto_sctp +for +.br sctp (7) +stream sockets; and +.ip \(bu +.b ipproto_udplite +for +.br udplite (7) +datagram sockets. +.pp +for +.b sock_raw +you may specify a valid iana ip protocol defined in +rfc\ 1700 assigned numbers. +.pp +when a process wants to receive new incoming packets or connections, it +should bind a socket to a local interface address using +.br bind (2). +in this case, only one ip socket may be bound to any given local +(address, port) pair. +when +.b inaddr_any +is specified in the bind call, the socket will be bound to +.i all +local interfaces. +when +.br listen (2) +is called on an unbound socket, the socket is automatically bound +to a random free port with the local address set to +.br inaddr_any . +when +.br connect (2) +is called on an unbound socket, the socket is automatically bound +to a random free port or to a usable shared port with the local address +set to +.br inaddr_any . +.pp +a tcp local socket address that has been bound is unavailable for +some time after closing, unless the +.b so_reuseaddr +flag has been set. +care should be taken when using this flag as it makes tcp less reliable. +.ss address format +an ip socket address is defined as a combination of an ip interface +address and a 16-bit port number. +the basic ip protocol does not supply port numbers, they +are implemented by higher level protocols like +.br udp (7) +and +.br tcp (7). +on raw sockets +.i sin_port +is set to the ip protocol. +.pp +.in +4n +.ex +struct sockaddr_in { + sa_family_t sin_family; /* address family: af_inet */ + in_port_t sin_port; /* port in network byte order */ + struct in_addr sin_addr; /* internet address */ +}; + +/* internet address */ +struct in_addr { + uint32_t s_addr; /* address in network byte order */ +}; +.ee +.in +.pp +.i sin_family +is always set to +.br af_inet . +this is required; in linux 2.2 most networking functions return +.b einval +when this setting is missing. +.i sin_port +contains the port in network byte order. +the port numbers below 1024 are called +.ir "privileged ports" +(or sometimes: +.ir "reserved ports" ). +only a privileged process +(on linux: a process that has the +.b cap_net_bind_service +capability in the user namespace governing its network namespace) may +.br bind (2) +to these sockets. +note that the raw ipv4 protocol as such has no concept of a +port, they are implemented only by higher protocols like +.br tcp (7) +and +.br udp (7). +.pp +.i sin_addr +is the ip host address. +the +.i s_addr +member of +.i struct in_addr +contains the host interface address in network byte order. +.i in_addr +should be assigned one of the +.br inaddr_* +values +(e.g., +.br inaddr_loopback ) +using +.br htonl (3) +or set using the +.br inet_aton (3), +.br inet_addr (3), +.br inet_makeaddr (3) +library functions or directly with the name resolver (see +.br gethostbyname (3)). +.pp +ipv4 addresses are divided into unicast, broadcast, +and multicast addresses. +unicast addresses specify a single interface of a host, +broadcast addresses specify all hosts on a network, and multicast +addresses address all hosts in a multicast group. +datagrams to broadcast addresses can be sent or received only when the +.b so_broadcast +socket flag is set. +in the current implementation, connection-oriented sockets are allowed +to use only unicast addresses. +.\" leave a loophole for xtp @) +.pp +note that the address and the port are always stored in +network byte order. +in particular, this means that you need to call +.br htons (3) +on the number that is assigned to a port. +all address/port manipulation +functions in the standard library work in network byte order. +.pp +there are several special addresses: +.b inaddr_loopback +(127.0.0.1) +always refers to the local host via the loopback device; +.b inaddr_any +(0.0.0.0) +means any address for binding; +.b inaddr_broadcast +(255.255.255.255) +means any host and has the same effect on bind as +.b inaddr_any +for historical reasons. +.ss socket options +ip supports some protocol-specific socket options that can be set with +.br setsockopt (2) +and read with +.br getsockopt (2). +the socket option level for ip is +.br ipproto_ip . +.\" or sol_ip on linux +a boolean integer flag is zero when it is false, otherwise true. +.pp +when an invalid socket option is specified, +.br getsockopt (2) +and +.br setsockopt (2) +fail with the error +.br enoprotoopt . +.tp +.br ip_add_membership " (since linux 1.2)" +join a multicast group. +argument is an +.i ip_mreqn +structure. +.pp +.in +4n +.ex +struct ip_mreqn { + struct in_addr imr_multiaddr; /* ip multicast group + address */ + struct in_addr imr_address; /* ip address of local + interface */ + int imr_ifindex; /* interface index */ +}; +.ee +.in +.pp +.i imr_multiaddr +contains the address of the multicast group the application +wants to join or leave. +it must be a valid multicast address +.\" (i.e., within the 224.0.0.0-239.255.255.255 range) +(or +.br setsockopt (2) +fails with the error +.br einval ). +.i imr_address +is the address of the local interface with which the system +should join the multicast group; if it is equal to +.br inaddr_any , +an appropriate interface is chosen by the system. +.i imr_ifindex +is the interface index of the interface that should join/leave the +.i imr_multiaddr +group, or 0 to indicate any interface. +.ip +the +.i ip_mreqn +structure is available only since linux 2.2. +for compatibility, the old +.i ip_mreq +structure (present since linux 1.2) is still supported; +it differs from +.i ip_mreqn +only by not including the +.i imr_ifindex +field. +(the kernel determines which structure is being passed based +on the size passed in +.ir optlen .) +.ip +.b ip_add_membership +is valid only for +.br setsockopt (2). +.\" +.tp +.br ip_add_source_membership " (since linux 2.4.22 / 2.5.68)" +join a multicast group and allow receiving data only +from a specified source. +argument is an +.i ip_mreq_source +structure. +.pp +.in +4n +.ex +struct ip_mreq_source { + struct in_addr imr_multiaddr; /* ip multicast group + address */ + struct in_addr imr_interface; /* ip address of local + interface */ + struct in_addr imr_sourceaddr; /* ip address of + multicast source */ +}; +.ee +.in +.pp +the +.i ip_mreq_source +structure is similar to +.i ip_mreqn +described under +.br ip_add_membership . +the +.i imr_multiaddr +field contains the address of the multicast group the application +wants to join or leave. +the +.i imr_interface +field is the address of the local interface with which +the system should join the multicast group. +finally, the +.i imr_sourceaddr +field contains the address of the source the +application wants to receive data from. +.ip +this option can be used multiple times to allow +receiving data from more than one source. +.tp +.br ip_bind_address_no_port " (since linux 4.2)" +.\" commit 90c337da1524863838658078ec34241f45d8394d +inform the kernel to not reserve an ephemeral port when using +.br bind (2) +with a port number of 0. +the port will later be automatically chosen at +.br connect (2) +time, +in a way that allows sharing a source port as long as the 4-tuple is unique. +.tp +.br ip_block_source " (since linux 2.4.22 / 2.5.68)" +stop receiving multicast data from a specific source in a given group. +this is valid only after the application has subscribed +to the multicast group using either +.br ip_add_membership +or +.br ip_add_source_membership . +.ip +argument is an +.i ip_mreq_source +structure as described under +.br ip_add_source_membership . +.tp +.br ip_drop_membership " (since linux 1.2)" +leave a multicast group. +argument is an +.i ip_mreqn +or +.i ip_mreq +structure similar to +.br ip_add_membership . +.tp +.br ip_drop_source_membership " (since linux 2.4.22 / 2.5.68)" +leave a source-specific group\(emthat is, stop receiving data from +a given multicast group that come from a given source. +if the application has subscribed to multiple sources within +the same group, data from the remaining sources will still be delivered. +to stop receiving data from all sources at once, use +.br ip_drop_membership . +.ip +argument is an +.i ip_mreq_source +structure as described under +.br ip_add_source_membership . +.tp +.br ip_freebind " (since linux 2.4)" +.\" precisely: 2.4.0-test10 +if enabled, this boolean option allows binding to an ip address +that is nonlocal or does not (yet) exist. +this permits listening on a socket, +without requiring the underlying network interface or the +specified dynamic ip address to be up at the time that +the application is trying to bind to it. +this option is the per-socket equivalent of the +.ir ip_nonlocal_bind +.i /proc +interface described below. +.tp +.br ip_hdrincl " (since linux 2.0)" +if enabled, +the user supplies an ip header in front of the user data. +valid only for +.b sock_raw +sockets; see +.br raw (7) +for more information. +when this flag is enabled, the values set by +.br ip_options , +.br ip_ttl , +and +.b ip_tos +are ignored. +.tp +.br ip_msfilter " (since linux 2.4.22 / 2.5.68)" +this option provides access to the advanced full-state filtering api. +argument is an +.i ip_msfilter +structure. +.pp +.in +4n +.ex +struct ip_msfilter { + struct in_addr imsf_multiaddr; /* ip multicast group + address */ + struct in_addr imsf_interface; /* ip address of local + interface */ + uint32_t imsf_fmode; /* filter\-mode */ + + uint32_t imsf_numsrc; /* number of sources in + the following array */ + struct in_addr imsf_slist[1]; /* array of source + addresses */ +}; +.ee +.in +.pp +there are two macros, +.br mcast_include +and +.br mcast_exclude , +which can be used to specify the filtering mode. +additionally, the +.br ip_msfilter_size (n) +macro exists to determine how much memory is needed to store +.i ip_msfilter +structure with +.i n +sources in the source list. +.ip +for the full description of multicast source filtering +refer to rfc 3376. +.tp +.br ip_mtu " (since linux 2.2)" +.\" precisely: 2.1.124 +retrieve the current known path mtu of the current socket. +returns an integer. +.ip +.b ip_mtu +is valid only for +.br getsockopt (2) +and can be employed only when the socket has been connected. +.tp +.br ip_mtu_discover " (since linux 2.2)" +.\" precisely: 2.1.124 +set or receive the path mtu discovery setting for a socket. +when enabled, linux will perform path mtu discovery +as defined in rfc\ 1191 on +.b sock_stream +sockets. +for +.rb non- sock_stream +sockets, +.b ip_pmtudisc_do +forces the don't-fragment flag to be set on all outgoing packets. +it is the user's responsibility to packetize the data +in mtu-sized chunks and to do the retransmits if necessary. +the kernel will reject (with +.br emsgsize ) +datagrams that are bigger than the known path mtu. +.b ip_pmtudisc_want +will fragment a datagram if needed according to the path mtu, +or will set the don't-fragment flag otherwise. +.ip +the system-wide default can be toggled between +.b ip_pmtudisc_want +and +.b ip_pmtudisc_dont +by writing (respectively, zero and nonzero values) to the +.i /proc/sys/net/ipv4/ip_no_pmtu_disc +file. +.ts +tab(:); +c l +l l. +path mtu discovery value:meaning +ip_pmtudisc_want:use per-route settings. +ip_pmtudisc_dont:never do path mtu discovery. +ip_pmtudisc_do:always do path mtu discovery. +ip_pmtudisc_probe:set df but ignore path mtu. +.te +.sp 1 +when pmtu discovery is enabled, the kernel automatically keeps track of +the path mtu per destination host. +when it is connected to a specific peer with +.br connect (2), +the currently known path mtu can be retrieved conveniently using the +.b ip_mtu +socket option (e.g., after an +.b emsgsize +error occurred). +the path mtu may change over time. +for connectionless sockets with many destinations, +the new mtu for a given destination can also be accessed using the +error queue (see +.br ip_recverr ). +a new error will be queued for every incoming mtu update. +.ip +while mtu discovery is in progress, initial packets from datagram sockets +may be dropped. +applications using udp should be aware of this and not +take it into account for their packet retransmit strategy. +.ip +to bootstrap the path mtu discovery process on unconnected sockets, it +is possible to start with a big datagram size +(headers up to 64 kilobytes long) and let it shrink by updates of the path mtu. +.ip +to get an initial estimate of the +path mtu, connect a datagram socket to the destination address using +.br connect (2) +and retrieve the mtu by calling +.br getsockopt (2) +with the +.b ip_mtu +option. +.ip +it is possible to implement rfc 4821 mtu probing with +.b sock_dgram +or +.b sock_raw +sockets by setting a value of +.br ip_pmtudisc_probe +(available since linux 2.6.22). +this is also particularly useful for diagnostic tools such as +.br tracepath (8) +that wish to deliberately send probe packets larger than +the observed path mtu. +.tp +.br ip_multicast_all " (since linux 2.6.31)" +this option can be used to modify the delivery policy of multicast messages +to sockets bound to the wildcard +.b inaddr_any +address. +the argument is a boolean integer (defaults to 1). +if set to 1, +the socket will receive messages from all the groups that have been joined +globally on the whole system. +otherwise, it will deliver messages only from +the groups that have been explicitly joined (for example via the +.b ip_add_membership +option) on this particular socket. +.tp +.br ip_multicast_if " (since linux 1.2)" +set the local device for a multicast socket. +the argument for +.br setsockopt (2) +is an +.i ip_mreqn +or +.\" net: ip_multicast_if setsockopt now recognizes struct mreq +.\" commit: 3a084ddb4bf299a6e898a9a07c89f3917f0713f7 +(since linux 3.5) +.i ip_mreq +structure similar to +.br ip_add_membership , +or an +.i in_addr +structure. +(the kernel determines which structure is being passed based +on the size passed in +.ir optlen .) +for +.br getsockopt (2), +the argument is an +.i in_addr +structure. +.tp +.br ip_multicast_loop " (since linux 1.2)" +set or read a boolean integer argument that determines whether +sent multicast packets should be looped back to the local sockets. +.tp +.br ip_multicast_ttl " (since linux 1.2)" +set or read the time-to-live value of outgoing multicast packets for this +socket. +it is very important for multicast packets to set the smallest ttl possible. +the default is 1 which means that multicast packets don't leave the local +network unless the user program explicitly requests it. +argument is an integer. +.tp +.br ip_nodefrag " (since linux 2.6.36)" +if enabled (argument is nonzero), +the reassembly of outgoing packets is disabled in the netfilter layer. +the argument is an integer. +.ip +this option is valid only for +.b sock_raw +sockets. +.tp +.br ip_options " (since linux 2.0)" +.\" precisely: 1.3.30 +set or get the ip options to be sent with every packet from this socket. +the arguments are a pointer to a memory buffer containing the options +and the option length. +the +.br setsockopt (2) +call sets the ip options associated with a socket. +the maximum option size for ipv4 is 40 bytes. +see rfc\ 791 for the allowed options. +when the initial connection request packet for a +.b sock_stream +socket contains ip options, the ip options will be set automatically +to the options from the initial packet with routing headers reversed. +incoming packets are not allowed to change options after the connection +is established. +the processing of all incoming source routing options +is disabled by default and can be enabled by using the +.i accept_source_route +.i /proc +interface. +other options like timestamps are still handled. +for datagram sockets, ip options can be set only by the local user. +calling +.br getsockopt (2) +with +.b ip_options +puts the current ip options used for sending into the supplied buffer. +.tp +.br ip_passsec " (since linux 2.6.17)" +.\" commit 2c7946a7bf45ae86736ab3b43d0085e43947945c +if labeled ipsec or netlabel is configured on the sending and receiving +hosts, this option enables receiving of the security context of the peer +socket in an ancillary message of type +.b scm_security +retrieved using +.br recvmsg (2). +this option is supported only for udp sockets; for tcp or sctp sockets, +see the description of the +.b so_peersec +option below. +.ip +the value given as an argument to +.br setsockopt (2) +and returned as the result of +.br getsockopt (2) +is an integer boolean flag. +.ip +the security context returned in the +.b scm_security +ancillary message +is of the same format as the one described under the +.b so_peersec +option below. +.ip +note: the reuse of the +.b scm_security +message type for the +.b ip_passsec +socket option was likely a mistake, since other ip control messages use +their own numbering scheme in the ip namespace and often use the +socket option value as the message type. +there is no conflict currently since the ip option with the same value as +.b scm_security +is +.b ip_hdrincl +and this is never used for a control message type. +.tp +.br ip_pktinfo " (since linux 2.2)" +.\" precisely: 2.1.68 +pass an +.b ip_pktinfo +ancillary message that contains a +.i pktinfo +structure that supplies some information about the incoming packet. +this works only for datagram oriented sockets. +the argument is a flag that tells the socket whether the +.b ip_pktinfo +message should be passed or not. +the message itself can be sent/retrieved +only as a control message with a packet using +.br recvmsg (2) +or +.br sendmsg (2). +.ip +.in +4n +.ex +struct in_pktinfo { + unsigned int ipi_ifindex; /* interface index */ + struct in_addr ipi_spec_dst; /* local address */ + struct in_addr ipi_addr; /* header destination + address */ +}; +.ee +.in +.ip +.i ipi_ifindex +is the unique index of the interface the packet was received on. +.i ipi_spec_dst +is the local address of the packet and +.i ipi_addr +is the destination address in the packet header. +if +.b ip_pktinfo +is passed to +.br sendmsg (2) +and +.\" this field is grossly misnamed +.i ipi_spec_dst +is not zero, then it is used as the local source address for the routing +table lookup and for setting up ip source route options. +when +.i ipi_ifindex +is not zero, the primary local address of the interface specified by the +index overwrites +.i ipi_spec_dst +for the routing table lookup. +.tp +.br ip_recverr " (since linux 2.2)" +.\" precisely: 2.1.15 +enable extended reliable error message passing. +when enabled on a datagram socket, all +generated errors will be queued in a per-socket error queue. +when the user receives an error from a socket operation, +the errors can be received by calling +.br recvmsg (2) +with the +.b msg_errqueue +flag set. +the +.i sock_extended_err +structure describing the error will be passed in an ancillary message with +the type +.b ip_recverr +and the level +.br ipproto_ip . +.\" or sol_ip on linux +this is useful for reliable error handling on unconnected sockets. +the received data portion of the error queue contains the error packet. +.ip +the +.b ip_recverr +control message contains a +.i sock_extended_err +structure: +.ip +.in +4n +.ex +#define so_ee_origin_none 0 +#define so_ee_origin_local 1 +#define so_ee_origin_icmp 2 +#define so_ee_origin_icmp6 3 + +struct sock_extended_err { + uint32_t ee_errno; /* error number */ + uint8_t ee_origin; /* where the error originated */ + uint8_t ee_type; /* type */ + uint8_t ee_code; /* code */ + uint8_t ee_pad; + uint32_t ee_info; /* additional information */ + uint32_t ee_data; /* other data */ + /* more data may follow */ +}; + +struct sockaddr *so_ee_offender(struct sock_extended_err *); +.ee +.in +.ip +.i ee_errno +contains the +.i errno +number of the queued error. +.i ee_origin +is the origin code of where the error originated. +the other fields are protocol-specific. +the macro +.b so_ee_offender +returns a pointer to the address of the network object +where the error originated from given a pointer to the ancillary message. +if this address is not known, the +.i sa_family +member of the +.i sockaddr +contains +.b af_unspec +and the other fields of the +.i sockaddr +are undefined. +.ip +ip uses the +.i sock_extended_err +structure as follows: +.i ee_origin +is set to +.b so_ee_origin_icmp +for errors received as an icmp packet, or +.b so_ee_origin_local +for locally generated errors. +unknown values should be ignored. +.i ee_type +and +.i ee_code +are set from the type and code fields of the icmp header. +.i ee_info +contains the discovered mtu for +.b emsgsize +errors. +the message also contains the +.i sockaddr_in of the node +caused the error, which can be accessed with the +.b so_ee_offender +macro. +the +.i sin_family +field of the +.b so_ee_offender +address is +.b af_unspec +when the source was unknown. +when the error originated from the network, all ip options +.rb ( ip_options ", " ip_ttl , +etc.) enabled on the socket and contained in the +error packet are passed as control messages. +the payload of the packet causing the error is returned as normal payload. +.\" fixme . is it a good idea to document that? it is a dubious feature. +.\" on +.\" .b sock_stream +.\" sockets, +.\" .b ip_recverr +.\" has slightly different semantics. instead of +.\" saving the errors for the next timeout, it passes all incoming +.\" errors immediately to the user. +.\" this might be useful for very short-lived tcp connections which +.\" need fast error handling. use this option with care: +.\" it makes tcp unreliable +.\" by not allowing it to recover properly from routing +.\" shifts and other normal +.\" conditions and breaks the protocol specification. +note that tcp has no error queue; +.b msg_errqueue +is not permitted on +.b sock_stream +sockets. +.b ip_recverr +is valid for tcp, but all errors are returned by socket function return or +.b so_error +only. +.ip +for raw sockets, +.b ip_recverr +enables passing of all received icmp errors to the +application, otherwise errors are reported only on connected sockets +.ip +it sets or retrieves an integer boolean flag. +.b ip_recverr +defaults to off. +.tp +.br ip_recvopts " (since linux 2.2)" +.\" precisely: 2.1.15 +pass all incoming ip options to the user in a +.b ip_options +control message. +the routing header and other options are already filled in +for the local host. +not supported for +.b sock_stream +sockets. +.tp +.br ip_recvorigdstaddr " (since linux 2.6.29)" +.\" commit e8b2dfe9b4501ed0047459b2756ba26e5a940a69 +this boolean option enables the +.b ip_origdstaddr +ancillary message in +.br recvmsg (2), +in which the kernel returns the original destination address +of the datagram being received. +the ancillary message contains a +.ir "struct sockaddr_in" . +.tp +.br ip_recvtos " (since linux 2.2)" +.\" precisely: 2.1.68 +if enabled, the +.b ip_tos +ancillary message is passed with incoming packets. +it contains a byte which specifies the type of service/precedence +field of the packet header. +expects a boolean integer flag. +.tp +.br ip_recvttl " (since linux 2.2)" +.\" precisely: 2.1.68 +when this flag is set, pass a +.b ip_ttl +control message with the time-to-live +field of the received packet as a 32 bit integer. +not supported for +.b sock_stream +sockets. +.tp +.br ip_retopts " (since linux 2.2)" +.\" precisely: 2.1.15 +identical to +.br ip_recvopts , +but returns raw unprocessed options with timestamp and route record +options not filled in for this hop. +.tp +.br ip_router_alert " (since linux 2.2)" +.\" precisely: 2.1.68 +pass all to-be forwarded packets with the +ip router alert option set to this socket. +valid only for raw sockets. +this is useful, for instance, for user-space rsvp daemons. +the tapped packets are not forwarded by the kernel; it is +the user's responsibility to send them out again. +socket binding is ignored, +such packets are filtered only by protocol. +expects an integer flag. +.tp +.br ip_tos " (since linux 1.0)" +set or receive the type-of-service (tos) field that is sent +with every ip packet originating from this socket. +it is used to prioritize packets on the network. +tos is a byte. +there are some standard tos flags defined: +.b iptos_lowdelay +to minimize delays for interactive traffic, +.b iptos_throughput +to optimize throughput, +.b iptos_reliability +to optimize for reliability, +.b iptos_mincost +should be used for "filler data" where slow transmission doesn't matter. +at most one of these tos values can be specified. +other bits are invalid and shall be cleared. +linux sends +.b iptos_lowdelay +datagrams first by default, +but the exact behavior depends on the configured queueing discipline. +.\" fixme elaborate on this +some high-priority levels may require superuser privileges (the +.b cap_net_admin +capability). +.\" the priority can also be set in a protocol-independent way by the +.\" .rb ( sol_socket ", " so_priority ) +.\" socket option (see +.\" .br socket (7)). +.tp +.br ip_transparent " (since linux 2.6.24)" +.\" commit f5715aea4564f233767ea1d944b2637a5fd7cd2e +.\" this patch introduces the ip_transparent socket option: enabling that +.\" will make the ipv4 routing omit the non-local source address check on +.\" output. setting ip_transparent requires net_admin capability. +.\" http://lwn.net/articles/252545/ +setting this boolean option enables transparent proxying on this socket. +this socket option allows +the calling application to bind to a nonlocal ip address and operate +both as a client and a server with the foreign address as the local endpoint. +note: this requires that routing be set up in a way that +packets going to the foreign address are routed through the tproxy box +(i.e., the system hosting the application that employs the +.b ip_transparent +socket option). +enabling this socket option requires superuser privileges +(the +.br cap_net_admin +capability). +.ip +tproxy redirection with the iptables tproxy target also requires that +this option be set on the redirected socket. +.tp +.br ip_ttl " (since linux 1.0)" +set or retrieve the current time-to-live field that is used in every packet +sent from this socket. +.tp +.br ip_unblock_source " (since linux 2.4.22 / 2.5.68)" +unblock previously blocked multicast source. +returns +.br eaddrnotavail +when given source is not being blocked. +.ip +argument is an +.i ip_mreq_source +structure as described under +.br ip_add_source_membership . +.tp +.br so_peersec " (since linux 2.6.17)" +if labeled ipsec or netlabel is configured on both the sending and +receiving hosts, this read-only socket option returns the security +context of the peer socket connected to this socket. +by default, +this will be the same as the security context of the process that created +the peer socket unless overridden by the policy or by a process with +the required permissions. +.ip +the argument to +.br getsockopt (2) +is a pointer to a buffer of the specified length in bytes +into which the security context string will be copied. +if the buffer length is less than the length of the security +context string, then +.br getsockopt (2) +returns \-1, sets +.i errno +to +.br erange , +and returns the required length via +.ir optlen . +the caller should allocate at least +.br name_max +bytes for the buffer initially, although this is not guaranteed +to be sufficient. +resizing the buffer to the returned length +and retrying may be necessary. +.ip +the security context string may include a terminating null character +in the returned length, but is not guaranteed to do so: a security +context "foo" might be represented as either {'f','o','o'} of length 3 +or {'f','o','o','\\0'} of length 4, which are considered to be +interchangeable. +the string is printable, does not contain non-terminating null characters, +and is in an unspecified encoding (in particular, it +is not guaranteed to be ascii or utf-8). +.ip +the use of this option for sockets in the +.b af_inet +address family is supported since linux 2.6.17 +.\" commit 2c7946a7bf45ae86736ab3b43d0085e43947945c +for tcp sockets, and since linux 4.17 +.\" commit d452930fd3b9031e59abfeddb2fa383f1403d61a +for sctp sockets. +.ip +for selinux, netlabel conveys only the mls portion of the security +context of the peer across the wire, defaulting the rest of the +security context to the values defined in the policy for the +netmsg initial security identifier (sid). +however, netlabel can +be configured to pass full security contexts over loopback. +labeled ipsec always passes full security contexts as part of establishing +the security association (sa) and looks them up based on the association +for each packet. +.\" +.ss /proc interfaces +the ip protocol +supports a set of +.i /proc +interfaces to configure some global parameters. +the parameters can be accessed by reading or writing files in the directory +.ir /proc/sys/net/ipv4/ . +.\" fixme as at 2.6.12, 14 jun 2005, the following are undocumented: +.\" ip_queue_maxlen +.\" ip_conntrack_max +interfaces described as +.i boolean +take an integer value, with a nonzero value ("true") meaning that +the corresponding option is enabled, and a zero value ("false") +meaning that the option is disabled. +.\" +.tp +.ir ip_always_defrag " (boolean; since linux 2.2.13)" +[new with kernel 2.2.13; in earlier kernel versions this feature +was controlled at compile time by the +.b config_ip_always_defrag +option; this option is not present in 2.4.x and later] +.ip +when this boolean flag is enabled (not equal 0), incoming fragments +(parts of ip packets +that arose when some host between origin and destination decided +that the packets were too large and cut them into pieces) will be +reassembled (defragmented) before being processed, even if they are +about to be forwarded. +.ip +enable only if running either a firewall that is the sole link +to your network or a transparent proxy; never ever use it for a +normal router or host. +otherwise, fragmented communication can be disturbed +if the fragments travel over different links. +defragmentation also has a large memory and cpu time cost. +.ip +this is automagically turned on when masquerading or transparent +proxying are configured. +.\" +.tp +.ir ip_autoconfig " (since linux 2.2 to 2.6.17)" +.\" precisely: since 2.1.68 +.\" fixme document ip_autoconfig +not documented. +.\" +.tp +.ir ip_default_ttl " (integer; default: 64; since linux 2.2)" +.\" precisely: 2.1.15 +set the default time-to-live value of outgoing packets. +this can be changed per socket with the +.b ip_ttl +option. +.\" +.tp +.ir ip_dynaddr " (boolean; default: disabled; since linux 2.0.31)" +enable dynamic socket address and masquerading entry rewriting on interface +address change. +this is useful for dialup interface with changing ip addresses. +0 means no rewriting, 1 turns it on and 2 enables verbose mode. +.\" +.tp +.ir ip_forward " (boolean; default: disabled; since linux 1.2)" +enable ip forwarding with a boolean flag. +ip forwarding can be also set on a per-interface basis. +.\" +.tp +.ir ip_local_port_range " (since linux 2.2)" +.\" precisely: since 2.1.68 +this file contains two integers that define the default local port range +allocated to sockets that are not explicitly bound to a port number\(emthat +is, the range used for +.ir "ephemeral ports" . +an ephemeral port is allocated to a socket in the following circumstances: +.rs +.ip * 3 +the port number in a socket address is specified as 0 when calling +.br bind (2); +.ip * +.br listen (2) +is called on a stream socket that was not previously bound; +.ip * +.br connect (2) +was called on a socket that was not previously bound; +.ip * +.br sendto (2) +is called on a datagram socket that was not previously bound. +.re +.ip +allocation of ephemeral ports starts with the first number in +.ir ip_local_port_range +and ends with the second number. +if the range of ephemeral ports is exhausted, +then the relevant system call returns an error (but see bugs). +.ip +note that the port range in +.ir ip_local_port_range +should not conflict with the ports used by masquerading +(although the case is handled). +also, arbitrary choices may cause problems with some firewall packet +filters that make assumptions about the local ports in use. +the first number should be at least greater than 1024, +or better, greater than 4096, to avoid clashes +with well known ports and to minimize firewall problems. +.\" +.tp +.ir ip_no_pmtu_disc " (boolean; default: disabled; since linux 2.2)" +.\" precisely: 2.1.15 +if enabled, don't do path mtu discovery for tcp sockets by default. +path mtu discovery may fail if misconfigured firewalls (that drop +all icmp packets) or misconfigured interfaces (e.g., a point-to-point +link where the both ends don't agree on the mtu) are on the path. +it is better to fix the broken routers on the path than to turn off +path mtu discovery globally, because not doing it incurs a high cost +to the network. +.\" +.\" the following is from 2.6.12: documentation/networking/ip-sysctl.txt +.tp +.ir ip_nonlocal_bind " (boolean; default: disabled; since linux 2.4)" +.\" precisely: patch-2.4.0-test10 +if set, allows processes to +.br bind (2) +to nonlocal ip addresses, +which can be quite useful, but may break some applications. +.\" +.\" the following is from 2.6.12: documentation/networking/ip-sysctl.txt +.tp +.ir ip6frag_time " (integer; default: 30)" +time in seconds to keep an ipv6 fragment in memory. +.\" +.\" the following is from 2.6.12: documentation/networking/ip-sysctl.txt +.tp +.ir ip6frag_secret_interval " (integer; default: 600)" +regeneration interval (in seconds) of the hash secret (or lifetime +for the hash secret) for ipv6 fragments. +.tp +.ir ipfrag_high_thresh " (integer), " ipfrag_low_thresh " (integer)" +if the amount of queued ip fragments reaches +.ir ipfrag_high_thresh , +the queue is pruned down to +.ir ipfrag_low_thresh . +contains an integer with the number of bytes. +.tp +.i neigh/* +see +.br arp (7). +.\" fixme document the conf/*/* interfaces +.\" +.\" fixme document the route/* interfaces +.ss ioctls +all ioctls described in +.br socket (7) +apply to +.br ip . +.pp +ioctls to configure generic device parameters are described in +.br netdevice (7). +.\" fixme add a discussion of multicasting +.sh errors +.\" fixme document all errors. +.\" we should really fix the kernels to give more uniform +.\" error returns (enomem vs enobufs, eperm vs eacces etc.) +.tp +.b eacces +the user tried to execute an operation without the necessary permissions. +these include: +sending a packet to a broadcast address without having the +.b so_broadcast +flag set; +sending a packet via a +.i prohibit +route; +modifying firewall settings without superuser privileges (the +.b cap_net_admin +capability); +binding to a privileged port without superuser privileges (the +.b cap_net_bind_service +capability). +.tp +.b eaddrinuse +tried to bind to an address already in use. +.tp +.b eaddrnotavail +a nonexistent interface was requested or the requested source +address was not local. +.tp +.b eagain +operation on a nonblocking socket would block. +.tp +.b ealready +a connection operation on a nonblocking socket is already in progress. +.tp +.b econnaborted +a connection was closed during an +.br accept (2). +.tp +.b ehostunreach +no valid routing table entry matches the destination address. +this error can be caused by an icmp message from a remote router or +for the local routing table. +.tp +.b einval +invalid argument passed. +for send operations this can be caused by sending to a +.i blackhole +route. +.tp +.b eisconn +.br connect (2) +was called on an already connected socket. +.tp +.b emsgsize +datagram is bigger than an mtu on the path and it cannot be fragmented. +.tp +.br enobufs ", " enomem +not enough free memory. +this often means that the memory allocation is limited by the socket +buffer limits, not by the system memory, but this is not 100% consistent. +.tp +.b enoent +.b siocgstamp +was called on a socket where no packet arrived. +.tp +.b enopkg +a kernel subsystem was not configured. +.tp +.br enoprotoopt " and " eopnotsupp +invalid socket option passed. +.tp +.b enotconn +the operation is defined only on a connected socket, but the socket wasn't +connected. +.tp +.b eperm +user doesn't have permission to set high priority, change configuration, +or send signals to the requested process or group. +.tp +.b epipe +the connection was unexpectedly closed or shut down by the other end. +.tp +.b esocktnosupport +the socket is not configured or an unknown socket type was requested. +.pp +other errors may be generated by the overlaying protocols; see +.br tcp (7), +.br raw (7), +.br udp (7), +and +.br socket (7). +.sh notes +.br ip_freebind , +.br ip_msfilter , +.br ip_mtu , +.br ip_mtu_discover , +.br ip_recvorigdstaddr , +.br ip_passsec , +.br ip_pktinfo , +.br ip_recverr , +.br ip_router_alert , +and +.br ip_transparent +are linux-specific. +.\" ip_xfrm_policy is linux-specific +.\" ip_ipsec_policy is a nonstandard extension, also present on some bsds +.pp +be very careful with the +.b so_broadcast +option \- it is not privileged in linux. +it is easy to overload the network +with careless broadcasts. +for new application protocols +it is better to use a multicast group instead of broadcasting. +broadcasting is discouraged. +.pp +some other bsd sockets implementations provide +.b ip_rcvdstaddr +and +.b ip_recvif +socket options to get the destination address and the interface of +received datagrams. +linux has the more general +.b ip_pktinfo +for the same task. +.pp +some bsd sockets implementations also provide an +.b ip_recvttl +option, but an ancillary message with type +.b ip_recvttl +is passed with the incoming packet. +this is different from the +.b ip_ttl +option used in linux. +.pp +using the +.b sol_ip +socket options level isn't portable; bsd-based stacks use the +.b ipproto_ip +level. +.pp +.b inaddr_any +(0.0.0.0) and +.b inaddr_broadcast +(255.255.255.255) are byte-order-neutral. + this means +.br htonl (3) +has no effect on them. +.ss compatibility +for compatibility with linux 2.0, the obsolete +.bi "socket(af_inet, sock_packet, " protocol ) +syntax is still supported to open a +.br packet (7) +socket. +this is deprecated and should be replaced by +.bi "socket(af_packet, sock_raw, " protocol ) +instead. +the main difference is the new +.i sockaddr_ll +address structure for generic link layer information instead of the old +.br sockaddr_pkt . +.sh bugs +there are too many inconsistent error values. +.pp +the error used to diagnose exhaustion of the ephemeral port range differs +across the various system calls +.rb ( connect (2), +.br bind (2), +.br listen (2), +.br sendto (2)) +that can assign ephemeral ports. +.pp +the ioctls to configure ip-specific interface options and arp tables are +not described. +.\" .pp +.\" some versions of glibc forget to declare +.\" .ir in_pktinfo . +.\" workaround currently is to copy it into your program from this man page. +.pp +receiving the original destination address with +.b msg_errqueue +in +.i msg_name +by +.br recvmsg (2) +does not work in some 2.2 kernels. +.\" .sh authors +.\" this man page was written by andi kleen. +.sh see also +.br recvmsg (2), +.br sendmsg (2), +.br byteorder (3), +.br capabilities (7), +.br icmp (7), +.br ipv6 (7), +.br netdevice (7), +.br netlink (7), +.br raw (7), +.br socket (7), +.br tcp (7), +.br udp (7), +.br ip (8) +.pp +the kernel source file +.ir documentation/networking/ip\-sysctl.txt . +.pp +rfc\ 791 for the original ip specification. +rfc\ 1122 for the ipv4 host requirements. +rfc\ 1812 for the ipv4 router requirements. +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/lstat.2 + +.\" copyright (c) 2016 by michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th tmpfs 5 2021-03-22 "linux" "linux programmer's manual" +.sh name +tmpfs \- a virtual memory filesystem +.sh description +the +.b tmpfs +facility allows the creation of filesystems whose contents reside +in virtual memory. +since the files on such filesystems typically reside in ram, +file access is extremely fast. +.pp +the filesystem is automatically created when mounting +a filesystem with the type +.br tmpfs +via a command such as the following: +.pp +.in +4n +.ex +$ sudo mount \-t tmpfs \-o size=10m tmpfs /mnt/mytmpfs +.ee +.in +.pp +a +.b tmpfs +filesystem has the following properties: +.ip * 3 +the filesystem can employ swap space when physical memory pressure +demands it. +.ip * +the filesystem consumes only as much physical memory and swap space +as is required to store the current contents of the filesystem. +.ip * +during a remount operation +.ri ( "mount\ \-o\ remount" ), +the filesystem size can be changed +(without losing the existing contents of the filesystem). +.pp +if a +.b tmpfs +filesystem is unmounted, its contents are discarded (lost). +.\" see mm/shmem.c:shmem_parse_options for options it supports. +.ss mount options +the +.b tmpfs +filesystem supports the following mount options: +.tp +.br size "=\fibytes\fp" +specify an upper limit on the size of the filesystem. +the size is given in bytes, and rounded up to entire pages. +.ip +the size may have a +.br k , +.br m , +or +.b g +suffix for ki, mi, gi (binary kilo (kibi), binary mega (mebi), and binary giga +(gibi)). +.ip +the size may also have a % suffix to limit this instance to a percentage of +physical ram. +.ip +the default, when neither +.b size +nor +.b nr_blocks +is specified, is +.ir size=50% . +.tp +.br nr_blocks "=\fiblocks\fp" +the same as +.br size , +but in blocks of +.br page_cache_size . +.ip +blocks may be specified with +.br k , +.br m , +or +.b g +suffixes like +.br size , +but not a % suffix. +.tp +.br nr_inodes "=\fiinodes\fp" +the maximum number of inodes for this instance. +the default is half of the number of your physical ram pages, or (on a +machine with highmem) the number of lowmem ram pages, whichever is smaller. +.ip +inodes may be specified with +.br k , +.br m , +or +.b g +suffixes like +.br size , +but not a % suffix. +.tp +.br mode "=\fimode\fp" +set initial permissions of the root directory. +.tp +.br gid "=\figid\fp (since linux 2.5.7)" +.\" technically this is also in some version of linux 2.4. +.\" commit 099445b489625b80b1d6687c9b6072dbeaca4096 +set the initial group id of the root directory. +.tp +.br uid "=\fiuid\fp (since linux 2.5.7)" +.\" technically this is also in some version of linux 2.4. +.\" commit 099445b489625b80b1d6687c9b6072dbeaca4096 +set the initial user id of the root directory. +.tp +.br huge "=\fihuge_option\fr (since linux 4.7.0)" +.\" commit 5a6e75f8110c97e2a5488894d4e922187e6cb343 +set the huge table memory allocation policy for all files in this instance (if +.b config_transparent_huge_pagecache +is enabled). +.ip +the +.i huge_option +value is one of the following: +.rs +.tp +.b never +do not allocate huge pages. +this is the default. +.tp +.b always +attempt to allocate huge pages every time a new page is needed. +.tp +.b within_size +only allocate huge page if it will be fully within +.ir i_size . +also respect +.br fadvise (2)/ madvise (2) +hints +.tp +.b advise +only allocate huge pages if requested with +.br fadvise (2)/ madvise (2). +.tp +.b deny +for use in emergencies, to force the huge option off from all mounts. +.tp +.b force +force the huge option on for all mounts; useful for testing. +.re +.tp +.br mpol "=\fimpol_option\fr (since linux 2.6.15)" +.\" commit 7339ff8302fd70aabf5f1ae26e0c4905fa74a495 +set the numa memory allocation policy for all files in this instance (if +.b config_numa +is enabled). +.ip +the +.i mpol_option +value is one of the following: +.rs +.tp +.b default +use the process allocation policy (see +.br set_mempolicy (2)). +.tp +.br prefer ":\finode\fp" +preferably allocate memory from the given +.ir node . +.tp +.br bind ":\finodelist\fp" +allocate memory only from nodes in +.ir nodelist . +.tp +.b interleave +allocate from each node in turn. +.tp +.br interleave ":\finodelist\fp" +allocate from each node of +.i in +turn. +.tp +.b local +preferably allocate memory from the local node. +.re +.ip +in the above, +.i nodelist +is a comma-separated list of decimal numbers and ranges +that specify numa nodes. +a range is a pair of hyphen-separated decimal numbers, +the smallest and largest node numbers in the range. +for example, +.ir mpol=bind:0\-3,5,7,9\-15 . +.sh versions +the +.b tmpfs +facility was added in linux 2.4, as a successor to the older +.b ramfs +facility, which did not provide limit checking or +allow for the use of swap space. +.sh notes +in order for user-space tools and applications to create +.b tmpfs +filesystems, the kernel must be configured with the +.b config_tmpfs +option. +.pp +the +.br tmpfs +filesystem supports extended attributes (see +.br xattr (7)), +but +.i user +extended attributes are not permitted. +.pp +an internal shared memory filesystem is used for +system v shared memory +.rb ( shmget (2)) +and shared anonymous mappings +.rb ( mmap (2) +with the +.b map_shared +and +.br map_anonymous +flags). +this filesystem is available regardless of whether +the kernel was configured with the +.b config_tmpfs +option. +.pp +a +.b tmpfs +filesystem mounted at +.ir /dev/shm +is used for the implementation of posix shared memory +.rb ( shm_overview (7)) +and posix semaphores +.rb ( sem_overview (7)). +.pp +the amount of memory consumed by all +.b tmpfs +filesystems is shown in the +.i shmem +field of +.ir /proc/meminfo +and in the +.i shared +field displayed by +.br free (1). +.pp +the +.b tmpfs +facility was formerly called +.br shmfs . +.sh see also +.br df (1), +.br du (1), +.br memfd_create (2), +.br mmap (2), +.br set_mempolicy (2), +.br shm_open (3), +.br mount (8) +.pp +the kernel source files +.ir documentation/filesystems/tmpfs.txt +and +.ir documentation/admin\-guide/mm/transhuge.rst . +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/ether_aton.3 + +.so man2/mlock.2 + +.\" this man page is copyright (c) 1999 andi kleen . +.\" and copyright (c) 1999 matthew wilcox. +.\" +.\" %%%license_start(verbatim_one_para) +.\" permission is granted to distribute possibly modified copies +.\" of this page provided the header is included verbatim, +.\" and in case of nontrivial modification author and date +.\" of the modification is added to the header. +.\" %%%license_end +.\" +.\" 2002-10-30, michael kerrisk, +.\" added description of so_acceptconn +.\" 2004-05-20, aeb, added so_rcvtimeo/so_sndtimeo text. +.\" modified, 27 may 2004, michael kerrisk +.\" added notes on capability requirements +.\" a few small grammar fixes +.\" 2010-06-13 jan engelhardt +.\" documented so_domain and so_protocol. +.\" +.\" fixme +.\" the following are not yet documented: +.\" +.\" so_peername (2.4?) +.\" get only +.\" seems to do something similar to getpeername(), but then +.\" why is it necessary / how does it differ? +.\" +.\" so_timestamping (2.6.30) +.\" documentation/networking/timestamping.txt +.\" commit cb9eff097831007afb30d64373f29d99825d0068 +.\" author: patrick ohly +.\" +.\" so_wifi_status (3.3) +.\" commit 6e3e939f3b1bf8534b32ad09ff199d88800835a0 +.\" author: johannes berg +.\" also: scm_wifi_status +.\" +.\" so_nofcs (3.4) +.\" commit 3bdc0eba0b8b47797f4a76e377dd8360f317450f +.\" author: ben greear +.\" +.\" so_get_filter (3.8) +.\" commit a8fc92778080c845eaadc369a0ecf5699a03bef0 +.\" author: pavel emelyanov +.\" +.\" so_max_pacing_rate (3.13) +.\" commit 62748f32d501f5d3712a7c372bbb92abc7c62bc7 +.\" author: eric dumazet +.\" +.\" so_bpf_extensions (3.14) +.\" commit ea02f9411d9faa3553ed09ce0ec9f00ceae9885e +.\" author: michal sekletar +.\" +.th socket 7 2021-03-22 linux "linux programmer's manual" +.sh name +socket \- linux socket interface +.sh synopsis +.nf +.b #include +.pp +.ib sockfd " = socket(int " socket_family ", int " socket_type ", int " protocol ); +.fi +.sh description +this manual page describes the linux networking socket layer user +interface. +the bsd compatible sockets +are the uniform interface +between the user process and the network protocol stacks in the kernel. +the protocol modules are grouped into +.i protocol families +such as +.br af_inet ", " af_ipx ", and " af_packet , +and +.i socket types +such as +.b sock_stream +or +.br sock_dgram . +see +.br socket (2) +for more information on families and types. +.ss socket-layer functions +these functions are used by the user process to send or receive packets +and to do other socket operations. +for more information see their respective manual pages. +.pp +.br socket (2) +creates a socket, +.br connect (2) +connects a socket to a remote socket address, +the +.br bind (2) +function binds a socket to a local socket address, +.br listen (2) +tells the socket that new connections shall be accepted, and +.br accept (2) +is used to get a new socket with a new incoming connection. +.br socketpair (2) +returns two connected anonymous sockets (implemented only for a few +local families like +.br af_unix ) +.pp +.br send (2), +.br sendto (2), +and +.br sendmsg (2) +send data over a socket, and +.br recv (2), +.br recvfrom (2), +.br recvmsg (2) +receive data from a socket. +.br poll (2) +and +.br select (2) +wait for arriving data or a readiness to send data. +in addition, the standard i/o operations like +.br write (2), +.br writev (2), +.br sendfile (2), +.br read (2), +and +.br readv (2) +can be used to read and write data. +.pp +.br getsockname (2) +returns the local socket address and +.br getpeername (2) +returns the remote socket address. +.br getsockopt (2) +and +.br setsockopt (2) +are used to set or get socket layer or protocol options. +.br ioctl (2) +can be used to set or read some other options. +.pp +.br close (2) +is used to close a socket. +.br shutdown (2) +closes parts of a full-duplex socket connection. +.pp +seeking, or calling +.br pread (2) +or +.br pwrite (2) +with a nonzero position is not supported on sockets. +.pp +it is possible to do nonblocking i/o on sockets by setting the +.b o_nonblock +flag on a socket file descriptor using +.br fcntl (2). +then all operations that would block will (usually) +return with +.b eagain +(operation should be retried later); +.br connect (2) +will return +.b einprogress +error. +the user can then wait for various events via +.br poll (2) +or +.br select (2). +.ts +tab(:) allbox; +c s s +l l lx. +i/o events +event:poll flag:occurrence +read:pollin:t{ +new data arrived. +t} +read:pollin:t{ +a connection setup has been completed +(for connection-oriented sockets) +t} +read:pollhup:t{ +a disconnection request has been initiated by the other end. +t} +read:pollhup:t{ +a connection is broken (only for connection-oriented protocols). +when the socket is written +.b sigpipe +is also sent. +t} +write:pollout:t{ +socket has enough send buffer space for writing new data. +t} +read/write:t{ +pollin | +.br +pollout +t}:t{ +an outgoing +.br connect (2) +finished. +t} +read/write:pollerr:t{ +an asynchronous error occurred. +t} +read/write:pollhup:t{ +the other end has shut down one direction. +t} +exception:pollpri:t{ +urgent data arrived. +.b sigurg +is sent then. +t} +.\" fixme . the following is not true currently: +.\" it is no i/o event when the connection +.\" is broken from the local end using +.\" .br shutdown (2) +.\" or +.\" .br close (2). +.te +.pp +an alternative to +.br poll (2) +and +.br select (2) +is to let the kernel inform the application about events +via a +.b sigio +signal. +for that the +.b o_async +flag must be set on a socket file descriptor via +.br fcntl (2) +and a valid signal handler for +.b sigio +must be installed via +.br sigaction (2). +see the +.i signals +discussion below. +.ss socket address structures +each socket domain has its own format for socket addresses, +with a domain-specific address structure. +each of these structures begins with an +integer "family" field (typed as +.ir sa_family_t ) +that indicates the type of the address structure. +this allows +the various system calls (e.g., +.br connect (2), +.br bind (2), +.br accept (2), +.br getsockname (2), +.br getpeername (2)), +which are generic to all socket domains, +to determine the domain of a particular socket address. +.pp +to allow any type of socket address to be passed to +interfaces in the sockets api, +the type +.ir "struct sockaddr" +is defined. +the purpose of this type is purely to allow casting of +domain-specific socket address types to a "generic" type, +so as to avoid compiler warnings about type mismatches in +calls to the sockets api. +.pp +in addition, the sockets api provides the data type +.ir "struct sockaddr_storage". +this type +is suitable to accommodate all supported domain-specific socket +address structures; it is large enough and is aligned properly. +(in particular, it is large enough to hold +ipv6 socket addresses.) +the structure includes the following field, which can be used to identify +the type of socket address actually stored in the structure: +.pp +.in +4n +.ex + sa_family_t ss_family; +.ee +.in +.pp +the +.i sockaddr_storage +structure is useful in programs that must handle socket addresses +in a generic way +(e.g., programs that must deal with both ipv4 and ipv6 socket addresses). +.ss socket options +the socket options listed below can be set by using +.br setsockopt (2) +and read with +.br getsockopt (2) +with the socket level set to +.b sol_socket +for all sockets. +unless otherwise noted, +.i optval +is a pointer to an +.ir int . +.\" fixme . +.\" in the list below, the text used to describe argument types +.\" for each socket option should be more consistent +.\" +.\" so_acceptconn is in posix.1-2001, and its origin is explained in +.\" w r stevens, unpv1 +.tp +.b so_acceptconn +returns a value indicating whether or not this socket has been marked +to accept connections with +.br listen (2). +the value 0 indicates that this is not a listening socket, +the value 1 indicates that this is a listening socket. +this socket option is read-only. +.tp +.br so_attach_filter " (since linux 2.2), " so_attach_bpf " (since linux 3.19)" +attach a classic bpf +.rb ( so_attach_filter ) +or an extended bpf +.rb ( so_attach_bpf ) +program to the socket for use as a filter of incoming packets. +a packet will be dropped if the filter program returns zero. +if the filter program returns a +nonzero value which is less than the packet's data length, +the packet will be truncated to the length returned. +if the value returned by the filter is greater than or equal to the +packet's data length, the packet is allowed to proceed unmodified. +.ip +the argument for +.br so_attach_filter +is a +.i sock_fprog +structure, defined in +.ir : +.ip +.in +4n +.ex +struct sock_fprog { + unsigned short len; + struct sock_filter *filter; +}; +.ee +.in +.ip +the argument for +.br so_attach_bpf +is a file descriptor returned by the +.br bpf (2) +system call and must refer to a program of type +.br bpf_prog_type_socket_filter . +.ip +these options may be set multiple times for a given socket, +each time replacing the previous filter program. +the classic and extended versions may be called on the same socket, +but the previous filter will always be replaced such that a socket +never has more than one filter defined. +.ip +both classic and extended bpf are explained in the kernel source file +.i documentation/networking/filter.txt +.tp +.br so_attach_reuseport_cbpf ", " so_attach_reuseport_ebpf +for use with the +.br so_reuseport +option, these options allow the user to set a classic bpf +.rb ( so_attach_reuseport_cbpf ) +or an extended bpf +.rb ( so_attach_reuseport_ebpf ) +program which defines how packets are assigned to +the sockets in the reuseport group (that is, all sockets which have +.br so_reuseport +set and are using the same local address to receive packets). +.ip +the bpf program must return an index between 0 and n\-1 representing +the socket which should receive the packet +(where n is the number of sockets in the group). +if the bpf program returns an invalid index, +socket selection will fall back to the plain +.br so_reuseport +mechanism. +.ip +sockets are numbered in the order in which they are added to the group +(that is, the order of +.br bind (2) +calls for udp sockets or the order of +.br listen (2) +calls for tcp sockets). +new sockets added to a reuseport group will inherit the bpf program. +when a socket is removed from a reuseport group (via +.br close (2)), +the last socket in the group will be moved into the closed socket's +position. +.ip +these options may be set repeatedly at any time on any socket in the group +to replace the current bpf program used by all sockets in the group. +.ip +.br so_attach_reuseport_cbpf +takes the same argument type as +.br so_attach_filter +and +.br so_attach_reuseport_ebpf +takes the same argument type as +.br so_attach_bpf . +.ip +udp support for this feature is available since linux 4.5; +tcp support is available since linux 4.6. +.tp +.b so_bindtodevice +bind this socket to a particular device like \(lqeth0\(rq, +as specified in the passed interface name. +if the +name is an empty string or the option length is zero, the socket device +binding is removed. +the passed option is a variable-length null-terminated +interface name string with the maximum size of +.br ifnamsiz . +if a socket is bound to an interface, +only packets received from that particular interface are processed by the +socket. +note that this works only for some socket types, particularly +.b af_inet +sockets. +it is not supported for packet sockets (use normal +.br bind (2) +there). +.ip +before linux 3.8, +this socket option could be set, but could not retrieved with +.br getsockopt (2). +since linux 3.8, it is readable. +the +.i optlen +argument should contain the buffer size available +to receive the device name and is recommended to be +.br ifnamsiz +bytes. +the real device name length is reported back in the +.i optlen +argument. +.tp +.b so_broadcast +set or get the broadcast flag. +when enabled, datagram sockets are allowed to send +packets to a broadcast address. +this option has no effect on stream-oriented sockets. +.tp +.b so_bsdcompat +enable bsd bug-to-bug compatibility. +this is used by the udp protocol module in linux 2.0 and 2.2. +if enabled, icmp errors received for a udp socket will not be passed +to the user program. +in later kernel versions, support for this option has been phased out: +linux 2.4 silently ignores it, and linux 2.6 generates a kernel warning +(printk()) if a program uses this option. +linux 2.0 also enabled bsd bug-to-bug compatibility +options (random header changing, skipping of the broadcast flag) for raw +sockets with this option, but that was removed in linux 2.2. +.tp +.b so_debug +enable socket debugging. +allowed only for processes with the +.b cap_net_admin +capability or an effective user id of 0. +.tp +.br so_detach_filter " (since linux 2.2), " so_detach_bpf " (since linux 3.19)" +these two options, which are synonyms, +may be used to remove the classic or extended bpf +program attached to a socket with either +.br so_attach_filter +or +.br so_attach_bpf . +the option value is ignored. +.tp +.br so_domain " (since linux 2.6.32)" +retrieves the socket domain as an integer, returning a value such as +.br af_inet6 . +see +.br socket (2) +for details. +this socket option is read-only. +.tp +.b so_error +get and clear the pending socket error. +this socket option is read-only. +expects an integer. +.tp +.b so_dontroute +don't send via a gateway, send only to directly connected hosts. +the same effect can be achieved by setting the +.b msg_dontroute +flag on a socket +.br send (2) +operation. +expects an integer boolean flag. +.tp +.br so_incoming_cpu " (gettable since linux 3.19, settable since linux 4.4)" +.\" getsockopt 2c8c56e15df3d4c2af3d656e44feb18789f75837 +.\" setsockopt 70da268b569d32a9fddeea85dc18043de9d89f89 +sets or gets the cpu affinity of a socket. +expects an integer flag. +.ip +.in +4n +.ex +int cpu = 1; +setsockopt(fd, sol_socket, so_incoming_cpu, &cpu, + sizeof(cpu)); +.ee +.in +.ip +because all of the packets for a single stream +(i.e., all packets for the same 4-tuple) +arrive on the single rx queue that is associated with a particular cpu, +the typical use case is to employ one listening process per rx queue, +with the incoming flow being handled by a listener +on the same cpu that is handling the rx queue. +this provides optimal numa behavior and keeps cpu caches hot. +.\" +.\" from an email conversation with eric dumazet: +.\" >> note that setting the option is not supported if so_reuseport is used. +.\" > +.\" > please define "not supported". does this yield an api diagnostic? +.\" > if so, what is it? +.\" > +.\" >> socket will be selected from an array, either by a hash or bpf program +.\" >> that has no access to this information. +.\" > +.\" > sorry -- i'm lost here. how does this comment relate to the proposed +.\" > man page text above? +.\" +.\" simply that : +.\" +.\" if an application uses both so_incoming_cpu and so_reuseport, then +.\" so_reuseport logic, selecting the socket to receive the packet, ignores +.\" so_incoming_cpu setting. +.tp +.br so_incoming_napi_id " (gettable since linux 4.12)" +.\" getsockopt 6d4339028b350efbf87c61e6d9e113e5373545c9 +returns a system-level unique id called napi id that is associated +with a rx queue on which the last packet associated with that +socket is received. +.ip +this can be used by an application to split the incoming flows among worker +threads based on the rx queue on which the packets associated with the +flows are received. +it allows each worker thread to be associated with +a nic hw receive queue and service all the connection +requests received on that rx queue. +this mapping between a app thread and +a hw nic queue streamlines the +flow of data from the nic to the application. +.tp +.b so_keepalive +enable sending of keep-alive messages on connection-oriented sockets. +expects an integer boolean flag. +.tp +.b so_linger +sets or gets the +.b so_linger +option. +the argument is a +.i linger +structure. +.ip +.in +4n +.ex +struct linger { + int l_onoff; /* linger active */ + int l_linger; /* how many seconds to linger for */ +}; +.ee +.in +.ip +when enabled, a +.br close (2) +or +.br shutdown (2) +will not return until all queued messages for the socket have been +successfully sent or the linger timeout has been reached. +otherwise, +the call returns immediately and the closing is done in the background. +when the socket is closed as part of +.br exit (2), +it always lingers in the background. +.tp +.b so_lock_filter +.\" commit d59577b6ffd313d0ab3be39cb1ab47e29bdc9182 +when set, this option will prevent +changing the filters associated with the socket. +these filters include any set using the socket options +.br so_attach_filter , +.br so_attach_bpf , +.br so_attach_reuseport_cbpf , +and +.br so_attach_reuseport_ebpf . +.ip +the typical use case is for a privileged process to set up a raw socket +(an operation that requires the +.br cap_net_raw +capability), apply a restrictive filter, set the +.br so_lock_filter +option, +and then either drop its privileges or pass the socket file descriptor +to an unprivileged process via a unix domain socket. +.ip +once the +.br so_lock_filter +option has been enabled, attempts to change or remove the filter +attached to a socket, or to disable the +.br so_lock_filter +option will fail with the error +.br eperm . +.tp +.br so_mark " (since linux 2.6.25)" +.\" commit 4a19ec5800fc3bb64e2d87c4d9fdd9e636086fe0 +.\" and 914a9ab386a288d0f22252fc268ecbc048cdcbd5 +set the mark for each packet sent through this socket +(similar to the netfilter mark target but socket-based). +changing the mark can be used for mark-based +routing without netfilter or for packet filtering. +setting this option requires the +.b cap_net_admin +capability. +.tp +.b so_oobinline +if this option is enabled, +out-of-band data is directly placed into the receive data stream. +otherwise, out-of-band data is passed only when the +.b msg_oob +flag is set during receiving. +.\" don't document it because it can do too much harm. +.\".b so_no_check +.\" the kernel has support for the so_no_check socket +.\" option (boolean: 0 == default, calculate checksum on xmit, +.\" 1 == do not calculate checksum on xmit). +.\" additional note from andi kleen on so_no_check (2010-08-30) +.\" on linux udp checksums are essentially free and there's no reason +.\" to turn them off and it would disable another safety line. +.\" that is why i didn't document the option. +.tp +.b so_passcred +enable or disable the receiving of the +.b scm_credentials +control message. +for more information see +.br unix (7). +.tp +.b so_passsec +enable or disable the receiving of the +.b scm_security +control message. +for more information see +.br unix (7). +.tp +.br so_peek_off " (since linux 3.4)" +.\" commit ef64a54f6e558155b4f149bb10666b9e914b6c54 +this option, which is currently supported only for +.br unix (7) +sockets, sets the value of the "peek offset" for the +.br recv (2) +system call when used with +.br msg_peek +flag. +.ip +when this option is set to a negative value +(it is set to \-1 for all new sockets), +traditional behavior is provided: +.br recv (2) +with the +.br msg_peek +flag will peek data from the front of the queue. +.ip +when the option is set to a value greater than or equal to zero, +then the next peek at data queued in the socket will occur at +the byte offset specified by the option value. +at the same time, the "peek offset" will be +incremented by the number of bytes that were peeked from the queue, +so that a subsequent peek will return the next data in the queue. +.ip +if data is removed from the front of the queue via a call to +.br recv (2) +(or similar) without the +.br msg_peek +flag, the "peek offset" will be decreased by the number of bytes removed. +in other words, receiving data without the +.b msg_peek +flag will cause the "peek offset" to be adjusted to maintain +the correct relative position in the queued data, +so that a subsequent peek will retrieve the data that would have been +retrieved had the data not been removed. +.ip +for datagram sockets, if the "peek offset" points to the middle of a packet, +the data returned will be marked with the +.br msg_trunc +flag. +.ip +the following example serves to illustrate the use of +.br so_peek_off . +suppose a stream socket has the following queued input data: +.ip + aabbccddeeff +.ip +the following sequence of +.br recv (2) +calls would have the effect noted in the comments: +.ip +.in +4n +.ex +int ov = 4; // set peek offset to 4 +setsockopt(fd, sol_socket, so_peek_off, &ov, sizeof(ov)); + +recv(fd, buf, 2, msg_peek); // peeks "cc"; offset set to 6 +recv(fd, buf, 2, msg_peek); // peeks "dd"; offset set to 8 +recv(fd, buf, 2, 0); // reads "aa"; offset set to 6 +recv(fd, buf, 2, msg_peek); // peeks "ee"; offset set to 8 +.ee +.in +.tp +.b so_peercred +return the credentials of the peer process connected to this socket. +for further details, see +.br unix (7). +.tp +.br so_peersec " (since linux 2.6.2)" +return the security context of the peer socket connected to this socket. +for further details, see +.br unix (7) +and +.br ip (7). +.tp +.b so_priority +set the protocol-defined priority for all packets to be sent on +this socket. +linux uses this value to order the networking queues: +packets with a higher priority may be processed first depending +on the selected device queueing discipline. +.\" for +.\" .br ip (7), +.\" this also sets the ip type-of-service (tos) field for outgoing packets. +setting a priority outside the range 0 to 6 requires the +.b cap_net_admin +capability. +.tp +.br so_protocol " (since linux 2.6.32)" +retrieves the socket protocol as an integer, returning a value such as +.br ipproto_sctp . +see +.br socket (2) +for details. +this socket option is read-only. +.tp +.b so_rcvbuf +sets or gets the maximum socket receive buffer in bytes. +the kernel doubles this value (to allow space for bookkeeping overhead) +when it is set using +.\" most (all?) other implementations do not do this -- mtk, dec 05 +.br setsockopt (2), +and this doubled value is returned by +.br getsockopt (2). +.\" the following thread on lmkl is quite informative: +.\" getsockopt/setsockopt with so_rcvbuf and so_sndbuf "non-standard" behavior +.\" 17 july 2012 +.\" http://thread.gmane.org/gmane.linux.kernel/1328935 +the default value is set by the +.i /proc/sys/net/core/rmem_default +file, and the maximum allowed value is set by the +.i /proc/sys/net/core/rmem_max +file. +the minimum (doubled) value for this option is 256. +.tp +.br so_rcvbufforce " (since linux 2.6.14)" +using this socket option, a privileged +.rb ( cap_net_admin ) +process can perform the same task as +.br so_rcvbuf , +but the +.i rmem_max +limit can be overridden. +.tp +.br so_rcvlowat " and " so_sndlowat +specify the minimum number of bytes in the buffer until the socket layer +will pass the data to the protocol +.rb ( so_sndlowat ) +or the user on receiving +.rb ( so_rcvlowat ). +these two values are initialized to 1. +.b so_sndlowat +is not changeable on linux +.rb ( setsockopt (2) +fails with the error +.br enoprotoopt ). +.b so_rcvlowat +is changeable +only since linux 2.4. +.ip +before linux 2.6.28 +.\" tested on kernel 2.6.14 -- mtk, 30 nov 05 +.br select (2), +.br poll (2), +and +.br epoll (7) +did not respect the +.b so_rcvlowat +setting on linux, +and indicated a socket as readable when even a single byte of data +was available. +a subsequent read from the socket would then block until +.b so_rcvlowat +bytes are available. +since linux 2.6.28, +.\" commit c7004482e8dcb7c3c72666395cfa98a216a4fb70 +.br select (2), +.br poll (2), +and +.br epoll (7) +indicate a socket as readable only if at least +.b so_rcvlowat +bytes are available. +.tp +.br so_rcvtimeo " and " so_sndtimeo +.\" not implemented in 2.0. +.\" implemented in 2.1.11 for getsockopt: always return a zero struct. +.\" implemented in 2.3.41 for setsockopt, and actually used. +specify the receiving or sending timeouts until reporting an error. +the argument is a +.ir "struct timeval" . +if an input or output function blocks for this period of time, and +data has been sent or received, the return value of that function +will be the amount of data transferred; if no data has been transferred +and the timeout has been reached, then \-1 is returned with +.i errno +set to +.br eagain +or +.br ewouldblock , +.\" in fact to eagain +or +.b einprogress +(for +.br connect (2)) +just as if the socket was specified to be nonblocking. +if the timeout is set to zero (the default), +then the operation will never timeout. +timeouts only have effect for system calls that perform socket i/o (e.g., +.br read (2), +.br recvmsg (2), +.br send (2), +.br sendmsg (2)); +timeouts have no effect for +.br select (2), +.br poll (2), +.br epoll_wait (2), +and so on. +.tp +.b so_reuseaddr +.\" commit c617f398edd4db2b8567a28e899a88f8f574798d +.\" https://lwn.net/articles/542629/ +indicates that the rules used in validating addresses supplied in a +.br bind (2) +call should allow reuse of local addresses. +for +.b af_inet +sockets this +means that a socket may bind, except when there +is an active listening socket bound to the address. +when the listening socket is bound to +.b inaddr_any +with a specific port then it is not possible +to bind to this port for any local address. +argument is an integer boolean flag. +.tp +.br so_reuseport " (since linux 3.9)" +permits multiple +.b af_inet +or +.b af_inet6 +sockets to be bound to an identical socket address. +this option must be set on each socket (including the first socket) +prior to calling +.br bind (2) +on the socket. +to prevent port hijacking, +all of the processes binding to the same address must have the same +effective uid. +this option can be employed with both tcp and udp sockets. +.ip +for tcp sockets, this option allows +.br accept (2) +load distribution in a multi-threaded server to be improved by +using a distinct listener socket for each thread. +this provides improved load distribution as compared +to traditional techniques such using a single +.br accept (2)ing +thread that distributes connections, +or having multiple threads that compete to +.br accept (2) +from the same socket. +.ip +for udp sockets, +the use of this option can provide better distribution +of incoming datagrams to multiple processes (or threads) as compared +to the traditional technique of having multiple processes +compete to receive datagrams on the same socket. +.tp +.br so_rxq_ovfl " (since linux 2.6.33)" +.\" commit 3b885787ea4112eaa80945999ea0901bf742707f +indicates that an unsigned 32-bit value ancillary message (cmsg) +should be attached to received skbs indicating +the number of packets dropped by the socket since its creation. +.tp +.br so_select_err_queue " (since linux 3.10)" +.\" commit 7d4c04fc170087119727119074e72445f2bb192b +.\" author: keller, jacob e +when this option is set on a socket, +an error condition on a socket causes notification not only via the +.i exceptfds +set of +.br select (2). +similarly, +.br poll (2) +also returns a +.b pollpri +whenever an +.b pollerr +event is returned. +.\" it does not affect wake up. +.ip +background: this option was added when waking up on an error condition +occurred only via the +.ir readfds +and +.ir writefds +sets of +.br select (2). +the option was added to allow monitoring for error conditions via the +.i exceptfds +argument without simultaneously having to receive notifications (via +.ir readfds ) +for regular data that can be read from the socket. +after changes in linux 4.16, +.\" commit 6e5d58fdc9bedd0255a8 +.\" ("skbuff: fix not waking applications when errors are enqueued") +the use of this flag to achieve the desired notifications +is no longer necessary. +this option is nevertheless retained for backwards compatibility. +.tp +.b so_sndbuf +sets or gets the maximum socket send buffer in bytes. +the kernel doubles this value (to allow space for bookkeeping overhead) +when it is set using +.\" most (all?) other implementations do not do this -- mtk, dec 05 +.\" see also the comment to so_rcvbuf (17 jul 2012 lkml mail) +.br setsockopt (2), +and this doubled value is returned by +.br getsockopt (2). +the default value is set by the +.i /proc/sys/net/core/wmem_default +file and the maximum allowed value is set by the +.i /proc/sys/net/core/wmem_max +file. +the minimum (doubled) value for this option is 2048. +.tp +.br so_sndbufforce " (since linux 2.6.14)" +using this socket option, a privileged +.rb ( cap_net_admin ) +process can perform the same task as +.br so_sndbuf , +but the +.i wmem_max +limit can be overridden. +.tp +.b so_timestamp +enable or disable the receiving of the +.b so_timestamp +control message. +the timestamp control message is sent with level +.b sol_socket +and a +.i cmsg_type +of +.br scm_timestamp . +the +.i cmsg_data +field is a +.i "struct timeval" +indicating the +reception time of the last packet passed to the user in this call. +see +.br cmsg (3) +for details on control messages. +.tp +.br so_timestampns " (since linux 2.6.22)" +.\" commit 92f37fd2ee805aa77925c1e64fd56088b46094fc +enable or disable the receiving of the +.b so_timestampns +control message. +the timestamp control message is sent with level +.b sol_socket +and a +.i cmsg_type +of +.br scm_timestampns . +the +.i cmsg_data +field is a +.i "struct timespec" +indicating the +reception time of the last packet passed to the user in this call. +the clock used for the timestamp is +.br clock_realtime . +see +.br cmsg (3) +for details on control messages. +.ip +a socket cannot mix +.b so_timestamp +and +.br so_timestampns : +the two modes are mutually exclusive. +.tp +.b so_type +gets the socket type as an integer (e.g., +.br sock_stream ). +this socket option is read-only. +.tp +.br so_busy_poll " (since linux 3.11)" +sets the approximate time in microseconds to busy poll on a blocking receive +when there is no data. +increasing this value requires +.br cap_net_admin . +the default for this option is controlled by the +.i /proc/sys/net/core/busy_read +file. +.ip +the value in the +.i /proc/sys/net/core/busy_poll +file determines how long +.br select (2) +and +.br poll (2) +will busy poll when they operate on sockets with +.br so_busy_poll +set and no events to report are found. +.ip +in both cases, +busy polling will only be done when the socket last received data +from a network device that supports this option. +.ip +while busy polling may improve latency of some applications, +care must be taken when using it since this will increase +both cpu utilization and power usage. +.ss signals +when writing onto a connection-oriented socket that has been shut down +(by the local or the remote end) +.b sigpipe +is sent to the writing process and +.b epipe +is returned. +the signal is not sent when the write call +specified the +.b msg_nosignal +flag. +.pp +when requested with the +.b fiosetown +.br fcntl (2) +or +.b siocspgrp +.br ioctl (2), +.b sigio +is sent when an i/o event occurs. +it is possible to use +.br poll (2) +or +.br select (2) +in the signal handler to find out which socket the event occurred on. +an alternative (in linux 2.2) is to set a real-time signal using the +.b f_setsig +.br fcntl (2); +the handler of the real time signal will be called with +the file descriptor in the +.i si_fd +field of its +.ir siginfo_t . +see +.br fcntl (2) +for more information. +.pp +under some circumstances (e.g., multiple processes accessing a +single socket), the condition that caused the +.b sigio +may have already disappeared when the process reacts to the signal. +if this happens, the process should wait again because linux +will resend the signal later. +.\" .ss ancillary messages +.ss /proc interfaces +the core socket networking parameters can be accessed +via files in the directory +.ir /proc/sys/net/core/ . +.tp +.i rmem_default +contains the default setting in bytes of the socket receive buffer. +.tp +.i rmem_max +contains the maximum socket receive buffer size in bytes which a user may +set by using the +.b so_rcvbuf +socket option. +.tp +.i wmem_default +contains the default setting in bytes of the socket send buffer. +.tp +.i wmem_max +contains the maximum socket send buffer size in bytes which a user may +set by using the +.b so_sndbuf +socket option. +.tp +.ir message_cost " and " message_burst +configure the token bucket filter used to load limit warning messages +caused by external network events. +.tp +.i netdev_max_backlog +maximum number of packets in the global input queue. +.tp +.i optmem_max +maximum length of ancillary data and user control data like the iovecs +per socket. +.\" netdev_fastroute is not documented because it is experimental +.ss ioctls +these operations can be accessed using +.br ioctl (2): +.pp +.in +4n +.ex +.ib error " = ioctl(" ip_socket ", " ioctl_type ", " &value_result ");" +.ee +.in +.tp +.b siocgstamp +return a +.i struct timeval +with the receive timestamp of the last packet passed to the user. +this is useful for accurate round trip time measurements. +see +.br setitimer (2) +for a description of +.ir "struct timeval" . +.\" +this ioctl should be used only if the socket options +.b so_timestamp +and +.b so_timestampns +are not set on the socket. +otherwise, it returns the timestamp of the +last packet that was received while +.b so_timestamp +and +.b so_timestampns +were not set, or it fails if no such packet has been received, +(i.e., +.br ioctl (2) +returns \-1 with +.i errno +set to +.br enoent ). +.tp +.b siocspgrp +set the process or process group that is to receive +.b sigio +or +.b sigurg +signals when i/o becomes possible or urgent data is available. +the argument is a pointer to a +.ir pid_t . +for further details, see the description of +.br f_setown +in +.br fcntl (2). +.tp +.b fioasync +change the +.b o_async +flag to enable or disable asynchronous i/o mode of the socket. +asynchronous i/o mode means that the +.b sigio +signal or the signal set with +.b f_setsig +is raised when a new i/o event occurs. +.ip +argument is an integer boolean flag. +(this operation is synonymous with the use of +.br fcntl (2) +to set the +.b o_async +flag.) +.\" +.tp +.b siocgpgrp +get the current process or process group that receives +.b sigio +or +.b sigurg +signals, +or 0 +when none is set. +.pp +valid +.br fcntl (2) +operations: +.tp +.b fiogetown +the same as the +.b siocgpgrp +.br ioctl (2). +.tp +.b fiosetown +the same as the +.b siocspgrp +.br ioctl (2). +.sh versions +.b so_bindtodevice +was introduced in linux 2.0.30. +.b so_passcred +is new in linux 2.2. +the +.i /proc +interfaces were introduced in linux 2.2. +.b so_rcvtimeo +and +.b so_sndtimeo +are supported since linux 2.3.41. +earlier, timeouts were fixed to +a protocol-specific setting, and could not be read or written. +.sh notes +linux assumes that half of the send/receive buffer is used for internal +kernel structures; thus the values in the corresponding +.i /proc +files are twice what can be observed on the wire. +.pp +linux will allow port reuse only with the +.b so_reuseaddr +option +when this option was set both in the previous program that performed a +.br bind (2) +to the port and in the program that wants to reuse the port. +this differs from some implementations (e.g., freebsd) +where only the later program needs to set the +.b so_reuseaddr +option. +typically this difference is invisible, since, for example, a server +program is designed to always set this option. +.\" .sh authors +.\" this man page was written by andi kleen. +.sh see also +.br wireshark (1), +.br bpf (2), +.br connect (2), +.br getsockopt (2), +.br setsockopt (2), +.br socket (2), +.br pcap (3), +.br address_families (7), +.br capabilities (7), +.br ddp (7), +.br ip (7), +.br ipv6 (7), +.br packet (7), +.br tcp (7), +.br udp (7), +.br unix (7), +.br tcpdump (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/getrpcent.3 + +.\" copyright 2001 alexey mahotkin +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th koi8-r 7 2020-08-13 "linux" "linux programmer's manual" +.sh name +koi8-r \- russian character set encoded in octal, decimal, +and hexadecimal +.sh description +rfc\ 1489 defines an 8-bit character set, koi8-r. +koi8-r encodes the +characters used in russian. +.ss koi8-r characters +the following table displays the characters in koi8-r that +are printable and unlisted in the +.br ascii (7) +manual page. +.ts +l l l c lp-1. +oct dec hex char description +_ +200 128 80 ─ box drawings light horizontal +201 129 81 │ box drawings light vertical +202 130 82 ┌ box drawings light down and right +203 131 83 ┐ box drawings light down and left +204 132 84 └ box drawings light up and right +205 133 85 ┘ box drawings light up and left +206 134 86 ├ box drawings light vertical and right +207 135 87 ┤ box drawings light vertical and left +210 136 88 ┬ box drawings light down and horizontal +211 137 89 ┴ box drawings light up and horizontal +212 138 8a ┼ box drawings light vertical and horizontal +213 139 8b ▀ upper half block +214 140 8c ▄ lower half block +215 141 8d █ full block +216 142 8e ▌ left half block +217 143 8f ▐ right half block +220 144 90 ░ light shade +221 145 91 ▒ medium shade +222 146 92 ▓ dark shade +223 147 93 ⌠ top half integral +224 148 94 ■ black square +225 149 95 ∙ bullet operator +226 150 96 √ square root +227 151 97 ≈ almost equal to +230 152 98 ≤ less-than or equal to +231 153 99 ≥ greater-than or equal to +232 154 9a   no-break space +233 155 9b ⌡ bottom half integral +234 156 9c ° degree sign +235 157 9d ² superscript two +236 158 9e · middle dot +237 159 9f ÷ division sign +240 160 a0 ═ box drawings double horizontal +241 161 a1 ║ box drawings double vertical +242 162 a2 ╒ box drawings down single and right double +243 163 a3 ё cyrillic small letter io +244 164 a4 ╓ box drawings down double and right single +245 165 a5 ╔ box drawings double down and right +246 166 a6 ╕ box drawings down single and left double +247 167 a7 ╖ box drawings down double and left single +250 168 a8 ╗ box drawings double down and left +251 169 a9 ╘ box drawings up single and right double +252 170 aa ╙ box drawings up double and right single +253 171 ab ╚ box drawings double up and right +254 172 ac ╛ box drawings up single and left double +255 173 ad ╜ box drawings up double and left single +256 174 ae ╝ box drawings double up and left +257 175 af ╞ box drawings vertical single and right double +260 176 b0 ╟ box drawings vertical double and right single +261 177 b1 ╠ box drawings double vertical and right +262 178 b2 ╡ box drawings vertical single and left double +263 179 b3 ё cyrillic capital letter io +264 180 b4 ╢ box drawings vertical double and left single +265 181 b5 ╣ box drawings double vertical and left +266 182 b6 ╤ box drawings down single and horizontal double +267 183 b7 ╥ box drawings down double and horizontal single +270 184 b8 ╦ box drawings double down and horizontal +271 185 b9 ╧ box drawings up single and horizontal double +272 186 ba ╨ box drawings up double and horizontal single +273 187 bb ╩ box drawings double up and horizontal +274 188 bc ╪ t{ +box drawings vertical single +.br +and horizontal double +t} +275 189 bd ╫ t{ +box drawings vertical double +.br +and horizontal single +t} +276 190 be ╬ box drawings double vertical and horizontal +277 191 bf © copyright sign +300 192 c0 ю cyrillic small letter yu +301 193 c1 а cyrillic small letter a +302 194 c2 б cyrillic small letter be +303 195 c3 ц cyrillic small letter tse +304 196 c4 д cyrillic small letter de +305 197 c5 е cyrillic small letter ie +306 198 c6 ф cyrillic small letter ef +307 199 c7 г cyrillic small letter ghe +310 200 c8 х cyrillic small letter ha +311 201 c9 и cyrillic small letter i +312 202 ca й cyrillic small letter short i +313 203 cb к cyrillic small letter ka +314 204 cc л cyrillic small letter el +315 205 cd м cyrillic small letter em +316 206 ce н cyrillic small letter en +317 207 cf о cyrillic small letter o +320 208 d0 п cyrillic small letter pe +321 209 d1 я cyrillic small letter ya +322 210 d2 р cyrillic small letter er +323 211 d3 с cyrillic small letter es +324 212 d4 т cyrillic small letter te +325 213 d5 у cyrillic small letter u +326 214 d6 ж cyrillic small letter zhe +327 215 d7 в cyrillic small letter ve +330 216 d8 ь cyrillic small letter soft sign +331 217 d9 ы cyrillic small letter yeru +332 218 da з cyrillic small letter ze +333 219 db ш cyrillic small letter sha +334 220 dc э cyrillic small letter e +335 221 dd щ cyrillic small letter shcha +336 222 de ч cyrillic small letter che +337 223 df ъ cyrillic small letter hard sign +340 224 e0 ю cyrillic capital letter yu +341 225 e1 а cyrillic capital letter a +342 226 e2 б cyrillic capital letter be +343 227 e3 ц cyrillic capital letter tse +344 228 e4 д cyrillic capital letter de +345 229 e5 е cyrillic capital letter ie +346 230 e6 ф cyrillic capital letter ef +347 231 e7 г cyrillic capital letter ghe +350 232 e8 х cyrillic capital letter ha +351 233 e9 и cyrillic capital letter i +352 234 ea й cyrillic capital letter short i +353 235 eb к cyrillic capital letter ka +354 236 ec л cyrillic capital letter el +355 237 ed м cyrillic capital letter em +356 238 ee н cyrillic capital letter en +357 239 ef о cyrillic capital letter o +360 240 f0 п cyrillic capital letter pe +361 241 f1 я cyrillic capital letter ya +362 242 f2 р cyrillic capital letter er +363 243 f3 с cyrillic capital letter es +364 244 f4 т cyrillic capital letter te +365 245 f5 у cyrillic capital letter u +366 246 f6 ж cyrillic capital letter zhe +367 247 f7 в cyrillic capital letter ve +370 248 f8 ь cyrillic capital letter soft sign +371 249 f9 ы cyrillic capital letter yeru +372 250 fa з cyrillic capital letter ze +373 251 fb ш cyrillic capital letter sha +374 252 fc э cyrillic capital letter e +375 253 fd щ cyrillic capital letter shcha +376 254 fe ч cyrillic capital letter che +377 255 ff ъ cyrillic capital letter hard sign +.te +.sh notes +the differences with koi8-u are in the hex positions +a4, a6, a7, ad, b4, b6, b7, and bd. +.sh see also +.br ascii (7), +.br charsets (7), +.br cp1251 (7), +.br iso_8859\-5 (7), +.br koi8\-u (7), +.br utf\-8 (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/endian.3 + +.\" copyright (c) 2006 by michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th adjtime 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +adjtime \- correct the time to synchronize the system clock +.sh synopsis +.nf +.b #include +.pp +.bi "int adjtime(const struct timeval *" delta ", struct timeval *" olddelta ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br adjtime (): +.nf + since glibc 2.19: + _default_source + glibc 2.19 and earlier: + _bsd_source +.fi +.sh description +the +.br adjtime () +function gradually adjusts the system clock (as returned by +.br gettimeofday (2)). +the amount of time by which the clock is to be adjusted is specified +in the structure pointed to by +.ir delta . +this structure has the following form: +.pp +.in +4n +.ex +struct timeval { + time_t tv_sec; /* seconds */ + suseconds_t tv_usec; /* microseconds */ +}; +.ee +.in +.pp +if the adjustment in +.i delta +is positive, then the system clock is speeded up by some +small percentage (i.e., by adding a small +amount of time to the clock value in each second) until the adjustment +has been completed. +if the adjustment in +.i delta +is negative, then the clock is slowed down in a similar fashion. +.pp +if a clock adjustment from an earlier +.br adjtime () +call is already in progress +at the time of a later +.br adjtime () +call, and +.i delta +is not null for the later call, then the earlier adjustment is stopped, +but any already completed part of that adjustment is not undone. +.pp +if +.i olddelta +is not null, then the buffer that it points to is used to return +the amount of time remaining from any previous adjustment that +has not yet been completed. +.sh return value +on success, +.br adjtime () +returns 0. +on failure, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b einval +the adjustment in +.i delta +is outside the permitted range. +.tp +.b eperm +the caller does not have sufficient privilege to adjust the time. +under linux, the +.b cap_sys_time +capability is required. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br adjtime () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +4.3bsd, system v. +.sh notes +the adjustment that +.br adjtime () +makes to the clock is carried out in such a manner that the clock +is always monotonically increasing. +using +.br adjtime () +to adjust the time prevents the problems that can be caused for certain +applications (e.g., +.br make (1)) +by abrupt positive or negative jumps in the system time. +.pp +.br adjtime () +is intended to be used to make small adjustments to the system time. +most systems impose a limit on the adjustment that can be specified in +.ir delta . +in the glibc implementation, +.i delta +must be less than or equal to (int_max / 1000000 \- 2) +and greater than or equal to (int_min / 1000000 + 2) +(respectively 2145 and \-2145 seconds on i386). +.sh bugs +a longstanding bug +.\" http://sourceware.org/bugzilla/show_bug?id=2449 +.\" http://bugzilla.kernel.org/show_bug.cgi?id=6761 +meant that if +.i delta +was specified as null, +no valid information about the outstanding clock adjustment was returned in +.ir olddelta . +(in this circumstance, +.br adjtime () +should return the outstanding clock adjustment, without changing it.) +this bug is fixed +.\" thanks to the new adjtimex() adj_offset_ss_read flag +on systems with glibc 2.8 or later and +linux kernel 2.6.26 or later. +.sh see also +.br adjtimex (2), +.br gettimeofday (2), +.br time (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/ctan.3 + +.\" this page was taken from the 4.4bsd-lite cdrom (bsd license) +.\" +.\" %%%license_start(bsd_oneline_cdrom) +.\" this page was taken from the 4.4bsd-lite cdrom (bsd license) +.\" %%%license_end +.\" +.\" @(#)getrpcent.3n 2.2 88/08/02 4.0 rpcsrc; from 1.11 88/03/14 smi +.th getrpcent 3 2021-03-22 "" "linux programmer's manual" +.sh name +getrpcent, getrpcbyname, getrpcbynumber, setrpcent, endrpcent \- get +rpc entry +.sh synopsis +.nf +.b #include +.pp +.bi "struct rpcent *getrpcent(void);" +.pp +.bi "struct rpcent *getrpcbyname(const char *" name ); +.bi "struct rpcent *getrpcbynumber(int " number ); +.pp +.bi "void setrpcent(int " stayopen ); +.bi "void endrpcent(void);" +.fi +.sh description +the +.br getrpcent (), +.br getrpcbyname (), +and +.br getrpcbynumber () +functions each return a pointer to an object with the +following structure containing the broken-out +fields of an entry in the rpc program number data base. +.pp +.in +4n +.ex +struct rpcent { + char *r_name; /* name of server for this rpc program */ + char **r_aliases; /* alias list */ + long r_number; /* rpc program number */ +}; +.ee +.in +.pp +the members of this structure are: +.tp +.i r_name +the name of the server for this rpc program. +.tp +.i r_aliases +a null-terminated list of alternate names for the rpc program. +.tp +.i r_number +the rpc program number for this service. +.pp +the +.br getrpcent () +function reads the next entry from the database. +a connection is opened to the database if necessary. +.pp +the +.br setrpcent () +function opens a connection to the database, +and sets the next entry to the first entry. +if +.i stayopen +is nonzero, +then the connection to the database +will not be closed between calls to one of the +.br getrpc* () +functions. +.pp +the +.br endrpcent () +function closes the connection to the database. +.pp +the +.br getrpcbyname () +and +.br getrpcbynumber () +functions sequentially search from the beginning +of the file until a matching rpc program name or +program number is found, or until end-of-file is encountered. +.sh return value +on success, +.br getrpcent (), +.br getrpcbyname (), +and +.br getrpcbynumber () +return a pointer to a statically allocated +.i rpcent +structure. +null is returned on eof or error. +.sh files +.tp +.i /etc/rpc +rpc program number database. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br getrpcent (), +.br getrpcbyname (), +.br getrpcbynumber () +t} thread safety mt-unsafe +t{ +.br setrpcent (), +.br endrpcent () +t} thread safety mt-safe locale +.te +.hy +.ad +.sp 1 +.sh conforming to +not in posix.1. +present on the bsds, solaris, and many other systems. +.sh bugs +all information +is contained in a static area +so it must be copied if it is +to be saved. +.sh see also +.br getrpcent_r (3), +.br rpc (5), +.br rpcinfo (8), +.br ypserv (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/fsync.2 + +.\" copyright (c) openbsd group +.\" all rights reserved. +.\" +.\" %%%license_start(bsd_3_clause_ucb) +.\" redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. neither the name of the university nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" this software is provided by the regents and contributors ``as is'' and +.\" any express or implied warranties, including, but not limited to, the +.\" implied warranties of merchantability and fitness for a particular purpose +.\" are disclaimed. in no event shall the regents or contributors be liable +.\" for any direct, indirect, incidental, special, exemplary, or consequential +.\" damages (including, but not limited to, procurement of substitute goods +.\" or services; loss of use, data, or profits; or business interruption) +.\" however caused and on any theory of liability, whether in contract, strict +.\" liability, or tort (including negligence or otherwise) arising in any way +.\" out of the use of this software, even if advised of the possibility of +.\" such damage. +.\" %%%license_end +.\" +.\" converted into a manpage again by martin schulze +.\" +.\" added -lutil remark, 030718 +.\" +.th openpty 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +openpty, login_tty, forkpty \- terminal utility functions +.sh synopsis +.nf +.b #include +.pp +.bi "int openpty(int *" amaster ", int *" aslave ", char *" name , +.bi " const struct termios *" termp , +.bi " const struct winsize *" winp ); +.bi "pid_t forkpty(int *" amaster ", char *" name , +.bi " const struct termios *" termp , +.bi " const struct winsize *" winp ); +.pp +.b #include +.pp +.bi "int login_tty(int " fd ); +.pp +link with \fi\-lutil\fp. +.fi +.sh description +the +.br openpty () +function finds an available pseudoterminal and returns file descriptors +for the master and slave in +.i amaster +and +.ir aslave . +if +.i name +is not null, the filename of the slave is returned in +.ir name . +if +.i termp +is not null, the terminal parameters of the slave will be set to the +values in +.ir termp . +if +.i winp +is not null, the window size of the slave will be set to the values in +.ir winp . +.pp +the +.br login_tty () +function prepares for a login on the terminal +referred to by the file descriptor +.i fd +(which may be a real terminal device, or the slave of a pseudoterminal as +returned by +.br openpty ()) +by creating a new session, making +.i fd +the controlling terminal for the calling process, setting +.i fd +to be the standard input, output, and error streams of the current +process, and closing +.ir fd . +.pp +the +.br forkpty () +function combines +.br openpty (), +.br fork (2), +and +.br login_tty () +to create a new process operating in a pseudoterminal. +a file descriptor referring to +master side of the pseudoterminal is returned in +.ir amaster . +if +.i name +is not null, the buffer it points to is used to return the +filename of the slave. +the +.i termp +and +.i winp +arguments, if not null, +will determine the terminal attributes and window size of the slave +side of the pseudoterminal. +.sh return value +if a call to +.br openpty (), +.br login_tty (), +or +.br forkpty () +is not successful, \-1 is returned and +.i errno +is set to indicate the error. +otherwise, +.br openpty (), +.br login_tty (), +and the child process of +.br forkpty () +return 0, and the parent process of +.br forkpty () +returns the process id of the child process. +.sh errors +.br openpty () +fails if: +.tp +.b enoent +there are no available terminals. +.pp +.br login_tty () +fails if +.br ioctl (2) +fails to set +.i fd +to the controlling terminal of the calling process. +.pp +.br forkpty () +fails if either +.br openpty () +or +.br fork (2) +fails. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br forkpty (), +.br openpty () +t} thread safety mt-safe locale +t{ +.br login_tty () +t} thread safety mt-unsafe race:ttyname +.te +.hy +.ad +.sp 1 +.sh conforming to +these are bsd functions, present in glibc. +they are not standardized in posix. +.sh notes +the +.b const +modifiers were added to the structure pointer arguments of +.br openpty () +and +.br forkpty () +in glibc 2.8. +.pp +in versions of glibc before 2.0.92, +.br openpty () +returns file descriptors for a bsd pseudoterminal pair; +since glibc 2.0.92, +it first attempts to open a unix 98 pseudoterminal pair, +and falls back to opening a bsd pseudoterminal pair if that fails. +.sh bugs +nobody knows how much space should be reserved for +.ir name . +so, calling +.br openpty () +or +.br forkpty () +with non-null +.i name +may not be secure. +.sh see also +.br fork (2), +.br ttyname (3), +.br pty (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/mq_notify.3 +.\" because mq_notify(3) is layered on a system call of the same name + +.so man3/infinity.3 + +.so man3/rpc.3 + +.so man3/malloc_get_state.3 + +.so man3/isalpha.3 + +.\" copyright (c) 1993 by thomas koenig (ig25@rz.uni-karlsruhe.de) +.\" and copyright 2006-2008, michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified sat jul 24 19:27:50 1993 by rik faith (faith@cs.unc.edu) +.\" modified mon aug 30 22:02:34 1995 by jim van zandt +.\" longindex is a pointer, has_arg can take 3 values, using consistent +.\" names for optstring and longindex, "\n" in formats fixed. documenting +.\" opterr and getopt_long_only. clarified explanations (borrowing heavily +.\" from the source code). +.\" modified 8 may 1998 by joseph s. myers (jsm28@cam.ac.uk) +.\" modified 990715, aeb: changed `eof' into `-1' since that is what posix +.\" says; moreover, eof is not defined in . +.\" modified 2002-02-16, joey: added information about nonexistent +.\" option character and colon as first option character +.\" modified 2004-07-28, michael kerrisk +.\" added text to explain how to order both '[-+]' and ':' at +.\" the start of optstring +.\" modified 2006-12-15, mtk, added getopt() example program. +.\" +.th getopt 3 2021-08-27 "gnu" "linux programmer's manual" +.sh name +getopt, getopt_long, getopt_long_only, +optarg, optind, opterr, optopt \- parse command-line options +.sh synopsis +.nf +.b #include +.pp +.bi "int getopt(int " argc ", char *const " argv [], +.bi " const char *" optstring ); +.pp +.bi "extern char *" optarg ; +.bi "extern int " optind ", " opterr ", " optopt ; +.pp +.b #include +.pp +.bi "int getopt_long(int " argc ", char *const " argv [], +.bi " const char *" optstring , +.bi " const struct option *" longopts ", int *" longindex ); +.bi "int getopt_long_only(int " argc ", char *const " argv [], +.bi " const char *" optstring , +.bi " const struct option *" longopts ", int *" longindex ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br getopt (): +.nf + _posix_c_source >= 2 || _xopen_source +.fi +.pp +.br getopt_long (), +.br getopt_long_only (): +.nf + _gnu_source +.fi +.sh description +the +.br getopt () +function parses the command-line arguments. +its arguments +.i argc +and +.i argv +are the argument count and array as passed to the +.ir main () +function on program invocation. +an element of \fiargv\fp that starts with \(aq\-\(aq +(and is not exactly "\-" or "\-\-") +is an option element. +the characters of this element +(aside from the initial \(aq\-\(aq) are option characters. +if +.br getopt () +is called repeatedly, it returns successively each of the option characters +from each of the option elements. +.pp +the variable +.i optind +is the index of the next element to be processed in +.ir argv . +the system initializes this value to 1. +the caller can reset it to 1 to restart scanning of the same +.ir argv , +or when scanning a new argument vector. +.pp +if +.br getopt () +finds another option character, it returns that +character, updating the external variable \fioptind\fp and a static +variable \finextchar\fp so that the next call to +.br getopt () +can +resume the scan with the following option character or +\fiargv\fp-element. +.pp +if there are no more option characters, +.br getopt () +returns \-1. +then \fioptind\fp is the index in \fiargv\fp of the first +\fiargv\fp-element that is not an option. +.pp +.i optstring +is a string containing the legitimate option characters. +a legitimate option character is any visible one byte +.br ascii (7) +character (for which +.br isgraph (3) +would return nonzero) that is not \(aq\-\(aq, \(aq:\(aq, or \(aq;\(aq. +if such a +character is followed by a colon, the option requires an argument, so +.br getopt () +places a pointer to the following text in the same +\fiargv\fp-element, or the text of the following \fiargv\fp-element, in +.ir optarg . +two colons mean an option takes +an optional arg; if there is text in the current \fiargv\fp-element +(i.e., in the same word as the option name itself, for example, "\-oarg"), +then it is returned in \fioptarg\fp, otherwise \fioptarg\fp is set to zero. +this is a gnu extension. +if +.i optstring +contains +.b w +followed by a semicolon, then +.b \-w foo +is treated as the long option +.br \-\-foo . +(the +.b \-w +option is reserved by posix.2 for implementation extensions.) +this behavior is a gnu extension, not available with libraries before +glibc 2. +.pp +by default, +.br getopt () +permutes the contents of \fiargv\fp as it +scans, so that eventually all the nonoptions are at the end. +two other scanning modes are also implemented. +if the first character of +\fioptstring\fp is \(aq+\(aq or the environment variable +.b posixly_correct +is set, then option processing stops as soon as a nonoption argument is +encountered. +if \(aq+\(aq is not the first character of +.ir optstring , +it is treated as a normal option. +if +.b posixly_correct +behaviour is required in this case +.i optstring +will contain two \(aq+\(aq symbols. +if the first character of \fioptstring\fp is \(aq\-\(aq, then +each nonoption \fiargv\fp-element is handled as if it were the argument of +an option with character code 1. +(this is used by programs that were +written to expect options and other \fiargv\fp-elements in any order +and that care about the ordering of the two.) +the special argument "\-\-" forces an end of option-scanning regardless +of the scanning mode. +.pp +while processing the option list, +.br getopt () +can detect two kinds of errors: +(1) an option character that was not specified in +.ir optstring +and (2) a missing option argument +(i.e., an option at the end of the command line without an expected argument). +such errors are handled and reported as follows: +.ip * 3 +by default, +.br getopt () +prints an error message on standard error, +places the erroneous option character in +.ir optopt , +and returns \(aq?\(aq as the function result. +.ip * +if the caller has set the global variable +.ir opterr +to zero, then +.br getopt () +does not print an error message. +the caller can determine that there was an error by testing whether +the function return value is \(aq?\(aq. +(by default, +.ir opterr +has a nonzero value.) +.ip * +if the first character +(following any optional \(aq+\(aq or \(aq\-\(aq described above) +of \fioptstring\fp +is a colon (\(aq:\(aq), then +.br getopt () +likewise does not print an error message. +in addition, it returns \(aq:\(aq instead of \(aq?\(aq to +indicate a missing option argument. +this allows the caller to distinguish the two different types of errors. +.\" +.ss getopt_long() and getopt_long_only() +the +.br getopt_long () +function works like +.br getopt () +except that it also accepts long options, started with two dashes. +(if the program accepts only long options, then +.i optstring +should be specified as an empty string (""), not null.) +long option names may be abbreviated if the abbreviation is +unique or is an exact match for some defined option. +a long option +may take a parameter, of the form +.b \-\-arg=param +or +.br "\-\-arg param" . +.pp +.i longopts +is a pointer to the first element of an array of +.i struct option +declared in +.i +as +.pp +.in +4n +.ex +struct option { + const char *name; + int has_arg; + int *flag; + int val; +}; +.ee +.in +.pp +the meanings of the different fields are: +.tp +.i name +is the name of the long option. +.tp +.i has_arg +is: +\fbno_argument\fp (or 0) if the option does not take an argument; +\fbrequired_argument\fp (or 1) if the option requires an argument; or +\fboptional_argument\fp (or 2) if the option takes an optional argument. +.tp +.i flag +specifies how results are returned for a long option. +if \fiflag\fp +is null, then +.br getopt_long () +returns \fival\fp. +(for example, the calling program may set \fival\fp to the equivalent short +option character.) +otherwise, +.br getopt_long () +returns 0, and +\fiflag\fp points to a variable which is set to \fival\fp if the +option is found, but left unchanged if the option is not found. +.tp +\fival\fp +is the value to return, or to load into the variable pointed +to by \fiflag\fp. +.pp +the last element of the array has to be filled with zeros. +.pp +if \filongindex\fp is not null, it +points to a variable which is set to the index of the long option relative to +.ir longopts . +.pp +.br getopt_long_only () +is like +.br getopt_long (), +but \(aq\-\(aq as well +as "\-\-" can indicate a long option. +if an option that starts with \(aq\-\(aq +(not "\-\-") doesn't match a long option, but does match a short option, +it is parsed as a short option instead. +.sh return value +if an option was successfully found, then +.br getopt () +returns the option character. +if all command-line options have been parsed, then +.br getopt () +returns \-1. +if +.br getopt () +encounters an option character that was not in +.ir optstring , +then \(aq?\(aq is returned. +if +.br getopt () +encounters an option with a missing argument, +then the return value depends on the first character in +.ir optstring : +if it is \(aq:\(aq, then \(aq:\(aq is returned; otherwise \(aq?\(aq is returned. +.pp +.br getopt_long () +and +.br getopt_long_only () +also return the option +character when a short option is recognized. +for a long option, they +return \fival\fp if \fiflag\fp is null, and 0 otherwise. +error and \-1 returns are the same as for +.br getopt (), +plus \(aq?\(aq for an +ambiguous match or an extraneous parameter. +.sh environment +.tp +.b posixly_correct +if this is set, then option processing stops as soon as a nonoption +argument is encountered. +.tp +.b __gnu_nonoption_argv_flags_ +this variable was used by +.br bash (1) +2.0 to communicate to glibc which arguments are the results of +wildcard expansion and so should not be considered as options. +this behavior was removed in +.br bash (1) +version 2.01, but the support remains in glibc. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lb lb lbx +l l l. +interface attribute value +t{ +.br getopt (), +.br getopt_long (), +.br getopt_long_only () +t} thread safety t{ +mt-unsafe race:getopt env +t} +.te +.hy +.ad +.sp 1 +.sh conforming to +.tp +.br getopt (): +posix.1-2001, posix.1-2008, and posix.2, +provided the environment variable +.b posixly_correct +is set. +otherwise, the elements of \fiargv\fp aren't really +.ir const , +because these functions permute them. +nevertheless, +.i const +is used in the prototype to be compatible with other systems. +.ip +the use of \(aq+\(aq and \(aq\-\(aq in +.i optstring +is a gnu extension. +.ip +on some older implementations, +.br getopt () +was declared in +.ir . +susv1 permitted the declaration to appear in either +.i +or +.ir . +posix.1-1996 marked the use of +.i +for this purpose as legacy. +posix.1-2001 does not require the declaration to appear in +.ir . +.tp +.br getopt_long "() and " getopt_long_only (): +these functions are gnu extensions. +.sh notes +a program that scans multiple argument vectors, +or rescans the same vector more than once, +and wants to make use of gnu extensions such as \(aq+\(aq +and \(aq\-\(aq at the start of +.ir optstring , +or changes the value of +.b posixly_correct +between scans, +must reinitialize +.br getopt () +by resetting +.i optind +to 0, rather than the traditional value of 1. +(resetting to 0 forces the invocation of an internal initialization +routine that rechecks +.b posixly_correct +and checks for gnu extensions in +.ir optstring .) +.pp +command-line arguments are parsed in strict order +meaning that an option requiring an argument will consume the next argument, +regardless of whether that argument is the correctly specified option argument +or simply the next option +(in the scenario the user mis-specifies the command line). +for example, if +.i optstring +is specified as "1n:" +and the user specifies the command line arguments incorrectly as +.ir "prog\ \-n\ \-1" , +the +.i \-n +option will be given the +.b optarg +value "\-1", and the +.i \-1 +option will be considered to have not been specified. +.sh examples +.ss getopt() +the following trivial example program uses +.br getopt () +to handle two program options: +.ir \-n , +with no associated value; and +.ir "\-t val" , +which expects an associated value. +.pp +.ex +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + int flags, opt; + int nsecs, tfnd; + + nsecs = 0; + tfnd = 0; + flags = 0; + while ((opt = getopt(argc, argv, "nt:")) != \-1) { + switch (opt) { + case \(aqn\(aq: + flags = 1; + break; + case \(aqt\(aq: + nsecs = atoi(optarg); + tfnd = 1; + break; + default: /* \(aq?\(aq */ + fprintf(stderr, "usage: %s [\-t nsecs] [\-n] name\en", + argv[0]); + exit(exit_failure); + } + } + + printf("flags=%d; tfnd=%d; nsecs=%d; optind=%d\en", + flags, tfnd, nsecs, optind); + + if (optind >= argc) { + fprintf(stderr, "expected argument after options\en"); + exit(exit_failure); + } + + printf("name argument = %s\en", argv[optind]); + + /* other code omitted */ + + exit(exit_success); +} +.ee +.ss getopt_long() +the following example program illustrates the use of +.br getopt_long () +with most of its features. +.pp +.ex +#include /* for printf */ +#include /* for exit */ +#include + +int +main(int argc, char *argv[]) +{ + int c; + int digit_optind = 0; + + while (1) { + int this_option_optind = optind ? optind : 1; + int option_index = 0; + static struct option long_options[] = { + {"add", required_argument, 0, 0 }, + {"append", no_argument, 0, 0 }, + {"delete", required_argument, 0, 0 }, + {"verbose", no_argument, 0, 0 }, + {"create", required_argument, 0, \(aqc\(aq}, + {"file", required_argument, 0, 0 }, + {0, 0, 0, 0 } + }; + + c = getopt_long(argc, argv, "abc:d:012", + long_options, &option_index); + if (c == \-1) + break; + + switch (c) { + case 0: + printf("option %s", long_options[option_index].name); + if (optarg) + printf(" with arg %s", optarg); + printf("\en"); + break; + + case \(aq0\(aq: + case \(aq1\(aq: + case \(aq2\(aq: + if (digit_optind != 0 && digit_optind != this_option_optind) + printf("digits occur in two different argv\-elements.\en"); + digit_optind = this_option_optind; + printf("option %c\en", c); + break; + + case \(aqa\(aq: + printf("option a\en"); + break; + + case \(aqb\(aq: + printf("option b\en"); + break; + + case \(aqc\(aq: + printf("option c with value \(aq%s\(aq\en", optarg); + break; + + case \(aqd\(aq: + printf("option d with value \(aq%s\(aq\en", optarg); + break; + + case \(aq?\(aq: + break; + + default: + printf("?? getopt returned character code 0%o ??\en", c); + } + } + + if (optind < argc) { + printf("non\-option argv\-elements: "); + while (optind < argc) + printf("%s ", argv[optind++]); + printf("\en"); + } + + exit(exit_success); +} +.ee +.sh see also +.br getopt (1), +.br getsubopt (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2017 by michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" +.th network_namespaces 7 2020-06-09 "linux" "linux programmer's manual" +.sh name +network_namespaces \- overview of linux network namespaces +.sh description +network namespaces provide isolation of the system resources associated +with networking: network devices, ipv4 and ipv6 protocol stacks, +ip routing tables, firewall rules, the +.i /proc/net +directory (which is a symbolic link to +.ir /proc/pid/net ), +the +.i /sys/class/net +directory, various files under +.ir /proc/sys/net , +port numbers (sockets), and so on. +in addition, +network namespaces isolate the unix domain abstract socket namespace (see +.br unix (7)). +.pp +a physical network device can live in exactly one +network namespace. +when a network namespace is freed +(i.e., when the last process in the namespace terminates), +its physical network devices are moved back to the +initial network namespace (not to the parent of the process). +.pp +a virtual network +.rb ( veth (4)) +device pair provides a pipe-like abstraction +that can be used to create tunnels between network namespaces, +and can be used to create a bridge to a physical network device +in another namespace. +when a namespace is freed, the +.br veth (4) +devices that it contains are destroyed. +.pp +use of network namespaces requires a kernel that is configured with the +.b config_net_ns +option. +.\" fixme .sh examples +.sh see also +.br nsenter (1), +.br unshare (1), +.br clone (2), +.br veth (4), +.br proc (5), +.br sysfs (5), +.br namespaces (7), +.br user_namespaces (7), +.br brctl (8), +.br ip (8), +.br ip\-address (8), +.br ip\-link (8), +.br ip\-netns (8), +.br iptables (8), +.br ovs\-vsctl (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/sync_file_range.2 + +.so man3/fenv.3 + +.\" copyright (c) 1994 michael haardt (michael@moria.de), 1994-06-04 +.\" copyright (c) 1995 michael haardt +.\" (michael@cantor.informatik.rwth-aachen.de), 1995-03-16 +.\" copyright (c) 1996 andries brouwer (aeb@cwi.nl), 1996-01-13 +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" 1996-01-13 aeb: merged in some text contributed by melvin smith +.\" (msmith@falcon.mercer.peachnet.edu) and various other changes. +.\" modified 1996-05-16 by martin schulze (joey@infodrom.north.de) +.\" +.th perror 3 2021-03-22 "" "linux programmer's manual" +.sh name +perror \- print a system error message +.sh synopsis +.nf +.b #include +.pp +.bi "void perror(const char *" s ); +.pp +.b #include +.pp +.bi "const char *const " sys_errlist []; +.bi "int " sys_nerr ; +.bi "int " errno "; \fr/* not really declared this way; see errno(3) */" +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.ir sys_errlist , +.ir sys_nerr : +.nf + from glibc 2.19 to 2.31: + _default_source + glibc 2.19 and earlier: + _bsd_source +.fi +.sh description +the +.br perror () +function produces a message on standard error describing the last +error encountered during a call to a system or library function. +.pp +first (if +.i s +is not null and +.i *s +is not a null byte (\(aq\e0\(aq)), the argument string +.i s +is printed, followed by a colon and a blank. +then an error message corresponding to the current value of +.i errno +and a new-line. +.pp +to be of most use, the argument string should include the name +of the function that incurred the error. +.pp +the global error list +.ir sys_errlist "[]," +which can be indexed by +.ir errno , +can be used to obtain the error message without the newline. +the largest message number provided in the table is +.ir sys_nerr "\-1." +be careful when directly accessing this list, because new error values +may not have been added to +.ir sys_errlist "[]." +the use of +.ir sys_errlist "[]" +is nowadays deprecated; use +.br strerror (3) +instead. +.pp +when a system call fails, it usually returns \-1 and sets the +variable +.i errno +to a value describing what went wrong. +(these values can be found in +.ir .) +many library functions do likewise. +the function +.br perror () +serves to translate this error code into human-readable form. +note that +.i errno +is undefined after a successful system call or library function call: +this call may well change this variable, even though it succeeds, +for example because it internally used some other library function that failed. +thus, if a failing call is not immediately followed by a call to +.br perror (), +the value of +.i errno +should be saved. +.sh versions +since glibc version 2.32, the declarations of +.i sys_errlist +and +.i sys_nerr +are no longer exposed by +.ir . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br perror () +t} thread safety mt-safe race:stderr +.te +.hy +.ad +.sp 1 +.sh conforming to +.br perror (), +.ir errno : +posix.1-2001, posix.1-2008, c89, c99, 4.3bsd. +.pp +the externals +.i sys_nerr +and +.i sys_errlist +derive from bsd, but are not specified in posix.1. +.sh notes +the externals +.i sys_nerr +and +.i sys_errlist +are defined by glibc, but in +.ir . +.\" and only when _bsd_source is defined. +.\" when +.\" .b _gnu_source +.\" is defined, the symbols +.\" .i _sys_nerr +.\" and +.\" .i _sys_errlist +.\" are provided. +.sh see also +.br err (3), +.br errno (3), +.br error (3), +.br strerror (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +man1/memusagestat.1 +man1/intro.1 +man1/pldd.1 +man1/time.1 +man1/iconv.1 +man1/getent.1 +man1/localedef.1 +man1/memusage.1 +man1/locale.1 +man1/ldd.1 +man1/sprof.1 +man1/mtrace.1 +man2/vserver.2 +man2/rt_sigtimedwait.2 +man2/epoll_pwait.2 +man2/init_module.2 +man2/shmat.2 +man2/process_madvise.2 +man2/perf_event_open.2 +man2/get_robust_list.2 +man2/times.2 +man2/linkat.2 +man2/sched_setattr.2 +man2/sigreturn.2 +man2/perfmonctl.2 +man2/epoll_ctl.2 +man2/add_key.2 +man2/timerfd_gettime.2 +man2/fdetach.2 +man2/alloc_hugepages.2 +man2/getsid.2 +man2/getpagesize.2 +man2/isastream.2 +man2/semget.2 +man2/setfsuid.2 +man2/setuid32.2 +man2/getpgid.2 +man2/mprotect.2 +man2/sched_setaffinity.2 +man2/chroot.2 +man2/rmdir.2 +man2/pread64.2 +man2/rt_tgsigqueueinfo.2 +man2/getcpu.2 +man2/ioctl_fideduperange.2 +man2/lookup_dcookie.2 +man2/getdents.2 +man2/fadvise64.2 +man2/getgroups32.2 +man2/setup.2 +man2/io_getevents.2 +man2/setfsgid32.2 +man2/getpeername.2 +man2/truncate64.2 +man2/_syscall.2 +man2/break.2 +man2/sigaltstack.2 +man2/fanotify_init.2 +man2/ioperm.2 +man2/munmap.2 +man2/getpmsg.2 +man2/unlinkat.2 +man2/mq_unlink.2 +man2/readlinkat.2 +man2/signalfd4.2 +man2/readv.2 +man2/clock_adjtime.2 +man2/sbrk.2 +man2/setxattr.2 +man2/madvise1.2 +man2/getegid32.2 +man2/signalfd.2 +man2/inl.2 +man2/pciconfig_iobase.2 +man2/rt_sigsuspend.2 +man2/setgid.2 +man2/shmop.2 +man2/pidfd_send_signal.2 +man2/removexattr.2 +man2/getdents64.2 +man2/setpgrp.2 +man2/mount.2 +man2/ftruncate.2 +man2/pselect.2 +man2/mknodat.2 +man2/msgctl.2 +man2/utimes.2 +man2/free_hugepages.2 +man2/chown32.2 +man2/preadv.2 +man2/select.2 +man2/pkey_free.2 +man2/seteuid.2 +man2/pselect6.2 +man2/eventfd2.2 +man2/sched_getaffinity.2 +man2/setresuid.2 +man2/exit.2 +man2/spu_run.2 +man2/inl_p.2 +man2/modify_ldt.2 +man2/sysctl.2 +man2/arm_sync_file_range.2 +man2/fchmod.2 +man2/msgget.2 +man2/poll.2 +man2/setreuid.2 +man2/getunwind.2 +man2/inw.2 +man2/mq_timedsend.2 +man2/fallocate.2 +man2/fchdir.2 +man2/ioctl_userfaultfd.2 +man2/set_thread_area.2 +man2/syscall.2 +man2/lchown.2 +man2/getgid.2 +man2/get_kernel_syms.2 +man2/pidfd_open.2 +man2/getresgid.2 +man2/sync.2 +man2/set_tid_address.2 +man2/timer_settime.2 +man2/pause.2 +man2/stty.2 +man2/idle.2 +man2/outb_p.2 +man2/gethostname.2 +man2/readlink.2 +man2/sched_yield.2 +man2/wait3.2 +man2/accept4.2 +man2/sigpending.2 +man2/msgop.2 +man2/ioctl_ficlone.2 +man2/open_by_handle_at.2 +man2/pivot_root.2 +man2/recvmsg.2 +man2/fadvise64_64.2 +man2/query_module.2 +man2/uname.2 +man2/fork.2 +man2/recv.2 +man2/unlink.2 +man2/oldolduname.2 +man2/renameat.2 +man2/rt_sigaction.2 +man2/clock_nanosleep.2 +man2/spu_create.2 +man2/outsw.2 +man2/timer_getoverrun.2 +man2/setregid32.2 +man2/ppoll.2 +man2/move_pages.2 +man2/futimesat.2 +man2/symlinkat.2 +man2/inb.2 +man2/ioctl_ficlonerange.2 +man2/timer_create.2 +man2/process_vm_writev.2 +man2/remap_file_pages.2 +man2/recvmmsg.2 +man2/setrlimit.2 +man2/sgetmask.2 +man2/oldfstat.2 +man2/mq_notify.2 +man2/vm86.2 +man2/epoll_create1.2 +man2/subpage_prot.2 +man2/s390_pci_mmio_read.2 +man2/timer_gettime.2 +man2/getresuid32.2 +man2/faccessat2.2 +man2/fsync.2 +man2/iopl.2 +man2/semop.2 +man2/olduname.2 +man2/sched_rr_get_interval.2 +man2/dup3.2 +man2/__clone2.2 +man2/flock.2 +man2/accept.2 +man2/semctl.2 +man2/signal.2 +man2/sigsuspend.2 +man2/setpgid.2 +man2/clone3.2 +man2/setresgid32.2 +man2/set_mempolicy.2 +man2/s390_guarded_storage.2 +man2/getdomainname.2 +man2/pkey_mprotect.2 +man2/io_submit.2 +man2/s390_pci_mmio_write.2 +man2/putmsg.2 +man2/preadv2.2 +man2/outsb.2 +man2/oldlstat.2 +man2/msync.2 +man2/symlink.2 +man2/link.2 +man2/set_robust_list.2 +man2/kill.2 +man2/setsockopt.2 +man2/setpriority.2 +man2/setfsuid32.2 +man2/getitimer.2 +man2/kexec_load.2 +man2/dup.2 +man2/clone2.2 +man2/get_mempolicy.2 +man2/seccomp_unotify.2 +man2/setuid.2 +man2/setitimer.2 +man2/mpx.2 +man2/lgetxattr.2 +man2/nfsservctl.2 +man2/swapon.2 +man2/epoll_wait.2 +man2/epoll_create.2 +man2/inotify_init.2 +man2/tkill.2 +man2/setgroups32.2 +man2/sendfile64.2 +man2/ioctl_ns.2 +man2/s390_sthyi.2 +man2/getpriority.2 +man2/ioctl.2 +man2/listen.2 +man2/cacheflush.2 +man2/lstat64.2 +man2/mincore.2 +man2/mknod.2 +man2/fcntl64.2 +man2/insl.2 +man2/outw_p.2 +man2/execveat.2 +man2/recvfrom.2 +man2/mlockall.2 +man2/pwritev2.2 +man2/munlockall.2 +man2/ftruncate64.2 +man2/wait.2 +man2/writev.2 +man2/uselib.2 +man2/getsockopt.2 +man2/delete_module.2 +man2/pread.2 +man2/security.2 +man2/pkey_alloc.2 +man2/pipe2.2 +man2/clone.2 +man2/gtty.2 +man2/setresgid.2 +man2/get_thread_area.2 +man2/arch_prctl.2 +man2/socketcall.2 +man2/inb_p.2 +man2/close.2 +man2/mkdirat.2 +man2/timer_delete.2 +man2/vfork.2 +man2/ipc.2 +man2/ioctl_console.2 +man2/swapoff.2 +man2/personality.2 +man2/phys.2 +man2/flistxattr.2 +man2/chmod.2 +man2/lremovexattr.2 +man2/setfsgid.2 +man2/putpmsg.2 +man2/fanotify_mark.2 +man2/madvise.2 +man2/prlimit64.2 +man2/statx.2 +man2/lstat.2 +man2/unshare.2 +man2/keyctl.2 +man2/s390_runtime_instr.2 +man2/newfstatat.2 +man2/settimeofday.2 +man2/llistxattr.2 +man2/pwritev.2 +man2/msgsnd.2 +man2/getrandom.2 +man2/mount_setattr.2 +man2/insw.2 +man2/pciconfig_write.2 +man2/acct.2 +man2/open.2 +man2/pipe.2 +man2/alarm.2 +man2/rt_sigreturn.2 +man2/unimplemented.2 +man2/fchownat.2 +man2/mlock2.2 +man2/umask.2 +man2/fdatasync.2 +man2/inotify_rm_watch.2 +man2/syscalls.2 +man2/fchown.2 +man2/membarrier.2 +man2/stime.2 +man2/sysfs.2 +man2/outb.2 +man2/sched_getattr.2 +man2/sendto.2 +man2/sethostname.2 +man2/renameat2.2 +man2/mlock.2 +man2/outw.2 +man2/mq_getsetattr.2 +man2/gettimeofday.2 +man2/setns.2 +man2/wait4.2 +man2/rt_sigqueueinfo.2 +man2/close_range.2 +man2/utime.2 +man2/getrlimit.2 +man2/kcmp.2 +man2/reboot.2 +man2/eventfd.2 +man2/clock_settime.2 +man2/waitpid.2 +man2/dup2.2 +man2/getppid.2 +man2/lsetxattr.2 +man2/clock_gettime.2 +man2/sync_file_range.2 +man2/umount2.2 +man2/shutdown.2 +man2/brk.2 +man2/openat2.2 +man2/fchmodat.2 +man2/read.2 +man2/sendmsg.2 +man2/mkdir.2 +man2/create_module.2 +man2/futex.2 +man2/getresuid.2 +man2/shmget.2 +man2/waitid.2 +man2/inw_p.2 +man2/_exit.2 +man2/rt_sigpending.2 +man2/mq_open.2 +man2/fattach.2 +man2/chdir.2 +man2/userfaultfd.2 +man2/faccessat.2 +man2/restart_syscall.2 +man2/setreuid32.2 +man2/getegid.2 +man2/adjtimex.2 +man2/getgroups.2 +man2/execve.2 +man2/mremap.2 +man2/tgkill.2 +man2/sigprocmask.2 +man2/memfd_create.2 +man2/rt_sigprocmask.2 +man2/bdflush.2 +man2/clock_getres.2 +man2/fgetxattr.2 +man2/posix_fadvise.2 +man2/getcwd.2 +man2/geteuid.2 +man2/getmsg.2 +man2/fremovexattr.2 +man2/pwrite64.2 +man2/fstatat.2 +man2/setsid.2 +man2/readahead.2 +man2/fstat.2 +man2/afs_syscall.2 +man2/pwrite.2 +man2/timerfd_create.2 +man2/sendmmsg.2 +man2/epoll_pwait2.2 +man2/sysinfo.2 +man2/vhangup.2 +man2/statfs.2 +man2/prof.2 +man2/fcntl.2 +man2/stat64.2 +man2/tee.2 +man2/syslog.2 +man2/tuxcall.2 +man2/mq_timedreceive.2 +man2/_llseek.2 +man2/ioctl_fslabel.2 +man2/gettid.2 +man2/fstatat64.2 +man2/ptrace.2 +man2/getxattr.2 +man2/quotactl.2 +man2/bpf.2 +man2/bind.2 +man2/chown.2 +man2/getsockname.2 +man2/sched_getparam.2 +man2/lseek.2 +man2/getuid32.2 +man2/pciconfig_read.2 +man2/ssetmask.2 +man2/fstatfs64.2 +man2/getresgid32.2 +man2/getpgrp.2 +man2/select_tut.2 +man2/sigwaitinfo.2 +man2/outl.2 +man2/creat.2 +man2/exit_group.2 +man2/ugetrlimit.2 +man2/insb.2 +man2/process_vm_readv.2 +man2/capget.2 +man2/getrusage.2 +man2/setgid32.2 +man2/mbind.2 +man2/ustat.2 +man2/stat.2 +man2/send.2 +man2/splice.2 +man2/lock.2 +man2/timerfd_settime.2 +man2/access.2 +man2/ioprio_set.2 +man2/openat.2 +man2/intro.2 +man2/vmsplice.2 +man2/outl_p.2 +man2/sched_get_priority_min.2 +man2/ioctl_fat.2 +man2/lchown32.2 +man2/io_destroy.2 +man2/statfs64.2 +man2/prctl.2 +man2/socketpair.2 +man2/_newselect.2 +man2/ioprio_get.2 +man2/readdir.2 +man2/_exit.2 +man2/fchown32.2 +man2/migrate_pages.2 +man2/getpid.2 +man2/prlimit.2 +man2/setdomainname.2 +man2/copy_file_range.2 +man2/getuid.2 +man2/time.2 +man2/setregid.2 +man2/request_key.2 +man2/inotify_add_watch.2 +man2/sigtimedwait.2 +man2/pidfd_getfd.2 +man2/capset.2 +man2/llseek.2 +man2/arm_fadvise.2 +man2/write.2 +man2/outsl.2 +man2/munlock.2 +man2/sched_get_priority_max.2 +man2/geteuid32.2 +man2/fsetxattr.2 +man2/ioctl_tty.2 +man2/nice.2 +man2/fstat64.2 +man2/utimensat.2 +man2/listxattr.2 +man2/mmap.2 +man2/shmctl.2 +man2/vm86old.2 +man2/ioctl_getfsmap.2 +man2/shmdt.2 +man2/ioctl_iflags.2 +man2/seccomp.2 +man2/semtimedop.2 +man2/connect.2 +man2/io_cancel.2 +man2/setgroups.2 +man2/finit_module.2 +man2/io_setup.2 +man2/sched_setscheduler.2 +man2/rename.2 +man2/sendfile.2 +man2/mmap2.2 +man2/syncfs.2 +man2/msgrcv.2 +man2/sync_file_range2.2 +man2/name_to_handle_at.2 +man2/umount.2 +man2/inotify_init1.2 +man2/sigaction.2 +man2/arm_fadvise64_64.2 +man2/_sysctl.2 +man2/nanosleep.2 +man2/sched_getscheduler.2 +man2/setegid.2 +man2/fstatfs.2 +man2/kexec_file_load.2 +man2/socket.2 +man2/getgid32.2 +man2/sched_setparam.2 +man2/truncate.2 +man2/oldstat.2 +man2/setresuid32.2 +man3/res_querydomain.3 +man3/pthread_sigqueue.3 +man3/sem_close.3 +man3/strptime.3 +man3/clnt_broadcast.3 +man3/hcreate_r.3 +man3/res_nmkquery.3 +man3/fgetws_unlocked.3 +man3/pthread_attr_setdetachstate.3 +man3/dl_iterate_phdr.3 +man3/qecvt.3 +man3/program_invocation_short_name.3 +man3/acoshf.3 +man3/sgetspent_r.3 +man3/hash.3 +man3/bswap.3 +man3/alphasort.3 +man3/simpleq_insert_head.3 +man3/xdrmem_create.3 +man3/sigwait.3 +man3/slist.3 +man3/explicit_bzero.3 +man3/strerrorname_np.3 +man3/getgrnam.3 +man3/slist_first.3 +man3/tcsendbreak.3 +man3/significand.3 +man3/ffs.3 +man3/realloc.3 +man3/fputs.3 +man3/dlinfo.3 +man3/clogf.3 +man3/lgamma_r.3 +man3/fread_unlocked.3 +man3/pthread_getattr_np.3 +man3/tailq_last.3 +man3/iswpunct.3 +man3/conjl.3 +man3/sys_errlist.3 +man3/nan.3 +man3/mq_open.3 +man3/errno.3 +man3/cacos.3 +man3/localeconv.3 +man3/lcong48.3 +man3/setstate_r.3 +man3/vtimes.3 +man3/execlp.3 +man3/gethostbyname2.3 +man3/pthread_attr_setstack.3 +man3/suseconds_t.3 +man3/cfgetispeed.3 +man3/iswlower.3 +man3/isinff.3 +man3/getwd.3 +man3/pow.3 +man3/sigmask.3 +man3/__ppc_set_ppr_med.3 +man3/localtime.3 +man3/feof_unlocked.3 +man3/catanf.3 +man3/isascii.3 +man3/list_next.3 +man3/getdtablesize.3 +man3/fgetc.3 +man3/xdrrec_eof.3 +man3/sinhl.3 +man3/scalblnf.3 +man3/coshf.3 +man3/setnetgrent.3 +man3/circleq_head_initializer.3 +man3/siglongjmp.3 +man3/isless.3 +man3/clnt_sperrno.3 +man3/circleq_prev.3 +man3/j0l.3 +man3/aio_suspend.3 +man3/l64a.3 +man3/putgrent.3 +man3/clnt_create.3 +man3/isxdigit_l.3 +man3/getcwd.3 +man3/clnt_sperror.3 +man3/fgetspent_r.3 +man3/jn.3 +man3/simpleq_head_initializer.3 +man3/sscanf.3 +man3/erfcf.3 +man3/isupper.3 +man3/putchar.3 +man3/malloc_usable_size.3 +man3/circleq_insert_head.3 +man3/remquol.3 +man3/getrpcent_r.3 +man3/atoq.3 +man3/islessgreater.3 +man3/tcgetattr.3 +man3/toupper.3 +man3/putpwent.3 +man3/regexec.3 +man3/xdrrec_endofrecord.3 +man3/time_t.3 +man3/tfind.3 +man3/svctcp_create.3 +man3/argz_delete.3 +man3/nl_langinfo_l.3 +man3/tolower.3 +man3/pututline.3 +man3/feupdateenv.3 +man3/res_mkquery.3 +man3/strchr.3 +man3/fts_open.3 +man3/fdimf.3 +man3/malloc_get_state.3 +man3/remove.3 +man3/nftw.3 +man3/xdr_getpos.3 +man3/isalpha_l.3 +man3/exit.3 +man3/log2.3 +man3/ftok.3 +man3/gmtime.3 +man3/assert.3 +man3/pthread_equal.3 +man3/fmax.3 +man3/significandl.3 +man3/cbrt.3 +man3/lutimes.3 +man3/nl_langinfo.3 +man3/log1pf.3 +man3/mkostemps.3 +man3/remainder.3 +man3/sinl.3 +man3/slist_empty.3 +man3/getutxid.3 +man3/cpu_free.3 +man3/addseverity.3 +man3/calloc.3 +man3/fesetenv.3 +man3/endaliasent.3 +man3/off_t.3 +man3/malloc_trim.3 +man3/addmntent.3 +man3/bzero.3 +man3/mb_cur_max.3 +man3/llrintf.3 +man3/pthread_mutexattr_setrobust_np.3 +man3/strtok_r.3 +man3/getdelim.3 +man3/llround.3 +man3/isspace.3 +man3/lgamma.3 +man3/xdr_u_char.3 +man3/res_init.3 +man3/mbtowc.3 +man3/va_copy.3 +man3/cfsetispeed.3 +man3/pthread_attr_setstackaddr.3 +man3/free.3 +man3/wctob.3 +man3/pthread_attr_getstackaddr.3 +man3/malloc_stats.3 +man3/tsearch.3 +man3/cacoshf.3 +man3/isnan.3 +man3/csinh.3 +man3/rcmd.3 +man3/clntudp_bufcreate.3 +man3/localtime_r.3 +man3/clock_getcpuclockid.3 +man3/wcscasecmp.3 +man3/void.3 +man3/timerclear.3 +man3/circleq.3 +man3/mb_len_max.3 +man3/clog10.3 +man3/error_at_line.3 +man3/simpleq_init.3 +man3/xdr_callhdr.3 +man3/ctermid.3 +man3/__free_hook.3 +man3/iscntrl.3 +man3/wcspbrk.3 +man3/timezone.3 +man3/strcasestr.3 +man3/ptrdiff_t.3 +man3/pthread_setconcurrency.3 +man3/basename.3 +man3/lround.3 +man3/ftime.3 +man3/fwrite.3 +man3/pthread_kill_other_threads_np.3 +man3/rand.3 +man3/getservent_r.3 +man3/cmsg_space.3 +man3/circleq_foreach_reverse.3 +man3/pthread_mutexattr_setrobust.3 +man3/mq_send.3 +man3/setbuffer.3 +man3/atanf.3 +man3/fread.3 +man3/iconv_close.3 +man3/fexcept_t.3 +man3/ether_aton_r.3 +man3/htobe64.3 +man3/bcmp.3 +man3/authnone_create.3 +man3/tailq_foreach.3 +man3/gnu_dev_makedev.3 +man3/getspnam_r.3 +man3/inet_makeaddr.3 +man3/atol.3 +man3/xdrrec_skiprecord.3 +man3/clnt_perror.3 +man3/mbsnrtowcs.3 +man3/isupper_l.3 +man3/circleq_first.3 +man3/stailq_init.3 +man3/xdr_reference.3 +man3/wctrans.3 +man3/xprt_unregister.3 +man3/regoff_t.3 +man3/key_secretkey_is_set.3 +man3/mmap64.3 +man3/wmemcmp.3 +man3/fabsf.3 +man3/ulckpwdf.3 +man3/isalpha.3 +man3/svcerr_noprog.3 +man3/setlocale.3 +man3/opendir.3 +man3/be64toh.3 +man3/isprint.3 +man3/circleq_loop_next.3 +man3/dlopen.3 +man3/malloc_hook.3 +man3/isprint_l.3 +man3/ntohl.3 +man3/getw.3 +man3/aiocb.3 +man3/circleq_loop_prev.3 +man3/y0f.3 +man3/imaxdiv.3 +man3/ceil.3 +man3/casin.3 +man3/dladdr1.3 +man3/pthread_attr_setsigmask_np.3 +man3/mallopt.3 +man3/fwprintf.3 +man3/pthread_setschedparam.3 +man3/usleep.3 +man3/ynl.3 +man3/erfcl.3 +man3/erfc.3 +man3/siginfo_t.3 +man3/round.3 +man3/ccos.3 +man3/y1.3 +man3/csinl.3 +man3/ctanhf.3 +man3/strerror_l.3 +man3/argz_count.3 +man3/stdarg.3 +man3/sgetspent.3 +man3/qfcvt_r.3 +man3/cabsf.3 +man3/drem.3 +man3/svcerr_auth.3 +man3/getaliasent.3 +man3/modfl.3 +man3/mq_timedreceive.3 +man3/clearerr.3 +man3/xdr_short.3 +man3/ftrylockfile.3 +man3/fgetwc.3 +man3/strnlen.3 +man3/uintptr_t.3 +man3/rewinddir.3 +man3/coshl.3 +man3/expm1f.3 +man3/sprintf.3 +man3/tailq_entry.3 +man3/re_comp.3 +man3/nrand48_r.3 +man3/crypt.3 +man3/slist_head.3 +man3/argz_replace.3 +man3/pthread_mutexattr_destroy.3 +man3/atoll.3 +man3/fegetenv.3 +man3/verrx.3 +man3/fts_read.3 +man3/pmap_unset.3 +man3/inet_netof.3 +man3/ptsname.3 +man3/lrand48.3 +man3/rresvport.3 +man3/backtrace_symbols.3 +man3/endian.3 +man3/strtoq.3 +man3/fmaf.3 +man3/ether_ntohost.3 +man3/isdigit.3 +man3/llabs.3 +man3/list_first.3 +man3/fscanf.3 +man3/htobe16.3 +man3/simpleq_insert_tail.3 +man3/vdprintf.3 +man3/list_entry.3 +man3/svc_sendreply.3 +man3/stailq_head.3 +man3/dlsym.3 +man3/cosl.3 +man3/pthread_mutex_consistent_np.3 +man3/off64_t.3 +man3/isfinite.3 +man3/cmsg_align.3 +man3/hasmntopt.3 +man3/acosf.3 +man3/le64toh.3 +man3/program_invocation_name.3 +man3/sigrelse.3 +man3/nextupf.3 +man3/iswxdigit.3 +man3/valloc.3 +man3/wcsspn.3 +man3/cpu_set_s.3 +man3/uint16_t.3 +man3/toascii.3 +man3/fmal.3 +man3/slist_remove.3 +man3/tcdrain.3 +man3/ctime_r.3 +man3/fgetwc_unlocked.3 +man3/db.3 +man3/setspent.3 +man3/posix_fallocate.3 +man3/snprintf.3 +man3/fcvt.3 +man3/initgroups.3 +man3/mpool.3 +man3/memchr.3 +man3/casinh.3 +man3/wcschr.3 +man3/qsort_r.3 +man3/htobe32.3 +man3/strfromf.3 +man3/fmtmsg.3 +man3/log2f.3 +man3/gcvt.3 +man3/erand48.3 +man3/wcscspn.3 +man3/vsnprintf.3 +man3/fgetws.3 +man3/remquo.3 +man3/getfsfile.3 +man3/execvpe.3 +man3/catclose.3 +man3/clog2f.3 +man3/acosh.3 +man3/atof.3 +man3/strpbrk.3 +man3/iswspace.3 +man3/le16toh.3 +man3/gethostid.3 +man3/pthread_spin_trylock.3 +man3/jrand48_r.3 +man3/xdr_replymsg.3 +man3/stailq_insert_head.3 +man3/strsep.3 +man3/seed48.3 +man3/stailq_foreach.3 +man3/xdr_inline.3 +man3/fdopen.3 +man3/res_query.3 +man3/if_freenameindex.3 +man3/signbit.3 +man3/get_nprocs_conf.3 +man3/lckpwdf.3 +man3/clntudp_create.3 +man3/getc.3 +man3/pthread_cleanup_pop.3 +man3/stailq_insert_after.3 +man3/svcudp_create.3 +man3/memmem.3 +man3/ftello.3 +man3/lgammal_r.3 +man3/isdigit_l.3 +man3/gamma.3 +man3/wcsncasecmp.3 +man3/xdr_opaque_auth.3 +man3/strfry.3 +man3/stailq_concat.3 +man3/sigblock.3 +man3/fclose.3 +man3/csinf.3 +man3/tailq_init.3 +man3/fmin.3 +man3/conjf.3 +man3/getspent.3 +man3/hdestroy_r.3 +man3/getwc_unlocked.3 +man3/rexec.3 +man3/gammal.3 +man3/setttyent.3 +man3/strcasecmp.3 +man3/rpmatch.3 +man3/res_nsearch.3 +man3/srand.3 +man3/sigabbrev_np.3 +man3/int32_t.3 +man3/if_indextoname.3 +man3/ctanhl.3 +man3/svc_getargs.3 +man3/timespec.3 +man3/setkey_r.3 +man3/strdup.3 +man3/pthread_setaffinity_np.3 +man3/lrintl.3 +man3/errx.3 +man3/list_head.3 +man3/fd_clr.3 +man3/float_t.3 +man3/setcontext.3 +man3/mtrace.3 +man3/sigsetops.3 +man3/dlclose.3 +man3/fflush.3 +man3/lgammaf_r.3 +man3/wordfree.3 +man3/fgetpwent.3 +man3/__freading.3 +man3/cmsg_nxthdr.3 +man3/malloc_set_state.3 +man3/key_decryptsession.3 +man3/simpleq_next.3 +man3/getnetgrent.3 +man3/raise.3 +man3/ccoshf.3 +man3/tzset.3 +man3/pthread_attr_setschedpolicy.3 +man3/huge_val.3 +man3/simpleq_remove_head.3 +man3/tailq_first.3 +man3/aio_error.3 +man3/makedev.3 +man3/va_list.3 +man3/inet_net_ntop.3 +man3/envz_entry.3 +man3/strtold.3 +man3/pthread_rwlockattr_getkind_np.3 +man3/timelocal.3 +man3/sincos.3 +man3/gmtime_r.3 +man3/setutent.3 +man3/sysv_signal.3 +man3/dev_t.3 +man3/getgrgid_r.3 +man3/strsignal.3 +man3/rresvport_af.3 +man3/err.3 +man3/getline.3 +man3/mcheck_check_all.3 +man3/circleq_entry.3 +man3/circleq_remove.3 +man3/dn_expand.3 +man3/mq_receive.3 +man3/dlvsym.3 +man3/copysign.3 +man3/strfmon_l.3 +man3/cpu_and_s.3 +man3/fstatvfs.3 +man3/pthread_mutexattr_getrobust.3 +man3/swprintf.3 +man3/getifaddrs.3 +man3/frexp.3 +man3/putc.3 +man3/gethostbyname2_r.3 +man3/getnetent_r.3 +man3/netlink.3 +man3/getopt_long.3 +man3/optind.3 +man3/fgetspent.3 +man3/strncpy.3 +man3/mallinfo.3 +man3/ruserok_af.3 +man3/llroundl.3 +man3/tdelete.3 +man3/qgcvt.3 +man3/minor.3 +man3/sys_siglist.3 +man3/initstate_r.3 +man3/wordexp.3 +man3/svcraw_create.3 +man3/uint32_t.3 +man3/vwarnx.3 +man3/cacosh.3 +man3/getdate_r.3 +man3/_flushlbf.3 +man3/dremf.3 +man3/y0.3 +man3/xdrrec_create.3 +man3/memfrob.3 +man3/pthread_join.3 +man3/freeaddrinfo.3 +man3/encrypt.3 +man3/list_init.3 +man3/getspent_r.3 +man3/fdiml.3 +man3/clnt_call.3 +man3/vscanf.3 +man3/mblen.3 +man3/acos.3 +man3/syslog.3 +man3/aio_cancel.3 +man3/cpu_alloc.3 +man3/posix_madvise.3 +man3/stailq_next.3 +man3/euidaccess.3 +man3/fileno_unlocked.3 +man3/posix_openpt.3 +man3/nextafterl.3 +man3/vsprintf.3 +man3/backtrace_symbols_fd.3 +man3/ccosl.3 +man3/sched_getcpu.3 +man3/sinh.3 +man3/fmodf.3 +man3/nexttoward.3 +man3/svc_getreqset.3 +man3/offsetof.3 +man3/remainderl.3 +man3/tanhf.3 +man3/execle.3 +man3/strrchr.3 +man3/grantpt.3 +man3/cc_t.3 +man3/cpu_count.3 +man3/slist_remove_head.3 +man3/mktime.3 +man3/xdr_opaque.3 +man3/tailq_prev.3 +man3/dysize.3 +man3/cpu_isset.3 +man3/__ppc_get_timebase_freq.3 +man3/key_encryptsession.3 +man3/be16toh.3 +man3/circleq_insert_tail.3 +man3/setenv.3 +man3/inet_lnaof.3 +man3/getloadavg.3 +man3/list_insert_head.3 +man3/wcsncpy.3 +man3/__realloc_hook.3 +man3/uintmax_t.3 +man3/mprobe.3 +man3/ldiv_t.3 +man3/ntohs.3 +man3/fabsl.3 +man3/cimagf.3 +man3/cpu_clr_s.3 +man3/clearerr_unlocked.3 +man3/modff.3 +man3/strncasecmp.3 +man3/va_start.3 +man3/pthread_setcancelstate.3 +man3/futimens.3 +man3/wcsncat.3 +man3/ether_line.3 +man3/tanh.3 +man3/fdopendir.3 +man3/putw.3 +man3/j0f.3 +man3/fts_close.3 +man3/huge_vall.3 +man3/fesetexceptflag.3 +man3/mcheck.3 +man3/random_r.3 +man3/exp2f.3 +man3/tcgetsid.3 +man3/execl.3 +man3/fopencookie.3 +man3/fabs.3 +man3/strtof.3 +man3/tmpfile.3 +man3/sqrtl.3 +man3/psignal.3 +man3/tcsetpgrp.3 +man3/scalbl.3 +man3/pthread_setname_np.3 +man3/abs.3 +man3/sethostent.3 +man3/ecvt.3 +man3/getpw.3 +man3/fileno.3 +man3/putwc_unlocked.3 +man3/list_insert_after.3 +man3/difftime.3 +man3/getfsspec.3 +man3/strftime.3 +man3/xdr_authunix_parms.3 +man3/scalbln.3 +man3/random.3 +man3/cfmakeraw.3 +man3/tgammaf.3 +man3/execvp.3 +man3/stdio.3 +man3/vsscanf.3 +man3/copysignf.3 +man3/wcsdup.3 +man3/xdr_free.3 +man3/xdr_union.3 +man3/ffsl.3 +man3/__fbufsize.3 +man3/get_avphys_pages.3 +man3/clog10l.3 +man3/passwd2des.3 +man3/xdr_setpos.3 +man3/sigandset.3 +man3/wcscat.3 +man3/max.3 +man3/__fsetlocking.3 +man3/ungetwc.3 +man3/svcerr_decode.3 +man3/argz_append.3 +man3/btree.3 +man3/des_failed.3 +man3/strtod.3 +man3/xdr_accepted_reply.3 +man3/llroundf.3 +man3/getutmpx.3 +man3/tailq_insert_head.3 +man3/execv.3 +man3/yn.3 +man3/envz_merge.3 +man3/argz_next.3 +man3/__freadable.3 +man3/strcspn.3 +man3/circleq_foreach.3 +man3/be32toh.3 +man3/pthread_yield.3 +man3/cuserid.3 +man3/ilogbl.3 +man3/error_message_count.3 +man3/res_nsend.3 +man3/htole64.3 +man3/re_exec.3 +man3/alloca.3 +man3/innetgr.3 +man3/sem_init.3 +man3/iconv_open.3 +man3/dladdr.3 +man3/pthread_mutexattr_setpshared.3 +man3/pthread_timedjoin_np.3 +man3/clnt_perrno.3 +man3/endttyent.3 +man3/sigset_t.3 +man3/log2l.3 +man3/wmemmove.3 +man3/atanh.3 +man3/setgrent.3 +man3/strncat.3 +man3/sincosl.3 +man3/tan.3 +man3/mq_getattr.3 +man3/siginterrupt.3 +man3/circleq_init.3 +man3/tcgetpgrp.3 +man3/logbf.3 +man3/svcerr_weakauth.3 +man3/resolver.3 +man3/svcerr_noproc.3 +man3/strverscmp.3 +man3/openlog.3 +man3/assert_perror.3 +man3/xdr_array.3 +man3/vswprintf.3 +man3/cpu_alloc_size.3 +man3/cpu_equal.3 +man3/fmod.3 +man3/lrand48_r.3 +man3/__ppc_mdoom.3 +man3/inet_ntop.3 +man3/gai_cancel.3 +man3/nearbyint.3 +man3/xdr_double.3 +man3/pathconf.3 +man3/getprotobynumber_r.3 +man3/sethostid.3 +man3/pthread_testcancel.3 +man3/isgreater.3 +man3/cpowl.3 +man3/fcvt_r.3 +man3/htole32.3 +man3/wcsstr.3 +man3/des_crypt.3 +man3/endnetent.3 +man3/uselocale.3 +man3/strchrnul.3 +man3/endrpcent.3 +man3/getwchar_unlocked.3 +man3/__memalign_hook.3 +man3/intptr_t.3 +man3/warnx.3 +man3/callrpc.3 +man3/tcflow.3 +man3/qfcvt.3 +man3/scanf.3 +man3/atanhl.3 +man3/mq_close.3 +man3/sigaddset.3 +man3/hypot.3 +man3/memmove.3 +man3/pthread_cancel.3 +man3/cpu_and.3 +man3/lockf.3 +man3/setpwent.3 +man3/expf.3 +man3/strfmon.3 +man3/clntraw_create.3 +man3/sigsetjmp.3 +man3/bswap_32.3 +man3/eventfd_write.3 +man3/gai_strerror.3 +man3/drand48_r.3 +man3/pmap_set.3 +man3/csinhl.3 +man3/atanhf.3 +man3/getchar.3 +man3/a64l.3 +man3/tanl.3 +man3/inet_addr.3 +man3/slist_entry.3 +man3/fputs_unlocked.3 +man3/floorf.3 +man3/timegm.3 +man3/sysconf.3 +man3/cbrtf.3 +man3/cpu_zero_s.3 +man3/lgammaf.3 +man3/gnu_dev_major.3 +man3/dirfd.3 +man3/circleq_last.3 +man3/bsd_signal.3 +man3/powl.3 +man3/fdim.3 +man3/undocumented.3 +man3/wcscmp.3 +man3/queue.3 +man3/gethostent_r.3 +man3/fexecve.3 +man3/auth_destroy.3 +man3/bcopy.3 +man3/bsearch.3 +man3/casinhf.3 +man3/getservbyname_r.3 +man3/iruserok_af.3 +man3/__fpurge.3 +man3/bswap_64.3 +man3/list_empty.3 +man3/getdirentries.3 +man3/if_nameindex.3 +man3/cpow.3 +man3/cacoshl.3 +man3/xdr_u_short.3 +man3/getenv.3 +man3/isinf.3 +man3/group_member.3 +man3/res_search.3 +man3/aio_read.3 +man3/getaddrinfo.3 +man3/scalbnf.3 +man3/wctype.3 +man3/freehostent.3 +man3/vprintf.3 +man3/cexp2.3 +man3/lroundl.3 +man3/on_exit.3 +man3/endmntent.3 +man3/recno.3 +man3/intro.3 +man3/putchar_unlocked.3 +man3/argz_create.3 +man3/ether_aton.3 +man3/catgets.3 +man3/cos.3 +man3/nearbyintl.3 +man3/get_myaddress.3 +man3/endfsent.3 +man3/cfgetospeed.3 +man3/imaxabs.3 +man3/putwchar.3 +man3/freopen.3 +man3/cfsetspeed.3 +man3/stpncpy.3 +man3/clock_t.3 +man3/strdupa.3 +man3/strtouq.3 +man3/sem_destroy.3 +man3/cprojf.3 +man3/memrchr.3 +man3/hsearch.3 +man3/xencrypt.3 +man3/cosf.3 +man3/getprotobynumber.3 +man3/scandirat.3 +man3/casinhl.3 +man3/simpleq_empty.3 +man3/getservbyname.3 +man3/truncf.3 +man3/roundf.3 +man3/clnt_spcreateerror.3 +man3/cargl.3 +man3/getrpcent.3 +man3/backtrace.3 +man3/cmsg_len.3 +man3/fputc.3 +man3/finite.3 +man3/argz_insert.3 +man3/getaliasbyname_r.3 +man3/getpwnam_r.3 +man3/y1l.3 +man3/regex_t.3 +man3/ldexp.3 +man3/logwtmp.3 +man3/envz_get.3 +man3/jnl.3 +man3/vfprintf.3 +man3/vlimit.3 +man3/envz_add.3 +man3/bstring.3 +man3/abort.3 +man3/va_end.3 +man3/int16_t.3 +man3/timercmp.3 +man3/truncl.3 +man3/__after_morecore_hook.3 +man3/casinl.3 +man3/strcat.3 +man3/envz.3 +man3/lsearch.3 +man3/catanh.3 +man3/key_gendes.3 +man3/tzname.3 +man3/jrand48.3 +man3/getttynam.3 +man3/fcloseall.3 +man3/login_tty.3 +man3/gammaf.3 +man3/getusershell.3 +man3/argz_stringify.3 +man3/htons.3 +man3/vsyslog.3 +man3/strerror_r.3 +man3/fmaxf.3 +man3/isascii_l.3 +man3/ldexpl.3 +man3/xdr_bool.3 +man3/getopt_long_only.3 +man3/gai_suspend.3 +man3/gethostent.3 +man3/tailq_empty.3 +man3/rtime.3 +man3/fegetexcept.3 +man3/list_head_initializer.3 +man3/qecvt_r.3 +man3/feraiseexcept.3 +man3/strtoll.3 +man3/rintf.3 +man3/cpu_clr.3 +man3/simpleq_first.3 +man3/warn.3 +man3/insque.3 +man3/drand48.3 +man3/index.3 +man3/cabs.3 +man3/asinhf.3 +man3/perror.3 +man3/ctanh.3 +man3/sem_getvalue.3 +man3/gnu_dev_minor.3 +man3/setlinebuf.3 +man3/isalnum_l.3 +man3/getnetbyaddr.3 +man3/updwtmp.3 +man3/wcstombs.3 +man3/getrpcport.3 +man3/towlower_l.3 +man3/stailq_head_initializer.3 +man3/stailq_empty.3 +man3/puts.3 +man3/xdr_pmap.3 +man3/le32toh.3 +man3/pthread_create.3 +man3/mkstemp.3 +man3/hdestroy.3 +man3/wcpcpy.3 +man3/fts_set.3 +man3/simpleq_insert_after.3 +man3/ferror_unlocked.3 +man3/pthread_attr_getdetachstate.3 +man3/iswgraph.3 +man3/bswap_16.3 +man3/pthread_attr_getscope.3 +man3/simpleq.3 +man3/get_phys_pages.3 +man3/getipnodebyname.3 +man3/end.3 +man3/glob.3 +man3/expm1.3 +man3/pthread_attr_setscope.3 +man3/uint8_t.3 +man3/asprintf.3 +man3/ctime.3 +man3/scalbn.3 +man3/islower.3 +man3/sigemptyset.3 +man3/mbsinit.3 +man3/sem_unlink.3 +man3/argz_add.3 +man3/clnt_geterr.3 +man3/sem_trywait.3 +man3/tailq_head_initializer.3 +man3/atexit.3 +man3/__ppc_set_ppr_med_low.3 +man3/strndupa.3 +man3/lrint.3 +man3/seed48_r.3 +man3/strncmp.3 +man3/sigignore.3 +man3/aio_fsync.3 +man3/iswalpha.3 +man3/sigset.3 +man3/tempnam.3 +man3/towupper_l.3 +man3/wcslen.3 +man3/readdir.3 +man3/cpu_or.3 +man3/logb.3 +man3/cacosl.3 +man3/circleq_insert_before.3 +man3/ldexpf.3 +man3/strspn.3 +man3/ttyname.3 +man3/cfree.3 +man3/nexttowardl.3 +man3/cpu_zero.3 +man3/unsetenv.3 +man3/cpu_xor.3 +man3/catanhl.3 +man3/getservbyport.3 +man3/xdr_enum.3 +man3/clock.3 +man3/flockfile.3 +man3/pthread_setcanceltype.3 +man3/exp10l.3 +man3/pmap_getport.3 +man3/getcontext.3 +man3/getaddrinfo_a.3 +man3/strtol.3 +man3/dreml.3 +man3/setutxent.3 +man3/endnetgrent.3 +man3/res_ninit.3 +man3/cacosf.3 +man3/clnttcp_create.3 +man3/fgetc_unlocked.3 +man3/getc_unlocked.3 +man3/simpleq_entry.3 +man3/__ppc_set_ppr_med_high.3 +man3/regcomp.3 +man3/aio_write.3 +man3/wctomb.3 +man3/tgammal.3 +man3/fmaxl.3 +man3/timeval.3 +man3/setservent.3 +man3/ilogb.3 +man3/error_print_progname.3 +man3/circleq_insert_after.3 +man3/xdr_string.3 +man3/significandf.3 +man3/strlen.3 +man3/sys_nerr.3 +man3/fgetpos.3 +man3/slist_foreach.3 +man3/atanl.3 +man3/argz_add_sep.3 +man3/rpc.3 +man3/argz_create_sep.3 +man3/carg.3 +man3/sinf.3 +man3/fflush_unlocked.3 +man3/freelocale.3 +man3/btowc.3 +man3/fedisableexcept.3 +man3/get_nprocs.3 +man3/feclearexcept.3 +man3/svcerr_progvers.3 +man3/isgraph.3 +man3/mkdtemp.3 +man3/putwchar_unlocked.3 +man3/acosl.3 +man3/qsort.3 +man3/twalk_r.3 +man3/iswblank.3 +man3/tailq_concat.3 +man3/getdate.3 +man3/pvalloc.3 +man3/towlower.3 +man3/wmempcpy.3 +man3/dn_comp.3 +man3/wmemset.3 +man3/shm_open.3 +man3/ntp_adjtime.3 +man3/lrintf.3 +man3/nextdownl.3 +man3/cosh.3 +man3/mq_setattr.3 +man3/pthread_attr_getstacksize.3 +man3/stailq.3 +man3/wcsrtombs.3 +man3/setaliasent.3 +man3/div.3 +man3/argz_extract.3 +man3/fpurge.3 +man3/verr.3 +man3/nextupl.3 +man3/expl.3 +man3/fputc_unlocked.3 +man3/catan.3 +man3/hcreate.3 +man3/gets.3 +man3/pmap_rmtcall.3 +man3/res_nquery.3 +man3/fprintf.3 +man3/getprotobyname_r.3 +man3/ctanf.3 +man3/acoshl.3 +man3/xdr_char.3 +man3/ceilf.3 +man3/crealf.3 +man3/blksize_t.3 +man3/stailq_first.3 +man3/strtoull.3 +man3/pow10l.3 +man3/des_setparity.3 +man3/nrand48.3 +man3/scalbnl.3 +man3/setbuf.3 +man3/mktemp.3 +man3/nexttowardf.3 +man3/lfind.3 +man3/rintl.3 +man3/ctanl.3 +man3/key_setsecret.3 +man3/longjmp.3 +man3/uint64_t.3 +man3/setstate.3 +man3/slist_next.3 +man3/iswprint.3 +man3/__malloc_hook.3 +man3/getutxent.3 +man3/getnetbyaddr_r.3 +man3/tcsetattr.3 +man3/sigfillset.3 +man3/fopen.3 +man3/strtoumax.3 +man3/isunordered.3 +man3/sqrt.3 +man3/versionsort.3 +man3/pthread_attr_setschedparam.3 +man3/pthread_attr_setstacksize.3 +man3/cpu_set.3 +man3/gethostbyname.3 +man3/iconv.3 +man3/opterr.3 +man3/lio_listio.3 +man3/timer_t.3 +man3/unlockpt.3 +man3/strtoul.3 +man3/logl.3 +man3/daylight.3 +man3/id_t.3 +man3/copysignl.3 +man3/cimag.3 +man3/rint.3 +man3/asin.3 +man3/islessequal.3 +man3/pthread_detach.3 +man3/feenableexcept.3 +man3/fmemopen.3 +man3/stderr.3 +man3/strtoimax.3 +man3/telldir.3 +man3/res_nclose.3 +man3/__setfpucw.3 +man3/getpwuid.3 +man3/login.3 +man3/isnanl.3 +man3/fts.3 +man3/pthread_attr_getschedpolicy.3 +man3/__fpending.3 +man3/nextdownf.3 +man3/fgets_unlocked.3 +man3/printf.3 +man3/shm_unlink.3 +man3/readdir_r.3 +man3/endutent.3 +man3/lgammal.3 +man3/simpleq_foreach.3 +man3/iswdigit.3 +man3/uid_t.3 +man3/atan2f.3 +man3/optopt.3 +man3/asctime.3 +man3/nextdown.3 +man3/mbsrtowcs.3 +man3/strerror.3 +man3/gnu_get_libc_release.3 +man3/mkfifo.3 +man3/pthread_spin_unlock.3 +man3/svcerr_systemerr.3 +man3/ssize_t.3 +man3/__fwriting.3 +man3/gsignal.3 +man3/atoi.3 +man3/psiginfo.3 +man3/pthread_getname_np.3 +man3/srandom.3 +man3/labs.3 +man3/simpleq_remove.3 +man3/blkcnt_t.3 +man3/confstr.3 +man3/eventfd_read.3 +man3/getaliasent_r.3 +man3/clearenv.3 +man3/rawmemchr.3 +man3/sigval.3 +man3/inet_network.3 +man3/sigdelset.3 +man3/sighold.3 +man3/fnmatch.3 +man3/strcmp.3 +man3/duplocale.3 +man3/log1p.3 +man3/ntp_gettimex.3 +man3/fwide.3 +man3/htole16.3 +man3/pthread_attr_destroy.3 +man3/wcswidth.3 +man3/creall.3 +man3/sigvec.3 +man3/log10f.3 +man3/gid_t.3 +man3/adjtime.3 +man3/wcstok.3 +man3/__ppc_get_timebase.3 +man3/getfsent.3 +man3/isgraph_l.3 +man3/setlogmask.3 +man3/pthread_exit.3 +man3/rexec_af.3 +man3/sigstack.3 +man3/popen.3 +man3/asinl.3 +man3/fegetround.3 +man3/feholdexcept.3 +man3/timerisset.3 +man3/getutxline.3 +man3/wcwidth.3 +man3/endservent.3 +man3/logout.3 +man3/ynf.3 +man3/endprotoent.3 +man3/lldiv.3 +man3/getentropy.3 +man3/cmsg_data.3 +man3/memcpy.3 +man3/feof.3 +man3/mrand48.3 +man3/ispunct_l.3 +man3/fesetround.3 +man3/log1pl.3 +man3/openpty.3 +man3/ispunct.3 +man3/aio_init.3 +man3/fegetexceptflag.3 +man3/cabsl.3 +man3/j1.3 +man3/catanl.3 +man3/tailq_remove.3 +man3/circleq_head.3 +man3/casinf.3 +man3/fpclassify.3 +man3/cpowf.3 +man3/ualarm.3 +man3/inet_ntoa.3 +man3/fgetgrent_r.3 +man3/pthread_setattr_default_np.3 +man3/getutid_r.3 +man3/log10l.3 +man3/xdr_vector.3 +man3/getpwuid_r.3 +man3/getpt.3 +man3/trunc.3 +man3/stdout.3 +man3/xdr_pointer.3 +man3/sigsetmask.3 +man3/pthread_attr_getguardsize.3 +man3/sin.3 +man3/getutmp.3 +man3/getauxval.3 +man3/isspace_l.3 +man3/fseeko.3 +man3/xdr_void.3 +man3/fgets.3 +man3/getutline.3 +man3/sincosf.3 +man3/iruserok.3 +man3/stailq_remove_head.3 +man3/cbc_crypt.3 +man3/fd_set.3 +man3/pthread_getattr_default_np.3 +man3/cprojl.3 +man3/klogctl.3 +man3/cpu_xor_s.3 +man3/tailq_head.3 +man3/getservent.3 +man3/sqrtf.3 +man3/getgrent.3 +man3/svc_destroy.3 +man3/circleq_next.3 +man3/rtnetlink.3 +man3/wcrtomb.3 +man3/llrint.3 +man3/error_one_per_line.3 +man3/xdrstdio_create.3 +man3/fenv.3 +man3/mode_t.3 +man3/res_nquerydomain.3 +man3/registerrpc.3 +man3/getprotoent.3 +man3/fts_children.3 +man3/log.3 +man3/fminf.3 +man3/getopt.3 +man3/fputwc.3 +man3/isnanf.3 +man3/posix_spawn.3 +man3/simpleq_head.3 +man3/wmemcpy.3 +man3/memalign.3 +man3/getnameinfo.3 +man3/scalblnl.3 +man3/getlogin.3 +man3/seekdir.3 +man3/pmap_getmaps.3 +man3/tanf.3 +man3/inet_aton.3 +man3/globfree.3 +man3/pthread_attr_getaffinity_np.3 +man3/ruserok.3 +man3/ntp_gettime.3 +man3/iswcntrl.3 +man3/malloc.3 +man3/signgam.3 +man3/list_insert_before.3 +man3/envz_remove.3 +man3/pthread_attr_setaffinity_np.3 +man3/cmsg.3 +man3/iswctype.3 +man3/clog10f.3 +man3/dlmopen.3 +man3/memcmp.3 +man3/cpu_equal_s.3 +man3/strcpy.3 +man3/timeradd.3 +man3/fd_isset.3 +man3/putwc.3 +man3/clog.3 +man3/htonl.3 +man3/envz_strip.3 +man3/byteorder.3 +man3/asinf.3 +man3/getrpcbyname_r.3 +man3/pclose.3 +man3/fma.3 +man3/getpwent_r.3 +man3/pthread_spin_lock.3 +man3/nextafterf.3 +man3/pthread_mutexattr_init.3 +man3/towctrans.3 +man3/ftell.3 +man3/wcstoimax.3 +man3/pthread_cleanup_pop_restore_np.3 +man3/closelog.3 +man3/sigorset.3 +man3/dirname.3 +man3/tolower_l.3 +man3/secure_getenv.3 +man3/aio_return.3 +man3/huge_valf.3 +man3/slist_head_initializer.3 +man3/ctan.3 +man3/xdecrypt.3 +man3/svc_freeargs.3 +man3/ecvt_r.3 +man3/exp2.3 +man3/cexp.3 +man3/fwrite_unlocked.3 +man3/slist_insert_after.3 +man3/strfromd.3 +man3/cpu_or_s.3 +man3/ssignal.3 +man3/sigqueue.3 +man3/vasprintf.3 +man3/fenv_t.3 +man3/min.3 +man3/getpwnam.3 +man3/setnetent.3 +man3/nanf.3 +man3/svc_run.3 +man3/ilogbf.3 +man3/clnt_destroy.3 +man3/tmpnam_r.3 +man3/csqrtl.3 +man3/lroundf.3 +man3/pthread_getcpuclockid.3 +man3/tcflush.3 +man3/towupper.3 +man3/fd_zero.3 +man3/isfdtype.3 +man3/iswupper.3 +man3/eaccess.3 +man3/fgetpwent_r.3 +man3/expm1l.3 +man3/pthread_atfork.3 +man3/cpu_isset_s.3 +man3/pthread_spin_destroy.3 +man3/srand48_r.3 +man3/pthread_getschedparam.3 +man3/scalb.3 +man3/canonicalize_file_name.3 +man3/getpwent.3 +man3/setkey.3 +man3/svcfd_create.3 +man3/__ppc_set_ppr_low.3 +man3/ttyname_r.3 +man3/pthread_mutexattr_getpshared.3 +man3/lconv.3 +man3/logf.3 +man3/regerror.3 +man3/putenv.3 +man3/ccosf.3 +man3/wcstoumax.3 +man3/getwc.3 +man3/endutxent.3 +man3/strtok.3 +man3/pthread_getaffinity_np.3 +man3/xdr_int.3 +man3/xdr_u_int.3 +man3/strerrordesc_np.3 +man3/xdr_destroy.3 +man3/inet_net_pton.3 +man3/cexpf.3 +man3/vfscanf.3 +man3/ccoshl.3 +man3/finitel.3 +man3/sigpause.3 +man3/tailq_insert_after.3 +man3/mbrlen.3 +man3/mkostemp.3 +man3/getlogin_r.3 +man3/frexpf.3 +man3/erf.3 +man3/setmntent.3 +man3/pthread_cleanup_push_defer_np.3 +man3/reallocarray.3 +man3/uintn_t.3 +man3/clnt_freeres.3 +man3/memset.3 +man3/xdr_u_long.3 +man3/siggetmask.3 +man3/optarg.3 +man3/srand48.3 +man3/sigisemptyset.3 +man3/xprt_register.3 +man3/strcoll.3 +man3/gai_error.3 +man3/nextafter.3 +man3/setfsent.3 +man3/setprotoent.3 +man3/endhostent.3 +man3/getgrnam_r.3 +man3/wprintf.3 +man3/sinhf.3 +man3/statvfs.3 +man3/ffsll.3 +man3/pthread_spin_init.3 +man3/strstr.3 +man3/roundl.3 +man3/getmntent.3 +man3/y0l.3 +man3/wcsnlen.3 +man3/memccpy.3 +man3/xcrypt.3 +man3/list_foreach.3 +man3/mrand48_r.3 +man3/getnetgrent_r.3 +man3/mkfifoat.3 +man3/inet.3 +man3/int8_t.3 +man3/major.3 +man3/list.3 +man3/endgrent.3 +man3/cfsetospeed.3 +man3/exp2l.3 +man3/sigdescr_np.3 +man3/scalbf.3 +man3/tailq_insert_tail.3 +man3/catanhf.3 +man3/dlerror.3 +man3/xdr_rejected_reply.3 +man3/getutid.3 +man3/dbopen.3 +man3/getprotobyname.3 +man3/clockid_t.3 +man3/sem_post.3 +man3/fseek.3 +man3/stdin.3 +man3/stailq_insert_tail.3 +man3/csin.3 +man3/ttyslot.3 +man3/exp10.3 +man3/unlocked_stdio.3 +man3/__flbf.3 +man3/tailq.3 +man3/isxdigit.3 +man3/fetestexcept.3 +man3/getprotoent_r.3 +man3/file.3 +man3/gethostbyname_r.3 +man3/log10.3 +man3/updwtmpx.3 +man3/powf.3 +man3/pthread_attr_setguardsize.3 +man3/nearbyintf.3 +man3/getipnodebyaddr.3 +man3/wcsnrtombs.3 +man3/xdr_pmaplist.3 +man3/atan.3 +man3/mcheck_pedantic.3 +man3/erfl.3 +man3/isatty.3 +man3/scandir.3 +man3/remainderf.3 +man3/endspent.3 +man3/size_t.3 +man3/fminl.3 +man3/mq_timedsend.3 +man3/hypotl.3 +man3/open_wmemstream.3 +man3/__ppc_yield.3 +man3/asctime_r.3 +man3/ether_hostton.3 +man3/cexpl.3 +man3/fmodl.3 +man3/swab.3 +man3/vwarn.3 +man3/sem_wait.3 +man3/__ppc_set_ppr_very_low.3 +man3/remquof.3 +man3/muntrace.3 +man3/getrpcbynumber_r.3 +man3/bindresvport.3 +man3/j1l.3 +man3/finitef.3 +man3/stailq_remove.3 +man3/islower_l.3 +man3/h_errno.3 +man3/tgamma.3 +man3/tmpnam.3 +man3/ccosh.3 +man3/sockatmark.3 +man3/nextup.3 +man3/setrpcent.3 +man3/fputws_unlocked.3 +man3/cimagl.3 +man3/j1f.3 +man3/get_current_dir_name.3 +man3/mq_notify.3 +man3/getgrent_r.3 +man3/cexp2l.3 +man3/ether_ntoa_r.3 +man3/utmpname.3 +man3/pthread_attr_setinheritsched.3 +man3/malloc_info.3 +man3/getutline_r.3 +man3/getutent.3 +man3/vwprintf.3 +man3/getnetbyname.3 +man3/regmatch_t.3 +man3/remque.3 +man3/exec.3 +man3/futimes.3 +man3/gethostbyaddr_r.3 +man3/timersub.3 +man3/getmntent_r.3 +man3/csqrt.3 +man3/hstrerror.3 +man3/ungetc.3 +man3/gethostbyaddr.3 +man3/pthread_kill.3 +man3/wcsncmp.3 +man3/pthread_attr_getsigmask_np.3 +man3/sem_open.3 +man3/inet_pton.3 +man3/svc_getreq.3 +man3/pthread_attr_init.3 +man3/svc_register.3 +man3/pthread_attr_getinheritsched.3 +man3/res_send.3 +man3/closedir.3 +man3/sockaddr.3 +man3/asinh.3 +man3/strxfrm.3 +man3/stailq_entry.3 +man3/getgrouplist.3 +man3/asinhl.3 +man3/termios.3 +man3/exp.3 +man3/clog2.3 +man3/cpu_count_s.3 +man3/crypt_r.3 +man3/makecontext.3 +man3/posix_spawnp.3 +man3/newlocale.3 +man3/pow10.3 +man3/hsearch_r.3 +man3/strndup.3 +man3/slist_init.3 +man3/cbrtl.3 +man3/fputwc_unlocked.3 +man3/xdr_wrapstring.3 +man3/funlockfile.3 +man3/fputws.3 +man3/wmemchr.3 +man3/rcmd_af.3 +man3/getwchar.3 +man3/pthread_tryjoin_np.3 +man3/mbstowcs.3 +man3/rindex.3 +man3/sigismember.3 +man3/csqrtf.3 +man3/getservbyport_r.3 +man3/isinfl.3 +man3/lseek64.3 +man3/clog2l.3 +man3/sleep.3 +man3/slist_insert_head.3 +man3/endpwent.3 +man3/twalk.3 +man3/jnf.3 +man3/cexp2f.3 +man3/fgetgrent.3 +man3/logbl.3 +man3/cproj.3 +man3/getnetbyname_r.3 +man3/xdr.3 +man3/isnormal.3 +man3/double_t.3 +man3/mempcpy.3 +man3/erand48_r.3 +man3/stdio_ext.3 +man3/profil.3 +man3/authunix_create.3 +man3/ceill.3 +man3/stpcpy.3 +man3/etext.3 +man3/strfroml.3 +man3/pthread_attr_getschedparam.3 +man3/xdr_callmsg.3 +man3/catopen.3 +man3/cargf.3 +man3/__fwritable.3 +man3/if_nametoindex.3 +man3/tailq_next.3 +man3/getrpcbynumber.3 +man3/atan2l.3 +man3/pthread_rwlockattr_setkind_np.3 +man3/getttyent.3 +man3/pthread_getconcurrency.3 +man3/frexpl.3 +man3/tailq_insert_before.3 +man3/getutent_r.3 +man3/isgreaterequal.3 +man3/floor.3 +man3/svc_getcaller.3 +man3/circleq_empty.3 +man3/setjmp.3 +man3/regfree.3 +man3/dprintf.3 +man3/mq_unlink.3 +man3/getchar_unlocked.3 +man3/__ppc_mdoio.3 +man3/pow10f.3 +man3/pthread_mutexattr_getrobust_np.3 +man3/putc_unlocked.3 +man3/socklen_t.3 +man3/forkpty.3 +man3/int64_t.3 +man3/mallinfo2.3 +man3/getsubopt.3 +man3/j0.3 +man3/encrypt_r.3 +man3/atan2.3 +man3/vfwprintf.3 +man3/iswalnum.3 +man3/list_remove.3 +man3/pthread_setschedprio.3 +man3/ecb_crypt.3 +man3/getpass.3 +man3/pthread_sigmask.3 +man3/getnetent.3 +man3/tdestroy.3 +man3/y1f.3 +man3/getrpcbyname.3 +man3/isblank_l.3 +man3/floorl.3 +man3/tailq_foreach_reverse.3 +man3/pthread_mutex_consistent.3 +man3/setvbuf.3 +man3/exp10f.3 +man3/getgrgid.3 +man3/wcpncpy.3 +man3/realpath.3 +man3/ferror.3 +man3/intmax_t.3 +man3/rand_r.3 +man3/herror.3 +man3/aligned_alloc.3 +man3/setusershell.3 +man3/pthread_self.3 +man3/pthread_cleanup_push.3 +man3/hypotf.3 +man3/creal.3 +man3/edata.3 +man3/ptsname_r.3 +man3/pututxline.3 +man3/fpathconf.3 +man3/open_memstream.3 +man3/intn_t.3 +man3/getdate_err.3 +man3/matherr.3 +man3/infinity.3 +man3/gnu_get_libc_version.3 +man3/svcudp_bufcreate.3 +man3/string.3 +man3/va_arg.3 +man3/wcsrchr.3 +man3/pthread_attr_getstack.3 +man3/xdr_long.3 +man3/svc_unregister.3 +man3/pid_t.3 +man3/modf.3 +man3/imaxdiv_t.3 +man3/authunix_create_default.3 +man3/daemon.3 +man3/div_t.3 +man3/clnt_control.3 +man3/killpg.3 +man3/mkstemps.3 +man3/nanl.3 +man3/swapcontext.3 +man3/toupper_l.3 +man3/ldiv.3 +man3/lldiv_t.3 +man3/xdr_float.3 +man3/putspent.3 +man3/nan.3 +man3/isalnum.3 +man3/srandom_r.3 +man3/iscntrl_l.3 +man3/cmsg_firsthdr.3 +man3/sem_timedwait.3 +man3/lcong48_r.3 +man3/conj.3 +man3/getspnam.3 +man3/system.3 +man3/wcscpy.3 +man3/ulimit.3 +man3/posix_memalign.3 +man3/tailq_swap.3 +man3/clnt_pcreateerror.3 +man3/llrintl.3 +man3/clogl.3 +man3/erff.3 +man3/ftw.3 +man3/regex.3 +man3/mbrtowc.3 +man3/utmpxname.3 +man3/argz.3 +man3/error.3 +man3/isblank.3 +man3/tanhl.3 +man3/freeifaddrs.3 +man3/getaliasbyname.3 +man3/__malloc_initialize_hook.3 +man3/xdr_bytes.3 +man3/csinhf.3 +man3/ether_ntoa.3 +man3/endusershell.3 +man3/initstate.3 +man3/fsetpos.3 +man3/rewind.3 +man4/ptmx.4 +man4/ttys.4 +man4/dsp56k.4 +man4/port.4 +man4/ram.4 +man4/veth.4 +man4/st.4 +man4/loop.4 +man4/wavelan.4 +man4/sk98lin.4 +man4/loop-control.4 +man4/hd.4 +man4/rtc.4 +man4/random.4 +man4/mouse.4 +man4/kmem.4 +man4/console_codes.4 +man4/pts.4 +man4/vcs.4 +man4/tty_ioctl.4 +man4/fuse.4 +man4/lp.4 +man4/smartpqi.4 +man4/cpuid.4 +man4/full.4 +man4/intro.4 +man4/fd.4 +man4/initrd.4 +man4/sd.4 +man4/lirc.4 +man4/cciss.4 +man4/tty.4 +man4/msr.4 +man4/zero.4 +man4/null.4 +man4/urandom.4 +man4/hpsa.4 +man4/vcsa.4 +man4/mem.4 +man4/console_ioctl.4 +man5/ftpusers.5 +man5/dir_colors.5 +man5/sysfs.5 +man5/securetty.5 +man5/nss.5 +man5/core.5 +man5/locale.5 +man5/motd.5 +man5/utmp.5 +man5/passwd.5 +man5/nsswitch.conf.5 +man5/gai.conf.5 +man5/intro.5 +man5/fs.5 +man5/hosts.equiv.5 +man5/elf.5 +man5/resolv.conf.5 +man5/utmpx.5 +man5/wtmp.5 +man5/nscd.conf.5 +man5/termcap.5 +man5/slabinfo.5 +man5/repertoiremap.5 +man5/ttytype.5 +man5/shells.5 +man5/protocols.5 +man5/host.conf.5 +man5/charmap.5 +man5/issue.5 +man5/resolver.5 +man5/networks.5 +man5/filesystems.5 +man5/hosts.5 +man5/procfs.5 +man5/tzfile.5 +man5/group.5 +man5/rpc.5 +man5/acct.5 +man5/proc.5 +man5/tmpfs.5 +man5/nologin.5 +man5/services.5 +man6/intro.6 +man7/uts_namespaces.7 +man7/user_namespaces.7 +man7/iso_8859_1.7 +man7/queue.7 +man7/iso_8859-14.7 +man7/iso_8859_11.7 +man7/glob.7 +man7/iso_8859-8.7 +man7/iso-8859-10.7 +man7/charsets.7 +man7/netdevice.7 +man7/posixoptions.7 +man7/process-keyring.7 +man7/suffixes.7 +man7/iso_8859_7.7 +man7/credentials.7 +man7/netlink.7 +man7/iso_8859-6.7 +man7/pipe.7 +man7/cp1252.7 +man7/latin10.7 +man7/address_families.7 +man7/latin3.7 +man7/latin5.7 +man7/latin2.7 +man7/session-keyring.7 +man7/latin8.7 +man7/socket.7 +man7/iso-8859-9.7 +man7/namespaces.7 +man7/iso-8859-13.7 +man7/cgroups.7 +man7/udp.7 +man7/bpf-helpers.7 +man7/tcp.7 +man7/ipc_namespaces.7 +man7/sem_overview.7 +man7/environ.7 +man7/termio.7 +man7/url.7 +man7/iso_8859_6.7 +man7/iso_8859_10.7 +man7/armscii-8.7 +man7/sysvipc.7 +man7/aio.7 +man7/hier.7 +man7/iso_8859-1.7 +man7/operator.7 +man7/glibc.7 +man7/cp1251.7 +man7/vdso.7 +man7/keyrings.7 +man7/iso_8859_3.7 +man7/iso-8859-2.7 +man7/iso_8859_13.7 +man7/packet.7 +man7/ipv6.7 +man7/regex.7 +man7/iso_8859-13.7 +man7/symlink.7 +man7/latin9.7 +man7/unicode.7 +man7/iso_8859_16.7 +man7/user-session-keyring.7 +man7/uri.7 +man7/iso-8859-1.7 +man7/unix.7 +man7/svipc.7 +man7/mount_namespaces.7 +man7/numa.7 +man7/iso-8859-11.7 +man7/mq_overview.7 +man7/iso-8859-8.7 +man7/iso_8859_2.7 +man7/iso_8859_4.7 +man7/pthreads.7 +man7/rtld-audit.7 +man7/iso-8859-6.7 +man7/mailaddr.7 +man7/iso_8859-11.7 +man7/pkeys.7 +man7/standards.7 +man7/complex.7 +man7/intro.7 +man7/nptl.7 +man7/precedence.7 +man7/iso-8859-7.7 +man7/ddp.7 +man7/ascii.7 +man7/time_namespaces.7 +man7/epoll.7 +man7/sched.7 +man7/pid_namespaces.7 +man7/udplite.7 +man7/feature_test_macros.7 +man7/libc.7 +man7/cgroup_namespaces.7 +man7/iso_8859-9.7 +man7/iso_8859-4.7 +man7/attributes.7 +man7/iso_8859_9.7 +man7/user-keyring.7 +man7/inode.7 +man7/thread-keyring.7 +man7/x25.7 +man7/utf-8.7 +man7/rtnetlink.7 +man7/math_error.7 +man7/iso_8859_14.7 +man7/inotify.7 +man7/iso_8859-7.7 +man7/iso_8859-2.7 +man7/urn.7 +man7/arp.7 +man7/capabilities.7 +man7/time.7 +man7/iso_8859-15.7 +man7/icmp.7 +man7/iso-8859-3.7 +man7/iso-8859-4.7 +man7/units.7 +man7/hostname.7 +man7/koi8-u.7 +man7/sock_diag.7 +man7/iso-8859-16.7 +man7/iso_8859-10.7 +man7/cpuset.7 +man7/iso_8859-16.7 +man7/raw.7 +man7/boot.7 +man7/xattr.7 +man7/locale.7 +man7/signal.7 +man7/iso-8859-14.7 +man7/man.7 +man7/kernel_lockdown.7 +man7/iso_8859_8.7 +man7/koi8-r.7 +man7/spufs.7 +man7/utf8.7 +man7/random.7 +man7/latin1.7 +man7/signal-safety.7 +man7/path_resolution.7 +man7/iso-8859-15.7 +man7/vsock.7 +man7/shm_overview.7 +man7/latin4.7 +man7/persistent-keyring.7 +man7/system_data_types.7 +man7/latin7.7 +man7/latin6.7 +man7/tis-620.7 +man7/bootparam.7 +man7/sigevent.7 +man7/iso-8859-5.7 +man7/ip.7 +man7/iso_8859_15.7 +man7/fifo.7 +man7/pty.7 +man7/man-pages.7 +man7/network_namespaces.7 +man7/iso_8859-3.7 +man7/fanotify.7 +man7/iso_8859_5.7 +man7/iso_8859-5.7 +man7/futex.7 +man8/ld.so.8 +man8/ldconfig.8 +man8/zic.8 +man8/sln.8 +man8/zdump.8 +man8/nscd.8 +man8/ld-linux.so.8 +man8/ld-linux.8 +man8/tzselect.8 +man8/intro.8 +man8/iconvconfig.8 + +.so man3/encrypt.3 + +.so man3/isalpha.3 + +.\" copyright (c) 2001 andries brouwer . +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" fixme . there are a lot of other process termination actions that +.\" could be listed on this page. see, for example, the list in the +.\" posix exit(3p) page. +.\" +.th exit 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +exit \- cause normal process termination +.sh synopsis +.nf +.b #include +.pp +.bi "noreturn void exit(int " status ); +.fi +.sh description +the +.br exit () +function causes normal process termination and the least significant byte of +.i status +(i.e., \fistatus & 0xff\fp) is returned to the parent (see +.br wait (2)). +.pp +all functions registered with +.br atexit (3) +and +.br on_exit (3) +are called, in the reverse order of their registration. +(it is possible for one of these functions to use +.br atexit (3) +or +.br on_exit (3) +to register an additional +function to be executed during exit processing; +the new registration is added to the front of the list of functions +that remain to be called.) +if one of these functions does not return +(e.g., it calls +.br _exit (2), +or kills itself with a signal), +then none of the remaining functions is called, +and further exit processing (in particular, flushing of +.br stdio (3) +streams) is abandoned. +if a function has been registered multiple times using +.br atexit (3) +or +.br on_exit (3), +then it is called as many times as it was registered. +.pp +all open +.br stdio (3) +streams are flushed and closed. +files created by +.br tmpfile (3) +are removed. +.pp +the c standard specifies two constants, +\fbexit_success\fp and \fbexit_failure\fp, +that may be passed to +.br exit () +to indicate successful or unsuccessful +termination, respectively. +.sh return value +the +.br exit () +function does not return. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br exit () +t} thread safety mt-unsafe race:exit +.te +.hy +.ad +.sp 1 +.pp +the +.br exit () +function uses a global variable that is not protected, +so it is not thread-safe. +.sh conforming to +posix.1-2001, posix.1-2008, c89, c99, svr4, 4.3bsd. +.sh notes +the behavior is undefined if one of the functions registered using +.br atexit (3) +and +.br on_exit (3) +calls either +.br exit () +or +.br longjmp (3). +note that a call to +.br execve (2) +removes registrations created using +.br atexit (3) +and +.br on_exit (3). +.pp +the use of +.b exit_success +and +.b exit_failure +is slightly more portable +(to non-unix environments) than the use of 0 and some nonzero value +like 1 or \-1. +in particular, vms uses a different convention. +.pp +bsd has attempted to standardize exit codes +(which some c libraries such as the gnu c library have also adopted); +see the file +.ir . +.pp +after +.br exit (), +the exit status must be transmitted to the +parent process. +there are three cases: +.ip \(bu 3 +if the parent has set +.br sa_nocldwait , +or has set the +.b sigchld +handler to +.br sig_ign , +the status is discarded and the child dies immediately. +.ip \(bu +if the parent was waiting on the child, +it is notified of the exit status and the child dies immediately. +.ip \(bu +otherwise, +the child becomes a "zombie" process: +most of the process resources are recycled, +but a slot containing minimal information about the child process +(termination status, resource usage statistics) is retained in process table. +this allows the parent to subsequently use +.br waitpid (2) +(or similar) to learn the termination status of the child; +at that point the zombie process slot is released. +.pp +if the implementation supports the +.b sigchld +signal, this signal +is sent to the parent. +if the parent has set +.br sa_nocldwait , +it is undefined whether a +.b sigchld +signal is sent. +.\" +.ss signals sent to other processes +if the exiting process is a session leader and its controlling terminal +is the controlling terminal of the session, then each process in +the foreground process group of this controlling terminal +is sent a +.b sighup +signal, and the terminal is disassociated +from this session, allowing it to be acquired by a new controlling +process. +.pp +if the exit of the process causes a process group to become orphaned, +and if any member of the newly orphaned process group is stopped, +then a +.b sighup +signal followed by a +.b sigcont +signal will be +sent to each process in this process group. +see +.br setpgid (2) +for an explanation of orphaned process groups. +.pp +except in the above cases, +where the signalled processes may be children of the terminating process, +termination of a process does +.i not +in general cause a signal to be sent to children of that process. +however, a process can use the +.br prctl (2) +.b pr_set_pdeathsig +operation to arrange that it receives a signal if its parent terminates. +.sh see also +.br _exit (2), +.br get_robust_list (2), +.br setpgid (2), +.br wait (2), +.br atexit (3), +.br on_exit (3), +.br tmpfile (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/fabs.3 + +.so man3/ccos.3 + +.so man3/des_crypt.3 + +.so man3/getdate.3 + +.\" copyright (c) 2009 linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th timer_settime 2 2021-03-22 linux "linux programmer's manual" +.sh name +timer_settime, timer_gettime \- arm/disarm and fetch +state of posix per-process timer +.sh synopsis +.nf +.b #include +.pp +.bi "int timer_settime(timer_t " timerid ", int " flags , +.bi " const struct itimerspec *restrict " new_value , +.bi " struct itimerspec *restrict " old_value ); +.bi "int timer_gettime(timer_t " timerid ", struct itimerspec *" curr_value ); +.fi +.pp +link with \fi\-lrt\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br timer_settime (), +.br timer_gettime (): +.nf + _posix_c_source >= 199309l +.fi +.sh description +.br timer_settime () +arms or disarms the timer identified by +.ir timerid . +the +.i new_value +argument is pointer to an +.i itimerspec +structure that specifies the new initial value and +the new interval for the timer. +the +.i itimerspec +structure is defined as follows: +.pp +.in +4n +.ex +struct timespec { + time_t tv_sec; /* seconds */ + long tv_nsec; /* nanoseconds */ +}; + +struct itimerspec { + struct timespec it_interval; /* timer interval */ + struct timespec it_value; /* initial expiration */ +}; +.ee +.in +.pp +each of the substructures of the +.i itimerspec +structure is a +.i timespec +structure that allows a time value to be specified +in seconds and nanoseconds. +these time values are measured according to the clock +that was specified when the timer was created by +.br timer_create (2). +.pp +if +.i new_value\->it_value +specifies a nonzero value (i.e., either subfield is nonzero), then +.br timer_settime () +arms (starts) the timer, +setting it to initially expire at the given time. +(if the timer was already armed, +then the previous settings are overwritten.) +if +.i new_value\->it_value +specifies a zero value +(i.e., both subfields are zero), +then the timer is disarmed. +.pp +the +.i new_value\->it_interval +field specifies the period of the timer, in seconds and nanoseconds. +if this field is nonzero, then each time that an armed timer expires, +the timer is reloaded from the value specified in +.ir new_value\->it_interval . +if +.i new_value\->it_interval +specifies a zero value, +then the timer expires just once, at the time specified by +.ir it_value . +.pp +by default, the initial expiration time specified in +.i new_value\->it_value +is interpreted relative to the current time on the timer's +clock at the time of the call. +this can be modified by specifying +.b timer_abstime +in +.ir flags , +in which case +.i new_value\->it_value +is interpreted as an absolute value as measured on the timer's clock; +that is, the timer will expire when the clock value reaches the +value specified by +.ir new_value\->it_value . +if the specified absolute time has already passed, +then the timer expires immediately, +and the overrun count (see +.br timer_getoverrun (2)) +will be set correctly. +.\" by experiment: the overrun count is set correctly, for clock_realtime. +.pp +if the value of the +.b clock_realtime +clock is adjusted while an absolute timer based on that clock is armed, +then the expiration of the timer will be appropriately adjusted. +adjustments to the +.b clock_realtime +clock have no effect on relative timers based on that clock. +.\" similar remarks might apply with respect to process and thread cpu time +.\" clocks, but these clocks are not currently (2.6.28) settable on linux. +.pp +if +.i old_value +is not null, then it points to a buffer +that is used to return the previous interval of the timer (in +.ir old_value\->it_interval ) +and the amount of time until the timer +would previously have next expired (in +.ir old_value\->it_value ). +.pp +.br timer_gettime () +returns the time until next expiration, and the interval, +for the timer specified by +.ir timerid , +in the buffer pointed to by +.ir curr_value . +the time remaining until the next timer expiration is returned in +.ir curr_value\->it_value ; +this is always a relative value, regardless of whether the +.br timer_abstime +flag was used when arming the timer. +if the value returned in +.ir curr_value\->it_value +is zero, then the timer is currently disarmed. +the timer interval is returned in +.ir curr_value\->it_interval . +if the value returned in +.ir curr_value\->it_interval +is zero, then this is a "one-shot" timer. +.sh return value +on success, +.br timer_settime () +and +.br timer_gettime () +return 0. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +these functions may fail with the following errors: +.tp +.b efault +.ir new_value , +.ir old_value , +or +.i curr_value +is not a valid pointer. +.tp +.b einval +.i timerid +is invalid. +.\" fixme . eventually: invalid value in flags +.pp +.br timer_settime () +may fail with the following errors: +.tp +.b einval +.i new_value.it_value +is negative; or +.i new_value.it_value.tv_nsec +is negative or greater than 999,999,999. +.sh versions +these system calls are available since linux 2.6. +.sh conforming to +posix.1-2001, posix.1-2008. +.sh examples +see +.br timer_create (2). +.sh see also +.br timer_create (2), +.br timer_getoverrun (2), +.br time (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/fgetc.3 + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" iso/iec 9899:1999 +.\" +.th mbrlen 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +mbrlen \- determine number of bytes in next multibyte character +.sh synopsis +.nf +.b #include +.pp +.bi "size_t mbrlen(const char *restrict " s ", size_t " n , +.bi " mbstate_t *restrict " ps ); +.fi +.sh description +the +.br mbrlen () +function inspects at most +.i n +bytes of the multibyte +string starting at +.i s +and extracts the next complete multibyte character. +it updates the shift state +.ir *ps . +if the multibyte character is not the +null wide character, it returns the number of bytes that were consumed from +.ir s . +if the multibyte character is the null wide character, it resets the +shift state +.i *ps +to the initial state and returns 0. +.pp +if the +.ir n +bytes starting at +.i s +do not contain a complete multibyte +character, +.br mbrlen () +returns +.ir "(size_t)\ \-2" . +this can happen even if +.i n +>= +.ir mb_cur_max , +if the multibyte string contains redundant shift +sequences. +.pp +if the multibyte string starting at +.i s +contains an invalid multibyte +sequence before the next complete character, +.br mbrlen () +returns +.ir "(size_t)\ \-1" +and sets +.i errno +to +.br eilseq . +in this case, +the effects on +.i *ps +are undefined. +.pp +if +.i ps +is null, a static anonymous state known only to the +.br mbrlen () +function is used instead. +.sh return value +the +.br mbrlen () +function returns the number of bytes +parsed from the multibyte +sequence starting at +.ir s , +if a non-null wide character was recognized. +it returns 0, if a null wide character was recognized. +it returns +.i "(size_t)\ \-1" +and sets +.i errno +to +.br eilseq , +if an invalid multibyte sequence was +encountered. +it returns +.ir "(size_t)\ \-2" +if it couldn't parse a complete multibyte +character, meaning that +.i n +should be increased. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br mbrlen () +t} thread safety mt-unsafe race:mbrlen/!ps +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh notes +the behavior of +.br mbrlen () +depends on the +.b lc_ctype +category of the +current locale. +.sh see also +.br mbrtowc (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/ioctl_ficlonerange.2 + +.so man3/ecvt_r.3 + +.so man3/puts.3 + +.so man2/chdir.2 + +.so man2/pread.2 + +.so man7/iso_8859-14.7 + +.\" copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de) +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under gpl +.\" %%%license_end +.\" +.th clog 3 2021-03-22 "" "linux programmer's manual" +.sh name +clog, clogf, clogl \- natural logarithm of a complex number +.sh synopsis +.nf +.b #include +.pp +.bi "double complex clog(double complex " z ); +.bi "float complex clogf(float complex " z ); +.bi "long double complex clogl(long double complex " z ); +.pp +link with \fi\-lm\fp. +.fi +.sh description +these functions calculate the complex natural logarithm of +.ir z , +with a branch cut along the negative real axis. +.pp +the logarithm +.br clog () +is the inverse function of the exponential +.br cexp (3). +thus, if \fiy\ =\ clog(z)\fp, then \fiz\ =\ cexp(y)\fp. +the imaginary part of +.i y +is chosen in the interval [\-pi,pi]. +.pp +one has: +.pp +.nf + clog(z) = log(cabs(z)) + i * carg(z) +.fi +.pp +note that +.i z +close to zero will cause an overflow. +.sh versions +these functions first appeared in glibc in version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br clog (), +.br clogf (), +.br clogl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.sh see also +.br cabs (3), +.br cexp (3), +.br clog10 (3), +.br clog2 (3), +.br complex (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 2020 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th svipc 7 2020-04-11 "linux" "linux programmer's manual" +.sh name +sysvipc \- system v interprocess communication mechanisms +.sh description +system v ipc is the name given to three interprocess +communication mechanisms that are widely available on unix systems: +message queues, semaphore, and shared memory. +.\" +.ss message queues +system v message queues allow data to be exchanged in units called messages. +each messages can have an associated priority, +posix message queues provide an alternative api for achieving the same result; +see +.br mq_overview (7). +.pp +the system v message queue api consists of the following system calls: +.tp +.br msgget (2) +create a new message queue or obtain the id of an existing message queue. +this call returns an identifier that is used in the remaining apis. +.tp +.br msgsnd (2) +add a message to a queue. +.tp +.br msgrcv (2) +remove a message from a queue. +.tp +.br msgctl (2) +perform various control operations on a queue, including deletion. +.\" +.ss semaphore sets +system v semaphores allow processes to synchronize their actions. +system v semaphores are allocated in groups called sets; +each semaphore in a set is a counting semaphore. +posix semaphores provide an alternative api for achieving the same result; +see +.br sem_overview (7). +.pp +the system v semaphore api consists of the following system calls: +.tp +.br semget (2) +create a new set or obtain the id of an existing set. +this call returns an identifier that is used in the remaining apis. +.tp +.br semop (2) +perform operations on the semaphores in a set. +.tp +.br semctl (2) +perform various control operations on a set, including deletion. +.\" +.ss shared memory segments +system v shared memory allows processes to share a region a memory +(a "segment"). +posix shared memory is an alternative api for achieving the same result; see +.br shm_overview (7). +.pp +the system v shared memory api consists of the following system calls: +.tp +.br shmget (2) +create a new segment or obtain the id of an existing segment. +this call returns an identifier that is used in the remaining apis. +.tp +.br shmat (2) +attach an existing shared memory object into the calling process's +address space. +.tp +.br shmdt (2) +detach a segment from the calling process's address space. +.tp +.br shmctl (2) +perform various control operations on a segment, including deletion. +.\" +.ss ipc namespaces +for a discussion of the interaction of system v ipc objects and +ipc namespaces, see +.br ipc_namespaces (7). +.sh see also +.br ipcmk (1), +.br ipcrm (1), +.br ipcs (1), +.br lsipc (1), +.br ipc (2), +.br msgctl (2), +.br msgget (2), +.br msgrcv (2), +.br msgsnd (2), +.br semctl (2), +.br semget (2), +.br semop (2), +.br shmat (2), +.br shmctl (2), +.br shmdt (2), +.br shmget (2), +.br ftok (3), +.br ipc_namespaces (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/unlocked_stdio.3 + +.so man3/lgamma.3 + +.so man3/frexp.3 + +.\" copyright (c) 1993 by thomas koenig (ig25@rz.uni-karlsruhe.de) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified sat jul 24 18:16:02 1993 by rik faith (faith@cs.unc.edu) +.th sleep 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +sleep \- sleep for a specified number of seconds +.sh synopsis +.nf +.b #include +.pp +.bi "unsigned int sleep(unsigned int " "seconds" ); +.fi +.sh description +.br sleep () +causes the calling thread to sleep either until +the number of real-time seconds specified in +.i seconds +have elapsed or until a signal arrives which is not ignored. +.sh return value +zero if the requested time has elapsed, +or the number of seconds left to sleep, +if the call was interrupted by a signal handler. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br sleep () +t} thread safety mt-unsafe sig:sigchld/linux +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +on linux, +.br sleep () +is implemented via +.br nanosleep (2). +see the +.br nanosleep (2) +man page for a discussion of the clock used. +.ss portability notes +on some systems, +.br sleep () +may be implemented using +.br alarm (2) +and +.br sigalrm +(posix.1 permits this); +mixing calls to +.br alarm (2) +and +.br sleep () +is a bad idea. +.pp +using +.br longjmp (3) +from a signal handler or modifying the handling of +.b sigalrm +while sleeping will cause undefined results. +.sh see also +.br sleep (1), +.br alarm (2), +.br nanosleep (2), +.br signal (2), +.br signal (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/euidaccess.3 + +.so man2/removexattr.2 + +.so man3/exp10.3 + +.so man3/conj.3 + +.\" %%%license_start(public_domain) +.\" this file is in the public domain, so clarified as of +.\" 1996-06-05 by arthur david olson . +.\" %%%license_end +.\" +.th tzfile 5 2020-04-27 "" "linux programmer's manual" +.sh name +tzfile \- timezone information +.sh description +.ie '\(lq'' .ds lq \&"\" +.el .ds lq \(lq\" +.ie '\(rq'' .ds rq \&"\" +.el .ds rq \(rq\" +.de q +\\$3\*(lq\\$1\*(rq\\$2 +.. +.ie \n(.g .ds - \f(cw-\fp +.el ds - \- +the timezone information files used by +.br tzset (3) +are typically found under a directory with a name like +.ir /usr/share/zoneinfo . +these files use the format described in internet rfc 8536. +each file is a sequence of 8-bit bytes. +in a file, a binary integer is represented by a sequence of one or +more bytes in network order (bigendian, or high-order byte first), +with all bits significant, +a signed binary integer is represented using two's complement, +and a boolean is represented by a one-byte binary integer that is +either 0 (false) or 1 (true). +the format begins with a 44-byte header containing the following fields: +.ip * 2 +the magic four-byte ascii sequence +.q "tzif" +identifies the file as a timezone information file. +.ip * +a byte identifying the version of the file's format +(as of 2017, either an ascii nul, or +.q "2", +or +.q "3" ). +.ip * +fifteen bytes containing zeros reserved for future use. +.ip * +six four-byte integer values, in the following order: +.rs +.tp +.i tzh_ttisutcnt +the number of ut/local indicators stored in the file. +(ut is universal time.) +.tp +.i tzh_ttisstdcnt +the number of standard/wall indicators stored in the file. +.tp +.i tzh_leapcnt +the number of leap seconds for which data entries are stored in the file. +.tp +.i tzh_timecnt +the number of transition times for which data entries are stored +in the file. +.tp +.i tzh_typecnt +the number of local time types for which data entries are stored +in the file (must not be zero). +.tp +.i tzh_charcnt +the number of bytes of time zone abbreviation strings +stored in the file. +.re +.pp +the above header is followed by the following fields, whose lengths +depend on the contents of the header: +.ip * 2 +.i tzh_timecnt +four-byte signed integer values sorted in ascending order. +these values are written in network byte order. +each is used as a transition time (as returned by +.br time (2)) +at which the rules for computing local time change. +.ip * +.i tzh_timecnt +one-byte unsigned integer values; +each one but the last tells which of the different types of local time types +described in the file is associated with the time period +starting with the same-indexed transition time +and continuing up to but not including the next transition time. +(the last time type is present only for consistency checking with the +posix-style tz string described below.) +these values serve as indices into the next field. +.ip * +.i tzh_typecnt +.i ttinfo +entries, each defined as follows: +.in +.5i +.sp +.nf +.ta .5i +\w'unsigned char\0\0'u +struct ttinfo { + int32_t tt_utoff; + unsigned char tt_isdst; + unsigned char tt_desigidx; +}; +.in -.5i +.fi +.sp +each structure is written as a four-byte signed integer value for +.ir tt_utoff , +in network byte order, followed by a one-byte boolean for +.i tt_isdst +and a one-byte value for +.ir tt_desigidx . +in each structure, +.i tt_utoff +gives the number of seconds to be added to ut, +.i tt_isdst +tells whether +.i tm_isdst +should be set by +.br localtime (3) +and +.i tt_desigidx +serves as an index into the array of time zone abbreviation bytes +that follow the +.i ttinfo +structure(s) in the file. +the +.i tt_utoff +value is never equal to \-2**31, to let 32-bit clients negate it without +overflow. +also, in realistic applications +.i tt_utoff +is in the range [\-89999, 93599] (i.e., more than \-25 hours and less +than 26 hours); this allows easy support by implementations that +already support the posix-required range [\-24:59:59, 25:59:59]. +.ip * +.i tzh_leapcnt +pairs of four-byte values, written in network byte order; +the first value of each pair gives the nonnegative time +(as returned by +.br time (2)) +at which a leap second occurs; +the second is a signed integer specifying the +.i total +number of leap seconds to be applied during the time period +starting at the given time. +the pairs of values are sorted in ascending order by time. +each transition is for one leap second, either positive or negative; +transitions always separated by at least 28 days minus 1 second. +.ip * +.i tzh_ttisstdcnt +standard/wall indicators, each stored as a one-byte boolean; +they tell whether the transition times associated with local time types +were specified as standard time or local (wall clock) time. +.ip * +.i tzh_ttisutcnt +ut/local indicators, each stored as a one-byte boolean; +they tell whether the transition times associated with local time types +were specified as ut or local time. +if a ut/local indicator is set, the corresponding standard/wall indicator +must also be set. +.pp +the standard/wall and ut/local indicators were designed for +transforming a tzif file's transition times into transitions appropriate +for another time zone specified via a posix-style tz string that lacks rules. +for example, when tz="eet\*-2eest" and there is no tzif file "eet\*-2eest", +the idea was to adapt the transition times from a tzif file with the +well-known name "posixrules" that is present only for this purpose and +is a copy of the file "europe/brussels", a file with a different ut offset. +posix does not specify this obsolete transformational behavior, +the default rules are installation-dependent, and no implementation +is known to support this feature for timestamps past 2037, +so users desiring (say) greek time should instead specify +tz="europe/athens" for better historical coverage, falling back on +tz="eet\*-2eest,m3.5.0/3,m10.5.0/4" if posix conformance is required +and older timestamps need not be handled accurately. +.pp +the +.br localtime (3) +function +normally uses the first +.i ttinfo +structure in the file +if either +.i tzh_timecnt +is zero or the time argument is less than the first transition time recorded +in the file. +.ss version 2 format +for version-2-format timezone files, +the above header and data are followed by a second header and data, +identical in format except that +eight bytes are used for each transition time or leap second time. +(leap second counts remain four bytes.) +after the second header and data comes a newline-enclosed, +posix-tz-environment-variable-style string for use in handling instants +after the last transition time stored in the file +or for all instants if the file has no transitions. +the posix-style tz string is empty (i.e., nothing between the newlines) +if there is no posix representation for such instants. +if nonempty, the posix-style tz string must agree with the local time +type after the last transition time if present in the eight-byte data; +for example, given the string +.q "wet0west,m3.5.0,m10.5.0/3" +then if a last transition time is in july, the transition's local time +type must specify a daylight-saving time abbreviated +.q "west" +that is one hour east of ut. +also, if there is at least one transition, time type 0 is associated +with the time period from the indefinite past up to but not including +the earliest transition time. +.ss version 3 format +for version-3-format timezone files, the posix-tz-style string may +use two minor extensions to the posix tz format, as described in +.br newtzset (3). +first, the hours part of its transition times may be signed and range from +\-167 through 167 instead of the posix-required unsigned values +from 0 through 24. +second, dst is in effect all year if it starts +january 1 at 00:00 and ends december 31 at 24:00 plus the difference +between daylight saving and standard time. +.ss interoperability considerations +future changes to the format may append more data. +.pp +version 1 files are considered a legacy format and +should be avoided, as they do not support transition +times after the year 2038. +readers that only understand version 1 must ignore +any data that extends beyond the calculated end of the version +1 data block. +.pp +writers should generate a version 3 file if +tz string extensions are necessary to accurately +model transition times. +otherwise, version 2 files should be generated. +.pp +the sequence of time changes defined by the version 1 +header and data block should be a contiguous subsequence +of the time changes defined by the version 2+ header and data +block, and by the footer. +this guideline helps obsolescent version 1 readers +agree with current readers about timestamps within the +contiguous subsequence. it also lets writers not +supporting obsolescent readers use a +.i tzh_timecnt +of zero +in the version 1 data block to save space. +.pp +time zone designations should consist of at least three (3) +and no more than six (6) ascii characters from the set of +alphanumerics, +.q "\*-", +and +.q "+". +this is for compatibility with posix requirements for +time zone abbreviations. +.pp +when reading a version 2 or 3 file, readers +should ignore the version 1 header and data block except for +the purpose of skipping over them. +.pp +readers should calculate the total lengths of the +headers and data blocks and check that they all fit within +the actual file size, as part of a validity check for the file. +.ss common interoperability issues +this section documents common problems in reading or writing tzif files. +most of these are problems in generating tzif files for use by +older readers. +the goals of this section are: +.ip * 2 +to help tzif writers output files that avoid common +pitfalls in older or buggy tzif readers, +.ip * +to help tzif readers avoid common pitfalls when reading +files generated by future tzif writers, and +.ip * +to help any future specification authors see what sort of +problems arise when the tzif format is changed. +.pp +when new versions of the tzif format have been defined, a +design goal has been that a reader can successfully use a tzif +file even if the file is of a later tzif version than what the +reader was designed for. +when complete compatibility was not achieved, an attempt was +made to limit glitches to rarely used timestamps, and to allow +simple partial workarounds in writers designed to generate +new-version data useful even for older-version readers. +this section attempts to document these compatibility issues and +workarounds, as well as to document other common bugs in +readers. +.pp +interoperability problems with tzif include the following: +.ip * 2 +some readers examine only version 1 data. +as a partial workaround, a writer can output as much version 1 +data as possible. +however, a reader should ignore version 1 data, and should use +version 2+ data even if the reader's native timestamps have only +32 bits. +.ip * +some readers designed for version 2 might mishandle +timestamps after a version 3 file's last transition, because +they cannot parse extensions to posix in the tz-like string. +as a partial workaround, a writer can output more transitions +than necessary, so that only far-future timestamps are +mishandled by version 2 readers. +.ip * +some readers designed for version 2 do not support +permanent daylight saving time, e.g., a tz string +.q "est5edt,0/0,j365/25" +denoting permanent eastern daylight time (\-04). +as a partial workaround, a writer can substitute standard time +for the next time zone east, e.g., +.q "ast4" +for permanent atlantic standard time (\-04). +.ip * +some readers ignore the footer, and instead predict future +timestamps from the time type of the last transition. +as a partial workaround, a writer can output more transitions +than necessary. +.ip * +some readers do not use time type 0 for timestamps before +the first transition, in that they infer a time type using a +heuristic that does not always select time type 0. +as a partial workaround, a writer can output a dummy (no-op) +first transition at an early time. +.ip * +some readers mishandle timestamps before the first +transition that has a timestamp not less than \-2**31. +readers that support only 32-bit timestamps are likely to be +more prone to this problem, for example, when they process +64-bit transitions only some of which are representable in 32 +bits. +as a partial workaround, a writer can output a dummy +transition at timestamp \-2**31. +.ip * +some readers mishandle a transition if its timestamp has +the minimum possible signed 64-bit value. +timestamps less than \-2**59 are not recommended. +.ip * +some readers mishandle posix-style tz strings that +contain +.q "<" +or +.q ">". +as a partial workaround, a writer can avoid using +.q "<" +or +.q ">" +for time zone abbreviations containing only alphabetic +characters. +.ip * +many readers mishandle time zone abbreviations that contain +non-ascii characters. +these characters are not recommended. +.ip * +some readers may mishandle time zone abbreviations that +contain fewer than 3 or more than 6 characters, or that +contain ascii characters other than alphanumerics, +.q "\*-", +and +.q "+". +these abbreviations are not recommended. +.ip * +some readers mishandle tzif files that specify +daylight-saving time ut offsets that are less than the ut +offsets for the corresponding standard time. +these readers do not support locations like ireland, which +uses the equivalent of the posix tz string +.q "ist\*-1gmt0,m10.5.0,m3.5.0/1", +observing standard time +(ist, +01) in summer and daylight saving time (gmt, +00) in winter. +as a partial workaround, a writer can output data for the +equivalent of the posix tz string +.q "gmt0ist,m3.5.0/1,m10.5.0", +thus swapping standard and daylight saving time. +although this workaround misidentifies which part of the year +uses daylight saving time, it records ut offsets and time zone +abbreviations correctly. +.pp +some interoperability problems are reader bugs that +are listed here mostly as warnings to developers of readers. +.ip * 2 +some readers do not support negative timestamps. +developers of distributed applications should keep this +in mind if they need to deal with pre-1970 data. +.ip * +some readers mishandle timestamps before the first +transition that has a nonnegative timestamp. +readers that do not support negative timestamps are likely to +be more prone to this problem. +.ip * +some readers mishandle time zone abbreviations like +.q "\*-08" +that contain +.q "+", +.q "\*-", +or digits. +.ip * +some readers mishandle ut offsets that are out of the +traditional range of \-12 through +12 hours, and so do not +support locations like kiritimati that are outside this +range. +.ip * +some readers mishandle ut offsets in the range [\-3599, \-1] +seconds from ut, because they integer-divide the offset by +3600 to get 0 and then display the hour part as +.q "+00". +.ip * +some readers mishandle ut offsets that are not a multiple +of one hour, or of 15 minutes, or of 1 minute. +.sh see also +.br time (2), +.br localtime (3), +.br tzset (3), +.br tzselect (8), +.br zdump (8), +.br zic (8). +.pp +olson a, eggert p, murchison k. the time zone information format (tzif). +2019 feb. +.ur https://\:www.rfc-editor.org/\:info/\:rfc8536 +internet rfc 8536 +.ue +.ur https://\:doi.org/\:10.17487/\:rfc8536 +doi:10.17487/rfc8536 +.ue . +.\" this file is in the public domain, so clarified as of +.\" 1996-06-05 by arthur david olson. +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" this manpage is copyright (c) 1992 drew eckhardt, +.\" copyright (c) 1995 michael shields, +.\" copyright (c) 2001 paul sheer, +.\" copyright (c) 2006, 2019 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified 1993-07-24 by rik faith +.\" modified 1995-05-18 by jim van zandt +.\" sun feb 11 14:07:00 met 1996 martin schulze +.\" * layout slightly modified +.\" +.\" modified mon oct 21 23:05:29 edt 1996 by eric s. raymond +.\" modified thu feb 24 01:41:09 cet 2000 by aeb +.\" modified thu feb 9 22:32:09 cet 2001 by bert hubert , aeb +.\" modified mon nov 11 14:35:00 pst 2002 by ben woodard +.\" 2005-03-11, mtk, modified pselect() text (it is now a system +.\" call in 2.6.16. +.\" +.th select 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +select, pselect, fd_clr, fd_isset, fd_set, fd_zero \- +synchronous i/o multiplexing +.sh synopsis +.nf +.b #include +.pp +.bi "int select(int " nfds ", fd_set *restrict " readfds , +.bi " fd_set *restrict " writefds ", fd_set *restrict " exceptfds , +.bi " struct timeval *restrict " timeout ); +.pp +.bi "void fd_clr(int " fd ", fd_set *" set ); +.bi "int fd_isset(int " fd ", fd_set *" set ); +.bi "void fd_set(int " fd ", fd_set *" set ); +.bi "void fd_zero(fd_set *" set ); +.pp +.bi "int pselect(int " nfds ", fd_set *restrict " readfds , +.bi " fd_set *restrict " writefds ", fd_set *restrict " exceptfds , +.bi " const struct timespec *restrict " timeout , +.bi " const sigset_t *restrict " sigmask ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br pselect (): +.nf + _posix_c_source >= 200112l +.fi +.sh description +.br "warning" : +.br select () +can monitor only file descriptors numbers that are less than +.br fd_setsize +(1024)\(eman unreasonably low limit for many modern applications\(emand +this limitation will not change. +all modern applications should instead use +.br poll (2) +or +.br epoll (7), +which do not suffer this limitation. +.pp +.br select () +allows a program to monitor multiple file descriptors, +waiting until one or more of the file descriptors become "ready" +for some class of i/o operation (e.g., input possible). +a file descriptor is considered ready if it is possible to +perform a corresponding i/o operation (e.g., +.br read (2), +or a sufficiently small +.br write (2)) +without blocking. +.\" +.ss file descriptor sets +the principal arguments of +.br select () +are three "sets" of file descriptors (declared with the type +.ir fd_set ), +which allow the caller to wait for three classes of events +on the specified set of file descriptors. +each of the +.i fd_set +arguments may be specified as null if no file descriptors are +to be watched for the corresponding class of events. +.pp +.br "note well" : +upon return, each of the file descriptor sets is modified in place +to indicate which file descriptors are currently "ready". +thus, if using +.br select () +within a loop, the sets \fimust be reinitialized\fp before each call. +.pp +the contents of a file descriptor set can be manipulated +using the following macros: +.tp +.br fd_zero () +this macro clears (removes all file descriptors from) +.ir set . +it should be employed as the first step in initializing a file descriptor set. +.tp +.br fd_set () +this macro adds the file descriptor +.i fd +to +.ir set . +adding a file descriptor that is already present in the set is a no-op, +and does not produce an error. +.tp +.br fd_clr () +this macro removes the file descriptor +.i fd +from +.ir set . +removing a file descriptor that is not present in the set is a no-op, +and does not produce an error. +.tp +.br fd_isset () +.br select () +modifies the contents of the sets according to the rules +described below. +after calling +.br select (), +the +.br fd_isset () +macro +can be used to test if a file descriptor is still present in a set. +.br fd_isset () +returns nonzero if the file descriptor +.i fd +is present in +.ir set , +and zero if it is not. +.\" +.ss arguments +the arguments of +.br select () +are as follows: +.tp +.i readfds +the file descriptors in this set are watched to see if they are +ready for reading. +a file descriptor is ready for reading if a read operation will not +block; in particular, a file descriptor is also ready on end-of-file. +.ip +after +.br select () +has returned, \fireadfds\fp will be +cleared of all file descriptors except for those that are ready for reading. +.tp +.i writefds +the file descriptors in this set are watched to see if they are +ready for writing. +a file descriptor is ready for writing if a write operation will not block. +however, even if a file descriptor indicates as writable, +a large write may still block. +.ip +after +.br select () +has returned, \fiwritefds\fp will be +cleared of all file descriptors except for those that are ready for writing. +.tp +.i exceptfds +the file descriptors in this set are watched for "exceptional conditions". +for examples of some exceptional conditions, see the discussion of +.b pollpri +in +.br poll (2). +.ip +after +.br select () +has returned, +\fiexceptfds\fp will be cleared of all file descriptors except for those +for which an exceptional condition has occurred. +.tp +.i nfds +this argument should be set to the highest-numbered file descriptor in any +of the three sets, plus 1. +the indicated file descriptors in each set are checked, up to this limit +(but see bugs). +.tp +.i timeout +the +.i timeout +argument is a +.i timeval +structure (shown below) that specifies the interval that +.br select () +should block waiting for a file descriptor to become ready. +the call will block until either: +.rs +.ip \(bu 2 +a file descriptor becomes ready; +.ip \(bu +the call is interrupted by a signal handler; or +.ip \(bu +the timeout expires. +.re +.ip +note that the +.i timeout +interval will be rounded up to the system clock granularity, +and kernel scheduling delays mean that the blocking interval +may overrun by a small amount. +.ip +if both fields of the +.i timeval +structure are zero, then +.br select () +returns immediately. +(this is useful for polling.) +.ip +if +.i timeout +is specified as null, +.br select () +blocks indefinitely waiting for a file descriptor to become ready. +.\" +.ss pselect() +the +.br pselect () +system call allows an application to safely wait until either +a file descriptor becomes ready or until a signal is caught. +.pp +the operation of +.br select () +and +.br pselect () +is identical, other than these three differences: +.ip \(bu 2 +.br select () +uses a timeout that is a +.i struct timeval +(with seconds and microseconds), while +.br pselect () +uses a +.i struct timespec +(with seconds and nanoseconds). +.ip \(bu +.br select () +may update the +.i timeout +argument to indicate how much time was left. +.br pselect () +does not change this argument. +.ip \(bu +.br select () +has no +.i sigmask +argument, and behaves as +.br pselect () +called with null +.ir sigmask . +.pp +.i sigmask +is a pointer to a signal mask (see +.br sigprocmask (2)); +if it is not null, then +.br pselect () +first replaces the current signal mask by the one pointed to by +.ir sigmask , +then does the "select" function, and then restores the original +signal mask. +(if +.i sigmask +is null, +the signal mask is not modified during the +.br pselect () +call.) +.pp +other than the difference in the precision of the +.i timeout +argument, the following +.br pselect () +call: +.pp +.in +4n +.ex +ready = pselect(nfds, &readfds, &writefds, &exceptfds, + timeout, &sigmask); +.ee +.in +.pp +is equivalent to +.i atomically +executing the following calls: +.pp +.in +4n +.ex +sigset_t origmask; + +pthread_sigmask(sig_setmask, &sigmask, &origmask); +ready = select(nfds, &readfds, &writefds, &exceptfds, timeout); +pthread_sigmask(sig_setmask, &origmask, null); +.ee +.in +.pp +the reason that +.br pselect () +is needed is that if one wants to wait for either a signal +or for a file descriptor to become ready, then +an atomic test is needed to prevent race conditions. +(suppose the signal handler sets a global flag and +returns. +then a test of this global flag followed by a call of +.br select () +could hang indefinitely if the signal arrived just after the test +but just before the call. +by contrast, +.br pselect () +allows one to first block signals, handle the signals that have come in, +then call +.br pselect () +with the desired +.ir sigmask , +avoiding the race.) +.ss the timeout +the +.i timeout +argument for +.br select () +is a structure of the following type: +.pp +.in +4n +.ex +struct timeval { + time_t tv_sec; /* seconds */ + suseconds_t tv_usec; /* microseconds */ +}; +.ee +.in +.pp +the corresponding argument for +.br pselect () +has the following type: +.pp +.in +4n +.ex +struct timespec { + time_t tv_sec; /* seconds */ + long tv_nsec; /* nanoseconds */ +}; +.ee +.in +.pp +on linux, +.br select () +modifies +.i timeout +to reflect the amount of time not slept; most other implementations +do not do this. +(posix.1 permits either behavior.) +this causes problems both when linux code which reads +.i timeout +is ported to other operating systems, and when code is ported to linux +that reuses a \fistruct timeval\fp for multiple +.br select ()s +in a loop without reinitializing it. +consider +.i timeout +to be undefined after +.br select () +returns. +.\" .pp - it is rumored that: +.\" on bsd, when a timeout occurs, the file descriptor bits are not changed. +.\" - it is certainly true that: +.\" linux follows susv2 and sets the bit masks to zero upon a timeout. +.sh return value +on success, +.br select () +and +.br pselect () +return the number of file descriptors contained in the three returned +descriptor sets (that is, the total number of bits that are set in +.ir readfds , +.ir writefds , +.ir exceptfds ). +the return value may be zero if the timeout expired before any +file descriptors became ready. +.pp +on error, \-1 is returned, and +.i errno +is set to indicate the error; +the file descriptor sets are unmodified, +and +.i timeout +becomes undefined. +.sh errors +.tp +.b ebadf +an invalid file descriptor was given in one of the sets. +(perhaps a file descriptor that was already closed, +or one on which an error has occurred.) +however, see bugs. +.tp +.b eintr +a signal was caught; see +.br signal (7). +.tp +.b einval +.i nfds +is negative or exceeds the +.br rlimit_nofile +resource limit (see +.br getrlimit (2)). +.tp +.b einval +the value contained within +.i timeout +is invalid. +.tp +.b enomem +unable to allocate memory for internal tables. +.sh versions +.br pselect () +was added to linux in kernel 2.6.16. +prior to this, +.br pselect () +was emulated in glibc (but see bugs). +.sh conforming to +.br select () +conforms to posix.1-2001, posix.1-2008, and +4.4bsd +.rb ( select () +first appeared in 4.2bsd). +generally portable to/from +non-bsd systems supporting clones of the bsd socket layer (including +system\ v variants). +however, note that the system\ v variant typically +sets the timeout variable before returning, but the bsd variant does not. +.pp +.br pselect () +is defined in posix.1g, and in +posix.1-2001 and posix.1-2008. +.sh notes +an +.i fd_set +is a fixed size buffer. +executing +.br fd_clr () +or +.br fd_set () +with a value of +.i fd +that is negative or is equal to or larger than +.b fd_setsize +will result +in undefined behavior. +moreover, posix requires +.i fd +to be a valid file descriptor. +.pp +the operation of +.br select () +and +.br pselect () +is not affected by the +.br o_nonblock +flag. +.pp +on some other unix systems, +.\" darwin, according to a report by jeremy sequoia, relayed by josh triplett +.br select () +can fail with the error +.b eagain +if the system fails to allocate kernel-internal resources, rather than +.b enomem +as linux does. +posix specifies this error for +.br poll (2), +but not for +.br select (). +portable programs may wish to check for +.b eagain +and loop, just as with +.br eintr . +.\" +.ss the self-pipe trick +on systems that lack +.br pselect (), +reliable (and more portable) signal trapping can be achieved +using the self-pipe trick. +in this technique, +a signal handler writes a byte to a pipe whose other end +is monitored by +.br select () +in the main program. +(to avoid possibly blocking when writing to a pipe that may be full +or reading from a pipe that may be empty, +nonblocking i/o is used when reading from and writing to the pipe.) +.\" +.ss emulating usleep(3) +before the advent of +.br usleep (3), +some code employed a call to +.br select () +with all three sets empty, +.i nfds +zero, and a non-null +.i timeout +as a fairly portable way to sleep with subsecond precision. +.\" +.ss correspondence between select() and poll() notifications +within the linux kernel source, +.\" fs/select.c +we find the following definitions which show the correspondence +between the readable, writable, and exceptional condition notifications of +.br select () +and the event notifications provided by +.br poll (2) +and +.br epoll (7): +.pp +.in +4n +.ex +#define pollin_set (epollrdnorm | epollrdband | epollin | + epollhup | epollerr) + /* ready for reading */ +#define pollout_set (epollwrband | epollwrnorm | epollout | + epollerr) + /* ready for writing */ +#define pollex_set (epollpri) + /* exceptional condition */ +.ee +.in +.\" +.ss multithreaded applications +if a file descriptor being monitored by +.br select () +is closed in another thread, the result is unspecified. +on some unix systems, +.br select () +unblocks and returns, with an indication that the file descriptor is ready +(a subsequent i/o operation will likely fail with an error, +unless another process reopens file descriptor between the time +.br select () +returned and the i/o operation is performed). +on linux (and some other systems), +closing the file descriptor in another thread has no effect on +.br select (). +in summary, any application that relies on a particular behavior +in this scenario must be considered buggy. +.\" +.ss c library/kernel differences +the linux kernel allows file descriptor sets of arbitrary size, +determining the length of the sets to be checked from the value of +.ir nfds . +however, in the glibc implementation, the +.ir fd_set +type is fixed in size. +see also bugs. +.pp +the +.br pselect () +interface described in this page is implemented by glibc. +the underlying linux system call is named +.br pselect6 (). +this system call has somewhat different behavior from the glibc +wrapper function. +.pp +the linux +.br pselect6 () +system call modifies its +.i timeout +argument. +however, the glibc wrapper function hides this behavior +by using a local variable for the timeout argument that +is passed to the system call. +thus, the glibc +.br pselect () +function does not modify its +.i timeout +argument; +this is the behavior required by posix.1-2001. +.pp +the final argument of the +.br pselect6 () +system call is not a +.i "sigset_t\ *" +pointer, but is instead a structure of the form: +.pp +.in +4n +.ex +struct { + const kernel_sigset_t *ss; /* pointer to signal set */ + size_t ss_len; /* size (in bytes) of object + pointed to by \(aqss\(aq */ +}; +.ee +.in +.pp +this allows the system call to obtain both +a pointer to the signal set and its size, +while allowing for the fact that most architectures +support a maximum of 6 arguments to a system call. +see +.br sigprocmask (2) +for a discussion of the difference between the kernel and libc +notion of the signal set. +.\" +.ss historical glibc details +glibc 2.0 provided an incorrect version of +.br pselect () +that did not take a +.i sigmask +argument. +.pp +in glibc versions 2.1 to 2.2.1, +one must define +.b _gnu_source +in order to obtain the declaration of +.br pselect () +from +.ir . +.sh bugs +posix allows an implementation to define an upper limit, +advertised via the constant +.br fd_setsize , +on the range of file descriptors that can be specified +in a file descriptor set. +the linux kernel imposes no fixed limit, but the glibc implementation makes +.ir fd_set +a fixed-size type, with +.br fd_setsize +defined as 1024, and the +.br fd_* () +macros operating according to that limit. +to monitor file descriptors greater than 1023, use +.br poll (2) +or +.br epoll (7) +instead. +.pp +the implementation of the +.i fd_set +arguments as value-result arguments is a design error that is avoided in +.br poll (2) +and +.br epoll (7). +.pp +according to posix, +.br select () +should check all specified file descriptors in the three file descriptor sets, +up to the limit +.ir nfds\-1 . +however, the current implementation ignores any file descriptor in +these sets that is greater than the maximum file descriptor number +that the process currently has open. +according to posix, any such file descriptor that is specified in one +of the sets should result in the error +.br ebadf . +.pp +starting with version 2.1, glibc provided an emulation of +.br pselect () +that was implemented using +.br sigprocmask (2) +and +.br select (). +this implementation remained vulnerable to the very race condition that +.br pselect () +was designed to prevent. +modern versions of glibc use the (race-free) +.br pselect () +system call on kernels where it is provided. +.pp +on linux, +.br select () +may report a socket file descriptor as "ready for reading", while +nevertheless a subsequent read blocks. +this could for example +happen when data has arrived but upon examination has the wrong +checksum and is discarded. +there may be other circumstances +in which a file descriptor is spuriously reported as ready. +.\" stevens discusses a case where accept can block after select +.\" returns successfully because of an intervening rst from the client. +thus it may be safer to use +.b o_nonblock +on sockets that should not block. +.\" maybe the kernel should have returned eio in such a situation? +.pp +on linux, +.br select () +also modifies +.i timeout +if the call is interrupted by a signal handler (i.e., the +.b eintr +error return). +this is not permitted by posix.1. +the linux +.br pselect () +system call has the same behavior, +but the glibc wrapper hides this behavior by internally copying the +.i timeout +to a local variable and passing that variable to the system call. +.sh examples +.ex +#include +#include +#include + +int +main(void) +{ + fd_set rfds; + struct timeval tv; + int retval; + + /* watch stdin (fd 0) to see when it has input. */ + + fd_zero(&rfds); + fd_set(0, &rfds); + + /* wait up to five seconds. */ + + tv.tv_sec = 5; + tv.tv_usec = 0; + + retval = select(1, &rfds, null, null, &tv); + /* don\(aqt rely on the value of tv now! */ + + if (retval == \-1) + perror("select()"); + else if (retval) + printf("data is available now.\en"); + /* fd_isset(0, &rfds) will be true. */ + else + printf("no data within five seconds.\en"); + + exit(exit_success); +} +.ee +.sh see also +.br accept (2), +.br connect (2), +.br poll (2), +.br read (2), +.br recv (2), +.br restart_syscall (2), +.br send (2), +.br sigprocmask (2), +.br write (2), +.br epoll (7), +.br time (7) +.pp +for a tutorial with discussion and examples, see +.br select_tut (2). +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sat jul 24 19:29:54 1993 by rik faith (faith@cs.unc.edu) +.th getgrent 3 2021-03-22 "" "linux programmer's manual" +.sh name +getgrent, setgrent, endgrent \- get group file entry +.sh synopsis +.nf +.b #include +.b #include +.pp +.b struct group *getgrent(void); +.pp +.b void setgrent(void); +.b void endgrent(void); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br setgrent (): +.nf + _xopen_source >= 500 +.\" || _xopen_source && _xopen_source_extended + || /* glibc since 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.pp +.br getgrent (), +.br endgrent (): +.nf + since glibc 2.22: + _xopen_source >= 500 || _default_source +.\" || _xopen_source && _xopen_source_extended + glibc 2.21 and earlier + _xopen_source >= 500 +.\" || _xopen_source && _xopen_source_extended + || /* since glibc 2.12: */ _posix_c_source >= 200809l + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.sh description +the +.br getgrent () +function returns a pointer to a structure containing +the broken-out fields of a record in the group database +(e.g., the local group file +.ir /etc/group , +nis, and ldap). +the first time +.br getgrent () +is called, +it returns the first entry; thereafter, it returns successive entries. +.pp +the +.br setgrent () +function rewinds to the beginning +of the group database, to allow repeated scans. +.pp +the +.br endgrent () +function is used to close the group database +after all processing has been performed. +.pp +the \figroup\fp structure is defined in \fi\fp as follows: +.pp +.in +4n +.ex +struct group { + char *gr_name; /* group name */ + char *gr_passwd; /* group password */ + gid_t gr_gid; /* group id */ + char **gr_mem; /* null\-terminated array of pointers + to names of group members */ +}; +.ee +.in +.pp +for more information about the fields of this structure, see +.br group (5). +.sh return value +the +.br getgrent () +function returns a pointer to a +.i group +structure, +or null if there are no more entries or an error occurs. +.pp +upon error, +.i errno +may be set. +if one wants to check +.i errno +after the call, it should be set to zero before the call. +.pp +the return value may point to a static area, and may be overwritten +by subsequent calls to +.br getgrent (), +.br getgrgid (3), +or +.br getgrnam (3). +(do not pass the returned pointer to +.br free (3).) +.sh errors +.tp +.b eagain +the service was temporarily unavailable; try again later. +for nss backends in glibc this indicates a temporary error talking to the backend. +the error may correct itself, retrying later is suggested. +.tp +.b eintr +a signal was caught; see +.br signal (7). +.tp +.b eio +i/o error. +.tp +.b emfile +the per-process limit on the number of open file descriptors has been reached. +.tp +.b enfile +the system-wide limit on the total number of open files has been reached. +.tp +.\" not in posix +.b enoent +a necessary input file cannot be found. +for nss backends in glibc this indicates the backend is not correctly configured. +.tp +.b enomem +.\" not in posix +insufficient memory to allocate +.i group +structure. +.tp +.b erange +insufficient buffer space supplied. +.sh files +.tp +.i /etc/group +local group database file +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lb lb lbx +l l l. +interface attribute value +t{ +.br getgrent () +t} thread safety t{ +mt-unsafe race:grent +race:grentbuf locale +t} +t{ +.br setgrent (), +.br endgrent () +t} thread safety t{ +mt-unsafe race:grent locale +t} +.te +.hy +.ad +.sp 1 +.pp +in the above table, +.i grent +in +.i race:grent +signifies that if any of the functions +.br setgrent (), +.br getgrent (), +or +.br endgrent () +are used in parallel in different threads of a program, +then data races could occur. +.sh conforming to +posix.1-2001, posix.1-2008, svr4, 4.3bsd. +.sh see also +.br fgetgrent (3), +.br getgrent_r (3), +.br getgrgid (3), +.br getgrnam (3), +.br getgrouplist (3), +.br putgrent (3), +.br group (5) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2001 andries brouwer (aeb@cwi.nl) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th getcontext 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +getcontext, setcontext \- get or set the user context +.sh synopsis +.nf +.b #include +.pp +.bi "int getcontext(ucontext_t *" ucp ); +.bi "int setcontext(const ucontext_t *" ucp ); +.fi +.sh description +in a system v-like environment, one has the two types +.i mcontext_t +and +.i ucontext_t +defined in +.i +and the four functions +.br getcontext (), +.br setcontext (), +.br makecontext (3), +and +.br swapcontext (3) +that allow user-level context switching between multiple +threads of control within a process. +.pp +the +.i mcontext_t +type is machine-dependent and opaque. +the +.i ucontext_t +type is a structure that has at least +the following fields: +.pp +.in +4n +.ex +typedef struct ucontext_t { + struct ucontext_t *uc_link; + sigset_t uc_sigmask; + stack_t uc_stack; + mcontext_t uc_mcontext; + ... +} ucontext_t; +.ee +.in +.pp +with +.ir sigset_t +and +.i stack_t +defined in +.ir . +here +.i uc_link +points to the context that will be resumed +when the current context terminates (in case the current context +was created using +.br makecontext (3)), +.i uc_sigmask +is the +set of signals blocked in this context (see +.br sigprocmask (2)), +.i uc_stack +is the stack used by this context (see +.br sigaltstack (2)), +and +.i uc_mcontext +is the +machine-specific representation of the saved context, +that includes the calling thread's machine registers. +.pp +the function +.br getcontext () +initializes the structure +pointed to by +.i ucp +to the currently active context. +.pp +the function +.br setcontext () +restores the user context +pointed to by +.ir ucp . +a successful call does not return. +the context should have been obtained by a call of +.br getcontext (), +or +.br makecontext (3), +or received as the third argument to a signal +handler (see the discussion of the +.br sa_siginfo +flag in +.br sigaction (2)). +.pp +if the context was obtained by a call of +.br getcontext (), +program execution continues as if this call just returned. +.pp +if the context was obtained by a call of +.br makecontext (3), +program execution continues by a call to the function +.i func +specified as the second argument of that call to +.br makecontext (3). +when the function +.i func +returns, we continue with the +.i uc_link +member of the structure +.i ucp +specified as the +first argument of that call to +.br makecontext (3). +when this member is null, the thread exits. +.pp +if the context was obtained by a call to a signal handler, +then old standard text says that "program execution continues with the +program instruction following the instruction interrupted +by the signal". +however, this sentence was removed in susv2, +and the present verdict is "the result is unspecified". +.sh return value +when successful, +.br getcontext () +returns 0 and +.br setcontext () +does not return. +on error, both return \-1 and set +.i errno +to indicate the error. +.sh errors +none defined. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br getcontext (), +.br setcontext () +t} thread safety mt-safe race:ucp +.te +.hy +.ad +.sp 1 +.sh conforming to +susv2, posix.1-2001. +posix.1-2008 removes the specification of +.br getcontext (), +citing portability issues, and +recommending that applications be rewritten to use posix threads instead. +.sh notes +the earliest incarnation of this mechanism was the +.br setjmp (3)/ longjmp (3) +mechanism. +since that does not define +the handling of the signal context, the next stage was the +.br sigsetjmp (3)/ siglongjmp (3) +pair. +the present mechanism gives much more control. +on the other hand, +there is no easy way to detect whether a return from +.br getcontext () +is from the first call, or via a +.br setcontext () +call. +the user has to invent their own bookkeeping device, and a register +variable won't do since registers are restored. +.pp +when a signal occurs, the current user context is saved and +a new context is created by the kernel for the signal handler. +do not leave the handler using +.br longjmp (3): +it is undefined what would happen with contexts. +use +.br siglongjmp (3) +or +.br setcontext () +instead. +.sh see also +.br sigaction (2), +.br sigaltstack (2), +.br sigprocmask (2), +.br longjmp (3), +.br makecontext (3), +.br sigsetjmp (3), +.br signal (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/getmntent.3 + +.\" copyright (c) 2012 by michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th malloc_usable_size 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +malloc_usable_size \- obtain size of block of memory allocated from heap +.sh synopsis +.nf +.b #include +.pp +.bi "size_t malloc_usable_size(void *" ptr ); +.fi +.sh description +the +.br malloc_usable_size () +function returns the number of usable bytes in the block pointed to by +.ir ptr , +a pointer to a block of memory allocated by +.br malloc (3) +or a related function. +.sh return value +.br malloc_usable_size () +returns the number of usable bytes in +the block of allocated memory pointed to by +.ir ptr . +if +.i ptr +is null, 0 is returned. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br malloc_usable_size () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +this function is a gnu extension. +.sh notes +the value returned by +.br malloc_usable_size () +may be greater than the requested size of the allocation because +of alignment and minimum size constraints. +although the excess bytes can be overwritten by the application +without ill effects, +this is not good programming practice: +the number of excess bytes in an allocation depends on +the underlying implementation. +.pp +the main use of this function is for debugging and introspection. +.sh see also +.br malloc (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man4/random.4 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" and (c) copyright 2015 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified 1993-07-25 by rik faith (faith@cs.unc.edu) +.\" modified 2004-10-31 by aeb +.\" +.th resolver 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +res_ninit, res_nclose, res_nquery, res_nsearch, res_nquerydomain, res_nmkquery, res_nsend, +res_init, res_query, res_search, res_querydomain, res_mkquery, res_send, +dn_comp, dn_expand \- resolver routines +.sh synopsis +.nf +.b #include +.b #include +.b #include +.pp +.b struct __res_state; +.b typedef struct __res_state *res_state; +.pp +.bi "int res_ninit(res_state " statep ); +.pp +.bi "void res_nclose(res_state " statep ); +.pp +.bi "int res_nquery(res_state " statep , +.bi " const char *" dname ", int " class ", int " type , +.bi " unsigned char *" answer ", int " anslen ); +.pp +.bi "int res_nsearch(res_state " statep , +.bi " const char *" dname ", int " class ", int " type , +.bi " unsigned char *" answer ", int " anslen ); +.pp +.bi "int res_nquerydomain(res_state " statep , +.bi " const char *" name ", const char *" domain , +.bi " int " class ", int " type ", unsigned char *" answer , +.bi " int " anslen ); +.pp +.bi "int res_nmkquery(res_state " statep , +.bi " int " op ", const char *" dname ", int " class , +.bi " int " type ", const unsigned char *" data ", int " datalen , +.bi " const unsigned char *" newrr , +.bi " unsigned char *" buf ", int " buflen ); +.pp +.bi "int res_nsend(res_state " statep , +.bi " const unsigned char *" msg ", int " msglen , +.bi " unsigned char *" answer ", int " anslen ); +.pp +.bi "int dn_comp(const char *" exp_dn ", unsigned char *" comp_dn , +.bi " int " length ", unsigned char **" dnptrs , +.bi " unsigned char **" lastdnptr ); +.pp +.bi "int dn_expand(const unsigned char *" msg , +.bi " const unsigned char *" eomorig , +.bi " const unsigned char *" comp_dn ", char *" exp_dn , +.bi " int " length ); +.fi +.\" +.ss deprecated +.nf +.b extern struct __res_state _res; +.pp +.b int res_init(void); +.pp +.bi "int res_query(const char *" dname ", int " class ", int " type , +.bi " unsigned char *" answer ", int " anslen ); +.pp +.bi "int res_search(const char *" dname ", int " class ", int " type , +.bi " unsigned char *" answer ", int " anslen ); +.pp +.bi "int res_querydomain(const char *" name ", const char *" domain , +.bi " int " class ", int " type ", unsigned char *" answer , +.bi " int " anslen ); +.pp +.bi "int res_mkquery(int " op ", const char *" dname ", int " class , +.bi " int " type ", const unsigned char *" data ", int " datalen , +.bi " const unsigned char *" newrr , +.bi " unsigned char *" buf ", int " buflen ); +.pp +.bi "int res_send(const unsigned char *" msg ", int " msglen , +.bi " unsigned char *" answer ", int " anslen ); +.fi +.pp +link with \fi\-lresolv\fp. +.sh description +.b note: +this page is incomplete (various resolver functions provided by glibc +are not described) and likely out of date. +.pp +the functions described below make queries to and interpret +the responses from internet domain name servers. +.pp +the api consists of a set of more modern, reentrant functions +and an older set of nonreentrant functions that have been superseded. +the traditional resolver interfaces such as +.br res_init () +and +.br res_query () +use some static (global) state stored in the +.i _res +structure, rendering these functions non-thread-safe. +bind 8.2 introduced a set of new interfaces +.br res_ninit (), +.br res_nquery (), +and so on, which take a +.i res_state +as their first argument, so you can use a per-thread resolver state. +.pp +the +.br res_ninit () +and +.br res_init () +functions read the configuration files (see +.br resolv.conf (5)) +to get the default domain name and name +server address(es). +if no server is given, the local host is tried. +if no domain is given, that associated with the local host is used. +it can be overridden with the environment variable +.br localdomain . +.br res_ninit () +or +.br res_init () +is normally executed by the first call to one of the +other functions. +every call to +.br res_ninit () +requires a corresponding call to +.br res_nclose () +to free memory allocated by +.br res_ninit () +and subsequent calls to +.br res_nquery (). +.pp +the +.br res_nquery () +and +.br res_query () +functions query the name server for the +fully qualified domain name \finame\fp of specified \fitype\fp and +\ficlass\fp. +the reply is left in the buffer \fianswer\fp of length +\fianslen\fp supplied by the caller. +.pp +the +.br res_nsearch () +and +.br res_search () +functions make a query and waits for the response like +.br res_nquery () +and +.br res_query (), +but in addition they implement the default and search +rules controlled by +.b res_defnames +and +.b res_dnsrch +(see description of +\fi_res\fp options below). +.pp +the +.br res_nquerydomain () +and +.br res_querydomain () +functions make a query using +.br res_nquery ()/ res_query () +on the concatenation of \finame\fp and \fidomain\fp. +.pp +the following functions are lower-level routines used by +.br res_nquery ()/ res_query (). +.pp +the +.br res_nmkquery () +and +.br res_mkquery () +functions construct a query message in \fibuf\fp +of length \fibuflen\fp for the domain name \fidname\fp. +the query type +\fiop\fp is one of the following (typically +.br query ): +.tp +.b query +standard query. +.tp +.b iquery +inverse query. +this option was removed in glibc 2.26, +.\" commit e4e794841e3140875f2aa86b90e2ada3d61e1244 +since it has not been supported by dns servers for a very long time. +.tp +.b ns_notify_op +notify secondary of soa (start of authority) change. +.pp +\finewrr\fp is currently unused. +.pp +the +.br res_nsend () +and +.br res_send () +function send a preformatted query given in +\fimsg\fp of length \fimsglen\fp and returns the answer in \fianswer\fp +which is of length \fianslen\fp. +they will call +.br res_ninit ()/ res_init () +if it has not already been called. +.pp +the +.br dn_comp () +function compresses the domain name \fiexp_dn\fp +and stores it in the buffer \ficomp_dn\fp of length \filength\fp. +the compression uses an array of pointers \fidnptrs\fp to previously +compressed names in the current message. +the first pointer points +to the beginning of the message and the list ends with null. +the limit of the array is specified by \filastdnptr\fp. +if \fidnptr\fp is null, domain names are not compressed. +if \filastdnptr\fp is null, the list +of labels is not updated. +.pp +the +.br dn_expand () +function expands the compressed domain name +\ficomp_dn\fp to a full domain name, which is placed in the buffer +\fiexp_dn\fp of size \filength\fp. +the compressed name is contained +in a query or reply message, and \fimsg\fp points to the beginning of +the message. +.pp +the resolver routines use configuration and state information +contained in a +.ir __res_state +structure (either passed as the +.ir statep +argument, or in the global variable +.ir _res , +in the case of the older nonreentrant functions). +the only field of this structure that is normally manipulated by the +user is the +.ir options +field. +this field can contain the bitwise "or" +of the following options: +.tp +.b res_init +true if +.br res_ninit () +or +.br res_init () +has been called. +.tp +.b res_debug +print debugging messages. +this option is available only if glibc was built with debugging enabled, +.\" see resolv/readme. +.\" support for res_debug was made conditional in glibc 2.2. +which is not the default. +.tp +.br res_aaonly " (unimplemented; deprecated in glibc 2.25)" +accept authoritative answers only. +.br res_send () +continues until +it finds an authoritative answer or returns an error. +this option was present but unimplemented in glibc until version 2.24; +since glibc 2.25, it is deprecated, and its usage produces a warning. +.tp +.b res_usevc +use tcp connections for queries rather than udp datagrams. +.tp +.br res_primary " (unimplemented; deprecated in glibc 2.25)" +query primary domain name server only. +this option was present but unimplemented in glibc until version 2.24; +since glibc 2.25, it is deprecated, and its usage produces a warning. +.tp +.b res_igntc +ignore truncation errors. +don't retry with tcp. +.tp +.b res_recurse +set the recursion desired bit in queries. +recursion is carried out +by the domain name server, not by +.br res_send (). +[enabled by default]. +.tp +.b res_defnames +if set, +.br res_search () +will append the default domain name to +single component names\(emthat is, those that do not contain a dot. +[enabled by default]. +.tp +.b res_stayopen +used with +.b res_usevc +to keep the tcp connection open between queries. +.tp +.b res_dnsrch +if set, +.br res_search () +will search for hostnames in the current +domain and in parent domains. +this option is used by +.br gethostbyname (3). +[enabled by default]. +.tp +.b res_insecure1 +accept a response from a wrong server. +this can be used to detect potential security hazards, +but you need to compile glibc with debugging enabled and use +.b res_debug +option (for debug purpose only). +.tp +.b res_insecure2 +accept a response which contains a wrong query. +this can be used to detect potential security hazards, +but you need to compile glibc with debugging enabled and use +.b res_debug +option (for debug purpose only). +.tp +.b res_noaliases +disable usage of +.b hostaliases +environment variable. +.tp +.b res_use_inet6 +try an aaaa query before an a query inside the +.br gethostbyname (3) +function, and map ipv4 responses in ipv6 "tunneled form" if no aaaa records +are found but an a record set exists. +since glibc 2.25, this option is deprecated, +and its usage produces a warning; +applications should use +.br getaddrinfo (3), +rather than +.br gethostbyname (3). +.tp +.b res_rotate +causes round-robin selection of name servers from among those listed. +this has the effect of spreading the query load among all listed servers, +rather than having all clients try the first listed server first every +time. +.tp +.br res_nocheckname " (unimplemented; deprecated in glibc 2.25)" +disable the modern bind checking of incoming hostnames and mail names +for invalid characters such as underscore (_), non-ascii, +or control characters. +this option was present in glibc until version 2.24; +since glibc 2.25, it is deprecated, and its usage produces a warning. +.tp +.br res_keeptsig " (unimplemented; deprecated in glibc 2.25)" +do not strip tsig records. +this option was present but unimplemented in glibc until version 2.24; +since glibc 2.25, it is deprecated, and its usage produces a warning. +.tp +.br res_blast " (unimplemented; deprecated in glibc 2.25)" +send each query simultaneously and recursively to all servers. +this option was present but unimplemented in glibc until version 2.24; +since glibc 2.25, it is deprecated, and its usage produces a warning. +.tp +.br res_usebstring " (glibc 2.3.4 to 2.24)" +make reverse ipv6 lookups using the bit-label format described in rfc 2673; +if this option is not set (which is the default), then nibble format is used. +this option was removed in glibc 2.25, +since it relied on a backward-incompatible +dns extension that was never deployed on the internet. +.tp +.br res_noip6dotint " (glibc 2.24 and earlier)" +use +.i ip6.arpa +zone in ipv6 reverse lookup instead of +.ir ip6.int , +which is deprecated since glibc 2.3.4. +this option is present in glibc up to and including version 2.24, +where it is enabled by default. +in glibc 2.25, this option was removed. +.tp +.br res_use_edns0 " (since glibc 2.6)" +enables support for the dns extensions (edns0) described in rfc 2671. +.tp +.br res_snglkup " (since glibc 2.10)" +by default, glibc performs ipv4 and ipv6 lookups in parallel since +version 2.9. +some appliance dns servers cannot handle these queries properly +and make the requests time out. +this option disables the behavior and makes glibc +perform the ipv6 and ipv4 requests sequentially +(at the cost of some slowdown of the resolving process). +.tp +.b res_snglkupreop +when +.b res_snglkup +option is enabled, opens a new socket for the each request. +.tp +.b res_use_dnssec +use dnssec with ok bit in opt record. +this option implies +.br res_use_edns0 . +.tp +.b res_notldquery +do not look up unqualified name as a top-level domain (tld). +.tp +.b res_default +default option which implies: +.br res_recurse , +.br res_defnames , +.br res_dnsrch , +and +.br res_noip6dotint . +.\" +.sh return value +the +.br res_ninit () +and +.br res_init () +functions return 0 on success, or \-1 if an error +occurs. +.pp +the +.br res_nquery (), +.br res_query (), +.br res_nsearch (), +.br res_search (), +.br res_nquerydomain (), +.br res_querydomain (), +.br res_nmkquery (), +.br res_mkquery (), +.br res_nsend (), +and +.br res_send () +functions return the length +of the response, or \-1 if an error occurs. +.pp +the +.br dn_comp () +and +.br dn_expand () +functions return the length +of the compressed name, or \-1 if an error occurs. +.pp +in the case of an error return from +.br res_nquery (), +.br res_query (), +.br res_nsearch (), +.br res_search (), +.br res_nquerydomain (), +or +.br res_querydomain (), +the global variable +.i h_errno +(see +.br gethostbyname (3)) +can be consulted to determine the cause of the error. +.sh files +.tp +.i /etc/resolv.conf +resolver configuration file +.tp +.i /etc/host.conf +resolver configuration file +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br res_ninit (), +.br res_nclose (), +.br res_nquery (), +.br res_nsearch (), +.br res_nquerydomain (), +.br res_nsend () +t} thread safety mt-safe locale +t{ +.br res_nmkquery (), +.br dn_comp (), +.br dn_expand () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +4.3bsd. +.sh see also +.br gethostbyname (3), +.br resolv.conf (5), +.br resolver (5), +.br hostname (7), +.br named (8) +.pp +the gnu c library source file +.ir resolv/readme . +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/scandir.3 + +.\" copyright 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th getprotoent_r 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +getprotoent_r, getprotobyname_r, getprotobynumber_r \- get +protocol entry (reentrant) +.sh synopsis +.nf +.b #include +.pp +.bi "int getprotoent_r(struct protoent *restrict " result_buf , +.bi " char *restrict " buf ", size_t " buflen , +.bi " struct protoent **restrict " result ); +.bi "int getprotobyname_r(const char *restrict " name , +.bi " struct protoent *restrict " result_buf , +.bi " char *restrict " buf ", size_t " buflen , +.bi " struct protoent **restrict " result ); +.bi "int getprotobynumber_r(int " proto , +.bi " struct protoent *restrict " result_buf , +.bi " char *restrict " buf ", size_t " buflen , +.bi " struct protoent **restrict " result ); +.pp +.fi +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br getprotoent_r (), +.br getprotobyname_r (), +.br getprotobynumber_r (): +.nf + since glibc 2.19: + _default_source + glibc 2.19 and earlier: + _bsd_source || _svid_source +.fi +.sh description +the +.br getprotoent_r (), +.br getprotobyname_r (), +and +.br getprotobynumber_r () +functions are the reentrant equivalents of, respectively, +.br getprotoent (3), +.br getprotobyname (3), +and +.br getprotobynumber (3). +they differ in the way that the +.i protoent +structure is returned, +and in the function calling signature and return value. +this manual page describes just the differences from +the nonreentrant functions. +.pp +instead of returning a pointer to a statically allocated +.i protoent +structure as the function result, +these functions copy the structure into the location pointed to by +.ir result_buf . +.pp +the +.i buf +array is used to store the string fields pointed to by the returned +.i protoent +structure. +(the nonreentrant functions allocate these strings in static storage.) +the size of this array is specified in +.ir buflen . +if +.i buf +is too small, the call fails with the error +.br erange , +and the caller must try again with a larger buffer. +(a buffer of length 1024 bytes should be sufficient for most applications.) +.\" i can find no information on the required/recommended buffer size; +.\" the nonreentrant functions use a 1024 byte buffer. +.\" the 1024 byte value is also what the solaris man page suggests. -- mtk +.pp +if the function call successfully obtains a protocol record, then +.i *result +is set pointing to +.ir result_buf ; +otherwise, +.i *result +is set to null. +.sh return value +on success, these functions return 0. +on error, they return one of the positive error numbers listed in errors. +.pp +on error, record not found +.rb ( getprotobyname_r (), +.br getprotobynumber_r ()), +or end of input +.rb ( getprotoent_r ()) +.i result +is set to null. +.sh errors +.tp +.b enoent +.rb ( getprotoent_r ()) +no more records in database. +.tp +.b erange +.i buf +is too small. +try again with a larger buffer +(and increased +.ir buflen ). +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br getprotoent_r (), +.br getprotobyname_r (), +.br getprotobynumber_r () +t} thread safety mt-safe locale +.te +.hy +.ad +.sp 1 +.sh conforming to +these functions are gnu extensions. +functions with similar names exist on some other systems, +though typically with different calling signatures. +.sh examples +the program below uses +.br getprotobyname_r () +to retrieve the protocol record for the protocol named +in its first command-line argument. +if a second (integer) command-line argument is supplied, +it is used as the initial value for +.ir buflen ; +if +.br getprotobyname_r () +fails with the error +.br erange , +the program retries with larger buffer sizes. +the following shell session shows a couple of sample runs: +.pp +.in +4n +.ex +.rb "$" " ./a.out tcp 1" +erange! retrying with larger buffer +getprotobyname_r() returned: 0 (success) (buflen=78) +p_name=tcp; p_proto=6; aliases=tcp +.rb "$" " ./a.out xxx 1" +erange! retrying with larger buffer +getprotobyname_r() returned: 0 (success) (buflen=100) +call failed/record not found +.ee +.in +.ss program source +\& +.ex +#define _gnu_source +#include +#include +#include +#include +#include +#include + +#define max_buf 10000 + +int +main(int argc, char *argv[]) +{ + int buflen, erange_cnt, s; + struct protoent result_buf; + struct protoent *result; + char buf[max_buf]; + + if (argc < 2) { + printf("usage: %s proto\-name [buflen]\en", argv[0]); + exit(exit_failure); + } + + buflen = 1024; + if (argc > 2) + buflen = atoi(argv[2]); + + if (buflen > max_buf) { + printf("exceeded buffer limit (%d)\en", max_buf); + exit(exit_failure); + } + + erange_cnt = 0; + do { + s = getprotobyname_r(argv[1], &result_buf, + buf, buflen, &result); + if (s == erange) { + if (erange_cnt == 0) + printf("erange! retrying with larger buffer\en"); + erange_cnt++; + + /* increment a byte at a time so we can see exactly + what size buffer was required. */ + + buflen++; + + if (buflen > max_buf) { + printf("exceeded buffer limit (%d)\en", max_buf); + exit(exit_failure); + } + } + } while (s == erange); + + printf("getprotobyname_r() returned: %s (buflen=%d)\en", + (s == 0) ? "0 (success)" : (s == enoent) ? "enoent" : + strerror(s), buflen); + + if (s != 0 || result == null) { + printf("call failed/record not found\en"); + exit(exit_failure); + } + + printf("p_name=%s; p_proto=%d; aliases=", + result_buf.p_name, result_buf.p_proto); + for (char **p = result_buf.p_aliases; *p != null; p++) + printf("%s ", *p); + printf("\en"); + + exit(exit_success); +} +.ee +.sh see also +.br getprotoent (3), +.br protocols (5) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/listxattr.2 + +.so man3/exp2.3 + + +.\" copyright (c) 2015 michael kerrisk +.\" +.\" %%%license_start(gplv2+) +.\" +.\" this program is free software; you can redistribute it and/or modify +.\" it under the terms of the gnu general public license as published by +.\" the free software foundation; either version 2 of the license, or +.\" (at your option) any later version. +.\" +.\" this program 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th posix_madvise 3 2021-03-22 linux "linux programmer's manual" +.sh name +posix_madvise \- give advice about patterns of memory usage +.sh synopsis +.nf +.b #include +.pp +.bi "int posix_madvise(void *" addr ", size_t " len ", int " advice ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br posix_madvise (): +.nf + _posix_c_source >= 200112l +.fi +.sh description +the +.br posix_madvise () +function allows an application to advise the system about its expected +patterns of usage of memory in the address range starting at +.i addr +and continuing for +.i len +bytes. +the system is free to use this advice in order to improve the performance +of memory accesses (or to ignore the advice altogether), but calling +.br posix_madvise () +shall not affect the semantics of access to memory in the specified range. +.pp +the +.i advice +argument is one of the following: +.tp +.b posix_madv_normal +the application has no special advice regarding its memory usage patterns +for the specified address range. +this is the default behavior. +.tp +.b posix_madv_sequential +the application expects to access the specified address range sequentially, +running from lower addresses to higher addresses. +hence, pages in this region can be aggressively read ahead, +and may be freed soon after they are accessed. +.tp +.b posix_madv_random +the application expects to access the specified address range randomly. +thus, read ahead may be less useful than normally. +.tp +.b posix_madv_willneed +the application expects to access the specified address range +in the near future. +thus, read ahead may be beneficial. +.tp +.b posix_madv_dontneed +the application expects that it will not access the specified address range +in the near future. +.sh return value +on success, +.br posix_madvise () +returns 0. +on failure, it returns a positive error number. +.sh errors +.tp +.b einval +.i addr +is not a multiple of the system page size or +.i len +is negative. +.tp +.b einval +.i advice +is invalid. +.tp +.b enomem +addresses in the specified range are partially or completely outside +the caller's address space. +.sh versions +support for +.br posix_madvise () +first appeared in glibc version 2.2. +.sh conforming to +posix.1-2001. +.sh notes +posix.1 permits an implementation to generate an error if +.i len +is 0. +on linux, specifying +.i len +as 0 is permitted (as a successful no-op). +.pp +in glibc, this function is implemented using +.br madvise (2). +however, since glibc 2.6, +.br posix_madv_dontneed +is treated as a no-op, because the corresponding +.br madvise (2) +value, +.br madv_dontneed , +has destructive semantics. +.sh see also +.br madvise (2), +.br posix_fadvise (2) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1993 +.\" the regents of the university of california. all rights reserved. +.\" +.\" %%%license_start(bsd_4_clause_ucb) +.\" redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. all advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" this product includes software developed by the university of +.\" california, berkeley and its contributors. +.\" 4. neither the name of the university nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" this software is provided by the regents and contributors ``as is'' and +.\" any express or implied warranties, including, but not limited to, the +.\" implied warranties of merchantability and fitness for a particular purpose +.\" are disclaimed. in no event shall the regents or contributors be liable +.\" for any direct, indirect, incidental, special, exemplary, or consequential +.\" damages (including, but not limited to, procurement of substitute goods +.\" or services; loss of use, data, or profits; or business interruption) +.\" however caused and on any theory of liability, whether in contract, strict +.\" liability, or tort (including negligence or otherwise) arising in any way +.\" out of the use of this software, even if advised of the possibility of +.\" such damage. +.\" %%%license_end +.\" +.\" @(#)daemon.3 8.1 (berkeley) 6/9/93 +.\" added mentioning of glibc weirdness wrt unistd.h. 5/11/98, al viro +.th daemon 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +daemon \- run in the background +.sh synopsis +.nf +.b #include +.pp +.bi "int daemon(int " nochdir ", int " noclose ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br daemon (): +.nf + since glibc 2.21: +.\" commit 266865c0e7b79d4196e2cc393693463f03c90bd8 + _default_source + in glibc 2.19 and 2.20: + _default_source || (_xopen_source && _xopen_source < 500) + up to and including glibc 2.19: + _bsd_source || (_xopen_source && _xopen_source < 500) +.fi +.sh description +the +.br daemon () +function is for programs wishing to detach themselves from the +controlling terminal and run in the background as system daemons. +.pp +if +.i nochdir +is zero, +.br daemon () +changes the process's current working directory +to the root directory ("/"); +otherwise, the current working directory is left unchanged. +.pp +if +.i noclose +is zero, +.br daemon () +redirects standard input, standard output, and standard error +to +.ir /dev/null ; +otherwise, no changes are made to these file descriptors. +.sh return value +(this function forks, and if the +.br fork (2) +succeeds, the parent calls +.\" not .ir in order not to underline _ +.br _exit (2), +so that further errors are seen by the child only.) +on success +.br daemon () +returns zero. +if an error occurs, +.br daemon () +returns \-1 and sets +.i errno +to any of the errors specified for the +.br fork (2) +and +.br setsid (2). +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br daemon () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +not in posix.1. +a similar function appears on the bsds. +the +.br daemon () +function first appeared in 4.4bsd. +.sh notes +the glibc implementation can also return \-1 when +.i /dev/null +exists but is not a character device with the expected +major and minor numbers. +in this case, +.i errno +need not be set. +.sh bugs +the gnu c library implementation of this function was taken from bsd, +and does not employ the double-fork technique (i.e., +.br fork (2), +.br setsid (2), +.br fork (2)) +that is necessary to ensure that the resulting daemon process is +not a session leader. +instead, the resulting daemon +.i is +a session leader. +.\" fixme . https://sourceware.org/bugzilla/show_bug.cgi?id=19144 +.\" tested using a program that uses daemon() and then opens an +.\" otherwise unused console device (/dev/ttyn) that does not +.\" have an associated getty process. +on systems that follow system v semantics (e.g., linux), +this means that if the daemon opens a terminal that is not +already a controlling terminal for another session, +then that terminal will inadvertently become +the controlling terminal for the daemon. +.sh see also +.br fork (2), +.br setsid (2), +.br daemon (7), +.br logrotate (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/malloc_hook.3 + +.so man3/statvfs.3 + +.\" copyright (c) 2019 by michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th pidfd_send_signal 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +pidfd_send_signal \- send a signal to a process specified by a file descriptor +.sh synopsis +.nf +.br "#include " " /* definition of " sig* " constants */" +.br "#include " " /* definition of " si_* " constants */" +.br "#include " " /* definition of " sys_* " constants */" +.b #include +.pp +.bi "int syscall(sys_pidfd_send_signal, int " pidfd ", int " sig \ +", siginfo_t *" info , +.bi " unsigned int " flags ); +.fi +.pp +.ir note : +glibc provides no wrapper for +.br pidfd_send_signal (), +necessitating the use of +.br syscall (2). +.sh description +the +.br pidfd_send_signal () +system call sends the signal +.i sig +to the target process referred to by +.ir pidfd , +a pid file descriptor that refers to a process. +.\" see the very detailed commit message for kernel commit +.\" 3eb39f47934f9d5a3027fe00d906a45fe3a15fad +.pp +if the +.i info +argument points to a +.i siginfo_t +buffer, that buffer should be populated as described in +.br rt_sigqueueinfo (2). +.pp +if the +.i info +argument is a null pointer, +this is equivalent to specifying a pointer to a +.i siginfo_t +buffer whose fields match the values that are +implicitly supplied when a signal is sent using +.br kill (2): +.pp +.pd 0 +.ip * 3 +.i si_signo +is set to the signal number; +.ip * +.i si_errno +is set to 0; +.ip * +.i si_code +is set to +.br si_user ; +.ip * +.i si_pid +is set to the caller's pid; and +.ip * +.i si_uid +is set to the caller's real user id. +.pd +.pp +the calling process must either be in the same pid namespace as the +process referred to by +.ir pidfd , +or be in an ancestor of that namespace. +.pp +the +.i flags +argument is reserved for future use; +currently, this argument must be specified as 0. +.sh return value +on success, +.br pidfd_send_signal () +returns 0. +on error, \-1 is returned and +.i errno +is set to indicate the error. +.sh errors +.tp +.b ebadf +.i pidfd +is not a valid pid file descriptor. +.tp +.b einval +.i sig +is not a valid signal. +.tp +.b einval +the calling process is not in a pid namespace from which it can +send a signal to the target process. +.tp +.b einval +.i flags +is not 0. +.tp +.b eperm +the calling process does not have permission to send the signal +to the target process. +.tp +.b eperm +.i pidfd +doesn't refer to the calling process, and +.ir info.si_code +is invalid (see +.br rt_sigqueueinfo (2)). +.tp +.b esrch +the target process does not exist +(i.e., it has terminated and been waited on). +.sh versions +.br pidfd_send_signal () +first appeared in linux 5.1. +.sh conforming to +.br pidfd_send_signal () +is linux specific. +.sh notes +.ss pid file descriptors +the +.i pidfd +argument is a pid file descriptor, +a file descriptor that refers to process. +such a file descriptor can be obtained in any of the following ways: +.ip * 3 +by opening a +.ir /proc/[pid] +directory; +.ip * +using +.br pidfd_open (2); +or +.ip * +via the pid file descriptor that is returned by a call to +.br clone (2) +or +.br clone3 (2) +that specifies the +.br clone_pidfd +flag. +.pp +the +.br pidfd_send_signal () +system call allows the avoidance of race conditions that occur +when using traditional interfaces (such as +.br kill (2)) +to signal a process. +the problem is that the traditional interfaces specify the target process +via a process id (pid), +with the result that the sender may accidentally send a signal to +the wrong process if the originally intended target process +has terminated and its pid has been recycled for another process. +by contrast, +a pid file descriptor is a stable reference to a specific process; +if that process terminates, +.br pidfd_send_signal () +fails with the error +.br esrch . +.sh examples +.ex +#define _gnu_source +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef __nr_pidfd_send_signal +#define __nr_pidfd_send_signal 424 +#endif + +static int +pidfd_send_signal(int pidfd, int sig, siginfo_t *info, + unsigned int flags) +{ + return syscall(__nr_pidfd_send_signal, pidfd, sig, info, flags); +} + +int +main(int argc, char *argv[]) +{ + siginfo_t info; + char path[path_max]; + int pidfd, sig; + + if (argc != 3) { + fprintf(stderr, "usage: %s \en", argv[0]); + exit(exit_failure); + } + + sig = atoi(argv[2]); + + /* obtain a pid file descriptor by opening the /proc/pid directory + of the target process. */ + + snprintf(path, sizeof(path), "/proc/%s", argv[1]); + + pidfd = open(path, o_rdonly); + if (pidfd == \-1) { + perror("open"); + exit(exit_failure); + } + + /* populate a \(aqsiginfo_t\(aq structure for use with + pidfd_send_signal(). */ + + memset(&info, 0, sizeof(info)); + info.si_code = si_queue; + info.si_signo = sig; + info.si_errno = 0; + info.si_uid = getuid(); + info.si_pid = getpid(); + info.si_value.sival_int = 1234; + + /* send the signal. */ + + if (pidfd_send_signal(pidfd, sig, &info, 0) == \-1) { + perror("pidfd_send_signal"); + exit(exit_failure); + } + + exit(exit_success); +} +.ee +.sh see also +.br clone (2), +.br kill (2), +.br pidfd_open (2), +.br rt_sigqueueinfo (2), +.br sigaction (2), +.br pid_namespaces (7), +.br signal (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/hypot.3 + +.so man3/list.3 + +.so man2/outb.2 + +.\" copyright (c) 1983, 1991 the regents of the university of california. +.\" all rights reserved. +.\" +.\" %%%license_start(bsd_4_clause_ucb) +.\" redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. all advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" this product includes software developed by the university of +.\" california, berkeley and its contributors. +.\" 4. neither the name of the university nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" this software is provided by the regents and contributors ``as is'' and +.\" any express or implied warranties, including, but not limited to, the +.\" implied warranties of merchantability and fitness for a particular purpose +.\" are disclaimed. in no event shall the regents or contributors be liable +.\" for any direct, indirect, incidental, special, exemplary, or consequential +.\" damages (including, but not limited to, procurement of substitute goods +.\" or services; loss of use, data, or profits; or business interruption) +.\" however caused and on any theory of liability, whether in contract, strict +.\" liability, or tort (including negligence or otherwise) arising in any way +.\" out of the use of this software, even if advised of the possibility of +.\" such damage. +.\" %%%license_end +.\" +.\" modified 1993-07-24 by rik faith +.\" modified 1996-10-22 by eric s. raymond +.\" modified oct 1998 by andi kleen +.\" modified oct 2003 by aeb +.\" modified 2004-07-01 by mtk +.\" +.th send 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +send, sendto, sendmsg \- send a message on a socket +.sh synopsis +.nf +.b #include +.pp +.bi "ssize_t send(int " sockfd ", const void *" buf ", size_t " len \ +", int " flags ); +.bi "ssize_t sendto(int " sockfd ", const void *" buf ", size_t " len \ +", int " flags , +.bi " const struct sockaddr *" dest_addr ", socklen_t " addrlen ); +.bi "ssize_t sendmsg(int " sockfd ", const struct msghdr *" msg \ +", int " flags ); +.fi +.sh description +the system calls +.br send (), +.br sendto (), +and +.br sendmsg () +are used to transmit a message to another socket. +.pp +the +.br send () +call may be used only when the socket is in a +.i connected +state (so that the intended recipient is known). +the only difference between +.br send () +and +.br write (2) +is the presence of +.ir flags . +with a zero +.i flags +argument, +.br send () +is equivalent to +.br write (2). +also, the following call +.pp + send(sockfd, buf, len, flags); +.pp +is equivalent to +.pp + sendto(sockfd, buf, len, flags, null, 0); +.pp +the argument +.i sockfd +is the file descriptor of the sending socket. +.pp +if +.br sendto () +is used on a connection-mode +.rb ( sock_stream , +.br sock_seqpacket ) +socket, the arguments +.i dest_addr +and +.i addrlen +are ignored (and the error +.b eisconn +may be returned when they are +not null and 0), and the error +.b enotconn +is returned when the socket was not actually connected. +otherwise, the address of the target is given by +.i dest_addr +with +.i addrlen +specifying its size. +for +.br sendmsg (), +the address of the target is given by +.ir msg.msg_name , +with +.i msg.msg_namelen +specifying its size. +.pp +for +.br send () +and +.br sendto (), +the message is found in +.i buf +and has length +.ir len . +for +.br sendmsg (), +the message is pointed to by the elements of the array +.ir msg.msg_iov . +the +.br sendmsg () +call also allows sending ancillary data (also known as control information). +.pp +if the message is too long to pass atomically through the +underlying protocol, the error +.b emsgsize +is returned, and the message is not transmitted. +.pp +no indication of failure to deliver is implicit in a +.br send (). +locally detected errors are indicated by a return value of \-1. +.pp +when the message does not fit into the send buffer of the socket, +.br send () +normally blocks, unless the socket has been placed in nonblocking i/o +mode. +in nonblocking mode it would fail with the error +.b eagain +or +.b ewouldblock +in this case. +the +.br select (2) +call may be used to determine when it is possible to send more data. +.ss the flags argument +the +.i flags +argument is the bitwise or +of zero or more of the following flags. +.\" fixme . ? document msg_proxy (which went away in 2.3.15) +.tp +.br msg_confirm " (since linux 2.3.15)" +tell the link layer that forward progress happened: you got a successful +reply from the other side. +if the link layer doesn't get this +it will regularly reprobe the neighbor (e.g., via a unicast arp). +valid only on +.b sock_dgram +and +.b sock_raw +sockets and currently implemented only for ipv4 and ipv6. +see +.br arp (7) +for details. +.tp +.b msg_dontroute +don't use a gateway to send out the packet, send to hosts only on +directly connected networks. +this is usually used only +by diagnostic or routing programs. +this is defined only for protocol +families that route; packet sockets don't. +.tp +.br msg_dontwait " (since linux 2.2)" +enables nonblocking operation; if the operation would block, +.b eagain +or +.b ewouldblock +is returned. +this provides similar behavior to setting the +.b o_nonblock +flag (via the +.br fcntl (2) +.b f_setfl +operation), but differs in that +.b msg_dontwait +is a per-call option, whereas +.b o_nonblock +is a setting on the open file description (see +.br open (2)), +which will affect all threads in the calling process +and as well as other processes that hold file descriptors +referring to the same open file description. +.tp +.br msg_eor " (since linux 2.2)" +terminates a record (when this notion is supported, as for sockets of type +.br sock_seqpacket ). +.tp +.br msg_more " (since linux 2.4.4)" +the caller has more data to send. +this flag is used with tcp sockets to obtain the same effect +as the +.b tcp_cork +socket option (see +.br tcp (7)), +with the difference that this flag can be set on a per-call basis. +.ip +since linux 2.6, this flag is also supported for udp sockets, and informs +the kernel to package all of the data sent in calls with this flag set +into a single datagram which is transmitted only when a call is performed +that does not specify this flag. +(see also the +.b udp_cork +socket option described in +.br udp (7).) +.tp +.br msg_nosignal " (since linux 2.2)" +don't generate a +.b sigpipe +signal if the peer on a stream-oriented socket has closed the connection. +the +.b epipe +error is still returned. +this provides similar behavior to using +.br sigaction (2) +to ignore +.br sigpipe , +but, whereas +.b msg_nosignal +is a per-call feature, +ignoring +.b sigpipe +sets a process attribute that affects all threads in the process. +.tp +.b msg_oob +sends +.i out-of-band +data on sockets that support this notion (e.g., of type +.br sock_stream ); +the underlying protocol must also support +.i out-of-band +data. +.ss sendmsg() +the definition of the +.i msghdr +structure employed by +.br sendmsg () +is as follows: +.pp +.in +4n +.ex +struct msghdr { + void *msg_name; /* optional address */ + socklen_t msg_namelen; /* size of address */ + struct iovec *msg_iov; /* scatter/gather array */ + size_t msg_iovlen; /* # elements in msg_iov */ + void *msg_control; /* ancillary data, see below */ + size_t msg_controllen; /* ancillary data buffer len */ + int msg_flags; /* flags (unused) */ +}; +.ee +.in +.pp +the +.i msg_name +field is used on an unconnected socket to specify the target +address for a datagram. +it points to a buffer containing the address; the +.i msg_namelen +field should be set to the size of the address. +for a connected socket, these fields should be specified as null and 0, +respectively. +.pp +the +.i msg_iov +and +.i msg_iovlen +fields specify scatter-gather locations, as for +.br writev (2). +.pp +you may send control information (ancillary data) using the +.i msg_control +and +.i msg_controllen +members. +the maximum control buffer length the kernel can process is limited +per socket by the value in +.ir /proc/sys/net/core/optmem_max ; +see +.br socket (7). +for further information on the use of ancillary data in various +socket domains, see +.br unix (7) +and +.br ip (7). +.pp +the +.i msg_flags +field is ignored. +.\" still to be documented: +.\" send file descriptors and user credentials using the +.\" msg_control* fields. +.sh return value +on success, these calls return the number of bytes sent. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +these are some standard errors generated by the socket layer. +additional errors +may be generated and returned from the underlying protocol modules; +see their respective manual pages. +.tp +.b eacces +(for unix domain sockets, which are identified by pathname) +write permission is denied on the destination socket file, +or search permission is denied for one of the directories +the path prefix. +(see +.br path_resolution (7).) +.ip +(for udp sockets) an attempt was made to send to a +network/broadcast address as though it was a unicast address. +.tp +.br eagain " or " ewouldblock +.\" actually eagain on linux +the socket is marked nonblocking and the requested operation +would block. +posix.1-2001 allows either error to be returned for this case, +and does not require these constants to have the same value, +so a portable application should check for both possibilities. +.tp +.b eagain +(internet domain datagram sockets) +the socket referred to by +.i sockfd +had not previously been bound to an address and, +upon attempting to bind it to an ephemeral port, +it was determined that all port numbers in the ephemeral port range +are currently in use. +see the discussion of +.i /proc/sys/net/ipv4/ip_local_port_range +in +.br ip (7). +.tp +.b ealready +another fast open is in progress. +.tp +.b ebadf +.i sockfd +is not a valid open file descriptor. +.tp +.b econnreset +connection reset by peer. +.tp +.b edestaddrreq +the socket is not connection-mode, and no peer address is set. +.tp +.b efault +an invalid user space address was specified for an argument. +.tp +.b eintr +a signal occurred before any data was transmitted; see +.br signal (7). +.tp +.b einval +invalid argument passed. +.tp +.b eisconn +the connection-mode socket was connected already but a +recipient was specified. +(now either this error is returned, or the recipient specification +is ignored.) +.tp +.b emsgsize +the socket type +.\" (e.g., sock_dgram ) +requires that message be sent atomically, and the size +of the message to be sent made this impossible. +.tp +.b enobufs +the output queue for a network interface was full. +this generally indicates that the interface has stopped sending, +but may be caused by transient congestion. +(normally, this does not occur in linux. +packets are just silently dropped +when a device queue overflows.) +.tp +.b enomem +no memory available. +.tp +.b enotconn +the socket is not connected, and no target has been given. +.tp +.b enotsock +the file descriptor +.i sockfd +does not refer to a socket. +.tp +.b eopnotsupp +some bit in the +.i flags +argument is inappropriate for the socket type. +.tp +.b epipe +the local end has been shut down on a connection oriented socket. +in this case, the process +will also receive a +.b sigpipe +unless +.b msg_nosignal +is set. +.sh conforming to +4.4bsd, svr4, posix.1-2001. +these interfaces first appeared in 4.2bsd. +.pp +posix.1-2001 describes only the +.b msg_oob +and +.b msg_eor +flags. +posix.1-2008 adds a specification of +.br msg_nosignal . +the +.b msg_confirm +flag is a linux extension. +.sh notes +according to posix.1-2001, the +.i msg_controllen +field of the +.i msghdr +structure should be typed as +.ir socklen_t , +and the +.i msg_iovlen +field should be typed as +.ir int , +but glibc currently types both as +.ir size_t . +.\" glibc bug for msg_controllen raised 12 mar 2006 +.\" http://sourceware.org/bugzilla/show_bug.cgi?id=2448 +.\" the problem is an underlying kernel issue: the size of the +.\" __kernel_size_t type used to type these fields varies +.\" across architectures, but socklen_t is always 32 bits, +.\" as (at least with gcc) is int. +.pp +see +.br sendmmsg (2) +for information about a linux-specific system call +that can be used to transmit multiple datagrams in a single call. +.sh bugs +linux may return +.b epipe +instead of +.br enotconn . +.sh examples +an example of the use of +.br sendto () +is shown in +.br getaddrinfo (3). +.sh see also +.br fcntl (2), +.br getsockopt (2), +.br recv (2), +.br select (2), +.br sendfile (2), +.br sendmmsg (2), +.br shutdown (2), +.br socket (2), +.br write (2), +.br cmsg (3), +.br ip (7), +.br ipv6 (7), +.br socket (7), +.br tcp (7), +.br udp (7), +.br unix (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/stdin.3 + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" iso/iec 9899:1999 +.\" +.th wcscspn 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +wcscspn \- search a wide-character string for any of a set of wide characters +.sh synopsis +.nf +.b #include +.pp +.bi "size_t wcscspn(const wchar_t *" wcs ", const wchar_t *" reject ); +.fi +.sh description +the +.br wcscspn () +function is the wide-character equivalent +of the +.br strcspn (3) +function. +it determines the length of the longest initial segment of +.i wcs +which consists entirely of wide-characters not listed in +.ir reject . +in +other words, it searches for the first occurrence in the wide-character +string +.i wcs +of any of the characters in the wide-character string +.ir reject . +.sh return value +the +.br wcscspn () +function returns the number of +wide characters in the longest +initial segment of +.i wcs +which consists entirely of wide-characters not +listed in +.ir reject . +in other words, it returns the position of the first +occurrence in the wide-character string +.i wcs +of any of the characters in +the wide-character string +.ir reject , +or +.ir wcslen(wcs) +if there is none. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br wcscspn () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh see also +.br strcspn (3), +.br wcspbrk (3), +.br wcsspn (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2007 by michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" 2007-06-13 creation +.\" +.th credentials 7 2020-11-01 "linux" "linux programmer's manual" +.sh name +credentials \- process identifiers +.sh description +.ss process id (pid) +each process has a unique nonnegative integer identifier +that is assigned when the process is created using +.br fork (2). +a process can obtain its pid using +.br getpid (2). +a pid is represented using the type +.i pid_t +(defined in +.ir ). +.pp +pids are used in a range of system calls to identify the process +affected by the call, for example: +.br kill (2), +.br ptrace (2), +.br setpriority (2) +.\" .br sched_rr_get_interval (2), +.\" .br sched_getaffinity (2), +.\" .br sched_setaffinity (2), +.\" .br sched_getparam (2), +.\" .br sched_setparam (2), +.\" .br sched_setscheduler (2), +.\" .br sched_getscheduler (2), +.br setpgid (2), +.\" .br getsid (2), +.br setsid (2), +.br sigqueue (3), +and +.br waitpid (2). +.\" .br waitid (2), +.\" .br wait4 (2), +.pp +a process's pid is preserved across an +.br execve (2). +.ss parent process id (ppid) +a process's parent process id identifies the process that created +this process using +.br fork (2). +a process can obtain its ppid using +.br getppid (2). +a ppid is represented using the type +.ir pid_t . +.pp +a process's ppid is preserved across an +.br execve (2). +.ss process group id and session id +each process has a session id and a process group id, +both represented using the type +.ir pid_t . +a process can obtain its session id using +.br getsid (2), +and its process group id using +.br getpgrp (2). +.pp +a child created by +.br fork (2) +inherits its parent's session id and process group id. +a process's session id and process group id are preserved across an +.br execve (2). +.pp +sessions and process groups are abstractions devised to support shell +job control. +a process group (sometimes called a "job") is a collection of +processes that share the same process group id; +the shell creates a new process group for the process(es) used +to execute single command or pipeline (e.g., the two processes +created to execute the command "ls\ |\ wc" are placed in the +same process group). +a process's group membership can be set using +.br setpgid (2). +the process whose process id is the same as its process group id is the +\fiprocess group leader\fp for that group. +.pp +a session is a collection of processes that share the same session id. +all of the members of a process group also have the same session id +(i.e., all of the members of a process group always belong to the +same session, so that sessions and process groups form a strict +two-level hierarchy of processes.) +a new session is created when a process calls +.br setsid (2), +which creates a new session whose session id is the same +as the pid of the process that called +.br setsid (2). +the creator of the session is called the \fisession leader\fp. +.pp +all of the processes in a session share a +.ir "controlling terminal" . +the controlling terminal is established when the session leader +first opens a terminal (unless the +.br o_noctty +flag is specified when calling +.br open (2)). +a terminal may be the controlling terminal of at most one session. +.pp +at most one of the jobs in a session may be the +.ir "foreground job" ; +other jobs in the session are +.ir "background jobs" . +only the foreground job may read from the terminal; +when a process in the background attempts to read from the terminal, +its process group is sent a +.br sigttin +signal, which suspends the job. +if the +.br tostop +flag has been set for the terminal (see +.br termios (3)), +then only the foreground job may write to the terminal; +writes from background job cause a +.br sigttou +signal to be generated, which suspends the job. +when terminal keys that generate a signal (such as the +.i interrupt +key, normally control-c) +are pressed, the signal is sent to the processes in the foreground job. +.pp +various system calls and library functions +may operate on all members of a process group, +including +.br kill (2), +.br killpg (3), +.br getpriority (2), +.br setpriority (2), +.br ioprio_get (2), +.br ioprio_set (2), +.br waitid (2), +and +.br waitpid (2). +see also the discussion of the +.br f_getown , +.br f_getown_ex , +.br f_setown , +and +.br f_setown_ex +operations in +.br fcntl (2). +.ss user and group identifiers +each process has various associated user and group ids. +these ids are integers, respectively represented using the types +.i uid_t +and +.i gid_t +(defined in +.ir ). +.pp +on linux, each process has the following user and group identifiers: +.ip * 3 +real user id and real group id. +these ids determine who owns the process. +a process can obtain its real user (group) id using +.br getuid (2) +.rb ( getgid (2)). +.ip * +effective user id and effective group id. +these ids are used by the kernel to determine the permissions +that the process will have when accessing shared resources such +as message queues, shared memory, and semaphores. +on most unix systems, these ids also determine the +permissions when accessing files. +however, linux uses the filesystem ids described below +for this task. +a process can obtain its effective user (group) id using +.br geteuid (2) +.rb ( getegid (2)). +.ip * +saved set-user-id and saved set-group-id. +these ids are used in set-user-id and set-group-id programs to save +a copy of the corresponding effective ids that were set when +the program was executed (see +.br execve (2)). +a set-user-id program can assume and drop privileges by +switching its effective user id back and forth between the values +in its real user id and saved set-user-id. +this switching is done via calls to +.br seteuid (2), +.br setreuid (2), +or +.br setresuid (2). +a set-group-id program performs the analogous tasks using +.br setegid (2), +.br setregid (2), +or +.br setresgid (2). +a process can obtain its saved set-user-id (set-group-id) using +.br getresuid (2) +.rb ( getresgid (2)). +.ip * +filesystem user id and filesystem group id (linux-specific). +these ids, in conjunction with the supplementary group ids described +below, are used to determine permissions for accessing files; see +.br path_resolution (7) +for details. +whenever a process's effective user (group) id is changed, +the kernel also automatically changes the filesystem user (group) id +to the same value. +consequently, the filesystem ids normally have the same values +as the corresponding effective id, and the semantics for file-permission +checks are thus the same on linux as on other unix systems. +the filesystem ids can be made to differ from the effective ids +by calling +.br setfsuid (2) +and +.br setfsgid (2). +.ip * +supplementary group ids. +this is a set of additional group ids that are used for permission +checks when accessing files and other shared resources. +on linux kernels before 2.6.4, +a process can be a member of up to 32 supplementary groups; +since kernel 2.6.4, +a process can be a member of up to 65536 supplementary groups. +the call +.i sysconf(_sc_ngroups_max) +can be used to determine the number of supplementary groups +of which a process may be a member. +.\" since kernel 2.6.4, the limit is visible via the read-only file +.\" /proc/sys/kernel/ngroups_max. +.\" as at 2.6.22-rc2, this file is still read-only. +a process can obtain its set of supplementary group ids using +.br getgroups (2). +.pp +a child process created by +.br fork (2) +inherits copies of its parent's user and groups ids. +during an +.br execve (2), +a process's real user and group id and supplementary +group ids are preserved; +the effective and saved set ids may be changed, as described in +.br execve (2). +.pp +aside from the purposes noted above, +a process's user ids are also employed in a number of other contexts: +.ip * 3 +when determining the permissions for sending signals (see +.br kill (2)); +.ip * +when determining the permissions for setting +process-scheduling parameters (nice value, real time +scheduling policy and priority, cpu affinity, i/o priority) using +.br setpriority (2), +.br sched_setaffinity (2), +.br sched_setscheduler (2), +.br sched_setparam (2), +.br sched_setattr (2), +and +.br ioprio_set (2); +.ip * +when checking resource limits (see +.br getrlimit (2)); +.ip * +when checking the limit on the number of inotify instances +that the process may create (see +.br inotify (7)). +.\" +.ss modifying process user and group ids +subject to rules described in the relevant manual pages, +a process can use the following apis to modify its user and group ids: +.tp +.br setuid "(2) (" setgid (2)) +modify the process's real (and possibly effective and saved-set) +user (group) ids. +.tp +.br seteuid "(2) (" setegid (2)) +modify the process's effective user (group) id. +.tp +.br setfsuid "(2) (" setfsgid (2)) +modify the process's filesystem user (group) id. +.tp +.br setreuid "(2) (" setregid (2)) +modify the process's real and effective (and possibly saved-set) +user (group) ids. +.tp +.br setresuid "(2) (" setresgid (2)) +modify the process's real, effective, and saved-set user (group) ids. +.tp +.br setgroups (2) +modify the process's supplementary group list. +.pp +any changes to a process's effective user (group) id +are automatically carried over to the process's +filesystem user (group) id. +changes to a process's effective user or group id can also affect the +process "dumpable" attribute, as described in +.br prctl (2). +.pp +changes to process user and group ids can affect the capabilities +of the process, as described in +.br capabilities (7). +.sh conforming to +process ids, parent process ids, process group ids, and session ids +are specified in posix.1. +the real, effective, and saved set user and groups ids, +and the supplementary group ids, are specified in posix.1. +the filesystem user and group ids are a linux extension. +.sh notes +various fields in the +.ir /proc/[pid]/status +file show the process credentials described above. +see +.br proc (5) +for further information. +.pp +the posix threads specification requires that +credentials are shared by all of the threads in a process. +however, at the kernel level, linux maintains separate user and group +credentials for each thread. +the nptl threading implementation does some work to ensure +that any change to user or group credentials +(e.g., calls to +.br setuid (2), +.br setresuid (2)) +is carried through to all of the posix threads in a process. +see +.br nptl (7) +for further details. +.sh see also +.br bash (1), +.br csh (1), +.br groups (1), +.br id (1), +.br newgrp (1), +.br ps (1), +.br runuser (1), +.br setpriv (1), +.br sg (1), +.br su (1), +.br access (2), +.br execve (2), +.br faccessat (2), +.br fork (2), +.br getgroups (2), +.br getpgrp (2), +.br getpid (2), +.br getppid (2), +.br getsid (2), +.br kill (2), +.br setegid (2), +.br seteuid (2), +.br setfsgid (2), +.br setfsuid (2), +.br setgid (2), +.br setgroups (2), +.br setpgid (2), +.br setresgid (2), +.br setresuid (2), +.br setsid (2), +.br setuid (2), +.br waitpid (2), +.br euidaccess (3), +.br initgroups (3), +.br killpg (3), +.br tcgetpgrp (3), +.br tcgetsid (3), +.br tcsetpgrp (3), +.br group (5), +.br passwd (5), +.br shadow (5), +.br capabilities (7), +.br namespaces (7), +.br path_resolution (7), +.br pid_namespaces (7), +.br pthreads (7), +.br signal (7), +.br system_data_types (7), +.br unix (7), +.br user_namespaces (7), +.br sudo (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sat jul 24 18:06:49 1993 by rik faith (faith@cs.unc.edu) +.\" modified fri aug 25 23:17:51 1995 by andries brouwer (aeb@cwi.nl) +.\" modified wed dec 18 00:47:18 1996 by andries brouwer (aeb@cwi.nl) +.\" 2007-06-15, marc boyer + mtk +.\" improve discussion of strncpy(). +.\" +.th strcpy 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +strcpy, strncpy \- copy a string +.sh synopsis +.nf +.b #include +.pp +.bi "char *strcpy(char *restrict " dest ", const char *" src ); +.bi "char *strncpy(char *restrict " dest ", const char *restrict " src \ +", size_t " n ); +.fi +.sh description +the +.br strcpy () +function copies the string pointed to by +.ir src , +including the terminating null byte (\(aq\e0\(aq), +to the buffer pointed to by +.ir dest . +the strings may not overlap, and the destination string +.i dest +must be large enough to receive the copy. +.ir "beware of buffer overruns!" +(see bugs.) +.pp +the +.br strncpy () +function is similar, except that at most +.i n +bytes of +.i src +are copied. +.br warning : +if there is no null byte +among the first +.i n +bytes of +.ir src , +the string placed in +.i dest +will not be null-terminated. +.pp +if the length of +.i src +is less than +.ir n , +.br strncpy () +writes additional null bytes to +.i dest +to ensure that a total of +.i n +bytes are written. +.pp +a simple implementation of +.br strncpy () +might be: +.pp +.in +4n +.ex +char * +strncpy(char *dest, const char *src, size_t n) +{ + size_t i; + + for (i = 0; i < n && src[i] != \(aq\e0\(aq; i++) + dest[i] = src[i]; + for ( ; i < n; i++) + dest[i] = \(aq\e0\(aq; + + return dest; +} +.ee +.in +.sh return value +the +.br strcpy () +and +.br strncpy () +functions return a pointer to +the destination string +.ir dest . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br strcpy (), +.br strncpy () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c89, c99, svr4, 4.3bsd. +.sh notes +some programmers consider +.br strncpy () +to be inefficient and error prone. +if the programmer knows (i.e., includes code to test!) +that the size of +.i dest +is greater than +the length of +.ir src , +then +.br strcpy () +can be used. +.pp +one valid (and intended) use of +.br strncpy () +is to copy a c string to a fixed-length buffer +while ensuring both that the buffer is not overflowed +and that unused bytes in the destination buffer are zeroed out +(perhaps to prevent information leaks if the buffer is to be +written to media or transmitted to another process via an +interprocess communication technique). +.pp +if there is no terminating null byte in the first +.i n +bytes of +.ir src , +.br strncpy () +produces an unterminated string in +.ir dest . +if +.i buf +has length +.ir buflen , +you can force termination using something like the following: +.pp +.in +4n +.ex +if (buflen > 0) { + strncpy(buf, str, buflen \- 1); + buf[buflen \- 1]= \(aq\e0\(aq; +} +.ee +.in +.pp +(of course, the above technique ignores the fact that, if +.i src +contains more than +.i "buflen\ \-\ 1" +bytes, information is lost in the copying to +.ir dest .) +.\" +.ss strlcpy() +some systems (the bsds, solaris, and others) provide the following function: +.pp + size_t strlcpy(char *dest, const char *src, size_t size); +.pp +.\" http://static.usenix.org/event/usenix99/full_papers/millert/millert_html/index.html +.\" "strlcpy and strlcat - consistent, safe, string copy and concatenation" +.\" 1999 usenix annual technical conference +this function is similar to +.br strncpy (), +but it copies at most +.i size\-1 +bytes to +.ir dest , +always adds a terminating null byte, +and does not pad the destination with (further) null bytes. +this function fixes some of the problems of +.br strcpy () +and +.br strncpy (), +but the caller must still handle the possibility of data loss if +.i size +is too small. +the return value of the function is the length of +.ir src , +which allows truncation to be easily detected: +if the return value is greater than or equal to +.ir size , +truncation occurred. +if loss of data matters, the caller +.i must +either check the arguments before the call, +or test the function return value. +.br strlcpy () +is not present in glibc and is not standardized by posix, +.\" https://lwn.net/articles/506530/ +but is available on linux via the +.ir libbsd +library. +.sh bugs +if the destination string of a +.br strcpy () +is not large enough, then anything might happen. +overflowing fixed-length string buffers is a favorite cracker technique +for taking complete control of the machine. +any time a program reads or copies data into a buffer, +the program first needs to check that there's enough space. +this may be unnecessary if you can show that overflow is impossible, +but be careful: programs can get changed over time, +in ways that may make the impossible possible. +.sh see also +.br bcopy (3), +.br memccpy (3), +.br memcpy (3), +.br memmove (3), +.br stpcpy (3), +.br stpncpy (3), +.br strdup (3), +.br string (3), +.br wcscpy (3), +.br wcsncpy (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/getutent.3 + +.so man3/stdio_ext.3 + +.so man3/getprotoent.3 + +.\" copyright (c) 2015-2016, alec leamas +.\" copyright (c) 2018, sean young +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.th lirc 4 2019-03-06 "linux" "linux programmer's manual" +.sh name +lirc \- lirc devices +.sh description +the +.i /dev/lirc* +character devices provide a low-level +bidirectional interface to infra-red (ir) remotes. +most of these devices can receive, and some can send. +when receiving or sending data, the driver works in two different modes +depending on the underlying hardware. +.pp +some hardware (typically tv-cards) decodes the ir signal internally +and provides decoded button presses as scancode values. +drivers for this kind of hardware work in +.br lirc_mode_scancode +mode. +such hardware usually does not support sending ir signals. +furthermore, such hardware can only decode a limited set of ir protocols, +usually only the protocol of the specific remote which is +bundled with, for example, a tv-card. +.pp +other hardware provides a stream of pulse/space durations. +such drivers work in +.br lirc_mode_mode2 +mode. +sometimes, this kind of hardware also supports +sending ir data. +such hardware can be used with (almost) any kind of remote. +this type of hardware can also be used in +.br lirc_mode_scancode +mode, in which case the kernel ir decoders will decode the ir. +these decoders can be written in extended bpf (see +.br bpf (2)) +and attached to the +.b lirc +device. +.pp +the \fblirc_get_features\fr ioctl (see below) allows probing for whether +receiving and sending is supported, and in which modes, amongst other +features. +.\" +.ss reading input with the lirc_mode_mode2 mode +in the \fblirc_mode_mode2 mode\fr, the data returned by +.br read (2) +provides 32-bit values representing a space or a pulse duration. +the time of the duration (microseconds) is encoded in the lower 24 bits. +the upper 8 bits indicate the type of package: +.tp 4 +.br lirc_mode2_space +value reflects a space duration (microseconds). +.tp 4 +.br lirc_mode2_pulse +value reflects a pulse duration (microseconds). +.tp 4 +.br lirc_mode2_frequency +value reflects a frequency (hz); see the +.b lirc_set_measure_carrier_mode +ioctl. +.tp 4 +.br lirc_mode2_timeout +value reflects a space duration (microseconds). +the package reflects a timeout; see the +.b lirc_set_rec_timeout_reports +ioctl. +.\" +.ss reading input with the lirc_mode_scancode mode +in the \fblirc_mode_scancode\fr +mode, the data returned by +.br read (2) +reflects decoded button presses, in the struct \filirc_scancode\fr. +the scancode is stored in the \fiscancode\fr field, and the ir protocol +is stored in \firc_proto\fr. +this field has one the values of the \fienum rc_proto\fr. +.\" +.ss writing output with the lirc_mode_pulse mode +the data written to the character device using +.br write (2) +is a pulse/space sequence of integer values. +pulses and spaces are only marked implicitly by their position. +the data must start and end with a pulse, thus it must always include +an odd number of samples. +the +.br write (2) +function blocks until the data has been transmitted by the +hardware. +if more data is provided than the hardware can send, the +.br write (2) +call fails with the error +.br einval . +.ss writing output with the lirc_mode_scancode mode +the data written to the character devices must be a single struct +\filirc_scancode\fr. +the \fiscancode\fr and \firc_proto\fr fields must +filled in, all other fields must be 0. +the kernel ir encoders will +convert the scancode to pulses and spaces. +the protocol or scancode is invalid, or the +.b lirc +device cannot transmit. +.sh ioctl commands +the lirc device's ioctl definition is bound by the ioctl function +definition of +.ir "struct file_operations" , +leaving us with an +.ir "unsigned int" +for the ioctl command and an +.ir "unsigned long" +for the argument. +for the purposes of ioctl portability across 32-bit and 64-bit architectures, +these values are capped to their 32-bit sizes. +.pp +.nf +#include /* but see bugs */ +int ioctl(int fd, int cmd, ...); +.fi +.pp +the following ioctls can be used to probe or change specific +.b lirc +hardware settings. +many require a third argument, usually an +.ir int , +referred to below as +.ir val . +.\" +.ss always supported commands +\fi/dev/lirc*\fr devices always support the following commands: +.tp 4 +.br lirc_get_features " (\fivoid\fp)" +returns a bit mask of combined features bits; see features. +.pp +if a device returns an error code for +.br lirc_get_features , +it is safe to assume it is not a +.b lirc +device. +.\" +.ss optional commands +some +.b lirc +devices support the commands listed below. +unless otherwise stated, these fail with the error \fbenotty\fr if the +operation isn't supported, or with the error \fbeinval\fr if the operation +failed, or invalid arguments were provided. +if a driver does not announce support of certain features, invoking +the corresponding ioctls will fail with the error +.br enotty . +.tp +.br lirc_get_rec_mode " (\fivoid\fp)" +if the +.b lirc +device has no receiver, this operation fails with the error +.br enotty . +otherwise, it returns the receive mode, which will be one of: +.rs +.tp +.br lirc_mode_mode2 +the driver returns a sequence of pulse/space durations. +.tp +.br lirc_mode_scancode +the driver returns struct +.i lirc_scancode +values, each of which represents +a decoded button press. +.re +.tp +.br lirc_set_rec_mode " (\fiint\fp)" +set the receive mode. +.ir val +is either +.br lirc_mode_scancode +or +.br lirc_mode_mode2 . +if the +.b lirc +device has no receiver, this operation fails with the error +.b enotty. +.tp +.br lirc_get_send_mode " (\fivoid\fp)" +return the send mode. +.br lirc_mode_pulse +or +.br lirc_mode_scancode +is supported. +if the +.b lirc +device cannot send, this operation fails with the error +.b enotty. +.tp +.br lirc_set_send_mode " (\fiint\fp)" +set the send mode. +.ir val +is either +.br lirc_mode_scancode +or +.br lirc_mode_pulse . +if the +.b lirc +device cannot send, this operation fails with the error +.br enotty . +.tp +.br lirc_set_send_carrier " (\fiint\fp)" +set the modulation frequency. +the argument is the frequency (hz). +.tp +.br lirc_set_send_duty_cycle " (\fiint\fp)" +set the carrier duty cycle. +.i val +is a number in the range [0,100] which +describes the pulse width as a percentage of the total cycle. +currently, no special meaning is defined for 0 or 100, but the values +are reserved for future use. +.ip +.tp +.br lirc_get_min_timeout " (\fivoid\fp)", " "\ +lirc_get_max_timeout " (\fivoid\fp)" +some devices have internal timers that can be used to detect when +there has been no ir activity for a long time. +this can help +.br lircd (8) +in detecting that an ir signal is finished and can speed up the +decoding process. +these operations +return integer values with the minimum/maximum timeout that can be +set (microseconds). +some devices have a fixed timeout. +for such drivers, +.br lirc_get_min_timeout +and +.br lirc_get_max_timeout +will fail with the error +.br enotty . +.tp +.br lirc_set_rec_timeout " (\fiint\fp)" +set the integer value for ir inactivity timeout (microseconds). +to be accepted, the value must be within the limits defined by +.br lirc_get_min_timeout +and +.br lirc_get_max_timeout . +a value of 0 (if supported by the hardware) disables all hardware +timeouts and data should be reported as soon as possible. +if the exact value cannot be set, then the next possible value +.i greater +than the given value should be set. +.tp +.br lirc_get_rec_timeout " (\fivoid\fp)" +return the current inactivity timeout (microseconds). +available since linux 4.18. +.tp +.br lirc_set_rec_timeout_reports " (\fiint\fp)" +enable +.ri ( val +is 1) or disable +.ri ( val +is 0) timeout packages in +.br lirc_mode_mode2 . +the behavior of this operation has varied across kernel versions: +.rs +.ip * 3 +since linux 4.16: each time the +.b lirc device is opened, +timeout reports are by default enabled for the resulting file descriptor. +the +.b lirc_set_rec_timeout +operation can be used to disable (and, if desired, to later re-enable) +the timeout on the file descriptor. +.ip * +in linux 4.15 and earlier: +timeout reports are disabled by default, and enabling them (via +.br lirc_set_rec_timeout ) +on any file descriptor associated with the +.b lirc +device has the effect of enabling timeouts for all file descriptors +referring to that device (until timeouts are disabled again). +.re +.tp +.br lirc_set_rec_carrier " (\fiint\fp)" +set the upper bound of the receive carrier frequency (hz). +see +.br lirc_set_rec_carrier_range . +.tp +.br lirc_set_rec_carrier_range " (\fiint\fp)" +sets the lower bound of the receive carrier frequency (hz). +for this to take affect, first set the lower bound using the +.br lirc_set_rec_carrier_range +ioctl, and then the upper bound using the +.br lirc_set_rec_carrier +ioctl. +.tp +.br lirc_set_measure_carrier_mode " (\fiint\fp)" +enable +.ri ( val +is 1) or disable +.ri ( val +is 0) the measure mode. +if enabled, from the next key press on, the driver will send +.br lirc_mode2_frequency +packets. +by default, this should be turned off. +.tp +.br lirc_get_rec_resolution " (\fivoid\fp)" +return the driver resolution (microseconds). +.tp +.br lirc_set_transmitter_mask " (\fiint\fp)" +enable the set of transmitters specified in +.ir val , +which contains a bit mask where each enabled transmitter is a 1. +the first transmitter is encoded by the least significant bit, and so on. +when an invalid bit mask is given, for example a bit is set even +though the device does not have so many transmitters, +this operation returns the +number of available transmitters and does nothing otherwise. +.tp +.br lirc_set_wideband_receiver " (\fiint\fp)" +some devices are equipped with a special wide band receiver which is +intended to be used to learn the output of an existing remote. +this ioctl can be used to enable +.ri ( val +equals 1) or disable +.ri ( val +equals 0) this functionality. +this might be useful for devices that otherwise have narrow band +receivers that prevent them to be used with certain remotes. +wide band receivers may also be more precise. +on the other hand, their disadvantage usually is reduced range of +reception. +.ip +note: wide band receiver may be implicitly enabled if you enable +carrier reports. +in that case, it will be disabled as soon as you disable carrier reports. +trying to disable a wide band receiver while carrier reports are active +will do nothing. +.\" +.sh features +the +.br lirc_get_features +ioctl returns a bit mask describing features of the driver. +the following bits may be returned in the mask: +.tp +.br lirc_can_rec_mode2 +the driver is capable of receiving using +.br lirc_mode_mode2 . +.tp +.br lirc_can_rec_scancode +the driver is capable of receiving using +.br lirc_mode_scancode . +.tp +.br lirc_can_set_send_carrier +the driver supports changing the modulation frequency using +.br lirc_set_send_carrier . +.tp +.br lirc_can_set_send_duty_cycle +the driver supports changing the duty cycle using +.br lirc_set_send_duty_cycle . +.tp +.br lirc_can_set_transmitter_mask +the driver supports changing the active transmitter(s) using +.br lirc_set_transmitter_mask . +.tp +.br lirc_can_set_rec_carrier +the driver supports setting the receive carrier frequency using +.br lirc_set_rec_carrier . +any +.b lirc +device since the drivers were merged in kernel release 2.6.36 +must have +.br lirc_can_set_rec_carrier_range +set if +.br lirc_can_set_rec_carrier +feature is set. +.tp +.br lirc_can_set_rec_carrier_range +the driver supports +.br lirc_set_rec_carrier_range . +the lower bound of the carrier must first be set using the +.br lirc_set_rec_carrier_range +ioctl, before using the +.br lirc_set_rec_carrier +ioctl to set the upper bound. +.tp +.br lirc_can_get_rec_resolution +the driver supports +.br lirc_get_rec_resolution . +.tp +.br lirc_can_set_rec_timeout +the driver supports +.br lirc_set_rec_timeout . +.tp +.br lirc_can_measure_carrier +the driver supports measuring of the modulation frequency using +.br lirc_set_measure_carrier_mode . +.tp +.br lirc_can_use_wideband_receiver +the driver supports learning mode using +.br lirc_set_wideband_receiver . +.tp +.br lirc_can_send_pulse +the driver supports sending using +.br lirc_mode_pulse +or +.br lirc_mode_scancode +.\" +.sh bugs +using these devices requires the kernel source header file +.ir lirc.h . +this file is not available before kernel release 4.6. +users of older kernels could use the file bundled in +.ur http://www.lirc.org +.ue . +.\" +.sh see also +\fbir\-ctl\fp(1), \fblircd\fp(8),\ \fbbpf\fp(2) +.pp +https://www.kernel.org/doc/html/latest/media/uapi/rc/lirc-dev.html +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2008 linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th pthread_setschedparam 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +pthread_setschedparam, pthread_getschedparam \- set/get +scheduling policy and parameters of a thread +.sh synopsis +.nf +.b #include +.pp +.bi "int pthread_setschedparam(pthread_t " thread ", int " policy , +.bi " const struct sched_param *" param ); +.bi "int pthread_getschedparam(pthread_t " thread ", int *restrict " policy , +.bi " struct sched_param *restrict " param ); +.pp +compile and link with \fi\-pthread\fp. +.fi +.sh description +the +.br pthread_setschedparam () +function sets the scheduling policy and parameters of the thread +.ir thread . +.pp +.i policy +specifies the new scheduling policy for +.ir thread . +the supported values for +.ir policy , +and their semantics, are described in +.br sched (7). +.\" fixme . pthread_setschedparam() places no restriction on the policy, +.\" but pthread_attr_setschedpolicy() restricts policy to rr/fifo/other +.\" http://sourceware.org/bugzilla/show_bug.cgi?id=7013 +.pp +the structure pointed to by +.i param +specifies the new scheduling parameters for +.ir thread . +scheduling parameters are maintained in the following structure: +.pp +.in +4n +.ex +struct sched_param { + int sched_priority; /* scheduling priority */ +}; +.ee +.in +.pp +as can be seen, only one scheduling parameter is supported. +for details of the permitted ranges for scheduling priorities +in each scheduling policy, see +.br sched (7). +.pp +the +.br pthread_getschedparam () +function returns the scheduling policy and parameters of the thread +.ir thread , +in the buffers pointed to by +.i policy +and +.ir param , +respectively. +the returned priority value is that set by the most recent +.br pthread_setschedparam (), +.br pthread_setschedprio (3), +or +.br pthread_create (3) +call that affected +.ir thread . +the returned priority does not reflect any temporary priority adjustments +as a result of calls to any priority inheritance or +priority ceiling functions (see, for example, +.br pthread_mutexattr_setprioceiling (3) +and +.br pthread_mutexattr_setprotocol (3)). +.\" fixme . nptl/pthread_setschedparam.c has the following +.\" /* if the thread should have higher priority because of some +.\" pthread_prio_protect mutexes it holds, adjust the priority. */ +.\" eventually (perhaps after writing the mutexattr pages), we +.\" may want to add something on the topic to this page. +.sh return value +on success, these functions return 0; +on error, they return a nonzero error number. +if +.br pthread_setschedparam () +fails, the scheduling policy and parameters of +.i thread +are not changed. +.sh errors +both of these functions can fail with the following error: +.tp +.b esrch +no thread with the id +.i thread +could be found. +.pp +.br pthread_setschedparam () +may additionally fail with the following errors: +.tp +.b einval +.i policy +is not a recognized policy, or +.i param +does not make sense for the +.ir policy . +.tp +.b eperm +the caller does not have appropriate privileges +to set the specified scheduling policy and parameters. +.pp +posix.1 also documents an +.b enotsup +("attempt was made to set the policy or scheduling parameters +to an unsupported value") error for +.br pthread_setschedparam (). +.\" .sh versions +.\" available since glibc 2.0 +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br pthread_setschedparam (), +.br pthread_getschedparam () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +for a description of the permissions required to, and the effect of, +changing a thread's scheduling policy and priority, +and details of the permitted ranges for priorities +in each scheduling policy, see +.br sched (7). +.sh examples +the program below demonstrates the use of +.br pthread_setschedparam () +and +.br pthread_getschedparam (), +as well as the use of a number of other scheduling-related +pthreads functions. +.pp +in the following run, the main thread sets its scheduling policy to +.br sched_fifo +with a priority of 10, +and initializes a thread attributes object with +a scheduling policy attribute of +.br sched_rr +and a scheduling priority attribute of 20. +the program then sets (using +.br pthread_attr_setinheritsched (3)) +the inherit scheduler attribute of the thread attributes object to +.br pthread_explicit_sched , +meaning that threads created using this attributes object should +take their scheduling attributes from the thread attributes object. +the program then creates a thread using the thread attributes object, +and that thread displays its scheduling policy and priority. +.pp +.in +4n +.ex +$ \fbsu\fp # need privilege to set real\-time scheduling policies +password: +# \fb./a.out \-mf10 \-ar20 \-i e\fp +scheduler settings of main thread + policy=sched_fifo, priority=10 + +scheduler settings in \(aqattr\(aq + policy=sched_rr, priority=20 + inheritsched is explicit + +scheduler attributes of new thread + policy=sched_rr, priority=20 +.ee +.in +.pp +in the above output, one can see that the scheduling policy and priority +were taken from the values specified in the thread attributes object. +.pp +the next run is the same as the previous, +except that the inherit scheduler attribute is set to +.br pthread_inherit_sched , +meaning that threads created using the thread attributes object should +ignore the scheduling attributes specified in the attributes object +and instead take their scheduling attributes from the creating thread. +.pp +.in +4n +.ex +# \fb./a.out \-mf10 \-ar20 \-i i\fp +scheduler settings of main thread + policy=sched_fifo, priority=10 + +scheduler settings in \(aqattr\(aq + policy=sched_rr, priority=20 + inheritsched is inherit + +scheduler attributes of new thread + policy=sched_fifo, priority=10 +.ee +.in +.pp +in the above output, one can see that the scheduling policy and priority +were taken from the creating thread, +rather than the thread attributes object. +.pp +note that if we had omitted the +.ir "\-i\ i" +option, the output would have been the same, since +.br pthread_inherit_sched +is the default for the inherit scheduler attribute. +.ss program source +\& +.ex +/* pthreads_sched_test.c */ + +#include +#include +#include +#include +#include + +#define handle_error_en(en, msg) \e + do { errno = en; perror(msg); exit(exit_failure); } while (0) + +static void +usage(char *prog_name, char *msg) +{ + if (msg != null) + fputs(msg, stderr); + + fprintf(stderr, "usage: %s [options]\en", prog_name); + fprintf(stderr, "options are:\en"); +#define fpe(msg) fprintf(stderr, "\et%s", msg); /* shorter */ + fpe("\-a set scheduling policy and priority in\en"); + fpe(" thread attributes object\en"); + fpe(" can be\en"); + fpe(" f sched_fifo\en"); + fpe(" r sched_rr\en"); + fpe(" o sched_other\en"); + fpe("\-a use default thread attributes object\en"); + fpe("\-i {e|i} set inherit scheduler attribute to\en"); + fpe(" \(aqexplicit\(aq or \(aqinherit\(aq\en"); + fpe("\-m set scheduling policy and priority on\en"); + fpe(" main thread before pthread_create() call\en"); + exit(exit_failure); +} + +static int +get_policy(char p, int *policy) +{ + switch (p) { + case \(aqf\(aq: *policy = sched_fifo; return 1; + case \(aqr\(aq: *policy = sched_rr; return 1; + case \(aqo\(aq: *policy = sched_other; return 1; + default: return 0; + } +} + +static void +display_sched_attr(int policy, struct sched_param *param) +{ + printf(" policy=%s, priority=%d\en", + (policy == sched_fifo) ? "sched_fifo" : + (policy == sched_rr) ? "sched_rr" : + (policy == sched_other) ? "sched_other" : + "???", + param\->sched_priority); +} + +static void +display_thread_sched_attr(char *msg) +{ + int policy, s; + struct sched_param param; + + s = pthread_getschedparam(pthread_self(), &policy, ¶m); + if (s != 0) + handle_error_en(s, "pthread_getschedparam"); + + printf("%s\en", msg); + display_sched_attr(policy, ¶m); +} + +static void * +thread_start(void *arg) +{ + display_thread_sched_attr("scheduler attributes of new thread"); + + return null; +} + +int +main(int argc, char *argv[]) +{ + int s, opt, inheritsched, use_null_attrib, policy; + pthread_t thread; + pthread_attr_t attr; + pthread_attr_t *attrp; + char *attr_sched_str, *main_sched_str, *inheritsched_str; + struct sched_param param; + + /* process command\-line options. */ + + use_null_attrib = 0; + attr_sched_str = null; + main_sched_str = null; + inheritsched_str = null; + + while ((opt = getopt(argc, argv, "a:ai:m:")) != \-1) { + switch (opt) { + case \(aqa\(aq: attr_sched_str = optarg; break; + case \(aqa\(aq: use_null_attrib = 1; break; + case \(aqi\(aq: inheritsched_str = optarg; break; + case \(aqm\(aq: main_sched_str = optarg; break; + default: usage(argv[0], "unrecognized option\en"); + } + } + + if (use_null_attrib && + (inheritsched_str != null || attr_sched_str != null)) + usage(argv[0], "can\(aqt specify \-a with \-i or \-a\en"); + + /* optionally set scheduling attributes of main thread, + and display the attributes. */ + + if (main_sched_str != null) { + if (!get_policy(main_sched_str[0], &policy)) + usage(argv[0], "bad policy for main thread (\-m)\en"); + param.sched_priority = strtol(&main_sched_str[1], null, 0); + + s = pthread_setschedparam(pthread_self(), policy, ¶m); + if (s != 0) + handle_error_en(s, "pthread_setschedparam"); + } + + display_thread_sched_attr("scheduler settings of main thread"); + printf("\en"); + + /* initialize thread attributes object according to options. */ + + attrp = null; + + if (!use_null_attrib) { + s = pthread_attr_init(&attr); + if (s != 0) + handle_error_en(s, "pthread_attr_init"); + attrp = &attr; + } + + if (inheritsched_str != null) { + if (inheritsched_str[0] == \(aqe\(aq) + inheritsched = pthread_explicit_sched; + else if (inheritsched_str[0] == \(aqi\(aq) + inheritsched = pthread_inherit_sched; + else + usage(argv[0], "value for \-i must be \(aqe\(aq or \(aqi\(aq\en"); + + s = pthread_attr_setinheritsched(&attr, inheritsched); + if (s != 0) + handle_error_en(s, "pthread_attr_setinheritsched"); + } + + if (attr_sched_str != null) { + if (!get_policy(attr_sched_str[0], &policy)) + usage(argv[0], + "bad policy for \(aqattr\(aq (\-a)\en"); + param.sched_priority = strtol(&attr_sched_str[1], null, 0); + + s = pthread_attr_setschedpolicy(&attr, policy); + if (s != 0) + handle_error_en(s, "pthread_attr_setschedpolicy"); + s = pthread_attr_setschedparam(&attr, ¶m); + if (s != 0) + handle_error_en(s, "pthread_attr_setschedparam"); + } + + /* if we initialized a thread attributes object, display + the scheduling attributes that were set in the object. */ + + if (attrp != null) { + s = pthread_attr_getschedparam(&attr, ¶m); + if (s != 0) + handle_error_en(s, "pthread_attr_getschedparam"); + s = pthread_attr_getschedpolicy(&attr, &policy); + if (s != 0) + handle_error_en(s, "pthread_attr_getschedpolicy"); + + printf("scheduler settings in \(aqattr\(aq\en"); + display_sched_attr(policy, ¶m); + + s = pthread_attr_getinheritsched(&attr, &inheritsched); + printf(" inheritsched is %s\en", + (inheritsched == pthread_inherit_sched) ? "inherit" : + (inheritsched == pthread_explicit_sched) ? "explicit" : + "???"); + printf("\en"); + } + + /* create a thread that will display its scheduling attributes. */ + + s = pthread_create(&thread, attrp, &thread_start, null); + if (s != 0) + handle_error_en(s, "pthread_create"); + + /* destroy unneeded thread attributes object. */ + + if (!use_null_attrib) { + s = pthread_attr_destroy(&attr); + if (s != 0) + handle_error_en(s, "pthread_attr_destroy"); + } + + s = pthread_join(thread, null); + if (s != 0) + handle_error_en(s, "pthread_join"); + + exit(exit_success); +} +.ee +.sh see also +.ad l +.nh +.br getrlimit (2), +.br sched_get_priority_min (2), +.br pthread_attr_init (3), +.br pthread_attr_setinheritsched (3), +.br pthread_attr_setschedparam (3), +.br pthread_attr_setschedpolicy (3), +.br pthread_create (3), +.br pthread_self (3), +.br pthread_setschedprio (3), +.br pthreads (7), +.br sched (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/carg.3 + +.so man3/tsearch.3 + +.\" copyright 1995 jim van zandt +.\" from jrv@vanzandt.mv.com mon sep 4 21:11:50 1995 +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" 1996-11-08, meem@sherilyn.wustl.edu, corrections +.\" 2004-10-31, aeb, changed maintainer address, updated list +.\" 2015-04-20, william@tuffbizz.com, updated list +.\" +.th undocumented 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +undocumented \- undocumented library functions +.sh synopsis +.nf +undocumented library functions +.fi +.sh description +this man page mentions those library functions which are implemented in +the standard libraries but not yet documented in man pages. +.ss solicitation +if you have information about these functions, +please look in the source code, write a man page (using a style +similar to that of the other linux section 3 man pages), and send it to +.b mtk.manpages@gmail.com +for inclusion in the next man page release. +.ss the list +.br authdes_create (3), +.br authdes_getucred (3), +.br authdes_pk_create (3), +.\" .br chflags (3), +.br clntunix_create (3), +.br creat64 (3), +.br dn_skipname (3), +.\" .br fattach (3), +.\" .br fchflags (3), +.\" .br fclean (3), +.br fcrypt (3), +.\" .br fdetach (3), +.br fp_nquery (3), +.br fp_query (3), +.br fp_resstat (3), +.br freading (3), +.br freopen64 (3), +.br fseeko64 (3), +.br ftello64 (3), +.br ftw64 (3), +.br fwscanf (3), +.br get_avphys_pages (3), +.br getdirentries64 (3), +.br getmsg (3), +.br getnetname (3), +.br get_phys_pages (3), +.br getpublickey (3), +.br getsecretkey (3), +.br h_errlist (3), +.br host2netname (3), +.br hostalias (3), +.br inet_nsap_addr (3), +.br inet_nsap_ntoa (3), +.br init_des (3), +.br libc_nls_init (3), +.br mstats (3), +.br netname2host (3), +.br netname2user (3), +.br nlist (3), +.br obstack_free (3), +.\" .br obstack stuff (3), +.br parse_printf_format (3), +.br p_cdname (3), +.br p_cdnname (3), +.br p_class (3), +.br p_fqname (3), +.br p_option (3), +.br p_query (3), +.br printf_size (3), +.br printf_size_info (3), +.br p_rr (3), +.br p_time (3), +.br p_type (3), +.br putlong (3), +.br putshort (3), +.br re_compile_fastmap (3), +.br re_compile_pattern (3), +.br register_printf_function (3), +.br re_match (3), +.br re_match_2 (3), +.br re_rx_search (3), +.br re_search (3), +.br re_search_2 (3), +.br re_set_registers (3), +.br re_set_syntax (3), +.br res_send_setqhook (3), +.br res_send_setrhook (3), +.br ruserpass (3), +.br setfileno (3), +.br sethostfile (3), +.br svc_exit (3), +.br svcudp_enablecache (3), +.br tell (3), +.br tr_break (3), +.br tzsetwall (3), +.br ufc_dofinalperm (3), +.br ufc_doit (3), +.br user2netname (3), +.br wcschrnul (3), +.br wcsftime (3), +.br wscanf (3), +.br xdr_authdes_cred (3), +.br xdr_authdes_verf (3), +.br xdr_cryptkeyarg (3), +.br xdr_cryptkeyres (3), +.br xdr_datum (3), +.br xdr_des_block (3), +.br xdr_domainname (3), +.br xdr_getcredres (3), +.br xdr_keybuf (3), +.br xdr_keystatus (3), +.br xdr_mapname (3), +.br xdr_netnamestr (3), +.br xdr_netobj (3), +.br xdr_passwd (3), +.br xdr_peername (3), +.br xdr_rmtcall_args (3), +.br xdr_rmtcallres (3), +.br xdr_unixcred (3), +.br xdr_yp_buf (3), +.br xdr_yp_inaddr (3), +.br xdr_ypbind_binding (3), +.br xdr_ypbind_resp (3), +.br xdr_ypbind_resptype (3), +.br xdr_ypbind_setdom (3), +.br xdr_ypdelete_args (3), +.br xdr_ypmaplist (3), +.br xdr_ypmaplist_str (3), +.br xdr_yppasswd (3), +.br xdr_ypreq_key (3), +.br xdr_ypreq_nokey (3), +.br xdr_ypresp_all (3), +.br xdr_ypresp_all_seq (3), +.br xdr_ypresp_key_val (3), +.br xdr_ypresp_maplist (3), +.br xdr_ypresp_master (3), +.br xdr_ypresp_order (3), +.br xdr_ypresp_val (3), +.br xdr_ypstat (3), +.br xdr_ypupdate_args (3), +.br yp_all (3), +.br yp_bind (3), +.br yperr_string (3), +.br yp_first (3), +.br yp_get_default_domain (3), +.br yp_maplist (3), +.br yp_master (3), +.br yp_match (3), +.br yp_next (3), +.br yp_order (3), +.br ypprot_err (3), +.br yp_unbind (3), +.br yp_update (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" (c) copyright 1999-2000 david a. wheeler (dwheeler@dwheeler.com) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" fragments of this document are directly derived from ietf standards. +.\" for those fragments which are directly derived from such standards, +.\" the following notice applies, which is the standard copyright and +.\" rights announcement of the internet society: +.\" +.\" copyright (c) the internet society (1998). all rights reserved. +.\" this document and translations of it may be copied and furnished to +.\" others, and derivative works that comment on or otherwise explain it +.\" or assist in its implementation may be prepared, copied, published +.\" and distributed, in whole or in part, without restriction of any +.\" kind, provided that the above copyright notice and this paragraph are +.\" included on all such copies and derivative works. however, this +.\" document itself may not be modified in any way, such as by removing +.\" the copyright notice or references to the internet society or other +.\" internet organizations, except as needed for the purpose of +.\" developing internet standards in which case the procedures for +.\" copyrights defined in the internet standards process must be +.\" followed, or as required to translate it into languages other than english. +.\" +.\" modified fri jul 25 23:00:00 1999 by david a. wheeler (dwheeler@dwheeler.com) +.\" modified fri aug 21 23:00:00 1999 by david a. wheeler (dwheeler@dwheeler.com) +.\" modified tue mar 14 2000 by david a. wheeler (dwheeler@dwheeler.com) +.\" +.th uri 7 2021-03-22 "linux" "linux programmer's manual" +.sh name +uri, url, urn \- uniform resource identifier (uri), including a url or urn +.sh synopsis +.nf +.hp 0.2i +uri = [ absoluteuri | relativeuri ] [ "#" fragment ] +.hp +absoluteuri = scheme ":" ( hierarchical_part | opaque_part ) +.hp +relativeuri = ( net_path | absolute_path | relative_path ) [ "?" query ] +.hp +scheme = "http" | "ftp" | "gopher" | "mailto" | "news" | "telnet" | + "file" | "man" | "info" | "whatis" | "ldap" | "wais" | \&... +.hp +hierarchical_part = ( net_path | absolute_path ) [ "?" query ] +.hp +net_path = "//" authority [ absolute_path ] +.hp +absolute_path = "/" path_segments +.hp +relative_path = relative_segment [ absolute_path ] +.fi +.sh description +a uniform resource identifier (uri) is a short string of characters +identifying an abstract or physical resource (for example, a web page). +a uniform resource locator (url) is a uri +that identifies a resource through its primary access +mechanism (e.g., its network "location"), rather than +by name or some other attribute of that resource. +a uniform resource name (urn) is a uri +that must remain globally unique and persistent even when +the resource ceases to exist or becomes unavailable. +.pp +uris are the standard way to name hypertext link destinations +for tools such as web browsers. +the string "http://www.kernel.org" is a url (and thus it +is also a uri). +many people use the term url loosely as a synonym for uri +(though technically urls are a subset of uris). +.pp +uris can be absolute or relative. +an absolute identifier refers to a resource independent of +context, while a relative +identifier refers to a resource by describing the difference +from the current context. +within a relative path reference, the complete path segments "." and +".." have special meanings: "the current hierarchy level" and "the +level above this hierarchy level", respectively, just like they do in +unix-like systems. +a path segment which contains a colon +character can't be used as the first segment of a relative uri path +(e.g., "this:that"), because it would be mistaken for a scheme name; +precede such segments with ./ (e.g., "./this:that"). +note that descendants of ms-dos (e.g., microsoft windows) replace +devicename colons with the vertical bar ("|") in uris, so "c:" becomes "c|". +.pp +a fragment identifier, if included, refers to a particular named portion +(fragment) of a resource; text after a \(aq#\(aq identifies the fragment. +a uri beginning with \(aq#\(aq refers to that fragment in the current resource. +.ss usage +there are many different uri schemes, each with specific +additional rules and meanings, but they are intentionally made to be +as similar as possible. +for example, many url schemes +permit the authority to be the following format, called here an +.i ip_server +(square brackets show what's optional): +.hp +.ir "ip_server = " [ user " [ : " password " ] @ ] " host " [ : " port ] +.pp +this format allows you to optionally insert a username, +a user plus password, and/or a port number. +the +.i host +is the name of the host computer, either its name as determined by dns +or an ip address (numbers separated by periods). +thus the uri + +logs into a web server on host example.com +as fred (using fredpassword) using port 8080. +avoid including a password in a uri if possible because of the many +security risks of having a password written down. +if the url supplies a username but no password, and the remote +server requests a password, the program interpreting the url +should request one from the user. +.pp +here are some of the most common schemes in use on unix-like systems +that are understood by many tools. +note that many tools using uris also have internal schemes or specialized +schemes; see those tools' documentation for information on those schemes. +.pp +.b "http \- web (http) server" +.pp +.ri http:// ip_server / path +.br +.ri http:// ip_server / path ? query +.pp +this is a url accessing a web (http) server. +the default port is 80. +if the path refers to a directory, the web server will choose what +to return; usually if there is a file named "index.html" or "index.htm" +its content is returned, otherwise, a list of the files in the current +directory (with appropriate links) is generated and returned. +an example is . +.pp +a query can be given in the archaic "isindex" format, consisting of a +word or phrase and not including an equal sign (=). +a query can also be in the longer "get" format, which has one or more +query entries of the form +.ir key = value +separated by the ampersand character (&). +note that +.i key +can be repeated more than once, though it's up to the web server +and its application programs to determine if there's any meaning to that. +there is an unfortunate interaction with html/xml/sgml and +the get query format; when such uris with more than one key +are embedded in sgml/xml documents (including html), the ampersand +(&) has to be rewritten as &. +note that not all queries use this format; larger forms +may be too long to store as a uri, so they use a different +interaction mechanism (called post) which does +not include the data in the uri. +see the common gateway interface specification at +.ur http://www.w3.org\:/cgi +.ue +for more information. +.pp +.b "ftp \- file transfer protocol (ftp)" +.pp +.ri ftp:// ip_server / path +.pp +this is a url accessing a file through the file transfer protocol (ftp). +the default port (for control) is 21. +if no username is included, the username "anonymous" is supplied, and +in that case many clients provide as the password the requestor's +internet email address. +an example is +. +.pp +.b "gopher \- gopher server" +.pp +.ri gopher:// ip_server / "gophertype selector" +.br +.ri gopher:// ip_server / "gophertype selector" %09 search +.br +.ri gopher:// ip_server / "gophertype selector" %09 search %09 gopher+_string +.br +.pp +the default gopher port is 70. +.i gophertype +is a single-character field to denote the +gopher type of the resource to +which the url refers. +the entire path may also be empty, in +which case the delimiting "/" is also optional and the gophertype +defaults to "1". +.pp +.i selector +is the gopher selector string. +in the gopher protocol, +gopher selector strings are a sequence of octets which may contain +any octets except 09 hexadecimal (us-ascii ht or tab), 0a hexadecimal +(us-ascii character lf), and 0d (us-ascii character cr). +.pp +.b "mailto \- email address" +.pp +.ri mailto: email-address +.pp +this is an email address, usually of the form +.ir name @ hostname . +see +.br mailaddr (7) +for more information on the correct format of an email address. +note that any % character must be rewritten as %25. +an example is . +.pp +.b "news \- newsgroup or news message" +.pp +.ri news: newsgroup-name +.br +.ri news: message-id +.pp +a +.i newsgroup-name +is a period-delimited hierarchical name, such as +"comp.infosystems.www.misc". +if is "*" (as in ), it is used to refer +to "all available news groups". +an example is . +.pp +a +.i message-id +corresponds to the message-id of +.ur http://www.ietf.org\:/rfc\:/rfc1036.txt +ietf rfc\ 1036, +.ue +without the enclosing "<" +and ">"; it takes the form +.ir unique @ full_domain_name . +a message identifier may be distinguished from a news group name by the +presence of the "@" character. +.pp +.b "telnet \- telnet login" +.pp +.ri telnet:// ip_server / +.pp +the telnet url scheme is used to designate interactive text services that +may be accessed by the telnet protocol. +the final "/" character may be omitted. +the default port is 23. +an example is . +.pp +.b "file \- normal file" +.pp +.ri file:// ip_server / path_segments +.br +.ri file: path_segments +.pp +this represents a file or directory accessible locally. +as a special case, +.i ip_server +can be the string "localhost" or the empty +string; this is interpreted as "the machine from which the url is +being interpreted". +if the path is to a directory, the viewer should display the +directory's contents with links to each containee; +not all viewers currently do this. +kde supports generated files through the url . +if the given file isn't found, browser writers may want to try to expand +the filename via filename globbing +(see +.br glob (7) +and +.br glob (3)). +.pp +the second format (e.g., ) +is a correct format for referring to +a local file. +however, older standards did not permit this format, +and some programs don't recognize this as a uri. +a more portable syntax is to use an empty string as the server name, +for example, +; this form does the same thing +and is easily recognized by pattern matchers and older programs as a uri. +note that if you really mean to say "start from the current location", don't +specify the scheme at all; use a relative address like <../test.txt>, +which has the side-effect of being scheme-independent. +an example of this scheme is . +.pp +.b "man \- man page documentation" +.pp +.ri man: command-name +.br +.ri man: command-name ( section ) +.pp +this refers to local online manual (man) reference pages. +the command name can optionally be followed by a +parenthesis and section number; see +.br man (7) +for more information on the meaning of the section numbers. +this uri scheme is unique to unix-like systems (such as linux) +and is not currently registered by the ietf. +an example is . +.pp +.b "info \- info page documentation" +.pp +.ri info: virtual-filename +.br +.ri info: virtual-filename # nodename +.br +.ri info:( virtual-filename ) +.br +.ri info:( virtual-filename ) nodename +.pp +this scheme refers to online info reference pages (generated from +texinfo files), +a documentation format used by programs such as the gnu tools. +this uri scheme is unique to unix-like systems (such as linux) +and is not currently registered by the ietf. +as of this writing, gnome and kde differ in their uri syntax +and do not accept the other's syntax. +the first two formats are the gnome format; in nodenames all spaces +are written as underscores. +the second two formats are the kde format; +spaces in nodenames must be written as spaces, even though this +is forbidden by the uri standards. +it's hoped that in the future most tools will understand all of these +formats and will always accept underscores for spaces in nodenames. +in both gnome and kde, if the form without the nodename is used the +nodename is assumed to be "top". +examples of the gnome format are and . +examples of the kde format are and . +.pp +.b "whatis \- documentation search" +.pp +.ri whatis: string +.pp +this scheme searches the database of short (one-line) descriptions of +commands and returns a list of descriptions containing that string. +only complete word matches are returned. +see +.br whatis (1). +this uri scheme is unique to unix-like systems (such as linux) +and is not currently registered by the ietf. +.pp +.b "ghelp \- gnome help documentation" +.pp +.ri ghelp: name-of-application +.pp +this loads gnome help for the given application. +note that not much documentation currently exists in this format. +.pp +.b "ldap \- lightweight directory access protocol" +.pp +.ri ldap:// hostport +.br +.ri ldap:// hostport / +.br +.ri ldap:// hostport / dn +.br +.ri ldap:// hostport / dn ? attributes +.br +.ri ldap:// hostport / dn ? attributes ? scope +.br +.ri ldap:// hostport / dn ? attributes ? scope ? filter +.br +.ri ldap:// hostport / dn ? attributes ? scope ? filter ? extensions +.pp +this scheme supports queries to the +lightweight directory access protocol (ldap), a protocol for querying +a set of servers for hierarchically organized information +(such as people and computing resources). +see +.ur http://www.ietf.org\:/rfc\:/rfc2255.txt +rfc\ 2255 +.ue +for more information on the ldap url scheme. +the components of this url are: +.ip hostport 12 +the ldap server to query, written as a hostname optionally followed by +a colon and the port number. +the default ldap port is tcp port 389. +if empty, the client determines which the ldap server to use. +.ip dn +the ldap distinguished name, which identifies +the base object of the ldap search (see +.ur http://www.ietf.org\:/rfc\:/rfc2253.txt +rfc\ 2253 +.ue +section 3). +.ip attributes +a comma-separated list of attributes to be returned; +see rfc\ 2251 section 4.1.5. +if omitted, all attributes should be returned. +.ip scope +specifies the scope of the search, which can be one of +"base" (for a base object search), "one" (for a one-level search), +or "sub" (for a subtree search). +if scope is omitted, "base" is assumed. +.ip filter +specifies the search filter (subset of entries +to return). +if omitted, all entries should be returned. +see +.ur http://www.ietf.org\:/rfc\:/rfc2254.txt +rfc\ 2254 +.ue +section 4. +.ip extensions +a comma-separated list of type=value +pairs, where the =value portion may be omitted for options not +requiring it. +an extension prefixed with a \(aq!\(aq is critical +(must be supported to be valid), otherwise it is noncritical (optional). +.pp +ldap queries are easiest to explain by example. +here's a query that asks ldap.itd.umich.edu for information about +the university of michigan in the u.s.: +.pp +.nf +ldap://ldap.itd.umich.edu/o=university%20of%20michigan,c=us +.fi +.pp +to just get its postal address attribute, request: +.pp +.nf +ldap://ldap.itd.umich.edu/o=university%20of%20michigan,c=us?postaladdress +.fi +.pp +to ask a host.com at port 6666 for information about the person +with common name (cn) "babs jensen" at university of michigan, request: +.pp +.nf +ldap://host.com:6666/o=university%20of%20michigan,c=us??sub?(cn=babs%20jensen) +.fi +.pp +.b "wais \- wide area information servers" +.pp +.ri wais:// hostport / database +.br +.ri wais:// hostport / database ? search +.br +.ri wais:// hostport / database / wtype / wpath +.pp +this scheme designates a wais database, search, or document +(see +.ur http://www.ietf.org\:/rfc\:/rfc1625.txt +ietf rfc\ 1625 +.ue +for more information on wais). +hostport is the hostname, optionally followed by a colon and port number +(the default port number is 210). +.pp +the first form designates a wais database for searching. +the second form designates a particular search of the wais database +.ir database . +the third form designates a particular document within a wais +database to be retrieved. +.i wtype +is the wais designation of the type of the object and +.i wpath +is the wais document-id. +.pp +.b "other schemes" +.pp +there are many other uri schemes. +most tools that accept uris support a set of internal uris +(e.g., mozilla has the about: scheme for internal information, +and the gnome help browser has the toc: scheme for various starting +locations). +there are many schemes that have been defined but are not as widely +used at the current time +(e.g., prospero). +the nntp: scheme is deprecated in favor of the news: scheme. +urns are to be supported by the urn: scheme, with a hierarchical name space +(e.g., urn:ietf:... would identify ietf documents); at this time +urns are not widely implemented. +not all tools support all schemes. +.ss character encoding +uris use a limited number of characters so that they can be +typed in and used in a variety of situations. +.pp +the following characters are reserved, that is, they may appear in a +uri but their use is limited to their reserved purpose +(conflicting data must be escaped before forming the uri): +.ip + ; / ? : @ & = + $ , +.pp +unreserved characters may be included in a uri. +unreserved characters +include uppercase and lowercase latin letters, +decimal digits, and the following +limited set of punctuation marks and symbols: +.ip + \- _ . ! \(ti * ' ( ) +.pp +all other characters must be escaped. +an escaped octet is encoded as a character triplet, consisting of the +percent character "%" followed by the two hexadecimal digits +representing the octet code (you can use uppercase or lowercase letters +for the hexadecimal digits). +for example, a blank space must be escaped +as "%20", a tab character as "%09", and the "&" as "%26". +because the percent "%" character always has the reserved purpose of +being the escape indicator, it must be escaped as "%25". +it is common practice to escape space characters as the plus symbol (+) +in query text; this practice isn't uniformly defined +in the relevant rfcs (which recommend %20 instead) but any tool accepting +uris with query text should be prepared for them. +a uri is always shown in its "escaped" form. +.pp +unreserved characters can be escaped without changing the semantics +of the uri, but this should not be done unless the uri is being used +in a context that does not allow the unescaped character to appear. +for example, "%7e" is sometimes used instead of "\(ti" in an http url +path, but the two are equivalent for an http url. +.pp +for uris which must handle characters outside the us ascii character set, +the html 4.01 specification (section b.2) and +ietf rfc\ 2718 (section 2.2.5) recommend the following approach: +.ip 1. 4 +translate the character sequences into utf-8 (ietf rfc\ 2279)\(emsee +.br utf\-8 (7)\(emand +then +.ip 2. +use the uri escaping mechanism, that is, +use the %hh encoding for unsafe octets. +.ss writing a uri +when written, uris should be placed inside double quotes +(e.g., "http://www.kernel.org"), +enclosed in angle brackets (e.g., ), +or placed on a line by themselves. +a warning for those who use double-quotes: +.b never +move extraneous punctuation (such as the period ending a sentence or the +comma in a list) +inside a uri, since this will change the value of the uri. +instead, use angle brackets instead, or +switch to a quoting system that never includes extraneous characters +inside quotation marks. +this latter system, called the 'new' or 'logical' quoting system by +"hart's rules" and the "oxford dictionary for writers and editors", +is preferred practice in great britain and in various european languages. +older documents suggested inserting the prefix "url:" +just before the uri, but this form has never caught on. +.pp +the uri syntax was designed to be unambiguous. +however, as uris have become commonplace, traditional media +(television, radio, newspapers, billboards, etc.) have increasingly +used abbreviated uri references consisting of +only the authority and path portions of the identified resource +(e.g., ). +such references are primarily +intended for human interpretation rather than machine, with the +assumption that context-based heuristics are sufficient to complete +the uri (e.g., hostnames beginning with "www" are likely to have +a uri prefix of "http://" and hostnames beginning with "ftp" likely +to have a prefix of "ftp://"). +many client implementations heuristically resolve these references. +such heuristics may +change over time, particularly when new schemes are introduced. +since an abbreviated uri has the same syntax as a relative url path, +abbreviated uri references cannot be used where relative uris are +permitted, and can be used only when there is no defined base +(such as in dialog boxes). +don't use abbreviated uris as hypertext links inside a document; +use the standard format as described here. +.sh conforming to +.ur http://www.ietf.org\:/rfc\:/rfc2396.txt +(ietf rfc\ 2396) +.ue , +.ur http://www.w3.org\:/tr\:/rec\-html40 +(html 4.0) +.ue . +.sh notes +any tool accepting uris (e.g., a web browser) on a linux system should +be able to handle (directly or indirectly) all of the +schemes described here, including the man: and info: schemes. +handling them by invoking some other program is +fine and in fact encouraged. +.pp +technically the fragment isn't part of the uri. +.pp +for information on how to embed uris (including urls) in a data format, +see documentation on that format. +html uses the format +.i text +. +texinfo files use the format @uref{\fiuri\fp}. +man and mdoc have the recently added ur macro, or just include the +uri in the text (viewers should be able to detect :// as part of a uri). +.pp +the gnome and kde desktop environments currently vary in the uris +they accept, in particular in their respective help browsers. +to list man pages, gnome uses while kde uses , and +to list info pages, gnome uses while kde uses +(the author of this man page prefers the kde approach here, though a more +regular format would be even better). +in general, kde uses as a prefix to a set of generated +files. +kde prefers documentation in html, accessed via the +. +gnome prefers the ghelp scheme to store and find documentation. +neither browser handles file: references to directories at the time +of this writing, making it difficult to refer to an entire directory with +a browsable uri. +as noted above, these environments differ in how they handle the +info: scheme, probably the most important variation. +it is expected that gnome and kde +will converge to common uri formats, and a future +version of this man page will describe the converged result. +efforts to aid this convergence are encouraged. +.ss security +a uri does not in itself pose a security threat. +there is no general guarantee that a url, which at one time +located a given resource, will continue to do so. +nor is there any +guarantee that a url will not locate a different resource at some +later point in time; such a guarantee can be +obtained only from the person(s) controlling that namespace and the +resource in question. +.pp +it is sometimes possible to construct a url such that an attempt to +perform a seemingly harmless operation, such as the +retrieval of an entity associated with the resource, will in fact +cause a possibly damaging remote operation to occur. +the unsafe url +is typically constructed by specifying a port number other than that +reserved for the network protocol in question. +the client unwittingly contacts a site that is in fact +running a different protocol. +the content of the url contains instructions that, when +interpreted according to this other protocol, cause an unexpected +operation. +an example has been the use of a gopher url to cause an +unintended or impersonating message to be sent via a smtp server. +.pp +caution should be used when using any url that specifies a port +number other than the default for the protocol, especially when it is +a number within the reserved space. +.pp +care should be taken when a uri contains escaped delimiters for a +given protocol (for example, cr and lf characters for telnet +protocols) that these are not unescaped before transmission. +this might violate the protocol, but avoids the potential for such +characters to be used to simulate an extra operation or parameter in +that protocol, which might lead to an unexpected and possibly harmful +remote operation to be performed. +.pp +it is clearly unwise to use a uri that contains a password which is +intended to be secret. +in particular, the use of a password within +the "userinfo" component of a uri is strongly recommended against except +in those rare cases where the "password" parameter is intended to be public. +.sh bugs +documentation may be placed in a variety of locations, so there +currently isn't a good uri scheme for general online documentation +in arbitrary formats. +references of the form + don't work because different distributions and +local installation requirements may place the files in different +directories +(it may be in /usr/doc, or /usr/local/doc, or /usr/share, +or somewhere else). +also, the directory zzz usually changes when a version changes +(though filename globbing could partially overcome this). +finally, using the file: scheme doesn't easily support people +who dynamically load documentation from the internet (instead of +loading the files onto a local filesystem). +a future uri scheme may be added (e.g., "userdoc:") to permit +programs to include cross-references to more detailed documentation +without having to know the exact location of that documentation. +alternatively, a future version of the filesystem specification may +specify file locations sufficiently so that the file: scheme will +be able to locate documentation. +.pp +many programs and file formats don't include a way to incorporate +or implement links using uris. +.pp +many programs can't handle all of these different uri formats; there +should be a standard mechanism to load an arbitrary uri that automatically +detects the users' environment (e.g., text or graphics, +desktop environment, local user preferences, and currently executing +tools) and invokes the right tool for any uri. +.\" .sh author +.\" david a. wheeler (dwheeler@dwheeler.com) wrote this man page. +.sh see also +.br lynx (1), +.br man2html (1), +.br mailaddr (7), +.br utf\-8 (7) +.pp +.ur http://www.ietf.org\:/rfc\:/rfc2255.txt +ietf rfc\ 2255 +.ue +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified mon mar 29 22:31:13 1993, david metcalfe +.\" modified sun jun 6 23:27:50 1993, david metcalfe +.\" modified sat jul 24 21:45:37 1993, rik faith (faith@cs.unc.edu) +.\" modified sat dec 16 15:02:59 2000, joseph s. myers +.\" +.th abs 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +abs, labs, llabs, imaxabs \- compute the absolute value of an integer +.sh synopsis +.nf +.b #include +.pp +.bi "int abs(int " j ); +.bi "long labs(long " j ); +.bi "long long llabs(long long " j ); +.pp +.b #include +.pp +.bi "intmax_t imaxabs(intmax_t " j ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br llabs (): +.nf + _isoc99_source || _posix_c_source >= 200112l +.fi +.sh description +the +.br abs () +function computes the absolute value of the integer +argument \fij\fp. +the +.br labs (), +.br llabs (), +and +.br imaxabs () +functions compute the absolute value of the argument \fij\fp of the +appropriate integer type for the function. +.sh return value +returns the absolute value of the integer argument, of the appropriate +integer type for the function. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br abs (), +.br labs (), +.br llabs (), +.br imaxabs () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99, svr4, 4.3bsd. +.\" posix.1 (1996 edition) requires only the +.\" .br abs () +.\" function. +c89 only +includes the +.br abs () +and +.br labs () +functions; the functions +.br llabs () +and +.br imaxabs () +were added in c99. +.sh notes +trying to take the absolute value of the most negative integer +is not defined. +.pp +the +.br llabs () +function is included in glibc since version 2.0. +the +.br imaxabs () +function is included in +glibc since version 2.1.1. +.pp +for +.br llabs () +to be declared, it may be necessary to define +\fb_isoc99_source\fp or \fb_isoc9x_source\fp (depending on the +version of glibc) before including any standard headers. +.pp +by default, +gcc handles +.br abs (), +.br labs (), +and (since gcc 3.0) +.br llabs () +and +.br imaxabs () +as built-in functions. +.sh see also +.br cabs (3), +.br ceil (3), +.br fabs (3), +.br floor (3), +.br rint (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/setnetgrent.3 + +.so man3/acos.3 + +.so man3/j0.3 + +.so man3/pthread_setaffinity_np.3 + +.so man3/bswap.3 + +.so man2/getrusage.2 +.\" no new programs should use vtimes(3). +.\" getrusage(2) briefly discusses vtimes(3), so point the user there. + +.so man3/tsearch.3 + +.so man2/outb.2 + +.so man3/sin.3 + +.\" copyright (c) 2002 by michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" 6 aug 2002 - initial creation +.\" modified 2003-05-23, michael kerrisk, +.\" modified 2004-05-27, michael kerrisk, +.\" 2004-12-08, mtk added o_noatime for cap_fowner +.\" 2005-08-16, mtk, added cap_audit_control and cap_audit_write +.\" 2008-07-15, serge hallyn +.\" document file capabilities, per-process capability +.\" bounding set, changed semantics for cap_setpcap, +.\" and other changes in 2.6.2[45]. +.\" add cap_mac_admin, cap_mac_override, cap_setfcap. +.\" 2008-07-15, mtk +.\" add text describing circumstances in which cap_setpcap +.\" (theoretically) permits a thread to change the +.\" capability sets of another thread. +.\" add section describing rules for programmatically +.\" adjusting thread capability sets. +.\" describe rationale for capability bounding set. +.\" document "securebits" flags. +.\" add text noting that if we set the effective flag for one file +.\" capability, then we must also set the effective flag for all +.\" other capabilities where the permitted or inheritable bit is set. +.\" 2011-09-07, mtk/serge hallyn: add cap_syslog +.\" +.th capabilities 7 2021-08-27 "linux" "linux programmer's manual" +.sh name +capabilities \- overview of linux capabilities +.sh description +for the purpose of performing permission checks, +traditional unix implementations distinguish two categories of processes: +.i privileged +processes (whose effective user id is 0, referred to as superuser or root), +and +.i unprivileged +processes (whose effective uid is nonzero). +privileged processes bypass all kernel permission checks, +while unprivileged processes are subject to full permission +checking based on the process's credentials +(usually: effective uid, effective gid, and supplementary group list). +.pp +starting with kernel 2.2, linux divides the privileges traditionally +associated with superuser into distinct units, known as +.ir capabilities , +which can be independently enabled and disabled. +capabilities are a per-thread attribute. +.\" +.ss capabilities list +the following list shows the capabilities implemented on linux, +and the operations or behaviors that each capability permits: +.tp +.br cap_audit_control " (since linux 2.6.11)" +enable and disable kernel auditing; change auditing filter rules; +retrieve auditing status and filtering rules. +.tp +.br cap_audit_read " (since linux 3.16)" +.\" commit a29b694aa1739f9d76538e34ae25524f9c549d59 +.\" commit 3a101b8de0d39403b2c7e5c23fd0b005668acf48 +allow reading the audit log via a multicast netlink socket. +.tp +.br cap_audit_write " (since linux 2.6.11)" +write records to kernel auditing log. +.\" fixme add fan_enable_audit +.tp +.br cap_block_suspend " (since linux 3.5)" +employ features that can block system suspend +.rb ( epoll (7) +.br epollwakeup , +.ir /proc/sys/wake_lock ). +.tp +.br cap_bpf " (since linux 5.8)" +employ privileged bpf operations; see +.br bpf (2) +and +.br bpf\-helpers (7). +.ip +this capability was added in linux 5.8 to separate out +bpf functionality from the overloaded +.br cap_sys_admin +capability. +.tp +.br cap_checkpoint_restore " (since linux 5.9)" +.\" commit 124ea650d3072b005457faed69909221c2905a1f +.pd 0 +.rs +.ip * 2 +update +.i /proc/sys/kernel/ns_last_pid +(see +.br pid_namespaces (7)); +.ip * +employ the +.i set_tid +feature of +.br clone3 (2); +.\" fixme there is also some use case relating to +.\" prctl_set_mm_exe_file(); in the 5.9 sources, see +.\" prctl_set_mm_map(). +.ip * +read the contents of the symbolic links in +.ir /proc/[pid]/map_files +for other processes. +.re +.pd +.ip +this capability was added in linux 5.9 to separate out +checkpoint/restore functionality from the overloaded +.br cap_sys_admin +capability. +.tp +.b cap_chown +make arbitrary changes to file uids and gids (see +.br chown (2)). +.tp +.b cap_dac_override +bypass file read, write, and execute permission checks. +(dac is an abbreviation of "discretionary access control".) +.tp +.b cap_dac_read_search +.pd 0 +.rs +.ip * 2 +bypass file read permission checks and +directory read and execute permission checks; +.ip * +invoke +.br open_by_handle_at (2); +.ip * +use the +.br linkat (2) +.b at_empty_path +flag to create a link to a file referred to by a file descriptor. +.re +.pd +.tp +.b cap_fowner +.pd 0 +.rs +.ip * 2 +bypass permission checks on operations that normally +require the filesystem uid of the process to match the uid of +the file (e.g., +.br chmod (2), +.br utime (2)), +excluding those operations covered by +.b cap_dac_override +and +.br cap_dac_read_search ; +.ip * +set inode flags (see +.br ioctl_iflags (2)) +on arbitrary files; +.ip * +set access control lists (acls) on arbitrary files; +.ip * +ignore directory sticky bit on file deletion; +.ip * +modify +.i user +extended attributes on sticky directory owned by any user; +.ip * +specify +.b o_noatime +for arbitrary files in +.br open (2) +and +.br fcntl (2). +.re +.pd +.tp +.b cap_fsetid +.pd 0 +.rs +.ip * 2 +don't clear set-user-id and set-group-id mode +bits when a file is modified; +.ip * +set the set-group-id bit for a file whose gid does not match +the filesystem or any of the supplementary gids of the calling process. +.re +.pd +.tp +.b cap_ipc_lock +.\" fixme . as at linux 3.2, there are some strange uses of this capability +.\" in other places; they probably should be replaced with something else. +.pd 0 +.rs +.ip * 2 +lock memory +.rb ( mlock (2), +.br mlockall (2), +.br mmap (2), +.br shmctl (2)); +.ip * +allocate memory using huge pages +.rb ( memfd_create (2), +.br mmap (2), +.br shmctl (2)). +.pd 0 +.re +.tp +.b cap_ipc_owner +bypass permission checks for operations on system v ipc objects. +.tp +.b cap_kill +bypass permission checks for sending signals (see +.br kill (2)). +this includes use of the +.br ioctl (2) +.b kdsigaccept +operation. +.\" fixme . cap_kill also has an effect for threads + setting child +.\" termination signal to other than sigchld: without this +.\" capability, the termination signal reverts to sigchld +.\" if the child does an exec(). what is the rationale +.\" for this? +.tp +.br cap_lease " (since linux 2.4)" +establish leases on arbitrary files (see +.br fcntl (2)). +.tp +.b cap_linux_immutable +set the +.b fs_append_fl +and +.b fs_immutable_fl +inode flags (see +.br ioctl_iflags (2)). +.tp +.br cap_mac_admin " (since linux 2.6.25)" +allow mac configuration or state changes. +implemented for the smack linux security module (lsm). +.tp +.br cap_mac_override " (since linux 2.6.25)" +override mandatory access control (mac). +implemented for the smack lsm. +.tp +.br cap_mknod " (since linux 2.4)" +create special files using +.br mknod (2). +.tp +.b cap_net_admin +perform various network-related operations: +.pd 0 +.rs +.ip * 2 +interface configuration; +.ip * +administration of ip firewall, masquerading, and accounting; +.ip * +modify routing tables; +.ip * +bind to any address for transparent proxying; +.ip * +set type-of-service (tos); +.ip * +clear driver statistics; +.ip * +set promiscuous mode; +.ip * +enabling multicasting; +.ip * +use +.br setsockopt (2) +to set the following socket options: +.br so_debug , +.br so_mark , +.br so_priority +(for a priority outside the range 0 to 6), +.br so_rcvbufforce , +and +.br so_sndbufforce . +.re +.pd +.tp +.b cap_net_bind_service +bind a socket to internet domain privileged ports +(port numbers less than 1024). +.tp +.b cap_net_broadcast +(unused) make socket broadcasts, and listen to multicasts. +.\" fixme since linux 4.2, there are use cases for netlink sockets +.\" commit 59324cf35aba5336b611074028777838a963d03b +.tp +.b cap_net_raw +.pd 0 +.rs +.ip * 2 +use raw and packet sockets; +.ip * +bind to any address for transparent proxying. +.re +.pd +.\" also various ip options and setsockopt(so_bindtodevice) +.tp +.br cap_perfmon " (since linux 5.8)" +employ various performance-monitoring mechanisms, including: +.rs +.ip * 2 +.pd 0 +call +.br perf_event_open (2); +.ip * +employ various bpf operations that have performance implications. +.re +.pd +.ip +this capability was added in linux 5.8 to separate out +performance monitoring functionality from the overloaded +.br cap_sys_admin +capability. +see also the kernel source file +.ir documentation/admin\-guide/perf\-security.rst . +.tp +.b cap_setgid +.rs +.pd 0 +.ip * 2 +make arbitrary manipulations of process gids and supplementary gid list; +.ip * +forge gid when passing socket credentials via unix domain sockets; +.ip * +write a group id mapping in a user namespace (see +.br user_namespaces (7)). +.pd +.re +.tp +.br cap_setfcap " (since linux 2.6.24)" +set arbitrary capabilities on a file. +.ip +.\" commit db2e718a47984b9d71ed890eb2ea36ecf150de18 +since linux 5.12, this capability is +also needed to map user id 0 in a new user namespace; see +.br user_namespaces (7) +for details. +.tp +.b cap_setpcap +if file capabilities are supported (i.e., since linux 2.6.24): +add any capability from the calling thread's bounding set +to its inheritable set; +drop capabilities from the bounding set (via +.br prctl (2) +.br pr_capbset_drop ); +make changes to the +.i securebits +flags. +.ip +if file capabilities are not supported (i.e., kernels before linux 2.6.24): +grant or remove any capability in the +caller's permitted capability set to or from any other process. +(this property of +.b cap_setpcap +is not available when the kernel is configured to support +file capabilities, since +.b cap_setpcap +has entirely different semantics for such kernels.) +.tp +.b cap_setuid +.rs +.pd 0 +.ip * 2 +make arbitrary manipulations of process uids +.rb ( setuid (2), +.br setreuid (2), +.br setresuid (2), +.br setfsuid (2)); +.ip * +forge uid when passing socket credentials via unix domain sockets; +.ip * +write a user id mapping in a user namespace (see +.br user_namespaces (7)). +.pd +.re +.\" fixme cap_setuid also an effect in exec(); document this. +.tp +.b cap_sys_admin +.ir note : +this capability is overloaded; see +.ir "notes to kernel developers" , +below. +.ip +.pd 0 +.rs +.ip * 2 +perform a range of system administration operations including: +.br quotactl (2), +.br mount (2), +.br umount (2), +.br pivot_root (2), +.br swapon (2), +.br swapoff (2), +.br sethostname (2), +and +.br setdomainname (2); +.ip * +perform privileged +.br syslog (2) +operations (since linux 2.6.37, +.br cap_syslog +should be used to permit such operations); +.ip * +perform +.b vm86_request_irq +.br vm86 (2) +command; +.ip * +access the same checkpoint/restore functionality that is governed by +.br cap_checkpoint_restore +(but the latter, weaker capability is preferred for accessing +that functionality). +.ip * +perform the same bpf operations as are governed by +.br cap_bpf +(but the latter, weaker capability is preferred for accessing +that functionality). +.ip * +employ the same performance monitoring mechanisms as are governed by +.br cap_perfmon +(but the latter, weaker capability is preferred for accessing +that functionality). +.ip * +perform +.b ipc_set +and +.b ipc_rmid +operations on arbitrary system v ipc objects; +.ip * +override +.b rlimit_nproc +resource limit; +.ip * +perform operations on +.i trusted +and +.i security +extended attributes (see +.br xattr (7)); +.ip * +use +.br lookup_dcookie (2); +.ip * +use +.br ioprio_set (2) +to assign +.b ioprio_class_rt +and (before linux 2.6.25) +.b ioprio_class_idle +i/o scheduling classes; +.ip * +forge pid when passing socket credentials via unix domain sockets; +.ip * +exceed +.ir /proc/sys/fs/file\-max , +the system-wide limit on the number of open files, +in system calls that open files (e.g., +.br accept (2), +.br execve (2), +.br open (2), +.br pipe (2)); +.ip * +employ +.b clone_* +flags that create new namespaces with +.br clone (2) +and +.br unshare (2) +(but, since linux 3.8, +creating user namespaces does not require any capability); +.ip * +access privileged +.i perf +event information; +.ip * +call +.br setns (2) +(requires +.b cap_sys_admin +in the +.i target +namespace); +.ip * +call +.br fanotify_init (2); +.ip * +perform privileged +.b keyctl_chown +and +.b keyctl_setperm +.br keyctl (2) +operations; +.ip * +perform +.br madvise (2) +.b madv_hwpoison +operation; +.ip * +employ the +.b tiocsti +.br ioctl (2) +to insert characters into the input queue of a terminal other than +the caller's controlling terminal; +.ip * +employ the obsolete +.br nfsservctl (2) +system call; +.ip * +employ the obsolete +.br bdflush (2) +system call; +.ip * +perform various privileged block-device +.br ioctl (2) +operations; +.ip * +perform various privileged filesystem +.br ioctl (2) +operations; +.ip * +perform privileged +.br ioctl (2) +operations on the +.ir /dev/random +device (see +.br random (4)); +.ip * +install a +.br seccomp (2) +filter without first having to set the +.i no_new_privs +thread attribute; +.ip * +modify allow/deny rules for device control groups; +.ip * +employ the +.br ptrace (2) +.b ptrace_seccomp_get_filter +operation to dump tracee's seccomp filters; +.ip * +employ the +.br ptrace (2) +.b ptrace_setoptions +operation to suspend the tracee's seccomp protections (i.e., the +.b ptrace_o_suspend_seccomp +flag); +.ip * +perform administrative operations on many device drivers; +.ip * +modify autogroup nice values by writing to +.ir /proc/[pid]/autogroup +(see +.br sched (7)). +.re +.pd +.tp +.b cap_sys_boot +use +.br reboot (2) +and +.br kexec_load (2). +.tp +.b cap_sys_chroot +.rs +.pd 0 +.ip * 2 +use +.br chroot (2); +.ip * +change mount namespaces using +.br setns (2). +.pd +.re +.tp +.b cap_sys_module +.rs +.pd 0 +.ip * 2 +load and unload kernel modules +(see +.br init_module (2) +and +.br delete_module (2)); +.ip * +in kernels before 2.6.25: +drop capabilities from the system-wide capability bounding set. +.pd +.re +.tp +.b cap_sys_nice +.pd 0 +.rs +.ip * 2 +lower the process nice value +.rb ( nice (2), +.br setpriority (2)) +and change the nice value for arbitrary processes; +.ip * +set real-time scheduling policies for calling process, +and set scheduling policies and priorities for arbitrary processes +.rb ( sched_setscheduler (2), +.br sched_setparam (2), +.br sched_setattr (2)); +.ip * +set cpu affinity for arbitrary processes +.rb ( sched_setaffinity (2)); +.ip * +set i/o scheduling class and priority for arbitrary processes +.rb ( ioprio_set (2)); +.ip * +apply +.br migrate_pages (2) +to arbitrary processes and allow processes +to be migrated to arbitrary nodes; +.\" fixme cap_sys_nice also has the following effect for +.\" migrate_pages(2): +.\" do_migrate_pages(mm, &old, &new, +.\" capable(cap_sys_nice) ? mpol_mf_move_all : mpol_mf_move); +.\" +.\" document this. +.ip * +apply +.br move_pages (2) +to arbitrary processes; +.ip * +use the +.b mpol_mf_move_all +flag with +.br mbind (2) +and +.br move_pages (2). +.re +.pd +.tp +.b cap_sys_pacct +use +.br acct (2). +.tp +.b cap_sys_ptrace +.pd 0 +.rs +.ip * 2 +trace arbitrary processes using +.br ptrace (2); +.ip * +apply +.br get_robust_list (2) +to arbitrary processes; +.ip * +transfer data to or from the memory of arbitrary processes using +.br process_vm_readv (2) +and +.br process_vm_writev (2); +.ip * +inspect processes using +.br kcmp (2). +.re +.pd +.tp +.b cap_sys_rawio +.pd 0 +.rs +.ip * 2 +perform i/o port operations +.rb ( iopl (2) +and +.br ioperm (2)); +.ip * +access +.ir /proc/kcore ; +.ip * +employ the +.b fibmap +.br ioctl (2) +operation; +.ip * +open devices for accessing x86 model-specific registers (msrs, see +.br msr (4)); +.ip * +update +.ir /proc/sys/vm/mmap_min_addr ; +.ip * +create memory mappings at addresses below the value specified by +.ir /proc/sys/vm/mmap_min_addr ; +.ip * +map files in +.ir /proc/bus/pci ; +.ip * +open +.ir /dev/mem +and +.ir /dev/kmem ; +.ip * +perform various scsi device commands; +.ip * +perform certain operations on +.br hpsa (4) +and +.br cciss (4) +devices; +.ip * +perform a range of device-specific operations on other devices. +.re +.pd +.tp +.b cap_sys_resource +.pd 0 +.rs +.ip * 2 +use reserved space on ext2 filesystems; +.ip * +make +.br ioctl (2) +calls controlling ext3 journaling; +.ip * +override disk quota limits; +.ip * +increase resource limits (see +.br setrlimit (2)); +.ip * +override +.b rlimit_nproc +resource limit; +.ip * +override maximum number of consoles on console allocation; +.ip * +override maximum number of keymaps; +.ip * +allow more than 64hz interrupts from the real-time clock; +.ip * +raise +.i msg_qbytes +limit for a system v message queue above the limit in +.i /proc/sys/kernel/msgmnb +(see +.br msgop (2) +and +.br msgctl (2)); +.ip * +allow the +.b rlimit_nofile +resource limit on the number of "in-flight" file descriptors +to be bypassed when passing file descriptors to another process +via a unix domain socket (see +.br unix (7)); +.ip * +override the +.i /proc/sys/fs/pipe\-size\-max +limit when setting the capacity of a pipe using the +.b f_setpipe_sz +.br fcntl (2) +command; +.ip * +use +.br f_setpipe_sz +to increase the capacity of a pipe above the limit specified by +.ir /proc/sys/fs/pipe\-max\-size ; +.ip * +override +.ir /proc/sys/fs/mqueue/queues_max , +.ir /proc/sys/fs/mqueue/msg_max , +and +.i /proc/sys/fs/mqueue/msgsize_max +limits when creating posix message queues (see +.br mq_overview (7)); +.ip * +employ the +.br prctl (2) +.b pr_set_mm +operation; +.ip * +set +.ir /proc/[pid]/oom_score_adj +to a value lower than the value last set by a process with +.br cap_sys_resource . +.re +.pd +.tp +.b cap_sys_time +set system clock +.rb ( settimeofday (2), +.br stime (2), +.br adjtimex (2)); +set real-time (hardware) clock. +.tp +.b cap_sys_tty_config +use +.br vhangup (2); +employ various privileged +.br ioctl (2) +operations on virtual terminals. +.tp +.br cap_syslog " (since linux 2.6.37)" +.rs +.pd 0 +.ip * 2 +perform privileged +.br syslog (2) +operations. +see +.br syslog (2) +for information on which operations require privilege. +.ip * +view kernel addresses exposed via +.i /proc +and other interfaces when +.ir /proc/sys/kernel/kptr_restrict +has the value 1. +(see the discussion of the +.i kptr_restrict +in +.br proc (5).) +.pd +.re +.tp +.br cap_wake_alarm " (since linux 3.0)" +trigger something that will wake up the system (set +.b clock_realtime_alarm +and +.b clock_boottime_alarm +timers). +.\" +.ss past and current implementation +a full implementation of capabilities requires that: +.ip 1. 3 +for all privileged operations, +the kernel must check whether the thread has the required +capability in its effective set. +.ip 2. +the kernel must provide system calls allowing a thread's capability sets to +be changed and retrieved. +.ip 3. +the filesystem must support attaching capabilities to an executable file, +so that a process gains those capabilities when the file is executed. +.pp +before kernel 2.6.24, only the first two of these requirements are met; +since kernel 2.6.24, all three requirements are met. +.\" +.ss notes to kernel developers +when adding a new kernel feature that should be governed by a capability, +consider the following points. +.ip * 3 +the goal of capabilities is divide the power of superuser into pieces, +such that if a program that has one or more capabilities is compromised, +its power to do damage to the system would be less than the same program +running with root privilege. +.ip * +you have the choice of either creating a new capability for your new feature, +or associating the feature with one of the existing capabilities. +in order to keep the set of capabilities to a manageable size, +the latter option is preferable, +unless there are compelling reasons to take the former option. +(there is also a technical limit: +the size of capability sets is currently limited to 64 bits.) +.ip * +to determine which existing capability might best be associated +with your new feature, review the list of capabilities above in order +to find a "silo" into which your new feature best fits. +one approach to take is to determine if there are other features +requiring capabilities that will always be used along with the new feature. +if the new feature is useless without these other features, +you should use the same capability as the other features. +.ip * +.ir don't +choose +.b cap_sys_admin +if you can possibly avoid it! +a vast proportion of existing capability checks are associated +with this capability (see the partial list above). +it can plausibly be called "the new root", +since on the one hand, it confers a wide range of powers, +and on the other hand, +its broad scope means that this is the capability +that is required by many privileged programs. +don't make the problem worse. +the only new features that should be associated with +.b cap_sys_admin +are ones that +.i closely +match existing uses in that silo. +.ip * +if you have determined that it really is necessary to create +a new capability for your feature, +don't make or name it as a "single-use" capability. +thus, for example, the addition of the highly specific +.br cap_sys_pacct +was probably a mistake. +instead, try to identify and name your new capability as a broader +silo into which other related future use cases might fit. +.\" +.ss thread capability sets +each thread has the following capability sets containing zero or more +of the above capabilities: +.tp +.ir permitted +this is a limiting superset for the effective +capabilities that the thread may assume. +it is also a limiting superset for the capabilities that +may be added to the inheritable set by a thread that does not have the +.b cap_setpcap +capability in its effective set. +.ip +if a thread drops a capability from its permitted set, +it can never reacquire that capability (unless it +.br execve (2)s +either a set-user-id-root program, or +a program whose associated file capabilities grant that capability). +.tp +.ir inheritable +this is a set of capabilities preserved across an +.br execve (2). +inheritable capabilities remain inheritable when executing any program, +and inheritable capabilities are added to the permitted set when executing +a program that has the corresponding bits set in the file inheritable set. +.ip +because inheritable capabilities are not generally preserved across +.br execve (2) +when running as a non-root user, applications that wish to run helper +programs with elevated capabilities should consider using +ambient capabilities, described below. +.tp +.ir effective +this is the set of capabilities used by the kernel to +perform permission checks for the thread. +.tp +.ir bounding " (per-thread since linux 2.6.25)" +the capability bounding set is a mechanism that can be used +to limit the capabilities that are gained during +.br execve (2). +.ip +since linux 2.6.25, this is a per-thread capability set. +in older kernels, the capability bounding set was a system wide attribute +shared by all threads on the system. +.ip +for more details on the capability bounding set, see below. +.tp +.ir ambient " (since linux 4.3)" +.\" commit 58319057b7847667f0c9585b9de0e8932b0fdb08 +this is a set of capabilities that are preserved across an +.br execve (2) +of a program that is not privileged. +the ambient capability set obeys the invariant that no capability +can ever be ambient if it is not both permitted and inheritable. +.ip +the ambient capability set can be directly modified using +.br prctl (2). +ambient capabilities are automatically lowered if either of +the corresponding permitted or inheritable capabilities is lowered. +.ip +executing a program that changes uid or gid due to the +set-user-id or set-group-id bits or executing a program that has +any file capabilities set will clear the ambient set. +ambient capabilities are added to the permitted set and +assigned to the effective set when +.br execve (2) +is called. +if ambient capabilities cause a process's permitted and effective +capabilities to increase during an +.br execve (2), +this does not trigger the secure-execution mode described in +.br ld.so (8). +.pp +a child created via +.br fork (2) +inherits copies of its parent's capability sets. +see below for a discussion of the treatment of capabilities during +.br execve (2). +.pp +using +.br capset (2), +a thread may manipulate its own capability sets (see below). +.pp +since linux 3.2, the file +.i /proc/sys/kernel/cap_last_cap +.\" commit 73efc0394e148d0e15583e13712637831f926720 +exposes the numerical value of the highest capability +supported by the running kernel; +this can be used to determine the highest bit +that may be set in a capability set. +.\" +.ss file capabilities +since kernel 2.6.24, the kernel supports +associating capability sets with an executable file using +.br setcap (8). +the file capability sets are stored in an extended attribute (see +.br setxattr (2) +and +.br xattr (7)) +named +.ir "security.capability" . +writing to this extended attribute requires the +.br cap_setfcap +capability. +the file capability sets, +in conjunction with the capability sets of the thread, +determine the capabilities of a thread after an +.br execve (2). +.pp +the three file capability sets are: +.tp +.ir permitted " (formerly known as " forced ): +these capabilities are automatically permitted to the thread, +regardless of the thread's inheritable capabilities. +.tp +.ir inheritable " (formerly known as " allowed ): +this set is anded with the thread's inheritable set to determine which +inheritable capabilities are enabled in the permitted set of +the thread after the +.br execve (2). +.tp +.ir effective : +this is not a set, but rather just a single bit. +if this bit is set, then during an +.br execve (2) +all of the new permitted capabilities for the thread are +also raised in the effective set. +if this bit is not set, then after an +.br execve (2), +none of the new permitted capabilities is in the new effective set. +.ip +enabling the file effective capability bit implies +that any file permitted or inheritable capability that causes a +thread to acquire the corresponding permitted capability during an +.br execve (2) +(see the transformation rules described below) will also acquire that +capability in its effective set. +therefore, when assigning capabilities to a file +.rb ( setcap (8), +.br cap_set_file (3), +.br cap_set_fd (3)), +if we specify the effective flag as being enabled for any capability, +then the effective flag must also be specified as enabled +for all other capabilities for which the corresponding permitted or +inheritable flags is enabled. +.\" +.ss file capability extended attribute versioning +to allow extensibility, +the kernel supports a scheme to encode a version number inside the +.i security.capability +extended attribute that is used to implement file capabilities. +these version numbers are internal to the implementation, +and not directly visible to user-space applications. +to date, the following versions are supported: +.tp +.br vfs_cap_revision_1 +this was the original file capability implementation, +which supported 32-bit masks for file capabilities. +.tp +.br vfs_cap_revision_2 " (since linux 2.6.25)" +.\" commit e338d263a76af78fe8f38a72131188b58fceb591 +this version allows for file capability masks that are 64 bits in size, +and was necessary as the number of supported capabilities grew beyond 32. +the kernel transparently continues to support the execution of files +that have 32-bit version 1 capability masks, +but when adding capabilities to files that did not previously +have capabilities, or modifying the capabilities of existing files, +it automatically uses the version 2 scheme +(or possibly the version 3 scheme, as described below). +.tp +.br vfs_cap_revision_3 " (since linux 4.14)" +.\" commit 8db6c34f1dbc8e06aa016a9b829b06902c3e1340 +version 3 file capabilities are provided +to support namespaced file capabilities (described below). +.ip +as with version 2 file capabilities, +version 3 capability masks are 64 bits in size. +but in addition, the root user id of namespace is encoded in the +.i security.capability +extended attribute. +(a namespace's root user id is the value that user id 0 +inside that namespace maps to in the initial user namespace.) +.ip +version 3 file capabilities are designed to coexist +with version 2 capabilities; +that is, on a modern linux system, +there may be some files with version 2 capabilities +while others have version 3 capabilities. +.pp +before linux 4.14, +the only kind of file capability extended attribute +that could be attached to a file was a +.b vfs_cap_revision_2 +attribute. +since linux 4.14, +the version of the +.i security.capability +extended attribute that is attached to a file +depends on the circumstances in which the attribute was created. +.pp +starting with linux 4.14, a +.i security.capability +extended attribute is automatically created as (or converted to) +a version 3 +.rb ( vfs_cap_revision_3 ) +attribute if both of the following are true: +.ip (1) 4 +the thread writing the attribute resides in a noninitial user namespace. +(more precisely: the thread resides in a user namespace other +than the one from which the underlying filesystem was mounted.) +.ip (2) +the thread has the +.br cap_setfcap +capability over the file inode, +meaning that (a) the thread has the +.b cap_setfcap +capability in its own user namespace; +and (b) the uid and gid of the file inode have mappings in +the writer's user namespace. +.pp +when a +.br vfs_cap_revision_3 +.i security.capability +extended attribute is created, the root user id of the creating thread's +user namespace is saved in the extended attribute. +.pp +by contrast, creating or modifying a +.i security.capability +extended attribute from a privileged +.rb ( cap_setfcap ) +thread that resides in the +namespace where the underlying filesystem was mounted +(this normally means the initial user namespace) +automatically results in the creation of a version 2 +.rb ( vfs_cap_revision_2 ) +attribute. +.pp +note that the creation of a version 3 +.i security.capability +extended attribute is automatic. +that is to say, when a user-space application writes +.rb ( setxattr (2)) +a +.i security.capability +attribute in the version 2 format, +the kernel will automatically create a version 3 attribute +if the attribute is created in the circumstances described above. +correspondingly, when a version 3 +.i security.capability +attribute is retrieved +.rb ( getxattr (2)) +by a process that resides inside a user namespace that was created by the +root user id (or a descendant of that user namespace), +the returned attribute is (automatically) +simplified to appear as a version 2 attribute +(i.e., the returned value is the size of a version 2 attribute and does +not include the root user id). +these automatic translations mean that no changes are required to +user-space tools (e.g., +.br setcap (1) +and +.br getcap (1)) +in order for those tools to be used to create and retrieve version 3 +.i security.capability +attributes. +.pp +note that a file can have either a version 2 or a version 3 +.i security.capability +extended attribute associated with it, but not both: +creation or modification of the +.i security.capability +extended attribute will automatically modify the version +according to the circumstances in which the extended attribute is +created or modified. +.\" +.ss transformation of capabilities during execve() +during an +.br execve (2), +the kernel calculates the new capabilities of +the process using the following algorithm: +.pp +.in +4n +.ex +p'(ambient) = (file is privileged) ? 0 : p(ambient) + +p'(permitted) = (p(inheritable) & f(inheritable)) | + (f(permitted) & p(bounding)) | p'(ambient) + +p'(effective) = f(effective) ? p'(permitted) : p'(ambient) + +p'(inheritable) = p(inheritable) [i.e., unchanged] + +p'(bounding) = p(bounding) [i.e., unchanged] +.ee +.in +.pp +where: +.rs 4 +.ip p() 6 +denotes the value of a thread capability set before the +.br execve (2) +.ip p'() +denotes the value of a thread capability set after the +.br execve (2) +.ip f() +denotes a file capability set +.re +.pp +note the following details relating to the above capability +transformation rules: +.ip * 3 +the ambient capability set is present only since linux 4.3. +when determining the transformation of the ambient set during +.br execve (2), +a privileged file is one that has capabilities or +has the set-user-id or set-group-id bit set. +.ip * +prior to linux 2.6.25, +the bounding set was a system-wide attribute shared by all threads. +that system-wide value was employed to calculate the new permitted set during +.br execve (2) +in the same manner as shown above for +.ir p(bounding) . +.pp +.ir note : +during the capability transitions described above, +file capabilities may be ignored (treated as empty) for the same reasons +that the set-user-id and set-group-id bits are ignored; see +.br execve (2). +file capabilities are similarly ignored if the kernel was booted with the +.i no_file_caps +option. +.pp +.ir note : +according to the rules above, +if a process with nonzero user ids performs an +.br execve (2) +then any capabilities that are present in +its permitted and effective sets will be cleared. +for the treatment of capabilities when a process with a +user id of zero performs an +.br execve (2), +see below under +.ir "capabilities and execution of programs by root" . +.\" +.ss safety checking for capability-dumb binaries +a capability-dumb binary is an application that has been +marked to have file capabilities, but has not been converted to use the +.br libcap (3) +api to manipulate its capabilities. +(in other words, this is a traditional set-user-id-root program +that has been switched to use file capabilities, +but whose code has not been modified to understand capabilities.) +for such applications, +the effective capability bit is set on the file, +so that the file permitted capabilities are automatically +enabled in the process effective set when executing the file. +the kernel recognizes a file which has the effective capability bit set +as capability-dumb for the purpose of the check described here. +.pp +when executing a capability-dumb binary, +the kernel checks if the process obtained all permitted capabilities +that were specified in the file permitted set, +after the capability transformations described above have been performed. +(the typical reason why this might +.i not +occur is that the capability bounding set masked out some +of the capabilities in the file permitted set.) +if the process did not obtain the full set of +file permitted capabilities, then +.br execve (2) +fails with the error +.br eperm . +this prevents possible security risks that could arise when +a capability-dumb application is executed with less privilege that it needs. +note that, by definition, +the application could not itself recognize this problem, +since it does not employ the +.br libcap (3) +api. +.\" +.ss capabilities and execution of programs by root +.\" see cap_bprm_set_creds(), bprm_caps_from_vfs_cap() and +.\" handle_privileged_root() in security/commoncap.c (linux 5.0 source) +in order to mirror traditional unix semantics, +the kernel performs special treatment of file capabilities when +a process with uid 0 (root) executes a program and +when a set-user-id-root program is executed. +.pp +after having performed any changes to the process effective id that +were triggered by the set-user-id mode bit of the binary\(eme.g., +switching the effective user id to 0 (root) because +a set-user-id-root program was executed\(emthe +kernel calculates the file capability sets as follows: +.ip 1. 3 +if the real or effective user id of the process is 0 (root), +then the file inheritable and permitted sets are ignored; +instead they are notionally considered to be all ones +(i.e., all capabilities enabled). +(there is one exception to this behavior, described below in +.ir "set-user-id-root programs that have file capabilities" .) +.ip 2. +if the effective user id of the process is 0 (root) or +the file effective bit is in fact enabled, +then the file effective bit is notionally defined to be one (enabled). +.pp +these notional values for the file's capability sets are then used +as described above to calculate the transformation of the process's +capabilities during +.br execve (2). +.pp +thus, when a process with nonzero uids +.br execve (2)s +a set-user-id-root program that does not have capabilities attached, +or when a process whose real and effective uids are zero +.br execve (2)s +a program, the calculation of the process's new +permitted capabilities simplifies to: +.pp +.in +4n +.ex +p'(permitted) = p(inheritable) | p(bounding) + +p'(effective) = p'(permitted) +.ee +.in +.pp +consequently, the process gains all capabilities in its permitted and +effective capability sets, +except those masked out by the capability bounding set. +(in the calculation of p'(permitted), +the p'(ambient) term can be simplified away because it is by +definition a proper subset of p(inheritable).) +.pp +the special treatments of user id 0 (root) described in this subsection +can be disabled using the securebits mechanism described below. +.\" +.\" +.ss set-user-id-root programs that have file capabilities +there is one exception to the behavior described under +.ir "capabilities and execution of programs by root" . +if (a) the binary that is being executed has capabilities attached and +(b) the real user id of the process is +.i not +0 (root) and +(c) the effective user id of the process +.i is +0 (root), then the file capability bits are honored +(i.e., they are not notionally considered to be all ones). +the usual way in which this situation can arise is when executing +a set-uid-root program that also has file capabilities. +when such a program is executed, +the process gains just the capabilities granted by the program +(i.e., not all capabilities, +as would occur when executing a set-user-id-root program +that does not have any associated file capabilities). +.pp +note that one can assign empty capability sets to a program file, +and thus it is possible to create a set-user-id-root program that +changes the effective and saved set-user-id of the process +that executes the program to 0, +but confers no capabilities to that process. +.\" +.ss capability bounding set +the capability bounding set is a security mechanism that can be used +to limit the capabilities that can be gained during an +.br execve (2). +the bounding set is used in the following ways: +.ip * 2 +during an +.br execve (2), +the capability bounding set is anded with the file permitted +capability set, and the result of this operation is assigned to the +thread's permitted capability set. +the capability bounding set thus places a limit on the permitted +capabilities that may be granted by an executable file. +.ip * +(since linux 2.6.25) +the capability bounding set acts as a limiting superset for +the capabilities that a thread can add to its inheritable set using +.br capset (2). +this means that if a capability is not in the bounding set, +then a thread can't add this capability to its +inheritable set, even if it was in its permitted capabilities, +and thereby cannot have this capability preserved in its +permitted set when it +.br execve (2)s +a file that has the capability in its inheritable set. +.pp +note that the bounding set masks the file permitted capabilities, +but not the inheritable capabilities. +if a thread maintains a capability in its inheritable set +that is not in its bounding set, +then it can still gain that capability in its permitted set +by executing a file that has the capability in its inheritable set. +.pp +depending on the kernel version, the capability bounding set is either +a system-wide attribute, or a per-process attribute. +.pp +.b "capability bounding set from linux 2.6.25 onward" +.pp +from linux 2.6.25, the +.i "capability bounding set" +is a per-thread attribute. +(the system-wide capability bounding set described below no longer exists.) +.pp +the bounding set is inherited at +.br fork (2) +from the thread's parent, and is preserved across an +.br execve (2). +.pp +a thread may remove capabilities from its capability bounding set using the +.br prctl (2) +.b pr_capbset_drop +operation, provided it has the +.b cap_setpcap +capability. +once a capability has been dropped from the bounding set, +it cannot be restored to that set. +a thread can determine if a capability is in its bounding set using the +.br prctl (2) +.b pr_capbset_read +operation. +.pp +removing capabilities from the bounding set is supported only if file +capabilities are compiled into the kernel. +in kernels before linux 2.6.33, +file capabilities were an optional feature configurable via the +.b config_security_file_capabilities +option. +since linux 2.6.33, +.\" commit b3a222e52e4d4be77cc4520a57af1a4a0d8222d1 +the configuration option has been removed +and file capabilities are always part of the kernel. +when file capabilities are compiled into the kernel, the +.b init +process (the ancestor of all processes) begins with a full bounding set. +if file capabilities are not compiled into the kernel, then +.b init +begins with a full bounding set minus +.br cap_setpcap , +because this capability has a different meaning when there are +no file capabilities. +.pp +removing a capability from the bounding set does not remove it +from the thread's inheritable set. +however it does prevent the capability from being added +back into the thread's inheritable set in the future. +.pp +.b "capability bounding set prior to linux 2.6.25" +.pp +in kernels before 2.6.25, the capability bounding set is a system-wide +attribute that affects all threads on the system. +the bounding set is accessible via the file +.ir /proc/sys/kernel/cap\-bound . +(confusingly, this bit mask parameter is expressed as a +signed decimal number in +.ir /proc/sys/kernel/cap\-bound .) +.pp +only the +.b init +process may set capabilities in the capability bounding set; +other than that, the superuser (more precisely: a process with the +.b cap_sys_module +capability) may only clear capabilities from this set. +.pp +on a standard system the capability bounding set always masks out the +.b cap_setpcap +capability. +to remove this restriction (dangerous!), modify the definition of +.b cap_init_eff_set +in +.i include/linux/capability.h +and rebuild the kernel. +.pp +the system-wide capability bounding set feature was added +to linux starting with kernel version 2.2.11. +.\" +.\" +.\" +.ss effect of user id changes on capabilities +to preserve the traditional semantics for transitions between +0 and nonzero user ids, +the kernel makes the following changes to a thread's capability +sets on changes to the thread's real, effective, saved set, +and filesystem user ids (using +.br setuid (2), +.br setresuid (2), +or similar): +.ip 1. 3 +if one or more of the real, effective, or saved set user ids +was previously 0, and as a result of the uid changes all of these ids +have a nonzero value, +then all capabilities are cleared from the permitted, effective, and ambient +capability sets. +.ip 2. +if the effective user id is changed from 0 to nonzero, +then all capabilities are cleared from the effective set. +.ip 3. +if the effective user id is changed from nonzero to 0, +then the permitted set is copied to the effective set. +.ip 4. +if the filesystem user id is changed from 0 to nonzero (see +.br setfsuid (2)), +then the following capabilities are cleared from the effective set: +.br cap_chown , +.br cap_dac_override , +.br cap_dac_read_search , +.br cap_fowner , +.br cap_fsetid , +.b cap_linux_immutable +(since linux 2.6.30), +.br cap_mac_override , +and +.b cap_mknod +(since linux 2.6.30). +if the filesystem uid is changed from nonzero to 0, +then any of these capabilities that are enabled in the permitted set +are enabled in the effective set. +.pp +if a thread that has a 0 value for one or more of its user ids wants +to prevent its permitted capability set being cleared when it resets +all of its user ids to nonzero values, it can do so using the +.b secbit_keep_caps +securebits flag described below. +.\" +.ss programmatically adjusting capability sets +a thread can retrieve and change its permitted, effective, and inheritable +capability sets using the +.br capget (2) +and +.br capset (2) +system calls. +however, the use of +.br cap_get_proc (3) +and +.br cap_set_proc (3), +both provided in the +.i libcap +package, +is preferred for this purpose. +the following rules govern changes to the thread capability sets: +.ip 1. 3 +if the caller does not have the +.b cap_setpcap +capability, +the new inheritable set must be a subset of the combination +of the existing inheritable and permitted sets. +.ip 2. +(since linux 2.6.25) +the new inheritable set must be a subset of the combination of the +existing inheritable set and the capability bounding set. +.ip 3. +the new permitted set must be a subset of the existing permitted set +(i.e., it is not possible to acquire permitted capabilities +that the thread does not currently have). +.ip 4. +the new effective set must be a subset of the new permitted set. +.ss the securebits flags: establishing a capabilities-only environment +.\" for some background: +.\" see http://lwn.net/articles/280279/ and +.\" http://article.gmane.org/gmane.linux.kernel.lsm/5476/ +starting with kernel 2.6.26, +and with a kernel in which file capabilities are enabled, +linux implements a set of per-thread +.i securebits +flags that can be used to disable special handling of capabilities for uid 0 +.ri ( root ). +these flags are as follows: +.tp +.b secbit_keep_caps +setting this flag allows a thread that has one or more 0 uids to retain +capabilities in its permitted set +when it switches all of its uids to nonzero values. +if this flag is not set, +then such a uid switch causes the thread to lose all permitted capabilities. +this flag is always cleared on an +.br execve (2). +.ip +note that even with the +.b secbit_keep_caps +flag set, the effective capabilities of a thread are cleared when it +switches its effective uid to a nonzero value. +however, +if the thread has set this flag and its effective uid is already nonzero, +and the thread subsequently switches all other uids to nonzero values, +then the effective capabilities will not be cleared. +.ip +the setting of the +.b secbit_keep_caps +flag is ignored if the +.b secbit_no_setuid_fixup +flag is set. +(the latter flag provides a superset of the effect of the former flag.) +.ip +this flag provides the same functionality as the older +.br prctl (2) +.b pr_set_keepcaps +operation. +.tp +.b secbit_no_setuid_fixup +setting this flag stops the kernel from adjusting the process's +permitted, effective, and ambient capability sets when +the thread's effective and filesystem uids are switched between +zero and nonzero values. +(see the subsection +.ir "effect of user id changes on capabilities" .) +.tp +.b secbit_noroot +if this bit is set, then the kernel does not grant capabilities +when a set-user-id-root program is executed, or when a process with +an effective or real uid of 0 calls +.br execve (2). +(see the subsection +.ir "capabilities and execution of programs by root" .) +.tp +.b secbit_no_cap_ambient_raise +setting this flag disallows raising ambient capabilities via the +.br prctl (2) +.br pr_cap_ambient_raise +operation. +.pp +each of the above "base" flags has a companion "locked" flag. +setting any of the "locked" flags is irreversible, +and has the effect of preventing further changes to the +corresponding "base" flag. +the locked flags are: +.br secbit_keep_caps_locked , +.br secbit_no_setuid_fixup_locked , +.br secbit_noroot_locked , +and +.br secbit_no_cap_ambient_raise_locked . +.pp +the +.i securebits +flags can be modified and retrieved using the +.br prctl (2) +.b pr_set_securebits +and +.b pr_get_securebits +operations. +the +.b cap_setpcap +capability is required to modify the flags. +note that the +.br secbit_* +constants are available only after including the +.i +header file. +.pp +the +.i securebits +flags are inherited by child processes. +during an +.br execve (2), +all of the flags are preserved, except +.b secbit_keep_caps +which is always cleared. +.pp +an application can use the following call to lock itself, +and all of its descendants, +into an environment where the only way of gaining capabilities +is by executing a program with associated file capabilities: +.pp +.in +4n +.ex +prctl(pr_set_securebits, + /* secbit_keep_caps off */ + secbit_keep_caps_locked | + secbit_no_setuid_fixup | + secbit_no_setuid_fixup_locked | + secbit_noroot | + secbit_noroot_locked); + /* setting/locking secbit_no_cap_ambient_raise + is not required */ +.ee +.in +.\" +.\" +.ss per-user-namespace """set-user-id-root""" programs +a set-user-id program whose uid matches the uid that +created a user namespace will confer capabilities +in the process's permitted and effective sets +when executed by any process inside that namespace +or any descendant user namespace. +.pp +the rules about the transformation of the process's capabilities during the +.br execve (2) +are exactly as described in the subsections +.ir "transformation of capabilities during execve()" +and +.ir "capabilities and execution of programs by root" , +with the difference that, in the latter subsection, "root" +is the uid of the creator of the user namespace. +.\" +.\" +.ss namespaced file capabilities +.\" commit 8db6c34f1dbc8e06aa016a9b829b06902c3e1340 +traditional (i.e., version 2) file capabilities associate +only a set of capability masks with a binary executable file. +when a process executes a binary with such capabilities, +it gains the associated capabilities (within its user namespace) +as per the rules described above in +"transformation of capabilities during execve()". +.pp +because version 2 file capabilities confer capabilities to +the executing process regardless of which user namespace it resides in, +only privileged processes are permitted to associate capabilities with a file. +here, "privileged" means a process that has the +.br cap_setfcap +capability in the user namespace where the filesystem was mounted +(normally the initial user namespace). +this limitation renders file capabilities useless for certain use cases. +for example, in user-namespaced containers, +it can be desirable to be able to create a binary that +confers capabilities only to processes executed inside that container, +but not to processes that are executed outside the container. +.pp +linux 4.14 added so-called namespaced file capabilities +to support such use cases. +namespaced file capabilities are recorded as version 3 (i.e., +.br vfs_cap_revision_3 ) +.i security.capability +extended attributes. +such an attribute is automatically created in the circumstances described +above under "file capability extended attribute versioning". +when a version 3 +.i security.capability +extended attribute is created, +the kernel records not just the capability masks in the extended attribute, +but also the namespace root user id. +.pp +as with a binary that has +.br vfs_cap_revision_2 +file capabilities, a binary with +.br vfs_cap_revision_3 +file capabilities confers capabilities to a process during +.br execve (). +however, capabilities are conferred only if the binary is executed by +a process that resides in a user namespace whose +uid 0 maps to the root user id that is saved in the extended attribute, +or when executed by a process that resides in a descendant of such a namespace. +.\" +.\" +.ss interaction with user namespaces +for further information on the interaction of +capabilities and user namespaces, see +.br user_namespaces (7). +.sh conforming to +no standards govern capabilities, but the linux capability implementation +is based on the withdrawn posix.1e draft standard; see +.ur https://archive.org\:/details\:/posix_1003.1e-990310 +.ue . +.sh notes +when attempting to +.br strace (1) +binaries that have capabilities (or set-user-id-root binaries), +you may find the +.i \-u +option useful. +something like: +.pp +.in +4n +.ex +$ \fbsudo strace \-o trace.log \-u ceci ./myprivprog\fp +.ee +.in +.pp +from kernel 2.5.27 to kernel 2.6.26, +.\" commit 5915eb53861c5776cfec33ca4fcc1fd20d66dd27 removed +.\" config_security_capabilities +capabilities were an optional kernel component, +and could be enabled/disabled via the +.b config_security_capabilities +kernel configuration option. +.pp +the +.i /proc/[pid]/task/tid/status +file can be used to view the capability sets of a thread. +the +.i /proc/[pid]/status +file shows the capability sets of a process's main thread. +before linux 3.8, nonexistent capabilities were shown as being +enabled (1) in these sets. +since linux 3.8, +.\" 7b9a7ec565505699f503b4fcf61500dceb36e744 +all nonexistent capabilities (above +.br cap_last_cap ) +are shown as disabled (0). +.pp +the +.i libcap +package provides a suite of routines for setting and +getting capabilities that is more comfortable and less likely +to change than the interface provided by +.br capset (2) +and +.br capget (2). +this package also provides the +.br setcap (8) +and +.br getcap (8) +programs. +it can be found at +.br +.ur https://git.kernel.org\:/pub\:/scm\:/libs\:/libcap\:/libcap.git\:/refs/ +.ue . +.pp +before kernel 2.6.24, and from kernel 2.6.24 to kernel 2.6.32 if +file capabilities are not enabled, a thread with the +.b cap_setpcap +capability can manipulate the capabilities of threads other than itself. +however, this is only theoretically possible, +since no thread ever has +.br cap_setpcap +in either of these cases: +.ip * 2 +in the pre-2.6.25 implementation the system-wide capability bounding set, +.ir /proc/sys/kernel/cap\-bound , +always masks out the +.b cap_setpcap +capability, and this can not be changed +without modifying the kernel source and rebuilding the kernel. +.ip * +if file capabilities are disabled (i.e., the kernel +.b config_security_file_capabilities +option is disabled), then +.b init +starts out with the +.b cap_setpcap +capability removed from its per-process bounding +set, and that bounding set is inherited by all other processes +created on the system. +.sh see also +.br capsh (1), +.br setpriv (1), +.br prctl (2), +.br setfsuid (2), +.br cap_clear (3), +.br cap_copy_ext (3), +.br cap_from_text (3), +.br cap_get_file (3), +.br cap_get_proc (3), +.br cap_init (3), +.br capgetp (3), +.br capsetp (3), +.br libcap (3), +.br proc (5), +.br credentials (7), +.br pthreads (7), +.br user_namespaces (7), +.br captest (8), \" from libcap-ng +.br filecap (8), \" from libcap-ng +.br getcap (8), +.br getpcaps (8), +.br netcap (8), \" from libcap-ng +.br pscap (8), \" from libcap-ng +.br setcap (8) +.pp +.i include/linux/capability.h +in the linux kernel source tree +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/cpu_set.3 + +.so man2/getpid.2 + +.so man3/tan.3 + +.\" copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de) +.\" and copyright 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under gpl +.\" %%%license_end +.\" +.\" modified 2004-11-15, added further text on flt_rounds +.\" as suggested by aeb and fabian kreutz +.\" +.th fma 3 2021-03-22 "" "linux programmer's manual" +.sh name +fma, fmaf, fmal \- floating-point multiply and add +.sh synopsis +.nf +.b #include +.pp +.bi "double fma(double " x ", double " y ", double " z ); +.bi "float fmaf(float " x ", float " y ", float " z ); +.bi "long double fmal(long double " x ", long double " y ", long double " z ); +.fi +.pp +link with \fi\-lm\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br fma (), +.br fmaf (), +.br fmal (): +.nf + _isoc99_source || _posix_c_source >= 200112l +.fi +.sh description +these functions compute +.ir x " * " y " + " z . +the result is rounded as one ternary operation according to the +current rounding mode (see +.br fenv (3)). +.sh return value +these functions return the value of +.ir x " * " y " + " z , +rounded as one ternary operation. +.pp +if +.i x +or +.i y +is a nan, a nan is returned. +.pp +if +.i x +times +.i y +is an exact infinity, and +.i z +is an infinity with the opposite sign, +a domain error occurs, +and a nan is returned. +.pp +.\" posix.1-2008 allows some possible differences for the following two +.\" domain error cases, but on linux they are treated the same (afaics). +.\" nevertheless, we'll mirror posix.1 and describe the two cases +.\" separately. +if one of +.i x +or +.i y +is an infinity, the other is 0, and +.i z +is not a nan, +a domain error occurs, and +a nan is returned. +.\" posix.1 says that a nan or an implementation-defined value shall +.\" be returned for this case. +.pp +if one of +.i x +or +.i y +is an infinity, and the other is 0, and +.i z +is a nan, +.\" posix.1 makes the domain error optional for this case. +a domain error occurs, and +a nan is returned. +.pp +if +.i x +times +.i y +is not an infinity times zero (or vice versa), and +.i z +is a nan, +a nan is returned. +.pp +if the result overflows, +a range error occurs, and +an infinity with the correct sign is returned. +.pp +if the result underflows, +a range error occurs, and +a signed 0 is returned. +.sh errors +see +.br math_error (7) +for information on how to determine whether an error has occurred +when calling these functions. +.pp +the following errors can occur: +.tp +domain error: \fix\fp * \fiy\fp + \fiz\fp, \ +or \fix\fp * \fiy\fp is invalid and \fiz\fp is not a nan +.\" .i errno +.\" is set to +.\" .br edom . +an invalid floating-point exception +.rb ( fe_invalid ) +is raised. +.tp +range error: result overflow +.\" .i errno +.\" is set to +.\" .br erange . +an overflow floating-point exception +.rb ( fe_overflow ) +is raised. +.tp +range error: result underflow +.\" .i errno +.\" is set to +.\" .br erange . +an underflow floating-point exception +.rb ( fe_underflow ) +is raised. +.pp +these functions do not set +.ir errno . +.\" fixme . is it intentional that these functions do not set errno? +.\" bug raised: http://sources.redhat.com/bugzilla/show_bug.cgi?id=6801 +.sh versions +these functions first appeared in glibc in version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br fma (), +.br fmaf (), +.br fmal () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.sh see also +.br remainder (3), +.br remquo (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" this manpage is copyright (c) 1992 drew eckhardt; +.\" and copyright (c) 1993 michael haardt; +.\" and copyright (c) 1993,1995 ian jackson +.\" and copyright (c) 2006, 2014 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified sat jul 24 00:35:52 1993 by rik faith +.\" modified thu jun 4 12:21:13 1998 by andries brouwer +.\" modified thu mar 3 09:49:35 2005 by michael haardt +.\" 2007-03-25, mtk, added various text to description. +.\" +.th rename 2 2021-08-27 "linux" "linux programmer's manual" +.sh name +rename, renameat, renameat2 \- change the name or location of a file +.sh synopsis +.nf +.b #include +.pp +.bi "int rename(const char *" oldpath ", const char *" newpath ); +.pp +.br "#include " "/* definition of " at_* " constants */" +.b #include +.pp +.bi "int renameat(int " olddirfd ", const char *" oldpath , +.bi " int " newdirfd ", const char *" newpath ); +.bi "int renameat2(int " olddirfd ", const char *" oldpath , +.bi " int " newdirfd ", const char *" newpath \ +", unsigned int " flags ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.nf +.br renameat (): + since glibc 2.10: + _posix_c_source >= 200809l + before glibc 2.10: + _atfile_source +.pp +.br renameat2 (): + _gnu_source +.fi +.sh description +.br rename () +renames a file, moving it between directories if required. +any other hard links to the file (as created using +.br link (2)) +are unaffected. +open file descriptors for +.i oldpath +are also unaffected. +.pp +various restrictions determine whether or not the rename operation succeeds: +see errors below. +.pp +if +.i newpath +already exists, it will be atomically replaced, so that there is +no point at which another process attempting to access +.i newpath +will find it missing. +however, there will probably be a window in which both +.i oldpath +and +.i newpath +refer to the file being renamed. +.pp +if +.i oldpath +and +.i newpath +are existing hard links referring to the same file, then +.br rename () +does nothing, and returns a success status. +.pp +if +.i newpath +exists but the operation fails for some reason, +.br rename () +guarantees to leave an instance of +.i newpath +in place. +.pp +.i oldpath +can specify a directory. +in this case, +.i newpath +must either not exist, or it must specify an empty directory. +.pp +if +.i oldpath +refers to a symbolic link, the link is renamed; if +.i newpath +refers to a symbolic link, the link will be overwritten. +.ss renameat() +the +.br renameat () +system call operates in exactly the same way as +.br rename (), +except for the differences described here. +.pp +if the pathname given in +.i oldpath +is relative, then it is interpreted relative to the directory +referred to by the file descriptor +.i olddirfd +(rather than relative to the current working directory of +the calling process, as is done by +.br rename () +for a relative pathname). +.pp +if +.i oldpath +is relative and +.i olddirfd +is the special value +.br at_fdcwd , +then +.i oldpath +is interpreted relative to the current working +directory of the calling process (like +.br rename ()). +.pp +if +.i oldpath +is absolute, then +.i olddirfd +is ignored. +.pp +the interpretation of +.i newpath +is as for +.ir oldpath , +except that a relative pathname is interpreted relative +to the directory referred to by the file descriptor +.ir newdirfd . +.pp +see +.br openat (2) +for an explanation of the need for +.br renameat (). +.ss renameat2() +.br renameat2 () +has an additional +.i flags +argument. +a +.br renameat2 () +call with a zero +.i flags +argument is equivalent to +.br renameat (). +.pp +the +.i flags +argument is a bit mask consisting of zero or more of the following flags: +.tp +.b rename_exchange +atomically exchange +.ir oldpath +and +.ir newpath . +both pathnames must exist +but may be of different types (e.g., one could be a non-empty directory +and the other a symbolic link). +.tp +.b rename_noreplace +don't overwrite +.ir newpath +of the rename. +return an error if +.ir newpath +already exists. +.ip +.b rename_noreplace +can't be employed together with +.br rename_exchange . +.ip +.b rename_noreplace +requires support from the underlying filesystem. +support for various filesystems was added as follows: +.rs +.ip * 3 +ext4 (linux 3.15); +.\" ext4: commit 0a7c3937a1f23f8cb5fc77ae01661e9968a51d0c +.ip * +btrfs, tmpfs, and cifs (linux 3.17); +.ip * +xfs (linux 4.0); +.\" btrfs: commit 80ace85c915d0f41016f82917218997b72431258 +.\" tmpfs: commit 3b69ff51d087d265aa4af3a532fc4f20bf33e718 +.\" cifs: commit 7c33d5972ce382bcc506d16235f1e9b7d22cbef8 +.\" +.\" gfs2 in 4.2? +.ip * +support for many other filesystems was added in linux 4.9, including +ext2, minix, reiserfs, jfs, vfat, and bpf. +.\" also affs, bfs, exofs, hfs, hfsplus, jffs2, logfs, msdos, +.\" nilfs2, omfs, sysvfs, ubifs, udf, ufs +.\" hugetlbfs, ramfs +.\" local filesystems: commit f03b8ad8d38634d13e802165cc15917481b47835 +.\" libfs: commit e0e0be8a835520e2f7c89f214dfda570922a1b90 +.re +.tp +.br rename_whiteout " (since linux 3.18)" +.\" commit 0d7a855526dd672e114aff2ac22b60fc6f155b08 +.\" commit 787fb6bc9682ec7c05fb5d9561b57100fbc1cc41 +this operation makes sense only for overlay/union +filesystem implementations. +.ip +specifying +.b rename_whiteout +creates a "whiteout" object at the source of +the rename at the same time as performing the rename. +the whole operation is atomic, +so that if the rename succeeds then the whiteout will also have been created. +.ip +a "whiteout" is an object that has special meaning in union/overlay +filesystem constructs. +in these constructs, +multiple layers exist and only the top one is ever modified. +a whiteout on an upper layer will effectively hide a +matching file in the lower layer, +making it appear as if the file didn't exist. +.ip +when a file that exists on the lower layer is renamed, +the file is first copied up (if not already on the upper layer) +and then renamed on the upper, read-write layer. +at the same time, the source file needs to be "whiteouted" +(so that the version of the source file in the lower layer +is rendered invisible). +the whole operation needs to be done atomically. +.ip +when not part of a union/overlay, +the whiteout appears as a character device with a {0,0} device number. +.\" https://www.freebsd.org/cgi/man.cgi?query=mount_unionfs&manpath=freebsd+11.0-release +(note that other union/overlay implementations may employ different methods +for storing whiteout entries; specifically, bsd union mount employs +a separate inode type, +.br dt_wht , +which, while supported by some filesystems available in linux, +such as coda and xfs, is ignored by the kernel's whiteout support code, +as of linux 4.19, at least.) +.ip +.b rename_whiteout +requires the same privileges as creating a device node (i.e., the +.br cap_mknod +capability). +.ip +.b rename_whiteout +can't be employed together with +.br rename_exchange . +.ip +.b rename_whiteout +requires support from the underlying filesystem. +among the filesystems that support it are +tmpfs (since linux 3.18), +.\" tmpfs: commit 46fdb794e3f52ef18b859ebc92f0a9d7db21c5df +ext4 (since linux 3.18), +.\" ext4: commit cd808deced431b66b5fa4e5c193cb7ec0059eaff +xfs (since linux 4.1), +.\" xfs: commit 7dcf5c3e4527cfa2807567b00387cf2ed5e07f00 +f2fs (since linux 4.2), +.\" f2fs: commit 7e01e7ad746bc8198a8b46163ddc73a1c7d22339 +btrfs (since linux 4.7), +.\" btrfs: commit cdd1fedf8261cd7a73c0596298902ff4f0f04492 +and ubifs (since linux 4.9). +.\" ubifs: commit 9e0a1fff8db56eaaebb74b4a3ef65f86811c4798 +.sh return value +on success, zero is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eacces +write permission is denied for the directory containing +.i oldpath +or +.ir newpath , +or, search permission is denied for one of the directories +in the path prefix of +.i oldpath +or +.ir newpath , +or +.i oldpath +is a directory and does not allow write permission (needed to update +the +.i .. +entry). +(see also +.br path_resolution (7).) +.tp +.b ebusy +the rename fails because +.ir oldpath " or " newpath +is a directory that is in use by some process (perhaps as +current working directory, or as root directory, or because +it was open for reading) or is in use by the system +(for example as a mount point), while the system considers +this an error. +(note that there is no requirement to return +.b ebusy +in such +cases\(emthere is nothing wrong with doing the rename anyway\(embut +it is allowed to return +.b ebusy +if the system cannot otherwise +handle such situations.) +.tp +.b edquot +the user's quota of disk blocks on the filesystem has been exhausted. +.tp +.b efault +.ir oldpath " or " newpath " points outside your accessible address space." +.tp +.b einval +the new pathname contained a path prefix of the old, or, more generally, +an attempt was made to make a directory a subdirectory of itself. +.tp +.b eisdir +.i newpath +is an existing directory, but +.i oldpath +is not a directory. +.tp +.b eloop +too many symbolic links were encountered in resolving +.ir oldpath " or " newpath . +.tp +.b emlink +.i oldpath +already has the maximum number of links to it, or +it was a directory and the directory containing +.i newpath +has the maximum number of links. +.tp +.b enametoolong +.ir oldpath " or " newpath " was too long." +.tp +.b enoent +the link named by +.i oldpath +does not exist; +or, a directory component in +.i newpath +does not exist; +or, +.i oldpath +or +.i newpath +is an empty string. +.tp +.b enomem +insufficient kernel memory was available. +.tp +.b enospc +the device containing the file has no room for the new directory +entry. +.tp +.b enotdir +a component used as a directory in +.ir oldpath " or " newpath +is not, in fact, a directory. +or, +.i oldpath +is a directory, and +.i newpath +exists but is not a directory. +.tp +.br enotempty " or " eexist +.i newpath +is a nonempty directory, that is, contains entries other than "." and "..". +.tp +.br eperm " or " eacces +the directory containing +.i oldpath +has the sticky bit +.rb ( s_isvtx ) +set and the process's effective user id is neither +the user id of the file to be deleted nor that of the directory +containing it, and the process is not privileged +(linux: does not have the +.b cap_fowner +capability); +or +.i newpath +is an existing file and the directory containing it has the sticky bit set +and the process's effective user id is neither the user id of the file +to be replaced nor that of the directory containing it, +and the process is not privileged +(linux: does not have the +.b cap_fowner +capability); +or the filesystem containing +.i oldpath +does not support renaming of the type requested. +.tp +.b erofs +the file is on a read-only filesystem. +.tp +.b exdev +.ir oldpath " and " newpath +are not on the same mounted filesystem. +(linux permits a filesystem to be mounted at multiple points, but +.br rename () +does not work across different mount points, +even if the same filesystem is mounted on both.) +.pp +the following additional errors can occur for +.br renameat () +and +.br renameat2 (): +.tp +.b ebadf +.i oldpath +.ri ( newpath ) +is relative but +.i olddirfd +.ri ( newdirfd ) +is not a valid file descriptor. +.tp +.b enotdir +.i oldpath +is relative and +.i olddirfd +is a file descriptor referring to a file other than a directory; +or similar for +.i newpath +and +.i newdirfd +.pp +the following additional errors can occur for +.br renameat2 (): +.tp +.b eexist +.i flags +contains +.b rename_noreplace +and +.i newpath +already exists. +.tp +.b einval +an invalid flag was specified in +.ir flags . +.tp +.b einval +both +.b rename_noreplace +and +.b rename_exchange +were specified in +.ir flags . +.tp +.b einval +both +.b rename_whiteout +and +.b rename_exchange +were specified in +.ir flags . +.tp +.b einval +the filesystem does not support one of the flags in +.ir flags . +.tp +.b enoent +.i flags +contains +.b rename_exchange +and +.ir newpath +does not exist. +.tp +.b eperm +.b rename_whiteout +was specified in +.ir flags , +but the caller does not have the +.b cap_mknod +capability. +.sh versions +.br renameat () +was added to linux in kernel 2.6.16; +library support was added to glibc in version 2.4. +.pp +.br renameat2 () +was added to linux in kernel 3.15; library support was added in glibc 2.28. +.sh conforming to +.br rename (): +4.3bsd, c89, c99, posix.1-2001, posix.1-2008. +.pp +.br renameat (): +posix.1-2008. +.pp +.br renameat2 () +is linux-specific. +.sh notes +.\" +.ss glibc notes +on older kernels where +.br renameat () +is unavailable, the glibc wrapper function falls back to the use of +.br rename (). +when +.i oldpath +and +.i newpath +are relative pathnames, +glibc constructs pathnames based on the symbolic links in +.ir /proc/self/fd +that correspond to the +.i olddirfd +and +.ir newdirfd +arguments. +.sh bugs +on nfs filesystems, you can not assume that if the operation +failed, the file was not renamed. +if the server does the rename operation +and then crashes, the retransmitted rpc which will be processed when the +server is up again causes a failure. +the application is expected to +deal with this. +see +.br link (2) +for a similar problem. +.sh see also +.br mv (1), +.br rename (1), +.br chmod (2), +.br link (2), +.br symlink (2), +.br unlink (2), +.br path_resolution (7), +.br symlink (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sat jul 24 19:40:39 1993 by rik faith (faith@cs.unc.edu) +.\" modified fri jun 25 12:10:47 1999 by andries brouwer (aeb@cwi.nl) +.\" +.th ecvt 3 2021-03-22 "" "linux programmer's manual" +.sh name +ecvt, fcvt \- convert a floating-point number to a string +.sh synopsis +.nf +.b #include +.pp +.bi "char *ecvt(double " number ", int " ndigits ", int *restrict " decpt , +.bi " int *restrict " sign ); +.bi "char *fcvt(double " number ", int " ndigits ", int *restrict " decpt , +.bi " int *restrict " sign ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br ecvt (), +.br fcvt (): +.nf + since glibc 2.17 + (_xopen_source >= 500 && ! (_posix_c_source >= 200809l)) + || /* glibc >= 2.20 */ _default_source + || /* glibc <= 2.19 */ _svid_source + glibc versions 2.12 to 2.16: + (_xopen_source >= 500 && ! (_posix_c_source >= 200112l)) + || _svid_source + before glibc 2.12: + _svid_source || _xopen_source >= 500 +.\" || _xopen_source && _xopen_source_extended +.fi +.sh description +the +.br ecvt () +function converts \finumber\fp to a null-terminated +string of \findigits\fp digits (where \findigits\fp is reduced to a +system-specific limit determined by the precision of a +.ir double ), +and returns a pointer to the string. +the high-order digit is nonzero, unless +.i number +is zero. +the low order digit is rounded. +the string itself does not contain a decimal point; however, +the position of the decimal point relative to the start of the string +is stored in \fi*decpt\fp. +a negative value for \fi*decpt\fp means that +the decimal point is to the left of the start of the string. +if the sign of +\finumber\fp is negative, \fi*sign\fp is set to a nonzero value, +otherwise it is set to 0. +if +.i number +is zero, it is unspecified whether \fi*decpt\fp is 0 or 1. +.pp +the +.br fcvt () +function is identical to +.br ecvt (), +except that +\findigits\fp specifies the number of digits after the decimal point. +.sh return value +both the +.br ecvt () +and +.br fcvt () +functions return a pointer to a +static string containing the ascii representation of \finumber\fp. +the static string is overwritten by each call to +.br ecvt () +or +.br fcvt (). +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br ecvt () +t} thread safety mt-unsafe race:ecvt +t{ +.br fcvt () +t} thread safety mt-unsafe race:fcvt +.te +.hy +.ad +.sp 1 +.sh conforming to +svr2; +marked as legacy in posix.1-2001. +posix.1-2008 removes the specifications of +.br ecvt () +and +.br fcvt (), +recommending the use of +.br sprintf (3) +instead (though +.br snprintf (3) +may be preferable). +.sh notes +.\" linux libc4 and libc5 specified the type of +.\" .i ndigits +.\" as +.\" .ir size_t . +not all locales use a point as the radix character ("decimal point"). +.sh see also +.br ecvt_r (3), +.br gcvt (3), +.br qecvt (3), +.br setlocale (3), +.br sprintf (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/getaddrinfo_a.3 + +.so man3/catopen.3 + +.so man3/opendir.3 + +.so man3/timeradd.3 + +.\" copyright (c) 1990, 1993 +.\" the regents of the university of california. all rights reserved. +.\" +.\" %%%license_start(bsd_4_clause_ucb) +.\" redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. all advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" this product includes software developed by the university of +.\" california, berkeley and its contributors. +.\" 4. neither the name of the university nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" this software is provided by the regents and contributors ``as is'' and +.\" any express or implied warranties, including, but not limited to, the +.\" implied warranties of merchantability and fitness for a particular purpose +.\" are disclaimed. in no event shall the regents or contributors be liable +.\" for any direct, indirect, incidental, special, exemplary, or consequential +.\" damages (including, but not limited to, procurement of substitute goods +.\" or services; loss of use, data, or profits; or business interruption) +.\" however caused and on any theory of liability, whether in contract, strict +.\" liability, or tort (including negligence or otherwise) arising in any way +.\" out of the use of this software, even if advised of the possibility of +.\" such damage. +.\" %%%license_end +.\" +.\" @(#)recno.3 8.5 (berkeley) 8/18/94 +.\" +.th recno 3 2017-09-15 "" "linux programmer's manual" +.uc 7 +.sh name +recno \- record number database access method +.sh synopsis +.nf +.ft b +#include +#include +.ft r +.fi +.sh description +.ir "note well" : +this page documents interfaces provided in glibc up until version 2.1. +since version 2.2, glibc no longer provides these interfaces. +probably, you are looking for the apis provided by the +.i libdb +library instead. +.pp +the routine +.br dbopen (3) +is the library interface to database files. +one of the supported file formats is record number files. +the general description of the database access methods is in +.br dbopen (3), +this manual page describes only the recno-specific information. +.pp +the record number data structure is either variable or fixed-length +records stored in a flat-file format, accessed by the logical record +number. +the existence of record number five implies the existence of records +one through four, and the deletion of record number one causes +record number five to be renumbered to record number four, as well +as the cursor, if positioned after record number one, to shift down +one record. +.pp +the recno access-method-specific data structure provided to +.br dbopen (3) +is defined in the +.i +include file as follows: +.pp +.in +4n +.ex +typedef struct { + unsigned long flags; + unsigned int cachesize; + unsigned int psize; + int lorder; + size_t reclen; + unsigned char bval; + char *bfname; +} recnoinfo; +.ee +.in +.pp +the elements of this structure are defined as follows: +.tp +.i flags +the flag value is specified by oring +any of the following values: +.rs +.tp +.b r_fixedlen +the records are fixed-length, not byte delimited. +the structure element +.i reclen +specifies the length of the record, and the structure element +.i bval +is used as the pad character. +any records, inserted into the database, that are less than +.i reclen +bytes long are automatically padded. +.tp +.b r_nokey +in the interface specified by +.br dbopen (3), +the sequential record retrieval fills in both the caller's key and +data structures. +if the +.b r_nokey +flag is specified, the +.i cursor +routines are not required to fill in the key structure. +this permits applications to retrieve records at the end of files without +reading all of the intervening records. +.tp +.b r_snapshot +this flag requires that a snapshot of the file be taken when +.br dbopen (3) +is called, instead of permitting any unmodified records to be read from +the original file. +.re +.tp +.i cachesize +a suggested maximum size, in bytes, of the memory cache. +this value is +.b only +advisory, and the access method will allocate more memory rather than fail. +if +.i cachesize +is 0 (no size is specified), a default cache is used. +.tp +.i psize +the recno access method stores the in-memory copies of its records +in a btree. +this value is the size (in bytes) of the pages used for nodes in that tree. +if +.i psize +is 0 (no page size is specified), a page size is chosen based on the +underlying filesystem i/o block size. +see +.br btree (3) +for more information. +.tp +.i lorder +the byte order for integers in the stored database metadata. +the number should represent the order as an integer; for example, +big endian order would be the number 4,321. +if +.i lorder +is 0 (no order is specified), the current host order is used. +.tp +.i reclen +the length of a fixed-length record. +.tp +.i bval +the delimiting byte to be used to mark the end of a record for +variable-length records, and the pad character for fixed-length +records. +if no value is specified, newlines ("\en") are used to mark the end +of variable-length records and fixed-length records are padded with +spaces. +.tp +.i bfname +the recno access method stores the in-memory copies of its records +in a btree. +if +.i bfname +is non-null, it specifies the name of the btree file, +as if specified as the filename for a +.br dbopen (3) +of a btree file. +.pp +the data part of the key/data pair used by the +.i recno +access method +is the same as other access methods. +the key is different. +the +.i data +field of the key should be a pointer to a memory location of type +.ir recno_t , +as defined in the +.i +include file. +this type is normally the largest unsigned integral type available to +the implementation. +the +.i size +field of the key should be the size of that type. +.pp +because there can be no metadata associated with the underlying +recno access method files, any changes made to the default values +(e.g., fixed record length or byte separator value) must be explicitly +specified each time the file is opened. +.pp +in the interface specified by +.br dbopen (3), +using the +.i put +interface to create a new record will cause the creation of multiple, +empty records if the record number is more than one greater than the +largest record currently in the database. +.sh errors +the +.i recno +access method routines may fail and set +.i errno +for any of the errors specified for the library routine +.br dbopen (3) +or the following: +.tp +.b einval +an attempt was made to add a record to a fixed-length database that +was too large to fit. +.sh bugs +only big and little endian byte order is supported. +.sh see also +.br btree (3), +.br dbopen (3), +.br hash (3), +.br mpool (3) +.pp +.ir "document processing in a relational database system" , +michael stonebraker, heidi stettner, joseph kalash, antonin guttman, +nadene lynn, memorandum no. ucb/erl m82/32, may 1982. +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/xcrypt.3 + +.so man7/system_data_types.7 + +.so man2/select.2 + +.so man3/syslog.3 + +.\" copyright (c) 2010, jan kara +.\" a few pieces copyright (c) 1996 andries brouwer (aeb@cwi.nl) +.\" and copyright 2010 (c) michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of +.\" this manual under the conditions for verbatim copying, provided that +.\" the entire resulting derived work is distributed under the terms of +.\" a permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume +.\" no responsibility for errors or omissions, or for damages resulting +.\" from the use of the information contained herein. the author(s) may +.\" not have taken the same level of care in the production of this +.\" manual, which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th quotactl 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +quotactl \- manipulate disk quotas +.sh synopsis +.nf +.b #include +.br "#include " " /* definition of " q_x* " and " xfs_quota_* \ +" constants" +.rb " (or " "; see notes) */" +.pp +.bi "int quotactl(int " cmd ", const char *" special ", int " id \ +", caddr_t " addr ); +.fi +.sh description +the quota system can be used to set per-user, per-group, and per-project limits +on the amount of disk space used on a filesystem. +for each user and/or group, +a soft limit and a hard limit can be set for each filesystem. +the hard limit can't be exceeded. +the soft limit can be exceeded, but warnings will ensue. +moreover, the user can't exceed the soft limit for more than grace period +duration (one week by default) at a time; +after this, the soft limit counts as a hard limit. +.pp +the +.br quotactl () +call manipulates disk quotas. +the +.i cmd +argument indicates a command to be applied to the user or +group id specified in +.ir id . +to initialize the +.ir cmd +argument, use the +.ir "qcmd(subcmd, type)" +macro. +the +.i type +value is either +.br usrquota , +for user quotas, +.br grpquota , +for group quotas, or (since linux 4.1) +.\" 847aac644e92e5624f2c153bab409bf713d5ff9a +.br prjquota , +for project quotas. +the +.i subcmd +value is described below. +.pp +the +.i special +argument is a pointer to a null-terminated string containing the pathname +of the (mounted) block special device for the filesystem being manipulated. +.pp +the +.i addr +argument is the address of an optional, command-specific, data structure +that is copied in or out of the system. +the interpretation of +.i addr +is given with each operation below. +.pp +the +.i subcmd +value is one of the following operations: +.tp +.b q_quotaon +turn on quotas for a filesystem. +the +.i id +argument is the identification number of the quota format to be used. +currently, there are three supported quota formats: +.rs +.tp 13 +.br qfmt_vfs_old +the original quota format. +.tp +.br qfmt_vfs_v0 +the standard vfs v0 quota format, which can handle 32-bit uids and gids +and quota limits up to 2^42 bytes and 2^32 inodes. +.tp +.br qfmt_vfs_v1 +a quota format that can handle 32-bit uids and gids +and quota limits of 2^64 bytes and 2^64 inodes. +.re +.ip +the +.ir addr +argument points to the pathname of a file containing the quotas for +the filesystem. +the quota file must exist; it is normally created with the +.br quotacheck (8) +program +.ip +quota information can be also stored in hidden system inodes +for ext4, xfs, and other filesystems if the filesystem is configured so. +in this case, there are no visible quota files and there is no need to +use +.br quotacheck (8). +quota information is always kept consistent by the filesystem and the +.b q_quotaon +operation serves only to enable enforcement of quota limits. +the presence of hidden +system inodes with quota information is indicated by the +.b dqf_sys_file +flag in the +.i dqi_flags +field returned by the +.b q_getinfo +operation. +.ip +this operation requires privilege +.rb ( cap_sys_admin ). +.tp +.b q_quotaoff +turn off quotas for a filesystem. +the +.i addr +and +.i id +arguments are ignored. +this operation requires privilege +.rb ( cap_sys_admin ). +.tp +.b q_getquota +get disk quota limits and current usage for user or group +.ir id . +the +.i addr +argument is a pointer to a +.i dqblk +structure defined in +.ir +as follows: +.ip +.in +4n +.ex +/* uint64_t is an unsigned 64\-bit integer; + uint32_t is an unsigned 32\-bit integer */ + +struct dqblk { /* definition since linux 2.4.22 */ + uint64_t dqb_bhardlimit; /* absolute limit on disk + quota blocks alloc */ + uint64_t dqb_bsoftlimit; /* preferred limit on + disk quota blocks */ + uint64_t dqb_curspace; /* current occupied space + (in bytes) */ + uint64_t dqb_ihardlimit; /* maximum number of + allocated inodes */ + uint64_t dqb_isoftlimit; /* preferred inode limit */ + uint64_t dqb_curinodes; /* current number of + allocated inodes */ + uint64_t dqb_btime; /* time limit for excessive + disk use */ + uint64_t dqb_itime; /* time limit for excessive + files */ + uint32_t dqb_valid; /* bit mask of qif_* + constants */ +}; + +/* flags in dqb_valid that indicate which fields in + dqblk structure are valid. */ + +#define qif_blimits 1 +#define qif_space 2 +#define qif_ilimits 4 +#define qif_inodes 8 +#define qif_btime 16 +#define qif_itime 32 +#define qif_limits (qif_blimits | qif_ilimits) +#define qif_usage (qif_space | qif_inodes) +#define qif_times (qif_btime | qif_itime) +#define qif_all (qif_limits | qif_usage | qif_times) +.ee +.in +.ip +the +.i dqb_valid +field is a bit mask that is set to indicate the entries in the +.i dqblk +structure that are valid. +currently, the kernel fills in all entries of the +.i dqblk +structure and marks them as valid in the +.i dqb_valid +field. +unprivileged users may retrieve only their own quotas; +a privileged user +.rb ( cap_sys_admin ) +can retrieve the quotas of any user. +.tp +.br q_getnextquota " (since linux 4.6)" +.\" commit 926132c0257a5a8d149a6a395cc3405e55420566 +this operation is the same as +.br q_getquota , +but it returns quota information for the next id greater than or equal to +.ir id +that has a quota set. +.ip +the +.i addr +argument is a pointer to a +.i nextdqblk +structure whose fields are as for the +.ir dqblk , +except for the addition of a +.i dqb_id +field that is used to return the id for which +quota information is being returned: +.ip +.in +4n +.ex +struct nextdqblk { + uint64_t dqb_bhardlimit; + uint64_t dqb_bsoftlimit; + uint64_t dqb_curspace; + uint64_t dqb_ihardlimit; + uint64_t dqb_isoftlimit; + uint64_t dqb_curinodes; + uint64_t dqb_btime; + uint64_t dqb_itime; + uint32_t dqb_valid; + uint32_t dqb_id; +}; +.ee +.in +.tp +.b q_setquota +set quota information for user or group +.ir id , +using the information supplied in the +.i dqblk +structure pointed to by +.ir addr . +the +.i dqb_valid +field of the +.i dqblk +structure indicates which entries in the structure have been set by the caller. +this operation supersedes the +.b q_setqlim +and +.b q_setuse +operations in the previous quota interfaces. +this operation requires privilege +.rb ( cap_sys_admin ). +.tp +.br q_getinfo " (since linux 2.4.22)" +get information (like grace times) about quotafile. +the +.i addr +argument should be a pointer to a +.i dqinfo +structure. +this structure is defined in +.ir +as follows: +.ip +.in +4n +.ex +/* uint64_t is an unsigned 64\-bit integer; + uint32_t is an unsigned 32\-bit integer */ + +struct dqinfo { /* defined since kernel 2.4.22 */ + uint64_t dqi_bgrace; /* time before block soft limit + becomes hard limit */ + uint64_t dqi_igrace; /* time before inode soft limit + becomes hard limit */ + uint32_t dqi_flags; /* flags for quotafile + (dqf_*) */ + uint32_t dqi_valid; +}; + +/* bits for dqi_flags */ + +/* quota format qfmt_vfs_old */ + +#define dqf_root_squash (1 << 0) /* root squash enabled */ + /* before linux v4.0, this had been defined + privately as v1_dqf_rsquash */ + +/* quota format qfmt_vfs_v0 / qfmt_vfs_v1 */ + +#define dqf_sys_file (1 << 16) /* quota stored in + a system file */ + +/* flags in dqi_valid that indicate which fields in + dqinfo structure are valid. */ + +#define iif_bgrace 1 +#define iif_igrace 2 +#define iif_flags 4 +#define iif_all (iif_bgrace | iif_igrace | iif_flags) +.ee +.in +.ip +the +.i dqi_valid +field in the +.i dqinfo +structure indicates the entries in the structure that are valid. +currently, the kernel fills in all entries of the +.i dqinfo +structure and marks them all as valid in the +.i dqi_valid +field. +the +.i id +argument is ignored. +.tp +.br q_setinfo " (since linux 2.4.22)" +set information about quotafile. +the +.i addr +argument should be a pointer to a +.i dqinfo +structure. +the +.i dqi_valid +field of the +.i dqinfo +structure indicates the entries in the structure +that have been set by the caller. +this operation supersedes the +.b q_setgrace +and +.b q_setflags +operations in the previous quota interfaces. +the +.i id +argument is ignored. +this operation requires privilege +.rb ( cap_sys_admin ). +.tp +.br q_getfmt " (since linux 2.4.22)" +get quota format used on the specified filesystem. +the +.i addr +argument should be a pointer to a 4-byte buffer +where the format number will be stored. +.tp +.b q_sync +update the on-disk copy of quota usages for a filesystem. +if +.i special +is null, then all filesystems with active quotas are sync'ed. +the +.i addr +and +.i id +arguments are ignored. +.tp +.br q_getstats " (supported up to linux 2.4.21)" +get statistics and other generic information about the quota subsystem. +the +.i addr +argument should be a pointer to a +.i dqstats +structure in which data should be stored. +this structure is defined in +.ir . +the +.i special +and +.i id +arguments are ignored. +.ip +this operation is obsolete and was removed in linux 2.4.22. +files in +.i /proc/sys/fs/quota/ +carry the information instead. +.pp +for xfs filesystems making use of the xfs quota manager (xqm), +the above operations are bypassed and the following operations are used: +.tp +.b q_xquotaon +turn on quotas for an xfs filesystem. +xfs provides the ability to turn on/off quota limit enforcement +with quota accounting. +therefore, xfs expects +.i addr +to be a pointer to an +.i "unsigned int" +that contains a bitwise combination of the following flags (defined in +.ir ): +.ip +.in +4n +.ex +xfs_quota_udq_acct /* user quota accounting */ +xfs_quota_udq_enfd /* user quota limits enforcement */ +xfs_quota_gdq_acct /* group quota accounting */ +xfs_quota_gdq_enfd /* group quota limits enforcement */ +xfs_quota_pdq_acct /* project quota accounting */ +xfs_quota_pdq_enfd /* project quota limits enforcement */ +.ee +.in +.ip +this operation requires privilege +.rb ( cap_sys_admin ). +the +.i id +argument is ignored. +.tp +.b q_xquotaoff +turn off quotas for an xfs filesystem. +as with +.br q_quotaon , +xfs filesystems expect a pointer to an +.i "unsigned int" +that specifies whether quota accounting and/or limit enforcement need +to be turned off (using the same flags as for +.b q_xquotaon +operation). +this operation requires privilege +.rb ( cap_sys_admin ). +the +.i id +argument is ignored. +.tp +.b q_xgetquota +get disk quota limits and current usage for user +.ir id . +the +.i addr +argument is a pointer to an +.i fs_disk_quota +structure, which is defined in +.i +as follows: +.ip +.in +4n +.ex +/* all the blk units are in bbs (basic blocks) of + 512 bytes. */ + +#define fs_dquot_version 1 /* fs_disk_quota.d_version */ + +#define xfs_user_quota (1<<0) /* user quota type */ +#define xfs_proj_quota (1<<1) /* project quota type */ +#define xfs_group_quota (1<<2) /* group quota type */ + +struct fs_disk_quota { + int8_t d_version; /* version of this structure */ + int8_t d_flags; /* xfs_{user,proj,group}_quota */ + uint16_t d_fieldmask; /* field specifier */ + uint32_t d_id; /* user, project, or group id */ + uint64_t d_blk_hardlimit; /* absolute limit on + disk blocks */ + uint64_t d_blk_softlimit; /* preferred limit on + disk blocks */ + uint64_t d_ino_hardlimit; /* maximum # allocated + inodes */ + uint64_t d_ino_softlimit; /* preferred inode limit */ + uint64_t d_bcount; /* # disk blocks owned by + the user */ + uint64_t d_icount; /* # inodes owned by the user */ + int32_t d_itimer; /* zero if within inode limits */ + /* if not, we refuse service */ + int32_t d_btimer; /* similar to above; for + disk blocks */ + uint16_t d_iwarns; /* # warnings issued with + respect to # of inodes */ + uint16_t d_bwarns; /* # warnings issued with + respect to disk blocks */ + int32_t d_padding2; /* padding \- for future use */ + uint64_t d_rtb_hardlimit; /* absolute limit on realtime + (rt) disk blocks */ + uint64_t d_rtb_softlimit; /* preferred limit on rt + disk blocks */ + uint64_t d_rtbcount; /* # realtime blocks owned */ + int32_t d_rtbtimer; /* similar to above; for rt + disk blocks */ + uint16_t d_rtbwarns; /* # warnings issued with + respect to rt disk blocks */ + int16_t d_padding3; /* padding \- for future use */ + char d_padding4[8]; /* yet more padding */ +}; +.ee +.in +.ip +unprivileged users may retrieve only their own quotas; +a privileged user +.rb ( cap_sys_admin ) +may retrieve the quotas of any user. +.tp +.br q_xgetnextquota " (since linux 4.6)" +.\" commit 8b37524962b9c54423374717786198f5c0820a28 +this operation is the same as +.br q_xgetquota , +but it returns (in the +.i fs_disk_quota +structure pointed by +.ir addr ) +quota information for the next id greater than or equal to +.ir id +that has a quota set. +note that since +.i fs_disk_quota +already has +.i q_id +field, no separate structure type is needed (in contrast with +.b q_getquota +and +.b q_getnextquota +operations) +.tp +.b q_xsetqlim +set disk quota limits for user +.ir id . +the +.i addr +argument is a pointer to an +.i fs_disk_quota +structure. +this operation requires privilege +.rb ( cap_sys_admin ). +.tp +.b q_xgetqstat +returns xfs filesystem-specific quota information in the +.i fs_quota_stat +structure pointed by +.ir addr . +this is useful for finding out how much space is used to store quota +information, and also to get the quota on/off status of a given local xfs +filesystem. +the +.i fs_quota_stat +structure itself is defined as follows: +.ip +.in +4n +.ex +#define fs_qstat_version 1 /* fs_quota_stat.qs_version */ + +struct fs_qfilestat { + uint64_t qfs_ino; /* inode number */ + uint64_t qfs_nblks; /* number of bbs + 512\-byte\-blocks */ + uint32_t qfs_nextents; /* number of extents */ +}; + +struct fs_quota_stat { + int8_t qs_version; /* version number for + future changes */ + uint16_t qs_flags; /* xfs_quota_{u,p,g}dq_{acct,enfd} */ + int8_t qs_pad; /* unused */ + struct fs_qfilestat qs_uquota; /* user quota storage + information */ + struct fs_qfilestat qs_gquota; /* group quota storage + information */ + uint32_t qs_incoredqs; /* number of dquots in core */ + int32_t qs_btimelimit; /* limit for blocks timer */ + int32_t qs_itimelimit; /* limit for inodes timer */ + int32_t qs_rtbtimelimit;/* limit for rt + blocks timer */ + uint16_t qs_bwarnlimit; /* limit for # of warnings */ + uint16_t qs_iwarnlimit; /* limit for # of warnings */ +}; +.ee +.in +.ip +the +.i id +argument is ignored. +.tp +.b q_xgetqstatv +returns xfs filesystem-specific quota information in the +.i fs_quota_statv +pointed to by +.ir addr . +this version of the operation uses a structure with proper versioning support, +along with appropriate layout (all fields are naturally aligned) and +padding to avoiding special compat handling; +it also provides the ability to get statistics regarding +the project quota file. +the +.i fs_quota_statv +structure itself is defined as follows: +.ip +.in +4n +.ex +#define fs_qstatv_version1 1 /* fs_quota_statv.qs_version */ + +struct fs_qfilestatv { + uint64_t qfs_ino; /* inode number */ + uint64_t qfs_nblks; /* number of bbs + 512\-byte\-blocks */ + uint32_t qfs_nextents; /* number of extents */ + uint32_t qfs_pad; /* pad for 8\-byte alignment */ +}; + +struct fs_quota_statv { + int8_t qs_version; /* version for future + changes */ + uint8_t qs_pad1; /* pad for 16\-bit alignment */ + uint16_t qs_flags; /* xfs_quota_.* flags */ + uint32_t qs_incoredqs; /* number of dquots incore */ + struct fs_qfilestatv qs_uquota; /* user quota + information */ + struct fs_qfilestatv qs_gquota; /* group quota + information */ + struct fs_qfilestatv qs_pquota; /* project quota + information */ + int32_t qs_btimelimit; /* limit for blocks timer */ + int32_t qs_itimelimit; /* limit for inodes timer */ + int32_t qs_rtbtimelimit; /* limit for rt blocks + timer */ + uint16_t qs_bwarnlimit; /* limit for # of warnings */ + uint16_t qs_iwarnlimit; /* limit for # of warnings */ + uint64_t qs_pad2[8]; /* for future proofing */ +}; +.ee +.in +.ip +the +.i qs_version +field of the structure should be filled with the version of the structure +supported by the callee (for now, only +.i fs_qstat_version1 +is supported). +the kernel will fill the structure in accordance with +version provided. +the +.i id +argument is ignored. +.tp +.b q_xquotarm " (since linux 3.16)" +.\" 9da93f9b7cdf8ab28da6b364cdc1fafc8670b4dc +free the disk space taken by disk quotas. +the +.i addr +argument should be a pointer to an +.i "unsigned int" +value containing flags (the same as in +.i d_flags +field of +.i fs_disk_quota +structure) +which identify what types of quota +should be removed. +(note that the quota type passed in the +.i cmd +argument is ignored, but should remain valid in order to pass preliminary +quotactl syscall handler checks.) +.ip +quotas must have already been turned off. +the +.i id +argument is ignored. +.tp +.br q_xquotasync " (since linux 2.6.15; no-op since linux 3.4)" +.\" added in commit ee34807a65aa0c5911dc27682863afca780a003e +this operation was an xfs quota equivalent to +.br q_sync , +but it is no-op since linux 3.4, +.\" 4b217ed9e30f94b6e8e5e262020ef0ceab6113af +as +.br sync (1) +writes quota information to disk now +(in addition to the other filesystem metadata that it writes out). +the +.ir special ", " id " and " addr +arguments are ignored. +.sh return value +on success, +.br quotactl () +returns 0; on error \-1 +is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eacces +.i cmd +is +.br q_quotaon , +and the quota file pointed to by +.i addr +exists, but is not a regular file or +is not on the filesystem pointed to by +.ir special . +.tp +.b ebusy +.i cmd +is +.br q_quotaon , +but another +.b q_quotaon +had already been performed. +.tp +.b efault +.i addr +or +.i special +is invalid. +.tp +.b einval +.i cmd +or +.i type +is invalid. +.tp +.b einval +.i cmd +is +.br q_quotaon , +but the specified quota file is corrupted. +.tp +.br einval " (since linux 5.5)" +.\" 3dd4d40b420846dd35869ccc8f8627feef2cff32 +.i cmd +is +.br q_xquotarm , +but +.i addr +does not point to valid quota types. +.tp +.b enoent +the file specified by +.i special +or +.i addr +does not exist. +.tp +.b enosys +the kernel has not been compiled with the +.b config_quota +option. +.tp +.b enotblk +.i special +is not a block device. +.tp +.b eperm +the caller lacked the required privilege +.rb ( cap_sys_admin ) +for the specified operation. +.tp +.b erange +.i cmd +is +.br q_setquota , +but the specified limits are out of the range allowed by the quota format. +.tp +.b esrch +no disk quota is found for the indicated user. +quotas have not been turned on for this filesystem. +.tp +.b esrch +.i cmd +is +.br q_quotaon , +but the specified quota format was not found. +.tp +.b esrch +.i cmd +is +.b q_getnextquota +or +.br q_xgetnextquota , +but there is no id greater than or equal to +.ir id +that has an active quota. +.sh notes +instead of +.i +one can use +.ir , +taking into account that there are several naming discrepancies: +.ip \(bu 3 +quota enabling flags (of format +.br xfs_quota_[ugp]dq_{acct,enfd} ) +are defined without a leading "x", as +.br fs_quota_[ugp]dq_{acct,enfd} . +.ip \(bu +the same is true for +.b xfs_{user,group,proj}_quota +quota type flags, which are defined as +.br fs_{user,group,proj}_quota . +.ip \(bu +the +.i dqblk_xfs.h +header file defines its own +.br xqm_usrquota , +.br xqm_grpquota , +and +.b xqm_prjquota +constants for the available quota types, but their values are the same as for +constants without the +.b xqm_ +prefix. +.sh see also +.br quota (1), +.br getrlimit (2), +.br quotacheck (8), +.br quotaon (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/getutent.3 + +.so man3/cpu_set.3 + +.\" copyright (c) 2006, 2008, michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th futimes 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +futimes, lutimes \- change file timestamps +.sh synopsis +.nf +.b #include +.pp +.bi "int futimes(int " fd ", const struct timeval " tv [2]); +.bi "int lutimes(const char *" filename ", const struct timeval " tv [2]); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br futimes (), +.br lutimes (): +.nf + since glibc 2.19: + _default_source + glibc 2.19 and earlier: + _bsd_source +.fi +.sh description +.br futimes () +changes the access and modification times of a file in the same way as +.br utimes (2), +with the difference that the file whose timestamps are to be changed +is specified via a file descriptor, +.ir fd , +rather than via a pathname. +.pp +.br lutimes () +changes the access and modification times of a file in the same way as +.br utimes (2), +with the difference that if +.i filename +refers to a symbolic link, then the link is not dereferenced: +instead, the timestamps of the symbolic link are changed. +.sh return value +on success, zero is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +errors are as for +.br utimes (2), +with the following additions for +.br futimes (): +.tp +.b ebadf +.i fd +is not a valid file descriptor. +.tp +.b enosys +the +.i /proc +filesystem could not be accessed. +.pp +the following additional error may occur for +.br lutimes (): +.tp +.b enosys +the kernel does not support this call; linux 2.6.22 or later is required. +.sh versions +.br futimes () +is available since glibc 2.3. +.br lutimes () +is available since glibc 2.6, and is implemented using the +.br utimensat (2) +system call, which is supported since kernel 2.6.22. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br futimes (), +.br lutimes () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +these functions are not specified in any standard. +other than linux, they are available only on the bsds. +.sh see also +.br utime (2), +.br utimensat (2), +.br symlink (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" and copyright 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified 1993-07-24 by rik faith (faith@cs.unc.edu) +.\" modified 2004-10-31 by aeb +.\" +.th ldexp 3 2021-03-22 "" "linux programmer's manual" +.sh name +ldexp, ldexpf, ldexpl \- multiply floating-point number by integral power of 2 +.sh synopsis +.nf +.b #include +.pp +.bi "double ldexp(double " x ", int " exp ); +.bi "float ldexpf(float " x ", int " exp ); +.bi "long double ldexpl(long double " x ", int " exp ); +.fi +.pp +link with \fi\-lm\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br ldexpf (), +.br ldexpl (): +.nf + _isoc99_source || _posix_c_source >= 200112l + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.sh description +these functions return the result of multiplying the floating-point number +.i x +by 2 raised to the power +.ir exp . +.sh return value +on success, these functions return +.ir "x * (2^exp)" . +.pp +if +.i exp +is zero, then +.i x +is returned. +.pp +if +.i x +is a nan, +a nan is returned. +.pp +if +.i x +is positive infinity (negative infinity), +positive infinity (negative infinity) is returned. +.pp +if the result underflows, +a range error occurs, +and zero is returned. +.pp +if the result overflows, +a range error occurs, +and the functions return +.br huge_val , +.br huge_valf , +or +.br huge_vall , +respectively, with a sign the same as +.ir x . +.sh errors +see +.br math_error (7) +for information on how to determine whether an error has occurred +when calling these functions. +.pp +the following errors can occur: +.tp +range error, overflow +.i errno +is set to +.br erange . +an overflow floating-point exception +.rb ( fe_overflow ) +is raised. +.tp +range error, underflow +.i errno +is set to +.br erange . +an underflow floating-point exception +.rb ( fe_underflow ) +is raised. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br ldexp (), +.br ldexpf (), +.br ldexpl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.pp +the variant returning +.i double +also conforms to +svr4, 4.3bsd, c89. +.sh see also +.br frexp (3), +.br modf (3), +.br scalbln (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/fdim.3 + +.so man3/ceil.3 + +.\" copyright (c) 1993 david metcalfe (david@prism.demon.co.uk) +.\" and copyright (c) 2008, 2016 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sat jul 24 16:09:49 1993 by rik faith (faith@cs.unc.edu) +.\" modified 11 june 1995 by andries brouwer (aeb@cwi.nl) +.\" modified 22 july 1996 by andries brouwer (aeb@cwi.nl) +.\" 2007-07-30 ulrich drepper , mtk: +.\" rework discussion of nonstandard structure fields. +.\" +.th readdir 3 2021-03-22 "" "linux programmer's manual" +.sh name +readdir \- read a directory +.sh synopsis +.nf +.b #include +.pp +.bi "struct dirent *readdir(dir *" dirp ); +.fi +.sh description +the +.br readdir () +function returns a pointer to a \fidirent\fp structure +representing the next directory entry in the directory stream pointed +to by \fidirp\fp. +it returns null on reaching the end of the directory stream or if +an error occurred. +.pp +in the glibc implementation, the +.i dirent +structure is defined as follows: +.pp +.in +4n +.ex +struct dirent { + ino_t d_ino; /* inode number */ + off_t d_off; /* not an offset; see below */ + unsigned short d_reclen; /* length of this record */ + unsigned char d_type; /* type of file; not supported + by all filesystem types */ + char d_name[256]; /* null\-terminated filename */ +}; +.ee +.in +.pp +the only fields in the +.i dirent +structure that are mandated by posix.1 are +.ir d_name +and +.ir d_ino . +the other fields are unstandardized, and not present on all systems; +see notes below for some further details. +.pp +the fields of the +.i dirent +structure are as follows: +.tp +.i d_ino +this is the inode number of the file. +.tp +.i d_off +the value returned in +.i d_off +is the same as would be returned by calling +.br telldir (3) +at the current position in the directory stream. +be aware that despite its type and name, the +.i d_off +field is seldom any kind of directory offset on modern filesystems. +.\" https://lwn.net/articles/544298/ +applications should treat this field as an opaque value, +making no assumptions about its contents; see also +.br telldir (3). +.tp +.i d_reclen +this is the size (in bytes) of the returned record. +this may not match the size of the structure definition shown above; +see notes. +.tp +.i d_type +this field contains a value indicating the file type, +making it possible to avoid the expense of calling +.br lstat (2) +if further actions depend on the type of the file. +.ip +when a suitable feature test macro is defined +.rb ( _default_source +on glibc versions since 2.19, or +.br _bsd_source +on glibc versions 2.19 and earlier), +glibc defines the following macro constants for the value returned in +.ir d_type : +.rs +.tp 12 +.b dt_blk +this is a block device. +.tp +.b dt_chr +this is a character device. +.tp +.b dt_dir +this is a directory. +.tp +.b dt_fifo +this is a named pipe (fifo). +.tp +.b dt_lnk +this is a symbolic link. +.tp +.b dt_reg +this is a regular file. +.tp +.b dt_sock +this is a unix domain socket. +.tp +.b dt_unknown +the file type could not be determined. +.re +.ip +currently, +.\" kernel 2.6.27 +.\" the same sentence is in getdents.2 +only some filesystems (among them: btrfs, ext2, ext3, and ext4) +have full support for returning the file type in +.ir d_type . +all applications must properly handle a return of +.br dt_unknown . +.tp +.i d_name +this field contains the null terminated filename. +.ir "see notes" . +.pp +the data returned by +.br readdir () +may be overwritten by subsequent calls to +.br readdir () +for the same directory stream. +.sh return value +on success, +.br readdir () +returns a pointer to a +.i dirent +structure. +(this structure may be statically allocated; do not attempt to +.br free (3) +it.) +.pp +if the end of the directory stream is reached, null is returned and +.i errno +is not changed. +if an error occurs, null is returned and +.i errno +is set to indicate the error. +to distinguish end of stream from an error, set +.i errno +to zero before calling +.br readdir () +and then check the value of +.i errno +if null is returned. +.sh errors +.tp +.b ebadf +invalid directory stream descriptor \fidirp\fp. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br readdir () +t} thread safety mt-unsafe race:dirstream +.te +.hy +.ad +.sp 1 +.pp +in the current posix.1 specification (posix.1-2008), +.br readdir () +is not required to be thread-safe. +however, in modern implementations (including the glibc implementation), +concurrent calls to +.br readdir () +that specify different directory streams are thread-safe. +in cases where multiple threads must read from the same directory stream, +using +.br readdir () +with external synchronization is still preferable to the use of the deprecated +.br readdir_r (3) +function. +it is expected that a future version of posix.1 +.\" fixme . +.\" http://www.austingroupbugs.net/view.php?id=696 +will require that +.br readdir () +be thread-safe when concurrently employed on different directory streams. +.sh conforming to +posix.1-2001, posix.1-2008, svr4, 4.3bsd. +.sh notes +a directory stream is opened using +.br opendir (3). +.pp +the order in which filenames are read by successive calls to +.br readdir () +depends on the filesystem implementation; +it is unlikely that the names will be sorted in any fashion. +.pp +only the fields +.i d_name +and (as an xsi extension) +.i d_ino +are specified in posix.1. +.\" posix.1-2001, posix.1-2008 +other than linux, the +.i d_type +field is available mainly only on bsd systems. +the remaining fields are available on many, but not all systems. +under glibc, +programs can check for the availability of the fields not defined +in posix.1 by testing whether the macros +.br _dirent_have_d_namlen , +.br _dirent_have_d_reclen , +.br _dirent_have_d_off , +or +.b _dirent_have_d_type +are defined. +.\" +.ss the d_name field +the +.i dirent +structure definition shown above is taken from the glibc headers, +and shows the +.i d_name +field with a fixed size. +.pp +.ir warning : +applications should avoid any dependence on the size of the +.i d_name +field. +posix defines it as +.ir "char\ d_name[]", +a character array of unspecified size, with at most +.b name_max +characters preceding the terminating null byte (\(aq\e0\(aq). +.pp +posix.1 explicitly notes that this field should not be used as an lvalue. +the standard also notes that the use of +.i sizeof(d_name) +is incorrect; use +.ir strlen(d_name) +instead. +(on some systems, this field is defined as +.ir char\ d_name[1] !) +by implication, the use +.ir "sizeof(struct dirent)" +to capture the size of the record including the size of +.ir d_name +is also incorrect. +.pp +note that while the call +.pp + fpathconf(fd, _pc_name_max) +.pp +returns the value 255 for most filesystems, +on some filesystems (e.g., cifs, windows smb servers), +the null-terminated filename that is (correctly) returned in +.i d_name +can actually exceed this size. +in such cases, the +.i d_reclen +field will contain a value that exceeds the size of the glibc +.i dirent +structure shown above. +.sh see also +.br getdents (2), +.br read (2), +.br closedir (3), +.br dirfd (3), +.br ftw (3), +.br offsetof (3), +.br opendir (3), +.br readdir_r (3), +.br rewinddir (3), +.br scandir (3), +.br seekdir (3), +.br telldir (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/malloc_hook.3 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sat jul 24 19:19:11 1993 by rik faith (faith@cs.unc.edu) +.\" modified wed oct 18 20:23:54 1995 by martin schulze +.\" modified mon apr 22 01:50:54 1996 by martin schulze +.\" 2001-07-25 added a clause about null proto (martin michlmayr or david n. welton) +.\" +.th getservent 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +getservent, getservbyname, getservbyport, setservent, endservent \- +get service entry +.sh synopsis +.nf +.b #include +.pp +.b struct servent *getservent(void); +.pp +.bi "struct servent *getservbyname(const char *" name ", const char *" proto ); +.bi "struct servent *getservbyport(int " port ", const char *" proto ); +.pp +.bi "void setservent(int " stayopen ); +.b void endservent(void); +.fi +.sh description +the +.br getservent () +function reads the next entry from the services database (see +.br services (5)) +and returns a +.i servent +structure containing +the broken-out fields from the entry. +a connection is opened to the database if necessary. +.pp +the +.br getservbyname () +function returns a +.i servent +structure +for the entry from the database +that matches the service +.i name +using protocol +.ir proto . +if +.i proto +is null, any protocol will be matched. +a connection is opened to the database if necessary. +.pp +the +.br getservbyport () +function returns a +.i servent +structure +for the entry from the database +that matches the port +.i port +(given in network byte order) +using protocol +.ir proto . +if +.i proto +is null, any protocol will be matched. +a connection is opened to the database if necessary. +.pp +the +.br setservent () +function opens a connection to the database, +and sets the next entry to the first entry. +if +.i stayopen +is nonzero, +then the connection to the database +will not be closed between calls to one of the +.br getserv* () +functions. +.pp +the +.br endservent () +function closes the connection to the database. +.pp +the +.i servent +structure is defined in +.i +as follows: +.pp +.in +4n +.ex +struct servent { + char *s_name; /* official service name */ + char **s_aliases; /* alias list */ + int s_port; /* port number */ + char *s_proto; /* protocol to use */ +} +.ee +.in +.pp +the members of the +.i servent +structure are: +.tp +.i s_name +the official name of the service. +.tp +.i s_aliases +a null-terminated list of alternative names for the service. +.tp +.i s_port +the port number for the service given in network byte order. +.tp +.i s_proto +the name of the protocol to use with this service. +.sh return value +the +.br getservent (), +.br getservbyname (), +and +.br getservbyport () +functions return a pointer to a +statically allocated +.i servent +structure, or null if an +error occurs or the end of the file is reached. +.sh files +.tp +.i /etc/services +services database file +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lb lb lbx +l l l. +interface attribute value +t{ +.br getservent () +t} thread safety t{ +mt-unsafe race:servent +race:serventbuf locale +t} +t{ +.br getservbyname () +t} thread safety t{ +mt-unsafe race:servbyname +locale +t} +t{ +.br getservbyport () +t} thread safety t{ +mt-unsafe race:servbyport +locale +t} +t{ +.br setservent (), +.br endservent () +t} thread safety t{ +mt-unsafe race:servent +locale +t} +.te +.hy +.ad +.sp 1 +in the above table, +.i servent +in +.i race:servent +signifies that if any of the functions +.br setservent (), +.br getservent (), +or +.br endservent () +are used in parallel in different threads of a program, +then data races could occur. +.sh conforming to +posix.1-2001, posix.1-2008, 4.3bsd. +.sh see also +.br getnetent (3), +.br getprotoent (3), +.br getservent_r (3), +.br services (5) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1997 nicolás lichtmaier +.\" created thu aug 7 00:44:00 art 1997 +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" added section stuff, aeb, 2002-04-22. +.\" corrected include file, drepper, 2003-06-15. +.\" +.th lockf 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +lockf \- apply, test or remove a posix lock on an open file +.sh synopsis +.nf +.b #include +.pp +.bi "int lockf(int " fd ", int " cmd ", off_t " len ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br lockf (): +.nf + _xopen_source >= 500 +.\" || _xopen_source && _xopen_source_extended + || /* glibc since 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.sh description +apply, test, or remove a posix lock on a section of an open file. +the file is specified by +.ir fd , +a file descriptor open for writing, the action by +.ir cmd , +and the section consists of byte positions +.ir pos .. pos + len \-1 +if +.i len +is positive, and +.ir pos \- len .. pos \-1 +if +.i len +is negative, where +.i pos +is the current file position, and if +.i len +is zero, the section extends from the current file position to +infinity, encompassing the present and future end-of-file positions. +in all cases, the section may extend past current end-of-file. +.pp +on linux, +.br lockf () +is just an interface on top of +.br fcntl (2) +locking. +many other systems implement +.br lockf () +in this way, but note that posix.1 leaves the relationship between +.br lockf () +and +.br fcntl (2) +locks unspecified. +a portable application should probably avoid mixing calls +to these interfaces. +.pp +valid operations are given below: +.tp +.b f_lock +set an exclusive lock on the specified section of the file. +if (part of) this section is already locked, the call +blocks until the previous lock is released. +if this section overlaps an earlier locked section, +both are merged. +file locks are released as soon as the process holding the locks +closes some file descriptor for the file. +a child process does not inherit these locks. +.tp +.b f_tlock +same as +.b f_lock +but the call never blocks and returns an error instead if the file is +already locked. +.tp +.b f_ulock +unlock the indicated section of the file. +this may cause a locked section to be split into two locked sections. +.tp +.b f_test +test the lock: return 0 if the specified section +is unlocked or locked by this process; return \-1, set +.i errno +to +.b eagain +.rb ( eacces +on some other systems), +if another process holds a lock. +.sh return value +on success, zero is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.br eacces " or " eagain +the file is locked and +.b f_tlock +or +.b f_test +was specified, or the operation is prohibited because the file has +been memory-mapped by another process. +.tp +.b ebadf +.i fd +is not an open file descriptor; or +.i cmd +is +.b f_lock +or +.br f_tlock +and +.i fd +is not a writable file descriptor. +.tp +.b edeadlk +the command was +.b f_lock +and this lock operation would cause a deadlock. +.tp +.b eintr +while waiting to acquire a lock, the call was interrupted by +delivery of a signal caught by a handler; see +.br signal (7). +.tp +.b einval +an invalid operation was specified in +.ir cmd . +.tp +.b enolck +too many segment locks open, lock table is full. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br lockf () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, svr4. +.sh see also +.br fcntl (2), +.br flock (2) +.pp +.i locks.txt +and +.i mandatory\-locking.txt +in the linux kernel source directory +.ir documentation/filesystems +(on older kernels, these files are directly under the +.i documentation +directory, and +.i mandatory\-locking.txt +is called +.ir mandatory.txt ) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/unimplemented.2 + +.so man7/iso_8859-15.7 + +.so man3/stailq.3 + +.\" copyright 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th getservent_r 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +getservent_r, getservbyname_r, getservbyport_r \- get +service entry (reentrant) +.sh synopsis +.nf +.b #include +.pp +.bi "int getservent_r(struct servent *restrict " result_buf , +.bi " char *restrict " buf ", size_t " buflen , +.bi " struct servent **restrict " result ); +.bi "int getservbyname_r(const char *restrict " name , +.bi " const char *restrict " proto , +.bi " struct servent *restrict " result_buf , +.bi " char *restrict " buf ", size_t " buflen , +.bi " struct servent **restrict " result ); +.bi "int getservbyport_r(int " port , +.bi " const char *restrict " proto , +.bi " struct servent *restrict " result_buf , +.bi " char *restrict " buf ", size_t " buflen , +.bi " struct servent **restrict " result ); +.pp +.fi +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br getservent_r (), +.br getservbyname_r (), +.br getservbyport_r (): +.nf + since glibc 2.19: + _default_source + glibc 2.19 and earlier: + _bsd_source || _svid_source +.fi +.sh description +the +.br getservent_r (), +.br getservbyname_r (), +and +.br getservbyport_r () +functions are the reentrant equivalents of, respectively, +.br getservent (3), +.br getservbyname (3), +and +.br getservbyport (3). +they differ in the way that the +.i servent +structure is returned, +and in the function calling signature and return value. +this manual page describes just the differences from +the nonreentrant functions. +.pp +instead of returning a pointer to a statically allocated +.i servent +structure as the function result, +these functions copy the structure into the location pointed to by +.ir result_buf . +.pp +the +.i buf +array is used to store the string fields pointed to by the returned +.i servent +structure. +(the nonreentrant functions allocate these strings in static storage.) +the size of this array is specified in +.ir buflen . +if +.i buf +is too small, the call fails with the error +.br erange , +and the caller must try again with a larger buffer. +(a buffer of length 1024 bytes should be sufficient for most applications.) +.\" i can find no information on the required/recommended buffer size; +.\" the nonreentrant functions use a 1024 byte buffer -- mtk. +.pp +if the function call successfully obtains a service record, then +.i *result +is set pointing to +.ir result_buf ; +otherwise, +.i *result +is set to null. +.sh return value +on success, these functions return 0. +on error, they return one of the positive error numbers listed in errors. +.pp +on error, record not found +.rb ( getservbyname_r (), +.br getservbyport_r ()), +or end of input +.rb ( getservent_r ()) +.i result +is set to null. +.sh errors +.tp +.b enoent +.rb ( getservent_r ()) +no more records in database. +.tp +.b erange +.i buf +is too small. +try again with a larger buffer +(and increased +.ir buflen ). +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br getservent_r (), +.br getservbyname_r (), +.br getservbyport_r () +t} thread safety mt-safe locale +.te +.hy +.ad +.sp 1 +.sh conforming to +these functions are gnu extensions. +functions with similar names exist on some other systems, +though typically with different calling signatures. +.sh examples +the program below uses +.br getservbyport_r () +to retrieve the service record for the port and protocol named +in its first command-line argument. +if a third (integer) command-line argument is supplied, +it is used as the initial value for +.ir buflen ; +if +.br getservbyport_r () +fails with the error +.br erange , +the program retries with larger buffer sizes. +the following shell session shows a couple of sample runs: +.pp +.in +4n +.ex +.rb "$" " ./a.out 7 tcp 1" +erange! retrying with larger buffer +getservbyport_r() returned: 0 (success) (buflen=87) +s_name=echo; s_proto=tcp; s_port=7; aliases= +.rb "$" " ./a.out 77777 tcp" +getservbyport_r() returned: 0 (success) (buflen=1024) +call failed/record not found +.ee +.in +.ss program source +\& +.ex +#define _gnu_source +#include +#include +#include +#include +#include +#include + +#define max_buf 10000 + +int +main(int argc, char *argv[]) +{ + int buflen, erange_cnt, port, s; + struct servent result_buf; + struct servent *result; + char buf[max_buf]; + char *protop; + + if (argc < 3) { + printf("usage: %s port\-num proto\-name [buflen]\en", argv[0]); + exit(exit_failure); + } + + port = htons(atoi(argv[1])); + protop = (strcmp(argv[2], "null") == 0 || + strcmp(argv[2], "null") == 0) ? null : argv[2]; + + buflen = 1024; + if (argc > 3) + buflen = atoi(argv[3]); + + if (buflen > max_buf) { + printf("exceeded buffer limit (%d)\en", max_buf); + exit(exit_failure); + } + + erange_cnt = 0; + do { + s = getservbyport_r(port, protop, &result_buf, + buf, buflen, &result); + if (s == erange) { + if (erange_cnt == 0) + printf("erange! retrying with larger buffer\en"); + erange_cnt++; + + /* increment a byte at a time so we can see exactly + what size buffer was required. */ + + buflen++; + + if (buflen > max_buf) { + printf("exceeded buffer limit (%d)\en", max_buf); + exit(exit_failure); + } + } + } while (s == erange); + + printf("getservbyport_r() returned: %s (buflen=%d)\en", + (s == 0) ? "0 (success)" : (s == enoent) ? "enoent" : + strerror(s), buflen); + + if (s != 0 || result == null) { + printf("call failed/record not found\en"); + exit(exit_failure); + } + + printf("s_name=%s; s_proto=%s; s_port=%d; aliases=", + result_buf.s_name, result_buf.s_proto, + ntohs(result_buf.s_port)); + for (char **p = result_buf.s_aliases; *p != null; p++) + printf("%s ", *p); + printf("\en"); + + exit(exit_success); +} +.ee +.sh see also +.br getservent (3), +.br services (5) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" iso/iec 9899:1999 +.\" +.th wcstok 3 2021-08-27 "gnu" "linux programmer's manual" +.sh name +wcstok \- split wide-character string into tokens +.sh synopsis +.nf +.b #include +.pp +.bi "wchar_t *wcstok(wchar_t *restrict " wcs \ +", const wchar_t *restrict " delim , +.bi " wchar_t **restrict " ptr ); +.fi +.sh description +the +.br wcstok () +function is the wide-character equivalent of the +.br strtok (3) +function, +with an added argument to make it multithread-safe. +it can be used +to split a wide-character string +.i wcs +into tokens, where a token is +defined as a substring not containing any wide-characters from +.ir delim . +.pp +the search starts at +.ir wcs , +if +.i wcs +is not null, +or at +.ir *ptr , +if +.i wcs +is null. +first, any delimiter wide-characters are skipped, that is, the +pointer is advanced beyond any wide-characters which occur in +.ir delim . +if the end of the wide-character string is now +reached, +.br wcstok () +returns null, to indicate that no tokens +were found, and stores an appropriate value in +.ir *ptr , +so that subsequent calls to +.br wcstok () +will continue to return null. +otherwise, the +.br wcstok () +function recognizes the beginning of a token +and returns a pointer to it, but before doing that, it zero-terminates the +token by replacing the next wide-character which occurs in +.i delim +with +a null wide character (l\(aq\e0\(aq), +and it updates +.i *ptr +so that subsequent calls will +continue searching after the end of recognized token. +.sh return value +the +.br wcstok () +function returns a pointer to the next token, +or null if no further token was found. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br wcstok () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh notes +the original +.i wcs +wide-character string is destructively modified during +the operation. +.sh examples +the following code loops over the tokens contained in a wide-character string. +.pp +.ex +wchar_t *wcs = ...; +wchar_t *token; +wchar_t *state; +for (token = wcstok(wcs, l" \et\en", &state); + token != null; + token = wcstok(null, l" \et\en", &state)) { + ... +} +.ee +.sh see also +.br strtok (3), +.br wcschr (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/sigsetops.3 + +.so man3/mq_getattr.3 + +.so man3/pthread_attr_setstack.3 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" and copyright (c) 2004, 2007 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sat jul 24 18:20:58 1993 by rik faith (faith@cs.unc.edu) +.\" modified fri feb 14 21:47:50 1997 by andries brouwer (aeb@cwi.nl) +.\" modified 9 jun 2004, michael kerrisk +.\" changed unsetenv() prototype; added einval error +.\" noted nonstandard behavior of setenv() if name contains '=' +.\" 2005-08-12, mtk, glibc 2.3.4 fixed the "name contains '='" bug +.\" +.th setenv 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +setenv \- change or add an environment variable +.sh synopsis +.nf +.b #include +.pp +.bi "int setenv(const char *" name ", const char *" value ", int " overwrite ); +.bi "int unsetenv(const char *" name ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br setenv (), +.br unsetenv (): +.nf + _posix_c_source >= 200112l + || /* glibc <= 2.19: */ _bsd_source +.fi +.sh description +the +.br setenv () +function adds the variable +.i name +to the +environment with the value +.ir value , +if +.i name +does not +already exist. +if +.i name +does exist in the environment, then +its value is changed to +.ir value +if +.i overwrite +is nonzero; +if +.ir overwrite +is zero, then the value of +.i name +is not changed (and +.br setenv () +returns a success status). +this function makes copies of the strings pointed to by +.i name +and +.i value +(by contrast with +.br putenv (3)). +.pp +the +.br unsetenv () +function deletes the variable +.i name +from +the environment. +if +.i name +does not exist in the environment, +then the function succeeds, and the environment is unchanged. +.sh return value +.br setenv () +and +.br unsetenv () +functions return zero on success, +or \-1 on error, with +.i errno +set to indicate the error. +.sh errors +.tp +.b einval +.i name +is null, points to a string of length 0, +or contains an \(aq=\(aq character. +.tp +.b enomem +insufficient memory to add a new variable to the environment. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br setenv (), +.br unsetenv () +t} thread safety mt-unsafe const:env +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, 4.3bsd. +.sh notes +posix.1 does not require +.br setenv () +or +.br unsetenv () +to be reentrant. +.pp +prior to glibc 2.2.2, +.br unsetenv () +was prototyped +as returning +.ir void ; +more recent glibc versions follow the +posix.1-compliant prototype shown in the synopsis. +.sh bugs +posix.1 specifies that if +.i name +contains an \(aq=\(aq character, then +.br setenv () +should fail with the error +.br einval ; +however, versions of glibc before 2.3.4 allowed an \(aq=\(aq sign in +.ir name . +.sh see also +.br clearenv (3), +.br getenv (3), +.br putenv (3), +.br environ (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" this manpage is copyright (c) 1992 drew eckhardt; +.\" and copyright (c) 1993 michael haardt, ian jackson. +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified 1993-07-24 by rik faith +.\" modified 1997-01-31 by eric s. raymond +.\" modified 2004-06-23 by michael kerrisk +.\" +.th rmdir 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +rmdir \- delete a directory +.sh synopsis +.nf +.b #include +.pp +.bi "int rmdir(const char *" pathname ); +.fi +.sh description +.br rmdir () +deletes a directory, which must be empty. +.sh return value +on success, zero is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eacces +write access to the directory containing +.i pathname +was not allowed, or one of the directories in the path prefix of +.i pathname +did not allow search permission. +(see also +.br path_resolution (7).) +.tp +.b ebusy +.i pathname +is currently in use by the system or some process that prevents its +removal. +on linux, this means +.i pathname +is currently used as a mount point +or is the root directory of the calling process. +.tp +.b efault +.ir pathname " points outside your accessible address space." +.tp +.b einval +.i pathname +has +.i . +as last component. +.tp +.b eloop +too many symbolic links were encountered in resolving +.ir pathname . +.tp +.b enametoolong +.ir pathname " was too long." +.tp +.b enoent +a directory component in +.i pathname +does not exist or is a dangling symbolic link. +.tp +.b enomem +insufficient kernel memory was available. +.tp +.b enotdir +.ir pathname , +or a component used as a directory in +.ir pathname , +is not, in fact, a directory. +.tp +.b enotempty +.i pathname +contains entries other than +.ir . " and " .. " ;" +or, +.i pathname +has +.i .. +as its final component. +posix.1 also allows +.\" posix.1-2001, posix.1-2008 +.b eexist +for this condition. +.tp +.b eperm +the directory containing +.i pathname +has the sticky bit +.rb ( s_isvtx ) +set and the process's effective user id is neither the user id +of the file to be deleted nor that of the directory containing it, +and the process is not privileged (linux: does not have the +.b cap_fowner +capability). +.tp +.b eperm +the filesystem containing +.i pathname +does not support the removal of directories. +.tp +.b erofs +.i pathname +refers to a directory on a read-only filesystem. +.sh conforming to +posix.1-2001, posix.1-2008, svr4, 4.3bsd. +.sh bugs +infelicities in the protocol underlying nfs can cause the unexpected +disappearance of directories which are still being used. +.sh see also +.br rm (1), +.br rmdir (1), +.br chdir (2), +.br chmod (2), +.br mkdir (2), +.br rename (2), +.br unlink (2), +.br unlinkat (2) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/rand.3 + +.\" this man page is copyright (c) 1999 andi kleen . +.\" +.\" %%%license_start(verbatim_one_para) +.\" permission is granted to distribute possibly modified copies +.\" of this page provided the header is included verbatim, +.\" and in case of nontrivial modification author and date +.\" of the modification is added to the header. +.\" %%%license_end +.\" +.\" $id: raw.7,v 1.6 1999/06/05 10:32:08 freitag exp $ +.\" +.th raw 7 2021-03-22 "linux" "linux programmer's manual" +.sh name +raw \- linux ipv4 raw sockets +.sh synopsis +.nf +.b #include +.b #include +.bi "raw_socket = socket(af_inet, sock_raw, int " protocol ); +.fi +.sh description +raw sockets allow new ipv4 protocols to be implemented in user space. +a raw socket receives or sends the raw datagram not +including link level headers. +.pp +the ipv4 layer generates an ip header when sending a packet unless the +.b ip_hdrincl +socket option is enabled on the socket. +when it is enabled, the packet must contain an ip header. +for receiving, the ip header is always included in the packet. +.pp +in order to create a raw socket, a process must have the +.b cap_net_raw +capability in the user namespace that governs its network namespace. +.pp +all packets or errors matching the +.i protocol +number specified +for the raw socket are passed to this socket. +for a list of the allowed protocols, +see the iana list of assigned protocol numbers at +.ur http://www.iana.org/assignments/protocol\-numbers/ +.ue +and +.br getprotobyname (3). +.pp +a protocol of +.b ipproto_raw +implies enabled +.b ip_hdrincl +and is able to send any ip protocol that is specified in the passed +header. +receiving of all ip protocols via +.b ipproto_raw +is not possible using raw sockets. +.rs +.ts +tab(:) allbox; +c s +l l. +ip header fields modified on sending by \fbip_hdrincl\fp +ip checksum:always filled in +source address:filled in when zero +packet id:filled in when zero +total length:always filled in +.te +.re +.pp +.pp +if +.b ip_hdrincl +is specified and the ip header has a nonzero destination address, then +the destination address of the socket is used to route the packet. +when +.b msg_dontroute +is specified, the destination address should refer to a local interface, +otherwise a routing table lookup is done anyway but gatewayed routes +are ignored. +.pp +if +.b ip_hdrincl +isn't set, then ip header options can be set on raw sockets with +.br setsockopt (2); +see +.br ip (7) +for more information. +.pp +starting with linux 2.2, all ip header fields and options can be set using +ip socket options. +this means raw sockets are usually needed only for new +protocols or protocols with no user interface (like icmp). +.pp +when a packet is received, it is passed to any raw sockets which have +been bound to its protocol before it is passed to other protocol handlers +(e.g., kernel protocol modules). +.ss address format +for sending and receiving datagrams +.rb ( sendto (2), +.br recvfrom (2), +and similar), +raw sockets use the standard +.i sockaddr_in +address structure defined in +.br ip (7). +the +.i sin_port +field could be used to specify the ip protocol number, +but it is ignored for sending in linux 2.2 and later, and should be always +set to 0 (see bugs). +for incoming packets, +.i sin_port +.\" commit f59fc7f30b710d45aadf715460b3e60dbe9d3418 +is set to zero. +.ss socket options +raw socket options can be set with +.br setsockopt (2) +and read with +.br getsockopt (2) +by passing the +.b ipproto_raw +.\" or sol_raw on linux +family flag. +.tp +.b icmp_filter +enable a special filter for raw sockets bound to the +.b ipproto_icmp +protocol. +the value has a bit set for each icmp message type which +should be filtered out. +the default is to filter no icmp messages. +.pp +in addition, all +.br ip (7) +.b ipproto_ip +socket options valid for datagram sockets are supported. +.ss error handling +errors originating from the network are passed to the user only when the +socket is connected or the +.b ip_recverr +flag is enabled. +for connected sockets, only +.b emsgsize +and +.b eproto +are passed for compatibility. +with +.br ip_recverr , +all network errors are saved in the error queue. +.sh errors +.tp +.b eacces +user tried to send to a broadcast address without having the +broadcast flag set on the socket. +.tp +.b efault +an invalid memory address was supplied. +.tp +.b einval +invalid argument. +.tp +.b emsgsize +packet too big. +either path mtu discovery is enabled (the +.b ip_mtu_discover +socket flag) or the packet size exceeds the maximum allowed ipv4 +packet size of 64\ kb. +.tp +.b eopnotsupp +invalid flag has been passed to a socket call (like +.br msg_oob ). +.tp +.b eperm +the user doesn't have permission to open raw sockets. +only processes with an effective user id of 0 or the +.b cap_net_raw +attribute may do that. +.tp +.b eproto +an icmp error has arrived reporting a parameter problem. +.sh versions +.b ip_recverr +and +.b icmp_filter +are new in linux 2.2. +they are linux extensions and should not be used in portable programs. +.pp +linux 2.0 enabled some bug-to-bug compatibility with bsd in the +raw socket code when the +.b so_bsdcompat +socket option was set; since linux 2.2, +this option no longer has that effect. +.sh notes +by default, raw sockets do path mtu (maximum transmission unit) discovery. +this means the kernel +will keep track of the mtu to a specific target ip address and return +.b emsgsize +when a raw packet write exceeds it. +when this happens, the application should decrease the packet size. +path mtu discovery can be also turned off using the +.b ip_mtu_discover +socket option or the +.i /proc/sys/net/ipv4/ip_no_pmtu_disc +file, see +.br ip (7) +for details. +when turned off, raw sockets will fragment outgoing packets +that exceed the interface mtu. +however, disabling it is not recommended +for performance and reliability reasons. +.pp +a raw socket can be bound to a specific local address using the +.br bind (2) +call. +if it isn't bound, all packets with the specified ip protocol are received. +in addition, a raw socket can be bound to a specific network device using +.br so_bindtodevice ; +see +.br socket (7). +.pp +an +.b ipproto_raw +socket is send only. +if you really want to receive all ip packets, use a +.br packet (7) +socket with the +.b eth_p_ip +protocol. +note that packet sockets don't reassemble ip fragments, +unlike raw sockets. +.pp +if you want to receive all icmp packets for a datagram socket, +it is often better to use +.b ip_recverr +on that particular socket; see +.br ip (7). +.pp +raw sockets may tap all ip protocols in linux, even +protocols like icmp or tcp which have a protocol module in the kernel. +in this case, the packets are passed to both the kernel module and the raw +socket(s). +this should not be relied upon in portable programs, many other bsd +socket implementation have limitations here. +.pp +linux never changes headers passed from the user (except for filling +in some zeroed fields as described for +.br ip_hdrincl ). +this differs from many other implementations of raw sockets. +.pp +raw sockets are generally rather unportable and should be avoided in +programs intended to be portable. +.pp +sending on raw sockets should take the ip protocol from +.ir sin_port ; +this ability was lost in linux 2.2. +the workaround is to use +.br ip_hdrincl . +.sh bugs +transparent proxy extensions are not described. +.pp +when the +.b ip_hdrincl +option is set, datagrams will not be fragmented and are limited to +the interface mtu. +.pp +setting the ip protocol for sending in +.i sin_port +got lost in linux 2.2. +the protocol that the socket was bound to or that +was specified in the initial +.br socket (2) +call is always used. +.\" .sh authors +.\" this man page was written by andi kleen. +.sh see also +.br recvmsg (2), +.br sendmsg (2), +.br capabilities (7), +.br ip (7), +.br socket (7) +.pp +.b rfc\ 1191 +for path mtu discovery. +.b rfc\ 791 +and the +.i +header file for the ip protocol. +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" +.th wmemcmp 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +wmemcmp \- compare two arrays of wide-characters +.sh synopsis +.nf +.b #include +.pp +.bi "int wmemcmp(const wchar_t *" s1 ", const wchar_t *" s2 ", size_t " n ); +.fi +.sh description +the +.br wmemcmp () +function is the wide-character equivalent of the +.br memcmp (3) +function. +it compares the +.ir n +wide-characters starting at +.i s1 +and the +.i n +wide-characters starting at +.ir s2 . +.sh return value +the +.br wmemcmp () +function returns +zero if the wide-character arrays of size +.i n +at +.ir s1 +and +.i s2 +are equal. +it returns an integer greater than +zero if at the first differing position +.i i +.ri ( i " <" +.ir n ), +the +corresponding wide-character +.i s1[i] +is greater than +.ir s2[i] . +it returns an integer less than zero if +at the first differing position +.i i +.ri ( i +< +.ir n ), +the corresponding +wide-character +.i s1[i] +is less than +.ir s2[i] . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br wmemcmp () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh see also +.br memcmp (3), +.br wcscmp (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/isalpha.3 + +.so man3/fmod.3 + +.so man3/printf.3 + +.\" copyright (c) 1993 luigi p. bai (lpb@softint.com) july 28, 1993 +.\" and copyright 1993 giorgio ciucci +.\" and copyright 2004, 2005 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified 1993-07-28, rik faith +.\" modified 1993-11-28, giorgio ciucci +.\" modified 1997-01-31, eric s. raymond +.\" modified 2001-02-18, andries brouwer +.\" modified 2002-01-05, 2004-05-27, 2004-06-17, +.\" michael kerrisk +.\" modified 2004-10-11, aeb +.\" modified, nov 2004, michael kerrisk +.\" language and formatting clean-ups +.\" updated shmid_ds structure definitions +.\" added information on shm_dest and shm_locked flags +.\" noted that cap_ipc_lock is not required for shm_unlock +.\" since kernel 2.6.9 +.\" modified, 2004-11-25, mtk, notes on 2.6.9 rlimit_memlock changes +.\" 2005-04-25, mtk -- noted aberrant linux behavior w.r.t. new +.\" attaches to a segment that has already been marked for deletion. +.\" 2005-08-02, mtk: added ipc_info, shm_info, shm_stat descriptions. +.\" 2018-03-20, dbueso: added shm_stat_any description. +.\" +.th shmctl 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +shmctl \- system v shared memory control +.sh synopsis +.nf +.ad l +.b #include +.pp +.bi "int shmctl(int " shmid ", int " cmd ", struct shmid_ds *" buf ); +.ad b +.fi +.sh description +.br shmctl () +performs the control operation specified by +.i cmd +on the system\ v shared memory segment whose identifier is given in +.ir shmid . +.pp +the +.i buf +argument is a pointer to a \fishmid_ds\fp structure, +defined in \fi\fp as follows: +.pp +.in +4n +.ex +struct shmid_ds { + struct ipc_perm shm_perm; /* ownership and permissions */ + size_t shm_segsz; /* size of segment (bytes) */ + time_t shm_atime; /* last attach time */ + time_t shm_dtime; /* last detach time */ + time_t shm_ctime; /* creation time/time of last + modification via shmctl() */ + pid_t shm_cpid; /* pid of creator */ + pid_t shm_lpid; /* pid of last shmat(2)/shmdt(2) */ + shmatt_t shm_nattch; /* no. of current attaches */ + ... +}; +.ee +.in +.pp +the fields of the +.i shmid_ds +structure are as follows: +.tp 12 +.i shm_perm +this is an +.i ipc_perm +structure (see below) that specifies the access permissions +on the shared memory segment. +.tp +.i shm_segsz +size in bytes of the shared memory segment. +.tp +.i shm_atime +time of the last +.br shmat (2) +system call that attached this segment. +.tp +.i shm_dtime +time of the last +.br shmdt (2) +system call that detached tgis segment. +.tp +.i shm_ctime +time of creation of segment or time of the last +.br shmctl () +.br ipc_set +operation. +.tp +.i shm_cpid +id of the process that created the shared memory segment. +.tp +.i shm_lpid +id of the last process that executed a +.br shmat (2) +or +.br shmdt (2) +system call on this segment. +.tp +.i shm_nattch +number of processes that have this segment attached. +.pp +the +.i ipc_perm +structure is defined as follows +(the highlighted fields are settable using +.br ipc_set ): +.pp +.in +4n +.ex +struct ipc_perm { + key_t __key; /* key supplied to shmget(2) */ + uid_t \fbuid\fp; /* effective uid of owner */ + gid_t \fbgid\fp; /* effective gid of owner */ + uid_t cuid; /* effective uid of creator */ + gid_t cgid; /* effective gid of creator */ + unsigned short \fbmode\fp; /* \fbpermissions\fp + shm_dest and + shm_locked flags */ + unsigned short __seq; /* sequence number */ +}; +.ee +.in +.pp +the least significant 9 bits of the +.i mode +field of the +.i ipc_perm +structure define the access permissions for the shared memory segment. +the permission bits are as follows: +.ts +l l. +0400 read by user +0200 write by user +0040 read by group +0020 write by group +0004 read by others +0002 write by others +.te +.pp +bits 0100, 0010, and 0001 (the execute bits) are unused by the system. +(it is not necessary to have execute permission on a segment +in order to perform a +.br shmat (2) +call with the +.b shm_exec +flag.) +.pp +valid values for +.i cmd +are: +.tp +.b ipc_stat +copy information from the kernel data structure associated with +.i shmid +into the +.i shmid_ds +structure pointed to by \fibuf\fp. +the caller must have read permission on the +shared memory segment. +.tp +.b ipc_set +write the values of some members of the +.i shmid_ds +structure pointed to by +.i buf +to the kernel data structure associated with this shared memory segment, +updating also its +.i shm_ctime +member. +.ip +the following fields are updated: +\fishm_perm.uid\fp, \fishm_perm.gid\fp, +and (the least significant 9 bits of) \fishm_perm.mode\fp. +.ip +the effective uid of the calling process must match the owner +.ri ( shm_perm.uid ) +or creator +.ri ( shm_perm.cuid ) +of the shared memory segment, or the caller must be privileged. +.tp +.b ipc_rmid +mark the segment to be destroyed. +the segment will actually be destroyed +only after the last process detaches it (i.e., when the +.i shm_nattch +member of the associated structure +.i shmid_ds +is zero). +the caller must be the owner or creator of the segment, or be privileged. +the +.i buf +argument is ignored. +.ip +if a segment has been marked for destruction, then the (nonstandard) +.b shm_dest +flag of the +.i shm_perm.mode +field in the associated data structure retrieved by +.b ipc_stat +will be set. +.ip +the caller \fimust\fp ensure that a segment is eventually destroyed; +otherwise its pages that were faulted in will remain in memory or swap. +.ip +see also the description of +.i /proc/sys/kernel/shm_rmid_forced +in +.br proc (5). +.tp +.br ipc_info " (linux-specific)" +return information about system-wide shared memory limits and +parameters in the structure pointed to by +.ir buf . +this structure is of type +.i shminfo +(thus, a cast is required), +defined in +.i +if the +.b _gnu_source +feature test macro is defined: +.ip +.in +4n +.ex +struct shminfo { + unsigned long shmmax; /* maximum segment size */ + unsigned long shmmin; /* minimum segment size; + always 1 */ + unsigned long shmmni; /* maximum number of segments */ + unsigned long shmseg; /* maximum number of segments + that a process can attach; + unused within kernel */ + unsigned long shmall; /* maximum number of pages of + shared memory, system\-wide */ +}; +.ee +.in +.ip +the +.ir shmmni , +.ir shmmax , +and +.i shmall +settings can be changed via +.i /proc +files of the same name; see +.br proc (5) +for details. +.tp +.br shm_info " (linux-specific)" +return a +.i shm_info +structure whose fields contain information +about system resources consumed by shared memory. +this structure is defined in +.i +if the +.b _gnu_source +feature test macro is defined: +.ip +.in +4n +.ex +struct shm_info { + int used_ids; /* # of currently existing + segments */ + unsigned long shm_tot; /* total number of shared + memory pages */ + unsigned long shm_rss; /* # of resident shared + memory pages */ + unsigned long shm_swp; /* # of swapped shared + memory pages */ + unsigned long swap_attempts; + /* unused since linux 2.4 */ + unsigned long swap_successes; + /* unused since linux 2.4 */ +}; +.ee +.in +.tp +.br shm_stat " (linux-specific)" +return a +.i shmid_ds +structure as for +.br ipc_stat . +however, the +.i shmid +argument is not a segment identifier, but instead an index into +the kernel's internal array that maintains information about +all shared memory segments on the system. +.tp +.br shm_stat_any " (linux-specific, since linux 4.17)" +return a +.i shmid_ds +structure as for +.br shm_stat . +however, +.i shm_perm.mode +is not checked for read access for +.ir shmid , +meaning that any user can employ this operation (just as any user may read +.ir /proc/sysvipc/shm +to obtain the same information). +.pp +the caller can prevent or allow swapping of a shared +memory segment with the following \ficmd\fp values: +.tp +.br shm_lock " (linux-specific)" +prevent swapping of the shared memory segment. +the caller must fault in +any pages that are required to be present after locking is enabled. +if a segment has been locked, then the (nonstandard) +.b shm_locked +flag of the +.i shm_perm.mode +field in the associated data structure retrieved by +.b ipc_stat +will be set. +.tp +.br shm_unlock " (linux-specific)" +unlock the segment, allowing it to be swapped out. +.pp +in kernels before 2.6.10, only a privileged process +could employ +.b shm_lock +and +.br shm_unlock . +since kernel 2.6.10, an unprivileged process can employ these operations +if its effective uid matches the owner or creator uid of the segment, and +(for +.br shm_lock ) +the amount of memory to be locked falls within the +.b rlimit_memlock +resource limit (see +.br setrlimit (2)). +.\" there was some weirdness in 2.6.9: shm_lock and shm_unlock could +.\" be applied to a segment, regardless of ownership of the segment. +.\" this was a botch-up in the move to rlimit_memlock, and was fixed +.\" in 2.6.10. mtk, may 2005 +.sh return value +a successful +.b ipc_info +or +.b shm_info +operation returns the index of the highest used entry in the +kernel's internal array recording information about all +shared memory segments. +(this information can be used with repeated +.b shm_stat +or +.b shm_stat_any +operations to obtain information about all shared memory segments +on the system.) +a successful +.b shm_stat +operation returns the identifier of the shared memory segment +whose index was given in +.ir shmid . +other operations return 0 on success. +.pp +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eacces +\fbipc_stat\fp or \fbshm_stat\fp is requested and +\fishm_perm.mode\fp does not allow read access for +.ir shmid , +and the calling process does not have the +.b cap_ipc_owner +capability in the user namespace that governs its ipc namespace. +.tp +.b efault +the argument +.i cmd +has value +.b ipc_set +or +.b ipc_stat +but the address pointed to by +.i buf +isn't accessible. +.tp +.b eidrm +\fishmid\fp points to a removed identifier. +.tp +.b einval +\fishmid\fp is not a valid identifier, or \ficmd\fp +is not a valid command. +or: for a +.b shm_stat +or +.b shm_stat_any +operation, the index value specified in +.i shmid +referred to an array slot that is currently unused. +.tp +.b enomem +(in kernels since 2.6.9), +.b shm_lock +was specified and the size of the to-be-locked segment would mean +that the total bytes in locked shared memory segments would exceed +the limit for the real user id of the calling process. +this limit is defined by the +.b rlimit_memlock +soft resource limit (see +.br setrlimit (2)). +.tp +.b eoverflow +\fbipc_stat\fp is attempted, and the gid or uid value +is too large to be stored in the structure pointed to by +.ir buf . +.tp +.b eperm +\fbipc_set\fp or \fbipc_rmid\fp is attempted, and the +effective user id of the calling process is not that of the creator +(found in +.ir shm_perm.cuid ), +or the owner +(found in +.ir shm_perm.uid ), +and the process was not privileged (linux: did not have the +.b cap_sys_admin +capability). +.ip +or (in kernels before 2.6.9), +.b shm_lock +or +.b shm_unlock +was specified, but the process was not privileged +(linux: did not have the +.b cap_ipc_lock +capability). +(since linux 2.6.9, this error can also occur if the +.b rlimit_memlock +is 0 and the caller is not privileged.) +.sh conforming to +posix.1-2001, posix.1-2008, svr4. +.\" svr4 documents additional error conditions einval, +.\" enoent, enospc, enomem, eexist. neither svr4 nor svid documents +.\" an eidrm error condition. +.sh notes +the +.br ipc_info , +.br shm_stat , +and +.b shm_info +operations are used by the +.br ipcs (1) +program to provide information on allocated resources. +in the future, these may modified or moved to a +.i /proc +filesystem interface. +.pp +linux permits a process to attach +.rb ( shmat (2)) +a shared memory segment that has already been marked for deletion +using +.ir shmctl(ipc_rmid) . +this feature is not available on other unix implementations; +portable applications should avoid relying on it. +.pp +various fields in a \fistruct shmid_ds\fp were typed as +.i short +under linux 2.2 +and have become +.i long +under linux 2.4. +to take advantage of this, +a recompilation under glibc-2.1.91 or later should suffice. +(the kernel distinguishes old and new calls by an +.b ipc_64 +flag in +.ir cmd .) +.sh see also +.br mlock (2), +.br setrlimit (2), +.br shmget (2), +.br shmop (2), +.br capabilities (7), +.br sysvipc (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2009 linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th timer_create 2 2021-03-22 linux "linux programmer's manual" +.sh name +timer_create \- create a posix per-process timer +.sh synopsis +.nf +.br "#include " " /* definition of " sigev_* " constants */" +.b #include +.pp +.bi "int timer_create(clockid_t " clockid ", struct sigevent *restrict " sevp , +.bi " timer_t *restrict " timerid ); +.fi +.pp +link with \fi\-lrt\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br timer_create (): +.nf + _posix_c_source >= 199309l +.fi +.sh description +.br timer_create () +creates a new per-process interval timer. +the id of the new timer is returned in the buffer pointed to by +.ir timerid , +which must be a non-null pointer. +this id is unique within the process, until the timer is deleted. +the new timer is initially disarmed. +.pp +the +.i clockid +argument specifies the clock that the new timer uses to measure time. +it can be specified as one of the following values: +.tp +.b clock_realtime +a settable system-wide real-time clock. +.tp +.b clock_monotonic +a nonsettable monotonically increasing clock that measures time +from some unspecified point in the past that does not change +after system startup. +.\" note: the clock_monotonic_raw clock added for clock_gettime() +.\" in 2.6.28 is not supported for posix timers -- mtk, feb 2009 +.tp +.br clock_process_cputime_id " (since linux 2.6.12)" +a clock that measures (user and system) cpu time consumed by +(all of the threads in) the calling process. +.tp +.br clock_thread_cputime_id " (since linux 2.6.12)" +a clock that measures (user and system) cpu time consumed by +the calling thread. +.\" the clock_monotonic_raw that was added in 2.6.28 can't be used +.\" to create a timer -- mtk, feb 2009 +.tp +.br clock_boottime " (since linux 2.6.39)" +.\" commit 70a08cca1227dc31c784ec930099a4417a06e7d0 +like +.br clock_monotonic , +this is a monotonically increasing clock. +however, whereas the +.br clock_monotonic +clock does not measure the time while a system is suspended, the +.br clock_boottime +clock does include the time during which the system is suspended. +this is useful for applications that need to be suspend-aware. +.br clock_realtime +is not suitable for such applications, since that clock is affected +by discontinuous changes to the system clock. +.tp +.br clock_realtime_alarm " (since linux 3.0)" +.\" commit 9a7adcf5c6dea63d2e47e6f6d2f7a6c9f48b9337 +this clock is like +.br clock_realtime , +but will wake the system if it is suspended. +the caller must have the +.b cap_wake_alarm +capability in order to set a timer against this clock. +.tp +.br clock_boottime_alarm " (since linux 3.0)" +.\" commit 9a7adcf5c6dea63d2e47e6f6d2f7a6c9f48b9337 +this clock is like +.br clock_boottime , +but will wake the system if it is suspended. +the caller must have the +.b cap_wake_alarm +capability in order to set a timer against this clock. +.tp +.br clock_tai " (since linux 3.10)" +a system-wide clock derived from wall-clock time but ignoring leap seconds. +.pp +see +.br clock_getres (2) +for some further details on the above clocks. +.pp +as well as the above values, +.i clockid +can be specified as the +.i clockid +returned by a call to +.br clock_getcpuclockid (3) +or +.br pthread_getcpuclockid (3). +.pp +the +.i sevp +argument points to a +.i sigevent +structure that specifies how the caller +should be notified when the timer expires. +for the definition and general details of this structure, see +.br sigevent (7). +.pp +the +.i sevp.sigev_notify +field can have the following values: +.tp +.br sigev_none +don't asynchronously notify when the timer expires. +progress of the timer can be monitored using +.br timer_gettime (2). +.tp +.br sigev_signal +upon timer expiration, generate the signal +.i sigev_signo +for the process. +see +.br sigevent (7) +for general details. +the +.i si_code +field of the +.i siginfo_t +structure will be set to +.br si_timer . +at any point in time, +at most one signal is queued to the process for a given timer; see +.br timer_getoverrun (2) +for more details. +.tp +.br sigev_thread +upon timer expiration, invoke +.i sigev_notify_function +as if it were the start function of a new thread. +see +.br sigevent (7) +for details. +.tp +.br sigev_thread_id " (linux-specific)" +as for +.br sigev_signal , +but the signal is targeted at the thread whose id is given in +.ir sigev_notify_thread_id , +which must be a thread in the same process as the caller. +the +.ir sigev_notify_thread_id +field specifies a kernel thread id, that is, the value returned by +.br clone (2) +or +.br gettid (2). +this flag is intended only for use by threading libraries. +.pp +specifying +.i sevp +as null is equivalent to specifying a pointer to a +.i sigevent +structure in which +.i sigev_notify +is +.br sigev_signal , +.i sigev_signo +is +.br sigalrm , +and +.i sigev_value.sival_int +is the timer id. +.sh return value +on success, +.br timer_create () +returns 0, and the id of the new timer is placed in +.ir *timerid . +on failure, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eagain +temporary error during kernel allocation of timer structures. +.tp +.b einval +clock id, +.ir sigev_notify , +.ir sigev_signo , +or +.ir sigev_notify_thread_id +is invalid. +.tp +.b enomem +.\" glibc layer: malloc() +could not allocate memory. +.tp +.b enotsup +the kernel does not support creating a timer against this +.ir clockid . +.tp +.b eperm +.i clockid +was +.br clock_realtime_alarm +or +.br clock_boottime_alarm +but the caller did not have the +.br cap_wake_alarm +capability. +.sh versions +this system call is available since linux 2.6. +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +a program may create multiple interval timers using +.br timer_create (). +.pp +timers are not inherited by the child of a +.br fork (2), +and are disarmed and deleted during an +.br execve (2). +.pp +the kernel preallocates a "queued real-time signal" +for each timer created using +.br timer_create (). +consequently, the number of timers is limited by the +.br rlimit_sigpending +resource limit (see +.br setrlimit (2)). +.pp +the timers created by +.br timer_create () +are commonly known as "posix (interval) timers". +the posix timers api consists of the following interfaces: +.ip * 3 +.br timer_create (): +create a timer. +.ip * +.br timer_settime (2): +arm (start) or disarm (stop) a timer. +.ip * +.br timer_gettime (2): +fetch the time remaining until the next expiration of a timer, +along with the interval setting of the timer. +.ip * +.br timer_getoverrun (2): +return the overrun count for the last timer expiration. +.ip * +.br timer_delete (2): +disarm and delete a timer. +.pp +since linux 3.10, the +.ir /proc/[pid]/timers +file can be used to list the posix timers for the process with pid +.ir pid . +see +.br proc (5) +for further information. +.pp +since linux 4.10, +.\" baa73d9e478ff32d62f3f9422822b59dd9a95a21 +support for posix timers is a configurable option that is enabled by default. +kernel support can be disabled via the +.br config_posix_timers +option. +.\" +.ss c library/kernel differences +part of the implementation of the posix timers api is provided by glibc. +.\" see nptl/sysdeps/unix/sysv/linux/timer_create.c +in particular: +.ip * 3 +much of the functionality for +.br sigev_thread +is implemented within glibc, rather than the kernel. +(this is necessarily so, +since the thread involved in handling the notification is one +that must be managed by the c library posix threads implementation.) +although the notification delivered to the process is via a thread, +internally the nptl implementation uses a +.i sigev_notify +value of +.br sigev_thread_id +along with a real-time signal that is reserved by the implementation (see +.br nptl (7)). +.ip * +the implementation of the default case where +.i evp +is null is handled inside glibc, +which invokes the underlying system call with a suitably populated +.i sigevent +structure. +.ip * +the timer ids presented at user level are maintained by glibc, +which maps these ids to the timer ids employed by the kernel. +.\" see the glibc source file kernel-posix-timers.h for the structure +.\" that glibc uses to map user-space timer ids to kernel timer ids +.\" the kernel-level timer id is exposed via siginfo.si_tid. +.pp +the posix timers system calls first appeared in linux 2.6. +prior to this, +glibc provided an incomplete user-space implementation +.rb ( clock_realtime +timers only) using posix threads, +and in glibc versions before 2.17, +.\" glibc commit 93a78ac437ba44f493333d7e2a4b0249839ce460 +the implementation falls back to this technique on systems +running pre-2.6 linux kernels. +.sh examples +the program below takes two arguments: a sleep period in seconds, +and a timer frequency in nanoseconds. +the program establishes a handler for the signal it uses for the timer, +blocks that signal, +creates and arms a timer that expires with the given frequency, +sleeps for the specified number of seconds, +and then unblocks the timer signal. +assuming that the timer expired at least once while the program slept, +the signal handler will be invoked, +and the handler displays some information about the timer notification. +the program terminates after one invocation of the signal handler. +.pp +in the following example run, the program sleeps for 1 second, +after creating a timer that has a frequency of 100 nanoseconds. +by the time the signal is unblocked and delivered, +there have been around ten million overruns. +.pp +.in +4n +.ex +$ \fb./a.out 1 100\fp +establishing handler for signal 34 +blocking signal 34 +timer id is 0x804c008 +sleeping for 1 seconds +unblocking signal 34 +caught signal 34 + sival_ptr = 0xbfb174f4; *sival_ptr = 0x804c008 + overrun count = 10004886 +.ee +.in +.ss program source +\& +.ex +#include +#include +#include +#include +#include +#include + +#define clockid clock_realtime +#define sig sigrtmin + +#define errexit(msg) do { perror(msg); exit(exit_failure); \e + } while (0) + +static void +print_siginfo(siginfo_t *si) +{ + timer_t *tidp; + int or; + + tidp = si\->si_value.sival_ptr; + + printf(" sival_ptr = %p; ", si\->si_value.sival_ptr); + printf(" *sival_ptr = %#jx\en", (uintmax_t) *tidp); + + or = timer_getoverrun(*tidp); + if (or == \-1) + errexit("timer_getoverrun"); + else + printf(" overrun count = %d\en", or); +} + +static void +handler(int sig, siginfo_t *si, void *uc) +{ + /* note: calling printf() from a signal handler is not safe + (and should not be done in production programs), since + printf() is not async\-signal\-safe; see signal\-safety(7). + nevertheless, we use printf() here as a simple way of + showing that the handler was called. */ + + printf("caught signal %d\en", sig); + print_siginfo(si); + signal(sig, sig_ign); +} + +int +main(int argc, char *argv[]) +{ + timer_t timerid; + struct sigevent sev; + struct itimerspec its; + long long freq_nanosecs; + sigset_t mask; + struct sigaction sa; + + if (argc != 3) { + fprintf(stderr, "usage: %s \en", + argv[0]); + exit(exit_failure); + } + + /* establish handler for timer signal. */ + + printf("establishing handler for signal %d\en", sig); + sa.sa_flags = sa_siginfo; + sa.sa_sigaction = handler; + sigemptyset(&sa.sa_mask); + if (sigaction(sig, &sa, null) == \-1) + errexit("sigaction"); + + /* block timer signal temporarily. */ + + printf("blocking signal %d\en", sig); + sigemptyset(&mask); + sigaddset(&mask, sig); + if (sigprocmask(sig_setmask, &mask, null) == \-1) + errexit("sigprocmask"); + + /* create the timer. */ + + sev.sigev_notify = sigev_signal; + sev.sigev_signo = sig; + sev.sigev_value.sival_ptr = &timerid; + if (timer_create(clockid, &sev, &timerid) == \-1) + errexit("timer_create"); + + printf("timer id is %#jx\en", (uintmax_t) timerid); + + /* start the timer. */ + + freq_nanosecs = atoll(argv[2]); + its.it_value.tv_sec = freq_nanosecs / 1000000000; + its.it_value.tv_nsec = freq_nanosecs % 1000000000; + its.it_interval.tv_sec = its.it_value.tv_sec; + its.it_interval.tv_nsec = its.it_value.tv_nsec; + + if (timer_settime(timerid, 0, &its, null) == \-1) + errexit("timer_settime"); + + /* sleep for a while; meanwhile, the timer may expire + multiple times. */ + + printf("sleeping for %d seconds\en", atoi(argv[1])); + sleep(atoi(argv[1])); + + /* unlock the timer signal, so that timer notification + can be delivered. */ + + printf("unblocking signal %d\en", sig); + if (sigprocmask(sig_unblock, &mask, null) == \-1) + errexit("sigprocmask"); + + exit(exit_success); +} +.ee +.sh see also +.ad l +.nh +.br clock_gettime (2), +.br setitimer (2), +.br timer_delete (2), +.br timer_getoverrun (2), +.br timer_settime (2), +.br timerfd_create (2), +.br clock_getcpuclockid (3), +.br pthread_getcpuclockid (3), +.br pthreads (7), +.br sigevent (7), +.br signal (7), +.br time (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/err.3 + +.\" copyright (c) 1983, 1991 the regents of the university of california. +.\" and copyright (c) 2011 guillem jover +.\" and copyright (c) 2006, 2014 michael kerrisk +.\" all rights reserved. +.\" +.\" %%%license_start(bsd_4_clause_ucb) +.\" redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. all advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" this product includes software developed by the university of +.\" california, berkeley and its contributors. +.\" 4. neither the name of the university nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" this software is provided by the regents and contributors ``as is'' and +.\" any express or implied warranties, including, but not limited to, the +.\" implied warranties of merchantability and fitness for a particular purpose +.\" are disclaimed. in no event shall the regents or contributors be liable +.\" for any direct, indirect, incidental, special, exemplary, or consequential +.\" damages (including, but not limited to, procurement of substitute goods +.\" or services; loss of use, data, or profits; or business interruption) +.\" however caused and on any theory of liability, whether in contract, strict +.\" liability, or tort (including negligence or otherwise) arising in any way +.\" out of the use of this software, even if advised of the possibility of +.\" such damage. +.\" %%%license_end +.\" +.\" @(#)readlink.2 6.8 (berkeley) 3/10/91 +.\" +.\" modified sat jul 24 00:10:21 1993 by rik faith (faith@cs.unc.edu) +.\" modified tue jul 9 23:55:17 1996 by aeb +.\" modified fri jan 24 00:26:00 1997 by aeb +.\" 2011-09-20, guillem jover : +.\" added text on dynamically allocating buffer + example program +.\" +.th readlink 2 2021-08-27 "linux" "linux programmer's manual" +.sh name +readlink, readlinkat \- read value of a symbolic link +.sh synopsis +.nf +.b #include +.pp +.bi "ssize_t readlink(const char *restrict " pathname ", char *restrict " buf , +.bi " size_t " bufsiz ); +.pp +.br "#include " "/* definition of " at_* " constants */" +.b #include +.pp +.bi "ssize_t readlinkat(int " dirfd ", const char *restrict " pathname , +.bi " char *restrict " buf ", size_t " bufsiz ); +.pp +.fi +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br readlink (): +.nf + _xopen_source >= 500 || _posix_c_source >= 200112l +.\" || _xopen_source && _xopen_source_extended + || /* glibc <= 2.19: */ _bsd_source +.fi +.pp +.br readlinkat (): +.nf + since glibc 2.10: + _posix_c_source >= 200809l + before glibc 2.10: + _atfile_source +.fi +.sh description +.br readlink () +places the contents of the symbolic link +.i pathname +in the buffer +.ir buf , +which has size +.ir bufsiz . +.br readlink () +does not append a terminating null byte to +.ir buf . +it will (silently) truncate the contents (to a length of +.i bufsiz +characters), in case the buffer is too small to hold all of the contents. +.ss readlinkat() +the +.br readlinkat () +system call operates in exactly the same way as +.br readlink (), +except for the differences described here. +.pp +if the pathname given in +.i pathname +is relative, then it is interpreted relative to the directory +referred to by the file descriptor +.i dirfd +(rather than relative to the current working directory of +the calling process, as is done by +.br readlink () +for a relative pathname). +.pp +if +.i pathname +is relative and +.i dirfd +is the special value +.br at_fdcwd , +then +.i pathname +is interpreted relative to the current working +directory of the calling process (like +.br readlink ()). +.pp +if +.i pathname +is absolute, then +.i dirfd +is ignored. +.pp +since linux 2.6.39, +.\" commit 65cfc6722361570bfe255698d9cd4dccaf47570d +.i pathname +can be an empty string, +in which case the call operates on the symbolic link referred to by +.ir dirfd +(which should have been obtained using +.br open (2) +with the +.b o_path +and +.b o_nofollow +flags). +.pp +see +.br openat (2) +for an explanation of the need for +.br readlinkat (). +.sh return value +on success, these calls return the number of bytes placed in +.ir buf . +(if the returned value equals +.ir bufsiz , +then truncation may have occurred.) +on error, \-1 is returned and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eacces +search permission is denied for a component of the path prefix. +(see also +.br path_resolution (7).) +.tp +.b ebadf +.rb ( readlinkat ()) +.i pathname +is relative but +.i dirfd +is neither +.b at_fdcwd +nor a valid file descriptor. +.tp +.b efault +.i buf +extends outside the process's allocated address space. +.tp +.b einval +.i bufsiz +is not positive. +.\" at the glibc level, bufsiz is unsigned, so this error can only occur +.\" if bufsiz==0. however, the in the kernel syscall, bufsiz is signed, +.\" and this error can also occur if bufsiz < 0. +.\" see: http://thread.gmane.org/gmane.linux.man/380 +.\" subject: [patch 0/3] [rfc] kernel/glibc mismatch of "readlink" syscall? +.tp +.b einval +the named file (i.e., the final filename component of +.ir pathname ) +is not a symbolic link. +.tp +.b eio +an i/o error occurred while reading from the filesystem. +.tp +.b eloop +too many symbolic links were encountered in translating the pathname. +.tp +.b enametoolong +a pathname, or a component of a pathname, was too long. +.tp +.b enoent +the named file does not exist. +.tp +.b enomem +insufficient kernel memory was available. +.tp +.b enotdir +a component of the path prefix is not a directory. +.tp +.b enotdir +.rb ( readlinkat ()) +.i pathname +is relative and +.i dirfd +is a file descriptor referring to a file other than a directory. +.sh versions +.br readlinkat () +was added to linux in kernel 2.6.16; +library support was added to glibc in version 2.4. +.sh conforming to +.br readlink (): +4.4bsd +.rb ( readlink () +first appeared in 4.2bsd), +posix.1-2001, posix.1-2008. +.pp +.br readlinkat (): +posix.1-2008. +.sh notes +in versions of glibc up to and including glibc 2.4, the return type of +.br readlink () +was declared as +.ir int . +nowadays, the return type is declared as +.ir ssize_t , +as (newly) required in posix.1-2001. +.pp +using a statically sized buffer might not provide enough room for the +symbolic link contents. +the required size for the buffer can be obtained from the +.i stat.st_size +value returned by a call to +.br lstat (2) +on the link. +however, the number of bytes written by +.br readlink () +and +.br readlinkat () +should be checked to make sure that the size of the +symbolic link did not increase between the calls. +dynamically allocating the buffer for +.br readlink () +and +.br readlinkat () +also addresses a common portability problem when using +.b path_max +for the buffer size, +as this constant is not guaranteed to be defined per posix +if the system does not have such limit. +.ss glibc notes +on older kernels where +.br readlinkat () +is unavailable, the glibc wrapper function falls back to the use of +.br readlink (). +when +.i pathname +is a relative pathname, +glibc constructs a pathname based on the symbolic link in +.ir /proc/self/fd +that corresponds to the +.ir dirfd +argument. +.sh examples +the following program allocates the buffer needed by +.br readlink () +dynamically from the information provided by +.br lstat (2), +falling back to a buffer of size +.br path_max +in cases where +.br lstat (2) +reports a size of zero. +.pp +.ex +#include +#include +#include +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + struct stat sb; + char *buf; + ssize_t nbytes, bufsiz; + + if (argc != 2) { + fprintf(stderr, "usage: %s \en", argv[0]); + exit(exit_failure); + } + + if (lstat(argv[1], &sb) == \-1) { + perror("lstat"); + exit(exit_failure); + } + + /* add one to the link size, so that we can determine whether + the buffer returned by readlink() was truncated. */ + + bufsiz = sb.st_size + 1; + + /* some magic symlinks under (for example) /proc and /sys + report \(aqst_size\(aq as zero. in that case, take path_max as + a "good enough" estimate. */ + + if (sb.st_size == 0) + bufsiz = path_max; + + buf = malloc(bufsiz); + if (buf == null) { + perror("malloc"); + exit(exit_failure); + } + + nbytes = readlink(argv[1], buf, bufsiz); + if (nbytes == \-1) { + perror("readlink"); + exit(exit_failure); + } + + /* print only \(aqnbytes\(aq of \(aqbuf\(aq, as it doesn't contain a terminating + null byte (\(aq\e0\(aq). */ + printf("\(aq%s\(aq points to \(aq%.*s\(aq\en", argv[1], (int) nbytes, buf); + + /* if the return value was equal to the buffer size, then the + the link target was larger than expected (perhaps because the + target was changed between the call to lstat() and the call to + readlink()). warn the user that the returned target may have + been truncated. */ + + if (nbytes == bufsiz) + printf("(returned buffer may have been truncated)\en"); + + free(buf); + exit(exit_success); +} +.ee +.sh see also +.br readlink (1), +.br lstat (2), +.br stat (2), +.br symlink (2), +.br realpath (3), +.br path_resolution (7), +.br symlink (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) tom bjorkholm & markus kuhn, 1996 +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" 1996-04-01 tom bjorkholm +.\" first version written +.\" 1996-04-10 markus kuhn +.\" revision +.\" +.th sched_yield 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +sched_yield \- yield the processor +.sh synopsis +.nf +.b #include +.pp +.b int sched_yield(void); +.fi +.sh description +.br sched_yield () +causes the calling thread to relinquish the cpu. +the thread is moved to the end of the queue for its static +priority and a new thread gets to run. +.sh return value +on success, +.br sched_yield () +returns 0. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +in the linux implementation, +.br sched_yield () +always succeeds. +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +if the calling thread is the only thread in the highest +priority list at that time, +it will continue to run after a call to +.br sched_yield (). +.pp +posix systems on which +.br sched_yield () +is available define +.b _posix_priority_scheduling +in +.ir . +.pp +strategic calls to +.br sched_yield () +can improve performance by giving other threads or processes +a chance to run when (heavily) contended resources (e.g., mutexes) +have been released by the caller. +avoid calling +.br sched_yield () +unnecessarily or inappropriately +(e.g., when resources needed by other +schedulable threads are still held by the caller), +since doing so will result in unnecessary context switches, +which will degrade system performance. +.pp +.br sched_yield () +is intended for use with real-time scheduling policies (i.e., +.br sched_fifo +or +.br sched_rr ). +use of +.br sched_yield () +with nondeterministic scheduling policies such as +.br sched_other +is unspecified and very likely means your application design is broken. +.sh see also +.br sched (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/cos.3 + +.so man3/j0.3 + +.so man3/drand48.3 + +.so man7/system_data_types.7 + +.so man2/getrlimit.2 +.\" no new programs should use vlimit(3). +.\" getrlimit(2) briefly discusses vlimit(3), so point the user there. + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" iso/iec 9899:1999 +.\" +.th wctrans 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +wctrans \- wide-character translation mapping +.sh synopsis +.nf +.b #include +.pp +.bi "wctrans_t wctrans(const char *" name ); +.fi +.sh description +the +.i wctrans_t +type represents a mapping +which can map a wide character to +another wide character. +its nature is implementation-dependent, but the special +value +.ir "(wctrans_t)\ 0" +denotes an invalid mapping. +nonzero +.i wctrans_t +values can be passed to the +.br towctrans (3) +function to actually perform +the wide-character mapping. +.pp +the +.br wctrans () +function returns a mapping, given by its name. +the set of +valid names depends on the +.b lc_ctype +category of the current locale, but the +following names are valid in all locales. +.pp +.nf + "tolower" \- realizes the \fbtolower\fp(3) mapping + "toupper" \- realizes the \fbtoupper\fp(3) mapping +.fi +.sh return value +the +.br wctrans () +function returns a mapping descriptor if the +.i name +is valid. +otherwise, it returns +.ir "(wctrans_t)\ 0" . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br wctrans () +t} thread safety mt-safe locale +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh notes +the behavior of +.br wctrans () +depends on the +.b lc_ctype +category of the +current locale. +.sh see also +.br towctrans (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2000 christoph j. thompson +.\" +.\" %%%license_start(gplv2+_doc_misc) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th ftpusers 5 2000-08-27 "linux" "linux programmer's manual" +.sh name +ftpusers \- list of users that may not log in via the ftp daemon +.sh description +the text file +.b ftpusers +contains a list of users that may not log in using the +file transfer protocol (ftp) server daemon. +this file is used not merely for +system administration purposes but also for improving security within a tcp/ip +networked environment. +.pp +the +.b ftpusers +file will typically contain a list of the users that +either have no business using ftp or have too many privileges to be allowed +to log in through the ftp server daemon. +such users usually include root, daemon, bin, uucp, and news. +.pp +if your ftp server daemon doesn't use +.br ftpusers , +then it is suggested that you read its documentation to find out how to +block access for certain users. +washington university ftp server daemon +(wuftpd) and professional ftp daemon (proftpd) are known to make use of +.br ftpusers . +.ss format +the format of +.b ftpusers +is very simple. +there is one account name (or username) per line. +lines starting with a # are ignored. +.sh files +.i /etc/ftpusers +.sh see also +.br passwd (5), +.br proftpd (8), +.br wuftpd (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/getpriority.2 + +.\" copyright (c) 1983, 1991 the regents of the university of california. +.\" and copyright (c) 2007, michael kerrisk +.\" all rights reserved. +.\" +.\" %%%license_start(bsd_4_clause_ucb) +.\" redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. all advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" this product includes software developed by the university of +.\" california, berkeley and its contributors. +.\" 4. neither the name of the university nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" this software is provided by the regents and contributors ``as is'' and +.\" any express or implied warranties, including, but not limited to, the +.\" implied warranties of merchantability and fitness for a particular purpose +.\" are disclaimed. in no event shall the regents or contributors be liable +.\" for any direct, indirect, incidental, special, exemplary, or consequential +.\" damages (including, but not limited to, procurement of substitute goods +.\" or services; loss of use, data, or profits; or business interruption) +.\" however caused and on any theory of liability, whether in contract, strict +.\" liability, or tort (including negligence or otherwise) arising in any way +.\" out of the use of this software, even if advised of the possibility of +.\" such damage. +.\" %%%license_end +.\" +.\" $id: listen.2,v 1.6 1999/05/18 14:10:32 freitag exp $ +.\" +.\" modified fri jul 23 22:07:54 1993 by rik faith +.\" modified 950727 by aeb, following a suggestion by urs thuermann +.\" +.\" modified tue oct 22 08:11:14 edt 1996 by eric s. raymond +.\" modified 1998 by andi kleen +.\" modified 11 may 2001 by sam varshavchik +.\" +.\" +.th listen 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +listen \- listen for connections on a socket +.sh synopsis +.nf +.b #include +.pp +.bi "int listen(int " sockfd ", int " backlog ); +.fi +.sh description +.br listen () +marks the socket referred to by +.i sockfd +as a passive socket, that is, as a socket that will +be used to accept incoming connection requests using +.br accept (2). +.pp +the +.i sockfd +argument is a file descriptor that refers to a socket of type +.b sock_stream +or +.br sock_seqpacket . +.pp +the +.i backlog +argument defines the maximum length +to which the queue of pending connections for +.i sockfd +may grow. +if a connection request arrives when the queue is full, the client +may receive an error with an indication of +.b econnrefused +or, if the underlying protocol supports retransmission, the request may be +ignored so that a later reattempt at connection succeeds. +.sh return value +on success, zero is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eaddrinuse +another socket is already listening on the same port. +.tp +.b eaddrinuse +(internet domain sockets) +the socket referred to by +.i sockfd +had not previously been bound to an address and, +upon attempting to bind it to an ephemeral port, +it was determined that all port numbers in the ephemeral port range +are currently in use. +see the discussion of +.i /proc/sys/net/ipv4/ip_local_port_range +in +.br ip (7). +.tp +.b ebadf +the argument +.i sockfd +is not a valid file descriptor. +.tp +.b enotsock +the file descriptor +.i sockfd +does not refer to a socket. +.tp +.b eopnotsupp +the socket is not of a type that supports the +.br listen () +operation. +.sh conforming to +posix.1-2001, posix.1-2008, 4.4bsd +.rb ( listen () +first appeared in 4.2bsd). +.sh notes +to accept connections, the following steps are performed: +.rs 4 +.ip 1. 4 +a socket is created with +.br socket (2). +.ip 2. +the socket is bound to a local address using +.br bind (2), +so that other sockets may be +.br connect (2)ed +to it. +.ip 3. +a willingness to accept incoming connections and a queue limit for incoming +connections are specified with +.br listen (). +.ip 4. +connections are accepted with +.br accept (2). +.re +.pp +the behavior of the +.i backlog +argument on tcp sockets changed with linux 2.2. +now it specifies the queue length for +.i completely +established sockets waiting to be accepted, +instead of the number of incomplete connection requests. +the maximum length of the queue for incomplete sockets +can be set using +.ir /proc/sys/net/ipv4/tcp_max_syn_backlog . +when syncookies are enabled there is no logical maximum +length and this setting is ignored. +see +.br tcp (7) +for more information. +.pp +if the +.i backlog +argument is greater than the value in +.ir /proc/sys/net/core/somaxconn , +then it is silently capped to that value. +since linux 5.4, the default in this file is 4096; +in earlier kernels, the default value is 128. +in kernels before 2.4.25, this limit was a hard coded value, +.br somaxconn , +with the value 128. +.\" the following is now rather historic information (mtk, jun 05) +.\" don't rely on this value in portable applications since bsd +.\" (and some bsd-derived systems) limit the backlog to 5. +.sh examples +see +.br bind (2). +.sh see also +.br accept (2), +.br bind (2), +.br connect (2), +.br socket (2), +.br socket (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1993 by thomas koenig (ig25@rz.uni-karlsruhe.de) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified sat jul 24 19:35:54 1993 by rik faith (faith@cs.unc.edu) +.\" modified mon oct 16 00:16:29 2000 following joseph s. myers +.\" +.th fnmatch 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +fnmatch \- match filename or pathname +.sh synopsis +.nf +.b #include +.pp +.bi "int fnmatch(const char *" "pattern" ", const char *" string ", int " flags ); +.fi +.sh description +the +.br fnmatch () +function checks whether the +.i string +argument matches the +.i pattern +argument, which is a shell wildcard pattern (see +.br glob (7)). +.pp +the +.i flags +argument modifies the behavior; it is the bitwise or of zero or more +of the following flags: +.tp +.b fnm_noescape +if this flag is set, treat backslash as an ordinary character, +instead of an escape character. +.tp +.b fnm_pathname +if this flag is set, match a slash in +.i string +only with a slash in +.i pattern +and not by an asterisk (*) or a question mark (?) metacharacter, +nor by a bracket expression ([]) containing a slash. +.tp +.b fnm_period +if this flag is set, a leading period in +.i string +has to be matched exactly by a period in +.ir pattern . +a period is considered to be leading if it is the first character in +.ir string , +or if both +.b fnm_pathname +is set and the period immediately follows a slash. +.tp +.b fnm_file_name +this is a gnu synonym for +.br fnm_pathname . +.tp +.b fnm_leading_dir +if this flag (a gnu extension) is set, the pattern is considered to be +matched if it matches an initial segment of +.i string +which is followed by a slash. +this flag is mainly for the internal +use of glibc and is implemented only in certain cases. +.tp +.b fnm_casefold +if this flag (a gnu extension) is set, the pattern is matched +case-insensitively. +.tp +.b fnm_extmatch +if this flag (a gnu extension) is set, extended patterns are +supported, as introduced by \&'ksh' and now supported by other shells. +the extended format is as follows, with \fipattern\-list\fr +being a \&'|' separated list of patterns. +.tp +\&'?(\fipattern\-list\fr)' +the pattern matches if zero or one occurrences of any of the +patterns in the \fipattern\-list\fr match the input \fistring\fr. +.tp +\&'*(\fipattern\-list\fr)' +the pattern matches if zero or more occurrences of any of the +patterns in the \fipattern\-list\fr match the input \fistring\fr. +.tp +\&'+(\fipattern\-list\fr)' +the pattern matches if one or more occurrences of any of the +patterns in the \fipattern\-list\fr match the input \fistring\fr. +.tp +\&'@(\fipattern\-list\fr)' +the pattern matches if exactly one occurrence of any of the +patterns in the \fipattern\-list\fr match the input \fistring\fr. +.tp +\&'!(\fipattern\-list\fr)' +the pattern matches if the input \fistring\fr cannot be matched with +any of the patterns in the \fipattern\-list\fr. +.sh return value +zero if +.i string +matches +.ir pattern , +.b fnm_nomatch +if there is no match or another nonzero value if there is an error. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br fnmatch () +t} thread safety mt-safe env locale +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, posix.2. +the +.br fnm_file_name ", " fnm_leading_dir ", and " fnm_casefold +flags are gnu extensions. +.sh see also +.br sh (1), +.br glob (3), +.br scandir (3), +.br wordexp (3), +.br glob (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/a64l.3 + +.so man3/xdr.3 + +.so man3/ferror.3 + +.\" copyright (c) 2008 silicon graphics, inc. +.\" +.\" author: paul jackson (http://oss.sgi.com/projects/cpusets) +.\" +.\" %%%license_start(gplv2_misc) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license +.\" version 2 as published by the free software foundation. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th cpuset 7 2020-11-01 "linux" "linux programmer's manual" +.sh name +cpuset \- confine processes to processor and memory node subsets +.sh description +the cpuset filesystem is a pseudo-filesystem interface +to the kernel cpuset mechanism, +which is used to control the processor placement +and memory placement of processes. +it is commonly mounted at +.ir /dev/cpuset . +.pp +on systems with kernels compiled with built in support for cpusets, +all processes are attached to a cpuset, and cpusets are always present. +if a system supports cpusets, then it will have the entry +.b nodev cpuset +in the file +.ir /proc/filesystems . +by mounting the cpuset filesystem (see the +.b examples +section below), +the administrator can configure the cpusets on a system +to control the processor and memory placement of processes +on that system. +by default, if the cpuset configuration +on a system is not modified or if the cpuset filesystem +is not even mounted, then the cpuset mechanism, +though present, has no effect on the system's behavior. +.pp +a cpuset defines a list of cpus and memory nodes. +.pp +the cpus of a system include all the logical processing +units on which a process can execute, including, if present, +multiple processor cores within a package and hyper-threads +within a processor core. +memory nodes include all distinct +banks of main memory; small and smp systems typically have +just one memory node that contains all the system's main memory, +while numa (non-uniform memory access) systems have multiple memory nodes. +.pp +cpusets are represented as directories in a hierarchical +pseudo-filesystem, where the top directory in the hierarchy +.ri ( /dev/cpuset ) +represents the entire system (all online cpus and memory nodes) +and any cpuset that is the child (descendant) of +another parent cpuset contains a subset of that parent's +cpus and memory nodes. +the directories and files representing cpusets have normal +filesystem permissions. +.pp +every process in the system belongs to exactly one cpuset. +a process is confined to run only on the cpus in +the cpuset it belongs to, and to allocate memory only +on the memory nodes in that cpuset. +when a process +.br fork (2)s, +the child process is placed in the same cpuset as its parent. +with sufficient privilege, a process may be moved from one +cpuset to another and the allowed cpus and memory nodes +of an existing cpuset may be changed. +.pp +when the system begins booting, a single cpuset is +defined that includes all cpus and memory nodes on the +system, and all processes are in that cpuset. +during the boot process, or later during normal system operation, +other cpusets may be created, as subdirectories of this top cpuset, +under the control of the system administrator, +and processes may be placed in these other cpusets. +.pp +cpusets are integrated with the +.br sched_setaffinity (2) +scheduling affinity mechanism and the +.br mbind (2) +and +.br set_mempolicy (2) +memory-placement mechanisms in the kernel. +neither of these mechanisms let a process make use +of a cpu or memory node that is not allowed by that process's cpuset. +if changes to a process's cpuset placement conflict with these +other mechanisms, then cpuset placement is enforced +even if it means overriding these other mechanisms. +the kernel accomplishes this overriding by silently +restricting the cpus and memory nodes requested by +these other mechanisms to those allowed by the +invoking process's cpuset. +this can result in these +other calls returning an error, if for example, such +a call ends up requesting an empty set of cpus or +memory nodes, after that request is restricted to +the invoking process's cpuset. +.pp +typically, a cpuset is used to manage +the cpu and memory-node confinement for a set of +cooperating processes such as a batch scheduler job, and these +other mechanisms are used to manage the placement of +individual processes or memory regions within that set or job. +.sh files +each directory below +.i /dev/cpuset +represents a cpuset and contains a fixed set of pseudo-files +describing the state of that cpuset. +.pp +new cpusets are created using the +.br mkdir (2) +system call or the +.br mkdir (1) +command. +the properties of a cpuset, such as its flags, allowed +cpus and memory nodes, and attached processes, are queried and modified +by reading or writing to the appropriate file in that cpuset's directory, +as listed below. +.pp +the pseudo-files in each cpuset directory are automatically created when +the cpuset is created, as a result of the +.br mkdir (2) +invocation. +it is not possible to directly add or remove these pseudo-files. +.pp +a cpuset directory that contains no child cpuset directories, +and has no attached processes, can be removed using +.br rmdir (2) +or +.br rmdir (1). +it is not necessary, or possible, +to remove the pseudo-files inside the directory before removing it. +.pp +the pseudo-files in each cpuset directory are +small text files that may be read and +written using traditional shell utilities such as +.br cat (1), +and +.br echo (1), +or from a program by using file i/o library functions or system calls, +such as +.br open (2), +.br read (2), +.br write (2), +and +.br close (2). +.pp +the pseudo-files in a cpuset directory represent internal kernel +state and do not have any persistent image on disk. +each of these per-cpuset files is listed and described below. +.\" ====================== tasks ====================== +.tp +.i tasks +list of the process ids (pids) of the processes in that cpuset. +the list is formatted as a series of ascii +decimal numbers, each followed by a newline. +a process may be added to a cpuset (automatically removing +it from the cpuset that previously contained it) by writing its +pid to that cpuset's +.i tasks +file (with or without a trailing newline). +.ip +.b warning: +only one pid may be written to the +.i tasks +file at a time. +if a string is written that contains more +than one pid, only the first one will be used. +.\" =================== notify_on_release =================== +.tp +.i notify_on_release +flag (0 or 1). +if set (1), that cpuset will receive special handling +after it is released, that is, after all processes cease using +it (i.e., terminate or are moved to a different cpuset) +and all child cpuset directories have been removed. +see the \fbnotify on release\fr section, below. +.\" ====================== cpus ====================== +.tp +.i cpuset.cpus +list of the physical numbers of the cpus on which processes +in that cpuset are allowed to execute. +see \fblist format\fr below for a description of the +format of +.ir cpus . +.ip +the cpus allowed to a cpuset may be changed by +writing a new list to its +.i cpus +file. +.\" ==================== cpu_exclusive ==================== +.tp +.i cpuset.cpu_exclusive +flag (0 or 1). +if set (1), the cpuset has exclusive use of +its cpus (no sibling or cousin cpuset may overlap cpus). +by default, this is off (0). +newly created cpusets also initially default this to off (0). +.ip +two cpusets are +.i sibling +cpusets if they share the same parent cpuset in the +.i /dev/cpuset +hierarchy. +two cpusets are +.i cousin +cpusets if neither is the ancestor of the other. +regardless of the +.i cpu_exclusive +setting, if one cpuset is the ancestor of another, +and if both of these cpusets have nonempty +.ir cpus , +then their +.i cpus +must overlap, because the +.i cpus +of any cpuset are always a subset of the +.i cpus +of its parent cpuset. +.\" ====================== mems ====================== +.tp +.i cpuset.mems +list of memory nodes on which processes in this cpuset are +allowed to allocate memory. +see \fblist format\fr below for a description of the +format of +.ir mems . +.\" ==================== mem_exclusive ==================== +.tp +.i cpuset.mem_exclusive +flag (0 or 1). +if set (1), the cpuset has exclusive use of +its memory nodes (no sibling or cousin may overlap). +also if set (1), the cpuset is a \fbhardwall\fr cpuset (see below). +by default, this is off (0). +newly created cpusets also initially default this to off (0). +.ip +regardless of the +.i mem_exclusive +setting, if one cpuset is the ancestor of another, +then their memory nodes must overlap, because the memory +nodes of any cpuset are always a subset of the memory nodes +of that cpuset's parent cpuset. +.\" ==================== mem_hardwall ==================== +.tp +.ir cpuset.mem_hardwall " (since linux 2.6.26)" +flag (0 or 1). +if set (1), the cpuset is a \fbhardwall\fr cpuset (see below). +unlike \fbmem_exclusive\fr, +there is no constraint on whether cpusets +marked \fbmem_hardwall\fr may have overlapping +memory nodes with sibling or cousin cpusets. +by default, this is off (0). +newly created cpusets also initially default this to off (0). +.\" ==================== memory_migrate ==================== +.tp +.ir cpuset.memory_migrate " (since linux 2.6.16)" +flag (0 or 1). +if set (1), then memory migration is enabled. +by default, this is off (0). +see the \fbmemory migration\fr section, below. +.\" ==================== memory_pressure ==================== +.tp +.ir cpuset.memory_pressure " (since linux 2.6.16)" +a measure of how much memory pressure the processes in this +cpuset are causing. +see the \fbmemory pressure\fr section, below. +unless +.i memory_pressure_enabled +is enabled, always has value zero (0). +this file is read-only. +see the +.b warnings +section, below. +.\" ================= memory_pressure_enabled ================= +.tp +.ir cpuset.memory_pressure_enabled " (since linux 2.6.16)" +flag (0 or 1). +this file is present only in the root cpuset, normally +.ir /dev/cpuset . +if set (1), the +.i memory_pressure +calculations are enabled for all cpusets in the system. +by default, this is off (0). +see the +\fbmemory pressure\fr section, below. +.\" ================== memory_spread_page ================== +.tp +.ir cpuset.memory_spread_page " (since linux 2.6.17)" +flag (0 or 1). +if set (1), pages in the kernel page cache +(filesystem buffers) are uniformly spread across the cpuset. +by default, this is off (0) in the top cpuset, +and inherited from the parent cpuset in +newly created cpusets. +see the \fbmemory spread\fr section, below. +.\" ================== memory_spread_slab ================== +.tp +.ir cpuset.memory_spread_slab " (since linux 2.6.17)" +flag (0 or 1). +if set (1), the kernel slab caches +for file i/o (directory and inode structures) are +uniformly spread across the cpuset. +by default, is off (0) in the top cpuset, +and inherited from the parent cpuset in +newly created cpusets. +see the \fbmemory spread\fr section, below. +.\" ================== sched_load_balance ================== +.tp +.ir cpuset.sched_load_balance " (since linux 2.6.24)" +flag (0 or 1). +if set (1, the default) the kernel will +automatically load balance processes in that cpuset over +the allowed cpus in that cpuset. +if cleared (0) the +kernel will avoid load balancing processes in this cpuset, +.i unless +some other cpuset with overlapping cpus has its +.i sched_load_balance +flag set. +see \fbscheduler load balancing\fr, below, for further details. +.\" ================== sched_relax_domain_level ================== +.tp +.ir cpuset.sched_relax_domain_level " (since linux 2.6.26)" +integer, between \-1 and a small positive value. +the +.i sched_relax_domain_level +controls the width of the range of cpus over which the kernel scheduler +performs immediate rebalancing of runnable tasks across cpus. +if +.i sched_load_balance +is disabled, then the setting of +.i sched_relax_domain_level +does not matter, as no such load balancing is done. +if +.i sched_load_balance +is enabled, then the higher the value of the +.ir sched_relax_domain_level , +the wider +the range of cpus over which immediate load balancing is attempted. +see \fbscheduler relax domain level\fr, below, for further details. +.\" ================== proc cpuset ================== +.pp +in addition to the above pseudo-files in each directory below +.ir /dev/cpuset , +each process has a pseudo-file, +.ir /proc//cpuset , +that displays the path of the process's cpuset directory +relative to the root of the cpuset filesystem. +.\" ================== proc status ================== +.pp +also the +.i /proc//status +file for each process has four added lines, +displaying the process's +.i cpus_allowed +(on which cpus it may be scheduled) and +.i mems_allowed +(on which memory nodes it may obtain memory), +in the two formats \fbmask format\fr and \fblist format\fr (see below) +as shown in the following example: +.pp +.in +4n +.ex +cpus_allowed: ffffffff,ffffffff,ffffffff,ffffffff +cpus_allowed_list: 0\-127 +mems_allowed: ffffffff,ffffffff +mems_allowed_list: 0\-63 +.ee +.in +.pp +the "allowed" fields were added in linux 2.6.24; +the "allowed_list" fields were added in linux 2.6.26. +.\" ================== extended capabilities ================== +.sh extended capabilities +in addition to controlling which +.i cpus +and +.i mems +a process is allowed to use, cpusets provide the following +extended capabilities. +.\" ================== exclusive cpusets ================== +.ss exclusive cpusets +if a cpuset is marked +.i cpu_exclusive +or +.ir mem_exclusive , +no other cpuset, other than a direct ancestor or descendant, +may share any of the same cpus or memory nodes. +.pp +a cpuset that is +.i mem_exclusive +restricts kernel allocations for +buffer cache pages and other internal kernel data pages +commonly shared by the kernel across +multiple users. +all cpusets, whether +.i mem_exclusive +or not, restrict allocations of memory for user space. +this enables configuring a +system so that several independent jobs can share common kernel data, +while isolating each job's user allocation in +its own cpuset. +to do this, construct a large +.i mem_exclusive +cpuset to hold all the jobs, and construct child, +.ri non- mem_exclusive +cpusets for each individual job. +only a small amount of kernel memory, +such as requests from interrupt handlers, is allowed to be +placed on memory nodes +outside even a +.i mem_exclusive +cpuset. +.\" ================== hardwall ================== +.ss hardwall +a cpuset that has +.i mem_exclusive +or +.i mem_hardwall +set is a +.i hardwall +cpuset. +a +.i hardwall +cpuset restricts kernel allocations for page, buffer, +and other data commonly shared by the kernel across multiple users. +all cpusets, whether +.i hardwall +or not, restrict allocations of memory for user space. +.pp +this enables configuring a system so that several independent +jobs can share common kernel data, such as filesystem pages, +while isolating each job's user allocation in its own cpuset. +to do this, construct a large +.i hardwall +cpuset to hold +all the jobs, and construct child cpusets for each individual +job which are not +.i hardwall +cpusets. +.pp +only a small amount of kernel memory, such as requests from +interrupt handlers, is allowed to be taken outside even a +.i hardwall +cpuset. +.\" ================== notify on release ================== +.ss notify on release +if the +.i notify_on_release +flag is enabled (1) in a cpuset, +then whenever the last process in the cpuset leaves +(exits or attaches to some other cpuset) +and the last child cpuset of that cpuset is removed, +the kernel will run the command +.ir /sbin/cpuset_release_agent , +supplying the pathname (relative to the mount point of the +cpuset filesystem) of the abandoned cpuset. +this enables automatic removal of abandoned cpusets. +.pp +the default value of +.i notify_on_release +in the root cpuset at system boot is disabled (0). +the default value of other cpusets at creation +is the current value of their parent's +.i notify_on_release +setting. +.pp +the command +.i /sbin/cpuset_release_agent +is invoked, with the name +.ri ( /dev/cpuset +relative path) +of the to-be-released cpuset in +.ir argv[1] . +.pp +the usual contents of the command +.i /sbin/cpuset_release_agent +is simply the shell script: +.pp +.in +4n +.ex +#!/bin/sh +rmdir /dev/cpuset/$1 +.ee +.in +.pp +as with other flag values below, this flag can +be changed by writing an ascii +number 0 or 1 (with optional trailing newline) +into the file, to clear or set the flag, respectively. +.\" ================== memory pressure ================== +.ss memory pressure +the +.i memory_pressure +of a cpuset provides a simple per-cpuset running average of +the rate that the processes in a cpuset are attempting to free up in-use +memory on the nodes of the cpuset to satisfy additional memory requests. +.pp +this enables batch managers that are monitoring jobs running in dedicated +cpusets to efficiently detect what level of memory pressure that job +is causing. +.pp +this is useful both on tightly managed systems running a wide mix of +submitted jobs, which may choose to terminate or reprioritize jobs that +are trying to use more memory than allowed on the nodes assigned them, +and with tightly coupled, long-running, massively parallel scientific +computing jobs that will dramatically fail to meet required performance +goals if they start to use more memory than allowed to them. +.pp +this mechanism provides a very economical way for the batch manager +to monitor a cpuset for signs of memory pressure. +it's up to the batch manager or other user code to decide +what action to take if it detects signs of memory pressure. +.pp +unless memory pressure calculation is enabled by setting the pseudo-file +.ir /dev/cpuset/cpuset.memory_pressure_enabled , +it is not computed for any cpuset, and reads from any +.i memory_pressure +always return zero, as represented by the ascii string "0\en". +see the \fbwarnings\fr section, below. +.pp +a per-cpuset, running average is employed for the following reasons: +.ip * 3 +because this meter is per-cpuset rather than per-process or per virtual +memory region, the system load imposed by a batch scheduler monitoring +this metric is sharply reduced on large systems, because a scan of +the tasklist can be avoided on each set of queries. +.ip * +because this meter is a running average rather than an accumulating +counter, a batch scheduler can detect memory pressure with a +single read, instead of having to read and accumulate results +for a period of time. +.ip * +because this meter is per-cpuset rather than per-process, +the batch scheduler can obtain the key information\(emmemory +pressure in a cpuset\(emwith a single read, rather than having to +query and accumulate results over all the (dynamically changing) +set of processes in the cpuset. +.pp +the +.i memory_pressure +of a cpuset is calculated using a per-cpuset simple digital filter +that is kept within the kernel. +for each cpuset, this filter tracks +the recent rate at which processes attached to that cpuset enter the +kernel direct reclaim code. +.pp +the kernel direct reclaim code is entered whenever a process has to +satisfy a memory page request by first finding some other page to +repurpose, due to lack of any readily available already free pages. +dirty filesystem pages are repurposed by first writing them +to disk. +unmodified filesystem buffer pages are repurposed +by simply dropping them, though if that page is needed again, it +will have to be reread from disk. +.pp +the +.i cpuset.memory_pressure +file provides an integer number representing the recent (half-life of +10 seconds) rate of entries to the direct reclaim code caused by any +process in the cpuset, in units of reclaims attempted per second, +times 1000. +.\" ================== memory spread ================== +.ss memory spread +there are two boolean flag files per cpuset that control where the +kernel allocates pages for the filesystem buffers and related +in-kernel data structures. +they are called +.i cpuset.memory_spread_page +and +.ir cpuset.memory_spread_slab . +.pp +if the per-cpuset boolean flag file +.i cpuset.memory_spread_page +is set, then +the kernel will spread the filesystem buffers (page cache) evenly +over all the nodes that the faulting process is allowed to use, instead +of preferring to put those pages on the node where the process is running. +.pp +if the per-cpuset boolean flag file +.i cpuset.memory_spread_slab +is set, +then the kernel will spread some filesystem-related slab caches, +such as those for inodes and directory entries, evenly over all the nodes +that the faulting process is allowed to use, instead of preferring to +put those pages on the node where the process is running. +.pp +the setting of these flags does not affect the data segment +(see +.br brk (2)) +or stack segment pages of a process. +.pp +by default, both kinds of memory spreading are off and the kernel +prefers to allocate memory pages on the node local to where the +requesting process is running. +if that node is not allowed by the +process's numa memory policy or cpuset configuration or if there are +insufficient free memory pages on that node, then the kernel looks +for the nearest node that is allowed and has sufficient free memory. +.pp +when new cpusets are created, they inherit the memory spread settings +of their parent. +.pp +setting memory spreading causes allocations for the affected page or +slab caches to ignore the process's numa memory policy and be spread +instead. +however, the effect of these changes in memory placement +caused by cpuset-specified memory spreading is hidden from the +.br mbind (2) +or +.br set_mempolicy (2) +calls. +these two numa memory policy calls always appear to behave as if +no cpuset-specified memory spreading is in effect, even if it is. +if cpuset memory spreading is subsequently turned off, the numa +memory policy most recently specified by these calls is automatically +reapplied. +.pp +both +.i cpuset.memory_spread_page +and +.i cpuset.memory_spread_slab +are boolean flag files. +by default, they contain "0", meaning that the feature is off +for that cpuset. +if a "1" is written to that file, that turns the named feature on. +.pp +cpuset-specified memory spreading behaves similarly to what is known +(in other contexts) as round-robin or interleave memory placement. +.pp +cpuset-specified memory spreading can provide substantial performance +improvements for jobs that: +.ip a) 3 +need to place thread-local data on +memory nodes close to the cpus which are running the threads that most +frequently access that data; but also +.ip b) +need to access large filesystem data sets that must to be spread +across the several nodes in the job's cpuset in order to fit. +.pp +without this policy, +the memory allocation across the nodes in the job's cpuset +can become very uneven, +especially for jobs that might have just a single +thread initializing or reading in the data set. +.\" ================== memory migration ================== +.ss memory migration +normally, under the default setting (disabled) of +.ir cpuset.memory_migrate , +once a page is allocated (given a physical page +of main memory), then that page stays on whatever node it +was allocated, so long as it remains allocated, even if the +cpuset's memory-placement policy +.i mems +subsequently changes. +.pp +when memory migration is enabled in a cpuset, if the +.i mems +setting of the cpuset is changed, then any memory page in use by any +process in the cpuset that is on a memory node that is no longer +allowed will be migrated to a memory node that is allowed. +.pp +furthermore, if a process is moved into a cpuset with +.i memory_migrate +enabled, any memory pages it uses that were on memory nodes allowed +in its previous cpuset, but which are not allowed in its new cpuset, +will be migrated to a memory node allowed in the new cpuset. +.pp +the relative placement of a migrated page within +the cpuset is preserved during these migration operations if possible. +for example, +if the page was on the second valid node of the prior cpuset, +then the page will be placed on the second valid node of the new cpuset, +if possible. +.\" ================== scheduler load balancing ================== +.ss scheduler load balancing +the kernel scheduler automatically load balances processes. +if one cpu is underutilized, +the kernel will look for processes on other more +overloaded cpus and move those processes to the underutilized cpu, +within the constraints of such placement mechanisms as cpusets and +.br sched_setaffinity (2). +.pp +the algorithmic cost of load balancing and its impact on key shared +kernel data structures such as the process list increases more than +linearly with the number of cpus being balanced. +for example, it +costs more to load balance across one large set of cpus than it does +to balance across two smaller sets of cpus, each of half the size +of the larger set. +(the precise relationship between the number of cpus being balanced +and the cost of load balancing depends +on implementation details of the kernel process scheduler, which is +subject to change over time, as improved kernel scheduler algorithms +are implemented.) +.pp +the per-cpuset flag +.i sched_load_balance +provides a mechanism to suppress this automatic scheduler load +balancing in cases where it is not needed and suppressing it would have +worthwhile performance benefits. +.pp +by default, load balancing is done across all cpus, except those +marked isolated using the kernel boot time "isolcpus=" argument. +(see \fbscheduler relax domain level\fr, below, to change this default.) +.pp +this default load balancing across all cpus is not well suited to +the following two situations: +.ip * 3 +on large systems, load balancing across many cpus is expensive. +if the system is managed using cpusets to place independent jobs +on separate sets of cpus, full load balancing is unnecessary. +.ip * +systems supporting real-time on some cpus need to minimize +system overhead on those cpus, including avoiding process load +balancing if that is not needed. +.pp +when the per-cpuset flag +.i sched_load_balance +is enabled (the default setting), +it requests load balancing across +all the cpus in that cpuset's allowed cpus, +ensuring that load balancing can move a process (not otherwise pinned, +as by +.br sched_setaffinity (2)) +from any cpu in that cpuset to any other. +.pp +when the per-cpuset flag +.i sched_load_balance +is disabled, then the +scheduler will avoid load balancing across the cpus in that cpuset, +\fiexcept\fr in so far as is necessary because some overlapping cpuset +has +.i sched_load_balance +enabled. +.pp +so, for example, if the top cpuset has the flag +.i sched_load_balance +enabled, then the scheduler will load balance across all +cpus, and the setting of the +.i sched_load_balance +flag in other cpusets has no effect, +as we're already fully load balancing. +.pp +therefore in the above two situations, the flag +.i sched_load_balance +should be disabled in the top cpuset, and only some of the smaller, +child cpusets would have this flag enabled. +.pp +when doing this, you don't usually want to leave any unpinned processes in +the top cpuset that might use nontrivial amounts of cpu, as such processes +may be artificially constrained to some subset of cpus, depending on +the particulars of this flag setting in descendant cpusets. +even if such a process could use spare cpu cycles in some other cpus, +the kernel scheduler might not consider the possibility of +load balancing that process to the underused cpu. +.pp +of course, processes pinned to a particular cpu can be left in a cpuset +that disables +.i sched_load_balance +as those processes aren't going anywhere else anyway. +.\" ================== scheduler relax domain level ================== +.ss scheduler relax domain level +the kernel scheduler performs immediate load balancing whenever +a cpu becomes free or another task becomes runnable. +this load +balancing works to ensure that as many cpus as possible are usefully +employed running tasks. +the kernel also performs periodic load +balancing off the software clock described in +.br time (7). +the setting of +.i sched_relax_domain_level +applies only to immediate load balancing. +regardless of the +.i sched_relax_domain_level +setting, periodic load balancing is attempted over all cpus +(unless disabled by turning off +.ir sched_load_balance .) +in any case, of course, tasks will be scheduled to run only on +cpus allowed by their cpuset, as modified by +.br sched_setaffinity (2) +system calls. +.pp +on small systems, such as those with just a few cpus, immediate load +balancing is useful to improve system interactivity and to minimize +wasteful idle cpu cycles. +but on large systems, attempting immediate +load balancing across a large number of cpus can be more costly than +it is worth, depending on the particular performance characteristics +of the job mix and the hardware. +.pp +the exact meaning of the small integer values of +.i sched_relax_domain_level +will depend on internal +implementation details of the kernel scheduler code and on the +non-uniform architecture of the hardware. +both of these will evolve +over time and vary by system architecture and kernel version. +.pp +as of this writing, when this capability was introduced in linux +2.6.26, on certain popular architectures, the positive values of +.i sched_relax_domain_level +have the following meanings. +.pp +.pd 0 +.ip \fb(1)\fr 4 +perform immediate load balancing across hyper-thread +siblings on the same core. +.ip \fb(2)\fr +perform immediate load balancing across other cores in the same package. +.ip \fb(3)\fr +perform immediate load balancing across other cpus +on the same node or blade. +.ip \fb(4)\fr +perform immediate load balancing across over several +(implementation detail) nodes [on numa systems]. +.ip \fb(5)\fr +perform immediate load balancing across over all cpus +in system [on numa systems]. +.pd +.pp +the +.i sched_relax_domain_level +value of zero (0) always means +don't perform immediate load balancing, +hence that load balancing is done only periodically, +not immediately when a cpu becomes available or another task becomes +runnable. +.pp +the +.i sched_relax_domain_level +value of minus one (\-1) +always means use the system default value. +the system default value can vary by architecture and kernel version. +this system default value can be changed by kernel +boot-time "relax_domain_level=" argument. +.pp +in the case of multiple overlapping cpusets which have conflicting +.i sched_relax_domain_level +values, then the highest such value +applies to all cpus in any of the overlapping cpusets. +in such cases, +the value \fbminus one (\-1)\fr is the lowest value, overridden by any +other value, and the value \fbzero (0)\fr is the next lowest value. +.sh formats +the following formats are used to represent sets of +cpus and memory nodes. +.\" ================== mask format ================== +.ss mask format +the \fbmask format\fr is used to represent cpu and memory-node bit masks +in the +.i /proc//status +file. +.pp +this format displays each 32-bit +word in hexadecimal (using ascii characters "0" - "9" and "a" - "f"); +words are filled with leading zeros, if required. +for masks longer than one word, a comma separator is used between words. +words are displayed in big-endian +order, which has the most significant bit first. +the hex digits within a word are also in big-endian order. +.pp +the number of 32-bit words displayed is the minimum number needed to +display all bits of the bit mask, based on the size of the bit mask. +.pp +examples of the \fbmask format\fr: +.pp +.in +4n +.ex +00000001 # just bit 0 set +40000000,00000000,00000000 # just bit 94 set +00000001,00000000,00000000 # just bit 64 set +000000ff,00000000 # bits 32\-39 set +00000000,000e3862 # 1,5,6,11\-13,17\-19 set +.ee +.in +.pp +a mask with bits 0, 1, 2, 4, 8, 16, 32, and 64 set displays as: +.pp +.in +4n +.ex +00000001,00000001,00010117 +.ee +.in +.pp +the first "1" is for bit 64, the +second for bit 32, the third for bit 16, the fourth for bit 8, the +fifth for bit 4, and the "7" is for bits 2, 1, and 0. +.\" ================== list format ================== +.ss list format +the \fblist format\fr for +.i cpus +and +.i mems +is a comma-separated list of cpu or memory-node +numbers and ranges of numbers, in ascii decimal. +.pp +examples of the \fblist format\fr: +.pp +.in +4n +.ex +0\-4,9 # bits 0, 1, 2, 3, 4, and 9 set +0\-2,7,12\-14 # bits 0, 1, 2, 7, 12, 13, and 14 set +.ee +.in +.\" ================== rules ================== +.sh rules +the following rules apply to each cpuset: +.ip * 3 +its cpus and memory nodes must be a (possibly equal) +subset of its parent's. +.ip * +it can be marked +.ir cpu_exclusive +only if its parent is. +.ip * +it can be marked +.ir mem_exclusive +only if its parent is. +.ip * +if it is +.ir cpu_exclusive , +its cpus may not overlap any sibling. +.ip * +if it is +.ir memory_exclusive , +its memory nodes may not overlap any sibling. +.\" ================== permissions ================== +.sh permissions +the permissions of a cpuset are determined by the permissions +of the directories and pseudo-files in the cpuset filesystem, +normally mounted at +.ir /dev/cpuset . +.pp +for instance, a process can put itself in some other cpuset (than +its current one) if it can write the +.i tasks +file for that cpuset. +this requires execute permission on the encompassing directories +and write permission on the +.i tasks +file. +.pp +an additional constraint is applied to requests to place some +other process in a cpuset. +one process may not attach another to +a cpuset unless it would have permission to send that process +a signal (see +.br kill (2)). +.pp +a process may create a child cpuset if it can access and write the +parent cpuset directory. +it can modify the cpus or memory nodes +in a cpuset if it can access that cpuset's directory (execute +permissions on the each of the parent directories) and write the +corresponding +.i cpus +or +.i mems +file. +.pp +there is one minor difference between the manner in which these +permissions are evaluated and the manner in which normal filesystem +operation permissions are evaluated. +the kernel interprets +relative pathnames starting at a process's current working directory. +even if one is operating on a cpuset file, relative pathnames +are interpreted relative to the process's current working directory, +not relative to the process's current cpuset. +the only ways that +cpuset paths relative to a process's current cpuset can be used are +if either the process's current working directory is its cpuset +(it first did a +.b cd +or +.br chdir (2) +to its cpuset directory beneath +.ir /dev/cpuset , +which is a bit unusual) +or if some user code converts the relative cpuset path to a +full filesystem path. +.pp +in theory, this means that user code should specify cpusets +using absolute pathnames, which requires knowing the mount point of +the cpuset filesystem (usually, but not necessarily, +.ir /dev/cpuset ). +in practice, all user level code that this author is aware of +simply assumes that if the cpuset filesystem is mounted, then +it is mounted at +.ir /dev/cpuset . +furthermore, it is common practice for carefully written +user code to verify the presence of the pseudo-file +.i /dev/cpuset/tasks +in order to verify that the cpuset pseudo-filesystem +is currently mounted. +.\" ================== warnings ================== +.sh warnings +.ss enabling memory_pressure +by default, the per-cpuset file +.i cpuset.memory_pressure +always contains zero (0). +unless this feature is enabled by writing "1" to the pseudo-file +.ir /dev/cpuset/cpuset.memory_pressure_enabled , +the kernel does +not compute per-cpuset +.ir memory_pressure . +.ss using the echo command +when using the +.b echo +command at the shell prompt to change the values of cpuset files, +beware that the built-in +.b echo +command in some shells does not display an error message if the +.br write (2) +system call fails. +.\" gack! csh(1)'s echo does this +for example, if the command: +.pp +.in +4n +.ex +echo 19 > cpuset.mems +.ee +.in +.pp +failed because memory node 19 was not allowed (perhaps +the current system does not have a memory node 19), then the +.b echo +command might not display any error. +it is better to use the +.b /bin/echo +external command to change cpuset file settings, as this +command will display +.br write (2) +errors, as in the example: +.pp +.in +4n +.ex +/bin/echo 19 > cpuset.mems +/bin/echo: write error: invalid argument +.ee +.in +.\" ================== exceptions ================== +.sh exceptions +.ss memory placement +not all allocations of system memory are constrained by cpusets, +for the following reasons. +.pp +if hot-plug functionality is used to remove all the cpus that are +currently assigned to a cpuset, then the kernel will automatically +update the +.i cpus_allowed +of all processes attached to cpus in that cpuset +to allow all cpus. +when memory hot-plug functionality for removing +memory nodes is available, a similar exception is expected to apply +there as well. +in general, the kernel prefers to violate cpuset placement, +rather than starving a process that has had all its allowed cpus or +memory nodes taken offline. +user code should reconfigure cpusets to refer only to online cpus +and memory nodes when using hot-plug to add or remove such resources. +.pp +a few kernel-critical, internal memory-allocation requests, marked +gfp_atomic, must be satisfied immediately. +the kernel may drop some +request or malfunction if one of these allocations fail. +if such a request cannot be satisfied within the current process's cpuset, +then we relax the cpuset, and look for memory anywhere we can find it. +it's better to violate the cpuset than stress the kernel. +.pp +allocations of memory requested by kernel drivers while processing +an interrupt lack any relevant process context, and are not confined +by cpusets. +.ss renaming cpusets +you can use the +.br rename (2) +system call to rename cpusets. +only simple renaming is supported; that is, changing the name of a cpuset +directory is permitted, but moving a directory into +a different directory is not permitted. +.\" ================== errors ================== +.sh errors +the linux kernel implementation of cpusets sets +.i errno +to specify the reason for a failed system call affecting cpusets. +.pp +the possible +.i errno +settings and their meaning when set on +a failed cpuset call are as listed below. +.tp +.b e2big +attempted a +.br write (2) +on a special cpuset file +with a length larger than some kernel-determined upper +limit on the length of such writes. +.tp +.b eacces +attempted to +.br write (2) +the process id (pid) of a process to a cpuset +.i tasks +file when one lacks permission to move that process. +.tp +.b eacces +attempted to add, using +.br write (2), +a cpu or memory node to a cpuset, when that cpu or memory node was +not already in its parent. +.tp +.b eacces +attempted to set, using +.br write (2), +.i cpuset.cpu_exclusive +or +.i cpuset.mem_exclusive +on a cpuset whose parent lacks the same setting. +.tp +.b eacces +attempted to +.br write (2) +a +.i cpuset.memory_pressure +file. +.tp +.b eacces +attempted to create a file in a cpuset directory. +.tp +.b ebusy +attempted to remove, using +.br rmdir (2), +a cpuset with attached processes. +.tp +.b ebusy +attempted to remove, using +.br rmdir (2), +a cpuset with child cpusets. +.tp +.b ebusy +attempted to remove +a cpu or memory node from a cpuset +that is also in a child of that cpuset. +.tp +.b eexist +attempted to create, using +.br mkdir (2), +a cpuset that already exists. +.tp +.b eexist +attempted to +.br rename (2) +a cpuset to a name that already exists. +.tp +.b efault +attempted to +.br read (2) +or +.br write (2) +a cpuset file using +a buffer that is outside the writing processes accessible address space. +.tp +.b einval +attempted to change a cpuset, using +.br write (2), +in a way that would violate a +.i cpu_exclusive +or +.i mem_exclusive +attribute of that cpuset or any of its siblings. +.tp +.b einval +attempted to +.br write (2) +an empty +.i cpuset.cpus +or +.i cpuset.mems +list to a cpuset which has attached processes or child cpusets. +.tp +.b einval +attempted to +.br write (2) +a +.i cpuset.cpus +or +.i cpuset.mems +list which included a range with the second number smaller than +the first number. +.tp +.b einval +attempted to +.br write (2) +a +.i cpuset.cpus +or +.i cpuset.mems +list which included an invalid character in the string. +.tp +.b einval +attempted to +.br write (2) +a list to a +.i cpuset.cpus +file that did not include any online cpus. +.tp +.b einval +attempted to +.br write (2) +a list to a +.i cpuset.mems +file that did not include any online memory nodes. +.tp +.b einval +attempted to +.br write (2) +a list to a +.i cpuset.mems +file that included a node that held no memory. +.tp +.b eio +attempted to +.br write (2) +a string to a cpuset +.i tasks +file that +does not begin with an ascii decimal integer. +.tp +.b eio +attempted to +.br rename (2) +a cpuset into a different directory. +.tp +.b enametoolong +attempted to +.br read (2) +a +.i /proc//cpuset +file for a cpuset path that is longer than the kernel page size. +.tp +.b enametoolong +attempted to create, using +.br mkdir (2), +a cpuset whose base directory name is longer than 255 characters. +.tp +.b enametoolong +attempted to create, using +.br mkdir (2), +a cpuset whose full pathname, +including the mount point (typically "/dev/cpuset/") prefix, +is longer than 4095 characters. +.tp +.b enodev +the cpuset was removed by another process at the same time as a +.br write (2) +was attempted on one of the pseudo-files in the cpuset directory. +.tp +.b enoent +attempted to create, using +.br mkdir (2), +a cpuset in a parent cpuset that doesn't exist. +.tp +.b enoent +attempted to +.br access (2) +or +.br open (2) +a nonexistent file in a cpuset directory. +.tp +.b enomem +insufficient memory is available within the kernel; can occur +on a variety of system calls affecting cpusets, but only if the +system is extremely short of memory. +.tp +.b enospc +attempted to +.br write (2) +the process id (pid) +of a process to a cpuset +.i tasks +file when the cpuset had an empty +.i cpuset.cpus +or empty +.i cpuset.mems +setting. +.tp +.b enospc +attempted to +.br write (2) +an empty +.i cpuset.cpus +or +.i cpuset.mems +setting to a cpuset that +has tasks attached. +.tp +.b enotdir +attempted to +.br rename (2) +a nonexistent cpuset. +.tp +.b eperm +attempted to remove a file from a cpuset directory. +.tp +.b erange +specified a +.i cpuset.cpus +or +.i cpuset.mems +list to the kernel which included a number too large for the kernel +to set in its bit masks. +.tp +.b esrch +attempted to +.br write (2) +the process id (pid) of a nonexistent process to a cpuset +.i tasks +file. +.\" ================== versions ================== +.sh versions +cpusets appeared in version 2.6.12 of the linux kernel. +.\" ================== notes ================== +.sh notes +despite its name, the +.i pid +parameter is actually a thread id, +and each thread in a threaded group can be attached to a different +cpuset. +the value returned from a call to +.br gettid (2) +can be passed in the argument +.ir pid . +.\" ================== bugs ================== +.sh bugs +.i cpuset.memory_pressure +cpuset files can be opened +for writing, creation, or truncation, but then the +.br write (2) +fails with +.i errno +set to +.br eacces , +and the creation and truncation options on +.br open (2) +have no effect. +.\" ================== examples ================== +.sh examples +the following examples demonstrate querying and setting cpuset +options using shell commands. +.ss creating and attaching to a cpuset. +to create a new cpuset and attach the current command shell to it, +the steps are: +.pp +.pd 0 +.ip 1) 4 +mkdir /dev/cpuset (if not already done) +.ip 2) +mount \-t cpuset none /dev/cpuset (if not already done) +.ip 3) +create the new cpuset using +.br mkdir (1). +.ip 4) +assign cpus and memory nodes to the new cpuset. +.ip 5) +attach the shell to the new cpuset. +.pd +.pp +for example, the following sequence of commands will set up a cpuset +named "charlie", containing just cpus 2 and 3, and memory node 1, +and then attach the current shell to that cpuset. +.pp +.in +4n +.ex +.rb "$" " mkdir /dev/cpuset" +.rb "$" " mount \-t cpuset cpuset /dev/cpuset" +.rb "$" " cd /dev/cpuset" +.rb "$" " mkdir charlie" +.rb "$" " cd charlie" +.rb "$" " /bin/echo 2\-3 > cpuset.cpus" +.rb "$" " /bin/echo 1 > cpuset.mems" +.rb "$" " /bin/echo $$ > tasks" +# the current shell is now running in cpuset charlie +# the next line should display \(aq/charlie\(aq +.rb "$" " cat /proc/self/cpuset" +.ee +.in +.\" +.ss migrating a job to different memory nodes. +to migrate a job (the set of processes attached to a cpuset) +to different cpus and memory nodes in the system, including moving +the memory pages currently allocated to that job, +perform the following steps. +.pp +.pd 0 +.ip 1) 4 +let's say we want to move the job in cpuset +.i alpha +(cpus 4\(en7 and memory nodes 2\(en3) to a new cpuset +.i beta +(cpus 16\(en19 and memory nodes 8\(en9). +.ip 2) +first create the new cpuset +.ir beta . +.ip 3) +then allow cpus 16\(en19 and memory nodes 8\(en9 in +.ir beta . +.ip 4) +then enable +.i memory_migration +in +.ir beta . +.ip 5) +then move each process from +.i alpha +to +.ir beta . +.pd +.pp +the following sequence of commands accomplishes this. +.pp +.in +4n +.ex +.rb "$" " cd /dev/cpuset" +.rb "$" " mkdir beta" +.rb "$" " cd beta" +.rb "$" " /bin/echo 16\-19 > cpuset.cpus" +.rb "$" " /bin/echo 8\-9 > cpuset.mems" +.rb "$" " /bin/echo 1 > cpuset.memory_migrate" +.rb "$" " while read i; do /bin/echo $i; done < ../alpha/tasks > tasks" +.ee +.in +.pp +the above should move any processes in +.i alpha +to +.ir beta , +and any memory held by these processes on memory nodes 2\(en3 to memory +nodes 8\(en9, respectively. +.pp +notice that the last step of the above sequence did not do: +.pp +.in +4n +.ex +.rb "$" " cp ../alpha/tasks tasks" +.ee +.in +.pp +the +.i while +loop, rather than the seemingly easier use of the +.br cp (1) +command, was necessary because +only one process pid at a time may be written to the +.i tasks +file. +.pp +the same effect (writing one pid at a time) as the +.i while +loop can be accomplished more efficiently, in fewer keystrokes and in +syntax that works on any shell, but alas more obscurely, by using the +.b \-u +(unbuffered) option of +.br sed (1): +.pp +.in +4n +.ex +.rb "$" " sed \-un p < ../alpha/tasks > tasks" +.ee +.in +.\" ================== see also ================== +.sh see also +.br taskset (1), +.br get_mempolicy (2), +.br getcpu (2), +.br mbind (2), +.br sched_getaffinity (2), +.br sched_setaffinity (2), +.br sched_setscheduler (2), +.br set_mempolicy (2), +.br cpu_set (3), +.br proc (5), +.br cgroups (7), +.br numa (7), +.br sched (7), +.br migratepages (8), +.br numactl (8) +.pp +.ir documentation/admin\-guide/cgroup\-v1/cpusets.rst +in the linux kernel source tree +.\" commit 45ce80fb6b6f9594d1396d44dd7e7c02d596fef8 +(or +.ir documentation/cgroup\-v1/cpusets.txt +before linux 4.18, and +.ir documentation/cpusets.txt +before linux 2.6.29) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/send.2 + +begin3 +title: section 2, 3, 4, 5 and 7 man pages for linux +version: 5.13 +entered-date: 2021-08-27 +description: linux manual pages +keywords: man pages +author: several +maintained-by: michael kerrisk +primary-site: http://www.kernel.org/pub/linux/docs/man-pages + 2825k man-pages-5.13.tar.gz +copying-policy: several; the pages are all freely distributable as long as + nroff source is provided +end + +.so man3/getspnam.3 + +.so man3/copysign.3 + +.so man2/adjtimex.2 + +.\" copyright (c) 2008 linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th pthread_setaffinity_np 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +pthread_setaffinity_np, pthread_getaffinity_np \- set/get +cpu affinity of a thread +.sh synopsis +.nf +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "int pthread_setaffinity_np(pthread_t " thread ", size_t " cpusetsize , +.bi " const cpu_set_t *" cpuset ); +.bi "int pthread_getaffinity_np(pthread_t " thread ", size_t " cpusetsize , +.bi " cpu_set_t *" cpuset ); +.pp +compile and link with \fi\-pthread\fp. +.fi +.sh description +the +.br pthread_setaffinity_np () +function +sets the cpu affinity mask of the thread +.i thread +to the cpu set pointed to by +.ir cpuset . +if the call is successful, +and the thread is not currently running on one of the cpus in +.ir cpuset , +then it is migrated to one of those cpus. +.pp +the +.br pthread_getaffinity_np () +function returns the cpu affinity mask of the thread +.i thread +in the buffer pointed to by +.ir cpuset . +.pp +for more details on cpu affinity masks, see +.br sched_setaffinity (2). +for a description of a set of macros +that can be used to manipulate and inspect cpu sets, see +.br cpu_set (3). +.pp +the argument +.i cpusetsize +is the length (in bytes) of the buffer pointed to by +.ir cpuset . +typically, this argument would be specified as +.ir sizeof(cpu_set_t) . +(it may be some other value, if using the macros described in +.br cpu_set (3) +for dynamically allocating a cpu set.) +.sh return value +on success, these functions return 0; +on error, they return a nonzero error number. +.sh errors +.tp +.b efault +a supplied memory address was invalid. +.tp +.b einval +.rb ( pthread_setaffinity_np ()) +the affinity bit mask +.i mask +contains no processors that are currently physically on the system +and permitted to the thread according to any restrictions that +may be imposed by the "cpuset" mechanism described in +.br cpuset (7). +.tp +.br einval +.rb ( pthread_setaffinity_np ()) +.i cpuset +specified a cpu that was outside the set supported by the kernel. +(the kernel configuration option +.br config_nr_cpus +defines the range of the set supported by the kernel data type +.\" cpumask_t +used to represent cpu sets.) +.\" the raw sched_getaffinity() system call returns the size (in bytes) +.\" of the cpumask_t type. +.tp +.b einval +.rb ( pthread_getaffinity_np ()) +.i cpusetsize +is smaller than the size of the affinity mask used by the kernel. +.tp +.b esrch +no thread with the id +.i thread +could be found. +.sh versions +these functions are provided by glibc since version 2.3.4. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br pthread_setaffinity_np (), +.br pthread_getaffinity_np () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +these functions are nonstandard gnu extensions; +hence the suffix "_np" (nonportable) in the names. +.sh notes +after a call to +.br pthread_setaffinity_np (), +the set of cpus on which the thread will actually run is +the intersection of the set specified in the +.i cpuset +argument and the set of cpus actually present on the system. +the system may further restrict the set of cpus on which the thread +runs if the "cpuset" mechanism described in +.br cpuset (7) +is being used. +these restrictions on the actual set of cpus on which the thread +will run are silently imposed by the kernel. +.pp +these functions are implemented on top of the +.br sched_setaffinity (2) +and +.br sched_getaffinity (2) +system calls. +.pp +in glibc 2.3.3 only, +versions of these functions were provided that did not have a +.i cpusetsize +argument. +instead the cpu set size given to the underlying system calls was always +.ir sizeof(cpu_set_t) . +.pp +a new thread created by +.br pthread_create (3) +inherits a copy of its creator's cpu affinity mask. +.sh examples +in the following program, the main thread uses +.br pthread_setaffinity_np () +to set its cpu affinity mask to include cpus 0 to 7 +(which may not all be available on the system), +and then calls +.br pthread_getaffinity_np () +to check the resulting cpu affinity mask of the thread. +.pp +.ex +#define _gnu_source +#include +#include +#include +#include + +#define handle_error_en(en, msg) \e + do { errno = en; perror(msg); exit(exit_failure); } while (0) + +int +main(int argc, char *argv[]) +{ + int s; + cpu_set_t cpuset; + pthread_t thread; + + thread = pthread_self(); + + /* set affinity mask to include cpus 0 to 7. */ + + cpu_zero(&cpuset); + for (int j = 0; j < 8; j++) + cpu_set(j, &cpuset); + + s = pthread_setaffinity_np(thread, sizeof(cpuset), &cpuset); + if (s != 0) + handle_error_en(s, "pthread_setaffinity_np"); + + /* check the actual affinity mask assigned to the thread. */ + + s = pthread_getaffinity_np(thread, sizeof(cpuset), &cpuset); + if (s != 0) + handle_error_en(s, "pthread_getaffinity_np"); + + printf("set returned by pthread_getaffinity_np() contained:\en"); + for (int j = 0; j < cpu_setsize; j++) + if (cpu_isset(j, &cpuset)) + printf(" cpu %d\en", j); + + exit(exit_success); +} +.ee +.sh see also +.br sched_setaffinity (2), +.br cpu_set (3), +.br pthread_attr_setaffinity_np (3), +.br pthread_self (3), +.br sched_getcpu (3), +.br cpuset (7), +.br pthreads (7), +.br sched (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/wait.2 + +.so man3/xdr.3 + +.so man3/inet.3 + +.so man3/rpc.3 + +.\" copyright (c) 2001 john levon +.\" based in part on gnu libc documentation +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th getline 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +getline, getdelim \- delimited string input +.sh synopsis +.nf +.b #include +.pp +.bi "ssize_t getline(char **restrict " lineptr ", size_t *restrict " n , +.bi " file *restrict " stream ); +.bi "ssize_t getdelim(char **restrict " lineptr ", size_t *restrict " n , +.bi " int " delim ", file *restrict " stream ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br getline (), +.br getdelim (): +.nf + since glibc 2.10: + _posix_c_source >= 200809l + before glibc 2.10: + _gnu_source +.fi +.sh description +.br getline () +reads an entire line from \fistream\fp, +storing the address of the buffer containing the text into +.ir "*lineptr" . +the buffer is null-terminated and includes the newline character, if +one was found. +.pp +if +.i "*lineptr" +is set to null before the call, then +.br getline () +will allocate a buffer for storing the line. +this buffer should be freed by the user program +even if +.br getline () +failed. +.pp +alternatively, before calling +.br getline (), +.i "*lineptr" +can contain a pointer to a +.br malloc (3)\-allocated +buffer +.i "*n" +bytes in size. +if the buffer is not large enough to hold the line, +.br getline () +resizes it with +.br realloc (3), +updating +.i "*lineptr" +and +.i "*n" +as necessary. +.pp +in either case, on a successful call, +.i "*lineptr" +and +.i "*n" +will be updated to reflect the buffer address and allocated size respectively. +.pp +.br getdelim () +works like +.br getline (), +except that a line delimiter other than newline can be specified as the +.i delimiter +argument. +as with +.br getline (), +a delimiter character is not added if one was not present +in the input before end of file was reached. +.sh return value +on success, +.br getline () +and +.br getdelim () +return the number of characters read, including the delimiter character, +but not including the terminating null byte (\(aq\e0\(aq). +this value can be used +to handle embedded null bytes in the line read. +.pp +both functions return \-1 on failure to read a line (including end-of-file +condition). +in the event of a failure, +.i errno +is set to indicate the error. +.sh errors +.tp +.b einval +bad arguments +.ri ( n +or +.i lineptr +is null, or +.i stream +is not valid). +.tp +.b enomem +allocation or reallocation of the line buffer failed. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br getline (), +.br getdelim () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +both +.br getline () +and +.br getdelim () +were originally gnu extensions. +they were standardized in posix.1-2008. +.sh examples +.ex +#define _gnu_source +#include +#include + +int +main(int argc, char *argv[]) +{ + file *stream; + char *line = null; + size_t len = 0; + ssize_t nread; + + if (argc != 2) { + fprintf(stderr, "usage: %s \en", argv[0]); + exit(exit_failure); + } + + stream = fopen(argv[1], "r"); + if (stream == null) { + perror("fopen"); + exit(exit_failure); + } + + while ((nread = getline(&line, &len, stream)) != \-1) { + printf("retrieved line of length %zd:\en", nread); + fwrite(line, nread, 1, stdout); + } + + free(line); + fclose(stream); + exit(exit_success); +} +.ee +.sh see also +.br read (2), +.br fgets (3), +.br fopen (3), +.br fread (3), +.br scanf (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/basename.3 + +.\" copyright (c) 1994,1995 mike battersby +.\" and copyright 2004, 2005 michael kerrisk +.\" based on work by faith@cs.unc.edu +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified, aeb, 960424 +.\" modified fri jan 31 17:31:20 1997 by eric s. raymond +.\" modified thu nov 26 02:12:45 1998 by aeb - add sigchld stuff. +.\" modified sat may 8 17:40:19 1999 by matthew wilcox +.\" add posix.1b signals +.\" modified sat dec 29 01:44:52 2001 by evan jones +.\" sa_onstack +.\" modified 2004-11-11 by michael kerrisk +.\" added mention of sigcont under sa_nocldstop +.\" added sa_nocldwait +.\" modified 2004-11-17 by michael kerrisk +.\" updated discussion for posix.1-2001 and sigchld and sa_flags. +.\" formatting fixes +.\" 2004-12-09, mtk, added si_tkill + other minor changes +.\" 2005-09-15, mtk, split sigpending(), sigprocmask(), sigsuspend() +.\" out of this page into separate pages. +.\" 2010-06-11 andi kleen, add hwpoison signal extensions +.\" 2010-06-11 mtk, improvements to discussion of various siginfo_t fields. +.\" 2015-01-17, kees cook +.\" added notes on ptrace sigtrap and sys_seccomp. +.\" +.th sigaction 2 2021-08-27 "linux" "linux programmer's manual" +.sh name +sigaction, rt_sigaction \- examine and change a signal action +.sh synopsis +.nf +.b #include +.pp +.bi "int sigaction(int " signum ", const struct sigaction *restrict " act , +.bi " struct sigaction *restrict " oldact ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br sigaction (): +.nf + _posix_c_source +.fi +.pp +.ir siginfo_t : +.nf + _posix_c_source >= 199309l +.fi +.sh description +the +.br sigaction () +system call is used to change the action taken by a process on +receipt of a specific signal. +(see +.br signal (7) +for an overview of signals.) +.pp +.i signum +specifies the signal and can be any valid signal except +.b sigkill +and +.br sigstop . +.pp +if +.i act +is non-null, the new action for signal +.i signum +is installed from +.ir act . +if +.i oldact +is non-null, the previous action is saved in +.ir oldact . +.pp +the +.i sigaction +structure is defined as something like: +.pp +.in +4n +.ex +struct sigaction { + void (*sa_handler)(int); + void (*sa_sigaction)(int, siginfo_t *, void *); + sigset_t sa_mask; + int sa_flags; + void (*sa_restorer)(void); +}; +.ee +.in +.pp +on some architectures a union is involved: do not assign to both +.i sa_handler +and +.ir sa_sigaction . +.pp +the +.i sa_restorer +field is not intended for application use. +(posix does not specify a +.i sa_restorer +field.) +some further details of the purpose of this field can be found in +.br sigreturn (2). +.pp +.i sa_handler +specifies the action to be associated with +.i signum +and is be one of the following: +.ip * 2 +.b sig_dfl +for the default action. +.ip * +.b sig_ign +to ignore this signal. +.ip * +a pointer to a signal handling function. +this function receives the signal number as its only argument. +.pp +if +.b sa_siginfo +is specified in +.ir sa_flags , +then +.i sa_sigaction +(instead of +.ir sa_handler ) +specifies the signal-handling function for +.ir signum . +this function receives three arguments, as described below. +.pp +.i sa_mask +specifies a mask of signals which should be blocked +(i.e., added to the signal mask of the thread in which +the signal handler is invoked) +during execution of the signal handler. +in addition, the signal which triggered the handler +will be blocked, unless the +.b sa_nodefer +flag is used. +.pp +.i sa_flags +specifies a set of flags which modify the behavior of the signal. +it is formed by the bitwise or of zero or more of the following: +.tp +.b sa_nocldstop +if +.i signum +is +.br sigchld , +do not receive notification when child processes stop (i.e., when they +receive one of +.br sigstop ", " sigtstp ", " sigttin , +or +.br sigttou ) +or resume (i.e., they receive +.br sigcont ) +(see +.br wait (2)). +this flag is meaningful only when establishing a handler for +.br sigchld . +.tp +.br sa_nocldwait " (since linux 2.6)" +.\" to be precise: linux 2.5.60 -- mtk +if +.i signum +is +.br sigchld , +do not transform children into zombies when they terminate. +see also +.br waitpid (2). +this flag is meaningful only when establishing a handler for +.br sigchld , +or when setting that signal's disposition to +.br sig_dfl . +.ip +if the +.b sa_nocldwait +flag is set when establishing a handler for +.br sigchld , +posix.1 leaves it unspecified whether a +.b sigchld +signal is generated when a child process terminates. +on linux, a +.b sigchld +signal is generated in this case; +on some other implementations, it is not. +.tp +.b sa_nodefer +do not add the signal to the thread's signal mask while the +handler is executing, unless the signal is specified in +.ir act.sa_mask . +consequently, a further instance of the signal may be delivered +to the thread while it is executing the handler. +this flag is meaningful only when establishing a signal handler. +.ip +.b sa_nomask +is an obsolete, nonstandard synonym for this flag. +.tp +.b sa_onstack +call the signal handler on an alternate signal stack provided by +.br sigaltstack (2). +if an alternate stack is not available, the default stack will be used. +this flag is meaningful only when establishing a signal handler. +.tp +.br sa_resethand +restore the signal action to the default upon entry to the signal handler. +this flag is meaningful only when establishing a signal handler. +.ip +.b sa_oneshot +is an obsolete, nonstandard synonym for this flag. +.tp +.b sa_restart +provide behavior compatible with bsd signal semantics by making certain +system calls restartable across signals. +this flag is meaningful only when establishing a signal handler. +see +.br signal (7) +for a discussion of system call restarting. +.tp +.br sa_restorer +.ir "not intended for application use" . +this flag is used by c libraries to indicate that the +.ir sa_restorer +field contains the address of a "signal trampoline". +see +.br sigreturn (2) +for more details. +.tp +.br sa_siginfo " (since linux 2.2)" +the signal handler takes three arguments, not one. +in this case, +.i sa_sigaction +should be set instead of +.ir sa_handler . +this flag is meaningful only when establishing a signal handler. +.\" (the +.\" .i sa_sigaction +.\" field was added in linux 2.1.86.) +.\" +.tp +.br sa_unsupported " (since linux 5.11)" +used to dynamically probe for flag bit support. +.ip +if an attempt to register a handler succeeds with this flag set in +.i act\->sa_flags +alongside other flags that are potentially unsupported by the kernel, +and an immediately subsequent +.br sigaction () +call specifying the same signal number and with a non-null +.i oldact +argument yields +.b sa_unsupported +.i clear +in +.ir oldact->sa_flags , +then +.i oldact->sa_flags +may be used as a bitmask +describing which of the potentially unsupported flags are, +in fact, supported. +see the section "dynamically probing for flag bit support" +below for more details. +.tp +.br sa_expose_tagbits " (since linux 5.11)" +normally, when delivering a signal, +an architecture-specific set of tag bits are cleared from the +.i si_addr +field of +.ir siginfo_t . +if this flag is set, +an architecture-specific subset of the tag bits will be preserved in +.ir si_addr . +.ip +programs that need to be compatible with linux versions older than 5.11 +must use +.b sa_unsupported +to probe for support. +.ss the siginfo_t argument to a sa_siginfo handler +when the +.b sa_siginfo +flag is specified in +.ir act.sa_flags , +the signal handler address is passed via the +.ir act.sa_sigaction +field. +this handler takes three arguments, as follows: +.pp +.in +4n +.ex +void +handler(int sig, siginfo_t *info, void *ucontext) +{ + ... +} +.ee +.in +.pp +these three arguments are as follows +.tp +.i sig +the number of the signal that caused invocation of the handler. +.tp +.i info +a pointer to a +.ir siginfo_t , +which is a structure containing further information about the signal, +as described below. +.tp +.i ucontext +this is a pointer to a +.i ucontext_t +structure, cast to \fivoid\ *\fp. +the structure pointed to by this field contains +signal context information that was saved +on the user-space stack by the kernel; for details, see +.br sigreturn (2). +further information about the +.ir ucontext_t +structure can be found in +.br getcontext (3) +and +.br signal (7). +commonly, the handler function doesn't make any use of the third argument. +.pp +the +.i siginfo_t +data type is a structure with the following fields: +.pp +.in +4n +.ex +siginfo_t { + int si_signo; /* signal number */ + int si_errno; /* an errno value */ + int si_code; /* signal code */ + int si_trapno; /* trap number that caused + hardware\-generated signal + (unused on most architectures) */ +.\" fixme +.\" the siginfo_t 'si_trapno' field seems to be used +.\" only on sparc and alpha; this page could use +.\" a little more detail on its purpose there. + pid_t si_pid; /* sending process id */ + uid_t si_uid; /* real user id of sending process */ + int si_status; /* exit value or signal */ + clock_t si_utime; /* user time consumed */ + clock_t si_stime; /* system time consumed */ + union sigval si_value; /* signal value */ + int si_int; /* posix.1b signal */ + void *si_ptr; /* posix.1b signal */ + int si_overrun; /* timer overrun count; + posix.1b timers */ + int si_timerid; /* timer id; posix.1b timers */ +.\" in the kernel: si_tid + void *si_addr; /* memory location which caused fault */ + long si_band; /* band event (was \fiint\fp in + glibc 2.3.2 and earlier) */ + int si_fd; /* file descriptor */ + short si_addr_lsb; /* least significant bit of address + (since linux 2.6.32) */ + void *si_lower; /* lower bound when address violation + occurred (since linux 3.19) */ + void *si_upper; /* upper bound when address violation + occurred (since linux 3.19) */ + int si_pkey; /* protection key on pte that caused + fault (since linux 4.6) */ + void *si_call_addr; /* address of system call instruction + (since linux 3.5) */ + int si_syscall; /* number of attempted system call + (since linux 3.5) */ + unsigned int si_arch; /* architecture of attempted system call + (since linux 3.5) */ +} +.ee +.in +.pp +.ir si_signo ", " si_errno " and " si_code +are defined for all signals. +.ri ( si_errno +is generally unused on linux.) +the rest of the struct may be a union, so that one should +read only the fields that are meaningful for the given signal: +.ip * 2 +signals sent with +.br kill (2) +and +.br sigqueue (3) +fill in +.ir si_pid " and " si_uid . +in addition, signals sent with +.br sigqueue (3) +fill in +.ir si_int " and " si_ptr +with the values specified by the sender of the signal; +see +.br sigqueue (3) +for more details. +.ip * +signals sent by posix.1b timers (since linux 2.6) fill in +.i si_overrun +and +.ir si_timerid . +the +.i si_timerid +field is an internal id used by the kernel to identify +the timer; it is not the same as the timer id returned by +.br timer_create (2). +the +.i si_overrun +field is the timer overrun count; +this is the same information as is obtained by a call to +.br timer_getoverrun (2). +these fields are nonstandard linux extensions. +.ip * +signals sent for message queue notification (see the description of +.b sigev_signal +in +.br mq_notify (3)) +fill in +.ir si_int / si_ptr , +with the +.i sigev_value +supplied to +.br mq_notify (3); +.ir si_pid , +with the process id of the message sender; and +.ir si_uid , +with the real user id of the message sender. +.ip * +.b sigchld +fills in +.ir si_pid ", " si_uid ", " si_status ", " si_utime ", and " si_stime , +providing information about the child. +the +.i si_pid +field is the process id of the child; +.i si_uid +is the child's real user id. +the +.i si_status +field contains the exit status of the child (if +.i si_code +is +.br cld_exited ), +or the signal number that caused the process to change state. +the +.i si_utime +and +.i si_stime +contain the user and system cpu time used by the child process; +these fields do not include the times used by waited-for children (unlike +.br getrusage (2) +and +.br times (2)). +in kernels up to 2.6, and since 2.6.27, these fields report +cpu time in units of +.ir sysconf(_sc_clk_tck) . +in 2.6 kernels before 2.6.27, +a bug meant that these fields reported time in units +of the (configurable) system jiffy (see +.br time (7)). +.\" fixme . +.\" when si_utime and si_stime where originally implemented, the +.\" measurement unit was hz, which was the same as clock ticks +.\" (sysconf(_sc_clk_tck)). in 2.6, hz became configurable, and +.\" was *still* used as the unit to return the info these fields, +.\" with the result that the field values depended on the +.\" configured hz. of course, the should have been measured in +.\" user_hz instead, so that sysconf(_sc_clk_tck) could be used to +.\" convert to seconds. i have a queued patch to fix this: +.\" http://thread.gmane.org/gmane.linux.kernel/698061/ . +.\" this patch made it into 2.6.27. +.\" but note that these fields still don't return the times of +.\" waited-for children (as is done by getrusage() and times() +.\" and wait4()). solaris 8 does include child times. +.ip * +.br sigill , +.br sigfpe , +.br sigsegv , +.br sigbus , +and +.br sigtrap +fill in +.i si_addr +with the address of the fault. +on some architectures, +these signals also fill in the +.i si_trapno +field. +.ip +some suberrors of +.br sigbus , +in particular +.b bus_mceerr_ao +and +.br bus_mceerr_ar , +also fill in +.ir si_addr_lsb . +this field indicates the least significant bit of the reported address +and therefore the extent of the corruption. +for example, if a full page was corrupted, +.i si_addr_lsb +contains +.ir log2(sysconf(_sc_pagesize)) . +when +.br sigtrap +is delivered in response to a +.br ptrace (2) +event (ptrace_event_foo), +.i si_addr +is not populated, but +.i si_pid +and +.i si_uid +are populated with the respective process id and user id responsible for +delivering the trap. +in the case of +.br seccomp (2), +the tracee will be shown as delivering the event. +.b bus_mceerr_* +and +.i si_addr_lsb +are linux-specific extensions. +.ip +the +.br segv_bnderr +suberror of +.b sigsegv +populates +.ir si_lower +and +.ir si_upper . +.ip +the +.br segv_pkuerr +suberror of +.b sigsegv +populates +.ir si_pkey . +.ip * +.br sigio / sigpoll +(the two names are synonyms on linux) +fills in +.ir si_band " and " si_fd . +the +.i si_band +event is a bit mask containing the same values as are filled in the +.i revents +field by +.br poll (2). +the +.i si_fd +field indicates the file descriptor for which the i/o event occurred; +for further details, see the description of +.br f_setsig +in +.br fcntl (2). +.ip * +.br sigsys , +generated (since linux 3.5) +.\" commit a0727e8ce513fe6890416da960181ceb10fbfae6 +when a seccomp filter returns +.br seccomp_ret_trap , +fills in +.ir si_call_addr , +.ir si_syscall , +.ir si_arch , +.ir si_errno , +and other fields as described in +.br seccomp (2). +.\" +.ss +the si_code field +the +.i si_code +field inside the +.i siginfo_t +argument that is passed to a +.b sa_siginfo +signal handler is a value (not a bit mask) +indicating why this signal was sent. +for a +.br ptrace (2) +event, +.i si_code +will contain +.br sigtrap +and have the ptrace event in the high byte: +.pp +.in +4n +.ex +(sigtrap | ptrace_event_foo << 8). +.ee +.in +.pp +for a +.rb non- ptrace (2) +event, the values that can appear in +.i si_code +are described in the remainder of this section. +since glibc 2.20, +the definitions of most of these symbols are obtained from +.i +by defining feature test macros (before including +.i any +header file) as follows: +.ip * 3 +.b _xopen_source +with the value 500 or greater; +.ip * +.b _xopen_source +and +.br _xopen_source_extended ; +or +.ip * +.b _posix_c_source +with the value 200809l or greater. +.pp +for the +.b trap_* +constants, the symbol definitions are provided only in the first two cases. +before glibc 2.20, no feature test macros were required to obtain these symbols. +.pp +for a regular signal, the following list shows the values which can be +placed in +.i si_code +for any signal, along with the reason that the signal was generated. +.rs 4 +.tp +.b si_user +.br kill (2). +.tp +.b si_kernel +sent by the kernel. +.tp +.b si_queue +.br sigqueue (3). +.tp +.b si_timer +posix timer expired. +.tp +.br si_mesgq " (since linux 2.6.6)" +posix message queue state changed; see +.br mq_notify (3). +.tp +.b si_asyncio +aio completed. +.tp +.b si_sigio +queued +.b sigio +(only in kernels up to linux 2.2; from linux 2.4 onward +.br sigio / sigpoll +fills in +.i si_code +as described below). +.tp +.br si_tkill " (since linux 2.4.19)" +.br tkill (2) +or +.br tgkill (2). +.\" si_dethread is defined in 2.6.9 sources, but isn't implemented +.\" it appears to have been an idea that was tried during 2.5.6 +.\" through to 2.5.24 and then was backed out. +.re +.pp +the following values can be placed in +.i si_code +for a +.b sigill +signal: +.rs 4 +.tp +.b ill_illopc +illegal opcode. +.tp +.b ill_illopn +illegal operand. +.tp +.b ill_illadr +illegal addressing mode. +.tp +.b ill_illtrp +illegal trap. +.tp +.b ill_prvopc +privileged opcode. +.tp +.b ill_prvreg +privileged register. +.tp +.b ill_coproc +coprocessor error. +.tp +.b ill_badstk +internal stack error. +.re +.pp +the following values can be placed in +.i si_code +for a +.b sigfpe +signal: +.rs 4 +.tp +.b fpe_intdiv +integer divide by zero. +.tp +.b fpe_intovf +integer overflow. +.tp +.b fpe_fltdiv +floating-point divide by zero. +.tp +.b fpe_fltovf +floating-point overflow. +.tp +.b fpe_fltund +floating-point underflow. +.tp +.b fpe_fltres +floating-point inexact result. +.tp +.b fpe_fltinv +floating-point invalid operation. +.tp +.b fpe_fltsub +subscript out of range. +.re +.pp +the following values can be placed in +.i si_code +for a +.b sigsegv +signal: +.rs 4 +.tp +.b segv_maperr +address not mapped to object. +.tp +.b segv_accerr +invalid permissions for mapped object. +.tp +.br segv_bnderr " (since linux 3.19)" +.\" commit ee1b58d36aa1b5a79eaba11f5c3633c88231da83 +failed address bound checks. +.tp +.br segv_pkuerr " (since linux 4.6)" +.\" commit cd0ea35ff5511cde299a61c21a95889b4a71464e +access was denied by memory protection keys. +see +.br pkeys (7). +the protection key which applied to this access is available via +.ir si_pkey . +.re +.pp +the following values can be placed in +.i si_code +for a +.b sigbus +signal: +.rs 4 +.tp +.b bus_adraln +invalid address alignment. +.tp +.b bus_adrerr +nonexistent physical address. +.tp +.b bus_objerr +object-specific hardware error. +.tp +.br bus_mceerr_ar " (since linux 2.6.32)" +hardware memory error consumed on a machine check; action required. +.tp +.br bus_mceerr_ao " (since linux 2.6.32)" +hardware memory error detected in process but not consumed; action optional. +.re +.pp +the following values can be placed in +.i si_code +for a +.b sigtrap +signal: +.rs 4 +.tp +.b trap_brkpt +process breakpoint. +.tp +.b trap_trace +process trace trap. +.tp +.br trap_branch " (since linux 2.4, ia64 only)" +process taken branch trap. +.tp +.br trap_hwbkpt " (since linux 2.4, ia64 only)" +hardware breakpoint/watchpoint. +.re +.pp +the following values can be placed in +.i si_code +for a +.b sigchld +signal: +.rs 4 +.tp +.b cld_exited +child has exited. +.tp +.b cld_killed +child was killed. +.tp +.b cld_dumped +child terminated abnormally. +.tp +.b cld_trapped +traced child has trapped. +.tp +.b cld_stopped +child has stopped. +.tp +.br cld_continued " (since linux 2.6.9)" +stopped child has continued. +.re +.pp +the following values can be placed in +.i si_code +for a +.br sigio / sigpoll +signal: +.rs 4 +.tp +.b poll_in +data input available. +.tp +.b poll_out +output buffers available. +.tp +.b poll_msg +input message available. +.tp +.b poll_err +i/o error. +.tp +.b poll_pri +high priority input available. +.tp +.b poll_hup +device disconnected. +.re +.pp +the following value can be placed in +.i si_code +for a +.br sigsys +signal: +.rs 4 +.tp +.br sys_seccomp " (since linux 3.5)" +triggered by a +.br seccomp (2) +filter rule. +.re +.ss dynamically probing for flag bit support +the +.br sigaction () +call on linux accepts unknown bits set in +.i act\->sa_flags +without error. +the behavior of the kernel starting with linux 5.11 is that a second +.br sigaction () +will clear unknown bits from +.ir oldact\->sa_flags . +however, historically, a second +.br sigaction () +call would typically leave those bits set in +.ir oldact\->sa_flags . +.pp +this means that support for new flags cannot be detected +simply by testing for a flag in +.ir sa_flags , +and a program must test that +.b sa_unsupported +has been cleared before relying on the contents of +.ir sa_flags . +.pp +since the behavior of the signal handler cannot be guaranteed +unless the check passes, +it is wise to either block the affected signal +while registering the handler and performing the check in this case, +or where this is not possible, +for example if the signal is synchronous, to issue the second +.br sigaction () +in the signal handler itself. +.pp +in kernels that do not support a specific flag, +the kernel's behavior is as if the flag was not set, +even if the flag was set in +.ir act\->sa_flags . +.pp +the flags +.br sa_nocldstop , +.br sa_nocldwait , +.br sa_siginfo , +.br sa_onstack , +.br sa_restart , +.br sa_nodefer , +.br sa_resethand , +and, if defined by the architecture, +.b sa_restorer +may not be reliably probed for using this mechanism, +because they were introduced before linux 5.11. +however, in general, programs may assume that these flags are supported, +since they have all been supported since linux 2.6, +which was released in the year 2003. +.pp +see examples below for a demonstration of the use of +.br sa_unsupported . +.sh return value +.br sigaction () +returns 0 on success; on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b efault +.ir act " or " oldact +points to memory which is not a valid part of the process address space. +.tp +.b einval +an invalid signal was specified. +this will also be generated if an attempt +is made to change the action for +.br sigkill " or " sigstop , +which cannot be caught or ignored. +.sh conforming to +posix.1-2001, posix.1-2008, svr4. +.\" svr4 does not document the eintr condition. +.sh notes +a child created via +.br fork (2) +inherits a copy of its parent's signal dispositions. +during an +.br execve (2), +the dispositions of handled signals are reset to the default; +the dispositions of ignored signals are left unchanged. +.pp +according to posix, the behavior of a process is undefined after it +ignores a +.br sigfpe , +.br sigill , +or +.b sigsegv +signal that was not generated by +.br kill (2) +or +.br raise (3). +integer division by zero has undefined result. +on some architectures it will generate a +.b sigfpe +signal. +(also dividing the most negative integer by \-1 may generate +.br sigfpe .) +ignoring this signal might lead to an endless loop. +.pp +posix.1-1990 disallowed setting the action for +.b sigchld +to +.br sig_ign . +posix.1-2001 and later allow this possibility, so that ignoring +.b sigchld +can be used to prevent the creation of zombies (see +.br wait (2)). +nevertheless, the historical bsd and system\ v behaviors for ignoring +.b sigchld +differ, so that the only completely portable method of ensuring that +terminated children do not become zombies is to catch the +.b sigchld +signal and perform a +.br wait (2) +or similar. +.pp +posix.1-1990 specified only +.br sa_nocldstop . +posix.1-2001 added +.br sa_nocldstop , +.br sa_nocldwait , +.br sa_nodefer , +.br sa_onstack , +.br sa_resethand , +.br sa_restart , +and +.br sa_siginfo . +use of these latter values in +.i sa_flags +may be less portable in applications intended for older +unix implementations. +.pp +the +.b sa_resethand +flag is compatible with the svr4 flag of the same name. +.pp +the +.b sa_nodefer +flag is compatible with the svr4 flag of the same name under kernels +1.3.9 and later. +on older kernels the linux implementation +allowed the receipt of any signal, not just the one we are installing +(effectively overriding any +.i sa_mask +settings). +.pp +.br sigaction () +can be called with a null second argument to query the current signal +handler. +it can also be used to check whether a given signal is valid for +the current machine by calling it with null second and third arguments. +.pp +it is not possible to block +.br sigkill " or " sigstop +(by specifying them in +.ir sa_mask ). +attempts to do so are silently ignored. +.pp +see +.br sigsetops (3) +for details on manipulating signal sets. +.pp +see +.br signal\-safety (7) +for a list of the async-signal-safe functions that can be +safely called inside from inside a signal handler. +.\" +.ss c library/kernel differences +the glibc wrapper function for +.br sigaction () +gives an error +.rb ( einval ) +on attempts to change the disposition of the two real-time signals +used internally by the nptl threading implementation. +see +.br nptl (7) +for details. +.pp +on architectures where the signal trampoline resides in the c library, +the glibc wrapper function for +.br sigaction () +places the address of the trampoline code in the +.i act.sa_restorer +field and sets the +.b sa_restorer +flag in the +.ir act.sa_flags +field. +see +.br sigreturn (2). +.pp +the original linux system call was named +.br sigaction (). +however, with the addition of real-time signals in linux 2.2, +the fixed-size, 32-bit +.ir sigset_t +type supported by that system call was no longer fit for purpose. +consequently, a new system call, +.br rt_sigaction (), +was added to support an enlarged +.ir sigset_t +type. +the new system call takes a fourth argument, +.ir "size_t sigsetsize" , +which specifies the size in bytes of the signal sets in +.ir act.sa_mask +and +.ir oldact.sa_mask . +this argument is currently required to have the value +.ir sizeof(sigset_t) +(or the error +.b einval +results). +the glibc +.br sigaction () +wrapper function hides these details from us, transparently calling +.br rt_sigaction () +when the kernel provides it. +.\" +.ss undocumented +before the introduction of +.br sa_siginfo , +it was also possible to get some additional information about the signal. +this was done by providing an +.i sa_handler +signal handler with a second argument of type +.ir "struct sigcontext" , +which is the same structure as the one that is passed in the +.i uc_mcontext +field of the +.i ucontext +structure that is passed (via a pointer) in the third argument of the +.i sa_sigaction +handler. +see the relevant linux kernel sources for details. +this use is obsolete now. +.sh bugs +when delivering a signal with a +.b sa_siginfo +handler, +the kernel does not always provide meaningful values +for all of the fields of the +.i siginfo_t +that are relevant for that signal. +.pp +in kernels up to and including 2.6.13, specifying +.b sa_nodefer +in +.i sa_flags +prevents not only the delivered signal from being masked during +execution of the handler, but also the signals specified in +.ir sa_mask . +this bug was fixed in kernel 2.6.14. +.\" commit 69be8f189653cd81aae5a74e26615b12871bb72e +.sh examples +see +.br mprotect (2). +.ss probing for flag support +the following example program exits with status +.b exit_success +if +.b sa_expose_tagbits +is determined to be supported, and +.b exit_failure +otherwise. +.pp +.ex +#include +#include +#include +#include + +void +handler(int signo, siginfo_t *info, void *context) +{ + struct sigaction oldact; + + if (sigaction(sigsegv, null, &oldact) == \-1 || + (oldact.sa_flags & sa_unsupported) || + !(oldact.sa_flags & sa_expose_tagbits)) { + _exit(exit_failure); + } + _exit(exit_success); +} + +int +main(void) +{ + struct sigaction act = { 0 }; + + act.sa_flags = sa_siginfo | sa_unsupported | sa_expose_tagbits; + act.sa_sigaction = &handler; + if (sigaction(sigsegv, &act, null) == \-1) { + perror("sigaction"); + exit(exit_failure); + } + + raise(sigsegv); +} +.ee +.sh see also +.br kill (1), +.br kill (2), +.br pause (2), +.br pidfd_send_signal (2), +.br restart_syscall (2), +.br seccomp (2), +.br sigaltstack (2), +.br signal (2), +.br signalfd (2), +.br sigpending (2), +.br sigprocmask (2), +.br sigreturn (2), +.br sigsuspend (2), +.br wait (2), +.br killpg (3), +.br raise (3), +.br siginterrupt (3), +.br sigqueue (3), +.br sigsetops (3), +.br sigvec (3), +.br core (5), +.br signal (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 2004 andries brouwer . +.\" and copyright 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" inspired by a page by walter harms created 2002-08-10 +.\" +.th ilogb 3 2021-03-22 "" "linux programmer's manual" +.sh name +ilogb, ilogbf, ilogbl \- get integer exponent of a floating-point value +.sh synopsis +.nf +.b #include +.pp +.bi "int ilogb(double " x ); +.bi "int ilogbf(float " x ); +.bi "int ilogbl(long double " x ); +.fi +.pp +link with \fi\-lm\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br ilogb (): +.nf + _isoc99_source || _posix_c_source >= 200112l + || _xopen_source >= 500 +.\" || _xopen_source && _xopen_source_extended + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.pp +.br ilogbf (), +.br ilogbl (): +.nf + _isoc99_source || _posix_c_source >= 200112l + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.sh description +these functions return the exponent part of their argument +as a signed integer. +when no error occurs, these functions +are equivalent to the corresponding +.br logb (3) +functions, cast to +.ir int . +.sh return value +on success, these functions return the exponent of +.ir x , +as a signed integer. +.pp +if +.i x +is zero, then a domain error occurs, and the functions return +.\" the posix.1 spec for logb() says logb() gives pole error for this +.\" case, but for ilogb() it says domain error. +.br fp_ilogb0 . +.\" glibc: the numeric value is either `int_min' or `-int_max'. +.pp +if +.i x +is a nan, then a domain error occurs, and the functions return +.br fp_ilogbnan . +.\" glibc: the numeric value is either `int_min' or `int_max'. +.\" on i386, fp_ilogb0 and fp_ilogbnan have the same value. +.pp +if +.i x +is negative infinity or positive infinity, then +a domain error occurs, and the functions return +.br int_max . +.\" +.\" posix.1-2001 also says: +.\" if the correct value is greater than {int_max}, {int_max} +.\" shall be returned and a domain error shall occur. +.\" +.\" if the correct value is less than {int_min}, {int_min} +.\" shall be returned and a domain error shall occur. +.sh errors +see +.br math_error (7) +for information on how to determine whether an error has occurred +when calling these functions. +.pp +the following errors can occur: +.tp +domain error: \fix\fp is 0 or a nan +an invalid floating-point exception +.rb ( fe_invalid ) +is raised, and +.i errno +is set to +.br edom +(but see bugs). +.tp +domain error: \fix\fp is an infinity +an invalid floating-point exception +.rb ( fe_invalid ) +is raised, and +.i errno +is set to +.br edom +(but see bugs). +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br ilogb (), +.br ilogbf (), +.br ilogbl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.sh bugs +.\" bug raised: http://sources.redhat.com/bugzilla/show_bug.cgi?id=6794 +before version 2.16, the following bugs existed in the +glibc implementation of these functions: +.ip * 3 +the domain error case where +.i x +is 0 or a nan did not cause +.i errno +to be set or (on some architectures) raise a floating-point exception. +.ip * 3 +the domain error case where +.i x +is an infinity did not cause +.i errno +to be set or raise a floating-point exception. +.sh see also +.br log (3), +.br logb (3), +.br significand (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/glob.3 + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" iso/iec 9899:1999 +.\" +.th iswdigit 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +iswdigit \- test for decimal digit wide character +.sh synopsis +.nf +.b #include +.pp +.bi "int iswdigit(wint_t " wc ); +.fi +.sh description +the +.br iswdigit () +function is the wide-character equivalent of the +.br isdigit (3) +function. +it tests whether +.i wc +is a wide character +belonging to the wide-character class "digit". +.pp +the wide-character class "digit" is a subclass of the wide-character class +"xdigit", and therefore also a subclass +of the wide-character class "alnum", of +the wide-character class "graph" and of the wide-character class "print". +.pp +being a subclass of the wide character +class "print", the wide-character class +"digit" is disjoint from the wide-character class "cntrl". +.pp +being a subclass of the wide-character class "graph", +the wide-character class +"digit" is disjoint from the wide-character class "space" and its subclass +"blank". +.pp +being a subclass of the wide-character +class "alnum", the wide-character class +"digit" is disjoint from the wide-character class "punct". +.pp +the wide-character class "digit" is +disjoint from the wide-character class +"alpha" and therefore also disjoint from its subclasses "lower", "upper". +.pp +the wide-character class "digit" always +contains exactly the digits \(aq0\(aq to \(aq9\(aq. +.sh return value +the +.br iswdigit () +function returns nonzero +if +.i wc +is a wide character +belonging to the wide-character class "digit". +otherwise, it returns zero. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br iswdigit () +t} thread safety mt-safe locale +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh notes +the behavior of +.br iswdigit () +depends on the +.b lc_ctype +category of the +current locale. +.sh see also +.br isdigit (3), +.br iswctype (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2003 andries brouwer (aeb@cwi.nl) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" the pathconf note is from walter harms +.\" this is not a system call on linux +.\" +.\" modified 2004-06-23 by michael kerrisk +.\" +.th statvfs 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +statvfs, fstatvfs \- get filesystem statistics +.sh synopsis +.nf +.b #include +.pp +.bi "int statvfs(const char *restrict " path \ +", struct statvfs *restrict " buf ); +.bi "int fstatvfs(int " fd ", struct statvfs *" buf ); +.fi +.sh description +the function +.br statvfs () +returns information about a mounted filesystem. +.i path +is the pathname of any file within the mounted filesystem. +.i buf +is a pointer to a +.i statvfs +structure defined approximately as follows: +.pp +.in +4n +.ex +struct statvfs { + unsigned long f_bsize; /* filesystem block size */ + unsigned long f_frsize; /* fragment size */ + fsblkcnt_t f_blocks; /* size of fs in f_frsize units */ + fsblkcnt_t f_bfree; /* number of free blocks */ + fsblkcnt_t f_bavail; /* number of free blocks for + unprivileged users */ + fsfilcnt_t f_files; /* number of inodes */ + fsfilcnt_t f_ffree; /* number of free inodes */ + fsfilcnt_t f_favail; /* number of free inodes for + unprivileged users */ + unsigned long f_fsid; /* filesystem id */ + unsigned long f_flag; /* mount flags */ + unsigned long f_namemax; /* maximum filename length */ +}; +.ee +.in +.pp +here the types +.i fsblkcnt_t +and +.i fsfilcnt_t +are defined in +.ir . +both used to be +.ir "unsigned long" . +.pp +the field +.i f_flag +is a bit mask indicating various options that were employed +when mounting this filesystem. +it contains zero or more of the following flags: +.\" xxx keep this list in sync with statfs(2) +.tp +.b st_mandlock +mandatory locking is permitted on the filesystem (see +.br fcntl (2)). +.tp +.b st_noatime +do not update access times; see +.br mount (2). +.tp +.b st_nodev +disallow access to device special files on this filesystem. +.tp +.b st_nodiratime +do not update directory access times; see +.br mount (2). +.tp +.b st_noexec +execution of programs is disallowed on this filesystem. +.tp +.b st_nosuid +the set-user-id and set-group-id bits are ignored by +.br exec (3) +for executable files on this filesystem +.tp +.b st_rdonly +this filesystem is mounted read-only. +.tp +.b st_relatime +update atime relative to mtime/ctime; see +.br mount (2). +.tp +.b st_synchronous +writes are synched to the filesystem immediately (see the description of +.b o_sync +in +.br open (2)). +.pp +it is unspecified whether all members of the returned struct +have meaningful values on all filesystems. +.pp +.br fstatvfs () +returns the same information about an open file referenced by descriptor +.ir fd . +.sh return value +on success, zero is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eacces +.rb ( statvfs ()) +search permission is denied for a component of the path prefix of +.ir path . +(see also +.br path_resolution (7).) +.tp +.b ebadf +.rb ( fstatvfs ()) +.i fd +is not a valid open file descriptor. +.tp +.b efault +.i buf +or +.i path +points to an invalid address. +.tp +.b eintr +this call was interrupted by a signal; see +.br signal (7). +.tp +.b eio +an i/o error occurred while reading from the filesystem. +.tp +.b eloop +.rb ( statvfs ()) +too many symbolic links were encountered in translating +.ir path . +.tp +.b enametoolong +.rb ( statvfs ()) +.i path +is too long. +.tp +.b enoent +.rb ( statvfs ()) +the file referred to by +.i path +does not exist. +.tp +.b enomem +insufficient kernel memory was available. +.tp +.b enosys +the filesystem does not support this call. +.tp +.b enotdir +.rb ( statvfs ()) +a component of the path prefix of +.i path +is not a directory. +.tp +.b eoverflow +some values were too large to be represented in the returned struct. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br statvfs (), +.br fstatvfs () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.pp +only the +.b st_nosuid +and +.b st_rdonly +flags of the +.i f_flag +field are specified in posix.1. +to obtain definitions of the remaining flags, one must define +.br _gnu_source . +.sh notes +the linux kernel has system calls +.br statfs (2) +and +.br fstatfs (2) +to support this library call. +.pp +in glibc versions before 2.13, +.\" glibc commit 3cdaa6adb113a088fdfb87aa6d7747557eccc58d +.br statvfs () +populated the bits of the +.ir f_flag +field by scanning the mount options shown in +.ir /proc/mounts . +however, starting with linux 2.6.36, the underlying +.br statfs (2) +system call provides the necessary information via the +.ir f_flags +field, and since glibc version 2.13, the +.br statvfs () +function will use information from that field rather than scanning +.ir /proc/mounts . +.pp +the glibc implementations of +.pp +.in +4n +.ex +pathconf(path, _pc_rec_xfer_align); +pathconf(path, _pc_alloc_size_min); +pathconf(path, _pc_rec_min_xfer_size); +.ee +.in +.pp +respectively use the +.ir f_frsize , +.ir f_frsize , +and +.i f_bsize +fields returned by a call to +.br statvfs () +with the argument +.ir path . +.sh see also +.br statfs (2) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/circleq.3 + +.so man2/ftruncate.2 + +.so man3/scanf.3 + +.\" copyright (c) 1990, 1991 the regents of the university of california. +.\" all rights reserved. +.\" +.\" this code is derived from software contributed to berkeley by +.\" the american national standards committee x3, on information +.\" processing systems. +.\" +.\" %%%license_start(bsd_4_clause_ucb) +.\" redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. all advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" this product includes software developed by the university of +.\" california, berkeley and its contributors. +.\" 4. neither the name of the university nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" this software is provided by the regents and contributors ``as is'' and +.\" any express or implied warranties, including, but not limited to, the +.\" implied warranties of merchantability and fitness for a particular purpose +.\" are disclaimed. in no event shall the regents or contributors be liable +.\" for any direct, indirect, incidental, special, exemplary, or consequential +.\" damages (including, but not limited to, procurement of substitute goods +.\" or services; loss of use, data, or profits; or business interruption) +.\" however caused and on any theory of liability, whether in contract, strict +.\" liability, or tort (including negligence or otherwise) arising in any way +.\" out of the use of this software, even if advised of the possibility of +.\" such damage. +.\" %%%license_end +.\" +.\" @(#)strtod.3 5.3 (berkeley) 6/29/91 +.\" +.\" modified sun aug 21 17:16:22 1994 by rik faith (faith@cs.unc.edu) +.\" modified sat may 04 19:34:31 met dst 1996 by michael haardt +.\" (michael@cantor.informatik.rwth-aachen.de) +.\" added strof, strtold, aeb, 2001-06-07 +.\" +.th strtod 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +strtod, strtof, strtold \- convert ascii string to floating-point number +.sh synopsis +.nf +.b #include +.pp +.bi "double strtod(const char *restrict " nptr ", char **restrict " endptr ); +.bi "float strtof(const char *restrict " nptr ", char **restrict " endptr ); +.bi "long double strtold(const char *restrict " nptr \ +", char **restrict " endptr ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br strtof (), +.br strtold (): +.nf + _isoc99_source || _posix_c_source >= 200112l +.fi +.sh description +the +.br strtod (), +.br strtof (), +and +.br strtold () +functions convert the initial portion of the string pointed to by +.i nptr +to +.ir double , +.ir float , +and +.i long double +representation, respectively. +.pp +the expected form of the (initial portion of the) string is +optional leading white space as recognized by +.br isspace (3), +an optional plus (\(aq+\(aq) or minus sign (\(aq\-\(aq) and then either +(i) a decimal number, or (ii) a hexadecimal number, +or (iii) an infinity, or (iv) a nan (not-a-number). +.pp +a +.i "decimal number" +consists of a nonempty sequence of decimal digits +possibly containing a radix character (decimal point, locale-dependent, +usually \(aq.\(aq), optionally followed by a decimal exponent. +a decimal exponent consists of an \(aqe\(aq or \(aqe\(aq, followed by an +optional plus or minus sign, followed by a nonempty sequence of +decimal digits, and indicates multiplication by a power of 10. +.pp +a +.i "hexadecimal number" +consists of a "0x" or "0x" followed by a nonempty sequence of +hexadecimal digits possibly containing a radix character, +optionally followed by a binary exponent. +a binary exponent +consists of a \(aqp\(aq or \(aqp\(aq, followed by an optional +plus or minus sign, followed by a nonempty sequence of +decimal digits, and indicates multiplication by a power of 2. +at least one of radix character and binary exponent must be present. +.pp +an +.i infinity +is either "inf" or "infinity", disregarding case. +.pp +a +.i nan +is "nan" (disregarding case) optionally followed by a string, +.ir (n-char-sequence) , +where +.ir n-char-sequence +specifies in an implementation-dependent +way the type of nan (see notes). +.sh return value +these functions return the converted value, if any. +.pp +if +.i endptr +is not null, +a pointer to the character after the last character used in the conversion +is stored in the location referenced by +.ir endptr . +.pp +if no conversion is performed, zero is returned and (unless +.i endptr +is null) the value of +.i nptr +is stored in the location referenced by +.ir endptr . +.pp +if the correct value would cause overflow, plus or minus +.br huge_val , +.br huge_valf , +or +.b huge_vall +is returned (according to the return type and sign of the value), +and +.b erange +is stored in +.ir errno . +.pp +if the correct value would cause underflow, +a value with magnitude no larger than +.br dbl_min , +.br flt_min , +or +.b ldbl_min +is returned and +.b erange +is stored in +.ir errno . +.sh errors +.tp +.b erange +overflow or underflow occurred. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br strtod (), +.br strtof (), +.br strtold () +t} thread safety mt-safe locale +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.pp +.br strtod () +was also described in c89. +.sh notes +since +0 can legitimately be returned +on both success and failure, the calling program should set +.i errno +to 0 before the call, +and then determine if an error occurred by checking whether +.i errno +has a nonzero value after the call. +.pp +in the glibc implementation, the +.ir n-char-sequence +that optionally follows "nan" +is interpreted as an integer number +(with an optional '0' or '0x' prefix to select base 8 or 16) +that is to be placed in the +mantissa component of the returned value. +.\" from glibc 2.8's stdlib/strtod_l.c: +.\" we expect it to be a number which is put in the +.\" mantissa of the number. +.\" it looks as though at least freebsd (according to the manual) does +.\" something similar. +.\" c11 says: "an implementation may use the n-char sequence to determine +.\" extra information to be represented in the nan's significant." +.sh examples +see the example on the +.br strtol (3) +manual page; +the use of the functions described in this manual page is similar. +.sh see also +.br atof (3), +.br atoi (3), +.br atol (3), +.br nan (3), +.br nanf (3), +.br nanl (3), +.br strfromd (3), +.br strtol (3), +.br strtoul (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2010 michael kerrisk, +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th pthread_sigqueue 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +pthread_sigqueue \- queue a signal and data to a thread +.sh synopsis +.nf +.b #include +.b #include +.pp +.bi "int pthread_sigqueue(pthread_t " thread ", int " sig , +.bi " const union sigval " value ); +.fi +.pp +compile and link with \fi\-pthread\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br pthread_sigqueue (): +.nf + _gnu_source +.fi +.sh description +the +.br pthread_sigqueue () +function performs a similar task to +.br sigqueue (3), +but, rather than sending a signal to a process, +it sends a signal to a thread in the same process as the +calling thread. +.pp +the +.i thread +argument is the id of a thread in the same process as the caller. +the +.i sig +argument specifies the signal to be sent. +the +.i value +argument specifies data to accompany the signal; see +.br sigqueue (3) +for details. +.sh return value +on success, +.br pthread_sigqueue () +returns 0; +on error, it returns an error number. +.sh errors +.tp +.b eagain +the limit of signals which may be queued has been reached. +(see +.br signal (7) +for further information.) +.tp +.b einval +.i sig +was invalid. +.tp +.b enosys +.br pthread_sigqueue () +is not supported on this system. +.tp +.b esrch +.i thread +is not valid. +.sh versions +the +.br pthread_sigqueue () +function first appeared in glibc 2.11. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br pthread_sigqueue () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +this function is a gnu extension. +.sh notes +the glibc implementation of +.br pthread_sigqueue () +gives an error +.rb ( einval ) +on attempts to send either of the real-time signals +used internally by the nptl threading implementation. +see +.br nptl (7) +for details. +.sh see also +.br rt_tgsigqueueinfo (2), +.br sigaction (2), +.br pthread_sigmask (3), +.br sigqueue (3), +.br sigwait (3), +.br pthreads (7), +.br signal (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/psignal.3 + +.so man3/xdr.3 + +.so man3/circleq.3 + +.\" this man page is copyright (c) 2006 andi kleen . +.\" +.\" %%%license_start(verbatim_one_para) +.\" permission is granted to distribute possibly modified copies +.\" of this page provided the header is included verbatim, +.\" and in case of nontrivial modification author and date +.\" of the modification is added to the header. +.\" %%%license_end +.\" +.\" 2008, mtk, various edits +.\" +.th getcpu 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +getcpu \- determine cpu and numa node on which the calling thread is running +.sh synopsis +.nf +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "int getcpu(unsigned int *" cpu ", unsigned int *" node ); +.fi +.sh description +the +.br getcpu () +system call identifies the processor and node on which the calling +thread or process is currently running and writes them into the +integers pointed to by the +.i cpu +and +.i node +arguments. +the processor is a unique small integer identifying a cpu. +the node is a unique small identifier identifying a numa node. +when either +.i cpu +or +.i node +is null nothing is written to the respective pointer. +.pp +the information placed in +.i cpu +is guaranteed to be current only at the time of the call: +unless the cpu affinity has been fixed using +.br sched_setaffinity (2), +the kernel might change the cpu at any time. +(normally this does not happen +because the scheduler tries to minimize movements between cpus to +keep caches hot, but it is possible.) +the caller must allow for the possibility that the information returned in +.i cpu +and +.i node +is no longer current by the time the call returns. +.sh return value +on success, 0 is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b efault +arguments point outside the calling process's address space. +.sh versions +.br getcpu () +was added in kernel 2.6.19 for x86-64 and i386. +library support was added in glibc 2.29 +(earlier glibc versions did not provide a wrapper for this system call, +necessitating the use of +.br syscall (2).) +.sh conforming to +.br getcpu () +is linux-specific. +.sh notes +linux makes a best effort to make this call as fast as possible. +(on some architectures, this is done via an implementation in the +.br vdso (7).) +the intention of +.br getcpu () +is to allow programs to make optimizations with per-cpu data +or for numa optimization. +.\" +.ss c library/kernel differences +the kernel system call has a third argument: +.pp +.in +4n +.nf +.bi "int getcpu(unsigned int *" cpu ", unsigned int *" node , +.bi " struct getcpu_cache *" tcache ); +.fi +.in +.pp +the +.i tcache +argument is unused since linux 2.6.24, +and (when invoking the system call directly) +should be specified as null, +unless portability to linux 2.6.23 or earlier is required. +.pp +.\" commit 4307d1e5ada595c87f9a4d16db16ba5edb70dcb1 +.\" author: ingo molnar +.\" date: wed nov 7 18:37:48 2007 +0100 +.\" x86: ignore the sys_getcpu() tcache parameter +in linux 2.6.23 and earlier, if the +.i tcache +argument was non-null, +then it specified a pointer to a caller-allocated buffer in thread-local +storage that was used to provide a caching mechanism for +.br getcpu (). +use of the cache could speed +.br getcpu () +calls, at the cost that there was a very small chance that +the returned information would be out of date. +the caching mechanism was considered to cause problems when +migrating threads between cpus, and so the argument is now ignored. +.\" +.\" ===== before kernel 2.6.24: ===== +.\" .i tcache +.\" is a pointer to a +.\" .ir "struct getcpu_cache" +.\" that is used as a cache by +.\" .br getcpu (). +.\" the caller should put the cache into a thread-local variable +.\" if the process is multithreaded, +.\" because the cache cannot be shared between different threads. +.\" .i tcache +.\" can be null. +.\" if it is not null +.\" .br getcpu () +.\" will use it to speed up operation. +.\" the information inside the cache is private to the system call +.\" and should not be accessed by the user program. +.\" the information placed in the cache can change between kernel releases. +.\" +.\" when no cache is specified +.\" .br getcpu () +.\" will be slower, +.\" but always retrieve the current cpu and node information. +.\" with a cache +.\" .br getcpu () +.\" is faster. +.\" however, the cached information is updated only once per jiffy (see +.\" .br time (7)). +.\" this means that the information could theoretically be out of date, +.\" although in practice the scheduler's attempt to maintain +.\" soft cpu affinity means that the information is unlikely to change +.\" over the course of the caching interval. +.sh see also +.br mbind (2), +.br sched_setaffinity (2), +.br set_mempolicy (2), +.br sched_getcpu (3), +.br cpuset (7), +.br vdso (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/regex.3 + +.\" copyright (c) 1993 by thomas koenig (ig25@rz.uni-karlsruhe.de) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified wed jul 28 11:12:07 1993 by rik faith (faith@cs.unc.edu) +.\" modified fri sep 8 15:48:13 1995 by andries brouwer (aeb@cwi.nl) +.\" modified 2013-12-31, david malcolm +.\" split gets(3) into its own page; fgetc() et al. move to fgetc(3) +.th gets 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +gets \- get a string from standard input (deprecated) +.sh synopsis +.nf +.b #include +.pp +.bi "char *gets(char *" "s" ); +.fi +.sh description +.ir "never use this function" . +.pp +.br gets () +reads a line from +.i stdin +into the buffer pointed to by +.i s +until either a terminating newline or +.br eof , +which it replaces with a null byte (\(aq\e0\(aq). +no check for buffer overrun is performed (see bugs below). +.sh return value +.br gets () +returns +.i s +on success, and null +on error or when end of file occurs while no characters have been read. +however, given the lack of buffer overrun checking, there can be no +guarantees that the function will even return. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br gets () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c89, c99, posix.1-2001. +.pp +lsb deprecates +.br gets (). +posix.1-2008 marks +.br gets () +obsolescent. +iso c11 removes the specification of +.br gets () +from the c language, and since version 2.16, +glibc header files don't expose the function declaration if the +.b _isoc11_source +feature test macro is defined. +.sh bugs +never use +.br gets (). +because it is impossible to tell without knowing the data in advance how many +characters +.br gets () +will read, and because +.br gets () +will continue to store characters past the end of the buffer, +it is extremely dangerous to use. +it has been used to break computer security. +use +.br fgets () +instead. +.pp +for more information, see cwe-242 (aka "use of inherently dangerous +function") at +http://cwe.mitre.org/data/definitions/242.html +.sh see also +.br read (2), +.br write (2), +.br ferror (3), +.br fgetc (3), +.br fgets (3), +.br fgetwc (3), +.br fgetws (3), +.br fopen (3), +.br fread (3), +.br fseek (3), +.br getline (3), +.br getwchar (3), +.br puts (3), +.br scanf (3), +.br ungetwc (3), +.br unlocked_stdio (3), +.br feature_test_macros (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2014 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th pldd 1 2020-11-01 "gnu" "linux user manual" +.sh name +pldd \- display dynamic shared objects linked into a process +.sh synopsis +.nf +.bi "pldd " "pid" +.bi pldd " option" +.fi +.sh description +the +.b pldd +command displays a list of the dynamic shared objects (dsos) that are +linked into the process with the specified process id (pid). +the list includes the libraries that have been dynamically loaded using +.br dlopen (3). +.sh options +.tp +.br \-? ", " \-\-help +display a help message and exit. +.tp +.b \-\-usage +display a short usage message and exit. +.tp +.br \-v ", " \-\-version +display program version information and exit. +.sh exit status +on success, +.b pldd +exits with the status 0. +if the specified process does not exist, +the user does not have permission to access +its dynamic shared object list, +or no command-line arguments are supplied, +.b pldd +exists with a status of 1. +if given an invalid option, it exits with the status 64. +.sh versions +.b pldd +is available since glibc 2.15. +.sh conforming to +the +.b pldd +command is not specified by posix.1. +some other systems +.\" there are man pages on solaris and hp-ux. +have a similar command. +.sh notes +the command +.pp +.in +4n +.ex +lsof \-p pid +.ee +.in +.pp +also shows output that includes the dynamic shared objects +that are linked into a process. +.pp +the +.br gdb (1) +.i "info shared" +command also shows the shared libraries being used by a process, +so that one can obtain similar output to +.b pldd +using a command such as the following +(to monitor the process with the specified +.ir pid ): +.pp +.in +4n +.ex +$ \fbgdb \-ex "set confirm off" \-ex "set height 0" \-ex "info shared" \e\fp + \fb\-ex "quit" \-p $pid | grep \(aq\(ha0x.*0x\(aq\fp +.ee +.in +.sh bugs +from glibc 2.19 to 2.29, +.b pldd +was broken: it just hung when executed. +.\" glibc commit 1a4c27355e146b6d8cc6487b998462c7fdd1048f +this problem was fixed in glibc 2.30, and the fix has been backported +to earlier glibc versions in some distributions. +.sh examples +.ex +$ \fbecho $$\fp # display pid of shell +1143 +$ \fbpldd $$\fp # display dsos linked into the shell +1143: /usr/bin/bash +linux\-vdso.so.1 +/lib64/libtinfo.so.5 +/lib64/libdl.so.2 +/lib64/libc.so.6 +/lib64/ld\-linux\-x86\-64.so.2 +/lib64/libnss_files.so.2 +.ee +.sh see also +.br ldd (1), +.br lsof (1), +.br dlopen (3), +.br ld.so (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man7/system_data_types.7 + +.\" copyright (c) 2008, george spelvin , +.\" and copyright (c) 2008, matt mackall +.\" and copyright (c) 2016, laurent georget +.\" and copyright (c) 2016, nikos mavrogiannopoulos +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of +.\" this manual under the conditions for verbatim copying, provided that +.\" the entire resulting derived work is distributed under the terms of +.\" a permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume. +.\" no responsibility for errors or omissions, or for damages resulting. +.\" from the use of the information contained herein. the author(s) may. +.\" not have taken the same level of care in the production of this. +.\" manual, which is licensed free of charge, as they might when working. +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" the following web page is quite informative: +.\" http://www.2uo.de/myths-about-urandom/ +.\" +.th random 7 2017-03-13 "linux" "linux programmer's manual" +.sh name +random \- overview of interfaces for obtaining randomness +.sh description +the kernel random-number generator relies on entropy gathered from +device drivers and other sources of environmental noise to seed +a cryptographically secure pseudorandom number generator (csprng). +it is designed for security, rather than speed. +.pp +the following interfaces provide access to output from the kernel csprng: +.ip * 3 +the +.i /dev/urandom +and +.i /dev/random +devices, both described in +.br random (4). +these devices have been present on linux since early times, +and are also available on many other systems. +.ip * +the linux-specific +.br getrandom (2) +system call, available since linux 3.17. +this system call provides access either to the same source as +.i /dev/urandom +(called the +.i urandom +source in this page) +or to the same source as +.i /dev/random +(called the +.i random +source in this page). +the default is the +.i urandom +source; the +.i random +source is selected by specifying the +.br grnd_random +flag to the system call. +(the +.br getentropy (3) +function provides a slightly more portable interface on top of +.br getrandom (2).) +.\" +.ss initialization of the entropy pool +the kernel collects bits of entropy from the environment. +when a sufficient number of random bits has been collected, the +entropy pool is considered to be initialized. +.ss choice of random source +unless you are doing long-term key generation (and most likely not even +then), you probably shouldn't be reading from the +.ir /dev/random +device or employing +.br getrandom (2) +with the +.br grnd_random +flag. +instead, either read from the +.ir /dev/urandom +device or employ +.br getrandom (2) +without the +.b grnd_random +flag. +the cryptographic algorithms used for the +.ir urandom +source are quite conservative, and so should be sufficient for all purposes. +.pp +the disadvantage of +.b grnd_random +and reads from +.i /dev/random +is that the operation can block for an indefinite period of time. +furthermore, dealing with the partially fulfilled +requests that can occur when using +.b grnd_random +or when reading from +.i /dev/random +increases code complexity. +.\" +.ss monte carlo and other probabilistic sampling applications +using these interfaces to provide large quantities of data for +monte carlo simulations or other programs/algorithms which are +doing probabilistic sampling will be slow. +furthermore, it is unnecessary, because such applications do not +need cryptographically secure random numbers. +instead, use the interfaces described in this page to obtain +a small amount of data to seed a user-space pseudorandom +number generator for use by such applications. +.\" +.ss comparison between getrandom, /dev/urandom, and /dev/random +the following table summarizes the behavior of the various +interfaces that can be used to obtain randomness. +.b grnd_nonblock +is a flag that can be used to control the blocking behavior of +.br getrandom (2). +the final column of the table considers the case that can occur +in early boot time when the entropy pool is not yet initialized. +.ad l +.ts +allbox; +lbw13 lbw12 lbw14 lbw18 +l l l l. +interface pool t{ +blocking +\%behavior +t} t{ +behavior when pool is not yet ready +t} +t{ +.i /dev/random +t} t{ +blocking pool +t} t{ +if entropy too low, blocks until there is enough entropy again +t} t{ +blocks until enough entropy gathered +t} +t{ +.i /dev/urandom +t} t{ +csprng output +t} t{ +never blocks +t} t{ +returns output from uninitialized csprng (may be low entropy and unsuitable for cryptography) +t} +t{ +.br getrandom () +t} t{ +same as +.i /dev/urandom +t} t{ +does not block once is pool ready +t} t{ +blocks until pool ready +t} +t{ +.br getrandom () +.b grnd_random +t} t{ +same as +.i /dev/random +t} t{ +if entropy too low, blocks until there is enough entropy again +t} t{ +blocks until pool ready +t} +t{ +.br getrandom () +.b grnd_nonblock +t} t{ +same as +.i /dev/urandom +t} t{ +does not block once is pool ready +t} t{ +.b eagain +t} +t{ +.br getrandom () +.b grnd_random ++ +.b grnd_nonblock +t} t{ +same as +.i /dev/random +t} t{ +.b eagain +if not enough entropy available +t} t{ +.b eagain +t} +.te +.ad +.\" +.ss generating cryptographic keys +the amount of seed material required to generate a cryptographic key +equals the effective key size of the key. +for example, a 3072-bit rsa +or diffie-hellman private key has an effective key size of 128 bits +(it requires about 2^128 operations to break) so a key generator +needs only 128 bits (16 bytes) of seed material from +.ir /dev/random . +.pp +while some safety margin above that minimum is reasonable, as a guard +against flaws in the csprng algorithm, no cryptographic primitive +available today can hope to promise more than 256 bits of security, +so if any program reads more than 256 bits (32 bytes) from the kernel +random pool per invocation, or per reasonable reseed interval (not less +than one minute), that should be taken as a sign that its cryptography is +.i not +skillfully implemented. +.\" +.sh see also +.br getrandom (2), +.br getauxval (3), +.br getentropy (3), +.br random (4), +.br urandom (4), +.br signal (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/ldexp.3 + +.so man3/fabs.3 + +.so man3/xdr.3 + +.so man3/fpclassify.3 + +.\" copyright (c) international business machines corp., 2006 +.\" +.\" %%%license_start(gplv2+_sw_3_para) +.\" this program is free software; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" this program 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" history: +.\" 2005-09-28, created by arnd bergmann +.\" 2006-06-16, revised by eduardo m. fleury +.\" 2007-07-10, some polishing by mtk +.\" 2007-09-28, updates for newer kernels, added example +.\" by jeremy kerr +.\" +.th spu_run 2 2021-03-22 linux "linux programmer's manual" +.sh name +spu_run \- execute an spu context +.sh synopsis +.nf +.br "#include " " /* definition of " spu_* " constants */" +.br "#include " " /* definition of " sys_* " constants */" +.b #include +.pp +.bi "int spu_run(int " fd ", uint32_t *" npc ", uint32_t *" event ); +.fi +.pp +.ir note : +glibc provides no wrapper for +.br spu_run (), +necessitating the use of +.br syscall (2). +.sh description +the +.br spu_run () +system call is used on powerpc machines that implement the +cell broadband engine architecture in order to access synergistic +processor units (spus). +the +.i fd +argument is a file descriptor returned by +.br spu_create (2) +that refers to a specific spu context. +when the context gets scheduled to a physical spu, +it starts execution at the instruction pointer passed in +.ir npc . +.pp +execution of spu code happens synchronously, meaning that +.br spu_run () +blocks while the spu is still running. +if there is a need +to execute spu code in parallel with other code on either the +main cpu or other spus, a new thread of execution must be created +first (e.g., using +.br pthread_create (3)). +.pp +when +.br spu_run () +returns, the current value of the spu program counter is written to +.ir npc , +so successive calls to +.br spu_run () +can use the same +.i npc +pointer. +.pp +the +.i event +argument provides a buffer for an extended status code. +if the spu +context was created with the +.b spu_create_events_enabled +flag, then this buffer is populated by the linux kernel before +.br spu_run () +returns. +.pp +the status code may be one (or more) of the following constants: +.tp +.b spe_event_dma_alignment +a dma alignment error occurred. +.tp +.b spe_event_invalid_dma +an invalid mfc dma command was attempted. +.\" spe_event_spe_data_segment is defined, but does not seem to be generated +.\" at any point (in linux 5.9 sources). +.tp +.b spe_event_spe_data_storage +a dma storage error occurred. +.tp +.b spe_event_spe_error +an illegal instruction was executed. +.pp +null +is a valid value for the +.i event +argument. +in this case, the events will not be reported to the calling process. +.sh return value +on success, +.br spu_run () +returns the value of the +.i spu_status +register. +on failure, it returns \-1 and sets +.i errno +is set to indicate the error. +.pp +the +.i spu_status +register value is a bit mask of status codes and +optionally a 14-bit code returned from the +.br stop-and-signal +instruction on the spu. +the bit masks for the status codes +are: +.tp +.b 0x02 +spu was stopped by a +.br stop-and-signal +instruction. +.tp +.b 0x04 +spu was stopped by a +.br halt +instruction. +.tp +.b 0x08 +spu is waiting for a channel. +.tp +.b 0x10 +spu is in single-step mode. +.tp +.b 0x20 +spu has tried to execute an invalid instruction. +.tp +.b 0x40 +spu has tried to access an invalid channel. +.tp +.b 0x3fff0000 +the bits masked with this value contain the code returned from a +.br stop-and-signal +instruction. +these bits are valid only if the 0x02 bit is set. +.pp +if +.br spu_run () +has not returned an error, one or more bits among the lower eight +ones are always set. +.sh errors +.tp +.b ebadf +.i fd +is not a valid file descriptor. +.tp +.b efault +.i npc +is not a valid pointer, or +.i event +is non-null and an invalid pointer. +.tp +.b eintr +a signal occurred while +.br spu_run () +was in progress; see +.br signal (7). +the +.i npc +value has been updated to the new program counter value if +necessary. +.tp +.b einval +.i fd +is not a valid file descriptor returned from +.br spu_create (2). +.tp +.b enomem +there was not enough memory available to handle a page fault +resulting from a memory flow controller (mfc) direct memory access. +.tp +.b enosys +the functionality is not provided by the current system, because +either the hardware does not provide spus or the spufs module is not +loaded. +.sh versions +the +.br spu_run () +system call was added to linux in kernel 2.6.16. +.sh conforming to +this call is linux-specific and implemented only by the powerpc +architecture. +programs using this system call are not portable. +.sh notes +.br spu_run () +is meant to be used from libraries that implement a more abstract +interface to spus, not to be used from regular applications. +see +.ur http://www.bsc.es\:/projects\:/deepcomputing\:/linuxoncell/ +.ue +for the recommended libraries. +.sh examples +the following is an example of running a simple, one-instruction spu +program with the +.br spu_run () +system call. +.pp +.ex +#include +#include +#include +#include +#include +#include + +#define handle_error(msg) \e + do { perror(msg); exit(exit_failure); } while (0) + +int main(void) +{ + int context, fd, spu_status; + uint32_t instruction, npc; + + context = spu_create("/spu/example\-context", 0, 0755); + if (context == \-1) + handle_error("spu_create"); + + /* + * write a \(aqstop 0x1234\(aq instruction to the spu\(aqs + * local store memory. + */ + instruction = 0x00001234; + + fd = open("/spu/example\-context/mem", o_rdwr); + if (fd == \-1) + handle_error("open"); + write(fd, &instruction, sizeof(instruction)); + + /* + * set npc to the starting instruction address of the + * spu program. since we wrote the instruction at the + * start of the mem file, the entry point will be 0x0. + */ + npc = 0; + + spu_status = spu_run(context, &npc, null); + if (spu_status == \-1) + handle_error("open"); + + /* + * we should see a status code of 0x1234002: + * 0x00000002 (spu was stopped due to stop\-and\-signal) + * | 0x12340000 (the stop\-and\-signal code) + */ + printf("spu status: %#08x\en", spu_status); + + exit(exit_success); +} +.ee +.\" .sh authors +.\" arnd bergmann , jeremy kerr +.sh see also +.br close (2), +.br spu_create (2), +.br capabilities (7), +.br spufs (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" and copyright 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified 1993-07-24 by rik faith (faith@cs.unc.edu) +.\" modified 1995-08-14 by arnt gulbrandsen +.\" modified 2002-07-27 by walter harms +.\" (walter.harms@informatik.uni-oldenburg.de) +.\" +.th exp2 3 2021-03-22 "" "linux programmer's manual" +.sh name +exp2, exp2f, exp2l \- base-2 exponential function +.sh synopsis +.nf +.b #include +.pp +.bi "double exp2(double " x ); +.bi "float exp2f(float " x ); +.bi "long double exp2l(long double " x ); +.fi +.pp +link with \fi\-lm\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br exp2 (), +.br exp2f (), +.br exp2l (): +.nf + _isoc99_source || _posix_c_source >= 200112l +.fi +.sh description +these functions return the value of 2 raised to the power of +.ir x . +.sh return value +on success, these functions return the base-2 exponential value of +.ir x . +.pp +for various special cases, including the handling of infinity and nan, +as well as overflows and underflows, see +.br exp (3). +.sh errors +see +.br math_error (7) +for information on how to determine whether an error has occurred +when calling these functions. +.pp +for a discussion of the errors that can occur for these functions, see +.br exp (3). +.sh versions +these functions first appeared in glibc in version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br exp2 (), +.br exp2f (), +.br exp2l () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.pp +the variant returning +.i double +also conforms to +svr4, 4.3bsd. +.sh see also +.br cbrt (3), +.br cexp2 (3), +.br exp (3), +.br exp10 (3), +.br sqrt (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man7/iso_8859-11.7 + +.so man2/s390_pci_mmio_write.2 + +.so man3/exp.3 + +.so man3/rint.3 + +.so man2/outb.2 + +.so man3/termios.3 + +.so man3/xdr.3 + +.so man3/getipnodebyname.3 + +.\" copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de) +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under gpl +.\" %%%license_end +.\" +.th carg 3 2021-03-22 "" "linux programmer's manual" +.sh name +carg, cargf, cargl \- calculate the complex argument +.sh synopsis +.nf +.b #include +.pp +.bi "double carg(double complex " z ");" +.bi "float cargf(float complex " z ");" +.bi "long double cargl(long double complex " z ");" +.pp +link with \fi\-lm\fp. +.fi +.sh description +these functions calculate the complex argument (also called phase angle) of +.ir z , +with a branch cut along the negative real axis. +.pp +a complex number can be described by two real coordinates. +one may use rectangular coordinates and gets +.pp +.nf + z = x + i * y +.fi +.pp +where +.ir "x\ =\ creal(z)" +and +.ir "y\ =\ cimag(z)" . +.pp +or one may use polar coordinates and gets +.pp +.nf + z = r * cexp(i * a) +.fi +.pp +where +.ir "r\ =\ cabs(z)" +is the "radius", the "modulus", the absolute value of +.ir z , +and +.ir "a\ =\ carg(z)" +is the "phase angle", the argument of +.ir z . +.pp +one has: +.pp +.nf + tan(carg(z)) = cimag(z) / creal(z) +.fi +.sh return value +the return value is in the range of [\-pi,pi]. +.sh versions +these functions first appeared in glibc in version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br carg (), +.br cargf (), +.br cargl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.sh see also +.br cabs (3), +.br complex (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified mon mar 29 22:39:41 1993, david metcalfe +.\" modified sat jul 24 21:38:42 1993, rik faith (faith@cs.unc.edu) +.\" modified sun dec 17 18:35:06 2000, joseph s. myers +.\" +.th atoi 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +atoi, atol, atoll \- convert a string to an integer +.sh synopsis +.nf +.b #include +.pp +.bi "int atoi(const char *" nptr ); +.bi "long atol(const char *" nptr ); +.bi "long long atoll(const char *" nptr ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br atoll (): +.nf + _isoc99_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.sh description +the +.br atoi () +function converts the initial portion of the string +pointed to by \finptr\fp to +.ir int . +the behavior is the same as +.pp +.in +4n +.ex +strtol(nptr, null, 10); +.ee +.in +.pp +except that +.br atoi () +does not detect errors. +.pp +the +.br atol () +and +.br atoll () +functions behave the same as +.br atoi (), +except that they convert the initial portion of the +string to their return type of \filong\fp or \filong long\fp. +.sh return value +the converted value or 0 on error. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br atoi (), +.br atol (), +.br atoll () +t} thread safety mt-safe locale +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99, svr4, 4.3bsd. +c89 and +posix.1-1996 include the functions +.br atoi () +and +.br atol () +only. +.\" .sh notes +.\" linux libc provided +.\" .br atoq () +.\" as an obsolete name for +.\" .br atoll (); +.\" .br atoq () +.\" is not provided by glibc. +.\" the +.\" .br atoll () +.\" function is present in glibc 2 since version 2.0.2, but +.\" not in libc4 or libc5. +.sh notes +posix.1 leaves the return value of +.br atoi () +on error unspecified. +on glibc, musl libc, and uclibc, 0 is returned on error. +.sh bugs +.i errno +is not set on error so there is no way to distinguish between 0 as an +error and as the converted value. +no checks for overflow or underflow are done. +only base-10 input can be converted. +it is recommended to instead use the +.br strtol () +and +.br strtoul () +family of functions in new programs. +.sh see also +.br atof (3), +.br strtod (3), +.br strtol (3), +.br strtoul (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2003 andries brouwer (aeb@cwi.nl) +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th aio_write 3 2021-03-22 "" "linux programmer's manual" +.sh name +aio_write \- asynchronous write +.sh synopsis +.nf +.b "#include " +.pp +.bi "int aio_write(struct aiocb *" aiocbp ); +.pp +link with \fi\-lrt\fp. +.fi +.sh description +the +.br aio_write () +function queues the i/o request described by the buffer pointed to by +.ir aiocbp . +this function is the asynchronous analog of +.br write (2). +the arguments of the call +.pp + write(fd, buf, count) +.pp +correspond (in order) to the fields +.ir aio_fildes , +.ir aio_buf , +and +.ir aio_nbytes +of the structure pointed to by +.ir aiocbp . +(see +.br aio (7) +for a description of the +.i aiocb +structure.) +.pp +if +.b o_append +is not set, the data is written starting at the +absolute position +.ir aiocbp\->aio_offset , +regardless of the file offset. +if +.b o_append +is set, data is written at the end of the file in the same order as +.br aio_write () +calls are made. +after the call, the value of the file offset is unspecified. +.pp +the "asynchronous" means that this call returns as soon as the +request has been enqueued; the write may or may not have completed +when the call returns. +one tests for completion using +.br aio_error (3). +the return status of a completed i/o operation can be obtained +.br aio_return (3). +asynchronous notification of i/o completion can be obtained by setting +.ir aiocbp\->aio_sigevent +appropriately; see +.br sigevent (7) +for details. +.pp +if +.b _posix_prioritized_io +is defined, and this file supports it, +then the asynchronous operation is submitted at a priority equal +to that of the calling process minus +.ir aiocbp\->aio_reqprio . +.pp +the field +.i aiocbp\->aio_lio_opcode +is ignored. +.pp +no data is written to a regular file beyond its maximum offset. +.sh return value +on success, 0 is returned. +on error, the request is not enqueued, \-1 +is returned, and +.i errno +is set to indicate the error. +if an error is detected only later, it will +be reported via +.br aio_return (3) +(returns status \-1) and +.br aio_error (3) +(error status\(emwhatever one would have gotten in +.ir errno , +such as +.br ebadf ). +.sh errors +.tp +.b eagain +out of resources. +.tp +.b ebadf +.i aio_fildes +is not a valid file descriptor open for writing. +.tp +.b efbig +the file is a regular file, we want to write at least one byte, +but the starting position is at or beyond the maximum offset for this file. +.tp +.b einval +one or more of +.ir aio_offset , +.ir aio_reqprio , +.i aio_nbytes +are invalid. +.tp +.b enosys +.br aio_write () +is not implemented. +.sh versions +the +.br aio_write () +function is available since glibc 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br aio_write () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +it is a good idea to zero out the control block before use. +the control block must not be changed while the write operation +is in progress. +the buffer area being written out +.\" or the control block of the operation +must not be accessed during the operation or undefined results may occur. +the memory areas involved must remain valid. +.pp +simultaneous i/o operations specifying the same +.i aiocb +structure produce undefined results. +.sh see also +.br aio_cancel (3), +.br aio_error (3), +.br aio_fsync (3), +.br aio_read (3), +.br aio_return (3), +.br aio_suspend (3), +.br lio_listio (3), +.br aio (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/hsearch.3 + +.so man2/epoll_create.2 + +.\" copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de) +.\" and copyright 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under gpl +.\" %%%license_end +.\" +.\" based on glibc infopages, copyright free software foundation +.\" +.th signbit 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +signbit \- test sign of a real floating-point number +.sh synopsis +.nf +.b "#include " +.pp +.bi "int signbit(" x ");" +.fi +.pp +link with \fi\-lm\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br signbit (): +.nf + _isoc99_source || _posix_c_source >= 200112l +.fi +.sh description +.br signbit () +is a generic macro which can work on all real floating-point types. +it returns a nonzero value if the value of +.i x +has its sign bit set. +.pp +this is not the same as +.ir "x < 0.0" , +because ieee 754 floating point allows zero to be signed. +the comparison +.ir "\-0.0 < 0.0" +is false, but +.ir "signbit(\-0.0)" +will return a nonzero value. +.pp +nans and infinities have a sign bit. +.sh return value +the +.br signbit () +macro returns nonzero if the sign of +.i x +is negative; otherwise it returns zero. +.sh errors +no errors occur. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br signbit () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +this function is defined in iec 559 (and the appendix with +recommended functions in ieee 754/ieee 854). +.sh see also +.br copysign (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1996 tom bjorkholm +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" 1996-04-11 tom bjorkholm +.\" first version written (1.3.86) +.\" 1996-04-12 tom bjorkholm +.\" update for linux 1.3.87 and later +.\" 2005-10-11 mtk: added notes for mremap_fixed; revised einval text. +.\" +.th mremap 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +mremap \- remap a virtual memory address +.sh synopsis +.nf +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "void *mremap(void *" old_address ", size_t " old_size , +.bi " size_t " new_size ", int " flags ", ... /* void *" new_address " */);" +.fi +.sh description +.br mremap () +expands (or shrinks) an existing memory mapping, potentially +moving it at the same time (controlled by the \fiflags\fp argument and +the available virtual address space). +.pp +\fiold_address\fp is the old address of the virtual memory block that you +want to expand (or shrink). +note that \fiold_address\fp has to be page +aligned. +\fiold_size\fp is the old size of the +virtual memory block. +\finew_size\fp is the requested size of the +virtual memory block after the resize. +an optional fifth argument, +.ir new_address , +may be provided; see the description of +.b mremap_fixed +below. +.pp +if the value of \fiold_size\fp is zero, and \fiold_address\fp refers to +a shareable mapping (see +.br mmap (2) +.br map_shared ), +then +.br mremap () +will create a new mapping of the same pages. +\finew_size\fp +will be the size of the new mapping and the location of the new mapping +may be specified with \finew_address\fp; see the description of +.b mremap_fixed +below. +if a new mapping is requested via this method, then the +.b mremap_maymove +flag must also be specified. +.pp +the \fiflags\fp bit-mask argument may be 0, or include the following flags: +.tp +.b mremap_maymove +by default, if there is not sufficient space to expand a mapping +at its current location, then +.br mremap () +fails. +if this flag is specified, then the kernel is permitted to +relocate the mapping to a new virtual address, if necessary. +if the mapping is relocated, +then absolute pointers into the old mapping location +become invalid (offsets relative to the starting address of +the mapping should be employed). +.tp +.br mremap_fixed " (since linux 2.3.31)" +this flag serves a similar purpose to the +.b map_fixed +flag of +.br mmap (2). +if this flag is specified, then +.br mremap () +accepts a fifth argument, +.ir "void\ *new_address" , +which specifies a page-aligned address to which the mapping must +be moved. +any previous mapping at the address range specified by +.i new_address +and +.i new_size +is unmapped. +.ip +if +.b mremap_fixed +is specified, then +.b mremap_maymove +must also be specified. +.tp +.br mremap_dontunmap " (since linux 5.7)" +.\" commit e346b3813067d4b17383f975f197a9aa28a3b077 +this flag, which must be used in conjunction with +.br mremap_maymove , +remaps a mapping to a new address but does not unmap the mapping at +.ir old_address . +.ip +the +.b mremap_dontunmap +flag can be used only with private anonymous mappings +(see the description of +.br map_private +and +.br map_anonymous +in +.br mmap (2)). +.ip +after completion, +any access to the range specified by +.ir old_address +and +.i old_size +will result in a page fault. +the page fault will be handled by a +.br userfaultfd (2) +handler +if the address is in a range previously registered with +.br userfaultfd (2). +otherwise, the kernel allocates a zero-filled page to handle the fault. +.ip +the +.br mremap_dontunmap +flag may be used to atomically move a mapping while leaving the source +mapped. +see notes for some possible applications of +.br mremap_dontunmap . +.pp +if the memory segment specified by +.i old_address +and +.i old_size +is locked (using +.br mlock (2) +or similar), then this lock is maintained when the segment is +resized and/or relocated. +as a consequence, the amount of memory locked by the process may change. +.sh return value +on success +.br mremap () +returns a pointer to the new virtual memory area. +on error, the value +.b map_failed +(that is, \fi(void\ *)\ \-1\fp) is returned, +and \fierrno\fp is set to indicate the error. +.sh errors +.tp +.b eagain +the caller tried to expand a memory segment that is locked, +but this was not possible without exceeding the +.b rlimit_memlock +resource limit. +.tp +.b efault +some address in the range +\fiold_address\fp to \fiold_address\fp+\fiold_size\fp is an invalid +virtual memory address for this process. +you can also get +.b efault +even if there exist mappings that cover the +whole address space requested, but those mappings are of different types. +.tp +.b einval +an invalid argument was given. +possible causes are: +.rs +.ip * 3 +\fiold_address\fp was not +page aligned; +.ip * +a value other than +.b mremap_maymove +or +.b mremap_fixed +or +.b mremap_dontunmap +was specified in +.ir flags ; +.ip * +.i new_size +was zero; +.ip * +.i new_size +or +.i new_address +was invalid; +.ip * +the new address range specified by +.i new_address +and +.i new_size +overlapped the old address range specified by +.i old_address +and +.ir old_size ; +.ip * +.b mremap_fixed +or +.b mremap_dontunmap +was specified without also specifying +.br mremap_maymove ; +.ip * +.b mremap_dontunmap +was specified, but one or more pages in the range specified by +.ir old_address +and +.ir old_size +were not private anonymous; +.ip * +.b mremap_dontunmap +was specified and +.ir old_size +was not equal to +.ir new_size ; +.ip * +\fiold_size\fp was zero and \fiold_address\fp does not refer to a +shareable mapping (but see bugs); +.ip * +\fiold_size\fp was zero and the +.br mremap_maymove +flag was not specified. +.re +.tp +.b enomem +not enough memory was available to complete the operation. +possible causes are: +.rs +.ip * 3 +the memory area cannot be expanded at the current virtual address, and the +.b mremap_maymove +flag is not set in \fiflags\fp. +or, there is not enough (virtual) memory available. +.ip * +.b mremap_dontunmap +was used causing a new mapping to be created that would exceed the +(virtual) memory available. +or, it would exceed the maximum number of allowed mappings. +.re +.sh conforming to +this call is linux-specific, and should not be used in programs +intended to be portable. +.\" 4.2bsd had a (never actually implemented) +.\" .br mremap (2) +.\" call with completely different semantics. +.sh notes +.br mremap () +changes the +mapping between virtual addresses and memory pages. +this can be used to implement a very efficient +.br realloc (3). +.pp +in linux, memory is divided into pages. +a process has (one or) +several linear virtual memory segments. +each virtual memory segment has one +or more mappings to real memory pages (in the page table). +each virtual memory segment has its own +protection (access rights), which may cause +a segmentation violation +.rb ( sigsegv ) +if the memory is accessed incorrectly (e.g., +writing to a read-only segment). +accessing virtual memory outside of the +segments will also cause a segmentation violation. +.pp +if +.br mremap () +is used to move or expand an area locked with +.br mlock (2) +or equivalent, the +.br mremap () +call will make a best effort to populate the new area but will not fail +with +.b enomem +if the area cannot be populated. +.pp +prior to version 2.4, glibc did not expose the definition of +.br mremap_fixed , +and the prototype for +.br mremap () +did not allow for the +.i new_address +argument. +.\" +.ss mremap_dontunmap use cases +possible applications for +.br mremap_dontunmap +include: +.ip * 3 +non-cooperative +.br userfaultfd (2): +an application can yank out a virtual address range using +.br mremap_dontunmap +and then employ a +.br userfaultfd (2) +handler to handle the page faults that subsequently occur +as other threads in the process touch pages in the yanked range. +.ip * +garbage collection: +.br mremap_dontunmap +can be used in conjunction with +.br userfaultfd (2) +to implement garbage collection algorithms (e.g., in a java virtual machine). +such an implementation can be cheaper (and simpler) +than conventional garbage collection techniques that involve +marking pages with protection +.br prot_none +in conjunction with the of a +.br sigsegv +handler to catch accesses to those pages. +.sh bugs +before linux 4.14, +if +.i old_size +was zero and the mapping referred to by +.i old_address +was a private mapping +.rb ( mmap "(2) " map_private ), +.br mremap () +created a new private mapping unrelated to the original mapping. +this behavior was unintended +and probably unexpected in user-space applications +(since the intention of +.br mremap () +is to create a new mapping based on the original mapping). +since linux 4.14, +.\" commit dba58d3b8c5045ad89c1c95d33d01451e3964db7 +.br mremap () +fails with the error +.b einval +in this scenario. +.sh see also +.br brk (2), +.br getpagesize (2), +.br getrlimit (2), +.br mlock (2), +.br mmap (2), +.br sbrk (2), +.br malloc (3), +.br realloc (3) +.pp +your favorite text book on operating systems +for more information on paged memory +(e.g., \fimodern operating systems\fp by andrew s.\& tanenbaum, +\fiinside linux\fp by randolph bentson, +\fithe design of the unix operating system\fp by maurice j.\& bach) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man7/system_data_types.7 + +.so man3/argz_add.3 + +.\" copyright (c) 2008 linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th pthread_attr_setaffinity_np 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +pthread_attr_setaffinity_np, pthread_attr_getaffinity_np \- set/get +cpu affinity attribute in thread attributes object +.sh synopsis +.nf +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "int pthread_attr_setaffinity_np(pthread_attr_t *" attr , +.bi " size_t " cpusetsize ", const cpu_set_t *" cpuset ); +.bi "int pthread_attr_getaffinity_np(const pthread_attr_t *" attr , +.bi " size_t " cpusetsize ", cpu_set_t *" cpuset ); +.pp +compile and link with \fi\-pthread\fp. +.fi +.sh description +the +.br pthread_attr_setaffinity_np () +function +sets the cpu affinity mask attribute of the +thread attributes object referred to by +.i attr +to the value specified in +.ir cpuset . +this attribute determines the cpu affinity mask +of a thread created using the thread attributes object +.ir attr . +.pp +the +.br pthread_attr_getaffinity_np () +function +returns the cpu affinity mask attribute of the thread attributes object +referred to by +.ir attr +in the buffer pointed to by +.ir cpuset . +.pp +the argument +.i cpusetsize +is the length (in bytes) of the buffer pointed to by +.ir cpuset . +typically, this argument would be specified as +.ir sizeof(cpu_set_t) . +.pp +for more details on cpu affinity masks, see +.br sched_setaffinity (2). +for a description of a set of macros +that can be used to manipulate and inspect cpu sets, see +.br cpu_set (3). +.sh return value +on success, these functions return 0; +on error, they return a nonzero error number. +.sh errors +.tp +.br einval +.rb ( pthread_attr_setaffinity_np ()) +.i cpuset +specified a cpu that was outside the set supported by the kernel. +(the kernel configuration option +.br config_nr_cpus +defines the range of the set supported by the kernel data type +.\" cpumask_t +used to represent cpu sets.) +.\" the raw sched_getaffinity() system call returns the size (in bytes) +.\" of the cpumask_t type. +.tp +.b einval +.rb ( pthread_attr_getaffinity_np ()) +a cpu in the affinity mask of the thread attributes object referred to by +.i attr +lies outside the range specified by +.ir cpusetsize +(i.e., +.ir cpuset / cpusetsize +is too small). +.tp +.b enomem +.rb ( pthread_attr_setaffinity_np ()) +could not allocate memory. +.sh versions +these functions are provided by glibc since version 2.3.4. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br pthread_attr_setaffinity_np (), +.br pthread_attr_getaffinity_np () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +these functions are nonstandard gnu extensions; +hence the suffix "_np" (nonportable) in the names. +.sh notes +in glibc 2.3.3 only, +versions of these functions were provided that did not have a +.i cpusetsize +argument. +instead the cpu set size given to the underlying system calls was always +.ir sizeof(cpu_set_t) . +.sh see also +.br sched_setaffinity (2), +.br pthread_attr_init (3), +.br pthread_setaffinity_np (3), +.br cpuset (7), +.br pthreads (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/outb.2 + +.so man3/__ppc_get_timebase.3 + +.\" copyright 2009 lefteris dimitroulakis (edimitro@tee.gr) +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th iso_8859-6 7 2020-08-13 "linux" "linux programmer's manual" +.sh name +iso_8859-6 \- iso 8859-6 character set encoded in octal, decimal, +and hexadecimal +.sh description +the iso 8859 standard includes several 8-bit extensions to the ascii +character set (also known as iso 646-irv). +iso 8859-6 encodes the +characters used in the arabic language. +.ss iso 8859 alphabets +the full set of iso 8859 alphabets includes: +.ts +l l. +iso 8859-1 west european languages (latin-1) +iso 8859-2 central and east european languages (latin-2) +iso 8859-3 southeast european and miscellaneous languages (latin-3) +iso 8859-4 scandinavian/baltic languages (latin-4) +iso 8859-5 latin/cyrillic +iso 8859-6 latin/arabic +iso 8859-7 latin/greek +iso 8859-8 latin/hebrew +iso 8859-9 latin-1 modification for turkish (latin-5) +iso 8859-10 lappish/nordic/eskimo languages (latin-6) +iso 8859-11 latin/thai +iso 8859-13 baltic rim languages (latin-7) +iso 8859-14 celtic (latin-8) +iso 8859-15 west european languages (latin-9) +iso 8859-16 romanian (latin-10) +.te +.ss iso 8859-6 characters +the following table displays the characters in iso 8859-6 that +are printable and unlisted in the +.br ascii (7) +manual page. +.ts +l l l c lp-1. +oct dec hex char description +_ +240 160 a0   no-break space +244 164 a4 ¤ currency sign +254 172 ac ، arabic comma +255 173 ad ­ soft hyphen +273 187 bb ؛ arabic semicolon +277 191 bf ؟ arabic question mark +301 193 c1 ء arabic letter hamza +302 194 c2 آ arabic letter alef with madda above +303 195 c3 أ arabic letter alef with hamza above +304 196 c4 ؤ arabic letter waw with hamza above +305 197 c5 إ arabic letter alef with hamza below +306 198 c6 ئ arabic letter yeh with hamza above +307 199 c7 ا arabic letter alef +310 200 c8 ب arabic letter beh +311 201 c9 ة arabic letter teh marbuta +312 202 ca ت arabic letter teh +313 203 cb ث arabic letter theh +314 204 cc ج arabic letter jeem +315 205 cd ح arabic letter hah +316 206 ce خ arabic letter khah +317 207 cf د arabic letter dal +320 208 d0 ذ arabic letter thal +321 209 d1 ر arabic letter reh +322 210 d2 ز arabic letter zain +323 211 d3 س arabic letter seen +324 212 d4 ش arabic letter sheen +325 213 d5 ص arabic letter sad +326 214 d6 ض arabic letter dad +327 215 d7 ط arabic letter tah +330 216 d8 ظ arabic letter zah +331 217 d9 ع arabic letter ain +332 218 da غ arabic letter ghain +340 224 e0 ـ arabic tatweel +341 225 e1 ف arabic letter feh +342 226 e2 ق arabic letter qaf +343 227 e3 ك arabic letter kaf +344 228 e4 ل arabic letter lam +345 229 e5 م arabic letter meem +346 230 e6 ن arabic letter noon +347 231 e7 ه arabic letter heh +350 232 e8 و arabic letter waw +351 233 e9 ى arabic letter alef maksura +352 234 ea ي arabic letter yeh +353 235 eb ً arabic fathatan +354 236 ec ٌ arabic dammatan +355 237 ed ٍ arabic kasratan +356 238 ee َ arabic fatha +357 239 ef ُ arabic damma +360 240 f0 ِ arabic kasra +361 241 f1 ّ arabic shadda +362 242 f2 ْ arabic sukun +.te +.sh notes +iso 8859-6 lacks the glyphs required for many related languages, +such as urdu and persian (farsi). +.sh see also +.br ascii (7), +.br charsets (7), +.br utf\-8 (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/stailq.3 + +.\" copyright (c) 2013 by michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th sln 8 2021-03-22 "gnu" "linux programmer's manual" +.sh name +sln \- create symbolic links +.sh synopsis +.nf +.bi sln " source dest" +.bi sln " filelist" +.fi +.sh description +the +.b sln +program creates symbolic links. +unlike the +.br ln (1) +program, it is statically linked. +this means that if for some reason the dynamic linker is not working, +.br sln +can be used to make symbolic links to dynamic libraries. +.pp +the command line has two forms. +in the first form, it creates +.i dest +as a new symbolic link to +.ir source . +.pp +in the second form, +.i filelist +is a list of space-separated pathname pairs, +and the effect is as if +.br sln +was executed once for each line of the file, +with the two pathnames as the arguments. +.pp +the +.b sln +program supports no command-line options. +.sh see also +.br ln (1), +.br ld.so (8), +.br ldconfig (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/get_phys_pages.3 + +.\" copyright (c) 2009 linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th pthread_sigmask 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +pthread_sigmask \- examine and change mask of blocked signals +.sh synopsis +.nf +.b #include +.pp +.bi "int pthread_sigmask(int " how ", const sigset_t *" set \ +", sigset_t *" oldset ); +.fi +.pp +compile and link with \fi\-pthread\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br pthread_sigmask (): +.nf + _posix_c_source >= 199506l || _xopen_source >= 500 +.fi +.sh description +the +.br pthread_sigmask () +function is just like +.br sigprocmask (2), +with the difference that its use in multithreaded programs +is explicitly specified by posix.1. +other differences are noted in this page. +.pp +for a description of the arguments and operation of this function, see +.br sigprocmask (2). +.sh return value +on success, +.br pthread_sigmask () +returns 0; +on error, it returns an error number. +.sh errors +see +.br sigprocmask (2). +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br pthread_sigmask () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +a new thread inherits a copy of its creator's signal mask. +.pp +the glibc +.br pthread_sigmask () +function silently ignores attempts to block the two real-time signals that +are used internally by the nptl threading implementation. +see +.br nptl (7) +for details. +.sh examples +the program below blocks some signals in the main thread, +and then creates a dedicated thread to fetch those signals via +.br sigwait (3). +the following shell session demonstrates its use: +.pp +.in +4n +.ex +.rb "$" " ./a.out &" +[1] 5423 +.rb "$" " kill \-quit %1" +signal handling thread got signal 3 +.rb "$" " kill \-usr1 %1" +signal handling thread got signal 10 +.rb "$" " kill \-term %1" +[1]+ terminated ./a.out +.ee +.in +.ss program source +\& +.ex +#include +#include +#include +#include +#include +#include + +/* simple error handling functions */ + +#define handle_error_en(en, msg) \e + do { errno = en; perror(msg); exit(exit_failure); } while (0) + +static void * +sig_thread(void *arg) +{ + sigset_t *set = arg; + int s, sig; + + for (;;) { + s = sigwait(set, &sig); + if (s != 0) + handle_error_en(s, "sigwait"); + printf("signal handling thread got signal %d\en", sig); + } +} + +int +main(int argc, char *argv[]) +{ + pthread_t thread; + sigset_t set; + int s; + + /* block sigquit and sigusr1; other threads created by main() + will inherit a copy of the signal mask. */ + + sigemptyset(&set); + sigaddset(&set, sigquit); + sigaddset(&set, sigusr1); + s = pthread_sigmask(sig_block, &set, null); + if (s != 0) + handle_error_en(s, "pthread_sigmask"); + + s = pthread_create(&thread, null, &sig_thread, &set); + if (s != 0) + handle_error_en(s, "pthread_create"); + + /* main thread carries on to create other threads and/or do + other work. */ + + pause(); /* dummy pause so we can test program */ +} +.ee +.sh see also +.br sigaction (2), +.br sigpending (2), +.br sigprocmask (2), +.br pthread_attr_setsigmask_np (3), +.br pthread_create (3), +.br pthread_kill (3), +.br sigsetops (3), +.br pthreads (7), +.br signal (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/sem_wait.3 + +.so man3/atoi.3 + +.so man3/towupper.3 + +.so man5/utmp.5 + +.\" copyright (c) 2007 michael kerrisk +.\" drawing on material by justin pryzby +.\" +.\" %%%license_start(permissive_misc) +.\" permission is hereby granted, free of charge, to any person obtaining +.\" a copy of this software and associated documentation files (the +.\" "software"), to deal in the software without restriction, including +.\" without limitation the rights to use, copy, modify, merge, publish, +.\" distribute, sublicense, and/or sell copies of the software, and to +.\" permit persons to whom the software is furnished to do so, subject to +.\" the following conditions: +.\" +.\" the above copyright notice and this permission notice shall be +.\" included in all copies or substantial portions of the software. +.\" +.\" the software is provided "as is", without warranty of any kind, +.\" express or implied, including but not limited to the warranties of +.\" merchantability, fitness for a particular purpose and noninfringement. +.\" in no event shall the authors or copyright holders be liable for any +.\" claim, damages or other liability, whether in an action of contract, +.\" tort or otherwise, arising from, out of or in connection with the +.\" software or the use or other dealings in the software. +.\" %%%license_end +.\" +.\" references: +.\" glibc manual and source +.th backtrace 3 2021-03-22 gnu "linux programmer's manual" +.sh name +backtrace, backtrace_symbols, backtrace_symbols_fd \- support +for application self-debugging +.sh synopsis +.nf +.b #include +.pp +.bi "int backtrace(void **" buffer ", int " size ); +.pp +.bi "char **backtrace_symbols(void *const *" buffer ", int " size ); +.bi "void backtrace_symbols_fd(void *const *" buffer ", int " size ", int " fd ); +.fi +.sh description +.br backtrace () +returns a backtrace for the calling program, +in the array pointed to by +.ir buffer . +a backtrace is the series of currently active function calls for +the program. +each item in the array pointed to by +.i buffer +is of type +.ir "void\ *" , +and is the return address from +the corresponding stack frame. +the +.i size +argument specifies the maximum number of addresses +that can be stored in +.ir buffer . +if the backtrace is larger than +.ir size , +then the addresses corresponding to the +.i size +most recent function calls are returned; +to obtain the complete backtrace, make sure that +.i buffer +and +.i size +are large enough. +.pp +given the set of addresses returned by +.br backtrace () +in +.ir buffer , +.br backtrace_symbols () +translates the addresses into an array of strings that describe +the addresses symbolically. +the +.i size +argument specifies the number of addresses in +.ir buffer . +the symbolic representation of each address consists of the function name +(if this can be determined), a hexadecimal offset into the function, +and the actual return address (in hexadecimal). +the address of the array of string pointers is returned +as the function result of +.br backtrace_symbols (). +this array is +.br malloc (3)ed +by +.br backtrace_symbols (), +and must be freed by the caller. +(the strings pointed to by the array of pointers +need not and should not be freed.) +.pp +.br backtrace_symbols_fd () +takes the same +.i buffer +and +.i size +arguments as +.br backtrace_symbols (), +but instead of returning an array of strings to the caller, +it writes the strings, one per line, to the file descriptor +.ir fd . +.br backtrace_symbols_fd () +does not call +.br malloc (3), +and so can be employed in situations where the latter function might +fail, but see notes. +.sh return value +.br backtrace () +returns the number of addresses returned in +.ir buffer , +which is not greater than +.ir size . +if the return value is less than +.ir size , +then the full backtrace was stored; if it is equal to +.ir size , +then it may have been truncated, in which case the addresses of the +oldest stack frames are not returned. +.pp +on success, +.br backtrace_symbols () +returns a pointer to the array +.br malloc (3)ed +by the call; +on error, null is returned. +.sh versions +.br backtrace (), +.br backtrace_symbols (), +and +.br backtrace_symbols_fd () +are provided in glibc since version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br backtrace (), +.br backtrace_symbols (), +.br backtrace_symbols_fd () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +these functions are gnu extensions. +.sh notes +these functions make some assumptions about how a function's return +address is stored on the stack. +note the following: +.ip * 3 +omission of the frame pointers (as +implied by any of +.br gcc (1)'s +nonzero optimization levels) may cause these assumptions to be +violated. +.ip * +inlined functions do not have stack frames. +.ip * +tail-call optimization causes one stack frame to replace another. +.ip * +.br backtrace () +and +.br backtrace_symbols_fd () +don't call +.br malloc () +explicitly, but they are part of +.ir libgcc , +which gets loaded dynamically when first used. +dynamic loading usually triggers a call to +.br malloc (3). +if you need certain calls to these two functions to not allocate memory +(in signal handlers, for example), you need to make sure +.i libgcc +is loaded beforehand. +.pp +the symbol names may be unavailable without the use of special linker +options. +for systems using the gnu linker, it is necessary to use the +.i \-rdynamic +linker option. +note that names of "static" functions are not exposed, +and won't be available in the backtrace. +.sh examples +the program below demonstrates the use of +.br backtrace () +and +.br backtrace_symbols (). +the following shell session shows what we might see when running the +program: +.pp +.in +4n +.ex +.rb "$" " cc \-rdynamic prog.c \-o prog" +.rb "$" " ./prog 3" +backtrace() returned 8 addresses +\&./prog(myfunc3+0x5c) [0x80487f0] +\&./prog [0x8048871] +\&./prog(myfunc+0x21) [0x8048894] +\&./prog(myfunc+0x1a) [0x804888d] +\&./prog(myfunc+0x1a) [0x804888d] +\&./prog(main+0x65) [0x80488fb] +\&/lib/libc.so.6(__libc_start_main+0xdc) [0xb7e38f9c] +\&./prog [0x8048711] +.ee +.in +.ss program source +\& +.ex +#include +#include +#include +#include + +#define bt_buf_size 100 + +void +myfunc3(void) +{ + int nptrs; + void *buffer[bt_buf_size]; + char **strings; + + nptrs = backtrace(buffer, bt_buf_size); + printf("backtrace() returned %d addresses\en", nptrs); + + /* the call backtrace_symbols_fd(buffer, nptrs, stdout_fileno) + would produce similar output to the following: */ + + strings = backtrace_symbols(buffer, nptrs); + if (strings == null) { + perror("backtrace_symbols"); + exit(exit_failure); + } + + for (int j = 0; j < nptrs; j++) + printf("%s\en", strings[j]); + + free(strings); +} + +static void /* "static" means don\(aqt export the symbol... */ +myfunc2(void) +{ + myfunc3(); +} + +void +myfunc(int ncalls) +{ + if (ncalls > 1) + myfunc(ncalls \- 1); + else + myfunc2(); +} + +int +main(int argc, char *argv[]) +{ + if (argc != 2) { + fprintf(stderr, "%s num\-calls\en", argv[0]); + exit(exit_failure); + } + + myfunc(atoi(argv[1])); + exit(exit_success); +} +.ee +.sh see also +.br addr2line (1), +.br gcc (1), +.br gdb (1), +.br ld (1), +.br dlopen (3), +.br malloc (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/fgetc.3 + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" opengroup's single unix specification +.\" http://www.unix-systems.org/online.html +.\" +.\" 2007-03-31 bruno haible, describe the glibc/libiconv //translit +.\" and //ignore extensions for 'tocode'. +.\" +.th iconv_open 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +iconv_open \- allocate descriptor for character set conversion +.sh synopsis +.nf +.b #include +.pp +.bi "iconv_t iconv_open(const char *" tocode ", const char *" fromcode ); +.fi +.sh description +the +.br iconv_open () +function allocates a conversion descriptor suitable +for converting byte sequences from character encoding +.i fromcode +to +character encoding +.ir tocode . +.pp +the values permitted for +.ir fromcode +and +.i tocode +and the supported +combinations are system-dependent. +for the gnu c library, the permitted +values are listed by the +.i "iconv \-\-list" +command, and all combinations +of the listed values are supported. +furthermore the gnu c library and the +gnu libiconv library support the following two suffixes: +.tp +//translit +when the string "//translit" is appended to +.ir tocode , +transliteration +is activated. +this means that when a character cannot be represented in the +target character set, it can be approximated through one or several +similarly looking characters. +.tp +//ignore +when the string "//ignore" is appended to +.ir tocode , +characters that +cannot be represented in the target character set will be silently discarded. +.pp +the resulting conversion descriptor can be used with +.br iconv (3) +any number of times. +it remains valid until deallocated using +.br iconv_close (3). +.pp +a conversion descriptor contains a conversion state. +after creation using +.br iconv_open (), +the state is in the initial state. +using +.br iconv (3) +modifies the descriptor's conversion state. +to bring the state back to the initial state, use +.br iconv (3) +with null as +.i inbuf +argument. +.sh return value +on success, +.br iconv_open () +returns a freshly allocated conversion +descriptor. +on failure, it returns +.ir (iconv_t)\ \-1 +and sets +.i errno +to indicate the error. +.sh errors +the following error can occur, among others: +.tp +.b einval +the conversion from +.ir fromcode +to +.i tocode +is not supported by the +implementation. +.sh versions +this function is available in glibc since version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br iconv_open () +t} thread safety mt-safe locale +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, susv2. +.sh see also +.br iconv (1), +.br iconv (3), +.br iconv_close (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/readlink.2 + +.so man3/getusershell.3 + +.so man3/drand48.3 + +.so man3/unlocked_stdio.3 + +.so man3/rpc.3 + +.so man3/gethostbyname.3 + +.so man3/acosh.3 + +.so man3/err.3 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" and copyright (c) 2008, michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sat jul 24 18:48:48 1993 by rik faith (faith@cs.unc.edu) +.\" modified 980310, aeb +.\" modified 990328, aeb +.\" 2008-06-19, mtk, added mkostemp(); various other changes +.\" +.th mkstemp 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +mkstemp, mkostemp, mkstemps, mkostemps \- create a unique temporary file +.sh synopsis +.nf +.b #include +.pp +.bi "int mkstemp(char *" template ); +.bi "int mkostemp(char *" template ", int " flags ); +.bi "int mkstemps(char *" template ", int " suffixlen ); +.bi "int mkostemps(char *" template ", int " suffixlen ", int " flags ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br mkstemp (): +.nf + _xopen_source >= 500 +.\" || _xopen_source && _xopen_source_extended + || /* since glibc 2.12: */ _posix_c_source >= 200809l + || /* glibc <= 2.19: */ _svid_source || _bsd_source +.fi +.pp +.br mkostemp (): +.nf + _gnu_source +.fi +.pp +.br mkstemps (): +.nf + /* glibc since 2.19: */ _default_source + || /* glibc <= 2.19: */ _svid_source || _bsd_source +.fi +.pp +.br mkostemps (): +.nf + _gnu_source +.fi +.sh description +the +.br mkstemp () +function generates a unique temporary filename from +.ir template , +creates and opens the file, +and returns an open file descriptor for the file. +.pp +the last six characters of +.i template +must be "xxxxxx" and these are replaced with a string that makes the +filename unique. +since it will be modified, +.i template +must not be a string constant, but should be declared as a character array. +.pp +the file is created with +permissions 0600, that is, read plus write for owner only. +the returned file descriptor provides both read and write access to the file. +the file is opened with the +.br open (2) +.b o_excl +flag, guaranteeing that the caller is the process that creates the file. +.pp +the +.br mkostemp () +function is like +.br mkstemp (), +with the difference that the following bits\(emwith the same meaning as for +.br open (2)\(emmay +be specified in +.ir flags : +.br o_append , +.br o_cloexec , +and +.br o_sync . +note that when creating the file, +.br mkostemp () +includes the values +.br o_rdwr , +.br o_creat , +and +.br o_excl +in the +.i flags +argument given to +.br open (2); +including these values in the +.i flags +argument given to +.br mkostemp () +is unnecessary, and produces errors on some +.\" reportedly, freebsd +systems. +.pp +the +.br mkstemps () +function is like +.br mkstemp (), +except that the string in +.i template +contains a suffix of +.i suffixlen +characters. +thus, +.i template +is of the form +.ir "prefixxxxxxxsuffix" , +and the string xxxxxx is modified as for +.br mkstemp (). +.pp +the +.br mkostemps () +function is to +.br mkstemps () +as +.br mkostemp () +is to +.br mkstemp (). +.sh return value +on success, these functions return the file descriptor +of the temporary file. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eexist +could not create a unique temporary filename. +now the contents of \fitemplate\fp are undefined. +.tp +.b einval +for +.br mkstemp () +and +.br mkostemp (): +the last six characters of \fitemplate\fp were not xxxxxx; +now \fitemplate\fp is unchanged. +.ip +for +.br mkstemps () +and +.br mkostemps (): +.i template +is less than +.i "(6 + suffixlen)" +characters long, or the last 6 characters before the suffix in +.i template +were not xxxxxx. +.pp +these functions may also fail with any of the errors described for +.br open (2). +.sh versions +.br mkostemp () +is available since glibc 2.7. +.br mkstemps () +and +.br mkostemps () +are available since glibc 2.11. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br mkstemp (), +.br mkostemp (), +.br mkstemps (), +.br mkostemps () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +.br mkstemp (): +4.3bsd, posix.1-2001. +.pp +.br mkstemps (): +unstandardized, but appears on several other systems. +.\" mkstemps() appears to be at least on the bsds, mac os x, solaris, +.\" and tru64. +.pp +.br mkostemp () +and +.br mkostemps (): +are glibc extensions. +.sh notes +in glibc versions 2.06 and earlier, the file is created with permissions 0666, +that is, read and write for all users. +this old behavior may be +a security risk, especially since other unix flavors use 0600, +and somebody might overlook this detail when porting programs. +posix.1-2008 adds a requirement that the file be created with mode 0600. +.pp +more generally, the posix specification of +.br mkstemp () +does not say anything +about file modes, so the application should make sure its +file mode creation mask (see +.br umask (2)) +is set appropriately before calling +.br mkstemp () +(and +.br mkostemp ()). +.\" +.\" the prototype for +.\" .br mkstemp () +.\" is in +.\" .i +.\" for libc4, libc5, glibc1; glibc2 follows posix.1 and has the prototype in +.\" .ir . +.sh see also +.br mkdtemp (3), +.br mktemp (3), +.br tempnam (3), +.br tmpfile (3), +.br tmpnam (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/getresuid.2 + +.so man3/toupper.3 + +.so man3/fenv.3 + +.\" copyright 2004 andries brouwer . +.\" and copyright 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" inspired by a page by walter harms created 2002-08-10 +.\" +.th logb 3 2021-03-22 "" "linux programmer's manual" +.sh name +logb, logbf, logbl \- get exponent of a floating-point value +.sh synopsis +.nf +.b #include +.pp +.bi "double logb(double " x ); +.bi "float logbf(float " x ); +.bi "long double logbl(long double " x ); +.fi +.pp +link with \fi\-lm\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br logb (): +.nf + _isoc99_source || _posix_c_source >= 200112l + || _xopen_source >= 500 +.\" || _xopen_source && _xopen_source_extended + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.pp +.br logbf (), +.br logbl (): +.nf + _isoc99_source || _posix_c_source >= 200112l + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.sh description +these functions extract the exponent from the +internal floating-point representation of +.i x +and return it as a floating-point value. +the integer constant +.br flt_radix , +defined in +.ir , +indicates the radix used for the system's floating-point representation. +if +.b flt_radix +is 2, +.bi logb( x ) +is equal to +.bi floor(log2( x ))\fr, +except that it is probably faster. +.pp +if +.i x +is subnormal, +.br logb () +returns the exponent +.i x +would have if it were normalized. +.sh return value +on success, these functions return the exponent of +.ir x . +.pp +if +.i x +is a nan, +a nan is returned. +.pp +if +.i x +is zero, then a pole error occurs, and the functions return +.rb \- huge_val , +.rb \- huge_valf , +or +.rb \- huge_vall , +respectively. +.pp +if +.i x +is negative infinity or positive infinity, then +positive infinity is returned. +.sh errors +see +.br math_error (7) +for information on how to determine whether an error has occurred +when calling these functions. +.pp +the following errors can occur: +.tp +pole error: \fix\fp is 0 +.\" .i errno +.\" is set to +.\" .br erange . +a divide-by-zero floating-point exception +.rb ( fe_divbyzero ) +is raised. +.pp +these functions do not set +.ir errno . +.\" fixme . is it intentional that these functions do not set errno? +.\" log(), log2(), log10() do set errno +.\" bug raised: http://sources.redhat.com/bugzilla/show_bug.cgi?id=6793 +.\" +.\" .sh history +.\" the +.\" .br logb () +.\" function occurs in 4.3bsd. +.\" see ieee.3 in the 4.3bsd manual +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br logb (), +.br logbf (), +.br logbl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.sh see also +.br ilogb (3), +.br log (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/getaddrinfo_a.3 + +.\" copyright (c) andreas gruenbacher, february 2001 +.\" copyright (c) silicon graphics inc, september 2001 +.\" copyright (c) 2015 heinrich schuchardt +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th listxattr 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +listxattr, llistxattr, flistxattr \- list extended attribute names +.sh synopsis +.fam c +.nf +.b #include +.pp +.bi "ssize_t listxattr(const char *" path ", char *" list \ +", size_t " size ); +.bi "ssize_t llistxattr(const char *" path ", char *" list \ +", size_t " size ); +.bi "ssize_t flistxattr(int " fd ", char *" list ", size_t " size ); +.fi +.fam t +.sh description +extended attributes are +.ir name : value +pairs associated with inodes (files, directories, symbolic links, etc.). +they are extensions to the normal attributes which are associated +with all inodes in the system (i.e., the +.br stat (2) +data). +a complete overview of extended attributes concepts can be found in +.br xattr (7). +.pp +.br listxattr () +retrieves the list +of extended attribute names associated with the given +.i path +in the filesystem. +the retrieved list is placed in +.ir list , +a caller-allocated buffer whose size (in bytes) is specified in the argument +.ir size . +the list is the set of (null-terminated) names, one after the other. +names of extended attributes to which the calling process does not +have access may be omitted from the list. +the length of the attribute name +.i list +is returned. +.pp +.br llistxattr () +is identical to +.br listxattr (), +except in the case of a symbolic link, where the list of names of +extended attributes associated with the link itself is retrieved, +not the file that it refers to. +.pp +.br flistxattr () +is identical to +.br listxattr (), +only the open file referred to by +.i fd +(as returned by +.br open (2)) +is interrogated in place of +.ir path . +.pp +a single extended attribute +.i name +is a null-terminated string. +the name includes a namespace prefix; there may be several, disjoint +namespaces associated with an individual inode. +.pp +if +.i size +is specified as zero, these calls return the current size of the +list of extended attribute names (and leave +.i list +unchanged). +this can be used to determine the size of the buffer that +should be supplied in a subsequent call. +(but, bear in mind that there is a possibility that the +set of extended attributes may change between the two calls, +so that it is still necessary to check the return status +from the second call.) +.ss example +the +.i list +of names is returned as an unordered array of null-terminated character +strings (attribute names are separated by null bytes (\(aq\e0\(aq)), like this: +.pp +.in +4n +.ex +user.name1\e0system.name1\e0user.name2\e0 +.ee +.in +.pp +filesystems that implement posix acls using +extended attributes might return a +.i list +like this: +.pp +.in +4n +.ex +system.posix_acl_access\e0system.posix_acl_default\e0 +.ee +.in +.sh return value +on success, a nonnegative number is returned indicating the size of the +extended attribute name list. +on failure, \-1 is returned and +.i errno +is set to indicate the error. +.sh errors +.tp +.b e2big +the size of the list of extended attribute names is larger than the maximum +size allowed; the list cannot be retrieved. +this can happen on filesystems that support an unlimited number of +extended attributes per file such as xfs, for example. +see bugs. +.tp +.b enotsup +extended attributes are not supported by the filesystem, or are disabled. +.tp +.b erange +the +.i size +of the +.i list +buffer is too small to hold the result. +.pp +in addition, the errors documented in +.br stat (2) +can also occur. +.sh versions +these system calls have been available on linux since kernel 2.4; +glibc support is provided since version 2.3. +.sh conforming to +these system calls are linux-specific. +.\" .sh authors +.\" andreas gruenbacher, +.\" .ri < a.gruenbacher@computer.org > +.\" and the sgi xfs development team, +.\" .ri < linux-xfs@oss.sgi.com >. +.\" please send any bug reports or comments to these addresses. +.sh bugs +.\" the xattr(7) page refers to this text: +as noted in +.br xattr (7), +the vfs imposes a limit of 64\ kb on the size of the extended +attribute name list returned by +.br listxattr (7). +if the total size of attribute names attached to a file exceeds this limit, +it is no longer possible to retrieve the list of attribute names. +.sh examples +the following program demonstrates the usage of +.br listxattr () +and +.br getxattr (2). +for the file whose pathname is provided as a command-line argument, +it lists all extended file attributes and their values. +.pp +to keep the code simple, the program assumes that attribute keys and +values are constant during the execution of the program. +a production program should expect and handle changes during +execution of the program. +for example, +the number of bytes required for attribute keys +might increase between the two calls to +.br listxattr (). +an application could handle this possibility using +a loop that retries the call +(perhaps up to a predetermined maximum number of attempts) +with a larger buffer each time it fails with the error +.br erange . +calls to +.br getxattr (2) +could be handled similarly. +.pp +the following output was recorded by first creating a file, setting +some extended file attributes, +and then listing the attributes with the example program. +.ss example output +.in +4n +.ex +$ \fbtouch /tmp/foo\fp +$ \fbsetfattr \-n user.fred \-v chocolate /tmp/foo\fp +$ \fbsetfattr \-n user.frieda \-v bar /tmp/foo\fp +$ \fbsetfattr \-n user.empty /tmp/foo\fp +$ \fb./listxattr /tmp/foo\fp +user.fred: chocolate +user.frieda: bar +user.empty: +.ee +.in +.ss program source (listxattr.c) +.ex +#include +#include +#include +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + ssize_t buflen, keylen, vallen; + char *buf, *key, *val; + + if (argc != 2) { + fprintf(stderr, "usage: %s path\en", argv[0]); + exit(exit_failure); + } + + /* + * determine the length of the buffer needed. + */ + buflen = listxattr(argv[1], null, 0); + if (buflen == \-1) { + perror("listxattr"); + exit(exit_failure); + } + if (buflen == 0) { + printf("%s has no attributes.\en", argv[1]); + exit(exit_success); + } + + /* + * allocate the buffer. + */ + buf = malloc(buflen); + if (buf == null) { + perror("malloc"); + exit(exit_failure); + } + + /* + * copy the list of attribute keys to the buffer. + */ + buflen = listxattr(argv[1], buf, buflen); + if (buflen == \-1) { + perror("listxattr"); + exit(exit_failure); + } + + /* + * loop over the list of zero terminated strings with the + * attribute keys. use the remaining buffer length to determine + * the end of the list. + */ + key = buf; + while (buflen > 0) { + + /* + * output attribute key. + */ + printf("%s: ", key); + + /* + * determine length of the value. + */ + vallen = getxattr(argv[1], key, null, 0); + if (vallen == \-1) + perror("getxattr"); + + if (vallen > 0) { + + /* + * allocate value buffer. + * one extra byte is needed to append 0x00. + */ + val = malloc(vallen + 1); + if (val == null) { + perror("malloc"); + exit(exit_failure); + } + + /* + * copy value to buffer. + */ + vallen = getxattr(argv[1], key, val, vallen); + if (vallen == \-1) + perror("getxattr"); + else { + /* + * output attribute value. + */ + val[vallen] = 0; + printf("%s", val); + } + + free(val); + } else if (vallen == 0) + printf(""); + + printf("\en"); + + /* + * forward to next attribute key. + */ + keylen = strlen(key) + 1; + buflen \-= keylen; + key += keylen; + } + + free(buf); + exit(exit_success); +} +.ee +.sh see also +.br getfattr (1), +.br setfattr (1), +.br getxattr (2), +.br open (2), +.br removexattr (2), +.br setxattr (2), +.br stat (2), +.br symlink (7), +.br xattr (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/stailq.3 + +.so man3/getfsent.3 + +.\" copyright (c) 1993 michael haardt +.\" (michael@moria.de), fri apr 2 11:32:09 met dst +.\" 1993 +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" modified by thomas koenig (ig25@rz.uni-karlsruhe.de) 24 apr 1993 +.\" modified sat jul 24 17:28:08 1993 by rik faith (faith@cs.unc.edu) +.th intro 7 2007-10-23 "linux" "linux programmer's manual" +.sh name +intro \- introduction to overview and miscellany section +.sh description +section 7 of the manual provides overviews on various topics, and +describes conventions and protocols, +character set standards, the standard filesystem layout, +and miscellaneous other things. +.sh notes +.ss authors and copyright conditions +look at the header of the manual page source for the author(s) and copyright +conditions. +note that these can be different from page to page! +.sh see also +.br standards (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2009 petr baudis +.\" and clean-ups and additions (c) copyright 2010 michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references: http://people.redhat.com/drepper/asynchnl.pdf, +.\" http://www.imperialviolet.org/2005/06/01/asynchronous-dns-lookups-with-glibc.html +.\" +.th getaddrinfo_a 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +getaddrinfo_a, gai_suspend, gai_error, gai_cancel \- asynchronous +network address and service translation +.sh synopsis +.nf +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "int getaddrinfo_a(int " mode ", struct gaicb *" list [restrict], +.bi " int " nitems ", struct sigevent *restrict " sevp ); +.bi "int gai_suspend(const struct gaicb *const " list "[], int " nitems , +.bi " const struct timespec *" timeout ); +.pp +.bi "int gai_error(struct gaicb *" req ); +.bi "int gai_cancel(struct gaicb *" req ); +.pp +link with \fi\-lanl\fp. +.fi +.sh description +the +.br getaddrinfo_a () +function performs the same task as +.br getaddrinfo (3), +but allows multiple name look-ups to be performed asynchronously, +with optional notification on completion of look-up operations. +.pp +the +.i mode +argument has one of the following values: +.tp +.b gai_wait +perform the look-ups synchronously. +the call blocks until the look-ups have completed. +.tp +.b gai_nowait +perform the look-ups asynchronously. +the call returns immediately, +and the requests are resolved in the background. +see the discussion of the +.i sevp +argument below. +.pp +the array +.i list +specifies the look-up requests to process. +the +.i nitems +argument specifies the number of elements in +.ir list . +the requested look-up operations are started in parallel. +null elements in +.i list +are ignored. +each request is described by a +.i gaicb +structure, defined as follows: +.pp +.in +4n +.ex +struct gaicb { + const char *ar_name; + const char *ar_service; + const struct addrinfo *ar_request; + struct addrinfo *ar_result; +}; +.ee +.in +.pp +the elements of this structure correspond to the arguments of +.br getaddrinfo (3). +thus, +.i ar_name +corresponds to the +.i node +argument and +.i ar_service +to the +.i service +argument, identifying an internet host and a service. +the +.i ar_request +element corresponds to the +.i hints +argument, specifying the criteria for selecting +the returned socket address structures. +finally, +.i ar_result +corresponds to the +.i res +argument; you do not need to initialize this element, +it will be automatically set when the request +is resolved. +the +.i addrinfo +structure referenced by the last two elements is described in +.br getaddrinfo (3). +.pp +when +.i mode +is specified as +.br gai_nowait , +notifications about resolved requests +can be obtained by employing the +.i sigevent +structure pointed to by the +.i sevp +argument. +for the definition and general details of this structure, see +.br sigevent (7). +the +.i sevp\->sigev_notify +field can have the following values: +.tp +.br sigev_none +don't provide any notification. +.tp +.br sigev_signal +when a look-up completes, generate the signal +.i sigev_signo +for the process. +see +.br sigevent (7) +for general details. +the +.i si_code +field of the +.i siginfo_t +structure will be set to +.br si_asyncnl . +.\" si_pid and si_uid are also set, to the values of the calling process, +.\" which doesn't provide useful information, so we'll skip mentioning it. +.tp +.br sigev_thread +when a look-up completes, invoke +.i sigev_notify_function +as if it were the start function of a new thread. +see +.br sigevent (7) +for details. +.pp +for +.br sigev_signal +and +.br sigev_thread , +it may be useful to point +.ir sevp\->sigev_value.sival_ptr +to +.ir list . +.pp +the +.br gai_suspend () +function suspends execution of the calling thread, +waiting for the completion of one or more requests in the array +.ir list . +the +.i nitems +argument specifies the size of the array +.ir list . +the call blocks until one of the following occurs: +.ip * 3 +one or more of the operations in +.i list +completes. +.ip * +the call is interrupted by a signal that is caught. +.ip * +the time interval specified in +.i timeout +elapses. +this argument specifies a timeout in seconds plus nanoseconds (see +.br nanosleep (2) +for details of the +.i timespec +structure). +if +.i timeout +is null, then the call blocks indefinitely +(until one of the events above occurs). +.pp +no explicit indication of which request was completed is given; +you must determine which request(s) have completed by iterating with +.br gai_error () +over the list of requests. +.pp +the +.br gai_error () +function returns the status of the request +.ir req : +either +.b eai_inprogress +if the request was not completed yet, +0 if it was handled successfully, +or an error code if the request could not be resolved. +.pp +the +.br gai_cancel () +function cancels the request +.ir req . +if the request has been canceled successfully, +the error status of the request will be set to +.b eai_canceled +and normal asynchronous notification will be performed. +the request cannot be canceled if it is currently being processed; +in that case, it will be handled as if +.br gai_cancel () +has never been called. +if +.i req +is null, an attempt is made to cancel all outstanding requests +that the process has made. +.sh return value +the +.br getaddrinfo_a () +function returns 0 if all of the requests have been enqueued successfully, +or one of the following nonzero error codes: +.tp +.b eai_again +the resources necessary to enqueue the look-up requests were not available. +the application may check the error status of each +request to determine which ones failed. +.tp +.b eai_memory +out of memory. +.tp +.b eai_system +.i mode +is invalid. +.pp +the +.br gai_suspend () +function returns 0 if at least one of the listed requests has been completed. +otherwise, it returns one of the following nonzero error codes: +.tp +.b eai_again +the given timeout expired before any of the requests could be completed. +.tp +.b eai_alldone +there were no actual requests given to the function. +.tp +.b eai_intr +a signal has interrupted the function. +note that this interruption might have been +caused by signal notification of some completed look-up request. +.pp +the +.br gai_error () +function can return +.b eai_inprogress +for an unfinished look-up request, +0 for a successfully completed look-up +(as described above), one of the error codes that could be returned by +.br getaddrinfo (3), +or the error code +.b eai_canceled +if the request has been canceled explicitly before it could be finished. +.pp +the +.br gai_cancel () +function can return one of these values: +.tp +.b eai_canceled +the request has been canceled successfully. +.tp +.b eai_notcanceled +the request has not been canceled. +.tp +.b eai_alldone +the request has already completed. +.pp +the +.br gai_strerror (3) +function translates these error codes to a human readable string, +suitable for error reporting. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br getaddrinfo_a (), +.br gai_suspend (), +.br gai_error (), +.br gai_cancel () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +these functions are gnu extensions; +they first appeared in glibc in version 2.2.3. +.sh notes +the interface of +.br getaddrinfo_a () +was modeled after the +.br lio_listio (3) +interface. +.sh examples +two examples are provided: a simple example that resolves +several requests in parallel synchronously, and a complex example +showing some of the asynchronous capabilities. +.ss synchronous example +the program below simply resolves several hostnames in parallel, +giving a speed-up compared to resolving the hostnames sequentially using +.br getaddrinfo (3). +the program might be used like this: +.pp +.in +4n +.ex +$ \fb./a.out ftp.us.kernel.org enoent.linuxfoundation.org gnu.cz\fp +ftp.us.kernel.org: 128.30.2.36 +enoent.linuxfoundation.org: name or service not known +gnu.cz: 87.236.197.13 +.ee +.in +.pp +here is the program source code +.pp +.ex +#define _gnu_source +#include +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + int ret; + struct gaicb *reqs[argc \- 1]; + char host[ni_maxhost]; + struct addrinfo *res; + + if (argc < 2) { + fprintf(stderr, "usage: %s host...\en", argv[0]); + exit(exit_failure); + } + + for (int i = 0; i < argc \- 1; i++) { + reqs[i] = malloc(sizeof(*reqs[0])); + if (reqs[i] == null) { + perror("malloc"); + exit(exit_failure); + } + memset(reqs[i], 0, sizeof(*reqs[0])); + reqs[i]\->ar_name = argv[i + 1]; + } + + ret = getaddrinfo_a(gai_wait, reqs, argc \- 1, null); + if (ret != 0) { + fprintf(stderr, "getaddrinfo_a() failed: %s\en", + gai_strerror(ret)); + exit(exit_failure); + } + + for (int i = 0; i < argc \- 1; i++) { + printf("%s: ", reqs[i]\->ar_name); + ret = gai_error(reqs[i]); + if (ret == 0) { + res = reqs[i]\->ar_result; + + ret = getnameinfo(res\->ai_addr, res\->ai_addrlen, + host, sizeof(host), + null, 0, ni_numerichost); + if (ret != 0) { + fprintf(stderr, "getnameinfo() failed: %s\en", + gai_strerror(ret)); + exit(exit_failure); + } + puts(host); + + } else { + puts(gai_strerror(ret)); + } + } + exit(exit_success); +} +.ee +.ss asynchronous example +this example shows a simple interactive +.br getaddrinfo_a () +front-end. +the notification facility is not demonstrated. +.pp +an example session might look like this: +.pp +.in +4n +.ex +$ \fb./a.out\fp +> a ftp.us.kernel.org enoent.linuxfoundation.org gnu.cz +> c 2 +[2] gnu.cz: request not canceled +> w 0 1 +[00] ftp.us.kernel.org: finished +> l +[00] ftp.us.kernel.org: 216.165.129.139 +[01] enoent.linuxfoundation.org: processing request in progress +[02] gnu.cz: 87.236.197.13 +> l +[00] ftp.us.kernel.org: 216.165.129.139 +[01] enoent.linuxfoundation.org: name or service not known +[02] gnu.cz: 87.236.197.13 +.ee +.in +.pp +the program source is as follows: +.pp +.ex +#define _gnu_source +#include +#include +#include +#include + +static struct gaicb **reqs = null; +static int nreqs = 0; + +static char * +getcmd(void) +{ + static char buf[256]; + + fputs("> ", stdout); fflush(stdout); + if (fgets(buf, sizeof(buf), stdin) == null) + return null; + + if (buf[strlen(buf) \- 1] == \(aq\en\(aq) + buf[strlen(buf) \- 1] = 0; + + return buf; +} + +/* add requests for specified hostnames. */ +static void +add_requests(void) +{ + int nreqs_base = nreqs; + char *host; + int ret; + + while ((host = strtok(null, " "))) { + nreqs++; + reqs = realloc(reqs, sizeof(reqs[0]) * nreqs); + + reqs[nreqs \- 1] = calloc(1, sizeof(*reqs[0])); + reqs[nreqs \- 1]\->ar_name = strdup(host); + } + + /* queue nreqs_base..nreqs requests. */ + + ret = getaddrinfo_a(gai_nowait, &reqs[nreqs_base], + nreqs \- nreqs_base, null); + if (ret) { + fprintf(stderr, "getaddrinfo_a() failed: %s\en", + gai_strerror(ret)); + exit(exit_failure); + } +} + +/* wait until at least one of specified requests completes. */ +static void +wait_requests(void) +{ + char *id; + int ret, n; + struct gaicb const **wait_reqs = calloc(nreqs, sizeof(*wait_reqs)); + /* null elements are ignored by gai_suspend(). */ + + while ((id = strtok(null, " ")) != null) { + n = atoi(id); + + if (n >= nreqs) { + printf("bad request number: %s\en", id); + return; + } + + wait_reqs[n] = reqs[n]; + } + + ret = gai_suspend(wait_reqs, nreqs, null); + if (ret) { + printf("gai_suspend(): %s\en", gai_strerror(ret)); + return; + } + + for (int i = 0; i < nreqs; i++) { + if (wait_reqs[i] == null) + continue; + + ret = gai_error(reqs[i]); + if (ret == eai_inprogress) + continue; + + printf("[%02d] %s: %s\en", i, reqs[i]\->ar_name, + ret == 0 ? "finished" : gai_strerror(ret)); + } +} + +/* cancel specified requests. */ +static void +cancel_requests(void) +{ + char *id; + int ret, n; + + while ((id = strtok(null, " ")) != null) { + n = atoi(id); + + if (n >= nreqs) { + printf("bad request number: %s\en", id); + return; + } + + ret = gai_cancel(reqs[n]); + printf("[%s] %s: %s\en", id, reqs[atoi(id)]\->ar_name, + gai_strerror(ret)); + } +} + +/* list all requests. */ +static void +list_requests(void) +{ + int ret; + char host[ni_maxhost]; + struct addrinfo *res; + + for (int i = 0; i < nreqs; i++) { + printf("[%02d] %s: ", i, reqs[i]\->ar_name); + ret = gai_error(reqs[i]); + + if (!ret) { + res = reqs[i]\->ar_result; + + ret = getnameinfo(res\->ai_addr, res\->ai_addrlen, + host, sizeof(host), + null, 0, ni_numerichost); + if (ret) { + fprintf(stderr, "getnameinfo() failed: %s\en", + gai_strerror(ret)); + exit(exit_failure); + } + puts(host); + } else { + puts(gai_strerror(ret)); + } + } +} + +int +main(int argc, char *argv[]) +{ + char *cmdline; + char *cmd; + + while ((cmdline = getcmd()) != null) { + cmd = strtok(cmdline, " "); + + if (cmd == null) { + list_requests(); + } else { + switch (cmd[0]) { + case \(aqa\(aq: + add_requests(); + break; + case \(aqw\(aq: + wait_requests(); + break; + case \(aqc\(aq: + cancel_requests(); + break; + case \(aql\(aq: + list_requests(); + break; + default: + fprintf(stderr, "bad command: %c\en", cmd[0]); + break; + } + } + } + exit(exit_success); +} +.ee +.sh see also +.br getaddrinfo (3), +.br inet (3), +.br lio_listio (3), +.br hostname (7), +.br ip (7), +.br sigevent (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" +.\" modified, aeb, 990824 +.\" +.th mb_cur_max 3 2015-08-08 "linux" "linux programmer's manual" +.sh name +mb_cur_max \- maximum length of a multibyte character in the current locale +.sh synopsis +.nf +.b #include +.fi +.sh description +the +.b mb_cur_max +macro defines an integer expression giving +the maximum number of bytes needed to represent a single +wide character in the current locale. +this value is locale dependent and therefore not a compile-time constant. +.sh return value +an integer in the range [1, +.br mb_len_max ]. +the value 1 denotes traditional 8-bit encoded characters. +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh see also +.br mb_len_max (3), +.br mblen (3), +.br mbstowcs (3), +.br mbtowc (3), +.br wcstombs (3), +.br wctomb (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/getopt.3 + +.so man3/sigvec.3 + +.so man3/scalbln.3 + +.so man3/exp10.3 + +.so man3/getpwnam.3 + +.so man3/dlopen.3 + +.\" copyright 2007 (c) michael kerrisk +.\" some parts copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sat jul 24 21:46:21 1993 by rik faith (faith@cs.unc.edu) +.\" modified fri aug 4 10:51:53 2000 - patch from joseph s. myers +.\" 2007-12-15, mtk, mostly rewritten +.\" +.th abort 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +abort \- cause abnormal process termination +.sh synopsis +.nf +.b #include +.pp +.b noreturn void abort(void); +.fi +.sh description +the +.br abort () +function first unblocks the +.b sigabrt +signal, and then raises that signal for the calling process +(as though +.br raise (3) +was called). +this results in the abnormal termination of the process unless the +.b sigabrt +signal is caught and the signal handler does not return +(see +.br longjmp (3)). +.pp +if the +.b sigabrt +signal is ignored, or caught by a handler that returns, the +.br abort () +function will still terminate the process. +it does this by restoring the default disposition for +.b sigabrt +and then raising the signal for a second time. +.sh return value +the +.br abort () +function never returns. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br abort () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +svr4, posix.1-2001, posix.1-2008, 4.3bsd, c89, c99. +.sh notes +up until glibc 2.26, +if the +.br abort () +function caused process termination, +all open streams were closed and flushed (as with +.br fclose (3)). +however, in some cases this could result in deadlocks and data corruption. +therefore, starting with glibc 2.27, +.\" glibc commit 91e7cf982d0104f0e71770f5ae8e3faf352dea9f +.br abort () +terminates the process without flushing streams. +posix.1 permits either possible behavior, saying that +.br abort () +"may include an attempt to effect fclose() on all open streams". +.sh see also +.br gdb (1), +.br sigaction (2), +.br assert (3), +.br exit (3), +.br longjmp (3), +.br raise (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2006 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th sem_destroy 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +sem_destroy \- destroy an unnamed semaphore +.sh synopsis +.nf +.b #include +.pp +.bi "int sem_destroy(sem_t *" sem ); +.fi +.pp +link with \fi\-pthread\fp. +.sh description +.br sem_destroy () +destroys the unnamed semaphore at the address pointed to by +.ir sem . +.pp +only a semaphore that has been initialized by +.br sem_init (3) +should be destroyed using +.br sem_destroy (). +.pp +destroying a semaphore that other processes or threads are +currently blocked on (in +.br sem_wait (3)) +produces undefined behavior. +.pp +using a semaphore that has been destroyed produces undefined results, +until the semaphore has been reinitialized using +.br sem_init (3). +.sh return value +.br sem_destroy () +returns 0 on success; +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b einval +.i sem +is not a valid semaphore. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br sem_destroy () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +an unnamed semaphore should be destroyed with +.br sem_destroy () +before the memory in which it is located is deallocated. +failure to do this can result in resource leaks on some implementations. +.\" but not on nptl, where sem_destroy () is a no-op.. +.sh see also +.br sem_init (3), +.br sem_post (3), +.br sem_wait (3), +.br sem_overview (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/rpc.3 + +.so man3/__ppc_yield.3 + +.\" copyright 2000 sam varshavchik +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references: rfc 2553 +.th inet_ntop 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +inet_ntop \- convert ipv4 and ipv6 addresses from binary to text form +.sh synopsis +.nf +.b #include +.pp +.bi "const char *inet_ntop(int " af ", const void *restrict " src , +.bi " char *restrict " dst ", socklen_t " size ); +.fi +.sh description +this function converts the network address structure +.i src +in the +.i af +address family into a character string. +the resulting string is copied to the buffer pointed to by +.ir dst , +which must be a non-null pointer. +the caller specifies the number of bytes available in this buffer in +the argument +.ir size . +.pp +.br inet_ntop () +extends the +.br inet_ntoa (3) +function to support multiple address families, +.br inet_ntoa (3) +is now considered to be deprecated in favor of +.br inet_ntop (). +the following address families are currently supported: +.tp +.b af_inet +.i src +points to a +.i struct in_addr +(in network byte order) +which is converted to an ipv4 network address in +the dotted-decimal format, "\fiddd.ddd.ddd.ddd\fp". +the buffer +.i dst +must be at least +.b inet_addrstrlen +bytes long. +.tp +.b af_inet6 +.i src +points to a +.i struct in6_addr +(in network byte order) +which is converted to a representation of this address in the +most appropriate ipv6 network address format for this address. +the buffer +.i dst +must be at least +.b inet6_addrstrlen +bytes long. +.sh return value +on success, +.br inet_ntop () +returns a non-null pointer to +.ir dst . +null is returned if there was an error, with +.i errno +set to indicate the error. +.sh errors +.tp +.b eafnosupport +.i af +was not a valid address family. +.tp +.b enospc +the converted address string would exceed the size given by +.ir size . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br inet_ntop () +t} thread safety mt-safe locale +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +note that rfc\ 2553 defines a prototype where the last argument +.i size +is of type +.ir size_t . +many systems follow rfc\ 2553. +glibc 2.0 and 2.1 have +.ir size_t , +but 2.2 and later have +.ir socklen_t . +.\" 2.1.3: size_t, 2.1.91: socklen_t +.sh bugs +.b af_inet6 +converts ipv4-mapped ipv6 addresses into an ipv6 format. +.sh examples +see +.br inet_pton (3). +.sh see also +.br getnameinfo (3), +.br inet (3), +.br inet_pton (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de) +.\" and copyright 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under gpl +.\" %%%license_end +.\" +.th fmin 3 2021-03-22 "" "linux programmer's manual" +.sh name +fmin, fminf, fminl \- determine minimum of two floating-point numbers +.sh synopsis +.nf +.b #include +.pp +.bi "double fmin(double " x ", double " y ); +.bi "float fminf(float " x ", float " y ); +.bi "long double fminl(long double " x ", long double " y ); +.fi +.pp +link with \fi\-lm\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br fmin (), +.br fminf (), +.br fminl (): +.nf + _isoc99_source || _posix_c_source >= 200112l +.fi +.sh description +these functions return the lesser value of +.i x +and +.ir y . +.sh return value +these functions return the minimum of +.i x +and +.ir y . +.pp +if one argument is a nan, the other argument is returned. +.pp +if both arguments are nan, a nan is returned. +.sh errors +no errors occur. +.sh versions +these functions first appeared in glibc in version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br fmin (), +.br fminf (), +.br fminl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.sh see also +.br fdim (3), +.br fmax (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified 1993-04-02, david metcalfe +.\" modified 1993-07-25, rik faith (faith@cs.unc.edu) +.th on_exit 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +on_exit \- register a function to be called at normal process termination +.sh synopsis +.nf +.b #include +.pp +.bi "int on_exit(void (*" function ")(int, void *), void *" arg ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br on_exit (): +.nf + since glibc 2.19: + _default_source + glibc 2.19 and earlier: + _bsd_source || _svid_source +.fi +.sh description +the +.br on_exit () +function registers the given +.i function +to be +called at normal process termination, whether via +.br exit (3) +or via return from the program's +.ir main (). +the +.i function +is passed the status argument given to the last call to +.br exit (3) +and the +.i arg +argument from +.br on_exit (). +.pp +the same function may be registered multiple times: +it is called once for each registration. +.pp +when a child process is created via +.br fork (2), +it inherits copies of its parent's registrations. +upon a successful call to one of the +.br exec (3) +functions, all registrations are removed. +.sh return value +the +.br on_exit () +function returns the value 0 if successful; otherwise +it returns a nonzero value. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br on_exit () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +this function comes from sunos 4, but is also present in glibc. +it no longer occurs in solaris (sunos 5). +portable application should avoid this function, and use the standard +.br atexit (3) +instead. +.sh notes +by the time +.i function +is executed, stack +.ri ( auto ) +variables may already have gone out of scope. +therefore, +.i arg +should not be a pointer to a stack variable; +it may however be a pointer to a heap variable or a global variable. +.sh see also +.br _exit (2), +.br atexit (3), +.br exit (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/select.2 + +.\" copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de) +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under gpl +.\" %%%license_end +.\" +.th cexp 3 2021-03-22 "" "linux programmer's manual" +.sh name +cexp, cexpf, cexpl \- complex exponential function +.sh synopsis +.nf +.b #include +.pp +.bi "double complex cexp(double complex " z ");" +.bi "float complex cexpf(float complex " z ");" +.bi "long double complex cexpl(long double complex " z ");" +.pp +link with \fi\-lm\fp. +.fi +.sh description +these functions calculate e (2.71828..., the base of natural logarithms) +raised to the power of +.ir z . +.pp +one has: +.pp +.nf + cexp(i * z) = ccos(z) + i * csin(z) +.fi +.sh versions +these functions first appeared in glibc in version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br cexp (), +.br cexpf (), +.br cexpl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.sh see also +.br cabs (3), +.br cexp2 (3), +.br clog (3), +.br cpow (3), +.br complex (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/circleq.3 + +.so man3/tailq.3 + +.so man2/clock_getres.2 + +.\" copyright (c) 1993 by thomas koenig (ig25@rz.uni-karlsruhe.de) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified sat jul 24 21:27:01 1993 by rik faith (faith@cs.unc.edu) +.\" modified 14 jun 2002, michael kerrisk +.\" added notes on differences from other unix systems with respect to +.\" waited-for children. +.th clock 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +clock \- determine processor time +.sh synopsis +.nf +.b #include +.pp +.b clock_t clock(void); +.fi +.sh description +the +.br clock () +function returns an approximation of processor time used by the program. +.sh return value +the value returned is the cpu time used so far as a +.ir clock_t ; +to get the number of seconds used, divide by +.br clocks_per_sec . +if the processor time used is not available or its value cannot +be represented, the function returns the value +.ir (clock_t)\ \-1 . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br clock () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c89, c99. +xsi requires that +.b clocks_per_sec +equals 1000000 independent +of the actual resolution. +.sh notes +the c standard allows for arbitrary values at the start of the program; +subtract the value returned from a call to +.br clock () +at the start of the program to get maximum portability. +.pp +note that the time can wrap around. +on a 32-bit system where +.b clocks_per_sec +equals 1000000 this function will return the same +value approximately every 72 minutes. +.pp +on several other implementations, +the value returned by +.br clock () +also includes the times of any children whose status has been +collected via +.br wait (2) +(or another wait-type call). +linux does not include the times of waited-for children in the +value returned by +.br clock (). +.\" i have seen this behavior on irix 6.3, and the osf/1, hp/ux, and +.\" solaris manual pages say that clock() also does this on those systems. +.\" posix.1-2001 doesn't explicitly allow this, nor is there an +.\" explicit prohibition. -- mtk +the +.br times (2) +function, which explicitly returns (separate) information about the +caller and its children, may be preferable. +.pp +in glibc 2.17 and earlier, +.br clock () +was implemented on top of +.br times (2). +for improved accuracy, +since glibc 2.18, it is implemented on top of +.br clock_gettime (2) +(using the +.br clock_process_cputime_id +clock). +.sh see also +.br clock_gettime (2), +.br getrusage (2), +.br times (2) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" +.\" modified sun feb 26 14:52:00 1995 by rik faith +.\" modified tue oct 22 23:48:10 1996 by eric s. raymond +.\" " +.th bcopy 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +bcopy \- copy byte sequence +.sh synopsis +.nf +.b #include +.pp +.bi "void bcopy(const void *" src ", void *" dest ", size_t " n ); +.fi +.sh description +the +.br bcopy () +function copies +.i n +bytes from +.i src +to +.ir dest . +the result is correct, even when both areas overlap. +.sh return value +none. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br bcopy () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +4.3bsd. +this function is deprecated (marked as legacy in posix.1-2001): use +.br memcpy (3) +or +.br memmove (3) +in new programs. +note that the first two arguments +are interchanged for +.br memcpy (3) +and +.br memmove (3). +posix.1-2008 removes the specification of +.br bcopy (). +.sh see also +.br bstring (3), +.br memccpy (3), +.br memcpy (3), +.br memmove (3), +.br strcpy (3), +.br strncpy (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/pread.2 + +.so man2/seteuid.2 + +.so man3/timeradd.3 + +.\" copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de) +.\" and copyright 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under gpl +.\" %%%license_end +.\" +.\" based on glibc infopages +.\" polished, aeb +.\" +.th remquo 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +remquo, remquof, remquol \- remainder and part of quotient +.sh synopsis +.nf +.b #include +.pp +.bi "double remquo(double " x ", double " y ", int *" quo ); +.bi "float remquof(float " x ", float " y ", int *" quo ); +.bi "long double remquol(long double " x ", long double " y ", int *" quo ); +.fi +.pp +link with \fi\-lm\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br remquo (), +.br remquof (), +.br remquol (): +.nf + _isoc99_source || _posix_c_source >= 200112l +.fi +.sh description +these functions compute the remainder and part of the quotient +upon division of +.i x +by +.ir y . +a few bits of the quotient are stored via the +.i quo +pointer. +the remainder is returned as the function result. +.pp +the value of the remainder is the same as that computed by the +.br remainder (3) +function. +.pp +the value stored via the +.i quo +pointer has the sign of +.ir "x\ /\ y" +and agrees with the quotient in at least the low order 3 bits. +.pp +for example, \firemquo(29.0,\ 3.0)\fp returns \-1.0 and might store 2. +note that the actual quotient might not fit in an integer. +.\" a possible application of this function might be the computation +.\" of sin(x). compute remquo(x, pi/2, &quo) or so. +.\" +.\" glibc, unixware: return 3 bits +.\" macos 10: return 7 bits +.sh return value +on success, these functions return the same value as +the analogous functions described in +.br remainder (3). +.pp +if +.i x +or +.i y +is a nan, a nan is returned. +.pp +if +.i x +is an infinity, +and +.i y +is not a nan, +a domain error occurs, and +a nan is returned. +.pp +if +.i y +is zero, +and +.i x +is not a nan, +a domain error occurs, and +a nan is returned. +.sh errors +see +.br math_error (7) +for information on how to determine whether an error has occurred +when calling these functions. +.pp +the following errors can occur: +.tp +domain error: \fix\fp is an infinity or \fiy\fp is 0, \ +and the other argument is not a nan +.\" .i errno +.\" is set to +.\" .br edom . +an invalid floating-point exception +.rb ( fe_invalid ) +is raised. +.pp +these functions do not set +.ir errno . +.\" fixme . is it intentional that these functions do not set errno? +.\" bug raised: http://sources.redhat.com/bugzilla/show_bug.cgi?id=6802 +.sh versions +these functions first appeared in glibc in version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br remquo (), +.br remquof (), +.br remquol () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.sh see also +.br fmod (3), +.br logb (3), +.br remainder (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/posix_memalign.3 + +.\" copyright (c) 2001 andries brouwer +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th getpagesize 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +getpagesize \- get memory page size +.sh synopsis +.nf +.b #include +.pp +.b int getpagesize(void); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br getpagesize (): +.nf + since glibc 2.20: + _default_source || ! (_posix_c_source >= 200112l) + glibc 2.12 to 2.19: + _bsd_source || ! (_posix_c_source >= 200112l) + before glibc 2.12: + _bsd_source || _xopen_source >= 500 +.\" || _xopen_source && _xopen_source_extended +.fi +.sh description +the function +.br getpagesize () +returns the number of bytes in a memory page, +where "page" is a fixed-length block, +the unit for memory allocation and file mapping performed by +.br mmap (2). +.\" .sh history +.\" this call first appeared in 4.2bsd. +.sh conforming to +svr4, 4.4bsd, susv2. +in susv2 the +.br getpagesize () +call is labeled legacy, and in posix.1-2001 +it has been dropped; +hp-ux does not have this call. +.sh notes +portable applications should employ +.i sysconf(_sc_pagesize) +instead of +.br getpagesize (): +.pp +.in +4n +.ex +#include +long sz = sysconf(_sc_pagesize); +.ee +.in +.pp +(most systems allow the synonym +.b _sc_page_size +for +.br _sc_pagesize .) +.pp +whether +.br getpagesize () +is present as a linux system call depends on the architecture. +if it is, it returns the kernel symbol +.br page_size , +whose value depends on the architecture and machine model. +generally, one uses binaries that are dependent on the architecture but not +on the machine model, in order to have a single binary +distribution per architecture. +this means that a user program +should not find +.b page_size +at compile time from a header file, +but use an actual system call, at least for those architectures +(like sun4) where this dependency exists. +here glibc 2.0 fails because its +.br getpagesize () +returns a statically derived value, and does not use a system call. +things are ok in glibc 2.1. +.sh see also +.br mmap (2), +.br sysconf (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/list.3 + +.\" copyright 2014 (c) marko myllynen +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th cp1252 7 2020-08-13 "linux" "linux programmer's manual" +.sh name +cp1252 \- cp\ 1252 character set encoded in octal, decimal, +and hexadecimal +.sh description +the windows code pages include several 8-bit extensions to the ascii +character set (also known as iso 646-irv). +cp\ 1252 encodes the +characters used in many west european languages. +.ss cp\ 1252 characters +the following table displays the characters in cp\ 1252 that +are printable and unlisted in the +.br ascii (7) +manual page. +.ts +l l l c lp-1. +oct dec hex char description +_ +200 128 80 € euro sign +202 130 82 ‚ single low-9 quotation mark +203 131 83 ƒ latin small letter f with hook +204 132 84 „ double low-9 quotation mark +205 133 85 … horizontal ellipsis +206 134 86 † dagger +207 135 87 ‡ double dagger +210 136 88 ˆ modifier letter circumflex accent +211 137 89 ‰ per mille sign +212 138 8a š latin capital letter s with caron +213 139 8b ‹ single left-pointing angle quotation mark +214 140 8c œ latin capital ligature oe +216 142 8e ž latin capital letter z with caron +221 145 91 ‘ left single quotation mark +222 146 92 ’ right single quotation mark +223 147 93 “ left double quotation mark +224 148 94 ” right double quotation mark +225 149 95 • bullet +226 150 96 – en dash +227 151 97 — em dash +230 152 98 ˜ small tilde +231 153 99 ™ trade mark sign +232 154 9a š latin small letter s with caron +233 155 9b › single right-pointing angle quotation mark +234 156 9c œ latin small ligature oe +236 158 9e ž latin small letter z with caron +237 159 9f ÿ latin capital letter y with diaeresis +240 160 a0   no-break space +241 161 a1 ¡ inverted exclamation mark +242 162 a2 ¢ cent sign +243 163 a3 £ pound sign +244 164 a4 ¤ currency sign +245 165 a5 ¥ yen sign +246 166 a6 ¦ broken bar +247 167 a7 § section sign +250 168 a8 ¨ diaeresis +251 169 a9 © copyright sign +252 170 aa ª feminine ordinal indicator +253 171 ab « left-pointing double angle quotation mark +254 172 ac ¬ not sign +255 173 ad ­ soft hyphen +256 174 ae ® registered sign +257 175 af ¯ macron +260 176 b0 ° degree sign +261 177 b1 ± plus-minus sign +262 178 b2 ² superscript two +263 179 b3 ³ superscript three +264 180 b4 ´ acute accent +265 181 b5 µ micro sign +266 182 b6 ¶ pilcrow sign +267 183 b7 · middle dot +270 184 b8 ¸ cedilla +271 185 b9 ¹ superscript one +272 186 ba º masculine ordinal indicator +273 187 bb » right-pointing double angle quotation mark +274 188 bc ¼ vulgar fraction one quarter +275 189 bd ½ vulgar fraction one half +276 190 be ¾ vulgar fraction three quarters +277 191 bf ¿ inverted question mark +300 192 c0 à latin capital letter a with grave +301 193 c1 á latin capital letter a with acute +302 194 c2 â latin capital letter a with circumflex +303 195 c3 ã latin capital letter a with tilde +304 196 c4 ä latin capital letter a with diaeresis +305 197 c5 å latin capital letter a with ring above +306 198 c6 æ latin capital letter ae +307 199 c7 ç latin capital letter c with cedilla +310 200 c8 è latin capital letter e with grave +311 201 c9 é latin capital letter e with acute +312 202 ca ê latin capital letter e with circumflex +313 203 cb ë latin capital letter e with diaeresis +314 204 cc ì latin capital letter i with grave +315 205 cd í latin capital letter i with acute +316 206 ce î latin capital letter i with circumflex +317 207 cf ï latin capital letter i with diaeresis +320 208 d0 ð latin capital letter eth +321 209 d1 ñ latin capital letter n with tilde +322 210 d2 ò latin capital letter o with grave +323 211 d3 ó latin capital letter o with acute +324 212 d4 ô latin capital letter o with circumflex +325 213 d5 õ latin capital letter o with tilde +326 214 d6 ö latin capital letter o with diaeresis +327 215 d7 × multiplication sign +330 216 d8 ø latin capital letter o with stroke +331 217 d9 ù latin capital letter u with grave +332 218 da ú latin capital letter u with acute +333 219 db û latin capital letter u with circumflex +334 220 dc ü latin capital letter u with diaeresis +335 221 dd ý latin capital letter y with acute +336 222 de þ latin capital letter thorn +337 223 df ß latin small letter sharp s +340 224 e0 à latin small letter a with grave +341 225 e1 á latin small letter a with acute +342 226 e2 â latin small letter a with circumflex +343 227 e3 ã latin small letter a with tilde +344 228 e4 ä latin small letter a with diaeresis +345 229 e5 å latin small letter a with ring above +346 230 e6 æ latin small letter ae +347 231 e7 ç latin small letter c with cedilla +350 232 e8 è latin small letter e with grave +351 233 e9 é latin small letter e with acute +352 234 ea ê latin small letter e with circumflex +353 235 eb ë latin small letter e with diaeresis +354 236 ec ì latin small letter i with grave +355 237 ed í latin small letter i with acute +356 238 ee î latin small letter i with circumflex +357 239 ef ï latin small letter i with diaeresis +360 240 f0 ð latin small letter eth +361 241 f1 ñ latin small letter n with tilde +362 242 f2 ò latin small letter o with grave +363 243 f3 ó latin small letter o with acute +364 244 f4 ô latin small letter o with circumflex +365 245 f5 õ latin small letter o with tilde +366 246 f6 ö latin small letter o with diaeresis +367 247 f7 ÷ division sign +370 248 f8 ø latin small letter o with stroke +371 249 f9 ù latin small letter u with grave +372 250 fa ú latin small letter u with acute +373 251 fb û latin small letter u with circumflex +374 252 fc ü latin small letter u with diaeresis +375 253 fd ý latin small letter y with acute +376 254 fe þ latin small letter thorn +377 255 ff ÿ latin small letter y with diaeresis +.te +.sh notes +cp\ 1252 is also known as windows-1252. +.sh see also +.br ascii (7), +.br charsets (7), +.br cp1251 (7), +.br iso_8859\-1 (7), +.br iso_8859\-15 (7), +.br utf\-8 (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/getaddrinfo.3 + +.so man3/unlocked_stdio.3 + +.so man3/isalpha.3 + +.so man3/circleq.3 + +.so man3/nextup.3 + +.\" and copyright (c) 2014 michael kerrisk +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" iso/iec 9899:1999 +.\" +.th towupper 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +towupper, towupper_l \- convert a wide character to uppercase +.sh synopsis +.nf +.b #include +.pp +.bi "wint_t towupper(wint_t " wc ); +.bi "wint_t towupper_l(wint_t " wc ", locale_t " locale ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br towupper_l (): +.nf + since glibc 2.10: + _xopen_source >= 700 + before glibc 2.10: + _gnu_source +.fi +.sh description +the +.br towupper () +function is the wide-character equivalent of the +.br toupper (3) +function. +if +.i wc +is a lowercase wide character, +and there exists an uppercase equivalent in the current locale, +it returns the uppercase equivalent of +.ir wc . +in all other cases, +.i wc +is returned unchanged. +.pp +the +.br towupper_l () +function performs the same task, +but performs the conversion based on the character type information in +the locale specified by +.ir locale . +the behavior of +.br towupper_l () +is undefined if +.i locale +is the special locale object +.b lc_global_locale +(see +.br duplocale (3)) +or is not a valid locale object handle. +.pp +the argument +.i wc +must be representable as a +.i wchar_t +and be a valid character in the locale or be the value +.br weof . +.sh return value +if +.i wc +was convertible to uppercase, +.br towupper () +returns its uppercase equivalent; +otherwise it returns +.ir wc . +.sh versions +the +.br towupper_l () +function first appeared in glibc 2.3. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br towupper () +t} thread safety mt-safe locale +t{ +.br towupper_l () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +.br towupper (): +c99, posix.1-2001 (xsi); +present as an xsi extension in posix.1-2008, but marked obsolete. +.pp +.br towupper_l (): +posix.1-2008. +.sh notes +the behavior of these functions depends on the +.b lc_ctype +category of the locale. +.pp +these functions are not very appropriate for dealing with unicode characters, +because unicode knows about three cases: upper, lower, and title case. +.sh see also +.br iswupper (3), +.br towctrans (3), +.br towlower (3), +.br locale (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/strdup.3 + +.so man3/rpc.3 + +.\" copyright 1993 rickard e. faith (faith@cs.unc.edu) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified fri jun 23 01:35:19 1995 andries brouwer +.\" (prompted by bas v. de bakker ) +.\" corrected (and moved to man3), 980612, aeb +.th profil 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +profil \- execution time profile +.sh synopsis +.nf +.b #include +.pp +.bi "int profil(unsigned short *" buf ", size_t " bufsiz , +.bi " size_t " offset ", unsigned int " scale ); +.pp +.fi +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br profil (): +.nf + since glibc 2.21: +.\" commit 266865c0e7b79d4196e2cc393693463f03c90bd8 + _default_source + in glibc 2.19 and 2.20: + _default_source || (_xopen_source && _xopen_source < 500) + up to and including glibc 2.19: + _bsd_source || (_xopen_source && _xopen_source < 500) +.fi +.sh description +this routine provides a means to find out in what areas your program +spends most of its time. +the argument +.i buf +points to +.i bufsiz +bytes of core. +every virtual 10 milliseconds, the user's program counter (pc) +is examined: +.i offset +is subtracted and the result is multiplied by +.i scale +and divided by 65536. +if the resulting value is less than +.ir bufsiz , +then the corresponding entry in +.i buf +is incremented. +if +.i buf +is null, profiling is disabled. +.sh return value +zero is always returned. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br profil () +t} thread safety mt-unsafe +.te +.hy +.ad +.sp 1 +.sh conforming to +similar to a call in svr4 (but not posix.1). +.sh bugs +.br profil () +cannot be used on a program that also uses +.b itimer_prof +interval timers (see +.br setitimer (2)). +.pp +true kernel profiling provides more accurate results. +.\" libc 4.4 contained a kernel patch providing a system call profil. +.sh see also +.br gprof (1), +.br sprof (1), +.br setitimer (2), +.br sigaction (2), +.br signal (2) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/getsockopt.2 + +.so man3/cosh.3 + +.\" copyright (c) 1993 michael haardt (michael@moria.de), +.\" fri apr 2 11:32:09 met dst 1993 +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" modified sat jul 24 17:06:03 1993 by rik faith (faith@cs.unc.edu) +.th group 5 2020-04-11 "linux" "linux programmer's manual" +.sh name +group \- user group file +.sh description +the +.i /etc/group +file is a text file that defines the groups on the system. +there is one entry per line, with the following format: +.pp +.in +4n +.ex +group_name:password:gid:user_list +.ee +.in +.pp +the fields are as follows: +.tp +.i group_name +the name of the group. +.tp +.i password +the (encrypted) group password. +if this field is empty, no password is needed. +.tp +.i gid +the numeric group id. +.tp +.i user_list +a list of the usernames that are members of this group, separated by commas. +.sh files +.i /etc/group +.sh bugs +as the 4.2bsd +.br initgroups (3) +man page says: no one seems to keep +.i /etc/group +up-to-date. +.sh see also +.br chgrp (1), +.br gpasswd (1), +.br groups (1), +.br login (1), +.br newgrp (1), +.br sg (1), +.br getgrent (3), +.br getgrnam (3), +.br gshadow (5), +.br passwd (5), +.br vigr (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 2009 lefteris dimitroulakis +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\"thanomsub noppaburana made valuable suggestions. +.\" +.th iso_8859-11 7 2020-08-13 "linux" "linux programmer's manual" +.sh name +iso_8859-11 \- iso 8859-11 character set encoded in octal, decimal, +and hexadecimal +.sh description +the iso 8859 standard includes several 8-bit extensions to the ascii +character set (also known as iso 646-irv). +iso 8859-11 encodes the +characters used in the thai language. +.ss iso 8859 alphabets +the full set of iso 8859 alphabets includes: +.ts +l l. +iso 8859-1 west european languages (latin-1) +iso 8859-2 central and east european languages (latin-2) +iso 8859-3 southeast european and miscellaneous languages (latin-3) +iso 8859-4 scandinavian/baltic languages (latin-4) +iso 8859-5 latin/cyrillic +iso 8859-6 latin/arabic +iso 8859-7 latin/greek +iso 8859-8 latin/hebrew +iso 8859-9 latin-1 modification for turkish (latin-5) +iso 8859-10 lappish/nordic/eskimo languages (latin-6) +iso 8859-11 latin/thai +iso 8859-13 baltic rim languages (latin-7) +iso 8859-14 celtic (latin-8) +iso 8859-15 west european languages (latin-9) +iso 8859-16 romanian (latin-10) +.te +.ss iso 8859-11 characters +the following table displays the characters in iso 8859-11 that +are printable and unlisted in the +.br ascii (7) +manual page. +.ts +l l l c lp-1. +oct dec hex char description +_ +240 160 a0   no-break space +241 161 a1 ก thai character ko kai +242 162 a2 ข thai character kho khai +243 163 a3 ฃ thai character kho khuat +244 164 a4 ค thai character kho khwai +245 165 a5 ฅ thai character kho khon +246 166 a6 ฆ thai character kho rakhang +247 167 a7 ง thai character ngo ngu +250 168 a8 จ thai character cho chan +251 169 a9 ฉ thai character cho ching +252 170 aa ช thai character cho chang +253 171 ab ซ thai character so so +254 172 ac ฌ thai character cho choe +255 173 ad ญ thai character yo ying +256 174 ae ฎ thai character do chada +257 175 af ฏ thai character to patak +260 176 b0 ฐ thai character tho than +261 177 b1 ฑ thai character tho nangmontho +262 178 b2 ฒ thai character tho phuthao +263 179 b3 ณ thai character no nen +264 180 b4 ด thai character do dek +265 181 b5 ต thai character to tao +266 182 b6 ถ thai character tho thung +267 183 b7 ท thai character tho thahan +270 184 b8 ธ thai character tho thong +271 185 b9 น thai character no nu +272 186 ba บ thai character bo baimai +273 187 bb ป thai character po pla +274 188 bc ผ thai character pho phung +275 189 bd ฝ thai character fo fa +276 190 be พ thai character pho phan +277 191 bf ฟ thai character fo fan +300 192 c0 ภ thai character pho samphao +301 193 c1 ม thai character mo ma +302 194 c2 ย thai character yo yak +303 195 c3 ร thai character ro rua +304 196 c4 ฤ thai character ru +305 197 c5 ล thai character lo ling +306 198 c6 ฦ thai character lu +307 199 c7 ว thai character wo waen +310 200 c8 ศ thai character so sala +311 201 c9 ษ thai character so rusi +312 202 ca ส thai character so sua +313 203 cb ห thai character ho hip +314 204 cc ฬ thai character lo chula +315 205 cd อ thai character o ang +316 206 ce ฮ thai character ho nokhuk +317 207 cf ฯ thai character paiyannoi +320 208 d0 ะ thai character sara a +321 209 d1 ั thai character mai han-akat +322 210 d2 า thai character sara aa +323 211 d3 ำ thai character sara am +324 212 d4 ิ thai character sara i +325 213 d5 ี thai character sara ii +326 214 d6 ึ thai character sara ue +327 215 d7 ื thai character sara uee +330 216 d8 ุ thai character sara u +331 217 d9 ู thai character sara uu +332 218 da ฺ thai character phinthu +337 223 df ฿ thai currency symbol baht +340 224 e0 เ thai character sara e +341 225 e1 แ thai character sara ae +342 226 e2 โ thai character sara o +343 227 e3 ใ thai character sara ai maimuan +344 228 e4 ไ thai character sara ai maimalai +345 229 e5 ๅ thai character lakkhangyao +346 230 e6 ๆ thai character maiyamok +347 231 e7 ็ thai character maitaikhu +350 232 e8 ่ thai character mai ek +351 233 e9 ้ thai character mai tho +352 234 ea ๊ thai character mai tri +353 235 eb ๋ thai character mai chattawa +354 236 ec ์ thai character thanthakhat +355 237 ed ํ thai character nikhahit +356 238 ee ๎ thai character yamakkan +357 239 ef ๏ thai character fongman +360 240 f0 ๐ thai digit zero +361 241 f1 ๑ thai digit one +362 242 f2 ๒ thai digit two +363 243 f3 ๓ thai digit three +364 244 f4 ๔ thai digit four +365 245 f5 ๕ thai digit five +366 246 f6 ๖ thai digit six +367 247 f7 ๗ thai digit seven +370 248 f8 ๘ thai digit eight +371 249 f9 ๙ thai digit nine +372 250 fa ๚ thai character angkhankhu +373 251 fb ๛ thai character khomut +.te +.sh notes +iso 8859-11 is the same as tis (thai industrial standard) 620-2253, +commonly known as tis-620, except for the character in position a0: +iso 8859-11 defines this as no-break space, +while tis-620 leaves it undefined. +.sh see also +.br ascii (7), +.br charsets (7), +.br utf\-8 (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/open_by_handle_at.2 + +.so man3/getrpcent.3 + +######################################################################## +# copyright (c) 2021 alejandro colomar +# spdx-license-identifier: gpl-2.0 or lgpl-2.0 +######################################################################## +# conventions: +# +# - follow "makefile conventions" from the "gnu coding standards" closely. +# however, when something could be improved, don't follow those. +# - uppercase variables, when referring files, refer to files in this repo. +# - lowercase variables, when referring files, refer to system files. +# - variables starting with '_' refer to absolute paths, including $(destdir). +# - variables ending with '_' refer to a subdir of their parent dir, which +# is in a variable of the same name but without the '_'. the subdir is +# named after this project: <*/man>. +# - variables ending in '_rm' refer to files that can be removed (exist). +# - variables ending in '_rmdir' refer to dirs that can be removed (exist). +# - targets of the form '%-rm' remove their corresponding file '%'. +# - targets of the form '%/.-rmdir' remove their corresponding dir '%/'. +# - targets of the form '%/.' create their corresponding directory '%/'. +# - every file or directory to be created depends on its parent directory. +# this avoids race conditions caused by `mkdir -p`. only the root +# directories are created with parents. +# - the 'force' target is used to make phony some variables that can't be +# .phony to avoid some optimizations. +# +######################################################################## + +makeflags += --no-print-directory +makeflags += --silent +makeflags += --warn-undefined-variables + + +htmlbuilddir := $(curdir)/.html +htopts := + +destdir := +prefix := /usr/local +datarootdir := $(prefix)/share +docdir := $(datarootdir)/doc +mandir := $(curdir) +mandir := $(datarootdir)/man +man1dir := $(mandir)/man1 +man2dir := $(mandir)/man2 +man3dir := $(mandir)/man3 +man4dir := $(mandir)/man4 +man5dir := $(mandir)/man5 +man6dir := $(mandir)/man6 +man7dir := $(mandir)/man7 +man8dir := $(mandir)/man8 +man1dir := $(mandir)/man1 +man2dir := $(mandir)/man2 +man3dir := $(mandir)/man3 +man4dir := $(mandir)/man4 +man5dir := $(mandir)/man5 +man6dir := $(mandir)/man6 +man7dir := $(mandir)/man7 +man8dir := $(mandir)/man8 +manext := \.[0-9] +man1ext := .1 +man2ext := .2 +man3ext := .3 +man4ext := .4 +man5ext := .5 +man6ext := .6 +man7ext := .7 +man8ext := .8 +htmldir := $(docdir) +htmldir_ := $(htmldir)/man +htmlext := .html + +install := install +install_data := $(install) -m 644 +install_dir := $(install) -m 755 -d +rm := rm +rmdir := rmdir --ignore-fail-on-non-empty + +man_sections := 1 2 3 4 5 6 7 8 + + +.phony: all +all: + $(make) uninstall + $(make) install + + +%/.: + $(info - install $(@d)) + $(install_dir) $(@d) + +%-rm: + $(info - rm $*) + $(rm) $* + +%-rmdir: + $(info - rmdir $(@d)) + $(rmdir) $(@d) + + +.phony: install +install: install-man | installdirs + @: + +.phony: installdirs +installdirs: | installdirs-man + @: + +.phony: uninstall remove +uninstall remove: uninstall-man + @: + +.phony: clean +clean: + find man?/ -type f \ + |while read f; do \ + rm -f "$(htmlbuilddir)/$$f".*; \ + done; + +######################################################################## +# man + +manpages := $(sort $(shell find $(mandir)/man?/ -type f | grep '$(manext)$$')) +_manpages := $(patsubst $(mandir)/%,$(destdir)$(mandir)/%,$(manpages)) +_man1pages := $(filter %$(man1ext),$(_manpages)) +_man2pages := $(filter %$(man2ext),$(_manpages)) +_man3pages := $(filter %$(man3ext),$(_manpages)) +_man4pages := $(filter %$(man4ext),$(_manpages)) +_man5pages := $(filter %$(man5ext),$(_manpages)) +_man6pages := $(filter %$(man6ext),$(_manpages)) +_man7pages := $(filter %$(man7ext),$(_manpages)) +_man8pages := $(filter %$(man8ext),$(_manpages)) + +mandirs := $(sort $(shell find $(mandir)/man? -type d)) +_mandirs := $(patsubst $(mandir)/%,$(destdir)$(mandir)/%/.,$(mandirs)) +_man1dir := $(filter %man1/.,$(_mandirs)) +_man2dir := $(filter %man2/.,$(_mandirs)) +_man3dir := $(filter %man3/.,$(_mandirs)) +_man4dir := $(filter %man4/.,$(_mandirs)) +_man5dir := $(filter %man5/.,$(_mandirs)) +_man6dir := $(filter %man6/.,$(_mandirs)) +_man7dir := $(filter %man7/.,$(_mandirs)) +_man8dir := $(filter %man8/.,$(_mandirs)) +_mandir := $(destdir)$(mandir)/. + +_manpages_rm := $(addsuffix -rm,$(wildcard $(_manpages))) +_man1pages_rm := $(filter %$(man1ext)-rm,$(_manpages_rm)) +_man2pages_rm := $(filter %$(man2ext)-rm,$(_manpages_rm)) +_man3pages_rm := $(filter %$(man3ext)-rm,$(_manpages_rm)) +_man4pages_rm := $(filter %$(man4ext)-rm,$(_manpages_rm)) +_man5pages_rm := $(filter %$(man5ext)-rm,$(_manpages_rm)) +_man6pages_rm := $(filter %$(man6ext)-rm,$(_manpages_rm)) +_man7pages_rm := $(filter %$(man7ext)-rm,$(_manpages_rm)) +_man8pages_rm := $(filter %$(man8ext)-rm,$(_manpages_rm)) + +_mandirs_rmdir := $(addsuffix -rmdir,$(wildcard $(_mandirs))) +_man1dir_rmdir := $(addsuffix -rmdir,$(wildcard $(_man1dir))) +_man2dir_rmdir := $(addsuffix -rmdir,$(wildcard $(_man2dir))) +_man3dir_rmdir := $(addsuffix -rmdir,$(wildcard $(_man3dir))) +_man4dir_rmdir := $(addsuffix -rmdir,$(wildcard $(_man4dir))) +_man5dir_rmdir := $(addsuffix -rmdir,$(wildcard $(_man5dir))) +_man6dir_rmdir := $(addsuffix -rmdir,$(wildcard $(_man6dir))) +_man7dir_rmdir := $(addsuffix -rmdir,$(wildcard $(_man7dir))) +_man8dir_rmdir := $(addsuffix -rmdir,$(wildcard $(_man8dir))) +_mandir_rmdir := $(addsuffix -rmdir,$(wildcard $(_mandir))) + +install_manx := $(foreach x,$(man_sections),install-man$(x)) +installdirs_manx := $(foreach x,$(man_sections),installdirs-man$(x)) +uninstall_manx := $(foreach x,$(man_sections),uninstall-man$(x)) + + +.secondexpansion: +$(_manpages): $(destdir)$(mandir)/man%: $(mandir)/man% | $$(@d)/. + $(info - install $@) + $(install_data) -t $< $@ + +$(_mandirs): %/.: | $$(dir %). $(_mandir) + +$(_mandirs_rmdir): $(destdir)$(mandir)/man%/.-rmdir: $$(_man%pages_rm) force +$(_mandir_rmdir): $(uninstall_manx) force + + +.phony: $(install_manx) +$(install_manx): install-man%: $$(_man%pages) | installdirs-man% + @: + +.phony: install-man +install-man: $(install_manx) + @: + +.phony: $(installdirs_manx) +$(installdirs_manx): installdirs-man%: $$(_man%dir) $(_mandir) + @: + +.phony: installdirs-man +installdirs-man: $(installdirs_manx) + @: + +.phony: $(uninstall_manx) +$(uninstall_manx): uninstall-man%: $$(_man%pages_rm) $$(_man%dir_rmdir) + @: + +.phony: uninstall-man +uninstall-man: $(_mandir_rmdir) $(uninstall_manx) + @: + + +######################################################################## +# html + +# use with +# make htopts=whatever html +# the sed removes the lines "content-type: text/html\n\n" +.phony: html +html: | builddirs-html + find man?/ -type f \ + |while read f; do \ + man2html $(htopts) "$$f" \ + |sed -e '1,2d' \ + >"$(htmlbuilddir)/$${f}$(htmlext)" \ + || exit $$?; \ + done; + +.phony: builddirs-html +builddirs-html: + find man?/ -type d \ + |while read d; do \ + $(install_dir) "$(htmlbuilddir)/$$d" || exit $$?; \ + done; + +.phony: install-html +install-html: | installdirs-html + cd $(htmlbuilddir) && \ + find man?/ -type f \ + |while read f; do \ + $(install_data) -t "$$f" "$(destdir)$(htmldir_)/$$f" || exit $$?; \ + done; + +.phony: installdirs-html +installdirs-html: + find man?/ -type d \ + |while read d; do \ + $(install_dir) "$(destdir)$(htmldir_)/$$d" || exit $$?; \ + done; + +.phony: uninstall-html +uninstall-html: + find man?/ -type f \ + |while read f; do \ + rm -f "$(destdir)$(htmldir_)/$$f".* || exit $$?; \ + done; + + +######################################################################## +# tests + +# check if groff reports warnings (may be words of sentences not displayed) +# from https://lintian.debian.org/tags/groff-message.html +.phony: check-groff-warnings +check-groff-warnings: + groff_log="$$(mktemp --tmpdir manpages-checksxxxx)" || exit $$?; \ + for i in man?/*.[1-9]; \ + do \ + if grep -q 'sh.*name' "$$i"; then \ + lc_all=en_us.utf-8 manwidth=80 man --warnings -e utf-8 -l "$$i" > /dev/null 2>| "$$groff_log"; \ + [ -s "$$groff_log" ] && { echo "$$i: "; cat "$$groff_log"; echo; }; \ + fi; \ + done; \ + rm -f "$$groff_log" + +# someone might also want to look at /var/catman/cat2 or so ... +# a problem is that the location of cat pages varies a lot + +######################################################################## + +force: + +.so man3/tan.3 + +.so man3/inet_net_pton.3 + +.\" copyright (c) 1980, 1991 regents of the university of california. +.\" all rights reserved. +.\" +.\" %%%license_start(bsd_4_clause_ucb) +.\" redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. all advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" this product includes software developed by the university of +.\" california, berkeley and its contributors. +.\" 4. neither the name of the university nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" this software is provided by the regents and contributors ``as is'' and +.\" any express or implied warranties, including, but not limited to, the +.\" implied warranties of merchantability and fitness for a particular purpose +.\" are disclaimed. in no event shall the regents or contributors be liable +.\" for any direct, indirect, incidental, special, exemplary, or consequential +.\" damages (including, but not limited to, procurement of substitute goods +.\" or services; loss of use, data, or profits; or business interruption) +.\" however caused and on any theory of liability, whether in contract, strict +.\" liability, or tort (including negligence or otherwise) arising in any way +.\" out of the use of this software, even if advised of the possibility of +.\" such damage. +.\" %%%license_end +.\" +.\" @(#)alloca.3 5.1 (berkeley) 5/2/91 +.\" +.\" converted mon nov 29 11:05:55 1993 by rik faith +.\" modified tue oct 22 23:41:56 1996 by eric s. raymond +.\" modified 2002-07-17, aeb +.\" 2008-01-24, mtk: +.\" various rewrites and additions (notes on longjmp() and sigsegv). +.\" weaken warning against use of alloca() (as per debian bug 461100). +.\" +.th alloca 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +alloca \- allocate memory that is automatically freed +.sh synopsis +.nf +.b #include +.pp +.bi "void *alloca(size_t " size ); +.fi +.sh description +the +.br alloca () +function allocates +.i size +bytes of space in the stack frame of the caller. +this temporary space is +automatically freed when the function that called +.br alloca () +returns to its caller. +.sh return value +the +.br alloca () +function returns a pointer to the beginning of the allocated space. +if the allocation causes stack overflow, program behavior is undefined. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br alloca () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +this function is not in posix.1. +.pp +there is evidence that the +.br alloca () +function appeared in 32v, pwb, pwb.2, 3bsd, and 4bsd. +there is a man page for it in 4.3bsd. +linux uses the gnu version. +.sh notes +the +.br alloca () +function is machine- and compiler-dependent. +for certain applications, +its use can improve efficiency compared to the use of +.br malloc (3) +plus +.br free (3). +in certain cases, +it can also simplify memory deallocation in applications that use +.br longjmp (3) +or +.br siglongjmp (3). +otherwise, its use is discouraged. +.pp +because the space allocated by +.br alloca () +is allocated within the stack frame, +that space is automatically freed if the function return +is jumped over by a call to +.br longjmp (3) +or +.br siglongjmp (3). +.pp +the space allocated by +.br alloca () +is +.i not +automatically deallocated if the pointer that refers to it +simply goes out of scope. +.pp +do not attempt to +.br free (3) +space allocated by +.br alloca ()! +.ss notes on the gnu version +normally, +.br gcc (1) +translates calls to +.br alloca () +with inlined code. +this is not done when either the +.ir "\-ansi" , +.ir "\-std=c89" , +.ir "\-std=c99" , +or the +.ir "\-std=c11" +option is given +.br and +the header +.i +is not included. +otherwise, (without an \-ansi or \-std=c* option) the glibc version of +.i +includes +.i +and that contains the lines: +.pp +.in +4n +.ex +#ifdef __gnuc__ +#define alloca(size) __builtin_alloca (size) +#endif +.ee +.in +.pp +with messy consequences if one has a private version of this function. +.pp +the fact that the code is inlined means that it is impossible +to take the address of this function, or to change its behavior +by linking with a different library. +.pp +the inlined code often consists of a single instruction adjusting +the stack pointer, and does not check for stack overflow. +thus, there is no null error return. +.sh bugs +there is no error indication if the stack frame cannot be extended. +(however, after a failed allocation, the program is likely to receive a +.b sigsegv +signal if it attempts to access the unallocated space.) +.pp +on many systems +.br alloca () +cannot be used inside the list of arguments of a function call, because +the stack space reserved by +.br alloca () +would appear on the stack in the middle of the space for the +function arguments. +.sh see also +.br brk (2), +.br longjmp (3), +.br malloc (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" (c) copyright 1992-1999 rickard e. faith and david a. wheeler +.\" (faith@cs.unc.edu and dwheeler@ida.org) +.\" and (c) copyright 2007 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" 2007-05-30 created by mtk, using text from old man.7 plus +.\" rewrites and additional text. +.\" +.th man-pages 7 2021-03-22 "linux" "linux programmer's manual" +.sh name +man-pages \- conventions for writing linux man pages +.sh synopsis +.b man +.ri [ section ] +.i title +.sh description +this page describes the conventions that should be employed +when writing man pages for the linux \fiman-pages\fp project, +which documents the user-space api provided by the linux kernel +and the gnu c library. +the project thus provides most of the pages in section 2, +many of the pages that appear in sections 3, 4, and 7, +and a few of the pages that appear in sections 1, 5, and 8 +of the man pages on a linux system. +the conventions described on this page may also be useful +for authors writing man pages for other projects. +.ss sections of the manual pages +the manual sections are traditionally defined as follows: +.tp +.b 1 user commands (programs) +commands that can be executed by the user from within +a shell. +.tp +.b 2 system calls +functions which wrap operations performed by the kernel. +.tp +.b 3 library calls +all library functions excluding the system call wrappers +(most of the +.i libc +functions). +.tp +.b 4 special files (devices) +files found in +.i /dev +which allow to access to devices through the kernel. +.tp +.b 5 file formats and configuration files +describes various human-readable file formats and configuration files. +.tp +.b 6 games +games and funny little programs available on the system. +.tp +.b 7 overview, conventions, and miscellaneous +overviews or descriptions of various topics, conventions, and protocols, +character set standards, the standard filesystem layout, and miscellaneous +other things. +.tp +.b 8 system management commands +commands like +.br mount (8), +many of which only root can execute. +.\" .tp +.\" .b 9 kernel routines +.\" this is an obsolete manual section. +.\" once it was thought a good idea to document the linux kernel here, +.\" but in fact very little has been documented, and the documentation +.\" that exists is outdated already. +.\" there are better sources of +.\" information for kernel developers. +.ss macro package +new manual pages should be marked up using the +.b groff an.tmac +package described in +.br man (7). +this choice is mainly for consistency: the vast majority of +existing linux manual pages are marked up using these macros. +.ss conventions for source file layout +please limit source code line length to no more than about 75 characters +wherever possible. +this helps avoid line-wrapping in some mail clients when patches are +submitted inline. +.ss title line +the first command in a man page should be a +.b th +command: +.pp +.rs +.b \&.th +.i "title section date source manual" +.re +.pp +the arguments of the command are as follows: +.tp +.i title +the title of the man page, written in all caps (e.g., +.ir man-pages ). +.tp +.i section +the section number in which the man page should be placed (e.g., +.ir 7 ). +.tp +.i date +the date of the last nontrivial change that was made to the man page. +(within the +.i man-pages +project, the necessary updates to these timestamps are handled +automatically by scripts, so there is no need to manually update +them as part of a patch.) +dates should be written in the form yyyy-mm-dd. +.tp +.i source +the source of the command, function, or system call. +.ip +for those few \fiman-pages\fp pages in sections 1 and 8, +probably you just want to write +.ir gnu . +.ip +for system calls, just write +.ir "linux" . +(an earlier practice was to write the version number +of the kernel from which the manual page was being written/checked. +however, this was never done consistently, and so was +probably worse than including no version number. +henceforth, avoid including a version number.) +.ip +for library calls that are part of glibc or one of the +other common gnu libraries, just use +.ir "gnu c library" ", " gnu , +or an empty string. +.ip +for section 4 pages, use +.ir "linux" . +.ip +in cases of doubt, just write +.ir linux ", or " gnu . +.tp +.i manual +the title of the manual (e.g., for section 2 and 3 pages in +the \fiman-pages\fp package, use +.ir "linux programmer's manual" ). +.\" +.ss sections within a manual page +the list below shows conventional or suggested sections. +most manual pages should include at least the +.b highlighted +sections. +arrange a new manual page so that sections +are placed in the order shown in the list. +.pp +.rs +.ts +l l. +\fbname\fp +\fbsynopsis\fp +configuration [normally only in section 4] +\fbdescription\fp +options [normally only in sections 1, 8] +exit status [normally only in sections 1, 8] +return value [normally only in sections 2, 3] +.\" may 07: few current man pages have an error handling section,,, +.\" error handling, +errors [typically only in sections 2, 3] +.\" may 07: almost no current man pages have a usage section,,, +.\" usage, +.\" diagnostics, +.\" may 07: almost no current man pages have a security section,,, +.\" security, +environment +files +versions [normally only in sections 2, 3] +attributes [normally only in sections 2, 3] +conforming to +notes +bugs +examples +.\" authors sections are discouraged +authors [discouraged] +reporting bugs [not used in man-pages] +copyright [not used in man-pages] +\fbsee also\fp +.te +.re +.pp +.ir "where a traditional heading would apply" ", " "please use it" ; +this kind of consistency can make the information easier to understand. +if you must, you can create your own +headings if they make things easier to understand (this can +be especially useful for pages in sections 4 and 5). +however, before doing this, consider whether you could use the +traditional headings, with some subsections (\fi.ss\fp) within +those sections. +.pp +the following list elaborates on the contents of each of +the above sections. +.tp +.b name +the name of this manual page. +.ip +see +.br man (7) +for important details of the line(s) that should follow the +\fb.sh name\fp command. +all words in this line (including the word immediately +following the "\e\-") should be in lowercase, +except where english or technical terminological convention +dictates otherwise. +.tp +.b synopsis +a brief summary of the command or function's interface. +.ip +for commands, this shows the syntax of the command and its arguments +(including options); +boldface is used for as-is text and italics are used to +indicate replaceable arguments. +brackets ([]) surround optional arguments, vertical bars (|) +separate choices, and ellipses (\&...) can be repeated. +for functions, it shows any required data declarations or +.b #include +directives, followed by the function declaration. +.ip +where a feature test macro must be defined in order to obtain +the declaration of a function (or a variable) from a header file, +then the synopsis should indicate this, as described in +.br feature_test_macros (7). +.\" fixme . say something here about compiler options +.tp +.b configuration +configuration details for a device. +.ip +this section normally appears only in section 4 pages. +.tp +.b description +an explanation of what the program, function, or format does. +.ip +discuss how it interacts with files and standard input, and what it +produces on standard output or standard error. +omit internals and implementation details unless they're critical for +understanding the interface. +describe the usual case; +for information on command-line options of a program use the +.b options +section. +.\" if there is some kind of input grammar or complex set of subcommands, +.\" consider describing them in a separate +.\" .b usage +.\" section (and just place an overview in the +.\" .b description +.\" section). +.ip +when describing new behavior or new flags for +a system call or library function, +be careful to note the kernel or c library version +that introduced the change. +the preferred method of noting this information for flags is as part of a +.b .tp +list, in the following form (here, for a new system call flag): +.rs 16 +.tp +.br xyz_flag " (since linux 3.7)" +description of flag... +.re +.ip +including version information is especially useful to users +who are constrained to using older kernel or c library versions +(which is typical in embedded systems, for example). +.tp +.b options +a description of the command-line options accepted by a +program and how they change its behavior. +.ip +this section should appear only for section 1 and 8 manual pages. +.\" .tp +.\" .b usage +.\" describes the grammar of any sublanguage this implements. +.tp +.b exit status +a list of the possible exit status values of a program and +the conditions that cause these values to be returned. +.ip +this section should appear only for section 1 and 8 manual pages. +.tp +.b return value +for section 2 and 3 pages, this section gives a +list of the values the library routine will return to the caller +and the conditions that cause these values to be returned. +.tp +.b errors +for section 2 and 3 manual pages, this is a list of the +values that may be placed in +.i errno +in the event of an error, along with information about the cause +of the errors. +.ip +where several different conditions produce the same error, +the preferred approach is to create separate list entries +(with duplicate error names) for each of the conditions. +this makes the separate conditions clear, may make the list easier to read, +and allows metainformation +(e.g., kernel version number where the condition first became applicable) +to be more easily marked for each condition. +.ip +.ir "the error list should be in alphabetical order" . +.tp +.b environment +a list of all environment variables that affect the program or function +and how they affect it. +.tp +.b files +a list of the files the program or function uses, such as +configuration files, startup files, +and files the program directly operates on. +.ip +give the full pathname of these files, and use the installation +process to modify the directory part to match user preferences. +for many programs, the default installation location is in +.ir /usr/local , +so your base manual page should use +.i /usr/local +as the base. +.\" may 07: almost no current man pages have a diagnostics section; +.\" "return value" or "exit status" is preferred. +.\" .tp +.\" .b diagnostics +.\" gives an overview of the most common error messages and how to +.\" cope with them. +.\" you don't need to explain system error messages +.\" or fatal signals that can appear during execution of any program +.\" unless they're special in some way to the program. +.\" +.\" may 07: almost no current man pages have a security section. +.\".tp +.\".b security +.\"discusses security issues and implications. +.\"warn about configurations or environments that should be avoided, +.\"commands that may have security implications, and so on, especially +.\"if they aren't obvious. +.\"discussing security in a separate section isn't necessary; +.\"if it's easier to understand, place security information in the +.\"other sections (such as the +.\" .b description +.\" or +.\" .b usage +.\" section). +.\" however, please include security information somewhere! +.tp +.b attributes +a summary of various attributes of the function(s) documented on this page. +see +.br attributes (7) +for further details. +.tp +.b versions +a brief summary of the linux kernel or glibc versions where a +system call or library function appeared, +or changed significantly in its operation. +.ip +as a general rule, every new interface should +include a versions section in its manual page. +unfortunately, +many existing manual pages don't include this information +(since there was no policy to do so when they were written). +patches to remedy this are welcome, +but, from the perspective of programmers writing new code, +this information probably matters only in the case of kernel +interfaces that have been added in linux 2.4 or later +(i.e., changes since kernel 2.2), +and library functions that have been added to glibc since version 2.1 +(i.e., changes since glibc 2.0). +.ip +the +.br syscalls (2) +manual page also provides information about kernel versions +in which various system calls first appeared. +.tp +.b conforming to +a description of any standards or conventions that relate to the function +or command described by the manual page. +.ip +the preferred terms to use for the various standards are listed as +headings in +.br standards (7). +.ip +for a page in section 2 or 3, +this section should note the posix.1 +version(s) that the call conforms to, +and also whether the call is specified in c99. +(don't worry too much about other standards like sus, susv2, and xpg, +or the svr4 and 4.xbsd implementation standards, +unless the call was specified in those standards, +but isn't in the current version of posix.1.) +.ip +if the call is not governed by any standards but commonly +exists on other systems, note them. +if the call is linux-specific, note this. +.ip +if this section consists of just a list of standards +(which it commonly does), +terminate the list with a period (\(aq.\(aq). +.tp +.b notes +miscellaneous notes. +.ip +for section 2 and 3 man pages you may find it useful to include +subsections (\fbss\fp) named \filinux notes\fp and \figlibc notes\fp. +.ip +in section 2, use the heading +.i "c library/kernel differences" +to mark off notes that describe the differences (if any) between +the c library wrapper function for a system call and +the raw system call interface provided by the kernel. +.tp +.b bugs +a list of limitations, known defects or inconveniences, +and other questionable activities. +.tp +.b examples +one or more examples demonstrating how this function, file, or +command is used. +.ip +for details on writing example programs, +see \fiexample programs\fp below. +.tp +.b authors +a list of authors of the documentation or program. +.ip +\fbuse of an authors section is strongly discouraged\fp. +generally, it is better not to clutter every page with a list +of (over time potentially numerous) authors; +if you write or significantly amend a page, +add a copyright notice as a comment in the source file. +if you are the author of a device driver and want to include +an address for reporting bugs, place this under the bugs section. +.tp +.b reporting bugs +the +.ir man-pages +project doesn't use a reporting bugs section in manual pages. +information on reporting bugs is instead supplied in the +script-generated colophon section. +however, various projects do use a reporting bugs section. +it is recommended to place it near the foot of the page. +.tp +.b copyright +the +.ir man-pages +project doesn't use a copyright section in manual pages. +copyright information is instead maintained in the page source. +in pages where this section is present, +it is recommended to place it near the foot of the page, just above see also. +.tp +.b see also +a comma-separated list of related man pages, possibly followed by +other related pages or documents. +.ip +the list should be ordered by section number and +then alphabetically by name. +do not terminate this list with a period. +.ip +where the see also list contains many long manual page names, +to improve the visual result of the output, it may be useful to employ the +.i .ad l +(don't right justify) +and +.i .nh +(don't hyphenate) +directives. +hyphenation of individual page names can be prevented +by preceding words with the string "\e%". +.ip +given the distributed, autonomous nature of foss projects +and their documentation, it is sometimes necessary\(emand in many cases +desirable\(emthat the see also section includes references to +manual pages provided by other projects. +.sh formatting and wording conventions +the following subsections note some details for preferred formatting and +wording conventions in various sections of the pages in the +.ir man-pages +project. +.ss synopsis +wrap the function prototype(s) in a +.ir .nf / .fi +pair to prevent filling. +.pp +in general, where more than one function prototype is shown in the synopsis, +the prototypes should +.i not +be separated by blank lines. +however, blank lines (achieved using +.ir .pp ) +may be added in the following cases: +.ip * 3 +to separate long lists of function prototypes into related groups +(see for example +.br list (3)); +.ip * +in other cases that may improve readability. +.pp +in the synopsis, a long function prototype may need to be +continued over to the next line. +the continuation line is indented according to the following rules: +.ip 1. 3 +if there is a single such prototype that needs to be continued, +then align the continuation line so that when the page is +rendered on a fixed-width font device (e.g., on an xterm) the +continuation line starts just below the start of the argument +list in the line above. +(exception: the indentation may be +adjusted if necessary to prevent a very long continuation line +or a further continuation line where the function prototype is +very long.) +as an example: +.pp +.rs +.nf +.bi "int tcsetattr(int " fd ", int " optional_actions , +.bi " const struct termios *" termios_p ); +.fi +.re +.ip 2. 3 +but, where multiple functions in the synopsis require +continuation lines, and the function names have different +lengths, then align all continuation lines to start in the +same column. +this provides a nicer rendering in pdf output +(because the synopsis uses a variable width font where +spaces render narrower than most characters). +as an example: +.pp +.rs +.nf +.bi "int getopt(int " argc ", char * const " argv[] , +.bi " const char *" optstring ); +.bi "int getopt_long(int " argc ", char * const " argv[] , +.bi " const char *" optstring , +.bi " const struct option *" longopts ", int *" longindex ); +.fi +.re +.ss return value +the preferred wording to describe how +.i errno +is set is +.ri \(dq errno +is set to indicate the error" +or similar. +.\" before man-pages 5.11, many different wordings were used, which +.\" was confusing, and potentially made scripted edits more difficult. +this wording is consistent with the wording used in both posix.1 and freebsd. +.ss attributes +.\" see man-pages commit c466875ecd64ed3d3cd3e578406851b7dfb397bf +note the following: +.ip * 3 +wrap the table in this section in a +.ir ".ad\ l" / .ad +pair to disable text filling and a +.ir .nh / .hy +pair to disable hyphenation. +.ip * +ensure that the table occupies the full page width through the use of an +.i lbx +description for one of the columns +(usually the first column, +though in some cases the last column if it contains a lot of text). +.ip * +make free use of +.ir t{ / t} +macro pairs to allow table cells to be broken over multiple lines +(also bearing in mind that pages may sometimes be rendered to a +width of less than 80 columns). +.pp +for examples of all of the above, see the source code of various pages. +.sh style guide +the following subsections describe the preferred style for the +.ir man-pages +project. +for details not covered below, the chicago manual of style +is usually a good source; +try also grepping for preexisting usage in the project source tree. +.ss use of gender-neutral language +as far as possible, use gender-neutral language in the text of man +pages. +use of "they" ("them", "themself", "their") as a gender-neutral singular +pronoun is acceptable. +.\" +.ss formatting conventions for manual pages describing commands +for manual pages that describe a command (typically in sections 1 and 8), +the arguments are always specified using italics, +.ir "even in the synopsis section" . +.pp +the name of the command, and its options, should +always be formatted in bold. +.\" +.ss formatting conventions for manual pages describing functions +for manual pages that describe functions (typically in sections 2 and 3), +the arguments are always specified using italics, +.ir "even in the synopsis section" , +where the rest of the function is specified in bold: +.pp +.bi " int myfunction(int " argc ", char **" argv ); +.pp +variable names should, like argument names, be specified in italics. +.pp +any reference to the subject of the current manual page +should be written with the name in bold followed by +a pair of parentheses in roman (normal) font. +for example, in the +.br fcntl (2) +man page, references to the subject of the page would be written as: +.br fcntl (). +the preferred way to write this in the source file is: +.pp +.ex + .br fcntl () +.ee +.pp +(using this format, rather than the use of "\efb...\efp()" +makes it easier to write tools that parse man page source files.) +.\" +.ss use semantic newlines +in the source of a manual page, +new sentences should be started on new lines, +and long sentences should be split into lines at clause breaks +(commas, semicolons, colons, and so on). +this convention, sometimes known as "semantic newlines", +makes it easier to see the effect of patches, +which often operate at the level of individual sentences or sentence clauses. +.\" +.ss formatting conventions (general) +paragraphs should be separated by suitable markers (usually either +.i .pp +or +.ir .ip ). +do +.i not +separate paragraphs using blank lines, as this results in poor rendering +in some output formats (such as postscript and pdf). +.pp +filenames (whether pathnames, or references to header files) +are always in italics (e.g., +.ir ), +except in the synopsis section, where included files are in bold (e.g., +.br "#include " ). +when referring to a standard header file include, +specify the header file surrounded by angle brackets, +in the usual c way (e.g., +.ir ). +.pp +special macros, which are usually in uppercase, are in bold (e.g., +.br maxint ). +exception: don't boldface null. +.pp +when enumerating a list of error codes, the codes are in bold (this list +usually uses the +.b \&.tp +macro). +.pp +complete commands should, if long, +be written as an indented line on their own, +with a blank line before and after the command, for example +.pp +.in +4n +.ex +man 7 man\-pages +.ee +.in +.pp +if the command is short, then it can be included inline in the text, +in italic format, for example, +.ir "man 7 man-pages" . +in this case, it may be worth using nonbreaking spaces +("\e\ ") at suitable places in the command. +command options should be written in italics (e.g., +.ir \-l ). +.pp +expressions, if not written on a separate indented line, should +be specified in italics. +again, the use of nonbreaking spaces may be appropriate +if the expression is inlined with normal text. +.pp +when showing example shell sessions, user input should be formatted in bold, for example +.pp +.in +4n +.ex +$ \fbdate\fp +thu jul 7 13:01:27 cest 2016 +.ee +.in +.pp +any reference to another man page +should be written with the name in bold, +.i always +followed by the section number, +formatted in roman (normal) font, without any +separating spaces (e.g., +.br intro (2)). +the preferred way to write this in the source file is: +.pp +.ex + .br intro (2) +.ee +.pp +(including the section number in cross references lets tools like +.br man2html (1) +create properly hyperlinked pages.) +.pp +control characters should be written in bold face, +with no quotes; for example, +.br \(hax . +.ss spelling +starting with release 2.59, +.i man-pages +follows american spelling conventions +(previously, there was a random mix of british and american spellings); +please write all new pages and patches according to these conventions. +.pp +aside from the well-known spelling differences, +there are a few other subtleties to watch for: +.ip * 3 +american english tends to use the forms "backward", "upward", "toward", +and so on +rather than the british forms "backwards", "upwards", "towards", and so on. +.ip * +opinions are divided on "acknowledgement" vs "acknowledgment". +the latter is predominant, but not universal usage in american english. +posix and the bsd license use the former spelling. +in the linux man-pages project, we use "acknowledgement". +.ss bsd version numbers +the classical scheme for writing bsd version numbers is +.ir x.ybsd , +where +.i x.y +is the version number (e.g., 4.2bsd). +avoid forms such as +.ir "bsd 4.3" . +.ss capitalization +in subsection ("ss") headings, +capitalize the first word in the heading, but otherwise use lowercase, +except where english usage (e.g., proper nouns) or programming +language requirements (e.g., identifier names) dictate otherwise. +for example: +.pp +.ex + .ss unicode under linux +.ee +.\" +.ss indentation of structure definitions, shell session logs, and so on +when structure definitions, shell session logs, and so on are included +in running text, indent them by 4 spaces (i.e., a block enclosed by +.i ".in\ +4n" +and +.ir ".in" ), +format them using the +.i .ex +and +.i ee +macros, and surround them with suitable paragraph markers (either +.i .pp +or +.ir .ip ). +for example: +.pp +.in +4n +.ex + .pp + .in +4n + .ex + int + main(int argc, char *argv[]) + { + return 0; + } + .ee + .in + .pp +.ee +.in +.ss preferred terms +the following table lists some preferred terms to use in man pages, +mainly to ensure consistency across pages. +.ad l +.ts +l l l +--- +l l ll. +term avoid using notes + +bit mask bitmask +built-in builtin +epoch epoch t{ +for the unix epoch (00:00:00, 1 jan 1970 utc) +t} +filename file name +filesystem file system +hostname host name +inode i-node +lowercase lower case, lower-case +nonzero non-zero +pathname path name +pseudoterminal pseudo-terminal +privileged port t{ +reserved port, +system port +t} +real-time t{ +realtime, +real time +t} +run time runtime +saved set-group-id t{ +saved group id, +saved set-gid +t} +saved set-user-id t{ +saved user id, +saved set-uid +t} +set-group-id set-gid, setgid +set-user-id set-uid, setuid +superuser t{ +super user, +super-user +t} +superblock t{ +super block, +super-block +t} +timestamp time stamp +timezone time zone +uppercase upper case, upper-case +usable useable +user space userspace +username user name +x86-64 x86_64 t{ +except if referring to result of "uname\ \-m" or similar +t} +zeros zeroes +.te +.pp +see also the discussion +.ir "hyphenation of attributive compounds" +below. +.ss terms to avoid +the following table lists some terms to avoid using in man pages, +along with some suggested alternatives, +mainly to ensure consistency across pages. +.ad l +.ts +l l l +--- +l l l. +avoid use instead notes + +32bit 32-bit t{ +same for 8-bit, 16-bit, etc. +t} +current process calling process t{ +a common mistake made by kernel programmers when writing man pages +t} +manpage t{ +man page, manual page +t} +minus infinity negative infinity +non-root unprivileged user +non-superuser unprivileged user +nonprivileged unprivileged +os operating system +plus infinity positive infinity +pty pseudoterminal +tty terminal +unices unix systems +unixes unix systems +.te +.ad +.\" +.ss trademarks +use the correct spelling and case for trademarks. +the following is a list of the correct spellings of various +relevant trademarks that are sometimes misspelled: +.pp + dg/ux + hp-ux + unix + unixware +.ss null, nul, null pointer, and null byte +a +.ir "null pointer" +is a pointer that points to nothing, +and is normally indicated by the constant +.ir null . +on the other hand, +.i nul +is the +.ir "null byte", +a byte with the value 0, represented in c via the character constant +.ir \(aq\e0\(aq . +.pp +the preferred term for the pointer is "null pointer" or simply "null"; +avoid writing "null pointer". +.pp +the preferred term for the byte is "null byte". +avoid writing "nul", since it is too easily confused with "null". +avoid also the terms "zero byte" and "null character". +the byte that terminates a c string should be described +as "the terminating null byte"; +strings may be described as "null-terminated", +but avoid the use of "nul-terminated". +.ss hyperlinks +for hyperlinks, use the +.ir .ur / .ue +macro pair +(see +.br groff_man (7)). +this produces proper hyperlinks that can be used in a web browser, +when rendering a page with, say: +.pp + browser=firefox man -h pagename +.ss use of e.g., i.e., etc., a.k.a., and similar +in general, the use of abbreviations such as "e.g.", "i.e.", "etc.", +"cf.", and "a.k.a." should be avoided, +in favor of suitable full wordings +("for example", "that is", "and so on", "compare to", "also known as"). +.pp +the only place where such abbreviations may be acceptable is in +.i short +parenthetical asides (e.g., like this one). +.pp +always include periods in such abbreviations, as shown here. +in addition, "e.g." and "i.e." should always be followed by a comma. +.ss em-dashes +the way to write an em-dash\(emthe glyph that appears +at either end of this subphrase\(emin *roff is with the macro "\e(em". +(on an ascii terminal, an em-dash typically renders as two hyphens, +but in other typographical contexts it renders as a long dash.) +em-dashes should be written +.i without +surrounding spaces. +.ss hyphenation of attributive compounds +compound terms should be hyphenated when used attributively +(i.e., to qualify a following noun). some examples: +.pp + 32-bit value + command-line argument + floating-point number + run-time check + user-space function + wide-character string +.ss hyphenation with multi, non, pre, re, sub, and so on +the general tendency in modern english is not to hyphenate +after prefixes such as "multi", "non", "pre", "re", "sub", and so on. +manual pages should generally follow this rule when these prefixes are +used in natural english constructions with simple suffixes. +the following list gives some examples of the preferred forms: +.pp + interprocess + multithreaded + multiprocess + nonblocking + nondefault + nonempty + noninteractive + nonnegative + nonportable + nonzero + preallocated + precreate + prerecorded + reestablished + reinitialize + rearm + reread + subcomponent + subdirectory + subsystem +.pp +hyphens should be retained when the prefixes are used in nonstandard +english words, with trademarks, proper nouns, acronyms, or compound terms. +some examples: +.pp + non-ascii + non-english + non-null + non-real-time +.pp +finally, note that "re-create" and "recreate" are two different verbs, +and the former is probably what you want. +.\" +.ss generating optimal glyphs +where a real minus character is required (e.g., for numbers such as \-1, +for man page cross references such as +.br utf\-8 (7), +or when writing options that have a leading dash, such as in +.ir "ls\ \-l"), +use the following form in the man page source: +.pp + \e\- +.pp +this guideline applies also to code examples. +.pp +the use of real minus signs serves the following purposes: +.\" https://lore.kernel.org/linux-man/20210121061158.5ul7226fgbrmodbt@localhost.localdomain/ +.ip * 3 +to provide better renderings on various targets other than +ascii terminals, +notably in pdf and on unicode/utf\-8-capable terminals. +.ip * +to generate glyphs that when copied from rendered pages will +produce real minus signs when pasted into a terminal. +.pp +to produce unslanted single quotes that render well in ascii, utf-8, and pdf, +use "\e(aq" ("apostrophe quote"); for example +.pp + \e(aqc\e(aq +.pp +where +.i c +is the quoted character. +this guideline applies also to character constants used in code examples. +.pp +where a proper caret (\(ha) that renders well in both a terminal and pdf +is required, use "\\(ha". +this is especially necessary in code samples, +to get a nicely rendered caret when rendering to pdf. +.pp +using a naked "\(ti" character results in a poor rendering in pdf. +instead use "\\(ti". +this is especially necessary in code samples, +to get a nicely rendered tilde when rendering to pdf. +.\" +.ss example programs and shell sessions +manual pages may include example programs demonstrating how to +use a system call or library function. +however, note the following: +.ip * 3 +example programs should be written in c. +.ip * +an example program is necessary and useful only if it demonstrates +something beyond what can easily be provided in a textual +description of the interface. +an example program that does nothing +other than call an interface usually serves little purpose. +.ip * +example programs should ideally be short +(e.g., a good example can often be provided in less than 100 lines of code), +though in some cases longer programs may be necessary +to properly illustrate the use of an api. +.ip * +expressive code is appreciated. +.ip * +comments should included where helpful. +complete sentences in free-standing comments should be +terminated by a period. +periods should generally be omitted in "tag" comments +(i.e., comments that are placed on the same line of code); +such comments are in any case typically brief phrases +rather than complete sentences. +.ip * +example programs should do error checking after system calls and +library function calls. +.ip * +example programs should be complete, and compile without +warnings when compiled with \ficc\ \-wall\fp. +.ip * +where possible and appropriate, example programs should allow +experimentation, by varying their behavior based on inputs +(ideally from command-line arguments, or alternatively, via +input read by the program). +.ip * +example programs should be laid out according to kernighan and +ritchie style, with 4-space indents. +(avoid the use of tab characters in source code!) +the following command can be used to format your source code to +something close to the preferred style: +.ip + indent \-npro \-kr \-i4 \-ts4 \-sob \-l72 \-ss \-nut \-psl prog.c +.ip * +for consistency, all example programs should terminate using either of: +.ip + exit(exit_success); + exit(exit_failure); +.ip +avoid using the following forms to terminate a program: +.ip + exit(0); + exit(1); + return n; +.ip * +if there is extensive explanatory text before the +program source code, mark off the source code +with a subsection heading +.ir "program source" , +as in: +.ip + .ss program source +.ip +always do this if the explanatory text includes a shell session log. +.pp +if you include a shell session log demonstrating the use of a program +or other system feature: +.ip * 3 +place the session log above the source code listing +.ip * +indent the session log by four spaces. +.ip * +boldface the user input text, +to distinguish it from output produced by the system. +.pp +for some examples of what example programs should look like, see +.br wait (2) +and +.br pipe (2). +.sh examples +for canonical examples of how man pages in the +.i man-pages +package should look, see +.br pipe (2) +and +.br fcntl (2). +.sh see also +.br man (1), +.br man2html (1), +.br attributes (7), +.br groff (7), +.br groff_man (7), +.br man (7), +.br mdoc (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2012 by michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th mallinfo 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +mallinfo, mallinfo2 \- obtain memory allocation information +.sh synopsis +.nf +.b #include +.pp +.b struct mallinfo mallinfo(void); +.b struct mallinfo2 mallinfo2(void); +.fi +.sh description +these functions return a copy of a structure containing information about +memory allocations performed by +.br malloc (3) +and related functions. +the structure returned by each function contains the same fields. +however, the older function, +.br mallinfo (), +is deprecated since the type used for the fields is too small (see bugs). +.pp +note that not all allocations are visible to these functions; +see bugs and consider using +.br malloc_info (3) +instead. +.pp +the +.i mallinfo2 +structure returned by +.br mallinfo2 () +is defined as follows: +.pp +.in +4n +.ex +struct mallinfo2 { + size_t arena; /* non\-mmapped space allocated (bytes) */ + size_t ordblks; /* number of free chunks */ + size_t smblks; /* number of free fastbin blocks */ + size_t hblks; /* number of mmapped regions */ + size_t hblkhd; /* space allocated in mmapped regions + (bytes) */ + size_t usmblks; /* see below */ + size_t fsmblks; /* space in freed fastbin blocks (bytes) */ + size_t uordblks; /* total allocated space (bytes) */ + size_t fordblks; /* total free space (bytes) */ + size_t keepcost; /* top\-most, releasable space (bytes) */ +}; +.ee +.in +.pp +the +.i mallinfo +structure returned by the deprecated +.br mallinfo () +function is exactly the same, except that the fields are typed as +.ir int . +.pp +the structure fields contain the following information: +.tp 10 +.i arena +the total amount of memory allocated by means other than +.br mmap (2) +(i.e., memory allocated on the heap). +this figure includes both in-use blocks and blocks on the free list. +.tp +.i ordblks +the number of ordinary (i.e., non-fastbin) free blocks. +.tp +.i smblks +.\" the glibc info page wrongly says this field is unused +.\" https://sourceware.org/bugzilla/show_bug.cgi?id=26746 +the number of fastbin free blocks (see +.br mallopt (3)). +.tp +.i hblks +the number of blocks currently allocated using +.br mmap (2). +(see the discussion of +.b m_mmap_threshold +in +.br mallopt (3).) +.tp +.i hblkhd +the number of bytes in blocks currently allocated using +.br mmap (2). +.tp +.i usmblks +this field is unused, and is always 0. +.\" it seems to have been zero since at least as far back as glibc 2.15 +historically, it was the "highwater mark" for allocated space\(emthat is, +the maximum amount of space that was ever allocated (in bytes); +this field was maintained only in nonthreading environments. +.tp +.i fsmblks +.\" the glibc info page wrongly says this field is unused +.\" https://sourceware.org/bugzilla/show_bug.cgi?id=26746 +the total number of bytes in fastbin free blocks. +.tp +.i uordblks +the total number of bytes used by in-use allocations. +.tp +.i fordblks +the total number of bytes in free blocks. +.tp +.i keepcost +the total amount of releasable free space at the top +of the heap. +this is the maximum number of bytes that could ideally +(i.e., ignoring page alignment restrictions, and so on) be released by +.br malloc_trim (3). +.sh versions +.\" mallinfo(): available already in glibc 2.0, possibly earlier +the +.br mallinfo2 () +function was added +.\" commit e3960d1c57e57f33e0e846d615788f4ede73b945 +in glibc 2.33. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lb lb lbx +l l l. +interface attribute value +t{ +.br mallinfo (), +.br mallinfo2 () +t} thread safety t{ +mt-unsafe init const:mallopt +t} +.te +.hy +.ad +.sp 1 +.br mallinfo ()/ +.br mallinfo2 () +would access some global internal objects. +if modify them with non-atomically, +may get inconsistent results. +the identifier +.i mallopt +in +.i const:mallopt +mean that +.br mallopt () +would modify the global internal objects with atomics, that make sure +.br mallinfo ()/ +.br mallinfo2 () +is safe enough, others modify with non-atomically maybe not. +.sh conforming to +these functions are not specified by posix or the c standards. +a +.br mallinfo () +function exists on many system v derivatives, +and was specified in the svid. +.sh bugs +.\" fixme . http://sourceware.org/bugzilla/show_bug.cgi?id=208 +.\" see the 24 aug 2011 mail by paul pluzhnikov: +.\" "[patch] fix mallinfo() to accumulate results for all arenas" +.\" on libc-alpha@sourceware.org +.b information is returned for only the main memory allocation area. +allocations in other arenas are excluded. +see +.br malloc_stats (3) +and +.br malloc_info (3) +for alternatives that include information about other arenas. +.pp +the fields of the +.i mallinfo +structure that is returned by the older +.br mallinfo () +function are typed as +.ir int . +however, because some internal bookkeeping values may be of type +.ir long , +the reported values may wrap around zero and thus be inaccurate. +.sh examples +the program below employs +.br mallinfo2 () +to retrieve memory allocation statistics before and after +allocating and freeing some blocks of memory. +the statistics are displayed on standard output. +.pp +the first two command-line arguments specify the number and size of +blocks to be allocated with +.br malloc (3). +.pp +the remaining three arguments specify which of the allocated blocks +should be freed with +.br free (3). +these three arguments are optional, and specify (in order): +the step size to be used in the loop that frees blocks +(the default is 1, meaning free all blocks in the range); +the ordinal position of the first block to be freed +(default 0, meaning the first allocated block); +and a number one greater than the ordinal position +of the last block to be freed +(default is one greater than the maximum block number). +if these three arguments are omitted, +then the defaults cause all allocated blocks to be freed. +.pp +in the following example run of the program, +1000 allocations of 100 bytes are performed, +and then every second allocated block is freed: +.pp +.in +4n +.ex +$ \fb./a.out 1000 100 2\fp +============== before allocating blocks ============== +total non\-mmapped bytes (arena): 0 +# of free chunks (ordblks): 1 +# of free fastbin blocks (smblks): 0 +# of mapped regions (hblks): 0 +bytes in mapped regions (hblkhd): 0 +max. total allocated space (usmblks): 0 +free bytes held in fastbins (fsmblks): 0 +total allocated space (uordblks): 0 +total free space (fordblks): 0 +topmost releasable block (keepcost): 0 + +============== after allocating blocks ============== +total non\-mmapped bytes (arena): 135168 +# of free chunks (ordblks): 1 +# of free fastbin blocks (smblks): 0 +# of mapped regions (hblks): 0 +bytes in mapped regions (hblkhd): 0 +max. total allocated space (usmblks): 0 +free bytes held in fastbins (fsmblks): 0 +total allocated space (uordblks): 104000 +total free space (fordblks): 31168 +topmost releasable block (keepcost): 31168 + +============== after freeing blocks ============== +total non\-mmapped bytes (arena): 135168 +# of free chunks (ordblks): 501 +# of free fastbin blocks (smblks): 0 +# of mapped regions (hblks): 0 +bytes in mapped regions (hblkhd): 0 +max. total allocated space (usmblks): 0 +free bytes held in fastbins (fsmblks): 0 +total allocated space (uordblks): 52000 +total free space (fordblks): 83168 +topmost releasable block (keepcost): 31168 +.ee +.in +.ss program source +\& +.ex +#include +#include +#include + +static void +display_mallinfo2(void) +{ + struct mallinfo2 mi; + + mi = mallinfo2(); + + printf("total non\-mmapped bytes (arena): %zu\en", mi.arena); + printf("# of free chunks (ordblks): %zu\en", mi.ordblks); + printf("# of free fastbin blocks (smblks): %zu\en", mi.smblks); + printf("# of mapped regions (hblks): %zu\en", mi.hblks); + printf("bytes in mapped regions (hblkhd): %zu\en", mi.hblkhd); + printf("max. total allocated space (usmblks): %zu\en", mi.usmblks); + printf("free bytes held in fastbins (fsmblks): %zu\en", mi.fsmblks); + printf("total allocated space (uordblks): %zu\en", mi.uordblks); + printf("total free space (fordblks): %zu\en", mi.fordblks); + printf("topmost releasable block (keepcost): %zu\en", mi.keepcost); +} + +int +main(int argc, char *argv[]) +{ +#define max_allocs 2000000 + char *alloc[max_allocs]; + int numblocks, freebegin, freeend, freestep; + size_t blocksize; + + if (argc < 3 || strcmp(argv[1], "\-\-help") == 0) { + fprintf(stderr, "%s num\-blocks block\-size [free\-step " + "[start\-free [end\-free]]]\en", argv[0]); + exit(exit_failure); + } + + numblocks = atoi(argv[1]); + blocksize = atoi(argv[2]); + freestep = (argc > 3) ? atoi(argv[3]) : 1; + freebegin = (argc > 4) ? atoi(argv[4]) : 0; + freeend = (argc > 5) ? atoi(argv[5]) : numblocks; + + printf("============== before allocating blocks ==============\en"); + display_mallinfo2(); + + for (int j = 0; j < numblocks; j++) { + if (numblocks >= max_allocs) { + fprintf(stderr, "too many allocations\en"); + exit(exit_failure); + } + + alloc[j] = malloc(blocksize); + if (alloc[j] == null) { + perror("malloc"); + exit(exit_failure); + } + } + + printf("\en============== after allocating blocks ==============\en"); + display_mallinfo2(); + + for (int j = freebegin; j < freeend; j += freestep) + free(alloc[j]); + + printf("\en============== after freeing blocks ==============\en"); + display_mallinfo2(); + + exit(exit_success); +} +.ee +.sh see also +.ad l +.nh +.br mmap (2), +.br malloc (3), +.br malloc_info (3), +.br malloc_stats (3), +.br malloc_trim (3), +.br mallopt (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/adjtimex.2 + +.\" from dholland@burgundy.eecs.harvard.edu tue mar 24 18:08:15 1998 +.\" +.\" this man page was written in 1998 by david a. holland +.\" polished a bit by aeb. +.\" +.\" %%%license_start(public_domain) +.\" placed in the public domain. +.\" %%%license_end +.\" +.\" 2005-06-16 mtk, mentioned freopen() +.\" 2007-12-08, mtk, converted from mdoc to man macros +.\" +.th stdin 3 2017-09-15 "linux" "linux programmer's manual" +.sh name +stdin, stdout, stderr \- standard i/o streams +.sh synopsis +.nf +.b #include +.pp +.bi "extern file *" stdin ; +.bi "extern file *" stdout ; +.bi "extern file *" stderr ; +.fi +.sh description +under normal circumstances every unix program has three streams opened +for it when it starts up, one for input, one for output, and one for +printing diagnostic or error messages. +these are typically attached to +the user's terminal (see +.br tty (4)) +but might instead refer to files or other devices, depending on what +the parent process chose to set up. +(see also the "redirection" section of +.br sh (1).) +.pp +the input stream is referred to as "standard input"; the output stream is +referred to as "standard output"; and the error stream is referred to +as "standard error". +these terms are abbreviated to form the symbols +used to refer to these files, namely +.ir stdin , +.ir stdout , +and +.ir stderr . +.pp +each of these symbols is a +.br stdio (3) +macro of type pointer to +.ir file , +and can be used with functions like +.br fprintf (3) +or +.br fread (3). +.pp +since +.ir file s +are a buffering wrapper around unix file descriptors, the +same underlying files may also be accessed using the raw unix file +interface, that is, the functions like +.br read (2) +and +.br lseek (2). +.pp +on program startup, the integer file descriptors +associated with the streams +.ir stdin , +.ir stdout , +and +.i stderr +are 0, 1, and 2, respectively. +the preprocessor symbols +.br stdin_fileno , +.br stdout_fileno , +and +.b stderr_fileno +are defined with these values in +.ir . +(applying +.br freopen (3) +to one of these streams can change the file descriptor number +associated with the stream.) +.pp +note that mixing use of +.ir file s +and raw file descriptors can produce +unexpected results and should generally be avoided. +(for the masochistic among you: posix.1, section 8.2.3, describes +in detail how this interaction is supposed to work.) +a general rule is that file descriptors are handled in the kernel, +while stdio is just a library. +this means for example, that after an +.br exec (3), +the child inherits all open file descriptors, but all old streams +have become inaccessible. +.pp +since the symbols +.ir stdin , +.ir stdout , +and +.i stderr +are specified to be macros, assigning to them is nonportable. +the standard streams can be made to refer to different files +with help of the library function +.br freopen (3), +specially introduced to make it possible to reassign +.ir stdin , +.ir stdout , +and +.ir stderr . +the standard streams are closed by a call to +.br exit (3) +and by normal program termination. +.sh conforming to +the +.ir stdin , +.ir stdout , +and +.i stderr +macros conform to c89 +and this standard also stipulates that these three +streams shall be open at program startup. +.sh notes +the stream +.i stderr +is unbuffered. +the stream +.i stdout +is line-buffered when it points to a terminal. +partial lines will not +appear until +.br fflush (3) +or +.br exit (3) +is called, or a newline is printed. +this can produce unexpected +results, especially with debugging output. +the buffering mode of the standard streams (or any other stream) +can be changed using the +.br setbuf (3) +or +.br setvbuf (3) +call. +note that in case +.i stdin +is associated with a terminal, there may also be input buffering +in the terminal driver, entirely unrelated to stdio buffering. +(indeed, normally terminal input is line buffered in the kernel.) +this kernel input handling can be modified using calls like +.br tcsetattr (3); +see also +.br stty (1), +and +.br termios (3). +.sh see also +.br csh (1), +.br sh (1), +.br open (2), +.br fopen (3), +.br stdio (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" +.th wcsnlen 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +wcsnlen \- determine the length of a fixed-size wide-character string +.sh synopsis +.nf +.b #include +.pp +.bi "size_t wcsnlen(const wchar_t *" s ", size_t " maxlen ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br wcsnlen (): +.nf + since glibc 2.10: + _posix_c_source >= 200809l + before glibc 2.10: + _gnu_source +.fi +.sh description +the +.br wcsnlen () +function is the wide-character equivalent +of the +.br strnlen (3) +function. +it returns the number of wide-characters in the string pointed to by +.ir s , +not including the terminating null wide character (l\(aq\e0\(aq), +but at most +.i maxlen +wide characters (note: this parameter is not a byte count). +in doing this, +.br wcsnlen () +looks at only the first +.i maxlen +wide characters at +.i s +and never beyond +.ir s+maxlen . +.sh return value +the +.br wcsnlen () +function returns +.ir wcslen(s) , +if that is less than +.ir maxlen , +or +.i maxlen +if there is no null wide character among the +first +.i maxlen +wide characters pointed to by +.ir s . +.sh versions +the +.br wcsnlen () +function is provided in glibc since version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br wcsnlen () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2008. +.sh see also +.br strnlen (3), +.br wcslen (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/random_r.3 + +.so man7/iso_8859-10.7 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sat jul 24 21:36:50 1993 by rik faith +.\" modified tue oct 22 23:47:36 1996 by eric s. raymond +.th bcmp 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +bcmp \- compare byte sequences +.sh synopsis +.nf +.b #include +.pp +.bi "int bcmp(const void *" s1 ", const void *" s2 ", size_t " n ); +.fi +.sh description +the +.br bcmp () +function compares the two byte sequences +.i s1 +and +.i s2 +of length +.i n +each. +if they are equal, and in particular if +.i n +is zero, +.br bcmp () +returns 0. +otherwise, it returns a nonzero result. +.sh return value +the +.br bcmp () +function returns 0 if the byte sequences are equal, +otherwise a nonzero result is returned. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br bcmp () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +4.3bsd. +this function is deprecated (marked as legacy in posix.1-2001): use +.br memcmp (3) +in new programs. +posix.1-2008 removes the specification of +.br bcmp (). +.sh see also +.br bstring (3), +.br memcmp (3), +.br strcasecmp (3), +.br strcmp (3), +.br strcoll (3), +.br strncasecmp (3), +.br strncmp (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1993 michael haardt (michael@moria.de), +.\" fri apr 2 11:32:09 met dst 1993 +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" modified sat jul 24 16:56:20 1993 by rik faith +.\" modified mon oct 21 21:38:51 1996 by eric s. raymond +.\" (and some more by aeb) +.\" +.th hd 4 2017-09-15 "linux" "linux programmer's manual" +.sh name +hd \- mfm/ide hard disk devices +.sh description +the +.b hd* +devices are block devices to access mfm/ide hard disk drives +in raw mode. +the master drive on the primary ide controller (major device +number 3) is +.br hda ; +the slave drive is +.br hdb . +the master drive of the second controller (major device number 22) +is +.b hdc +and the slave is +.br hdd . +.pp +general ide block device names have the form +.bi hd x\c +, or +.bi hd xp\c +, where +.i x +is a letter denoting the physical drive, and +.i p +is a number denoting the partition on that physical drive. +the first form, +.bi hd x\c +, is used to address the whole drive. +partition numbers are assigned in the order the partitions +are discovered, and only nonempty, nonextended partitions +get a number. +however, partition numbers 1\(en4 are given to the +four partitions described in the mbr (the "primary" partitions), +regardless of whether they are unused or extended. +thus, the first logical partition will be +.bi hd x 5\c +\&. +both dos-type partitioning and bsd-disklabel partitioning are supported. +you can have at most 63 partitions on an ide disk. +.pp +for example, +.i /dev/hda +refers to all of the first ide drive in the system; and +.i /dev/hdb3 +refers to the third dos "primary" partition on the second one. +.pp +they are typically created by: +.pp +.in +4n +.ex +mknod \-m 660 /dev/hda b 3 0 +mknod \-m 660 /dev/hda1 b 3 1 +mknod \-m 660 /dev/hda2 b 3 2 +\&... +mknod \-m 660 /dev/hda8 b 3 8 +mknod \-m 660 /dev/hdb b 3 64 +mknod \-m 660 /dev/hdb1 b 3 65 +mknod \-m 660 /dev/hdb2 b 3 66 +\&... +mknod \-m 660 /dev/hdb8 b 3 72 +chown root:disk /dev/hd* +.ee +.in +.sh files +.i /dev/hd* +.sh see also +.br chown (1), +.br mknod (1), +.br sd (4), +.br mount (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/getlogin.3 + +.so man7/iso_8859-14.7 + +.so man3/end.3 + +.\" copyright (c) 1992 drew eckhardt (drew@cs.colorado.edu), march 28, 1992 +.\" and copyright (c) 2011 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified by michael haardt +.\" modified sat jul 24 12:02:47 1993 by rik faith +.\" modified 15 apr 1995 by michael chastain : +.\" added reference to `bdflush(2)'. +.\" modified 960414 by andries brouwer : +.\" added the fact that since 1.3.20 sync actually waits. +.\" modified tue oct 22 22:27:07 1996 by eric s. raymond +.\" modified 2001-10-10 by aeb, following michael kerrisk. +.\" 2011-09-07, mtk, added syncfs() documentation, +.\" +.th sync 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +sync, syncfs \- commit filesystem caches to disk +.sh synopsis +.nf +.b #include +.pp +.b void sync(void); +.pp +.bi "int syncfs(int " fd ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br sync (): +.nf + _xopen_source >= 500 +.\" || _xopen_source && _xopen_source_extended + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source +.fi +.pp +.br syncfs (): +.nf + _gnu_source +.fi +.sh description +.br sync () +causes all pending modifications to filesystem metadata and cached file +data to be written to the underlying filesystems. +.pp +.br syncfs () +is like +.br sync (), +but synchronizes just the filesystem containing file +referred to by the open file descriptor +.ir fd . +.sh return value +.br syncfs () +returns 0 on success; +on error, it returns \-1 and sets +.i errno +to indicate the error. +.sh errors +.br sync () +is always successful. +.pp +.br syncfs () +can fail for at least the following reasons: +.tp +.b ebadf +.i fd +is not a valid file descriptor. +.tp +.b eio +an error occurred during synchronization. +this error may relate to data written to any file on the filesystem, or on +metadata related to the filesystem itself. +.tp +.b enospc +disk space was exhausted while synchronizing. +.tp +.br enospc ", " edquot +data was written to a file on nfs or another filesystem which does not +allocate space at the time of a +.br write (2) +system call, and some previous write failed due to insufficient +storage space. +.sh versions +.br syncfs () +first appeared in linux 2.6.39; +library support was added to glibc in version 2.14. +.sh conforming to +.br sync (): +posix.1-2001, posix.1-2008, svr4, 4.3bsd. +.pp +.br syncfs () +is linux-specific. +.sh notes +since glibc 2.2.2, the linux prototype for +.br sync () +is as listed above, +following the various standards. +in glibc 2.2.1 and earlier, +it was "int sync(void)", and +.br sync () +always returned 0. +.pp +according to the standard specification (e.g., posix.1-2001), +.br sync () +schedules the writes, but may return before the actual +writing is done. +however linux waits for i/o completions, +and thus +.br sync () +or +.br syncfs () +provide the same guarantees as +.br fsync () +called on every file in +the system or filesystem respectively. +.pp +in mainline kernel versions prior to 5.8, +.br syncfs () +will fail only when passed a bad file descriptor +.rb ( ebadf ). +since linux 5.8, +.\" commit 735e4ae5ba28c886d249ad04d3c8cc097dad6336 +.br syncfs () +will also report an error if one or more inodes failed +to be written back since the last +.br syncfs () +call. +.sh bugs +before version 1.3.20 linux did not wait for i/o to complete +before returning. +.sh see also +.br sync (1), +.br fdatasync (2), +.br fsync (2) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/y0.3 + +.so man3/fdim.3 + +.\" this man page is copyright (c) 1999 andi kleen . +.\" and copyright (c) 2008 michael kerrisk +.\" note also that many pieces are drawn from the kernel source file +.\" documentation/networking/ip-sysctl.txt. +.\" +.\" %%%license_start(verbatim_one_para) +.\" permission is granted to distribute possibly modified copies +.\" of this page provided the header is included verbatim, +.\" and in case of nontrivial modification author and date +.\" of the modification is added to the header. +.\" %%%license_end +.\" +.\" 2.4 updates by nivedita singhvi 4/20/02 . +.\" modified, 2004-11-11, michael kerrisk and andries brouwer +.\" updated details of interaction of tcp_cork and tcp_nodelay. +.\" +.\" 2008-11-21, mtk, many, many updates. +.\" the descriptions of /proc files and socket options should now +.\" be more or less up to date and complete as at linux 2.6.27 +.\" (other than the remaining fixmes in the page source below). +.\" +.\" fixme the following need to be documented +.\" tcp_md5sig (2.6.20) +.\" commit cfb6eeb4c860592edd123fdea908d23c6ad1c7dc +.\" author was yoshfuji@linux-ipv6.org +.\" needs config_tcp_md5sig +.\" from net/inet/kconfig: +.\" bool "tcp: md5 signature option support (rfc2385) (experimental)" +.\" rfc2385 specifies a method of giving md5 protection to tcp sessions. +.\" its main (only?) use is to protect bgp sessions between core routers +.\" on the internet. +.\" +.\" there is a tcp_md5sig option documented in freebsd's tcp(4), +.\" but probably many details are different on linux +.\" http://thread.gmane.org/gmane.linux.network/47490 +.\" http://www.daemon-systems.org/man/tcp.4.html +.\" http://article.gmane.org/gmane.os.netbsd.devel.network/3767/match=tcp_md5sig+freebsd +.\" +.\" tcp_cookie_transactions (2.6.33) +.\" commit 519855c508b9a17878c0977a3cdefc09b59b30df +.\" author: william allen simpson +.\" commit e56fb50f2b7958b931c8a2fc0966061b3f3c8f3a +.\" author: william allen simpson +.\" +.\" removed in linux 3.10 +.\" commit 1a2c6181c4a1922021b4d7df373bba612c3e5f04 +.\" author: christoph paasch +.\" +.\" tcp_thin_linear_timeouts (2.6.34) +.\" commit 36e31b0af58728071e8023cf8e20c5166b700717 +.\" author: andreas petlund +.\" +.\" tcp_thin_dupack (2.6.34) +.\" commit 7e38017557bc0b87434d184f8804cadb102bb903 +.\" author: andreas petlund +.\" +.\" tcp_repair (3.5) +.\" commit ee9952831cfd0bbe834f4a26489d7dce74582e37 +.\" author: pavel emelyanov +.\" see also +.\" http://criu.org/tcp_connection +.\" https://lwn.net/articles/495304/ +.\" +.\" tcp_repair_queue (3.5) +.\" commit ee9952831cfd0bbe834f4a26489d7dce74582e37 +.\" author: pavel emelyanov +.\" +.\" tcp_queue_seq (3.5) +.\" commit ee9952831cfd0bbe834f4a26489d7dce74582e37 +.\" author: pavel emelyanov +.\" +.\" tcp_repair_options (3.5) +.\" commit b139ba4e90dccbf4cd4efb112af96a5c9e0b098c +.\" author: pavel emelyanov +.\" +.\" tcp_fastopen (3.6) +.\" (fast open server side implementation completed in 3.7) +.\" http://lwn.net/articles/508865/ +.\" +.\" tcp_timestamp (3.9) +.\" commit 93be6ce0e91b6a94783e012b1857a347a5e6e9f2 +.\" author: andrey vagin +.\" +.\" tcp_notsent_lowat (3.12) +.\" commit c9bee3b7fdecb0c1d070c7b54113b3bdfb9a3d36 +.\" author: eric dumazet +.\" +.\" tcp_cc_info (4.1) +.\" commit 6e9250f59ef9efb932c84850cd221f22c2a03c4a +.\" author: eric dumazet +.\" +.\" tcp_save_syn, tcp_saved_syn (4.2) +.\" commit cd8ae85299d54155702a56811b2e035e63064d3d +.\" author: eric dumazet +.\" +.th tcp 7 2021-03-22 "linux" "linux programmer's manual" +.sh name +tcp \- tcp protocol +.sh synopsis +.nf +.b #include +.b #include +.b #include +.pp +.b tcp_socket = socket(af_inet, sock_stream, 0); +.fi +.sh description +this is an implementation of the tcp protocol defined in +rfc\ 793, rfc\ 1122 and rfc\ 2001 with the newreno and sack +extensions. +it provides a reliable, stream-oriented, +full-duplex connection between two sockets on top of +.br ip (7), +for both v4 and v6 versions. +tcp guarantees that the data arrives in order and +retransmits lost packets. +it generates and checks a per-packet checksum to catch +transmission errors. +tcp does not preserve record boundaries. +.pp +a newly created tcp socket has no remote or local address and is not +fully specified. +to create an outgoing tcp connection use +.br connect (2) +to establish a connection to another tcp socket. +to receive new incoming connections, first +.br bind (2) +the socket to a local address and port and then call +.br listen (2) +to put the socket into the listening state. +after that a new socket for each incoming connection can be accepted using +.br accept (2). +a socket which has had +.br accept (2) +or +.br connect (2) +successfully called on it is fully specified and may transmit data. +data cannot be transmitted on listening or not yet connected sockets. +.pp +linux supports rfc\ 1323 tcp high performance +extensions. +these include protection against wrapped +sequence numbers (paws), window scaling and timestamps. +window scaling allows the use +of large (> 64\ kb) tcp windows in order to support links with high +latency or bandwidth. +to make use of them, the send and receive buffer sizes must be increased. +they can be set globally with the +.i /proc/sys/net/ipv4/tcp_wmem +and +.i /proc/sys/net/ipv4/tcp_rmem +files, or on individual sockets by using the +.b so_sndbuf +and +.b so_rcvbuf +socket options with the +.br setsockopt (2) +call. +.pp +the maximum sizes for socket buffers declared via the +.b so_sndbuf +and +.b so_rcvbuf +mechanisms are limited by the values in the +.i /proc/sys/net/core/rmem_max +and +.i /proc/sys/net/core/wmem_max +files. +note that tcp actually allocates twice the size of +the buffer requested in the +.br setsockopt (2) +call, and so a succeeding +.br getsockopt (2) +call will not return the same size of buffer as requested in the +.br setsockopt (2) +call. +tcp uses the extra space for administrative purposes and internal +kernel structures, and the +.i /proc +file values reflect the +larger sizes compared to the actual tcp windows. +on individual connections, the socket buffer size must be set prior to the +.br listen (2) +or +.br connect (2) +calls in order to have it take effect. +see +.br socket (7) +for more information. +.pp +tcp supports urgent data. +urgent data is used to signal the +receiver that some important message is part of the data +stream and that it should be processed as soon as possible. +to send urgent data specify the +.b msg_oob +option to +.br send (2). +when urgent data is received, the kernel sends a +.b sigurg +signal to the process or process group that has been set as the +socket "owner" using the +.b siocspgrp +or +.b fiosetown +ioctls (or the posix.1-specified +.br fcntl (2) +.b f_setown +operation). +when the +.b so_oobinline +socket option is enabled, urgent data is put into the normal +data stream (a program can test for its location using the +.b siocatmark +ioctl described below), +otherwise it can be received only when the +.b msg_oob +flag is set for +.br recv (2) +or +.br recvmsg (2). +.pp +when out-of-band data is present, +.br select (2) +indicates the file descriptor as having an exceptional condition and +.i poll (2) +indicates a +.b pollpri +event. +.pp +linux 2.4 introduced a number of changes for improved +throughput and scaling, as well as enhanced functionality. +some of these features include support for zero-copy +.br sendfile (2), +explicit congestion notification, new +management of time_wait sockets, keep-alive socket options +and support for duplicate sack extensions. +.ss address formats +tcp is built on top of ip (see +.br ip (7)). +the address formats defined by +.br ip (7) +apply to tcp. +tcp supports point-to-point communication only; +broadcasting and multicasting are not +supported. +.ss /proc interfaces +system-wide tcp parameter settings can be accessed by files in the directory +.ir /proc/sys/net/ipv4/ . +in addition, most ip +.i /proc +interfaces also apply to tcp; see +.br ip (7). +variables described as +.i boolean +take an integer value, with a nonzero value ("true") meaning that +the corresponding option is enabled, and a zero value ("false") +meaning that the option is disabled. +.tp +.ir tcp_abc " (integer; default: 0; linux 2.6.15 to linux 3.8)" +.\" since 2.6.15; removed in 3.9 +.\" commit ca2eb5679f8ddffff60156af42595df44a315ef0 +.\" the following is from 2.6.28-rc4: documentation/networking/ip-sysctl.txt +control the appropriate byte count (abc), defined in rfc 3465. +abc is a way of increasing the congestion window +.ri ( cwnd ) +more slowly in response to partial acknowledgements. +possible values are: +.rs +.ip 0 3 +increase +.i cwnd +once per acknowledgement (no abc) +.ip 1 +increase +.i cwnd +once per acknowledgement of full sized segment +.ip 2 +allow increase +.i cwnd +by two if acknowledgement is +of two segments to compensate for delayed acknowledgements. +.re +.tp +.ir tcp_abort_on_overflow " (boolean; default: disabled; since linux 2.4)" +.\" since 2.3.41 +enable resetting connections if the listening service is too +slow and unable to keep up and accept them. +it means that if overflow occurred due +to a burst, the connection will recover. +enable this option +.i only +if you are really sure that the listening daemon +cannot be tuned to accept connections faster. +enabling this option can harm the clients of your server. +.tp +.ir tcp_adv_win_scale " (integer; default: 2; since linux 2.4)" +.\" since 2.4.0-test7 +count buffering overhead as +.ir "bytes/2^tcp_adv_win_scale" , +if +.i tcp_adv_win_scale +is greater than 0; or +.ir "bytes\-bytes/2^(\-tcp_adv_win_scale)" , +if +.i tcp_adv_win_scale +is less than or equal to zero. +.ip +the socket receive buffer space is shared between the +application and kernel. +tcp maintains part of the buffer as +the tcp window, this is the size of the receive window +advertised to the other end. +the rest of the space is used +as the "application" buffer, used to isolate the network +from scheduling and application latencies. +the +.i tcp_adv_win_scale +default value of 2 implies that the space +used for the application buffer is one fourth that of the total. +.tp +.ir tcp_allowed_congestion_control " (string; default: see text; since linux 2.4.20)" +.\" the following is from 2.6.28-rc4: documentation/networking/ip-sysctl.txt +show/set the congestion control algorithm choices available to unprivileged +processes (see the description of the +.b tcp_congestion +socket option). +the items in the list are separated by white space and +terminated by a newline character. +the list is a subset of those listed in +.ir tcp_available_congestion_control . +the default value for this list is "reno" plus the default setting of +.ir tcp_congestion_control . +.tp +.ir tcp_autocorking " (boolean; default: enabled; since linux 3.14)" +.\" commit f54b311142a92ea2e42598e347b84e1655caf8e3 +.\" text heavily based on documentation/networking/ip-sysctl.txt +if this option is enabled, the kernel tries to coalesce small writes +(from consecutive +.br write (2) +and +.br sendmsg (2) +calls) as much as possible, +in order to decrease the total number of sent packets. +coalescing is done if at least one prior packet for the flow +is waiting in qdisc queues or device transmit queue. +applications can still use the +.b tcp_cork +socket option to obtain optimal behavior +when they know how/when to uncork their sockets. +.tp +.ir tcp_available_congestion_control " (string; read-only; since linux 2.4.20)" +.\" the following is from 2.6.28-rc4: documentation/networking/ip-sysctl.txt +show a list of the congestion-control algorithms +that are registered. +the items in the list are separated by white space and +terminated by a newline character. +this list is a limiting set for the list in +.ir tcp_allowed_congestion_control . +more congestion-control algorithms may be available as modules, +but not loaded. +.tp +.ir tcp_app_win " (integer; default: 31; since linux 2.4)" +.\" since 2.4.0-test7 +this variable defines how many +bytes of the tcp window are reserved for buffering overhead. +.ip +a maximum of (\fiwindow/2^tcp_app_win\fp, mss) bytes in the window +are reserved for the application buffer. +a value of 0 implies that no amount is reserved. +.\" +.\" the following is from 2.6.28-rc4: documentation/networking/ip-sysctl.txt +.tp +.ir tcp_base_mss " (integer; default: 512; since linux 2.6.17)" +the initial value of +.i search_low +to be used by the packetization layer path mtu discovery (mtu probing). +if mtu probing is enabled, +this is the initial mss used by the connection. +.\" +.\" the following is from 2.6.12: documentation/networking/ip-sysctl.txt +.tp +.ir tcp_bic " (boolean; default: disabled; linux 2.4.27/2.6.6 to 2.6.13)" +enable bic tcp congestion control algorithm. +bic-tcp is a sender-side-only change that ensures a linear rtt +fairness under large windows while offering both scalability and +bounded tcp-friendliness. +the protocol combines two schemes +called additive increase and binary search increase. +when the congestion window is large, additive increase with a large +increment ensures linear rtt fairness as well as good scalability. +under small congestion windows, binary search +increase provides tcp friendliness. +.\" +.\" the following is from 2.6.12: documentation/networking/ip-sysctl.txt +.tp +.ir tcp_bic_low_window " (integer; default: 14; linux 2.4.27/2.6.6 to 2.6.13)" +set the threshold window (in packets) where bic tcp starts to +adjust the congestion window. +below this threshold bic tcp behaves the same as the default tcp reno. +.\" +.\" the following is from 2.6.12: documentation/networking/ip-sysctl.txt +.tp +.ir tcp_bic_fast_convergence " (boolean; default: enabled; linux 2.4.27/2.6.6 to 2.6.13)" +force bic tcp to more quickly respond to changes in congestion window. +allows two flows sharing the same connection to converge more rapidly. +.tp +.ir tcp_congestion_control " (string; default: see text; since linux 2.4.13)" +.\" the following is from 2.6.28-rc4: documentation/networking/ip-sysctl.txt +set the default congestion-control algorithm to be used for new connections. +the algorithm "reno" is always available, +but additional choices may be available depending on kernel configuration. +the default value for this file is set as part of kernel configuration. +.tp +.ir tcp_dma_copybreak " (integer; default: 4096; since linux 2.6.24)" +lower limit, in bytes, of the size of socket reads that will be +offloaded to a dma copy engine, if one is present in the system +and the kernel was configured with the +.b config_net_dma +option. +.tp +.ir tcp_dsack " (boolean; default: enabled; since linux 2.4)" +.\" since 2.4.0-test7 +enable rfc\ 2883 tcp duplicate sack support. +.tp +.ir tcp_ecn " (integer; default: see below; since linux 2.4)" +.\" since 2.4.0-test7 +enable rfc\ 3168 explicit congestion notification. +.ip +this file can have one of the following values: +.rs +.ip 0 +disable ecn. +neither initiate nor accept ecn. +this was the default up to and including linux 2.6.30. +.ip 1 +enable ecn when requested by incoming connections and also +request ecn on outgoing connection attempts. +.ip 2 +.\" commit 255cac91c3c9ce7dca7713b93ab03c75b7902e0e +enable ecn when requested by incoming connections, +but do not request ecn on outgoing connections. +this value is supported, and is the default, since linux 2.6.31. +.re +.ip +when enabled, connectivity to some destinations could be affected +due to older, misbehaving middle boxes along the path, causing +connections to be dropped. +however, to facilitate and encourage deployment with option 1, and +to work around such buggy equipment, the +.b tcp_ecn_fallback +option has been introduced. +.tp +.ir tcp_ecn_fallback " (boolean; default: enabled; since linux 4.1)" +.\" commit 492135557dc090a1abb2cfbe1a412757e3ed68ab +enable rfc\ 3168, section 6.1.1.1. fallback. +when enabled, outgoing ecn-setup syns that time out within the +normal syn retransmission timeout will be resent with cwr and +ece cleared. +.tp +.ir tcp_fack " (boolean; default: enabled; since linux 2.2)" +.\" since 2.1.92 +enable tcp forward acknowledgement support. +.tp +.ir tcp_fin_timeout " (integer; default: 60; since linux 2.2)" +.\" since 2.1.53 +this specifies how many seconds to wait for a final fin packet before the +socket is forcibly closed. +this is strictly a violation of the tcp specification, +but required to prevent denial-of-service attacks. +in linux 2.2, the default value was 180. +.\" +.\" the following is from 2.6.12: documentation/networking/ip-sysctl.txt +.tp +.ir tcp_frto " (integer; default: see below; since linux 2.4.21/2.6)" +.\" since 2.4.21/2.5.43 +enable f-rto, an enhanced recovery algorithm for tcp retransmission +timeouts (rtos). +it is particularly beneficial in wireless environments +where packet loss is typically due to random radio interference +rather than intermediate router congestion. +see rfc 4138 for more details. +.ip +this file can have one of the following values: +.rs +.ip 0 3 +disabled. +this was the default up to and including linux 2.6.23. +.ip 1 +the basic version f-rto algorithm is enabled. +.ip 2 +.\" commit c96fd3d461fa495400df24be3b3b66f0e0b152f9 +enable sack-enhanced f-rto if flow uses sack. +the basic version can be used also when +sack is in use though in that case scenario(s) exists where f-rto +interacts badly with the packet counting of the sack-enabled tcp flow. +this value is the default since linux 2.6.24. +.re +.ip +before linux 2.6.22, this parameter was a boolean value, +supporting just values 0 and 1 above. +.tp +.ir tcp_frto_response " (integer; default: 0; since linux 2.6.22)" +when f-rto has detected that a tcp retransmission timeout was spurious +(i.e., the timeout would have been avoided had tcp set a +longer retransmission timeout), +tcp has several options concerning what to do next. +possible values are: +.rs +.ip 0 3 +rate halving based; a smooth and conservative response, +results in halved congestion window +.ri ( cwnd ) +and slow-start threshold +.ri ( ssthresh ) +after one rtt. +.ip 1 +very conservative response; not recommended because even +though being valid, it interacts poorly with the rest of linux tcp; halves +.i cwnd +and +.i ssthresh +immediately. +.ip 2 +aggressive response; undoes congestion-control measures +that are now known to be unnecessary +(ignoring the possibility of a lost retransmission that would require +tcp to be more cautious); +.i cwnd +and +.i ssthresh +are restored to the values prior to timeout. +.re +.tp +.ir tcp_keepalive_intvl " (integer; default: 75; since linux 2.4)" +.\" since 2.3.18 +the number of seconds between tcp keep-alive probes. +.tp +.ir tcp_keepalive_probes " (integer; default: 9; since linux 2.2)" +.\" since 2.1.43 +the maximum number of tcp keep-alive probes to send +before giving up and killing the connection if +no response is obtained from the other end. +.tp +.ir tcp_keepalive_time " (integer; default: 7200; since linux 2.2)" +.\" since 2.1.43 +the number of seconds a connection needs to be idle +before tcp begins sending out keep-alive probes. +keep-alives are sent only when the +.b so_keepalive +socket option is enabled. +the default value is 7200 seconds (2 hours). +an idle connection is terminated after +approximately an additional 11 minutes (9 probes an interval +of 75 seconds apart) when keep-alive is enabled. +.ip +note that underlying connection tracking mechanisms and +application timeouts may be much shorter. +.\" +.\" the following is from 2.6.12: documentation/networking/ip-sysctl.txt +.tp +.ir tcp_low_latency " (boolean; default: disabled; since linux 2.4.21/2.6; \ +obsolete since linux 4.14)" +.\" since 2.4.21/2.5.60 +if enabled, the tcp stack makes decisions that prefer lower +latency as opposed to higher throughput. +it this option is disabled, then higher throughput is preferred. +an example of an application where this default should be +changed would be a beowulf compute cluster. +since linux 4.14, +.\" commit b6690b14386698ce2c19309abad3f17656bdfaea +this file still exists, but its value is ignored. +.tp +.ir tcp_max_orphans " (integer; default: see below; since linux 2.4)" +.\" since 2.3.41 +the maximum number of orphaned (not attached to any user file +handle) tcp sockets allowed in the system. +when this number is exceeded, +the orphaned connection is reset and a warning is printed. +this limit exists only to prevent simple denial-of-service attacks. +lowering this limit is not recommended. +network conditions might require you to increase the number of +orphans allowed, but note that each orphan can eat up to \(ti64\ kb +of unswappable memory. +the default initial value is set equal to the kernel parameter nr_file. +this initial default is adjusted depending on the memory in the system. +.tp +.ir tcp_max_syn_backlog " (integer; default: see below; since linux 2.2)" +.\" since 2.1.53 +the maximum number of queued connection requests which have +still not received an acknowledgement from the connecting client. +if this number is exceeded, the kernel will begin +dropping requests. +the default value of 256 is increased to +1024 when the memory present in the system is adequate or +greater (>= 128\ mb), and reduced to 128 for those systems with +very low memory (<= 32\ mb). +.ip +prior to linux 2.6.20, +.\" commit 72a3effaf633bcae9034b7e176bdbd78d64a71db +it was recommended that if this needed to be increased above 1024, +the size of the synack hash table +.rb ( tcp_synq_hsize ) +in +.i include/net/tcp.h +should be modified to keep +.ip + tcp_synq_hsize * 16 <= tcp_max_syn_backlog +.ip +and the kernel should be +recompiled. +in linux 2.6.20, the fixed sized +.b tcp_synq_hsize +was removed in favor of dynamic sizing. +.tp +.ir tcp_max_tw_buckets " (integer; default: see below; since linux 2.4)" +.\" since 2.3.41 +the maximum number of sockets in time_wait state allowed in +the system. +this limit exists only to prevent simple denial-of-service attacks. +the default value of nr_file*2 is adjusted +depending on the memory in the system. +if this number is +exceeded, the socket is closed and a warning is printed. +.tp +.ir tcp_moderate_rcvbuf " (boolean; default: enabled; since linux 2.4.17/2.6.7)" +.\" the following is from 2.6.28-rc4: documentation/networking/ip-sysctl.txt +if enabled, tcp performs receive buffer auto-tuning, +attempting to automatically size the buffer (no greater than +.ir tcp_rmem[2] ) +to match the size required by the path for full throughput. +.tp +.ir tcp_mem " (since linux 2.4)" +.\" since 2.4.0-test7 +this is a vector of 3 integers: [low, pressure, high]. +these bounds, measured in units of the system page size, +are used by tcp to track its memory usage. +the defaults are calculated at boot time from the amount of +available memory. +(tcp can only use +.i "low memory" +for this, which is limited to around 900 megabytes on 32-bit systems. +64-bit systems do not suffer this limitation.) +.rs +.tp +.i low +tcp doesn't regulate its memory allocation when the number +of pages it has allocated globally is below this number. +.tp +.i pressure +when the amount of memory allocated by tcp +exceeds this number of pages, tcp moderates its memory consumption. +this memory pressure state is exited +once the number of pages allocated falls below +the +.i low +mark. +.tp +.i high +the maximum number of pages, globally, that tcp will allocate. +this value overrides any other limits imposed by the kernel. +.re +.tp +.ir tcp_mtu_probing " (integer; default: 0; since linux 2.6.17)" +.\" the following is from 2.6.28-rc4: documentation/networking/ip-sysctl.txt +this parameter controls tcp packetization-layer path mtu discovery. +the following values may be assigned to the file: +.rs +.ip 0 3 +disabled +.ip 1 +disabled by default, enabled when an icmp black hole detected +.ip 2 +always enabled, use initial mss of +.ir tcp_base_mss . +.re +.tp +.ir tcp_no_metrics_save " (boolean; default: disabled; since linux 2.6.6)" +.\" the following is from 2.6.28-rc4: documentation/networking/ip-sysctl.txt +by default, tcp saves various connection metrics in the route cache +when the connection closes, so that connections established in the +near future can use these to set initial conditions. +usually, this increases overall performance, +but it may sometimes cause performance degradation. +if +.i tcp_no_metrics_save +is enabled, tcp will not cache metrics on closing connections. +.tp +.ir tcp_orphan_retries " (integer; default: 8; since linux 2.4)" +.\" since 2.3.41 +the maximum number of attempts made to probe the other +end of a connection which has been closed by our end. +.tp +.ir tcp_reordering " (integer; default: 3; since linux 2.4)" +.\" since 2.4.0-test7 +the maximum a packet can be reordered in a tcp packet stream +without tcp assuming packet loss and going into slow start. +it is not advisable to change this number. +this is a packet reordering detection metric designed to +minimize unnecessary back off and retransmits provoked by +reordering of packets on a connection. +.tp +.ir tcp_retrans_collapse " (boolean; default: enabled; since linux 2.2)" +.\" since 2.1.96 +try to send full-sized packets during retransmit. +.tp +.ir tcp_retries1 " (integer; default: 3; since linux 2.2)" +.\" since 2.1.43 +the number of times tcp will attempt to retransmit a +packet on an established connection normally, +without the extra effort of getting the network layers involved. +once we exceed this number of +retransmits, we first have the network layer +update the route if possible before each new retransmit. +the default is the rfc specified minimum of 3. +.tp +.ir tcp_retries2 " (integer; default: 15; since linux 2.2)" +.\" since 2.1.43 +the maximum number of times a tcp packet is retransmitted +in established state before giving up. +the default value is 15, which corresponds to a duration of +approximately between 13 to 30 minutes, depending +on the retransmission timeout. +the rfc\ 1122 specified +minimum limit of 100 seconds is typically deemed too short. +.tp +.ir tcp_rfc1337 " (boolean; default: disabled; since linux 2.2)" +.\" since 2.1.90 +enable tcp behavior conformant with rfc\ 1337. +when disabled, +if a rst is received in time_wait state, we close +the socket immediately without waiting for the end +of the time_wait period. +.tp +.ir tcp_rmem " (since linux 2.4)" +.\" since 2.4.0-test7 +this is a vector of 3 integers: [min, default, max]. +these parameters are used by tcp to regulate receive buffer sizes. +tcp dynamically adjusts the size of the +receive buffer from the defaults listed below, in the range +of these values, depending on memory available in the system. +.rs +.tp +.i min +minimum size of the receive buffer used by each tcp socket. +the default value is the system page size. +(on linux 2.4, the default value is 4\ kb, lowered to +.b page_size +bytes in low-memory systems.) +this value +is used to ensure that in memory pressure mode, +allocations below this size will still succeed. +this is not +used to bound the size of the receive buffer declared +using +.b so_rcvbuf +on a socket. +.tp +.i default +the default size of the receive buffer for a tcp socket. +this value overwrites the initial default buffer size from +the generic global +.i net.core.rmem_default +defined for all protocols. +the default value is 87380 bytes. +(on linux 2.4, this will be lowered to 43689 in low-memory systems.) +if larger receive buffer sizes are desired, this value should +be increased (to affect all sockets). +to employ large tcp windows, the +.i net.ipv4.tcp_window_scaling +must be enabled (default). +.tp +.i max +the maximum size of the receive buffer used by each tcp socket. +this value does not override the global +.ir net.core.rmem_max . +this is not used to limit the size of the receive buffer declared using +.b so_rcvbuf +on a socket. +the default value is calculated using the formula +.ip + max(87380, min(4\ mb, \fitcp_mem\fp[1]*page_size/128)) +.ip +(on linux 2.4, the default is 87380*2 bytes, +lowered to 87380 in low-memory systems). +.re +.tp +.ir tcp_sack " (boolean; default: enabled; since linux 2.2)" +.\" since 2.1.36 +enable rfc\ 2018 tcp selective acknowledgements. +.tp +.ir tcp_slow_start_after_idle " (boolean; default: enabled; since linux 2.6.18)" +.\" the following is from 2.6.28-rc4: documentation/networking/ip-sysctl.txt +if enabled, provide rfc 2861 behavior and time out the congestion +window after an idle period. +an idle period is defined as the current rto (retransmission timeout). +if disabled, the congestion window will not +be timed out after an idle period. +.tp +.ir tcp_stdurg " (boolean; default: disabled; since linux 2.2)" +.\" since 2.1.44 +if this option is enabled, then use the rfc\ 1122 interpretation +of the tcp urgent-pointer field. +.\" rfc 793 was ambiguous in its specification of the meaning of the +.\" urgent pointer. rfc 1122 (and rfc 961) fixed on a particular +.\" resolution of this ambiguity (unfortunately the "wrong" one). +according to this interpretation, the urgent pointer points +to the last byte of urgent data. +if this option is disabled, then use the bsd-compatible interpretation of +the urgent pointer: +the urgent pointer points to the first byte after the urgent data. +enabling this option may lead to interoperability problems. +.tp +.ir tcp_syn_retries " (integer; default: 6; since linux 2.2)" +.\" since 2.1.38 +the maximum number of times initial syns for an active tcp +connection attempt will be retransmitted. +this value should not be higher than 255. +the default value is 6, which corresponds to retrying for up to +approximately 127 seconds. +before linux 3.7, +.\" commit 6c9ff979d1921e9fd05d89e1383121c2503759b9 +the default value was 5, which +(in conjunction with calculation based on other kernel parameters) +corresponded to approximately 180 seconds. +.tp +.ir tcp_synack_retries " (integer; default: 5; since linux 2.2)" +.\" since 2.1.38 +the maximum number of times a syn/ack segment +for a passive tcp connection will be retransmitted. +this number should not be higher than 255. +.tp +.ir tcp_syncookies " (integer; default: 1; since linux 2.2)" +.\" since 2.1.43 +enable tcp syncookies. +the kernel must be compiled with +.br config_syn_cookies . +the syncookies feature attempts to protect a +socket from a syn flood attack. +this should be used as a last resort, if at all. +this is a violation of the tcp protocol, +and conflicts with other areas of tcp such as tcp extensions. +it can cause problems for clients and relays. +it is not recommended as a tuning mechanism for heavily +loaded servers to help with overloaded or misconfigured conditions. +for recommended alternatives see +.ir tcp_max_syn_backlog , +.ir tcp_synack_retries , +and +.ir tcp_abort_on_overflow . +set to one of the following values: +.rs +.ip 0 3 +disable tcp syncookies. +.ip 1 +send out syncookies when the syn backlog queue of a socket overflows. +.ip 2 +(since linux 3.12) +.\" commit 5ad37d5deee1ff7150a2d0602370101de158ad86 +send out syncookies unconditionally. +this can be useful for network testing. +.re +.tp +.ir tcp_timestamps " (integer; default: 1; since linux 2.2)" +.\" since 2.1.36 +set to one of the following values to enable or disable rfc\ 1323 +tcp timestamps: +.rs +.ip 0 3 +disable timestamps. +.ip 1 +enable timestamps as defined in rfc1323 and use random offset for +each connection rather than only using the current time. +.ip 2 +as for the value 1, but without random offsets. +.\" commit 25429d7b7dca01dc4f17205de023a30ca09390d0 +setting +.i tcp_timestamps +to this value is meaningful since linux 4.10. +.re +.tp +.ir tcp_tso_win_divisor " (integer; default: 3; since linux 2.6.9)" +this parameter controls what percentage of the congestion window +can be consumed by a single tcp segmentation offload (tso) frame. +the setting of this parameter is a tradeoff between burstiness and +building larger tso frames. +.tp +.ir tcp_tw_recycle " (boolean; default: disabled; linux 2.4 to 4.11)" +.\" since 2.3.15 +.\" removed in 4.12; commit 4396e46187ca5070219b81773c4e65088dac50cc +enable fast recycling of time_wait sockets. +enabling this option is +not recommended as the remote ip may not use monotonically increasing +timestamps (devices behind nat, devices with per-connection timestamp +offsets). +see rfc 1323 (paws) and rfc 6191. +.\" +.\" the following is from 2.6.12: documentation/networking/ip-sysctl.txt +.tp +.ir tcp_tw_reuse " (boolean; default: disabled; since linux 2.4.19/2.6)" +.\" since 2.4.19/2.5.43 +allow to reuse time_wait sockets for new connections when it is +safe from protocol viewpoint. +it should not be changed without advice/request of technical experts. +.\" +.\" the following is from 2.6.12: documentation/networking/ip-sysctl.txt +.tp +.ir tcp_vegas_cong_avoid " (boolean; default: disabled; linux 2.2 to 2.6.13)" +.\" since 2.1.8; removed in 2.6.13 +enable tcp vegas congestion avoidance algorithm. +tcp vegas is a sender-side-only change to tcp that anticipates +the onset of congestion by estimating the bandwidth. +tcp vegas adjusts the sending rate by modifying the congestion window. +tcp vegas should provide less packet loss, but it is +not as aggressive as tcp reno. +.\" +.\" the following is from 2.6.12: documentation/networking/ip-sysctl.txt +.tp +.ir tcp_westwood " (boolean; default: disabled; linux 2.4.26/2.6.3 to 2.6.13)" +enable tcp westwood+ congestion control algorithm. +tcp westwood+ is a sender-side-only modification of the tcp reno +protocol stack that optimizes the performance of tcp congestion control. +it is based on end-to-end bandwidth estimation to set +congestion window and slow start threshold after a congestion episode. +using this estimation, tcp westwood+ adaptively sets a +slow start threshold and a congestion window which takes into +account the bandwidth used at the time congestion is experienced. +tcp westwood+ significantly increases fairness with respect to +tcp reno in wired networks and throughput over wireless links. +.tp +.ir tcp_window_scaling " (boolean; default: enabled; since linux 2.2)" +.\" since 2.1.36 +enable rfc\ 1323 tcp window scaling. +this feature allows the use of a large window +(> 64\ kb) on a tcp connection, should the other end support it. +normally, the 16 bit window length field in the tcp header +limits the window size to less than 64\ kb. +if larger windows are desired, applications can increase the size of +their socket buffers and the window scaling option will be employed. +if +.i tcp_window_scaling +is disabled, tcp will not negotiate the use of window +scaling with the other end during connection setup. +.tp +.ir tcp_wmem " (since linux 2.4)" +.\" since 2.4.0-test7 +this is a vector of 3 integers: [min, default, max]. +these parameters are used by tcp to regulate send buffer sizes. +tcp dynamically adjusts the size of the send buffer from the +default values listed below, in the range of these values, +depending on memory available. +.rs +.tp +.i min +minimum size of the send buffer used by each tcp socket. +the default value is the system page size. +(on linux 2.4, the default value is 4\ kb.) +this value is used to ensure that in memory pressure mode, +allocations below this size will still succeed. +this is not used to bound the size of the send buffer declared using +.b so_sndbuf +on a socket. +.tp +.i default +the default size of the send buffer for a tcp socket. +this value overwrites the initial default buffer size from +the generic global +.i /proc/sys/net/core/wmem_default +defined for all protocols. +the default value is 16\ kb. +.\" true in linux 2.4 and 2.6 +if larger send buffer sizes are desired, this value +should be increased (to affect all sockets). +to employ large tcp windows, the +.i /proc/sys/net/ipv4/tcp_window_scaling +must be set to a nonzero value (default). +.tp +.i max +the maximum size of the send buffer used by each tcp socket. +this value does not override the value in +.ir /proc/sys/net/core/wmem_max . +this is not used to limit the size of the send buffer declared using +.b so_sndbuf +on a socket. +the default value is calculated using the formula +.ip + max(65536, min(4\ mb, \fitcp_mem\fp[1]*page_size/128)) +.ip +(on linux 2.4, the default value is 128\ kb, +lowered 64\ kb depending on low-memory systems.) +.re +.tp +.ir tcp_workaround_signed_windows " (boolean; default: disabled; since linux 2.6.26)" +if enabled, assume that no receipt of a window-scaling option means that the +remote tcp is broken and treats the window as a signed quantity. +if disabled, assume that the remote tcp is not broken even if we do +not receive a window scaling option from it. +.ss socket options +to set or get a tcp socket option, call +.br getsockopt (2) +to read or +.br setsockopt (2) +to write the option with the option level argument set to +.br ipproto_tcp . +unless otherwise noted, +.i optval +is a pointer to an +.ir int . +.\" or sol_tcp on linux +in addition, +most +.b ipproto_ip +socket options are valid on tcp sockets. +for more information see +.br ip (7). +.pp +following is a list of tcp-specific socket options. +for details of some other socket options that are also applicable +for tcp sockets, see +.br socket (7). +.tp +.br tcp_congestion " (since linux 2.6.13)" +.\" commit 5f8ef48d240963093451bcf83df89f1a1364f51d +.\" author: stephen hemminger +the argument for this option is a string. +this option allows the caller to set the tcp congestion control +algorithm to be used, on a per-socket basis. +unprivileged processes are restricted to choosing one of the algorithms in +.ir tcp_allowed_congestion_control +(described above). +privileged processes +.rb ( cap_net_admin ) +can choose from any of the available congestion-control algorithms +(see the description of +.ir tcp_available_congestion_control +above). +.tp +.br tcp_cork " (since linux 2.2)" +.\" precisely: since 2.1.127 +if set, don't send out partial frames. +all queued partial frames are sent when the option is cleared again. +this is useful for prepending headers before calling +.br sendfile (2), +or for throughput optimization. +as currently implemented, there is a 200 millisecond ceiling on the time +for which output is corked by +.br tcp_cork . +if this ceiling is reached, then queued data is automatically transmitted. +this option can be combined with +.b tcp_nodelay +only since linux 2.5.71. +this option should not be used in code intended to be portable. +.tp +.br tcp_defer_accept " (since linux 2.4)" +.\" precisely: since 2.3.38 +.\" useful references: +.\" http://www.techrepublic.com/article/take-advantage-of-tcp-ip-options-to-optimize-data-transmission/ +.\" http://unix.stackexchange.com/questions/94104/real-world-use-of-tcp-defer-accept +allow a listener to be awakened only when data arrives on the socket. +takes an integer value (seconds), this can +bound the maximum number of attempts tcp will make to +complete the connection. +this option should not be used in code intended to be portable. +.tp +.br tcp_info " (since linux 2.4)" +used to collect information about this socket. +the kernel returns a \fistruct tcp_info\fp as defined in the file +.ir /usr/include/linux/tcp.h . +this option should not be used in code intended to be portable. +.tp +.br tcp_keepcnt " (since linux 2.4)" +.\" precisely: since 2.3.18 +the maximum number of keepalive probes tcp should send +before dropping the connection. +this option should not be +used in code intended to be portable. +.tp +.br tcp_keepidle " (since linux 2.4)" +.\" precisely: since 2.3.18 +the time (in seconds) the connection needs to remain idle +before tcp starts sending keepalive probes, if the socket +option +.b so_keepalive +has been set on this socket. +this option should not be used in code intended to be portable. +.tp +.br tcp_keepintvl " (since linux 2.4)" +.\" precisely: since 2.3.18 +the time (in seconds) between individual keepalive probes. +this option should not be used in code intended to be portable. +.tp +.br tcp_linger2 " (since linux 2.4)" +.\" precisely: since 2.3.41 +the lifetime of orphaned fin_wait2 state sockets. +this option can be used to override the system-wide setting in the file +.i /proc/sys/net/ipv4/tcp_fin_timeout +for this socket. +this is not to be confused with the +.br socket (7) +level option +.br so_linger . +this option should not be used in code intended to be portable. +.tp +.b tcp_maxseg +.\" present in linux 1.0 +the maximum segment size for outgoing tcp packets. +in linux 2.2 and earlier, and in linux 2.6.28 and later, +if this option is set before connection establishment, it also +changes the mss value announced to the other end in the initial packet. +values greater than the (eventual) interface mtu have no effect. +tcp will also impose +its minimum and maximum bounds over the value provided. +.tp +.b tcp_nodelay +.\" present in linux 1.0 +if set, disable the nagle algorithm. +this means that segments +are always sent as soon as possible, even if there is only a +small amount of data. +when not set, data is buffered until there +is a sufficient amount to send out, thereby avoiding the +frequent sending of small packets, which results in poor +utilization of the network. +this option is overridden by +.br tcp_cork ; +however, setting this option forces an explicit flush of +pending output, even if +.b tcp_cork +is currently set. +.tp +.br tcp_quickack " (since linux 2.4.4)" +enable quickack mode if set or disable quickack +mode if cleared. +in quickack mode, acks are sent +immediately, rather than delayed if needed in accordance +to normal tcp operation. +this flag is not permanent, +it only enables a switch to or from quickack mode. +subsequent operation of the tcp protocol will +once again enter/leave quickack mode depending on +internal protocol processing and factors such as +delayed ack timeouts occurring and data transfer. +this option should not be used in code intended to be +portable. +.tp +.br tcp_syncnt " (since linux 2.4)" +.\" precisely: since 2.3.18 +set the number of syn retransmits that tcp should send before +aborting the attempt to connect. +it cannot exceed 255. +this option should not be used in code intended to be portable. +.tp +.br tcp_user_timeout " (since linux 2.6.37)" +.\" commit dca43c75e7e545694a9dd6288553f55c53e2a3a3 +.\" author: jerry chu +.\" the following text taken nearly verbatim from jerry chu's (excellent) +.\" commit message. +.\" +this option takes an +.ir "unsigned int" +as an argument. +when the value is greater than 0, +it specifies the maximum amount of time in milliseconds that transmitted +data may remain unacknowledged, or bufferred data may remain untransmitted +(due to zero window size) before tcp will forcibly close the +corresponding connection and return +.b etimedout +to the application. +if the option value is specified as 0, +tcp will use the system default. +.ip +increasing user timeouts allows a tcp connection to survive extended +periods without end-to-end connectivity. +decreasing user timeouts +allows applications to "fail fast", if so desired. +otherwise, failure may take up to 20 minutes with +the current system defaults in a normal wan environment. +.ip +this option can be set during any state of a tcp connection, +but is effective only during the synchronized states of a connection +(established, fin-wait-1, fin-wait-2, close-wait, closing, and last-ack). +moreover, when used with the tcp keepalive +.rb ( so_keepalive ) +option, +.b tcp_user_timeout +will override keepalive to determine when to close a +connection due to keepalive failure. +.ip +the option has no effect on when tcp retransmits a packet, +nor when a keepalive probe is sent. +.ip +this option, like many others, will be inherited by the socket returned by +.br accept (2), +if it was set on the listening socket. +.ip +further details on the user timeout feature can be found in +rfc\ 793 and rfc\ 5482 ("tcp user timeout option"). +.tp +.br tcp_window_clamp " (since linux 2.4)" +.\" precisely: since 2.3.41 +bound the size of the advertised window to this value. +the kernel imposes a minimum size of sock_min_rcvbuf/2. +this option should not be used in code intended to be +portable. +.ss sockets api +tcp provides limited support for out-of-band data, +in the form of (a single byte of) urgent data. +in linux this means if the other end sends newer out-of-band +data the older urgent data is inserted as normal data into +the stream (even when +.b so_oobinline +is not set). +this differs from bsd-based stacks. +.pp +linux uses the bsd compatible interpretation of the urgent +pointer field by default. +this violates rfc\ 1122, but is +required for interoperability with other stacks. +it can be changed via +.ir /proc/sys/net/ipv4/tcp_stdurg . +.pp +it is possible to peek at out-of-band data using the +.br recv (2) +.b msg_peek +flag. +.pp +since version 2.4, linux supports the use of +.b msg_trunc +in the +.i flags +argument of +.br recv (2) +(and +.br recvmsg (2)). +this flag causes the received bytes of data to be discarded, +rather than passed back in a caller-supplied buffer. +since linux 2.4.4, +.br msg_trunc +also has this effect when used in conjunction with +.br msg_oob +to receive out-of-band data. +.ss ioctls +the following +.br ioctl (2) +calls return information in +.ir value . +the correct syntax is: +.pp +.rs +.nf +.bi int " value"; +.ib error " = ioctl(" tcp_socket ", " ioctl_type ", &" value ");" +.fi +.re +.pp +.i ioctl_type +is one of the following: +.tp +.b siocinq +returns the amount of queued unread data in the receive buffer. +the socket must not be in listen state, otherwise an error +.rb ( einval ) +is returned. +.b siocinq +is defined in +.ir . +.\" fixme http://sources.redhat.com/bugzilla/show_bug.cgi?id=12002, +.\" filed 2010-09-10, may cause siocinq to be defined in glibc headers +alternatively, +you can use the synonymous +.br fionread , +defined in +.ir . +.tp +.b siocatmark +returns true (i.e., +.i value +is nonzero) if the inbound data stream is at the urgent mark. +.ip +if the +.b so_oobinline +socket option is set, and +.b siocatmark +returns true, then the +next read from the socket will return the urgent data. +if the +.b so_oobinline +socket option is not set, and +.b siocatmark +returns true, then the +next read from the socket will return the bytes following +the urgent data (to actually read the urgent data requires the +.b recv(msg_oob) +flag). +.ip +note that a read never reads across the urgent mark. +if an application is informed of the presence of urgent data via +.br select (2) +(using the +.i exceptfds +argument) or through delivery of a +.b sigurg +signal, +then it can advance up to the mark using a loop which repeatedly tests +.b siocatmark +and performs a read (requesting any number of bytes) as long as +.b siocatmark +returns false. +.tp +.b siocoutq +returns the amount of unsent data in the socket send queue. +the socket must not be in listen state, otherwise an error +.rb ( einval ) +is returned. +.b siocoutq +is defined in +.ir . +.\" fixme . http://sources.redhat.com/bugzilla/show_bug.cgi?id=12002, +.\" filed 2010-09-10, may cause siocoutq to be defined in glibc headers +alternatively, +you can use the synonymous +.br tiocoutq , +defined in +.ir . +.ss error handling +when a network error occurs, tcp tries to resend the packet. +if it doesn't succeed after some time, either +.b etimedout +or the last received error on this connection is reported. +.pp +some applications require a quicker error notification. +this can be enabled with the +.b ipproto_ip +level +.b ip_recverr +socket option. +when this option is enabled, all incoming +errors are immediately passed to the user program. +use this option with care \(em it makes tcp less tolerant to routing +changes and other normal network conditions. +.sh errors +.tp +.b eafnotsupport +passed socket address type in +.i sin_family +was not +.br af_inet . +.tp +.b epipe +the other end closed the socket unexpectedly or a read is +executed on a shut down socket. +.tp +.b etimedout +the other end didn't acknowledge retransmitted data after some time. +.pp +any errors defined for +.br ip (7) +or the generic socket layer may also be returned for tcp. +.sh versions +support for explicit congestion notification, zero-copy +.br sendfile (2), +reordering support and some sack extensions +(dsack) were introduced in 2.4. +support for forward acknowledgement (fack), time_wait recycling, +and per-connection keepalive socket options were introduced in 2.3. +.sh bugs +not all errors are documented. +.pp +ipv6 is not described. +.\" only a single linux kernel version is described +.\" info for 2.2 was lost. should be added again, +.\" or put into a separate page. +.\" .sh authors +.\" this man page was originally written by andi kleen. +.\" it was updated for 2.4 by nivedita singhvi with input from +.\" alexey kuznetsov's documentation/networking/ip-sysctl.txt +.\" document. +.sh see also +.br accept (2), +.br bind (2), +.br connect (2), +.br getsockopt (2), +.br listen (2), +.br recvmsg (2), +.br sendfile (2), +.br sendmsg (2), +.br socket (2), +.br ip (7), +.br socket (7) +.pp +the kernel source file +.ir documentation/networking/ip\-sysctl.txt . +.pp +rfc\ 793 for the tcp specification. +.br +rfc\ 1122 for the tcp requirements and a description of the nagle algorithm. +.br +rfc\ 1323 for tcp timestamp and window scaling options. +.br +rfc\ 1337 for a description of time_wait assassination hazards. +.br +rfc\ 3168 for a description of explicit congestion notification. +.br +rfc\ 2581 for tcp congestion control algorithms. +.br +rfc\ 2018 and rfc\ 2883 for sack and extensions to sack. +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1996 andries brouwer (aeb@cwi.nl) +.\" and copyright (c) 2016 michael kerrisk +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" modified thu oct 31 14:18:40 1996 by eric s. raymond +.\" modified 2001-12-17, aeb +.th getsid 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +getsid \- get session id +.sh synopsis +.nf +.b #include +.pp +.bi "pid_t getsid(pid_t" " pid" ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br getsid (): +.nf + _xopen_source >= 500 +.\" || _xopen_source && _xopen_source_extended + || /* since glibc 2.12: */ _posix_c_source >= 200809l +.fi +.sh description +.i getsid(0) +returns the session id of the calling process. +.br getsid () +returns the session id of the process with process id +.ir pid . +if +.i pid +is 0, +.br getsid () +returns the session id of the calling process. +.sh return value +on success, a session id is returned. +on error, \fi(pid_t)\ \-1\fp is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eperm +a process with process id +.i pid +exists, but it is not in the same session as the calling process, +and the implementation considers this an error. +.tp +.b esrch +no process with process id +.i pid +was found. +.sh versions +this system call is available on linux since version 2.0. +.\" linux has this system call since linux 1.3.44. +.\" there is libc support since libc 5.2.19. +.sh conforming to +posix.1-2001, posix.1-2008, svr4. +.sh notes +linux does not return +.br eperm . +.pp +see +.br credentials (7) +for a description of sessions and session ids. +.sh see also +.br getpgid (2), +.br setsid (2), +.br credentials (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/select.2 + +.so man5/resolv.conf.5 + +.\" copyright (c) 1993 by thomas koenig (ig25@rz.uni-karlsruhe.de) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified wed jul 21 22:35:42 1993 by rik faith (faith@cs.unc.edu) +.\" modified 18 mar 1996 by martin schulze (joey@infodrom.north.de): +.\" corrected description of getwd(). +.\" modified sat aug 21 12:32:12 met 1999 by aeb - applied fix by aj +.\" modified mon dec 11 13:32:51 met 2000 by aeb +.\" modified thu apr 22 03:49:15 cest 2002 by roger luethi +.\" +.th getcwd 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +getcwd, getwd, get_current_dir_name \- get current working directory +.sh synopsis +.nf +.b #include +.pp +.bi "char *getcwd(char *" buf ", size_t " size ); +.bi "char *getwd(char *" buf ); +.b "char *get_current_dir_name(void);" +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br get_current_dir_name (): +.nf + _gnu_source +.fi +.pp +.br getwd (): +.nf + since glibc 2.12: + (_xopen_source >= 500) && ! (_posix_c_source >= 200809l) + || /* glibc since 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source + before glibc 2.12: + _bsd_source || _xopen_source >= 500 +.\" || _xopen_source && _xopen_source_extended +.fi +.sh description +these functions return a null-terminated string containing an +absolute pathname that is the current working directory of +the calling process. +the pathname is returned as the function result and via the argument +.ir buf , +if present. +.pp +the +.br getcwd () +function copies an absolute pathname of the current working directory +to the array pointed to by +.ir buf , +which is of length +.ir size . +.pp +if the length of the absolute pathname of the current working directory, +including the terminating null byte, exceeds +.i size +bytes, null is returned, and +.i errno +is set to +.br erange ; +an application should check for this error, and allocate a larger +buffer if necessary. +.pp +as an extension to the posix.1-2001 standard, glibc's +.br getcwd () +allocates the buffer dynamically using +.br malloc (3) +if +.i buf +is null. +in this case, the allocated buffer has the length +.i size +unless +.i size +is zero, when +.i buf +is allocated as big as necessary. +the caller should +.br free (3) +the returned buffer. +.pp +.br get_current_dir_name () +will +.br malloc (3) +an array big enough to hold the absolute pathname of +the current working directory. +if the environment +variable +.b pwd +is set, and its value is correct, then that value will be returned. +the caller should +.br free (3) +the returned buffer. +.pp +.br getwd () +does not +.br malloc (3) +any memory. +the +.i buf +argument should be a pointer to an array at least +.b path_max +bytes long. +if the length of the absolute pathname of the current working directory, +including the terminating null byte, exceeds +.b path_max +bytes, null is returned, and +.i errno +is set to +.br enametoolong . +(note that on some systems, +.b path_max +may not be a compile-time constant; +furthermore, its value may depend on the filesystem, see +.br pathconf (3).) +for portability and security reasons, use of +.br getwd () +is deprecated. +.sh return value +on success, these functions return a pointer to a string containing +the pathname of the current working directory. +in the case of +.br getcwd () +and +.br getwd () +this is the same value as +.ir buf . +.pp +on failure, these functions return null, and +.i errno +is set to indicate the error. +the contents of the array pointed to by +.i buf +are undefined on error. +.sh errors +.tp +.b eacces +permission to read or search a component of the filename was denied. +.tp +.b efault +.i buf +points to a bad address. +.tp +.b einval +the +.i size +argument is zero and +.i buf +is not a null pointer. +.tp +.b einval +.br getwd (): +.i buf +is null. +.tp +.b enametoolong +.br getwd (): +the size of the null-terminated absolute pathname string exceeds +.b path_max +bytes. +.tp +.b enoent +the current working directory has been unlinked. +.tp +.b enomem +out of memory. +.tp +.b erange +the +.i size +argument is less than the length of the absolute pathname of the +working directory, including the terminating null byte. +you need to allocate a bigger array and try again. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br getcwd (), +.br getwd () +t} thread safety mt-safe +t{ +.br get_current_dir_name () +t} thread safety mt-safe env +.te +.hy +.ad +.sp 1 +.sh conforming to +.br getcwd () +conforms to posix.1-2001. +note however that posix.1-2001 leaves the behavior of +.br getcwd () +unspecified if +.i buf +is null. +.pp +.br getwd () +is present in posix.1-2001, but marked legacy. +posix.1-2008 removes the specification of +.br getwd (). +use +.br getcwd () +instead. +posix.1-2001 +does not define any errors for +.br getwd (). +.pp +.br get_current_dir_name () +is a gnu extension. +.sh notes +under linux, these functions make use of the +.br getcwd () +system call (available since linux 2.1.92). +on older systems they would query +.ir /proc/self/cwd . +if both system call and proc filesystem are missing, a +generic implementation is called. +only in that case can +these calls fail under linux with +.br eacces . +.pp +these functions are often used to save the location of the current working +directory for the purpose of returning to it later. +opening the current +directory (".") and calling +.br fchdir (2) +to return is usually a faster and more reliable alternative when sufficiently +many file descriptors are available, especially on platforms other than linux. +.\" +.ss c library/kernel differences +on linux, the kernel provides a +.br getcwd () +system call, which the functions described in this page will use if possible. +the system call takes the same arguments as the library function +of the same name, but is limited to returning at most +.br path_max +bytes. +(before linux 3.12, +.\" commit 3272c544da48f8915a0e34189182aed029bd0f2b +the limit on the size of the returned pathname was the system page size. +on many architectures, +.br path_max +and the system page size are both 4096 bytes, +but a few architectures have a larger page size.) +if the length of the pathname of the current working directory +exceeds this limit, then the system call fails with the error +.br enametoolong . +in this case, the library functions fall back to +a (slower) alternative implementation that returns the full pathname. +.pp +following a change in linux 2.6.36, +.\" commit 8df9d1a4142311c084ffeeacb67cd34d190eff74 +the pathname returned by the +.br getcwd () +system call will be prefixed with the string "(unreachable)" +if the current directory is not below the root directory of the current +process (e.g., because the process set a new filesystem root using +.br chroot (2) +without changing its current directory into the new root). +such behavior can also be caused by an unprivileged user by changing +the current directory into another mount namespace. +when dealing with pathname from untrusted sources, callers of the +functions described in this page +should consider checking whether the returned pathname starts +with '/' or '(' to avoid misinterpreting an unreachable path +as a relative pathname. +.sh bugs +since the linux 2.6.36 change that added "(unreachable)" in the +circumstances described above, the glibc implementation of +.br getcwd () +has failed to conform to posix and returned a relative pathname when the api +contract requires an absolute pathname. +with glibc 2.27 onwards this is corrected; +calling +.br getcwd () +from such a pathname will now result in failure with +.br enoent . +.sh see also +.br pwd (1), +.br chdir (2), +.br fchdir (2), +.br open (2), +.br unlink (2), +.br free (3), +.br malloc (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man7/iso_8859-9.7 + +.\" copyright (c) 2016, 2019, 2021 by michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" +.th mount_namespaces 7 2021-08-27 "linux" "linux programmer's manual" +.sh name +mount_namespaces \- overview of linux mount namespaces +.sh description +for an overview of namespaces, see +.br namespaces (7). +.pp +mount namespaces provide isolation of the list of mounts seen +by the processes in each namespace instance. +thus, the processes in each of the mount namespace instances +will see distinct single-directory hierarchies. +.pp +the views provided by the +.ir /proc/[pid]/mounts , +.ir /proc/[pid]/mountinfo , +and +.ir /proc/[pid]/mountstats +files (all described in +.br proc (5)) +correspond to the mount namespace in which the process with the pid +.ir [pid] +resides. +(all of the processes that reside in the same mount namespace +will see the same view in these files.) +.pp +a new mount namespace is created using either +.br clone (2) +or +.br unshare (2) +with the +.br clone_newns +flag. +when a new mount namespace is created, +its mount list is initialized as follows: +.ip * 3 +if the namespace is created using +.br clone (2), +the mount list of the child's namespace is a copy +of the mount list in the parent process's mount namespace. +.ip * +if the namespace is created using +.br unshare (2), +the mount list of the new namespace is a copy of +the mount list in the caller's previous mount namespace. +.pp +subsequent modifications to the mount list +.rb ( mount (2) +and +.br umount (2)) +in either mount namespace will not (by default) affect the +mount list seen in the other namespace +(but see the following discussion of shared subtrees). +.\" +.sh shared subtrees +after the implementation of mount namespaces was completed, +experience showed that the isolation that they provided was, +in some cases, too great. +for example, in order to make a newly loaded optical disk +available in all mount namespaces, +a mount operation was required in each namespace. +for this use case, and others, +the shared subtree feature was introduced in linux 2.6.15. +this feature allows for automatic, controlled propagation of mount and unmount +.i events +between namespaces +(or, more precisely, between the mounts that are members of a +.ir "peer group" +that are propagating events to one another). +.pp +each mount is marked (via +.br mount (2)) +as having one of the following +.ir "propagation types" : +.tp +.br ms_shared +this mount shares events with members of a peer group. +mount and unmount events immediately under this mount will propagate +to the other mounts that are members of the peer group. +.i propagation +here means that the same mount or unmount will automatically occur +under all of the other mounts in the peer group. +conversely, mount and unmount events that take place under +peer mounts will propagate to this mount. +.tp +.br ms_private +this mount is private; it does not have a peer group. +mount and unmount events do not propagate into or out of this mount. +.tp +.br ms_slave +mount and unmount events propagate into this mount from +a (master) shared peer group. +mount and unmount events under this mount do not propagate to any peer. +.ip +note that a mount can be the slave of another peer group +while at the same time sharing mount and unmount events +with a peer group of which it is a member. +(more precisely, one peer group can be the slave of another peer group.) +.tp +.br ms_unbindable +this is like a private mount, +and in addition this mount can't be bind mounted. +attempts to bind mount this mount +.rb ( mount (2) +with the +.br ms_bind +flag) will fail. +.ip +when a recursive bind mount +.rb ( mount (2) +with the +.br ms_bind +and +.br ms_rec +flags) is performed on a directory subtree, +any bind mounts within the subtree are automatically pruned +(i.e., not replicated) +when replicating that subtree to produce the target subtree. +.pp +for a discussion of the propagation type assigned to a new mount, +see notes. +.pp +the propagation type is a per-mount-point setting; +some mounts may be marked as shared +(with each shared mount being a member of a distinct peer group), +while others are private +(or slaved or unbindable). +.pp +note that a mount's propagation type determines whether +mounts and unmounts of mounts +.i "immediately under" +the mount are propagated. +thus, the propagation type does not affect propagation of events for +grandchildren and further removed descendant mounts. +what happens if the mount itself is unmounted is determined by +the propagation type that is in effect for the +.i parent +of the mount. +.pp +members are added to a +.ir "peer group" +when a mount is marked as shared and either: +.ip * 3 +the mount is replicated during the creation of a new mount namespace; or +.ip * +a new bind mount is created from the mount. +.pp +in both of these cases, the new mount joins the peer group +of which the existing mount is a member. +.pp +a new peer group is also created when a child mount is created under +an existing mount that is marked as shared. +in this case, the new child mount is also marked as shared and +the resulting peer group consists of all the mounts +that are replicated under the peers of parent mounts. +.pp +a mount ceases to be a member of a peer group when either +the mount is explicitly unmounted, +or when the mount is implicitly unmounted because a mount namespace is removed +(because it has no more member processes). +.pp +the propagation type of the mounts in a mount namespace +can be discovered via the "optional fields" exposed in +.ir /proc/[pid]/mountinfo . +(see +.br proc (5) +for details of this file.) +the following tags can appear in the optional fields +for a record in that file: +.tp +.i shared:x +this mount is shared in peer group +.ir x . +each peer group has a unique id that is automatically +generated by the kernel, +and all mounts in the same peer group will show the same id. +(these ids are assigned starting from the value 1, +and may be recycled when a peer group ceases to have any members.) +.tp +.i master:x +this mount is a slave to shared peer group +.ir x . +.tp +.ir propagate_from:x " (since linux 2.6.26)" +.\" commit 97e7e0f71d6d948c25f11f0a33878d9356d9579e +this mount is a slave and receives propagation from shared peer group +.ir x . +this tag will always appear in conjunction with a +.ir master:x +tag. +here, +.ir x +is the closest dominant peer group under the process's root directory. +if +.ir x +is the immediate master of the mount, +or if there is no dominant peer group under the same root, +then only the +.ir master:x +field is present and not the +.ir propagate_from:x +field. +for further details, see below. +.tp +.ir unbindable +this is an unbindable mount. +.pp +if none of the above tags is present, then this is a private mount. +.ss ms_shared and ms_private example +suppose that on a terminal in the initial mount namespace, +we mark one mount as shared and another as private, +and then view the mounts in +.ir /proc/self/mountinfo : +.pp +.in +4n +.ex +sh1# \fbmount \-\-make\-shared /mnts\fp +sh1# \fbmount \-\-make\-private /mntp\fp +sh1# \fbcat /proc/self/mountinfo | grep \(aq/mnt\(aq | sed \(aqs/ \- .*//\(aq\fp +77 61 8:17 / /mnts rw,relatime shared:1 +83 61 8:15 / /mntp rw,relatime +.ee +.in +.pp +from the +.ir /proc/self/mountinfo +output, we see that +.ir /mnts +is a shared mount in peer group 1, and that +.ir /mntp +has no optional tags, indicating that it is a private mount. +the first two fields in each record in this file are the unique +id for this mount, and the mount id of the parent mount. +we can further inspect this file to see that the parent mount of +.ir /mnts +and +.ir /mntp +is the root directory, +.ir / , +which is mounted as private: +.pp +.in +4n +.ex +sh1# \fbcat /proc/self/mountinfo | awk \(aq$1 == 61\(aq | sed \(aqs/ \- .*//\(aq\fp +61 0 8:2 / / rw,relatime +.ee +.in +.pp +on a second terminal, +we create a new mount namespace where we run a second shell +and inspect the mounts: +.pp +.in +4n +.ex +$ \fbps1=\(aqsh2# \(aq sudo unshare \-m \-\-propagation unchanged sh\fp +sh2# \fbcat /proc/self/mountinfo | grep \(aq/mnt\(aq | sed \(aqs/ \- .*//\(aq\fp +222 145 8:17 / /mnts rw,relatime shared:1 +225 145 8:15 / /mntp rw,relatime +.ee +.in +.pp +the new mount namespace received a copy of the initial mount namespace's +mounts. +these new mounts maintain the same propagation types, +but have unique mount ids. +(the +.ir \-\-propagation\ unchanged +option prevents +.br unshare (1) +from marking all mounts as private when creating a new mount namespace, +.\" since util-linux 2.27 +which it does by default.) +.pp +in the second terminal, we then create submounts under each of +.ir /mnts +and +.ir /mntp +and inspect the set-up: +.pp +.in +4n +.ex +sh2# \fbmkdir /mnts/a\fp +sh2# \fbmount /dev/sdb6 /mnts/a\fp +sh2# \fbmkdir /mntp/b\fp +sh2# \fbmount /dev/sdb7 /mntp/b\fp +sh2# \fbcat /proc/self/mountinfo | grep \(aq/mnt\(aq | sed \(aqs/ \- .*//\(aq\fp +222 145 8:17 / /mnts rw,relatime shared:1 +225 145 8:15 / /mntp rw,relatime +178 222 8:22 / /mnts/a rw,relatime shared:2 +230 225 8:23 / /mntp/b rw,relatime +.ee +.in +.pp +from the above, it can be seen that +.ir /mnts/a +was created as shared (inheriting this setting from its parent mount) and +.ir /mntp/b +was created as a private mount. +.pp +returning to the first terminal and inspecting the set-up, +we see that the new mount created under the shared mount +.ir /mnts +propagated to its peer mount (in the initial mount namespace), +but the new mount created under the private mount +.ir /mntp +did not propagate: +.pp +.in +4n +.ex +sh1# \fbcat /proc/self/mountinfo | grep \(aq/mnt\(aq | sed \(aqs/ \- .*//\(aq\fp +77 61 8:17 / /mnts rw,relatime shared:1 +83 61 8:15 / /mntp rw,relatime +179 77 8:22 / /mnts/a rw,relatime shared:2 +.ee +.in +.\" +.ss ms_slave example +making a mount a slave allows it to receive propagated +mount and unmount events from a master shared peer group, +while preventing it from propagating events to that master. +this is useful if we want to (say) receive a mount event when +an optical disk is mounted in the master shared peer group +(in another mount namespace), +but want to prevent mount and unmount events under the slave mount +from having side effects in other namespaces. +.pp +we can demonstrate the effect of slaving by first marking +two mounts as shared in the initial mount namespace: +.pp +.in +4n +.ex +sh1# \fbmount \-\-make\-shared /mntx\fp +sh1# \fbmount \-\-make\-shared /mnty\fp +sh1# \fbcat /proc/self/mountinfo | grep \(aq/mnt\(aq | sed \(aqs/ \- .*//\(aq\fp +132 83 8:23 / /mntx rw,relatime shared:1 +133 83 8:22 / /mnty rw,relatime shared:2 +.ee +.in +.pp +on a second terminal, +we create a new mount namespace and inspect the mounts: +.pp +.in +4n +.ex +sh2# \fbunshare \-m \-\-propagation unchanged sh\fp +sh2# \fbcat /proc/self/mountinfo | grep \(aq/mnt\(aq | sed \(aqs/ \- .*//\(aq\fp +168 167 8:23 / /mntx rw,relatime shared:1 +169 167 8:22 / /mnty rw,relatime shared:2 +.ee +.in +.pp +in the new mount namespace, we then mark one of the mounts as a slave: +.pp +.in +4n +.ex +sh2# \fbmount \-\-make\-slave /mnty\fp +sh2# \fbcat /proc/self/mountinfo | grep \(aq/mnt\(aq | sed \(aqs/ \- .*//\(aq\fp +168 167 8:23 / /mntx rw,relatime shared:1 +169 167 8:22 / /mnty rw,relatime master:2 +.ee +.in +.pp +from the above output, we see that +.ir /mnty +is now a slave mount that is receiving propagation events from +the shared peer group with the id 2. +.pp +continuing in the new namespace, we create submounts under each of +.ir /mntx +and +.ir /mnty : +.pp +.in +4n +.ex +sh2# \fbmkdir /mntx/a\fp +sh2# \fbmount /dev/sda3 /mntx/a\fp +sh2# \fbmkdir /mnty/b\fp +sh2# \fbmount /dev/sda5 /mnty/b\fp +.ee +.in +.pp +when we inspect the state of the mounts in the new mount namespace, +we see that +.ir /mntx/a +was created as a new shared mount +(inheriting the "shared" setting from its parent mount) and +.ir /mnty/b +was created as a private mount: +.pp +.in +4n +.ex +sh2# \fbcat /proc/self/mountinfo | grep \(aq/mnt\(aq | sed \(aqs/ \- .*//\(aq\fp +168 167 8:23 / /mntx rw,relatime shared:1 +169 167 8:22 / /mnty rw,relatime master:2 +173 168 8:3 / /mntx/a rw,relatime shared:3 +175 169 8:5 / /mnty/b rw,relatime +.ee +.in +.pp +returning to the first terminal (in the initial mount namespace), +we see that the mount +.ir /mntx/a +propagated to the peer (the shared +.ir /mntx ), +but the mount +.ir /mnty/b +was not propagated: +.pp +.in +4n +.ex +sh1# \fbcat /proc/self/mountinfo | grep \(aq/mnt\(aq | sed \(aqs/ \- .*//\(aq\fp +132 83 8:23 / /mntx rw,relatime shared:1 +133 83 8:22 / /mnty rw,relatime shared:2 +174 132 8:3 / /mntx/a rw,relatime shared:3 +.ee +.in +.pp +now we create a new mount under +.ir /mnty +in the first shell: +.pp +.in +4n +.ex +sh1# \fbmkdir /mnty/c\fp +sh1# \fbmount /dev/sda1 /mnty/c\fp +sh1# \fbcat /proc/self/mountinfo | grep \(aq/mnt\(aq | sed \(aqs/ \- .*//\(aq\fp +132 83 8:23 / /mntx rw,relatime shared:1 +133 83 8:22 / /mnty rw,relatime shared:2 +174 132 8:3 / /mntx/a rw,relatime shared:3 +178 133 8:1 / /mnty/c rw,relatime shared:4 +.ee +.in +.pp +when we examine the mounts in the second mount namespace, +we see that in this case the new mount has been propagated +to the slave mount, +and that the new mount is itself a slave mount (to peer group 4): +.pp +.in +4n +.ex +sh2# \fbcat /proc/self/mountinfo | grep \(aq/mnt\(aq | sed \(aqs/ \- .*//\(aq\fp +168 167 8:23 / /mntx rw,relatime shared:1 +169 167 8:22 / /mnty rw,relatime master:2 +173 168 8:3 / /mntx/a rw,relatime shared:3 +175 169 8:5 / /mnty/b rw,relatime +179 169 8:1 / /mnty/c rw,relatime master:4 +.ee +.in +.\" +.ss ms_unbindable example +one of the primary purposes of unbindable mounts is to avoid +the "mount explosion" problem when repeatedly performing bind mounts +of a higher-level subtree at a lower-level mount. +the problem is illustrated by the following shell session. +.pp +suppose we have a system with the following mounts: +.pp +.in +4n +.ex +# \fbmount | awk \(aq{print $1, $2, $3}\(aq\fp +/dev/sda1 on / +/dev/sdb6 on /mntx +/dev/sdb7 on /mnty +.ee +.in +.pp +suppose furthermore that we wish to recursively bind mount +the root directory under several users' home directories. +we do this for the first user, and inspect the mounts: +.pp +.in +4n +.ex +# \fbmount \-\-rbind / /home/cecilia/\fp +# \fbmount | awk \(aq{print $1, $2, $3}\(aq\fp +/dev/sda1 on / +/dev/sdb6 on /mntx +/dev/sdb7 on /mnty +/dev/sda1 on /home/cecilia +/dev/sdb6 on /home/cecilia/mntx +/dev/sdb7 on /home/cecilia/mnty +.ee +.in +.pp +when we repeat this operation for the second user, +we start to see the explosion problem: +.pp +.in +4n +.ex +# \fbmount \-\-rbind / /home/henry\fp +# \fbmount | awk \(aq{print $1, $2, $3}\(aq\fp +/dev/sda1 on / +/dev/sdb6 on /mntx +/dev/sdb7 on /mnty +/dev/sda1 on /home/cecilia +/dev/sdb6 on /home/cecilia/mntx +/dev/sdb7 on /home/cecilia/mnty +/dev/sda1 on /home/henry +/dev/sdb6 on /home/henry/mntx +/dev/sdb7 on /home/henry/mnty +/dev/sda1 on /home/henry/home/cecilia +/dev/sdb6 on /home/henry/home/cecilia/mntx +/dev/sdb7 on /home/henry/home/cecilia/mnty +.ee +.in +.pp +under +.ir /home/henry , +we have not only recursively added the +.ir /mntx +and +.ir /mnty +mounts, but also the recursive mounts of those directories under +.ir /home/cecilia +that were created in the previous step. +upon repeating the step for a third user, +it becomes obvious that the explosion is exponential in nature: +.pp +.in +4n +.ex +# \fbmount \-\-rbind / /home/otto\fp +# \fbmount | awk \(aq{print $1, $2, $3}\(aq\fp +/dev/sda1 on / +/dev/sdb6 on /mntx +/dev/sdb7 on /mnty +/dev/sda1 on /home/cecilia +/dev/sdb6 on /home/cecilia/mntx +/dev/sdb7 on /home/cecilia/mnty +/dev/sda1 on /home/henry +/dev/sdb6 on /home/henry/mntx +/dev/sdb7 on /home/henry/mnty +/dev/sda1 on /home/henry/home/cecilia +/dev/sdb6 on /home/henry/home/cecilia/mntx +/dev/sdb7 on /home/henry/home/cecilia/mnty +/dev/sda1 on /home/otto +/dev/sdb6 on /home/otto/mntx +/dev/sdb7 on /home/otto/mnty +/dev/sda1 on /home/otto/home/cecilia +/dev/sdb6 on /home/otto/home/cecilia/mntx +/dev/sdb7 on /home/otto/home/cecilia/mnty +/dev/sda1 on /home/otto/home/henry +/dev/sdb6 on /home/otto/home/henry/mntx +/dev/sdb7 on /home/otto/home/henry/mnty +/dev/sda1 on /home/otto/home/henry/home/cecilia +/dev/sdb6 on /home/otto/home/henry/home/cecilia/mntx +/dev/sdb7 on /home/otto/home/henry/home/cecilia/mnty +.ee +.in +.pp +the mount explosion problem in the above scenario can be avoided +by making each of the new mounts unbindable. +the effect of doing this is that recursive mounts of the root +directory will not replicate the unbindable mounts. +we make such a mount for the first user: +.pp +.in +4n +.ex +# \fbmount \-\-rbind \-\-make\-unbindable / /home/cecilia\fp +.ee +.in +.pp +before going further, we show that unbindable mounts are indeed unbindable: +.pp +.in +4n +.ex +# \fbmkdir /mntz\fp +# \fbmount \-\-bind /home/cecilia /mntz\fp +mount: wrong fs type, bad option, bad superblock on /home/cecilia, + missing codepage or helper program, or other error + + in some cases useful info is found in syslog \- try + dmesg | tail or so. +.ee +.in +.pp +now we create unbindable recursive bind mounts for the other two users: +.pp +.in +4n +.ex +# \fbmount \-\-rbind \-\-make\-unbindable / /home/henry\fp +# \fbmount \-\-rbind \-\-make\-unbindable / /home/otto\fp +.ee +.in +.pp +upon examining the list of mounts, +we see there has been no explosion of mounts, +because the unbindable mounts were not replicated +under each user's directory: +.pp +.in +4n +.ex +# \fbmount | awk \(aq{print $1, $2, $3}\(aq\fp +/dev/sda1 on / +/dev/sdb6 on /mntx +/dev/sdb7 on /mnty +/dev/sda1 on /home/cecilia +/dev/sdb6 on /home/cecilia/mntx +/dev/sdb7 on /home/cecilia/mnty +/dev/sda1 on /home/henry +/dev/sdb6 on /home/henry/mntx +/dev/sdb7 on /home/henry/mnty +/dev/sda1 on /home/otto +/dev/sdb6 on /home/otto/mntx +/dev/sdb7 on /home/otto/mnty +.ee +.in +.\" +.ss propagation type transitions +the following table shows the effect that applying a new propagation type +(i.e., +.ir "mount \-\-make\-xxxx") +has on the existing propagation type of a mount. +the rows correspond to existing propagation types, +and the columns are the new propagation settings. +for reasons of space, "private" is abbreviated as "priv" and +"unbindable" as "unbind". +.ts +lb2 lb2 lb2 lb2 lb1 +lb | l l l l l. + make-shared make-slave make-priv make-unbind +_ +shared shared slave/priv [1] priv unbind +slave slave+shared slave [2] priv unbind +slave+shared slave+shared slave priv unbind +private shared priv [2] priv unbind +unbindable shared unbind [2] priv unbind +.te +.sp 1 +note the following details to the table: +.ip [1] 4 +if a shared mount is the only mount in its peer group, +making it a slave automatically makes it private. +.ip [2] +slaving a nonshared mount has no effect on the mount. +.\" +.ss bind (ms_bind) semantics +suppose that the following command is performed: +.pp +.in +4n +.ex +mount \-\-bind a/a b/b +.ee +.in +.pp +here, +.i a +is the source mount, +.i b +is the destination mount, +.i a +is a subdirectory path under the mount point +.ir a , +and +.i b +is a subdirectory path under the mount point +.ir b . +the propagation type of the resulting mount, +.ir b/b , +depends on the propagation types of the mounts +.ir a +and +.ir b , +and is summarized in the following table. +.pp +.ts +lb2 lb1 lb2 lb2 lb2 lb0 +lb2 lb1 lb2 lb2 lb2 lb0 +lb lb | l l l l l. + source(a) + shared private slave unbind +_ +dest(b) shared shared shared slave+shared invalid + nonshared shared private slave invalid +.te +.sp 1 +note that a recursive bind of a subtree follows the same semantics +as for a bind operation on each mount in the subtree. +(unbindable mounts are automatically pruned at the target mount point.) +.pp +for further details, see +.i documentation/filesystems/sharedsubtree.txt +in the kernel source tree. +.\" +.ss move (ms_move) semantics +suppose that the following command is performed: +.pp +.in +4n +.ex +mount \-\-move a b/b +.ee +.in +.pp +here, +.i a +is the source mount, +.i b +is the destination mount, and +.i b +is a subdirectory path under the mount point +.ir b . +the propagation type of the resulting mount, +.ir b/b , +depends on the propagation types of the mounts +.ir a +and +.ir b , +and is summarized in the following table. +.pp +.ts +lb2 lb1 lb2 lb2 lb2 lb0 +lb2 lb1 lb2 lb2 lb2 lb0 +lb lb | l l l l l. + source(a) + shared private slave unbind +_ +dest(b) shared shared shared slave+shared invalid + nonshared shared private slave unbindable +.te +.sp 1 +note: moving a mount that resides under a shared mount is invalid. +.pp +for further details, see +.i documentation/filesystems/sharedsubtree.txt +in the kernel source tree. +.\" +.ss mount semantics +suppose that we use the following command to create a mount: +.pp +.in +4n +.ex +mount device b/b +.ee +.in +.pp +here, +.i b +is the destination mount, and +.i b +is a subdirectory path under the mount point +.ir b . +the propagation type of the resulting mount, +.ir b/b , +follows the same rules as for a bind mount, +where the propagation type of the source mount +is considered always to be private. +.\" +.ss unmount semantics +suppose that we use the following command to tear down a mount: +.pp +.in +4n +.ex +unmount a +.ee +.in +.pp +here, +.i a +is a mount on +.ir b/b , +where +.i b +is the parent mount and +.i b +is a subdirectory path under the mount point +.ir b . +if +.b b +is shared, then all most-recently-mounted mounts at +.i b +on mounts that receive propagation from mount +.i b +and do not have submounts under them are unmounted. +.\" +.ss the /proc/[pid]/mountinfo "propagate_from" tag +the +.i propagate_from:x +tag is shown in the optional fields of a +.ir /proc/[pid]/mountinfo +record in cases where a process can't see a slave's immediate master +(i.e., the pathname of the master is not reachable from +the filesystem root directory) +and so cannot determine the +chain of propagation between the mounts it can see. +.pp +in the following example, we first create a two-link master-slave chain +between the mounts +.ir /mnt , +.ir /tmp/etc , +and +.ir /mnt/tmp/etc . +then the +.br chroot (1) +command is used to make the +.ir /tmp/etc +mount point unreachable from the root directory, +creating a situation where the master of +.ir /mnt/tmp/etc +is not reachable from the (new) root directory of the process. +.pp +first, we bind mount the root directory onto +.ir /mnt +and then bind mount +.ir /proc +at +.ir /mnt/proc +so that after the later +.br chroot (1) +the +.br proc (5) +filesystem remains visible at the correct location +in the chroot-ed environment. +.pp +.in +4n +.ex +# \fbmkdir \-p /mnt/proc\fp +# \fbmount \-\-bind / /mnt\fp +# \fbmount \-\-bind /proc /mnt/proc\fp +.ee +.in +.pp +next, we ensure that the +.ir /mnt +mount is a shared mount in a new peer group (with no peers): +.pp +.in +4n +.ex +# \fbmount \-\-make\-private /mnt\fp # isolate from any previous peer group +# \fbmount \-\-make\-shared /mnt\fp +# \fbcat /proc/self/mountinfo | grep \(aq/mnt\(aq | sed \(aqs/ \- .*//\(aq\fp +239 61 8:2 / /mnt ... shared:102 +248 239 0:4 / /mnt/proc ... shared:5 +.ee +.in +.pp +next, we bind mount +.ir /mnt/etc +onto +.ir /tmp/etc : +.pp +.in +4n +.ex +# \fbmkdir \-p /tmp/etc\fp +# \fbmount \-\-bind /mnt/etc /tmp/etc\fp +# \fbcat /proc/self/mountinfo | egrep \(aq/mnt|/tmp/\(aq | sed \(aqs/ \- .*//\(aq\fp +239 61 8:2 / /mnt ... shared:102 +248 239 0:4 / /mnt/proc ... shared:5 +267 40 8:2 /etc /tmp/etc ... shared:102 +.ee +.in +.pp +initially, these two mounts are in the same peer group, +but we then make the +.ir /tmp/etc +a slave of +.ir /mnt/etc , +and then make +.ir /tmp/etc +shared as well, +so that it can propagate events to the next slave in the chain: +.pp +.in +4n +.ex +# \fbmount \-\-make\-slave /tmp/etc\fp +# \fbmount \-\-make\-shared /tmp/etc\fp +# \fbcat /proc/self/mountinfo | egrep \(aq/mnt|/tmp/\(aq | sed \(aqs/ \- .*//\(aq\fp +239 61 8:2 / /mnt ... shared:102 +248 239 0:4 / /mnt/proc ... shared:5 +267 40 8:2 /etc /tmp/etc ... shared:105 master:102 +.ee +.in +.pp +then we bind mount +.ir /tmp/etc +onto +.ir /mnt/tmp/etc . +again, the two mounts are initially in the same peer group, +but we then make +.ir /mnt/tmp/etc +a slave of +.ir /tmp/etc : +.pp +.in +4n +.ex +# \fbmkdir \-p /mnt/tmp/etc\fp +# \fbmount \-\-bind /tmp/etc /mnt/tmp/etc\fp +# \fbmount \-\-make\-slave /mnt/tmp/etc\fp +# \fbcat /proc/self/mountinfo | egrep \(aq/mnt|/tmp/\(aq | sed \(aqs/ \- .*//\(aq\fp +239 61 8:2 / /mnt ... shared:102 +248 239 0:4 / /mnt/proc ... shared:5 +267 40 8:2 /etc /tmp/etc ... shared:105 master:102 +273 239 8:2 /etc /mnt/tmp/etc ... master:105 +.ee +.in +.pp +from the above, we see that +.ir /mnt +is the master of the slave +.ir /tmp/etc , +which in turn is the master of the slave +.ir /mnt/tmp/etc . +.pp +we then +.br chroot (1) +to the +.ir /mnt +directory, which renders the mount with id 267 unreachable +from the (new) root directory: +.pp +.in +4n +.ex +# \fbchroot /mnt\fp +.ee +.in +.pp +when we examine the state of the mounts inside the chroot-ed environment, +we see the following: +.pp +.in +4n +.ex +# \fbcat /proc/self/mountinfo | sed \(aqs/ \- .*//\(aq\fp +239 61 8:2 / / ... shared:102 +248 239 0:4 / /proc ... shared:5 +273 239 8:2 /etc /tmp/etc ... master:105 propagate_from:102 +.ee +.in +.pp +above, we see that the mount with id 273 +is a slave whose master is the peer group 105. +the mount point for that master is unreachable, and so a +.ir propagate_from +tag is displayed, indicating that the closest dominant peer group +(i.e., the nearest reachable mount in the slave chain) +is the peer group with the id 102 (corresponding to the +.ir /mnt +mount point before the +.br chroot (1) +was performed. +.\" +.sh versions +mount namespaces first appeared in linux 2.4.19. +.sh conforming to +namespaces are a linux-specific feature. +.\" +.sh notes +the propagation type assigned to a new mount depends +on the propagation type of the parent mount. +if the mount has a parent (i.e., it is a non-root mount +point) and the propagation type of the parent is +.br ms_shared , +then the propagation type of the new mount is also +.br ms_shared . +otherwise, the propagation type of the new mount is +.br ms_private . +.pp +notwithstanding the fact that the default propagation type +for new mount is in many cases +.br ms_private , +.br ms_shared +is typically more useful. +for this reason, +.br systemd (1) +automatically remounts all mounts as +.br ms_shared +on system startup. +thus, on most modern systems, the default propagation type is in practice +.br ms_shared . +.pp +since, when one uses +.br unshare (1) +to create a mount namespace, +the goal is commonly to provide full isolation of the mounts +in the new namespace, +.br unshare (1) +(since +.ir util\-linux +version 2.27) in turn reverses the step performed by +.br systemd (1), +by making all mounts private in the new namespace. +that is, +.br unshare (1) +performs the equivalent of the following in the new mount namespace: +.pp +.in +4n +.ex +mount \-\-make\-rprivate / +.ee +.in +.pp +to prevent this, one can use the +.ir "\-\-propagation\ unchanged" +option to +.br unshare (1). +.pp +an application that creates a new mount namespace directly using +.br clone (2) +or +.br unshare (2) +may desire to prevent propagation of mount events to other mount namespaces +(as is done by +.br unshare (1)). +this can be done by changing the propagation type of +mounts in the new namespace to either +.b ms_slave +or +.br ms_private , +using a call such as the following: +.pp +.in +4n +.ex +mount(null, "/", ms_slave | ms_rec, null); +.ee +.in +.pp +for a discussion of propagation types when moving mounts +.rb ( ms_move ) +and creating bind mounts +.rb ( ms_bind ), +see +.ir documentation/filesystems/sharedsubtree.txt . +.\" +.\" ============================================================ +.\" +.ss restrictions on mount namespaces +note the following points with respect to mount namespaces: +.ip [1] 4 +each mount namespace has an owner user namespace. +as explained above, when a new mount namespace is created, +its mount list is initialized as a copy of the mount list +of another mount namespace. +if the new namespace and the namespace from which the mount list +was copied are owned by different user namespaces, +then the new mount namespace is considered +.ir "less privileged" . +.ip [2] +when creating a less privileged mount namespace, +shared mounts are reduced to slave mounts. +this ensures that mappings performed in less +privileged mount namespaces will not propagate to more privileged +mount namespaces. +.ip [3] +mounts that come as a single unit from a more privileged mount namespace are +locked together and may not be separated in a less privileged mount +namespace. +(the +.br unshare (2) +.b clone_newns +operation brings across all of the mounts from the original +mount namespace as a single unit, +and recursive mounts that propagate between +mount namespaces propagate as a single unit.) +.ip +in this context, "may not be separated" means that the mounts +are locked so that they may not be individually unmounted. +consider the following example: +.ip +.rs +.in +4n +.ex +$ \fbsudo sh\fp +# \fbmount \-\-bind /dev/null /etc/shadow\fp +# \fbcat /etc/shadow\fp # produces no output +.ee +.in +.re +.ip +the above steps, performed in a more privileged mount namespace, +have created a bind mount that +obscures the contents of the shadow password file, +.ir /etc/shadow . +for security reasons, it should not be possible to unmount +that mount in a less privileged mount namespace, +since that would reveal the contents of +.ir /etc/shadow . +.ip +suppose we now create a new mount namespace +owned by a new user namespace. +the new mount namespace will inherit copies of all of the mounts +from the previous mount namespace. +however, those mounts will be locked because the new mount namespace +is less privileged. +consequently, an attempt to unmount the mount fails as show +in the following step: +.ip +.rs +.in +4n +.ex +# \fbunshare \-\-user \-\-map\-root\-user \-\-mount \e\fp + \fbstrace \-o /tmp/log \e\fp + \fbumount /mnt/dir\fp +umount: /etc/shadow: not mounted. +# \fbgrep \(aq^umount\(aq /tmp/log\fp +umount2("/etc/shadow", 0) = \-1 einval (invalid argument) +.ee +.in +.re +.ip +the error message from +.br mount (8) +is a little confusing, but the +.br strace (1) +output reveals that the underlying +.br umount2 (2) +system call failed with the error +.br einval , +which is the error that the kernel returns to indicate that +the mount is locked. +.ip +note, however, that it is possible to stack (and unstack) a +mount on top of one of the inherited locked mounts in a +less privileged mount namespace: +.ip +.in +4n +.ex +# \fbecho \(aqaaaaa\(aq > /tmp/a\fp # file to mount onto /etc/shadow +# \fbunshare \-\-user \-\-map\-root\-user \-\-mount \e\fp + \fbsh \-c \(aqmount \-\-bind /tmp/a /etc/shadow; cat /etc/shadow\(aq\fp +aaaaa +# \fbumount /etc/shadow\fp +.ee +.in +.ip +the final +.br umount (8) +command above, which is performed in the initial mount namespace, +makes the original +.i /etc/shadow +file once more visible in that namespace. +.ip [4] +following on from point [3], +note that it is possible to unmount an entire subtree of mounts that +propagated as a unit into a less privileged mount namespace, +as illustrated in the following example. +.ip +first, we create new user and mount namespaces using +.br unshare (1). +in the new mount namespace, +the propagation type of all mounts is set to private. +we then create a shared bind mount at +.ir /mnt , +and a small hierarchy of mounts underneath that mount. +.ip +.in +4n +.ex +$ \fbps1=\(aqns1# \(aq sudo unshare \-\-user \-\-map\-root\-user \e\fp + \fb\-\-mount \-\-propagation private bash\fp +ns1# \fbecho $$\fp # we need the pid of this shell later +778501 +ns1# \fbmount \-\-make\-shared \-\-bind /mnt /mnt\fp +ns1# \fbmkdir /mnt/x\fp +ns1# \fbmount \-\-make\-private \-t tmpfs none /mnt/x\fp +ns1# \fbmkdir /mnt/x/y\fp +ns1# \fbmount \-\-make\-private \-t tmpfs none /mnt/x/y\fp +ns1# \fbgrep /mnt /proc/self/mountinfo | sed \(aqs/ \- .*//\(aq\fp +986 83 8:5 /mnt /mnt rw,relatime shared:344 +989 986 0:56 / /mnt/x rw,relatime +990 989 0:57 / /mnt/x/y rw,relatime +.ee +.in +.ip +continuing in the same shell session, +we then create a second shell in a new user namespace and a new +(less privileged) mount namespace and +check the state of the propagated mounts rooted at +.ir /mnt . +.ip +.in +4n +.ex +ns1# \fbps1=\(aqns2# \(aq unshare \-\-user \-\-map\-root\-user \e\fp + \fb\-\-mount \-\-propagation unchanged bash\fp +ns2# \fbgrep /mnt /proc/self/mountinfo | sed \(aqs/ \- .*//\(aq\fp +1239 1204 8:5 /mnt /mnt rw,relatime master:344 +1240 1239 0:56 / /mnt/x rw,relatime +1241 1240 0:57 / /mnt/x/y rw,relatime +.ee +.in +.ip +of note in the above output is that the propagation type of the mount +.i /mnt +has been reduced to slave, as explained in point [2]. +this means that submount events will propagate from the master +.i /mnt +in "ns1", but propagation will not occur in the opposite direction. +.ip +from a separate terminal window, we then use +.br nsenter (1) +to enter the mount and user namespaces corresponding to "ns1". +in that terminal window, we then recursively bind mount +.ir /mnt/x +at the location +.ir /mnt/ppp . +.ip +.in +4n +.ex +$ \fbps1=\(aqns3# \(aq sudo nsenter \-t 778501 \-\-user \-\-mount\fp +ns3# \fbmount \-\-rbind \-\-make\-private /mnt/x /mnt/ppp\fp +ns3# \fbgrep /mnt /proc/self/mountinfo | sed \(aqs/ \- .*//\(aq\fp +986 83 8:5 /mnt /mnt rw,relatime shared:344 +989 986 0:56 / /mnt/x rw,relatime +990 989 0:57 / /mnt/x/y rw,relatime +1242 986 0:56 / /mnt/ppp rw,relatime +1243 1242 0:57 / /mnt/ppp/y rw,relatime shared:518 +.ee +.in +.ip +because the propagation type of the parent mount, +.ir /mnt , +was shared, the recursive bind mount propagated a small subtree of +mounts under the slave mount +.i /mnt +into "ns2", +as can be verified by executing the following command in that shell session: +.ip +.in +4n +.ex +ns2# \fbgrep /mnt /proc/self/mountinfo | sed \(aqs/ \- .*//\(aq\fp +1239 1204 8:5 /mnt /mnt rw,relatime master:344 +1240 1239 0:56 / /mnt/x rw,relatime +1241 1240 0:57 / /mnt/x/y rw,relatime +1244 1239 0:56 / /mnt/ppp rw,relatime +1245 1244 0:57 / /mnt/ppp/y rw,relatime master:518 +.ee +.in +.ip +while it is not possible to unmount a part of the propagated subtree +.ri ( /mnt/ppp/y ) +in "ns2", +it is possible to unmount the entire subtree, +as shown by the following commands: +.ip +.in +4n +.ex +ns2# \fbumount /mnt/ppp/y\fp +umount: /mnt/ppp/y: not mounted. +ns2# \fbumount \-l /mnt/ppp | sed \(aqs/ \- .*//\(aq\fp # succeeds... +ns2# \fbgrep /mnt /proc/self/mountinfo\fp +1239 1204 8:5 /mnt /mnt rw,relatime master:344 +1240 1239 0:56 / /mnt/x rw,relatime +1241 1240 0:57 / /mnt/x/y rw,relatime +.ee +.in +.ip [5] +the +.br mount (2) +flags +.br ms_rdonly , +.br ms_nosuid , +.br ms_noexec , +and the "atime" flags +.rb ( ms_noatime , +.br ms_nodiratime , +.br ms_relatime ) +settings become locked +.\" commit 9566d6742852c527bf5af38af5cbb878dad75705 +.\" author: eric w. biederman +.\" date: mon jul 28 17:26:07 2014 -0700 +.\" +.\" mnt: correct permission checks in do_remount +.\" +when propagated from a more privileged to +a less privileged mount namespace, +and may not be changed in the less privileged mount namespace. +.ip +this point is illustrated in the following example where, +in a more privileged mount namespace, +we create a bind mount that is marked as read-only. +for security reasons, +it should not be possible to make the mount writable in +a less privileged mount namespace, and indeed the kernel prevents this: +.ip +.rs +.in +4n +.ex +$ \fbsudo mkdir /mnt/dir\fp +$ \fbsudo mount \-\-bind \-o ro /some/path /mnt/dir\fp +$ \fbsudo unshare \-\-user \-\-map\-root\-user \-\-mount \e\fp + \fbmount \-o remount,rw /mnt/dir\fp +mount: /mnt/dir: permission denied. +.ee +.in +.re +.ip [6] +.\" (as of 3.18-rc1 (in al viro's 2014-08-30 vfs.git#for-next tree)) +a file or directory that is a mount point in one namespace that is not +a mount point in another namespace, may be renamed, unlinked, or removed +.rb ( rmdir (2)) +in the mount namespace in which it is not a mount point +(subject to the usual permission checks). +consequently, the mount point is removed in the mount namespace +where it was a mount point. +.ip +previously (before linux 3.18), +.\" mtk: the change was in linux 3.18, i think, with this commit: +.\" commit 8ed936b5671bfb33d89bc60bdcc7cf0470ba52fe +.\" author: eric w. biederman +.\" date: tue oct 1 18:33:48 2013 -0700 +.\" +.\" vfs: lazily remove mounts on unlinked files and directories. +attempting to unlink, rename, or remove a file or directory +that was a mount point in another mount namespace would result in the error +.br ebusy . +that behavior had technical problems of enforcement (e.g., for nfs) +and permitted denial-of-service attacks against more privileged users +(i.e., preventing individual files from being updated +by bind mounting on top of them). +.sh examples +see +.br pivot_root (2). +.sh see also +.br unshare (1), +.br clone (2), +.br mount (2), +.br mount_setattr (2), +.br pivot_root (2), +.br setns (2), +.br umount (2), +.br unshare (2), +.br proc (5), +.br namespaces (7), +.br user_namespaces (7), +.br findmnt (8), +.br mount (8), +.br pam_namespace (8), +.br pivot_root (8), +.br umount (8) +.pp +.ir documentation/filesystems/sharedsubtree.txt +in the kernel source tree. +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/cpu_set.3 + +.so man3/strsignal.3 + +.\" copyright (c) 1993 michael haardt (michael@moria.de), +.\" fri apr 2 11:32:09 met dst 1993 +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" modified sat jul 24 16:59:10 1993 by rik faith (faith@cs.unc.edu) +.th mem 4 2015-01-02 "linux" "linux programmer's manual" +.sh name +mem, kmem, port \- system memory, kernel memory and system ports +.sh description +.ir /dev/mem +is a character device file +that is an image of the main memory of the computer. +it may be used, for example, to examine (and even patch) the system. +.pp +byte addresses in +.ir /dev/mem +are interpreted as physical memory addresses. +references to nonexistent locations cause errors to be returned. +.pp +examining and patching is likely to lead to unexpected results +when read-only or write-only bits are present. +.pp +since linux 2.6.26, and depending on the architecture, the +.b config_strict_devmem +kernel configuration option limits the areas +which can be accessed through this file. +for example: on x86, ram access is not allowed but accessing +memory-mapped pci regions is. +.pp +it is typically created by: +.pp +.in +4n +.ex +mknod \-m 660 /dev/mem c 1 1 +chown root:kmem /dev/mem +.ee +.in +.pp +the file +.ir /dev/kmem +is the same as +.ir /dev/mem , +except that the kernel virtual memory +rather than physical memory is accessed. +since linux 2.6.26, this file is available only if the +.b config_devkmem +kernel configuration option is enabled. +.pp +it is typically created by: +.pp +.in +4n +.ex +mknod \-m 640 /dev/kmem c 1 2 +chown root:kmem /dev/kmem +.ee +.in +.pp +.ir /dev/port +is similar to +.ir /dev/mem , +but the i/o ports are accessed. +.pp +it is typically created by: +.pp +.in +4n +.ex +mknod \-m 660 /dev/port c 1 4 +chown root:kmem /dev/port +.ee +.in +.sh files +.i /dev/mem +.br +.i /dev/kmem +.br +.i /dev/port +.sh see also +.br chown (1), +.br mknod (1), +.br ioperm (2) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +#!/bin/sh +# +# add_parens_for_own_funcs.sh +# +# this script is designed to fix inconsistencies in the use of +# parentheses after function names in the manual pages. +# it changes manual pages to add these parentheses. +# the problem is how to determine what is a "function name". +# the approach this script takes is the following: +# +# for each manual page named in the command line that contains +# more than one line (i.e., skip man-page link files) +# create a set of names taken from the .sh section of the +# page and from grepping all pages for names that +# have .so links to this page +# for each name obtained above +# if we can find something that looks like a prototype on +# the page, then +# try to substitute instances of that name on the page. +# (instances are considered to be words formatted +# using ^.[bi] or \f[bi]...\f[pr] -- this script +# ignores unformatted instances of function names.) +# fi +# done +# done +# +# the rationale of the above is that the most likely function names +# that appear on a page are those that the manual page is describing. +# it doesn't fix everything, but it catches many instances. +# the rest will have to be done manually. +# +# this script is rather verbose because it provides a computer-assisted +# solution, rather than one that is fully automated. when running it, +# pipe the output through +# +# ... 2>&1 | less +# +# and take a good look at the output. in particular, you can scan +# the output for *possible* problems by looking for the pattern: /^%%%/ +# the script's output should be enough to help you determine if the +# problem is real or not. +# +# suggested usage (in this case to fix pages in section 2): +# +# cd man2 +# sh add_parens_for_own_funcs.sh *.2 2>&1 | tee changes.log | less +# +# use the "-n" option for a dry run, in order to see what would be +# done, without actually doing it. +# +# (and, yes, there are many ways that this script could probably be +# made to work faster...) +# +###################################################################### +# +# (c) copyright 2005 & 2013, michael kerrisk +# this program is free software; you can redistribute it and/or +# modify it under the terms of the gnu general public license +# as published by the free software foundation; either version 2 +# of the license, or (at your option) any later version. +# +# this program 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 general public license for more details +# (http://www.gnu.org/licenses/gpl-2.0.html). +# +# +# + +file_base="tmp.$(basename $0)" + +work_dst_file="$file_base.dst" +work_src_file="$file_base.src" + +matches_for_all_names="$file_base.all_match" +matches_for_this_name="$file_base.this_match" + +all_files="$work_dst_file $work_src_file $matches_for_all_names \ + $matches_for_this_name" + +rm -f $all_files + +# command-line option processing + +really_do_it=1 +while getopts "n" optname; do + case "$optname" in + n) really_do_it=0; + ;; + *) echo "unknown option: $optarg" + exit 1 + ;; + esac +done + +shift $(( $optind - 1 )) + +# only process files with > 1 line -- single-line files are link files + +for page in $(wc "$@" 2> /dev/null | awk '$1 > 1 {print $4}'| \ + grep -v '^total'); do + + echo ">>>>>>>>>>>>>>>>>>>>>>>>>" $page "<<<<<<<<<<<<<<<<<<<<<<<<<" + echo ">>>>>>>>>>>>>>>>>>>>>>>>>" $page "<<<<<<<<<<<<<<<<<<<<<<<<<" 1>&2 + + # extract names that follow the ".sh name" directive -- these will + # be our guesses about function names to look for + + sh_nlist=$(cat $page | \ + awk 'begin { p = 0 } + /^\.sh name/ { p = nr } + /^.sh/ && nr > p { p = 0 } # stop at the next .sh directive + p > 0 && nr > p { print $0 } # these are the lines between + # the two .sh directives + ') + sh_nlist=$(echo $sh_nlist | sed -e 's/ *\\-.*//' -e 's/, */ /g') + echo "### .sh name list:" $sh_nlist + + # some pages like msgop.2 don't actually list the function names in + # the .sh section -- but we can try using link pages to give us + # another guess at the right function names to look for + + so_nlist=$(grep -l "^\\.so.*/$(echo $page| \ + sed -e 's/\.[1-8]$//')\\." $* | \ + sed -e 's/\.[1-8]$//g') + + echo "### .so name list:" $so_nlist + + # combine the two lists, eliminate duplicates + + nlist=$(echo $sh_nlist $so_nlist | tr ' ' '\012' | sort -u) + + maybechanged=0 + + cp $page $work_dst_file + rm -f $matches_for_all_names; # touch $matches_for_all_names + + for rname in $nlist; do # try each name from out list for this page + + # a very few names in .sh sections contain regexp characters! + + name=$(echo $rname | sed -e 's/\*/\\*/g' -e 's/\./\\./g' \ + -e 's/\[/\\[/g' -e 's/\+/\\+/g') + + echo "########## trying $rname ##########" + + rm -f $matches_for_this_name + + grep "^.br* $name *$" $page | \ + >> $matches_for_this_name + grep "^.br $name [^(\"]$" $page | \ + >> $matches_for_this_name + grep '\\fb'"$name"'\\f[pr][ .,;:]' $page | \ + >> $matches_for_this_name + grep '\\fb'"$name"'\\f[pr]$' $page | \ + >> $matches_for_this_name + + cat $matches_for_this_name | sed -e 's/^/### match: /' + cat $matches_for_this_name >> $matches_for_all_names + + # only process a page if we can see something that looks + # like a function prototype for this name in the page + + if grep -q "$name *(" $page || \ + grep -q "$name\\\\f.[\\ ]*(" $page; then + + # '.b name$' + # '.br name [^("]*$ + # (the use of [^"] in the above eliminates lines + # like: .br func " and " func + # those lines better be done manually.) + cp $work_dst_file $work_src_file + cat $work_src_file | \ + sed \ + -e "s/^.br* $name *\$/.br $name ()/" \ + -e "/^.br *$name [^(\"]*\$/s/^.br *$name /.br $name ()/" \ + > $work_dst_file + + # '\fbname\fp[ .,;:]' + # '\fbname\fp$' + cp $work_dst_file $work_src_file + cat $work_src_file | \ + sed \ + -e 's/\\fb'$name'\\fp /\\fb'$name'\\fp() /g' \ + -e 's/\\fb'$name'\\fp\./\\fb'$name'\\fp()./g' \ + -e 's/\\fb'$name'\\fp,/\\fb'$name'\\fp(),/g' \ + -e 's/\\fb'$name'\\fp;/\\fb'$name'\\fp();/g' \ + -e 's/\\fb'$name'\\fp:/\\fb'$name'\\fp():/g' \ + -e 's/\\fb'$name'\\fp$/\\fb'$name'\\fp()/g' \ + > $work_dst_file + + # '\fbname\fr[ .,;:]' + # '\fbname\fr$' + cp $work_dst_file $work_src_file + cat $work_src_file | \ + sed \ + -e 's/\\fb'$name'\\fr /\\fb'$name'\\fr() /g' \ + -e 's/\\fb'$name'\\fr\./\\fb'$name'\\fr()./g' \ + -e 's/\\fb'$name'\\fr,/\\fb'$name'\\fr(),/g' \ + -e 's/\\fb'$name'\\fr;/\\fb'$name'\\fr();/g' \ + -e 's/\\fb'$name'\\fr:/\\fb'$name'\\fr():/g' \ + -e 's/\\fb'$name'\\fr$/\\fb'$name'\\fr()/g' \ + > $work_dst_file + + maybechanged=1 + else + echo "%%%%%%%%%% warning: no prototype matches for: $name" + fi + done + + # if the file was changed, then: + # show "diff -u" output to user; + # and count number of changed lines and compare it with what + # we expected, displaying a warning if it wasn't what was expected + + if test $maybechanged -ne 0 && ! cmp -s $page $work_dst_file; then + diff -u $page $work_dst_file + + made_matches=$(diff -u 0 $page $work_dst_file | grep '^\+[^+]' | \ + wc -l | awk '{print $1}') + + # the following line makes the changes -- comment it out if you + # just want to do a dry run to see what changes would be made. + + if test $really_do_it -ne 0; then + cat $work_dst_file > $page + fi + + else + echo "### nothing changed" + made_matches=0 + fi + + min_match=$(cat $matches_for_all_names | \ + sort -u | wc -l | awk '{print $1}') + + echo "### expected matches >= $min_match" + echo "### made matches $made_matches" + + if test $made_matches -lt $min_match; then + echo "%%%%%%%%%% warning: not enough matches: " \ + "$made_matches < $min_match" + fi + +done + +# clean up + +rm -f $all_files +exit 0 + +.so man3/pow10.3 + +.so man2/open.2 + +.so man2/select.2 + +.so man3/scalbln.3 + +.\" copyright (c) 1995 michael chastain (mec@shell.portal.com), 15 april 1995. +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" modified tue oct 22 22:11:53 1996 by eric s. raymond +.th socketcall 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +socketcall \- socket system calls +.sh synopsis +.nf +.br "#include " " /* definition of " sys_* " constants */" +.br "#include " " /* definition of " sys_socketcall " */" +.b #include +.pp +.bi "int syscall(sys_socketcall, int " call ", unsigned long *" args ); +.fi +.pp +.ir note : +glibc provides no wrapper for +.br socketcall (), +necessitating the use of +.br syscall (2). +.sh description +.br socketcall () +is a common kernel entry point for the socket system calls. +.i call +determines which socket function to invoke. +.i args +points to a block containing the actual arguments, +which are passed through to the appropriate call. +.pp +user programs should call the appropriate functions by their usual names. +only standard library implementors and kernel hackers need to know about +.br socketcall (). +.pp +.ts +tab(:); +l l. +\ficall\fr:man page +t{ +.b sys_socket +t}:t{ +.br socket (2) +t} +t{ +.b sys_bind +t}:t{ +.br bind (2) +t} +t{ +.b sys_connect +t}:t{ +.br connect (2) +t} +t{ +.b sys_listen +t}:t{ +.br listen (2) +t} +t{ +.b sys_accept +t}:t{ +.br accept (2) +t} +t{ +.b sys_getsockname +t}:t{ +.br getsockname (2) +t} +t{ +.b sys_getpeername +t}:t{ +.br getpeername (2) +t} +t{ +.b sys_socketpair +t}:t{ +.br socketpair (2) +t} +t{ +.b sys_send +t}:t{ +.br send (2) +t} +t{ +.b sys_recv +t}:t{ +.br recv (2) +t} +t{ +.b sys_sendto +t}:t{ +.br sendto (2) +t} +t{ +.b sys_recvfrom +t}:t{ +.br recvfrom (2) +t} +t{ +.b sys_shutdown +t}:t{ +.br shutdown (2) +t} +t{ +.b sys_setsockopt +t}:t{ +.br setsockopt (2) +t} +t{ +.b sys_getsockopt +t}:t{ +.br getsockopt (2) +t} +t{ +.b sys_sendmsg +t}:t{ +.br sendmsg (2) +t} +t{ +.b sys_recvmsg +t}:t{ +.br recvmsg (2) +t} +t{ +.b sys_accept4 +t}:t{ +.br accept4 (2) +t} +t{ +.b sys_recvmmsg +t}:t{ +.br recvmmsg (2) +t} +t{ +.b sys_sendmmsg +t}:t{ +.br sendmmsg (2) +t} +.te +.sh conforming to +this call is specific to linux, and should not be used in programs +intended to be portable. +.sh notes +on some architectures\(emfor example, x86-64 and arm\(emthere is no +.br socketcall () +system call; instead +.br socket (2), +.br accept (2), +.br bind (2), +and so on really are implemented as separate system calls. +.pp +on x86-32, +.br socketcall () +was historically the only entry point for the sockets api. +however, starting in linux 4.3, +.\" commit 9dea5dc921b5f4045a18c63eb92e84dc274d17eb +direct system calls are provided on x86-32 for the sockets api. +this facilitates the creation of +.br seccomp (2) +filters that filter sockets system calls +(for new user-space binaries that are compiled +to use the new entry points) +and also provides a (very) small performance improvement. +.sh see also +.br accept (2), +.br bind (2), +.br connect (2), +.br getpeername (2), +.br getsockname (2), +.br getsockopt (2), +.br listen (2), +.br recv (2), +.br recvfrom (2), +.br recvmsg (2), +.br send (2), +.br sendmsg (2), +.br sendto (2), +.br setsockopt (2), +.br shutdown (2), +.br socket (2), +.br socketpair (2) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/rpc.3 + +.\" copyright (c) 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th getutmp 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +getutmp, getutmpx \- copy utmp structure to utmpx, and vice versa +.sh synopsis +.nf +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "void getutmp(const struct utmpx *" ux ", struct utmp *" u ); +.bi "void getutmpx(const struct utmp *" u ", struct utmpx *" ux ); +.fi +.sh description +the +.br getutmp () +function copies the fields of the +.i utmpx +structure pointed to by +.i ux +to the corresponding fields of the +.i utmp +structure pointed to by +.ir u . +the +.br getutmpx () +function performs the converse operation. +.sh return value +these functions do not return a value. +.sh versions +these functions first appeared in glibc in version 2.1.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br getutmp (), +.br getutmpx () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +these functions are nonstandard, but appear on a few other systems, +such as solaris and netbsd. +.sh notes +these functions exist primarily for compatibility with other +systems where the +.i utmp +and +.i utmpx +structures contain different fields, +or the size of corresponding fields differs. +.\" e.g., on solaris, the utmpx structure is rather larger than utmp. +on linux, the two structures contain the same fields, +and the fields have the same sizes. +.sh see also +.br utmpdump (1), +.br getutent (3), +.br utmp (5) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/getopt.3 + +.so man3/gnu_get_libc_version.3 + +.so man7/system_data_types.7 + +.so man3/isalpha.3 + +.so man3/__ppc_set_ppr_med.3 + +.so man3/pthread_mutexattr_setrobust.3 + +.so man3/rexec.3 + +.so man3/printf.3 + +.so man3/perror.3 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" and copyright 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified 1993-07-24 by rik faith (faith@cs.unc.edu) +.\" modified 2002-07-27 by walter harms +.\" (walter.harms@informatik.uni-oldenburg.de) +.\" +.th erf 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +erf, erff, erfl \- error function +.sh synopsis +.nf +.b #include +.pp +.bi "double erf(double " x ); +.bi "float erff(float " x ); +.bi "long double erfl(long double " x ); +.pp +.fi +link with \fi\-lm\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br erf (): +.nf + _isoc99_source || _posix_c_source >= 200112l || _xopen_source + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.pp +.br erff (), +.br erfl (): +.nf + _isoc99_source || _posix_c_source >= 200112l + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.sh description +these functions return the error function of +.ir x , +defined as +.tp + erf(x) = 2/sqrt(pi) * integral from 0 to x of exp(\-t*t) dt +.sh return value +on success, these functions return the value of the error function of +.ir x , +a value in the range [\-1,\ 1]. +.pp +if +.i x +is a nan, a nan is returned. +.pp +if +.i x +is +0 (\-0), +0 (\-0) is returned. +.pp +if +.i x +is positive infinity (negative infinity), ++1 (\-1) is returned. +.pp +if +.i x +is subnormal, +a range error occurs, +and the return value is 2*x/sqrt(pi). +.sh errors +see +.br math_error (7) +for information on how to determine whether an error has occurred +when calling these functions. +.pp +the following errors can occur: +.tp +range error: result underflow (\fix\fp is subnormal) +.\" .i errno +.\" is set to +.\" .br erange . +an underflow floating-point exception +.rb ( fe_underflow ) +is raised. +.pp +these functions do not set +.ir errno . +.\" it is intentional that these functions do not set errno for this case +.\" see http://sources.redhat.com/bugzilla/show_bug.cgi?id=6785 +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br erf (), +.br erff (), +.br erfl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.pp +the variant returning +.i double +also conforms to +svr4, 4.3bsd. +.sh see also +.br cerf (3), +.br erfc (3), +.br exp (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified 1993-04-12, david metcalfe +.\" modified 1993-07-24, rik faith (faith@cs.unc.edu) +.\" modified 2002-01-20, walter harms +.th bstring 3 2021-03-22 "" "linux programmer's manual" +.sh name +bcmp, bcopy, bzero, memccpy, memchr, memcmp, memcpy, memfrob, memmem, +memmove, memset \- byte string operations +.sh synopsis +.nf +.b #include +.pp +.bi "int bcmp(const void *" s1 ", const void *" s2 ", size_t " n ); +.pp +.bi "void bcopy(const void *" src ", void *" dest ", size_t " n ); +.pp +.bi "void bzero(void *" s ", size_t " n ); +.pp +.bi "void *memccpy(void *" dest ", const void *" src ", int " c ", size_t " n ); +.pp +.bi "void *memchr(const void *" s ", int " c ", size_t " n ); +.pp +.bi "int memcmp(const void *" s1 ", const void *" s2 ", size_t " n ); +.pp +.bi "void *memcpy(void *" dest ", const void *" src ", size_t " n ); +.pp +.bi "void *memfrob(void *" s ", size_t " n ); +.pp +.bi "void *memmem(const void *" haystack ", size_t " haystacklen , +.bi " const void *" needle ", size_t " needlelen ); +.pp +.bi "void *memmove(void *" dest ", const void *" src ", size_t " n ); +.pp +.bi "void *memset(void *" s ", int " c ", size_t " n ); +.fi +.sh description +the byte string functions perform operations on strings (byte arrays) +that are not necessarily null-terminated. +see the individual man pages +for descriptions of each function. +.sh notes +the functions +.br bcmp (), +.br bcopy (), +and +.br bzero () +are obsolete. +use +.br memcmp (), +.br memcpy (), +and +.br memset () +instead. +.\" the old functions are not even available on some non-gnu/linux systems. +.sh see also +.br bcmp (3), +.br bcopy (3), +.br bzero (3), +.br memccpy (3), +.br memchr (3), +.br memcmp (3), +.br memcpy (3), +.br memfrob (3), +.br memmem (3), +.br memmove (3), +.br memset (3), +.br string (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/nextafter.3 + +.\" copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de) +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under gpl +.\" %%%license_end +.\" +.th cimag 3 2021-03-22 "" "linux programmer's manual" +.sh name +cimag, cimagf, cimagl \- get imaginary part of a complex number +.sh synopsis +.nf +.b #include +.pp +.bi "double cimag(double complex " z ");" +.bi "float cimagf(float complex " z ");" +.bi "long double cimagl(long double complex " z ");" +.pp +link with \fi\-lm\fp. +.fi +.sh description +these functions return the imaginary part of the complex number +.ir z . +.pp +one has: +.pp +.nf + z = creal(z) + i * cimag(z) +.fi +.sh versions +these functions first appeared in glibc in version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br cimag (), +.br cimagf (), +.br cimagl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.sh notes +gcc also supports __imag__. +that is a gnu extension. +.sh see also +.br cabs (3), +.br creal (3), +.br complex (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/stdio_ext.3 + +.\" copyright (c) 2006 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th mq_overview 7 2020-06-09 "linux" "linux programmer's manual" +.sh name +mq_overview \- overview of posix message queues +.sh description +posix message queues allow processes to exchange data in +the form of messages. +this api is distinct from that provided by system v message queues +.rb ( msgget (2), +.br msgsnd (2), +.br msgrcv (2), +etc.), but provides similar functionality. +.pp +message queues are created and opened using +.br mq_open (3); +this function returns a +.i message queue descriptor +.ri ( mqd_t ), +which is used to refer to the open message queue in later calls. +each message queue is identified by a name of the form +.ir /somename ; +that is, a null-terminated string of up to +.bi name_max +(i.e., 255) characters consisting of an initial slash, +followed by one or more characters, none of which are slashes. +two processes can operate on the same queue by passing the same name to +.br mq_open (3). +.pp +messages are transferred to and from a queue using +.br mq_send (3) +and +.br mq_receive (3). +when a process has finished using the queue, it closes it using +.br mq_close (3), +and when the queue is no longer required, it can be deleted using +.br mq_unlink (3). +queue attributes can be retrieved and (in some cases) modified using +.br mq_getattr (3) +and +.br mq_setattr (3). +a process can request asynchronous notification +of the arrival of a message on a previously empty queue using +.br mq_notify (3). +.pp +a message queue descriptor is a reference to an +.i "open message queue description" +(see +.br open (2)). +after a +.br fork (2), +a child inherits copies of its parent's message queue descriptors, +and these descriptors refer to the same open message queue descriptions +as the corresponding message queue descriptors in the parent. +corresponding message queue descriptors in the two processes share the flags +.ri ( mq_flags ) +that are associated with the open message queue description. +.pp +each message has an associated +.ir priority , +and messages are always delivered to the receiving process +highest priority first. +message priorities range from 0 (low) to +.i sysconf(_sc_mq_prio_max)\ \-\ 1 +(high). +on linux, +.i sysconf(_sc_mq_prio_max) +returns 32768, but posix.1 requires only that +an implementation support at least priorities in the range 0 to 31; +some implementations provide only this range. +.pp +the remainder of this section describes some specific details +of the linux implementation of posix message queues. +.ss library interfaces and system calls +in most cases the +.br mq_* () +library interfaces listed above are implemented +on top of underlying system calls of the same name. +deviations from this scheme are indicated in the following table: +.rs +.ts +lb lb +l l. +library interface system call +mq_close(3) close(2) +mq_getattr(3) mq_getsetattr(2) +mq_notify(3) mq_notify(2) +mq_open(3) mq_open(2) +mq_receive(3) mq_timedreceive(2) +mq_send(3) mq_timedsend(2) +mq_setattr(3) mq_getsetattr(2) +mq_timedreceive(3) mq_timedreceive(2) +mq_timedsend(3) mq_timedsend(2) +mq_unlink(3) mq_unlink(2) +.te +.re +.ss versions +posix message queues have been supported on linux since kernel 2.6.6. +glibc support has been provided since version 2.3.4. +.ss kernel configuration +support for posix message queues is configurable via the +.b config_posix_mqueue +kernel configuration option. +this option is enabled by default. +.ss persistence +posix message queues have kernel persistence: +if not removed by +.br mq_unlink (3), +a message queue will exist until the system is shut down. +.ss linking +programs using the posix message queue api must be compiled with +.i cc \-lrt +to link against the real-time library, +.ir librt . +.ss /proc interfaces +the following interfaces can be used to limit the amount of +kernel memory consumed by posix message queues and to set +the default attributes for new message queues: +.tp +.ir /proc/sys/fs/mqueue/msg_default " (since linux 3.5)" +this file defines the value used for a new queue's +.i mq_maxmsg +setting when the queue is created with a call to +.br mq_open (3) +where +.i attr +is specified as null. +the default value for this file is 10. +the minimum and maximum are as for +.ir /proc/sys/fs/mqueue/msg_max . +a new queue's default +.i mq_maxmsg +value will be the smaller of +.ir msg_default +and +.ir msg_max . +up until linux 2.6.28, the default +.i mq_maxmsg +was 10; +from linux 2.6.28 to linux 3.4, the default was the value defined for the +.i msg_max +limit. +.tp +.i /proc/sys/fs/mqueue/msg_max +this file can be used to view and change the ceiling value for the +maximum number of messages in a queue. +this value acts as a ceiling on the +.i attr\->mq_maxmsg +argument given to +.br mq_open (3). +the default value for +.i msg_max +is 10. +the minimum value is 1 (10 in kernels before 2.6.28). +the upper limit is +.br hard_msgmax . +the +.i msg_max +limit is ignored for privileged processes +.rb ( cap_sys_resource ), +but the +.br hard_msgmax +ceiling is nevertheless imposed. +.ip +the definition of +.br hard_msgmax +has changed across kernel versions: +.rs +.ip * 3 +up to linux 2.6.32: +.ir "131072\ /\ sizeof(void\ *)" +.ip * +linux 2.6.33 to 3.4: +.ir "(32768\ *\ sizeof(void\ *) / 4)" +.ip * +since linux 3.5: +.\" commit 5b5c4d1a1440e94994c73dddbad7be0676cd8b9a +65,536 +.re +.tp +.ir /proc/sys/fs/mqueue/msgsize_default " (since linux 3.5)" +this file defines the value used for a new queue's +.i mq_msgsize +setting when the queue is created with a call to +.br mq_open (3) +where +.i attr +is specified as null. +the default value for this file is 8192 (bytes). +the minimum and maximum are as for +.ir /proc/sys/fs/mqueue/msgsize_max . +if +.ir msgsize_default +exceeds +.ir msgsize_max , +a new queue's default +.i mq_msgsize +value is capped to the +.i msgsize_max +limit. +up until linux 2.6.28, the default +.i mq_msgsize +was 8192; +from linux 2.6.28 to linux 3.4, the default was the value defined for the +.i msgsize_max +limit. +.tp +.i /proc/sys/fs/mqueue/msgsize_max +this file can be used to view and change the ceiling on the +maximum message size. +this value acts as a ceiling on the +.i attr\->mq_msgsize +argument given to +.br mq_open (3). +the default value for +.i msgsize_max +is 8192 bytes. +the minimum value is 128 (8192 in kernels before 2.6.28). +the upper limit for +.i msgsize_max +has varied across kernel versions: +.rs +.ip * 3 +before linux 2.6.28, the upper limit is +.br int_max . +.ip * +from linux 2.6.28 to 3.4, the limit is 1,048,576. +.ip * +since linux 3.5, the limit is 16,777,216 +.rb ( hard_msgsizemax ). +.re +.ip +the +.i msgsize_max +limit is ignored for privileged process +.rb ( cap_sys_resource ), +but, since linux 3.5, the +.br hard_msgsizemax +ceiling is enforced for privileged processes. +.tp +.i /proc/sys/fs/mqueue/queues_max +this file can be used to view and change the system-wide limit on the +number of message queues that can be created. +the default value for +.i queues_max +is 256. +no ceiling is imposed on the +.i queues_max +limit; privileged processes +.rb ( cap_sys_resource ) +can exceed the limit (but see bugs). +.ss resource limit +the +.b rlimit_msgqueue +resource limit, which places a limit on the amount of space +that can be consumed by all of the message queues +belonging to a process's real user id, is described in +.br getrlimit (2). +.ss mounting the message queue filesystem +on linux, message queues are created in a virtual filesystem. +(other implementations may also provide such a feature, +but the details are likely to differ.) +this filesystem can be mounted (by the superuser) using the following +commands: +.pp +.in +4n +.ex +.rb "#" " mkdir /dev/mqueue" +.rb "#" " mount \-t mqueue none /dev/mqueue" +.ee +.in +.pp +the sticky bit is automatically enabled on the mount directory. +.pp +after the filesystem has been mounted, the message queues on the system +can be viewed and manipulated using the commands usually used for files +(e.g., +.br ls (1) +and +.br rm (1)). +.pp +the contents of each file in the directory consist of a single line +containing information about the queue: +.pp +.in +4n +.ex +.rb "$" " cat /dev/mqueue/mymq" +qsize:129 notify:2 signo:0 notify_pid:8260 +.ee +.in +.pp +these fields are as follows: +.tp +.b qsize +number of bytes of data in all messages in the queue (but see bugs). +.tp +.b notify_pid +if this is nonzero, then the process with this pid has used +.br mq_notify (3) +to register for asynchronous message notification, +and the remaining fields describe how notification occurs. +.tp +.b notify +notification method: +0 is +.br sigev_signal ; +1 is +.br sigev_none ; +and +2 is +.br sigev_thread . +.tp +.b signo +signal number to be used for +.br sigev_signal . +.ss linux implementation of message queue descriptors +on linux, a message queue descriptor is actually a file descriptor. +(posix does not require such an implementation.) +this means that a message queue descriptor can be monitored using +.br select (2), +.br poll (2), +or +.br epoll (7). +this is not portable. +.pp +the close-on-exec flag (see +.br open (2)) +is automatically set on the file descriptor returned by +.br mq_open (2). +.ss ipc namespaces +for a discussion of the interaction of posix message queue objects and +ipc namespaces, see +.br ipc_namespaces (7). +.sh notes +system v message queues +.rb ( msgget (2), +.br msgsnd (2), +.br msgrcv (2), +etc.) are an older api for exchanging messages between processes. +posix message queues provide a better designed interface than +system v message queues; +on the other hand posix message queues are less widely available +(especially on older systems) than system v message queues. +.pp +linux does not currently (2.6.26) support the use of access control +lists (acls) for posix message queues. +.sh bugs +in linux versions 3.5 to 3.14, the kernel imposed a ceiling of 1024 +.rb ( hard_queuesmax ) +on the value to which the +.i queues_max +limit could be raised, +and the ceiling was enforced even for privileged processes. +this ceiling value was removed in linux 3.14, +and patches to stable kernels 3.5.x to 3.13.x also removed the ceiling. +.pp +as originally implemented (and documented), +the qsize field displayed the total number of (user-supplied) +bytes in all messages in the message queue. +some changes in linux 3.5 +.\" commit d6629859b36d +inadvertently changed the behavior, +so that this field also included a count of kernel overhead bytes +used to store the messages in the queue. +this behavioral regression was rectified in linux 4.2 +.\" commit de54b9ac253787c366bbfb28d901a31954eb3511 +(and earlier stable kernel series), +so that the count once more included just the bytes of user data +in messages in the queue. +.sh examples +an example of the use of various message queue functions is shown in +.br mq_notify (3). +.sh see also +.br getrlimit (2), +.br mq_getsetattr (2), +.br poll (2), +.br select (2), +.br mq_close (3), +.br mq_getattr (3), +.br mq_notify (3), +.br mq_open (3), +.br mq_receive (3), +.br mq_send (3), +.br mq_unlink (3), +.br epoll (7), +.br namespaces (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/fopen.3 + +.so man3/makecontext.3 + +.\" copyright (c) 2017 david howells +.\" +.\" derived from the stat.2 manual page: +.\" copyright (c) 1992 drew eckhardt (drew@cs.colorado.edu), march 28, 1992 +.\" parts copyright (c) 1995 nicolai langfeldt (janl@ifi.uio.no), 1/1/95 +.\" and copyright (c) 2006, 2007, 2014 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th statx 2 2021-08-27 "linux" "linux programmer's manual" +.sh name +statx \- get file status (extended) +.sh synopsis +.nf +.br "#include " "/* definition of " at_* " constants */" +.b #include +.pp +.bi "int statx(int " dirfd ", const char *restrict " pathname ", int " flags , +.bi " unsigned int " mask ", struct statx *restrict " statxbuf ); +.fi +.sh description +this function returns information about a file, storing it in the buffer +pointed to by +.ir statxbuf . +the returned buffer is a structure of the following type: +.pp +.in +4n +.ex +struct statx { + __u32 stx_mask; /* mask of bits indicating + filled fields */ + __u32 stx_blksize; /* block size for filesystem i/o */ + __u64 stx_attributes; /* extra file attribute indicators */ + __u32 stx_nlink; /* number of hard links */ + __u32 stx_uid; /* user id of owner */ + __u32 stx_gid; /* group id of owner */ + __u16 stx_mode; /* file type and mode */ + __u64 stx_ino; /* inode number */ + __u64 stx_size; /* total size in bytes */ + __u64 stx_blocks; /* number of 512b blocks allocated */ + __u64 stx_attributes_mask; + /* mask to show what\(aqs supported + in stx_attributes */ + + /* the following fields are file timestamps */ + struct statx_timestamp stx_atime; /* last access */ + struct statx_timestamp stx_btime; /* creation */ + struct statx_timestamp stx_ctime; /* last status change */ + struct statx_timestamp stx_mtime; /* last modification */ + + /* if this file represents a device, then the next two + fields contain the id of the device */ + __u32 stx_rdev_major; /* major id */ + __u32 stx_rdev_minor; /* minor id */ + + /* the next two fields contain the id of the device + containing the filesystem where the file resides */ + __u32 stx_dev_major; /* major id */ + __u32 stx_dev_minor; /* minor id */ + __u64 stx_mnt_id; /* mount id */ +}; +.ee +.in +.pp +the file timestamps are structures of the following type: +.pp +.in +4n +.ex +struct statx_timestamp { + __s64 tv_sec; /* seconds since the epoch (unix time) */ + __u32 tv_nsec; /* nanoseconds since tv_sec */ +}; +.ee +.in +.pp +(note that reserved space and padding is omitted.) +.ss +invoking \fbstatx\fr(): +to access a file's status, no permissions are required on the file itself, +but in the case of +.br statx () +with a pathname, +execute (search) permission is required on all of the directories in +.i pathname +that lead to the file. +.pp +.br statx () +uses +.ir pathname , +.ir dirfd , +and +.ir flags +to identify the target file in one of the following ways: +.tp +an absolute pathname +if +.i pathname +begins with a slash, +then it is an absolute pathname that identifies the target file. +in this case, +.i dirfd +is ignored. +.tp +a relative pathname +if +.i pathname +is a string that begins with a character other than a slash and +.ir dirfd +is +.br at_fdcwd , +then +.i pathname +is a relative pathname that is interpreted relative to the process's +current working directory. +.tp +a directory-relative pathname +if +.i pathname +is a string that begins with a character other than a slash and +.i dirfd +is a file descriptor that refers to a directory, then +.i pathname +is a relative pathname that is interpreted relative to the directory +referred to by +.ir dirfd . +(see +.br openat (2) +for an explanation of why this is useful.) +.tp +by file descriptor +if +.ir pathname +is an empty string and the +.b at_empty_path +flag is specified in +.ir flags +(see below), +then the target file is the one referred to by the file descriptor +.ir dirfd . +.pp +.i flags +can be used to influence a pathname-based lookup. +a value for +.i flags +is constructed by oring together zero or more of the following constants: +.tp +.br at_empty_path +.\" commit 65cfc6722361570bfe255698d9cd4dccaf47570d +if +.i pathname +is an empty string, operate on the file referred to by +.ir dirfd +(which may have been obtained using the +.br open (2) +.b o_path +flag). +in this case, +.i dirfd +can refer to any type of file, not just a directory. +.ip +if +.i dirfd +is +.br at_fdcwd , +the call operates on the current working directory. +.ip +this flag is linux-specific; define +.b _gnu_source +.\" before glibc 2.16, defining _atfile_source sufficed +to obtain its definition. +.tp +.br at_no_automount +don't automount the terminal ("basename") component of +.i pathname +if it is a directory that is an automount point. +this allows the caller to gather attributes of an automount point +(rather than the location it would mount). +this flag can be used in tools that scan directories +to prevent mass-automounting of a directory of automount points. +the +.b at_no_automount +flag has no effect if the mount point has already been mounted over. +this flag is linux-specific; define +.b _gnu_source +.\" before glibc 2.16, defining _atfile_source sufficed +to obtain its definition. +.tp +.b at_symlink_nofollow +if +.i pathname +is a symbolic link, do not dereference it: +instead return information about the link itself, like +.br lstat (2). +.pp +.i flags +can also be used to control what sort of synchronization the kernel will do +when querying a file on a remote filesystem. +this is done by oring in one of the following values: +.tp +.b at_statx_sync_as_stat +do whatever +.br stat (2) +does. +this is the default and is very much filesystem-specific. +.tp +.b at_statx_force_sync +force the attributes to be synchronized with the server. +this may require that +a network filesystem perform a data writeback to get the timestamps correct. +.tp +.b at_statx_dont_sync +don't synchronize anything, but rather just take whatever +the system has cached if possible. +this may mean that the information returned is approximate, but, +on a network filesystem, it may not involve a round trip to the server - even +if no lease is held. +.pp +the +.i mask +argument to +.br statx () +is used to tell the kernel which fields the caller is interested in. +.i mask +is an ored combination of the following constants: +.pp +.in +4n +.ts +lb l. +statx_type want stx_mode & s_ifmt +statx_mode want stx_mode & \(tis_ifmt +statx_nlink want stx_nlink +statx_uid want stx_uid +statx_gid want stx_gid +statx_atime want stx_atime +statx_mtime want stx_mtime +statx_ctime want stx_ctime +statx_ino want stx_ino +statx_size want stx_size +statx_blocks want stx_blocks +statx_basic_stats [all of the above] +statx_btime want stx_btime +statx_mnt_id want stx_mnt_id (since linux 5.8) +statx_all [all currently available fields] +.te +.in +.pp +note that, in general, the kernel does +.i not +reject values in +.i mask +other than the above. +(for an exception, see +.b einval +in errors.) +instead, it simply informs the caller which values are supported +by this kernel and filesystem via the +.i statx.stx_mask +field. +therefore, +.i "do not" +simply set +.i mask +to +.b uint_max +(all bits set), +as one or more bits may, in the future, be used to specify an +extension to the buffer. +.ss +the returned information +the status information for the target file is returned in the +.i statx +structure pointed to by +.ir statxbuf . +included in this is +.i stx_mask +which indicates what other information has been returned. +.i stx_mask +has the same format as the +.i mask +argument and bits are set in it to indicate +which fields have been filled in. +.pp +it should be noted that the kernel may return fields that weren't +requested and may fail to return fields that were requested, +depending on what the backing filesystem supports. +(fields that are given values despite being unrequested can just be ignored.) +in either case, +.i stx_mask +will not be equal +.ir mask . +.pp +if a filesystem does not support a field or if it has +an unrepresentable value (for instance, a file with an exotic type), +then the mask bit corresponding to that field will be cleared in +.i stx_mask +even if the user asked for it and a dummy value will be filled in for +compatibility purposes if one is available (e.g., a dummy uid and gid may be +specified to mount under some circumstances). +.pp +a filesystem may also fill in fields that the caller didn't ask for if it has +values for them available and the information is available at no extra cost. +if this happens, the corresponding bits will be set in +.ir stx_mask . +.pp +.\" background: inode attributes are modified with i_mutex held, but +.\" read by stat() without taking the mutex. +.ir note : +for performance and simplicity reasons, different fields in the +.i statx +structure may contain state information from different moments +during the execution of the system call. +for example, if +.ir stx_mode +or +.ir stx_uid +is changed by another process by calling +.br chmod (2) +or +.br chown (2), +.br stat () +might return the old +.i stx_mode +together with the new +.ir stx_uid , +or the old +.i stx_uid +together with the new +.ir stx_mode . +.pp +apart from +.i stx_mask +(which is described above), the fields in the +.i statx +structure are: +.tp +.i stx_blksize +the "preferred" block size for efficient filesystem i/o. +(writing to a file in +smaller chunks may cause an inefficient read-modify-rewrite.) +.tp +.i stx_attributes +further status information about the file (see below for more information). +.tp +.i stx_nlink +the number of hard links on a file. +.tp +.i stx_uid +this field contains the user id of the owner of the file. +.tp +.i stx_gid +this field contains the id of the group owner of the file. +.tp +.i stx_mode +the file type and mode. +see +.br inode (7) +for details. +.tp +.i stx_ino +the inode number of the file. +.tp +.i stx_size +the size of the file (if it is a regular file or a symbolic link) in bytes. +the size of a symbolic link is the length of the pathname it contains, +without a terminating null byte. +.tp +.i stx_blocks +the number of blocks allocated to the file on the medium, in 512-byte units. +(this may be smaller than +.ir stx_size /512 +when the file has holes.) +.tp +.i stx_attributes_mask +a mask indicating which bits in +.ir stx_attributes +are supported by the vfs and the filesystem. +.tp +.i stx_atime +the file's last access timestamp. +.tp +.i stx_btime +the file's creation timestamp. +.tp +.i stx_ctime +the file's last status change timestamp. +.tp +.i stx_mtime +the file's last modification timestamp. +.tp +.ir stx_dev_major " and " stx_dev_minor +the device on which this file (inode) resides. +.tp +.ir stx_rdev_major " and " stx_rdev_minor +the device that this file (inode) represents if the file is of block or +character device type. +.tp +.i stx_mnt_id +.\" commit fa2fcf4f1df1559a0a4ee0f46915b496cc2ebf60 +the mount id of the mount containing the file. +this is the same number reported by +.br name_to_handle_at (2) +and corresponds to the number in the first field in one of the records in +.ir /proc/self/mountinfo . +.pp +for further information on the above fields, see +.br inode (7). +.\" +.ss file attributes +the +.i stx_attributes +field contains a set of ored flags that indicate additional attributes +of the file. +note that any attribute that is not indicated as supported by +.i stx_attributes_mask +has no usable value here. +the bits in +.i stx_attributes_mask +correspond bit-by-bit to +.ir stx_attributes . +.pp +the flags are as follows: +.tp +.b statx_attr_compressed +the file is compressed by the filesystem and may take extra resources +to access. +.tp +.b statx_attr_immutable +the file cannot be modified: it cannot be deleted or renamed, +no hard links can be created to this file and no data can be written to it. +see +.br chattr (1). +.tp +.b statx_attr_append +the file can only be opened in append mode for writing. +random access writing +is not permitted. +see +.br chattr (1). +.tp +.b statx_attr_nodump +file is not a candidate for backup when a backup program such as +.br dump (8) +is run. +see +.br chattr (1). +.tp +.b statx_attr_encrypted +a key is required for the file to be encrypted by the filesystem. +.tp +.br statx_attr_verity " (since linux 5.5)" +.\" commit 3ad2522c64cff1f5aebb987b00683268f0cc7c29 +the file has fs-verity enabled. +it cannot be written to, and all reads from it will be verified +against a cryptographic hash that covers the +entire file (e.g., via a merkle tree). +.tp +.br statx_attr_dax " (since linux 5.8)" +the file is in the dax (cpu direct access) state. +dax state attempts to +minimize software cache effects for both i/o and memory mappings of this file. +it requires a file system which has been configured to support dax. +.ip +dax generally assumes all accesses are via cpu load / store instructions +which can minimize overhead for small accesses, +but may adversely affect cpu utilization for large transfers. +.ip +file i/o is done directly to/from user-space buffers and memory mapped i/o may +be performed with direct memory mappings that bypass the kernel page cache. +.ip +while the dax property tends to result in data being transferred synchronously, +it does not give the same guarantees as the +.b o_sync +flag (see +.br open (2)), +where data and the necessary metadata are transferred together. +.ip +a dax file may support being mapped with the +.b map_sync +flag, which enables a +program to use cpu cache flush instructions to persist cpu store operations +without an explicit +.br fsync (2). +see +.br mmap (2) +for more information. +.sh return value +on success, zero is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eacces +search permission is denied for one of the directories +in the path prefix of +.ir pathname . +(see also +.br path_resolution (7).) +.tp +.b ebadf +.i pathname +is relative but +.i dirfd +is neither +.b at_fdcwd +nor a valid file descriptor. +.tp +.b efault +.i pathname +or +.i statxbuf +is null or points to a location outside the process's +accessible address space. +.tp +.b einval +invalid flag specified in +.ir flags . +.tp +.b einval +reserved flag specified in +.ir mask . +(currently, there is one such flag, designated by the constant +.br statx__reserved , +with the value 0x80000000u.) +.tp +.b eloop +too many symbolic links encountered while traversing the pathname. +.tp +.b enametoolong +.i pathname +is too long. +.tp +.b enoent +a component of +.i pathname +does not exist, or +.i pathname +is an empty string and +.b at_empty_path +was not specified in +.ir flags . +.tp +.b enomem +out of memory (i.e., kernel memory). +.tp +.b enotdir +a component of the path prefix of +.i pathname +is not a directory or +.i pathname +is relative and +.i dirfd +is a file descriptor referring to a file other than a directory. +.sh versions +.br statx () +was added to linux in kernel 4.11; library support was added in glibc 2.28. +.sh conforming to +.br statx () +is linux-specific. +.sh see also +.br ls (1), +.br stat (1), +.br access (2), +.br chmod (2), +.br chown (2), +.br name_to_handle_at (2), +.br readlink (2), +.br stat (2), +.br utime (2), +.br proc (5), +.br capabilities (7), +.br inode (7), +.br symlink (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/getrpcent.3 + +.so man3/cpu_set.3 + +.\" this man page is copyright (c) 1999 andi kleen . +.\" +.\" %%%license_start(verbatim_one_para) +.\" permission is granted to distribute possibly modified copies +.\" of this page provided the header is included verbatim, +.\" and in case of nontrivial modification author and date +.\" of the modification is added to the header. +.\" %%%license_end +.\" +.\" $id: icmp.7,v 1.6 2000/08/14 08:03:45 ak exp $ +.\" +.th icmp 7 2017-11-26 "linux" "linux programmer's manual" +.sh name +icmp \- linux ipv4 icmp kernel module. +.sh description +this kernel protocol module implements the internet control +message protocol defined in rfc\ 792. +it is used to signal error conditions and for diagnosis. +the user doesn't interact directly with this module; +instead it communicates with the other protocols in the kernel +and these pass the icmp errors to the application layers. +the kernel icmp module also answers icmp requests. +.pp +a user protocol may receive icmp packets for all local sockets by opening +a raw socket with the protocol +.br ipproto_icmp . +see +.br raw (7) +for more information. +the types of icmp packets passed to the socket can be filtered using the +.b icmp_filter +socket option. +icmp packets are always processed by the kernel too, even +when passed to a user socket. +.pp +linux limits the rate of icmp error packets to each destination. +.b icmp_redirect +and +.b icmp_dest_unreach +are also limited by the destination route of the incoming packets. +.ss /proc interfaces +icmp supports a set of +.i /proc +interfaces to configure some global ip parameters. +the parameters can be accessed by reading or writing files in the directory +.ir /proc/sys/net/ipv4/ . +most of these parameters are rate limitations for specific icmp types. +linux 2.2 uses a token bucket filter to limit icmps. +.\" fixme . better description needed +the value is the timeout in jiffies until the token bucket filter is +cleared after a burst. +a jiffy is a system dependent unit, usually 10ms on i386 and +about 1ms on alpha and ia64. +.tp +.ir icmp_destunreach_rate " (linux 2.2 to 2.4.9)" +.\" precisely: from 2.1.102 +maximum rate to send icmp destination unreachable packets. +this limits the rate at which packets are sent to any individual +route or destination. +the limit does not affect sending of +.b icmp_frag_needed +packets needed for path mtu discovery. +.tp +.ir icmp_echo_ignore_all " (since linux 2.2)" +.\" precisely: 2.1.68 +if this value is nonzero, linux will ignore all +.b icmp_echo +requests. +.tp +.ir icmp_echo_ignore_broadcasts " (since linux 2.2)" +.\" precisely: from 2.1.68 +if this value is nonzero, linux will ignore all +.b icmp_echo +packets sent to broadcast addresses. +.tp +.ir icmp_echoreply_rate " (linux 2.2 to 2.4.9)" +.\" precisely: from 2.1.102 +maximum rate for sending +.b icmp_echoreply +packets in response to +.b icmp_echorequest +packets. +.tp +.ir icmp_errors_use_inbound_ifaddr " (boolean; default: disabled; since linux 2.6.12)" +.\" the following taken from 2.6.28-rc4 documentation/networking/ip-sysctl.txt +if disabled, icmp error messages are sent with the primary address of +the exiting interface. +.ip +if enabled, the message will be sent with the primary address of +the interface that received the packet that caused the icmp error. +this is the behavior that many network administrators will expect from +a router. +and it can make debugging complicated network layouts much easier. +.ip +note that if no primary address exists for the interface selected, +then the primary address of the first non-loopback interface that +has one will be used regardless of this setting. +.tp +.ir icmp_ignore_bogus_error_responses " (boolean; default: disabled; since linux 2.2)" +.\" precisely: since 2.1.32 +.\" the following taken from 2.6.28-rc4 documentation/networking/ip-sysctl.txt +some routers violate rfc1122 by sending bogus responses to broadcast frames. +such violations are normally logged via a kernel warning. +if this parameter is enabled, the kernel will not give such warnings, +which will avoid log file clutter. +.tp +.ir icmp_paramprob_rate " (linux 2.2 to 2.4.9)" +.\" precisely: from 2.1.102 +maximum rate for sending +.b icmp_parameterprob +packets. +these packets are sent when a packet arrives with an invalid ip header. +.tp +.ir icmp_ratelimit " (integer; default: 1000; since linux 2.4.10)" +.\" the following taken from 2.6.28-rc4 documentation/networking/ip-sysctl.txt +limit the maximum rates for sending icmp packets whose type matches +.ir icmp_ratemask +(see below) to specific targets. +0 to disable any limiting, +otherwise the minimum space between responses in milliseconds. +.tp +.ir icmp_ratemask " (integer; default: see below; since linux 2.4.10)" +.\" the following taken from 2.6.28-rc4 documentation/networking/ip-sysctl.txt +mask made of icmp types for which rates are being limited. +.ip +significant bits: ihgfedcba9876543210 +.br +default mask: 0000001100000011000 (0x1818) +.ip +bit definitions (see the linux kernel source file +.ir include/linux/icmp.h ): +.rs 12 +.ts +l l. +0 echo reply +3 destination unreachable * +4 source quench * +5 redirect +8 echo request +b time exceeded * +c parameter problem * +d timestamp request +e timestamp reply +f info request +g info reply +h address mask request +i address mask reply +.te +.re +.pp +the bits marked with an asterisk are rate limited by default +(see the default mask above). +.tp +.ir icmp_timeexceed_rate " (linux 2.2 to 2.4.9)" +maximum rate for sending +.b icmp_time_exceeded +packets. +these packets are +sent to prevent loops when a packet has crossed too many hops. +.tp +.ir ping_group_range " (two integers; default: see below; since linux 2.6.39)" +range of the group ids (minimum and maximum group ids, inclusive) +that are allowed to create icmp echo sockets. +the default is "1 0", which +means no group is allowed to create icmp echo sockets. +.sh versions +support for the +.b icmp_address +request was removed in 2.2. +.pp +support for +.b icmp_source_quench +was removed in linux 2.2. +.sh notes +as many other implementations don't support +.b ipproto_icmp +raw sockets, this feature +should not be relied on in portable programs. +.\" not really true atm +.\" .pp +.\" linux icmp should be compliant to rfc 1122. +.pp +.b icmp_redirect +packets are not sent when linux is not acting as a router. +they are also accepted only from the old gateway defined in the +routing table and the redirect routes are expired after some time. +.pp +the 64-bit timestamp returned by +.b icmp_timestamp +is in milliseconds since the epoch, 1970-01-01 00:00:00 +0000 (utc). +.pp +linux icmp internally uses a raw socket to send icmps. +this raw socket may appear in +.br netstat (8) +output with a zero inode. +.sh see also +.br ip (7), +.br rdisc (8) +.pp +rfc\ 792 for a description of the icmp protocol. +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/epoll_wait.2 + +.\" copyright (c) 2006, 2014 michael kerrisk +.\" copyright (c) 2014 heinrich schuchardt +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th inotify 7 2021-03-22 "linux" "linux programmer's manual" +.sh name +inotify \- monitoring filesystem events +.sh description +the +.i inotify +api provides a mechanism for monitoring filesystem events. +inotify can be used to monitor individual files, +or to monitor directories. +when a directory is monitored, inotify will return events +for the directory itself, and for files inside the directory. +.pp +the following system calls are used with this api: +.ip * 3 +.br inotify_init (2) +creates an inotify instance and returns a file descriptor +referring to the inotify instance. +the more recent +.br inotify_init1 (2) +is like +.br inotify_init (2), +but has a +.ir flags +argument that provides access to some extra functionality. +.ip * +.br inotify_add_watch (2) +manipulates the "watch list" associated with an inotify instance. +each item ("watch") in the watch list specifies the pathname of +a file or directory, +along with some set of events that the kernel should monitor for the +file referred to by that pathname. +.br inotify_add_watch (2) +either creates a new watch item, or modifies an existing watch. +each watch has a unique "watch descriptor", an integer +returned by +.br inotify_add_watch (2) +when the watch is created. +.ip * +when events occur for monitored files and directories, +those events are made available to the application as structured data that +can be read from the inotify file descriptor using +.br read (2) +(see below). +.ip * +.br inotify_rm_watch (2) +removes an item from an inotify watch list. +.ip * +when all file descriptors referring to an inotify +instance have been closed (using +.br close (2)), +the underlying object and its resources are +freed for reuse by the kernel; +all associated watches are automatically freed. +.pp +with careful programming, +an application can use inotify to efficiently monitor and cache +the state of a set of filesystem objects. +however, robust applications should allow for the fact that bugs +in the monitoring logic or races of the kind described below +may leave the cache inconsistent with the filesystem state. +it is probably wise to do some consistency checking, +and rebuild the cache when inconsistencies are detected. +.ss reading events from an inotify file descriptor +to determine what events have occurred, an application +.br read (2)s +from the inotify file descriptor. +if no events have so far occurred, then, +assuming a blocking file descriptor, +.br read (2) +will block until at least one event occurs +(unless interrupted by a signal, +in which case the call fails with the error +.br eintr ; +see +.br signal (7)). +.pp +each successful +.br read (2) +returns a buffer containing one or more of the following structures: +.pp +.in +4n +.ex +struct inotify_event { + int wd; /* watch descriptor */ +.\" fixme . the type of the 'wd' field should probably be "int32_t". +.\" i submitted a patch to fix this. see the lkml thread +.\" "[patch] fix type errors in inotify interfaces", 18 nov 2008 +.\" glibc bug filed: http://sources.redhat.com/bugzilla/show_bug.cgi?id=7040 + uint32_t mask; /* mask describing event */ + uint32_t cookie; /* unique cookie associating related + events (for rename(2)) */ + uint32_t len; /* size of \finame\fp field */ + char name[]; /* optional null\-terminated name */ +}; +.ee +.in +.pp +.i wd +identifies the watch for which this event occurs. +it is one of the watch descriptors returned by a previous call to +.br inotify_add_watch (2). +.pp +.i mask +contains bits that describe the event that occurred (see below). +.pp +.i cookie +is a unique integer that connects related events. +currently, this is used only for rename events, and +allows the resulting pair of +.b in_moved_from +and +.b in_moved_to +events to be connected by the application. +for all other event types, +.i cookie +is set to 0. +.pp +the +.i name +field is present only when an event is returned +for a file inside a watched directory; +it identifies the filename within the watched directory. +this filename is null-terminated, +and may include further null bytes (\(aq\e0\(aq) to align subsequent reads to a +suitable address boundary. +.pp +the +.i len +field counts all of the bytes in +.ir name , +including the null bytes; +the length of each +.i inotify_event +structure is thus +.ir "sizeof(struct inotify_event)+len" . +.pp +the behavior when the buffer given to +.br read (2) +is too small to return information about the next event depends +on the kernel version: in kernels before 2.6.21, +.br read (2) +returns 0; since kernel 2.6.21, +.br read (2) +fails with the error +.br einval . +specifying a buffer of size +.pp + sizeof(struct inotify_event) + name_max + 1 +.pp +will be sufficient to read at least one event. +.ss inotify events +the +.br inotify_add_watch (2) +.i mask +argument and the +.i mask +field of the +.i inotify_event +structure returned when +.br read (2)ing +an inotify file descriptor are both bit masks identifying +inotify events. +the following bits can be specified in +.i mask +when calling +.br inotify_add_watch (2) +and may be returned in the +.i mask +field returned by +.br read (2): +.rs 4 +.tp +.br in_access " (+)" +file was accessed (e.g., +.br read (2), +.br execve (2)). +.tp +.br in_attrib " (*)" +metadata changed\(emfor example, permissions (e.g., +.br chmod (2)), +timestamps (e.g., +.br utimensat (2)), +extended attributes +.rb ( setxattr (2)), +link count (since linux 2.6.25; e.g., +.\" fixme . +.\" events do not occur for link count changes on a file inside a monitored +.\" directory. this differs from other metadata changes for files inside +.\" a monitored directory. +for the target of +.br link (2) +and for +.br unlink (2)), +and user/group id (e.g., +.br chown (2)). +.tp +.br in_close_write " (+)" +file opened for writing was closed. +.tp +.br in_close_nowrite " (*)" +file or directory not opened for writing was closed. +.tp +.br in_create " (+)" +file/directory created in watched directory (e.g., +.br open (2) +.br o_creat , +.br mkdir (2), +.br link (2), +.br symlink (2), +.br bind (2) +on a unix domain socket). +.tp +.br in_delete " (+)" +file/directory deleted from watched directory. +.tp +.b in_delete_self +watched file/directory was itself deleted. +(this event also occurs if an object is moved to another filesystem, +since +.br mv (1) +in effect copies the file to the other filesystem and +then deletes it from the original filesystem.) +in addition, an +.b in_ignored +event will subsequently be generated for the watch descriptor. +.tp +.br in_modify " (+)" +file was modified (e.g., +.br write (2), +.br truncate (2)). +.tp +.b in_move_self +watched file/directory was itself moved. +.tp +.br in_moved_from " (+)" +generated for the directory containing the old filename +when a file is renamed. +.tp +.br in_moved_to " (+)" +generated for the directory containing the new filename +when a file is renamed. +.tp +.br in_open " (*)" +file or directory was opened. +.re +.pp +inotify monitoring is inode-based: when monitoring a file +(but not when monitoring the directory containing a file), +an event can be generated for activity on any link to the file +(in the same or a different directory). +.pp +when monitoring a directory: +.ip * 3 +the events marked above with an asterisk (*) can occur both +for the directory itself and for objects inside the directory; and +.ip * +the events marked with a plus sign (+) occur only for objects +inside the directory (not for the directory itself). +.pp +.ir note : +when monitoring a directory, +events are not generated for the files inside the directory +when the events are performed via a pathname (i.e., a link) +that lies outside the monitored directory. +.pp +when events are generated for objects inside a watched directory, the +.i name +field in the returned +.i inotify_event +structure identifies the name of the file within the directory. +.pp +the +.b in_all_events +macro is defined as a bit mask of all of the above events. +this macro can be used as the +.i mask +argument when calling +.br inotify_add_watch (2). +.pp +two additional convenience macros are defined: +.rs 4 +.tp +.br in_move +equates to +.br "in_moved_from | in_moved_to" . +.tp +.br in_close +equates to +.br "in_close_write | in_close_nowrite" . +.re +.pp +the following further bits can be specified in +.i mask +when calling +.br inotify_add_watch (2): +.rs 4 +.tp +.br in_dont_follow " (since linux 2.6.15)" +don't dereference +.i pathname +if it is a symbolic link. +.tp +.br in_excl_unlink " (since linux 2.6.36)" +.\" commit 8c1934c8d70b22ca8333b216aec6c7d09fdbd6a6 +by default, when watching events on the children of a directory, +events are generated for children even after they have been unlinked +from the directory. +this can result in large numbers of uninteresting events for +some applications (e.g., if watching +.ir /tmp , +in which many applications create temporary files whose +names are immediately unlinked). +specifying +.b in_excl_unlink +changes the default behavior, +so that events are not generated for children after +they have been unlinked from the watched directory. +.tp +.b in_mask_add +if a watch instance already exists for the filesystem object corresponding to +.ir pathname , +add (or) the events in +.i mask +to the watch mask (instead of replacing the mask); +the error +.b einval +results if +.b in_mask_create +is also specified. +.tp +.b in_oneshot +monitor the filesystem object corresponding to +.i pathname +for one event, then remove from +watch list. +.tp +.br in_onlydir " (since linux 2.6.15)" +watch +.i pathname +only if it is a directory; +the error +.b enotdir +results if +.i pathname +is not a directory. +using this flag provides an application with a race-free way of +ensuring that the monitored object is a directory. +.tp +.br in_mask_create " (since linux 4.18)" +watch +.i pathname +only if it does not already have a watch associated with it; +the error +.b eexist +results if +.i pathname +is already being watched. +.ip +using this flag provides an application with a way of ensuring +that new watches do not modify existing ones. +this is useful because multiple paths may refer to the same inode, +and multiple calls to +.br inotify_add_watch (2) +without this flag may clobber existing watch masks. +.re +.pp +the following bits may be set in the +.i mask +field returned by +.br read (2): +.rs 4 +.tp +.b in_ignored +watch was removed explicitly +.rb ( inotify_rm_watch (2)) +or automatically (file was deleted, or filesystem was unmounted). +see also bugs. +.tp +.b in_isdir +subject of this event is a directory. +.tp +.b in_q_overflow +event queue overflowed +.ri ( wd +is \-1 for this event). +.tp +.b in_unmount +filesystem containing watched object was unmounted. +in addition, an +.b in_ignored +event will subsequently be generated for the watch descriptor. +.re +.ss examples +suppose an application is watching the directory +.i dir +and the file +.ir dir/myfile +for all events. +the examples below show some events that will be generated +for these two objects. +.rs 4 +.tp +fd = open("dir/myfile", o_rdwr); +generates +.b in_open +events for both +.i dir +and +.ir dir/myfile . +.tp +read(fd, buf, count); +generates +.b in_access +events for both +.i dir +and +.ir dir/myfile . +.tp +write(fd, buf, count); +generates +.b in_modify +events for both +.i dir +and +.ir dir/myfile . +.tp +fchmod(fd, mode); +generates +.b in_attrib +events for both +.i dir +and +.ir dir/myfile . +.tp +close(fd); +generates +.b in_close_write +events for both +.i dir +and +.ir dir/myfile . +.re +.pp +suppose an application is watching the directories +.i dir1 +and +.ir dir2 , +and the file +.ir dir1/myfile . +the following examples show some events that may be generated. +.rs 4 +.tp +link("dir1/myfile", "dir2/new"); +generates an +.b in_attrib +event for +.ir myfile +and an +.b in_create +event for +.ir dir2 . +.tp +rename("dir1/myfile", "dir2/myfile"); +generates an +.b in_moved_from +event for +.ir dir1 , +an +.b in_moved_to +event for +.ir dir2 , +and an +.b in_move_self +event for +.ir myfile . +the +.b in_moved_from +and +.b in_moved_to +events will have the same +.i cookie +value. +.re +.pp +suppose that +.ir dir1/xx +and +.ir dir2/yy +are (the only) links to the same file, and an application is watching +.ir dir1 , +.ir dir2 , +.ir dir1/xx , +and +.ir dir2/yy . +executing the following calls in the order given below will generate +the following events: +.rs 4 +.tp +unlink("dir2/yy"); +generates an +.br in_attrib +event for +.ir xx +(because its link count changes) +and an +.b in_delete +event for +.ir dir2 . +.tp +unlink("dir1/xx"); +generates +.br in_attrib , +.br in_delete_self , +and +.br in_ignored +events for +.ir xx , +and an +.br in_delete +event for +.ir dir1 . +.re +.pp +suppose an application is watching the directory +.ir dir +and (the empty) directory +.ir dir/subdir . +the following examples show some events that may be generated. +.rs 4 +.tp +mkdir("dir/new", mode); +generates an +.b "in_create | in_isdir" +event for +.ir dir . +.tp +rmdir("dir/subdir"); +generates +.b in_delete_self +and +.b in_ignored +events for +.ir subdir , +and an +.b "in_delete | in_isdir" +event for +.ir dir . +.re +.ss /proc interfaces +the following interfaces can be used to limit the amount of +kernel memory consumed by inotify: +.tp +.i /proc/sys/fs/inotify/max_queued_events +the value in this file is used when an application calls +.br inotify_init (2) +to set an upper limit on the number of events that can be +queued to the corresponding inotify instance. +events in excess of this limit are dropped, but an +.b in_q_overflow +event is always generated. +.tp +.i /proc/sys/fs/inotify/max_user_instances +this specifies an upper limit on the number of inotify instances +that can be created per real user id. +.tp +.i /proc/sys/fs/inotify/max_user_watches +this specifies an upper limit on the number of watches +that can be created per real user id. +.sh versions +inotify was merged into the 2.6.13 linux kernel. +the required library interfaces were added to glibc in version 2.4. +.rb ( in_dont_follow , +.br in_mask_add , +and +.b in_onlydir +were added in glibc version 2.5.) +.sh conforming to +the inotify api is linux-specific. +.sh notes +inotify file descriptors can be monitored using +.br select (2), +.br poll (2), +and +.br epoll (7). +when an event is available, the file descriptor indicates as readable. +.pp +since linux 2.6.25, +signal-driven i/o notification is available for inotify file descriptors; +see the discussion of +.b f_setfl +(for setting the +.b o_async +flag), +.br f_setown , +and +.b f_setsig +in +.br fcntl (2). +the +.i siginfo_t +structure (described in +.br sigaction (2)) +that is passed to the signal handler has the following fields set: +.ir si_fd +is set to the inotify file descriptor number; +.ir si_signo +is set to the signal number; +.ir si_code +is set to +.br poll_in ; +and +.b pollin +is set in +.ir si_band . +.pp +if successive output inotify events produced on the +inotify file descriptor are identical (same +.ir wd , +.ir mask , +.ir cookie , +and +.ir name ), +then they are coalesced into a single event if the +older event has not yet been read (but see bugs). +this reduces the amount of kernel memory required for the event queue, +but also means that an application can't use inotify to reliably count +file events. +.pp +the events returned by reading from an inotify file descriptor +form an ordered queue. +thus, for example, it is guaranteed that when renaming from +one directory to another, events will be produced in the +correct order on the inotify file descriptor. +.pp +the set of watch descriptors that is being monitored via +an inotify file descriptor can be viewed via the entry for +the inotify file descriptor in the process's +.ir /proc/[pid]/fdinfo +directory. +see +.br proc (5) +for further details. +the +.b fionread +.br ioctl (2) +returns the number of bytes available to read from an +inotify file descriptor. +.ss limitations and caveats +the inotify api provides no information about the user or process that +triggered the inotify event. +in particular, there is no easy +way for a process that is monitoring events via inotify +to distinguish events that it triggers +itself from those that are triggered by other processes. +.pp +inotify reports only events that a user-space program triggers through +the filesystem api. +as a result, it does not catch remote events that occur +on network filesystems. +(applications must fall back to polling the filesystem +to catch such events.) +furthermore, various pseudo-filesystems such as +.ir /proc , +.ir /sys , +and +.ir /dev/pts +are not monitorable with inotify. +.pp +the inotify api does not report file accesses and modifications that +may occur because of +.br mmap (2), +.br msync (2), +and +.br munmap (2). +.pp +the inotify api identifies affected files by filename. +however, by the time an application processes an inotify event, +the filename may already have been deleted or renamed. +.pp +the inotify api identifies events via watch descriptors. +it is the application's responsibility to cache a mapping +(if one is needed) between watch descriptors and pathnames. +be aware that directory renamings may affect multiple cached pathnames. +.pp +inotify monitoring of directories is not recursive: +to monitor subdirectories under a directory, +additional watches must be created. +this can take a significant amount time for large directory trees. +.pp +if monitoring an entire directory subtree, +and a new subdirectory is created in that tree or an existing directory +is renamed into that tree, +be aware that by the time you create a watch for the new subdirectory, +new files (and subdirectories) may already exist inside the subdirectory. +therefore, you may want to scan the contents of the subdirectory +immediately after adding the watch (and, if desired, +recursively add watches for any subdirectories that it contains). +.pp +note that the event queue can overflow. +in this case, events are lost. +robust applications should handle the possibility of +lost events gracefully. +for example, it may be necessary to rebuild part or all of +the application cache. +(one simple, but possibly expensive, +approach is to close the inotify file descriptor, empty the cache, +create a new inotify file descriptor, +and then re-create watches and cache entries +for the objects to be monitored.) +.pp +if a filesystem is mounted on top of a monitored directory, +no event is generated, and no events are generated +for objects immediately under the new mount point. +if the filesystem is subsequently unmounted, +events will subsequently be generated for the directory and +the objects it contains. +.\" +.ss dealing with rename() events +as noted above, the +.b in_moved_from +and +.b in_moved_to +event pair that is generated by +.br rename (2) +can be matched up via their shared cookie value. +however, the task of matching has some challenges. +.pp +these two events are usually consecutive in the event stream available +when reading from the inotify file descriptor. +however, this is not guaranteed. +if multiple processes are triggering events for monitored objects, +then (on rare occasions) an arbitrary number of +other events may appear between the +.b in_moved_from +and +.b in_moved_to +events. +furthermore, it is not guaranteed that the event pair is atomically +inserted into the queue: there may be a brief interval where the +.b in_moved_from +has appeared, but the +.b in_moved_to +has not. +.pp +matching up the +.b in_moved_from +and +.b in_moved_to +event pair generated by +.br rename (2) +is thus inherently racy. +(don't forget that if an object is renamed outside of a monitored directory, +there may not even be an +.br in_moved_to +event.) +heuristic approaches (e.g., assume the events are always consecutive) +can be used to ensure a match in most cases, +but will inevitably miss some cases, +causing the application to perceive the +.b in_moved_from +and +.b in_moved_to +events as being unrelated. +if watch descriptors are destroyed and re-created as a result, +then those watch descriptors will be inconsistent with +the watch descriptors in any pending events. +(re-creating the inotify file descriptor and rebuilding the cache may +be useful to deal with this scenario.) +.pp +applications should also allow for the possibility that the +.b in_moved_from +event was the last event that could fit in the buffer +returned by the current call to +.br read (2), +and the accompanying +.b in_moved_to +event might be fetched only on the next +.br read (2), +which should be done with a (small) timeout to allow for the fact that +insertion of the +.br in_moved_from + in_moved_to +event pair is not atomic, +and also the possibility that there may not be any +.b in_moved_to +event. +.sh bugs +before linux 3.19, +.br fallocate (2) +did not create any inotify events. +since linux 3.19, +.\" commit 820c12d5d6c0890bc93dd63893924a13041fdc35 +calls to +.br fallocate (2) +generate +.b in_modify +events. +.pp +.\" fixme . kernel commit 611da04f7a31b2208e838be55a42c7a1310ae321 +.\" implies that unmount events were buggy 2.6.11 to 2.6.36 +.\" +in kernels before 2.6.16, the +.b in_oneshot +.i mask +flag does not work. +.pp +as originally designed and implemented, the +.b in_oneshot +flag did not cause an +.b in_ignored +event to be generated when the watch was dropped after one event. +however, as an unintended effect of other changes, +since linux 2.6.36, an +.b in_ignored +event is generated in this case. +.pp +before kernel 2.6.25, +.\" commit 1c17d18e3775485bf1e0ce79575eb637a94494a2 +the kernel code that was intended to coalesce successive identical events +(i.e., the two most recent events could potentially be coalesced +if the older had not yet been read) +instead checked if the most recent event could be coalesced with the +.i oldest +unread event. +.pp +when a watch descriptor is removed by calling +.br inotify_rm_watch (2) +(or because a watch file is deleted or the filesystem +that contains it is unmounted), +any pending unread events for that watch descriptor remain available to read. +as watch descriptors are subsequently allocated with +.br inotify_add_watch (2), +the kernel cycles through the range of possible watch descriptors (0 to +.br int_max ) +incrementally. +when allocating a free watch descriptor, no check is made to see whether that +watch descriptor number has any pending unread events in the inotify queue. +thus, it can happen that a watch descriptor is reallocated even +when pending unread events exist for a previous incarnation of +that watch descriptor number, with the result that the application +might then read those events and interpret them as belonging to +the file associated with the newly recycled watch descriptor. +in practice, the likelihood of hitting this bug may be extremely low, +since it requires that an application cycle through +.b int_max +watch descriptors, +release a watch descriptor while leaving unread events for that +watch descriptor in the queue, +and then recycle that watch descriptor. +for this reason, and because there have been no reports +of the bug occurring in real-world applications, +as of linux 3.15, +.\" fixme . https://bugzilla.kernel.org/show_bug.cgi?id=77111 +no kernel changes have yet been made to eliminate this possible bug. +.sh examples +the following program demonstrates the usage of the inotify api. +it marks the directories passed as a command-line arguments +and waits for events of type +.br in_open , +.br in_close_nowrite , +and +.br in_close_write . +.pp +the following output was recorded while editing the file +.i /home/user/temp/foo +and listing directory +.ir /tmp . +before the file and the directory were opened, +.b in_open +events occurred. +after the file was closed, an +.b in_close_write +event occurred. +after the directory was closed, an +.b in_close_nowrite +event occurred. +execution of the program ended when the user pressed the enter key. +.ss example output +.in +4n +.ex +$ \fb./a.out /tmp /home/user/temp\fp +press enter key to terminate. +listening for events. +in_open: /home/user/temp/foo [file] +in_close_write: /home/user/temp/foo [file] +in_open: /tmp/ [directory] +in_close_nowrite: /tmp/ [directory] + +listening for events stopped. +.ee +.in +.ss program source +\& +.ex +#include +#include +#include +#include +#include +#include +#include + +/* read all available inotify events from the file descriptor \(aqfd\(aq. + wd is the table of watch descriptors for the directories in argv. + argc is the length of wd and argv. + argv is the list of watched directories. + entry 0 of wd and argv is unused. */ + +static void +handle_events(int fd, int *wd, int argc, char* argv[]) +{ + /* some systems cannot read integer variables if they are not + properly aligned. on other systems, incorrect alignment may + decrease performance. hence, the buffer used for reading from + the inotify file descriptor should have the same alignment as + struct inotify_event. */ + + char buf[4096] + __attribute__ ((aligned(__alignof__(struct inotify_event)))); + const struct inotify_event *event; + ssize_t len; + + /* loop while events can be read from inotify file descriptor. */ + + for (;;) { + + /* read some events. */ + + len = read(fd, buf, sizeof(buf)); + if (len == \-1 && errno != eagain) { + perror("read"); + exit(exit_failure); + } + + /* if the nonblocking read() found no events to read, then + it returns \-1 with errno set to eagain. in that case, + we exit the loop. */ + + if (len <= 0) + break; + + /* loop over all events in the buffer. */ + + for (char *ptr = buf; ptr < buf + len; + ptr += sizeof(struct inotify_event) + event\->len) { + + event = (const struct inotify_event *) ptr; + + /* print event type. */ + + if (event\->mask & in_open) + printf("in_open: "); + if (event\->mask & in_close_nowrite) + printf("in_close_nowrite: "); + if (event\->mask & in_close_write) + printf("in_close_write: "); + + /* print the name of the watched directory. */ + + for (int i = 1; i < argc; ++i) { + if (wd[i] == event\->wd) { + printf("%s/", argv[i]); + break; + } + } + + /* print the name of the file. */ + + if (event\->len) + printf("%s", event\->name); + + /* print type of filesystem object. */ + + if (event\->mask & in_isdir) + printf(" [directory]\en"); + else + printf(" [file]\en"); + } + } +} + +int +main(int argc, char* argv[]) +{ + char buf; + int fd, i, poll_num; + int *wd; + nfds_t nfds; + struct pollfd fds[2]; + + if (argc < 2) { + printf("usage: %s path [path ...]\en", argv[0]); + exit(exit_failure); + } + + printf("press enter key to terminate.\en"); + + /* create the file descriptor for accessing the inotify api. */ + + fd = inotify_init1(in_nonblock); + if (fd == \-1) { + perror("inotify_init1"); + exit(exit_failure); + } + + /* allocate memory for watch descriptors. */ + + wd = calloc(argc, sizeof(int)); + if (wd == null) { + perror("calloc"); + exit(exit_failure); + } + + /* mark directories for events + \- file was opened + \- file was closed */ + + for (i = 1; i < argc; i++) { + wd[i] = inotify_add_watch(fd, argv[i], + in_open | in_close); + if (wd[i] == \-1) { + fprintf(stderr, "cannot watch \(aq%s\(aq: %s\en", + argv[i], strerror(errno)); + exit(exit_failure); + } + } + + /* prepare for polling. */ + + nfds = 2; + + fds[0].fd = stdin_fileno; /* console input */ + fds[0].events = pollin; + + fds[1].fd = fd; /* inotify input */ + fds[1].events = pollin; + + /* wait for events and/or terminal input. */ + + printf("listening for events.\en"); + while (1) { + poll_num = poll(fds, nfds, \-1); + if (poll_num == \-1) { + if (errno == eintr) + continue; + perror("poll"); + exit(exit_failure); + } + + if (poll_num > 0) { + + if (fds[0].revents & pollin) { + + /* console input is available. empty stdin and quit. */ + + while (read(stdin_fileno, &buf, 1) > 0 && buf != \(aq\en\(aq) + continue; + break; + } + + if (fds[1].revents & pollin) { + + /* inotify events are available. */ + + handle_events(fd, wd, argc, argv); + } + } + } + + printf("listening for events stopped.\en"); + + /* close inotify file descriptor. */ + + close(fd); + + free(wd); + exit(exit_success); +} +.ee +.sh see also +.br inotifywait (1), +.br inotifywatch (1), +.br inotify_add_watch (2), +.br inotify_init (2), +.br inotify_init1 (2), +.br inotify_rm_watch (2), +.br read (2), +.br stat (2), +.br fanotify (7) +.pp +.ir documentation/filesystems/inotify.txt +in the linux kernel source tree +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/cpu_set.3 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" and copyright 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified 1993-07-24 by rik faith (faith@cs.unc.edu) +.\" modified 1995-08-14 by arnt gulbrandsen +.\" modified 2002-07-27 by walter harms +.\" (walter.harms@informatik.uni-oldenburg.de) +.\" +.th log10 3 2021-03-22 "" "linux programmer's manual" +.sh name +log10, log10f, log10l \- base-10 logarithmic function +.sh synopsis +.nf +.b #include +.pp +.bi "double log10(double " x ); +.bi "float log10f(float " x ); +.bi "long double log10l(long double " x ); +.fi +.pp +link with \fi\-lm\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br log10f (), +.br log10l (): +.nf + _isoc99_source || _posix_c_source >= 200112l + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.sh description +these functions return the base 10 logarithm of +.ir x . +.sh return value +on success, these functions return the base 10 logarithm of +.ir x . +.pp +for special cases, including where +.i x +is 0, 1, negative, infinity, or nan, see +.br log (3). +.sh errors +see +.br math_error (7) +for information on how to determine whether an error has occurred +when calling these functions. +.pp +for a discussion of the errors that can occur for these functions, see +.br log (3). +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br log10 (), +.br log10f (), +.br log10l () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.pp +the variant returning +.i double +also conforms to +svr4, 4.3bsd, c89. +.sh see also +.br cbrt (3), +.br clog10 (3), +.br exp10 (3), +.br log (3), +.br log2 (3), +.br sqrt (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/j0.3 + +.so man3/stailq.3 + +.so man7/iso_8859-16.7 + +.\" copyright 1997 nicolás lichtmaier +.\" created wed jul 2 23:27:34 art 1997 +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" added info on availability, aeb, 971207 +.\" added -lutil remark, 030718 +.\" 2008-07-02, mtk, document updwtmpx() +.\" +.th updwtmp 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +updwtmp, logwtmp \- append an entry to the wtmp file +.sh synopsis +.nf +.b #include +.pp +.bi "void updwtmp(const char *" wtmp_file ", const struct utmp *" ut ); +.bi "void logwtmp(const char *" line ", const char *" name \ +", const char *" host ); +.fi +.pp +for +.br logwtmp (), +link with \fi\-lutil\fp. +.sh description +.br updwtmp () +appends the utmp structure +.i ut +to the wtmp file. +.pp +.br logwtmp () +constructs a utmp structure using +.ir line ", " name ", " host , +current time, and current process id. +then it calls +.br updwtmp () +to append the structure to the wtmp file. +.sh files +.tp +.i /var/log/wtmp +database of past user logins +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br updwtmp (), +.br logwtmp () +t} thread safety mt-unsafe sig:alrm timer +.te +.hy +.ad +.sp 1 +.sh conforming to +not in posix.1. +present on solaris, netbsd, and perhaps other systems. +.sh notes +for consistency with the other "utmpx" functions (see +.br getutxent (3)), +glibc provides (since version 2.1): +.pp +.in +4n +.ex +.b #include +.bi "void updwtmpx (const char *" wtmpx_file ", const struct utmpx *" utx ); +.ee +.in +.pp +this function performs the same task as +.br updwtmp (), +but differs in that it takes a +.i utmpx +structure as its last argument. +.sh see also +.br getutxent (3), +.br wtmp (5) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th isatty 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +isatty \- test whether a file descriptor refers to a terminal +.sh synopsis +.nf +.b #include +.pp +.bi "int isatty(int " fd ); +.fi +.sh description +the +.br isatty () +function tests whether +.i fd +is an open file descriptor referring to a terminal. +.sh return value +.br isatty () +returns 1 if +.i fd +is an open file descriptor referring to a terminal; +otherwise 0 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b ebadf +.i fd +is not a valid file descriptor. +.tp +.b enotty +.i fd +refers to a file other than a terminal. +on some older kernels, some types of files +.\" e.g., fifos and pipes on 2.6.32 +resulted in the error +.b einval +in this case (which is a violation of posix, which specifies the error +.br enotty ). +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br isatty () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, svr4, 4.3bsd. +.sh see also +.br fstat (2), +.br ttyname (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/cpu_set.3 + +.so man3/cmsg.3 + +.so man3/envz_add.3 + +.so man3/sigsetops.3 + +.\" copyright (c) 2011, eric biederman +.\" and copyright (c) 2011, 2012, michael kerrisk +.\" +.\" %%%license_start(gplv2_oneline) +.\" licensed under the gplv2 +.\" %%%license_end +.\" +.th setns 2 2020-08-13 "linux" "linux programmer's manual" +.sh name +setns \- reassociate thread with a namespace +.sh synopsis +.nf +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "int setns(int " fd ", int " nstype ); +.fi +.sh description +the +.br setns () +system call allows the calling thread to move into different namespaces. +the +.i fd +argument is one of the following: +.ip \(bu 2 +a file descriptor referring to one of the magic links in a +.i /proc/[pid]/ns/ +directory (or a bind mount to such a link); +.ip \(bu +a pid file descriptor (see +.br pidfd_open (2)). +.pp +the +.i nstype +argument is interpreted differently in each case. +.\" +.ss fd refers to a /proc/[pid]/ns/ link +if +.i fd +refers to a +.i /proc/[pid]/ns/ +link, then +.br setns () +reassociates the calling thread with the namespace associated with that link, +subject to any constraints imposed by the +.i nstype +argument. +in this usage, each call to +.br setns () +changes just one of the caller's namespace memberships. +.pp +the +.i nstype +argument specifies which type of namespace +the calling thread may be reassociated with. +this argument can have +.i one +of the following values: +.tp +.br 0 +allow any type of namespace to be joined. +.tp +.br clone_newcgroup " (since linux 4.6)" +.i fd +must refer to a cgroup namespace. +.tp +.br clone_newipc " (since linux 3.0)" +.i fd +must refer to an ipc namespace. +.tp +.br clone_newnet " (since linux 3.0)" +.i fd +must refer to a network namespace. +.tp +.br clone_newns " (since linux 3.8)" +.i fd +must refer to a mount namespace. +.tp +.br clone_newpid " (since linux 3.8)" +.i fd +must refer to a descendant pid namespace. +.tp +.br clone_newtime " (since linux 5.8)" +.\" commit 76c12881a38aaa83e1eb4ce2fada36c3a732bad4 +.i fd +must refer to a time namespace. +.tp +.br clone_newuser " (since linux 3.8)" +.i fd +must refer to a user namespace. +.tp +.br clone_newuts " (since linux 3.0)" +.i fd +must refer to a uts namespace. +.pp +specifying +.i nstype +as 0 suffices if the caller knows (or does not care) +what type of namespace is referred to by +.ir fd . +specifying a nonzero value for +.i nstype +is useful if the caller does not know what type of namespace is referred to by +.ir fd +and wants to ensure that the namespace is of a particular type. +(the caller might not know the type of the namespace referred to by +.ir fd +if the file descriptor was opened by another process and, for example, +passed to the caller via a unix domain socket.) +.\" +.ss fd is a pid file descriptor +since linux 5.8, +.i fd +may refer to a pid file descriptor obtained from +.br pidfd_open (2) +or +.br clone (2). +in this usage, +.br setns () +atomically moves the calling thread into one or more of the same namespaces +as the thread referred to by +.ir fd . +.pp +the +.ir nstype +argument is a bit mask specified by oring together +.i "one or more" +of the +.br clone_new* +namespace constants listed above. +the caller is moved into each of the target thread's namespaces +that is specified in +.ir nstype ; +the caller's memberships in the remaining namespaces are left unchanged. +.pp +for example, the following code would move the caller into the +same user, network, and uts namespaces as pid 1234, +but would leave the caller's other namespace memberships unchanged: +.pp +.in +4n +.ex +int fd = pidfd_open(1234, 0); +setns(fd, clone_newuser | clone_newnet | clone_newuts); +.ee +.in +.\" +.ss details for specific namespace types +note the following details and restrictions when reassociating with +specific namespace types: +.tp +user namespaces +a process reassociating itself with a user namespace must have the +.b cap_sys_admin +.\" see kernel/user_namespace.c:userns_install() [3.8 source] +capability in the target user namespace. +(this necessarily implies that it is only possible to join +a descendant user namespace.) +upon successfully joining a user namespace, +a process is granted all capabilities in that namespace, +regardless of its user and group ids. +.ip +a multithreaded process may not change user namespace with +.br setns (). +.ip +it is not permitted to use +.br setns () +to reenter the caller's current user namespace. +this prevents a caller that has dropped capabilities from regaining +those capabilities via a call to +.br setns (). +.ip +for security reasons, +.\" commit e66eded8309ebf679d3d3c1f5820d1f2ca332c71 +.\" https://lwn.net/articles/543273/ +a process can't join a new user namespace if it is sharing +filesystem-related attributes +(the attributes whose sharing is controlled by the +.br clone (2) +.b clone_fs +flag) with another process. +.ip +for further details on user namespaces, see +.br user_namespaces (7). +.tp +mount namespaces +changing the mount namespace requires that the caller possess both +.b cap_sys_chroot +and +.br cap_sys_admin +capabilities in its own user namespace and +.br cap_sys_admin +in the user namespace that owns the target mount namespace. +.ip +a process can't join a new mount namespace if it is sharing +filesystem-related attributes +(the attributes whose sharing is controlled by the +.br clone (2) +.b clone_fs +flag) with another process. +.\" above check is in fs/namespace.c:mntns_install() [3.8 source] +.ip +see +.br user_namespaces (7) +for details on the interaction of user namespaces and mount namespaces. +.tp +pid namespaces +in order to reassociate itself with a new pid namespace, +the caller must have the +.b cap_sys_admin +capability both in its own user namespace and in the user namespace +that owns the target pid namespace. +.ip +reassociating the pid namespace has somewhat different +from other namespace types. +reassociating the calling thread with a pid namespace changes only +the pid namespace that subsequently created child processes of +the caller will be placed in; +it does not change the pid namespace of the caller itself. +.ip +reassociating with a pid namespace is allowed only if the target +pid namespace is a descendant (child, grandchild, etc.) +of, or is the same as, the current pid namespace of the caller. +.ip +for further details on pid namespaces, see +.br pid_namespaces (7). +.tp +cgroup namespaces +in order to reassociate itself with a new cgroup namespace, +the caller must have the +.b cap_sys_admin +capability both in its own user namespace and in the user namespace +that owns the target cgroup namespace. +.ip +using +.br setns () +to change the caller's cgroup namespace does not change +the caller's cgroup memberships. +.tp +network, ipc, time, and uts namespaces +in order to reassociate itself with a new network, ipc, time, or uts namespace, +the caller must have the +.b cap_sys_admin +capability both in its own user namespace and in the user namespace +that owns the target namespace. +.sh return value +on success, +.br setns () +returns 0. +on failure, \-1 is returned and +.i errno +is set to indicate the error. +.sh errors +.tp +.b ebadf +.i fd +is not a valid file descriptor. +.tp +.b einval +.i fd +refers to a namespace whose type does not match that specified in +.ir nstype . +.tp +.b einval +there is problem with reassociating +the thread with the specified namespace. +.tp +.\" see kernel/pid_namespace.c::pidns_install() [kernel 3.18 sources] +.b einval +the caller tried to join an ancestor (parent, grandparent, and so on) +pid namespace. +.tp +.b einval +the caller attempted to join the user namespace +in which it is already a member. +.tp +.b einval +.\" commit e66eded8309ebf679d3d3c1f5820d1f2ca332c71 +the caller shares filesystem +.rb ( clone_fs ) +state (in particular, the root directory) +with other processes and tried to join a new user namespace. +.tp +.b einval +.\" see kernel/user_namespace.c::userns_install() [kernel 3.15 sources] +the caller is multithreaded and tried to join a new user namespace. +.tp +.b einval +.i fd +is a pid file descriptor and +.i nstype +is invalid (e.g., it is 0). +.tp +.b enomem +cannot allocate sufficient memory to change the specified namespace. +.tp +.b eperm +the calling thread did not have the required capability +for this operation. +.tp +.b esrch +.i fd +is a pid file descriptor but the process it refers to no longer exists +(i.e., it has terminated and been waited on). +.sh versions +the +.br setns () +system call first appeared in linux in kernel 3.0; +library support was added to glibc in version 2.14. +.sh conforming to +the +.br setns () +system call is linux-specific. +.sh notes +for further information on the +.ir /proc/[pid]/ns/ +magic links, see +.br namespaces (7). +.pp +not all of the attributes that can be shared when +a new thread is created using +.br clone (2) +can be changed using +.br setns (). +.sh examples +the program below takes two or more arguments. +the first argument specifies the pathname of a namespace file in an existing +.i /proc/[pid]/ns/ +directory. +the remaining arguments specify a command and its arguments. +the program opens the namespace file, joins that namespace using +.br setns (), +and executes the specified command inside that namespace. +.pp +the following shell session demonstrates the use of this program +(compiled as a binary named +.ir ns_exec ) +in conjunction with the +.br clone_newuts +example program in the +.br clone (2) +man page (complied as a binary named +.ir newuts ). +.pp +we begin by executing the example program in +.br clone (2) +in the background. +that program creates a child in a separate uts namespace. +the child changes the hostname in its namespace, +and then both processes display the hostnames in their uts namespaces, +so that we can see that they are different. +.pp +.in +4n +.ex +$ \fbsu\fp # need privilege for namespace operations +password: +# \fb./newuts bizarro &\fp +[1] 3549 +clone() returned 3550 +uts.nodename in child: bizarro +uts.nodename in parent: antero +# \fbuname \-n\fp # verify hostname in the shell +antero +.ee +.in +.pp +we then run the program shown below, +using it to execute a shell. +inside that shell, we verify that the hostname is the one +set by the child created by the first program: +.pp +.in +4n +.ex +# \fb./ns_exec /proc/3550/ns/uts /bin/bash\fp +# \fbuname \-n\fp # executed in shell started by ns_exec +bizarro +.ee +.in +.ss program source +.ex +#define _gnu_source +#include +#include +#include +#include +#include + +#define errexit(msg) do { perror(msg); exit(exit_failure); \e + } while (0) + +int +main(int argc, char *argv[]) +{ + int fd; + + if (argc < 3) { + fprintf(stderr, "%s /proc/pid/ns/file cmd args...\en", argv[0]); + exit(exit_failure); + } + + /* get file descriptor for namespace; the file descriptor is opened + with o_cloexec so as to ensure that it is not inherited by the + program that is later executed. */ + + fd = open(argv[1], o_rdonly | o_cloexec); + if (fd == \-1) + errexit("open"); + + if (setns(fd, 0) == \-1) /* join that namespace */ + errexit("setns"); + + execvp(argv[2], &argv[2]); /* execute a command in namespace */ + errexit("execvp"); +} +.ee +.sh see also +.br nsenter (1), +.br clone (2), +.br fork (2), +.br unshare (2), +.br vfork (2), +.br namespaces (7), +.br unix (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2006 michael kerrisk +.\" and copyright (c) 2008 linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th cpu_set 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +cpu_set, cpu_clr, cpu_isset, cpu_zero, cpu_count, +cpu_and, cpu_or, cpu_xor, cpu_equal, +cpu_alloc, cpu_alloc_size, cpu_free, +cpu_set_s, cpu_clr_s, cpu_isset_s, cpu_zero_s, +cpu_count_s, cpu_and_s, cpu_or_s, cpu_xor_s, cpu_equal_s \- +macros for manipulating cpu sets +.sh synopsis +.nf +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "void cpu_zero(cpu_set_t *" set ); +.pp +.bi "void cpu_set(int " cpu ", cpu_set_t *" set ); +.bi "void cpu_clr(int " cpu ", cpu_set_t *" set ); +.bi "int cpu_isset(int " cpu ", cpu_set_t *" set ); +.pp +.bi "int cpu_count(cpu_set_t *" set ); +.pp +.bi "void cpu_and(cpu_set_t *" destset , +.bi " cpu_set_t *" srcset1 ", cpu_set_t *" srcset2 ); +.bi "void cpu_or(cpu_set_t *" destset , +.bi " cpu_set_t *" srcset1 ", cpu_set_t *" srcset2 ); +.bi "void cpu_xor(cpu_set_t *" destset , +.bi " cpu_set_t *" srcset1 ", cpu_set_t *" srcset2 ); +.pp +.bi "int cpu_equal(cpu_set_t *" set1 ", cpu_set_t *" set2 ); +.pp +.bi "cpu_set_t *cpu_alloc(int " num_cpus ); +.bi "void cpu_free(cpu_set_t *" set ); +.bi "size_t cpu_alloc_size(int " num_cpus ); +.pp +.bi "void cpu_zero_s(size_t " setsize ", cpu_set_t *" set ); +.pp +.bi "void cpu_set_s(int " cpu ", size_t " setsize ", cpu_set_t *" set ); +.bi "void cpu_clr_s(int " cpu ", size_t " setsize ", cpu_set_t *" set ); +.bi "int cpu_isset_s(int " cpu ", size_t " setsize ", cpu_set_t *" set ); +.pp +.bi "int cpu_count_s(size_t " setsize ", cpu_set_t *" set ); +.pp +.bi "void cpu_and_s(size_t " setsize ", cpu_set_t *" destset , +.bi " cpu_set_t *" srcset1 ", cpu_set_t *" srcset2 ); +.bi "void cpu_or_s(size_t " setsize ", cpu_set_t *" destset , +.bi " cpu_set_t *" srcset1 ", cpu_set_t *" srcset2 ); +.bi "void cpu_xor_s(size_t " setsize ", cpu_set_t *" destset , +.bi " cpu_set_t *" srcset1 ", cpu_set_t *" srcset2 ); +.pp +.bi "int cpu_equal_s(size_t " setsize ", cpu_set_t *" set1 \ +", cpu_set_t *" set2 ); +.fi +.sh description +the +.i cpu_set_t +data structure represents a set of cpus. +cpu sets are used by +.br sched_setaffinity (2) +and similar interfaces. +.pp +the +.i cpu_set_t +data type is implemented as a bit mask. +however, the data structure should be treated as opaque: +all manipulation of cpu sets should be done via the macros +described in this page. +.pp +the following macros are provided to operate on the cpu set +.ir set : +.tp +.br cpu_zero () +clears +.ir set , +so that it contains no cpus. +.tp +.br cpu_set () +add cpu +.i cpu +to +.ir set . +.tp +.br cpu_clr () +remove cpu +.i cpu +from +.ir set . +.tp +.br cpu_isset () +test to see if cpu +.i cpu +is a member of +.ir set . +.tp +.br cpu_count () +return the number of cpus in +.ir set . +.pp +where a +.i cpu +argument is specified, it should not produce side effects, +since the above macros may evaluate the argument more than once. +.pp +the first cpu on the system corresponds to a +.i cpu +value of 0, the next cpu corresponds to a +.i cpu +value of 1, and so on. +no assumptions should be made about particular cpus being +available, or the set of cpus being contiguous, since cpus can +be taken offline dynamically or be otherwise absent. +the constant +.b cpu_setsize +(currently 1024) specifies a value one greater than the maximum cpu +number that can be stored in +.ir cpu_set_t . +.pp +the following macros perform logical operations on cpu sets: +.tp +.br cpu_and () +store the intersection of the sets +.i srcset1 +and +.i srcset2 +in +.i destset +(which may be one of the source sets). +.tp +.br cpu_or () +store the union of the sets +.i srcset1 +and +.i srcset2 +in +.i destset +(which may be one of the source sets). +.tp +.br cpu_xor () +store the xor of the sets +.i srcset1 +and +.i srcset2 +in +.i destset +(which may be one of the source sets). +the xor means the set of cpus that are in either +.i srcset1 +or +.ir srcset2 , +but not both. +.tp +.br cpu_equal () +test whether two cpu set contain exactly the same cpus. +.ss dynamically sized cpu sets +because some applications may require the ability to dynamically +size cpu sets (e.g., to allocate sets larger than that +defined by the standard +.i cpu_set_t +data type), glibc nowadays provides a set of macros to support this. +.pp +the following macros are used to allocate and deallocate cpu sets: +.tp +.br cpu_alloc () +allocate a cpu set large enough to hold cpus +in the range 0 to +.ir num_cpus\-1 . +.tp +.br cpu_alloc_size () +return the size in bytes of the cpu set that would be needed to +hold cpus in the range 0 to +.ir num_cpus\-1 . +this macro provides the value that can be used for the +.i setsize +argument in the +.br cpu_*_s () +macros described below. +.tp +.br cpu_free () +free a cpu set previously allocated by +.br cpu_alloc (). +.pp +the macros whose names end with "_s" are the analogs of +the similarly named macros without the suffix. +these macros perform the same tasks as their analogs, +but operate on the dynamically allocated cpu set(s) whose size is +.i setsize +bytes. +.sh return value +.br cpu_isset () +and +.br cpu_isset_s () +return nonzero if +.i cpu +is in +.ir set ; +otherwise, it returns 0. +.pp +.br cpu_count () +and +.br cpu_count_s () +return the number of cpus in +.ir set . +.pp +.br cpu_equal () +and +.br cpu_equal_s () +return nonzero if the two cpu sets are equal; otherwise they return 0. +.pp +.br cpu_alloc () +returns a pointer on success, or null on failure. +(errors are as for +.br malloc (3).) +.pp +.br cpu_alloc_size () +returns the number of bytes required to store a +cpu set of the specified cardinality. +.pp +the other functions do not return a value. +.sh versions +the +.br cpu_zero (), +.br cpu_set (), +.br cpu_clr (), +and +.br cpu_isset () +macros were added in glibc 2.3.3. +.pp +.br cpu_count () +first appeared in glibc 2.6. +.pp +.br cpu_and (), +.br cpu_or (), +.br cpu_xor (), +.br cpu_equal (), +.br cpu_alloc (), +.br cpu_alloc_size (), +.br cpu_free (), +.br cpu_zero_s (), +.br cpu_set_s (), +.br cpu_clr_s (), +.br cpu_isset_s (), +.br cpu_and_s (), +.br cpu_or_s (), +.br cpu_xor_s (), +and +.br cpu_equal_s () +first appeared in glibc 2.7. +.sh conforming to +these interfaces are linux-specific. +.sh notes +to duplicate a cpu set, use +.br memcpy (3). +.pp +since cpu sets are bit masks allocated in units of long words, +the actual number of cpus in a dynamically +allocated cpu set will be rounded up to the next multiple of +.ir "sizeof(unsigned long)" . +an application should consider the contents of these extra bits +to be undefined. +.pp +notwithstanding the similarity in the names, +note that the constant +.b cpu_setsize +indicates the number of cpus in the +.i cpu_set_t +data type (thus, it is effectively a count of the bits in the bit mask), +while the +.i setsize +argument of the +.br cpu_*_s () +macros is a size in bytes. +.pp +the data types for arguments and return values shown +in the synopsis are hints what about is expected in each case. +however, since these interfaces are implemented as macros, +the compiler won't necessarily catch all type errors +if you violate the suggestions. +.sh bugs +on 32-bit platforms with glibc 2.8 and earlier, +.br cpu_alloc () +allocates twice as much space as is required, and +.br cpu_alloc_size () +returns a value twice as large as it should. +this bug should not affect the semantics of a program, +but does result in wasted memory +and less efficient operation of the macros that +operate on dynamically allocated cpu sets. +these bugs are fixed in glibc 2.9. +.\" http://sourceware.org/bugzilla/show_bug.cgi?id=7029 +.sh examples +the following program demonstrates the use of some of the macros +used for dynamically allocated cpu sets. +.pp +.ex +#define _gnu_source +#include +#include +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + cpu_set_t *cpusetp; + size_t size; + int num_cpus; + + if (argc < 2) { + fprintf(stderr, "usage: %s \en", argv[0]); + exit(exit_failure); + } + + num_cpus = atoi(argv[1]); + + cpusetp = cpu_alloc(num_cpus); + if (cpusetp == null) { + perror("cpu_alloc"); + exit(exit_failure); + } + + size = cpu_alloc_size(num_cpus); + + cpu_zero_s(size, cpusetp); + for (int cpu = 0; cpu < num_cpus; cpu += 2) + cpu_set_s(cpu, size, cpusetp); + + printf("cpu_count() of set: %d\en", cpu_count_s(size, cpusetp)); + + cpu_free(cpusetp); + exit(exit_success); +} +.ee +.sh see also +.br sched_setaffinity (2), +.br pthread_attr_setaffinity_np (3), +.br pthread_setaffinity_np (3), +.br cpuset (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/rpc.3 + +.so man3/pthread_attr_setguardsize.3 + +.so man3/pthread_setname_np.3 + +.\" copyright 1993-1995 daniel quinlan (quinlan@yggdrasil.com) +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" slightly rearranged, aeb, 950713 +.\" updated, dpo, 990531 +.th iso_8859-1 7 2020-08-13 "linux" "linux programmer's manual" +.sh name +iso_8859-1 \- iso 8859-1 character set encoded in octal, decimal, +and hexadecimal +.sh description +the iso 8859 standard includes several 8-bit extensions to the ascii +character set (also known as iso 646-irv). +iso 8859-1 encodes the +characters used in many west european languages. +.ss iso 8859 alphabets +the full set of iso 8859 alphabets includes: +.ts +l l. +iso 8859-1 west european languages (latin-1) +iso 8859-2 central and east european languages (latin-2) +iso 8859-3 southeast european and miscellaneous languages (latin-3) +iso 8859-4 scandinavian/baltic languages (latin-4) +iso 8859-5 latin/cyrillic +iso 8859-6 latin/arabic +iso 8859-7 latin/greek +iso 8859-8 latin/hebrew +iso 8859-9 latin-1 modification for turkish (latin-5) +iso 8859-10 lappish/nordic/eskimo languages (latin-6) +iso 8859-11 latin/thai +iso 8859-13 baltic rim languages (latin-7) +iso 8859-14 celtic (latin-8) +iso 8859-15 west european languages (latin-9) +iso 8859-16 romanian (latin-10) +.te +.ss iso 8859-1 characters +the following table displays the characters in iso 8859-1 that +are printable and unlisted in the +.br ascii (7) +manual page. +.ts +l l l c lp-1. +oct dec hex char description +_ +240 160 a0   no-break space +241 161 a1 ¡ inverted exclamation mark +242 162 a2 ¢ cent sign +243 163 a3 £ pound sign +244 164 a4 ¤ currency sign +245 165 a5 ¥ yen sign +246 166 a6 ¦ broken bar +247 167 a7 § section sign +250 168 a8 ¨ diaeresis +251 169 a9 © copyright sign +252 170 aa ª feminine ordinal indicator +253 171 ab « left-pointing double angle quotation mark +254 172 ac ¬ not sign +255 173 ad ­ soft hyphen +256 174 ae ® registered sign +257 175 af ¯ macron +260 176 b0 ° degree sign +261 177 b1 ± plus-minus sign +262 178 b2 ² superscript two +263 179 b3 ³ superscript three +264 180 b4 ´ acute accent +265 181 b5 µ micro sign +266 182 b6 ¶ pilcrow sign +267 183 b7 · middle dot +270 184 b8 ¸ cedilla +271 185 b9 ¹ superscript one +272 186 ba º masculine ordinal indicator +273 187 bb » right-pointing double angle quotation mark +274 188 bc ¼ vulgar fraction one quarter +275 189 bd ½ vulgar fraction one half +276 190 be ¾ vulgar fraction three quarters +277 191 bf ¿ inverted question mark +300 192 c0 à latin capital letter a with grave +301 193 c1 á latin capital letter a with acute +302 194 c2 â latin capital letter a with circumflex +303 195 c3 ã latin capital letter a with tilde +304 196 c4 ä latin capital letter a with diaeresis +305 197 c5 å latin capital letter a with ring above +306 198 c6 æ latin capital letter ae +307 199 c7 ç latin capital letter c with cedilla +310 200 c8 è latin capital letter e with grave +311 201 c9 é latin capital letter e with acute +312 202 ca ê latin capital letter e with circumflex +313 203 cb ë latin capital letter e with diaeresis +314 204 cc ì latin capital letter i with grave +315 205 cd í latin capital letter i with acute +316 206 ce î latin capital letter i with circumflex +317 207 cf ï latin capital letter i with diaeresis +320 208 d0 ð latin capital letter eth +321 209 d1 ñ latin capital letter n with tilde +322 210 d2 ò latin capital letter o with grave +323 211 d3 ó latin capital letter o with acute +324 212 d4 ô latin capital letter o with circumflex +325 213 d5 õ latin capital letter o with tilde +326 214 d6 ö latin capital letter o with diaeresis +327 215 d7 × multiplication sign +330 216 d8 ø latin capital letter o with stroke +331 217 d9 ù latin capital letter u with grave +332 218 da ú latin capital letter u with acute +333 219 db û latin capital letter u with circumflex +334 220 dc ü latin capital letter u with diaeresis +335 221 dd ý latin capital letter y with acute +336 222 de þ latin capital letter thorn +337 223 df ß latin small letter sharp s +340 224 e0 à latin small letter a with grave +341 225 e1 á latin small letter a with acute +342 226 e2 â latin small letter a with circumflex +343 227 e3 ã latin small letter a with tilde +344 228 e4 ä latin small letter a with diaeresis +345 229 e5 å latin small letter a with ring above +346 230 e6 æ latin small letter ae +347 231 e7 ç latin small letter c with cedilla +350 232 e8 è latin small letter e with grave +351 233 e9 é latin small letter e with acute +352 234 ea ê latin small letter e with circumflex +353 235 eb ë latin small letter e with diaeresis +354 236 ec ì latin small letter i with grave +355 237 ed í latin small letter i with acute +356 238 ee î latin small letter i with circumflex +357 239 ef ï latin small letter i with diaeresis +360 240 f0 ð latin small letter eth +361 241 f1 ñ latin small letter n with tilde +362 242 f2 ò latin small letter o with grave +363 243 f3 ó latin small letter o with acute +364 244 f4 ô latin small letter o with circumflex +365 245 f5 õ latin small letter o with tilde +366 246 f6 ö latin small letter o with diaeresis +367 247 f7 ÷ division sign +370 248 f8 ø latin small letter o with stroke +371 249 f9 ù latin small letter u with grave +372 250 fa ú latin small letter u with acute +373 251 fb û latin small letter u with circumflex +374 252 fc ü latin small letter u with diaeresis +375 253 fd ý latin small letter y with acute +376 254 fe þ latin small letter thorn +377 255 ff ÿ latin small letter y with diaeresis +.te +.sh notes +iso 8859-1 is also known as latin-1. +.sh see also +.br ascii (7), +.br charsets (7), +.br cp1252 (7), +.br iso_8859\-15 (7), +.br utf\-8 (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/perror.3 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified mon mar 29 22:39:24 1993, david metcalfe +.\" modified sat jul 24 21:39:22 1993, rik faith (faith@cs.unc.edu) +.th atof 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +atof \- convert a string to a double +.sh synopsis +.nf +.b #include +.pp +.bi "double atof(const char *" nptr ); +.fi +.sh description +the +.br atof () +function converts the initial portion of the string +pointed to by \finptr\fp to +.ir double . +the behavior is the same as +.pp +.in +4n +.ex +strtod(nptr, null); +.ee +.in +.pp +except that +.br atof () +does not detect errors. +.sh return value +the converted value. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br atof () +t} thread safety mt-safe locale +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c89, c99, svr4, 4.3bsd. +.sh see also +.br atoi (3), +.br atol (3), +.br strfromd (3), +.br strtod (3), +.br strtol (3), +.br strtoul (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/stdio_ext.3 + +.so man7/system_data_types.7 + +.so man3/nan.3 + +.\" copyright (c) 1995,1997 paul gortmaker and andries brouwer +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" this man page written 950814 by aeb, based on paul gortmaker's howto +.\" (dated v1.0.1, 15/08/95). +.\" major update, aeb, 970114. +.\" +.th bootparam 7 2021-03-22 "linux" "linux programmer's manual" +.sh name +bootparam \- introduction to boot time parameters of the linux kernel +.sh description +the linux kernel accepts certain 'command-line options' or 'boot time +parameters' at the moment it is started. +in general, this is used to +supply the kernel with information about hardware parameters that +the kernel would not be able to determine on its own, or to avoid/override +the values that the kernel would otherwise detect. +.pp +when the kernel is booted directly by the bios, +you have no opportunity to specify any parameters. +so, in order to take advantage of this possibility you have to +use a boot loader that is able to pass parameters, such as grub. +.ss the argument list +the kernel command line is parsed into a list of strings +(boot arguments) separated by spaces. +most of the boot arguments have the form: +.pp +.in +4n +.ex +name[=value_1][,value_2]...[,value_10] +.ee +.in +.pp +where 'name' is a unique keyword that is used to identify what part of +the kernel the associated values (if any) are to be given to. +note the limit of 10 is real, as the present code handles only 10 comma +separated parameters per keyword. +(however, you can reuse the same +keyword with up to an additional 10 parameters in unusually +complicated situations, assuming the setup function supports it.) +.pp +most of the sorting is coded in the kernel source file +.ir init/main.c . +first, the kernel +checks to see if the argument is any of the special arguments 'root=', +\&'nfsroot=', 'nfsaddrs=', 'ro', 'rw', 'debug', or 'init'. +the meaning of these special arguments is described below. +.pp +then it walks a list of setup functions +to see if the specified argument string (such as 'foo') has +been associated with a setup function ('foo_setup()') for a particular +device or part of the kernel. +if you passed the kernel the line +foo=3,4,5,6 then the kernel would search the bootsetups array to see +if 'foo' was registered. +if it was, then it would call the setup +function associated with 'foo' (foo_setup()) and hand it the arguments +3, 4, 5, and 6 as given on the kernel command line. +.pp +anything of the form 'foo=bar' that is not accepted as a setup function +as described above is then interpreted as an environment variable to +be set. +a (useless?) example would be to use 'term=vt100' as a boot +argument. +.pp +any remaining arguments that were not picked up by the kernel and were +not interpreted as environment variables are then passed onto pid 1, +which is usually the +.br init (1) +program. +the most common argument that +is passed to the +.i init +process is the word 'single' which instructs it +to boot the computer in single user mode, and not launch all the usual +daemons. +check the manual page for the version of +.br init (1) +installed on +your system to see what arguments it accepts. +.ss general non-device-specific boot arguments +.tp +.b "'init=...'" +this sets the initial command to be executed by the kernel. +if this is not set, or cannot be found, the kernel will try +.ir /sbin/init , +then +.ir /etc/init , +then +.ir /bin/init , +then +.i /bin/sh +and panic if all of this fails. +.tp +.b "'nfsaddrs=...'" +this sets the nfs boot address to the given string. +this boot address is used in case of a net boot. +.tp +.b "'nfsroot=...'" +this sets the nfs root name to the given string. +if this string +does not begin with '/' or ',' or a digit, then it is prefixed by +\&'/tftpboot/'. +this root name is used in case of a net boot. +.tp +.b "'root=...'" +this argument tells the kernel what device is to be used as the root +filesystem while booting. +the default of this setting is determined +at compile time, and usually is the value of the root device of the +system that the kernel was built on. +to override this value, and +select the second floppy drive as the root device, one would +use 'root=/dev/fd1'. +.ip +the root device can be specified symbolically or numerically. +a symbolic specification has the form +.ir /dev/xxyn , +where xx designates +the device type (e.g., 'hd' for st-506 compatible hard disk, with y in +\&'a'\(en'd'; 'sd' for scsi compatible disk, with y in 'a'\(en'e'), +y the driver letter or +number, and n the number (in decimal) of the partition on this device. +.ip +note that this has nothing to do with the designation of these +devices on your filesystem. +the '/dev/' part is purely conventional. +.ip +the more awkward and less portable numeric specification of the above +possible root devices in major/minor format is also accepted. +(for example, +.i /dev/sda3 +is major 8, minor 3, so you could use 'root=0x803' as an +alternative.) +.tp +.br "'rootdelay='" +this parameter sets the delay (in seconds) to pause before attempting +to mount the root filesystem. +.tp +.br "'rootflags=...'" +this parameter sets the mount option string for the root filesystem +(see also +.br fstab (5)). +.tp +.br "'rootfstype=...'" +the 'rootfstype' option tells the kernel to mount the root filesystem as +if it where of the type specified. +this can be useful (for example) to +mount an ext3 filesystem as ext2 and then remove the journal in the root +filesystem, in fact reverting its format from ext3 to ext2 without the +need to boot the box from alternate media. +.tp +.br 'ro' " and " 'rw' +the 'ro' option tells the kernel to mount the root filesystem +as 'read-only' so that filesystem consistency check programs (fsck) +can do their work on a quiescent filesystem. +no processes can +write to files on the filesystem in question until it is 'remounted' +as read/write capable, for example, by 'mount \-w \-n \-o remount /'. +(see also +.br mount (8).) +.ip +the 'rw' option tells the kernel to mount the root filesystem read/write. +this is the default. +.tp +.b "'resume=...'" +this tells the kernel the location of the suspend-to-disk data that you want the machine to resume from after hibernation. +usually, it is the same as your swap partition or file. +example: +.ip +.in +4n +.ex +resume=/dev/hda2 +.ee +.in +.tp +.b "'reserve=...'" +this is used to protect i/o port regions from probes. +the form of the command is: +.ip +.in +4n +.ex +.bi reserve= iobase,extent[,iobase,extent]... +.ee +.in +.ip +in some machines it may be necessary to prevent device drivers from +checking for devices (auto-probing) in a specific region. +this may be +because of hardware that reacts badly to the probing, or hardware +that would be mistakenly identified, or merely +hardware you don't want the kernel to initialize. +.ip +the reserve boot-time argument specifies an i/o port region that +shouldn't be probed. +a device driver will not probe a reserved region, +unless another boot argument explicitly specifies that it do so. +.ip +for example, the boot line +.ip +.in +4n +.ex +reserve=0x300,32 blah=0x300 +.ee +.in +.ip +keeps all device drivers except the driver for 'blah' from probing +0x300\-0x31f. +.tp +.b "'panic=n'" +by default, the kernel will not reboot after a panic, but this option +will cause a kernel reboot after n seconds (if n is greater than zero). +this panic timeout can also be set by +.ip +.in +4n +.ex +echo n > /proc/sys/kernel/panic +.ee +.in +.tp +.b "'reboot=[warm|cold][,[bios|hard]]'" +since linux 2.0.22, a reboot is by default a cold reboot. +one asks for the old default with 'reboot=warm'. +(a cold reboot may be required to reset certain hardware, +but might destroy not yet written data in a disk cache. +a warm reboot may be faster.) +by default, a reboot is hard, by asking the keyboard controller +to pulse the reset line low, but there is at least one type +of motherboard where that doesn't work. +the option 'reboot=bios' will +instead jump through the bios. +.tp +.br 'nosmp' " and " 'maxcpus=n' +(only when __smp__ is defined.) +a command-line option of 'nosmp' or 'maxcpus=0' will disable smp +activation entirely; an option 'maxcpus=n' limits the maximum number +of cpus activated in smp mode to n. +.ss boot arguments for use by kernel developers +.tp +.b "'debug'" +kernel messages are handed off to a daemon (e.g., +.br klogd (8) +or similar) so that they may be logged to disk. +messages with a priority above +.i console_loglevel +are also printed on the console. +(for a discussion of log levels, see +.br syslog (2).) +by default, +.i console_loglevel +is set to log messages at levels higher than +.br kern_debug . +this boot argument will cause the kernel to also +print messages logged at level +.br kern_debug . +the console loglevel can also be set on a booted system via the +.ir /proc/sys/kernel/printk +file (described in +.br syslog (2)), +the +.br syslog (2) +.b syslog_action_console_level +operation, or +.br dmesg (8). +.tp +.b "'profile=n'" +it is possible to enable a kernel profiling function, +if one wishes to find out where the kernel is spending its cpu cycles. +profiling is enabled by setting the variable +.i prof_shift +to a nonzero value. +this is done either by specifying +.b config_profile +at compile time, or by giving the 'profile=' option. +now the value that +.i prof_shift +gets will be n, when given, or +.br config_profile_shift , +when that is given, or 2, the default. +the significance of this variable is that it +gives the granularity of the profiling: each clock tick, if the +system was executing kernel code, a counter is incremented: +.ip +.in +4n +.ex +profile[address >> prof_shift]++; +.ee +.in +.ip +the raw profiling information can be read from +.ir /proc/profile . +probably you'll want to use a tool such as readprofile.c to digest it. +writing to +.i /proc/profile +will clear the counters. +.ss boot arguments for ramdisk use +(only if the kernel was compiled with +.br config_blk_dev_ram .) +in general it is a bad idea to use a ramdisk under linux\(emthe +system will use available memory more efficiently itself. +but while booting, +it is often useful to load the floppy contents into a +ramdisk. +one might also have a system in which first +some modules (for filesystem or hardware) must be loaded +before the main disk can be accessed. +.ip +in linux 1.3.48, ramdisk handling was changed drastically. +earlier, the memory was allocated statically, and there was +a 'ramdisk=n' parameter to tell its size. +(this could also be set in the kernel image at compile time.) +these days ram disks use the buffer cache, and grow dynamically. +for a lot of information on the current ramdisk +setup, see the kernel source file +.ir documentation/blockdev/ramdisk.txt +.ri ( documentation/ramdisk.txt +in older kernels). +.ip +there are four parameters, two boolean and two integral. +.tp +.b "'load_ramdisk=n'" +if n=1, do load a ramdisk. +if n=0, do not load a ramdisk. +(this is the default.) +.tp +.b "'prompt_ramdisk=n'" +if n=1, do prompt for insertion of the floppy. +(this is the default.) +if n=0, do not prompt. +(thus, this parameter is never needed.) +.tp +.br 'ramdisk_size=n' " or (obsolete) " 'ramdisk=n' +set the maximal size of the ramdisk(s) to n kb. +the default is 4096 (4\ mb). +.tp +.b "'ramdisk_start=n'" +sets the starting block number (the offset on the floppy where +the ramdisk starts) to n. +this is needed in case the ramdisk follows a kernel image. +.tp +.b "'noinitrd'" +(only if the kernel was compiled with +.b config_blk_dev_ram +and +.br config_blk_dev_initrd .) +these days it is possible to compile the kernel to use initrd. +when this feature is enabled, the boot process will load the kernel +and an initial ramdisk; then the kernel converts initrd into +a "normal" ramdisk, which is mounted read-write as root device; +then +.i /linuxrc +is executed; afterward the "real" root filesystem is mounted, +and the initrd filesystem is moved over to +.ir /initrd ; +finally +the usual boot sequence (e.g., invocation of +.ir /sbin/init ) +is performed. +.ip +for a detailed description of the initrd feature, see the kernel source file +.i documentation/admin\-guide/initrd.rst +.\" commit 9d85025b0418163fae079c9ba8f8445212de8568 +(or +.i documentation/initrd.txt +before linux 4.10). +.ip +the 'noinitrd' option tells the kernel that although it was compiled for +operation with initrd, it should not go through the above steps, but +leave the initrd data under +.ir /dev/initrd . +(this device can be used only once: the data is freed as soon as +the last process that used it has closed +.ir /dev/initrd .) +.ss boot arguments for scsi devices +general notation for this section: +.pp +.i iobase +-- the first i/o port that the scsi host occupies. +these are specified in hexadecimal notation, +and usually lie in the range from 0x200 to 0x3ff. +.pp +.i irq +-- the hardware interrupt that the card is configured to use. +valid values will be dependent on the card in question, but will +usually be 5, 7, 9, 10, 11, 12, and 15. +the other values are usually +used for common peripherals like ide hard disks, floppies, serial +ports, and so on. +.pp +.i scsi\-id +-- the id that the host adapter uses to identify itself on the +scsi bus. +only some host adapters allow you to change this value, as +most have it permanently specified internally. +the usual default value +is 7, but the seagate and future domain tmc-950 boards use 6. +.pp +.i parity +-- whether the scsi host adapter expects the attached devices +to supply a parity value with all information exchanges. +specifying a one indicates parity checking is enabled, +and a zero disables parity checking. +again, not all adapters will support selection of parity +behavior as a boot argument. +.tp +.b "'max_scsi_luns=...'" +a scsi device can have a number of 'subdevices' contained within +itself. +the most common example is one of the new scsi cd-roms that +handle more than one disk at a time. +each cd is addressed as a +\&'logical unit number' (lun) of that particular device. +but most +devices, such as hard disks, tape drives, and such are only one device, +and will be assigned to lun zero. +.ip +some poorly designed scsi devices cannot handle being probed for +luns not equal to zero. +therefore, if the compile-time flag +.b config_scsi_multi_lun +is not set, newer kernels will by default probe only lun zero. +.ip +to specify the number of probed luns at boot, one enters +\&'max_scsi_luns=n' as a boot arg, where n is a number between one and +eight. +to avoid problems as described above, one would use n=1 to +avoid upsetting such broken devices. +.tp +.b "scsi tape configuration" +some boot time configuration of the scsi tape driver can be achieved +by using the following: +.ip +.in +4n +.ex +.bi st= buf_size[,write_threshold[,max_bufs]] +.ee +.in +.ip +the first two numbers are specified in units of kb. +the default +.i buf_size +is 32k\ b, and the maximum size that can be specified is a +ridiculous 16384\ kb. +the +.i write_threshold +is the value at which the buffer is committed to tape, with a +default value of 30\ kb. +the maximum number of buffers varies +with the number of drives detected, and has a default of two. +an example usage would be: +.ip +.in +4n +.ex +st=32,30,2 +.ee +.in +.ip +full details can be found in the file +.i documentation/scsi/st.txt +(or +.i drivers/scsi/readme.st +for older kernels) in the linux kernel source. +.ss hard disks +.tp +.b "ide disk/cd-rom driver parameters" +the ide driver accepts a number of parameters, which range from disk +geometry specifications, to support for broken controller chips. +drive-specific options are specified by using 'hdx=' with x in 'a'\(en'h'. +.ip +non-drive-specific options are specified with the prefix 'hd='. +note that using a drive-specific prefix for a non-drive-specific option +will still work, and the option will just be applied as expected. +.ip +also note that 'hd=' can be used to refer to the next unspecified +drive in the (a, ..., h) sequence. +for the following discussions, +the 'hd=' option will be cited for brevity. +see the file +.i documentation/ide/ide.txt +(or +.i documentation/ide.txt +.\" linux 2.0, 2.2, 2.4 +in older kernels, or +.i drivers/block/readme.ide +in ancient kernels) in the linux kernel source for more details. +.tp +.b "the 'hd=cyls,heads,sects[,wpcom[,irq]]' options" +these options are used to specify the physical geometry of the disk. +only the first three values are required. +the cylinder/head/sectors +values will be those used by fdisk. +the write precompensation value +is ignored for ide disks. +the irq value specified will be the irq +used for the interface that the drive resides on, and is not really a +drive-specific parameter. +.tp +.b "the 'hd=serialize' option" +the dual ide interface cmd-640 chip is broken as designed such that +when drives on the secondary interface are used at the same time as +drives on the primary interface, it will corrupt your data. +using this +option tells the driver to make sure that both interfaces are never +used at the same time. +.tp +.b "the 'hd=noprobe' option" +do not probe for this drive. +for example, +.ip +.in +4n +.ex +hdb=noprobe hdb=1166,7,17 +.ee +.in +.ip +would disable the probe, but still specify the drive geometry so +that it would be registered as a valid block device, and hence +usable. +.tp +.b "the 'hd=nowerr' option" +some drives apparently have the +.b wrerr_stat +bit stuck on permanently. +this enables a work-around for these broken devices. +.tp +.b "the 'hd=cdrom' option" +this tells the ide driver that there is an atapi compatible cd-rom +attached in place of a normal ide hard disk. +in most cases the cd-rom +is identified automatically, but if it isn't then this may help. +.tp +.b "standard st-506 disk driver options ('hd=')" +the standard disk driver can accept geometry arguments for the disks +similar to the ide driver. +note however that it expects only three +values (c/h/s); any more or any less and it will silently ignore you. +also, it accepts only 'hd=' as an argument, that is, 'hda=' +and so on are not valid here. +the format is as follows: +.ip +.in +4n +.ex +hd=cyls,heads,sects +.ee +.in +.ip +if there are two disks installed, the above is repeated with the +geometry parameters of the second disk. +.ss ethernet devices +different drivers make use of different parameters, but they all at +least share having an irq, an i/o port base value, and a name. +in its most generic form, it looks something like this: +.pp +.in +4n +.ex +ether=irq,iobase[,param_1[,...param_8]],name +.ee +.in +.pp +the first nonnumeric argument is taken as the name. +the param_n values (if applicable) usually have different meanings for each +different card/driver. +typical param_n values are used to specify +things like shared memory address, interface selection, dma channel +and the like. +.pp +the most common use of this parameter is to force probing for a second +ethercard, as the default is to probe only for one. +this can be accomplished with a simple: +.pp +.in +4n +.ex +ether=0,0,eth1 +.ee +.in +.pp +note that the values of zero for the irq and i/o base in the above +example tell the driver(s) to autoprobe. +.pp +the ethernet-howto has extensive documentation on using multiple +cards and on the card/driver-specific implementation +of the param_n values where used. +interested readers should refer to +the section in that document on their particular card. +.ss the floppy disk driver +there are many floppy driver options, and they are all listed in +.i documentation/blockdev/floppy.txt +(or +.i documentation/floppy.txt +in older kernels, or +.i drivers/block/readme.fd +for ancient kernels) in the linux kernel source. +see that file for the details. +.ss the sound driver +the sound driver can also accept boot arguments to override the compiled-in +values. +this is not recommended, as it is rather complex. +it is described in the linux kernel source file +.ir documentation/sound/oss/readme.oss +.ri ( drivers/sound/readme.linux +in older kernel versions). +it accepts +a boot argument of the form: +.pp +.in +4n +.ex +sound=device1[,device2[,device3...[,device10]]] +.ee +.in +.pp +where each devicen value is of the following format 0xtaaaid and the +bytes are used as follows: +.pp +t \- device type: 1=fm, 2=sb, 3=pas, 4=gus, 5=mpu401, 6=sb16, +7=sb16-mpu401 +.pp +aaa \- i/o address in hex. +.pp +i \- interrupt line in hex (i.e., 10=a, 11=b, ...) +.pp +d \- dma channel. +.pp +as you can see, it gets pretty messy, and you are better off to compile +in your own personal values as recommended. +using a boot argument of +\&'sound=0' will disable the sound driver entirely. +.ss the line printer driver +.tp +.b "'lp='" +.br +syntax: +.ip +.in +4n +.ex +lp=0 +lp=auto +lp=reset +lp=port[,port...] +.ee +.in +.ip +you can tell the printer driver what ports to use and what ports not +to use. +the latter comes in handy if you don't want the printer driver +to claim all available parallel ports, so that other drivers +(e.g., plip, ppa) can use them instead. +.ip +the format of the argument is multiple port names. +for example, +lp=none,parport0 would use the first parallel port for lp1, and +disable lp0. +to disable the printer driver entirely, one can use +lp=0. +.\" .sh authors +.\" linus torvalds (and many others) +.sh see also +.br klogd (8), +.br mount (8) +.pp +for up-to-date information, see the kernel source file +.ir documentation/admin\-guide/kernel\-parameters.txt . +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" iso/iec 9899:1999 +.\" +.th wmemcpy 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +wmemcpy \- copy an array of wide-characters +.sh synopsis +.nf +.b #include +.pp +.bi "wchar_t *wmemcpy(wchar_t *restrict " dest \ +", const wchar_t *restrict " src , +.bi " size_t " n ); +.fi +.sh description +the +.br wmemcpy () +function is the wide-character equivalent of the +.br memcpy (3) +function. +it copies +.i n +wide characters from the array starting at +.i src +to the array starting at +.ir dest . +.pp +the arrays may not overlap; use +.br wmemmove (3) +to copy between overlapping +arrays. +.pp +the programmer must ensure that there is room for at least +.i n +wide +characters at +.ir dest . +.sh return value +.br wmemcpy () +returns +.ir dest . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br wmemcpy () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh see also +.br memcpy (3), +.br wcscpy (3), +.br wmemmove (3), +.br wmempcpy (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/getutent.3 + +.so man3/tailq.3 + +.\" copyright (c) 1992 drew eckhardt (drew@cs.colorado.edu), march 28, 1992 +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified by michael haardt +.\" modified sun jul 25 10:14:13 1993 by rik faith +.\" modified 15 april 1995 by michael chastain +.\" update calling parameters to linux 1.2.4 values. +.\" modified 10 june 1995 by andries brouwer +.\" modified 3 may 1996 by martin schulze +.\" modified wed nov 6 04:05:28 1996 by eric s. raymond +.\" modified sat jan 29 01:08:23 2000 by aeb +.\" +.th setup 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +setup \- setup devices and filesystems, mount root filesystem +.sh synopsis +.nf +.b #include +.pp +.b int setup(void); +.fi +.sh description +.br setup () +is called once from within +.ir linux/init/main.c . +it calls initialization functions for devices and filesystems +configured into the kernel and then mounts the root filesystem. +.pp +no user process may call +.br setup (). +any user process, even a process with superuser permission, +will receive +.br eperm . +.sh return value +.br setup () +always returns \-1 for a user process. +.sh errors +.tp +.b eperm +always, for a user process. +.sh versions +since linux 2.1.121, no such function exists anymore. +.sh conforming to +this function is linux-specific, and should not be used in programs +intended to be portable, or indeed in any programs at all. +.sh notes +the calling sequence varied: at some times +.br setup () +has had a single argument +.i "void\ *bios" +and at other times a single argument +.ir "int magic" . +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +release +the linux man page maintainer proudly announces. . . + + man-pages-5.13.tar.gz - man pages for linux + +differences from the previous manual pages release are listed in +the file "changes". + +for further information, visit http://www.kernel.org/doc/man-pages/ + +posix pages +this package used to contains a copy of the posix 1003.1-2003 +man pages. the posix pages are now distributed in the separate +man-pages-posix package. + +the pages +these pages are most of the section 2, 3, 4, 5, 7 man pages +for linux. a few pages are provided in sections 1 and 8 for commands +that are not documented in other packages, and there are a few pages +in sections 5 and 8 for the timezone utilities. + +[the timezone pages were taken from +ftp://elsie.nci.nih.gov/pub/tzcode2001a.tar.gz.] +[the section 3 man pages for the db routines have been taken from +ftp://ftp.terra.net/pub/sleepycat/db.1.86.tar.gz.] +[the rpc man pages were taken from the 4.4bsd-lite cdrom.] + +here is a breakdown of what this distribution contains: + + section 1 = user commands (intro, plus a few other pages) + section 2 = system calls + section 3 = libc calls + section 4 = devices (e.g., hd, sd) + section 5 = file formats and configuration files (e.g., wtmp, /etc/passwd) + section 6 = games (intro only) + section 7 = overviews, conventions, macro packages, etc. + section 8 = system administration (intro, plus a few other pages) + + this package contains no, or very few, section 1, 6, and 8 man pages + because these should be distributed with the binaries they are written + for. sometimes section 9 is used for man pages describing parts of + the kernel. + + note that only section 2 is rather complete, but section 3 contains + several hundred man pages. if you want to write some man pages, + or suggest improvements to existing pages, please visit + http://www.kernel.org/doc/man-pages/ . + + +copyright information: + + these man pages are distributed under a variety of copyright licenses. + although these licenses permit free distribution of the nroff sources + contained in this package, commercial distribution may impose other + requirements (e.g., acknowledgement of copyright or inclusion of the + raw nroff sources with the commercial distribution). + if you distribute these man pages commercially, it is your + responsibility to figure out your obligations. (for many man pages, + these obligations require you to distribute nroff sources with any + pre-formatted man pages that you provide.) each file that contains + nroff source for a man page also contains the author(s) name, email + address, and copyright notice. + +.so man3/pthread_cleanup_push.3 + +.\" this manpage is copyright (c) 1992 drew eckhardt; +.\" and copyright (c) 1993 michael haardt +.\" and copyright (c) 1993,1994 ian jackson +.\" and copyright (c) 2006, 2014 michael kerrisk +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" you may distribute it under the terms of the gnu general +.\" public license. it comes with no warranty. +.\" %%%license_end +.\" +.th mkdir 2 2021-08-27 "linux" "linux programmer's manual" +.sh name +mkdir, mkdirat \- create a directory +.sh synopsis +.nf +.b #include +.\" .b #include +.pp +.bi "int mkdir(const char *" pathname ", mode_t " mode ); +.pp +.br "#include " "/* definition of at_* constants */" +.b #include +.pp +.bi "int mkdirat(int " dirfd ", const char *" pathname ", mode_t " mode ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br mkdirat (): +.nf + since glibc 2.10: + _posix_c_source >= 200809l + before glibc 2.10: + _atfile_source +.fi +.sh description +.br mkdir () +attempts to create a directory named +.ir pathname . +.pp +the argument +.i mode +specifies the mode for the new directory (see +.br inode (7)). +it is modified by the process's +.i umask +in the usual way: in the absence of a default acl, the mode of the +created directory is +.ri ( mode " & \(ti" umask " & 0777)." +whether other +.i mode +bits are honored for the created directory depends on the operating system. +for linux, see notes below. +.pp +the newly created directory will be owned by the effective user id of the +process. +if the directory containing the file has the set-group-id +bit set, or if the filesystem is mounted with bsd group semantics +.ri ( "mount \-o bsdgroups" +or, synonymously +.ir "mount \-o grpid" ), +the new directory will inherit the group ownership from its parent; +otherwise it will be owned by the effective group id of the process. +.pp +if the parent directory has the set-group-id bit set, then so will the +newly created directory. +.\" +.\" +.ss mkdirat() +the +.br mkdirat () +system call operates in exactly the same way as +.br mkdir (), +except for the differences described here. +.pp +if the pathname given in +.i pathname +is relative, then it is interpreted relative to the directory +referred to by the file descriptor +.i dirfd +(rather than relative to the current working directory of +the calling process, as is done by +.br mkdir () +for a relative pathname). +.pp +if +.i pathname +is relative and +.i dirfd +is the special value +.br at_fdcwd , +then +.i pathname +is interpreted relative to the current working +directory of the calling process (like +.br mkdir ()). +.pp +if +.i pathname +is absolute, then +.i dirfd +is ignored. +.pp +see +.br openat (2) +for an explanation of the need for +.br mkdirat (). +.sh return value +.br mkdir () +and +.br mkdirat () +return zero on success. +on error, \-1 is returned and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eacces +the parent directory does not allow write permission to the process, +or one of the directories in +.i pathname +did not allow search permission. +(see also +.br path_resolution (7).) +.tp +.b ebadf +.rb ( mkdirat ()) +.i pathname +is relative but +.i dirfd +is neither +.b at_fdcwd +nor a valid file descriptor. +.tp +.b edquot +the user's quota of disk blocks or inodes on the filesystem has been +exhausted. +.tp +.b eexist +.i pathname +already exists (not necessarily as a directory). +this includes the case where +.i pathname +is a symbolic link, dangling or not. +.tp +.b efault +.ir pathname " points outside your accessible address space." +.tp +.b einval +the final component ("basename") of the new directory's +.i pathname +is invalid +(e.g., it contains characters not permitted by the underlying filesystem). +.tp +.b eloop +too many symbolic links were encountered in resolving +.ir pathname . +.tp +.b emlink +the number of links to the parent directory would exceed +.br link_max . +.tp +.b enametoolong +.ir pathname " was too long." +.tp +.b enoent +a directory component in +.i pathname +does not exist or is a dangling symbolic link. +.tp +.b enomem +insufficient kernel memory was available. +.tp +.b enospc +the device containing +.i pathname +has no room for the new directory. +.tp +.b enospc +the new directory cannot be created because the user's disk quota is +exhausted. +.tp +.b enotdir +a component used as a directory in +.i pathname +is not, in fact, a directory. +.tp +.b enotdir +.rb ( mkdirat ()) +.i pathname +is relative and +.i dirfd +is a file descriptor referring to a file other than a directory. +.tp +.b eperm +the filesystem containing +.i pathname +does not support the creation of directories. +.tp +.b erofs +.i pathname +refers to a file on a read-only filesystem. +.sh versions +.br mkdirat () +was added to linux in kernel 2.6.16; +library support was added to glibc in version 2.4. +.sh conforming to +.br mkdir (): +svr4, bsd, posix.1-2001, posix.1-2008. +.\" svr4 documents additional eio, emultihop +.pp +.br mkdirat (): +posix.1-2008. +.sh notes +under linux, apart from the permission bits, the +.b s_isvtx +.i mode +bit is also honored. +.pp +there are many infelicities in the protocol underlying nfs. +some of these affect +.br mkdir (). +.ss glibc notes +on older kernels where +.br mkdirat () +is unavailable, the glibc wrapper function falls back to the use of +.br mkdir (). +when +.i pathname +is a relative pathname, +glibc constructs a pathname based on the symbolic link in +.ir /proc/self/fd +that corresponds to the +.ir dirfd +argument. +.sh see also +.br mkdir (1), +.br chmod (2), +.br chown (2), +.br mknod (2), +.br mount (2), +.br rmdir (2), +.br stat (2), +.br umask (2), +.br unlink (2), +.br acl (5), +.br path_resolution (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1993 rickard e. faith (faith@cs.unc.edu) +.\" +.\" updated with additions from mitchum dsouza +.\" portions copyright 1993 mitchum dsouza +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified tue oct 22 00:22:35 edt 1996 by eric s. raymond +.th gethostid 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +gethostid, sethostid \- get or set the unique identifier of the current host +.sh synopsis +.nf +.b #include +.pp +.b long gethostid(void); +.bi "int sethostid(long " hostid ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br gethostid (): +.nf + since glibc 2.20: + _default_source || _xopen_source >= 500 +.\" || _xopen_source && _xopen_source_extended + up to and including glibc 2.19: + _bsd_source || _xopen_source >= 500 +.\" || _xopen_source && _xopen_source_extended +.fi +.pp +.br sethostid (): +.nf + since glibc 2.21: +.\" commit 266865c0e7b79d4196e2cc393693463f03c90bd8 + _default_source + in glibc 2.19 and 2.20: + _default_source || (_xopen_source && _xopen_source < 500) + up to and including glibc 2.19: + _bsd_source || (_xopen_source && _xopen_source < 500) +.fi +.sh description +.br gethostid () +and +.br sethostid () +respectively get or set a unique 32-bit identifier for the current machine. +the 32-bit identifier was intended to be unique among all unix systems in +existence. +this normally resembles the internet address for the local +machine, as returned by +.br gethostbyname (3), +and thus usually never needs to be set. +.pp +the +.br sethostid () +call is restricted to the superuser. +.sh return value +.br gethostid () +returns the 32-bit identifier for the current host as set by +.br sethostid (). +.pp +on success, +.br sethostid () +returns 0; on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.br sethostid () +can fail with the following errors: +.tp +.b eacces +the caller did not have permission to write to the file used +to store the host id. +.tp +.b eperm +the calling process's effective user or group id is not the same +as its corresponding real id. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lb lb lbx +l l l. +interface attribute value +t{ +.br gethostid () +t} thread safety t{ +mt-safe hostid env locale +t} +t{ +.br sethostid () +t} thread safety t{ +mt-unsafe const:hostid +t} +.te +.hy +.ad +.sp 1 +.sh conforming to +4.2bsd; these functions were dropped in 4.4bsd. +svr4 includes +.br gethostid () +but not +.br sethostid (). +.pp +posix.1-2001 and posix.1-2008 specify +.br gethostid () +but not +.br sethostid (). +.sh notes +in the glibc implementation, the +.i hostid +is stored in the file +.ir /etc/hostid . +(in glibc versions before 2.2, the file +.i /var/adm/hostid +was used.) +.\" libc5 used /etc/hostid; libc4 didn't have these functions +.pp +in the glibc implementation, if +.br gethostid () +cannot open the file containing the host id, +then it obtains the hostname using +.br gethostname (2), +passes that hostname to +.br gethostbyname_r (3) +in order to obtain the host's ipv4 address, +and returns a value obtained by bit-twiddling the ipv4 address. +(this value may not be unique.) +.sh bugs +it is impossible to ensure that the identifier is globally unique. +.sh see also +.br hostid (1), +.br gethostbyname (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/isalpha.3 + +.so man3/cmsg.3 + +.so man3/rcmd.3 + +.so man3/inet.3 + +.\" copyright (c) 2001 andries brouwer . +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th flockfile 3 2021-03-22 "" "linux programmer's manual" +.sh name +flockfile, ftrylockfile, funlockfile \- lock file for stdio +.sh synopsis +.nf +.b #include +.pp +.bi "void flockfile(file *" filehandle ); +.bi "int ftrylockfile(file *" filehandle ); +.bi "void funlockfile(file *" filehandle ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +all functions shown above: +.nf + /* since glibc 2.24: */ _posix_c_source >= 199309l + || /* glibc <= 2.23: */ _posix_c_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.sh description +the stdio functions are thread-safe. +this is achieved by assigning +to each +.i file +object a lockcount and (if the lockcount is nonzero) +an owning thread. +for each library call, these functions wait until the +.i file +object +is no longer locked by a different thread, then lock it, do the +requested i/o, and unlock the object again. +.pp +(note: this locking has nothing to do with the file locking done +by functions like +.br flock (2) +and +.br lockf (3).) +.pp +all this is invisible to the c-programmer, but there may be two +reasons to wish for more detailed control. +on the one hand, maybe +a series of i/o actions by one thread belongs together, and should +not be interrupted by the i/o of some other thread. +on the other hand, maybe the locking overhead should be avoided +for greater efficiency. +.pp +to this end, a thread can explicitly lock the +.i file +object, +then do its series of i/o actions, then unlock. +this prevents +other threads from coming in between. +if the reason for doing +this was to achieve greater efficiency, one does the i/o with +the nonlocking versions of the stdio functions: with +.br getc_unlocked (3) +and +.br putc_unlocked (3) +instead of +.br getc (3) +and +.br putc (3). +.pp +the +.br flockfile () +function waits for +.i *filehandle +to be +no longer locked by a different thread, then makes the +current thread owner of +.ir *filehandle , +and increments +the lockcount. +.pp +the +.br funlockfile () +function decrements the lock count. +.pp +the +.br ftrylockfile () +function is a nonblocking version +of +.br flockfile (). +it does nothing in case some other thread +owns +.ir *filehandle , +and it obtains ownership and increments +the lockcount otherwise. +.sh return value +the +.br ftrylockfile () +function returns zero for success +(the lock was obtained), and nonzero for failure. +.sh errors +none. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br flockfile (), +.br ftrylockfile (), +.br funlockfile () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.pp +these functions are available when +.b _posix_thread_safe_functions +is defined. +.sh see also +.br unlocked_stdio (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/y0.3 + +.so man2/unimplemented.2 + +.\" copyright (c) 1995 andries brouwer (aeb@cwi.nl) +.\" and copyright 2008, 2015 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" written 11 june 1995 by andries brouwer +.\" modified 22 july 1995 by michael chastain : +.\" derived from 'readdir.2'. +.\" modified tue oct 22 08:11:14 edt 1996 by eric s. raymond +.\" +.th getdents 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +getdents, getdents64 \- get directory entries +.sh synopsis +.nf +.br "#include " " /* definition of " sys_* " constants */" +.b #include +.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 "#include " +.pp +.bi "ssize_t getdents64(int " fd ", void *" dirp ", size_t " count ); +.fi +.pp +.ir note : +glibc provides no wrapper for +.br getdents (), +necessitating the use of +.br syscall (2). +.pp +.ir note : +there is no definition of +.i struct linux_dirent +in glibc; see notes. +.sh description +these are not the interfaces you are interested in. +look at +.br readdir (3) +for the posix-conforming c library interface. +this page documents the bare kernel system call interfaces. +.ss getdents() +the system call +.br getdents () +reads several +.i linux_dirent +structures from the directory +referred to by the open file descriptor +.i fd +into the buffer pointed to by +.ir dirp . +the argument +.i count +specifies the size of that buffer. +.pp +the +.i linux_dirent +structure is declared as follows: +.pp +.in +4n +.ex +struct linux_dirent { + unsigned long d_ino; /* inode number */ + unsigned long d_off; /* offset to next \filinux_dirent\fp */ + unsigned short d_reclen; /* length of this \filinux_dirent\fp */ + char d_name[]; /* filename (null\-terminated) */ + /* length is actually (d_reclen \- 2 \- + offsetof(struct linux_dirent, d_name)) */ + /* + char pad; // zero padding byte + char d_type; // file type (only since linux + // 2.6.4); offset is (d_reclen \- 1) + */ +} +.ee +.in +.pp +.i d_ino +is an inode number. +.i d_off +is the distance from the start of the directory to the start of the next +.ir linux_dirent . +.i d_reclen +is the size of this entire +.ir linux_dirent . +.i d_name +is a null-terminated filename. +.pp +.i d_type +is a byte at the end of the structure that indicates the file type. +it contains one of the following values (defined in +.ir ): +.tp 12 +.b dt_blk +this is a block device. +.tp +.b dt_chr +this is a character device. +.tp +.b dt_dir +this is a directory. +.tp +.b dt_fifo +this is a named pipe (fifo). +.tp +.b dt_lnk +this is a symbolic link. +.tp +.b dt_reg +this is a regular file. +.tp +.b dt_sock +this is a unix domain socket. +.tp +.b dt_unknown +the file type is unknown. +.pp +the +.i d_type +field is implemented since linux 2.6.4. +it occupies a space that was previously a zero-filled padding byte in the +.ir linux_dirent +structure. +thus, on kernels up to and including 2.6.3, +attempting to access this field always provides the value 0 +.rb ( dt_unknown ). +.pp +currently, +.\" kernel 2.6.27 +.\" the same sentence is in readdir.2 +only some filesystems (among them: btrfs, ext2, ext3, and ext4) +have full support for returning the file type in +.ir d_type . +all applications must properly handle a return of +.br dt_unknown . +.ss getdents64() +the original linux +.br getdents () +system call did not handle large filesystems and large file offsets. +consequently, linux 2.4 added +.br getdents64 (), +with wider types for the +.i d_ino +and +.i d_off +fields. +in addition, +.br getdents64 () +supports an explicit +.i d_type +field. +.pp +the +.br getdents64 () +system call is like +.br getdents (), +except that its second argument is a pointer to a buffer containing +structures of the following type: +.pp +.in +4n +.ex +struct linux_dirent64 { + ino64_t d_ino; /* 64\-bit inode number */ + off64_t d_off; /* 64\-bit offset to next structure */ + unsigned short d_reclen; /* size of this dirent */ + unsigned char d_type; /* file type */ + char d_name[]; /* filename (null\-terminated) */ +}; +.ee +.in +.sh return value +on success, the number of bytes read is returned. +on end of directory, 0 is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b ebadf +invalid file descriptor +.ir fd . +.tp +.b efault +argument points outside the calling process's address space. +.tp +.b einval +result buffer is too small. +.tp +.b enoent +no such directory. +.tp +.b enotdir +file descriptor does not refer to a directory. +.sh conforming to +svr4. +.\" svr4 documents additional enolink, eio error conditions. +.sh notes +library support for +.br getdents64 () +was added in glibc 2.30; +glibc does not provide a wrapper for +.br getdents (); +call +.br getdents () +(or +.br getdents64 () +on earlier glibc versions) using +.br syscall (2). +in that case you will need to define the +.i linux_dirent +or +.i linux_dirent64 +structure yourself. +.pp +probably, you want to use +.br readdir (3) +instead of these system calls. +.pp +these calls supersede +.br readdir (2). +.sh examples +.\" fixme the example program needs to be revised, since it uses the older +.\" getdents() system call and the structure with smaller field widths. +the program below demonstrates the use of +.br getdents (). +the following output shows an example of what we see when running this +program on an ext2 directory: +.pp +.in +4n +.ex +.rb "$" " ./a.out /testfs/" +-\-\-\-\-\-\-\-\-\-\-\-\-\-\- nread=120 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\- +inode# file type d_reclen d_off d_name + 2 directory 16 12 . + 2 directory 16 24 .. + 11 directory 24 44 lost+found + 12 regular 16 56 a + 228929 directory 16 68 sub + 16353 directory 16 80 sub2 + 130817 directory 16 4096 sub3 +.ee +.in +.ss program source +\& +.ex +#define _gnu_source +#include /* defines dt_* constants */ +#include +#include +#include +#include +#include +#include +#include + +#define handle_error(msg) \e + do { perror(msg); exit(exit_failure); } while (0) + +struct linux_dirent { + unsigned long d_ino; + off_t d_off; + unsigned short d_reclen; + char d_name[]; +}; + +#define buf_size 1024 + +int +main(int argc, char *argv[]) +{ + int fd; + long nread; + char buf[buf_size]; + struct linux_dirent *d; + char d_type; + + fd = open(argc > 1 ? argv[1] : ".", o_rdonly | o_directory); + if (fd == \-1) + handle_error("open"); + + for (;;) { + nread = syscall(sys_getdents, fd, buf, buf_size); + if (nread == \-1) + handle_error("getdents"); + + if (nread == 0) + break; + + printf("\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- nread=%d \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\en", nread); + printf("inode# file type d_reclen d_off d_name\en"); + for (long bpos = 0; bpos < nread;) { + d = (struct linux_dirent *) (buf + bpos); + printf("%8ld ", d\->d_ino); + d_type = *(buf + bpos + d\->d_reclen \- 1); + printf("%\-10s ", (d_type == dt_reg) ? "regular" : + (d_type == dt_dir) ? "directory" : + (d_type == dt_fifo) ? "fifo" : + (d_type == dt_sock) ? "socket" : + (d_type == dt_lnk) ? "symlink" : + (d_type == dt_blk) ? "block dev" : + (d_type == dt_chr) ? "char dev" : "???"); + printf("%4d %10jd %s\en", d\->d_reclen, + (intmax_t) d\->d_off, d\->d_name); + bpos += d\->d_reclen; + } + } + + exit(exit_success); +} +.ee +.sh see also +.br readdir (2), +.br readdir (3), +.br inode (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/log2.3 + +.so man3/xdr.3 + +.so man3/mq_unlink.3 +.\" because mq_unlink(3) is layered on a system call of the same name + +.so man3/acos.3 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" and copyright 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified 1993-07-24 by rik faith (faith@cs.unc.edu) +.\" modified 2002-07-27 by walter harms +.\" (walter.harms@informatik.uni-oldenburg.de) +.\" +.th atanh 3 2021-03-22 "" "linux programmer's manual" +.sh name +atanh, atanhf, atanhl \- inverse hyperbolic tangent function +.sh synopsis +.nf +.b #include +.pp +.bi "double atanh(double " x ); +.bi "float atanhf(float " x ); +.bi "long double atanhl(long double " x ); +.pp +.fi +link with \fi\-lm\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br atanh (): +.nf + _isoc99_source || _posix_c_source >= 200112l + || _xopen_source >= 500 +.\" || _xopen_source && _xopen_source_extended + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.pp +.br atanhf (), +.br atanhl (): +.nf + _isoc99_source || _posix_c_source >= 200112l + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.sh description +these functions calculate the inverse hyperbolic tangent of +.ir x ; +that is the value whose hyperbolic tangent is +.ir x . +.sh return value +on success, these functions return the inverse hyperbolic tangent of +.ir x . +.pp +if +.i x +is a nan, a nan is returned. +.pp +if +.i x +is +0 (\-0), +0 (\-0) is returned. +.pp +if +.i x +is +1 or \-1, +a pole error occurs, +and the functions return +.br huge_val , +.br huge_valf , +or +.br huge_vall , +respectively, with the mathematically correct sign. +.pp +if the absolute value of +.i x +is greater than 1, +a domain error occurs, +and a nan is returned. +.\" +.\" posix.1-2001 documents an optional range error for subnormal x; +.\" glibc 2.8 does not do this. +.sh errors +see +.br math_error (7) +for information on how to determine whether an error has occurred +when calling these functions. +.pp +the following errors can occur: +.tp +domain error: \fix\fp less than \-1 or greater than +1 +.i errno +is set to +.br edom . +an invalid floating-point exception +.rb ( fe_invalid ) +is raised. +.tp +pole error: \fix\fp is +1 or \-1 +.i errno +is set to +.br erange +(but see bugs). +a divide-by-zero floating-point exception +.rb ( fe_divbyzero ) +is raised. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br atanh (), +.br atanhf (), +.br atanhl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.pp +the variant returning +.i double +also conforms to +svr4, 4.3bsd. +.sh bugs +in glibc 2.9 and earlier, +.\" bug: http://sources.redhat.com/bugzilla/show_bug.cgi?id=6759 +.\" this can be seen in sysdeps/ieee754/k_standard.c +when a pole error occurs, +.i errno +is set to +.br edom +instead of the posix-mandated +.br erange . +since version 2.10, glibc does the right thing. +.sh see also +.br acosh (3), +.br asinh (3), +.br catanh (3), +.br cosh (3), +.br sinh (3), +.br tanh (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/log10.3 + +.\" copyright 1993 giorgio ciucci (giorgio@crcc.it) +.\" and copyright (c) 2020 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified tue oct 22 17:54:56 1996 by eric s. raymond +.\" modified 1 jan 2002, martin schulze +.\" modified 4 jan 2002, michael kerrisk +.\" modified, 27 may 2004, michael kerrisk +.\" added notes on capability requirements +.\" modified, 11 nov 2004, michael kerrisk +.\" language and formatting clean-ups +.\" added notes on /proc files +.\" rewrote bugs note about semget()'s failure to initialize +.\" semaphore values +.\" +.th semget 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +semget \- get a system v semaphore set identifier +.sh synopsis +.nf +.b #include +.fi +.pp +.bi "int semget(key_t " key , +.bi "int " nsems , +.bi "int " semflg ); +.sh description +the +.br semget () +system call returns the system\ v semaphore set identifier +associated with the argument +.ir key . +it may be used either to obtain the identifier of a previously created +semaphore set (when +.i semflg +is zero and +.i key +does not have the value +.br ipc_private ), +or to create a new set. +.pp +a new set of +.i nsems +semaphores is created if +.i key +has the value +.b ipc_private +or if no existing semaphore set is associated with +.i key +and +.b ipc_creat +is specified in +.ir semflg . +.pp +if +.i semflg +specifies both +.b ipc_creat +and +.b ipc_excl +and a semaphore set already exists for +.ir key , +then +.br semget () +fails with +.i errno +set to +.br eexist . +(this is analogous to the effect of the combination +.b o_creat | o_excl +for +.br open (2).) +.pp +upon creation, the least significant 9 bits of the argument +.i semflg +define the permissions (for owner, group, and others) +for the semaphore set. +these bits have the same format, and the same +meaning, as the +.i mode +argument of +.br open (2) +(though the execute permissions are +not meaningful for semaphores, and write permissions mean permission +to alter semaphore values). +.pp +when creating a new semaphore set, +.br semget () +initializes the set's associated data structure, +.i semid_ds +(see +.br semctl (2)), +as follows: +.ip \(bu 2 +.i sem_perm.cuid +and +.i sem_perm.uid +are set to the effective user id of the calling process. +.ip \(bu +.i sem_perm.cgid +and +.i sem_perm.gid +are set to the effective group id of the calling process. +.ip \(bu +the least significant 9 bits of +.i sem_perm.mode +are set to the least significant 9 bits of +.ir semflg . +.ip \(bu +.i sem_nsems +is set to the value of +.ir nsems . +.ip \(bu +.i sem_otime +is set to 0. +.ip \(bu +.i sem_ctime +is set to the current time. +.pp +the argument +.i nsems +can be 0 +(a don't care) +when a semaphore set is not being created. +otherwise, +.i nsems +must be greater than 0 +and less than or equal to the maximum number of semaphores per semaphore set +.rb ( semmsl ). +.pp +if the semaphore set already exists, the permissions are +verified. +.\" and a check is made to see if it is marked for destruction. +.sh return value +on success, +.br semget () +returns the semaphore set identifier (a nonnegative integer). +on failure, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eacces +a semaphore set exists for +.ir key , +but the calling process does not have permission to access the set, +and does not have the +.b cap_ipc_owner +capability in the user namespace that governs its ipc namespace. +.tp +.b eexist +.b ipc_creat +and +.br ipc_excl +were specified in +.ir semflg , +but a semaphore set already exists for +.ir key . +.\" .tp +.\" .b eidrm +.\" the semaphore set is marked to be deleted. +.tp +.b einval +.i nsems +is less than 0 or greater than the limit on the number +of semaphores per semaphore set +.rb ( semmsl ). +.tp +.b einval +a semaphore set corresponding to +.i key +already exists, but +.i nsems +is larger than the number of semaphores in that set. +.tp +.b enoent +no semaphore set exists for +.i key +and +.i semflg +did not specify +.br ipc_creat . +.tp +.b enomem +a semaphore set has to be created but the system does not have +enough memory for the new data structure. +.tp +.b enospc +a semaphore set has to be created but the system limit for the maximum +number of semaphore sets +.rb ( semmni ), +or the system wide maximum number of semaphores +.rb ( semmns ), +would be exceeded. +.sh conforming to +svr4, posix.1-2001. +.\" svr4 documents additional error conditions efbig, e2big, eagain, +.\" erange, efault. +.sh notes +.b ipc_private +isn't a flag field but a +.i key_t +type. +if this special value is used for +.ir key , +the system call ignores all but the least significant 9 bits of +.i semflg +and creates a new semaphore set (on success). +.\" +.ss semaphore initialization +the values of the semaphores in a newly created set are indeterminate. +(posix.1-2001 and posix.1-2008 are explicit on this point, +although posix.1-2008 notes that a future version of the standard +may require an implementation to initialize the semaphores to 0.) +although linux, like many other implementations, +initializes the semaphore values to 0, +a portable application cannot rely on this: +it should explicitly initialize the semaphores to the desired values. +.\" in truth, every one of the many implementations that i've tested sets +.\" the values to zero, but i suppose there is/was some obscure +.\" implementation out there that does not. +.pp +initialization can be done using +.br semctl (2) +.b setval +or +.b setall +operation. +where multiple peers do not know who will be the first to +initialize the set, checking for a nonzero +.i sem_otime +in the associated data structure retrieved by a +.br semctl (2) +.b ipc_stat +operation can be used to avoid races. +.\" +.ss semaphore limits +the following limits on semaphore set resources affect the +.br semget () +call: +.tp +.b semmni +system-wide limit on the number of semaphore sets. +on linux systems before version 3.19, +the default value for this limit was 128. +since linux 3.19, +.\" commit e843e7d2c88b7db107a86bd2c7145dc715c058f4 +the default value is 32,000. +on linux, this limit can be read and modified via the fourth field of +.ir /proc/sys/kernel/sem . +.\" this /proc file is not available in linux 2.2 and earlier -- mtk +.tp +.b semmsl +maximum number of semaphores per semaphore id. +on linux systems before version 3.19, +the default value for this limit was 250. +since linux 3.19, +.\" commit e843e7d2c88b7db107a86bd2c7145dc715c058f4 +the default value is 32,000. +on linux, this limit can be read and modified via the first field of +.ir /proc/sys/kernel/sem . +.tp +.b semmns +system-wide limit on the number of semaphores: policy dependent +(on linux, this limit can be read and modified via the second field of +.ir /proc/sys/kernel/sem ). +note that the number of semaphores system-wide +is also limited by the product of +.b semmsl +and +.br semmni . +.sh bugs +the name choice +.b ipc_private +was perhaps unfortunate, +.b ipc_new +would more clearly show its function. +.sh examples +the program shown below uses +.br semget () +to create a new semaphore set or retrieve the id of an existing set. +it generates the +.i key +for +.br semget () +using +.br ftok (3). +the first two command-line arguments are used as the +.i pathname +and +.i proj_id +arguments for +.br ftok (3). +the third command-line argument is an integer that specifies the +.i nsems +argument for +.br semget (). +command-line options can be used to specify the +.br ipc_creat +.ri ( \-c ) +and +.br ipc_excl +.ri ( \-x ) +flags for the call to +.br semget (). +the usage of this program is demonstrated below. +.pp +we first create two files that will be used to generate keys using +.br ftok (3), +create two semaphore sets using those files, and then list the sets using +.br ipcs (1): +.pp +.in +4n +.ex +$ \fbtouch mykey mykey2\fp +$ \fb./t_semget \-c mykey p 1\fp +id = 9 +$ \fb./t_semget \-c mykey2 p 2\fp +id = 10 +$ \fbipcs \-s\fp + +\-\-\-\-\-\- semaphore arrays \-\-\-\-\-\-\-\- +key semid owner perms nsems +0x7004136d 9 mtk 600 1 +0x70041368 10 mtk 600 2 +.ee +.in +.pp +next, we demonstrate that when +.br semctl (2) +is given the same +.i key +(as generated by the same arguments to +.br ftok (3)), +it returns the id of the already existing semaphore set: +.pp +.in +4n +.ex +$ \fb./t_semget \-c mykey p 1\fp +id = 9 +.ee +.in +.pp +finally, we demonstrate the kind of collision that can occur when +.br ftok (3) +is given different +.i pathname +arguments that have the same inode number: +.pp +.in +4n +.ex +$ \fbln mykey link\fp +$ \fbls \-i1 link mykey\fp +2233197 link +2233197 mykey +$ \fb./t_semget link p 1\fp # generates same key as \(aqmykey\(aq +id = 9 +.ee +.in +.ss program source +\& +.ex +/* t_semget.c + + licensed under gnu general public license v2 or later. +*/ +#include +#include +#include +#include +#include +#include +#include + +static void +usage(const char *pname) +{ + fprintf(stderr, "usage: %s [\-cx] pathname proj\-id num\-sems\en", + pname); + fprintf(stderr, " \-c use ipc_creat flag\en"); + fprintf(stderr, " \-x use ipc_excl flag\en"); + exit(exit_failure); +} + +int +main(int argc, char *argv[]) +{ + int semid, nsems, flags, opt; + key_t key; + + flags = 0; + while ((opt = getopt(argc, argv, "cx")) != \-1) { + switch (opt) { + case \(aqc\(aq: flags |= ipc_creat; break; + case \(aqx\(aq: flags |= ipc_excl; break; + default: usage(argv[0]); + } + } + + if (argc != optind + 3) + usage(argv[0]); + + key = ftok(argv[optind], argv[optind + 1][0]); + if (key == \-1) { + perror("ftok"); + exit(exit_failure); + } + + nsems = atoi(argv[optind + 2]); + + semid = semget(key, nsems, flags | 0600); + if (semid == \-1) { + perror("semget"); + exit(exit_failure); + } + + printf("id = %d\en", semid); + + exit(exit_success); +} +.ee +.sh see also +.br semctl (2), +.br semop (2), +.br ftok (3), +.br capabilities (7), +.br sem_overview (7), +.br sysvipc (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/getnetent.3 + +.so man3/stailq.3 + +.\" copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de) +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under gpl +.\" %%%license_end +.\" +.\" based on glibc infopages +.\" and copyright 2008, linux foundation, written by michael kerrisk +.\" +.\" modified 2004-11-15, fixed error noted by fabian kreutz +.\" +.\" +.th tgamma 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +tgamma, tgammaf, tgammal \- true gamma function +.sh synopsis +.nf +.b #include +.pp +.bi "double tgamma(double " x ); +.bi "float tgammaf(float " x ); +.bi "long double tgammal(long double " x ); +.fi +.pp +link with \fi\-lm\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br tgamma (), +.br tgammaf (), +.br tgammal (): +.nf + _isoc99_source || _posix_c_source >= 200112l +.fi +.sh description +these functions calculate the gamma function of +.ir x . +.pp +the gamma function is defined by +.pp +.rs +gamma(x) = integral from 0 to infinity of t^(x\-1) e^\-t dt +.re +.pp +it is defined for every real number except for nonpositive integers. +for nonnegative integral +.i m +one has +.pp +.rs +gamma(m+1) = m! +.re +.pp +and, more generally, for all +.ir x : +.pp +.rs +gamma(x+1) = x * gamma(x) +.re +.pp +furthermore, the following is valid for all values of +.i x +outside the poles: +.pp +.rs +gamma(x) * gamma(1 \- x) = pi / sin(pi * x) +.re +.sh return value +on success, these functions return gamma(x). +.pp +if +.i x +is a nan, a nan is returned. +.pp +if +.i x +is positive infinity, positive infinity is returned. +.pp +if +.i x +is a negative integer, or is negative infinity, +a domain error occurs, +and a nan is returned. +.pp +if the result overflows, +a range error occurs, +and the functions return +.br huge_val , +.br huge_valf , +or +.br huge_vall , +respectively, with the correct mathematical sign. +.pp +if the result underflows, +a range error occurs, +and the functions return 0, with the correct mathematical sign. +.pp +if +.i x +is \-0 or +0, +a pole error occurs, +and the functions return +.br huge_val , +.br huge_valf , +or +.br huge_vall , +respectively, with the same sign as the 0. +.sh errors +see +.br math_error (7) +for information on how to determine whether an error has occurred +when calling these functions. +.pp +the following errors can occur: +.tp +domain error: \fix\fp is a negative integer, or negative infinity +.i errno +is set to +.br edom . +an invalid floating-point exception +.rb ( fe_invalid ) +is raised (but see bugs). +.tp +pole error: \fix\fp is +0 or \-0 +.i errno +is set to +.br erange . +a divide-by-zero floating-point exception +.rb ( fe_divbyzero ) +is raised. +.tp +range error: result overflow +.i errno +is set to +.br erange . +an overflow floating-point exception +.rb ( fe_overflow ) +is raised. +.pp +glibc also gives the following error which is not specified +in c99 or posix.1-2001. +.tp +range error: result underflow +.\" e.g., tgamma(-172.5) on glibc 2.8/x86-32 +.\" .i errno +.\" is set to +.\" .br erange . +an underflow floating-point exception +.rb ( fe_underflow ) +is raised, and +.i errno +is set to +.br erange . +.\" glibc (as at 2.8) also supports an inexact +.\" exception for various cases. +.sh versions +these functions first appeared in glibc in version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br tgamma (), +.br tgammaf (), +.br tgammal () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.sh notes +this function had to be called "true gamma function" +since there is already a function +.br gamma (3) +that returns something else (see +.br gamma (3) +for details). +.sh bugs +before version 2.18, the glibc implementation of these functions did not set +.\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=6809 +.i errno +to +.b edom +when +.i x +is negative infinity. +.pp +before glibc 2.19, +.\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=6810 +the glibc implementation of these functions did not set +.i errno +to +.b erange +on an underflow range error. +.pp +.\" +in glibc versions 2.3.3 and earlier, +an argument of +0 or \-0 incorrectly produced a domain error +.ri ( errno +set to +.b edom +and an +.b fe_invalid +exception raised), rather than a pole error. +.sh see also +.br gamma (3), +.br lgamma (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/cpu_set.3 + +.so man3/csinh.3 + +.\" copyright 2003 abhijit menon-sen +.\" and copyright (c) 2008 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th gettid 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +gettid \- get thread identification +.sh synopsis +.nf +.b #define _gnu_source +.b #include +.pp +.b pid_t gettid(void); +.fi +.sh description +.br gettid () +returns the caller's thread id (tid). +in a single-threaded process, the thread id +is equal to the process id (pid, as returned by +.br getpid (2)). +in a multithreaded process, all threads +have the same pid, but each one has a unique tid. +for further details, see the discussion of +.br clone_thread +in +.br clone (2). +.sh return value +on success, returns the thread id of the calling thread. +.sh errors +this call is always successful. +.sh versions +the +.br gettid () +system call first appeared on linux in kernel 2.4.11. +library support was added in glibc 2.30. +(earlier glibc versions did not provide a wrapper for this system call, +necessitating the use of +.br syscall (2).) +.sh conforming to +.br gettid () +is linux-specific and should not be used in programs that +are intended to be portable. +.sh notes +the thread id returned by this call is not the same thing as a +posix thread id (i.e., the opaque value returned by +.br pthread_self (3)). +.pp +in a new thread group created by a +.br clone (2) +call that does not specify the +.br clone_thread +flag (or, equivalently, a new process created by +.br fork (2)), +the new process is a thread group leader, +and its thread group id (the value returned by +.br getpid (2)) +is the same as its thread id (the value returned by +.br gettid ()). +.sh see also +.br capget (2), +.br clone (2), +.br fcntl (2), +.br fork (2), +.br get_robust_list (2), +.br getpid (2), +.\" .br kcmp (2), +.br ioprio_set (2), +.\" .br move_pages (2), +.\" .br migrate_pages (2), +.br perf_event_open (2), +.\" .br process_vm_readv (2), +.\" .br ptrace (2), +.br sched_setaffinity (2), +.br sched_setparam (2), +.br sched_setscheduler (2), +.br tgkill (2), +.br timer_create (2) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1993 michael haardt +.\" (michael@moria.de) +.\" fri apr 2 11:32:09 met dst 1993 +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" modified sat jul 24 14:23:14 1993 by rik faith (faith@cs.unc.edu) +.\" modified sun oct 18 17:31:43 1998 by andries brouwer (aeb@cwi.nl) +.\" 2008-06-23, mtk, minor rewrites, added some details +.\" +.th ftime 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +ftime \- return date and time +.sh synopsis +.nf +.b "#include " +.pp +.bi "int ftime(struct timeb *" tp ); +.fi +.sh description +.br note : +this function is no longer provided by the gnu c library. +use +.br clock_gettime (2) +instead. +.pp +this function returns the current time as seconds and milliseconds +since the epoch, 1970-01-01 00:00:00 +0000 (utc). +the time is returned in +.ir tp , +which is declared as follows: +.pp +.in +4n +.ex +struct timeb { + time_t time; + unsigned short millitm; + short timezone; + short dstflag; +}; +.ee +.in +.pp +here \fitime\fp is the number of seconds since the epoch, +and \fimillitm\fp is the number of milliseconds since \fitime\fp +seconds since the epoch. +the \fitimezone\fp field is the local timezone measured in minutes +of time west of greenwich (with a negative value indicating minutes +east of greenwich). +the \fidstflag\fp field +is a flag that, if nonzero, indicates that daylight saving time +applies locally during the appropriate part of the year. +.pp +posix.1-2001 says that the contents of the \fitimezone\fp and \fidstflag\fp +fields are unspecified; avoid relying on them. +.sh return value +this function always returns 0. +(posix.1-2001 specifies, and some systems document, a \-1 error return.) +.sh versions +starting with glibc 2.33, the +.br ftime () +function and the +.i +header have been removed. +to support old binaries, +glibc continues to provide a compatibility symbol for +applications linked against glibc 2.32 and earlier. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br ftime () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +4.2bsd, posix.1-2001. +posix.1-2008 removes the specification of +.br ftime (). +.pp +this function is obsolete. +don't use it. +if the time in seconds +suffices, +.br time (2) +can be used; +.br gettimeofday (2) +gives microseconds; +.br clock_gettime (2) +gives nanoseconds but is not as widely available. +.sh bugs +early glibc2 is buggy and returns 0 in the +.i millitm +field; +glibc 2.1.1 is correct again. +.\" .sh history +.\" the +.\" .br ftime () +.\" function appeared in 4.2bsd. +.sh see also +.br gettimeofday (2), +.br time (2) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1999 andries brouwer (aeb@cwi.nl) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" rewritten old page, 990824, aeb@cwi.nl +.\" 2004-12-14, mtk, added discussion of resolved_path == null +.\" +.th realpath 3 2021-03-22 "" "linux programmer's manual" +.sh name +realpath \- return the canonicalized absolute pathname +.sh synopsis +.nf +.b #include +.b #include +.pp +.bi "char *realpath(const char *restrict " path , +.bi " char *restrict " resolved_path ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br realpath (): +.nf + _xopen_source >= 500 +.\" || _xopen_source && _xopen_source_extended + || /* glibc since 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source +.fi +.sh description +.br realpath () +expands all symbolic links and resolves references +to +.ir "/./" ", " "/../" +and extra \(aq/\(aq +characters in the null-terminated string named by +.i path +to produce a canonicalized absolute pathname. +the resulting pathname is stored as a null-terminated string, +up to a maximum of +.b path_max +bytes, +in the buffer pointed to by +.ir resolved_path . +the resulting path will have no symbolic link, +.i "/./" +or +.i "/../" +components. +.pp +if +.i resolved_path +is specified as null, then +.br realpath () +uses +.br malloc (3) +to allocate a buffer of up to +.b path_max +bytes to hold the resolved pathname, +and returns a pointer to this buffer. +the caller should deallocate this buffer using +.br free (3). +.\" even if we use resolved_path == null, then realpath() will still +.\" return enametoolong if the resolved pathname would exceed path_max +.\" bytes -- mtk, dec 04 +.\" .sh history +.\" the +.\" .br realpath () +.\" function first appeared in 4.4bsd, contributed by jan-simon pendry. +.sh return value +if there is no error, +.br realpath () +returns a pointer to the +.ir resolved_path . +.pp +otherwise, it returns null, the contents +of the array +.i resolved_path +are undefined, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eacces +read or search permission was denied for a component of the path prefix. +.tp +.b einval +.i path +is null. +.\" (in libc5 this would just cause a segfault.) +(in glibc versions before 2.3, +this error is also returned if +.ir resolved_path +is null.) +.tp +.b eio +an i/o error occurred while reading from the filesystem. +.tp +.b eloop +too many symbolic links were encountered in translating the pathname. +.tp +.b enametoolong +a component of a pathname exceeded +.b name_max +characters, or an entire pathname exceeded +.b path_max +characters. +.tp +.b enoent +the named file does not exist. +.tp +.b enomem +out of memory. +.tp +.b enotdir +a component of the path prefix is not a directory. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br realpath () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +4.4bsd, posix.1-2001. +.pp +posix.1-2001 says that the behavior if +.i resolved_path +is null is implementation-defined. +posix.1-2008 specifies the behavior described in this page. +.sh notes +in 4.4bsd and solaris, the limit on the pathname length is +.b maxpathlen +(found in \fi\fp). +susv2 prescribes +.b path_max +and +.br name_max , +as found in \fi\fp or provided by the +.br pathconf (3) +function. +a typical source fragment would be +.pp +.in +4n +.ex +#ifdef path_max + path_max = path_max; +#else + path_max = pathconf(path, _pc_path_max); + if (path_max <= 0) + path_max = 4096; +#endif +.ee +.in +.pp +(but see the bugs section.) +.\".pp +.\" 2012-05-05, according to casper dik, the statement about +.\" solaris was not true at least as far back as 1997, and +.\" may never have been true. +.\" +.\" the 4.4bsd, linux and susv2 versions always return an absolute +.\" pathname. +.\" solaris may return a relative pathname when the +.\" .i path +.\" argument is relative. +.\" the prototype of +.\" .br realpath () +.\" is given in \fi\fp in libc4 and libc5, +.\" but in \fi\fp everywhere else. +.ss gnu extensions +if the call fails with either +.br eacces +or +.br enoent +and +.i resolved_path +is not null, then the prefix of +.i path +that is not readable or does not exist is returned in +.ir resolved_path . +.sh bugs +the posix.1-2001 standard version of this function is broken by design, +since it is impossible to determine a suitable size for the output buffer, +.ir resolved_path . +according to posix.1-2001 a buffer of size +.b path_max +suffices, but +.b path_max +need not be a defined constant, and may have to be obtained using +.br pathconf (3). +and asking +.br pathconf (3) +does not really help, since, on the one hand posix warns that +the result of +.br pathconf (3) +may be huge and unsuitable for mallocing memory, +and on the other hand +.br pathconf (3) +may return \-1 to signify that +.b path_max +is not bounded. +the +.i "resolved_path\ ==\ null" +feature, not standardized in posix.1-2001, +but standardized in posix.1-2008, allows this design problem to be avoided. +.\" .lp +.\" the libc4 and libc5 implementation contained a buffer overflow +.\" (fixed in libc-5.4.13). +.\" thus, set-user-id programs like +.\" .br mount (8) +.\" needed a private version. +.sh see also +.br realpath (1), +.br readlink (2), +.br canonicalize_file_name (3), +.br getcwd (3), +.br pathconf (3), +.br sysconf (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/printf.3 + +.so man7/iso_8859-13.7 + +.so man3/getgrnam.3 + +.\" copyright 1993 giorgio ciucci +.\" and copyright 2015 bill pemberton +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified tue oct 22 16:40:11 1996 by eric s. raymond +.\" modified mon jul 10 21:09:59 2000 by aeb +.\" modified 1 jun 2002, michael kerrisk +.\" language clean-ups. +.\" enhanced and corrected information on msg_qbytes, msgmnb and msgmax +.\" added note on restart behavior of msgsnd() and msgrcv() +.\" formatting clean-ups (argument and field names marked as .i +.\" instead of .b) +.\" modified, 27 may 2004, michael kerrisk +.\" added notes on capability requirements +.\" modified, 11 nov 2004, michael kerrisk +.\" language and formatting clean-ups +.\" added notes on /proc files +.\" +.th msgop 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +msgrcv, msgsnd \- system v message queue operations +.sh synopsis +.nf +.b #include +.pp +.bi "int msgsnd(int " msqid ", const void *" msgp ", size_t " msgsz \ +", int " msgflg ); +.pp +.bi "ssize_t msgrcv(int " msqid ", void *" msgp ", size_t " msgsz \ +", long " msgtyp , +.bi " int " msgflg ); +.fi +.sh description +the +.br msgsnd () +and +.br msgrcv () +system calls are used to send messages to, +and receive messages from, a system\ v message queue. +the calling process must have write permission on the message queue +in order to send a message, and read permission to receive a message. +.pp +the +.i msgp +argument is a pointer to a caller-defined structure +of the following general form: +.pp +.in +4n +.ex +struct msgbuf { + long mtype; /* message type, must be > 0 */ + char mtext[1]; /* message data */ +}; +.ee +.in +.pp +the +.i mtext +field is an array (or other structure) whose size is specified by +.ir msgsz , +a nonnegative integer value. +messages of zero length (i.e., no +.i mtext +field) are permitted. +the +.i mtype +field must have a strictly positive integer value. +this value can be +used by the receiving process for message selection +(see the description of +.br msgrcv () +below). +.ss msgsnd() +the +.br msgsnd () +system call appends a copy of the message pointed to by +.i msgp +to the message queue whose identifier is specified +by +.ir msqid . +.pp +if sufficient space is available in the queue, +.br msgsnd () +succeeds immediately. +the queue capacity is governed by the +.i msg_qbytes +field in the associated data structure for the message queue. +during queue creation this field is initialized to +.b msgmnb +bytes, but this limit can be modified using +.br msgctl (2). +a message queue is considered to be full if either of the following +conditions is true: +.ip \(bu 2 +adding a new message to the queue would cause the total number of bytes +in the queue to exceed the queue's maximum size (the +.i msg_qbytes +field). +.ip \(bu +adding another message to the queue would cause the total number of messages +in the queue to exceed the queue's maximum size (the +.i msg_qbytes +field). +this check is necessary to prevent an unlimited number of zero-length +messages being placed on the queue. +although such messages contain no data, +they nevertheless consume (locked) kernel memory. +.pp +if insufficient space is available in the queue, then the default +behavior of +.br msgsnd () +is to block until space becomes available. +if +.b ipc_nowait +is specified in +.ir msgflg , +then the call instead fails with the error +.br eagain . +.pp +a blocked +.br msgsnd () +call may also fail if: +.ip \(bu 2 +the queue is removed, +in which case the system call fails with +.i errno +set to +.br eidrm ; +or +.ip \(bu +a signal is caught, in which case the system call fails +with +.i errno +set to +.br eintr ; see +.br signal (7). +.rb ( msgsnd () +is never automatically restarted after being interrupted by a +signal handler, regardless of the setting of the +.b sa_restart +flag when establishing a signal handler.) +.pp +upon successful completion the message queue data structure is updated +as follows: +.ip \(bu 2 +.i msg_lspid +is set to the process id of the calling process. +.ip \(bu +.i msg_qnum +is incremented by 1. +.ip \(bu +.i msg_stime +is set to the current time. +.ss msgrcv() +the +.br msgrcv () +system call removes a message from the queue specified by +.i msqid +and places it in the buffer +pointed to by +.ir msgp . +.pp +the argument +.i msgsz +specifies the maximum size in bytes for the member +.i mtext +of the structure pointed to by the +.i msgp +argument. +if the message text has length greater than +.ir msgsz , +then the behavior depends on whether +.b msg_noerror +is specified in +.ir msgflg . +if +.b msg_noerror +is specified, then +the message text will be truncated (and the truncated part will be +lost); if +.b msg_noerror +is not specified, then +the message isn't removed from the queue and +the system call fails returning \-1 with +.i errno +set to +.br e2big . +.pp +unless +.b msg_copy +is specified in +.ir msgflg +(see below), +the +.i msgtyp +argument specifies the type of message requested, as follows: +.ip \(bu 2 +if +.i msgtyp +is 0, +then the first message in the queue is read. +.ip \(bu +if +.i msgtyp +is greater than 0, +then the first message in the queue of type +.i msgtyp +is read, unless +.b msg_except +was specified in +.ir msgflg , +in which case +the first message in the queue of type not equal to +.i msgtyp +will be read. +.ip \(bu +if +.i msgtyp +is less than 0, +then the first message in the queue with the lowest type less than or +equal to the absolute value of +.i msgtyp +will be read. +.pp +the +.i msgflg +argument is a bit mask constructed by oring together zero or more +of the following flags: +.tp +.b ipc_nowait +return immediately if no message of the requested type is in the queue. +the system call fails with +.i errno +set to +.br enomsg . +.tp +.br msg_copy " (since linux 3.8)" +.\" commit 4a674f34ba04a002244edaf891b5da7fc1473ae8 +nondestructively fetch a copy of the message at the ordinal position +in the queue specified by +.i msgtyp +(messages are considered to be numbered starting at 0). +.ip +this flag must be specified in conjunction with +.br ipc_nowait , +with the result that, if there is no message available at the given position, +the call fails immediately with the error +.br enomsg . +because they alter the meaning of +.i msgtyp +in orthogonal ways, +.br msg_copy +and +.br msg_except +may not both be specified in +.ir msgflg . +.ip +the +.br msg_copy +flag was added for the implementation of +the kernel checkpoint-restore facility and +is available only if the kernel was built with the +.b config_checkpoint_restore +option. +.tp +.b msg_except +used with +.i msgtyp +greater than 0 +to read the first message in the queue with message type that differs +from +.ir msgtyp . +.tp +.b msg_noerror +to truncate the message text if longer than +.i msgsz +bytes. +.pp +if no message of the requested type is available and +.b ipc_nowait +isn't specified in +.ir msgflg , +the calling process is blocked until one of the following conditions occurs: +.ip \(bu 2 +a message of the desired type is placed in the queue. +.ip \(bu +the message queue is removed from the system. +in this case, the system call fails with +.i errno +set to +.br eidrm . +.ip \(bu +the calling process catches a signal. +in this case, the system call fails with +.i errno +set to +.br eintr . +.rb ( msgrcv () +is never automatically restarted after being interrupted by a +signal handler, regardless of the setting of the +.b sa_restart +flag when establishing a signal handler.) +.pp +upon successful completion the message queue data structure is updated +as follows: +.ip +.i msg_lrpid +is set to the process id of the calling process. +.ip +.i msg_qnum +is decremented by 1. +.ip +.i msg_rtime +is set to the current time. +.sh return value +on success, +.br msgsnd () +returns 0 +and +.br msgrcv () +returns the number of bytes actually copied into the +.i mtext +array. +on failure, both functions return \-1, and set +.i errno +to indicate the error. +.sh errors +.br msgsnd () +can fail with the following errors: +.tp +.b eacces +the calling process does not have write permission on the message queue, +and does not have the +.b cap_ipc_owner +capability in the user namespace that governs its ipc namespace. +.tp +.b eagain +the message can't be sent due to the +.i msg_qbytes +limit for the queue and +.b ipc_nowait +was specified in +.ir msgflg . +.tp +.b efault +the address pointed to by +.i msgp +isn't accessible. +.tp +.b eidrm +the message queue was removed. +.tp +.b eintr +sleeping on a full message queue condition, the process caught a signal. +.tp +.b einval +invalid +.i msqid +value, or nonpositive +.i mtype +value, or +invalid +.i msgsz +value (less than 0 or greater than the system value +.br msgmax ). +.tp +.b enomem +the system does not have enough memory to make a copy of the +message pointed to by +.ir msgp . +.pp +.br msgrcv () +can fail with the following errors: +.tp +.b e2big +the message text length is greater than +.i msgsz +and +.b msg_noerror +isn't specified in +.ir msgflg . +.tp +.b eacces +the calling process does not have read permission on the message queue, +and does not have the +.b cap_ipc_owner +capability in the user namespace that governs its ipc namespace. +.tp +.b efault +the address pointed to by +.i msgp +isn't accessible. +.tp +.b eidrm +while the process was sleeping to receive a message, +the message queue was removed. +.tp +.b eintr +while the process was sleeping to receive a message, +the process caught a signal; see +.br signal (7). +.tp +.b einval +.i msqid +was invalid, or +.i msgsz +was less than 0. +.tp +.br einval " (since linux 3.14)" +.i msgflg +specified +.br msg_copy , +but not +.br ipc_nowait . +.tp +.br einval " (since linux 3.14)" +.i msgflg +specified both +.br msg_copy +and +.br msg_except . +.tp +.b enomsg +.b ipc_nowait +was specified in +.i msgflg +and no message of the requested type existed on the message queue. +.tp +.b enomsg +.b ipc_nowait +and +.b msg_copy +were specified in +.i msgflg +and the queue contains less than +.i msgtyp +messages. +.tp +.br enosys " (since linux 3.8)" +both +.b msg_copy +and +.b ipc_nowait +were specified in +.ir msgflg , +and this kernel was configured without +.br config_checkpoint_restore . +.sh conforming to +posix.1-2001, posix.1-2008, svr4. +.pp +the +.b msg_except +and +.b msg_copy +flags are linux-specific; +their definitions can be obtained by defining the +.b _gnu_source +.\" msg_copy since glibc 2.18 +feature test macro. +.sh notes +the +.i msgp +argument is declared as \fistruct msgbuf\ *\fp in +glibc 2.0 and 2.1. +it is declared as \fivoid\ *\fp +in glibc 2.2 and later, as required by susv2 and susv3. +.pp +the following limits on message queue resources affect the +.br msgsnd () +call: +.tp +.b msgmax +maximum size of a message text, in bytes (default value: 8192 bytes). +on linux, this limit can be read and modified via +.ir /proc/sys/kernel/msgmax . +.tp +.b msgmnb +maximum number of bytes that can be held in a message queue +(default value: 16384 bytes). +on linux, this limit can be read and modified via +.ir /proc/sys/kernel/msgmnb . +a privileged process +(linux: a process with the +.b cap_sys_resource +capability) +can increase the size of a message queue beyond +.b msgmnb +using the +.br msgctl (2) +.b ipc_set +operation. +.pp +the implementation has no intrinsic system-wide limits on the +number of message headers +.rb ( msgtql ) +and the number of bytes in the message pool +.rb ( msgpool ). +.sh bugs +in linux 3.13 and earlier, +if +.br msgrcv () +was called with the +.br msg_copy +flag, but without +.br ipc_nowait , +and the message queue contained less than +.i msgtyp +messages, then the call would block until the next message is written +to the queue. +.\" http://marc.info/?l=linux-kernel&m=139048542803605&w=2 +at that point, the call would return a copy of the message, +.i regardless +of whether that message was at the ordinal position +.ir msgtyp . +this bug is fixed +.\" commit 4f87dac386cc43d5525da7a939d4b4e7edbea22c +in linux 3.14. +.pp +specifying both +.b msg_copy +and +.b msc_except +in +.i msgflg +is a logical error (since these flags impose different interpretations on +.ir msgtyp ). +in linux 3.13 and earlier, +.\" http://marc.info/?l=linux-kernel&m=139048542803605&w=2 +this error was not diagnosed by +.br msgrcv (). +this bug is fixed +.\" commit 4f87dac386cc43d5525da7a939d4b4e7edbea22c +in linux 3.14. +.sh examples +the program below demonstrates the use of +.br msgsnd () +and +.br msgrcv (). +.pp +the example program is first run with the \fb\-s\fp option to send a +message and then run again with the \fb\-r\fp option to receive a +message. +.pp +the following shell session shows a sample run of the program: +.pp +.in +4n +.ex +.rb "$" " ./a.out \-s" +sent: a message at wed mar 4 16:25:45 2015 + +.rb "$" " ./a.out \-r" +message received: a message at wed mar 4 16:25:45 2015 +.ee +.in +.ss program source +\& +.ex +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct msgbuf { + long mtype; + char mtext[80]; +}; + +static void +usage(char *prog_name, char *msg) +{ + if (msg != null) + fputs(msg, stderr); + + fprintf(stderr, "usage: %s [options]\en", prog_name); + fprintf(stderr, "options are:\en"); + fprintf(stderr, "\-s send message using msgsnd()\en"); + fprintf(stderr, "\-r read message using msgrcv()\en"); + fprintf(stderr, "\-t message type (default is 1)\en"); + fprintf(stderr, "\-k message queue key (default is 1234)\en"); + exit(exit_failure); +} + +static void +send_msg(int qid, int msgtype) +{ + struct msgbuf msg; + time_t t; + + msg.mtype = msgtype; + + time(&t); + snprintf(msg.mtext, sizeof(msg.mtext), "a message at %s", + ctime(&t)); + + if (msgsnd(qid, &msg, sizeof(msg.mtext), + ipc_nowait) == \-1) { + perror("msgsnd error"); + exit(exit_failure); + } + printf("sent: %s\en", msg.mtext); +} + +static void +get_msg(int qid, int msgtype) +{ + struct msgbuf msg; + + if (msgrcv(qid, &msg, sizeof(msg.mtext), msgtype, + msg_noerror | ipc_nowait) == \-1) { + if (errno != enomsg) { + perror("msgrcv"); + exit(exit_failure); + } + printf("no message available for msgrcv()\en"); + } else + printf("message received: %s\en", msg.mtext); +} + +int +main(int argc, char *argv[]) +{ + int qid, opt; + int mode = 0; /* 1 = send, 2 = receive */ + int msgtype = 1; + int msgkey = 1234; + + while ((opt = getopt(argc, argv, "srt:k:")) != \-1) { + switch (opt) { + case \(aqs\(aq: + mode = 1; + break; + case \(aqr\(aq: + mode = 2; + break; + case \(aqt\(aq: + msgtype = atoi(optarg); + if (msgtype <= 0) + usage(argv[0], "\-t option must be greater than 0\en"); + break; + case \(aqk\(aq: + msgkey = atoi(optarg); + break; + default: + usage(argv[0], "unrecognized option\en"); + } + } + + if (mode == 0) + usage(argv[0], "must use either \-s or \-r option\en"); + + qid = msgget(msgkey, ipc_creat | 0666); + + if (qid == \-1) { + perror("msgget"); + exit(exit_failure); + } + + if (mode == 2) + get_msg(qid, msgtype); + else + send_msg(qid, msgtype); + + exit(exit_success); +} +.ee +.sh see also +.br msgctl (2), +.br msgget (2), +.br capabilities (7), +.br mq_overview (7), +.br sysvipc (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/sigvec.3 + +.so man7/iso_8859-6.7 + +.so man2/unimplemented.2 + +.\" copyright (c) 2018, red hat, inc. all rights reserved. +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.th ioctl_fslabel 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +ioctl_fslabel \- get or set a filesystem label +.sh synopsis +.nf +.br "#include " " /* definition of " *fslabel* " constants */" +.b #include +.pp +.bi "int ioctl(int " fd ", fs_ioc_getfslabel, char " label [fslabel_max]); +.bi "int ioctl(int " fd ", fs_ioc_setfslabel, char " label [fslabel_max]); +.fi +.sh description +if a filesystem supports online label manipulation, these +.br ioctl (2) +operations can be used to get or set the filesystem label for the filesystem +on which +.i fd +resides. +the +.b fs_ioc_setfslabel +operation requires privilege +.rb ( cap_sys_admin ). +.sh return value +on success zero is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +possible errors include (but are not limited to) the following: +.tp +.b efault +.i label +references an inaccessible memory area. +.tp +.b einval +the specified label exceeds the maximum label length for the filesystem. +.tp +.b enotty +this can appear if the filesystem does not support online label manipulation. +.tp +.b eperm +the calling process does not have sufficient permissions to set the label. +.sh versions +these +.br ioctl (2) +operations first appeared in linux 4.18. +they were previously known as +.b btrfs_ioc_get_fslabel +and +.b btrfs_ioc_set_fslabel +and were private to btrfs. +.sh conforming to +this api is linux-specific. +.sh notes +the maximum string length for this interface is +.br fslabel_max , +including the terminating null byte (\(aq\\0\(aq). +filesystems have differing maximum label lengths, which may or +may not include the terminating null. +the string provided to +.b fs_ioc_setfslabel +must always be null-terminated, and the string returned by +.b fs_ioc_getfslabel +will always be null-terminated. +.sh see also +.br ioctl (2), +.br blkid (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1995, thomas k. dyas +.\" and copyright (c) 2016, michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" created sat aug 21 1995 thomas k. dyas +.\" +.\" typo corrected, aeb, 950825 +.\" added layout change from joey, 960722 +.\" changed prototype, documented 0xffffffff, aeb, 030101 +.\" modified 2004-11-03 patch from martin schulze +.\" +.th personality 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +personality \- set the process execution domain +.sh synopsis +.nf +.b #include +.pp +.bi "int personality(unsigned long " persona ); +.fi +.sh description +linux supports different execution domains, or personalities, for each +process. +among other things, execution domains tell linux how to map +signal numbers into signal actions. +the execution domain system allows +linux to provide limited support for binaries compiled under other +unix-like operating systems. +.pp +if +.i persona +is not +0xffffffff, then +.br personality () +sets the caller's execution domain to the value specified by +.ir persona . +specifying +.ir persona +as 0xffffffff provides a way of retrieving +the current persona without changing it. +.pp +a list of the available execution domains can be found in +.ir . +the execution domain is a 32-bit value in which the top three +bytes are set aside for flags that cause the kernel to modify the +behavior of certain system calls so as to emulate historical or +architectural quirks. +the least significant byte is a value defining the personality +the kernel should assume. +the flag values are as follows: +.tp +.br addr_compat_layout " (since linux 2.6.9)" +with this flag set, provide legacy virtual address space layout. +.tp +.br addr_no_randomize " (since linux 2.6.12)" +with this flag set, disable address-space-layout randomization. +.tp +.br addr_limit_32bit " (since linux 2.2)" +limit the address space to 32 bits. +.tp +.br addr_limit_3gb " (since linux 2.4.0)" +with this flag set, use 0xc0000000 as the offset at which to search +a virtual memory chunk on +.br mmap (2); +otherwise use 0xffffe000. +.tp +.br fdpic_funcptrs " (since linux 2.6.11)" +user-space function pointers to signal handlers point +(on certain architectures) to descriptors. +.tp +.br mmap_page_zero " (since linux 2.4.0)" +map page 0 as read-only +(to support binaries that depend on this svr4 behavior). +.tp +.br read_implies_exec " (since linux 2.6.8)" +with this flag set, +.br prot_read +implies +.br prot_exec +for +.br mmap (2). +.tp +.br short_inode " (since linux 2.4.0)" +no effects(?). +.tp +.br sticky_timeouts " (since linux 1.2.0)" +with this flag set, +.br select (2), +.br pselect (2), +and +.br ppoll (2) +do not modify the returned timeout argument when +interrupted by a signal handler. +.tp +.br uname26 " (since linux 3.1)" +have +.br uname (2) +report a 2.6.40+ version number rather than a 3.x version number. +added as a stopgap measure to support broken applications that +could not handle the kernel version-numbering switch from 2.6.x to 3.x. +.tp +.br whole_seconds " (since linux 1.2.0)" +no effects(?). +.pp +the available execution domains are: +.tp +.br per_bsd " (since linux 1.2.0)" +bsd. (no effects.) +.tp +.br per_hpux " (since linux 2.4)" +support for 32-bit hp/ux. +this support was never complete, and was dropped so that since linux 4.0, +this value has no effect. +.tp +.br per_irix32 " (since linux 2.2)" +irix 5 32-bit. +never fully functional; support dropped in linux 2.6.27. +implies +.br sticky_timeouts . +.tp +.br per_irix64 " (since linux 2.2)" +irix 6 64-bit. +implies +.br sticky_timeouts ; +otherwise no effects. +.tp +.br per_irixn32 " (since linux 2.2)" +irix 6 new 32-bit. +implies +.br sticky_timeouts ; +otherwise no effects. +.tp +.br per_iscr4 " (since linux 1.2.0)" +implies +.br sticky_timeouts ; +otherwise no effects. +.tp +.br per_linux " (since linux 1.2.0)" +linux. +.tp +.br per_linux32 " (since linux 2.2)" +[to be documented.] +.tp +.br per_linux32_3gb " (since linux 2.4)" +implies +.br addr_limit_3gb . +.tp +.br per_linux_32bit " (since linux 2.0)" +implies +.br addr_limit_32bit . +.tp +.br per_linux_fdpic " (since linux 2.6.11)" +implies +.br fdpic_funcptrs . +.tp +.br per_osf4 " (since linux 2.4)" +osf/1 v4. +on alpha, +.\" following is from a comment in arch/alpha/kernel/osf_sys.c +clear top 32 bits of iov_len in the user's buffer for +compatibility with old versions of osf/1 where iov_len +was defined as. +.ir int . +.tp +.br per_osr5 " (since linux 2.4)" +implies +.br sticky_timeouts +and +.br whole_seconds ; +otherwise no effects. +.tp +.br per_riscos " (since linux 2.2)" +[to be documented.] +.tp +.br per_scosvr3 " (since linux 1.2.0)" +implies +.br sticky_timeouts , +.br whole_seconds , +and +.br short_inode ; +otherwise no effects. +.tp +.br per_solaris " (since linux 2.4)" +implies +.br sticky_timeouts ; +otherwise no effects. +.tp +.br per_sunos " (since linux 2.4.0)" +implies +.br sticky_timeouts . +divert library and dynamic linker searches to +.ir /usr/gnemul . +buggy, largely unmaintained, and almost entirely unused; +support was removed in linux 2.6.26. +.tp +.br per_svr3 " (since linux 1.2.0)" +implies +.br sticky_timeouts +and +.br short_inode ; +otherwise no effects. +.tp +.br per_svr4 " (since linux 1.2.0)" +implies +.br sticky_timeouts +and +.br mmap_page_zero ; +otherwise no effects. +.tp +.br per_uw7 " (since linux 2.4)" +implies +.br sticky_timeouts +and +.br mmap_page_zero ; +otherwise no effects. +.tp +.br per_wysev386 " (since linux 1.2.0)" +implies +.br sticky_timeouts +and +.br short_inode ; +otherwise no effects. +.tp +.br per_xenix " (since linux 1.2.0)" +implies +.br sticky_timeouts +and +.br short_inode ; +otherwise no effects. +.sh return value +on success, the previous +.i persona +is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b einval +the kernel was unable to change the personality. +.sh versions +this system call first appeared in linux 1.1.20 +(and thus first in a stable kernel release with linux 1.2.0); +library support was added in glibc 2.3. +.\" personality wrapper first appeared in glibc 1.90, +.\" was added later in 2.2.91. +.sh conforming to +.br personality () +is linux-specific and should not be used in programs intended to +be portable. +.sh see also +.br setarch (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1992 drew eckhardt, march 28, 1992 +.\" and copyright (c) 2002, 2004, 2005, 2008, 2010 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified by michael haardt +.\" modified 1993-07-23 by rik faith +.\" modified 1996-01-13 by arnt gulbrandsen +.\" modified 1996-01-22 by aeb, following a remark by +.\" tigran aivazian +.\" modified 1996-04-14 by aeb, following a remark by +.\" robert bihlmeyer +.\" modified 1996-10-22 by eric s. raymond +.\" modified 2001-05-04 by aeb, following a remark by +.\" håvard lygre +.\" modified 2001-04-17 by michael kerrisk +.\" modified 2002-06-13 by michael kerrisk +.\" added note on nonstandard behavior when sigchld is ignored. +.\" modified 2002-07-09 by michael kerrisk +.\" enhanced descriptions of 'resource' values +.\" modified 2003-11-28 by aeb, added rlimit_core +.\" modified 2004-03-26 by aeb, added rlimit_as +.\" modified 2004-06-16 by michael kerrisk +.\" added notes on cap_sys_resource +.\" +.\" 2004-11-16 -- mtk: the getrlimit.2 page, which formally included +.\" coverage of getrusage(2), has been split, so that the latter +.\" is now covered in its own getrusage.2. +.\" +.\" modified 2004-11-16, mtk: a few other minor changes +.\" modified 2004-11-23, mtk +.\" added notes on rlimit_memlock, rlimit_nproc, and rlimit_rss +.\" to "conforming to" +.\" modified 2004-11-25, mtk +.\" rewrote discussion on rlimit_memlock to incorporate kernel +.\" 2.6.9 changes. +.\" added note on rlimit_cpu error in older kernels +.\" 2004-11-03, mtk, added rlimit_sigpending +.\" 2005-07-13, mtk, documented rlimit_msgqueue limit. +.\" 2005-07-28, mtk, added descriptions of rlimit_nice and rlimit_rtprio +.\" 2008-05-07, mtk / peter zijlstra, added description of rlimit_rttime +.\" 2010-11-06, mtk: added documentation of prlimit() +.\" +.th getrlimit 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +getrlimit, setrlimit, prlimit \- get/set resource limits +.sh synopsis +.nf +.b #include +.pp +.bi "int getrlimit(int " resource ", struct rlimit *" rlim ); +.bi "int setrlimit(int " resource ", const struct rlimit *" rlim ); +.pp +.bi "int prlimit(pid_t " pid ", int " resource ", const struct rlimit *" new_limit , +.bi " struct rlimit *" old_limit ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br prlimit (): +.nf + _gnu_source +.fi +.sh description +the +.br getrlimit () +and +.br setrlimit () +system calls get and set resource limits. +each resource has an associated soft and hard limit, as defined by the +.i rlimit +structure: +.pp +.in +4n +.ex +struct rlimit { + rlim_t rlim_cur; /* soft limit */ + rlim_t rlim_max; /* hard limit (ceiling for rlim_cur) */ +}; +.ee +.in +.pp +the soft limit is the value that the kernel enforces for the +corresponding resource. +the hard limit acts as a ceiling for the soft limit: +an unprivileged process may set only its soft limit to a value in the +range from 0 up to the hard limit, and (irreversibly) lower its hard limit. +a privileged process (under linux: one with the +.b cap_sys_resource +capability in the initial user namespace) +may make arbitrary changes to either limit value. +.pp +the value +.b rlim_infinity +denotes no limit on a resource (both in the structure returned by +.br getrlimit () +and in the structure passed to +.br setrlimit ()). +.pp +the +.i resource +argument must be one of: +.tp +.b rlimit_as +this is the maximum size of the process's virtual memory +(address space). +the limit is specified in bytes, and is rounded down to the system page size. +.\" since 2.0.27 / 2.1.12 +this limit affects calls to +.br brk (2), +.br mmap (2), +and +.br mremap (2), +which fail with the error +.b enomem +upon exceeding this limit. +in addition, automatic stack expansion fails +(and generates a +.b sigsegv +that kills the process if no alternate stack +has been made available via +.br sigaltstack (2)). +since the value is a \filong\fp, on machines with a 32-bit \filong\fp +either this limit is at most 2\ gib, or this resource is unlimited. +.tp +.b rlimit_core +this is the maximum size of a +.i core +file (see +.br core (5)) +in bytes that the process may dump. +when 0 no core dump files are created. +when nonzero, larger dumps are truncated to this size. +.tp +.b rlimit_cpu +this is a limit, in seconds, +on the amount of cpu time that the process can consume. +when the process reaches the soft limit, it is sent a +.b sigxcpu +signal. +the default action for this signal is to terminate the process. +however, the signal can be caught, and the handler can return control to +the main program. +if the process continues to consume cpu time, it will be sent +.b sigxcpu +once per second until the hard limit is reached, at which time +it is sent +.br sigkill . +(this latter point describes linux behavior. +implementations vary in how they treat processes which continue to +consume cpu time after reaching the soft limit. +portable applications that need to catch this signal should +perform an orderly termination upon first receipt of +.br sigxcpu .) +.tp +.b rlimit_data +this is the maximum size +of the process's data segment (initialized data, +uninitialized data, and heap). +the limit is specified in bytes, and is rounded down to the system page size. +this limit affects calls to +.br brk (2), +.br sbrk (2), +and (since linux 4.7) +.br mmap (2), +.\" commits 84638335900f1995495838fe1bd4870c43ec1f67 +.\" ("mm: rework virtual memory accounting"), +.\" f4fcd55841fc9e46daac553b39361572453c2b88 +.\" (mm: enable rlimit_data by default with workaround for valgrind). +which fail with the error +.b enomem +upon encountering the soft limit of this resource. +.tp +.b rlimit_fsize +this is the maximum size in bytes of files that the process may create. +attempts to extend a file beyond this limit result in delivery of a +.b sigxfsz +signal. +by default, this signal terminates a process, but a process can +catch this signal instead, in which case the relevant system call (e.g., +.br write (2), +.br truncate (2)) +fails with the error +.br efbig . +.tp +.br rlimit_locks " (linux 2.4.0 to 2.4.24)" +.\" to be precise: linux 2.4.0-test9; no longer in 2.4.25 / 2.5.65 +this is a limit on the combined number of +.br flock (2) +locks and +.br fcntl (2) +leases that this process may establish. +.tp +.b rlimit_memlock +this is the maximum number of bytes of memory that may be locked +into ram. +this limit is in effect rounded down to the nearest multiple +of the system page size. +this limit affects +.br mlock (2), +.br mlockall (2), +and the +.br mmap (2) +.b map_locked +operation. +since linux 2.6.9, it also affects the +.br shmctl (2) +.b shm_lock +operation, where it sets a maximum on the total bytes in +shared memory segments (see +.br shmget (2)) +that may be locked by the real user id of the calling process. +the +.br shmctl (2) +.b shm_lock +locks are accounted for separately from the per-process memory +locks established by +.br mlock (2), +.br mlockall (2), +and +.br mmap (2) +.br map_locked ; +a process can lock bytes up to this limit in each of these +two categories. +.ip +in linux kernels before 2.6.9, this limit controlled the amount of +memory that could be locked by a privileged process. +since linux 2.6.9, no limits are placed on the amount of memory +that a privileged process may lock, and this limit instead governs +the amount of memory that an unprivileged process may lock. +.tp +.br rlimit_msgqueue " (since linux 2.6.8)" +this is a limit on the number of bytes that can be allocated +for posix message queues for the real user id of the calling process. +this limit is enforced for +.br mq_open (3). +each message queue that the user creates counts (until it is removed) +against this limit according to the formula: +.ip + since linux 3.5: +.ip +.ex + bytes = attr.mq_maxmsg * sizeof(struct msg_msg) + + min(attr.mq_maxmsg, mq_prio_max) * + sizeof(struct posix_msg_tree_node)+ + /* for overhead */ + attr.mq_maxmsg * attr.mq_msgsize; + /* for message data */ +.ee +.ip + linux 3.4 and earlier: +.ip +.ex + bytes = attr.mq_maxmsg * sizeof(struct msg_msg *) + + /* for overhead */ + attr.mq_maxmsg * attr.mq_msgsize; + /* for message data */ +.ee +.ip +where +.i attr +is the +.i mq_attr +structure specified as the fourth argument to +.br mq_open (3), +and the +.i msg_msg +and +.i posix_msg_tree_node +structures are kernel-internal structures. +.ip +the "overhead" addend in the formula accounts for overhead +bytes required by the implementation +and ensures that the user cannot +create an unlimited number of zero-length messages (such messages +nevertheless each consume some system memory for bookkeeping overhead). +.tp +.br rlimit_nice " (since linux 2.6.12, but see bugs below)" +this specifies a ceiling to which the process's nice value can be raised using +.br setpriority (2) +or +.br nice (2). +the actual ceiling for the nice value is calculated as +.ir "20\ \-\ rlim_cur" . +the useful range for this limit is thus from 1 +(corresponding to a nice value of 19) to 40 +(corresponding to a nice value of \-20). +this unusual choice of range was necessary +because negative numbers cannot be specified +as resource limit values, since they typically have special meanings. +for example, +.b rlim_infinity +typically is the same as \-1. +for more detail on the nice value, see +.br sched (7). +.tp +.b rlimit_nofile +this specifies a value one greater than the maximum file descriptor number +that can be opened by this process. +attempts +.rb ( open (2), +.br pipe (2), +.br dup (2), +etc.) +to exceed this limit yield the error +.br emfile . +(historically, this limit was named +.b rlimit_ofile +on bsd.) +.ip +since linux 4.5, +this limit also defines the maximum number of file descriptors that +an unprivileged process (one without the +.br cap_sys_resource +capability) may have "in flight" to other processes, +by being passed across unix domain sockets. +this limit applies to the +.br sendmsg (2) +system call. +for further details, see +.br unix (7). +.tp +.b rlimit_nproc +this is a limit on the number of extant process +(or, more precisely on linux, threads) +for the real user id of the calling process. +so long as the current number of processes belonging to this +process's real user id is greater than or equal to this limit, +.br fork (2) +fails with the error +.br eagain . +.ip +the +.b rlimit_nproc +limit is not enforced for processes that have either the +.b cap_sys_admin +or the +.b cap_sys_resource +capability. +.tp +.b rlimit_rss +this is a limit (in bytes) on the process's resident set +(the number of virtual pages resident in ram). +this limit has effect only in linux 2.4.x, x < 30, and there +affects only calls to +.br madvise (2) +specifying +.br madv_willneed . +.\" as at kernel 2.6.12, this limit still does nothing in 2.6 though +.\" talk of making it do something has surfaced from time to time in lkml +.\" -- mtk, jul 05 +.tp +.br rlimit_rtprio " (since linux 2.6.12, but see bugs)" +this specifies a ceiling on the real-time priority that may be set for +this process using +.br sched_setscheduler (2) +and +.br sched_setparam (2). +.ip +for further details on real-time scheduling policies, see +.br sched (7) +.tp +.br rlimit_rttime " (since linux 2.6.25)" +this is a limit (in microseconds) +on the amount of cpu time that a process scheduled +under a real-time scheduling policy may consume without making a blocking +system call. +for the purpose of this limit, +each time a process makes a blocking system call, +the count of its consumed cpu time is reset to zero. +the cpu time count is not reset if the process continues trying to +use the cpu but is preempted, its time slice expires, or it calls +.br sched_yield (2). +.ip +upon reaching the soft limit, the process is sent a +.b sigxcpu +signal. +if the process catches or ignores this signal and +continues consuming cpu time, then +.b sigxcpu +will be generated once each second until the hard limit is reached, +at which point the process is sent a +.b sigkill +signal. +.ip +the intended use of this limit is to stop a runaway +real-time process from locking up the system. +.ip +for further details on real-time scheduling policies, see +.br sched (7) +.tp +.br rlimit_sigpending " (since linux 2.6.8)" +this is a limit on the number of signals +that may be queued for the real user id of the calling process. +both standard and real-time signals are counted for the purpose of +checking this limit. +however, the limit is enforced only for +.br sigqueue (3); +it is always possible to use +.br kill (2) +to queue one instance of any of the signals that are not already +queued to the process. +.\" this replaces the /proc/sys/kernel/rtsig-max system-wide limit +.\" that was present in kernels <= 2.6.7. mtk dec 04 +.tp +.b rlimit_stack +this is the maximum size of the process stack, in bytes. +upon reaching this limit, a +.b sigsegv +signal is generated. +to handle this signal, a process must employ an alternate signal stack +.rb ( sigaltstack (2)). +.ip +since linux 2.6.23, +this limit also determines the amount of space used for the process's +command-line arguments and environment variables; for details, see +.br execve (2). +.ss prlimit() +.\" commit c022a0acad534fd5f5d5f17280f6d4d135e74e81 +.\" author: jiri slaby +.\" date: tue may 4 18:03:50 2010 +0200 +.\" +.\" rlimits: implement prlimit64 syscall +.\" +.\" commit 6a1d5e2c85d06da35cdfd93f1a27675bfdc3ad8c +.\" author: jiri slaby +.\" date: wed mar 24 17:06:58 2010 +0100 +.\" +.\" rlimits: add rlimit64 structure +.\" +the linux-specific +.br prlimit () +system call combines and extends the functionality of +.br setrlimit () +and +.br getrlimit (). +it can be used to both set and get the resource limits of an arbitrary process. +.pp +the +.i resource +argument has the same meaning as for +.br setrlimit () +and +.br getrlimit (). +.pp +if the +.ir new_limit +argument is a not null, then the +.i rlimit +structure to which it points is used to set new values for +the soft and hard limits for +.ir resource . +if the +.ir old_limit +argument is a not null, then a successful call to +.br prlimit () +places the previous soft and hard limits for +.i resource +in the +.i rlimit +structure pointed to by +.ir old_limit . +.pp +the +.i pid +argument specifies the id of the process on which the call is to operate. +if +.i pid +is 0, then the call applies to the calling process. +to set or get the resources of a process other than itself, +the caller must have the +.b cap_sys_resource +capability in the user namespace of the process +whose resource limits are being changed, or the +real, effective, and saved set user ids of the target process +must match the real user id of the caller +.i and +the real, effective, and saved set group ids of the target process +must match the real group id of the caller. +.\" fixme . this permission check is strange +.\" asked about this on lkml, 7 nov 2010 +.\" "inconsistent credential checking in prlimit() syscall" +.sh return value +on success, these system calls return 0. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b efault +a pointer argument points to a location +outside the accessible address space. +.tp +.b einval +the value specified in +.i resource +is not valid; +or, for +.br setrlimit () +or +.br prlimit (): +.i rlim\->rlim_cur +was greater than +.ir rlim\->rlim_max . +.tp +.b eperm +an unprivileged process tried to raise the hard limit; the +.b cap_sys_resource +capability is required to do this. +.tp +.b eperm +the caller tried to increase the hard +.b rlimit_nofile +limit above the maximum defined by +.ir /proc/sys/fs/nr_open +(see +.br proc (5)) +.tp +.b eperm +.rb ( prlimit ()) +the calling process did not have permission to set limits +for the process specified by +.ir pid . +.tp +.b esrch +could not find a process with the id specified in +.ir pid . +.sh versions +the +.br prlimit () +system call is available since linux 2.6.36. +library support is available since glibc 2.13. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br getrlimit (), +.br setrlimit (), +.br prlimit () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +.br getrlimit (), +.br setrlimit (): +posix.1-2001, posix.1-2008, svr4, 4.3bsd. +.pp +.br prlimit (): +linux-specific. +.pp +.b rlimit_memlock +and +.b rlimit_nproc +derive from bsd and are not specified in posix.1; +they are present on the bsds and linux, but on few other implementations. +.b rlimit_rss +derives from bsd and is not specified in posix.1; +it is nevertheless present on most implementations. +.br rlimit_msgqueue , +.br rlimit_nice , +.br rlimit_rtprio , +.br rlimit_rttime , +and +.b rlimit_sigpending +are linux-specific. +.sh notes +a child process created via +.br fork (2) +inherits its parent's resource limits. +resource limits are preserved across +.br execve (2). +.pp +resource limits are per-process attributes that are shared +by all of the threads in a process. +.pp +lowering the soft limit for a resource below the process's +current consumption of that resource will succeed +(but will prevent the process from further increasing +its consumption of the resource). +.pp +one can set the resource limits of the shell using the built-in +.ir ulimit +command +.ri ( limit +in +.br csh (1)). +the shell's resource limits are inherited by the processes that +it creates to execute commands. +.pp +since linux 2.6.24, the resource limits of any process can be inspected via +.ir /proc/[pid]/limits ; +see +.br proc (5). +.pp +ancient systems provided a +.br vlimit () +function with a similar purpose to +.br setrlimit (). +for backward compatibility, glibc also provides +.br vlimit (). +all new applications should be written using +.br setrlimit (). +.ss c library/kernel abi differences +since version 2.13, the glibc +.br getrlimit () +and +.br setrlimit () +wrapper functions no longer invoke the corresponding system calls, +but instead employ +.br prlimit (), +for the reasons described in bugs. +.pp +the name of the glibc wrapper function is +.br prlimit (); +the underlying system call is +.br prlimit64 (). +.sh bugs +in older linux kernels, the +.b sigxcpu +and +.b sigkill +signals delivered when a process encountered the soft and hard +.b rlimit_cpu +limits were delivered one (cpu) second later than they should have been. +this was fixed in kernel 2.6.8. +.pp +in 2.6.x kernels before 2.6.17, a +.b rlimit_cpu +limit of 0 is wrongly treated as "no limit" (like +.br rlim_infinity ). +since linux 2.6.17, setting a limit of 0 does have an effect, +but is actually treated as a limit of 1 second. +.\" see http://marc.theaimsgroup.com/?l=linux-kernel&m=114008066530167&w=2 +.pp +a kernel bug means that +.\" see https://lwn.net/articles/145008/ +.b rlimit_rtprio +does not work in kernel 2.6.12; the problem is fixed in kernel 2.6.13. +.pp +in kernel 2.6.12, there was an off-by-one mismatch +between the priority ranges returned by +.br getpriority (2) +and +.br rlimit_nice . +this had the effect that the actual ceiling for the nice value +was calculated as +.ir "19\ \-\ rlim_cur" . +this was fixed in kernel 2.6.13. +.\" see http://marc.theaimsgroup.com/?l=linux-kernel&m=112256338703880&w=2 +.pp +since linux 2.6.12, +.\" the relevant patch, sent to lkml, seems to be +.\" http://thread.gmane.org/gmane.linux.kernel/273462 +.\" from: roland mcgrath redhat.com> +.\" subject: [patch 7/7] make rlimit_cpu/sigxcpu per-process +.\" date: 2005-01-23 23:27:46 gmt +if a process reaches its soft +.br rlimit_cpu +limit and has a handler installed for +.br sigxcpu , +then, in addition to invoking the signal handler, +the kernel increases the soft limit by one second. +this behavior repeats if the process continues to consume cpu time, +until the hard limit is reached, +at which point the process is killed. +other implementations +.\" tested solaris 10, freebsd 9, openbsd 5.0 +do not change the +.br rlimit_cpu +soft limit in this manner, +and the linux behavior is probably not standards conformant; +portable applications should avoid relying on this linux-specific behavior. +.\" fixme . https://bugzilla.kernel.org/show_bug.cgi?id=50951 +the linux-specific +.br rlimit_rttime +limit exhibits the same behavior when the soft limit is encountered. +.pp +kernels before 2.4.22 did not diagnose the error +.b einval +for +.br setrlimit () +when +.i rlim\->rlim_cur +was greater than +.ir rlim\->rlim_max . +.\" d3561f78fd379a7110e46c87964ba7aa4120235c +.pp +linux doesn't return an error when an attempt to set +.b rlimit_cpu +has failed, for compatibility reasons. +.\" +.ss representation of """large""" resource limit values on 32-bit platforms +the glibc +.br getrlimit () +and +.br setrlimit () +wrapper functions use a 64-bit +.ir rlim_t +data type, even on 32-bit platforms. +however, the +.i rlim_t +data type used in the +.br getrlimit () +and +.br setrlimit () +system calls is a (32-bit) +.ir "unsigned long" . +.\" linux still uses long for limits internally: +.\" c022a0acad534fd5f5d5f17280f6d4d135e74e81 +.\" kernel/sys.c:do_prlimit() still uses struct rlimit which +.\" uses kernel_ulong_t for its members, i.e. 32-bit on 32-bit kernel. +furthermore, in linux, +the kernel represents resource limits on 32-bit platforms as +.ir "unsigned long" . +however, a 32-bit data type is not wide enough. +.\" https://bugzilla.kernel.org/show_bug.cgi?id=5042 +.\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=12201 +the most pertinent limit here is +.br rlimit_fsize , +which specifies the maximum size to which a file can grow: +to be useful, this limit must be represented using a type +that is as wide as the type used to +represent file offsets\(emthat is, as wide as a 64-bit +.br off_t +(assuming a program compiled with +.ir _file_offset_bits=64 ). +.pp +to work around this kernel limitation, +if a program tried to set a resource limit to a value larger than +can be represented in a 32-bit +.ir "unsigned long" , +then the glibc +.br setrlimit () +wrapper function silently converted the limit value to +.br rlim_infinity . +in other words, the requested resource limit setting was silently ignored. +.pp +since version 2.13, +.\" https://www.sourceware.org/bugzilla/show_bug.cgi?id=12201 +glibc works around the limitations of the +.br getrlimit () +and +.br setrlimit () +system calls by implementing +.br setrlimit () +and +.br getrlimit () +as wrapper functions that call +.br prlimit (). +.sh examples +the program below demonstrates the use of +.br prlimit (). +.pp +.ex +#define _gnu_source +#define _file_offset_bits 64 +#include +#include +#include +#include +#include +#include + +#define errexit(msg) do { perror(msg); exit(exit_failure); \e + } while (0) + +int +main(int argc, char *argv[]) +{ + struct rlimit old, new; + struct rlimit *newp; + pid_t pid; + + if (!(argc == 2 || argc == 4)) { + fprintf(stderr, "usage: %s [ " + "]\en", argv[0]); + exit(exit_failure); + } + + pid = atoi(argv[1]); /* pid of target process */ + + newp = null; + if (argc == 4) { + new.rlim_cur = atoi(argv[2]); + new.rlim_max = atoi(argv[3]); + newp = &new; + } + + /* set cpu time limit of target process; retrieve and display + previous limit */ + + if (prlimit(pid, rlimit_cpu, newp, &old) == \-1) + errexit("prlimit\-1"); + printf("previous limits: soft=%jd; hard=%jd\en", + (intmax_t) old.rlim_cur, (intmax_t) old.rlim_max); + + /* retrieve and display new cpu time limit */ + + if (prlimit(pid, rlimit_cpu, null, &old) == \-1) + errexit("prlimit\-2"); + printf("new limits: soft=%jd; hard=%jd\en", + (intmax_t) old.rlim_cur, (intmax_t) old.rlim_max); + + exit(exit_success); +} +.ee +.sh see also +.br prlimit (1), +.br dup (2), +.br fcntl (2), +.br fork (2), +.br getrusage (2), +.br mlock (2), +.br mmap (2), +.br open (2), +.br quotactl (2), +.br sbrk (2), +.br shmctl (2), +.br malloc (3), +.br sigqueue (3), +.br ulimit (3), +.br core (5), +.br capabilities (7), +.br cgroups (7), +.br credentials (7), +.br signal (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2009 intel corporation, author andi kleen +.\" description based on comments in arch/x86/kernel/cpuid.c +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th cpuid 4 2019-08-02 "linux" "linux programmer's manual" +.sh name +cpuid \- x86 cpuid access device +.sh description +cpuid provides an interface for querying information about the x86 cpu. +.pp +this device is accessed by +.br lseek (2) +or +.br pread (2) +to the appropriate cpuid level and reading in chunks of 16 bytes. +a larger read size means multiple reads of consecutive levels. +.pp +the lower 32 bits of the file position is used as the incoming +.ir %eax , +and the upper 32 bits of the file position as the incoming +.ir %ecx , +the latter is intended for "counting" +.i eax +levels like +.ir eax=4 . +.pp +this driver uses +.ir /dev/cpu/cpunum/cpuid , +where +.i cpunum +is the minor number, +and on an smp box will direct the access to cpu +.i cpunum +as listed in +.ir /proc/cpuinfo . +.pp +this file is protected so that it can be read only by the user +.ir root , +or members of the group +.ir root . +.sh notes +the cpuid instruction can be directly executed by a program +using inline assembler. +however this device allows convenient +access to all cpus without changing process affinity. +.pp +most of the information in +.i cpuid +is reported by the kernel in cooked form either in +.i /proc/cpuinfo +or through subdirectories in +.ir /sys/devices/system/cpu . +direct cpuid access through this device should only +be used in exceptional cases. +.pp +the +.i cpuid +driver is not auto-loaded. +on modular kernels you might need to use the following command +to load it explicitly before use: +.pp +.in +4n +.ex +$ modprobe cpuid +.ee +.in +.pp +there is no support for cpuid functions that require additional +input registers. +.pp +very old x86 cpus don't support cpuid. +.sh see also +.br cpuid (1) +.pp +intel corporation, intel 64 and ia-32 architectures +software developer's manual volume 2a: +instruction set reference, a-m, 3-180 cpuid reference. +.pp +intel corporation, intel processor identification and +the cpuid instruction, application note 485. +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/stailq.3 + +.so man3/pthread_attr_setinheritsched.3 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" +.\" modified 1993-03-29, david metcalfe +.\" modified 1993-07-24, rik faith (faith@cs.unc.edu) +.\" modified 2002-08-10, 2003-11-01 walter harms, aeb +.\" +.th div 3 2021-03-22 "" "linux programmer's manual" +.sh name +div, ldiv, lldiv, imaxdiv \- compute quotient and remainder of +an integer division +.sh synopsis +.nf +.b #include +.pp +.bi "div_t div(int " numerator ", int " denominator ); +.bi "ldiv_t ldiv(long " numerator ", long " denominator ); +.bi "lldiv_t lldiv(long long " numerator ", long long " denominator ); +.pp +.b #include +.pp +.bi "imaxdiv_t imaxdiv(intmax_t " numerator ", intmax_t " denominator ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br lldiv (): +.nf + _isoc99_source || _posix_c_source >= 200112l +.fi +.sh description +the +.br div () +function computes the value +\finumerator\fp/\fidenominator\fp and +returns the quotient and remainder in a structure +named \fidiv_t\fp that contains +two integer members (in unspecified order) named \fiquot\fp and \firem\fp. +the quotient is rounded toward zero. +the result satisfies \fiquot\fp*\fidenominator\fp+\firem\fp = \finumerator\fp. +.pp +the +.br ldiv (), +.br lldiv (), +and +.br imaxdiv () +functions do the same, +dividing numbers of the indicated type and +returning the result in a structure +of the indicated name, in all cases with fields \fiquot\fp and \firem\fp +of the same type as the function arguments. +.sh return value +the \fidiv_t\fp (etc.) structure. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br div (), +.br ldiv (), +.br lldiv (), +.br imaxdiv () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c89, c99, svr4, 4.3bsd. +the functions +.br lldiv () +and +.br imaxdiv () +were added in c99. +.sh examples +after +.pp +.in +4n +.ex +div_t q = div(\-5, 3); +.ee +.in +.pp +the values \fiq.quot\fp and \fiq.rem\fp are \-1 and \-2, respectively. +.sh see also +.br abs (3), +.br remainder (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1997 john s. kallal (kallal@voicenet.com) +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" some changes by tytso and aeb. +.\" +.\" 2004-12-16, john v. belmonte/mtk, updated init and quit scripts +.\" 2004-04-08, aeb, improved description of read from /dev/urandom +.\" 2008-06-20, george spelvin , +.\" matt mackall +.\" +.th random 4 2021-03-22 "linux" "linux programmer's manual" +.sh name +random, urandom \- kernel random number source devices +.sh synopsis +.nf +#include +.pp +.bi "int ioctl(" fd ", rnd" request ", " param ");" +.fi +.sh description +the character special files \fi/dev/random\fp and +\fi/dev/urandom\fp (present since linux 1.3.30) +provide an interface to the kernel's random number generator. +the file +.i /dev/random +has major device number 1 and minor device number 8. +the file +.i /dev/urandom +has major device number 1 and minor device number 9. +.pp +the random number generator gathers environmental noise +from device drivers and other sources into an entropy pool. +the generator also keeps an estimate of the +number of bits of noise in the entropy pool. +from this entropy pool, random numbers are created. +.pp +linux 3.17 and later provides the simpler and safer +.br getrandom (2) +interface which requires no special files; +see the +.br getrandom (2) +manual page for details. +.pp +when read, the +.i /dev/urandom +device returns random bytes using a pseudorandom +number generator seeded from the entropy pool. +reads from this device do not block (i.e., the cpu is not yielded), +but can incur an appreciable delay when requesting large amounts of data. +.pp +when read during early boot time, +.ir /dev/urandom +may return data prior to the entropy pool being initialized. +.\" this is a real problem; see +.\" commit 9b4d008787f864f17d008c9c15bbe8a0f7e2fc24 +if this is of concern in your application, use +.br getrandom (2) +or \fi/dev/random\fp instead. +.pp +the \fi/dev/random\fp device is a legacy interface which dates back to +a time where the cryptographic primitives used in the implementation +of \fi/dev/urandom\fp were not widely trusted. +it will return random bytes only within the estimated number of +bits of fresh noise in the entropy pool, blocking if necessary. +\fi/dev/random\fp is suitable for applications that need +high quality randomness, and can afford indeterminate delays. +.pp +when the entropy pool is empty, reads from \fi/dev/random\fp will block +until additional environmental noise is gathered. +if +.br open (2) +is called for +.i /dev/random +with the +.br o_nonblock +flag, a subsequent +.br read (2) +will not block if the requested number of bytes is not available. +instead, the available bytes are returned. +if no byte is available, +.br read (2) +will return \-1 and +.i errno +will be set to +.br eagain . +.pp +the +.b o_nonblock +flag has no effect when opening +.ir /dev/urandom . +when calling +.br read (2) +for the device +.ir /dev/urandom , +reads of up to 256 bytes will return as many bytes as are requested +and will not be interrupted by a signal handler. +reads with a buffer over this limit may return less than the +requested number of bytes or fail with the error +.br eintr , +if interrupted by a signal handler. +.pp +since linux 3.16, +.\" commit 79a8468747c5f95ed3d5ce8376a3e82e0c5857fc +a +.br read (2) +from +.ir /dev/urandom +will return at most 32\ mb. +a +.br read (2) +from +.ir /dev/random +will return at most 512 bytes +.\" sec_xfer_size in drivers/char/random.c +(340 bytes on linux kernels before version 2.6.12). +.pp +writing to \fi/dev/random\fp or \fi/dev/urandom\fp will update the +entropy pool with the data written, but this will not result in a +higher entropy count. +this means that it will impact the contents +read from both files, but it will not make reads from +\fi/dev/random\fp faster. +.ss usage +the +.ir /dev/random +interface is considered a legacy interface, and +.ir /dev/urandom +is preferred and sufficient in all use cases, with the exception of +applications which require randomness during early boot time; for +these applications, +.br getrandom (2) +must be used instead, +because it will block until the entropy pool is initialized. +.pp +if a seed file is saved across reboots as recommended below, +the output is +cryptographically secure against attackers without local root access as +soon as it is reloaded in the boot sequence, and perfectly adequate for +network encryption session keys. +(all major linux distributions have saved the seed file across reboots +since 2000 at least.) +since reads from +.i /dev/random +may block, users will usually want to open it in nonblocking mode +(or perform a read with timeout), +and provide some sort of user notification if the desired +entropy is not immediately available. +.\" +.ss configuration +if your system does not have +\fi/dev/random\fp and \fi/dev/urandom\fp created already, they +can be created with the following commands: +.pp +.in +4n +.ex +mknod \-m 666 /dev/random c 1 8 +mknod \-m 666 /dev/urandom c 1 9 +chown root:root /dev/random /dev/urandom +.ee +.in +.pp +when a linux system starts up without much operator interaction, +the entropy pool may be in a fairly predictable state. +this reduces the actual amount of noise in the entropy pool +below the estimate. +in order to counteract this effect, it helps to carry +entropy pool information across shut-downs and start-ups. +to do this, add the lines to an appropriate script +which is run during the linux system start-up sequence: +.pp +.in +4n +.ex +echo "initializing random number generator..." +random_seed=/var/run/random\-seed +# carry a random seed from start\-up to start\-up +# load and then save the whole entropy pool +if [ \-f $random_seed ]; then + cat $random_seed >/dev/urandom +else + touch $random_seed +fi +chmod 600 $random_seed +poolfile=/proc/sys/kernel/random/poolsize +[ \-r $poolfile ] && bits=$(cat $poolfile) || bits=4096 +bytes=$(expr $bits / 8) +dd if=/dev/urandom of=$random_seed count=1 bs=$bytes +.ee +.in +.pp +also, add the following lines in an appropriate script which is +run during the linux system shutdown: +.pp +.in +4n +.ex +# carry a random seed from shut\-down to start\-up +# save the whole entropy pool +echo "saving random seed..." +random_seed=/var/run/random\-seed +touch $random_seed +chmod 600 $random_seed +poolfile=/proc/sys/kernel/random/poolsize +[ \-r $poolfile ] && bits=$(cat $poolfile) || bits=4096 +bytes=$(expr $bits / 8) +dd if=/dev/urandom of=$random_seed count=1 bs=$bytes +.ee +.in +.pp +in the above examples, we assume linux 2.6.0 or later, where +.ir /proc/sys/kernel/random/poolsize +returns the size of the entropy pool in bits (see below). +.\" +.ss /proc interfaces +the files in the directory +.i /proc/sys/kernel/random +(present since 2.3.16) provide additional information about the +.i /dev/random +device: +.tp +.i entropy_avail +this read-only file gives the available entropy, in bits. +this will be a number in the range 0 to 4096. +.tp +.i poolsize +this file +gives the size of the entropy pool. +the semantics of this file vary across kernel versions: +.rs +.tp +linux 2.4: +this file gives the size of the entropy pool in +.ir bytes . +normally, this file will have the value 512, but it is writable, +and can be changed to any value for which an algorithm is available. +the choices are 32, 64, 128, 256, 512, 1024, or 2048. +.tp +linux 2.6 and later: +this file is read-only, and gives the size of the entropy pool in +.ir bits . +it contains the value 4096. +.re +.tp +.i read_wakeup_threshold +this file +contains the number of bits of entropy required for waking up processes +that sleep waiting for entropy from +.ir /dev/random . +the default is 64. +.tp +.i write_wakeup_threshold +this file +contains the number of bits of entropy below which we wake up +processes that do a +.br select (2) +or +.br poll (2) +for write access to +.ir /dev/random . +these values can be changed by writing to the files. +.tp +.ir uuid " and " boot_id +these read-only files +contain random strings like 6fd5a44b-35f4-4ad4-a9b9-6b9be13e1fe9. +the former is generated afresh for each read, the latter was +generated once. +.\" +.ss ioctl(2) interface +the following +.br ioctl (2) +requests are defined on file descriptors connected to either \fi/dev/random\fp +or \fi/dev/urandom\fp. +all requests performed will interact with the input +entropy pool impacting both \fi/dev/random\fp and \fi/dev/urandom\fp. +the +.b cap_sys_admin +capability is required for all requests except +.br rndgetentcnt . +.tp +.br rndgetentcnt +retrieve the entropy count of the input pool, the contents will be the same +as the +.i entropy_avail +file under proc. +the result will be stored in the int pointed to by the argument. +.tp +.br rndaddtoentcnt +increment or decrement the entropy count of the input pool +by the value pointed to by the argument. +.tp +.br rndgetpool +removed in linux 2.6.9. +.tp +.br rndaddentropy +add some additional entropy to the input pool, +incrementing the entropy count. +this differs from writing to \fi/dev/random\fp or \fi/dev/urandom\fp, +which only adds some +data but does not increment the entropy count. +the following structure is used: +.ip +.in +4n +.ex +struct rand_pool_info { + int entropy_count; + int buf_size; + __u32 buf[0]; +}; +.ee +.in +.ip +here +.i entropy_count +is the value added to (or subtracted from) the entropy count, and +.i buf +is the buffer of size +.i buf_size +which gets added to the entropy pool. +.tp +.br rndzapentcnt ", " rndclearpool +zero the entropy count of all pools and add some system data (such as +wall clock) to the pools. +.sh files +.i /dev/random +.br +.i /dev/urandom +.sh notes +for an overview and comparison of the various interfaces that +can be used to obtain randomness, see +.br random (7). +.sh bugs +during early boot time, reads from +.i /dev/urandom +may return data prior to the entropy pool being initialized. +.\" .sh author +.\" the kernel's random number generator was written by +.\" theodore ts'o (tytso@athena.mit.edu). +.sh see also +.br mknod (1), +.br getrandom (2), +.br random (7) +.pp +rfc\ 1750, "randomness recommendations for security" +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2005 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th pty 7 2020-08-13 "linux" "linux programmer's manual" +.sh name +pty \- pseudoterminal interfaces +.sh description +a pseudoterminal (sometimes abbreviated "pty") +is a pair of virtual character devices that +provide a bidirectional communication channel. +one end of the channel is called the +.ir master ; +the other end is called the +.ir slave . +.pp +the slave end of the pseudoterminal provides an interface +that behaves exactly like a classical terminal. +a process that expects to be connected to a terminal, +can open the slave end of a pseudoterminal and +then be driven by a program that has opened the master end. +anything that is written on the master end is provided to the process +on the slave end as though it was input typed on a terminal. +for example, writing the interrupt character (usually control-c) +to the master device would cause an interrupt signal +.rb ( sigint ) +to be generated for the foreground process group +that is connected to the slave. +conversely, anything that is written to the slave end of the +pseudoterminal can be read by the process that is connected to +the master end. +.pp +data flow between master and slave is handled asynchronously, +much like data flow with a physical terminal. +data written to the slave will be available at the master promptly, +but may not be available immediately. +similarly, there may be a small processing delay between +a write to the master, and the effect being visible at the slave. +.pp +historically, two pseudoterminal apis have evolved: bsd and system v. +susv1 standardized a pseudoterminal api based on the system v api, +and this api should be employed in all new programs that use +pseudoterminals. +.pp +linux provides both bsd-style and (standardized) system v-style +pseudoterminals. +system v-style terminals are commonly called unix 98 pseudoterminals +on linux systems. +.pp +since kernel 2.6.4, bsd-style pseudoterminals are considered deprecated: +support can be disabled when building the kernel by disabling the +.b config_legacy_ptys +option. +(starting with linux 2.6.30, +that option is disabled by default in the mainline kernel.) +unix 98 pseudoterminals should be used in new applications. +.ss unix 98 pseudoterminals +an unused unix 98 pseudoterminal master is opened by calling +.br posix_openpt (3). +(this function opens the master clone device, +.ir /dev/ptmx ; +see +.br pts (4).) +after performing any program-specific initializations, +changing the ownership and permissions of the slave device using +.br grantpt (3), +and unlocking the slave using +.br unlockpt (3)), +the corresponding slave device can be opened by passing +the name returned by +.br ptsname (3) +in a call to +.br open (2). +.pp +the linux kernel imposes a limit on the number of available +unix 98 pseudoterminals. +in kernels up to and including 2.6.3, this limit is configured +at kernel compilation time +.rb ( config_unix98_ptys ), +and the permitted number of pseudoterminals can be up to 2048, +with a default setting of 256. +since kernel 2.6.4, the limit is dynamically adjustable via +.ir /proc/sys/kernel/pty/max , +and a corresponding file, +.ir /proc/sys/kernel/pty/nr , +indicates how many pseudoterminals are currently in use. +for further details on these two files, see +.br proc (5). +.ss bsd pseudoterminals +bsd-style pseudoterminals are provided as precreated pairs, with +names of the form +.i /dev/ptyxy +(master) and +.i /dev/ttyxy +(slave), +where x is a letter from the 16-character set [p\-za\-e], +and y is a letter from the 16-character set [0\-9a\-f]. +(the precise range of letters in these two sets varies across unix +implementations.) +for example, +.i /dev/ptyp1 +and +.i /dev/ttyp1 +constitute a bsd pseudoterminal pair. +a process finds an unused pseudoterminal pair by trying to +.br open (2) +each pseudoterminal master until an open succeeds. +the corresponding pseudoterminal slave (substitute "tty" +for "pty" in the name of the master) can then be opened. +.sh files +.tp +.i /dev/ptmx +unix 98 master clone device +.tp +.i /dev/pts/* +unix 98 slave devices +.tp +.i /dev/pty[p\-za\-e][0\-9a\-f] +bsd master devices +.tp +.i /dev/tty[p\-za\-e][0\-9a\-f] +bsd slave devices +.sh notes +pseudoterminals are used by applications such as network login services +.rb ( ssh "(1), " rlogin "(1), " telnet (1)), +terminal emulators such as +.br xterm (1), +.br script (1), +.br screen (1), +.br tmux (1), +.br unbuffer (1), +and +.br expect (1). +.pp +a description of the +.b tiocpkt +.br ioctl (2), +which controls packet mode operation, can be found in +.br ioctl_tty (2). +.pp +the bsd +.br ioctl (2) +operations +.br tiocstop , +.br tiocstart , +.br tiocucntl , +and +.br tiocremote +have not been implemented under linux. +.sh see also +.br ioctl_tty (2), +.br select (2), +.br setsid (2), +.br forkpty (3), +.br openpty (3), +.br termios (3), +.br pts (4), +.br tty (4) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 2013 michael kerrisk +.\" (replaces an earlier page by walter harms and michael kerrisk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th canonicalize_file_name 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +canonicalize_file_name \- return the canonicalized absolute pathname +.sh synopsis +.nf +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "char *canonicalize_file_name(const char *" path ");" +.fi +.sh description +the +.br canonicalize_file_name () +function returns a null-terminated string containing +the canonicalized absolute pathname corresponding to +.ir path . +in the returned string, symbolic links are resolved, as are +.i . +and +.i .. +pathname components. +consecutive slash +.ri ( / ) +characters are replaced by a single slash. +.pp +the returned string is dynamically allocated by +.br canonicalize_file_name () +and the caller should deallocate it with +.br free (3) +when it is no longer required. +.pp +the call +.i canonicalize_file_name(path) +is equivalent to the call: +.pp + realpath(path, null); +.sh return value +on success, +.br canonicalize_file_name () +returns a null-terminated string. +on error (e.g., a pathname component is unreadable or does not exist), +.br canonicalize_file_name () +returns null and sets +.i errno +to indicate the error. +.sh errors +see +.br realpath (3). +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br canonicalize_file_name () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +this function is a gnu extension. +.sh see also +.br readlink (2), +.br realpath (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1993 michael haardt (michael@moria.de), +.\" thu may 20 20:45:48 met dst 1993 +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" modified sat jul 24 17:11:07 1993 by rik faith (faith@cs.unc.edu) +.\" modified sun nov 21 10:49:38 1993 by michael haardt +.\" modified sun feb 26 15:09:15 1995 by rik faith (faith@cs.unc.edu) +.th shells 5 2020-06-09 "" "linux programmer's manual" +.sh name +shells \- pathnames of valid login shells +.sh description +.i /etc/shells +is a text file which contains the full pathnames of valid login shells. +this file is consulted by +.br chsh (1) +and available to be queried by other programs. +.pp +be aware that there are programs which consult this file to +find out if a user is a normal user; +for example, +ftp daemons traditionally +disallow access to users with shells not included in this file. +.sh files +.i /etc/shells +.sh examples +.i /etc/shells +may contain the following paths: +.pp +.in +4n +.ex +.i /bin/sh +.i /bin/bash +.i /bin/csh +.ee +.in +.sh see also +.br chsh (1), +.br getusershell (3), +.br pam_shells (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" @(#)des_crypt.3 2.1 88/08/11 4.0 rpcsrc; from 1.16 88/03/02 smi; +.\" +.\" taken from libc4 sources, which say: +.\" copyright (c) 1993 eric young - can be distributed under gpl. +.\" +.\" however, the above header line suggests that this file in fact is +.\" copyright sun microsystems, inc (and is provided for unrestricted use, +.\" see other sun rpc sources). +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" can be distributed under gpl. +.\" %%%license_end +.\" +.th des_crypt 3 2021-03-22 "" "linux programmer's manual" +.sh name +des_crypt, ecb_crypt, cbc_crypt, des_setparity, des_failed \- fast +des encryption +.sh synopsis +.nf +.\" sun version +.\" .b #include +.b #include +.pp +.bi "int ecb_crypt(char *" key ", char *" data ", unsigned int " datalen , +.bi " unsigned int " mode ); +.bi "int cbc_crypt(char *" key ", char *" data ", unsigned int " datalen , +.bi " unsigned int " mode ", char *" ivec ); +.pp +.bi "void des_setparity(char *" key ); +.pp +.bi "int des_failed(int " status ); +.fi +.sh description +.br ecb_crypt () +and +.br cbc_crypt () +implement the +nbs +des +(data encryption standard). +these routines are faster and more general purpose than +.br crypt (3). +they also are able to utilize +des +hardware if it is available. +.br ecb_crypt () +encrypts in +ecb +(electronic code book) +mode, which encrypts blocks of data independently. +.br cbc_crypt () +encrypts in +cbc +(cipher block chaining) +mode, which chains together +successive blocks. +cbc +mode protects against insertions, deletions, and +substitutions of blocks. +also, regularities in the clear text will +not appear in the cipher text. +.pp +here is how to use these routines. +the first argument, +.ir key , +is the 8-byte encryption key with parity. +to set the key's parity, which for +des +is in the low bit of each byte, use +.br des_setparity (). +the second argument, +.ir data , +contains the data to be encrypted or decrypted. +the +third argument, +.ir datalen , +is the length in bytes of +.ir data , +which must be a multiple of 8. +the fourth argument, +.ir mode , +is formed by oring together some things. +for the encryption direction or in either +.br des_encrypt +or +.br des_decrypt . +for software versus hardware +encryption, or in either +.br des_hw +or +.br des_sw . +if +.br des_hw +is specified, and there is no hardware, then the encryption is performed +in software and the routine returns +.br deserr_nohwdevice . +for +.br cbc_crypt (), +the argument +.i ivec +is the 8-byte initialization +vector for the chaining. +it is updated to the next initialization +vector upon return. +.sh return value +.tp +.br deserr_none +no error. +.tp +.br deserr_nohwdevice +encryption succeeded, but done in software instead of the requested hardware. +.tp +.br deserr_hwerror +an error occurred in the hardware or driver. +.tp +.br deserr_badparam +bad argument to routine. +.pp +given a result status +.ir stat , +the macro +.\" .br des_failed\c +.\" .br ( stat ) +.bi des_failed( stat ) +is false only for the first two statuses. +.\" so far the sun page +.\" some additions - aeb +.sh versions +these functions were added to glibc in version 2.1. +.pp +because they employ the des block cipher, +which is no longer considered secure, +.br ecb_crypt (), +.br ecb_crypt (), +.br crypt_r (), +and +.br des_setparity () +were removed in glibc 2.28. +applications should switch to a modern cryptography library, such as +.br libgcrypt . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br ecb_crypt (), +.br cbc_crypt (), +.br des_setparity () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +4.3bsd. +not in posix.1. +.sh see also +.br des (1), +.br crypt (3), +.br xcrypt (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man7/iso_8859-1.7 + +.so man3/pthread_spin_init.3 + +.so man3/ether_aton.3 + +.so man3/stailq.3 + +.so man3/xdr.3 + +.so man3/cpu_set.3 + +.so man3/termios.3 + +.\" copyright (c) 2001 bert hubert +.\" and copyright (c) 2007 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" created sun jun 3 17:23:32 2001 by bert hubert +.\" slightly adapted, following comments by hugh dickins, aeb, 2001-06-04. +.\" modified, 20 may 2003, michael kerrisk +.\" modified, 30 apr 2004, michael kerrisk +.\" 2005-04-05 mtk, fixed error descriptions +.\" after message from +.\" 2007-01-08 mtk, rewrote various parts +.\" +.th mincore 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +mincore \- determine whether pages are resident in memory +.sh synopsis +.nf +.b #include +.pp +.bi "int mincore(void *" addr ", size_t " length ", unsigned char *" vec ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br mincore (): +.nf + since glibc 2.19: + _default_source + glibc 2.19 and earlier: + _bsd_source || _svid_source +.fi +.sh description +.br mincore () +returns a vector that indicates whether pages +of the calling process's virtual memory are resident in core (ram), +and so will not cause a disk access (page fault) if referenced. +the kernel returns residency information about the pages +starting at the address +.ir addr , +and continuing for +.i length +bytes. +.pp +the +.i addr +argument must be a multiple of the system page size. +the +.i length +argument need not be a multiple of the page size, +but since residency information is returned for whole pages, +.i length +is effectively rounded up to the next multiple of the page size. +one may obtain the page size +.rb ( page_size ) +using +.ir sysconf(_sc_pagesize) . +.pp +the +.i vec +argument must point to an array containing at least +.i "(length+page_size\-1) / page_size" +bytes. +on return, +the least significant bit of each byte will be set if +the corresponding page is currently resident in memory, +and be clear otherwise. +(the settings of the other bits in each byte are undefined; +these bits are reserved for possible later use.) +of course the information returned in +.i vec +is only a snapshot: pages that are not +locked in memory can come and go at any moment, and the contents of +.i vec +may already be stale by the time this call returns. +.sh return value +on success, +.br mincore () +returns zero. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.b eagain +kernel is temporarily out of resources. +.tp +.b efault +.i vec +points to an invalid address. +.tp +.b einval +.i addr +is not a multiple of the page size. +.tp +.b enomem +.i length +is greater than +.ri ( task_size " \- " addr ). +(this could occur if a negative value is specified for +.ir length , +since that value will be interpreted as a large +unsigned integer.) +in linux 2.6.11 and earlier, the error +.b einval +was returned for this condition. +.tp +.b enomem +.i addr +to +.i addr ++ +.i length +contained unmapped memory. +.sh versions +available since linux 2.3.99pre1 and glibc 2.2. +.sh conforming to +.br mincore () +is not specified in posix.1, +and it is not available on all unix implementations. +.\" it is on at least netbsd, freebsd, openbsd, solaris 8, +.\" aix 5.1, sunos 4.1 +.\" .sh history +.\" the +.\" .br mincore () +.\" function first appeared in 4.4bsd. +.sh bugs +before kernel 2.6.21, +.br mincore () +did not return correct information for +.b map_private +mappings, or for nonlinear mappings (established using +.br remap_file_pages (2)). +.\" linux (up to now, 2.6.5), +.\" .b mincore +.\" does not return correct information for map_private mappings: +.\" for a map_private file mapping, +.\" .b mincore +.\" returns the residency of the file pages, rather than any +.\" modified process-private pages that have been copied on write; +.\" for a map_private mapping of +.\" .ir /dev/zero , +.\" .b mincore +.\" always reports pages as nonresident; +.\" and for a map_private, map_anonymous mapping, +.\" .b mincore +.\" always fails with the error +.\" .br enomem . +.sh see also +.br fincore (1), +.br madvise (2), +.br mlock (2), +.br mmap (2), +.br posix_fadvise (2), +.br posix_madvise (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th sigwait 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +sigwait \- wait for a signal +.sh synopsis +.nf +.b #include +.pp +.bi "int sigwait(const sigset_t *restrict " set ", int *restrict " sig ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br sigwait (): +.nf + since glibc 2.26: + _posix_c_source >= 199506l + glibc 2.25 and earlier: + _posix_c_source +.fi +.sh description +the +.br sigwait () +function suspends execution of the calling thread until +one of the signals specified in the signal set +.ir set +becomes pending. +the function accepts the signal +(removes it from the pending list of signals), +and returns the signal number in +.ir sig . +.pp +the operation of +.br sigwait () +is the same as +.br sigwaitinfo (2), +except that: +.ip * 2 +.br sigwait () +returns only the signal number, rather than a +.i siginfo_t +structure describing the signal. +.ip * +the return values of the two functions are different. +.sh return value +on success, +.br sigwait () +returns 0. +on error, it returns a positive error number (listed in errors). +.sh errors +.tp +.b einval +.\" does not occur for glibc. +.i set +contains an invalid signal number. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br sigwait () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +.br sigwait () +is implemented using +.br sigtimedwait (2). +.pp +the glibc implementation of +.br sigwait () +silently ignores attempts to wait for the two real-time signals that +are used internally by the nptl threading implementation. +see +.br nptl (7) +for details. +.sh examples +see +.br pthread_sigmask (3). +.sh see also +.br sigaction (2), +.br signalfd (2), +.br sigpending (2), +.br sigsuspend (2), +.br sigwaitinfo (2), +.br sigsetops (3), +.br signal (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2003 andries brouwer (aeb@cwi.nl) +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th wordexp 3 2021-08-27 "" "linux programmer's manual" +.sh name +wordexp, wordfree \- perform word expansion like a posix-shell +.sh synopsis +.nf +.b "#include " +.pp +.bi "int wordexp(const char *restrict " s ", wordexp_t *restrict " p \ +", int " flags ); +.bi "void wordfree(wordexp_t *" p ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br wordexp (), +.br wordfree (): +.nf + _xopen_source +.fi +.sh description +the function +.br wordexp () +performs a shell-like expansion of the string +.i s +and returns the result in the structure pointed to by +.ir p . +the data type +.i wordexp_t +is a structure that at least has the fields +.ir we_wordc , +.ir we_wordv , +and +.ir we_offs . +the field +.i we_wordc +is a +.i size_t +that gives the number of words in the expansion of +.ir s . +the field +.i we_wordv +is a +.i "char\ **" +that points to the array of words found. +the field +.i we_offs +of type +.i size_t +is sometimes (depending on +.ir flags , +see below) used to indicate the number of initial elements in the +.i we_wordv +array that should be filled with nulls. +.pp +the function +.br wordfree () +frees the allocated memory again. +more precisely, it does not free +its argument, but it frees the array +.i we_wordv +and the strings that points to. +.ss the string argument +since the expansion is the same as the expansion by the shell (see +.br sh (1)) +of the parameters to a command, the string +.i s +must not contain characters that would be illegal in shell command +parameters. +in particular, there must not be any unescaped +newline or |, &, ;, <, >, (, ), {, } characters +outside a command substitution or parameter substitution context. +.pp +if the argument +.i s +contains a word that starts with an unquoted comment character #, +then it is unspecified whether that word and all following words +are ignored, or the # is treated as a non-comment character. +.ss the expansion +the expansion done consists of the following stages: +tilde expansion (replacing \(tiuser by user's home directory), +variable substitution (replacing $foo by the value of the environment +variable foo), command substitution (replacing $(command) or \`command\` +by the output of command), arithmetic expansion, field splitting, +wildcard expansion, quote removal. +.pp +the result of expansion of special parameters +($@, $*, $#, $?, $\-, $$, $!, $0) is unspecified. +.pp +field splitting is done using the environment variable $ifs. +if it is not set, the field separators are space, tab, and newline. +.ss the output array +the array +.i we_wordv +contains the words found, followed by a null. +.ss the flags argument +the +.i flag +argument is a bitwise inclusive or of the following values: +.tp +.b wrde_append +append the words found to the array resulting from a previous call. +.tp +.b wrde_dooffs +insert +.i we_offs +initial nulls in the array +.ir we_wordv . +(these are not counted in the returned +.ir we_wordc .) +.tp +.b wrde_nocmd +don't do command substitution. +.tp +.b wrde_reuse +the argument +.i p +resulted from a previous call to +.br wordexp (), +and +.br wordfree () +was not called. +reuse the allocated storage. +.tp +.b wrde_showerr +normally during command substitution +.i stderr +is redirected to +.ir /dev/null . +this flag specifies that +.i stderr +is not to be redirected. +.tp +.b wrde_undef +consider it an error if an undefined shell variable is expanded. +.sh return value +on success, +.br wordexp () +returns 0. +on failure, +.br wordexp () +returns one of the following nonzero values: +.tp +.b wrde_badchar +illegal occurrence of newline or one of |, &, ;, <, >, (, ), {, }. +.tp +.b wrde_badval +an undefined shell variable was referenced, and the +.b wrde_undef +flag +told us to consider this an error. +.tp +.b wrde_cmdsub +command substitution requested, but the +.b wrde_nocmd +flag told us to consider this an error. +.tp +.b wrde_nospace +out of memory. +.tp +.b wrde_syntax +shell syntax error, such as unbalanced parentheses or +unmatched quotes. +.sh versions +.br wordexp () +and +.br wordfree () +are provided in glibc since version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lb lb lbx +l l l. +interface attribute value +t{ +.br wordexp () +t} thread safety t{ +mt-unsafe race:utent const:env +env sig:alrm timer locale +t} +t{ +.br wordfree () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +in the above table, +.i utent +in +.i race:utent +signifies that if any of the functions +.br setutent (3), +.br getutent (3), +or +.br endutent (3) +are used in parallel in different threads of a program, +then data races could occur. +.br wordexp () +calls those functions, +so we use race:utent to remind users. +.sh conforming to +posix.1-2001, posix.1-2008. +.sh examples +the output of the following example program +is approximately that of "ls [a-c]*.c". +.pp +.ex +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + wordexp_t p; + char **w; + + wordexp("[a\-c]*.c", &p, 0); + w = p.we_wordv; + for (int i = 0; i < p.we_wordc; i++) + printf("%s\en", w[i]); + wordfree(&p); + exit(exit_success); +} +.ee +.sh see also +.br fnmatch (3), +.br glob (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" iso/iec 9899:1999 +.\" +.th wctomb 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +wctomb \- convert a wide character to a multibyte sequence +.sh synopsis +.nf +.b #include +.pp +.bi "int wctomb(char *" s ", wchar_t " wc ); +.fi +.sh description +if +.i s +is not null, +the +.br wctomb () +function converts the wide character +.i wc +to its multibyte representation and stores it at the beginning of +the character array pointed to by +.ir s . +it updates the shift state, which +is stored in a static anonymous variable +known only to the +.br wctomb () +function, +and returns the length of said multibyte representation, +that is, the number of +bytes written at +.ir s . +.pp +the programmer must ensure that there is +room for at least +.b mb_cur_max +bytes at +.ir s . +.pp +if +.i s +is null, the +.br wctomb () +function +.\" the dinkumware doc and the single unix specification say this, but +.\" glibc doesn't implement this. +resets the shift state, known only to this function, +to the initial state, and +returns nonzero if the encoding has nontrivial shift state, +or zero if the encoding is stateless. +.sh return value +if +.i s +is not null, the +.br wctomb () +function +returns the number of bytes +that have been written to the byte array at +.ir s . +if +.i wc +can not be +represented as a multibyte sequence (according +to the current locale), \-1 is returned. +.pp +if +.i s +is null, the +.br wctomb () +function returns nonzero if the +encoding has nontrivial shift state, or zero if the encoding is stateless. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br wctomb () +t} thread safety mt-unsafe race +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh notes +the behavior of +.br wctomb () +depends on the +.b lc_ctype +category of the +current locale. +.pp +the function +.br wcrtomb (3) +provides +a better interface to the same functionality. +.sh see also +.br mb_cur_max (3), +.br mblen (3), +.br mbstowcs (3), +.br mbtowc (3), +.br wcrtomb (3), +.br wcstombs (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1995 jim van zandt and aeb +.\" sun feb 26 11:46:23 met 1995 +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" modified, sun feb 26 15:04:20 1995, faith@cs.unc.edu +.\" modified, thu apr 20 22:08:17 1995, jrv@vanzandt.mv.com +.\" modified, mon sep 18 22:32:47 1995, hpa@storm.net (h. peter anvin) +.\" fixme the following are not documented: +.\" kdfontop (since 2.1.111) +.\" kdgkbdiacruc (since 2.6.24) +.\" kdskbdiacr +.\" kdskbdiacruc (since 2.6.24) +.\" kdkbdrep (since 2.1.113) +.\" kdmapdisp (not implemented as at 2.6.27) +.\" kdunmapdisp (not implemented as at 2.6.27) +.\" vt_lockswitch (since 1.3.47, needs cap_sys_tty_config) +.\" vt_unlockswitch (since 1.3.47, needs cap_sys_tty_config) +.\" vt_gethifontmask (since 2.6.18) +.\" +.th ioctl_console 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +ioctl_console \- ioctls for console terminal and virtual consoles +.sh description +the following linux-specific +.br ioctl (2) +requests are supported for console terminals and virtual consoles. +each requires a third argument, assumed here to be +.ir argp . +.tp +.b kdgetled +get state of leds. +.i argp +points to a +.ir char . +the lower three bits +of +.i *argp +are set to the state of the leds, as follows: +.ts +l l l. +led_cap 0x04 caps lock led +led_num 0x02 num lock led +led_scr 0x01 scroll lock led +.te +.tp +.b kdsetled +set the leds. +the leds are set to correspond to the lower three bits of the +unsigned long integer in +.ir argp . +however, if a higher order bit is set, +the leds revert to normal: displaying the state of the +keyboard functions of caps lock, num lock, and scroll lock. +.pp +before linux 1.1.54, the leds just reflected the state of the corresponding +keyboard flags, and kdgetled/kdsetled would also change the keyboard +flags. +since linux 1.1.54 the leds can be made to display arbitrary +information, but by default they display the keyboard flags. +the following two ioctls are used to access the keyboard flags. +.tp +.b kdgkbled +get keyboard flags capslock, numlock, scrolllock (not lights). +.i argp +points to a char which is set to the flag state. +the low order three bits (mask 0x7) get the current flag state, +and the low order bits of the next nibble (mask 0x70) get +the default flag state. +(since linux 1.1.54.) +.tp +.b kdskbled +set keyboard flags capslock, numlock, scrolllock (not lights). +.i argp +is an unsigned long integer that has the desired flag state. +the low order three bits (mask 0x7) have the flag state, +and the low order bits of the next nibble (mask 0x70) have +the default flag state. +(since linux 1.1.54.) +.tp +.b kdgkbtype +get keyboard type. +this returns the value kb_101, defined as 0x02. +.tp +.b kdaddio +add i/o port as valid. +equivalent to +.ir ioperm(arg,1,1) . +.tp +.b kddelio +delete i/o port as valid. +equivalent to +.ir ioperm(arg,1,0) . +.tp +.b kdenabio +enable i/o to video board. +equivalent to +.ir "ioperm(0x3b4, 0x3df\-0x3b4+1, 1)" . +.tp +.b kddisabio +disable i/o to video board. +equivalent to +.ir "ioperm(0x3b4, 0x3df\-0x3b4+1, 0)" . +.tp +.b kdsetmode +set text/graphics mode. +.i argp +is an unsigned integer containing one of: +.ts +l l. +kd_text 0x00 +kd_graphics 0x01 +.te +.tp +.b kdgetmode +get text/graphics mode. +.i argp +points to an +.i int +which is set to one +of the values shown above for +.br kdsetmode . +.tp +.b kdmktone +generate tone of specified length. +the lower 16 bits of the unsigned long integer in +.i argp +specify the period in clock cycles, +and the upper 16 bits give the duration in msec. +if the duration is zero, the sound is turned off. +control returns immediately. +for example, +.i argp += (125<<16) + 0x637 would specify +the beep normally associated with a ctrl-g. +(thus since linux 0.99pl1; broken in linux 2.1.49-50.) +.tp +.b kiocsound +start or stop sound generation. +the lower 16 bits of +.i argp +specify the period in clock cycles +(that is, +.i argp += 1193180/frequency). +.i argp += 0 turns sound off. +in either case, control returns immediately. +.tp +.b gio_cmap +get the current default color map from kernel. +.i argp +points to +a 48-byte array. +(since linux 1.3.3.) +.tp +.b pio_cmap +change the default text-mode color map. +.i argp +points to a +48-byte array which contains, in order, the red, green, and blue +values for the 16 available screen colors: 0 is off, and 255 is full +intensity. +the default colors are, in order: black, dark red, dark +green, brown, dark blue, dark purple, dark cyan, light grey, dark +grey, bright red, bright green, yellow, bright blue, bright purple, +bright cyan, and white. +(since linux 1.3.3.) +.tp +.b gio_font +gets 256-character screen font in expanded form. +.i argp +points to an 8192-byte array. +fails with error code +.b einval +if the +currently loaded font is a 512-character font, or if the console is +not in text mode. +.tp +.b gio_fontx +gets screen font and associated information. +.i argp +points to a +.i "struct consolefontdesc" +(see +.br pio_fontx ). +on call, the +.i charcount +field should be set to the maximum number of +characters that would fit in the buffer pointed to by +.ir chardata . +on return, the +.i charcount +and +.i charheight +are filled with +the respective data for the currently loaded font, and the +.i chardata +array contains the font data if the initial value of +.i charcount +indicated enough space was available; otherwise the +buffer is untouched and +.i errno +is set to +.br enomem . +(since linux 1.3.1.) +.tp +.b pio_font +sets 256-character screen font. +load font into the ega/vga character +generator. +.i argp +points to an 8192-byte map, with 32 bytes per +character. +only the first +.i n +of them are used for an 8x\fin\fp font +(0 < +.i n +<= 32). +this call also invalidates the unicode mapping. +.tp +.b pio_fontx +sets screen font and associated rendering information. +.i argp +points to a +.ip +.in +4n +.ex +struct consolefontdesc { + unsigned short charcount; /* characters in font + (256 or 512) */ + unsigned short charheight; /* scan lines per + character (1\-32) */ + char *chardata; /* font data in + expanded form */ +}; +.ee +.in +.ip +if necessary, the screen will be appropriately resized, and +.b sigwinch +sent to the appropriate processes. +this call also invalidates the unicode mapping. +(since linux 1.3.1.) +.tp +.b pio_fontreset +resets the screen font, size, and unicode mapping to the bootup +defaults. +.i argp +is unused, but should be set to null to +ensure compatibility with future versions of linux. +(since linux 1.3.28.) +.tp +.b gio_scrnmap +get screen mapping from kernel. +.i argp +points to an area of size +e_tabsz, which is loaded with the font positions used to display each +character. +this call is likely to return useless information if the +currently loaded font is more than 256 characters. +.tp +.b gio_uniscrnmap +get full unicode screen mapping from kernel. +.i argp +points to an +area of size +.ir "e_tabsz*sizeof(unsigned short)" , +which is loaded with the +unicodes each character represent. +a special set of unicodes, +starting at u+f000, are used to represent "direct to font" mappings. +(since linux 1.3.1.) +.tp +.b pio_scrnmap +loads the "user definable" (fourth) table in the kernel which maps +bytes into console screen symbols. +.i argp +points to an area of +size e_tabsz. +.tp +.b pio_uniscrnmap +loads the "user definable" (fourth) table in the kernel which maps +bytes into unicodes, which are then translated into screen symbols +according to the currently loaded unicode-to-font map. +special unicodes starting at u+f000 can be used to map directly to the font +symbols. +(since linux 1.3.1.) +.tp +.b gio_unimap +get unicode-to-font mapping from kernel. +.i argp +points to a +.ip +.in +4n +.ex +struct unimapdesc { + unsigned short entry_ct; + struct unipair *entries; +}; +.ee +.in +.ip +where +.i entries +points to an array of +.ip +.in +4n +.ex +struct unipair { + unsigned short unicode; + unsigned short fontpos; +}; +.ee +.in +.ip +(since linux 1.1.92.) +.tp +.b pio_unimap +put unicode-to-font mapping in kernel. +.i argp +points to a +.ir "struct unimapdesc" . +(since linux 1.1.92) +.tp +.b pio_unimapclr +clear table, possibly advise hash algorithm. +.i argp +points to a +.ip +.in +4n +.ex +struct unimapinit { + unsigned short advised_hashsize; /* 0 if no opinion */ + unsigned short advised_hashstep; /* 0 if no opinion */ + unsigned short advised_hashlevel; /* 0 if no opinion */ +}; +.ee +.in +.ip +(since linux 1.1.92.) +.tp +.b kdgkbmode +gets current keyboard mode. +.i argp +points to a +.i long +which is set to one +of these: +.ts +l l. +k_raw 0x00 /* raw (scancode) mode */ +k_xlate 0x01 /* translate keycodes using keymap */ +k_mediumraw 0x02 /* medium raw (scancode) mode */ +k_unicode 0x03 /* unicode mode */ +k_off 0x04 /* disabled mode; since linux 2.6.39 */ +.\" k_off: commit 9fc3de9c83565fcaa23df74c2fc414bb6e7efb0a +.te +.tp +.b kdskbmode +sets current keyboard mode. +.i argp +is a +.i long +equal to one of the values shown for +.br kdgkbmode . +.tp +.b kdgkbmeta +gets meta key handling mode. +.i argp +points to a +.i long +which is +set to one of these: +.ts +l l l. +k_metabit 0x03 set high order bit +k_escprefix 0x04 escape prefix +.te +.tp +.b kdskbmeta +sets meta key handling mode. +.i argp +is a +.i long +equal to one of the values shown above for +.br kdgkbmeta . +.tp +.b kdgkbent +gets one entry in key translation table (keycode to action code). +.i argp +points to a +.ip +.in +4n +.ex +struct kbentry { + unsigned char kb_table; + unsigned char kb_index; + unsigned short kb_value; +}; +.ee +.in +.ip +with the first two members filled in: +.i kb_table +selects the key table (0 <= +.i kb_table +< max_nr_keymaps), +and +.ir kb_index +is the keycode (0 <= +.i kb_index +< nr_keys). +.i kb_value +is set to the corresponding action code, +or k_hole if there is no such key, +or k_nosuchmap if +.i kb_table +is invalid. +.tp +.b kdskbent +sets one entry in translation table. +.i argp +points to a +.ir "struct kbentry" . +.tp +.b kdgkbsent +gets one function key string. +.i argp +points to a +.ip +.in +4n +.ex +struct kbsentry { + unsigned char kb_func; + unsigned char kb_string[512]; +}; +.ee +.in +.ip +.i kb_string +is set to the (null-terminated) string corresponding to +the +.ir kb_func th +function key action code. +.tp +.b kdskbsent +sets one function key string entry. +.i argp +points to a +.ir "struct kbsentry" . +.tp +.b kdgkbdiacr +read kernel accent table. +.i argp +points to a +.ip +.in +4n +.ex +struct kbdiacrs { + unsigned int kb_cnt; + struct kbdiacr kbdiacr[256]; +}; +.ee +.in +.ip +where +.i kb_cnt +is the number of entries in the array, each of which +is a +.ip +.in +4n +.ex +struct kbdiacr { + unsigned char diacr; + unsigned char base; + unsigned char result; +}; +.ee +.in +.tp +.b kdgetkeycode +read kernel keycode table entry (scan code to keycode). +.i argp +points to a +.ip +.in +4n +.ex +struct kbkeycode { + unsigned int scancode; + unsigned int keycode; +}; +.ee +.in +.ip +.i keycode +is set to correspond to the given +.ir scancode . +(89 <= +.i scancode +<= 255 only. +for 1 <= +.i scancode +<= 88, +.ir keycode == scancode .) +(since linux 1.1.63.) +.tp +.b kdsetkeycode +write kernel keycode table entry. +.i argp +points to a +.ir "struct kbkeycode" . +(since linux 1.1.63.) +.tp +.b kdsigaccept +the calling process indicates its willingness to accept the signal +.i argp +when it is generated by pressing an appropriate key combination. +(1 <= +.i argp +<= nsig). +(see +.ir spawn_console () +in +.ir linux/drivers/char/keyboard.c .) +.tp +.b vt_openqry +returns the first available (non-opened) console. +.i argp +points to an +.i int +which is set to the +number of the vt (1 <= +.i *argp +<= max_nr_consoles). +.tp +.b vt_getmode +get mode of active vt. +.i argp +points to a +.ip +.in +4n +.ex +struct vt_mode { + char mode; /* vt mode */ + char waitv; /* if set, hang on writes if not active */ + short relsig; /* signal to raise on release req */ + short acqsig; /* signal to raise on acquisition */ + short frsig; /* unused (set to 0) */ +}; +.ee +.in +.ip +which is set to the mode of the active vt. +.i mode +is set to one of these values: +.ts +l l. +vt_auto auto vt switching +vt_process process controls switching +vt_ackacq acknowledge switch +.te +.tp +.b vt_setmode +set mode of active vt. +.i argp +points to a +.ir "struct vt_mode" . +.tp +.b vt_getstate +get global vt state info. +.i argp +points to a +.ip +.in +4n +.ex +struct vt_stat { + unsigned short v_active; /* active vt */ + unsigned short v_signal; /* signal to send */ + unsigned short v_state; /* vt bit mask */ +}; +.ee +.in +.ip +for each vt in use, the corresponding bit in the +.i v_state +member is set. +(kernels 1.0 through 1.1.92.) +.tp +.b vt_reldisp +release a display. +.tp +.b vt_activate +switch to vt +.ir argp +(1 <= +.i argp +<= max_nr_consoles). +.tp +.b vt_waitactive +wait until vt +.i argp +has been activated. +.tp +.b vt_disallocate +deallocate the memory associated with vt +.ir argp . +(since linux 1.1.54.) +.tp +.b vt_resize +set the kernel's idea of screensize. +.i argp +points to a +.ip +.in +4n +.ex +struct vt_sizes { + unsigned short v_rows; /* # rows */ + unsigned short v_cols; /* # columns */ + unsigned short v_scrollsize; /* no longer used */ +}; +.ee +.in +.ip +note that this does not change the videomode. +see +.br resizecons (8). +(since linux 1.1.54.) +.tp +.b vt_resizex +set the kernel's idea of various screen parameters. +.i argp +points to a +.ip +.in +4n +.ex +struct vt_consize { + unsigned short v_rows; /* number of rows */ + unsigned short v_cols; /* number of columns */ + unsigned short v_vlin; /* number of pixel rows + on screen */ + unsigned short v_clin; /* number of pixel rows + per character */ + unsigned short v_vcol; /* number of pixel columns + on screen */ + unsigned short v_ccol; /* number of pixel columns + per character */ +}; +.ee +.in +.ip +any parameter may be set to zero, indicating "no change", but if +multiple parameters are set, they must be self-consistent. +note that this does not change the videomode. +see +.br resizecons (8). +(since linux 1.3.3.) +.pp +the action of the following ioctls depends on the first byte in the struct +pointed to by +.ir argp , +referred to here as the +.ir subcode . +these are legal only for the superuser or the owner of the current terminal. +.tp +.b "tioclinux, subcode=0" +dump the screen. +disappeared in linux 1.1.92. +(with kernel 1.1.92 or later, read from +.i /dev/vcsn +or +.i /dev/vcsan +instead.) +.tp +.b "tioclinux, subcode=1" +get task information. +disappeared in linux 1.1.92. +.tp +.b "tioclinux, subcode=2" +set selection. +.i argp +points to a +.ip +.in +4n +.ex +struct { + char subcode; + short xs, ys, xe, ye; + short sel_mode; +}; +.ee +.in +.ip +.i xs +and +.i ys +are the starting column and row. +.i xe +and +.i ye +are the ending +column and row. +(upper left corner is row=column=1.) +.i sel_mode +is 0 for character-by-character selection, +1 for word-by-word selection, +or 2 for line-by-line selection. +the indicated screen characters are highlighted and saved +in the static array sel_buffer in +.ir devices/char/console.c . +.tp +.b "tioclinux, subcode=3" +paste selection. +the characters in the selection buffer are +written to +.ir fd . +.tp +.b "tioclinux, subcode=4" +unblank the screen. +.tp +.b "tioclinux, subcode=5" +sets contents of a 256-bit look up table defining characters in a "word", +for word-by-word selection. +(since linux 1.1.32.) +.tp +.b "tioclinux, subcode=6" +.i argp +points to a char which is set to the value of the kernel +variable +.ir shift_state . +(since linux 1.1.32.) +.tp +.b "tioclinux, subcode=7" +.i argp +points to a char which is set to the value of the kernel +variable +.ir report_mouse . +(since linux 1.1.33.) +.tp +.b "tioclinux, subcode=8" +dump screen width and height, cursor position, and all the +character-attribute pairs. +(kernels 1.1.67 through 1.1.91 only. +with kernel 1.1.92 or later, read from +.i /dev/vcsa* +instead.) +.tp +.b "tioclinux, subcode=9" +restore screen width and height, cursor position, and all the +character-attribute pairs. +(kernels 1.1.67 through 1.1.91 only. +with kernel 1.1.92 or later, write to +.i /dev/vcsa* +instead.) +.tp +.b "tioclinux, subcode=10" +handles the power saving +feature of the new generation of monitors. +vesa screen blanking mode is set to +.ir argp[1] , +which governs what +screen blanking does: +.rs +.ip 0: 3 +screen blanking is disabled. +.ip 1: +the current video adapter +register settings are saved, then the controller is programmed to turn off +the vertical synchronization pulses. +this puts the monitor into "standby" mode. +if your monitor has an off_mode timer, then +it will eventually power down by itself. +.ip 2: +the current settings are saved, then both the vertical and horizontal +synchronization pulses are turned off. +this puts the monitor into "off" mode. +if your monitor has no off_mode timer, +or if you want your monitor to power down immediately when the +blank_timer times out, then you choose this option. +.ri ( caution: +powering down frequently will damage the monitor.) +(since linux 1.1.76.) +.re +.sh return value +on success, 0 is returned. +on failure, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b ebadf +the file descriptor is invalid. +.tp +.b einval +the file descriptor or +.i argp +is invalid. +.tp +.b enotty +the file descriptor is not associated with a character special device, +or the specified request does not apply to it. +.tp +.b eperm +insufficient permission. +.sh notes +.br warning : +do not regard this man page as documentation of the linux console ioctls. +this is provided for the curious only, as an alternative to reading the +source. +ioctl's are undocumented linux internals, liable to be changed +without warning. +(and indeed, this page more or less describes the +situation as of kernel version 1.1.94; +there are many minor and not-so-minor +differences with earlier versions.) +.pp +very often, ioctls are introduced for communication between the +kernel and one particular well-known program (fdisk, hdparm, setserial, +tunelp, loadkeys, selection, setfont, etc.), and their behavior will be +changed when required by this particular program. +.pp +programs using these ioctls will not be portable to other versions +of unix, will not work on older versions of linux, and will not work +on future versions of linux. +.pp +use posix functions. +.sh see also +.br dumpkeys (1), +.br kbd_mode (1), +.br loadkeys (1), +.br mknod (1), +.br setleds (1), +.br setmetamode (1), +.br execve (2), +.br fcntl (2), +.br ioctl_tty (2), +.br ioperm (2), +.br termios (3), +.br console_codes (4), +.br mt (4), +.br sd (4), +.br tty (4), +.br ttys (4), +.br vcs (4), +.br vcsa (4), +.br charsets (7), +.br mapscrn (8), +.br resizecons (8), +.br setfont (8) +.pp +.ir /usr/include/linux/kd.h , +.i /usr/include/linux/vt.h +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sat jul 24 19:39:35 1993 by rik faith (faith@cs.unc.edu) +.\" +.\" modified 2003 walter harms (walter.harms@informatik.uni-oldenburg.de) +.\" +.th ffs 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +ffs, ffsl, ffsll \- find first bit set in a word +.sh synopsis +.nf +.b #include +.pp +.bi "int ffs(int " i ); +.pp +.b #include +.pp +.bi "int ffsl(long " i ); +.bi "int ffsll(long long " i ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br ffs (): +.nf + since glibc 2.12: + _xopen_source >= 700 + || ! (_posix_c_source >= 200809l) + || /* glibc since 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source + before glibc 2.12: + none +.fi +.pp +.br ffsl (), +.br ffsll (): +.nf + since glibc 2.27: +.\" glibc commit 68fe16dd327c895c08b9ee443b234c49c13b36e9 + _default_source + before glibc 2.27: + _gnu_source +.fi +.sh description +the +.br ffs () +function returns the position of the first +(least significant) bit set in the word \fii\fp. +the least significant bit is position 1 and the +most significant position is, for example, 32 or 64. +the functions +.br ffsll () +and +.br ffsl () +do the same but take +arguments of possibly different size. +.sh return value +these functions return the position of the first bit set, +or 0 if no bits are set in +.ir i . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br ffs (), +.br ffsl (), +.br ffsll () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +.br ffs (): +posix.1-2001, posix.1-2008, 4.3bsd. +.pp +the +.br ffsl () +and +.br ffsll () +functions are glibc extensions. +.sh notes +bsd systems have a prototype in +.ir . +.sh see also +.br memchr (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 2004 andries brouwer . +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th finite 3 2021-03-22 "" "linux programmer's manual" +.sh name +finite, finitef, finitel, isinf, isinff, isinfl, isnan, isnanf, isnanl \- +bsd floating-point classification functions +.sh synopsis +.nf +.b #include +.pp +.bi "int finite(double " x ); +.bi "int finitef(float " x ); +.bi "int finitel(long double " x ); +.pp +.bi "int isinf(double " x ); +.bi "int isinff(float " x ); +.bi "int isinfl(long double " x ); +.pp +.bi "int isnan(double " x ); +.bi "int isnanf(float " x ); +.bi "int isnanl(long double " x ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br finite (), +.br finitef (), +.br finitel (): +.nf + /* glibc since 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.pp +.br isinf (): + _xopen_source >= 600 || _isoc99_source + || /* glibc since 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.pp +.br isinff (), +.br isinfl (): +.nf + /* glibc since 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.pp +.br isnan (): +.nf + _xopen_source || _isoc99_source + || /* glibc since 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.pp +.br isnanf (), +.br isnanl (): +.nf + _xopen_source >= 600 + || /* glibc since 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.sh description +the +.br finite (), +.br finitef (), +and +.br finitel () +functions return a nonzero value if +.i x +is neither infinite +nor a "not-a-number" (nan) value, and 0 otherwise. +.pp +the +.br isnan (), +.br isnanf (), +and +.br isnanl () +functions return a nonzero value if +.i x +is a nan value, +and 0 otherwise. +.pp +the +.br isinf (), +.br isinff (), +and +.br isinfl () +functions return 1 if +.i x +is positive infinity, \-1 if +.i x +is negative infinity, and 0 otherwise. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br finite (), +.br finitef (), +.br finitel (), +.br isinf (), +.br isinff (), +.br isinfl (), +.br isnan (), +.br isnanf (), +.br isnanl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh notes +note that these functions are obsolete. +c99 defines macros +.br isfinite (), +.br isinf (), +and +.br isnan () +(for all types) replacing them. +further note that the c99 +.br isinf () +has weaker guarantees on the return value. +see +.br fpclassify (3). +.\" +.\" finite* not on hp-ux; they exist on tru64. +.\" .sh history +.\" the +.\" .br finite () +.\" function occurs in 4.3bsd. +.\" see ieee.3 in the 4.3bsd manual +.sh see also +.br fpclassify (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/atanh.3 + +.so man3/regex.3 + +.so man3/get_nprocs_conf.3 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sat jul 24 18:02:26 1993 by rik faith (faith@cs.unc.edu) +.th strlen 3 2021-08-27 "gnu" "linux programmer's manual" +.sh name +strlen \- calculate the length of a string +.sh synopsis +.nf +.b #include +.pp +.bi "size_t strlen(const char *" s ); +.fi +.sh description +the +.br strlen () +function calculates the length of the string pointed to by +.ir s , +excluding the terminating null byte (\(aq\e0\(aq). +.sh return value +the +.br strlen () +function returns the number of bytes in the string pointed to by +.ir s . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br strlen () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c89, c99, c11, svr4, 4.3bsd. +.sh notes +in cases where the input buffer may not contain +a terminating null byte, +.br strnlen (3) +should be used instead. +.sh see also +.br string (3), +.br strnlen (3), +.br wcslen (3), +.br wcsnlen (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1993 david metcalfe (david@prism.demon.co.uk) +.\" and copyright (c) 2005, 2014, 2020 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sat jul 24 18:05:30 1993 by rik faith +.\" modified fri feb 16 14:25:17 1996 by andries brouwer +.\" modified sun jul 21 20:55:44 1996 by andries brouwer +.\" modified mon oct 15 21:16:25 2001 by john levon +.\" modified tue oct 16 00:04:43 2001 by andries brouwer +.\" modified fri jun 20 03:04:30 2003 by andries brouwer +.\" 2005-12-13, mtk, substantial rewrite of strerror_r() description +.\" addition of extra material on portability and standards. +.\" +.th strerror 3 2021-03-22 "" "linux programmer's manual" +.sh name +strerror, strerrorname_np, strerrordesc_np, strerror_r, strerror_l \- return string describing error number +.sh synopsis +.nf +.b #include +.pp +.bi "char *strerror(int " errnum ); +.bi "const char *strerrorname_np(int " errnum ); +.bi "const char *strerrordesc_np(int " errnum ); +.pp +.bi "int strerror_r(int " errnum ", char *" buf ", size_t " buflen ); + /* xsi-compliant */ +.pp +.bi "char *strerror_r(int " errnum ", char *" buf ", size_t " buflen ); + /* gnu-specific */ +.pp +.bi "char *strerror_l(int " errnum ", locale_t " locale ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br strerrorname_np (), +.br strerrordesc_np (): +.nf + _gnu_source +.fi +.pp +.br strerror_r (): +.nf + the xsi-compliant version is provided if: + (_posix_c_source >= 200112l) && ! _gnu_source + otherwise, the gnu-specific version is provided. +.fi +.sh description +the +.br strerror () +function returns a pointer to a string that describes the error +code passed in the argument +.ir errnum , +possibly using the +.b lc_messages +part of the current locale to select the appropriate language. +(for example, if +.i errnum +is +.br einval , +the returned description will be "invalid argument".) +this string must not be modified by the application, but may be +modified by a subsequent call to +.br strerror () +or +.br strerror_l (). +no other library function, including +.br perror (3), +will modify this string. +.pp +like +.br strerror (), +the +.br strerrordesc_np () +function returns a pointer to a string that describes the error +code passed in the argument +.ir errnum , +with the difference that the returned string is not translated +according to the current locale. +.pp +the +.br strerrorname_np () +function returns a pointer to a string containing the name of the error +code passed in the argument +.ir errnum . +for example, given +.br eperm +as an argument, this function returns a pointer to the string "eperm". +.\" +.ss strerror_r() +the +.br strerror_r () +function is similar to +.br strerror (), +but is +thread safe. +this function is available in two versions: +an xsi-compliant version specified in posix.1-2001 +(available since glibc 2.3.4, but not posix-compliant until glibc 2.13), +and a gnu-specific version (available since glibc 2.0). +the xsi-compliant version is provided with the feature test macros +settings shown in the synopsis; +otherwise the gnu-specific version is provided. +if no feature test macros are explicitly defined, +then (since glibc 2.4) +.b _posix_c_source +is defined by default with the value +200112l, so that the xsi-compliant version of +.br strerror_r () +is provided by default. +.pp +the xsi-compliant +.br strerror_r () +is preferred for portable applications. +it returns the error string in the user-supplied buffer +.i buf +of length +.ir buflen . +.pp +the gnu-specific +.br strerror_r () +returns a pointer to a string containing the error message. +this may be either a pointer to a string that the function stores in +.ir buf , +or a pointer to some (immutable) static string +(in which case +.i buf +is unused). +if the function stores a string in +.ir buf , +then at most +.i buflen +bytes are stored (the string may be truncated if +.i buflen +is too small and +.i errnum +is unknown). +the string always includes a terminating null byte (\(aq\e0\(aq). +.\" +.ss strerror_l() +.br strerror_l () +is like +.br strerror (), +but maps +.i errnum +to a locale-dependent error message in the locale specified by +.ir locale . +the behavior of +.br strerror_l () +is undefined if +.i locale +is the special locale object +.br lc_global_locale +or is not a valid locale object handle. +.sh return value +the +.br strerror (), +.br strerror_l (), +and the gnu-specific +.br strerror_r () +functions return +the appropriate error description string, +or an "unknown error nnn" message if the error number is unknown. +.pp +on success, +.br strerrorname_np () +and +.br strerrordesc_np () +return the appropriate error description string. +if +.i errnum +is an invalid error number, these functions return null. +.pp +the xsi-compliant +.br strerror_r () +function returns 0 on success. +on error, +a (positive) error number is returned (since glibc 2.13), +or \-1 is returned and +.i errno +is set to indicate the error (glibc versions before 2.13). +.pp +posix.1-2001 and posix.1-2008 require that a successful call to +.br strerror () +or +.br strerror_l () +shall leave +.i errno +unchanged, and note that, +since no function return value is reserved to indicate an error, +an application that wishes to check for errors should initialize +.i errno +to zero before the call, +and then check +.i errno +after the call. +.sh errors +.tp +.b einval +the value of +.i errnum +is not a valid error number. +.tp +.b erange +insufficient storage was supplied to contain the error description string. +.sh versions +the +.br strerror_l () +function first appeared in glibc 2.6. +.pp +the +.br strerrorname_np () +and +.br strerrordesc_np () +functions first appeared in glibc 2.32. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lb lb lbx +l l l. +interface attribute value +t{ +.br strerror () +t} thread safety t{ +mt-unsafe race:strerror +t} +t{ +.br strerrorname_np (), +.br strerrordesc_np () +t} thread safety mt-safe +t{ +.br strerror_r (), +.br strerror_l () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +.br strerror () +is specified by posix.1-2001, posix.1-2008, c89, and c99. +.br strerror_r () +is specified by posix.1-2001 and posix.1-2008. +.\" fixme . for later review when issue 8 is one day released... +.\" a future posix.1 may remove strerror_r() +.\" http://austingroupbugs.net/tag_view_page.php?tag_id=8 +.\" http://austingroupbugs.net/view.php?id=508 +.pp +.br strerror_l () +is specified in posix.1-2008. +.pp +the gnu-specific functions +.br strerror_r (), +.br strerrorname_np (), +and +.br strerrordesc_np () +are nonstandard extensions. +.pp +posix.1-2001 permits +.br strerror () +to set +.i errno +if the call encounters an error, but does not specify what +value should be returned as the function result in the event of an error. +on some systems, +.\" e.g., solaris 8, hp-ux 11 +.br strerror () +returns null if the error number is unknown. +on other systems, +.\" e.g., freebsd 5.4, tru64 5.1b +.br strerror () +returns a string something like "error nnn occurred" and sets +.i errno +to +.b einval +if the error number is unknown. +c99 and posix.1-2008 require the return value to be non-null. +.sh notes +the gnu c library uses a buffer of 1024 characters for +.br strerror (). +this buffer size therefore should be sufficient to avoid an +.b erange +error when calling +.br strerror_r (). +.pp +.br strerrorname_np () +and +.br strerrordesc_np () +are thread-safe and async-signal-safe. +.sh see also +.br err (3), +.br errno (3), +.br error (3), +.br perror (3), +.br strsignal (3), +.br locale (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/finite.3 + +.\"copyright (c) 2010 novell inc., written by robert schweikert +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th pthread_rwlockattr_setkind_np 3 2021-03-22 "linux programmer's manual" +.sh name +pthread_rwlockattr_setkind_np, pthread_rwlockattr_getkind_np \- set/get +the read-write lock kind of the thread read-write lock attribute object +.sh synopsis +.nf +.b #include +.pp +.bi "int pthread_rwlockattr_setkind_np(pthread_rwlockattr_t *" attr , +.bi " int " pref ); +.bi "int pthread_rwlockattr_getkind_np(" +.bi " const pthread_rwlockattr_t *restrict " attr , +.bi " int *restrict " pref ); +.pp +compile and link with \fi\-pthread\fp. +.pp +.fi +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br pthread_rwlockattr_setkind_np (), +.br pthread_rwlockattr_getkind_np (): +.nf + _xopen_source >= 500 || _posix_c_source >= 200809l +.fi +.sh description +the +.br pthread_rwlockattr_setkind_np () +function sets the "lock kind" attribute of the +read-write lock attribute object referred to by +.i attr +to the value specified in +.ir pref . +the argument +.i pref +may be set to one of the following: +.tp +.b pthread_rwlock_prefer_reader_np +this is the default. +a thread may hold multiple read locks; that is, read locks are recursive. +according to the single unix specification, the behavior is unspecified when a +reader tries to place a lock, and there is no write lock but writers are +waiting. +giving preference to the reader, as is set by +.br pthread_rwlock_prefer_reader_np , +implies that the reader will receive the requested lock, even if +a writer is waiting. +as long as there are readers, the writer will be +starved. +.tp +.b pthread_rwlock_prefer_writer_np +this is intended as the write lock analog of +.br pthread_rwlock_prefer_reader_np . +this is ignored by glibc because the posix requirement to support +recursive read locks would cause this option to create trivial +deadlocks; instead use +.b pthread_rwlock_prefer_writer_nonrecursive_np +which ensures the application developer will not take recursive +read locks thus avoiding deadlocks. +.\" --- +.\" here is the relevant wording: +.\" +.\" a thread may hold multiple concurrent read locks on rwlock (that is, +.\" successfully call the pthread_rwlock_rdlock() function n times). if +.\" so, the thread must perform matching unlocks (that is, it must call +.\" the pthread_rwlock_unlock() function n times). +.\" +.\" by making write-priority work correctly, i broke the above requirement, +.\" because i had no clue that recursive read locks are permissible. +.\" +.\" if a thread which holds a read lock tries to acquire another read lock, +.\" and now one or more writers is waiting for a write lock, then the algorithm +.\" will lead to an obvious deadlock. the reader will be suspended, waiting for +.\" the writers to acquire and release the lock, and the writers will be +.\" suspended waiting for every existing read lock to be released. +.\" --- +.\" https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_rwlock_rdlock.html +.\" https://sourceware.org/legacy-ml/libc-alpha/2000-01/msg00055.html +.\" https://sourceware.org/bugzilla/show_bug.cgi?id=7057 +.tp +.b pthread_rwlock_prefer_writer_nonrecursive_np +setting the lock kind to this +avoids writer starvation as long as any read locking is not done in a +recursive fashion. +.pp +the +.br pthread_rwlockattr_getkind_np () +function returns the value of the lock kind attribute of the +read-write lock attribute object referred to by +.ir attr +in the pointer +.ir pref . +.sh return value +on success, these functions return 0. +given valid pointer arguments, +.br pthread_rwlockattr_getkind_np () +always succeeds. +on error, +.br pthread_rwlockattr_setkind_np () +returns a nonzero error number. +.sh errors +.tp +.br einval +.i pref +specifies an unsupported value. +.sh versions +the +.br pthread_rwlockattr_getkind_np () +and +.br pthread_rwlockattr_setkind_np () +functions first appeared in glibc 2.1. +.sh conforming to +these functions are non-standard gnu extensions; +hence the suffix "_np" (nonportable) in the names. +.sh see also +.br pthreads (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/unimplemented.2 + +.\" copyright (c) 2002 andries brouwer +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th tcgetpgrp 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +tcgetpgrp, tcsetpgrp \- get and set terminal foreground process group +.sh synopsis +.nf +.b "#include " +.pp +.bi "pid_t tcgetpgrp(int " fd ); +.bi "int tcsetpgrp(int " fd ", pid_t " pgrp ); +.fi +.sh description +the function +.br tcgetpgrp () +returns the process group id of the foreground process group on the +terminal associated to +.ir fd , +which must be the controlling terminal of the calling process. +.\" the process itself may be a background process. +.pp +the function +.br tcsetpgrp () +makes the process group with process group id +.i pgrp +the foreground process group on the terminal associated to +.ir fd , +which must be the controlling terminal of the calling process, +and still be associated with its session. +moreover, +.i pgrp +must be a (nonempty) process group belonging to +the same session as the calling process. +.pp +if +.br tcsetpgrp () +is called by a member of a background process group in its session, +and the calling process is not blocking or ignoring +.br sigttou , +a +.b sigttou +signal is sent to all members of this background process group. +.sh return value +when +.i fd +refers to the controlling terminal of the calling process, +the function +.br tcgetpgrp () +will return the foreground process group id of that terminal +if there is one, and some value larger than 1 that is not +presently a process group id otherwise. +when +.i fd +does not refer to the controlling terminal of the calling process, +\-1 is returned, and +.i errno +is set to indicate the error. +.pp +when successful, +.br tcsetpgrp () +returns 0. +otherwise, it returns \-1, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b ebadf +.i fd +is not a valid file descriptor. +.tp +.b einval +.i pgrp +has an unsupported value. +.tp +.b enotty +the calling process does not have a controlling terminal, or +it has one but it is not described by +.ir fd , +or, for +.br tcsetpgrp (), +this controlling terminal is no longer associated with the session +of the calling process. +.tp +.b eperm +.i pgrp +has a supported value, but is not the process group id of a +process in the same session as the calling process. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br tcgetpgrp (), +.br tcsetpgrp () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +these functions are implemented via the +.b tiocgpgrp +and +.b tiocspgrp +ioctls. +.ss history +the ioctls appeared in 4.2bsd. +the functions are posix inventions. +.sh see also +.br setpgid (2), +.br setsid (2), +.br credentials (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/mcheck.3 + +.so man3/circleq.3 + +.\" copyright 2002 ionel mugurel ciobîcă (imciobica@netscape.net) +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th iso_8859-16 7 2020-08-13 "linux" "linux programmer's manual" +.sh name +iso_8859-16 \- iso 8859-16 character set encoded in octal, decimal, +and hexadecimal +.sh description +the iso 8859 standard includes several 8-bit extensions to the ascii +character set (also known as iso 646-irv). +iso 8859-16 encodes the +latin characters used in southeast european languages. +.ss iso 8859 alphabets +the full set of iso 8859 alphabets includes: +.ts +l l. +iso 8859-1 west european languages (latin-1) +iso 8859-2 central and east european languages (latin-2) +iso 8859-3 southeast european and miscellaneous languages (latin-3) +iso 8859-4 scandinavian/baltic languages (latin-4) +iso 8859-5 latin/cyrillic +iso 8859-6 latin/arabic +iso 8859-7 latin/greek +iso 8859-8 latin/hebrew +iso 8859-9 latin-1 modification for turkish (latin-5) +iso 8859-10 lappish/nordic/eskimo languages (latin-6) +iso 8859-11 latin/thai +iso 8859-13 baltic rim languages (latin-7) +iso 8859-14 celtic (latin-8) +iso 8859-15 west european languages (latin-9) +iso 8859-16 romanian (latin-10) +.te +.ss iso 8859-16 characters +the following table displays the characters in iso 8859-16 that +are printable and unlisted in the +.br ascii (7) +manual page. +.ts +l l l c lp-1. +oct dec hex char description +_ +240 160 a0   no-break space +241 161 a1 ą latin capital letter a with ogonek +242 162 a2 ą latin small letter a with ogonek +243 163 a3 ł latin capital letter l with stroke +244 164 a4 € euro sign +245 165 a5 „ double low-9 quotation mark +246 166 a6 š latin capital letter s with caron +247 167 a7 § section sign +250 168 a8 š latin small letter s with caron +251 169 a9 © copyright sign +252 170 aa ș latin capital letter s with comma below +253 171 ab « left-pointing double angle quotation mark +254 172 ac ź latin capital letter z with acute +255 173 ad ­ soft hyphen +256 174 ae ź latin small letter z with acute +257 175 af ż latin capital letter z with dot above +260 176 b0 ° degree sign +261 177 b1 ± plus-minus sign +262 178 b2 č latin capital letter c with caron +263 179 b3 ł latin small letter l with stroke +264 180 b4 ž latin capital letter z with caron +265 181 b5 ” left double quotation mark +266 182 b6 ¶ pilcrow sign +267 183 b7 · middle dot +270 184 b8 ž latin small letter z with caron +271 185 b9 č latin small letter c with caron +272 186 ba ș latin small letter s with comma below +273 187 bb » right-pointing double angle quotation mark +274 188 bc œ latin capital ligature oe +275 189 bd œ latin small ligature oe +276 190 be ÿ latin capital letter y with diaeresis +277 191 bf ż latin small letter z with dot above +300 192 c0 à latin capital letter a with grave +301 193 c1 á latin capital letter a with acute +302 194 c2 â latin capital letter a with circumflex +303 195 c3 ă latin capital letter a with breve +304 196 c4 ä latin capital letter a with diaeresis +305 197 c5 ć latin capital letter c with acute +306 198 c6 æ latin capital letter ae +307 199 c7 ç latin capital letter c with cedilla +310 200 c8 è latin capital letter e with grave +311 201 c9 é latin capital letter e with acute +312 202 ca ê latin capital letter e with circumflex +313 203 cb ë latin capital letter e with diaeresis +314 204 cc ì latin capital letter i with grave +315 205 cd í latin capital letter i with acute +316 206 ce î latin capital letter i with circumflex +317 207 cf ï latin capital letter i with diaeresis +320 208 d0 đ latin capital letter d with stroke +321 209 d1 ń latin capital letter n with acute +322 210 d2 ò latin capital letter o with grave +323 211 d3 ó latin capital letter o with acute +324 212 d4 ô latin capital letter o with circumflex +325 213 d5 ő latin capital letter o with double acute +326 214 d6 ö latin capital letter o with diaeresis +327 215 d7 ś latin capital letter s with acute +330 216 d8 ű latin capital letter u with double acute +331 217 d9 ù latin capital letter u with grave +332 218 da ú latin capital letter u with acute +333 219 db û latin capital letter u with circumflex +334 220 dc ü latin capital letter u with diaeresis +335 221 dd ę latin capital letter e with ogonek +336 222 de ț latin capital letter t with comma below +337 223 df ß latin small letter sharp s +340 224 e0 à latin small letter a with grave +341 225 e1 á latin small letter a with acute +342 226 e2 â latin small letter a with circumflex +343 227 e3 ă latin small letter a with breve +344 228 e4 ä latin small letter a with diaeresis +345 229 e5 ć latin small letter c with acute +346 230 e6 æ latin small letter ae +347 231 e7 ç latin small letter c with cedilla +350 232 e8 è latin small letter e with grave +351 233 e9 é latin small letter e with acute +352 234 ea ê latin small letter e with circumflex +353 235 eb ë latin small letter e with diaeresis +354 236 ec ì latin small letter i with grave +355 237 ed í latin small letter i with acute +356 238 ee î latin small letter i with circumflex +357 239 ef ï latin small letter i with diaeresis +360 240 f0 đ latin small letter d with stroke +361 241 f1 ń latin small letter n with acute +362 242 f2 ò latin small letter o with grave +363 243 f3 ó latin small letter o with acute +364 244 f4 ô latin small letter o with circumflex +365 245 f5 ő latin small letter o with double acute +366 246 f6 ö latin small letter o with diaeresis +367 247 f7 ś latin small letter s with acute +370 248 f8 ű latin small letter u with double acute +371 249 f9 ù latin small letter u with grave +372 250 fa ú latin small letter u with acute +373 251 fb û latin small letter u with circumflex +374 252 fc ü latin small letter u with diaeresis +375 253 fd ę latin small letter e with ogonek +376 254 fe ț latin small letter t with comma below +377 255 ff ÿ latin small letter y with diaeresis +.te +.sh notes +iso 8859-16 is also known as latin-10. +.sh see also +.br ascii (7), +.br charsets (7), +.br iso_8859\-3 (7), +.br utf\-8 (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +externally generated pages +========================== + +a few pages come from external sources. fixes to the pages should really +go to the upstream source. + +tzfile(5), zdump(8), and zic(8) come from the tz project +(https://www.iana.org/time-zones). + +bpf-helpers(7) is autogenerated from the kernel sources using scripts. +see man-pages commit 53666f6c30451cde022f65d35a8d448f5a7132ba for +details. + +.\" copyright (c) 2006 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th mq_receive 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +mq_receive, mq_timedreceive \- receive a message from a message queue +.sh synopsis +.nf +.b #include +.pp +.bi "ssize_t mq_receive(mqd_t " mqdes ", char *" msg_ptr , +.bi " size_t " msg_len ", unsigned int *" msg_prio ); +.pp +.b #include +.b #include +.pp +.bi "ssize_t mq_timedreceive(mqd_t " mqdes ", char *restrict " msg_ptr , +.bi " size_t " msg_len ", unsigned int *restrict " msg_prio , +.bi " const struct timespec *restrict " abs_timeout ); +.fi +.pp +link with \fi\-lrt\fp. +.pp +.ad l +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br mq_timedreceive (): +.nf + _posix_c_source >= 200112l +.fi +.sh description +.br mq_receive () +removes the oldest message with the highest priority from +the message queue referred to by the message queue descriptor +.ir mqdes , +and places it in the buffer pointed to by +.ir msg_ptr . +the +.i msg_len +argument specifies the size of the buffer pointed to by +.ir msg_ptr ; +this must be greater than or equal to the +.i mq_msgsize +attribute of the queue (see +.br mq_getattr (3)). +if +.i msg_prio +is not null, then the buffer to which it points is used +to return the priority associated with the received message. +.pp +if the queue is empty, then, by default, +.br mq_receive () +blocks until a message becomes available, +or the call is interrupted by a signal handler. +if the +.b o_nonblock +flag is enabled for the message queue description, +then the call instead fails immediately with the error +.br eagain . +.pp +.br mq_timedreceive () +behaves just like +.br mq_receive (), +except that if the queue is empty and the +.b o_nonblock +flag is not enabled for the message queue description, then +.i abs_timeout +points to a structure which specifies how long the call will block. +this value is an absolute timeout in seconds and nanoseconds +since the epoch, 1970-01-01 00:00:00 +0000 (utc), +specified in the following structure: +.pp +.in +4n +.ex +struct timespec { + time_t tv_sec; /* seconds */ + long tv_nsec; /* nanoseconds */ +}; +.ee +.in +.pp +if no message is available, +and the timeout has already expired by the time of the call, +.br mq_timedreceive () +returns immediately. +.sh return value +on success, +.br mq_receive () +and +.br mq_timedreceive () +return the number of bytes in the received message; +on error, \-1 is returned, with +.i errno +set to indicate the error. +.sh errors +.tp +.b eagain +the queue was empty, and the +.b o_nonblock +flag was set for the message queue description referred to by +.ir mqdes . +.tp +.b ebadf +the descriptor specified in +.i mqdes +was invalid or not opened for reading. +.tp +.b eintr +the call was interrupted by a signal handler; see +.br signal (7). +.tp +.b einval +the call would have blocked, and +.i abs_timeout +was invalid, either because +.i tv_sec +was less than zero, or because +.i tv_nsec +was less than zero or greater than 1000 million. +.tp +.b emsgsize +.i msg_len +was less than the +.i mq_msgsize +attribute of the message queue. +.tp +.b etimedout +the call timed out before a message could be transferred. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br mq_receive (), +.br mq_timedreceive () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +on linux, +.br mq_timedreceive () +is a system call, and +.br mq_receive () +is a library function layered on top of that system call. +.sh see also +.br mq_close (3), +.br mq_getattr (3), +.br mq_notify (3), +.br mq_open (3), +.br mq_send (3), +.br mq_unlink (3), +.br mq_overview (7), +.br time (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/outb.2 + +.so man3/re_comp.3 + +.\" copyright (c) 1983, 1990, 1991 the regents of the university of california. +.\" all rights reserved. +.\" +.\" %%%license_start(bsd_4_clause_ucb) +.\" redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. all advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" this product includes software developed by the university of +.\" california, berkeley and its contributors. +.\" 4. neither the name of the university nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" this software is provided by the regents and contributors ``as is'' and +.\" any express or implied warranties, including, but not limited to, the +.\" implied warranties of merchantability and fitness for a particular purpose +.\" are disclaimed. in no event shall the regents or contributors be liable +.\" for any direct, indirect, incidental, special, exemplary, or consequential +.\" damages (including, but not limited to, procurement of substitute goods +.\" or services; loss of use, data, or profits; or business interruption) +.\" however caused and on any theory of liability, whether in contract, strict +.\" liability, or tort (including negligence or otherwise) arising in any way +.\" out of the use of this software, even if advised of the possibility of +.\" such damage. +.\" %%%license_end +.\" +.\" $id: recv.2,v 1.3 1999/05/13 11:33:38 freitag exp $ +.\" +.\" modified sat jul 24 00:22:20 1993 by rik faith +.\" modified tue oct 22 17:45:19 1996 by eric s. raymond +.\" modified 1998,1999 by andi kleen +.\" 2001-06-19 corrected so_ee_offender, bug report by james hawtin +.\" +.th recv 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +recv, recvfrom, recvmsg \- receive a message from a socket +.sh synopsis +.nf +.b #include +.pp +.bi "ssize_t recv(int " sockfd ", void *" buf ", size_t " len ", int " flags ); +.bi "ssize_t recvfrom(int " sockfd ", void *restrict " buf ", size_t " len \ +", int " flags , +.bi " struct sockaddr *restrict " src_addr , +.bi " socklen_t *restrict " addrlen ); +.bi "ssize_t recvmsg(int " sockfd ", struct msghdr *" msg ", int " flags ); +.fi +.sh description +the +.br recv (), +.br recvfrom (), +and +.br recvmsg () +calls are used to receive messages from a socket. +they may be used +to receive data on both connectionless and connection-oriented sockets. +this page first describes common features of all three system calls, +and then describes the differences between the calls. +.pp +the only difference between +.br recv () +and +.br read (2) +is the presence of +.ir flags . +with a zero +.i flags +argument, +.br recv () +is generally equivalent to +.br read (2) +(but see notes). +also, the following call +.pp + recv(sockfd, buf, len, flags); +.pp +is equivalent to +.pp + recvfrom(sockfd, buf, len, flags, null, null); +.pp +all three calls return the length of the message on successful +completion. +if a message is too long to fit in the supplied buffer, excess +bytes may be discarded depending on the type of socket the message is +received from. +.pp +if no messages are available at the socket, the receive calls wait for a +message to arrive, unless the socket is nonblocking (see +.br fcntl (2)), +in which case the value \-1 is returned and +.i errno +is set to +.br eagain " or " ewouldblock . +the receive calls normally return any data available, up to the requested +amount, rather than waiting for receipt of the full amount requested. +.pp +an application can use +.br select (2), +.br poll (2), +or +.br epoll (7) +to determine when more data arrives on a socket. +.ss the flags argument +the +.i flags +argument is formed by oring one or more of the following values: +.tp +.br msg_cmsg_cloexec " (" recvmsg "() only; since linux 2.6.23)" +set the close-on-exec flag for the file descriptor received +via a unix domain file descriptor using the +.b scm_rights +operation (described in +.br unix (7)). +this flag is useful for the same reasons as the +.b o_cloexec +flag of +.br open (2). +.tp +.br msg_dontwait " (since linux 2.2)" +enables nonblocking operation; if the operation would block, +the call fails with the error +.br eagain " or " ewouldblock . +this provides similar behavior to setting the +.b o_nonblock +flag (via the +.br fcntl (2) +.b f_setfl +operation), but differs in that +.b msg_dontwait +is a per-call option, whereas +.b o_nonblock +is a setting on the open file description (see +.br open (2)), +which will affect all threads in the calling process +and as well as other processes that hold file descriptors +referring to the same open file description. +.tp +.br msg_errqueue " (since linux 2.2)" +this flag +specifies that queued errors should be received from the socket error queue. +the error is passed in +an ancillary message with a type dependent on the protocol (for ipv4 +.br ip_recverr ). +the user should supply a buffer of sufficient size. +see +.br cmsg (3) +and +.br ip (7) +for more information. +the payload of the original packet that caused the error +is passed as normal data via +.ir msg_iovec . +the original destination address of the datagram that caused the error +is supplied via +.ir msg_name . +.ip +the error is supplied in a +.i sock_extended_err +structure: +.ip +.in +4n +.ex +#define so_ee_origin_none 0 +#define so_ee_origin_local 1 +#define so_ee_origin_icmp 2 +#define so_ee_origin_icmp6 3 + +struct sock_extended_err +{ + uint32_t ee_errno; /* error number */ + uint8_t ee_origin; /* where the error originated */ + uint8_t ee_type; /* type */ + uint8_t ee_code; /* code */ + uint8_t ee_pad; /* padding */ + uint32_t ee_info; /* additional information */ + uint32_t ee_data; /* other data */ + /* more data may follow */ +}; + +struct sockaddr *so_ee_offender(struct sock_extended_err *); +.ee +.in +.ip +.i ee_errno +contains the +.i errno +number of the queued error. +.i ee_origin +is the origin code of where the error originated. +the other fields are protocol-specific. +the macro +.b so_ee_offender +returns a pointer to the address of the network object +where the error originated from given a pointer to the ancillary message. +if this address is not known, the +.i sa_family +member of the +.i sockaddr +contains +.b af_unspec +and the other fields of the +.i sockaddr +are undefined. +the payload of the packet that caused the error is passed as normal data. +.ip +for local errors, no address is passed (this +can be checked with the +.i cmsg_len +member of the +.ir cmsghdr ). +for error receives, +the +.b msg_errqueue +flag is set in the +.ir msghdr . +after an error has been passed, the pending socket error +is regenerated based on the next queued error and will be passed +on the next socket operation. +.tp +.b msg_oob +this flag requests receipt of out-of-band data that would not be received +in the normal data stream. +some protocols place expedited data +at the head of the normal data queue, and thus this flag cannot +be used with such protocols. +.tp +.b msg_peek +this flag causes the receive operation to +return data from the beginning of the +receive queue without removing that data from the queue. +thus, a +subsequent receive call will return the same data. +.tp +.br msg_trunc " (since linux 2.2)" +for raw +.rb ( af_packet ), +internet datagram (since linux 2.4.27/2.6.8), +netlink (since linux 2.6.22), and unix datagram +.\" commit 9f6f9af7694ede6314bed281eec74d588ba9474f +(since linux 3.4) sockets: +return the real length of the packet or datagram, +even when it was longer than the passed buffer. +.ip +for use with internet stream sockets, see +.br tcp (7). +.tp +.br msg_waitall " (since linux 2.2)" +this flag requests that the operation block until the full request is +satisfied. +however, the call may still return less data than requested if +a signal is caught, an error or disconnect occurs, or the next data to be +received is of a different type than that returned. +this flag has no effect for datagram sockets. +.\" +.ss recvfrom() +.br recvfrom () +places the received message into the buffer +.ir buf . +the caller must specify the size of the buffer in +.ir len . +.pp +if +.i src_addr +is not null, +and the underlying protocol provides the source address of the message, +that source address is placed in the buffer pointed to by +.ir src_addr . +.\" (note: for datagram sockets in both the unix and internet domains, +.\" .i src_addr +.\" is filled in. +.\" .i src_addr +.\" is also filled in for stream sockets in the unix domain, but is not +.\" filled in for stream sockets in the internet domain.) +.\" [the above notes on af_unix and af_inet sockets apply as at +.\" kernel 2.4.18. (mtk, 22 jul 02)] +in this case, +.i addrlen +is a value-result argument. +before the call, +it should be initialized to the size of the buffer associated with +.ir src_addr . +upon return, +.i addrlen +is updated to contain the actual size of the source address. +the returned address is truncated if the buffer provided is too small; +in this case, +.i addrlen +will return a value greater than was supplied to the call. +.pp +if the caller is not interested in the source address, +.i src_addr +and +.i addrlen +should be specified as null. +.\" +.ss recv() +the +.br recv () +call is normally used only on a +.i connected +socket (see +.br connect (2)). +it is equivalent to the call: +.pp + recvfrom(fd, buf, len, flags, null, 0); +.\" +.ss recvmsg() +the +.br recvmsg () +call uses a +.i msghdr +structure to minimize the number of directly supplied arguments. +this structure is defined as follows in +.ir : +.pp +.in +4n +.ex +struct iovec { /* scatter/gather array items */ + void *iov_base; /* starting address */ + size_t iov_len; /* number of bytes to transfer */ +}; + +struct msghdr { + void *msg_name; /* optional address */ + socklen_t msg_namelen; /* size of address */ + struct iovec *msg_iov; /* scatter/gather array */ + size_t msg_iovlen; /* # elements in msg_iov */ + void *msg_control; /* ancillary data, see below */ + size_t msg_controllen; /* ancillary data buffer len */ + int msg_flags; /* flags on received message */ +}; +.ee +.in +.pp +the +.i msg_name +field points to a caller-allocated buffer that is used to +return the source address if the socket is unconnected. +the caller should set +.i msg_namelen +to the size of this buffer before this call; +upon return from a successful call, +.i msg_namelen +will contain the length of the returned address. +if the application does not need to know the source address, +.i msg_name +can be specified as null. +.pp +the fields +.i msg_iov +and +.i msg_iovlen +describe scatter-gather locations, as discussed in +.br readv (2). +.pp +the field +.ir msg_control , +which has length +.ir msg_controllen , +points to a buffer for other protocol control-related messages or +miscellaneous ancillary data. +when +.br recvmsg () +is called, +.i msg_controllen +should contain the length of the available buffer in +.ir msg_control ; +upon return from a successful call it will contain the length +of the control message sequence. +.pp +the messages are of the form: +.pp +.in +4n +.ex +struct cmsghdr { + size_t cmsg_len; /* data byte count, including header + (type is socklen_t in posix) */ + int cmsg_level; /* originating protocol */ + int cmsg_type; /* protocol\-specific type */ +/* followed by + unsigned char cmsg_data[]; */ +}; +.ee +.in +.pp +ancillary data should be accessed only by the macros defined in +.br cmsg (3). +.pp +as an example, linux uses this ancillary data mechanism to pass extended +errors, ip options, or file descriptors over unix domain sockets. +for further information on the use of ancillary data in various +socket domains, see +.br unix (7) +and +.br ip (7). +.pp +the +.i msg_flags +field in the +.i msghdr +is set on return of +.br recvmsg (). +it can contain several flags: +.tp +.b msg_eor +indicates end-of-record; the data returned completed a record (generally +used with sockets of type +.br sock_seqpacket ). +.tp +.b msg_trunc +indicates that the trailing portion of a datagram was discarded because the +datagram was larger than the buffer supplied. +.tp +.b msg_ctrunc +indicates that some control data was discarded due to lack of space in the +buffer for ancillary data. +.tp +.b msg_oob +is returned to indicate that expedited or out-of-band data was received. +.tp +.b msg_errqueue +indicates that no data was received but an extended error from the socket +error queue. +.sh return value +these calls return the number of bytes received, or \-1 +if an error occurred. +in the event of an error, +.i errno +is set to indicate the error. +.pp +when a stream socket peer has performed an orderly shutdown, +the return value will be 0 (the traditional "end-of-file" return). +.pp +datagram sockets in various domains (e.g., the unix and internet domains) +permit zero-length datagrams. +when such a datagram is received, the return value is 0. +.pp +the value 0 may also be returned if the requested number of bytes +to receive from a stream socket was 0. +.sh errors +these are some standard errors generated by the socket layer. +additional errors +may be generated and returned from the underlying protocol modules; +see their manual pages. +.tp +.br eagain " or " ewouldblock +.\" actually eagain on linux +the socket is marked nonblocking and the receive operation +would block, or a receive timeout had been set and the timeout expired +before data was received. +posix.1 allows either error to be returned for this case, +and does not require these constants to have the same value, +so a portable application should check for both possibilities. +.tp +.b ebadf +the argument +.i sockfd +is an invalid file descriptor. +.tp +.b econnrefused +a remote host refused to allow the network connection (typically +because it is not running the requested service). +.tp +.b efault +the receive buffer pointer(s) point outside the process's +address space. +.tp +.b eintr +the receive was interrupted by delivery of a signal before +any data was available; see +.br signal (7). +.tp +.b einval +invalid argument passed. +.\" e.g., msg_namelen < 0 for recvmsg() or addrlen < 0 for recvfrom() +.tp +.b enomem +could not allocate memory for +.br recvmsg (). +.tp +.b enotconn +the socket is associated with a connection-oriented protocol +and has not been connected (see +.br connect (2) +and +.br accept (2)). +.tp +.b enotsock +the file descriptor +.i sockfd +does not refer to a socket. +.sh conforming to +posix.1-2001, posix.1-2008, +4.4bsd (these interfaces first appeared in 4.2bsd). +.pp +posix.1 describes only the +.br msg_oob , +.br msg_peek , +and +.b msg_waitall +flags. +.sh notes +if a zero-length datagram is pending, +.br read (2) +and +.br recv () +with a +.i flags +argument of zero provide different behavior. +in this circumstance, +.br read (2) +has no effect (the datagram remains pending), while +.br recv () +consumes the pending datagram. +.pp +the +.i socklen_t +type was invented by posix. +see also +.br accept (2). +.pp +according to posix.1, +.\" posix.1-2001, posix.1-2008 +the +.i msg_controllen +field of the +.i msghdr +structure should be typed as +.ir socklen_t , +and the +.i msg_iovlen +field should be typed as +.ir int , +but glibc currently types both as +.ir size_t . +.\" glibc bug for msg_controllen raised 12 mar 2006 +.\" http://sourceware.org/bugzilla/show_bug.cgi?id=2448 +.\" the problem is an underlying kernel issue: the size of the +.\" __kernel_size_t type used to type these fields varies +.\" across architectures, but socklen_t is always 32 bits, +.\" as (at least with gcc) is int. +.pp +see +.br recvmmsg (2) +for information about a linux-specific system call +that can be used to receive multiple datagrams in a single call. +.sh examples +an example of the use of +.br recvfrom () +is shown in +.br getaddrinfo (3). +.sh see also +.br fcntl (2), +.br getsockopt (2), +.br read (2), +.br recvmmsg (2), +.br select (2), +.br shutdown (2), +.br socket (2), +.br cmsg (3), +.br sockatmark (3), +.br ip (7), +.br ipv6 (7), +.br socket (7), +.br tcp (7), +.br udp (7), +.br unix (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1993 michael haardt (michael@moria.de), +.\" fri apr 2 11:32:09 met dst 1993 +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" modified sat jul 24 17:06:52 1993 by rik faith (faith@cs.unc.edu) +.\" modified sun jan 14 00:34:09 1996 by andries brouwer (aeb@cwi.nl) +.th intro 5 2017-03-13 "linux" "linux programmer's manual" +.sh name +intro \- introduction to file formats and filesystems +.sh description +section 5 of the manual describes various file formats, +as well as the corresponding c structures, if any. +.pp +in addition, +this section contains a number of pages that document various filesystems. +.sh notes +.ss authors and copyright conditions +look at the header of the manual page source for the author(s) and copyright +conditions. +note that these can be different from page to page! +.sh see also +.br standards (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/byteorder.3 + +.so man7/system_data_types.7 + +.\" copyright (c) 2001 david gómez +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" based on comments from mm/filemap.c. last modified on 10-06-2001 +.\" modified, 25 feb 2002, michael kerrisk, +.\" added notes on madv_dontneed +.\" 2010-06-19, mtk, added documentation of madv_mergeable and +.\" madv_unmergeable +.\" 2010-06-15, andi kleen, add documentation of madv_hwpoison. +.\" 2010-06-19, andi kleen, add documentation of madv_soft_offline. +.\" 2011-09-18, doug goldstein +.\" document madv_hugepage and madv_nohugepage +.\" +.th madvise 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +madvise \- give advice about use of memory +.sh synopsis +.nf +.b #include +.pp +.bi "int madvise(void *" addr ", size_t " length ", int " advice ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br madvise (): +.nf + since glibc 2.19: + _default_source + up to and including glibc 2.19: + _bsd_source +.fi +.sh description +the +.br madvise () +system call is used to give advice or directions to the kernel +about the address range beginning at address +.i addr +and with size +.i length +bytes +in most cases, +the goal of such advice is to improve system or application performance. +.pp +initially, the system call supported a set of "conventional" +.i advice +values, which are also available on several other implementations. +(note, though, that +.br madvise () +is not specified in posix.) +subsequently, a number of linux-specific +.ir advice +values have been added. +.\" +.\" ====================================================================== +.\" +.ss conventional advice values +the +.i advice +values listed below +allow an application to tell the kernel how it expects to use +some mapped or shared memory areas, so that the kernel can choose +appropriate read-ahead and caching techniques. +these +.i advice +values do not influence the semantics of the application +(except in the case of +.br madv_dontneed ), +but may influence its performance. +all of the +.i advice +values listed here have analogs in the posix-specified +.br posix_madvise (3) +function, and the values have the same meanings, with the exception of +.br madv_dontneed . +.pp +the advice is indicated in the +.i advice +argument, which is one of the following: +.tp +.b madv_normal +no special treatment. +this is the default. +.tp +.b madv_random +expect page references in random order. +(hence, read ahead may be less useful than normally.) +.tp +.b madv_sequential +expect page references in sequential order. +(hence, pages in the given range can be aggressively read ahead, +and may be freed soon after they are accessed.) +.tp +.b madv_willneed +expect access in the near future. +(hence, it might be a good idea to read some pages ahead.) +.tp +.b madv_dontneed +do not expect access in the near future. +(for the time being, the application is finished with the given range, +so the kernel can free resources associated with it.) +.ip +after a successful +.b madv_dontneed +operation, +the semantics of memory access in the specified region are changed: +subsequent accesses of pages in the range will succeed, but will result +in either repopulating the memory contents from the +up-to-date contents of the underlying mapped file +(for shared file mappings, shared anonymous mappings, +and shmem-based techniques such as system v shared memory segments) +or zero-fill-on-demand pages for anonymous private mappings. +.ip +note that, when applied to shared mappings, +.br madv_dontneed +might not lead to immediate freeing of the pages in the range. +the kernel is free to delay freeing the pages until an appropriate moment. +the resident set size (rss) of the calling process will be immediately +reduced however. +.ip +.b madv_dontneed +cannot be applied to locked pages, huge tlb pages, or +.br vm_pfnmap +pages. +(pages marked with the kernel-internal +.b vm_pfnmap +.\" http://lwn.net/articles/162860/ +flag are special memory areas that are not managed +by the virtual memory subsystem. +such pages are typically created by device drivers that +map the pages into user space.) +.\" +.\" ====================================================================== +.\" +.ss linux-specific advice values +the following linux-specific +.i advice +values have no counterparts in the posix-specified +.br posix_madvise (3), +and may or may not have counterparts in the +.br madvise () +interface available on other implementations. +note that some of these operations change the semantics of memory accesses. +.tp +.br madv_remove " (since linux 2.6.16)" +.\" commit f6b3ec238d12c8cc6cc71490c6e3127988460349 +free up a given range of pages +and its associated backing store. +this is equivalent to punching a hole in the corresponding byte +range of the backing store (see +.br fallocate (2)). +subsequent accesses in the specified address range will see +bytes containing zero. +.\" databases want to use this feature to drop a section of their +.\" bufferpool (shared memory segments) - without writing back to +.\" disk/swap space. this feature is also useful for supporting +.\" hot-plug memory on uml. +.ip +the specified address range must be mapped shared and writable. +this flag cannot be applied to locked pages, huge tlb pages, or +.br vm_pfnmap +pages. +.ip +in the initial implementation, only +.br tmpfs (5) +was supported +.br madv_remove ; +but since linux 3.5, +.\" commit 3f31d07571eeea18a7d34db9af21d2285b807a17 +any filesystem which supports the +.br fallocate (2) +.br falloc_fl_punch_hole +mode also supports +.br madv_remove . +hugetlbfs fails with the error +.br einval +and other filesystems fail with the error +.br eopnotsupp . +.tp +.br madv_dontfork " (since linux 2.6.16)" +.\" commit f822566165dd46ff5de9bf895cfa6c51f53bb0c4 +.\" see http://lwn.net/articles/171941/ +do not make the pages in this range available to the child after a +.br fork (2). +this is useful to prevent copy-on-write semantics from changing +the physical location of a page if the parent writes to it after a +.br fork (2). +(such page relocations cause problems for hardware that +dmas into the page.) +.\" [patch] madvise madv_dontfork/madv_dofork +.\" currently, copy-on-write may change the physical address of +.\" a page even if the user requested that the page is pinned in +.\" memory (either by mlock or by get_user_pages). this happens +.\" if the process forks meanwhile, and the parent writes to that +.\" page. as a result, the page is orphaned: in case of +.\" get_user_pages, the application will never see any data hardware +.\" dma's into this page after the cow. in case of mlock'd memory, +.\" the parent is not getting the realtime/security benefits of mlock. +.\" +.\" in particular, this affects the infiniband modules which do dma from +.\" and into user pages all the time. +.\" +.\" this patch adds madvise options to control whether memory range is +.\" inherited across fork. useful e.g. for when hardware is doing dma +.\" from/into these pages. could also be useful to an application +.\" wanting to speed up its forks by cutting large areas out of +.\" consideration. +.\" +.\" see also: http://lwn.net/articles/171941/ +.\" "tweaks to madvise() and posix_fadvise()", 14 feb 2006 +.tp +.br madv_dofork " (since linux 2.6.16)" +undo the effect of +.br madv_dontfork , +restoring the default behavior, whereby a mapping is inherited across +.br fork (2). +.tp +.br madv_hwpoison " (since linux 2.6.32)" +.\" commit 9893e49d64a4874ea67849ee2cfbf3f3d6817573 +poison the pages in the range specified by +.i addr +and +.ir length +and handle subsequent references to those pages +like a hardware memory corruption. +this operation is available only for privileged +.rb ( cap_sys_admin ) +processes. +this operation may result in the calling process receiving a +.b sigbus +and the page being unmapped. +.ip +this feature is intended for testing of memory error-handling code; +it is available only if the kernel was configured with +.br config_memory_failure . +.tp +.br madv_mergeable " (since linux 2.6.32)" +.\" commit f8af4da3b4c14e7267c4ffb952079af3912c51c5 +enable kernel samepage merging (ksm) for the pages in the range specified by +.i addr +and +.ir length . +the kernel regularly scans those areas of user memory that have +been marked as mergeable, +looking for pages with identical content. +these are replaced by a single write-protected page (which is automatically +copied if a process later wants to update the content of the page). +ksm merges only private anonymous pages (see +.br mmap (2)). +.ip +the ksm feature is intended for applications that generate many +instances of the same data (e.g., virtualization systems such as kvm). +it can consume a lot of processing power; use with care. +see the linux kernel source file +.i documentation/admin\-guide/mm/ksm.rst +for more details. +.ip +the +.br madv_mergeable +and +.br madv_unmergeable +operations are available only if the kernel was configured with +.br config_ksm . +.tp +.br madv_unmergeable " (since linux 2.6.32)" +undo the effect of an earlier +.br madv_mergeable +operation on the specified address range; +ksm unmerges whatever pages it had merged in the address range specified by +.ir addr +and +.ir length . +.tp +.br madv_soft_offline " (since linux 2.6.33)" +.\" commit afcf938ee0aac4ef95b1a23bac704c6fbeb26de6 +soft offline the pages in the range specified by +.i addr +and +.ir length . +the memory of each page in the specified range is preserved +(i.e., when next accessed, the same content will be visible, +but in a new physical page frame), +and the original page is offlined +(i.e., no longer used, and taken out of normal memory management). +the effect of the +.b madv_soft_offline +operation is invisible to (i.e., does not change the semantics of) +the calling process. +.ip +this feature is intended for testing of memory error-handling code; +it is available only if the kernel was configured with +.br config_memory_failure . +.tp +.br madv_hugepage " (since linux 2.6.38)" +.\" commit 0af4e98b6b095c74588af04872f83d333c958c32 +.\" http://lwn.net/articles/358904/ +.\" https://lwn.net/articles/423584/ +enable transparent huge pages (thp) for pages in the range specified by +.i addr +and +.ir length . +currently, transparent huge pages work only with private anonymous pages (see +.br mmap (2)). +the kernel will regularly scan the areas marked as huge page candidates +to replace them with huge pages. +the kernel will also allocate huge pages directly when the region is +naturally aligned to the huge page size (see +.br posix_memalign (2)). +.ip +this feature is primarily aimed at applications that use large mappings of +data and access large regions of that memory at a time (e.g., virtualization +systems such as qemu). +it can very easily waste memory (e.g., a 2\ mb mapping that only ever accesses +1 byte will result in 2\ mb of wired memory instead of one 4\ kb page). +see the linux kernel source file +.i documentation/admin\-guide/mm/transhuge.rst +for more details. +.ip +most common kernels configurations provide +.br madv_hugepage -style +behavior by default, and thus +.br madv_hugepage +is normally not necessary. +it is mostly intended for embedded systems, where +.br madv_hugepage -style +behavior may not be enabled by default in the kernel. +on such systems, +this flag can be used in order to selectively enable thp. +whenever +.br madv_hugepage +is used, it should always be in regions of memory with +an access pattern that the developer knows in advance won't risk +to increase the memory footprint of the application when transparent +hugepages are enabled. +.ip +the +.br madv_hugepage +and +.br madv_nohugepage +operations are available only if the kernel was configured with +.br config_transparent_hugepage . +.tp +.br madv_nohugepage " (since linux 2.6.38)" +ensures that memory in the address range specified by +.ir addr +and +.ir length +will not be backed by transparent hugepages. +.tp +.br madv_dontdump " (since linux 3.4)" +.\" commit 909af768e88867016f427264ae39d27a57b6a8ed +.\" commit accb61fe7bb0f5c2a4102239e4981650f9048519 +exclude from a core dump those pages in the range specified by +.i addr +and +.ir length . +this is useful in applications that have large areas of memory +that are known not to be useful in a core dump. +the effect of +.br madv_dontdump +takes precedence over the bit mask that is set via the +.i /proc/[pid]/coredump_filter +file (see +.br core (5)). +.tp +.br madv_dodump " (since linux 3.4)" +undo the effect of an earlier +.br madv_dontdump . +.tp +.br madv_free " (since linux 4.5)" +the application no longer requires the pages in the range specified by +.ir addr +and +.ir len . +the kernel can thus free these pages, +but the freeing could be delayed until memory pressure occurs. +for each of the pages that has been marked to be freed +but has not yet been freed, +the free operation will be canceled if the caller writes into the page. +after a successful +.b madv_free +operation, any stale data (i.e., dirty, unwritten pages) will be lost +when the kernel frees the pages. +however, subsequent writes to pages in the range will succeed +and then kernel cannot free those dirtied pages, +so that the caller can always see just written data. +if there is no subsequent write, +the kernel can free the pages at any time. +once pages in the range have been freed, the caller will +see zero-fill-on-demand pages upon subsequent page references. +.ip +the +.b madv_free +operation +can be applied only to private anonymous pages (see +.br mmap (2)). +in linux before version 4.12, +.\" commit 93e06c7a645343d222c9a838834a51042eebbbf7 +when freeing pages on a swapless system, +the pages in the given range are freed instantly, +regardless of memory pressure. +.tp +.br madv_wipeonfork " (since linux 4.14)" +.\" commit d2cd9ede6e193dd7d88b6d27399e96229a551b19 +present the child process with zero-filled memory in this range after a +.br fork (2). +this is useful in forking servers in order to ensure +that sensitive per-process data +(for example, prng seeds, cryptographic secrets, and so on) +is not handed to child processes. +.ip +the +.b madv_wipeonfork +operation can be applied only to private anonymous pages (see +.br mmap (2)). +.ip +within the child created by +.br fork (2), +the +.b madv_wipeonfork +setting remains in place on the specified address range. +this setting is cleared during +.br execve (2). +.tp +.br madv_keeponfork " (since linux 4.14)" +.\" commit d2cd9ede6e193dd7d88b6d27399e96229a551b19 +undo the effect of an earlier +.br madv_wipeonfork . +.tp +.br madv_cold " (since linux 5.4)" +.\" commit 9c276cc65a58faf98be8e56962745ec99ab87636 +deactivate a given range of pages. +this will make the pages a more probable +reclaim target should there be a memory pressure. +this is a nondestructive operation. +the advice might be ignored for some pages in the range when it is not +applicable. +.tp +.br madv_pageout " (since linux 5.4)" +.\" commit 1a4e58cce84ee88129d5d49c064bd2852b481357 +reclaim a given range of pages. +this is done to free up memory occupied by these pages. +if a page is anonymous, it will be swapped out. +if a page is file-backed and dirty, it will be written back to the backing +storage. +the advice might be ignored for some pages in the range when it is not +applicable. +.sh return value +on success, +.br madvise () +returns zero. +on error, it returns \-1 and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eacces +.i advice +is +.br madv_remove , +but the specified address range is not a shared writable mapping. +.tp +.b eagain +a kernel resource was temporarily unavailable. +.tp +.b ebadf +the map exists, but the area maps something that isn't a file. +.tp +.b einval +.i addr +is not page-aligned or +.i length +is negative. +.\" .i length +.\" is zero, +.tp +.b einval +.i advice +is not a valid. +.tp +.b einval +.i advice +is +.b madv_dontneed +or +.br madv_remove +and the specified address range includes locked, huge tlb pages, or +.b vm_pfnmap +pages. +.tp +.b einval +.i advice +is +.br madv_mergeable +or +.br madv_unmergeable , +but the kernel was not configured with +.br config_ksm . +.tp +.b einval +.i advice +is +.br madv_free +or +.br madv_wipeonfork +but the specified address range includes file, huge tlb, +.br map_shared , +or +.br vm_pfnmap +ranges. +.tp +.b eio +(for +.br madv_willneed ) +paging in this area would exceed the process's +maximum resident set size. +.tp +.b enomem +(for +.br madv_willneed ) +not enough memory: paging in failed. +.tp +.b enomem +addresses in the specified range are not currently +mapped, or are outside the address space of the process. +.tp +.b eperm +.i advice +is +.br madv_hwpoison , +but the caller does not have the +.b cap_sys_admin +capability. +.sh versions +since linux 3.18, +.\" commit d3ac21cacc24790eb45d735769f35753f5b56ceb +support for this system call is optional, +depending on the setting of the +.b config_advise_syscalls +configuration option. +.sh conforming to +.br madvise () +is not specified by any standards. +versions of this system call, implementing a wide variety of +.i advice +values, exist on many other implementations. +other implementations typically implement at least the flags listed +above under +.ir "conventional advice flags" , +albeit with some variation in semantics. +.pp +posix.1-2001 describes +.br posix_madvise (3) +with constants +.br posix_madv_normal , +.br posix_madv_random , +.br posix_madv_sequential , +.br posix_madv_willneed , +and +.br posix_madv_dontneed , +and so on, with behavior close to the similarly named flags listed above. +.sh notes +.ss linux notes +the linux implementation requires that the address +.i addr +be page-aligned, and allows +.i length +to be zero. +if there are some parts of the specified address range +that are not mapped, the linux version of +.br madvise () +ignores them and applies the call to the rest (but returns +.b enomem +from the system call, as it should). +.\" .sh history +.\" the +.\" .br madvise () +.\" function first appeared in 4.4bsd. +.sh see also +.br getrlimit (2), +.br mincore (2), +.br mmap (2), +.br mprotect (2), +.br msync (2), +.br munmap (2), +.br prctl (2), +.br process_madvise (2), +.br posix_madvise (3), +.br core (5) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/isalpha.3 + +.\" copyright (c) 2020 by michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" +.th time_namespaces 7 2021-03-22 "linux" "linux programmer's manual" +.sh name +time_namespaces \- overview of linux time namespaces +.sh description +time namespaces virtualize the values of two system clocks: +.ip \(bu 2 +.br clock_monotonic +(and likewise +.br clock_monotonic_coarse +and +.br clock_monotonic_raw ), +a nonsettable clock that represents monotonic time since\(emas +described by posix\(em"some unspecified point in the past". +.ip \(bu +.br clock_boottime +(and likewise +.br clock_boottime_alarm ), +a nonsettable clock that is identical to +.br clock_monotonic , +except that it also includes any time that the system is suspended. +.pp +thus, the processes in a time namespace share per-namespace values +for these clocks. +this affects various apis that measure against these clocks, including: +.br clock_gettime (2), +.br clock_nanosleep (2), +.br nanosleep (2), +.br timer_settime (2), +.br timerfd_settime (2), +and +.ir /proc/uptime . +.pp +currently, the only way to create a time namespace is by calling +.br unshare (2) +with the +.br clone_newtime +flag. +this call creates a new time namespace but does +.i not +place the calling process in the new namespace. +instead, the calling process's +subsequently created children are placed in the new namespace. +this allows clock offsets (see below) for the new namespace +to be set before the first process is placed in the namespace. +the +.ir /proc/[pid]/ns/time_for_children +symbolic link shows the time namespace in which +the children of a process will be created. +(a process can use a file descriptor opened on +this symbolic link in a call to +.br setns (2) +in order to move into the namespace.) +.\" +.ss /proc/pid/timens_offsets +associated with each time namespace are offsets, +expressed with respect to the initial time namespace, +that define the values of the monotonic and +boot-time clocks in that namespace. +these offsets are exposed via the file +.ir /proc/pid/timens_offsets . +within this file, +the offsets are expressed as lines consisting of +three space-delimited fields: +.pp +.in +4n +.ex + +.ee +.in +.pp +the +.i clock-id +is a string that identifies the clock whose offsets are being shown. +this field is either +.ir monotonic , +for +.br clock_monotonic , +or +.ir boottime , +for +.br clock_boottime . +the remaining fields express the offset (seconds plus nanoseconds) for the +clock in this time namespace. +these offsets are expressed relative to the clock values in +the initial time namespace. +the +.i offset-secs +value can be negative, subject to restrictions noted below; +.i offset-nanosecs +is an unsigned value. +.pp +in the initial time namespace, the contents of the +.i timens_offsets +file are as follows: +.pp +.in +4n +.ex +$ \fbcat /proc/self/timens_offsets\fp +monotonic 0 0 +boottime 0 0 +.ee +.in +.pp +in a new time namespace that has had no member processes, +the clock offsets can be modified by writing newline-terminated +records of the same form to the +.i timens_offsets +file. +the file can be written to multiple times, +but after the first process has been created in or has entered the namespace, +.br write (2)s +on this file fail with the error +.br eacces . +in order to write to the +.ir timens_offsets +file, a process must have the +.br cap_sys_time +capability in the user namespace that owns the time namespace. +.pp +writes to the +.i timens_offsets +file can fail with the following errors: +.tp +.b einval +an +.i offset-nanosecs +value is greater than 999,999,999. +.tp +.b einval +a +.i clock-id +value is not valid. +.tp +.b eperm +the caller does not have the +.br cap_sys_time +capability. +.tp +.b erange +an +.i offset-secs +value is out of range. +in particular; +.rs +.ip \(bu 2 +.i offset-secs +can't be set to a value which would make the current +time on the corresponding clock inside the namespace a negative value; and +.ip \(bu +.i offset-secs +can't be set to a value such that the time on the corresponding clock +inside the namespace would exceed half of the value of the kernel constant +.br ktime_sec_max +(this limits the clock value to a maximum of approximately 146 years). +.re +.pp +in a new time namespace created by +.br unshare (2), +the contents of the +.i timens_offsets +file are inherited from the time namespace of the creating process. +.sh notes +use of time namespaces requires a kernel that is configured with the +.b config_time_ns +option. +.pp +note that time namespaces do not virtualize the +.br clock_realtime +clock. +virtualization of this clock was avoided for reasons of complexity +and overhead within the kernel. +.pp +for compatibility with the initial implementation, when writing a +.i clock-id +to the +.ir /proc/[pid]/timens_offsets +file, the numerical values of the ids can be written +instead of the symbolic names show above; i.e., 1 instead of +.ir monotonic , +and 7 instead of +.ir boottime . +for readability, the use of the symbolic names over the numbers is preferred. +.pp +the motivation for adding time namespaces was to allow +the monotonic and boot-time clocks to maintain consistent values +during container migration and checkpoint/restore. +.sh examples +the following shell session demonstrates the operation of time namespaces. +we begin by displaying the inode number of the time namespace +of a shell in the initial time namespace: +.pp +.in +4n +.ex +$ \fbreadlink /proc/$$/ns/time\fp +time:[4026531834] +.ee +.in +.pp +continuing in the initial time namespace, we display the system uptime using +.br uptime (1) +and use the +.i clock_times +example program shown in +.br clock_getres (2) +to display the values of various clocks: +.pp +.in +4n +.ex +$ \fbuptime \-\-pretty\fp +up 21 hours, 17 minutes +$ \fb./clock_times\fp +clock_realtime : 1585989401.971 (18356 days + 8h 36m 41s) +clock_tai : 1585989438.972 (18356 days + 8h 37m 18s) +clock_monotonic: 56338.247 (15h 38m 58s) +clock_boottime : 76633.544 (21h 17m 13s) +.ee +.in +.pp +we then use +.br unshare (1) +to create a time namespace and execute a +.br bash (1) +shell. +from the new shell, we use the built-in +.b echo +command to write records to the +.i timens_offsets +file adjusting the offset for the +.b clock_monotonic +clock forward 2 days +and the offset for the +.b clock_boottime +clock forward 7 days: +.pp +.in +4n +.ex +$ \fbps1="ns2# " sudo unshare \-t \-\- bash \-\-norc\fp +ns2# \fbecho "monotonic $((2*24*60*60)) 0" > /proc/$$/timens_offsets\fp +ns2# \fbecho "boottime $((7*24*60*60)) 0" > /proc/$$/timens_offsets\fp +.ee +.in +.pp +above, we started the +.br bash (1) +shell with the +.b \-\-norc +options so that no start-up scripts were executed. +this ensures that no child processes are created from the +shell before we have a chance to update the +.i timens_offsets +file. +.pp +we then use +.br cat (1) +to display the contents of the +.i timens_offsets +file. +the execution of +.br cat (1) +creates the first process in the new time namespace, +after which further attempts to update the +.i timens_offsets +file produce an error. +.pp +.in +4n +.ex +ns2# \fbcat /proc/$$/timens_offsets\fp +monotonic 172800 0 +boottime 604800 0 +ns2# \fbecho "boottime $((9*24*60*60)) 0" > /proc/$$/timens_offsets\fp +bash: echo: write error: permission denied +.ee +.in +.pp +continuing in the new namespace, we execute +.br uptime (1) +and the +.i clock_times +example program: +.pp +.in +4n +.ex +ns2# \fbuptime \-\-pretty\fp +up 1 week, 21 hours, 18 minutes +ns2# \fb./clock_times\fp +clock_realtime : 1585989457.056 (18356 days + 8h 37m 37s) +clock_tai : 1585989494.057 (18356 days + 8h 38m 14s) +clock_monotonic: 229193.332 (2 days + 15h 39m 53s) +clock_boottime : 681488.629 (7 days + 21h 18m 8s) +.ee +.in +.pp +from the above output, we can see that the monotonic +and boot-time clocks have different values in the new time namespace. +.pp +examining the +.i /proc/[pid]/ns/time +and +.i /proc/[pid]/ns/time_for_children +symbolic links, we see that the shell is a member of the initial time +namespace, but its children are created in the new namespace. +.pp +.in +4n +.ex +ns2# \fbreadlink /proc/$$/ns/time\fp +time:[4026531834] +ns2# \fbreadlink /proc/$$/ns/time_for_children\fp +time:[4026532900] +ns2# \fbreadlink /proc/self/ns/time\fp # creates a child process +time:[4026532900] +.ee +.in +.pp +returning to the shell in the initial time namespace, +we see that the monotonic and boot-time clocks +are unaffected by the +.i timens_offsets +changes that were made in the other time namespace: +.pp +.in +4n +.ex +$ \fbuptime \-\-pretty\fp +up 21 hours, 19 minutes +$ \fb./clock_times\fp +clock_realtime : 1585989401.971 (18356 days + 8h 38m 51s) +clock_tai : 1585989438.972 (18356 days + 8h 39m 28s) +clock_monotonic: 56338.247 (15h 41m 8s) +clock_boottime : 76633.544 (21h 19m 23s) +.ee +.in +.sh see also +.br nsenter (1), +.br unshare (1), +.br clock_settime (2), +.\" clone3() support for time namespaces is a work in progress +.\" .br clone3 (2), +.br setns (2), +.br unshare (2), +.br namespaces (7), +.br time (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1993 michael haardt (michael@moria.de), +.\" fri apr 2 11:32:09 met dst 1993 +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" modified sun jul 25 11:06:27 1993 by rik faith (faith@cs.unc.edu) +.th securetty 5 2020-06-09 "linux" "linux programmer's manual" +.sh name +securetty \- list of terminals on which root is allowed to login +.sh description +the file +.i /etc/securetty +contains the names of terminals +(one per line, without leading +.ir /dev/ ) +which are considered secure for the transmission of certain authentication +tokens. +.pp +it is used by (some versions of) +.br login (1) +to restrict the terminals +on which root is allowed to login. +see +.br login.defs (5) +if you use the shadow suite. +.pp +on pam enabled systems, it is used for the same purpose by +.br pam_securetty (8) +to restrict the terminals on which empty passwords are accepted. +.sh files +.i /etc/securetty +.sh see also +.br login (1), +.br login.defs (5), +.br pam_securetty (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1993 michael haardt (michael@moria.de), +.\" fri apr 2 11:32:09 met dst 1993 +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" modified sun jul 25 10:46:28 1993 by rik faith (faith@cs.unc.edu) +.\" modified sun aug 21 18:12:27 1994 by rik faith (faith@cs.unc.edu) +.\" modified sun jun 18 01:53:57 1995 by andries brouwer (aeb@cwi.nl) +.\" modified mon jan 5 20:24:40 met 1998 by michael haardt +.\" (michael@cantor.informatik.rwth-aachen.de) +.th passwd 5 2018-04-30 "linux" "linux programmer's manual" +.sh name +passwd \- password file +.sh description +the +.ir /etc/passwd +file is a text file that describes user login accounts for the system. +it should have read permission allowed for all users (many utilities, like +.br ls (1) +use it to map user ids to usernames), but write access only for the +superuser. +.pp +in the good old days there was no great problem with this general +read permission. +everybody could read the encrypted passwords, but the +hardware was too slow to crack a well-chosen password, and moreover the +basic assumption used to be that of a friendly user-community. +these days many people run some version of the shadow password suite, where +.i /etc/passwd +has an \(aqx\(aq character in the password field, +and the encrypted passwords are in +.ir /etc/shadow , +which is readable by the superuser only. +.pp +if the encrypted password, whether in +.i /etc/passwd +or in +.ir /etc/shadow , +is an empty string, login is allowed without even asking for a password. +note that this functionality may be intentionally disabled in applications, +or configurable (for example using the "nullok" or "nonull" arguments to +pam_unix.so). +.pp +if the encrypted password in +.i /etc/passwd +is "\fi*np*\fp" (without the quotes), +the shadow record should be obtained from an nis+ server. +.pp +regardless of whether shadow passwords are used, many system administrators +use an asterisk (*) in the encrypted password field to make sure +that this user can not authenticate themself using a +password. +(but see notes below.) +.pp +if you create a new login, first put an asterisk (*) in the password field, +then use +.br passwd (1) +to set it. +.pp +each line of the file describes a single user, +and contains seven colon-separated fields: +.pp +.in +4n +.ex +name:password:uid:gid:gecos:directory:shell +.ee +.in +.pp +the field are as follows: +.tp 12 +.i name +this is the user's login name. +it should not contain capital letters. +.tp +.i password +this is either the encrypted user password, +an asterisk (*), or the letter \(aqx\(aq. +(see +.br pwconv (8) +for an explanation of \(aqx\(aq.) +.tp +.i uid +the privileged +.i root +login account (superuser) has the user id 0. +.tp +.i gid +this is the numeric primary group id for this user. +(additional groups for the user are defined in the system group file; see +.br group (5)). +.tp +.i gecos +this field (sometimes called the "comment field") +is optional and used only for informational purposes. +usually, it contains the full username. +some programs (for example, +.br finger (1)) +display information from this field. +.ip +gecos stands for "general electric comprehensive operating system", +which was renamed to gcos when +ge's large systems division was sold to honeywell. +dennis ritchie has reported: "sometimes we sent printer output or +batch jobs to the gcos machine. +the gcos field in the password file was a place to stash the +information for the $identcard. +not elegant." +.tp +.i directory +this is the user's home directory: +the initial directory where the user is placed after logging in. +the value in this field is used to set the +.b home +environment variable. +.tp +.i shell +this is the program to run at login (if empty, use +.ir /bin/sh ). +if set to a nonexistent executable, the user will be unable to login +through +.br login (1). +the value in this field is used to set the +.b shell +environment variable. +.sh files +.i /etc/passwd +.sh notes +if you want to create user groups, there must be an entry in +.ir /etc/group , +or no group will exist. +.pp +if the encrypted password is set to an asterisk (*), the user will be unable +to login using +.br login (1), +but may still login using +.br rlogin (1), +run existing processes and initiate new ones through +.br rsh (1), +.br cron (8), +.br at (1), +or mail filters, etc. +trying to lock an account by simply changing the +shell field yields the same result and additionally allows the use of +.br su (1). +.sh see also +.br chfn (1), +.br chsh (1), +.br login (1), +.br passwd (1), +.br su (1), +.br crypt (3), +.br getpwent (3), +.br getpwnam (3), +.br group (5), +.br shadow (5), +.br vipw (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/circleq.3 + +.\" copyright (c) 1995 michael chastain (mec@shell.portal.com), 15 april 1995. +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" modified 1997-01-31 by eric s. raymond +.\" modified 2004-06-17 by michael kerrisk +.\" +.th bdflush 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +bdflush \- start, flush, or tune buffer-dirty-flush daemon +.sh synopsis +.nf +.b #include +.pp +.bi "int bdflush(int " func ", long *" address ); +.bi "int bdflush(int " func ", long " data ); +.fi +.pp +.ir note : +there is no glibc wrapper for this system call; see versions. +.sh description +.ir note : +since linux 2.6, +.\" as noted in changes in the 2.5.12 source +this system call is deprecated and does nothing. +it is likely to disappear altogether in a future kernel release. +nowadays, the task performed by +.br bdflush () +is handled by the kernel +.i pdflush +thread. +.pp +.br bdflush () +starts, flushes, or tunes the buffer-dirty-flush daemon. +only a privileged process (one with the +.b cap_sys_admin +capability) may call +.br bdflush (). +.pp +if +.i func +is negative or 0, and no daemon has been started, then +.br bdflush () +enters the daemon code and never returns. +.pp +if +.i func +is 1, +some dirty buffers are written to disk. +.pp +if +.i func +is 2 or more and is even (low bit is 0), then +.i address +is the address of a long word, +and the tuning parameter numbered +.ri "(" "func" "\-2)/2" +is returned to the caller in that address. +.pp +if +.i func +is 3 or more and is odd (low bit is 1), then +.i data +is a long word, +and the kernel sets tuning parameter numbered +.ri "(" "func" "\-3)/2" +to that value. +.pp +the set of parameters, their values, and their valid ranges +are defined in the linux kernel source file +.ir fs/buffer.c . +.sh return value +if +.i func +is negative or 0 and the daemon successfully starts, +.br bdflush () +never returns. +otherwise, the return value is 0 on success and \-1 on failure, with +.i errno +set to indicate the error. +.sh errors +.tp +.b ebusy +an attempt was made to enter the daemon code after +another process has already entered. +.tp +.b efault +.i address +points outside your accessible address space. +.tp +.b einval +an attempt was made to read or write an invalid parameter number, +or to write an invalid value to a parameter. +.tp +.b eperm +caller does not have the +.b cap_sys_admin +capability. +.sh versions +since version 2.23, glibc no longer supports this obsolete system call. +.sh conforming to +.br bdflush () +is linux-specific and should not be used in programs +intended to be portable. +.sh see also +.br sync (1), +.br fsync (2), +.br sync (2) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1995 jim van zandt +.\" and copyright 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified 2002-07-27 by walter harms +.\" (walter.harms@informatik.uni-oldenburg.de) +.th log1p 3 2021-03-22 "" "linux programmer's manual" +.sh name +log1p, log1pf, log1pl \- logarithm of 1 plus argument +.sh synopsis +.nf +.b #include +.pp +.bi "double log1p(double " x ); +.bi "float log1pf(float " x ); +.bi "long double log1pl(long double " x ); +.pp +.fi +link with \fi\-lm\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.nf +.br log1p (): + _isoc99_source || _posix_c_source >= 200112l + || _xopen_source >= 500 +.\" || _xopen_source && _xopen_source_extended + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.pp +.br log1pf (), +.br log1pl (): +.nf + _isoc99_source || _posix_c_source >= 200112l + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.sh description +these functions return a value equivalent to +.pp +.nf + log (1 + \fix\fp) +.fi +.pp +the result is computed in a way +that is accurate even if the value of +.i x +is near zero. +.sh return value +on success, these functions return the natural logarithm of +.ir "(1\ +\ x)" . +.pp +if +.i x +is a nan, +a nan is returned. +.pp +if +.i x +is positive infinity, positive infinity is returned. +.pp +if +.i x +is \-1, a pole error occurs, +and the functions return +.rb \- huge_val , +.rb \- huge_valf , +or +.rb \- huge_vall , +respectively. +.pp +if +.i x +is less than \-1 (including negative infinity), +a domain error occurs, +and a nan (not a number) is returned. +.\" posix.1 specifies a possible range error if x is subnormal +.\" glibc 2.8 doesn't do this +.sh errors +see +.br math_error (7) +for information on how to determine whether an error has occurred +when calling these functions. +.pp +the following errors can occur: +.tp +domain error: \fix\fp is less than \-1 +.i errno +is set to +.br edom +(but see bugs). +an invalid floating-point exception +.rb ( fe_invalid ) +is raised. +.tp +pole error: \fix\fp is \-1 +.i errno +is set to +.br erange +(but see bugs). +a divide-by-zero floating-point exception +.rb ( fe_divbyzero ) +is raised. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br log1p (), +.br log1pf (), +.br log1pl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.\" bsd +.sh bugs +before version 2.22, the glibc implementation did not set +.\" https://www.sourceware.org/bugzilla/show_bug.cgi?id=6792 +.i errno +to +.b edom +when a domain error occurred. +.pp +before version 2.22, the glibc implementation did not set +.\" https://www.sourceware.org/bugzilla/show_bug.cgi?id=6792 +.i errno +to +.b erange +when a range error occurred. +.sh see also +.br exp (3), +.br expm1 (3), +.br log (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man7/iso_8859-15.7 + +.\" copyright (c) 2006 red hat, inc. all rights reserved. +.\" author: ulrich drepper +.\" +.\" %%%license_start(gplv2_misc) +.\" this copyrighted material is made available to anyone wishing to use, +.\" modify, copy, or redistribute it subject to the terms and conditions of the +.\" gnu general public license v.2. +.\" +.\" this program 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 general public license for +.\" more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th gai.conf 5 2020-06-09 "linux" "linux programmer's manual" +.sh name +gai.conf \- getaddrinfo(3) configuration file +.sh description +a call to +.br getaddrinfo (3) +might return multiple answers. +according to rfc\ 3484 these answers must be sorted so that +the answer with the highest success rate is first in the list. +the rfc provides an algorithm for the sorting. +the static rules are not always adequate, though. +for this reason, +the rfc also requires that system administrators should have the possibility +to dynamically change the sorting. +for the glibc implementation, this can be achieved with the +.i /etc/gai.conf +file. +.pp +each line in the configuration file consists of a keyword and its parameters. +white spaces in any place are ignored. +lines starting with \(aq#\(aq are comments and are ignored. +.pp +the keywords currently recognized are: +.tp +\fblabel\fr \finetmask\fr \fiprecedence\fr +the value is added to the label table used in the rfc\ 3484 sorting. +if any \fblabel\fr definition is present in the configuration file, +the default table is not used. +all the label definitions +of the default table which are to be maintained have to be duplicated. +following the keyword, +the line has to contain a network mask and a precedence value. +.tp +\fbprecedence\fr \finetmask\fr \fiprecedence\fr +this keyword is similar to \fblabel\fr, but instead the value is added +to the precedence table as specified in rfc\ 3484. +once again, the +presence of a single \fbprecedence\fr line in the configuration file +causes the default table to not be used. +.tp +\fbreload\fr <\fbyes\fr|\fbno\fr> +this keyword controls whether a process checks whether the configuration +file has been changed since the last time it was read. +if the value is +"\fbyes\fr", the file is reread. +this might cause problems in multithreaded +applications and is generally a bad idea. +the default is "\fbno\fr". +.tp +\fbscopev4\fr \fimask\fr \fivalue\fr +add another rule to the rfc\ 3484 scope table for ipv4 address. +by default, the scope ids described in section 3.2 in rfc\ 3438 are used. +changing these defaults should hardly ever be necessary. +.sh files +\fi/etc/gai.conf\fr +.sh versions +the +.i gai.conf +.\" added in 2006 +file is supported by glibc since version 2.5. +.sh examples +the default table according to rfc\ 3484 would be specified with the +following configuration file: +.pp +.in +4n +.ex +label ::1/128 0 +label ::/0 1 +label 2002::/16 2 +label ::/96 3 +label ::ffff:0:0/96 4 +precedence ::1/128 50 +precedence ::/0 40 +precedence 2002::/16 30 +precedence ::/96 20 +precedence ::ffff:0:0/96 10 +.ee +.in +.\" .sh author +.\" ulrich drepper +.\" +.sh see also +.br getaddrinfo (3), +rfc\ 3484 +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 2002 walter harms +.\" and andries brouwer . +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under gpl +.\" %%%license_end +.\" +.th ioctl_tty 2 2021-08-27 "linux" "linux programmer's manual" +.sh name +ioctl_tty \- ioctls for terminals and serial lines +.sh synopsis +.nf +.b #include +.br "#include " " /* definition of " clocal ", and" +.br " tc*" { flush , on , off "} constants */" +.pp +.bi "int ioctl(int " fd ", int " cmd ", ...);" +.fi +.sh description +the +.br ioctl (2) +call for terminals and serial ports accepts many possible command arguments. +most require a third argument, of varying type, here called +.i argp +or +.ir arg . +.pp +use of +.br ioctl () +makes for nonportable programs. +use the posix interface described in +.br termios (3) +whenever possible. +.ss get and set terminal attributes +.tp +.b tcgets +argument: +.bi "struct termios *" argp +.ip +equivalent to +.ir "tcgetattr(fd, argp)" . +.ip +get the current serial port settings. +.tp +.b tcsets +argument: +.bi "const struct termios *" argp +.ip +equivalent to +.ir "tcsetattr(fd, tcsanow, argp)" . +.ip +set the current serial port settings. +.tp +.b tcsetsw +argument: +.bi "const struct termios *" argp +.ip +equivalent to +.ir "tcsetattr(fd, tcsadrain, argp)" . +.ip +allow the output buffer to drain, and +set the current serial port settings. +.tp +.b tcsetsf +argument: +.bi "const struct termios *" argp +.ip +equivalent to +.ir "tcsetattr(fd, tcsaflush, argp)" . +.ip +allow the output buffer to drain, discard pending input, and +set the current serial port settings. +.pp +the following four ioctls, added in linux 2.6.20, +.\" commit 64bb6c5e1ddcd47c951740485026ef08975ee2e6 +.\" commit 592ee3a5e5e2a981ef2829a0380093006d045661 +are just like +.br tcgets , +.br tcsets , +.br tcsetsw , +.br tcsetsf , +except that they take a +.i "struct termios2\ *" +instead of a +.ir "struct termios\ *" . +if the structure member +.b c_cflag +contains the flag +.br bother , +then the baud rate is stored in the structure members +.b c_ispeed +and +.b c_ospeed +as integer values. +these ioctls are not supported on all architectures. +.rs +.ts +lb l. +tcgets2 \fbstruct termios2 *\fpargp +tcsets2 \fbconst struct termios2 *\fpargp +tcsetsw2 \fbconst struct termios2 *\fpargp +tcsetsf2 \fbconst struct termios2 *\fpargp +.te +.re +.pp +the following four ioctls are just like +.br tcgets , +.br tcsets , +.br tcsetsw , +.br tcsetsf , +except that they take a +.i "struct termio\ *" +instead of a +.ir "struct termios\ *" . +.rs +.ts +lb l. +tcgeta \fbstruct termio *\fpargp +tcseta \fbconst struct termio *\fpargp +tcsetaw \fbconst struct termio *\fpargp +tcsetaf \fbconst struct termio *\fpargp +.te +.re +.ss locking the termios structure +the +.i termios +structure of a terminal can be locked. +the lock is itself a +.i termios +structure, with nonzero bits or fields indicating a +locked value. +.tp +.b tiocglcktrmios +argument: +.bi "struct termios *" argp +.ip +gets the locking status of the +.i termios +structure of the terminal. +.tp +.b tiocslcktrmios +argument: +.bi "const struct termios *" argp +.ip +sets the locking status of the +.i termios +structure of the terminal. +only a process with the +.br cap_sys_admin +capability can do this. +.ss get and set window size +window sizes are kept in the kernel, but not used by the kernel +(except in the case of virtual consoles, where the kernel will +update the window size when the size of the virtual console changes, +for example, by loading a new font). +.tp +.b tiocgwinsz +argument: +.bi "struct winsize *" argp +.ip +get window size. +.tp +.b tiocswinsz +argument: +.bi "const struct winsize *" argp +.ip +set window size. +.pp +the struct used by these ioctls is defined as +.pp +.in +4n +.ex +struct winsize { + unsigned short ws_row; + unsigned short ws_col; + unsigned short ws_xpixel; /* unused */ + unsigned short ws_ypixel; /* unused */ +}; +.ee +.in +.pp +when the window size changes, a +.b sigwinch +signal is sent to the +foreground process group. +.ss sending a break +.tp +.b tcsbrk +argument: +.bi "int " arg +.ip +equivalent to +.ir "tcsendbreak(fd, arg)" . +.ip +if the terminal is using asynchronous serial data transmission, and +.i arg +is zero, then send a break (a stream of zero bits) for between +0.25 and 0.5 seconds. +if the terminal is not using asynchronous +serial data transmission, then either a break is sent, or the function +returns without doing anything. +when +.i arg +is nonzero, nobody knows what will happen. +.ip +(svr4, unixware, solaris, and linux treat +.i "tcsendbreak(fd,arg)" +with nonzero +.i arg +like +.ir "tcdrain(fd)" . +sunos treats +.i arg +as a multiplier, and sends a stream of bits +.i arg +times as long as done for zero +.ir arg . +dg/ux and aix treat +.i arg +(when nonzero) as a time interval measured in milliseconds. +hp-ux ignores +.ir arg .) +.tp +.b tcsbrkp +argument: +.bi "int " arg +.ip +so-called "posix version" of +.br tcsbrk . +it treats nonzero +.i arg +as a time interval measured in deciseconds, and does nothing +when the driver does not support breaks. +.tp +.b tiocsbrk +argument: +.bi "void" +.ip +turn break on, that is, start sending zero bits. +.tp +.b tioccbrk +argument: +.bi "void" +.ip +turn break off, that is, stop sending zero bits. +.ss software flow control +.tp +.b tcxonc +argument: +.bi "int " arg +.ip +equivalent to +.ir "tcflow(fd, arg)" . +.ip +see +.br tcflow (3) +for the argument values +.br tcooff , +.br tcoon , +.br tcioff , +.br tcion . +.ss buffer count and flushing +.tp +.bi fionread +argument: +.bi "int *" argp +.ip +get the number of bytes in the input buffer. +.tp +.b tiocinq +argument: +.bi "int *" argp +.ip +same as +.br fionread . +.tp +.b tiocoutq +argument: +.bi "int *" argp +.ip +get the number of bytes in the output buffer. +.tp +.b tcflsh +argument: +.bi "int " arg +.ip +equivalent to +.ir "tcflush(fd, arg)" . +.ip +see +.br tcflush (3) +for the argument values +.br tciflush , +.br tcoflush , +.br tcioflush . +.ss faking input +.tp +.b tiocsti +argument: +.bi "const char *" argp +.ip +insert the given byte in the input queue. +.ss redirecting console output +.tp +.b tioccons +argument: +.bi "void" +.ip +redirect output that would have gone to +.i /dev/console +or +.i /dev/tty0 +to the given terminal. +if that was a pseudoterminal master, send it to the slave. +in linux before version 2.6.10, +anybody can do this as long as the output was not redirected yet; +since version 2.6.10, only a process with the +.br cap_sys_admin +capability may do this. +if output was redirected already, then +.b ebusy +is returned, +but redirection can be stopped by using this ioctl with +.i fd +pointing at +.i /dev/console +or +.ir /dev/tty0 . +.ss controlling terminal +.tp +.b tiocsctty +argument: +.bi "int " arg +.ip +make the given terminal the controlling terminal of the calling process. +the calling process must be a session leader and not have a +controlling terminal already. +for this case, +.i arg +should be specified as zero. +.ip +if this terminal is already the controlling terminal +of a different session group, then the ioctl fails with +.br eperm , +unless the caller has the +.br cap_sys_admin +capability and +.i arg +equals 1, in which case the terminal is stolen, and all processes that had +it as controlling terminal lose it. +.tp +.b tiocnotty +argument: +.bi "void" +.ip +if the given terminal was the controlling terminal of the calling process, +give up this controlling terminal. +if the process was session leader, +then send +.b sighup +and +.b sigcont +to the foreground process group +and all processes in the current session lose their controlling terminal. +.ss process group and session id +.tp +.b tiocgpgrp +argument: +.bi "pid_t *" argp +.ip +when successful, equivalent to +.ir "*argp = tcgetpgrp(fd)" . +.ip +get the process group id of the foreground process group on this terminal. +.tp +.b tiocspgrp +argument: +.bi "const pid_t *" argp +.ip +equivalent to +.ir "tcsetpgrp(fd, *argp)" . +.ip +set the foreground process group id of this terminal. +.tp +.b tiocgsid +argument: +.bi "pid_t *" argp +.ip +get the session id of the given terminal. +this fails with the error +.b enotty +if the terminal is not a master pseudoterminal +and not our controlling terminal. +strange. +.ss exclusive mode +.tp +.b tiocexcl +argument: +.bi "void" +.ip +put the terminal into exclusive mode. +no further +.br open (2) +operations on the terminal are permitted. +(they fail with +.br ebusy , +except for a process with the +.br cap_sys_admin +capability.) +.tp +.b tiocgexcl +argument: +.bi "int *" argp +.ip +(since linux 3.8) +if the terminal is currently in exclusive mode, +place a nonzero value in the location pointed to by +.ir argp ; +otherwise, place zero in +.ir *argp . +.tp +.b tiocnxcl +argument: +.bi "void" +.ip +disable exclusive mode. +.ss line discipline +.tp +.b tiocgetd +argument: +.bi "int *" argp +.ip +get the line discipline of the terminal. +.tp +.b tiocsetd +argument: +.bi "const int *" argp +.ip +set the line discipline of the terminal. +.ss pseudoterminal ioctls +.tp +.b tiocpkt +argument: +.bi "const int *" argp +.ip +enable (when +.ri * argp +is nonzero) or disable packet mode. +can be applied to the master side of a pseudoterminal only (and will return +.b enotty +otherwise). +in packet mode, each subsequent +.br read (2) +will return a packet that either contains a single nonzero control byte, +or has a single byte containing zero (\(aq\e0\(aq) followed by data +written on the slave side of the pseudoterminal. +if the first byte is not +.b tiocpkt_data +(0), it is an or of one +or more of the following bits: +.ip +.ad l +.ts +lb l. +tiocpkt_flushread t{ +the read queue for the terminal is flushed. +t} +tiocpkt_flushwrite t{ +the write queue for the terminal is flushed. +t} +tiocpkt_stop t{ +output to the terminal is stopped. +t} +tiocpkt_start t{ +output to the terminal is restarted. +t} +tiocpkt_dostop t{ +the start and stop characters are \fb\(has\fp/\fb\(haq\fp. +t} +tiocpkt_nostop t{ +the start and stop characters are not \fb\(has\fp/\fb\(haq\fp. +t} +.te +.ad +.ip +while packet mode is in use, the presence +of control status information to be read +from the master side may be detected by a +.br select (2) +for exceptional conditions or a +.br poll (2) +for the +.b pollpri +event. +.ip +this mode is used by +.br rlogin (1) +and +.br rlogind (8) +to implement a remote-echoed, +locally \fb\(has\fp/\fb\(haq\fp flow-controlled remote login. +.tp +.b tiocgpkt +argument: +.bi "const int *" argp +.ip +(since linux 3.8) +return the current packet mode setting in the integer pointed to by +.ir argp . +.tp +.b tiocsptlck +argument: +.bi "int *" argp +.ip +set (if +.ir *argp +is nonzero) or remove (if +.ir *argp +is zero) the lock on the pseudoterminal slave device. +(see also +.br unlockpt (3).) +.tp +.b tiocgptlck +argument: +.bi "int *" argp +.ip +(since linux 3.8) +place the current lock state of the pseudoterminal slave device +in the location pointed to by +.ir argp . +.tp +.b tiocgptpeer +argument: +.bi "int " flags +.ip +.\" commit 54ebbfb1603415d9953c150535850d30609ef077 +(since linux 4.13) +given a file descriptor in +.i fd +that refers to a pseudoterminal master, +open (with the given +.br open (2)-style +.ir flags ) +and return a new file descriptor that refers to the peer +pseudoterminal slave device. +this operation can be performed +regardless of whether the pathname of the slave device +is accessible through the calling process's mount namespace. +.ip +security-conscious programs interacting with namespaces may wish to use this +operation rather than +.br open (2) +with the pathname returned by +.br ptsname (3), +and similar library functions that have insecure apis. +(for example, confusion can occur in some cases using +.br ptsname (3) +with a pathname where a devpts filesystem +has been mounted in a different mount namespace.) +.pp +the bsd ioctls +.br tiocstop , +.br tiocstart , +.br tiocucntl , +and +.b tiocremote +have not been implemented under linux. +.ss modem control +.tp +.b tiocmget +argument: +.bi "int *" argp +.ip +get the status of modem bits. +.tp +.b tiocmset +argument: +.bi "const int *" argp +.ip +set the status of modem bits. +.tp +.b tiocmbic +argument: +.bi "const int *" argp +.ip +clear the indicated modem bits. +.tp +.b tiocmbis +argument: +.bi "const int *" argp +.ip +set the indicated modem bits. +.pp +the following bits are used by the above ioctls: +.pp +.ts +lb l. +tiocm_le dsr (data set ready/line enable) +tiocm_dtr dtr (data terminal ready) +tiocm_rts rts (request to send) +tiocm_st secondary txd (transmit) +tiocm_sr secondary rxd (receive) +tiocm_cts cts (clear to send) +tiocm_car dcd (data carrier detect) +tiocm_cd see tiocm_car +tiocm_rng rng (ring) +tiocm_ri see tiocm_rng +tiocm_dsr dsr (data set ready) +.te +.tp +.b tiocmiwait +argument: +.bi "int " arg +.ip +wait for any of the 4 modem bits (dcd, ri, dsr, cts) to change. +the bits of interest are specified as a bit mask in +.ir arg , +by oring together any of the bit values, +.br tiocm_rng , +.br tiocm_dsr , +.br tiocm_cd , +and +.br tiocm_cts . +the caller should use +.b tiocgicount +to see which bit has changed. +.tp +.b tiocgicount +argument: +.bi "struct serial_icounter_struct *" argp +.ip +get counts of input serial line interrupts (dcd, ri, dsr, cts). +the counts are written to the +.i serial_icounter_struct +structure pointed to by +.ir argp . +.ip +note: both 1->0 and 0->1 transitions are counted, except for +ri, where only 0->1 transitions are counted. +.ss marking a line as local +.tp +.b tiocgsoftcar +argument: +.bi "int *" argp +.ip +("get software carrier flag") +get the status of the clocal flag in the c_cflag field of the +.i termios +structure. +.tp +.b tiocssoftcar +argument: +.bi "const int *" argp +.ip +("set software carrier flag") +set the clocal flag in the +.i termios +structure when +.ri * argp +is nonzero, and clear it otherwise. +.pp +if the +.b clocal +flag for a line is off, the hardware carrier detect (dcd) +signal is significant, and an +.br open (2) +of the corresponding terminal will block until dcd is asserted, +unless the +.b o_nonblock +flag is given. +if +.b clocal +is set, the line behaves as if dcd is always asserted. +the software carrier flag is usually turned on for local devices, +and is off for lines with modems. +.ss linux-specific +for the +.b tioclinux +ioctl, see +.br ioctl_console (2). +.ss kernel debugging +.b "#include " +.tp +.b tiocttygstruct +argument: +.bi "struct tty_struct *" argp +.ip +get the +.i tty_struct +corresponding to +.ir fd . +this command was removed in linux 2.5.67. +.\" commit b3506a09d15dc5aee6d4bb88d759b157016e1864 +.\" author: andries e. brouwer +.\" date: tue apr 1 04:42:46 2003 -0800 +.\" +.\" [patch] kill tiocttygstruct +.\" +.\" only used for (dubious) debugging purposes, and exposes +.\" internal kernel state. +.\" +.\" .ss serial info +.\" .br "#include " +.\" .pp +.\" .tp +.\" .bi "tiocgserial struct serial_struct *" argp +.\" get serial info. +.\" .tp +.\" .bi "tiocsserial const struct serial_struct *" argp +.\" set serial info. +.sh return value +the +.br ioctl (2) +system call returns 0 on success. +on error, it returns \-1 and sets +.i errno +to indicate the error. +.sh errors +.tp +.b einval +invalid command parameter. +.tp +.b enoioctlcmd +unknown command. +.tp +.b enotty +inappropriate +.ir fd . +.tp +.b eperm +insufficient permission. +.sh examples +check the condition of dtr on the serial port. +.pp +.ex +#include +#include +#include +#include + +int +main(void) +{ + int fd, serial; + + fd = open("/dev/ttys0", o_rdonly); + ioctl(fd, tiocmget, &serial); + if (serial & tiocm_dtr) + puts("tiocm_dtr is set"); + else + puts("tiocm_dtr is not set"); + close(fd); +} +.ee +.sh see also +.br ldattach (1), +.br ioctl (2), +.br ioctl_console (2), +.br termios (3), +.br pty (7) +.\" +.\" fionbio const int * +.\" fionclex void +.\" fioclex void +.\" fioasync const int * +.\" from serial.c: +.\" tiocserconfig void +.\" tiocsergwild int * +.\" tiocserswild const int * +.\" tiocsergstruct struct async_struct * +.\" tiocsergetlsr int * +.\" tiocsergetmulti struct serial_multiport_struct * +.\" tiocsersetmulti const struct serial_multiport_struct * +.\" tiocgserial, tiocsserial (see above) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/fpclassify.3 + +.\" copyright (c) 1993 by thomas koenig (ig25@rz.uni-karlsruhe.de) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified sat jul 24 19:01:20 1993 by rik faith (faith@cs.unc.edu) +.th localeconv 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +localeconv \- get numeric formatting information +.sh synopsis +.nf +.b #include +.pp +.b struct lconv *localeconv(void); +.fi +.sh description +the +.br localeconv () +function returns a pointer to a +.i struct lconv +for the current locale. +this structure is shown in +.br locale (7), +and contains all values associated with the locale categories +.b lc_numeric +and +.br lc_monetary . +programs may also use the functions +.br printf (3) +and +.br strfmon (3), +which behave according to the actual locale in use. +.sh return value +the +.br localeconv () +function returns a pointer to a filled in +.ir "struct lconv" . +this structure may be (in glibc, +.ir is ) +statically allocated, and may be overwritten by subsequent calls. +according to posix, +the caller should not modify the contents of this structure. +the +.br localeconv () +function always succeeds. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lb lb lbx +l l l. +interface attribute value +t{ +.br localeconv () +t} thread safety t{ +mt-unsafe race:localeconv locale +t} +.te +.hy +.ad +.sp 1 +.sh conforming to +c89, c99. +.sh bugs +the +.br printf (3) +family of functions may or may not honor the current locale. +.sh see also +.br locale (1), +.br localedef (1), +.br isalpha (3), +.br nl_langinfo (3), +.br setlocale (3), +.br strcoll (3), +.br strftime (3), +.br locale (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/lrint.3 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sat jul 24 18:43:46 1993 by rik faith (faith@cs.unc.edu) +.th putpwent 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +putpwent \- write a password file entry +.sh synopsis +.nf +.b #include +.b #include +.b #include +.pp +.bi "int putpwent(const struct passwd *restrict " p \ +", file *restrict " stream ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br putpwent (): +.nf + since glibc 2.19: + _default_source + glibc 2.19 and earlier: + _svid_source +.fi +.sh description +the +.br putpwent () +function writes a password entry from the +structure \fip\fp in the file associated with \fistream\fp. +.pp +the \fipasswd\fp structure is defined in \fi\fp as follows: +.pp +.in +4n +.ex +struct passwd { + char *pw_name; /* username */ + char *pw_passwd; /* user password */ + uid_t pw_uid; /* user id */ + gid_t pw_gid; /* group id */ + char *pw_gecos; /* real name */ + char *pw_dir; /* home directory */ + char *pw_shell; /* shell program */ +}; +.ee +.in +.sh return value +the +.br putpwent () +function returns 0 on success. +on failure, it returns \-1, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b einval +invalid (null) argument given. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br putpwent () +t} thread safety mt-safe locale +.te +.hy +.ad +.sp 1 +.sh conforming to +svr4. +.sh see also +.br endpwent (3), +.br fgetpwent (3), +.br getpw (3), +.br getpwent (3), +.br getpwnam (3), +.br getpwuid (3), +.br setpwent (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1993 +.\" the regents of the university of california. all rights reserved. +.\" and copyright (c) 2020 by alejandro colomar +.\" +.\" %%%license_start(bsd_3_clause_ucb) +.\" redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. neither the name of the university nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" this software is provided by the regents and contributors ``as is'' and +.\" any express or implied warranties, including, but not limited to, the +.\" implied warranties of merchantability and fitness for a particular purpose +.\" are disclaimed. in no event shall the regents or contributors be liable +.\" for any direct, indirect, incidental, special, exemplary, or consequential +.\" damages (including, but not limited to, procurement of substitute goods +.\" or services; loss of use, data, or profits; or business interruption) +.\" however caused and on any theory of liability, whether in contract, strict +.\" liability, or tort (including negligence or otherwise) arising in any way +.\" out of the use of this software, even if advised of the possibility of +.\" such damage. +.\" %%%license_end +.\" +.\" +.th list 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +list_empty, +list_entry, +list_first, +list_foreach, +.\"list_foreach_from, +.\"list_foreach_safe, +.\"list_foreach_from_safe, +list_head, +list_head_initializer, +list_init, +list_insert_after, +list_insert_before, +list_insert_head, +list_next, +.\"list_prev, +list_remove +.\"list_swap +\- implementation of a doubly linked list +.sh synopsis +.nf +.b #include +.pp +.b list_entry(type); +.pp +.b list_head(headname, type); +.bi "list_head list_head_initializer(list_head " head ); +.bi "void list_init(list_head *" head ); +.pp +.bi "int list_empty(list_head *" head ); +.pp +.bi "void list_insert_head(list_head *" head , +.bi " struct type *" elm ", list_entry " name ); +.bi "void list_insert_before(struct type *" listelm , +.bi " struct type *" elm ", list_entry " name ); +.bi "void list_insert_after(struct type *" listelm , +.bi " struct type *" elm ", list_entry " name ); +.pp +.bi "struct type *list_first(list_head *" head ); +.\" .bi "struct type *list_prev(struct type *" elm ", list_head *" head , +.\" .bi " struct type, list_entry " name ); +.bi "struct type *list_next(struct type *" elm ", list_entry " name ); +.pp +.bi "list_foreach(struct type *" var ", list_head *" head ", list_entry " name ); +.\" .bi "list_foreach_from(struct type *" var ", list_head *" head ", list_entry " name ); +.\" .pp +.\" .bi "list_foreach_safe(struct type *" var ", list_head *" head , +.\" .bi " list_entry " name ", struct type *" temp_var ); +.\" .bi "list_foreach_from_safe(struct type *" var ", list_head *" head , +.\" .bi " list_entry " name ", struct type *" temp_var ); +.pp +.bi "void list_remove(struct type *" elm ", list_entry " name ); +.\" .pp +.\" .bi "void list_swap(list_head *" head1 ", list_head *" head2 , +.\" .bi " struct type, list_entry " name ); +.fi +.sh description +these macros define and operate on doubly linked lists. +.pp +in the macro definitions, +.i type +is the name of a user-defined structure, +that must contain a field of type +.ir list_entry , +named +.ir name . +the argument +.ir headname +is the name of a user-defined structure +that must be declared using the macro +.br list_head (). +.ss creation +a list is headed by a structure defined by the +.br list_head () +macro. +this structure contains a single pointer to the first element on the list. +the elements are doubly linked +so that an arbitrary element can be removed without traversing the list. +new elements can be added to the list +after an existing element, +before an existing element, +or at the head of the list. +a +.i list_head +structure is declared as follows: +.pp +.in +4 +.ex +list_head(headname, type) head; +.ee +.in +.pp +where +.i struct headname +is the structure to be defined, and +.i struct type +is the type of the elements to be linked into the list. +a pointer to the head of the list can later be declared as: +.pp +.in +4 +.ex +struct headname *headp; +.ee +.in +.pp +(the names +.i head +and +.i headp +are user selectable.) +.pp +.br list_entry () +declares a structure that connects the elements in the list. +.pp +.br list_head_initializer () +evaluates to an initializer for the list +.ir head . +.pp +.br list_init () +initializes the list referenced by +.ir head . +.pp +.br list_empty () +evaluates to true if there are no elements in the list. +.ss insertion +.br list_insert_head () +inserts the new element +.i elm +at the head of the list. +.pp +.br list_insert_before () +inserts the new element +.i elm +before the element +.ir listelm . +.pp +.br list_insert_after () +inserts the new element +.i elm +after the element +.ir listelm . +.ss traversal +.br list_first () +returns the first element in the list, or null if the list is empty. +.\" .pp +.\" .br list_prev () +.\" returns the previous element in the list, or null if this is the first. +.\" list +.\" .i head +.\" must contain element +.\" .ir elm . +.pp +.br list_next () +returns the next element in the list, or null if this is the last. +.pp +.br list_foreach () +traverses the list referenced by +.i head +in the forward direction, +assigning each element in turn to +.ir var . +.\" .pp +.\" .br list_foreach_from () +.\" behaves identically to +.\" .br list_foreach () +.\" when +.\" .i var +.\" is null, else it treats +.\" .i var +.\" as a previously found list element and begins the loop at +.\" .i var +.\" instead of the first element in the list referenced by +.\" .ir head . +.\" .pp +.\" .br list_foreach_safe () +.\" traverses the list referenced by +.\" .i head +.\" in the forward direction, assigning each element in turn to +.\" .ir var . +.\" however, unlike +.\" .br list_foreach () +.\" here it is permitted to both remove +.\" .i var +.\" as well as free it from within the loop safely without interfering with the +.\" traversal. +.\" .pp +.\" .br list_foreach_from_safe () +.\" behaves identically to +.\" .br list_foreach_safe () +.\" when +.\" .i var +.\" is null, else it treats +.\" .i var +.\" as a previously found list element and begins the loop at +.\" .i var +.\" instead of the first element in the list referenced by +.\" .ir head . +.ss removal +.br list_remove () +removes the element +.i elm +from the list. +.\" .ss other features +.\" .br list_swap () +.\" swaps the contents of +.\" .i head1 +.\" and +.\" .ir head2 . +.sh return value +.br list_empty () +returns nonzero if the list is empty, +and zero if the list contains at least one entry. +.pp +.br list_first (), +and +.br list_next () +return a pointer to the first or next +.i type +structure, respectively. +.pp +.br list_head_initializer () +returns an initializer that can be assigned to the list +.ir head . +.sh conforming to +not in posix.1, posix.1-2001, or posix.1-2008. +present on the bsds +(list macros first appeared in 4.4bsd). +.sh bugs +.br list_foreach () +doesn't allow +.i var +to be removed or freed within the loop, +as it would interfere with the traversal. +.br list_foreach_safe (), +which is present on the bsds but is not present in glibc, +fixes this limitation by allowing +.i var +to safely be removed from the list and freed from within the loop +without interfering with the traversal. +.sh examples +.ex +#include +#include +#include +#include + +struct entry { + int data; + list_entry(entry) entries; /* list */ +}; + +list_head(listhead, entry); + +int +main(void) +{ + struct entry *n1, *n2, *n3, *np; + struct listhead head; /* list head */ + int i; + + list_init(&head); /* initialize the list */ + + n1 = malloc(sizeof(struct entry)); /* insert at the head */ + list_insert_head(&head, n1, entries); + + n2 = malloc(sizeof(struct entry)); /* insert after */ + list_insert_after(n1, n2, entries); + + n3 = malloc(sizeof(struct entry)); /* insert before */ + list_insert_before(n2, n3, entries); + + i = 0; /* forward traversal */ + list_foreach(np, &head, entries) + np\->data = i++; + + list_remove(n2, entries); /* deletion */ + free(n2); + /* forward traversal */ + list_foreach(np, &head, entries) + printf("%i\en", np\->data); + /* list deletion */ + n1 = list_first(&head); + while (n1 != null) { + n2 = list_next(n1, entries); + free(n1); + n1 = n2; + } + list_init(&head); + + exit(exit_success); +} +.ee +.sh see also +.br insque (3), +.br queue (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 2009 lefteris dimitroulakis (edimitro@tee.gr) +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th iso_8859-14 7 2020-08-13 "linux" "linux programmer's manual" +.sh name +iso_8859-14 \- iso 8859-14 character set encoded in octal, decimal, +and hexadecimal +.sh description +the iso 8859 standard includes several 8-bit extensions to the ascii +character set (also known as iso 646-irv). +iso 8859-14 encodes the +characters used in celtic languages. +.ss iso 8859 alphabets +the full set of iso 8859 alphabets includes: +.ts +l l. +iso 8859-1 west european languages (latin-1) +iso 8859-2 central and east european languages (latin-2) +iso 8859-3 southeast european and miscellaneous languages (latin-3) +iso 8859-4 scandinavian/baltic languages (latin-4) +iso 8859-5 latin/cyrillic +iso 8859-6 latin/arabic +iso 8859-7 latin/greek +iso 8859-8 latin/hebrew +iso 8859-9 latin-1 modification for turkish (latin-5) +iso 8859-10 lappish/nordic/eskimo languages (latin-6) +iso 8859-11 latin/thai +iso 8859-13 baltic rim languages (latin-7) +iso 8859-14 celtic (latin-8) +iso 8859-15 west european languages (latin-9) +iso 8859-16 romanian (latin-10) +.te +.ss iso 8859-14 characters +the following table displays the characters in iso 8859-14 that +are printable and unlisted in the +.br ascii (7) +manual page. +.ts +l l l c lp-1. +oct dec hex char description +_ +240 160 a0   no-break space +241 161 a1 ḃ latin capital letter b with dot above +242 162 a2 ḃ latin small letter b with dot above +243 163 a3 £ pound sign +244 164 a4 ċ latin capital letter c with dot above +245 165 a5 ċ latin small letter c with dot above +246 166 a6 ḋ latin capital letter d with dot above +247 167 a7 § section sign +250 168 a8 ẁ latin capital letter w with grave +251 169 a9 © copyright sign +252 170 aa ẃ latin capital letter w with acute +253 171 ab ḋ latin small letter d with dot above +254 172 ac ỳ latin capital letter y with grave +255 173 ad ­ soft hyphen +256 174 ae ® registered sign +257 175 af ÿ latin capital letter y with diaeresis +260 176 b0 ḟ latin capital letter f with dot above +261 177 b1 ḟ latin small letter f with dot above +262 178 b2 ġ latin capital letter g with dot above +263 179 b3 ġ latin small letter g with dot above +264 180 b4 ṁ latin capital letter m with dot above +265 181 b5 ṁ latin small letter m with dot above +266 182 b6 ¶ pilcrow sign +267 183 b7 ṗ latin capital letter p with dot above +270 184 b8 ẁ latin small letter w with grave +271 185 b9 ṗ latin small letter p with dot above +272 186 ba ẃ latin small letter w with acute +273 187 bb ṡ latin capital letter s with dot above +274 188 bc ỳ latin small letter y with grave +275 189 bd ẅ latin capital letter w with diaeresis +276 190 be ẅ latin small letter w with diaeresis +277 191 bf ṡ latin small letter s with dot above +300 192 c0 à latin capital letter a with grave +301 193 c1 á latin capital letter a with acute +302 194 c2 â latin capital letter a with circumflex +303 195 c3 ã latin capital letter a with tilde +304 196 c4 ä latin capital letter a with diaeresis +305 197 c5 å latin capital letter a with ring above +306 198 c6 æ latin capital letter ae +307 199 c7 ç latin capital letter c with cedilla +310 200 c8 è latin capital letter e with grave +311 201 c9 é latin capital letter e with acute +312 202 ca ê latin capital letter e with circumflex +313 203 cb ë latin capital letter e with diaeresis +314 204 cc ì latin capital letter i with grave +315 205 cd í latin capital letter i with acute +316 206 ce î latin capital letter i with circumflex +317 207 cf ï latin capital letter i with diaeresis +320 208 d0 ŵ latin capital letter w with circumflex +321 209 d1 ñ latin capital letter n with tilde +322 210 d2 ò latin capital letter o with grave +323 211 d3 ó latin capital letter o with acute +324 212 d4 ô latin capital letter o with circumflex +325 213 d5 õ latin capital letter o with tilde +326 214 d6 ö latin capital letter o with diaeresis +327 215 d7 ṫ latin capital letter t with dot above +330 216 d8 ø latin capital letter o with stroke +331 217 d9 ù latin capital letter u with grave +332 218 da ú latin capital letter u with acute +333 219 db û latin capital letter u with circumflex +334 220 dc ü latin capital letter u with diaeresis +335 221 dd ý latin capital letter y with acute +336 222 de ŷ latin capital letter y with circumflex +337 223 df ß latin small letter sharp s +340 224 e0 à latin small letter a with grave +341 225 e1 á latin small letter a with acute +342 226 e2 â latin small letter a with circumflex +343 227 e3 ã latin small letter a with tilde +344 228 e4 ä latin small letter a with diaeresis +345 229 e5 å latin small letter a with ring above +346 230 e6 æ latin small letter ae +347 231 e7 ç latin small letter c with cedilla +350 232 e8 è latin small letter e with grave +351 233 e9 é latin small letter e with acute +352 234 ea ê latin small letter e with circumflex +353 235 eb ë latin small letter e with diaeresis +354 236 ec ì latin small letter i with grave +355 237 ed í latin small letter i with acute +356 238 ee î latin small letter i with circumflex +357 239 ef ï latin small letter i with diaeresis +360 240 f0 ŵ latin small letter w with circumflex +361 241 f1 ñ latin small letter n with tilde +362 242 f2 ò latin small letter o with grave +363 243 f3 ó latin small letter o with acute +364 244 f4 ô latin small letter o with circumflex +365 245 f5 õ latin small letter o with tilde +366 246 f6 ö latin small letter o with diaeresis +367 247 f7 ṫ latin small letter t with dot above +370 248 f8 ø latin small letter o with stroke +371 249 f9 ù latin small letter u with grave +372 250 fa ú latin small letter u with acute +373 251 fb û latin small letter u with circumflex +374 252 fc ü latin small letter u with diaeresis +375 253 fd ý latin small letter y with acute +376 254 fe ŷ latin small letter y with circumflex +377 255 ff ÿ latin small letter y with diaeresis +.te +.sh notes +iso 8859-14 is also known as latin-8. +.sh see also +.br ascii (7), +.br charsets (7), +.br utf\-8 (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" written by ralf baechle (ralf@waldorf-gmbh.de), +.\" copyright (c) 1994, 1995 waldorf gmbh +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th cacheflush 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +cacheflush \- flush contents of instruction and/or data cache +.sh synopsis +.nf +.b #include +.pp +.bi "int cacheflush(void *" addr ", int "nbytes ", int "cache ); +.fi +.pp +.ir note : +on some architectures, +there is no glibc wrapper for this system call; see notes. +.sh description +.br cacheflush () +flushes the contents of the indicated cache(s) for the +user addresses in the range +.i addr +to +.ir (addr+nbytes\-1) . +.i cache +may be one of: +.tp +.b icache +flush the instruction cache. +.tp +.b dcache +write back to memory and invalidate the affected valid cache lines. +.tp +.b bcache +same as +.br (icache|dcache) . +.sh return value +.br cacheflush () +returns 0 on success. +on error, it returns \-1 and sets +.i errno +to indicate the error. +.sh errors +.tp +.b efault +some or all of the address range +.i addr +to +.i (addr+nbytes\-1) +is not accessible. +.tp +.b einval +.i cache +is not one of +.br icache , +.br dcache , +or +.br bcache +(but see bugs). +.sh conforming to +historically, this system call was available on all mips unix variants +including risc/os, irix, ultrix, netbsd, openbsd, and freebsd +(and also on some non-unix mips operating systems), so that +the existence of this call in mips operating systems is a de-facto +standard. +.ss caveat +.br cacheflush () +should not be used in programs intended to be portable. +on linux, this call first appeared on the mips architecture, +but nowadays, linux provides a +.br cacheflush () +system call on some other architectures, but with different arguments. +.sh notes +.ss architecture-specific variants +glibc provides a wrapper for this system call, +with the prototype shown in synopsis, +for the following architectures: +arc, csky, mips, and nios2. +.pp +on some other architectures, +linux provides this system call, with different arguments: +.tp +m68k: +.nf +.bi "int cacheflush(unsigned long " addr ", int " scope ", int " cache , +.bi " unsigned long " len ); +.fi +.tp +sh: +.nf +.bi "int cacheflush(unsigned long " addr ", unsigned long " len ", int " op ); +.fi +.tp +nds32: +.nf +.bi "int cacheflush(unsigned int " start ", unsigned int " end ", int " cache ); +.fi +.pp +on the above architectures, +glibc does not provide a wrapper for this system call; call it using +.br syscall (2). +.ss gcc alternative +unless you need the finer grained control that this system call provides, +you probably want to use the gcc built-in function +.br __builtin___clear_cache (), +which provides a portable interface +across platforms supported by gcc and compatible compilers: +.pp +.in +4n +.ex +.bi "void __builtin___clear_cache(void *" begin ", void *" end ); +.ee +.in +.pp +on platforms that don't require instruction cache flushes, +.br __builtin___clear_cache () +has no effect. +.pp +.ir note : +on some gcc-compatible compilers, +the prototype for this built-in function uses +.i char * +instead of +.i void * +for the parameters. +.sh bugs +linux kernels older than version 2.6.11 ignore the +.i addr +and +.i nbytes +arguments, making this function fairly expensive. +therefore, the whole cache is always flushed. +.pp +this function always behaves as if +.br bcache +has been passed for the +.i cache +argument and does not do any error checking on the +.i cache +argument. +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2006 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th sem_init 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +sem_init \- initialize an unnamed semaphore +.sh synopsis +.nf +.b #include +.pp +.bi "int sem_init(sem_t *" sem ", int " pshared ", unsigned int " value ); +.fi +.pp +link with \fi\-pthread\fp. +.sh description +.br sem_init () +initializes the unnamed semaphore at the address pointed to by +.ir sem . +the +.i value +argument specifies the initial value for the semaphore. +.pp +the +.i pshared +argument indicates whether this semaphore is to be shared +between the threads of a process, or between processes. +.pp +if +.i pshared +has the value 0, +then the semaphore is shared between the threads of a process, +and should be located at some address that is visible to all threads +(e.g., a global variable, or a variable allocated dynamically on +the heap). +.pp +if +.i pshared +is nonzero, then the semaphore is shared between processes, +and should be located in a region of shared memory (see +.br shm_open (3), +.br mmap (2), +and +.br shmget (2)). +(since a child created by +.br fork (2) +inherits its parent's memory mappings, it can also access the semaphore.) +any process that can access the shared memory region +can operate on the semaphore using +.br sem_post (3), +.br sem_wait (3), +and so on. +.pp +initializing a semaphore that has already been initialized +results in undefined behavior. +.sh return value +.br sem_init () +returns 0 on success; +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b einval +.i value +exceeds +.br sem_value_max . +.tp +.b enosys +.i pshared +is nonzero, +but the system does not support process-shared semaphores (see +.br sem_overview (7)). +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br sem_init () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001. +.sh notes +bizarrely, posix.1-2001 does not specify the value that should +be returned by a successful call to +.br sem_init (). +posix.1-2008 rectifies this, specifying the zero return on success. +.sh examples +see +.br shm_open (3) +and +.br sem_wait (3). +.sh see also +.br sem_destroy (3), +.br sem_post (3), +.br sem_wait (3), +.br sem_overview (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2002 andries brouwer (aeb@cwi.nl) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th dirfd 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +dirfd \- get directory stream file descriptor +.sh synopsis +.nf +.b #include +.b #include +.pp +.bi "int dirfd(dir *" dirp ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br dirfd (): +.nf + /* since glibc 2.10: */ _posix_c_source >= 200809l + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.sh description +the function +.br dirfd () +returns the file descriptor associated with the directory stream +.ir dirp . +.pp +this file descriptor is the one used internally by the directory stream. +as a result, it is useful only for functions which do not depend on +or alter the file position, such as +.br fstat (2) +and +.br fchdir (2). +it will be automatically closed when +.br closedir (3) +is called. +.sh return value +on success, +.br dirfd () +returns a file descriptor (a nonnegative integer). +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +posix.1-2008 specifies two errors, +neither of which is returned by the current +.\" glibc 2.8 +implementation. +.tp +.b einval +.i dirp +does not refer to a valid directory stream. +.tp +.b enotsup +the implementation does not support the association of a file +descriptor with a directory. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br dirfd () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2008. +this function was a bsd extension, present in 4.3bsd-reno, not in 4.2bsd. +.\" it is present in libc5 (since 5.1.2) and in glibc2. +.sh see also +.br open (2), +.br openat (2), +.br closedir (3), +.br opendir (3), +.br readdir (3), +.br rewinddir (3), +.br scandir (3), +.br seekdir (3), +.br telldir (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2014 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th duplocale 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +duplocale \- duplicate a locale object +.sh synopsis +.nf +.b #include +.pp +.bi "locale_t duplocale(locale_t " locobj ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br duplocale (): +.nf + since glibc 2.10: + _xopen_source >= 700 + before glibc 2.10: + _gnu_source +.fi +.sh description +the +.br duplocale () +function creates a duplicate of the locale object referred to by +.ir locobj . +.pp +if +.i locobj +is +.br lc_global_locale , +.br duplocale () +creates a locale object containing a copy of the global locale +determined by +.br setlocale (3). +.sh return value +on success, +.br duplocale () +returns a handle for the new locale object. +on error, it returns +.ir "(locale_t)\ 0", +and sets +.i errno +to indicate the error. +.sh errors +.tp +.b enomem +insufficient memory to create the duplicate locale object. +.sh versions +the +.br duplocale () +function first appeared in version 2.3 of the gnu c library. +.sh conforming to +posix.1-2008. +.sh notes +duplicating a locale can serve the following purposes: +.ip * 3 +to create a copy of a locale object in which one of more categories +are to be modified (using +.br newlocale (3)). +.ip * +to obtain a handle for the current locale which can used in +other functions that employ a locale handle, such as +.br toupper_l (3). +this is done by applying +.br duplocale () +to the value returned by the following call: +.ip + loc = uselocale((locale_t) 0); +.ip +this technique is necessary, because the above +.br uselocale (3) +call may return the value +.br lc_global_locale , +which results in undefined behavior if passed to functions such as +.br toupper_l (3). +calling +.br duplocale () +can be used to ensure that the +.br lc_global_locale +value is converted into a usable locale object. +see examples, below. +.pp +each locale object created by +.br duplocale () +should be deallocated using +.br freelocale (3). +.sh examples +the program below uses +.br uselocale (3) +and +.br duplocale () +to obtain a handle for the current locale which is then passed to +.br toupper_l (3). +the program takes one command-line argument, +a string of characters that is converted to uppercase and +displayed on standard output. +an example of its use is the following: +.pp +.in +4n +.ex +$ \fb./a.out abc\fp +abc +.ee +.in +.ss program source +\& +.ex +#define _xopen_source 700 +#include +#include +#include +#include + +#define errexit(msg) do { perror(msg); exit(exit_failure); \e + } while (0) + +int +main(int argc, char *argv[]) +{ + locale_t loc, nloc; + + if (argc != 2) { + fprintf(stderr, "usage: %s string\en", argv[0]); + exit(exit_failure); + } + + /* this sequence is necessary, because uselocale() might return + the value lc_global_locale, which can\(aqt be passed as an + argument to toupper_l(). */ + + loc = uselocale((locale_t) 0); + if (loc == (locale_t) 0) + errexit("uselocale"); + + nloc = duplocale(loc); + if (nloc == (locale_t) 0) + errexit("duplocale"); + + for (char *p = argv[1]; *p; p++) + putchar(toupper_l(*p, nloc)); + + printf("\en"); + + freelocale(nloc); + + exit(exit_success); +} +.ee +.sh see also +.br freelocale (3), +.br newlocale (3), +.br setlocale (3), +.br uselocale (3), +.br locale (5), +.br locale (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/getrlimit.2 + +.so man3/isalpha.3 + +.\" copyright 1993-1995 daniel quinlan (quinlan@yggdrasil.com) +.\" copyright 1999 dimitri papadopoulos (dpo@club-internet.fr) +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th iso_8859-15 7 2020-08-13 "linux" "linux programmer's manual" +.sh name +iso_8859-15 \- iso 8859-15 character set encoded in octal, decimal, +and hexadecimal +.sh description +the iso 8859 standard includes several 8-bit extensions to the ascii +character set (also known as iso 646-irv). +iso 8859-15 encodes the +characters used in many west european languages and adds the euro sign. +.ss iso 8859 alphabets +the full set of iso 8859 alphabets includes: +.ts +l l. +iso 8859-1 west european languages (latin-1) +iso 8859-2 central and east european languages (latin-2) +iso 8859-3 southeast european and miscellaneous languages (latin-3) +iso 8859-4 scandinavian/baltic languages (latin-4) +iso 8859-5 latin/cyrillic +iso 8859-6 latin/arabic +iso 8859-7 latin/greek +iso 8859-8 latin/hebrew +iso 8859-9 latin-1 modification for turkish (latin-5) +iso 8859-10 lappish/nordic/eskimo languages (latin-6) +iso 8859-11 latin/thai +iso 8859-13 baltic rim languages (latin-7) +iso 8859-14 celtic (latin-8) +iso 8859-15 west european languages (latin-9) +iso 8859-16 romanian (latin-10) +.te +.ss iso 8859-15 characters +the following table displays the characters in iso 8859-15 that +are printable and unlisted in the +.br ascii (7) +manual page. +.ts +l l l c lp-1. +oct dec hex char description +_ +240 160 a0   no-break space +241 161 a1 ¡ inverted exclamation mark +242 162 a2 ¢ cent sign +243 163 a3 £ pound sign +244 164 a4 € euro sign +245 165 a5 ¥ yen sign +246 166 a6 š latin capital letter s with caron +247 167 a7 § section sign +250 168 a8 š latin small letter s with caron +251 169 a9 © copyright sign +252 170 aa ª feminine ordinal indicator +253 171 ab « left-pointing double angle quotation mark +254 172 ac ¬ not sign +255 173 ad ­ soft hyphen +256 174 ae ® registered sign +257 175 af ¯ macron +260 176 b0 ° degree sign +261 177 b1 ± plus-minus sign +262 178 b2 ² superscript two +263 179 b3 ³ superscript three +264 180 b4 ž latin capital letter z with caron +265 181 b5 µ micro sign +266 182 b6 ¶ pilcrow sign +267 183 b7 · middle dot +270 184 b8 ž latin small letter z with caron +271 185 b9 ¹ superscript one +272 186 ba º masculine ordinal indicator +273 187 bb » right-pointing double angle quotation mark +274 188 bc œ latin capital ligature oe +275 189 bd œ latin small ligature oe +276 190 be ÿ latin capital letter y with diaeresis +277 191 bf ¿ inverted question mark +300 192 c0 à latin capital letter a with grave +301 193 c1 á latin capital letter a with acute +302 194 c2 â latin capital letter a with circumflex +303 195 c3 ã latin capital letter a with tilde +304 196 c4 ä latin capital letter a with diaeresis +305 197 c5 å latin capital letter a with ring above +306 198 c6 æ latin capital letter ae +307 199 c7 ç latin capital letter c with cedilla +310 200 c8 è latin capital letter e with grave +311 201 c9 é latin capital letter e with acute +312 202 ca ê latin capital letter e with circumflex +313 203 cb ë latin capital letter e with diaeresis +314 204 cc ì latin capital letter i with grave +315 205 cd í latin capital letter i with acute +316 206 ce î latin capital letter i with circumflex +317 207 cf ï latin capital letter i with diaeresis +320 208 d0 ð latin capital letter eth +321 209 d1 ñ latin capital letter n with tilde +322 210 d2 ò latin capital letter o with grave +323 211 d3 ó latin capital letter o with acute +324 212 d4 ô latin capital letter o with circumflex +325 213 d5 õ latin capital letter o with tilde +326 214 d6 ö latin capital letter o with diaeresis +327 215 d7 × multiplication sign +330 216 d8 ø latin capital letter o with stroke +331 217 d9 ù latin capital letter u with grave +332 218 da ú latin capital letter u with acute +333 219 db û latin capital letter u with circumflex +334 220 dc ü latin capital letter u with diaeresis +335 221 dd ý latin capital letter y with acute +336 222 de þ latin capital letter thorn +337 223 df ß latin small letter sharp s +340 224 e0 à latin small letter a with grave +341 225 e1 á latin small letter a with acute +342 226 e2 â latin small letter a with circumflex +343 227 e3 ã latin small letter a with tilde +344 228 e4 ä latin small letter a with diaeresis +345 229 e5 å latin small letter a with ring above +346 230 e6 æ latin small letter ae +347 231 e7 ç latin small letter c with cedilla +350 232 e8 è latin small letter e with grave +351 233 e9 é latin small letter e with acute +352 234 ea ê latin small letter e with circumflex +353 235 eb ë latin small letter e with diaeresis +354 236 ec ì latin small letter i with grave +355 237 ed í latin small letter i with acute +356 238 ee î latin small letter i with circumflex +357 239 ef ï latin small letter i with diaeresis +360 240 f0 ð latin small letter eth +361 241 f1 ñ latin small letter n with tilde +362 242 f2 ò latin small letter o with grave +363 243 f3 ó latin small letter o with acute +364 244 f4 ô latin small letter o with circumflex +365 245 f5 õ latin small letter o with tilde +366 246 f6 ö latin small letter o with diaeresis +367 247 f7 ÷ division sign +370 248 f8 ø latin small letter o with stroke +371 249 f9 ù latin small letter u with grave +372 250 fa ú latin small letter u with acute +373 251 fb û latin small letter u with circumflex +374 252 fc ü latin small letter u with diaeresis +375 253 fd ý latin small letter y with acute +376 254 fe þ latin small letter thorn +377 255 ff ÿ latin small letter y with diaeresis +.te +.sh notes +iso 8859-15 is also known as latin-9 (or sometimes as latin-0). +.sh see also +.br ascii (7), +.br charsets (7), +.br cp1252 (7), +.br iso_8859\-1 (7), +.br utf\-8 (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" %%%license_start(public_domain) +.\" this page is in the public domain. +.\" %%%license_end +.\" +.\" almost all details are from rfc 2553. +.\" +.\" 2004-12-14, mtk, added eai_overflow error +.\" 2004-12-14 fixed description of error return +.\" +.th getnameinfo 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +getnameinfo \- address-to-name translation in protocol-independent manner +.sh synopsis +.nf +.b #include +.b #include +.pp +.bi "int getnameinfo(const struct sockaddr *restrict " addr \ +", socklen_t " addrlen , +.bi " char *restrict " host ", socklen_t " hostlen , +.bi " char *restrict " serv ", socklen_t " servlen \ +", int " flags ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br getnameinfo (): +.nf + since glibc 2.22: + _posix_c_source >= 200112l + glibc 2.21 and earlier: + _posix_c_source +.fi +.sh description +the +.br getnameinfo () +function is the inverse of +.br getaddrinfo (3): +it converts a socket address to a corresponding host and service, +in a protocol-independent manner. +it combines the functionality of +.br gethostbyaddr (3) +and +.br getservbyport (3), +but unlike those functions, +.br getnameinfo () +is reentrant and allows programs to eliminate +ipv4-versus-ipv6 dependencies. +.pp +the +.i addr +argument is a pointer to a generic socket address structure +(of type +.i sockaddr_in +or +.ir sockaddr_in6 ) +of size +.i addrlen +that holds the input ip address and port number. +the arguments +.i host +and +.i serv +are pointers to caller-allocated buffers (of size +.i hostlen +and +.i servlen +respectively) into which +.br getnameinfo () +places null-terminated strings containing the host and +service names respectively. +.pp +the caller can specify that no hostname (or no service name) +is required by providing a null +.i host +(or +.ir serv ) +argument or a zero +.i hostlen +(or +.ir servlen ) +argument. +however, at least one of hostname or service name +must be requested. +.pp +the +.i flags +argument modifies the behavior of +.br getnameinfo () +as follows: +.tp +.b ni_namereqd +if set, then an error is returned if the hostname cannot be determined. +.tp +.b ni_dgram +if set, then the service is datagram (udp) based rather than +stream (tcp) based. +this is required for the few ports (512\(en514) +that have different services for udp and tcp. +.tp +.b ni_nofqdn +if set, return only the hostname part of the fully qualified domain name +for local hosts. +.tp +.b ni_numerichost +if set, then the numeric form of the hostname is returned. +.\" for example, by calling +.\" .br inet_ntop () +.\" instead of +.\" .br gethostbyaddr (). +(when not set, this will still happen in case the node's name +cannot be determined.) +.\" posix.1-2001 tc1 has ni_numericscope, but glibc doesn't have it. +.tp +.b ni_numericserv +if set, then the numeric form of the service address is returned. +(when not set, this will still happen in case the service's name +cannot be determined.) +.ss extensions to getnameinfo() for internationalized domain names +starting with glibc 2.3.4, +.br getnameinfo () +has been extended to selectively allow +hostnames to be transparently converted to and from the +internationalized domain name (idn) format (see rfc 3490, +.ir "internationalizing domain names in applications (idna)" ). +three new flags are defined: +.tp +.b ni_idn +if this flag is used, then the name found in the lookup process is +converted from idn format to the locale's encoding if necessary. +ascii-only names are not affected by the conversion, which +makes this flag usable in existing programs and environments. +.tp +.br ni_idn_allow_unassigned ", " ni_idn_use_std3_ascii_rules +setting these flags will enable the +idna_allow_unassigned (allow unassigned unicode code points) and +idna_use_std3_ascii_rules (check output to make sure it is a std3 +conforming hostname) +flags respectively to be used in the idna handling. +.sh return value +.\" fixme glibc defines the following additional errors, some which +.\" can probably be returned by getnameinfo(); they need to +.\" be documented. +.\" +.\" #ifdef __use_gnu +.\" #define eai_inprogress -100 /* processing request in progress. */ +.\" #define eai_canceled -101 /* request canceled. */ +.\" #define eai_notcanceled -102 /* request not canceled. */ +.\" #define eai_alldone -103 /* all requests done. */ +.\" #define eai_intr -104 /* interrupted by a signal. */ +.\" #define eai_idn_encode -105 /* idn encoding failed. */ +.\" #endif +on success, 0 is returned, and node and service names, if requested, +are filled with null-terminated strings, possibly truncated to fit +the specified buffer lengths. +on error, one of the following nonzero error codes is returned: +.tp +.b eai_again +the name could not be resolved at this time. +try again later. +.tp +.b eai_badflags +the +.i flags +argument has an invalid value. +.tp +.b eai_fail +a nonrecoverable error occurred. +.tp +.b eai_family +the address family was not recognized, +or the address length was invalid for the specified family. +.tp +.b eai_memory +out of memory. +.tp +.b eai_noname +the name does not resolve for the supplied arguments. +.b ni_namereqd +is set and the host's name cannot be located, +or neither hostname nor service name were requested. +.tp +.b eai_overflow +the buffer pointed to by +.i host +or +.i serv +was too small. +.tp +.b eai_system +a system error occurred. +the error code can be found in +.ir errno . +.pp +the +.br gai_strerror (3) +function translates these error codes to a human readable string, +suitable for error reporting. +.sh files +.i /etc/hosts +.br +.i /etc/nsswitch.conf +.br +.i /etc/resolv.conf +.sh versions +.br getnameinfo () +is provided in glibc since version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br getnameinfo () +t} thread safety mt-safe env locale +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, rfc\ 2553. +.sh notes +in order to assist the programmer in choosing reasonable sizes +for the supplied buffers, +.i +defines the constants +.pp +.in +4n +.ex +#define ni_maxhost 1025 +#define ni_maxserv 32 +.ee +.in +.pp +since glibc 2.8, +these definitions are exposed only if suitable +feature test macros are defined, namely: +.br _gnu_source , +.br _default_source +(since glibc 2.19), +or (in glibc versions up to and including 2.19) +.br _bsd_source +or +.br _svid_source . +.pp +the former is the constant +.b maxdname +in recent versions of bind's +.i +header file. +the latter is a guess based on the services listed +in the current assigned numbers rfc. +.pp +before glibc version 2.2, the +.i hostlen +and +.i servlen +arguments were typed as +.ir size_t . +.sh examples +the following code tries to get the numeric hostname and service name, +for a given socket address. +note that there is no hardcoded reference to +a particular address family. +.pp +.in +4n +.ex +struct sockaddr *addr; /* input */ +socklen_t addrlen; /* input */ +char hbuf[ni_maxhost], sbuf[ni_maxserv]; + +if (getnameinfo(addr, addrlen, hbuf, sizeof(hbuf), sbuf, + sizeof(sbuf), ni_numerichost | ni_numericserv) == 0) + printf("host=%s, serv=%s\en", hbuf, sbuf); +.ee +.in +.pp +the following version checks if the socket address has a +reverse address mapping. +.pp +.in +4n +.ex +struct sockaddr *addr; /* input */ +socklen_t addrlen; /* input */ +char hbuf[ni_maxhost]; + +if (getnameinfo(addr, addrlen, hbuf, sizeof(hbuf), + null, 0, ni_namereqd)) + printf("could not resolve hostname"); +else + printf("host=%s\en", hbuf); +.ee +.in +.pp +an example program using +.br getnameinfo () +can be found in +.br getaddrinfo (3). +.sh see also +.br accept (2), +.br getpeername (2), +.br getsockname (2), +.br recvfrom (2), +.br socket (2), +.br getaddrinfo (3), +.br gethostbyaddr (3), +.br getservbyname (3), +.br getservbyport (3), +.br inet_ntop (3), +.br hosts (5), +.br services (5), +.br hostname (7), +.br named (8) +.pp +r.\& gilligan, s.\& thomson, j.\& bound and w.\& stevens, +.ir "basic socket interface extensions for ipv6" , +rfc\ 2553, march 1999. +.pp +tatsuya jinmei and atsushi onoe, +.ir "an extension of format for ipv6 scoped addresses" , +internet draft, work in progress +.ur ftp://ftp.ietf.org\:/internet\-drafts\:/draft\-ietf\-ipngwg\-scopedaddr\-format\-02.txt +.ue . +.pp +craig metz, +.ir "protocol independence using the sockets api" , +proceedings of the freenix track: +2000 usenix annual technical conference, june 2000 +.ad l +.ur http://www.usenix.org\:/publications\:/library\:/proceedings\:/usenix2000\:/freenix\:/metzprotocol.html +.ue . +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/fpclassify.3 + +.so man2/truncate.2 + +.so man3/isgreater.3 + +.so man3/scandir.3 + +.\" copyright (c) 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th shm_overview 7 2021-03-22 "linux" "linux programmer's manual" +.sh name +shm_overview \- overview of posix shared memory +.sh description +the posix shared memory api allows processes to communicate information +by sharing a region of memory. +.pp +the interfaces employed in the api are: +.tp 15 +.br shm_open (3) +create and open a new object, or open an existing object. +this is analogous to +.br open (2). +the call returns a file descriptor for use by the other +interfaces listed below. +.tp +.br ftruncate (2) +set the size of the shared memory object. +(a newly created shared memory object has a length of zero.) +.tp +.br mmap (2) +map the shared memory object into the virtual address space +of the calling process. +.tp +.br munmap (2) +unmap the shared memory object from the virtual address space +of the calling process. +.tp +.br shm_unlink (3) +remove a shared memory object name. +.tp +.br close (2) +close the file descriptor allocated by +.br shm_open (3) +when it is no longer needed. +.tp +.br fstat (2) +obtain a +.i stat +structure that describes the shared memory object. +among the information returned by this call are the object's +size +.ri ( st_size ), +permissions +.ri ( st_mode ), +owner +.ri ( st_uid ), +and group +.ri ( st_gid ). +.tp +.br fchown (2) +to change the ownership of a shared memory object. +.tp +.br fchmod (2) +to change the permissions of a shared memory object. +.ss versions +posix shared memory is supported since linux 2.4 and glibc 2.2. +.ss persistence +posix shared memory objects have kernel persistence: +a shared memory object will exist until the system is shut down, +or until all processes have unmapped the object and it has been deleted with +.br shm_unlink (3) +.ss linking +programs using the posix shared memory api must be compiled with +.i cc \-lrt +to link against the real-time library, +.ir librt . +.ss accessing shared memory objects via the filesystem +on linux, shared memory objects are created in a +.rb ( tmpfs (5)) +virtual filesystem, normally mounted under +.ir /dev/shm . +since kernel 2.6.19, linux supports the use of access control lists (acls) +to control the permissions of objects in the virtual filesystem. +.sh notes +typically, processes must synchronize their access to a shared +memory object, using, for example, posix semaphores. +.pp +system v shared memory +.rb ( shmget (2), +.br shmop (2), +etc.) is an older shared memory api. +posix shared memory provides a simpler, and better designed interface; +on the other hand posix shared memory is somewhat less widely available +(especially on older systems) than system v shared memory. +.sh see also +.br fchmod (2), +.br fchown (2), +.br fstat (2), +.br ftruncate (2), +.br memfd_create (2), +.br mmap (2), +.br mprotect (2), +.br munmap (2), +.br shmget (2), +.br shmop (2), +.br shm_open (3), +.br shm_unlink (3), +.br sem_overview (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1989, 1991, 1993 +.\" the regents of the university of california. all rights reserved. +.\" +.\" %%%license_start(bsd_3_clause_ucb) +.\" redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. neither the name of the university nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" this software is provided by the regents and contributors ``as is'' and +.\" any express or implied warranties, including, but not limited to, the +.\" implied warranties of merchantability and fitness for a particular purpose +.\" are disclaimed. in no event shall the regents or contributors be liable +.\" for any direct, indirect, incidental, special, exemplary, or consequential +.\" damages (including, but not limited to, procurement of substitute goods +.\" or services; loss of use, data, or profits; or business interruption) +.\" however caused and on any theory of liability, whether in contract, strict +.\" liability, or tort (including negligence or otherwise) arising in any way +.\" out of the use of this software, even if advised of the possibility of +.\" such damage. +.\" %%%license_end +.\" +.\" @(#)getloadavg.3 8.1 (berkeley) 6/4/93 +.\" +.\" 2007-12-08, mtk, converted from mdoc to man macros +.\" +.th getloadavg 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +getloadavg \- get system load averages +.sh synopsis +.nf +.b #include +.pp +.bi "int getloadavg(double " loadavg[] ", int " nelem ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br getloadavg (): +.nf + since glibc 2.19: + _default_source + in glibc up to and including 2.19: + _bsd_source +.fi +.sh description +the +.br getloadavg () +function returns the number of processes in the system run queue +averaged over various periods of time. +up to +.i nelem +samples are retrieved and assigned to successive elements of +.ir loadavg[] . +the system imposes a maximum of 3 samples, representing averages +over the last 1, 5, and 15 minutes, respectively. +.sh return value +if the load average was unobtainable, \-1 is returned; otherwise, +the number of samples actually retrieved is returned. +.\" .sh history +.\" the +.\" br getloadavg () +.\" function appeared in +.\" 4.3bsd reno . +.sh versions +this function is available in glibc since version 2.2. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br getloadavg () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +not in posix.1. +present on the bsds and solaris. +.\" mdoc seems to have a bug - there must be no newline here +.sh see also +.br uptime (1), +.br proc (5) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/isalpha.3 + +.so man3/termios.3 + +.\" this manpage is copyright (c) 1992 drew eckhardt; +.\" and copyright (c) 1993 michael haardt, ian jackson. +.\" and copyright (c) 2006, 2014 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified 1993-07-24 by rik faith +.\" modified 1996-04-26 by nick duffek +.\" modified 1996-11-06 by eric s. raymond +.\" modified 1997-01-31 by eric s. raymond +.\" modified 2004-06-23 by michael kerrisk +.\" +.th symlink 2 2021-08-27 "linux" "linux programmer's manual" +.sh name +symlink, symlinkat \- make a new name for a file +.sh synopsis +.nf +.b #include +.pp +.bi "int symlink(const char *" target ", const char *" linkpath ); +.pp +.br "#include " "/* definition of " at_* " constants */" +.b #include +.pp +.bi "int symlinkat(const char *" target ", int " newdirfd \ +", const char *" linkpath ); +.pp +.fi +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br symlink (): +.nf + _xopen_source >= 500 || _posix_c_source >= 200112l +.\" || _xopen_source && _xopen_source_extended + || /* glibc <= 2.19: */ _bsd_source +.fi +.pp +.br symlinkat (): +.nf + since glibc 2.10: + _posix_c_source >= 200809l + before glibc 2.10: + _atfile_source +.fi +.sh description +.br symlink () +creates a symbolic link named +.i linkpath +which contains the string +.ir target . +.pp +symbolic links are interpreted at run time as if the contents of the +link had been substituted into the path being followed to find a file or +directory. +.pp +symbolic links may contain +.i .. +path components, which (if used at the start of the link) refer to the +parent directories of that in which the link resides. +.pp +a symbolic link (also known as a soft link) may point to an existing +file or to a nonexistent one; the latter case is known as a dangling +link. +.pp +the permissions of a symbolic link are irrelevant; the ownership is +ignored when following the link, but is checked when removal or +renaming of the link is requested and the link is in a directory with +the sticky bit +.rb ( s_isvtx ) +set. +.pp +if +.i linkpath +exists, it will +.i not +be overwritten. +.ss symlinkat() +the +.br symlinkat () +system call operates in exactly the same way as +.br symlink (), +except for the differences described here. +.pp +if the pathname given in +.i linkpath +is relative, then it is interpreted relative to the directory +referred to by the file descriptor +.i newdirfd +(rather than relative to the current working directory of +the calling process, as is done by +.br symlink () +for a relative pathname). +.pp +if +.i linkpath +is relative and +.i newdirfd +is the special value +.br at_fdcwd , +then +.i linkpath +is interpreted relative to the current working +directory of the calling process (like +.br symlink ()). +.pp +if +.i linkpath +is absolute, then +.i newdirfd +is ignored. +.pp +see +.br openat (2) +for an explanation of the need for +.br symlinkat (). +.sh return value +on success, zero is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eacces +write access to the directory containing +.i linkpath +is denied, or one of the directories in the path prefix of +.i linkpath +did not allow search permission. +(see also +.br path_resolution (7).) +.tp +.b ebadf +.rb ( symlinkat ()) +.i linkpath +is relative but +.i newdirfd +is neither +.b at_fdcwd +nor a valid file descriptor. +.tp +.b edquot +the user's quota of resources on the filesystem has been exhausted. +the resources could be inodes or disk blocks, depending on the filesystem +implementation. +.tp +.b eexist +.i linkpath +already exists. +.tp +.b efault +.ir target " or " linkpath " points outside your accessible address space." +.tp +.b eio +an i/o error occurred. +.tp +.b eloop +too many symbolic links were encountered in resolving +.ir linkpath . +.tp +.b enametoolong +.ir target " or " linkpath " was too long." +.tp +.b enoent +a directory component in +.i linkpath +does not exist or is a dangling symbolic link, or +.i target +or +.i linkpath +is an empty string. +.tp +.b enoent +.rb ( symlinkat ()) +.i linkpath +is a relative pathname and +.ir newdirfd +refers to a directory that has been deleted. +.tp +.b enomem +insufficient kernel memory was available. +.tp +.b enospc +the device containing the file has no room for the new directory +entry. +.tp +.b enotdir +a component used as a directory in +.i linkpath +is not, in fact, a directory. +.tp +.b enotdir +.rb ( symlinkat ()) +.i linkpath +is relative and +.i newdirfd +is a file descriptor referring to a file other than a directory. +.tp +.b eperm +the filesystem containing +.i linkpath +does not support the creation of symbolic links. +.tp +.b erofs +.i linkpath +is on a read-only filesystem. +.sh versions +.br symlinkat () +was added to linux in kernel 2.6.16; +library support was added to glibc in version 2.4. +.sh conforming to +.br symlink (): +svr4, 4.3bsd, posix.1-2001, posix.1-2008. +.\" svr4 documents additional error codes edquot and enosys. +.\" see +.\" .br open (2) +.\" re multiple files with the same name, and nfs. +.pp +.br symlinkat (): +posix.1-2008. +.sh notes +no checking of +.i target +is done. +.pp +deleting the name referred to by a symbolic link will actually delete the +file (unless it also has other hard links). +if this behavior is not desired, use +.br link (2). +.ss glibc notes +on older kernels where +.br symlinkat () +is unavailable, the glibc wrapper function falls back to the use of +.br symlink (). +when +.i linkpath +is a relative pathname, +glibc constructs a pathname based on the symbolic link in +.ir /proc/self/fd +that corresponds to the +.ir newdirfd +argument. +.sh see also +.br ln (1), +.br namei (1), +.br lchown (2), +.br link (2), +.br lstat (2), +.br open (2), +.br readlink (2), +.br rename (2), +.br unlink (2), +.br path_resolution (7), +.br symlink (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1999 andries brouwer (aeb@cwi.nl) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th tempnam 3 2021-03-22 "" "linux programmer's manual" +.sh name +tempnam \- create a name for a temporary file +.sh synopsis +.nf +.b #include +.pp +.bi "char *tempnam(const char *" dir ", const char *" pfx ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br tempnam (): +.nf + since glibc 2.19: + _default_source + glibc 2.19 and earlier: + _bsd_source || _svid_source +.fi +.sh description +.i "never use this function." +use +.br mkstemp (3) +or +.br tmpfile (3) +instead. +.pp +the +.br tempnam () +function returns a pointer to a string that is a valid filename, +and such that a file with this name did not exist when +.br tempnam () +checked. +the filename suffix of the pathname generated will start with +.i pfx +in case +.i pfx +is a non-null string of at most five bytes. +the directory prefix part of the pathname generated is required to +be "appropriate" (often that at least implies writable). +.pp +attempts to find an appropriate directory go through the following +steps: +.tp 3 +a) +in case the environment variable +.b tmpdir +exists and +contains the name of an appropriate directory, that is used. +.tp +b) +otherwise, if the +.i dir +argument is non-null and appropriate, it is used. +.tp +c) +otherwise, +.i p_tmpdir +(as defined in +.ir ) +is used when appropriate. +.tp +d) +finally an implementation-defined directory may be used. +.pp +the string returned by +.br tempnam () +is allocated using +.br malloc (3) +and hence should be freed by +.br free (3). +.sh return value +on success, the +.br tempnam () +function returns a pointer to a unique temporary filename. +it returns null if a unique name cannot be generated, with +.i errno +set to indicate the error. +.sh errors +.tp +.b enomem +allocation of storage failed. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br tempnam () +t} thread safety mt-safe env +.te +.hy +.ad +.sp 1 +.sh conforming to +svr4, 4.3bsd, posix.1-2001. +posix.1-2008 marks +.br tempnam () +as obsolete. +.sh notes +although +.br tempnam () +generates names that are difficult to guess, +it is nevertheless possible that between the time that +.br tempnam () +returns a pathname, and the time that the program opens it, +another program might create that pathname using +.br open (2), +or create it as a symbolic link. +this can lead to security holes. +to avoid such possibilities, use the +.br open (2) +.b o_excl +flag to open the pathname. +or better yet, use +.br mkstemp (3) +or +.br tmpfile (3). +.pp +susv2 does not mention the use of +.br tmpdir ; +glibc will use it only +when the program is not set-user-id. +on svr4, the directory used under \fbd)\fp is +.i /tmp +(and this is what glibc does). +.pp +because it dynamically allocates memory used to return the pathname, +.br tempnam () +is reentrant, and thus thread safe, unlike +.br tmpnam (3). +.pp +the +.br tempnam () +function generates a different string each time it is called, +up to +.b tmp_max +(defined in +.ir ) +times. +if it is called more than +.b tmp_max +times, +the behavior is implementation defined. +.pp +.br tempnam () +uses at most the first five bytes from +.ir pfx . +.pp +the glibc implementation of +.br tempnam () +fails with the error +.b eexist +upon failure to find a unique name. +.sh bugs +the precise meaning of "appropriate" is undefined; +it is unspecified how accessibility of a directory is determined. +.sh see also +.br mkstemp (3), +.br mktemp (3), +.br tmpfile (3), +.br tmpnam (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/__ppc_set_ppr_med.3 + +.so man3/syslog.3 + + +.so man2/pipe.2 + +.so man3/rpc.3 + +.so man3/cpow.3 + +#!/bin/sh +# +# print_encoding.sh +# +# print man pages with encoding other than us-ascii, together with +# their encoding by file utility and by the first line in the man page. +# +# example usage: +# +# cd man-pages-x.yy +# sh print_encoding.sh man?/* +# +###################################################################### +# +# (c) copyright 2013, peter schiffer +# this program is free software; you can redistribute it and/or +# modify it under the terms of the gnu general public license +# as published by the free software foundation; either version 2 +# of the license, or (at your option) any later version. +# +# this program 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 general public license for more details +# (http://www.gnu.org/licenses/gpl-2.0.html). +# + +if [[ $# -lt 1 ]]; then + echo "usage: ${0} man?/*" 1>&2 + exit 1 +fi + +printf "\n %-23s%-19s%s\n\n" "man page" "encoding by file" "encoding by first line" + +for f in "$@"; do + if [[ ! -f "$f" ]]; then + continue + fi + + enc=$(file -bi "$f" | cut -d = -f 2) + if [[ $enc != "us-ascii" ]]; then + lenc=$(head -n 1 "$f" | sed -n "s/.*coding: \([^ ]*\).*/\1/p") + printf " * %-23s%-19s%s\n" "$f" "$enc" "$lenc" + fi +done + +exit 0 + +.so man3/fseek.3 + +.\" copyright (c) 2005 michael kerrisk +.\" based on earlier work by faith@cs.unc.edu and +.\" mike battersby +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" 2005-09-15, mtk, created new page by splitting off from sigaction.2 +.\" +.th sigpending 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +sigpending, rt_sigpending \- examine pending signals +.sh synopsis +.nf +.b #include +.pp +.bi "int sigpending(sigset_t *" set ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br sigpending (): +.nf + _posix_c_source +.fi +.sh description +.br sigpending () +returns the set of signals that are pending for delivery to the calling +thread (i.e., the signals which have been raised while blocked). +the mask of pending signals is returned in +.ir set . +.sh return value +.br sigpending () +returns 0 on success. +on failure, \-1 is returned and +.i errno +is set to indicate the error. +.sh errors +.tp +.b efault +.i set +points to memory which is not a valid part of the process address space. +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +see +.br sigsetops (3) +for details on manipulating signal sets. +.pp +if a signal is both blocked and has a disposition of "ignored", it is +.i not +added to the mask of pending signals when generated. +.pp +the set of signals that is pending for a thread +is the union of the set of signals that is pending for that thread +and the set of signals that is pending for the process as a whole; see +.br signal (7). +.pp +a child created via +.br fork (2) +initially has an empty pending signal set; +the pending signal set is preserved across an +.br execve (2). +.\" +.ss c library/kernel differences +the original linux system call was named +.br sigpending (). +however, with the addition of real-time signals in linux 2.2, +the fixed-size, 32-bit +.ir sigset_t +argument supported by that system call was no longer fit for purpose. +consequently, a new system call, +.br rt_sigpending (), +was added to support an enlarged +.ir sigset_t +type. +the new system call takes a second argument, +.ir "size_t sigsetsize" , +which specifies the size in bytes of the signal set in +.ir set . +.\" this argument is currently required to be less than or equal to +.\" .ir sizeof(sigset_t) +.\" (or the error +.\" .b einval +.\" results). +the glibc +.br sigpending () +wrapper function hides these details from us, transparently calling +.br rt_sigpending () +when the kernel provides it. +.\" +.sh bugs +in versions of glibc up to and including 2.2.1, +there is a bug in the wrapper function for +.br sigpending () +which means that information about pending real-time signals +is not correctly returned. +.sh see also +.br kill (2), +.br sigaction (2), +.br signal (2), +.br sigprocmask (2), +.br sigsuspend (2), +.br sigsetops (3), +.br signal (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/slist.3 + +.so man3/getutent.3 + +.\" copyright (c) 2006 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th mq_open 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +mq_open \- open a message queue +.sh synopsis +.nf +.br "#include " " /* for o_* constants */" +.br "#include " " /* for mode constants */" +.b #include +.pp +.bi "mqd_t mq_open(const char *" name ", int " oflag ); +.bi "mqd_t mq_open(const char *" name ", int " oflag ", mode_t " mode , +.bi " struct mq_attr *" attr ); +.fi +.pp +link with \fi\-lrt\fp. +.sh description +.br mq_open () +creates a new posix message queue or opens an existing queue. +the queue is identified by +.ir name . +for details of the construction of +.ir name , +see +.br mq_overview (7). +.pp +the +.i oflag +argument specifies flags that control the operation of the call. +(definitions of the flags values can be obtained by including +.ir .) +exactly one of the following must be specified in +.ir oflag : +.tp +.b o_rdonly +open the queue to receive messages only. +.tp +.b o_wronly +open the queue to send messages only. +.tp +.b o_rdwr +open the queue to both send and receive messages. +.pp +zero or more of the following flags can additionally be +.ir or ed +in +.ir oflag : +.tp +.br o_cloexec " (since linux 2.6.26)" +.\" commit 269f21344b23e552c21c9e2d7ca258479dcd7a0a +set the close-on-exec flag for the message queue descriptor. +see +.br open (2) +for a discussion of why this flag is useful. +.tp +.b o_creat +create the message queue if it does not exist. +the owner (user id) of the message queue is set to the effective +user id of the calling process. +the group ownership (group id) is set to the effective group id +of the calling process. +.\" in reality the filesystem ids are used on linux. +.tp +.b o_excl +if +.b o_creat +was specified in +.ir oflag , +and a queue with the given +.i name +already exists, then fail with the error +.br eexist . +.tp +.b o_nonblock +open the queue in nonblocking mode. +in circumstances where +.br mq_receive (3) +and +.br mq_send (3) +would normally block, these functions instead fail with the error +.br eagain . +.pp +if +.b o_creat +is specified in +.ir oflag , +then two additional arguments must be supplied. +the +.i mode +argument specifies the permissions to be placed on the new queue, +as for +.br open (2). +(symbolic definitions for the permissions bits can be obtained by including +.ir .) +the permissions settings are masked against the process umask. +.pp +the fields of the +.ir "struct mq_attr" +pointed to +.i attr +specify the maximum number of messages and +the maximum size of messages that the queue will allow. +this structure is defined as follows: +.pp +.in +4n +.ex +struct mq_attr { + long mq_flags; /* flags (ignored for mq_open()) */ + long mq_maxmsg; /* max. # of messages on queue */ + long mq_msgsize; /* max. message size (bytes) */ + long mq_curmsgs; /* # of messages currently in queue + (ignored for mq_open()) */ +}; +.ee +.in +.pp +only the +.i mq_maxmsg +and +.i mq_msgsize +fields are employed when calling +.br mq_open (); +the values in the remaining fields are ignored. +.pp +if +.i attr +is null, then the queue is created with implementation-defined +default attributes. +since linux 3.5, two +.i /proc +files can be used to control these defaults; see +.br mq_overview (7) +for details. +.sh return value +on success, +.br mq_open () +returns a message queue descriptor for use by other +message queue functions. +on error, +.br mq_open () +returns +.ir "(mqd_t)\ \-1", +with +.i errno +set to indicate the error. +.sh errors +.tp +.b eacces +the queue exists, but the caller does not have permission to +open it in the specified mode. +.tp +.b eacces +.i name +contained more than one slash. +.\" note that this isn't consistent with the same case for sem_open() +.tp +.b eexist +both +.b o_creat +and +.b o_excl +were specified in +.ir oflag , +but a queue with this +.i name +already exists. +.tp +.b einval +.\" glibc checks whether the name starts with a "/" and if not, +.\" gives this error +.i name +doesn't follow the format in +.br mq_overview (7). +.tp +.b einval +.b o_creat +was specified in +.ir oflag , +and +.i attr +was not null, but +.i attr\->mq_maxmsg +or +.i attr\->mq_msqsize +was invalid. +both of these fields must be greater than zero. +in a process that is unprivileged (does not have the +.b cap_sys_resource +capability), +.i attr\->mq_maxmsg +must be less than or equal to the +.i msg_max +limit, and +.i attr\->mq_msgsize +must be less than or equal to the +.i msgsize_max +limit. +in addition, even in a privileged process, +.i attr\->mq_maxmsg +cannot exceed the +.b hard_max +limit. +(see +.br mq_overview (7) +for details of these limits.) +.tp +.b emfile +the per-process limit on the number of open file +and message queue descriptors has been reached +(see the description of +.br rlimit_nofile +in +.br getrlimit (2)). +.tp +.b enametoolong +.i name +was too long. +.tp +.b enfile +the system-wide limit on the total number of open files +and message queues has been reached. +.tp +.b enoent +the +.b o_creat +flag was not specified in +.ir oflag , +and no queue with this +.i name +exists. +.tp +.b enoent +.i name +was just "/" followed by no other characters. +.\" note that this isn't consistent with the same case for sem_open() +.tp +.b enomem +insufficient memory. +.tp +.b enospc +insufficient space for the creation of a new message queue. +this probably occurred because the +.i queues_max +limit was encountered; see +.br mq_overview (7). +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br mq_open () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +.ss c library/kernel differences +the +.br mq_open () +library function is implemented on top of a system call of the same name. +the library function performs the check that the +.i name +starts with a slash (/), giving the +.b einval +error if it does not. +the kernel system call expects +.i name +to contain no preceding slash, +so the c library function passes +.i name +without the preceding slash (i.e., +.ir name+1 ) +to the system call. +.sh bugs +in kernels before 2.6.14, +the process umask was not applied to the permissions specified in +.ir mode . +.sh see also +.br mq_close (3), +.br mq_getattr (3), +.br mq_notify (3), +.br mq_receive (3), +.br mq_send (3), +.br mq_unlink (3), +.br mq_overview (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1980, 1991 the regents of the university of california. +.\" all rights reserved. +.\" +.\" %%%license_start(bsd_4_clause_ucb) +.\" redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. all advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" this product includes software developed by the university of +.\" california, berkeley and its contributors. +.\" 4. neither the name of the university nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" this software is provided by the regents and contributors ``as is'' and +.\" any express or implied warranties, including, but not limited to, the +.\" implied warranties of merchantability and fitness for a particular purpose +.\" are disclaimed. in no event shall the regents or contributors be liable +.\" for any direct, indirect, incidental, special, exemplary, or consequential +.\" damages (including, but not limited to, procurement of substitute goods +.\" or services; loss of use, data, or profits; or business interruption) +.\" however caused and on any theory of liability, whether in contract, strict +.\" liability, or tort (including negligence or otherwise) arising in any way +.\" out of the use of this software, even if advised of the possibility of +.\" such damage. +.\" %%%license_end +.\" +.\" @(#)getpriority.2 6.9 (berkeley) 3/10/91 +.\" +.\" modified 1993-07-24 by rik faith +.\" modified 1996-07-01 by andries brouwer +.\" modified 1996-11-06 by eric s. raymond +.\" modified 2001-10-21 by michael kerrisk +.\" corrected statement under eperm to clarify privileges required +.\" modified 2002-06-21 by michael kerrisk +.\" clarified meaning of 0 value for 'who' argument +.\" modified 2004-05-27 by michael kerrisk +.\" +.th getpriority 2 2021-08-27 "linux" "linux programmer's manual" +.sh name +getpriority, setpriority \- get/set program scheduling priority +.sh synopsis +.nf +.b #include +.pp +.bi "int getpriority(int " which ", id_t " who ); +.bi "int setpriority(int " which ", id_t " who ", int " prio ); +.fi +.sh description +the scheduling priority of the process, process group, or user, as +indicated by +.i which +and +.i who +is obtained with the +.br getpriority () +call and set with the +.br setpriority () +call. +the process attribute dealt with by these system calls is +the same attribute (also known as the "nice" value) that is dealt with by +.br nice (2). +.pp +the value +.i which +is one of +.br prio_process , +.br prio_pgrp , +or +.br prio_user , +and +.i who +is interpreted relative to +.i which +(a process identifier for +.br prio_process , +process group +identifier for +.br prio_pgrp , +and a user id for +.br prio_user ). +a zero value for +.i who +denotes (respectively) the calling process, the process group of the +calling process, or the real user id of the calling process. +.pp +the +.i prio +argument is a value in the range \-20 to 19 (but see notes below), +with \-20 being the highest priority and 19 being the lowest priority. +attempts to set a priority outside this range +are silently clamped to the range. +the default priority is 0; +lower values give a process a higher scheduling priority. +.pp +the +.br getpriority () +call returns the highest priority (lowest numerical value) +enjoyed by any of the specified processes. +the +.br setpriority () +call sets the priorities of all of the specified processes +to the specified value. +.pp +traditionally, only a privileged process could lower the nice value +(i.e., set a higher priority). +however, since linux 2.6.12, an unprivileged process can decrease +the nice value of a target process that has a suitable +.br rlimit_nice +soft limit; see +.br getrlimit (2) +for details. +.sh return value +on success, +.br getpriority () +returns the calling thread's nice value, which may be a negative number. +on error, it returns \-1 and sets +.i errno +to indicate the error. +.pp +since a successful call to +.br getpriority () +can legitimately return the value \-1, it is necessary +to clear +.i errno +prior to the +call, then check +.i errno +afterward to determine +if \-1 is an error or a legitimate value. +.pp +.br setpriority () +returns 0 on success. +on failure, it returns \-1 and sets +.i errno +to indicate the error. +.sh errors +.tp +.b eacces +the caller attempted to set a lower nice value +(i.e., a higher process priority), but did not +have the required privilege (on linux: did not have the +.b cap_sys_nice +capability). +.tp +.b einval +.i which +was not one of +.br prio_process , +.br prio_pgrp , +or +.br prio_user . +.tp +.b eperm +a process was located, but its effective user id did not match +either the effective or the real user id of the caller, +and was not privileged (on linux: did not have the +.b cap_sys_nice +capability). +but see notes below. +.tp +.b esrch +no process was located using the +.i which +and +.i who +values specified. +.sh conforming to +posix.1-2001, posix.1-2008, +svr4, 4.4bsd (these interfaces first appeared in 4.2bsd). +.sh notes +for further details on the nice value, see +.br sched (7). +.pp +.ir note : +the addition of the "autogroup" feature in linux 2.6.38 means that +the nice value no longer has its traditional effect in many circumstances. +for details, see +.br sched (7). +.pp +a child created by +.br fork (2) +inherits its parent's nice value. +the nice value is preserved across +.br execve (2). +.pp +the details on the condition for +.b eperm +depend on the system. +the above description is what posix.1-2001 says, and seems to be followed on +all system\ v-like systems. +linux kernels before 2.6.12 required the real or +effective user id of the caller to match +the real user of the process \fiwho\fp (instead of its effective user id). +linux 2.6.12 and later require +the effective user id of the caller to match +the real or effective user id of the process \fiwho\fp. +all bsd-like systems (sunos 4.1.3, ultrix 4.2, +4.3bsd, freebsd 4.3, openbsd-2.5, ...) behave in the same +manner as linux 2.6.12 and later. +.\" +.ss c library/kernel differences +within the kernel, nice values are actually represented +using the range 40..1 +(since negative numbers are error codes) and these are the values +employed by the +.br setpriority () +and +.br getpriority () +system calls. +the glibc wrapper functions for these system calls handle the +translations between the user-land and kernel representations +of the nice value according to the formula +.ir "unice\ =\ 20\ \-\ knice" . +(thus, the kernel's 40..1 range corresponds to the +range \-20..19 as seen by user space.) +.sh bugs +according to posix, the nice value is a per-process setting. +however, under the current linux/nptl implementation of posix threads, +the nice value is a per-thread attribute: +different threads in the same process can have different nice values. +portable applications should avoid relying on the linux behavior, +which may be made standards conformant in the future. +.sh see also +.br nice (1), +.br renice (1), +.br fork (2), +.br capabilities (7), +.br sched (7) +.pp +.i documentation/scheduler/sched\-nice\-design.txt +in the linux kernel source tree (since linux 2.6.23) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man7/system_data_types.7 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" and copyright (c) 2020 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sat jul 24 17:59:03 1993 by rik faith (faith@cs.unc.edu) +.th strsignal 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +strsignal, sigabbrev_np, sigdescr_np, sys_siglist \- return string describing signal +.sh synopsis +.nf +.b #include +.pp +.bi "char *strsignal(int " sig ); +.bi "const char *sigdescr_np(int " sig ); +.bi "const char *sigabbrev_np(int " sig ); +.pp +.bi "extern const char *const " sys_siglist []; +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br sigabbrev_np (), +.br sigdescr_np (): +.nf + _gnu_source +.fi +.pp +.br strsignal (): +.nf + from glibc 2.10 to 2.31: + _posix_c_source >= 200809l + before glibc 2.10: + _gnu_source +.fi +.pp +.ir sys_siglist : +.nf + since glibc 2.19: + _default_source + glibc 2.19 and earlier: + _bsd_source +.fi +.sh description +the +.br strsignal () +function returns a string describing the signal +number passed in the argument +.ir sig . +the string can be used only until the next call to +.br strsignal (). +the string returned by +.br strsignal () +is localized according to the +.b lc_messages +category in the current locale. +.pp +the +.br sigdescr_np () +function returns a string describing the signal +number passed in the argument +.ir sig . +unlike +.br strsignal () +this string is not influenced by the current locale. +.pp +the +.br sigabbrev_np () +function returns the abbreviated name of the signal, +.ir sig . +for example, given the value +.br sigint , +it returns the string "int". +.pp +the (deprecated) array +.i sys_siglist +holds the signal description strings +indexed by signal number. +the +.br strsignal () +or the +.br sigdescr_np () +function should be used instead of this array; see also versions. +.sh return value +the +.br strsignal () +function returns the appropriate description +string, or an unknown signal message if the signal number is invalid. +on some systems (but not on linux), null may instead be +returned for an invalid signal number. +.pp +the +.br sigdescr_np () +and +.br sigabbrev_np () +functions return the appropriate description string. +the returned string is statically allocated and valid for +the lifetime of the program. +these functions return null for an invalid signal number. +.sh versions +.br sigdescr_np () +and +.br sigabbrev_np () +first appeared in glibc 2.32. +.pp +starting with version 2.32, +.\" glibc commit b1ccfc061feee9ce616444ded8e1cd5acf9fa97f +the +.i sys_siglist +symbol is no longer exported by glibc. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lb lb lbx +l l l. +interface attribute value +t{ +.br strsignal () +t} thread safety t{ +mt-unsafe race:strsignal locale +t} +t{ +.br sigdescr_np (), +.br sigabbrev_np () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +.br strsignal (): +posix.1-2008. +present on solaris and the bsds. +.pp +.br sigdescr_np () +and +.br sigdabbrev_np () +are gnu extensions. +.pp +.i sys_siglist +is nonstandard, but present on many other systems. +.sh notes +.br sigdescr_np () +and +.br sigdabbrev_np () +are thread-safe and async-signal-safe. +.sh see also +.br psignal (3), +.br strerror (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/puts.3 + +.so man2/chown.2 + +.so man3/termios.3 + +.so man2/timerfd_create.2 + +.\" copyright (c) 1996 andries brouwer (aeb@cwi.nl) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" moved to man3, aeb, 980612 +.\" +.th ulimit 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +ulimit \- get and set user limits +.sh synopsis +.nf +.b #include +.pp +.bi "long ulimit(int " cmd ", long " newlimit ); +.fi +.sh description +warning: this routine is obsolete. +use +.br getrlimit (2), +.br setrlimit (2), +and +.br sysconf (3) +instead. +for the shell command +.br ulimit , +see +.br bash (1). +.pp +the +.br ulimit () +call will get or set some limit for the calling process. +the +.i cmd +argument can have one of the following values. +.tp +.b ul_getfsize +return the limit on the size of a file, in units of 512 bytes. +.tp +.b ul_setfsize +set the limit on the size of a file. +.tp +.b 3 +(not implemented for linux.) +return the maximum possible address of the data segment. +.tp +.b 4 +(implemented but no symbolic constant provided.) +return the maximum number of files that the calling process can open. +.sh return value +on success, +.br ulimit () +returns a nonnegative value. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eperm +an unprivileged process tried to increase a limit. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br ulimit () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +svr4, posix.1-2001. +posix.1-2008 marks +.br ulimit () +as obsolete. +.sh see also +.br bash (1), +.br getrlimit (2), +.br setrlimit (2), +.br sysconf (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sat jul 24 18:25:21 1993 by rik faith (faith@cs.unc.edu) +.\" +.th seekdir 3 2021-03-22 "" "linux programmer's manual" +.sh name +seekdir \- set the position of the next readdir() call in the directory +stream. +.sh synopsis +.nf +.b #include +.pp +.bi "void seekdir(dir *" dirp ", long " loc ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br seekdir (): +.nf + _xopen_source + || /* glibc since 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.sh description +the +.br seekdir () +function sets the location in the directory stream +from which the next +.br readdir (2) +call will start. +the +.i loc +argument should be a value returned by a previous call to +.br telldir (3). +.sh return value +the +.br seekdir () +function returns no value. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br seekdir () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, 4.3bsd. +.sh notes +in glibc up to version 2.1.1, the type of the +.i loc +argument was +.ir off_t . +posix.1-2001 specifies +.ir long , +and this is the type used since glibc 2.1.2. +see +.br telldir (3) +for information on why you should be careful in making any +assumptions about the value in this argument. +.sh see also +.br lseek (2), +.br closedir (3), +.br opendir (3), +.br readdir (3), +.br rewinddir (3), +.br scandir (3), +.br telldir (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1990, 1993 +.\" the regents of the university of california. all rights reserved. +.\" +.\" %%%license_start(bsd_4_clause_ucb) +.\" redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. all advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" this product includes software developed by the university of +.\" california, berkeley and its contributors. +.\" 4. neither the name of the university nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" this software is provided by the regents and contributors ``as is'' and +.\" any express or implied warranties, including, but not limited to, the +.\" implied warranties of merchantability and fitness for a particular purpose +.\" are disclaimed. in no event shall the regents or contributors be liable +.\" for any direct, indirect, incidental, special, exemplary, or consequential +.\" damages (including, but not limited to, procurement of substitute goods +.\" or services; loss of use, data, or profits; or business interruption) +.\" however caused and on any theory of liability, whether in contract, strict +.\" liability, or tort (including negligence or otherwise) arising in any way +.\" out of the use of this software, even if advised of the possibility of +.\" such damage. +.\" %%%license_end +.\" +.\" @(#)btree.3 8.4 (berkeley) 8/18/94 +.\" +.th btree 3 2020-12-21 "" "linux programmer's manual" +.\".uc 7 +.sh name +btree \- btree database access method +.sh synopsis +.nf +.ft b +#include +#include +.ft r +.fi +.sh description +.ir "note well" : +this page documents interfaces provided in glibc up until version 2.1. +since version 2.2, glibc no longer provides these interfaces. +probably, you are looking for the apis provided by the +.i libdb +library instead. +.pp +the routine +.br dbopen (3) +is the library interface to database files. +one of the supported file formats is btree files. +the general description of the database access methods is in +.br dbopen (3), +this manual page describes only the btree-specific information. +.pp +the btree data structure is a sorted, balanced tree structure storing +associated key/data pairs. +.pp +the btree access-method-specific data structure provided to +.br dbopen (3) +is defined in the +.i +include file as follows: +.pp +.in +4n +.ex +typedef struct { + unsigned long flags; + unsigned int cachesize; + int maxkeypage; + int minkeypage; + unsigned int psize; + int (*compare)(const dbt *key1, const dbt *key2); + size_t (*prefix)(const dbt *key1, const dbt *key2); + int lorder; +} btreeinfo; +.ee +.in +.pp +the elements of this structure are as follows: +.tp +.i flags +the flag value is specified by oring any of the following values: +.rs +.tp +.b r_dup +permit duplicate keys in the tree, that is, +permit insertion if the key to be +inserted already exists in the tree. +the default behavior, as described in +.br dbopen (3), +is to overwrite a matching key when inserting a new key or to fail if +the +.b r_nooverwrite +flag is specified. +the +.b r_dup +flag is overridden by the +.b r_nooverwrite +flag, and if the +.b r_nooverwrite +flag is specified, attempts to insert duplicate keys into +the tree will fail. +.ip +if the database contains duplicate keys, the order of retrieval of +key/data pairs is undefined if the +.i get +routine is used, however, +.i seq +routine calls with the +.b r_cursor +flag set will always return the logical +"first" of any group of duplicate keys. +.re +.tp +.i cachesize +a suggested maximum size (in bytes) of the memory cache. +this value is +.i only +advisory, and the access method will allocate more memory rather than fail. +since every search examines the root page of the tree, caching the most +recently used pages substantially improves access time. +in addition, physical writes are delayed as long as possible, so a moderate +cache can reduce the number of i/o operations significantly. +obviously, using a cache increases (but only increases) the likelihood of +corruption or lost data if the system crashes while a tree is being modified. +if +.i cachesize +is 0 (no size is specified), a default cache is used. +.tp +.i maxkeypage +the maximum number of keys which will be stored on any single page. +not currently implemented. +.\" the maximum number of keys which will be stored on any single page. +.\" because of the way the btree data structure works, +.\" .i maxkeypage +.\" must always be greater than or equal to 2. +.\" if +.\" .i maxkeypage +.\" is 0 (no maximum number of keys is specified), the page fill factor is +.\" made as large as possible (which is almost invariably what is wanted). +.tp +.i minkeypage +the minimum number of keys which will be stored on any single page. +this value is used to determine which keys will be stored on overflow +pages, that is, if a key or data item is longer than the pagesize divided +by the minkeypage value, it will be stored on overflow pages instead +of in the page itself. +if +.i minkeypage +is 0 (no minimum number of keys is specified), a value of 2 is used. +.tp +.i psize +page size is the size (in bytes) of the pages used for nodes in the tree. +the minimum page size is 512 bytes and the maximum page size is 64\ kib. +if +.i psize +is 0 (no page size is specified), a page size is chosen based on the +underlying filesystem i/o block size. +.tp +.i compare +compare is the key comparison function. +it must return an integer less than, equal to, or greater than zero if the +first key argument is considered to be respectively less than, equal to, +or greater than the second key argument. +the same comparison function must be used on a given tree every time it +is opened. +if +.i compare +is null (no comparison function is specified), the keys are compared +lexically, with shorter keys considered less than longer keys. +.tp +.i prefix +prefix is the prefix comparison function. +if specified, this routine must return the number of bytes of the second key +argument which are necessary to determine that it is greater than the first +key argument. +if the keys are equal, the key length should be returned. +note, the usefulness of this routine is very data-dependent, but, in some +data sets can produce significantly reduced tree sizes and search times. +if +.i prefix +is null (no prefix function is specified), +.i and +no comparison function is specified, a default lexical comparison routine +is used. +if +.i prefix +is null and a comparison routine is specified, no prefix comparison is +done. +.tp +.i lorder +the byte order for integers in the stored database metadata. +the number should represent the order as an integer; for example, +big endian order would be the number 4,321. +if +.i lorder +is 0 (no order is specified), the current host order is used. +.pp +if the file already exists (and the +.b o_trunc +flag is not specified), the +values specified for the arguments +.ir flags , +.ir lorder , +and +.i psize +are ignored +in favor of the values used when the tree was created. +.pp +forward sequential scans of a tree are from the least key to the greatest. +.pp +space freed up by deleting key/data pairs from the tree is never reclaimed, +although it is normally made available for reuse. +this means that the btree storage structure is grow-only. +the only solutions are to avoid excessive deletions, or to create a fresh +tree periodically from a scan of an existing one. +.pp +searches, insertions, and deletions in a btree will all complete in +o lg base n where base is the average fill factor. +often, inserting ordered data into btrees results in a low fill factor. +this implementation has been modified to make ordered insertion the best +case, resulting in a much better than normal page fill factor. +.sh errors +the +.i btree +access method routines may fail and set +.i errno +for any of the errors specified for the library routine +.br dbopen (3). +.sh bugs +only big and little endian byte order is supported. +.sh see also +.br dbopen (3), +.br hash (3), +.br mpool (3), +.br recno (3) +.pp +.ir "the ubiquitous b-tree" , +douglas comer, acm comput. surv. 11, 2 (june 1979), 121-138. +.pp +.ir "prefix b-trees" , +bayer and unterauer, acm transactions on database systems, vol. 2, 1 +(march 1977), 11-26. +.pp +.ir "the art of computer programming vol. 3: sorting and searching" , +d.e. knuth, 1968, pp 471-480. +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" this manpage is copyright (c) 1996 michael haardt. +.\" updates nov 1998, andries brouwer +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.th mouse 4 2020-08-13 "linux" "linux programmer's manual" +.sh name +mouse \- serial mouse interface +.sh configuration +serial mice are connected to a serial rs232/v24 dialout line, see +.br ttys (4) +for a description. +.sh description +.ss introduction +the pinout of the usual 9 pin plug as used for serial mice is: +.pp +.ts +center; +r c l. +pin name used for +2 rx data +3 tx \-12 v, imax = 10 ma +4 dtr +12 v, imax = 10 ma +7 rts +12 v, imax = 10 ma +5 gnd ground +.te +.pp +this is the specification, in fact 9 v suffices with most mice. +.pp +the mouse driver can recognize a mouse by dropping rts to low and raising +it again. +about 14 ms later the mouse will send 0x4d (\(aqm\(aq) on the data line. +after a further 63 ms, a microsoft-compatible 3-button mouse will send +0x33 (\(aq3\(aq). +.pp +the relative mouse movement is sent as +.i dx +(positive means right) +and +.i dy +(positive means down). +various mice can operate at different speeds. +to select speeds, cycle through the +speeds 9600, 4800, 2400, and 1200 bit/s, each time writing the two characters +from the table below and waiting 0.1 seconds. +the following table shows available speeds and the strings that select them: +.pp +.ts +center; +l l. +bit/s string +9600 *q +4800 *p +2400 *o +1200 *n +.te +.pp +the first byte of a data packet can be used for synchronization purposes. +.ss microsoft protocol +the +.b microsoft +protocol uses 1 start bit, 7 data bits, no parity +and one stop bit at the speed of 1200 bits/sec. +data is sent to rxd in 3-byte packets. +the +.ir dx +and +.i dy +movements are sent as +two's-complement, +.i lb +.ri ( rb ) +are set when the left (right) +button is pressed: +.pp +.ts +center; +r c c c c c c c. +byte d6 d5 d4 d3 d2 d1 d0 +1 1 lb rb dy7 dy6 dx7 dx6 +2 0 dx5 dx4 dx3 dx2 dx1 dx0 +3 0 dy5 dy4 dy3 dy2 dy1 dy0 +.te +.ss 3-button microsoft protocol +original microsoft mice only have two buttons. +however, there are some +three button mice which also use the microsoft protocol. +pressing or +releasing the middle button is reported by sending a packet with zero +movement and no buttons pressed. +(thus, unlike for the other two buttons, the status of the middle +button is not reported in each packet.) +.ss logitech protocol +logitech serial 3-button mice use a different extension of the +microsoft protocol: when the middle button is up, the above 3-byte +packet is sent. +when the middle button is down a 4-byte packet is +sent, where the 4th byte has value 0x20 (or at least has the 0x20 +bit set). +in particular, a press of the middle button is reported +as 0,0,0,0x20 when no other buttons are down. +.ss mousesystems protocol +the +.b mousesystems +protocol uses 1 start bit, 8 data bits, no parity, +and two stop bits at the speed of 1200 bits/sec. +data is sent to rxd in +5-byte packets. +.i dx +is sent as the sum of the two two's-complement +values, +.i dy +is send as negated sum of the two two's-complement +values. +.i lb +.ri ( mb , +.ir rb ) +are cleared when the left (middle, +right) button is pressed: +.pp +.ts +center; +r c c c c c c c c. +byte d7 d6 d5 d4 d3 d2 d1 d0 +1 1 0 0 0 0 lb mb rb +2 0 dxa6 dxa5 dxa4 dxa3 dxa2 dxa1 dxa0 +3 0 dya6 dya5 dya4 dya3 dya2 dya1 dya0 +4 0 dxb6 dxb5 dxb4 dxb3 dxb2 dxb1 dxb0 +5 0 dyb6 dyb5 dyb4 dyb3 dyb2 dyb1 dyb0 +.te +.pp +bytes 4 and 5 describe the change that occurred since bytes 2 and 3 +were transmitted. +.ss sun protocol +the +.b sun +protocol is the 3-byte version of the above 5-byte +mousesystems protocol: the last two bytes are not sent. +.ss mm protocol +the +.b mm +protocol uses 1 start bit, 8 data bits, odd parity, and one +stop bit at the speed of 1200 bits/sec. +data is sent to rxd in 3-byte +packets. +.i dx +and +.i dy +are sent as single signed values, the +sign bit indicating a negative value. +.i lb +.ri ( mb , +.ir rb ) +are +set when the left (middle, right) button is pressed: +.pp +.ts +center; +r c c c c c c c c. +byte d7 d6 d5 d4 d3 d2 d1 d0 +1 1 0 0 dxs dys lb mb rb +2 0 dx6 dx5 dx4 dx3 dx2 dx1 dx0 +3 0 dy6 dy5 dy4 dy3 dy2 dy1 dy0 +.te +.sh files +.tp +.i /dev/mouse +a commonly used symbolic link pointing to a mouse device. +.sh see also +.br ttys (4), +.br gpm (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1993 michael haardt (michael@cantor.informatik.rwth-aachen.de) +.\" and 1994,1995 alain knaff (alain.knaff@imag.fr) +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" modified, sun feb 26 15:00:02 1995, faith@cs.unc.edu +.\" +.th fd 4 2020-08-13 "linux" "linux programmer's manual" +.sh name +fd \- floppy disk device +.sh configuration +floppy drives are block devices with major number 2. +typically they +are owned by +root:floppy +(i.e., user root, group floppy) and have +either mode 0660 (access checking via group membership) or mode 0666 +(everybody has access). +the minor +numbers encode the device type, drive number, and controller number. +for each device type (that is, combination of density and track count) +there is a base minor number. +to this base number, add the drive's +number on its controller and 128 if the drive is on the secondary +controller. +in the following device tables, \fin\fp represents the +drive number. +.pp +\fbwarning: if you use formats with more tracks +than supported by your drive, you may cause it mechanical damage.\fp +trying once if more tracks than the usual 40/80 are supported should not +damage it, but no warranty is given for that. +if you are not sure, don't create device +entries for those formats, so as to prevent their usage. +.pp +drive-independent device files which automatically detect the media +format and capacity: +.ts +l c +l c. +name base + minor # +_ +\fbfd\fp\fin\fp 0 +.te +.pp +5.25 inch double-density device files: +.ts +lw(1i) l l l l c +lw(1i) c c c c c. +name capacity cyl. sect. heads base + kib minor # +_ +\fbfd\fp\fin\fp\fbd360\fp 360 40 9 2 4 +.te +.pp +5.25 inch high-density device files: +.ts +lw(1i) l l l l c +lw(1i) c c c c c. +name capacity cyl. sect. heads base + kib minor # +_ +\fbfd\fp\fin\fp\fbh360\fp 360 40 9 2 20 +\fbfd\fp\fin\fp\fbh410\fp 410 41 10 2 48 +\fbfd\fp\fin\fp\fbh420\fp 420 42 10 2 64 +\fbfd\fp\fin\fp\fbh720\fp 720 80 9 2 24 +\fbfd\fp\fin\fp\fbh880\fp 880 80 11 2 80 +\fbfd\fp\fin\fp\fbh1200\fp 1200 80 15 2 8 +\fbfd\fp\fin\fp\fbh1440\fp 1440 80 18 2 40 +\fbfd\fp\fin\fp\fbh1476\fp 1476 82 18 2 56 +\fbfd\fp\fin\fp\fbh1494\fp 1494 83 18 2 72 +\fbfd\fp\fin\fp\fbh1600\fp 1600 80 20 2 92 +.te +.pp +3.5 inch double-density device files: +.ts +lw(1i) l l l l c +lw(1i) c c c c c. +name capacity cyl. sect. heads base + kib minor # +_ +\fbfd\fp\fin\fp\fbu360\fp 360 80 9 1 12 +\fbfd\fp\fin\fp\fbu720\fp 720 80 9 2 16 +\fbfd\fp\fin\fp\fbu800\fp 800 80 10 2 120 +\fbfd\fp\fin\fp\fbu1040\fp 1040 80 13 2 84 +\fbfd\fp\fin\fp\fbu1120\fp 1120 80 14 2 88 +.te +.pp +3.5 inch high-density device files: +.ts +lw(1i) l l l l c +lw(1i) c c c c c. +name capacity cyl. sect. heads base + kib minor # +_ +\fbfd\fp\fin\fp\fbu360\fp 360 40 9 2 12 +\fbfd\fp\fin\fp\fbu720\fp 720 80 9 2 16 +\fbfd\fp\fin\fp\fbu820\fp 820 82 10 2 52 +\fbfd\fp\fin\fp\fbu830\fp 830 83 10 2 68 +\fbfd\fp\fin\fp\fbu1440\fp 1440 80 18 2 28 +\fbfd\fp\fin\fp\fbu1600\fp 1600 80 20 2 124 +\fbfd\fp\fin\fp\fbu1680\fp 1680 80 21 2 44 +\fbfd\fp\fin\fp\fbu1722\fp 1722 82 21 2 60 +\fbfd\fp\fin\fp\fbu1743\fp 1743 83 21 2 76 +\fbfd\fp\fin\fp\fbu1760\fp 1760 80 22 2 96 +\fbfd\fp\fin\fp\fbu1840\fp 1840 80 23 2 116 +\fbfd\fp\fin\fp\fbu1920\fp 1920 80 24 2 100 +.te +.pp +3.5 inch extra-density device files: +.ts +lw(1i) l l l l c +lw(1i) c c c c c. +name capacity cyl. sect. heads base + kib minor # +_ +\fbfd\fp\fin\fp\fbu2880\fp 2880 80 36 2 32 +\fbfd\fp\fin\fp\fbcompaq\fp 2880 80 36 2 36 +\fbfd\fp\fin\fp\fbu3200\fp 3200 80 40 2 104 +\fbfd\fp\fin\fp\fbu3520\fp 3520 80 44 2 108 +\fbfd\fp\fin\fp\fbu3840\fp 3840 80 48 2 112 +.te +.sh description +\fbfd\fp special files access the floppy disk drives in raw mode. +the following +.br ioctl (2) +calls are supported by \fbfd\fp devices: +.ip \fbfdclrprm\fp +clears the media information of a drive (geometry of disk in drive). +.ip \fbfdsetprm\fp +sets the media information of a drive. +the media information will be +lost when the media is changed. +.ip \fbfddefprm\fp +sets the media information of a drive (geometry of disk in drive). +the media information will not be lost when the media is changed. +this will disable autodetection. +in order to reenable autodetection, you +have to issue an \fbfdclrprm\fp. +.ip \fbfdgetdrvtyp\fp +returns the type of a drive (name parameter). +for formats which work +in several drive types, \fbfdgetdrvtyp\fp returns a name which is +appropriate for the oldest drive type which supports this format. +.ip \fbfdflush\fp +invalidates the buffer cache for the given drive. +.ip \fbfdsetmaxerrs\fp +sets the error thresholds for reporting errors, aborting the operation, +recalibrating, resetting, and reading sector by sector. +.ip \fbfdsetmaxerrs\fp +gets the current error thresholds. +.ip \fbfdgetdrvtyp\fp +gets the internal name of the drive. +.ip \fbfdwerrorclr\fp +clears the write error statistics. +.ip \fbfdwerrorget\fp +reads the write error statistics. +these include the total number of +write errors, the location and disk of the first write error, and the +location and disk of the last write error. +disks are identified by a +generation number which is incremented at (almost) each disk change. +.ip \fbfdtwaddle\fp +switch the drive motor off for a few microseconds. +this might be +needed in order to access a disk whose sectors are too close together. +.ip \fbfdsetdrvprm\fp +sets various drive parameters. +.ip \fbfdgetdrvprm\fp +reads these parameters back. +.ip \fbfdgetdrvstat\fp +gets the cached drive state (disk changed, write protected et al.) +.ip \fbfdpolldrvstat\fp +polls the drive and return its state. +.ip \fbfdgetfdcstat\fp +gets the floppy controller state. +.ip \fbfdreset\fp +resets the floppy controller under certain conditions. +.ip \fbfdrawcmd\fp +sends a raw command to the floppy controller. +.pp +for more precise information, consult also the \fi\fp and +\fi\fp include files, as well as the +.br floppycontrol (1) +manual page. +.sh files +.i /dev/fd* +.sh notes +the various formats permit reading and writing many types of disks. +however, if a floppy is formatted with an inter-sector gap that is too small, +performance may drop, +to the point of needing a few seconds to access an entire track. +to prevent this, use interleaved formats. +.pp +it is not possible to +read floppies which are formatted using gcr (group code recording), +which is used by apple ii and macintosh computers (800k disks). +.pp +reading floppies which are hard sectored (one hole per sector, with +the index hole being a little skewed) is not supported. +this used to be common with older 8-inch floppies. +.\" .sh authors +.\" alain knaff (alain.knaff@imag.fr), david niemi +.\" (niemidc@clark.net), bill broadhurst (bbroad@netcom.com). +.sh see also +.br chown (1), +.br floppycontrol (1), +.br getfdprm (1), +.br mknod (1), +.br superformat (1), +.br mount (8), +.br setfdprm (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th clock_nanosleep 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +clock_nanosleep \- high-resolution sleep with specifiable clock +.sh synopsis +.b #include +.nf +.pp +.bi "int clock_nanosleep(clockid_t " clockid ", int " flags , +.bi " const struct timespec *" request , +.bi " struct timespec *" remain ); +.fi +.pp +link with \fi\-lrt\fp (only for glibc versions before 2.17). +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br clock_nanosleep (): +.nf + _posix_c_source >= 200112l +.fi +.sh description +like +.br nanosleep (2), +.br clock_nanosleep () +allows the calling thread to sleep for an interval specified +with nanosecond precision. +it differs in allowing the caller to select the clock against +which the sleep interval is to be measured, +and in allowing the sleep interval to be specified as +either an absolute or a relative value. +.pp +the time values passed to and returned by this call are specified using +.i timespec +structures, defined as follows: +.pp +.in +4n +.ex +struct timespec { + time_t tv_sec; /* seconds */ + long tv_nsec; /* nanoseconds [0 .. 999999999] */ +}; +.ee +.in +.pp +the +.i clockid +argument specifies the clock against which the sleep interval +is to be measured. +this argument can have one of the following values: +.\" look in time/posix-timers.c (kernel 5.6 sources) for the +.\" 'struct k_clock' structures that have an 'nsleep' method +.tp +.br clock_realtime +a settable system-wide real-time clock. +.tp +.br clock_tai " (since linux 3.10)" +a system-wide clock derived from wall-clock time but ignoring leap seconds. +.tp +.br clock_monotonic +a nonsettable, monotonically increasing clock that measures time +since some unspecified point in the past that does not change after +system startup. +.\" on linux this clock measures time since boot. +.tp +.br clock_bootime " (since linux 2.6.39)" +identical to +.br clock_monotonic , +except that it also includes any time that the system is suspended. +.tp +.br clock_process_cputime_id +a settable per-process clock that measures cpu time consumed +by all threads in the process. +.\" there is some trickery between glibc and the kernel +.\" to deal with the clock_process_cputime_id case. +.pp +see +.br clock_getres (2) +for further details on these clocks. +in addition, the cpu clock ids returned by +.br clock_getcpuclockid (3) +and +.br pthread_getcpuclockid (3) +can also be passed in +.ir clockid . +.\" sleeping against clock_realtime_alarm and clock_boottime_alarm +.\" is also possible (tested), with cap_wake_alarm, but i'm not +.\" sure if this is useful or needs to be documented. +.pp +if +.i flags +is 0, then the value specified in +.i request +is interpreted as an interval relative to the current +value of the clock specified by +.ir clockid . +.pp +if +.i flags +is +.br timer_abstime , +then +.i request +is interpreted as an absolute time as measured by the clock, +.ir clockid . +if +.i request +is less than or equal to the current value of the clock, +then +.br clock_nanosleep () +returns immediately without suspending the calling thread. +.pp +.br clock_nanosleep () +suspends the execution of the calling thread +until either at least the time specified by +.ir request +has elapsed, +or a signal is delivered that causes a signal handler to be called or +that terminates the process. +.pp +if the call is interrupted by a signal handler, +.br clock_nanosleep () +fails with the error +.br eintr . +in addition, if +.i remain +is not null, and +.i flags +was not +.br timer_abstime , +it returns the remaining unslept time in +.ir remain . +this value can then be used to call +.br clock_nanosleep () +again and complete a (relative) sleep. +.sh return value +on successfully sleeping for the requested interval, +.br clock_nanosleep () +returns 0. +if the call is interrupted by a signal handler or encounters an error, +then it returns one of the positive error number listed in errors. +.sh errors +.tp +.b efault +.i request +or +.i remain +specified an invalid address. +.tp +.b eintr +the sleep was interrupted by a signal handler; see +.br signal (7). +.tp +.b einval +the value in the +.i tv_nsec +field was not in the range 0 to 999999999 or +.i tv_sec +was negative. +.tp +.b einval +.i clockid +was invalid. +.rb ( clock_thread_cputime_id +is not a permitted value for +.ir clockid .) +.tp +.b enotsup +the kernel does not support sleeping against this +.ir clockid . +.sh versions +the +.br clock_nanosleep () +system call first appeared in linux 2.6. +support is available in glibc since version 2.1. +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +if the interval specified in +.i request +is not an exact multiple of the granularity underlying clock (see +.br time (7)), +then the interval will be rounded up to the next multiple. +furthermore, after the sleep completes, there may still be a delay before +the cpu becomes free to once again execute the calling thread. +.pp +using an absolute timer is useful for preventing +timer drift problems of the type described in +.br nanosleep (2). +(such problems are exacerbated in programs that try to restart +a relative sleep that is repeatedly interrupted by signals.) +to perform a relative sleep that avoids these problems, call +.br clock_gettime (2) +for the desired clock, +add the desired interval to the returned time value, +and then call +.br clock_nanosleep () +with the +.b timer_abstime +flag. +.pp +.br clock_nanosleep () +is never restarted after being interrupted by a signal handler, +regardless of the use of the +.br sigaction (2) +.b sa_restart +flag. +.pp +the +.i remain +argument is unused, and unnecessary, when +.i flags +is +.br timer_abstime . +(an absolute sleep can be restarted using the same +.i request +argument.) +.pp +posix.1 specifies that +.br clock_nanosleep () +has no effect on signals dispositions or the signal mask. +.pp +posix.1 specifies that after changing the value of the +.b clock_realtime +clock via +.br clock_settime (2), +the new clock value shall be used to determine the time +at which a thread blocked on an absolute +.br clock_nanosleep () +will wake up; +if the new clock value falls past the end of the sleep interval, then the +.br clock_nanosleep () +call will return immediately. +.pp +posix.1 specifies that +changing the value of the +.b clock_realtime +clock via +.br clock_settime (2) +shall have no effect on a thread that is blocked on a relative +.br clock_nanosleep (). +.sh see also +.br clock_getres (2), +.br nanosleep (2), +.br restart_syscall (2), +.br timer_create (2), +.br sleep (3), +.br usleep (3), +.br time (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/outb.2 + +.so man3/getservent.3 + +.\" copyright (c) 2000 andries brouwer (aeb@cwi.nl) +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" 2000-08-14 added gnu additions from andreas jaeger +.\" 2000-12-05 some changes inspired by acahalan's remarks +.\" +.th fenv 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +feclearexcept, fegetexceptflag, feraiseexcept, fesetexceptflag, +fetestexcept, fegetenv, fegetround, feholdexcept, fesetround, +fesetenv, feupdateenv, feenableexcept, fedisableexcept, +fegetexcept \- floating-point rounding and exception handling +.sh synopsis +.nf +.b #include +.pp +.bi "int feclearexcept(int " excepts ); +.bi "int fegetexceptflag(fexcept_t *" flagp ", int " excepts ); +.bi "int feraiseexcept(int " excepts ); +.bi "int fesetexceptflag(const fexcept_t *" flagp ", int " excepts ); +.bi "int fetestexcept(int " excepts ); +.pp +.b "int fegetround(void);" +.bi "int fesetround(int " rounding_mode ); +.pp +.bi "int fegetenv(fenv_t *" envp ); +.bi "int feholdexcept(fenv_t *" envp ); +.bi "int fesetenv(const fenv_t *" envp ); +.bi "int feupdateenv(const fenv_t *" envp ); +.fi +.pp +link with \fi\-lm\fp. +.sh description +these eleven functions were defined in c99, and describe the handling +of floating-point rounding and exceptions (overflow, zero-divide, etc.). +.ss exceptions +the +.i divide-by-zero +exception occurs when an operation on finite numbers +produces infinity as exact answer. +.pp +the +.i overflow +exception occurs when a result has to be represented as a +floating-point number, but has (much) larger absolute value than the +largest (finite) floating-point number that is representable. +.pp +the +.i underflow +exception occurs when a result has to be represented as a +floating-point number, but has smaller absolute value than the smallest +positive normalized floating-point number (and would lose much accuracy +when represented as a denormalized number). +.pp +the +.i inexact +exception occurs when the rounded result of an operation +is not equal to the infinite precision result. +it may occur whenever +.i overflow +or +.i underflow +occurs. +.pp +the +.i invalid +exception occurs when there is no well-defined result +for an operation, as for 0/0 or infinity \- infinity or sqrt(\-1). +.ss exception handling +exceptions are represented in two ways: as a single bit +(exception present/absent), and these bits correspond in some +implementation-defined way with bit positions in an integer, +and also as an opaque structure that may contain more information +about the exception (perhaps the code address where it occurred). +.pp +each of the macros +.br fe_divbyzero , +.br fe_inexact , +.br fe_invalid , +.br fe_overflow , +.b fe_underflow +is defined when the implementation supports handling +of the corresponding exception, and if so then +defines the corresponding bit(s), so that one can call +exception handling functions, for example, using the integer argument +.br fe_overflow | fe_underflow . +other exceptions may be supported. +the macro +.b fe_all_except +is the bitwise or of all bits corresponding to supported exceptions. +.pp +the +.br feclearexcept () +function clears the supported exceptions represented by the bits +in its argument. +.pp +the +.br fegetexceptflag () +function stores a representation of the state of the exception flags +represented by the argument +.i excepts +in the opaque object +.ir *flagp . +.pp +the +.br feraiseexcept () +function raises the supported exceptions represented by the bits in +.ir excepts . +.pp +the +.br fesetexceptflag () +function sets the complete status for the exceptions represented by +.i excepts +to the value +.ir *flagp . +this value must have been obtained by an earlier call of +.br fegetexceptflag () +with a last argument that contained all bits in +.ir excepts . +.pp +the +.br fetestexcept () +function returns a word in which the bits are set that were +set in the argument +.i excepts +and for which the corresponding exception is currently set. +.ss rounding mode +the rounding mode determines how the result of floating-point operations +is treated when the result cannot be exactly represented in the significand. +various rounding modes may be provided: +round to nearest (the default), +round up (toward positive infinity), +round down (toward negative infinity), and +round toward zero. +.pp +each of the macros +.br fe_tonearest , +.br fe_upward , +.br fe_downward , +and +.br fe_towardzero +is defined when the implementation supports getting and setting +the corresponding rounding direction. +.pp +the +.br fegetround () +function returns the macro corresponding to the current +rounding mode. +.pp +the +.br fesetround () +function sets the rounding mode as specified by its argument +and returns zero when it was successful. +.pp +c99 and posix.1-2008 specify an identifier, +.br flt_rounds , +defined in +.ir , +which indicates the implementation-defined rounding +behavior for floating-point addition. +this identifier has one of the following values: +.ip \-1 +the rounding mode is not determinable. +.ip 0 +rounding is toward 0. +.ip 1 +rounding is toward nearest number. +.ip 2 +rounding is toward positive infinity. +.ip 3 +rounding is toward negative infinity. +.pp +other values represent machine-dependent, nonstandard rounding modes. +.pp +the value of +.br flt_rounds +should reflect the current rounding mode as set by +.br fesetround () +(but see bugs). +.ss floating-point environment +the entire floating-point environment, including +control modes and status flags, can be handled +as one opaque object, of type +.ir fenv_t . +the default environment is denoted by +.b fe_dfl_env +(of type +.ir "const fenv_t\ *" ). +this is the environment setup at program start and it is defined by +iso c to have round to nearest, all exceptions cleared and a nonstop +(continue on exceptions) mode. +.pp +the +.br fegetenv () +function saves the current floating-point environment in the object +.ir *envp . +.pp +the +.br feholdexcept () +function does the same, then clears all exception flags, +and sets a nonstop (continue on exceptions) mode, +if available. +it returns zero when successful. +.pp +the +.br fesetenv () +function restores the floating-point environment from +the object +.ir *envp . +this object must be known to be valid, for example, the result of a call to +.br fegetenv () +or +.br feholdexcept () +or equal to +.br fe_dfl_env . +this call does not raise exceptions. +.pp +the +.br feupdateenv () +function installs the floating-point environment represented by +the object +.ir *envp , +except that currently raised exceptions are not cleared. +after calling this function, the raised exceptions will be a bitwise or +of those previously set with those in +.ir *envp . +as before, the object +.i *envp +must be known to be valid. +.sh return value +these functions return zero on success and nonzero if an error occurred. +.\" earlier seven of these functions were listed as returning void. +.\" this was corrected in corrigendum 1 (iso/iec 9899:1999/cor.1:2001(e)) +.\" of the c99 standard. +.sh versions +these functions first appeared in glibc in version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.nh +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br feclearexcept (), +.br fegetexceptflag (), +.br feraiseexcept (), +.br fesetexceptflag (), +.br fetestexcept (), +.br fegetround (), +.br fesetround (), +.br fegetenv (), +.br feholdexcept (), +.br fesetenv (), +.br feupdateenv (), +.br feenableexcept (), +.br fedisableexcept (), +.br fegetexcept () +t} thread safety t{ +mt-safe +t} +.te +.hy +.ad +.sp 1 +.hy +.sh conforming to +iec 60559 (iec 559:1989), ansi/ieee 854, c99, posix.1-2001. +.sh notes +.ss glibc notes +if possible, the gnu c library defines a macro +.b fe_nomask_env +which represents an environment where every exception raised causes a +trap to occur. +you can test for this macro using +.br #ifdef . +it is defined only if +.b _gnu_source +is defined. +the c99 standard does not define a way to set individual bits in the +floating-point mask, for example, to trap on specific flags. +since version 2.2, glibc supports the functions +.br feenableexcept () +and +.br fedisableexcept () +to set individual floating-point traps, and +.br fegetexcept () +to query the state. +.pp +.nf +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b "#include " +.pp +.bi "int feenableexcept(int " excepts ); +.bi "int fedisableexcept(int " excepts ); +.b "int fegetexcept(void);" +.fi +.pp +the +.br feenableexcept () +and +.br fedisableexcept () +functions enable (disable) traps for each of the exceptions represented by +.i excepts +and return the previous set of enabled exceptions when successful, +and \-1 otherwise. +the +.br fegetexcept () +function returns the set of all currently enabled exceptions. +.sh bugs +c99 specifies that the value of +.b flt_rounds +should reflect changes to the current rounding mode, as set by +.br fesetround (). +currently, +.\" aug 08, glibc 2.8 +this does not occur: +.b flt_rounds +always has the value 1. +.\" see http://gcc.gnu.org/ml/gcc/2002-02/msg01535.html +.sh see also +.br math_error (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/slist.3 + +.\" copyright (c) 2014 by michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th open_by_handle_at 2 2021-08-27 "linux" "linux programmer's manual" +.sh name +name_to_handle_at, open_by_handle_at \- obtain handle +for a pathname and open file via a handle +.sh synopsis +.nf +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "int name_to_handle_at(int " dirfd ", const char *" pathname , +.bi " struct file_handle *" handle , +.bi " int *" mount_id ", int " flags ); +.bi "int open_by_handle_at(int " mount_fd ", struct file_handle *" handle , +.bi " int " flags ); +.fi +.sh description +the +.br name_to_handle_at () +and +.br open_by_handle_at () +system calls split the functionality of +.br openat (2) +into two parts: +.br name_to_handle_at () +returns an opaque handle that corresponds to a specified file; +.br open_by_handle_at () +opens the file corresponding to a handle returned by a previous call to +.br name_to_handle_at () +and returns an open file descriptor. +.\" +.\" +.ss name_to_handle_at() +the +.br name_to_handle_at () +system call returns a file handle and a mount id corresponding to +the file specified by the +.ir dirfd +and +.ir pathname +arguments. +the file handle is returned via the argument +.ir handle , +which is a pointer to a structure of the following form: +.pp +.in +4n +.ex +struct file_handle { + unsigned int handle_bytes; /* size of f_handle [in, out] */ + int handle_type; /* handle type [out] */ + unsigned char f_handle[0]; /* file identifier (sized by + caller) [out] */ +}; +.ee +.in +.pp +it is the caller's responsibility to allocate the structure +with a size large enough to hold the handle returned in +.ir f_handle . +before the call, the +.ir handle_bytes +field should be initialized to contain the allocated size for +.ir f_handle . +(the constant +.br max_handle_sz , +defined in +.ir , +specifies the maximum expected size for a file handle. +it is not a +guaranteed upper limit as future filesystems may require more space.) +upon successful return, the +.ir handle_bytes +field is updated to contain the number of bytes actually written to +.ir f_handle . +.pp +the caller can discover the required size for the +.i file_handle +structure by making a call in which +.ir handle\->handle_bytes +is zero; +in this case, the call fails with the error +.br eoverflow +and +.ir handle\->handle_bytes +is set to indicate the required size; +the caller can then use this information to allocate a structure +of the correct size (see examples below). +some care is needed here as +.br eoverflow +can also indicate that no file handle is available for this particular +name in a filesystem which does normally support file-handle lookup. +this case can be detected when the +.b eoverflow +error is returned without +.i handle_bytes +being increased. +.pp +other than the use of the +.ir handle_bytes +field, the caller should treat the +.ir file_handle +structure as an opaque data type: the +.ir handle_type +and +.ir f_handle +fields are needed only by a subsequent call to +.br open_by_handle_at (). +.pp +the +.i flags +argument is a bit mask constructed by oring together zero or more of +.br at_empty_path +and +.br at_symlink_follow , +described below. +.pp +together, the +.i pathname +and +.i dirfd +arguments identify the file for which a handle is to be obtained. +there are four distinct cases: +.ip * 3 +if +.i pathname +is a nonempty string containing an absolute pathname, +then a handle is returned for the file referred to by that pathname. +in this case, +.ir dirfd +is ignored. +.ip * +if +.i pathname +is a nonempty string containing a relative pathname and +.ir dirfd +has the special value +.br at_fdcwd , +then +.i pathname +is interpreted relative to the current working directory of the caller, +and a handle is returned for the file to which it refers. +.ip * +if +.i pathname +is a nonempty string containing a relative pathname and +.ir dirfd +is a file descriptor referring to a directory, then +.i pathname +is interpreted relative to the directory referred to by +.ir dirfd , +and a handle is returned for the file to which it refers. +(see +.br openat (2) +for an explanation of why "directory file descriptors" are useful.) +.ip * +if +.i pathname +is an empty string and +.i flags +specifies the value +.br at_empty_path , +then +.ir dirfd +can be an open file descriptor referring to any type of file, +or +.br at_fdcwd , +meaning the current working directory, +and a handle is returned for the file to which it refers. +.pp +the +.i mount_id +argument returns an identifier for the filesystem +mount that corresponds to +.ir pathname . +this corresponds to the first field in one of the records in +.ir /proc/self/mountinfo . +opening the pathname in the fifth field of that record yields a file +descriptor for the mount point; +that file descriptor can be used in a subsequent call to +.br open_by_handle_at (). +.i mount_id +is returned both for a successful call and for a call that results +in the error +.br eoverflow . +.pp +by default, +.br name_to_handle_at () +does not dereference +.i pathname +if it is a symbolic link, and thus returns a handle for the link itself. +if +.b at_symlink_follow +is specified in +.ir flags , +.i pathname +is dereferenced if it is a symbolic link +(so that the call returns a handle for the file referred to by the link). +.pp +.br name_to_handle_at () +does not trigger a mount when the final component of the pathname is an +automount point. +when a filesystem supports both file handles and +automount points, a +.br name_to_handle_at () +call on an automount point will return with error +.br eoverflow +without having increased +.ir handle_bytes . +this can happen since linux 4.13 +.\" commit 20fa19027286983ab2734b5910c4a687436e0c31 +with nfs when accessing a directory +which is on a separate filesystem on the server. +in this case, the automount can be triggered by adding a "/" to the end +of the pathname. +.ss open_by_handle_at() +the +.br open_by_handle_at () +system call opens the file referred to by +.ir handle , +a file handle returned by a previous call to +.br name_to_handle_at (). +.pp +the +.ir mount_fd +argument is a file descriptor for any object (file, directory, etc.) +in the mounted filesystem with respect to which +.ir handle +should be interpreted. +the special value +.b at_fdcwd +can be specified, meaning the current working directory of the caller. +.pp +the +.i flags +argument +is as for +.br open (2). +if +.i handle +refers to a symbolic link, the caller must specify the +.b o_path +flag, and the symbolic link is not dereferenced; the +.b o_nofollow +flag, if specified, is ignored. +.pp +the caller must have the +.b cap_dac_read_search +capability to invoke +.br open_by_handle_at (). +.sh return value +on success, +.br name_to_handle_at () +returns 0, +and +.br open_by_handle_at () +returns a file descriptor (a nonnegative integer). +.pp +in the event of an error, both system calls return \-1 and set +.i errno +to indicate the error. +.sh errors +.br name_to_handle_at () +and +.br open_by_handle_at () +can fail for the same errors as +.br openat (2). +in addition, they can fail with the errors noted below. +.pp +.br name_to_handle_at () +can fail with the following errors: +.tp +.b efault +.ir pathname , +.ir mount_id , +or +.ir handle +points outside your accessible address space. +.tp +.b einval +.i flags +includes an invalid bit value. +.tp +.b einval +.ir handle\->handle_bytes +is greater than +.br max_handle_sz . +.tp +.b enoent +.i pathname +is an empty string, but +.br at_empty_path +was not specified in +.ir flags . +.tp +.b enotdir +the file descriptor supplied in +.i dirfd +does not refer to a directory, +and it is not the case that both +.i flags +includes +.br at_empty_path +and +.i pathname +is an empty string. +.tp +.b eopnotsupp +the filesystem does not support decoding of a pathname to a file handle. +.tp +.b eoverflow +the +.i handle\->handle_bytes +value passed into the call was too small. +when this error occurs, +.i handle\->handle_bytes +is updated to indicate the required size for the handle. +.\" +.\" +.pp +.br open_by_handle_at () +can fail with the following errors: +.tp +.b ebadf +.ir mount_fd +is not an open file descriptor. +.tp +.b ebadf +.i pathname +is relative but +.i dirfd +is neither +.b at_fdcwd +nor a valid file descriptor. +.tp +.b efault +.ir handle +points outside your accessible address space. +.tp +.b einval +.i handle\->handle_bytes +is greater than +.br max_handle_sz +or is equal to zero. +.tp +.b eloop +.i handle +refers to a symbolic link, but +.b o_path +was not specified in +.ir flags . +.tp +.b eperm +the caller does not have the +.br cap_dac_read_search +capability. +.tp +.b estale +the specified +.i handle +is not valid. +this error will occur if, for example, the file has been deleted. +.sh versions +these system calls first appeared in linux 2.6.39. +library support is provided in glibc since version 2.14. +.sh conforming to +these system calls are nonstandard linux extensions. +.pp +freebsd has a broadly similar pair of system calls in the form of +.br getfh () +and +.br openfh (). +.sh notes +a file handle can be generated in one process using +.br name_to_handle_at () +and later used in a different process that calls +.br open_by_handle_at (). +.pp +some filesystem don't support the translation of pathnames to +file handles, for example, +.ir /proc , +.ir /sys , +and various network filesystems. +.pp +a file handle may become invalid ("stale") if a file is deleted, +or for other filesystem-specific reasons. +invalid handles are notified by an +.b estale +error from +.br open_by_handle_at (). +.pp +these system calls are designed for use by user-space file servers. +for example, a user-space nfs server might generate a file handle +and pass it to an nfs client. +later, when the client wants to open the file, +it could pass the handle back to the server. +.\" https://lwn.net/articles/375888/ +.\" "open by handle" - jonathan corbet, 2010-02-23 +this sort of functionality allows a user-space file server to operate in +a stateless fashion with respect to the files it serves. +.pp +if +.i pathname +refers to a symbolic link and +.ir flags +does not specify +.br at_symlink_follow , +then +.br name_to_handle_at () +returns a handle for the link (rather than the file to which it refers). +.\" commit bcda76524cd1fa32af748536f27f674a13e56700 +the process receiving the handle can later perform operations +on the symbolic link by converting the handle to a file descriptor using +.br open_by_handle_at () +with the +.br o_path +flag, and then passing the file descriptor as the +.ir dirfd +argument in system calls such as +.br readlinkat (2) +and +.br fchownat (2). +.ss obtaining a persistent filesystem id +the mount ids in +.ir /proc/self/mountinfo +can be reused as filesystems are unmounted and mounted. +therefore, the mount id returned by +.br name_to_handle_at () +(in +.ir *mount_id ) +should not be treated as a persistent identifier +for the corresponding mounted filesystem. +however, an application can use the information in the +.i mountinfo +record that corresponds to the mount id +to derive a persistent identifier. +.pp +for example, one can use the device name in the fifth field of the +.i mountinfo +record to search for the corresponding device uuid via the symbolic links in +.ir /dev/disks/by\-uuid . +(a more comfortable way of obtaining the uuid is to use the +.\" e.g., http://stackoverflow.com/questions/6748429/using-libblkid-to-find-uuid-of-a-partition +.br libblkid (3) +library.) +that process can then be reversed, +using the uuid to look up the device name, +and then obtaining the corresponding mount point, +in order to produce the +.ir mount_fd +argument used by +.br open_by_handle_at (). +.sh examples +the two programs below demonstrate the use of +.br name_to_handle_at () +and +.br open_by_handle_at (). +the first program +.ri ( t_name_to_handle_at.c ) +uses +.br name_to_handle_at () +to obtain the file handle and mount id +for the file specified in its command-line argument; +the handle and mount id are written to standard output. +.pp +the second program +.ri ( t_open_by_handle_at.c ) +reads a mount id and file handle from standard input. +the program then employs +.br open_by_handle_at () +to open the file using that handle. +if an optional command-line argument is supplied, then the +.ir mount_fd +argument for +.br open_by_handle_at () +is obtained by opening the directory named in that argument. +otherwise, +.ir mount_fd +is obtained by scanning +.ir /proc/self/mountinfo +to find a record whose mount id matches the mount id +read from standard input, +and the mount directory specified in that record is opened. +(these programs do not deal with the fact that mount ids are not persistent.) +.pp +the following shell session demonstrates the use of these two programs: +.pp +.in +4n +.ex +$ \fbecho \(aqcan you please think about it?\(aq > cecilia.txt\fp +$ \fb./t_name_to_handle_at cecilia.txt > fh\fp +$ \fb./t_open_by_handle_at < fh\fp +open_by_handle_at: operation not permitted +$ \fbsudo ./t_open_by_handle_at < fh\fp # need cap_sys_admin +read 31 bytes +$ \fbrm cecilia.txt\fp +.ee +.in +.pp +now we delete and (quickly) re-create the file so that +it has the same content and (by chance) the same inode. +nevertheless, +.br open_by_handle_at () +.\" christoph hellwig: that's why the file handles contain a generation +.\" counter that gets incremented in this case. +recognizes that the original file referred to by the file handle +no longer exists. +.pp +.in +4n +.ex +$ \fbstat \-\-printf="%i\en" cecilia.txt\fp # display inode number +4072121 +$ \fbrm cecilia.txt\fp +$ \fbecho \(aqcan you please think about it?\(aq > cecilia.txt\fp +$ \fbstat \-\-printf="%i\en" cecilia.txt\fp # check inode number +4072121 +$ \fbsudo ./t_open_by_handle_at < fh\fp +open_by_handle_at: stale nfs file handle +.ee +.in +.ss program source: t_name_to_handle_at.c +\& +.ex +#define _gnu_source +#include +#include +#include +#include +#include +#include +#include +#include + +#define errexit(msg) do { perror(msg); exit(exit_failure); \e + } while (0) + +int +main(int argc, char *argv[]) +{ + struct file_handle *fhp; + int mount_id, fhsize, flags, dirfd; + char *pathname; + + if (argc != 2) { + fprintf(stderr, "usage: %s pathname\en", argv[0]); + exit(exit_failure); + } + + pathname = argv[1]; + + /* allocate file_handle structure. */ + + fhsize = sizeof(*fhp); + fhp = malloc(fhsize); + if (fhp == null) + errexit("malloc"); + + /* make an initial call to name_to_handle_at() to discover + the size required for file handle. */ + + dirfd = at_fdcwd; /* for name_to_handle_at() calls */ + flags = 0; /* for name_to_handle_at() calls */ + fhp\->handle_bytes = 0; + if (name_to_handle_at(dirfd, pathname, fhp, + &mount_id, flags) != \-1 || errno != eoverflow) { + fprintf(stderr, "unexpected result from name_to_handle_at()\en"); + exit(exit_failure); + } + + /* reallocate file_handle structure with correct size. */ + + fhsize = sizeof(*fhp) + fhp\->handle_bytes; + fhp = realloc(fhp, fhsize); /* copies fhp\->handle_bytes */ + if (fhp == null) + errexit("realloc"); + + /* get file handle from pathname supplied on command line. */ + + if (name_to_handle_at(dirfd, pathname, fhp, &mount_id, flags) == \-1) + errexit("name_to_handle_at"); + + /* write mount id, file handle size, and file handle to stdout, + for later reuse by t_open_by_handle_at.c. */ + + printf("%d\en", mount_id); + printf("%u %d ", fhp\->handle_bytes, fhp\->handle_type); + for (int j = 0; j < fhp\->handle_bytes; j++) + printf(" %02x", fhp\->f_handle[j]); + printf("\en"); + + exit(exit_success); +} +.ee +.ss program source: t_open_by_handle_at.c +\& +.ex +#define _gnu_source +#include +#include +#include +#include +#include +#include +#include +#include + +#define errexit(msg) do { perror(msg); exit(exit_failure); \e + } while (0) + +/* scan /proc/self/mountinfo to find the line whose mount id matches + \(aqmount_id\(aq. (an easier way to do this is to install and use the + \(aqlibmount\(aq library provided by the \(aqutil\-linux\(aq project.) + open the corresponding mount path and return the resulting file + descriptor. */ + +static int +open_mount_path_by_id(int mount_id) +{ + char *linep; + size_t lsize; + char mount_path[path_max]; + int mi_mount_id, found; + ssize_t nread; + file *fp; + + fp = fopen("/proc/self/mountinfo", "r"); + if (fp == null) + errexit("fopen"); + + found = 0; + linep = null; + while (!found) { + nread = getline(&linep, &lsize, fp); + if (nread == \-1) + break; + + nread = sscanf(linep, "%d %*d %*s %*s %s", + &mi_mount_id, mount_path); + if (nread != 2) { + fprintf(stderr, "bad sscanf()\en"); + exit(exit_failure); + } + + if (mi_mount_id == mount_id) + found = 1; + } + free(linep); + + fclose(fp); + + if (!found) { + fprintf(stderr, "could not find mount point\en"); + exit(exit_failure); + } + + return open(mount_path, o_rdonly); +} + +int +main(int argc, char *argv[]) +{ + struct file_handle *fhp; + int mount_id, fd, mount_fd, handle_bytes; + ssize_t nread; + char buf[1000]; +#define line_size 100 + char line1[line_size], line2[line_size]; + char *nextp; + + if ((argc > 1 && strcmp(argv[1], "\-\-help") == 0) || argc > 2) { + fprintf(stderr, "usage: %s [mount\-path]\en", argv[0]); + exit(exit_failure); + } + + /* standard input contains mount id and file handle information: + + line 1: + line 2: + */ + + if ((fgets(line1, sizeof(line1), stdin) == null) || + (fgets(line2, sizeof(line2), stdin) == null)) { + fprintf(stderr, "missing mount_id / file handle\en"); + exit(exit_failure); + } + + mount_id = atoi(line1); + + handle_bytes = strtoul(line2, &nextp, 0); + + /* given handle_bytes, we can now allocate file_handle structure. */ + + fhp = malloc(sizeof(*fhp) + handle_bytes); + if (fhp == null) + errexit("malloc"); + + fhp\->handle_bytes = handle_bytes; + + fhp\->handle_type = strtoul(nextp, &nextp, 0); + + for (int j = 0; j < fhp\->handle_bytes; j++) + fhp\->f_handle[j] = strtoul(nextp, &nextp, 16); + + /* obtain file descriptor for mount point, either by opening + the pathname specified on the command line, or by scanning + /proc/self/mounts to find a mount that matches the \(aqmount_id\(aq + that we received from stdin. */ + + if (argc > 1) + mount_fd = open(argv[1], o_rdonly); + else + mount_fd = open_mount_path_by_id(mount_id); + + if (mount_fd == \-1) + errexit("opening mount fd"); + + /* open file using handle and mount point. */ + + fd = open_by_handle_at(mount_fd, fhp, o_rdonly); + if (fd == \-1) + errexit("open_by_handle_at"); + + /* try reading a few bytes from the file. */ + + nread = read(fd, buf, sizeof(buf)); + if (nread == \-1) + errexit("read"); + + printf("read %zd bytes\en", nread); + + exit(exit_success); +} +.ee +.sh see also +.br open (2), +.br libblkid (3), +.br blkid (8), +.br findfs (8), +.br mount (8) +.pp +the +.i libblkid +and +.i libmount +documentation in the latest +.i util\-linux +release at +.ur https://www.kernel.org/pub/linux/utils/util\-linux/ +.ue +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/mq_send.3 + +.so man3/tailq.3 + +.so man3/stailq.3 + +.so man2/unimplemented.2 + +.\" copyright (c) 2003, michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" 2003-12-10 initial creation, michael kerrisk +.\" 2004-10-28 aeb, corrected prototype, prot must be 0 +.\" +.th remap_file_pages 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +remap_file_pages \- create a nonlinear file mapping +.sh synopsis +.nf +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "int remap_file_pages(void *" addr ", size_t " size ", int " prot , +.bi " size_t " pgoff ", int " flags ); +.fi +.sh description +.br note : +.\" commit 33041a0d76d3c3e0aff28ac95a2ffdedf1282dbc +.\" http://lwn.net/articles/597632/ +this system call was marked as deprecated starting with linux 3.16. +in linux 4.0, the implementation was replaced +.\" commit c8d78c1823f46519473949d33f0d1d33fe21ea16 +by a slower in-kernel emulation. +those few applications that use this system call should +consider migrating to alternatives. +this change was made because the kernel code for this system call was complex, +and it is believed to be little used or perhaps even completely unused. +while it had some use cases in database applications on 32-bit systems, +those use cases don't exist on 64-bit systems. +.pp +the +.br remap_file_pages () +system call is used to create a nonlinear mapping, that is, a mapping +in which the pages of the file are mapped into a nonsequential order +in memory. +the advantage of using +.br remap_file_pages () +over using repeated calls to +.br mmap (2) +is that the former approach does not require the kernel to create +additional vma (virtual memory area) data structures. +.pp +to create a nonlinear mapping we perform the following steps: +.tp 3 +1. +use +.br mmap (2) +to create a mapping (which is initially linear). +this mapping must be created with the +.b map_shared +flag. +.tp +2. +use one or more calls to +.br remap_file_pages () +to rearrange the correspondence between the pages of the mapping +and the pages of the file. +it is possible to map the same page of a file +into multiple locations within the mapped region. +.pp +the +.i pgoff +and +.i size +arguments specify the region of the file that is to be relocated +within the mapping: +.i pgoff +is a file offset in units of the system page size; +.i size +is the length of the region in bytes. +.pp +the +.i addr +argument serves two purposes. +first, it identifies the mapping whose pages we want to rearrange. +thus, +.i addr +must be an address that falls within +a region previously mapped by a call to +.br mmap (2). +second, +.i addr +specifies the address at which the file pages +identified by +.i pgoff +and +.i size +will be placed. +.pp +the values specified in +.i addr +and +.i size +should be multiples of the system page size. +if they are not, then the kernel rounds +.i both +values +.i down +to the nearest multiple of the page size. +.\" this rounding is weird, and not consistent with the treatment of +.\" the analogous arguments for munmap()/mprotect() and for mlock(). +.\" mtk, 14 sep 2005 +.pp +the +.i prot +argument must be specified as 0. +.pp +the +.i flags +argument has the same meaning as for +.br mmap (2), +but all flags other than +.b map_nonblock +are ignored. +.sh return value +on success, +.br remap_file_pages () +returns 0. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b einval +.i addr +does not refer to a valid mapping +created with the +.b map_shared +flag. +.tp +.b einval +.ir addr , +.ir size , +.ir prot , +or +.i pgoff +is invalid. +.\" and possibly others from vma->vm_ops->populate() +.sh versions +the +.br remap_file_pages () +system call appeared in linux 2.5.46; +glibc support was added in version 2.3.3. +.sh conforming to +the +.br remap_file_pages () +system call is linux-specific. +.sh notes +since linux 2.6.23, +.\" commit 3ee6dafc677a68e461a7ddafc94a580ebab80735 +.br remap_file_pages () +creates non-linear mappings only +on in-memory filesystems such as +.br tmpfs (5), +hugetlbfs or ramfs. +on filesystems with a backing store, +.br remap_file_pages () +is not much more efficient than using +.br mmap (2) +to adjust which parts of the file are mapped to which addresses. +.sh see also +.br getpagesize (2), +.br mmap (2), +.br mmap2 (2), +.br mprotect (2), +.br mremap (2), +.br msync (2) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +#!/bin/bash +# +# check_unbalanced_macros.sh +# +# dec 2007, michael kerrisk +# +# look for unbalanced pairs of macros in man page source files, with +# $1 and $2 specifying the macro pair. these arguments should +# _not_ include the leading dot (.) in the macro. +# as output, the program prints the line numbers containing each macro, +# and if an unbalanced macro is detected, the string "unbalanced!" +# is printed. +# +# example usage: +# +# sh check_unbalanced_macros.sh nf fi */*.[1-8] +# sh check_unbalanced_macros.sh rs re */*.[1-8] +# sh check_unbalanced_macros.sh ex ee */*.[1-8] +# +###################################################################### +# +# (c) copyright 2020, michael kerrisk +# this program is free software; you can redistribute it and/or +# modify it under the terms of the gnu general public license +# as published by the free software foundation; either version 2 +# of the license, or (at your option) any later version. +# +# this program 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 general public license for more details +# (http://www.gnu.org/licenses/gpl-2.0.html). +# + +if test $# -lt 4; then + echo "usage: $0 opener closer pages..." + exit 1 +fi + +opener="$1" +closer="$2" +shift 2 + +for f in $@; do + if egrep "^\.($opener|$closer)" $f > /dev/null; then + echo "================== $f" + + nl -ba $f | + awk 'begin { level = 0 } + + $2 == "'".$opener"'" { level++ } + + $2 == "'".$opener"'" || $2 == "'".$closer"'" { + printf "%s %s %d", $1, $2, level + if (level == 0) + print " unbalanced!" + else + print "" + } + + $2 == "'".$closer"'" { level-- } + + end { + if (level != 0) + print "unbalanced!" + }' + fi +done + +.\" copyright (c) 2008 linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th pthread_attr_setschedparam 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +pthread_attr_setschedparam, pthread_attr_getschedparam \- set/get +scheduling parameter attributes in thread attributes object +.sh synopsis +.nf +.b #include +.pp +.bi "int pthread_attr_setschedparam(pthread_attr_t *restrict " attr , +.bi " const struct sched_param *restrict " param ); +.bi "int pthread_attr_getschedparam(const pthread_attr_t *restrict " attr , +.bi " struct sched_param *restrict " param ); +.pp +compile and link with \fi\-pthread\fp. +.fi +.sh description +the +.br pthread_attr_setschedparam () +function sets the scheduling parameter attributes of the +thread attributes object referred to by +.ir attr +to the values specified in the buffer pointed to by +.ir param . +these attributes determine the scheduling parameters of +a thread created using the thread attributes object +.ir attr . +.pp +the +.br pthread_attr_getschedparam () +returns the scheduling parameter attributes of the thread attributes object +.ir attr +in the buffer pointed to by +.ir param . +.pp +scheduling parameters are maintained in the following structure: +.pp +.in +4n +.ex +struct sched_param { + int sched_priority; /* scheduling priority */ +}; +.ee +.in +.pp +as can be seen, only one scheduling parameter is supported. +for details of the permitted ranges for scheduling priorities +in each scheduling policy, see +.br sched (7). +.pp +in order for the parameter setting made by +.br pthread_attr_setschedparam () +to have effect when calling +.br pthread_create (3), +the caller must use +.br pthread_attr_setinheritsched (3) +to set the inherit-scheduler attribute of the attributes object +.i attr +to +.br pthread_explicit_sched . +.sh return value +on success, these functions return 0; +on error, they return a nonzero error number. +.sh errors +.br pthread_attr_setschedparam () +can fail with the following error: +.tp +.b einval +the priority specified in +.i param +does not make sense for the current scheduling policy of +.ir attr . +.pp +posix.1 also documents an +.b enotsup +error for +.br pthread_attr_setschedparam (). +this value is never returned on linux +(but portable and future-proof applications should nevertheless +handle this error return value). +.\" .sh versions +.\" available since glibc 2.0. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br pthread_attr_setschedparam (), +.br pthread_attr_getschedparam () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +see +.br pthread_attr_setschedpolicy (3) +for a list of the thread scheduling policies supported on linux. +.sh examples +see +.br pthread_setschedparam (3). +.sh see also +.ad l +.nh +.br sched_get_priority_min (2), +.br pthread_attr_init (3), +.br pthread_attr_setinheritsched (3), +.br pthread_attr_setschedpolicy (3), +.br pthread_create (3), +.br pthread_setschedparam (3), +.br pthread_setschedprio (3), +.br pthreads (7), +.br sched (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" iso/iec 9899:1999 +.\" +.th wmemset 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +wmemset \- fill an array of wide-characters with a constant wide character +.sh synopsis +.nf +.b #include +.pp +.bi "wchar_t *wmemset(wchar_t *" wcs ", wchar_t " wc ", size_t " n ); +.fi +.sh description +the +.br wmemset () +function is the wide-character equivalent of the +.br memset (3) +function. +it fills the array of +.i n +wide-characters starting at +.i wcs +with +.i n +copies of the wide character +.ir wc . +.sh return value +.br wmemset () +returns +.ir wcs . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br wmemset () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh see also +.br memset (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" this man page was written by jeremy phelps . +.\" notes added - aeb +.\" +.\" %%%license_start(freely_redistributable) +.\" redistribute and revise at will. +.\" %%%license_end +.\" +.th pts 4 2020-08-13 "linux" "linux programmer's manual" +.sh name +ptmx, pts \- pseudoterminal master and slave +.sh description +the file +.i /dev/ptmx +(the pseudoterminal multiplexor device) +is a character file with major number 5 and +minor number 2, usually with mode 0666 and ownership root:root. +it is used to create a pseudoterminal master and slave pair. +.pp +when a process opens +.ir /dev/ptmx , +it gets a file +descriptor for a pseudoterminal master +and a pseudoterminal slave device is created in the +.i /dev/pts +directory. +each file descriptor obtained by opening +.ir /dev/ptmx +is an independent pseudoterminal master with its own associated slave, +whose path can +be found by passing the file descriptor to +.br ptsname (3). +.pp +before opening the pseudoterminal slave, you must pass the master's file +descriptor to +.br grantpt (3) +and +.br unlockpt (3). +.pp +once both the pseudoterminal master and slave are open, the slave provides +processes with an interface that is identical to that of a real terminal. +.pp +data written to the slave is presented on the master file descriptor as input. +data written to the master is presented to the slave as input. +.pp +in practice, pseudoterminals are used for implementing terminal emulators +such as +.br xterm (1), +in which data read from the pseudoterminal master is interpreted by the +application in the same way +a real terminal would interpret the data, and for implementing remote-login +programs such as +.br sshd (8), +in which data read from the pseudoterminal master is sent across the network +to a client program that is connected to a terminal or terminal emulator. +.pp +pseudoterminals can also be used to send input to programs that normally +refuse to read input from pipes (such as +.br su (1), +and +.br passwd (1)). +.sh files +.ir /dev/ptmx , +.i /dev/pts/* +.sh notes +the linux support for the above (known as unix 98 pseudoterminal naming) +is done using the +.i devpts +filesystem, which should be mounted on +.ir /dev/pts . +.sh see also +.br getpt (3), +.br grantpt (3), +.br ptsname (3), +.br unlockpt (3), +.br pty (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/stailq.3 + +.so man7/iso_8859-5.7 + +.so man3/xdr.3 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sat jul 24 19:38:44 1993 by rik faith (faith@cs.unc.edu) +.th fgetgrent 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +fgetgrent \- get group file entry +.sh synopsis +.nf +.b #include +.b #include +.b #include +.pp +.bi "struct group *fgetgrent(file *" stream ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br fgetgrent (): +.nf + since glibc 2.19: + _default_source + glibc 2.19 and earlier: + _svid_source +.fi +.sh description +the +.br fgetgrent () +function returns a pointer to a structure containing +the group information from the file referred to by +.ir stream . +the first time it is called +it returns the first entry; thereafter, it returns successive entries. +the file referred to by +.i stream +must have the same format as +.i /etc/group +(see +.br group (5)). +.pp +the \figroup\fp structure is defined in \fi\fp as follows: +.pp +.in +4n +.ex +struct group { + char *gr_name; /* group name */ + char *gr_passwd; /* group password */ + gid_t gr_gid; /* group id */ + char **gr_mem; /* null\-terminated array of pointers + to names of group members */ +}; +.ee +.in +.sh return value +the +.br fgetgrent () +function returns a pointer to a +.i group +structure, +or null if there are no more entries or an error occurs. +in the event of an error, +.i errno +is set to indicate the error. +.sh errors +.tp +.b enomem +insufficient memory to allocate +.i group +structure. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br fgetgrent () +t} thread safety mt-unsafe race:fgetgrent +.te +.hy +.ad +.sp 1 +.\" fixme the marking is different from that in the glibc manual, +.\" which has: +.\" +.\" fgetgrent: mt-unsafe race:fgrent +.\" +.\" we think race:fgrent in glibc may be hard for users to understand, +.\" and have sent a patch to the gnu libc community for changing it to +.\" race:fgetgrent, however, something about the copyright impeded the +.\" progress. +.sh conforming to +svr4. +.sh see also +.br endgrent (3), +.br fgetgrent_r (3), +.br fopen (3), +.br getgrent (3), +.br getgrgid (3), +.br getgrnam (3), +.br putgrent (3), +.br setgrent (3), +.br group (5) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/rpc.3 + +.\" copyright (c) 2006 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th mq_getattr 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +mq_getattr, mq_setattr \- get/set message queue attributes +.sh synopsis +.nf +.b #include +.pp +.bi "int mq_getattr(mqd_t " mqdes ", struct mq_attr *" attr ); +.bi "int mq_setattr(mqd_t " mqdes ", const struct mq_attr *restrict " newattr , +.bi " struct mq_attr *restrict " oldattr ); +.fi +.pp +link with \fi\-lrt\fp. +.sh description +.br mq_getattr () +and +.br mq_setattr () +respectively retrieve and modify attributes of the message queue +referred to by the message queue descriptor +.ir mqdes . +.pp +.br mq_getattr () +returns an +.i mq_attr +structure in the buffer pointed by +.ir attr . +this structure is defined as: +.pp +.in +4n +.ex +struct mq_attr { + long mq_flags; /* flags: 0 or o_nonblock */ + long mq_maxmsg; /* max. # of messages on queue */ + long mq_msgsize; /* max. message size (bytes) */ + long mq_curmsgs; /* # of messages currently in queue */ +}; +.ee +.in +.pp +the +.i mq_flags +field contains flags associated with the open message queue description. +this field is initialized when the queue is created by +.br mq_open (3). +the only flag that can appear in this field is +.br o_nonblock . +.pp +the +.i mq_maxmsg +and +.i mq_msgsize +fields are set when the message queue is created by +.br mq_open (3). +the +.i mq_maxmsg +field is an upper limit on the number of messages +that may be placed on the queue using +.br mq_send (3). +the +.i mq_msgsize +field is an upper limit on the size of messages +that may be placed on the queue. +both of these fields must have a value greater than zero. +two +.i /proc +files that place ceilings on the values for these fields are described in +.br mq_overview (7). +.pp +the +.i mq_curmsgs +field returns the number of messages currently held in the queue. +.pp +.br mq_setattr () +sets message queue attributes using information supplied in the +.i mq_attr +structure pointed to by +.ir newattr . +the only attribute that can be modified is the setting of the +.b o_nonblock +flag in +.ir mq_flags . +the other fields in +.i newattr +are ignored. +if the +.i oldattr +field is not null, +then the buffer that it points to is used to return an +.i mq_attr +structure that contains the same information that is returned by +.br mq_getattr (). +.sh return value +on success +.br mq_getattr () +and +.br mq_setattr () +return 0; on error, \-1 is returned, with +.i errno +set to indicate the error. +.sh errors +.tp +.b ebadf +the message queue descriptor specified in +.i mqdes +is invalid. +.tp +.b einval +.i newattr\->mq_flags +contained set bits other than +.br o_nonblock . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br mq_getattr (), +.br mq_setattr () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +on linux, +.br mq_getattr () +and +.br mq_setattr () +are library functions layered on top of the +.br mq_getsetattr (2) +system call. +.sh examples +the program below can be used to show the default +.i mq_maxmsg +and +.i mq_msgsize +values that are assigned to a message queue that is created with a call to +.br mq_open (3) +in which the +.i attr +argument is null. +here is an example run of the program: +.pp +.in +4n +.ex +$ \fb./a.out /testq\fp +maximum # of messages on queue: 10 +maximum message size: 8192 +.ee +.in +.pp +since linux 3.5, the following +.i /proc +files (described in +.br mq_overview (7)) +can be used to control the defaults: +.pp +.in +4n +.ex +$ \fbuname \-sr\fp +linux 3.8.0 +$ \fbcat /proc/sys/fs/mqueue/msg_default\fp +10 +$ \fbcat /proc/sys/fs/mqueue/msgsize_default\fp +8192 +.ee +.in +.ss program source +\& +.ex +#include +#include +#include +#include +#include +#include + +#define errexit(msg) do { perror(msg); exit(exit_failure); \e + } while (0) + +int +main(int argc, char *argv[]) +{ + mqd_t mqd; + struct mq_attr attr; + + if (argc != 2) { + fprintf(stderr, "usage: %s mq\-name\en", argv[0]); + exit(exit_failure); + } + + mqd = mq_open(argv[1], o_creat | o_excl, s_irusr | s_iwusr, null); + if (mqd == (mqd_t) \-1) + errexit("mq_open"); + + if (mq_getattr(mqd, &attr) == \-1) + errexit("mq_getattr"); + + printf("maximum # of messages on queue: %ld\en", attr.mq_maxmsg); + printf("maximum message size: %ld\en", attr.mq_msgsize); + + if (mq_unlink(argv[1]) == \-1) + errexit("mq_unlink"); + + exit(exit_success); +} +.ee +.sh see also +.br mq_close (3), +.br mq_notify (3), +.br mq_open (3), +.br mq_receive (3), +.br mq_send (3), +.br mq_unlink (3), +.br mq_overview (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/slist.3 + +.so man2/readv.2 + +.so man3/getspnam.3 + +.so man3/getusershell.3 + +.\" copyright (c) 2007 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th sysv_signal 3 2021-03-22 "" "linux programmer's manual" +.sh name +sysv_signal \- signal handling with system v semantics +.sh synopsis +.nf +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.b typedef void (*sighandler_t)(int); +.pp +.bi "sighandler_t sysv_signal(int " signum ", sighandler_t " handler ); +.fi +.sh description +the +.br sysv_signal () +function takes the same arguments, and performs the same task, as +.br signal (2). +.pp +however +.br sysv_signal () +provides the system v unreliable signal semantics, that is: +a) the disposition of the signal is reset to the default +when the handler is invoked; +b) delivery of further instances of the signal is not blocked while +the signal handler is executing; and +c) if the handler interrupts (certain) blocking system calls, +then the system call is not automatically restarted. +.sh return value +the +.br sysv_signal () +function returns the previous value of the signal handler, or +.b sig_err +on error. +.sh errors +as for +.br signal (2). +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br sysv_signal () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +this function is nonstandard. +.sh notes +use of +.br sysv_signal () +should be avoided; use +.br sigaction (2) +instead. +.pp +on older linux systems, +.br sysv_signal () +and +.br signal (2) +were equivalent. +but on newer systems, +.br signal (2) +provides reliable signal semantics; see +.br signal (2) +for details. +.pp +the use of +.i sighandler_t +is a gnu extension; +this type is defined only if +the +.b _gnu_source +feature test macro is defined. +.sh see also +.br sigaction (2), +.br signal (2), +.br bsd_signal (3), +.br signal (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/wordexp.3 + +.so man3/drand48.3 + +.\" copyright (c) 2012 yoshifuji hideaki +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of +.\" this manual under the conditions for verbatim copying, provided that +.\" the entire resulting derived work is distributed under the terms of +.\" a permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume +.\" no responsibility for errors or omissions, or for damages resulting +.\" from the use of the information contained herein. the author(s) may +.\" not have taken the same level of care in the production of this +.\" manual, which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th if_nametoindex 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +if_nametoindex, if_indextoname \- mappings between network interface +names and indexes +.sh synopsis +.nf +.b #include +.pp +.bi "unsigned int if_nametoindex(const char *" "ifname" ); +.bi "char *if_indextoname(unsigned int ifindex, char *" ifname ); +.fi +.sh description +the +.br if_nametoindex () +function returns the index of the network interface +corresponding to the name +.ir ifname . +.pp +the +.br if_indextoname () +function returns the name of the network interface +corresponding to the interface index +.ir ifindex . +the name is placed in the buffer pointed to by +.ir ifname . +the buffer must allow for the storage of at least +.b if_namesize +bytes. +.sh return value +on success, +.br if_nametoindex () +returns the index number of the network interface; +on error, 0 is returned and +.i errno +is set to indicate the error. +.pp +on success, +.br if_indextoname () +returns +.ir ifname ; +on error, null is returned and +.i errno +is set to indicate the error. +.sh errors +.br if_nametoindex () +may fail and set +.i errno +if: +.tp +.b enodev +no interface found with given name. +.pp +.br if_indextoname () +may fail and set +.i errno +if: +.tp +.b enxio +no interface found for the index. +.pp +.br if_nametoindex () +and +.br if_indextoname () +may also fail for any of the errors specified for +.br socket (2) +or +.br ioctl (2). +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br if_nametoindex (), +.br if_indextoname () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, rfc\ 3493. +.pp +this function first appeared in bsdi. +.sh see also +.br getifaddrs (3), +.br if_nameindex (3), +.br ifconfig (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 2004 andries brouwer (aeb@cwi.nl) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th pow10 3 2021-03-22 "" "linux programmer's manual" +.sh name +pow10, pow10f, pow10l \- base-10 power functions +.sh synopsis +.nf +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "double pow10(double " x ); +.bi "float pow10f(float " x ); +.bi "long double pow10l(long double " x ); +.fi +.pp +link with \fi\-lm\fp. +.sh description +these functions return the value of 10 raised to the power +.ir x . +.pp +.br "note well" : +these functions perform exactly the same task as the functions described in +.br exp10 (3), +with the difference that the latter functions are now standardized +in ts\ 18661-4:2015. +those latter functions should be used in preference +to the functions described in this page. +.sh versions +these functions first appeared in glibc in version 2.1. +since glibc 2.27, +.\" glibc commit 5a80d39d0d2587e9bd8e72f19e92eeb2a66fbe9e +the use of these functions in new programs is no longer supported. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br pow10 (), +.br pow10f (), +.br pow10l () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +this functions are nonstandard gnu extensions. +.sh see also +.br exp10 (3), +.br pow (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/getnetent_r.3 + +.\" copyright: written by andrew morgan +.\" and copyright 2006, 2008, michael kerrisk +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" may be distributed as per gpl +.\" %%%license_end +.\" +.\" modified by david a. wheeler +.\" modified 2004-05-27, mtk +.\" modified 2004-06-21, aeb +.\" modified 2008-04-28, morgan of kernel.org +.\" update in line with addition of file capabilities and +.\" 64-bit capability sets in kernel 2.6.2[45]. +.\" modified 2009-01-26, andi kleen +.\" +.th capget 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +capget, capset \- set/get capabilities of thread(s) +.sh synopsis +.nf +.br "#include " " /* definition of " cap_* " and" +.br " _linux_capability_*" " constants */" +.br "#include " " /* definition of " sys_* " constants */" +.b #include +.pp +.bi "int syscall(sys_capget, cap_user_header_t " hdrp , +.bi " cap_user_data_t " datap ); +.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. +not only are these system calls specific to linux, +but the kernel api is likely to change and use of +these system calls (in particular the format of the +.i cap_user_*_t +types) is subject to extension with each kernel revision, +but old programs will keep working. +.pp +the portable interfaces are +.br cap_set_proc (3) +and +.br cap_get_proc (3); +if possible, you should use those interfaces in applications; see notes. +.\" +.ss current details +now that you have been warned, some current kernel details. +the structures are defined as follows. +.pp +.in +4n +.ex +#define _linux_capability_version_1 0x19980330 +#define _linux_capability_u32s_1 1 + + /* v2 added in linux 2.6.25; deprecated */ +#define _linux_capability_version_2 0x20071026 +.\" commit e338d263a76af78fe8f38a72131188b58fceb591 +.\" added 64 bit capability support +#define _linux_capability_u32s_2 2 + + /* v3 added in linux 2.6.26 */ +#define _linux_capability_version_3 0x20080522 +.\" commit ca05a99a54db1db5bca72eccb5866d2a86f8517f +#define _linux_capability_u32s_3 2 + +typedef struct __user_cap_header_struct { + __u32 version; + int pid; +} *cap_user_header_t; + +typedef struct __user_cap_data_struct { + __u32 effective; + __u32 permitted; + __u32 inheritable; +} *cap_user_data_t; +.ee +.in +.pp +the +.ir effective , +.ir permitted , +and +.i inheritable +fields are bit masks of the capabilities defined in +.br capabilities (7). +note that the +.b cap_* +values are bit indexes and need to be bit-shifted before oring into +the bit fields. +to define the structures for passing to the system call, you have to use the +.i struct __user_cap_header_struct +and +.i struct __user_cap_data_struct +names because the typedefs are only pointers. +.pp +kernels prior to 2.6.25 prefer +32-bit capabilities with version +.br _linux_capability_version_1 . +linux 2.6.25 added 64-bit capability sets, with version +.br _linux_capability_version_2 . +there was, however, an api glitch, and linux 2.6.26 added +.br _linux_capability_version_3 +to fix the problem. +.pp +note that 64-bit capabilities use +.i datap[0] +and +.ir datap[1] , +whereas 32-bit capabilities use only +.ir datap[0] . +.pp +on kernels that support file capabilities (vfs capabilities support), +these system calls behave slightly differently. +this support was added as an option in linux 2.6.24, +and became fixed (nonoptional) in linux 2.6.33. +.pp +for +.br capget () +calls, one can probe the capabilities of any process by specifying its +process id with the +.i hdrp\->pid +field value. +.pp +for details on the data, see +.br capabilities (7). +.\" +.ss with vfs capabilities support +vfs capabilities employ a file extended attribute (see +.br xattr (7)) +to allow capabilities to be attached to executables. +this privilege model obsoletes kernel support for one process +asynchronously setting the capabilities of another. +that is, on kernels that have vfs capabilities support, when calling +.br capset (), +the only permitted values for +.i hdrp\->pid +are 0 or, equivalently, the value returned by +.br gettid (2). +.\" +.ss without vfs capabilities support +on older kernels that do not provide vfs capabilities support +.br capset () +can, if the caller has the +.br cap_setpcap +capability, be used to change not only the caller's own capabilities, +but also the capabilities of other threads. +the call operates on the capabilities of the thread specified by the +.i pid +field of +.i hdrp +when that is nonzero, or on the capabilities of the calling thread if +.i pid +is 0. +if +.i pid +refers to a single-threaded process, then +.i pid +can be specified as a traditional process id; +operating on a thread of a multithreaded process requires a thread id +of the type returned by +.br gettid (2). +for +.br capset (), +.i pid +can also be: \-1, meaning perform the change on all threads except the +caller and +.br init (1); +or a value less than \-1, in which case the change is applied +to all members of the process group whose id is \-\fipid\fp. +.sh return value +on success, zero is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.pp +the calls fail with the error +.br einval , +and set the +.i version +field of +.i hdrp +to the kernel preferred value of +.b _linux_capability_version_? +when an unsupported +.i version +value is specified. +in this way, one can probe what the current +preferred capability revision is. +.sh errors +.tp +.b efault +bad memory address. +.i hdrp +must not be null. +.i datap +may be null only when the user is trying to determine the preferred +capability version format supported by the kernel. +.tp +.b einval +one of the arguments was invalid. +.tp +.b eperm +an attempt was made to add a capability to the permitted set, or to set +a capability in the effective set that is not in the +permitted set. +.tp +.b eperm +an attempt was made to add a capability to the inheritable set, and either: +.rs +.ip * 3 +that capability was not in the caller's bounding set; or +.ip * +the capability was not in the caller's permitted set +and the caller lacked the +.b cap_setpcap +capability in its effective set. +.re +.tp +.b eperm +the caller attempted to use +.br capset () +to modify the capabilities of a thread other than itself, +but lacked sufficient privilege. +for kernels supporting vfs +capabilities, this is never permitted. +for kernels lacking vfs +support, the +.b cap_setpcap +capability is required. +(a bug in kernels before 2.6.11 meant that this error could also +occur if a thread without this capability tried to change its +own capabilities by specifying the +.i pid +field as a nonzero value (i.e., the value returned by +.br getpid (2)) +instead of 0.) +.tp +.b esrch +no such thread. +.sh conforming to +these system calls are linux-specific. +.sh notes +the portable interface to the capability querying and setting +functions is provided by the +.i libcap +library and is available here: +.br +.ur http://git.kernel.org/cgit\:/linux\:/kernel\:/git\:/morgan\:\:/libcap.git +.ue +.sh see also +.br clone (2), +.br gettid (2), +.br capabilities (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2006, 2019 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" additions from richard gooch and aeb, 971207 +.\" 2006-03-13, mtk, added ppoll() + various other rewordings +.\" 2006-07-01, mtk, added pollrdhup + various other wording and +.\" formatting changes. +.\" +.th poll 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +poll, ppoll \- wait for some event on a file descriptor +.sh synopsis +.nf +.b #include +.pp +.bi "int poll(struct pollfd *" fds ", nfds_t " nfds ", int " timeout ); +.pp +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "int ppoll(struct pollfd *" fds ", nfds_t " nfds , +.bi " const struct timespec *" tmo_p ", const sigset_t *" sigmask ); +.fi +.sh description +.br poll () +performs a similar task to +.br select (2): +it waits for one of a set of file descriptors to become ready +to perform i/o. +the linux-specific +.br epoll (7) +api performs a similar task, but offers features beyond those found in +.br poll (). +.pp +the set of file descriptors to be monitored is specified in the +.i fds +argument, which is an array of structures of the following form: +.pp +.in +4n +.ex +struct pollfd { + int fd; /* file descriptor */ + short events; /* requested events */ + short revents; /* returned events */ +}; +.ee +.in +.pp +the caller should specify the number of items in the +.i fds +array in +.ir nfds . +.pp +the field +.i fd +contains a file descriptor for an open file. +if this field is negative, then the corresponding +.i events +field is ignored and the +.i revents +field returns zero. +(this provides an easy way of ignoring a +file descriptor for a single +.br poll () +call: simply negate the +.i fd +field. +note, however, that this technique can't be used to ignore file descriptor 0.) +.pp +the field +.i events +is an input parameter, a bit mask specifying the events the application +is interested in for the file descriptor +.ir fd . +this field may be specified as zero, +in which case the only events that can be returned in +.i revents +are +.br pollhup , +.br pollerr , +and +.b pollnval +(see below). +.pp +the field +.i revents +is an output parameter, filled by the kernel with the events that +actually occurred. +the bits returned in +.i revents +can include any of those specified in +.ir events , +or one of the values +.br pollerr , +.br pollhup , +or +.br pollnval . +(these three bits are meaningless in the +.i events +field, and will be set in the +.i revents +field whenever the corresponding condition is true.) +.pp +if none of the events requested (and no error) has occurred for any +of the file descriptors, then +.br poll () +blocks until one of the events occurs. +.pp +the +.i timeout +argument specifies the number of milliseconds that +.br poll () +should block waiting for a file descriptor to become ready. +the call will block until either: +.ip \(bu 2 +a file descriptor becomes ready; +.ip \(bu +the call is interrupted by a signal handler; or +.ip \(bu +the timeout expires. +.pp +note that the +.i timeout +interval will be rounded up to the system clock granularity, +and kernel scheduling delays mean that the blocking interval +may overrun by a small amount. +specifying a negative value in +.i timeout +means an infinite timeout. +specifying a +.i timeout +of zero causes +.br poll () +to return immediately, even if no file descriptors are ready. +.pp +the bits that may be set/returned in +.i events +and +.i revents +are defined in \fi\fp: +.tp +.b pollin +there is data to read. +.tp +.b pollpri +there is some exceptional condition on the file descriptor. +possibilities include: +.rs +.ip \(bu 2 +there is out-of-band data on a tcp socket (see +.br tcp (7)). +.ip \(bu +a pseudoterminal master in packet mode has seen a state change on the slave +(see +.br ioctl_tty (2)). +.ip \(bu +a +.i cgroup.events +file has been modified (see +.br cgroups (7)). +.re +.tp +.b pollout +writing is now possible, though a write larger than the available space +in a socket or pipe will still block (unless +.b o_nonblock +is set). +.tp +.br pollrdhup " (since linux 2.6.17)" +stream socket peer closed connection, +or shut down writing half of connection. +the +.b _gnu_source +feature test macro must be defined +(before including +.i any +header files) +in order to obtain this definition. +.tp +.b pollerr +error condition (only returned in +.ir revents ; +ignored in +.ir events ). +this bit is also set for a file descriptor referring +to the write end of a pipe when the read end has been closed. +.tp +.b pollhup +hang up (only returned in +.ir revents ; +ignored in +.ir events ). +note that when reading from a channel such as a pipe or a stream socket, +this event merely indicates that the peer closed its end of the channel. +subsequent reads from the channel will return 0 (end of file) +only after all outstanding data in the channel has been consumed. +.tp +.b pollnval +invalid request: +.i fd +not open (only returned in +.ir revents ; +ignored in +.ir events ). +.pp +when compiling with +.b _xopen_source +defined, one also has the following, +which convey no further information beyond the bits listed above: +.tp +.b pollrdnorm +equivalent to +.br pollin . +.tp +.b pollrdband +priority band data can be read (generally unused on linux). +.\" pollrdband is used in the decnet protocol. +.tp +.b pollwrnorm +equivalent to +.br pollout . +.tp +.b pollwrband +priority data may be written. +.pp +linux also knows about, but does not use +.br pollmsg . +.ss ppoll() +the relationship between +.br poll () +and +.br ppoll () +is analogous to the relationship between +.br select (2) +and +.br pselect (2): +like +.br pselect (2), +.br ppoll () +allows an application to safely wait until either a file descriptor +becomes ready or until a signal is caught. +.pp +other than the difference in the precision of the +.i timeout +argument, the following +.br ppoll () +call: +.pp +.in +4n +.ex +ready = ppoll(&fds, nfds, tmo_p, &sigmask); +.ee +.in +.pp +is nearly equivalent to +.i atomically +executing the following calls: +.pp +.in +4n +.ex +sigset_t origmask; +int timeout; + +timeout = (tmo_p == null) ? \-1 : + (tmo_p\->tv_sec * 1000 + tmo_p\->tv_nsec / 1000000); +pthread_sigmask(sig_setmask, &sigmask, &origmask); +ready = poll(&fds, nfds, timeout); +pthread_sigmask(sig_setmask, &origmask, null); +.ee +.in +.pp +the above code segment is described as +.i nearly +equivalent because whereas a negative +.i timeout +value for +.br poll () +is interpreted as an infinite timeout, a negative value expressed in +.ir *tmo_p +results in an error from +.br ppoll (). +.pp +see the description of +.br pselect (2) +for an explanation of why +.br ppoll () +is necessary. +.pp +if the +.i sigmask +argument is specified as null, then +no signal mask manipulation is performed +(and thus +.br ppoll () +differs from +.br poll () +only in the precision of the +.i timeout +argument). +.pp +the +.i tmo_p +argument specifies an upper limit on the amount of time that +.br ppoll () +will block. +this argument is a pointer to a structure of the following form: +.pp +.in +4n +.ex +struct timespec { + long tv_sec; /* seconds */ + long tv_nsec; /* nanoseconds */ +}; +.ee +.in +.pp +if +.i tmo_p +is specified as null, then +.br ppoll () +can block indefinitely. +.sh return value +on success, +.br poll () +returns a nonnegative value which is the number of elements in the +.i pollfds +whose +.i revents +fields have been set to a nonzero value (indicating an event or an error). +a return value of zero indicates that the system call timed out +before any file descriptors became read. +.pp +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b efault +.i fds +points outside the process's accessible address space. +the array given as argument was not contained in the calling program's +address space. +.tp +.b eintr +a signal occurred before any requested event; see +.br signal (7). +.tp +.b einval +the +.i nfds +value exceeds the +.b rlimit_nofile +value. +.tp +.b einval +.rb ( ppoll ()) +the timeout value expressed in +.ir *ip +is invalid (negative). +.tp +.b enomem +unable to allocate memory for kernel data structures. +.sh versions +the +.br poll () +system call was introduced in linux 2.1.23. +on older kernels that lack this system call, +the glibc +.br poll () +wrapper function provides emulation using +.br select (2). +.pp +the +.br ppoll () +system call was added to linux in kernel 2.6.16. +the +.br ppoll () +library call was added in glibc 2.4. +.sh conforming to +.br poll () +conforms to posix.1-2001 and posix.1-2008. +.br ppoll () +is linux-specific. +.\" fixme . +.\" ppoll() is proposed for inclusion in posix: +.\" https://www.austingroupbugs.net/view.php?id=1263 +.\" netbsd 3.0 has a pollts() which is like linux ppoll(). +.sh notes +the operation of +.br poll () +and +.br ppoll () +is not affected by the +.br o_nonblock +flag. +.pp +on some other unix systems, +.\" darwin, according to a report by jeremy sequoia, relayed by josh triplett +.br poll () +can fail with the error +.b eagain +if the system fails to allocate kernel-internal resources, rather than +.b enomem +as linux does. +posix permits this behavior. +portable programs may wish to check for +.b eagain +and loop, just as with +.br eintr . +.pp +some implementations define the nonstandard constant +.b inftim +with the value \-1 for use as a +.ir timeout +for +.br poll (). +this constant is not provided in glibc. +.pp +for a discussion of what may happen if a file descriptor being monitored by +.br poll () +is closed in another thread, see +.br select (2). +.ss c library/kernel differences +the linux +.br ppoll () +system call modifies its +.i tmo_p +argument. +however, the glibc wrapper function hides this behavior +by using a local variable for the timeout argument that +is passed to the system call. +thus, the glibc +.br ppoll () +function does not modify its +.i tmo_p +argument. +.pp +the raw +.br ppoll () +system call has a fifth argument, +.ir "size_t sigsetsize" , +which specifies the size in bytes of the +.ir sigmask +argument. +the glibc +.br ppoll () +wrapper function specifies this argument as a fixed value +(equal to +.ir sizeof(kernel_sigset_t) ). +see +.br sigprocmask (2) +for a discussion on the differences between the kernel and the libc +notion of the sigset. +.sh bugs +see the discussion of spurious readiness notifications under the +bugs section of +.br select (2). +.sh examples +the program below opens each of the files named in its command-line +arguments and monitors the resulting file descriptors for readiness to read +.rb ( pollin ). +the program loops, repeatedly using +.br poll () +to monitor the file descriptors, +printing the number of ready file descriptors on return. +for each ready file descriptor, the program: +.ip \(bu 2 +displays the returned +.i revents +field in a human-readable form; +.ip \(bu +if the file descriptor is readable, reads some data from it, +and displays that data on standard output; and +.ip \(bu +if the file descriptors was not readable, +but some other event occurred (presumably +.br pollhup ), +closes the file descriptor. +.pp +suppose we run the program in one terminal, asking it to open a fifo: +.pp +.in +4n +.ex +$ \fbmkfifo myfifo\fp +$ \fb./poll_input myfifo\fp +.ee +.in +.pp +in a second terminal window, we then open the fifo for writing, +write some data to it, and close the fifo: +.pp +.in +4n +.ex +$ \fbecho aaaaabbbbbccccc > myfifo\fp +.ee +.in +.pp +in the terminal where we are running the program, we would then see: +.pp +.in +4n +.ex +opened "myfifo" on fd 3 +about to poll() +ready: 1 + fd=3; events: pollin pollhup + read 10 bytes: aaaaabbbbb +about to poll() +ready: 1 + fd=3; events: pollin pollhup + read 6 bytes: ccccc + +about to poll() +ready: 1 + fd=3; events: pollhup + closing fd 3 +all file descriptors closed; bye +.ee +.in +.pp +in the above output, we see that +.br poll () +returned three times: +.ip \(bu 2 +on the first return, the bits returned in the +.i revents +field were +.br pollin , +indicating that the file descriptor is readable, and +.br pollhup , +indicating that the other end of the fifo has been closed. +the program then consumed some of the available input. +.ip \(bu +the second return from +.br poll () +also indicated +.br pollin +and +.br pollhup ; +the program then consumed the last of the available input. +.ip \(bu +on the final return, +.br poll () +indicated only +.br pollhup +on the fifo, +at which point the file descriptor was closed and the program terminated. +.\" +.ss program source +\& +.ex +/* poll_input.c + + licensed under gnu general public license v2 or later. +*/ +#include +#include +#include +#include +#include +#include + +#define errexit(msg) do { perror(msg); exit(exit_failure); \e + } while (0) + +int +main(int argc, char *argv[]) +{ + int nfds, num_open_fds; + struct pollfd *pfds; + + if (argc < 2) { + fprintf(stderr, "usage: %s file...\en", argv[0]); + exit(exit_failure); + } + + num_open_fds = nfds = argc \- 1; + pfds = calloc(nfds, sizeof(struct pollfd)); + if (pfds == null) + errexit("malloc"); + + /* open each file on command line, and add it \(aqpfds\(aq array. */ + + for (int j = 0; j < nfds; j++) { + pfds[j].fd = open(argv[j + 1], o_rdonly); + if (pfds[j].fd == \-1) + errexit("open"); + + printf("opened \e"%s\e" on fd %d\en", argv[j + 1], pfds[j].fd); + + pfds[j].events = pollin; + } + + /* keep calling poll() as long as at least one file descriptor is + open. */ + + while (num_open_fds > 0) { + int ready; + + printf("about to poll()\en"); + ready = poll(pfds, nfds, \-1); + if (ready == \-1) + errexit("poll"); + + printf("ready: %d\en", ready); + + /* deal with array returned by poll(). */ + + for (int j = 0; j < nfds; j++) { + char buf[10]; + + if (pfds[j].revents != 0) { + printf(" fd=%d; events: %s%s%s\en", pfds[j].fd, + (pfds[j].revents & pollin) ? "pollin " : "", + (pfds[j].revents & pollhup) ? "pollhup " : "", + (pfds[j].revents & pollerr) ? "pollerr " : ""); + + if (pfds[j].revents & pollin) { + ssize_t s = read(pfds[j].fd, buf, sizeof(buf)); + if (s == \-1) + errexit("read"); + printf(" read %zd bytes: %.*s\en", + s, (int) s, buf); + } else { /* pollerr | pollhup */ + printf(" closing fd %d\en", pfds[j].fd); + if (close(pfds[j].fd) == \-1) + errexit("close"); + num_open_fds\-\-; + } + } + } + } + + printf("all file descriptors closed; bye\en"); + exit(exit_success); +} +.ee +.sh see also +.br restart_syscall (2), +.br select (2), +.br select_tut (2), +.br epoll (7), +.br time (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/_exit.2 + +.\" copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de) +.\" and copyright (c) 2011 michael kerrisk +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under gpl +.\" %%%license_end +.\" +.th catanh 3 2021-03-22 "" "linux programmer's manual" +.sh name +catanh, catanhf, catanhl \- complex arc tangents hyperbolic +.sh synopsis +.nf +.b #include +.pp +.bi "double complex catanh(double complex " z ); +.bi "float complex catanhf(float complex " z ); +.bi "long double complex catanhl(long double complex " z ); +.pp +link with \fi\-lm\fp. +.fi +.sh description +these functions calculate the complex arc hyperbolic tangent of +.ir z . +if \fiy\ =\ catanh(z)\fp, then \fiz\ =\ ctanh(y)\fp. +the imaginary part of +.i y +is chosen in the interval [\-pi/2,pi/2]. +.pp +one has: +.pp +.nf + catanh(z) = 0.5 * (clog(1 + z) \- clog(1 \- z)) +.fi +.sh versions +these functions first appeared in glibc in version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br catanh (), +.br catanhf (), +.br catanhl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.sh examples +.ex +/* link with "\-lm" */ + +#include +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + double complex z, c, f; + + if (argc != 3) { + fprintf(stderr, "usage: %s \en", argv[0]); + exit(exit_failure); + } + + z = atof(argv[1]) + atof(argv[2]) * i; + + c = catanh(z); + printf("catanh() = %6.3f %6.3f*i\en", creal(c), cimag(c)); + + f = 0.5 * (clog(1 + z) \- clog(1 \- z)); + printf("formula = %6.3f %6.3f*i\en", creal(f2), cimag(f2)); + + exit(exit_success); +} +.ee +.sh see also +.br atanh (3), +.br cabs (3), +.br cimag (3), +.br ctanh (3), +.br complex (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2002, 2011 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th rt_sigqueueinfo 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +rt_sigqueueinfo, rt_tgsigqueueinfo \- queue a signal and data +.sh synopsis +.nf +.br "#include " " /* definition of " si_* " constants */" +.br "#include " " /* definition of " sys_* " constants */" +.b #include +.pp +.bi "int syscall(sys_rt_sigqueueinfo, pid_t " tgid , +.bi " int " sig ", siginfo_t *" info ); +.bi "int syscall(sys_rt_tgsigqueueinfo, pid_t " tgid ", pid_t " tid , +.bi " int " sig ", siginfo_t *" info ); +.fi +.pp +.ir note : +there are no glibc wrappers for these system calls; see notes. +.sh description +the +.br rt_sigqueueinfo () +and +.br rt_tgsigqueueinfo () +system calls are the low-level interfaces used to send a signal plus data +to a process or thread. +the receiver of the signal can obtain the accompanying data +by establishing a signal handler with the +.br sigaction (2) +.b sa_siginfo +flag. +.pp +these system calls are not intended for direct application use; +they are provided to allow the implementation of +.br sigqueue (3) +and +.br pthread_sigqueue (3). +.pp +the +.br rt_sigqueueinfo () +system call sends the signal +.i sig +to the thread group with the id +.ir tgid . +(the term "thread group" is synonymous with "process", and +.i tid +corresponds to the traditional unix process id.) +the signal will be delivered to an arbitrary member of the thread group +(i.e., one of the threads that is not currently blocking the signal). +.pp +the +.i info +argument specifies the data to accompany the signal. +this argument is a pointer to a structure of type +.ir siginfo_t , +described in +.br sigaction (2) +(and defined by including +.ir ). +the caller should set the following fields in this structure: +.tp +.i si_code +this should be one of the +.b si_* +codes in the linux kernel source file +.ir include/asm\-generic/siginfo.h . +if the signal is being sent to any process other than the caller itself, +the following restrictions apply: +.rs +.ip * 3 +the code can't be a value greater than or equal to zero. +in particular, it can't be +.br si_user , +which is used by the kernel to indicate a signal sent by +.br kill (2), +and nor can it be +.br si_kernel , +which is used to indicate a signal generated by the kernel. +.ip * +the code can't (since linux 2.6.39) be +.br si_tkill , +which is used by the kernel to indicate a signal sent using +.\" tkill(2) or +.br tgkill (2). +.re +.tp +.i si_pid +this should be set to a process id, +typically the process id of the sender. +.tp +.i si_uid +this should be set to a user id, +typically the real user id of the sender. +.tp +.i si_value +this field contains the user data to accompany the signal. +for more information, see the description of the last +.ri ( "union sigval" ) +argument of +.br sigqueue (3). +.pp +internally, the kernel sets the +.i si_signo +field to the value specified in +.ir sig , +so that the receiver of the signal can also obtain +the signal number via that field. +.pp +the +.br rt_tgsigqueueinfo () +system call is like +.br rt_sigqueueinfo (), +but sends the signal and data to the single thread +specified by the combination of +.ir tgid , +a thread group id, +and +.ir tid , +a thread in that thread group. +.sh return value +on success, these system calls return 0. +on error, they return \-1 and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eagain +the limit of signals which may be queued has been reached. +(see +.br signal (7) +for further information.) +.tp +.b einval +.ir sig , +.ir tgid , +or +.ir tid +was invalid. +.tp +.b eperm +the caller does not have permission to send the signal to the target. +for the required permissions, see +.br kill (2). +.tp +.b eperm +.i tgid +specifies a process other than the caller and +.i info\->si_code +is invalid. +.tp +.b esrch +.br rt_sigqueueinfo (): +no thread group matching +.i tgid +was found. +.pp +.br rt_tgsigqueinfo (): +no thread matching +.i tgid +and +.i tid +was found. +.sh versions +the +.br rt_sigqueueinfo () +system call was added to linux in version 2.2. +the +.br rt_tgsigqueueinfo () +system call was added to linux in version 2.6.31. +.sh conforming to +these system calls are linux-specific. +.sh notes +since these system calls are not intended for application use, +there are no glibc wrapper functions; use +.br syscall (2) +in the unlikely case that you want to call them directly. +.pp +as with +.br kill (2), +the null signal (0) can be used to check if the specified process +or thread exists. +.sh see also +.br kill (2), +.br pidfd_send_signal (2), +.br sigaction (2), +.br sigprocmask (2), +.br tgkill (2), +.br pthread_sigqueue (3), +.br sigqueue (3), +.br signal (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/rpc.3 + +.so man7/system_data_types.7 + +.so man3/cpu_set.3 + +.\" copyright (c) 1993 michael haardt (michael@moria.de), +.\" fri apr 2 11:32:09 met dst 1993 +.\" and copyright (c) 2007 michael kerrisk +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" modified sat jul 24 17:35:48 1993 by rik faith (faith@cs.unc.edu) +.\" 2007-10-23 mtk: minor rewrites, and added paragraph on exit status +.\" +.th intro 8 2007-10-23 "linux" "linux programmer's manual" +.sh name +intro \- introduction to administration and privileged commands +.sh description +section 8 of the manual describes commands +which either can be or are used only by the superuser, +like system-administration commands, daemons, +and hardware-related commands. +.pp +as with the commands described in section 1, the commands described +in this section terminate with an exit status that indicates +whether the command succeeded or failed. +see +.br intro (1) +for more information. +.sh notes +.ss authors and copyright conditions +look at the header of the manual page source for the author(s) and copyright +conditions. +note that these can be different from page to page! +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/fenv.3 + +.so man3/openpty.3 + +.\" copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de) +.\" and copyright 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under gpl +.\" %%%license_end +.\" +.th sincos 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +sincos, sincosf, sincosl \- calculate sin and cos simultaneously +.sh synopsis +.nf +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "void sincos(double " x ", double *" sin ", double *" cos ); +.bi "void sincosf(float " x ", float *" sin ", float *" cos ); +.bi "void sincosl(long double " x ", long double *" sin ", long double *" cos ); +.fi +.pp +link with \fi\-lm\fp. +.sh description +several applications need sine and cosine of the same angle +.ir x . +these functions compute both at the same time, and store the results in +.i *sin +and +.ir *cos . +using this function can be more efficient than two separate calls to +.br sin (3) +and +.br cos (3). +.pp +if +.i x +is a nan, +a nan is returned in +.i *sin +and +.ir *cos . +.pp +if +.i x +is positive infinity or negative infinity, +a domain error occurs, and +a nan is returned in +.i *sin +and +.ir *cos . +.sh return value +these functions return +.ir void . +.sh errors +see +.br math_error (7) +for information on how to determine whether an error has occurred +when calling these functions. +.pp +the following errors can occur: +.tp +domain error: \fix\fp is an infinity +.i errno +is set to +.br edom +(but see bugs). +an invalid floating-point exception +.rb ( fe_invalid ) +is raised. +.sh versions +these functions first appeared in glibc in version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br sincos (), +.br sincosf (), +.br sincosl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +these functions are gnu extensions. +.sh notes +to see the performance advantage of +.br sincos (), +it may be necessary to disable +.br gcc (1) +built-in optimizations, using flags such as: +.pp +.in +4n +.ex +cc \-o \-lm \-fno\-builtin prog.c +.ee +.in +.sh bugs +before version 2.22, the glibc implementation did not set +.\" https://www.sourceware.org/bugzilla/show_bug.cgi?id=15467 +.i errno +to +.b edom +when a domain error occurred. +.sh see also +.br cos (3), +.br sin (3), +.br tan (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1993 by thomas koenig (ig25@rz.uni-karlsruhe.de) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified sat jul 24 21:42:42 1993 by rik faith +.\" modified tue oct 22 23:44:11 1996 by eric s. raymond +.\" modified thu jun 2 23:44:11 2016 by nikos mavrogiannopoulos +.th assert 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +assert \- abort the program if assertion is false +.sh synopsis +.nf +.b #include +.pp +.bi "void assert(scalar " expression ); +.fi +.sh description +this macro can help programmers find bugs in their programs, +or handle exceptional cases +via a crash that will produce limited debugging output. +.pp +if +.i expression +is false (i.e., compares equal to zero), +.br assert () +prints an error message to standard error +and terminates the program by calling +.br abort (3). +the error message includes the name of the file and function containing the +.br assert () +call, the source code line number of the call, and the text of the argument; +something like: +.pp +.in +4n +.ex +prog: some_file.c:16: some_func: assertion \`val == 0\(aq failed. +.ee +.in +.pp +if the macro +.b ndebug +is defined at the moment +.i +was last included, the macro +.br assert () +generates no code, and hence does nothing at all. +it is not recommended to define +.b ndebug +if using +.br assert () +to detect error conditions since the software +may behave non-deterministically. +.sh return value +no value is returned. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br assert () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c89, c99. +in c89, +.i expression +is required to be of type +.i int +and undefined behavior results if it is not, but in c99 +it may have any scalar type. +.\" see defect report 107 for more details. +.sh bugs +.br assert () +is implemented as a macro; if the expression tested has side-effects, +program behavior will be different depending on whether +.b ndebug +is defined. +this may create heisenbugs which go away when debugging +is turned on. +.sh see also +.br abort (3), +.br assert_perror (3), +.br exit (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1995, thomas k. dyas +.\" and copyright (c) 2019, michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" created 1995-08-06 thomas k. dyas +.\" modified 2000-07-01 aeb +.\" modified 2002-07-23 aeb +.\" modified, 27 may 2004, michael kerrisk +.\" added notes on capability requirements +.\" +.th setfsgid 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +setfsgid \- set group identity used for filesystem checks +.sh synopsis +.nf +.b #include +.pp +.bi "int setfsgid(gid_t " fsgid ); +.fi +.sh description +on linux, a process has both a filesystem group id and an effective group id. +the (linux-specific) filesystem group id is used +for permissions checking when accessing filesystem objects, +while the effective group id is used for some other kinds +of permissions checks (see +.br credentials (7)). +.pp +normally, the value of the process's filesystem group id +is the same as the value of its effective group id. +this is so, because whenever a process's effective group id is changed, +the kernel also changes the filesystem group id to be the same as +the new value of the effective group id. +a process can cause the value of its filesystem group id to diverge +from its effective group id by using +.br setfsgid () +to change its filesystem group id to the value given in +.ir fsgid . +.pp +.br setfsgid () +will succeed only if the caller is the superuser or if +.i fsgid +matches either the caller's real group id, effective group id, +saved set-group-id, or current the filesystem user id. +.sh return value +on both success and failure, +this call returns the previous filesystem group id of the caller. +.sh versions +this system call is present in linux since version 1.2. +.\" this system call is present since linux 1.1.44 +.\" and in libc since libc 4.7.6. +.sh conforming to +.br setfsgid () +is linux-specific and should not be used in programs intended +to be portable. +.sh notes +the filesystem group id concept and the +.br setfsgid () +system call were invented for historical reasons that are +no longer applicable on modern linux kernels. +see +.br setfsuid (2) +for a discussion of why the use of both +.br setfsuid (2) +and +.br setfsgid () +is nowadays unneeded. +.pp +the original linux +.br setfsgid () +system call supported only 16-bit group ids. +subsequently, linux 2.4 added +.br setfsgid32 () +supporting 32-bit ids. +the glibc +.br setfsgid () +wrapper function transparently deals with the variation across kernel versions. +.ss c library/kernel differences +in glibc 2.15 and earlier, +when the wrapper for this system call determines that the argument can't be +passed to the kernel without integer truncation (because the kernel +is old and does not support 32-bit group ids), +it will return \-1 and set \fierrno\fp to +.b einval +without attempting +the system call. +.sh bugs +no error indications of any kind are returned to the caller, +and the fact that both successful and unsuccessful calls return +the same value makes it impossible to directly determine +whether the call succeeded or failed. +instead, the caller must resort to looking at the return value +from a further call such as +.ir setfsgid(\-1) +(which will always fail), in order to determine if a preceding call to +.br setfsgid () +changed the filesystem group id. +at the very +least, +.b eperm +should be returned when the call fails (because the caller lacks the +.b cap_setgid +capability). +.sh see also +.br kill (2), +.br setfsuid (2), +.br capabilities (7), +.br credentials (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/backtrace.3 + +.so man3/hsearch.3 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" and copyright 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" +.\" modified 1993-07-24 by rik faith (faith@cs.unc.edu) +.\" modified 2002-08-10 walter harms +.\" (walter.harms@informatik.uni-oldenburg.de) +.\" modified 2003-11-18, 2004-10-05 aeb +.\" +.th remainder 3 2021-03-22 "" "linux programmer's manual" +.sh name +drem, dremf, dreml, remainder, remainderf, remainderl \- \ +floating-point remainder function +.sh synopsis +.nf +.b #include +.pp +/* the c99 versions */ +.bi "double remainder(double " x ", double " y ); +.bi "float remainderf(float " x ", float " y ); +.bi "long double remainderl(long double " x ", long double " y ); +.pp +/* obsolete synonyms */ +.bi "double drem(double " x ", double " y ); +.bi "float dremf(float " x ", float " y ); +.bi "long double dreml(long double " x ", long double " y ); +.pp +.fi +link with \fi\-lm\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br remainder (): +.nf + _isoc99_source || _posix_c_source >= 200112l + || _xopen_source >= 500 +.\" || _xopen_source && _xopen_source_extended + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.pp +.br remainderf (), +.br remainderl (): +.nf + _isoc99_source || _posix_c_source >= 200112l + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.pp +.br drem (), +.br dremf (), +.br dreml (): +.nf + /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.sh description +these +functions compute the remainder of dividing +.i x +by +.ir y . +the return value is +\fix\fp\-\fin\fp*\fiy\fp, +where +.i n +is the value +.ir "x\ /\ y" , +rounded to the nearest integer. +if the absolute value of +\fix\fp\-\fin\fp*\fiy\fp +is 0.5, +.i n +is chosen to be even. +.pp +these functions are unaffected by the current rounding mode (see +.br fenv (3)). +.pp +the +.br drem () +function does precisely the same thing. +.sh return value +on success, these +functions return the floating-point remainder, +\fix\fp\-\fin\fp*\fiy\fp. +if the return value is 0, it has the sign of +.ir x . +.pp +if +.i x +or +.i y +is a nan, a nan is returned. +.pp +if +.i x +is an infinity, +and +.i y +is not a nan, +a domain error occurs, and +a nan is returned. +.pp +if +.i y +is zero, +.\" fixme . instead, glibc gives a domain error even if x is a nan +and +.i x +is not a nan, +.\" interestingly, remquo(3) does not have the same problem. +a domain error occurs, and +a nan is returned. +.sh errors +see +.br math_error (7) +for information on how to determine whether an error has occurred +when calling these functions. +.pp +the following errors can occur: +.tp +domain error: \fix\fp is an infinity and \fiy\fp is not a nan +.i errno +is set to +.br edom +(but see bugs). +an invalid floating-point exception +.rb ( fe_invalid ) +is raised. +.ip +these functions do not set +.ir errno +for this case. +.tp +domain error: \fiy\fp is zero\" [xxx see bug above] and \fix\fp is not a nan +.i errno +is set to +.br edom . +an invalid floating-point exception +.rb ( fe_invalid ) +is raised. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br drem (), +.br dremf (), +.br dreml (), +.br remainder (), +.br remainderf (), +.br remainderl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +.\" iec 60559. +the functions +.br remainder (), +.br remainderf (), +and +.br remainderl () +are specified in c99, posix.1-2001, and posix.1-2008. +.pp +the function +.br drem () +is from 4.3bsd. +the +.i float +and +.i "long double" +variants +.br dremf () +and +.br dreml () +exist on some systems, such as tru64 and glibc2. +avoid the use of these functions in favor of +.br remainder () +etc. +.sh bugs +before glibc 2.15, +.\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=6779 +the call +.pp + remainder(nan(""), 0); +.pp +returned a nan, as expected, but wrongly caused a domain error. +since glibc 2.15, a silent nan (i.e., no domain error) is returned. +.pp +before glibc 2.15, +.\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=6783 +.i errno +was not set to +.br edom +for the domain error that occurs when +.i x +is an infinity and +.i y +is not a nan. +.sh examples +the call "remainder(29.0, 3.0)" returns \-1. +.sh see also +.br div (3), +.br fmod (3), +.br remquo (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/slist.3 + +.so man3/rpc.3 + +.\" copyright 2000 sam varshavchik +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references: rfc 2553 +.th getipnodebyname 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +getipnodebyname, getipnodebyaddr, freehostent \- get network +hostnames and addresses +.sh synopsis +.nf +.b #include +.b #include +.b #include +.pp +.bi "struct hostent *getipnodebyname(const char *" name ", int " af , +.bi " int " flags ", int *" error_num ); +.bi "struct hostent *getipnodebyaddr(const void *" addr ", size_t " len , +.bi " int " af ", int *" "error_num" ); +.bi "void freehostent(struct hostent *" "ip" ); +.fi +.sh description +these functions are deprecated (and unavailable in glibc). +use +.br getaddrinfo (3) +and +.br getnameinfo (3) +instead. +.pp +the +.br getipnodebyname () +and +.br getipnodebyaddr () +functions return the names and addresses of a network host. +these functions return a pointer to the +following structure: +.pp +.in +4n +.ex +struct hostent { + char *h_name; + char **h_aliases; + int h_addrtype; + int h_length; + char **h_addr_list; +}; +.ee +.in +.pp +these functions replace the +.br gethostbyname (3) +and +.br gethostbyaddr (3) +functions, which could access only the ipv4 network address family. +the +.br getipnodebyname () +and +.br getipnodebyaddr () +functions can access multiple network address families. +.pp +unlike the +.b gethostby +functions, +these functions return pointers to dynamically allocated memory. +the +.br freehostent () +function is used to release the dynamically allocated memory +after the caller no longer needs the +.i hostent +structure. +.ss getipnodebyname() arguments +the +.br getipnodebyname () +function +looks up network addresses for the host +specified by the +.i name +argument. +the +.i af +argument specifies one of the following values: +.tp +.b af_inet +the +.i name +argument points to a dotted-quad ipv4 address or a name +of an ipv4 network host. +.tp +.b af_inet6 +the +.i name +argument points to a hexadecimal ipv6 address or a name +of an ipv6 network host. +.pp +the +.i flags +argument specifies additional options. +more than one option can be specified by bitwise or-ing +them together. +.i flags +should be set to 0 +if no options are desired. +.tp +.b ai_v4mapped +this flag is used with +.b af_inet6 +to request a query for ipv4 addresses instead of +ipv6 addresses; the ipv4 addresses will +be mapped to ipv6 addresses. +.tp +.b ai_all +this flag is used with +.b ai_v4mapped +to request a query for both ipv4 and ipv6 addresses. +any ipv4 address found will be mapped to an ipv6 address. +.tp +.b ai_addrconfig +this flag is used with +.b af_inet6 +to +further request that queries for ipv6 addresses should not be made unless +the system has at least one ipv6 address assigned to a network interface, +and that queries for ipv4 addresses should not be made unless the +system has at least one ipv4 address assigned to a network interface. +this flag may be used by itself or with the +.b ai_v4mapped +flag. +.tp +.b ai_default +this flag is equivalent to +.br "(ai_addrconfig | ai_v4mapped)" . +.ss getipnodebyaddr() arguments +the +.br getipnodebyaddr () +function +looks up the name of the host whose +network address is +specified by the +.i addr +argument. +the +.i af +argument specifies one of the following values: +.tp +.b af_inet +the +.i addr +argument points to a +.i struct in_addr +and +.i len +must be set to +.ir "sizeof(struct in_addr)" . +.tp +.b af_inet6 +the +.i addr +argument points to a +.i struct in6_addr +and +.i len +must be set to +.ir "sizeof(struct in6_addr)" . +.sh return value +null is returned if an error occurred, and +.i error_num +will contain an error code from the following list: +.tp +.b host_not_found +the hostname or network address was not found. +.tp +.b no_address +the domain name server recognized the network address or name, +but no answer was returned. +this can happen if the network host has only ipv4 addresses and +a request has been made for ipv6 information only, or vice versa. +.tp +.b no_recovery +the domain name server returned a permanent failure response. +.tp +.b try_again +the domain name server returned a temporary failure response. +you might have better luck next time. +.pp +a successful query returns a pointer to a +.i hostent +structure that contains the following fields: +.tp +.i h_name +this is the official name of this network host. +.tp +.i h_aliases +this is an array of pointers to unofficial aliases for the same host. +the array is terminated by a null pointer. +.tp +.i h_addrtype +this is a copy of the +.i af +argument to +.br getipnodebyname () +or +.br getipnodebyaddr (). +.i h_addrtype +will always be +.b af_inet +if the +.i af +argument was +.br af_inet . +.i h_addrtype +will always be +.b af_inet6 +if the +.i af +argument was +.br af_inet6 . +.tp +.i h_length +this field will be set to +.i sizeof(struct in_addr) +if +.i h_addrtype +is +.br af_inet , +and to +.i sizeof(struct in6_addr) +if +.i h_addrtype +is +.br af_inet6 . +.tp +.i h_addr_list +this is an array of one or more pointers to network address structures for the +network host. +the array is terminated by a null pointer. +.sh conforming to +rfc\ 2553. +.\" not in posix.1-2001. +.sh notes +these functions were present in glibc 2.1.91-95, but were +removed again. +several unix-like systems support them, but all +call them deprecated. +.sh see also +.br getaddrinfo (3), +.br getnameinfo (3), +.br inet_ntop (3), +.br inet_pton (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/cexp2.3 + +.so man3/abs.3 + +.so man3/rpc.3 + +.\" copyright (c) ibm corp. 2012 +.\" author: jan glauber +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th s390_runtime_instr 2 2021-03-22 "linux programmer's manual" +.sh name +s390_runtime_instr \- enable/disable s390 cpu run-time instrumentation +.sh synopsis +.nf +.br "#include " " /* definition of " s390_* " constants */" +.br "#include " " /* definition of " sys_* " constants */" +.b #include +.pp +.bi "int syscall(sys_s390_runtime_instr, int " command ", int " signum ); +.fi +.pp +.ir note : +glibc provides no wrapper for +.br s390_runtime_instr (), +necessitating the use of +.br syscall (2). +.sh description +the +.br s390_runtime_instr () +system call starts or stops cpu run-time instrumentation for the +calling thread. +.pp +the +.ir command +argument controls whether run-time instrumentation is started +.rb ( s390_runtime_instr_start , +1) or stopped +.rb ( s390_runtime_instr_stop , +2) for the calling thread. +.pp +the +.ir signum +argument specifies the number of a real-time signal. +this argument was used to specify a signal number that should be delivered +to the thread if the run-time instrumentation buffer was full or if +the run-time-instrumentation-halted interrupt had occurred. +this feature was never used, +and in linux 4.4 support for this feature was removed; +.\" commit b38feccd663b55ab07116208b68e1ffc7c3c7e78 +thus, in current kernels, this argument is ignored. +.sh return value +on success, +.br s390_runtime_instr () +returns 0 and enables the thread for +run-time instrumentation by assigning the thread a default run-time +instrumentation control block. +the caller can then read and modify the control block and start the run-time +instrumentation. +on error, \-1 is returned and +.ir errno +is set to indicate the error. +.sh errors +.tp +.b einval +the value specified in +.ir command +is not a valid command. +.tp +.b einval +the value specified in +.ir signum +is not a real-time signal number. +from linux 4.4 onwards, the +.ir signum +argument has no effect, +so that an invalid signal number will not result in an error. +.tp +.b enomem +allocating memory for the run-time instrumentation control block failed. +.tp +.b eopnotsupp +the run-time instrumentation facility is not available. +.sh versions +this system call is available since linux 3.7. +.sh conforming to +this linux-specific system call is available only on the s390 architecture. +the run-time instrumentation facility is available +beginning with system z ec12. +.sh notes +the +.i asm/runtime_instr.h +header file is available +.\" commit df2f815a7df7edb5335a3bdeee6a8f9f6f9c35c4 +since linux 4.16. +.pp +starting with linux 4.4, +support for signalling was removed, as was the check whether +.ir signum +is a valid real-time signal. +for backwards compatibility with older kernels, it is recommended to pass +a valid real-time signal number in +.i signum +and install a handler for that signal. +.sh see also +.br syscall (2), +.br signal (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/getfsent.3 + +.so man4/loop.4 + +.so man3/xdr.3 + +.so man3/malloc.3 + +.so man3/rpc.3 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" and copyright 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified 1993-07-24 by rik faith (faith@cs.unc.edu) +.\" modified 2002-07-27 by walter harms +.\" (walter.harms@informatik.uni-oldenburg.de) +.\" +.th fmod 3 2021-03-22 "" "linux programmer's manual" +.sh name +fmod, fmodf, fmodl \- floating-point remainder function +.sh synopsis +.nf +.b #include +.pp +.bi "double fmod(double " x ", double " y ); +.bi "float fmodf(float " x ", float " y ); +.bi "long double fmodl(long double " x ", long double " y ); +.fi +.pp +link with \fi\-lm\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br fmodf (), +.br fmodl (): +.nf + _isoc99_source || _posix_c_source >= 200112l + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.sh description +these functions compute the floating-point remainder of dividing +.i x +by +.ir y . +the return value is +.ir x +\- +.i n +* +.ir y , +where +.i n +is the quotient of +.i x +/ +.ir y , +rounded toward zero to an integer. +.sh return value +on success, these +functions return the value \fix\fp\ \-\ \fin\fp*\fiy\fp, +for some integer +.ir n , +such that the returned value has the same sign as +.i x +and a magnitude less than the magnitude of +.ir y . +.pp +if +.i x +or +.i y +is a nan, a nan is returned. +.pp +if +.i x +is an infinity, +a domain error occurs, and +a nan is returned. +.pp +if +.i y +is zero, +a domain error occurs, and +a nan is returned. +.pp +if +.i x +is +0 (\-0), and +.i y +is not zero, +0 (\-0) is returned. +.sh errors +see +.br math_error (7) +for information on how to determine whether an error has occurred +when calling these functions. +.pp +the following errors can occur: +.tp +domain error: \fix\fp is an infinity +.i errno +is set to +.br edom +(but see bugs). +an invalid floating-point exception +.rb ( fe_invalid ) +is raised. +.tp +domain error: \fiy\fp is zero +.i errno +is set to +.br edom . +an invalid floating-point exception +.rb ( fe_invalid ) +is raised. +.\" posix.1 documents an optional underflow error, but afaict it doesn't +.\" (can't?) occur -- mtk, jul 2008 +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br fmod (), +.br fmodf (), +.br fmodl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.pp +the variant returning +.i double +also conforms to +svr4, 4.3bsd, c89. +.sh bugs +before version 2.10, the glibc implementation did not set +.\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=6784 +.i errno +to +.b edom +when a domain error occurred for an infinite +.ir x . +.sh see also +.br remainder (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/carg.3 + +.\" copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de) +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under gpl +.\" %%%license_end +.\" +.th cpow 3 2021-03-22 "" "linux programmer's manual" +.sh name +cpow, cpowf, cpowl \- complex power function +.sh synopsis +.nf +.b #include +.pp +.bi "double complex cpow(double complex " x ", double complex " z ); +.bi "float complex cpowf(float complex " x ", float complex " z ); +.bi "long double complex cpowl(long double complex " x , +.bi " long double complex " z ); +.pp +link with \fi\-lm\fp. +.fi +.sh description +these functions calculate +.i x +raised to the power +.ir z +(with a branch cut for +.i x +along the negative real axis.) +.sh versions +these functions first appeared in glibc in version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br cpow (), +.br cpowf (), +.br cpowl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.sh see also +.br cabs (3), +.br pow (3), +.br complex (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/outb.2 + +.\" copyright (c) 2002, michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified 31 jan 2002, michael kerrisk +.\" added description of mmap2 +.\" modified, 2004-11-25, mtk -- removed stray #endif in prototype +.\" +.th mmap2 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +mmap2 \- map files or devices into memory +.sh synopsis +.nf +.br "#include " " /* definition of " map_* " and " prot_* " constants */" +.br "#include " " /* definition of " sys_* " constants */" +.br "#include +.pp +.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 +.br mmap (2), +which describes the glibc wrapper function that invokes this system call. +.pp +the +.br mmap2 () +system call provides the same interface as +.br mmap (2), +except that the final argument specifies the offset into the +file in 4096-byte units (instead of bytes, as is done by +.br mmap (2)). +this enables applications that use a 32-bit +.i off_t +to map large files (up to 2^44 bytes). +.sh return value +on success, +.br mmap2 () +returns a pointer to the mapped area. +on error, \-1 is returned and +.i errno +is set to indicate the error. +.sh errors +.tp +.b efault +problem with getting the data from user space. +.tp +.b einval +(various platforms where the page size is not 4096 bytes.) +.i "offset\ *\ 4096" +is not a multiple of the system page size. +.pp +.br mmap2 () +can also return any of the errors described in +.br mmap (2). +.sh versions +.br mmap2 () +is available since linux 2.3.31. +.sh conforming to +this system call is linux-specific. +.sh notes +on architectures where this system call is present, +the glibc +.br mmap () +wrapper function invokes this system call rather than the +.br mmap (2) +system call. +.pp +this system call does not exist on x86-64. +.pp +on ia64, the unit for +.i offset +is actually the system page size, rather than 4096 bytes. +.\" ia64 can have page sizes ranging from 4 kb to 64 kb. +.\" on cris, it looks like the unit might also be the page size, +.\" which is 8192 bytes. -- mtk, june 2007 +.sh see also +.br getpagesize (2), +.br mmap (2), +.br mremap (2), +.br msync (2), +.br shm_open (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/xdr.3 + +.so man3/tailq.3 + +.\" this page was taken from the 4.4bsd-lite cdrom (bsd license) +.\" +.\" %%%license_start(bsd_oneline_cdrom) +.\" this page was taken from the 4.4bsd-lite cdrom (bsd license) +.\" %%%license_end +.\" +.\" @(#)getrpcport.3r 2.2 88/08/02 4.0 rpcsrc; from 1.12 88/02/26 smi +.th getrpcport 3 2021-03-22 "" "linux programmer's manual" +.sh name +getrpcport \- get rpc port number +.sh synopsis +.nf +.b "#include " +.pp +.bi "int getrpcport(const char *" host ", unsigned long " prognum , +.bi " unsigned long " versnum ", unsigned int " proto ); +.fi +.sh description +.br getrpcport () +returns the port number for version +.i versnum +of the rpc program +.i prognum +running on +.i host +and using protocol +.ir proto . +it returns 0 if it cannot contact the portmapper, or if +.i prognum +is not registered. +if +.i prognum +is registered but not with version +.ir versnum , +it will still return a port number (for some version of the program) +indicating that the program is indeed registered. +the version mismatch will be detected upon the first call to the service. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br getrpcport () +t} thread safety mt-safe env locale +.te +.hy +.ad +.sp 1 +.sh conforming to +not in posix.1. +present on the bsds, solaris, and many other systems. +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/rcmd.3 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" and copyright 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified 1993-07-24 by rik faith (faith@cs.unc.edu) +.\" modified 2002-07-27 by walter harms +.\" (walter.harms@informatik.uni-oldenburg.de) +.\" +.th asinh 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +asinh, asinhf, asinhl \- inverse hyperbolic sine function +.sh synopsis +.nf +.b #include +.pp +.bi "double asinh(double " x ); +.bi "float asinhf(float " x ); +.bi "long double asinhl(long double " x ); +.fi +.pp +link with \fi\-lm\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br asinh (): +.nf + _isoc99_source || _posix_c_source >= 200112l + || _xopen_source >= 500 +.\" || _xopen_source && _xopen_source_extended + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.pp +.br asinhf (), +.br asinhl (): +.nf + _isoc99_source || _posix_c_source >= 200112l + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.sh description +these functions calculate the inverse hyperbolic sine of +.ir x ; +that is the value whose hyperbolic sine is +.ir x . +.sh return value +on success, these functions return the inverse hyperbolic sine of +.ir x . +.pp +if +.i x +is a nan, a nan is returned. +.pp +if +.i x +is +0 (\-0), +0 (\-0) is returned. +.pp +if +.i x +is positive infinity (negative infinity), +positive infinity (negative infinity) is returned. +.\" +.\" posix.1-2001 documents an optional range error for subnormal x; +.\" glibc 2.8 does not do this. +.sh errors +no errors occur. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br asinh (), +.br asinhf (), +.br asinhl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.pp +the variant returning +.i double +also conforms to +svr4, 4.3bsd. +.sh see also +.br acosh (3), +.br atanh (3), +.br casinh (3), +.br cosh (3), +.br sinh (3), +.br tanh (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/stailq.3 + +.\" this man page is copyright (c) 1998 by andi kleen. +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" subject to the gpl. +.\" %%%license_end +.\" +.\" based on the original comments from alexey kuznetsov +.\" modified 2005-12-27 by hasso tepper +.\" $id: netlink.7,v 1.8 2000/06/22 13:23:00 ak exp $ +.th netlink 7 2021-03-22 "linux" "linux programmer's manual" +.sh name +netlink \- communication between kernel and user space (af_netlink) +.sh synopsis +.nf +.b #include +.b #include +.b #include +.pp +.bi "netlink_socket = socket(af_netlink, " socket_type ", " netlink_family ); +.fi +.sh description +netlink is used to transfer information between the kernel and +user-space processes. +it consists of a standard sockets-based interface for user space +processes and an internal kernel api for kernel modules. +the internal kernel interface is not documented in this manual page. +there is also an obsolete netlink interface +via netlink character devices; this interface is not documented here +and is provided only for backward compatibility. +.pp +netlink is a datagram-oriented service. +both +.b sock_raw +and +.b sock_dgram +are valid values for +.ir socket_type . +however, the netlink protocol does not distinguish between datagram +and raw sockets. +.pp +.i netlink_family +selects the kernel module or netlink group to communicate with. +the currently assigned netlink families are: +.tp +.br netlink_route +receives routing and link updates and may be used to modify the routing +tables (both ipv4 and ipv6), ip addresses, link parameters, +neighbor setups, queueing disciplines, traffic classes, and +packet classifiers (see +.br rtnetlink (7)). +.tp +.br netlink_w1 " (linux 2.6.13 to 2.16.17)" +messages from 1-wire subsystem. +.tp +.br netlink_usersock +reserved for user-mode socket protocols. +.tp +.br netlink_firewall " (up to and including linux 3.4)" +.\" removed by commit d16cf20e2f2f13411eece7f7fb72c17d141c4a84 +transport ipv4 packets from netfilter to user space. +used by +.i ip_queue +kernel module. +after a long period of being declared obsolete (in favor of the more advanced +.i nfnetlink_queue +feature), +.br netlink_firewall +was removed in linux 3.5. +.tp +.br netlink_sock_diag " (since linux 3.3)" +.\" commit 7f1fb60c4fc9fb29fbb406ac8c4cfb4e59e168d6 +query information about sockets of various protocol families from the kernel +(see +.br sock_diag (7)). +.tp +.br netlink_inet_diag " (since linux 2.6.14)" +an obsolete synonym for +.br netlink_sock_diag . +.tp +.br netlink_nflog " (up to and including linux 3.16)" +netfilter/iptables ulog. +.tp +.br netlink_xfrm +.\" fixme more details on netlink_xfrm needed. +ipsec. +.tp +.br netlink_selinux " (since linux 2.6.4)" +selinux event notifications. +.tp +.br netlink_iscsi " (since linux 2.6.15)" +.\" fixme more details on netlink_iscsi needed. +open-iscsi. +.tp +.br netlink_audit " (since linux 2.6.6)" +.\" fixme more details on netlink_audit needed. +auditing. +.tp +.br netlink_fib_lookup " (since linux 2.6.13)" +.\" fixme more details on netlink_fib_lookup needed. +access to fib lookup from user space. +.tp +.br netlink_connector " (since linux 2.6.14)" +kernel connector. +see +.i documentation/driver\-api/connector.rst +(or +.ir /documentation/connector/connector.* +.\" commit baa293e9544bea71361950d071579f0e4d5713ed +in kernel 5.2 and earlier) +in the linux kernel source tree for further information. +.tp +.br netlink_netfilter " (since linux 2.6.14)" +.\" fixme more details on netlink_netfilter needed. +netfilter subsystem. +.tp +.br netlink_scsitransport " (since linux 2.6.19)" +.\" commit 84314fd4740ad73550c76dee4a9578979d84af48 +.\" fixme more details on netlink_scsitransport needed. +scsi transports. +.tp +.br netlink_rdma " (since linux 3.0)" +.\" commit b2cbae2c248776d81cc265ff7d48405b6a4cc463 +.\" fixme more details on netlink_rdma needed. +infiniband rdma. +.tp +.br netlink_ip6_fw " (up to and including linux 3.4)" +transport ipv6 packets from netfilter to user space. +used by +.i ip6_queue +kernel module. +.tp +.b netlink_dnrtmsg +decnet routing messages. +.tp +.br netlink_kobject_uevent " (since linux 2.6.10)" +.\" fixme more details on netlink_kobject_uevent needed. +kernel messages to user space. +.tp +.br netlink_generic " (since linux 2.6.15)" +generic netlink family for simplified netlink usage. +.tp +.br netlink_crypto " (since linux 3.2)" +.\" commit a38f7907b926e4c6c7d389ad96cc38cec2e5a9e9 +.\" author: steffen klassert +netlink interface to request information about ciphers registered +with the kernel crypto api as well as allow configuration of the +kernel crypto api. +.pp +netlink messages consist of a byte stream with one or multiple +.i nlmsghdr +headers and associated payload. +the byte stream should be accessed only with the standard +.b nlmsg_* +macros. +see +.br netlink (3) +for further information. +.pp +in multipart messages (multiple +.i nlmsghdr +headers with associated payload in one byte stream) the first and all +following headers have the +.b nlm_f_multi +flag set, except for the last header which has the type +.br nlmsg_done . +.pp +after each +.i nlmsghdr +the payload follows. +.pp +.in +4n +.ex +struct nlmsghdr { + __u32 nlmsg_len; /* length of message including header */ + __u16 nlmsg_type; /* type of message content */ + __u16 nlmsg_flags; /* additional flags */ + __u32 nlmsg_seq; /* sequence number */ + __u32 nlmsg_pid; /* sender port id */ +}; +.ee +.in +.pp +.i nlmsg_type +can be one of the standard message types: +.b nlmsg_noop +message is to be ignored, +.b nlmsg_error +message signals an error and the payload contains an +.i nlmsgerr +structure, +.b nlmsg_done +message terminates a multipart message. +error messages get the +original request appened, unless the user requests to cap the +error message, and get extra error data if requested. +.pp +.in +4n +.ex +struct nlmsgerr { + int error; /* negative errno or 0 for acknowledgements */ + struct nlmsghdr msg; /* message header that caused the error */ + /* + * followed by the message contents unless netlink_cap_ack was set + * or the ack indicates success (error == 0). + * for example generic netlink message with attributes. + * message length is aligned with nlmsg_align() + */ + /* + * followed by tlvs defined in enum nlmsgerr_attrs + * if netlink_ext_ack was set + */ +}; +.ee +.in +.pp +a netlink family usually specifies more message types, see the +appropriate manual pages for that, for example, +.br rtnetlink (7) +for +.br netlink_route . +.nh +.ad l +.ts +tab(:); +l s +lb lx. +standard flag bits in \finlmsg_flags\fp +_ +nlm_f_request:t{ +must be set on all request messages. +t} +nlm_f_multi:t{ +the message is part of a multipart message terminated by +.br nlmsg_done . +t} +nlm_f_ack:t{ +request for an acknowledgement on success. +t} +nlm_f_echo:t{ +echo this request. +t} +.te +.ad +.hy +.\" no right adjustment for text blocks in tables +.nh +.ad l +.ts +tab(:); +l s +lb lx. +additional flag bits for get requests +_ +nlm_f_root:t{ +return the complete table instead of a single entry. +t} +nlm_f_match:t{ +return all entries matching criteria passed in message content. +not implemented yet. +t} +nlm_f_atomic:t{ +return an atomic snapshot of the table. +t} +nlm_f_dump:t{ +convenience macro; equivalent to +(nlm_f_root|nlm_f_match). +t} +.te +.ad +.hy +.\" fixme nlm_f_atomic is not used anymore? +.pp +note that +.b nlm_f_atomic +requires the +.b cap_net_admin +capability or an effective uid of 0. +.nh +.ad l +.ts +tab(:); +l s +lb lx. +additional flag bits for new requests +_ +nlm_f_replace:t{ +replace existing matching object. +t} +nlm_f_excl:t{ +don't replace if the object already exists. +t} +nlm_f_create:t{ +create object if it doesn't already exist. +t} +nlm_f_append:t{ +add to the end of the object list. +t} +.te +.ad +.hy +.pp +.i nlmsg_seq +and +.i nlmsg_pid +are used to track messages. +.i nlmsg_pid +shows the origin of the message. +note that there isn't a 1:1 relationship between +.i nlmsg_pid +and the pid of the process if the message originated from a netlink +socket. +see the +.b address formats +section for further information. +.pp +both +.i nlmsg_seq +and +.i nlmsg_pid +.\" fixme explain more about nlmsg_seq and nlmsg_pid. +are opaque to netlink core. +.pp +netlink is not a reliable protocol. +it tries its best to deliver a message to its destination(s), +but may drop messages when an out-of-memory condition or +other error occurs. +for reliable transfer the sender can request an +acknowledgement from the receiver by setting the +.b nlm_f_ack +flag. +an acknowledgement is an +.b nlmsg_error +packet with the error field set to 0. +the application must generate acknowledgements for +received messages itself. +the kernel tries to send an +.b nlmsg_error +message for every failed packet. +a user process should follow this convention too. +.pp +however, reliable transmissions from kernel to user are impossible +in any case. +the kernel can't send a netlink message if the socket buffer is full: +the message will be dropped and the kernel and the user-space process will +no longer have the same view of kernel state. +it is up to the application to detect when this happens (via the +.b enobufs +error returned by +.br recvmsg (2)) +and resynchronize. +.ss address formats +the +.i sockaddr_nl +structure describes a netlink client in user space or in the kernel. +a +.i sockaddr_nl +can be either unicast (only sent to one peer) or sent to +netlink multicast groups +.ri ( nl_groups +not equal 0). +.pp +.in +4n +.ex +struct sockaddr_nl { + sa_family_t nl_family; /* af_netlink */ + unsigned short nl_pad; /* zero */ + pid_t nl_pid; /* port id */ + __u32 nl_groups; /* multicast groups mask */ +}; +.ee +.in +.pp +.i nl_pid +is the unicast address of netlink socket. +it's always 0 if the destination is in the kernel. +for a user-space process, +.i nl_pid +is usually the pid of the process owning the destination socket. +however, +.i nl_pid +identifies a netlink socket, not a process. +if a process owns several netlink +sockets, then +.i nl_pid +can be equal to the process id only for at most one socket. +there are two ways to assign +.i nl_pid +to a netlink socket. +if the application sets +.i nl_pid +before calling +.br bind (2), +then it is up to the application to make sure that +.i nl_pid +is unique. +if the application sets it to 0, the kernel takes care of assigning it. +the kernel assigns the process id to the first netlink socket the process +opens and assigns a unique +.i nl_pid +to every netlink socket that the process subsequently creates. +.pp +.i nl_groups +is a bit mask with every bit representing a netlink group number. +each netlink family has a set of 32 multicast groups. +when +.br bind (2) +is called on the socket, the +.i nl_groups +field in the +.i sockaddr_nl +should be set to a bit mask of the groups which it wishes to listen to. +the default value for this field is zero which means that no multicasts +will be received. +a socket may multicast messages to any of the multicast groups by setting +.i nl_groups +to a bit mask of the groups it wishes to send to when it calls +.br sendmsg (2) +or does a +.br connect (2). +only processes with an effective uid of 0 or the +.b cap_net_admin +capability may send or listen to a netlink multicast group. +since linux 2.6.13, +.\" commit d629b836d151d43332492651dd841d32e57ebe3b +messages can't be broadcast to multiple groups. +any replies to a message received for a multicast group should be +sent back to the sending pid and the multicast group. +some linux kernel subsystems may additionally allow other users +to send and/or receive messages. +as at linux 3.0, the +.br netlink_kobject_uevent , +.br netlink_generic , +.br netlink_route , +and +.br netlink_selinux +groups allow other users to receive messages. +no groups allow other users to send messages. +.ss socket options +to set or get a netlink socket option, call +.br getsockopt (2) +to read or +.br setsockopt (2) +to write the option with the option level argument set to +.br sol_netlink . +unless otherwise noted, +.i optval +is a pointer to an +.ir int . +.tp +.br netlink_pktinfo " (since linux 2.6.14)" +.\" commit 9a4595bc7e67962f13232ee55a64e063062c3a99 +.\" author: patrick mchardy +enable +.b nl_pktinfo +control messages for received packets to get the extended +destination group number. +.tp +.br netlink_add_membership ,\ netlink_drop_membership " (since linux 2.6.14)" +.\" commit 9a4595bc7e67962f13232ee55a64e063062c3a99 +.\" author: patrick mchardy +join/leave a group specified by +.ir optval . +.tp +.br netlink_list_memberships " (since linux 4.2)" +.\" commit b42be38b2778eda2237fc759e55e3b698b05b315 +.\" author: david herrmann +retrieve all groups a socket is a member of. +.i optval +is a pointer to +.b __u32 +and +.i optlen +is the size of the array. +the array is filled with the full membership set of the +socket, and the required array size is returned in +.ir optlen . +.tp +.br netlink_broadcast_error " (since linux 2.6.30)" +.\" commit be0c22a46cfb79ab2342bb28fde99afa94ef868e +.\" author: pablo neira ayuso +when not set, +.b netlink_broadcast() +only reports +.b esrch +errors and silently ignore +.b enobufs +errors. +.tp +.br netlink_no_enobufs " (since linux 2.6.30)" +.\" commit 38938bfe3489394e2eed5e40c9bb8f66a2ce1405 +.\" author: pablo neira ayuso +this flag can be used by unicast and broadcast listeners to avoid receiving +.b enobufs +errors. +.tp +.br netlink_listen_all_nsid " (since linux 4.2)" +.\" commit 59324cf35aba5336b611074028777838a963d03b +.\" author: nicolas dichtel +when set, this socket will receive netlink notifications from +all network namespaces that have an +.i nsid +assigned into the network namespace where the socket has been opened. +the +.i nsid +is sent to user space via an ancillary data. +.tp +.br netlink_cap_ack " (since linux 4.3)" +.\" commit 0a6a3a23ea6efde079a5b77688541a98bf202721 +.\" author: christophe ricard +the kernel may fail to allocate the necessary room for the acknowledgement +message back to user space. +this option trims off the payload of the original netlink message. +the netlink message header is still included, so the user can guess from the +sequence number which message triggered the acknowledgement. +.sh versions +the socket interface to netlink first appeared linux 2.2. +.pp +linux 2.0 supported a more primitive device-based netlink interface +(which is still available as a compatibility option). +this obsolete interface is not described here. +.sh notes +it is often better to use netlink via +.i libnetlink +or +.i libnl +than via the low-level kernel interface. +.sh bugs +this manual page is not complete. +.sh examples +the following example creates a +.b netlink_route +netlink socket which will listen to the +.b rtmgrp_link +(network interface create/delete/up/down events) and +.b rtmgrp_ipv4_ifaddr +(ipv4 addresses add/delete events) multicast groups. +.pp +.in +4n +.ex +struct sockaddr_nl sa; + +memset(&sa, 0, sizeof(sa)); +sa.nl_family = af_netlink; +sa.nl_groups = rtmgrp_link | rtmgrp_ipv4_ifaddr; + +fd = socket(af_netlink, sock_raw, netlink_route); +bind(fd, (struct sockaddr *) &sa, sizeof(sa)); +.ee +.in +.pp +the next example demonstrates how to send a netlink message to the +kernel (pid 0). +note that the application must take care of message sequence numbers +in order to reliably track acknowledgements. +.pp +.in +4n +.ex +struct nlmsghdr *nh; /* the nlmsghdr with payload to send */ +struct sockaddr_nl sa; +struct iovec iov = { nh, nh\->nlmsg_len }; +struct msghdr msg; + +msg = { &sa, sizeof(sa), &iov, 1, null, 0, 0 }; +memset(&sa, 0, sizeof(sa)); +sa.nl_family = af_netlink; +nh\->nlmsg_pid = 0; +nh\->nlmsg_seq = ++sequence_number; +/* request an ack from kernel by setting nlm_f_ack */ +nh\->nlmsg_flags |= nlm_f_ack; + +sendmsg(fd, &msg, 0); +.ee +.in +.pp +and the last example is about reading netlink message. +.pp +.in +4n +.ex +int len; +/* 8192 to avoid message truncation on platforms with + page size > 4096 */ +struct nlmsghdr buf[8192/sizeof(struct nlmsghdr)]; +struct iovec iov = { buf, sizeof(buf) }; +struct sockaddr_nl sa; +struct msghdr msg; +struct nlmsghdr *nh; + +msg = { &sa, sizeof(sa), &iov, 1, null, 0, 0 }; +len = recvmsg(fd, &msg, 0); + +for (nh = (struct nlmsghdr *) buf; nlmsg_ok (nh, len); + nh = nlmsg_next (nh, len)) { + /* the end of multipart message */ + if (nh\->nlmsg_type == nlmsg_done) + return; + + if (nh\->nlmsg_type == nlmsg_error) + /* do some error handling */ + ... + + /* continue with parsing payload */ + ... +} +.ee +.in +.sh see also +.br cmsg (3), +.br netlink (3), +.br capabilities (7), +.br rtnetlink (7), +.br sock_diag (7) +.pp +.ur ftp://ftp.inr.ac.ru\:/ip\-routing\:/iproute2* +information about libnetlink +.ue +.pp +.ur http://www.infradead.org\:/\(titgr\:/libnl/ +information about libnl +.ue +.pp +rfc 3549 "linux netlink as an ip services protocol" +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2005 by michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th sigset 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +sigset, sighold, sigrelse, sigignore \- system v signal api +.sh synopsis +.nf +.b #include +.pp +.b typedef void (*sighandler_t)(int); +.pp +.bi "sighandler_t sigset(int " sig ", sighandler_t " disp ); +.pp +.bi "int sighold(int " sig ); +.bi "int sigrelse(int " sig ); +.bi "int sigignore(int " sig ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br sigset (), +.br sighold (), +.br sigrelse (), +.br sigignore (): +.nf + _xopen_source >= 500 +.\" || _xopen_source && _xopen_source_extended +.fi +.sh description +these functions are provided in glibc as a compatibility interface +for programs that make use of the historical system v signal api. +this api is obsolete: new applications should use the posix signal api +.rb ( sigaction (2), +.br sigprocmask (2), +etc.) +.pp +the +.br sigset () +function modifies the disposition of the signal +.ir sig . +the +.i disp +argument can be the address of a signal handler function, +or one of the following constants: +.tp +.b sig_dfl +reset the disposition of +.i sig +to the default. +.tp +.b sig_ign +ignore +.ir sig . +.tp +.b sig_hold +add +.i sig +to the process's signal mask, but leave the disposition of +.i sig +unchanged. +.pp +if +.i disp +specifies the address of a signal handler, then +.i sig +is added to the process's signal mask during execution of the handler. +.pp +if +.i disp +was specified as a value other than +.br sig_hold , +then +.i sig +is removed from the process's signal mask. +.pp +the dispositions for +.b sigkill +and +.b sigstop +cannot be changed. +.pp +the +.br sighold () +function adds +.i sig +to the calling process's signal mask. +.pp +the +.br sigrelse () +function removes +.i sig +from the calling process's signal mask. +.pp +the +.br sigignore () +function sets the disposition of +.i sig +to +.br sig_ign . +.sh return value +on success, +.br sigset () +returns +.b sig_hold +if +.i sig +was blocked before the call, +or the signal's previous disposition +if it was not blocked before the call. +on error, +.br sigset () +returns \-1, with +.i errno +set to indicate the error. +(but see bugs below.) +.pp +the +.br sighold (), +.br sigrelse (), +and +.br sigignore () +functions return 0 on success; on error, these functions return \-1 and set +.i errno +to indicate the error. +.sh errors +for +.br sigset () +see the errors under +.br sigaction (2) +and +.br sigprocmask (2). +.pp +for +.br sighold () +and +.br sigrelse () +see the errors under +.br sigprocmask (2). +.pp +for +.br sigignore (), +see the errors under +.br sigaction (2). +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br sigset (), +.br sighold (), +.br sigrelse (), +.br sigignore () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +svr4, posix.1-2001, posix.1-2008. +these functions are obsolete: do not use them in new programs. +posix.1-2008 marks +.br sighold (), +.br sigignore (), +.br sigpause (3), +.br sigrelse (), +and +.br sigset () +as obsolete, recommending the use of +.br sigaction (2), +.br sigprocmask (2), +.br pthread_sigmask (3), +and +.br sigsuspend (2) +instead. +.sh notes +these functions appeared in glibc version 2.1. +.pp +the +.i sighandler_t +type is a gnu extension; it is used on this page only to make the +.br sigset () +prototype more easily readable. +.pp +the +.br sigset () +function provides reliable signal handling semantics (as when calling +.br sigaction (2) +with +.i sa_mask +equal to 0). +.pp +on system v, the +.br signal () +function provides unreliable semantics (as when calling +.br sigaction (2) +with +.i sa_mask +equal to +.ir "sa_resethand | sa_nodefer" ). +on bsd, +.br signal () +provides reliable semantics. +posix.1-2001 leaves these aspects of +.br signal () +unspecified. +see +.br signal (2) +for further details. +.pp +in order to wait for a signal, +bsd and system v both provided a function named +.br sigpause (3), +but this function has a different argument on the two systems. +see +.br sigpause (3) +for details. +.sh bugs +in versions of glibc before 2.2, +.br sigset () +did not unblock +.i sig +if +.i disp +was specified as a value other than +.br sig_hold . +.pp +in versions of glibc before 2.5, +.br sigset () +does not correctly return the previous disposition of the signal +in two cases. +first, if +.i disp +is specified as +.br sig_hold , +then a successful +.br sigset () +always returns +.br sig_hold . +instead, it should return the previous disposition of the signal +(unless the signal was blocked, in which case +.b sig_hold +should be returned). +second, if the signal is currently blocked, then +the return value of a successful +.br sigset () +should be +.br sig_hold . +instead, the previous disposition of the signal is returned. +these problems have been fixed since glibc 2.5. +.\" see http://sourceware.org/bugzilla/show_bug.cgi?id=1951 +.sh see also +.br kill (2), +.br pause (2), +.br sigaction (2), +.br signal (2), +.br sigprocmask (2), +.br raise (3), +.br sigpause (3), +.br sigvec (3), +.br signal (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de) +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under gpl +.\" %%%license_end +.\" +.th conj 3 2021-03-22 "" "linux programmer's manual" +.sh name +conj, conjf, conjl \- calculate the complex conjugate +.sh synopsis +.nf +.b #include +.pp +.bi "double complex conj(double complex " z ); +.bi "float complex conjf(float complex " z ); +.bi "long double complex conjl(long double complex " z ); +.pp +link with \fi\-lm\fp. +.fi +.sh description +these functions return the complex conjugate value of +.ir z . +that is the value obtained by changing the sign of the imaginary part. +.pp +one has: +.pp +.nf + cabs(z) = csqrt(z * conj(z)) +.fi +.sh versions +these functions first appeared in glibc in version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br conj (), +.br conjf (), +.br conjl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.sh see also +.br cabs (3), +.br csqrt (3), +.br complex (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/qecvt.3 + +.so man3/resolver.3 + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" +.th iconv_close 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +iconv_close \- deallocate descriptor for character set conversion +.sh synopsis +.nf +.b #include +.pp +.bi "int iconv_close(iconv_t " cd ); +.fi +.sh description +the +.br iconv_close () +function deallocates a conversion descriptor +.i cd +previously allocated using +.br iconv_open (3). +.sh return value +on success, +.br iconv_close () +returns 0; otherwise, it returns \-1 and sets +.i errno +to indicate the error. +.sh versions +this function is available in glibc since version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br iconv_close () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, susv2. +.sh see also +.br iconv (3), +.br iconv_open (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/error.3 + +.so man3/pthread_attr_setaffinity_np.3 + +.\" copyright (c) 2012 by michael kerrisk +.\" with some material from a draft by +.\" stephan mueller +.\" in turn based on andi kleen's recvmmsg.2 page. +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th sendmmsg 2 2020-06-09 "linux" "linux programmer's manual" +.sh name +sendmmsg \- send multiple messages on a socket +.sh synopsis +.nf +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.bi "#include " +.pp +.bi "int sendmmsg(int " sockfd ", struct mmsghdr *" msgvec \ +", unsigned int " vlen "," +.bi " int " flags ");" +.fi +.sh description +the +.br sendmmsg () +system call is an extension of +.br sendmsg (2) +that allows the caller to transmit multiple messages on a socket +using a single system call. +(this has performance benefits for some applications.) +.\" see commit 228e548e602061b08ee8e8966f567c12aa079682 +.pp +the +.i sockfd +argument is the file descriptor of the socket +on which data is to be transmitted. +.pp +the +.i msgvec +argument is a pointer to an array of +.i mmsghdr +structures. +the size of this array is specified in +.ir vlen . +.pp +the +.i mmsghdr +structure is defined in +.i +as: +.pp +.in +4n +.ex +struct mmsghdr { + struct msghdr msg_hdr; /* message header */ + unsigned int msg_len; /* number of bytes transmitted */ +}; +.ee +.in +.pp +the +.i msg_hdr +field is a +.i msghdr +structure, as described in +.br sendmsg (2). +the +.i msg_len +field is used to return the number of bytes sent from the message in +.ir msg_hdr +(i.e., the same as the return value from a single +.br sendmsg (2) +call). +.pp +the +.i flags +argument contains flags ored together. +the flags are the same as for +.br sendmsg (2). +.pp +a blocking +.br sendmmsg () +call blocks until +.i vlen +messages have been sent. +a nonblocking call sends as many messages as possible +(up to the limit specified by +.ir vlen ) +and returns immediately. +.pp +on return from +.br sendmmsg (), +the +.i msg_len +fields of successive elements of +.ir msgvec +are updated to contain the number of bytes transmitted from the corresponding +.ir msg_hdr . +the return value of the call indicates the number of elements of +.i msgvec +that have been updated. +.sh return value +on success, +.br sendmmsg () +returns the number of messages sent from +.ir msgvec ; +if this is less than +.ir vlen , +the caller can retry with a further +.br sendmmsg () +call to send the remaining messages. +.pp +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +errors are as for +.br sendmsg (2). +an error is returned only if no datagrams could be sent. +see also bugs. +.\" commit 728ffb86f10873aaf4abd26dde691ee40ae731fe +.\" ... only return an error if no datagrams could be sent. +.\" if less than the requested number of messages were sent, the application +.\" must retry starting at the first failed one and if the problem is +.\" persistent the error will be returned. +.\" +.\" this matches the behavior of other syscalls like read/write - it +.\" is not an error if less than the requested number of elements are sent. +.sh versions +the +.br sendmmsg () +system call was added in linux 3.0. +support in glibc was added in version 2.14. +.sh conforming to +.br sendmmsg () +is linux-specific. +.sh notes +the value specified in +.i vlen +is capped to +.b uio_maxiov +(1024). +.\" commit 98382f419f32d2c12d021943b87dea555677144b +.\" net: cap number of elements for sendmmsg +.\" +.\" to limit the amount of time we can spend in sendmmsg, cap the +.\" number of elements to uio_maxiov (currently 1024). +.\" +.\" for error handling an application using sendmmsg needs to retry at +.\" the first unsent message, so capping is simpler and requires less +.\" application logic than returning einval. +.sh bugs +if an error occurs after at least one message has been sent, +the call succeeds, and returns the number of messages sent. +the error code is lost. +the caller can retry the transmission, +starting at the first failed message, but there is no guarantee that, +if an error is returned, it will be the same as the one that was lost +on the previous call. +.sh examples +the example below uses +.br sendmmsg () +to send +.i onetwo +and +.i three +in two distinct udp datagrams using one system call. +the contents of the first datagram originates from a pair of buffers. +.pp +.ex +#define _gnu_source +#include +#include +#include +#include +#include +#include + +int +main(void) +{ + int sockfd; + struct sockaddr_in addr; + struct mmsghdr msg[2]; + struct iovec msg1[2], msg2; + int retval; + + sockfd = socket(af_inet, sock_dgram, 0); + if (sockfd == \-1) { + perror("socket()"); + exit(exit_failure); + } + + addr.sin_family = af_inet; + addr.sin_addr.s_addr = htonl(inaddr_loopback); + addr.sin_port = htons(1234); + if (connect(sockfd, (struct sockaddr *) &addr, sizeof(addr)) == \-1) { + perror("connect()"); + exit(exit_failure); + } + + memset(msg1, 0, sizeof(msg1)); + msg1[0].iov_base = "one"; + msg1[0].iov_len = 3; + msg1[1].iov_base = "two"; + msg1[1].iov_len = 3; + + memset(&msg2, 0, sizeof(msg2)); + msg2.iov_base = "three"; + msg2.iov_len = 5; + + memset(msg, 0, sizeof(msg)); + msg[0].msg_hdr.msg_iov = msg1; + msg[0].msg_hdr.msg_iovlen = 2; + + msg[1].msg_hdr.msg_iov = &msg2; + msg[1].msg_hdr.msg_iovlen = 1; + + retval = sendmmsg(sockfd, msg, 2, 0); + if (retval == \-1) + perror("sendmmsg()"); + else + printf("%d messages sent\en", retval); + + exit(0); +} +.ee +.sh see also +.br recvmmsg (2), +.br sendmsg (2), +.br socket (2), +.br socket (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1987, 1990, 1993 +.\" the regents of the university of california. all rights reserved. +.\" +.\" %%%license_start(bsd_4_clause_ucb) +.\" redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. all advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" this product includes software developed by the university of +.\" california, berkeley and its contributors. +.\" 4. neither the name of the university nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" this software is provided by the regents and contributors ``as is'' and +.\" any express or implied warranties, including, but not limited to, the +.\" implied warranties of merchantability and fitness for a particular purpose +.\" are disclaimed. in no event shall the regents or contributors be liable +.\" for any direct, indirect, incidental, special, exemplary, or consequential +.\" damages (including, but not limited to, procurement of substitute goods +.\" or services; loss of use, data, or profits; or business interruption) +.\" however caused and on any theory of liability, whether in contract, strict +.\" liability, or tort (including negligence or otherwise) arising in any way +.\" out of the use of this software, even if advised of the possibility of +.\" such damage. +.\" %%%license_end +.\" +.\" @(#)hostname.7 8.2 (berkeley) 12/30/93 +.\" $freebsd: src/share/man/man7/hostname.7,v 1.7 2004/07/03 18:29:23 ru exp $ +.\" +.\" 2008-06-11, mtk, taken from freebsd 6.2 and modified for linux. +.\" +.th hostname 7 2019-05-09 "linux" "linux programmer's manual" +.sh name +hostname \- hostname resolution description +.sh description +hostnames are domains, where a domain is a hierarchical, dot-separated +list of subdomains; for example, the machine "monet", in the "example" +subdomain of the "com" domain would be represented as "monet.example.com". +.pp +each element of the hostname must be from 1 to 63 characters long and the +entire hostname, including the dots, can be at most 253 characters long. +valid characters for hostnames are +.br ascii (7) +letters from +.i a +to +.ir z , +the digits from +.i 0 +to +.ir 9 , +and the hyphen (\-). +a hostname may not start with a hyphen. +.pp +hostnames are often used with network client and server programs, +which must generally translate the name to an address for use. +(this task is generally performed by either +.br getaddrinfo (3) +or the obsolete +.br gethostbyname (3).) +.pp +hostnames are resolved by the nss framework in glibc according +to the +.b hosts +configuration in +.br nsswitch.conf . +the dns-based name resolver +(in the +.b dns +nss service module) resolves them in the following fashion. +.pp +if the name consists of a single component, that is, contains no dot, +and if the environment variable +.b hostaliases +is set to the name of a file, +that file is searched for any string matching the input hostname. +the file should consist of lines made up of two white-space separated strings, +the first of which is the hostname alias, +and the second of which is the complete hostname +to be substituted for that alias. +if a case-insensitive match is found between the hostname to be resolved +and the first field of a line in the file, the substituted name is looked +up with no further processing. +.pp +if the input name ends with a trailing dot, +the trailing dot is removed, +and the remaining name is looked up with no further processing. +.pp +if the input name does not end with a trailing dot, it is looked up +by searching through a list of domains until a match is found. +the default search list includes first the local domain, +then its parent domains with at least 2 name components (longest first). +for example, +in the domain cs.example.com, the name lithium.cchem will be checked first +as lithium.cchem.cs.example and then as lithium.cchem.example.com. +lithium.cchem.com will not be tried, as there is only one component +remaining from the local domain. +the search path can be changed from the default +by a system-wide configuration file (see +.br resolver (5)). +.sh see also +.br getaddrinfo (3), +.br gethostbyname (3), +.br nsswitch.conf (5), +.br resolver (5), +.br mailaddr (7), +.br named (8) +.pp +.ur http://www.ietf.org\:/rfc\:/rfc1123.txt +ietf rfc\ 1123 +.ue +.pp +.ur http://www.ietf.org\:/rfc\:/rfc1178.txt +ietf rfc\ 1178 +.ue +.\" .sh history +.\" hostname appeared in +.\" 4.2bsd. +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/tailq.3 + +.so man3/setaliasent.3 + +.\" copyright 2002 urs thuermann (urs@isnogud.escape.de) +.\" and copyright 2015 michael kerrisk +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, write to the free +.\" software foundation, inc., 59 temple place, suite 330, boston, ma 02111, +.\" usa. +.\" %%%license_end +.\" +.th loop 4 2021-03-22 "linux" "linux programmer's manual" +.sh name +loop, loop-control \- loop devices +.sh synopsis +.nf +#include +.fi +.sh description +the loop device is a block device that maps its data blocks not to a +physical device such as a hard disk or optical disk drive, +but to the blocks of +a regular file in a filesystem or to another block device. +this can be useful for example to provide a block device for a filesystem +image stored in a file, so that it can be mounted with the +.br mount (8) +command. +you could do +.pp +.in +4n +.ex +$ \fbdd if=/dev/zero of=file.img bs=1mib count=10\fp +$ \fbsudo losetup /dev/loop4 file.img\fp +$ \fbsudo mkfs \-t ext4 /dev/loop4\fp +$ \fbsudo mkdir /myloopdev\fp +$ \fbsudo mount /dev/loop4 /myloopdev\fp +.ee +.in +.pp +see +.br losetup (8) +for another example. +.pp +a transfer function can be specified for each loop device for +encryption and decryption purposes. +.pp +the following +.br ioctl (2) +operations are provided by the loop block device: +.tp +.b loop_set_fd +associate the loop device with the open file whose file descriptor is +passed as the (third) +.br ioctl (2) +argument. +.tp +.b loop_clr_fd +disassociate the loop device from any file descriptor. +.tp +.b loop_set_status +set the status of the loop device using the (third) +.br ioctl (2) +argument. +this argument is a pointer to a +.i loop_info +structure, defined in +.i +as: +.ip +.in +4n +.ex +struct loop_info { + int lo_number; /* ioctl r/o */ + dev_t lo_device; /* ioctl r/o */ + unsigned long lo_inode; /* ioctl r/o */ + dev_t lo_rdevice; /* ioctl r/o */ + int lo_offset; + int lo_encrypt_type; + int lo_encrypt_key_size; /* ioctl w/o */ + int lo_flags; /* ioctl r/w (r/o before + linux 2.6.25) */ + char lo_name[lo_name_size]; + unsigned char lo_encrypt_key[lo_key_size]; + /* ioctl w/o */ + unsigned long lo_init[2]; + char reserved[4]; +}; +.ee +.in +.ip +the encryption type +.ri ( lo_encrypt_type ) +should be one of +.br lo_crypt_none , +.br lo_crypt_xor , +.br lo_crypt_des , +.br lo_crypt_fish2 , +.br lo_crypt_blow , +.br lo_crypt_cast128 , +.br lo_crypt_idea , +.br lo_crypt_dummy , +.br lo_crypt_skipjack , +or (since linux 2.6.0) +.br lo_crypt_cryptoapi . +.ip +the +.i lo_flags +field is a bit mask that can include zero or more of the following: +.rs +.tp +.br lo_flags_read_only +the loopback device is read-only. +.tp +.br lo_flags_autoclear " (since linux 2.6.25)" +.\" commit 96c5865559cee0f9cbc5173f3c949f6ce3525581 +the loopback device will autodestruct on last close. +.tp +.br lo_flags_partscan " (since linux 3.2)" +.\" commit e03c8dd14915fabc101aa495828d58598dc5af98 +allow automatic partition scanning. +.tp +.br lo_flags_direct_io " (since linux 4.10)" +.\" commit 2e5ab5f379f96a6207c45be40c357ebb1beb8ef3 +use direct i/o mode to access the backing file. +.re +.ip +the only +.i lo_flags +that can be modified by +.br loop_set_status +are +.br lo_flags_autoclear +and +.br lo_flags_partscan . +.tp +.b loop_get_status +get the status of the loop device. +the (third) +.br ioctl (2) +argument must be a pointer to a +.ir "struct loop_info" . +.tp +.br loop_change_fd " (since linux 2.6.5)" +switch the backing store of the loop device to the new file identified +file descriptor specified in the (third) +.br ioctl (2) +argument, which is an integer. +this operation is possible only if the loop device is read-only and +the new backing store is the same size and type as the old backing store. +.tp +.br loop_set_capacity " (since linux 2.6.30)" +.\" commit 53d6660836f233df66490707365ab177e5fb2bb4 +resize a live loop device. +one can change the size of the underlying backing store and then use this +operation so that the loop driver learns about the new size. +this operation takes no argument. +.tp +.br loop_set_direct_io " (since linux 4.10)" +.\" commit ab1cb278bc7027663adbfb0b81404f8398437e11 +set direct i/o mode on the loop device, so that +it can be used to open backing file. +the (third) +.br ioctl (2) +argument is an unsigned long value. +a nonzero represents direct i/o mode. +.tp +.br loop_set_block_size " (since linux 4.14)" +.\" commit 89e4fdecb51cf5535867026274bc97de9480ade5 +set the block size of the loop device. +the (third) +.br ioctl (2) +argument is an unsigned long value. +this value must be a power of two in the range +[512,pagesize]; +otherwise, an +.b einval +error results. +.tp +.br loop_configure " (since linux 5.8)" +.\" commit 3448914e8cc550ba792d4ccc74471d1ca4293aae +setup and configure all loop device parameters in a single step using +the (third) +.br ioctl (2) +argument. +this argument is a pointer to a +.i loop_config +structure, defined in +.i +as: +.ip +.in +4n +.ex +struct loop_config { + __u32 fd; + __u32 block_size; + struct loop_info64 info; + __u64 __reserved[8]; +}; +.ee +.in +.ip +in addition to doing what +.br loop_set_status +can do, +.br loop_configure +can also be used to do the following: +.rs +.ip * 2 +set the correct block size immediately by setting +.ir loop_config.block_size ; +.ip * +explicitly request direct i/o mode by setting +.br lo_flags_direct_io +in +.ir loop_config.info.lo_flags ; +and +.ip * +explicitly request read-only mode by setting +.br lo_flags_read_only +in +.ir loop_config.info.lo_flags . +.re +.pp +since linux 2.6, there are two new +.br ioctl (2) +operations: +.tp +.br loop_set_status64 ", " loop_get_status64 +these are similar to +.br loop_set_status " and " loop_get_status +described above but use the +.i loop_info64 +structure, +which has some additional fields and a larger range for some other fields: +.ip +.in +4n +.ex +struct loop_info64 { + uint64_t lo_device; /* ioctl r/o */ + uint64_t lo_inode; /* ioctl r/o */ + uint64_t lo_rdevice; /* ioctl r/o */ + uint64_t lo_offset; + uint64_t lo_sizelimit; /* bytes, 0 == max available */ + uint32_t lo_number; /* ioctl r/o */ + uint32_t lo_encrypt_type; + uint32_t lo_encrypt_key_size; /* ioctl w/o */ + uint32_t lo_flags; i /* ioctl r/w (r/o before + linux 2.6.25) */ + uint8_t lo_file_name[lo_name_size]; + uint8_t lo_crypt_name[lo_name_size]; + uint8_t lo_encrypt_key[lo_key_size]; /* ioctl w/o */ + uint64_t lo_init[2]; +}; +.ee +.in +.ss /dev/loop-control +since linux 3.1, +.\" commit 770fe30a46a12b6fb6b63fbe1737654d28e84844 +the kernel provides the +.i /dev/loop\-control +device, which permits an application to dynamically find a free device, +and to add and remove loop devices from the system. +to perform these operations, one first opens +.ir /dev/loop\-control +and then employs one of the following +.br ioctl (2) +operations: +.tp +.b loop_ctl_get_free +allocate or find a free loop device for use. +on success, the device number is returned as the result of the call. +this operation takes no argument. +.tp +.b loop_ctl_add +add the new loop device whose device number is specified +as a long integer in the third +.br ioctl (2) +argument. +on success, the device index is returned as the result of the call. +if the device is already allocated, the call fails with the error +.br eexist . +.tp +.b loop_ctl_remove +remove the loop device whose device number is specified +as a long integer in the third +.br ioctl (2) +argument. +on success, the device number is returned as the result of the call. +if the device is in use, the call fails with the error +.br ebusy . +.sh files +.tp +.ir /dev/loop* +the loop block special device files. +.sh examples +the program below uses the +.i /dev/loop\-control +device to find a free loop device, opens the loop device, +opens a file to be used as the underlying storage for the device, +and then associates the loop device with the backing store. +the following shell session demonstrates the use of the program: +.pp +.in +4n +.ex +$ \fbdd if=/dev/zero of=file.img bs=1mib count=10\fp +10+0 records in +10+0 records out +10485760 bytes (10 mb) copied, 0.00609385 s, 1.7 gb/s +$ \fbsudo ./mnt_loop file.img\fp +loopname = /dev/loop5 +.ee +.in +.ss program source +\& +.ex +#include +#include +#include +#include +#include +#include + +#define errexit(msg) do { perror(msg); exit(exit_failure); \e + } while (0) + +int +main(int argc, char *argv[]) +{ + int loopctlfd, loopfd, backingfile; + long devnr; + char loopname[4096]; + + if (argc != 2) { + fprintf(stderr, "usage: %s backing\-file\en", argv[0]); + exit(exit_failure); + } + + loopctlfd = open("/dev/loop\-control", o_rdwr); + if (loopctlfd == \-1) + errexit("open: /dev/loop\-control"); + + devnr = ioctl(loopctlfd, loop_ctl_get_free); + if (devnr == \-1) + errexit("ioctl\-loop_ctl_get_free"); + + sprintf(loopname, "/dev/loop%ld", devnr); + printf("loopname = %s\en", loopname); + + loopfd = open(loopname, o_rdwr); + if (loopfd == \-1) + errexit("open: loopname"); + + backingfile = open(argv[1], o_rdwr); + if (backingfile == \-1) + errexit("open: backing\-file"); + + if (ioctl(loopfd, loop_set_fd, backingfile) == \-1) + errexit("ioctl\-loop_set_fd"); + + exit(exit_success); +} +.ee +.sh see also +.br losetup (8), +.br mount (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/ntp_gettime.3 + +.\" copyright (c), 1995, graeme w. wilford. (wilf.) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" wed jun 14 16:10:28 bst 1995 wilf. (g.wilford@@ee.surrey.ac.uk) +.\" +.th re_comp 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +re_comp, re_exec \- bsd regex functions +.sh synopsis +.nf +.b #define _regex_re_comp +.b #include +.b #include +.pp +.bi "char *re_comp(const char *" regex ); +.bi "int re_exec(const char *" string ); +.fi +.sh description +.br re_comp () +is used to compile the null-terminated regular expression pointed to by +.ir regex . +the compiled pattern occupies a static area, the pattern buffer, +which is overwritten by subsequent use of +.br re_comp (). +if +.i regex +is null, +no operation is performed and the pattern buffer's contents are not +altered. +.pp +.br re_exec () +is used to assess whether the null-terminated string pointed to by +.i string +matches the previously compiled +.ir regex . +.sh return value +.br re_comp () +returns null on successful compilation of +.i regex +otherwise it returns a pointer to an appropriate error message. +.pp +.br re_exec () +returns 1 for a successful match, zero for failure. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br re_comp (), +.br re_exec () +t} thread safety mt-unsafe +.te +.hy +.ad +.sp 1 +.sh conforming to +4.3bsd. +.sh notes +these functions are obsolete; the functions documented in +.br regcomp (3) +should be used instead. +.sh see also +.br regcomp (3), +.br regex (7), +gnu regex manual +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/timeradd.3 + +.so man3/getopt.3 + +.so man3/argz_add.3 + +.so man7/system_data_types.7 + +.so man3/isalpha.3 + +.so man3/rpc.3 + +.\" copyright 1999 roman maurer (roman.maurer@hermes.si) +.\" copyright 1993-1995 daniel quinlan (quinlan@yggdrasil.com) +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" slightly rearranged, aeb, 950713 +.\" updated, dpo, 990531 +.th iso_8859-2 7 2020-08-13 "linux" "linux programmer's manual" +.sh name +iso_8859-2 \- iso 8859-2 character set encoded in octal, decimal, +and hexadecimal +.sh description +the iso 8859 standard includes several 8-bit extensions to the ascii +character set (also known as iso 646-irv). +iso 8859-2 encodes the +latin characters used in many central and east european languages. +.ss iso 8859 alphabets +the full set of iso 8859 alphabets includes: +.ts +l l. +iso 8859-1 west european languages (latin-1) +iso 8859-2 central and east european languages (latin-2) +iso 8859-3 southeast european and miscellaneous languages (latin-3) +iso 8859-4 scandinavian/baltic languages (latin-4) +iso 8859-5 latin/cyrillic +iso 8859-6 latin/arabic +iso 8859-7 latin/greek +iso 8859-8 latin/hebrew +iso 8859-9 latin-1 modification for turkish (latin-5) +iso 8859-10 lappish/nordic/eskimo languages (latin-6) +iso 8859-11 latin/thai +iso 8859-13 baltic rim languages (latin-7) +iso 8859-14 celtic (latin-8) +iso 8859-15 west european languages (latin-9) +iso 8859-16 romanian (latin-10) +.te +.ss iso 8859-2 characters +the following table displays the characters in iso 8859-2 that +are printable and unlisted in the +.br ascii (7) +manual page. +.ts +l l l c lp-1. +oct dec hex char description +_ +240 160 a0   no-break space +241 161 a1 ą latin capital letter a with ogonek +242 162 a2 ˘ breve +243 163 a3 ł latin capital letter l with stroke +244 164 a4 ¤ currency sign +245 165 a5 ľ latin capital letter l with caron +246 166 a6 ś latin capital letter s with acute +247 167 a7 § section sign +250 168 a8 ¨ diaeresis +251 169 a9 š latin capital letter s with caron +252 170 aa ş latin capital letter s with cedilla +253 171 ab ť latin capital letter t with caron +254 172 ac ź latin capital letter z with acute +255 173 ad ­ soft hyphen +256 174 ae ž latin capital letter z with caron +257 175 af ż latin capital letter z with dot above +260 176 b0 ° degree sign +261 177 b1 ą latin small letter a with ogonek +262 178 b2 ˛ ogonek +263 179 b3 ł latin small letter l with stroke +264 180 b4 ´ acute accent +265 181 b5 ľ latin small letter l with caron +266 182 b6 ś latin small letter s with acute +267 183 b7 ˇ caron +270 184 b8 ¸ cedilla +271 185 b9 š latin small letter s with caron +272 186 ba ş latin small letter s with cedilla +273 187 bb ť latin small letter t with caron +274 188 bc ź latin small letter z with acute +275 189 bd ˝ double acute accent +276 190 be ž latin small letter z with caron +277 191 bf ż latin small letter z with dot above +300 192 c0 ŕ latin capital letter r with acute +301 193 c1 á latin capital letter a with acute +302 194 c2 â latin capital letter a with circumflex +303 195 c3 ă latin capital letter a with breve +304 196 c4 ä latin capital letter a with diaeresis +305 197 c5 ĺ latin capital letter l with acute +306 198 c6 ć latin capital letter c with acute +307 199 c7 ç latin capital letter c with cedilla +310 200 c8 č latin capital letter c with caron +311 201 c9 é latin capital letter e with acute +312 202 ca ę latin capital letter e with ogonek +313 203 cb ë latin capital letter e with diaeresis +314 204 cc ě latin capital letter e with caron +315 205 cd í latin capital letter i with acute +316 206 ce î latin capital letter i with circumflex +317 207 cf ď latin capital letter d with caron +320 208 d0 đ latin capital letter d with stroke +321 209 d1 ń latin capital letter n with acute +322 210 d2 ň latin capital letter n with caron +323 211 d3 ó latin capital letter o with acute +324 212 d4 ô latin capital letter o with circumflex +325 213 d5 ő latin capital letter o with double acute +326 214 d6 ö latin capital letter o with diaeresis +327 215 d7 × multiplication sign +330 216 d8 ř latin capital letter r with caron +331 217 d9 ů latin capital letter u with ring above +332 218 da ú latin capital letter u with acute +333 219 db ű latin capital letter u with double acute +334 220 dc ü latin capital letter u with diaeresis +335 221 dd ý latin capital letter y with acute +336 222 de ţ latin capital letter t with cedilla +337 223 df ß latin small letter sharp s +340 224 e0 ŕ latin small letter r with acute +341 225 e1 á latin small letter a with acute +342 226 e2 â latin small letter a with circumflex +343 227 e3 ă latin small letter a with breve +344 228 e4 ä latin small letter a with diaeresis +345 229 e5 ĺ latin small letter l with acute +346 230 e6 ć latin small letter c with acute +347 231 e7 ç latin small letter c with cedilla +350 232 e8 č latin small letter c with caron +351 233 e9 é latin small letter e with acute +352 234 ea ę latin small letter e with ogonek +353 235 eb ë latin small letter e with diaeresis +354 236 ec ě latin small letter e with caron +355 237 ed í latin small letter i with acute +356 238 ee î latin small letter i with circumflex +357 239 ef ď latin small letter d with caron +360 240 f0 đ latin small letter d with stroke +361 241 f1 ń latin small letter n with acute +362 242 f2 ň latin small letter n with caron +363 243 f3 ó latin small letter o with acute +364 244 f4 ô latin small letter o with circumflex +365 245 f5 ő latin small letter o with double acute +366 246 f6 ö latin small letter o with diaeresis +367 247 f7 ÷ division sign +370 248 f8 ř latin small letter r with caron +371 249 f9 ů latin small letter u with ring above +372 250 fa ú latin small letter u with acute +373 251 fb ű latin small letter u with double acute +374 252 fc ü latin small letter u with diaeresis +375 253 fd ý latin small letter y with acute +376 254 fe ţ latin small letter t with cedilla +377 255 ff ˙ dot above +.te +.sh notes +iso 8859-2 is also known as latin-2. +.sh see also +.br ascii (7), +.br charsets (7), +.br iso_8859\-1 (7), +.br iso_8859\-16 (7), +.br utf\-8 (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/gamma.3 + +.so man2/outb.2 + +.so man3/significand.3 + +.so man3/remainder.3 + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" +.th wcsncasecmp 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +wcsncasecmp \- compare two fixed-size wide-character strings, ignoring case +.sh synopsis +.nf +.b #include +.pp +.bi "int wcsncasecmp(const wchar_t *" s1 ", const wchar_t *" s2 ", size_t " n ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br wcsncasecmp (): +.nf + since glibc 2.10: + _posix_c_source >= 200809l + before glibc 2.10: + _gnu_source +.fi +.sh description +the +.br wcsncasecmp () +function is the wide-character equivalent of the +.br strncasecmp (3) +function. +it compares the wide-character string pointed to +by +.i s1 +and the wide-character string +pointed to by +.ir s2 , +but at most +.i n +wide characters from each string, ignoring case differences +.rb ( towupper (3), +.br towlower (3)). +.sh return value +the +.br wcsncasecmp () +function returns zero +if the wide-character strings at +.i s1 +and +.ir s2 , +truncated to at most length +.ir n , +are equal except +for case distinctions. +it returns a positive integer if truncated +.i s1 +is +greater than truncated +.ir s2 , +ignoring case. +it returns a negative integer +if truncated +.i s1 +is smaller than truncated +.ir s2 , +ignoring case. +.sh versions +the +.br wcsncasecmp () +function is provided in glibc since version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br wcsncasecmp () +t} thread safety mt-safe locale +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2008. +this function is not specified in posix.1-2001, +and is not widely available on other systems. +.sh notes +the behavior of +.br wcsncasecmp () +depends on the +.b lc_ctype +category of the +current locale. +.sh see also +.br strncasecmp (3), +.br wcsncmp (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/list.3 + +.\" +.\" copyright (c) 2017 red hat, inc. all rights reserved. +.\" written by david howells (dhowells@redhat.com) +.\" +.\" %%%license_start(gplv2+_sw_onepara) +.\" this program is free software; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license +.\" as published by the free software foundation; either version +.\" 2 of the license, or (at your option) any later version. +.\" %%%license_end +.\" +.th kernel_lockdown 7 2021-06-20 linux "linux programmer's manual" +.sh name +kernel_lockdown \- kernel image access prevention feature +.sh description +the kernel lockdown feature is designed to prevent both direct and indirect +access to a running kernel image, attempting to protect against unauthorized +modification of the kernel image and to prevent access to security and +cryptographic data located in kernel memory, whilst still permitting driver +modules to be loaded. +.pp +if a prohibited or restricted feature is accessed or used, the kernel will emit +a message that looks like: +.pp +.rs + lockdown: x: y is restricted, see man kernel_lockdown.7 +.re +.pp +where x indicates the process name and y indicates what is restricted. +.pp +on an efi-enabled x86 or arm64 machine, lockdown will be automatically enabled +if the system boots in efi secure boot mode. +.\" +.ss coverage +when lockdown is in effect, a number of features are disabled or have their +use restricted. +this includes special device files and kernel services that allow +direct access of the kernel image: +.pp +.rs +/dev/mem +.br +/dev/kmem +.br +/dev/kcore +.br +/dev/ioports +.br +bpf +.br +kprobes +.re +.pp +and the ability to directly configure and control devices, so as to prevent +the use of a device to access or modify a kernel image: +.ip \(bu 2 +the use of module parameters that directly specify hardware parameters to +drivers through the kernel command line or when loading a module. +.ip \(bu +the use of direct pci bar access. +.ip \(bu +the use of the ioperm and iopl instructions on x86. +.ip \(bu +the use of the kd*io console ioctls. +.ip \(bu +the use of the tiocsserial serial ioctl. +.ip \(bu +the alteration of msr registers on x86. +.ip \(bu +the replacement of the pcmcia cis. +.ip \(bu +the overriding of acpi tables. +.ip \(bu +the use of acpi error injection. +.ip \(bu +the specification of the acpi rdsp address. +.ip \(bu +the use of acpi custom methods. +.pp +certain facilities are restricted: +.ip \(bu 2 +only validly signed modules may be loaded (waived if the module file being +loaded is vouched for by ima appraisal). +.ip \(bu +only validly signed binaries may be kexec'd (waived if the binary image file +to be executed is vouched for by ima appraisal). +.ip \(bu +unencrypted hibernation/suspend to swap are disallowed as the kernel image is +saved to a medium that can then be accessed. +.ip \(bu +use of debugfs is not permitted as this allows a whole range of actions +including direct configuration of, access to and driving of hardware. +.ip \(bu +ima requires the addition of the "secure_boot" rules to the policy, +whether or not they are specified on the command line, +for both the built-in and custom policies in secure boot lockdown mode. +.sh versions +the kernel lockdown feature was added in linux 5.4. +.sh notes +the kernel lockdown feature is enabled by config_security_lockdown_lsm. +the +.i lsm=lsm1,...,lsmn +command line parameter controls the sequence of the initialization of +linux security modules. +it must contain the string +.i lockdown +to enable the kernel lockdown feature. +if the command line parameter is not specified, +the initialization falls back to the value of the deprecated +.i security= +command line parameter and further to the value of config_lsm. +.\" commit 000d388ed3bbed745f366ce71b2bb7c2ee70f449 +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1998 andries brouwer +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" 2003-08-24 fix for / by john kristoff + joey +.\" +.th glob 7 2020-08-13 "linux" "linux programmer's manual" +.sh name +glob \- globbing pathnames +.sh description +long ago, in unix\ v6, there was a program +.i /etc/glob +that would expand wildcard patterns. +soon afterward this became a shell built-in. +.pp +these days there is also a library routine +.br glob (3) +that will perform this function for a user program. +.pp +the rules are as follows (posix.2, 3.13). +.ss wildcard matching +a string is a wildcard pattern if it contains one of the +characters \(aq?\(aq, \(aq*\(aq, or \(aq[\(aq. +globbing is the operation +that expands a wildcard pattern into the list of pathnames +matching the pattern. +matching is defined by: +.pp +a \(aq?\(aq (not between brackets) matches any single character. +.pp +a \(aq*\(aq (not between brackets) matches any string, +including the empty string. +.pp +.b "character classes" +.pp +an expression "\fi[...]\fp" where the first character after the +leading \(aq[\(aq is not an \(aq!\(aq matches a single character, +namely any of the characters enclosed by the brackets. +the string enclosed by the brackets cannot be empty; +therefore \(aq]\(aq can be allowed between the brackets, provided +that it is the first character. +(thus, "\fi[][!]\fp" matches the +three characters \(aq[\(aq, \(aq]\(aq, and \(aq!\(aq.) +.pp +.b ranges +.pp +there is one special convention: +two characters separated by \(aq\-\(aq denote a range. +(thus, "\fi[a\-fa\-f0\-9]\fp" +is equivalent to "\fi[abcdefabcdef0123456789]\fp".) +one may include \(aq\-\(aq in its literal meaning by making it the +first or last character between the brackets. +(thus, "\fi[]\-]\fp" matches just the two characters \(aq]\(aq and \(aq\-\(aq, +and "\fi[\-\-0]\fp" matches the +three characters \(aq\-\(aq, \(aq.\(aq, \(aq0\(aq, since \(aq/\(aq +cannot be matched.) +.pp +.b complementation +.pp +an expression "\fi[!...]\fp" matches a single character, namely +any character that is not matched by the expression obtained +by removing the first \(aq!\(aq from it. +(thus, "\fi[!]a\-]\fp" matches any +single character except \(aq]\(aq, \(aqa\(aq, and \(aq\-\(aq.) +.pp +one can remove the special meaning of \(aq?\(aq, \(aq*\(aq, and \(aq[\(aq by +preceding them by a backslash, or, in case this is part of +a shell command line, enclosing them in quotes. +between brackets these characters stand for themselves. +thus, "\fi[[?*\e]\fp" matches the +four characters \(aq[\(aq, \(aq?\(aq, \(aq*\(aq, and \(aq\e\(aq. +.ss pathnames +globbing is applied on each of the components of a pathname +separately. +a \(aq/\(aq in a pathname cannot be matched by a \(aq?\(aq or \(aq*\(aq +wildcard, or by a range like "\fi[.\-0]\fp". +a range containing an explicit \(aq/\(aq character is syntactically incorrect. +(posix requires that syntactically incorrect patterns are left unchanged.) +.pp +if a filename starts with a \(aq.\(aq, +this character must be matched explicitly. +(thus, \firm\ *\fp will not remove .profile, and \fitar\ c\ *\fp will not +archive all your files; \fitar\ c\ .\fp is better.) +.ss empty lists +the nice and simple rule given above: "expand a wildcard pattern +into the list of matching pathnames" was the original unix +definition. +it allowed one to have patterns that expand into +an empty list, as in +.pp +.nf + xv \-wait 0 *.gif *.jpg +.fi +.pp +where perhaps no *.gif files are present (and this is not +an error). +however, posix requires that a wildcard pattern is left +unchanged when it is syntactically incorrect, or the list of +matching pathnames is empty. +with +.i bash +one can force the classical behavior using this command: +.pp + shopt \-s nullglob +.\" in bash v1, by setting allow_null_glob_expansion=true +.pp +(similar problems occur elsewhere. +for example, where old scripts have +.pp +.nf + rm \`find . \-name "*\(ti"\` +.fi +.pp +new scripts require +.pp +.nf + rm \-f nosuchfile \`find . \-name "*\(ti"\` +.fi +.pp +to avoid error messages from +.i rm +called with an empty argument list.) +.sh notes +.ss regular expressions +note that wildcard patterns are not regular expressions, +although they are a bit similar. +first of all, they match +filenames, rather than text, and secondly, the conventions +are not the same: for example, in a regular expression \(aq*\(aq means zero or +more copies of the preceding thing. +.pp +now that regular expressions have bracket expressions where +the negation is indicated by a \(aq\(ha\(aq, posix has declared the +effect of a wildcard pattern "\fi[\(ha...]\fp" to be undefined. +.ss character classes and internationalization +of course ranges were originally meant to be ascii ranges, +so that "\fi[\ \-%]\fp" stands for "\fi[\ !"#$%]\fp" and "\fi[a\-z]\fp" stands +for "any lowercase letter". +some unix implementations generalized this so that a range x\-y +stands for the set of characters with code between the codes for +x and for y. +however, this requires the user to know the +character coding in use on the local system, and moreover, is +not convenient if the collating sequence for the local alphabet +differs from the ordering of the character codes. +therefore, posix extended the bracket notation greatly, +both for wildcard patterns and for regular expressions. +in the above we saw three types of items that can occur in a bracket +expression: namely (i) the negation, (ii) explicit single characters, +and (iii) ranges. +posix specifies ranges in an internationally +more useful way and adds three more types: +.pp +(iii) ranges x\-y comprise all characters that fall between x +and y (inclusive) in the current collating sequence as defined +by the +.b lc_collate +category in the current locale. +.pp +(iv) named character classes, like +.pp +.nf +[:alnum:] [:alpha:] [:blank:] [:cntrl:] +[:digit:] [:graph:] [:lower:] [:print:] +[:punct:] [:space:] [:upper:] [:xdigit:] +.fi +.pp +so that one can say "\fi[[:lower:]]\fp" instead of "\fi[a\-z]\fp", and have +things work in denmark, too, where there are three letters past \(aqz\(aq +in the alphabet. +these character classes are defined by the +.b lc_ctype +category +in the current locale. +.pp +(v) collating symbols, like "\fi[.ch.]\fp" or "\fi[.a-acute.]\fp", +where the string between "\fi[.\fp" and "\fi.]\fp" is a collating +element defined for the current locale. +note that this may +be a multicharacter element. +.pp +(vi) equivalence class expressions, like "\fi[=a=]\fp", +where the string between "\fi[=\fp" and "\fi=]\fp" is any collating +element from its equivalence class, as defined for the +current locale. +for example, "\fi[[=a=]]\fp" might be equivalent +to "\fi[a\('a\(\`a\(:a\(^a]\fp", that is, +to "\fi[a[.a-acute.][.a-grave.][.a-umlaut.][.a-circumflex.]]\fp". +.sh see also +.br sh (1), +.br fnmatch (3), +.br glob (3), +.br locale (7), +.br regex (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sat jul 24 18:26:16 1993 by rik faith (faith@cs.unc.edu) +.\" modified thu apr 11 17:11:33 1996 by andries brouwer (aeb@cwi.nl): +.\" corrected type of compar routines, as suggested by +.\" miguel barreiro (enano@avalon.yaix.es). added example. +.\" modified sun sep 24 20:15:46 2000 by aeb, following petter reinholdtsen. +.\" modified 2001-12-26 by aeb, following joey. added versionsort. +.\" +.\" the pieces on scandirat(3) were copyright and licensed as follows. +.\" +.\" copyright (c) 2012, mark r. bannister +.\" based on text in mkfifoat.3 copyright (c) 2006, michael kerrisk +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th scandir 3 2021-08-27 "gnu" "linux programmer's manual" +.sh name +scandir, scandirat, alphasort, versionsort \- scan +a directory for matching entries +.sh synopsis +.nf +.b #include +.pp +.bi "int scandir(const char *restrict " dirp , +.bi " struct dirent ***restrict " namelist , +.bi " int (*" filter ")(const struct dirent *)," +.bi " int (*" compar ")(const struct dirent **," +.br " const struct dirent **));" +.pp +.bi "int alphasort(const struct dirent **" a ", const struct dirent **" b ); +.bi "int versionsort(const struct dirent **" a ", const struct dirent **" b ); +.pp +.br "#include " " /* definition of at_* constants */" +.b #include +.pp +.bi "int scandirat(int " dirfd ", const char *restrict " dirp , +.bi " struct dirent ***restrict " namelist , +.bi " int (*" filter ")(const struct dirent *)," +.bi " int (*" compar ")(const struct dirent **," +.bi " const struct dirent **));" +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br scandir (), +.br alphasort (): +.nf + /* since glibc 2.10: */ _posix_c_source >= 200809l + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.pp +.br versionsort (): +.nf + _gnu_source +.fi +.pp +.br scandirat (): +.nf + _gnu_source +.fi +.sh description +the +.br scandir () +function scans the directory \fidirp\fp, calling +\fifilter\fp() on each directory entry. +entries for which +\fifilter\fp() returns nonzero are stored in strings allocated via +.br malloc (3), +sorted using +.br qsort (3) +with the comparison +function \ficompar\fp(), and collected in array \finamelist\fp +which is allocated via +.br malloc (3). +if \fifilter\fp is null, all entries are selected. +.pp +the +.br alphasort () +and +.br versionsort () +functions can be used as the comparison function +.ir compar (). +the former sorts directory entries using +.br strcoll (3), +the latter using +.br strverscmp (3) +on the strings \fi(*a)\->d_name\fp and \fi(*b)\->d_name\fp. +.ss scandirat() +the +.br scandirat () +function operates in exactly the same way as +.br scandir (), +except for the differences described here. +.pp +if the pathname given in +.i dirp +is relative, then it is interpreted relative to the directory +referred to by the file descriptor +.i dirfd +(rather than relative to the current working directory of +the calling process, as is done by +.br scandir () +for a relative pathname). +.pp +if +.i dirp +is relative and +.i dirfd +is the special value +.br at_fdcwd , +then +.i dirp +is interpreted relative to the current working +directory of the calling process (like +.br scandir ()). +.pp +if +.i dirp +is absolute, then +.i dirfd +is ignored. +.pp +see +.br openat (2) +for an explanation of the need for +.br scandirat (). +.sh return value +the +.br scandir () +function returns the number of directory entries +selected. +on error, \-1 is returned, with +.i errno +set to indicate the error. +.pp +the +.br alphasort () +and +.br versionsort () +functions return an integer less than, equal to, +or greater than zero if the first argument is considered to be +respectively less than, equal to, or greater than the second. +.sh errors +.tp +.b ebadf +.rb ( scandirat ()) +.i dirp +is relative but +.i dirfd +is neither +.b at_fdcwd +nor a valid file descriptor. +.tp +.b enoent +the path in \fidirp\fr does not exist. +.tp +.b enomem +insufficient memory to complete the operation. +.tp +.b enotdir +the path in \fidirp\fr is not a directory. +.tp +.b enotdir +.rb ( scandirat ()) +.i dirp +is a relative pathname and +.i dirfd +is a file descriptor referring to a file other than a directory. +.sh versions +.br versionsort () +was added to glibc in version 2.1. +.pp +.br scandirat () +was added to glibc in version 2.15. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br scandir (), +.br scandirat () +t} thread safety mt-safe +t{ +.br alphasort (), +.br versionsort () +t} thread safety mt-safe locale +.te +.hy +.ad +.sp 1 +.sh conforming to +.br alphasort (), +.br scandir (): +4.3bsd, posix.1-2008. +.pp +.br versionsort () +and +.br scandirat () +are gnu extensions. +.\" .lp +.\" the functions +.\" .br scandir () +.\" and +.\" .br alphasort () +.\" are from 4.3bsd, and have been available under linux since libc4. +.\" libc4 and libc5 use the more precise prototype +.\" .sp +.\" .nf +.\" int alphasort(const struct dirent ** a, +.\" const struct dirent **b); +.\" .fi +.\" .sp +.\" but glibc 2.0 returns to the imprecise bsd prototype. +.sh notes +since glibc 2.1, +.br alphasort () +calls +.br strcoll (3); +earlier it used +.br strcmp (3). +.pp +before glibc 2.10, the two arguments of +.br alphasort () +and +.br versionsort () +were typed as +.ir "const void\ *" . +when +.br alphasort () +was standardized in posix.1-2008, +the argument type was specified as the type-safe +.ir "const struct dirent\ **", +and glibc 2.10 changed the definition of +.br alphasort () +(and the nonstandard +.br versionsort ()) +to match the standard. +.sh examples +the program below prints a list of the files in the current directory +in reverse order. +.\" +.ss program source +\& +.ex +#define _default_source +#include +#include +#include + +int +main(void) +{ + struct dirent **namelist; + int n; + + n = scandir(".", &namelist, null, alphasort); + if (n == \-1) { + perror("scandir"); + exit(exit_failure); + } + + while (n\-\-) { + printf("%s\en", namelist[n]\->d_name); + free(namelist[n]); + } + free(namelist); + + exit(exit_success); +} +.ee +.sh see also +.br closedir (3), +.br fnmatch (3), +.br opendir (3), +.br readdir (3), +.br rewinddir (3), +.br seekdir (3), +.br strcmp (3), +.br strcoll (3), +.br strverscmp (3), +.br telldir (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2001 andries brouwer . +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th trunc 3 2021-03-22 "" "linux programmer's manual" +.sh name +trunc, truncf, truncl \- round to integer, toward zero +.sh synopsis +.nf +.b #include +.pp +.bi "double trunc(double " x ); +.bi "float truncf(float " x ); +.bi "long double truncl(long double " x ); +.fi +.pp +link with \fi\-lm\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br trunc (), +.br truncf (), +.br truncl (): +.nf + _isoc99_source || _posix_c_source >= 200112l +.fi +.sh description +these functions round +.i x +to the nearest integer value that is not larger in magnitude than +.ir x . +.sh return value +these functions return the rounded integer value, in floating format. +.pp +if +.i x +is integral, infinite, or nan, +.i x +itself is returned. +.sh errors +no errors occur. +.sh versions +these functions first appeared in glibc in version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br trunc (), +.br truncf (), +.br truncl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.sh notes +the integral value returned by these functions may be too large +to store in an integer type +.ri ( int , +.ir long , +etc.). +to avoid an overflow, which will produce undefined results, +an application should perform a range check on the returned value +before assigning it to an integer type. +.sh see also +.br ceil (3), +.br floor (3), +.br lrint (3), +.br nearbyint (3), +.br rint (3), +.br round (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de) +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under gpl +.\" %%%license_end +.\" +.\" heavily based on glibc infopages, copyright free software foundation +.\" +.\" aeb, 2003, polished a little +.th mempcpy 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +mempcpy, wmempcpy \- copy memory area +.sh synopsis +.nf +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "void *mempcpy(void *restrict " dest ", const void *restrict " src \ +", size_t " n ); +.pp +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "wchar_t *wmempcpy(wchar_t *restrict " dest \ +", const wchar_t *restrict " src , +.bi " size_t " n ); +.fi +.sh description +the +.br mempcpy () +function is nearly identical to the +.br memcpy (3) +function. +it copies +.i n +bytes from the object beginning at +.i src +into the object pointed to by +.ir dest . +but instead of returning the value of +.i dest +it returns a pointer to the byte following the last written byte. +.pp +this function is useful in situations where a number of objects +shall be copied to consecutive memory positions. +.pp +the +.br wmempcpy () +function is identical but takes +.i wchar_t +type arguments and copies +.i n +wide characters. +.sh return value +.i dest ++ +.ir n . +.sh versions +.br mempcpy () +first appeared in glibc in version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br mempcpy (), +.br wmempcpy () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +this function is a gnu extension. +.sh examples +.ex +void * +combine(void *o1, size_t s1, void *o2, size_t s2) +{ + void *result = malloc(s1 + s2); + if (result != null) + mempcpy(mempcpy(result, o1, s1), o2, s2); + return result; +} +.ee +.sh see also +.br memccpy (3), +.br memcpy (3), +.br memmove (3), +.br wmemcpy (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/termios.3 + +.so man3/backtrace.3 + +.so man2/fstatat.2 + +.\" copyright (c) tom bjorkholm & markus kuhn, 1996 +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" 1996-04-01 tom bjorkholm +.\" first version written +.\" 1996-04-10 markus kuhn +.\" revision +.\" +.th sched_get_priority_max 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +sched_get_priority_max, sched_get_priority_min \- get static priority range +.sh synopsis +.nf +.b #include +.pp +.bi "int sched_get_priority_max(int " policy ); +.bi "int sched_get_priority_min(int " policy ); +.fi +.sh description +.br sched_get_priority_max () +returns the maximum priority value that can be used with the +scheduling algorithm identified by +.ir policy . +.br sched_get_priority_min () +returns the minimum priority value that can be used with the +scheduling algorithm identified by +.ir policy . +supported +.i policy +values are +.br sched_fifo , +.br sched_rr , +.br sched_other , +.br sched_batch , +.br sched_idle , +and +.br sched_deadline . +further details about these policies can be found in +.br sched (7). +.pp +processes with numerically higher priority values are scheduled before +processes with numerically lower priority values. +thus, the value +returned by +.br sched_get_priority_max () +will be greater than the +value returned by +.br sched_get_priority_min (). +.pp +linux allows the static priority range 1 to 99 for the +.b sched_fifo +and +.b sched_rr +policies, and the priority 0 for the remaining policies. +scheduling priority ranges for the various policies +are not alterable. +.pp +the range of scheduling priorities may vary on other posix systems, +thus it is a good idea for portable applications to use a virtual +priority range and map it to the interval given by +.br sched_get_priority_max () +and +.br sched_get_priority_min () +posix.1 requires +.\" posix.1-2001, posix.1-2008 (xbd 2.8.4) +a spread of at least 32 between the maximum and the minimum values for +.b sched_fifo +and +.br sched_rr . +.pp +posix systems on which +.br sched_get_priority_max () +and +.br sched_get_priority_min () +are available define +.b _posix_priority_scheduling +in +.ir . +.sh return value +on success, +.br sched_get_priority_max () +and +.br sched_get_priority_min () +return the maximum/minimum priority value for the named scheduling +policy. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b einval +the argument +.i policy +does not identify a defined scheduling policy. +.sh conforming to +posix.1-2001, posix.1-2008. +.sh see also +.ad l +.nh +.br sched_getaffinity (2), +.br sched_getparam (2), +.br sched_getscheduler (2), +.br sched_setaffinity (2), +.br sched_setparam (2), +.br sched_setscheduler (2), +.br sched (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de) +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under gpl +.\" %%%license_end +.\" +.\" heavily based on glibc documentation +.\" polished, added docs, removed glibc doc bug, 2002-07-20, aeb +.\" +.th malloc_hook 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +__malloc_hook, __malloc_initialize_hook, +__memalign_hook, __free_hook, __realloc_hook, +__after_morecore_hook \- malloc debugging variables +.sh synopsis +.nf +.b "#include " +.pp +.bi "void *(*volatile __malloc_hook)(size_t " size ", const void *" caller ); +.pp +.bi "void *(*volatile __realloc_hook)(void *" ptr ", size_t " size \ +", const void *" caller ); +.pp +.bi "void *(*volatile __memalign_hook)(size_t " alignment ", size_t " size , +.bi " const void *" caller ); +.pp +.bi "void (*volatile __free_hook)(void *" ptr ", const void *" caller ); +.pp +.b "void (*__malloc_initialize_hook)(void);" +.pp +.b "void (*volatile __after_morecore_hook)(void);" +.fi +.sh description +the gnu c library lets you modify the behavior of +.br malloc (3), +.br realloc (3), +and +.br free (3) +by specifying appropriate hook functions. +you can use these hooks +to help you debug programs that use dynamic memory allocation, +for example. +.pp +the variable +.b __malloc_initialize_hook +points at a function that is called once when the malloc implementation +is initialized. +this is a weak variable, so it can be overridden in +the application with a definition like the following: +.pp +.in +4n +.ex +void (*__malloc_initialize_hook)(void) = my_init_hook; +.ee +.in +.pp +now the function +.ir my_init_hook () +can do the initialization of all hooks. +.pp +the four functions pointed to by +.br __malloc_hook , +.br __realloc_hook , +.br __memalign_hook , +.b __free_hook +have a prototype like the functions +.br malloc (3), +.br realloc (3), +.br memalign (3), +.br free (3), +respectively, except that they have a final argument +.i caller +that gives the address of the caller of +.br malloc (3), +etc. +.pp +the variable +.b __after_morecore_hook +points at a function that is called each time after +.br sbrk (2) +was asked for more memory. +.sh conforming to +these functions are gnu extensions. +.sh notes +the use of these hook functions is not safe in multithreaded programs, +and they are now deprecated. +from glibc 2.24 onwards, the +.b __malloc_initialize_hook +variable has been removed from the api. +.\" https://bugzilla.redhat.com/show_bug.cgi?id=450187 +.\" http://sourceware.org/bugzilla/show_bug.cgi?id=9957 +programmers should instead preempt calls to the relevant functions +by defining and exporting functions such as "malloc" and "free". +.sh examples +here is a short example of how to use these variables. +.pp +.ex +#include +#include + +/* prototypes for our hooks */ +static void my_init_hook(void); +static void *my_malloc_hook(size_t, const void *); + +/* variables to save original hooks */ +static void *(*old_malloc_hook)(size_t, const void *); + +/* override initializing hook from the c library */ +void (*__malloc_initialize_hook)(void) = my_init_hook; + +static void +my_init_hook(void) +{ + old_malloc_hook = __malloc_hook; + __malloc_hook = my_malloc_hook; +} + +static void * +my_malloc_hook(size_t size, const void *caller) +{ + void *result; + + /* restore all old hooks */ + __malloc_hook = old_malloc_hook; + + /* call recursively */ + result = malloc(size); + + /* save underlying hooks */ + old_malloc_hook = __malloc_hook; + + /* printf() might call malloc(), so protect it too */ + printf("malloc(%zu) called from %p returns %p\en", + size, caller, result); + + /* restore our own hooks */ + __malloc_hook = my_malloc_hook; + + return result; +} +.ee +.sh see also +.br mallinfo (3), +.br malloc (3), +.br mcheck (3), +.br mtrace (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/isalpha.3 + +.so man3/error.3 + +.so man3/list.3 + +.so man2/statfs.2 + +.so man3/round.3 + +.\" man page generated from restructuredtext. +. +.th bpf-helpers 7 "" "" "" +.sh name +bpf-helpers \- list of ebpf helper functions +. +.nr rst2man-indent-level 0 +. +.de1 rstreportmargin +\\$1 \\n[an-margin] +level \\n[rst2man-indent-level] +level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] +- +\\n[rst2man-indent0] +\\n[rst2man-indent1] +\\n[rst2man-indent2] +.. +.de1 indent +.\" .rstreportmargin pre: +. rs \\$1 +. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] +. nr rst2man-indent-level +1 +.\" .rstreportmargin post: +.. +.de unindent +. re +.\" indent \\n[an-margin] +.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] +.nr rst2man-indent-level -1 +.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] +.in \\n[rst2man-indent\\n[rst2man-indent-level]]u +.. +.\" copyright (c) all bpf authors and contributors from 2014 to present. +. +.\" see git log include/uapi/linux/bpf.h in kernel tree for details. +. +.\" +. +.\" %%%license_start(verbatim) +. +.\" permission is granted to make and distribute verbatim copies of this +. +.\" manual provided the copyright notice and this permission notice are +. +.\" preserved on all copies. +. +.\" +. +.\" permission is granted to copy and distribute modified versions of this +. +.\" manual under the conditions for verbatim copying, provided that the +. +.\" entire resulting derived work is distributed under the terms of a +. +.\" permission notice identical to this one. +. +.\" +. +.\" since the linux kernel and libraries are constantly changing, this +. +.\" manual page may be incorrect or out-of-date. the author(s) assume no +. +.\" responsibility for errors or omissions, or for damages resulting from +. +.\" the use of the information contained herein. the author(s) may not +. +.\" have taken the same level of care in the production of this manual, +. +.\" which is licensed free of charge, as they might when working +. +.\" professionally. +. +.\" +. +.\" formatted or processed versions of this manual, if unaccompanied by +. +.\" the source, must acknowledge the copyright and authors of this work. +. +.\" %%%license_end +. +.\" +. +.\" please do not edit this file. it was generated from the documentation +. +.\" located in file include/uapi/linux/bpf.h of the linux kernel sources +. +.\" (helpers description), and from scripts/bpf_helpers_doc.py in the same +. +.\" repository (header and footer). +. +.sh description +.sp +the extended berkeley packet filter (ebpf) subsystem consists in programs +written in a pseudo\-assembly language, then attached to one of the several +kernel hooks and run in reaction of specific events. this framework differs +from the older, "classic" bpf (or "cbpf") in several aspects, one of them being +the ability to call special functions (or "helpers") from within a program. +these functions are restricted to a white\-list of helpers defined in the +kernel. +.sp +these helpers are used by ebpf programs to interact with the system, or with +the context in which they work. for instance, they can be used to print +debugging messages, to get the time since the system was booted, to interact +with ebpf maps, or to manipulate network packets. since there are several ebpf +program types, and that they do not run in the same context, each program type +can only call a subset of those helpers. +.sp +due to ebpf conventions, a helper can not have more than five arguments. +.sp +internally, ebpf programs call directly into the compiled helper functions +without requiring any foreign\-function interface. as a result, calling helpers +introduces no overhead, thus offering excellent performance. +.sp +this document is an attempt to list and document the helpers available to ebpf +developers. they are sorted by chronological order (the oldest helpers in the +kernel at the top). +.sh helpers +.indent 0.0 +.tp +.b \fbvoid *bpf_map_lookup_elem(struct bpf_map *\fp\fimap\fp\fb, const void *\fp\fikey\fp\fb)\fp +.indent 7.0 +.tp +.b description +perform a lookup in \fimap\fp for an entry associated to \fikey\fp\&. +.tp +.b return +map value associated to \fikey\fp, or \fbnull\fp if no entry was +found. +.unindent +.tp +.b \fblong bpf_map_update_elem(struct bpf_map *\fp\fimap\fp\fb, const void *\fp\fikey\fp\fb, const void *\fp\fivalue\fp\fb, u64\fp \fiflags\fp\fb)\fp +.indent 7.0 +.tp +.b description +add or update the value of the entry associated to \fikey\fp in +\fimap\fp with \fivalue\fp\&. \fiflags\fp is one of: +.indent 7.0 +.tp +.b \fbbpf_noexist\fp +the entry for \fikey\fp must not exist in the map. +.tp +.b \fbbpf_exist\fp +the entry for \fikey\fp must already exist in the map. +.tp +.b \fbbpf_any\fp +no condition on the existence of the entry for \fikey\fp\&. +.unindent +.sp +flag value \fbbpf_noexist\fp cannot be used for maps of types +\fbbpf_map_type_array\fp or \fbbpf_map_type_percpu_array\fp (all +elements always exist), the helper would return an error. +.tp +.b return +0 on success, or a negative error in case of failure. +.unindent +.tp +.b \fblong bpf_map_delete_elem(struct bpf_map *\fp\fimap\fp\fb, const void *\fp\fikey\fp\fb)\fp +.indent 7.0 +.tp +.b description +delete entry with \fikey\fp from \fimap\fp\&. +.tp +.b return +0 on success, or a negative error in case of failure. +.unindent +.tp +.b \fblong bpf_probe_read(void *\fp\fidst\fp\fb, u32\fp \fisize\fp\fb, const void *\fp\fiunsafe_ptr\fp\fb)\fp +.indent 7.0 +.tp +.b description +for tracing programs, safely attempt to read \fisize\fp bytes from +kernel space address \fiunsafe_ptr\fp and store the data in \fidst\fp\&. +.sp +generally, use \fbbpf_probe_read_user\fp() or +\fbbpf_probe_read_kernel\fp() instead. +.tp +.b return +0 on success, or a negative error in case of failure. +.unindent +.tp +.b \fbu64 bpf_ktime_get_ns(void)\fp +.indent 7.0 +.tp +.b description +return the time elapsed since system boot, in nanoseconds. +does not include time the system was suspended. +see: \fbclock_gettime\fp(\fbclock_monotonic\fp) +.tp +.b return +current \fiktime\fp\&. +.unindent +.tp +.b \fblong bpf_trace_printk(const char *\fp\fifmt\fp\fb, u32\fp \fifmt_size\fp\fb, ...)\fp +.indent 7.0 +.tp +.b description +this helper is a "printk()\-like" facility for debugging. it +prints a message defined by format \fifmt\fp (of size \fifmt_size\fp) +to file \fi/sys/kernel/debug/tracing/trace\fp from debugfs, if +available. it can take up to three additional \fbu64\fp +arguments (as an ebpf helpers, the total number of arguments is +limited to five). +.sp +each time the helper is called, it appends a line to the trace. +lines are discarded while \fi/sys/kernel/debug/tracing/trace\fp is +open, use \fi/sys/kernel/debug/tracing/trace_pipe\fp to avoid this. +the format of the trace is customizable, and the exact output +one will get depends on the options set in +\fi/sys/kernel/debug/tracing/trace_options\fp (see also the +\fireadme\fp file under the same directory). however, it usually +defaults to something like: +.indent 7.0 +.indent 3.5 +.sp +.nf +.ft c +telnet\-470 [001] .n.. 419421.045894: 0x00000001: +.ft p +.fi +.unindent +.unindent +.sp +in the above: +.indent 7.0 +.indent 3.5 +.indent 0.0 +.ip \(bu 2 +\fbtelnet\fp is the name of the current task. +.ip \(bu 2 +\fb470\fp is the pid of the current task. +.ip \(bu 2 +\fb001\fp is the cpu number on which the task is +running. +.ip \(bu 2 +in \fb\&.n..\fp, each character refers to a set of +options (whether irqs are enabled, scheduling +options, whether hard/softirqs are running, level of +preempt_disabled respectively). \fbn\fp means that +\fbtif_need_resched\fp and \fbpreempt_need_resched\fp +are set. +.ip \(bu 2 +\fb419421.045894\fp is a timestamp. +.ip \(bu 2 +\fb0x00000001\fp is a fake value used by bpf for the +instruction pointer register. +.ip \(bu 2 +\fb\fp is the message formatted with +\fifmt\fp\&. +.unindent +.unindent +.unindent +.sp +the conversion specifiers supported by \fifmt\fp are similar, but +more limited than for printk(). they are \fb%d\fp, \fb%i\fp, +\fb%u\fp, \fb%x\fp, \fb%ld\fp, \fb%li\fp, \fb%lu\fp, \fb%lx\fp, \fb%lld\fp, +\fb%lli\fp, \fb%llu\fp, \fb%llx\fp, \fb%p\fp, \fb%s\fp\&. no modifier (size +of field, padding with zeroes, etc.) is available, and the +helper will return \fb\-einval\fp (but print nothing) if it +encounters an unknown specifier. +.sp +also, note that \fbbpf_trace_printk\fp() is slow, and should +only be used for debugging purposes. for this reason, a notice +block (spanning several lines) is printed to kernel logs and +states that the helper should not be used "for production use" +the first time this helper is used (or more precisely, when +\fbtrace_printk\fp() buffers are allocated). for passing values +to user space, perf events should be preferred. +.tp +.b return +the number of bytes written to the buffer, or a negative error +in case of failure. +.unindent +.tp +.b \fbu32 bpf_get_prandom_u32(void)\fp +.indent 7.0 +.tp +.b description +get a pseudo\-random number. +.sp +from a security point of view, this helper uses its own +pseudo\-random internal state, and cannot be used to infer the +seed of other random functions in the kernel. however, it is +essential to note that the generator used by the helper is not +cryptographically secure. +.tp +.b return +a random 32\-bit unsigned value. +.unindent +.tp +.b \fbu32 bpf_get_smp_processor_id(void)\fp +.indent 7.0 +.tp +.b description +get the smp (symmetric multiprocessing) processor id. note that +all programs run with preemption disabled, which means that the +smp processor id is stable during all the execution of the +program. +.tp +.b return +the smp id of the processor running the program. +.unindent +.tp +.b \fblong bpf_skb_store_bytes(struct sk_buff *\fp\fiskb\fp\fb, u32\fp \fioffset\fp\fb, const void *\fp\fifrom\fp\fb, u32\fp \filen\fp\fb, u64\fp \fiflags\fp\fb)\fp +.indent 7.0 +.tp +.b description +store \filen\fp bytes from address \fifrom\fp into the packet +associated to \fiskb\fp, at \fioffset\fp\&. \fiflags\fp are a combination of +\fbbpf_f_recompute_csum\fp (automatically recompute the +checksum for the packet after storing the bytes) and +\fbbpf_f_invalidate_hash\fp (set \fiskb\fp\fb\->hash\fp, \fiskb\fp\fb\->swhash\fp and \fiskb\fp\fb\->l4hash\fp to 0). +.sp +a call to this helper is susceptible to change the underlying +packet buffer. therefore, at load time, all checks on pointers +previously done by the verifier are invalidated and must be +performed again, if the helper is used in combination with +direct packet access. +.tp +.b return +0 on success, or a negative error in case of failure. +.unindent +.tp +.b \fblong bpf_l3_csum_replace(struct sk_buff *\fp\fiskb\fp\fb, u32\fp \fioffset\fp\fb, u64\fp \fifrom\fp\fb, u64\fp \fito\fp\fb, u64\fp \fisize\fp\fb)\fp +.indent 7.0 +.tp +.b description +recompute the layer 3 (e.g. ip) checksum for the packet +associated to \fiskb\fp\&. computation is incremental, so the helper +must know the former value of the header field that was +modified (\fifrom\fp), the new value of this field (\fito\fp), and the +number of bytes (2 or 4) for this field, stored in \fisize\fp\&. +alternatively, it is possible to store the difference between +the previous and the new values of the header field in \fito\fp, by +setting \fifrom\fp and \fisize\fp to 0. for both methods, \fioffset\fp +indicates the location of the ip checksum within the packet. +.sp +this helper works in combination with \fbbpf_csum_diff\fp(), +which does not update the checksum in\-place, but offers more +flexibility and can handle sizes larger than 2 or 4 for the +checksum to update. +.sp +a call to this helper is susceptible to change the underlying +packet buffer. therefore, at load time, all checks on pointers +previously done by the verifier are invalidated and must be +performed again, if the helper is used in combination with +direct packet access. +.tp +.b return +0 on success, or a negative error in case of failure. +.unindent +.tp +.b \fblong bpf_l4_csum_replace(struct sk_buff *\fp\fiskb\fp\fb, u32\fp \fioffset\fp\fb, u64\fp \fifrom\fp\fb, u64\fp \fito\fp\fb, u64\fp \fiflags\fp\fb)\fp +.indent 7.0 +.tp +.b description +recompute the layer 4 (e.g. tcp, udp, or icmp) checksum for the +packet associated to \fiskb\fp\&. computation is incremental, so the +helper must know the former value of the header field that was +modified (\fifrom\fp), the new value of this field (\fito\fp), and the +number of bytes (2 or 4) for this field, stored on the lowest +four bits of \fiflags\fp\&. alternatively, it is possible to store +the difference between the previous and the new values of the +header field in \fito\fp, by setting \fifrom\fp and the four lowest +bits of \fiflags\fp to 0. for both methods, \fioffset\fp indicates the +location of the ip checksum within the packet. in addition to +the size of the field, \fiflags\fp can be added (bitwise or) actual +flags. with \fbbpf_f_mark_mangled_0\fp, a null checksum is left +untouched (unless \fbbpf_f_mark_enforce\fp is added as well), and +for updates resulting in a null checksum the value is set to +\fbcsum_mangled_0\fp instead. flag \fbbpf_f_pseudo_hdr\fp indicates +the checksum is to be computed against a pseudo\-header. +.sp +this helper works in combination with \fbbpf_csum_diff\fp(), +which does not update the checksum in\-place, but offers more +flexibility and can handle sizes larger than 2 or 4 for the +checksum to update. +.sp +a call to this helper is susceptible to change the underlying +packet buffer. therefore, at load time, all checks on pointers +previously done by the verifier are invalidated and must be +performed again, if the helper is used in combination with +direct packet access. +.tp +.b return +0 on success, or a negative error in case of failure. +.unindent +.tp +.b \fblong bpf_tail_call(void *\fp\fictx\fp\fb, struct bpf_map *\fp\fiprog_array_map\fp\fb, u32\fp \fiindex\fp\fb)\fp +.indent 7.0 +.tp +.b description +this special helper is used to trigger a "tail call", or in +other words, to jump into another ebpf program. the same stack +frame is used (but values on stack and in registers for the +caller are not accessible to the callee). this mechanism allows +for program chaining, either for raising the maximum number of +available ebpf instructions, or to execute given programs in +conditional blocks. for security reasons, there is an upper +limit to the number of successive tail calls that can be +performed. +.sp +upon call of this helper, the program attempts to jump into a +program referenced at index \fiindex\fp in \fiprog_array_map\fp, a +special map of type \fbbpf_map_type_prog_array\fp, and passes +\fictx\fp, a pointer to the context. +.sp +if the call succeeds, the kernel immediately runs the first +instruction of the new program. this is not a function call, +and it never returns to the previous program. if the call +fails, then the helper has no effect, and the caller continues +to run its subsequent instructions. a call can fail if the +destination program for the jump does not exist (i.e. \fiindex\fp +is superior to the number of entries in \fiprog_array_map\fp), or +if the maximum number of tail calls has been reached for this +chain of programs. this limit is defined in the kernel by the +macro \fbmax_tail_call_cnt\fp (not accessible to user space), +which is currently set to 32. +.tp +.b return +0 on success, or a negative error in case of failure. +.unindent +.tp +.b \fblong bpf_clone_redirect(struct sk_buff *\fp\fiskb\fp\fb, u32\fp \fiifindex\fp\fb, u64\fp \fiflags\fp\fb)\fp +.indent 7.0 +.tp +.b description +clone and redirect the packet associated to \fiskb\fp to another +net device of index \fiifindex\fp\&. both ingress and egress +interfaces can be used for redirection. the \fbbpf_f_ingress\fp +value in \fiflags\fp is used to make the distinction (ingress path +is selected if the flag is present, egress path otherwise). +this is the only flag supported for now. +.sp +in comparison with \fbbpf_redirect\fp() helper, +\fbbpf_clone_redirect\fp() has the associated cost of +duplicating the packet buffer, but this can be executed out of +the ebpf program. conversely, \fbbpf_redirect\fp() is more +efficient, but it is handled through an action code where the +redirection happens only after the ebpf program has returned. +.sp +a call to this helper is susceptible to change the underlying +packet buffer. therefore, at load time, all checks on pointers +previously done by the verifier are invalidated and must be +performed again, if the helper is used in combination with +direct packet access. +.tp +.b return +0 on success, or a negative error in case of failure. +.unindent +.tp +.b \fbu64 bpf_get_current_pid_tgid(void)\fp +.indent 7.0 +.tp +.b return +a 64\-bit integer containing the current tgid and pid, and +created as such: +\ficurrent_task\fp\fb\->tgid << 32 |\fp +\ficurrent_task\fp\fb\->pid\fp\&. +.unindent +.tp +.b \fbu64 bpf_get_current_uid_gid(void)\fp +.indent 7.0 +.tp +.b return +a 64\-bit integer containing the current gid and uid, and +created as such: \ficurrent_gid\fp \fb<< 32 |\fp \ficurrent_uid\fp\&. +.unindent +.tp +.b \fblong bpf_get_current_comm(void *\fp\fibuf\fp\fb, u32\fp \fisize_of_buf\fp\fb)\fp +.indent 7.0 +.tp +.b description +copy the \fbcomm\fp attribute of the current task into \fibuf\fp of +\fisize_of_buf\fp\&. the \fbcomm\fp attribute contains the name of +the executable (excluding the path) for the current task. the +\fisize_of_buf\fp must be strictly positive. on success, the +helper makes sure that the \fibuf\fp is nul\-terminated. on failure, +it is filled with zeroes. +.tp +.b return +0 on success, or a negative error in case of failure. +.unindent +.tp +.b \fbu32 bpf_get_cgroup_classid(struct sk_buff *\fp\fiskb\fp\fb)\fp +.indent 7.0 +.tp +.b description +retrieve the classid for the current task, i.e. for the net_cls +cgroup to which \fiskb\fp belongs. +.sp +this helper can be used on tc egress path, but not on ingress. +.sp +the net_cls cgroup provides an interface to tag network packets +based on a user\-provided identifier for all traffic coming from +the tasks belonging to the related cgroup. see also the related +kernel documentation, available from the linux sources in file +\fidocumentation/admin\-guide/cgroup\-v1/net_cls.rst\fp\&. +.sp +the linux kernel has two versions for cgroups: there are +cgroups v1 and cgroups v2. both are available to users, who can +use a mixture of them, but note that the net_cls cgroup is for +cgroup v1 only. this makes it incompatible with bpf programs +run on cgroups, which is a cgroup\-v2\-only feature (a socket can +only hold data for one version of cgroups at a time). +.sp +this helper is only available is the kernel was compiled with +the \fbconfig_cgroup_net_classid\fp configuration option set to +"\fby\fp" or to "\fbm\fp". +.tp +.b return +the classid, or 0 for the default unconfigured classid. +.unindent +.tp +.b \fblong bpf_skb_vlan_push(struct sk_buff *\fp\fiskb\fp\fb, __be16\fp \fivlan_proto\fp\fb, u16\fp \fivlan_tci\fp\fb)\fp +.indent 7.0 +.tp +.b description +push a \fivlan_tci\fp (vlan tag control information) of protocol +\fivlan_proto\fp to the packet associated to \fiskb\fp, then update +the checksum. note that if \fivlan_proto\fp is different from +\fbeth_p_8021q\fp and \fbeth_p_8021ad\fp, it is considered to +be \fbeth_p_8021q\fp\&. +.sp +a call to this helper is susceptible to change the underlying +packet buffer. therefore, at load time, all checks on pointers +previously done by the verifier are invalidated and must be +performed again, if the helper is used in combination with +direct packet access. +.tp +.b return +0 on success, or a negative error in case of failure. +.unindent +.tp +.b \fblong bpf_skb_vlan_pop(struct sk_buff *\fp\fiskb\fp\fb)\fp +.indent 7.0 +.tp +.b description +pop a vlan header from the packet associated to \fiskb\fp\&. +.sp +a call to this helper is susceptible to change the underlying +packet buffer. therefore, at load time, all checks on pointers +previously done by the verifier are invalidated and must be +performed again, if the helper is used in combination with +direct packet access. +.tp +.b return +0 on success, or a negative error in case of failure. +.unindent +.tp +.b \fblong bpf_skb_get_tunnel_key(struct sk_buff *\fp\fiskb\fp\fb, struct bpf_tunnel_key *\fp\fikey\fp\fb, u32\fp \fisize\fp\fb, u64\fp \fiflags\fp\fb)\fp +.indent 7.0 +.tp +.b description +get tunnel metadata. this helper takes a pointer \fikey\fp to an +empty \fbstruct bpf_tunnel_key\fp of \fbsize\fp, that will be +filled with tunnel metadata for the packet associated to \fiskb\fp\&. +the \fiflags\fp can be set to \fbbpf_f_tuninfo_ipv6\fp, which +indicates that the tunnel is based on ipv6 protocol instead of +ipv4. +.sp +the \fbstruct bpf_tunnel_key\fp is an object that generalizes the +principal parameters used by various tunneling protocols into a +single struct. this way, it can be used to easily make a +decision based on the contents of the encapsulation header, +"summarized" in this struct. in particular, it holds the ip +address of the remote end (ipv4 or ipv6, depending on the case) +in \fikey\fp\fb\->remote_ipv4\fp or \fikey\fp\fb\->remote_ipv6\fp\&. also, +this struct exposes the \fikey\fp\fb\->tunnel_id\fp, which is +generally mapped to a vni (virtual network identifier), making +it programmable together with the \fbbpf_skb_set_tunnel_key\fp() helper. +.sp +let\(aqs imagine that the following code is part of a program +attached to the tc ingress interface, on one end of a gre +tunnel, and is supposed to filter out all messages coming from +remote ends with ipv4 address other than 10.0.0.1: +.indent 7.0 +.indent 3.5 +.sp +.nf +.ft c +int ret; +struct bpf_tunnel_key key = {}; + +ret = bpf_skb_get_tunnel_key(skb, &key, sizeof(key), 0); +if (ret < 0) + return tc_act_shot; // drop packet + +if (key.remote_ipv4 != 0x0a000001) + return tc_act_shot; // drop packet + +return tc_act_ok; // accept packet +.ft p +.fi +.unindent +.unindent +.sp +this interface can also be used with all encapsulation devices +that can operate in "collect metadata" mode: instead of having +one network device per specific configuration, the "collect +metadata" mode only requires a single device where the +configuration can be extracted from this helper. +.sp +this can be used together with various tunnels such as vxlan, +geneve, gre, or ip in ip (ipip). +.tp +.b return +0 on success, or a negative error in case of failure. +.unindent +.tp +.b \fblong bpf_skb_set_tunnel_key(struct sk_buff *\fp\fiskb\fp\fb, struct bpf_tunnel_key *\fp\fikey\fp\fb, u32\fp \fisize\fp\fb, u64\fp \fiflags\fp\fb)\fp +.indent 7.0 +.tp +.b description +populate tunnel metadata for packet associated to \fiskb.\fp the +tunnel metadata is set to the contents of \fikey\fp, of \fisize\fp\&. the +\fiflags\fp can be set to a combination of the following values: +.indent 7.0 +.tp +.b \fbbpf_f_tuninfo_ipv6\fp +indicate that the tunnel is based on ipv6 protocol +instead of ipv4. +.tp +.b \fbbpf_f_zero_csum_tx\fp +for ipv4 packets, add a flag to tunnel metadata +indicating that checksum computation should be skipped +and checksum set to zeroes. +.tp +.b \fbbpf_f_dont_fragment\fp +add a flag to tunnel metadata indicating that the +packet should not be fragmented. +.tp +.b \fbbpf_f_seq_number\fp +add a flag to tunnel metadata indicating that a +sequence number should be added to tunnel header before +sending the packet. this flag was added for gre +encapsulation, but might be used with other protocols +as well in the future. +.unindent +.sp +here is a typical usage on the transmit path: +.indent 7.0 +.indent 3.5 +.sp +.nf +.ft c +struct bpf_tunnel_key key; + populate key ... +bpf_skb_set_tunnel_key(skb, &key, sizeof(key), 0); +bpf_clone_redirect(skb, vxlan_dev_ifindex, 0); +.ft p +.fi +.unindent +.unindent +.sp +see also the description of the \fbbpf_skb_get_tunnel_key\fp() +helper for additional information. +.tp +.b return +0 on success, or a negative error in case of failure. +.unindent +.tp +.b \fbu64 bpf_perf_event_read(struct bpf_map *\fp\fimap\fp\fb, u64\fp \fiflags\fp\fb)\fp +.indent 7.0 +.tp +.b description +read the value of a perf event counter. this helper relies on a +\fimap\fp of type \fbbpf_map_type_perf_event_array\fp\&. the nature of +the perf event counter is selected when \fimap\fp is updated with +perf event file descriptors. the \fimap\fp is an array whose size +is the number of available cpus, and each cell contains a value +relative to one cpu. the value to retrieve is indicated by +\fiflags\fp, that contains the index of the cpu to look up, masked +with \fbbpf_f_index_mask\fp\&. alternatively, \fiflags\fp can be set to +\fbbpf_f_current_cpu\fp to indicate that the value for the +current cpu should be retrieved. +.sp +note that before linux 4.13, only hardware perf event can be +retrieved. +.sp +also, be aware that the newer helper +\fbbpf_perf_event_read_value\fp() is recommended over +\fbbpf_perf_event_read\fp() in general. the latter has some abi +quirks where error and counter value are used as a return code +(which is wrong to do since ranges may overlap). this issue is +fixed with \fbbpf_perf_event_read_value\fp(), which at the same +time provides more features over the \fbbpf_perf_event_read\fp() interface. please refer to the description of +\fbbpf_perf_event_read_value\fp() for details. +.tp +.b return +the value of the perf event counter read from the map, or a +negative error code in case of failure. +.unindent +.tp +.b \fblong bpf_redirect(u32\fp \fiifindex\fp\fb, u64\fp \fiflags\fp\fb)\fp +.indent 7.0 +.tp +.b description +redirect the packet to another net device of index \fiifindex\fp\&. +this helper is somewhat similar to \fbbpf_clone_redirect\fp(), except that the packet is not cloned, which provides +increased performance. +.sp +except for xdp, both ingress and egress interfaces can be used +for redirection. the \fbbpf_f_ingress\fp value in \fiflags\fp is used +to make the distinction (ingress path is selected if the flag +is present, egress path otherwise). currently, xdp only +supports redirection to the egress interface, and accepts no +flag at all. +.sp +the same effect can also be attained with the more generic +\fbbpf_redirect_map\fp(), which uses a bpf map to store the +redirect target instead of providing it directly to the helper. +.tp +.b return +for xdp, the helper returns \fbxdp_redirect\fp on success or +\fbxdp_aborted\fp on error. for other program types, the values +are \fbtc_act_redirect\fp on success or \fbtc_act_shot\fp on +error. +.unindent +.tp +.b \fbu32 bpf_get_route_realm(struct sk_buff *\fp\fiskb\fp\fb)\fp +.indent 7.0 +.tp +.b description +retrieve the realm or the route, that is to say the +\fbtclassid\fp field of the destination for the \fiskb\fp\&. the +identifier retrieved is a user\-provided tag, similar to the +one used with the net_cls cgroup (see description for +\fbbpf_get_cgroup_classid\fp() helper), but here this tag is +held by a route (a destination entry), not by a task. +.sp +retrieving this identifier works with the clsact tc egress hook +(see also \fbtc\-bpf(8)\fp), or alternatively on conventional +classful egress qdiscs, but not on tc ingress path. in case of +clsact tc egress hook, this has the advantage that, internally, +the destination entry has not been dropped yet in the transmit +path. therefore, the destination entry does not need to be +artificially held via \fbnetif_keep_dst\fp() for a classful +qdisc until the \fiskb\fp is freed. +.sp +this helper is available only if the kernel was compiled with +\fbconfig_ip_route_classid\fp configuration option. +.tp +.b return +the realm of the route for the packet associated to \fiskb\fp, or 0 +if none was found. +.unindent +.tp +.b \fblong bpf_perf_event_output(void *\fp\fictx\fp\fb, struct bpf_map *\fp\fimap\fp\fb, u64\fp \fiflags\fp\fb, void *\fp\fidata\fp\fb, u64\fp \fisize\fp\fb)\fp +.indent 7.0 +.tp +.b description +write raw \fidata\fp blob into a special bpf perf event held by +\fimap\fp of type \fbbpf_map_type_perf_event_array\fp\&. this perf +event must have the following attributes: \fbperf_sample_raw\fp +as \fbsample_type\fp, \fbperf_type_software\fp as \fbtype\fp, and +\fbperf_count_sw_bpf_output\fp as \fbconfig\fp\&. +.sp +the \fiflags\fp are used to indicate the index in \fimap\fp for which +the value must be put, masked with \fbbpf_f_index_mask\fp\&. +alternatively, \fiflags\fp can be set to \fbbpf_f_current_cpu\fp +to indicate that the index of the current cpu core should be +used. +.sp +the value to write, of \fisize\fp, is passed through ebpf stack and +pointed by \fidata\fp\&. +.sp +the context of the program \fictx\fp needs also be passed to the +helper. +.sp +on user space, a program willing to read the values needs to +call \fbperf_event_open\fp() on the perf event (either for +one or for all cpus) and to store the file descriptor into the +\fimap\fp\&. this must be done before the ebpf program can send data +into it. an example is available in file +\fisamples/bpf/trace_output_user.c\fp in the linux kernel source +tree (the ebpf program counterpart is in +\fisamples/bpf/trace_output_kern.c\fp). +.sp +\fbbpf_perf_event_output\fp() achieves better performance +than \fbbpf_trace_printk\fp() for sharing data with user +space, and is much better suitable for streaming data from ebpf +programs. +.sp +note that this helper is not restricted to tracing use cases +and can be used with programs attached to tc or xdp as well, +where it allows for passing data to user space listeners. data +can be: +.indent 7.0 +.ip \(bu 2 +only custom structs, +.ip \(bu 2 +only the packet payload, or +.ip \(bu 2 +a combination of both. +.unindent +.tp +.b return +0 on success, or a negative error in case of failure. +.unindent +.tp +.b \fblong bpf_skb_load_bytes(const void *\fp\fiskb\fp\fb, u32\fp \fioffset\fp\fb, void *\fp\fito\fp\fb, u32\fp \filen\fp\fb)\fp +.indent 7.0 +.tp +.b description +this helper was provided as an easy way to load data from a +packet. it can be used to load \filen\fp bytes from \fioffset\fp from +the packet associated to \fiskb\fp, into the buffer pointed by +\fito\fp\&. +.sp +since linux 4.7, usage of this helper has mostly been replaced +by "direct packet access", enabling packet data to be +manipulated with \fiskb\fp\fb\->data\fp and \fiskb\fp\fb\->data_end\fp +pointing respectively to the first byte of packet data and to +the byte after the last byte of packet data. however, it +remains useful if one wishes to read large quantities of data +at once from a packet into the ebpf stack. +.tp +.b return +0 on success, or a negative error in case of failure. +.unindent +.tp +.b \fblong bpf_get_stackid(void *\fp\fictx\fp\fb, struct bpf_map *\fp\fimap\fp\fb, u64\fp \fiflags\fp\fb)\fp +.indent 7.0 +.tp +.b description +walk a user or a kernel stack and return its id. to achieve +this, the helper needs \fictx\fp, which is a pointer to the context +on which the tracing program is executed, and a pointer to a +\fimap\fp of type \fbbpf_map_type_stack_trace\fp\&. +.sp +the last argument, \fiflags\fp, holds the number of stack frames to +skip (from 0 to 255), masked with +\fbbpf_f_skip_field_mask\fp\&. the next bits can be used to set +a combination of the following flags: +.indent 7.0 +.tp +.b \fbbpf_f_user_stack\fp +collect a user space stack instead of a kernel stack. +.tp +.b \fbbpf_f_fast_stack_cmp\fp +compare stacks by hash only. +.tp +.b \fbbpf_f_reuse_stackid\fp +if two different stacks hash into the same \fistackid\fp, +discard the old one. +.unindent +.sp +the stack id retrieved is a 32 bit long integer handle which +can be further combined with other data (including other stack +ids) and used as a key into maps. this can be useful for +generating a variety of graphs (such as flame graphs or off\-cpu +graphs). +.sp +for walking a stack, this helper is an improvement over +\fbbpf_probe_read\fp(), which can be used with unrolled loops +but is not efficient and consumes a lot of ebpf instructions. +instead, \fbbpf_get_stackid\fp() can collect up to +\fbperf_max_stack_depth\fp both kernel and user frames. note that +this limit can be controlled with the \fbsysctl\fp program, and +that it should be manually increased in order to profile long +user stacks (such as stacks for java programs). to do so, use: +.indent 7.0 +.indent 3.5 +.sp +.nf +.ft c +# sysctl kernel.perf_event_max_stack= +.ft p +.fi +.unindent +.unindent +.tp +.b return +the positive or null stack id on success, or a negative error +in case of failure. +.unindent +.tp +.b \fbs64 bpf_csum_diff(__be32 *\fp\fifrom\fp\fb, u32\fp \fifrom_size\fp\fb, __be32 *\fp\fito\fp\fb, u32\fp \fito_size\fp\fb, __wsum\fp \fiseed\fp\fb)\fp +.indent 7.0 +.tp +.b description +compute a checksum difference, from the raw buffer pointed by +\fifrom\fp, of length \fifrom_size\fp (that must be a multiple of 4), +towards the raw buffer pointed by \fito\fp, of size \fito_size\fp +(same remark). an optional \fiseed\fp can be added to the value +(this can be cascaded, the seed may come from a previous call +to the helper). +.sp +this is flexible enough to be used in several ways: +.indent 7.0 +.ip \(bu 2 +with \fifrom_size\fp == 0, \fito_size\fp > 0 and \fiseed\fp set to +checksum, it can be used when pushing new data. +.ip \(bu 2 +with \fifrom_size\fp > 0, \fito_size\fp == 0 and \fiseed\fp set to +checksum, it can be used when removing data from a packet. +.ip \(bu 2 +with \fifrom_size\fp > 0, \fito_size\fp > 0 and \fiseed\fp set to 0, it +can be used to compute a diff. note that \fifrom_size\fp and +\fito_size\fp do not need to be equal. +.unindent +.sp +this helper can be used in combination with +\fbbpf_l3_csum_replace\fp() and \fbbpf_l4_csum_replace\fp(), to +which one can feed in the difference computed with +\fbbpf_csum_diff\fp(). +.tp +.b return +the checksum result, or a negative error code in case of +failure. +.unindent +.tp +.b \fblong bpf_skb_get_tunnel_opt(struct sk_buff *\fp\fiskb\fp\fb, void *\fp\fiopt\fp\fb, u32\fp \fisize\fp\fb)\fp +.indent 7.0 +.tp +.b description +retrieve tunnel options metadata for the packet associated to +\fiskb\fp, and store the raw tunnel option data to the buffer \fiopt\fp +of \fisize\fp\&. +.sp +this helper can be used with encapsulation devices that can +operate in "collect metadata" mode (please refer to the related +note in the description of \fbbpf_skb_get_tunnel_key\fp() for +more details). a particular example where this can be used is +in combination with the geneve encapsulation protocol, where it +allows for pushing (with \fbbpf_skb_get_tunnel_opt\fp() helper) +and retrieving arbitrary tlvs (type\-length\-value headers) from +the ebpf program. this allows for full customization of these +headers. +.tp +.b return +the size of the option data retrieved. +.unindent +.tp +.b \fblong bpf_skb_set_tunnel_opt(struct sk_buff *\fp\fiskb\fp\fb, void *\fp\fiopt\fp\fb, u32\fp \fisize\fp\fb)\fp +.indent 7.0 +.tp +.b description +set tunnel options metadata for the packet associated to \fiskb\fp +to the option data contained in the raw buffer \fiopt\fp of \fisize\fp\&. +.sp +see also the description of the \fbbpf_skb_get_tunnel_opt\fp() +helper for additional information. +.tp +.b return +0 on success, or a negative error in case of failure. +.unindent +.tp +.b \fblong bpf_skb_change_proto(struct sk_buff *\fp\fiskb\fp\fb, __be16\fp \fiproto\fp\fb, u64\fp \fiflags\fp\fb)\fp +.indent 7.0 +.tp +.b description +change the protocol of the \fiskb\fp to \fiproto\fp\&. currently +supported are transition from ipv4 to ipv6, and from ipv6 to +ipv4. the helper takes care of the groundwork for the +transition, including resizing the socket buffer. the ebpf +program is expected to fill the new headers, if any, via +\fbskb_store_bytes\fp() and to recompute the checksums with +\fbbpf_l3_csum_replace\fp() and \fbbpf_l4_csum_replace\fp(). the main case for this helper is to perform nat64 +operations out of an ebpf program. +.sp +internally, the gso type is marked as dodgy so that headers are +checked and segments are recalculated by the gso/gro engine. +the size for gso target is adapted as well. +.sp +all values for \fiflags\fp are reserved for future usage, and must +be left at zero. +.sp +a call to this helper is susceptible to change the underlying +packet buffer. therefore, at load time, all checks on pointers +previously done by the verifier are invalidated and must be +performed again, if the helper is used in combination with +direct packet access. +.tp +.b return +0 on success, or a negative error in case of failure. +.unindent +.tp +.b \fblong bpf_skb_change_type(struct sk_buff *\fp\fiskb\fp\fb, u32\fp \fitype\fp\fb)\fp +.indent 7.0 +.tp +.b description +change the packet type for the packet associated to \fiskb\fp\&. this +comes down to setting \fiskb\fp\fb\->pkt_type\fp to \fitype\fp, except +the ebpf program does not have a write access to \fiskb\fp\fb\->pkt_type\fp beside this helper. using a helper here allows +for graceful handling of errors. +.sp +the major use case is to change incoming \fiskb*s to +**packet_host*\fp in a programmatic way instead of having to +recirculate via \fbredirect\fp(..., \fbbpf_f_ingress\fp), for +example. +.sp +note that \fitype\fp only allows certain values. at this time, they +are: +.indent 7.0 +.tp +.b \fbpacket_host\fp +packet is for us. +.tp +.b \fbpacket_broadcast\fp +send packet to all. +.tp +.b \fbpacket_multicast\fp +send packet to group. +.tp +.b \fbpacket_otherhost\fp +send packet to someone else. +.unindent +.tp +.b return +0 on success, or a negative error in case of failure. +.unindent +.tp +.b \fblong bpf_skb_under_cgroup(struct sk_buff *\fp\fiskb\fp\fb, struct bpf_map *\fp\fimap\fp\fb, u32\fp \fiindex\fp\fb)\fp +.indent 7.0 +.tp +.b description +check whether \fiskb\fp is a descendant of the cgroup2 held by +\fimap\fp of type \fbbpf_map_type_cgroup_array\fp, at \fiindex\fp\&. +.tp +.b return +the return value depends on the result of the test, and can be: +.indent 7.0 +.ip \(bu 2 +0, if the \fiskb\fp failed the cgroup2 descendant test. +.ip \(bu 2 +1, if the \fiskb\fp succeeded the cgroup2 descendant test. +.ip \(bu 2 +a negative error code, if an error occurred. +.unindent +.unindent +.tp +.b \fbu32 bpf_get_hash_recalc(struct sk_buff *\fp\fiskb\fp\fb)\fp +.indent 7.0 +.tp +.b description +retrieve the hash of the packet, \fiskb\fp\fb\->hash\fp\&. if it is +not set, in particular if the hash was cleared due to mangling, +recompute this hash. later accesses to the hash can be done +directly with \fiskb\fp\fb\->hash\fp\&. +.sp +calling \fbbpf_set_hash_invalid\fp(), changing a packet +prototype with \fbbpf_skb_change_proto\fp(), or calling +\fbbpf_skb_store_bytes\fp() with the +\fbbpf_f_invalidate_hash\fp are actions susceptible to clear +the hash and to trigger a new computation for the next call to +\fbbpf_get_hash_recalc\fp(). +.tp +.b return +the 32\-bit hash. +.unindent +.tp +.b \fbu64 bpf_get_current_task(void)\fp +.indent 7.0 +.tp +.b return +a pointer to the current task struct. +.unindent +.tp +.b \fblong bpf_probe_write_user(void *\fp\fidst\fp\fb, const void *\fp\fisrc\fp\fb, u32\fp \filen\fp\fb)\fp +.indent 7.0 +.tp +.b description +attempt in a safe way to write \filen\fp bytes from the buffer +\fisrc\fp to \fidst\fp in memory. it only works for threads that are in +user context, and \fidst\fp must be a valid user space address. +.sp +this helper should not be used to implement any kind of +security mechanism because of toc\-tou attacks, but rather to +debug, divert, and manipulate execution of semi\-cooperative +processes. +.sp +keep in mind that this feature is meant for experiments, and it +has a risk of crashing the system and running programs. +therefore, when an ebpf program using this helper is attached, +a warning including pid and process name is printed to kernel +logs. +.tp +.b return +0 on success, or a negative error in case of failure. +.unindent +.tp +.b \fblong bpf_current_task_under_cgroup(struct bpf_map *\fp\fimap\fp\fb, u32\fp \fiindex\fp\fb)\fp +.indent 7.0 +.tp +.b description +check whether the probe is being run is the context of a given +subset of the cgroup2 hierarchy. the cgroup2 to test is held by +\fimap\fp of type \fbbpf_map_type_cgroup_array\fp, at \fiindex\fp\&. +.tp +.b return +the return value depends on the result of the test, and can be: +.indent 7.0 +.ip \(bu 2 +0, if the \fiskb\fp task belongs to the cgroup2. +.ip \(bu 2 +1, if the \fiskb\fp task does not belong to the cgroup2. +.ip \(bu 2 +a negative error code, if an error occurred. +.unindent +.unindent +.tp +.b \fblong bpf_skb_change_tail(struct sk_buff *\fp\fiskb\fp\fb, u32\fp \filen\fp\fb, u64\fp \fiflags\fp\fb)\fp +.indent 7.0 +.tp +.b description +resize (trim or grow) the packet associated to \fiskb\fp to the +new \filen\fp\&. the \fiflags\fp are reserved for future usage, and must +be left at zero. +.sp +the basic idea is that the helper performs the needed work to +change the size of the packet, then the ebpf program rewrites +the rest via helpers like \fbbpf_skb_store_bytes\fp(), +\fbbpf_l3_csum_replace\fp(), \fbbpf_l3_csum_replace\fp() +and others. this helper is a slow path utility intended for +replies with control messages. and because it is targeted for +slow path, the helper itself can afford to be slow: it +implicitly linearizes, unclones and drops offloads from the +\fiskb\fp\&. +.sp +a call to this helper is susceptible to change the underlying +packet buffer. therefore, at load time, all checks on pointers +previously done by the verifier are invalidated and must be +performed again, if the helper is used in combination with +direct packet access. +.tp +.b return +0 on success, or a negative error in case of failure. +.unindent +.tp +.b \fblong bpf_skb_pull_data(struct sk_buff *\fp\fiskb\fp\fb, u32\fp \filen\fp\fb)\fp +.indent 7.0 +.tp +.b description +pull in non\-linear data in case the \fiskb\fp is non\-linear and not +all of \filen\fp are part of the linear section. make \filen\fp bytes +from \fiskb\fp readable and writable. if a zero value is passed for +\filen\fp, then the whole length of the \fiskb\fp is pulled. +.sp +this helper is only needed for reading and writing with direct +packet access. +.sp +for direct packet access, testing that offsets to access +are within packet boundaries (test on \fiskb\fp\fb\->data_end\fp) is +susceptible to fail if offsets are invalid, or if the requested +data is in non\-linear parts of the \fiskb\fp\&. on failure the +program can just bail out, or in the case of a non\-linear +buffer, use a helper to make the data available. the +\fbbpf_skb_load_bytes\fp() helper is a first solution to access +the data. another one consists in using \fbbpf_skb_pull_data\fp +to pull in once the non\-linear parts, then retesting and +eventually access the data. +.sp +at the same time, this also makes sure the \fiskb\fp is uncloned, +which is a necessary condition for direct write. as this needs +to be an invariant for the write part only, the verifier +detects writes and adds a prologue that is calling +\fbbpf_skb_pull_data()\fp to effectively unclone the \fiskb\fp from +the very beginning in case it is indeed cloned. +.sp +a call to this helper is susceptible to change the underlying +packet buffer. therefore, at load time, all checks on pointers +previously done by the verifier are invalidated and must be +performed again, if the helper is used in combination with +direct packet access. +.tp +.b return +0 on success, or a negative error in case of failure. +.unindent +.tp +.b \fbs64 bpf_csum_update(struct sk_buff *\fp\fiskb\fp\fb, __wsum\fp \ficsum\fp\fb)\fp +.indent 7.0 +.tp +.b description +add the checksum \ficsum\fp into \fiskb\fp\fb\->csum\fp in case the +driver has supplied a checksum for the entire packet into that +field. return an error otherwise. this helper is intended to be +used in combination with \fbbpf_csum_diff\fp(), in particular +when the checksum needs to be updated after data has been +written into the packet through direct packet access. +.tp +.b return +the checksum on success, or a negative error code in case of +failure. +.unindent +.tp +.b \fbvoid bpf_set_hash_invalid(struct sk_buff *\fp\fiskb\fp\fb)\fp +.indent 7.0 +.tp +.b description +invalidate the current \fiskb\fp\fb\->hash\fp\&. it can be used after +mangling on headers through direct packet access, in order to +indicate that the hash is outdated and to trigger a +recalculation the next time the kernel tries to access this +hash or when the \fbbpf_get_hash_recalc\fp() helper is called. +.unindent +.tp +.b \fblong bpf_get_numa_node_id(void)\fp +.indent 7.0 +.tp +.b description +return the id of the current numa node. the primary use case +for this helper is the selection of sockets for the local numa +node, when the program is attached to sockets using the +\fbso_attach_reuseport_ebpf\fp option (see also \fbsocket(7)\fp), +but the helper is also available to other ebpf program types, +similarly to \fbbpf_get_smp_processor_id\fp(). +.tp +.b return +the id of current numa node. +.unindent +.tp +.b \fblong bpf_skb_change_head(struct sk_buff *\fp\fiskb\fp\fb, u32\fp \filen\fp\fb, u64\fp \fiflags\fp\fb)\fp +.indent 7.0 +.tp +.b description +grows headroom of packet associated to \fiskb\fp and adjusts the +offset of the mac header accordingly, adding \filen\fp bytes of +space. it automatically extends and reallocates memory as +required. +.sp +this helper can be used on a layer 3 \fiskb\fp to push a mac header +for redirection into a layer 2 device. +.sp +all values for \fiflags\fp are reserved for future usage, and must +be left at zero. +.sp +a call to this helper is susceptible to change the underlying +packet buffer. therefore, at load time, all checks on pointers +previously done by the verifier are invalidated and must be +performed again, if the helper is used in combination with +direct packet access. +.tp +.b return +0 on success, or a negative error in case of failure. +.unindent +.tp +.b \fblong bpf_xdp_adjust_head(struct xdp_buff *\fp\fixdp_md\fp\fb, int\fp \fidelta\fp\fb)\fp +.indent 7.0 +.tp +.b description +adjust (move) \fixdp_md\fp\fb\->data\fp by \fidelta\fp bytes. note that +it is possible to use a negative value for \fidelta\fp\&. this helper +can be used to prepare the packet for pushing or popping +headers. +.sp +a call to this helper is susceptible to change the underlying +packet buffer. therefore, at load time, all checks on pointers +previously done by the verifier are invalidated and must be +performed again, if the helper is used in combination with +direct packet access. +.tp +.b return +0 on success, or a negative error in case of failure. +.unindent +.tp +.b \fblong bpf_probe_read_str(void *\fp\fidst\fp\fb, u32\fp \fisize\fp\fb, const void *\fp\fiunsafe_ptr\fp\fb)\fp +.indent 7.0 +.tp +.b description +copy a nul terminated string from an unsafe kernel address +\fiunsafe_ptr\fp to \fidst\fp\&. see \fbbpf_probe_read_kernel_str\fp() for +more details. +.sp +generally, use \fbbpf_probe_read_user_str\fp() or +\fbbpf_probe_read_kernel_str\fp() instead. +.tp +.b return +on success, the strictly positive length of the string, +including the trailing nul character. on error, a negative +value. +.unindent +.tp +.b \fbu64 bpf_get_socket_cookie(struct sk_buff *\fp\fiskb\fp\fb)\fp +.indent 7.0 +.tp +.b description +if the \fbstruct sk_buff\fp pointed by \fiskb\fp has a known socket, +retrieve the cookie (generated by the kernel) of this socket. +if no cookie has been set yet, generate a new cookie. once +generated, the socket cookie remains stable for the life of the +socket. this helper can be useful for monitoring per socket +networking traffic statistics as it provides a global socket +identifier that can be assumed unique. +.tp +.b return +a 8\-byte long non\-decreasing number on success, or 0 if the +socket field is missing inside \fiskb\fp\&. +.unindent +.tp +.b \fbu64 bpf_get_socket_cookie(struct bpf_sock_addr *\fp\fictx\fp\fb)\fp +.indent 7.0 +.tp +.b description +equivalent to bpf_get_socket_cookie() helper that accepts +\fiskb\fp, but gets socket from \fbstruct bpf_sock_addr\fp context. +.tp +.b return +a 8\-byte long non\-decreasing number. +.unindent +.tp +.b \fbu64 bpf_get_socket_cookie(struct bpf_sock_ops *\fp\fictx\fp\fb)\fp +.indent 7.0 +.tp +.b description +equivalent to \fbbpf_get_socket_cookie\fp() helper that accepts +\fiskb\fp, but gets socket from \fbstruct bpf_sock_ops\fp context. +.tp +.b return +a 8\-byte long non\-decreasing number. +.unindent +.tp +.b \fbu32 bpf_get_socket_uid(struct sk_buff *\fp\fiskb\fp\fb)\fp +.indent 7.0 +.tp +.b return +the owner uid of the socket associated to \fiskb\fp\&. if the socket +is \fbnull\fp, or if it is not a full socket (i.e. if it is a +time\-wait or a request socket instead), \fboverflowuid\fp value +is returned (note that \fboverflowuid\fp might also be the actual +uid value for the socket). +.unindent +.tp +.b \fblong bpf_set_hash(struct sk_buff *\fp\fiskb\fp\fb, u32\fp \fihash\fp\fb)\fp +.indent 7.0 +.tp +.b description +set the full hash for \fiskb\fp (set the field \fiskb\fp\fb\->hash\fp) +to value \fihash\fp\&. +.tp +.b return +0 +.unindent +.tp +.b \fblong bpf_setsockopt(void *\fp\fibpf_socket\fp\fb, int\fp \filevel\fp\fb, int\fp \fioptname\fp\fb, void *\fp\fioptval\fp\fb, int\fp \fioptlen\fp\fb)\fp +.indent 7.0 +.tp +.b description +emulate a call to \fbsetsockopt()\fp on the socket associated to +\fibpf_socket\fp, which must be a full socket. the \filevel\fp at +which the option resides and the name \fioptname\fp of the option +must be specified, see \fbsetsockopt(2)\fp for more information. +the option value of length \fioptlen\fp is pointed by \fioptval\fp\&. +.sp +\fibpf_socket\fp should be one of the following: +.indent 7.0 +.ip \(bu 2 +\fbstruct bpf_sock_ops\fp for \fbbpf_prog_type_sock_ops\fp\&. +.ip \(bu 2 +\fbstruct bpf_sock_addr\fp for \fbbpf_cgroup_inet4_connect\fp +and \fbbpf_cgroup_inet6_connect\fp\&. +.unindent +.sp +this helper actually implements a subset of \fbsetsockopt()\fp\&. +it supports the following \filevel\fps: +.indent 7.0 +.ip \(bu 2 +\fbsol_socket\fp, which supports the following \fioptname\fps: +\fbso_rcvbuf\fp, \fbso_sndbuf\fp, \fbso_max_pacing_rate\fp, +\fbso_priority\fp, \fbso_rcvlowat\fp, \fbso_mark\fp, +\fbso_bindtodevice\fp, \fbso_keepalive\fp\&. +.ip \(bu 2 +\fbipproto_tcp\fp, which supports the following \fioptname\fps: +\fbtcp_congestion\fp, \fbtcp_bpf_iw\fp, +\fbtcp_bpf_sndcwnd_clamp\fp, \fbtcp_save_syn\fp, +\fbtcp_keepidle\fp, \fbtcp_keepintvl\fp, \fbtcp_keepcnt\fp, +\fbtcp_syncnt\fp, \fbtcp_user_timeout\fp\&. +.ip \(bu 2 +\fbipproto_ip\fp, which supports \fioptname\fp \fbip_tos\fp\&. +.ip \(bu 2 +\fbipproto_ipv6\fp, which supports \fioptname\fp \fbipv6_tclass\fp\&. +.unindent +.tp +.b return +0 on success, or a negative error in case of failure. +.unindent +.tp +.b \fblong bpf_skb_adjust_room(struct sk_buff *\fp\fiskb\fp\fb, s32\fp \filen_diff\fp\fb, u32\fp \fimode\fp\fb, u64\fp \fiflags\fp\fb)\fp +.indent 7.0 +.tp +.b description +grow or shrink the room for data in the packet associated to +\fiskb\fp by \filen_diff\fp, and according to the selected \fimode\fp\&. +.sp +by default, the helper will reset any offloaded checksum +indicator of the skb to checksum_none. this can be avoided +by the following flag: +.indent 7.0 +.ip \(bu 2 +\fbbpf_f_adj_room_no_csum_reset\fp: do not reset offloaded +checksum data of the skb to checksum_none. +.unindent +.sp +there are two supported modes at this time: +.indent 7.0 +.ip \(bu 2 +\fbbpf_adj_room_mac\fp: adjust room at the mac layer +(room space is added or removed below the layer 2 header). +.ip \(bu 2 +\fbbpf_adj_room_net\fp: adjust room at the network layer +(room space is added or removed below the layer 3 header). +.unindent +.sp +the following flags are supported at this time: +.indent 7.0 +.ip \(bu 2 +\fbbpf_f_adj_room_fixed_gso\fp: do not adjust gso_size. +adjusting mss in this way is not allowed for datagrams. +.ip \(bu 2 +\fbbpf_f_adj_room_encap_l3_ipv4\fp, +\fbbpf_f_adj_room_encap_l3_ipv6\fp: +any new space is reserved to hold a tunnel header. +configure skb offsets and other fields accordingly. +.ip \(bu 2 +\fbbpf_f_adj_room_encap_l4_gre\fp, +\fbbpf_f_adj_room_encap_l4_udp\fp: +use with encap_l3 flags to further specify the tunnel type. +.ip \(bu 2 +\fbbpf_f_adj_room_encap_l2\fp(\filen\fp): +use with encap_l3/l4 flags to further specify the tunnel +type; \filen\fp is the length of the inner mac header. +.unindent +.sp +a call to this helper is susceptible to change the underlying +packet buffer. therefore, at load time, all checks on pointers +previously done by the verifier are invalidated and must be +performed again, if the helper is used in combination with +direct packet access. +.tp +.b return +0 on success, or a negative error in case of failure. +.unindent +.tp +.b \fblong bpf_redirect_map(struct bpf_map *\fp\fimap\fp\fb, u32\fp \fikey\fp\fb, u64\fp \fiflags\fp\fb)\fp +.indent 7.0 +.tp +.b description +redirect the packet to the endpoint referenced by \fimap\fp at +index \fikey\fp\&. depending on its type, this \fimap\fp can contain +references to net devices (for forwarding packets through other +ports), or to cpus (for redirecting xdp frames to another cpu; +but this is only implemented for native xdp (with driver +support) as of this writing). +.sp +the lower two bits of \fiflags\fp are used as the return code if +the map lookup fails. this is so that the return value can be +one of the xdp program return codes up to \fbxdp_tx\fp, as chosen +by the caller. any higher bits in the \fiflags\fp argument must be +unset. +.sp +see also \fbbpf_redirect\fp(), which only supports redirecting +to an ifindex, but doesn\(aqt require a map to do so. +.tp +.b return +\fbxdp_redirect\fp on success, or the value of the two lower bits +of the \fiflags\fp argument on error. +.unindent +.tp +.b \fblong bpf_sk_redirect_map(struct sk_buff *\fp\fiskb\fp\fb, struct bpf_map *\fp\fimap\fp\fb, u32\fp \fikey\fp\fb, u64\fp \fiflags\fp\fb)\fp +.indent 7.0 +.tp +.b description +redirect the packet to the socket referenced by \fimap\fp (of type +\fbbpf_map_type_sockmap\fp) at index \fikey\fp\&. both ingress and +egress interfaces can be used for redirection. the +\fbbpf_f_ingress\fp value in \fiflags\fp is used to make the +distinction (ingress path is selected if the flag is present, +egress path otherwise). this is the only flag supported for now. +.tp +.b return +\fbsk_pass\fp on success, or \fbsk_drop\fp on error. +.unindent +.tp +.b \fblong bpf_sock_map_update(struct bpf_sock_ops *\fp\fiskops\fp\fb, struct bpf_map *\fp\fimap\fp\fb, void *\fp\fikey\fp\fb, u64\fp \fiflags\fp\fb)\fp +.indent 7.0 +.tp +.b description +add an entry to, or update a \fimap\fp referencing sockets. the +\fiskops\fp is used as a new value for the entry associated to +\fikey\fp\&. \fiflags\fp is one of: +.indent 7.0 +.tp +.b \fbbpf_noexist\fp +the entry for \fikey\fp must not exist in the map. +.tp +.b \fbbpf_exist\fp +the entry for \fikey\fp must already exist in the map. +.tp +.b \fbbpf_any\fp +no condition on the existence of the entry for \fikey\fp\&. +.unindent +.sp +if the \fimap\fp has ebpf programs (parser and verdict), those will +be inherited by the socket being added. if the socket is +already attached to ebpf programs, this results in an error. +.tp +.b return +0 on success, or a negative error in case of failure. +.unindent +.tp +.b \fblong bpf_xdp_adjust_meta(struct xdp_buff *\fp\fixdp_md\fp\fb, int\fp \fidelta\fp\fb)\fp +.indent 7.0 +.tp +.b description +adjust the address pointed by \fixdp_md\fp\fb\->data_meta\fp by +\fidelta\fp (which can be positive or negative). note that this +operation modifies the address stored in \fixdp_md\fp\fb\->data\fp, +so the latter must be loaded only after the helper has been +called. +.sp +the use of \fixdp_md\fp\fb\->data_meta\fp is optional and programs +are not required to use it. the rationale is that when the +packet is processed with xdp (e.g. as dos filter), it is +possible to push further meta data along with it before passing +to the stack, and to give the guarantee that an ingress ebpf +program attached as a tc classifier on the same device can pick +this up for further post\-processing. since tc works with socket +buffers, it remains possible to set from xdp the \fbmark\fp or +\fbpriority\fp pointers, or other pointers for the socket buffer. +having this scratch space generic and programmable allows for +more flexibility as the user is free to store whatever meta +data they need. +.sp +a call to this helper is susceptible to change the underlying +packet buffer. therefore, at load time, all checks on pointers +previously done by the verifier are invalidated and must be +performed again, if the helper is used in combination with +direct packet access. +.tp +.b return +0 on success, or a negative error in case of failure. +.unindent +.tp +.b \fblong bpf_perf_event_read_value(struct bpf_map *\fp\fimap\fp\fb, u64\fp \fiflags\fp\fb, struct bpf_perf_event_value *\fp\fibuf\fp\fb, u32\fp \fibuf_size\fp\fb)\fp +.indent 7.0 +.tp +.b description +read the value of a perf event counter, and store it into \fibuf\fp +of size \fibuf_size\fp\&. this helper relies on a \fimap\fp of type +\fbbpf_map_type_perf_event_array\fp\&. the nature of the perf event +counter is selected when \fimap\fp is updated with perf event file +descriptors. the \fimap\fp is an array whose size is the number of +available cpus, and each cell contains a value relative to one +cpu. the value to retrieve is indicated by \fiflags\fp, that +contains the index of the cpu to look up, masked with +\fbbpf_f_index_mask\fp\&. alternatively, \fiflags\fp can be set to +\fbbpf_f_current_cpu\fp to indicate that the value for the +current cpu should be retrieved. +.sp +this helper behaves in a way close to +\fbbpf_perf_event_read\fp() helper, save that instead of +just returning the value observed, it fills the \fibuf\fp +structure. this allows for additional data to be retrieved: in +particular, the enabled and running times (in \fibuf\fp\fb\->enabled\fp and \fibuf\fp\fb\->running\fp, respectively) are +copied. in general, \fbbpf_perf_event_read_value\fp() is +recommended over \fbbpf_perf_event_read\fp(), which has some +abi issues and provides fewer functionalities. +.sp +these values are interesting, because hardware pmu (performance +monitoring unit) counters are limited resources. when there are +more pmu based perf events opened than available counters, +kernel will multiplex these events so each event gets certain +percentage (but not all) of the pmu time. in case that +multiplexing happens, the number of samples or counter value +will not reflect the case compared to when no multiplexing +occurs. this makes comparison between different runs difficult. +typically, the counter value should be normalized before +comparing to other experiments. the usual normalization is done +as follows. +.indent 7.0 +.indent 3.5 +.sp +.nf +.ft c +normalized_counter = counter * t_enabled / t_running +.ft p +.fi +.unindent +.unindent +.sp +where t_enabled is the time enabled for event and t_running is +the time running for event since last normalization. the +enabled and running times are accumulated since the perf event +open. to achieve scaling factor between two invocations of an +ebpf program, users can use cpu id as the key (which is +typical for perf array usage model) to remember the previous +value and do the calculation inside the ebpf program. +.tp +.b return +0 on success, or a negative error in case of failure. +.unindent +.tp +.b \fblong bpf_perf_prog_read_value(struct bpf_perf_event_data *\fp\fictx\fp\fb, struct bpf_perf_event_value *\fp\fibuf\fp\fb, u32\fp \fibuf_size\fp\fb)\fp +.indent 7.0 +.tp +.b description +for en ebpf program attached to a perf event, retrieve the +value of the event counter associated to \fictx\fp and store it in +the structure pointed by \fibuf\fp and of size \fibuf_size\fp\&. enabled +and running times are also stored in the structure (see +description of helper \fbbpf_perf_event_read_value\fp() for +more details). +.tp +.b return +0 on success, or a negative error in case of failure. +.unindent +.tp +.b \fblong bpf_getsockopt(void *\fp\fibpf_socket\fp\fb, int\fp \filevel\fp\fb, int\fp \fioptname\fp\fb, void *\fp\fioptval\fp\fb, int\fp \fioptlen\fp\fb)\fp +.indent 7.0 +.tp +.b description +emulate a call to \fbgetsockopt()\fp on the socket associated to +\fibpf_socket\fp, which must be a full socket. the \filevel\fp at +which the option resides and the name \fioptname\fp of the option +must be specified, see \fbgetsockopt(2)\fp for more information. +the retrieved value is stored in the structure pointed by +\fiopval\fp and of length \fioptlen\fp\&. +.sp +\fibpf_socket\fp should be one of the following: +.indent 7.0 +.ip \(bu 2 +\fbstruct bpf_sock_ops\fp for \fbbpf_prog_type_sock_ops\fp\&. +.ip \(bu 2 +\fbstruct bpf_sock_addr\fp for \fbbpf_cgroup_inet4_connect\fp +and \fbbpf_cgroup_inet6_connect\fp\&. +.unindent +.sp +this helper actually implements a subset of \fbgetsockopt()\fp\&. +it supports the following \filevel\fps: +.indent 7.0 +.ip \(bu 2 +\fbipproto_tcp\fp, which supports \fioptname\fp +\fbtcp_congestion\fp\&. +.ip \(bu 2 +\fbipproto_ip\fp, which supports \fioptname\fp \fbip_tos\fp\&. +.ip \(bu 2 +\fbipproto_ipv6\fp, which supports \fioptname\fp \fbipv6_tclass\fp\&. +.unindent +.tp +.b return +0 on success, or a negative error in case of failure. +.unindent +.tp +.b \fblong bpf_override_return(struct pt_regs *\fp\firegs\fp\fb, u64\fp \firc\fp\fb)\fp +.indent 7.0 +.tp +.b description +used for error injection, this helper uses kprobes to override +the return value of the probed function, and to set it to \firc\fp\&. +the first argument is the context \firegs\fp on which the kprobe +works. +.sp +this helper works by setting the pc (program counter) +to an override function which is run in place of the original +probed function. this means the probed function is not run at +all. the replacement function just returns with the required +value. +.sp +this helper has security implications, and thus is subject to +restrictions. it is only available if the kernel was compiled +with the \fbconfig_bpf_kprobe_override\fp configuration +option, and in this case it only works on functions tagged with +\fballow_error_injection\fp in the kernel code. +.sp +also, the helper is only available for the architectures having +the config_function_error_injection option. as of this writing, +x86 architecture is the only one to support this feature. +.tp +.b return +0 +.unindent +.tp +.b \fblong bpf_sock_ops_cb_flags_set(struct bpf_sock_ops *\fp\fibpf_sock\fp\fb, int\fp \fiargval\fp\fb)\fp +.indent 7.0 +.tp +.b description +attempt to set the value of the \fbbpf_sock_ops_cb_flags\fp field +for the full tcp socket associated to \fibpf_sock_ops\fp to +\fiargval\fp\&. +.sp +the primary use of this field is to determine if there should +be calls to ebpf programs of type +\fbbpf_prog_type_sock_ops\fp at various points in the tcp +code. a program of the same type can change its value, per +connection and as necessary, when the connection is +established. this field is directly accessible for reading, but +this helper must be used for updates in order to return an +error if an ebpf program tries to set a callback that is not +supported in the current kernel. +.sp +\fiargval\fp is a flag array which can combine these flags: +.indent 7.0 +.ip \(bu 2 +\fbbpf_sock_ops_rto_cb_flag\fp (retransmission time out) +.ip \(bu 2 +\fbbpf_sock_ops_retrans_cb_flag\fp (retransmission) +.ip \(bu 2 +\fbbpf_sock_ops_state_cb_flag\fp (tcp state change) +.ip \(bu 2 +\fbbpf_sock_ops_rtt_cb_flag\fp (every rtt) +.unindent +.sp +therefore, this function can be used to clear a callback flag by +setting the appropriate bit to zero. e.g. to disable the rto +callback: +.indent 7.0 +.tp +.b \fbbpf_sock_ops_cb_flags_set(bpf_sock,\fp +\fbbpf_sock\->bpf_sock_ops_cb_flags & ~bpf_sock_ops_rto_cb_flag)\fp +.unindent +.sp +here are some examples of where one could call such ebpf +program: +.indent 7.0 +.ip \(bu 2 +when rto fires. +.ip \(bu 2 +when a packet is retransmitted. +.ip \(bu 2 +when the connection terminates. +.ip \(bu 2 +when a packet is sent. +.ip \(bu 2 +when a packet is received. +.unindent +.tp +.b return +code \fb\-einval\fp if the socket is not a full tcp socket; +otherwise, a positive number containing the bits that could not +be set is returned (which comes down to 0 if all bits were set +as required). +.unindent +.tp +.b \fblong bpf_msg_redirect_map(struct sk_msg_buff *\fp\fimsg\fp\fb, struct bpf_map *\fp\fimap\fp\fb, u32\fp \fikey\fp\fb, u64\fp \fiflags\fp\fb)\fp +.indent 7.0 +.tp +.b description +this helper is used in programs implementing policies at the +socket level. if the message \fimsg\fp is allowed to pass (i.e. if +the verdict ebpf program returns \fbsk_pass\fp), redirect it to +the socket referenced by \fimap\fp (of type +\fbbpf_map_type_sockmap\fp) at index \fikey\fp\&. both ingress and +egress interfaces can be used for redirection. the +\fbbpf_f_ingress\fp value in \fiflags\fp is used to make the +distinction (ingress path is selected if the flag is present, +egress path otherwise). this is the only flag supported for now. +.tp +.b return +\fbsk_pass\fp on success, or \fbsk_drop\fp on error. +.unindent +.tp +.b \fblong bpf_msg_apply_bytes(struct sk_msg_buff *\fp\fimsg\fp\fb, u32\fp \fibytes\fp\fb)\fp +.indent 7.0 +.tp +.b description +for socket policies, apply the verdict of the ebpf program to +the next \fibytes\fp (number of bytes) of message \fimsg\fp\&. +.sp +for example, this helper can be used in the following cases: +.indent 7.0 +.ip \(bu 2 +a single \fbsendmsg\fp() or \fbsendfile\fp() system call +contains multiple logical messages that the ebpf program is +supposed to read and for which it should apply a verdict. +.ip \(bu 2 +an ebpf program only cares to read the first \fibytes\fp of a +\fimsg\fp\&. if the message has a large payload, then setting up +and calling the ebpf program repeatedly for all bytes, even +though the verdict is already known, would create unnecessary +overhead. +.unindent +.sp +when called from within an ebpf program, the helper sets a +counter internal to the bpf infrastructure, that is used to +apply the last verdict to the next \fibytes\fp\&. if \fibytes\fp is +smaller than the current data being processed from a +\fbsendmsg\fp() or \fbsendfile\fp() system call, the first +\fibytes\fp will be sent and the ebpf program will be re\-run with +the pointer for start of data pointing to byte number \fibytes\fp +\fb+ 1\fp\&. if \fibytes\fp is larger than the current data being +processed, then the ebpf verdict will be applied to multiple +\fbsendmsg\fp() or \fbsendfile\fp() calls until \fibytes\fp are +consumed. +.sp +note that if a socket closes with the internal counter holding +a non\-zero value, this is not a problem because data is not +being buffered for \fibytes\fp and is sent as it is received. +.tp +.b return +0 +.unindent +.tp +.b \fblong bpf_msg_cork_bytes(struct sk_msg_buff *\fp\fimsg\fp\fb, u32\fp \fibytes\fp\fb)\fp +.indent 7.0 +.tp +.b description +for socket policies, prevent the execution of the verdict ebpf +program for message \fimsg\fp until \fibytes\fp (byte number) have been +accumulated. +.sp +this can be used when one needs a specific number of bytes +before a verdict can be assigned, even if the data spans +multiple \fbsendmsg\fp() or \fbsendfile\fp() calls. the extreme +case would be a user calling \fbsendmsg\fp() repeatedly with +1\-byte long message segments. obviously, this is bad for +performance, but it is still valid. if the ebpf program needs +\fibytes\fp bytes to validate a header, this helper can be used to +prevent the ebpf program to be called again until \fibytes\fp have +been accumulated. +.tp +.b return +0 +.unindent +.tp +.b \fblong bpf_msg_pull_data(struct sk_msg_buff *\fp\fimsg\fp\fb, u32\fp \fistart\fp\fb, u32\fp \fiend\fp\fb, u64\fp \fiflags\fp\fb)\fp +.indent 7.0 +.tp +.b description +for socket policies, pull in non\-linear data from user space +for \fimsg\fp and set pointers \fimsg\fp\fb\->data\fp and \fimsg\fp\fb\->data_end\fp to \fistart\fp and \fiend\fp bytes offsets into \fimsg\fp, +respectively. +.sp +if a program of type \fbbpf_prog_type_sk_msg\fp is run on a +\fimsg\fp it can only parse data that the (\fbdata\fp, \fbdata_end\fp) +pointers have already consumed. for \fbsendmsg\fp() hooks this +is likely the first scatterlist element. but for calls relying +on the \fbsendpage\fp handler (e.g. \fbsendfile\fp()) this will +be the range (\fb0\fp, \fb0\fp) because the data is shared with +user space and by default the objective is to avoid allowing +user space to modify data while (or after) ebpf verdict is +being decided. this helper can be used to pull in data and to +set the start and end pointer to given values. data will be +copied if necessary (i.e. if data was not linear and if start +and end pointers do not point to the same chunk). +.sp +a call to this helper is susceptible to change the underlying +packet buffer. therefore, at load time, all checks on pointers +previously done by the verifier are invalidated and must be +performed again, if the helper is used in combination with +direct packet access. +.sp +all values for \fiflags\fp are reserved for future usage, and must +be left at zero. +.tp +.b return +0 on success, or a negative error in case of failure. +.unindent +.tp +.b \fblong bpf_bind(struct bpf_sock_addr *\fp\fictx\fp\fb, struct sockaddr *\fp\fiaddr\fp\fb, int\fp \fiaddr_len\fp\fb)\fp +.indent 7.0 +.tp +.b description +bind the socket associated to \fictx\fp to the address pointed by +\fiaddr\fp, of length \fiaddr_len\fp\&. this allows for making outgoing +connection from the desired ip address, which can be useful for +example when all processes inside a cgroup should use one +single ip address on a host that has multiple ip configured. +.sp +this helper works for ipv4 and ipv6, tcp and udp sockets. the +domain (\fiaddr\fp\fb\->sa_family\fp) must be \fbaf_inet\fp (or +\fbaf_inet6\fp). it\(aqs advised to pass zero port (\fbsin_port\fp +or \fbsin6_port\fp) which triggers ip_bind_address_no_port\-like +behavior and lets the kernel efficiently pick up an unused +port as long as 4\-tuple is unique. passing non\-zero port might +lead to degraded performance. +.tp +.b return +0 on success, or a negative error in case of failure. +.unindent +.tp +.b \fblong bpf_xdp_adjust_tail(struct xdp_buff *\fp\fixdp_md\fp\fb, int\fp \fidelta\fp\fb)\fp +.indent 7.0 +.tp +.b description +adjust (move) \fixdp_md\fp\fb\->data_end\fp by \fidelta\fp bytes. it is +possible to both shrink and grow the packet tail. +shrink done via \fidelta\fp being a negative integer. +.sp +a call to this helper is susceptible to change the underlying +packet buffer. therefore, at load time, all checks on pointers +previously done by the verifier are invalidated and must be +performed again, if the helper is used in combination with +direct packet access. +.tp +.b return +0 on success, or a negative error in case of failure. +.unindent +.tp +.b \fblong bpf_skb_get_xfrm_state(struct sk_buff *\fp\fiskb\fp\fb, u32\fp \fiindex\fp\fb, struct bpf_xfrm_state *\fp\fixfrm_state\fp\fb, u32\fp \fisize\fp\fb, u64\fp \fiflags\fp\fb)\fp +.indent 7.0 +.tp +.b description +retrieve the xfrm state (ip transform framework, see also +\fbip\-xfrm(8)\fp) at \fiindex\fp in xfrm "security path" for \fiskb\fp\&. +.sp +the retrieved value is stored in the \fbstruct bpf_xfrm_state\fp +pointed by \fixfrm_state\fp and of length \fisize\fp\&. +.sp +all values for \fiflags\fp are reserved for future usage, and must +be left at zero. +.sp +this helper is available only if the kernel was compiled with +\fbconfig_xfrm\fp configuration option. +.tp +.b return +0 on success, or a negative error in case of failure. +.unindent +.tp +.b \fblong bpf_get_stack(void *\fp\fictx\fp\fb, void *\fp\fibuf\fp\fb, u32\fp \fisize\fp\fb, u64\fp \fiflags\fp\fb)\fp +.indent 7.0 +.tp +.b description +return a user or a kernel stack in bpf program provided buffer. +to achieve this, the helper needs \fictx\fp, which is a pointer +to the context on which the tracing program is executed. +to store the stacktrace, the bpf program provides \fibuf\fp with +a nonnegative \fisize\fp\&. +.sp +the last argument, \fiflags\fp, holds the number of stack frames to +skip (from 0 to 255), masked with +\fbbpf_f_skip_field_mask\fp\&. the next bits can be used to set +the following flags: +.indent 7.0 +.tp +.b \fbbpf_f_user_stack\fp +collect a user space stack instead of a kernel stack. +.tp +.b \fbbpf_f_user_build_id\fp +collect buildid+offset instead of ips for user stack, +only valid if \fbbpf_f_user_stack\fp is also specified. +.unindent +.sp +\fbbpf_get_stack\fp() can collect up to +\fbperf_max_stack_depth\fp both kernel and user frames, subject +to sufficient large buffer size. note that +this limit can be controlled with the \fbsysctl\fp program, and +that it should be manually increased in order to profile long +user stacks (such as stacks for java programs). to do so, use: +.indent 7.0 +.indent 3.5 +.sp +.nf +.ft c +# sysctl kernel.perf_event_max_stack= +.ft p +.fi +.unindent +.unindent +.tp +.b return +a non\-negative value equal to or less than \fisize\fp on success, +or a negative error in case of failure. +.unindent +.tp +.b \fblong bpf_skb_load_bytes_relative(const void *\fp\fiskb\fp\fb, u32\fp \fioffset\fp\fb, void *\fp\fito\fp\fb, u32\fp \filen\fp\fb, u32\fp \fistart_header\fp\fb)\fp +.indent 7.0 +.tp +.b description +this helper is similar to \fbbpf_skb_load_bytes\fp() in that +it provides an easy way to load \filen\fp bytes from \fioffset\fp +from the packet associated to \fiskb\fp, into the buffer pointed +by \fito\fp\&. the difference to \fbbpf_skb_load_bytes\fp() is that +a fifth argument \fistart_header\fp exists in order to select a +base offset to start from. \fistart_header\fp can be one of: +.indent 7.0 +.tp +.b \fbbpf_hdr_start_mac\fp +base offset to load data from is \fiskb\fp\(aqs mac header. +.tp +.b \fbbpf_hdr_start_net\fp +base offset to load data from is \fiskb\fp\(aqs network header. +.unindent +.sp +in general, "direct packet access" is the preferred method to +access packet data, however, this helper is in particular useful +in socket filters where \fiskb\fp\fb\->data\fp does not always point +to the start of the mac header and where "direct packet access" +is not available. +.tp +.b return +0 on success, or a negative error in case of failure. +.unindent +.tp +.b \fblong bpf_fib_lookup(void *\fp\fictx\fp\fb, struct bpf_fib_lookup *\fp\fiparams\fp\fb, int\fp \fiplen\fp\fb, u32\fp \fiflags\fp\fb)\fp +.indent 7.0 +.tp +.b description +do fib lookup in kernel tables using parameters in \fiparams\fp\&. +if lookup is successful and result shows packet is to be +forwarded, the neighbor tables are searched for the nexthop. +if successful (ie., fib lookup shows forwarding and nexthop +is resolved), the nexthop address is returned in ipv4_dst +or ipv6_dst based on family, smac is set to mac address of +egress device, dmac is set to nexthop mac address, rt_metric +is set to metric from route (ipv4/ipv6 only), and ifindex +is set to the device index of the nexthop from the fib lookup. +.sp +\fiplen\fp argument is the size of the passed in struct. +\fiflags\fp argument can be a combination of one or more of the +following values: +.indent 7.0 +.tp +.b \fbbpf_fib_lookup_direct\fp +do a direct table lookup vs full lookup using fib +rules. +.tp +.b \fbbpf_fib_lookup_output\fp +perform lookup from an egress perspective (default is +ingress). +.unindent +.sp +\fictx\fp is either \fbstruct xdp_md\fp for xdp programs or +\fbstruct sk_buff\fp tc cls_act programs. +.tp +.b return +.indent 7.0 +.ip \(bu 2 +< 0 if any input argument is invalid +.ip \(bu 2 +0 on success (packet is forwarded, nexthop neighbor exists) +.ip \(bu 2 +> 0 one of \fbbpf_fib_lkup_ret_\fp codes explaining why the +packet is not forwarded or needs assist from full stack +.unindent +.unindent +.tp +.b \fblong bpf_sock_hash_update(struct bpf_sock_ops *\fp\fiskops\fp\fb, struct bpf_map *\fp\fimap\fp\fb, void *\fp\fikey\fp\fb, u64\fp \fiflags\fp\fb)\fp +.indent 7.0 +.tp +.b description +add an entry to, or update a sockhash \fimap\fp referencing sockets. +the \fiskops\fp is used as a new value for the entry associated to +\fikey\fp\&. \fiflags\fp is one of: +.indent 7.0 +.tp +.b \fbbpf_noexist\fp +the entry for \fikey\fp must not exist in the map. +.tp +.b \fbbpf_exist\fp +the entry for \fikey\fp must already exist in the map. +.tp +.b \fbbpf_any\fp +no condition on the existence of the entry for \fikey\fp\&. +.unindent +.sp +if the \fimap\fp has ebpf programs (parser and verdict), those will +be inherited by the socket being added. if the socket is +already attached to ebpf programs, this results in an error. +.tp +.b return +0 on success, or a negative error in case of failure. +.unindent +.tp +.b \fblong bpf_msg_redirect_hash(struct sk_msg_buff *\fp\fimsg\fp\fb, struct bpf_map *\fp\fimap\fp\fb, void *\fp\fikey\fp\fb, u64\fp \fiflags\fp\fb)\fp +.indent 7.0 +.tp +.b description +this helper is used in programs implementing policies at the +socket level. if the message \fimsg\fp is allowed to pass (i.e. if +the verdict ebpf program returns \fbsk_pass\fp), redirect it to +the socket referenced by \fimap\fp (of type +\fbbpf_map_type_sockhash\fp) using hash \fikey\fp\&. both ingress and +egress interfaces can be used for redirection. the +\fbbpf_f_ingress\fp value in \fiflags\fp is used to make the +distinction (ingress path is selected if the flag is present, +egress path otherwise). this is the only flag supported for now. +.tp +.b return +\fbsk_pass\fp on success, or \fbsk_drop\fp on error. +.unindent +.tp +.b \fblong bpf_sk_redirect_hash(struct sk_buff *\fp\fiskb\fp\fb, struct bpf_map *\fp\fimap\fp\fb, void *\fp\fikey\fp\fb, u64\fp \fiflags\fp\fb)\fp +.indent 7.0 +.tp +.b description +this helper is used in programs implementing policies at the +skb socket level. if the sk_buff \fiskb\fp is allowed to pass (i.e. +if the verdict ebpf program returns \fbsk_pass\fp), redirect it +to the socket referenced by \fimap\fp (of type +\fbbpf_map_type_sockhash\fp) using hash \fikey\fp\&. both ingress and +egress interfaces can be used for redirection. the +\fbbpf_f_ingress\fp value in \fiflags\fp is used to make the +distinction (ingress path is selected if the flag is present, +egress otherwise). this is the only flag supported for now. +.tp +.b return +\fbsk_pass\fp on success, or \fbsk_drop\fp on error. +.unindent +.tp +.b \fblong bpf_lwt_push_encap(struct sk_buff *\fp\fiskb\fp\fb, u32\fp \fitype\fp\fb, void *\fp\fihdr\fp\fb, u32\fp \filen\fp\fb)\fp +.indent 7.0 +.tp +.b description +encapsulate the packet associated to \fiskb\fp within a layer 3 +protocol header. this header is provided in the buffer at +address \fihdr\fp, with \filen\fp its size in bytes. \fitype\fp indicates +the protocol of the header and can be one of: +.indent 7.0 +.tp +.b \fbbpf_lwt_encap_seg6\fp +ipv6 encapsulation with segment routing header +(\fbstruct ipv6_sr_hdr\fp). \fihdr\fp only contains the srh, +the ipv6 header is computed by the kernel. +.tp +.b \fbbpf_lwt_encap_seg6_inline\fp +only works if \fiskb\fp contains an ipv6 packet. insert a +segment routing header (\fbstruct ipv6_sr_hdr\fp) inside +the ipv6 header. +.tp +.b \fbbpf_lwt_encap_ip\fp +ip encapsulation (gre/gue/ipip/etc). the outer header +must be ipv4 or ipv6, followed by zero or more +additional headers, up to \fblwt_bpf_max_headroom\fp +total bytes in all prepended headers. please note that +if \fbskb_is_gso\fp(\fiskb\fp) is true, no more than two +headers can be prepended, and the inner header, if +present, should be either gre or udp/gue. +.unindent +.sp +\fbbpf_lwt_encap_seg6\fp* types can be called by bpf programs +of type \fbbpf_prog_type_lwt_in\fp; \fbbpf_lwt_encap_ip\fp type can +be called by bpf programs of types \fbbpf_prog_type_lwt_in\fp and +\fbbpf_prog_type_lwt_xmit\fp\&. +.sp +a call to this helper is susceptible to change the underlying +packet buffer. therefore, at load time, all checks on pointers +previously done by the verifier are invalidated and must be +performed again, if the helper is used in combination with +direct packet access. +.tp +.b return +0 on success, or a negative error in case of failure. +.unindent +.tp +.b \fblong bpf_lwt_seg6_store_bytes(struct sk_buff *\fp\fiskb\fp\fb, u32\fp \fioffset\fp\fb, const void *\fp\fifrom\fp\fb, u32\fp \filen\fp\fb)\fp +.indent 7.0 +.tp +.b description +store \filen\fp bytes from address \fifrom\fp into the packet +associated to \fiskb\fp, at \fioffset\fp\&. only the flags, tag and tlvs +inside the outermost ipv6 segment routing header can be +modified through this helper. +.sp +a call to this helper is susceptible to change the underlying +packet buffer. therefore, at load time, all checks on pointers +previously done by the verifier are invalidated and must be +performed again, if the helper is used in combination with +direct packet access. +.tp +.b return +0 on success, or a negative error in case of failure. +.unindent +.tp +.b \fblong bpf_lwt_seg6_adjust_srh(struct sk_buff *\fp\fiskb\fp\fb, u32\fp \fioffset\fp\fb, s32\fp \fidelta\fp\fb)\fp +.indent 7.0 +.tp +.b description +adjust the size allocated to tlvs in the outermost ipv6 +segment routing header contained in the packet associated to +\fiskb\fp, at position \fioffset\fp by \fidelta\fp bytes. only offsets +after the segments are accepted. \fidelta\fp can be as well +positive (growing) as negative (shrinking). +.sp +a call to this helper is susceptible to change the underlying +packet buffer. therefore, at load time, all checks on pointers +previously done by the verifier are invalidated and must be +performed again, if the helper is used in combination with +direct packet access. +.tp +.b return +0 on success, or a negative error in case of failure. +.unindent +.tp +.b \fblong bpf_lwt_seg6_action(struct sk_buff *\fp\fiskb\fp\fb, u32\fp \fiaction\fp\fb, void *\fp\fiparam\fp\fb, u32\fp \fiparam_len\fp\fb)\fp +.indent 7.0 +.tp +.b description +apply an ipv6 segment routing action of type \fiaction\fp to the +packet associated to \fiskb\fp\&. each action takes a parameter +contained at address \fiparam\fp, and of length \fiparam_len\fp bytes. +\fiaction\fp can be one of: +.indent 7.0 +.tp +.b \fbseg6_local_action_end_x\fp +end.x action: endpoint with layer\-3 cross\-connect. +type of \fiparam\fp: \fbstruct in6_addr\fp\&. +.tp +.b \fbseg6_local_action_end_t\fp +end.t action: endpoint with specific ipv6 table lookup. +type of \fiparam\fp: \fbint\fp\&. +.tp +.b \fbseg6_local_action_end_b6\fp +end.b6 action: endpoint bound to an srv6 policy. +type of \fiparam\fp: \fbstruct ipv6_sr_hdr\fp\&. +.tp +.b \fbseg6_local_action_end_b6_encap\fp +end.b6.encap action: endpoint bound to an srv6 +encapsulation policy. +type of \fiparam\fp: \fbstruct ipv6_sr_hdr\fp\&. +.unindent +.sp +a call to this helper is susceptible to change the underlying +packet buffer. therefore, at load time, all checks on pointers +previously done by the verifier are invalidated and must be +performed again, if the helper is used in combination with +direct packet access. +.tp +.b return +0 on success, or a negative error in case of failure. +.unindent +.tp +.b \fblong bpf_rc_repeat(void *\fp\fictx\fp\fb)\fp +.indent 7.0 +.tp +.b description +this helper is used in programs implementing ir decoding, to +report a successfully decoded repeat key message. this delays +the generation of a key up event for previously generated +key down event. +.sp +some ir protocols like nec have a special ir message for +repeating last button, for when a button is held down. +.sp +the \fictx\fp should point to the lirc sample as passed into +the program. +.sp +this helper is only available is the kernel was compiled with +the \fbconfig_bpf_lirc_mode2\fp configuration option set to +"\fby\fp". +.tp +.b return +0 +.unindent +.tp +.b \fblong bpf_rc_keydown(void *\fp\fictx\fp\fb, u32\fp \fiprotocol\fp\fb, u64\fp \fiscancode\fp\fb, u32\fp \fitoggle\fp\fb)\fp +.indent 7.0 +.tp +.b description +this helper is used in programs implementing ir decoding, to +report a successfully decoded key press with \fiscancode\fp, +\fitoggle\fp value in the given \fiprotocol\fp\&. the scancode will be +translated to a keycode using the rc keymap, and reported as +an input key down event. after a period a key up event is +generated. this period can be extended by calling either +\fbbpf_rc_keydown\fp() again with the same values, or calling +\fbbpf_rc_repeat\fp(). +.sp +some protocols include a toggle bit, in case the button was +released and pressed again between consecutive scancodes. +.sp +the \fictx\fp should point to the lirc sample as passed into +the program. +.sp +the \fiprotocol\fp is the decoded protocol number (see +\fbenum rc_proto\fp for some predefined values). +.sp +this helper is only available is the kernel was compiled with +the \fbconfig_bpf_lirc_mode2\fp configuration option set to +"\fby\fp". +.tp +.b return +0 +.unindent +.tp +.b \fbu64 bpf_skb_cgroup_id(struct sk_buff *\fp\fiskb\fp\fb)\fp +.indent 7.0 +.tp +.b description +return the cgroup v2 id of the socket associated with the \fiskb\fp\&. +this is roughly similar to the \fbbpf_get_cgroup_classid\fp() +helper for cgroup v1 by providing a tag resp. identifier that +can be matched on or used for map lookups e.g. to implement +policy. the cgroup v2 id of a given path in the hierarchy is +exposed in user space through the f_handle api in order to get +to the same 64\-bit id. +.sp +this helper can be used on tc egress path, but not on ingress, +and is available only if the kernel was compiled with the +\fbconfig_sock_cgroup_data\fp configuration option. +.tp +.b return +the id is returned or 0 in case the id could not be retrieved. +.unindent +.tp +.b \fbu64 bpf_get_current_cgroup_id(void)\fp +.indent 7.0 +.tp +.b return +a 64\-bit integer containing the current cgroup id based +on the cgroup within which the current task is running. +.unindent +.tp +.b \fbvoid *bpf_get_local_storage(void *\fp\fimap\fp\fb, u64\fp \fiflags\fp\fb)\fp +.indent 7.0 +.tp +.b description +get the pointer to the local storage area. +the type and the size of the local storage is defined +by the \fimap\fp argument. +the \fiflags\fp meaning is specific for each map type, +and has to be 0 for cgroup local storage. +.sp +depending on the bpf program type, a local storage area +can be shared between multiple instances of the bpf program, +running simultaneously. +.sp +a user should care about the synchronization by himself. +for example, by using the \fbbpf_stx_xadd\fp instruction to alter +the shared data. +.tp +.b return +a pointer to the local storage area. +.unindent +.tp +.b \fblong bpf_sk_select_reuseport(struct sk_reuseport_md *\fp\fireuse\fp\fb, struct bpf_map *\fp\fimap\fp\fb, void *\fp\fikey\fp\fb, u64\fp \fiflags\fp\fb)\fp +.indent 7.0 +.tp +.b description +select a \fbso_reuseport\fp socket from a +\fbbpf_map_type_reuseport_array\fp \fimap\fp\&. +it checks the selected socket is matching the incoming +request in the socket buffer. +.tp +.b return +0 on success, or a negative error in case of failure. +.unindent +.tp +.b \fbu64 bpf_skb_ancestor_cgroup_id(struct sk_buff *\fp\fiskb\fp\fb, int\fp \fiancestor_level\fp\fb)\fp +.indent 7.0 +.tp +.b description +return id of cgroup v2 that is ancestor of cgroup associated +with the \fiskb\fp at the \fiancestor_level\fp\&. the root cgroup is at +\fiancestor_level\fp zero and each step down the hierarchy +increments the level. if \fiancestor_level\fp == level of cgroup +associated with \fiskb\fp, then return value will be same as that +of \fbbpf_skb_cgroup_id\fp(). +.sp +the helper is useful to implement policies based on cgroups +that are upper in hierarchy than immediate cgroup associated +with \fiskb\fp\&. +.sp +the format of returned id and helper limitations are same as in +\fbbpf_skb_cgroup_id\fp(). +.tp +.b return +the id is returned or 0 in case the id could not be retrieved. +.unindent +.tp +.b \fbstruct bpf_sock *bpf_sk_lookup_tcp(void *\fp\fictx\fp\fb, struct bpf_sock_tuple *\fp\fituple\fp\fb, u32\fp \fituple_size\fp\fb, u64\fp \finetns\fp\fb, u64\fp \fiflags\fp\fb)\fp +.indent 7.0 +.tp +.b description +look for tcp socket matching \fituple\fp, optionally in a child +network namespace \finetns\fp\&. the return value must be checked, +and if non\-\fbnull\fp, released via \fbbpf_sk_release\fp(). +.sp +the \fictx\fp should point to the context of the program, such as +the skb or socket (depending on the hook in use). this is used +to determine the base network namespace for the lookup. +.sp +\fituple_size\fp must be one of: +.indent 7.0 +.tp +.b \fbsizeof\fp(\fituple\fp\fb\->ipv4\fp) +look for an ipv4 socket. +.tp +.b \fbsizeof\fp(\fituple\fp\fb\->ipv6\fp) +look for an ipv6 socket. +.unindent +.sp +if the \finetns\fp is a negative signed 32\-bit integer, then the +socket lookup table in the netns associated with the \fictx\fp +will be used. for the tc hooks, this is the netns of the device +in the skb. for socket hooks, this is the netns of the socket. +if \finetns\fp is any other signed 32\-bit value greater than or +equal to zero then it specifies the id of the netns relative to +the netns associated with the \fictx\fp\&. \finetns\fp values beyond the +range of 32\-bit integers are reserved for future use. +.sp +all values for \fiflags\fp are reserved for future usage, and must +be left at zero. +.sp +this helper is available only if the kernel was compiled with +\fbconfig_net\fp configuration option. +.tp +.b return +pointer to \fbstruct bpf_sock\fp, or \fbnull\fp in case of failure. +for sockets with reuseport option, the \fbstruct bpf_sock\fp +result is from \fireuse\fp\fb\->socks\fp[] using the hash of the +tuple. +.unindent +.tp +.b \fbstruct bpf_sock *bpf_sk_lookup_udp(void *\fp\fictx\fp\fb, struct bpf_sock_tuple *\fp\fituple\fp\fb, u32\fp \fituple_size\fp\fb, u64\fp \finetns\fp\fb, u64\fp \fiflags\fp\fb)\fp +.indent 7.0 +.tp +.b description +look for udp socket matching \fituple\fp, optionally in a child +network namespace \finetns\fp\&. the return value must be checked, +and if non\-\fbnull\fp, released via \fbbpf_sk_release\fp(). +.sp +the \fictx\fp should point to the context of the program, such as +the skb or socket (depending on the hook in use). this is used +to determine the base network namespace for the lookup. +.sp +\fituple_size\fp must be one of: +.indent 7.0 +.tp +.b \fbsizeof\fp(\fituple\fp\fb\->ipv4\fp) +look for an ipv4 socket. +.tp +.b \fbsizeof\fp(\fituple\fp\fb\->ipv6\fp) +look for an ipv6 socket. +.unindent +.sp +if the \finetns\fp is a negative signed 32\-bit integer, then the +socket lookup table in the netns associated with the \fictx\fp +will be used. for the tc hooks, this is the netns of the device +in the skb. for socket hooks, this is the netns of the socket. +if \finetns\fp is any other signed 32\-bit value greater than or +equal to zero then it specifies the id of the netns relative to +the netns associated with the \fictx\fp\&. \finetns\fp values beyond the +range of 32\-bit integers are reserved for future use. +.sp +all values for \fiflags\fp are reserved for future usage, and must +be left at zero. +.sp +this helper is available only if the kernel was compiled with +\fbconfig_net\fp configuration option. +.tp +.b return +pointer to \fbstruct bpf_sock\fp, or \fbnull\fp in case of failure. +for sockets with reuseport option, the \fbstruct bpf_sock\fp +result is from \fireuse\fp\fb\->socks\fp[] using the hash of the +tuple. +.unindent +.tp +.b \fblong bpf_sk_release(struct bpf_sock *\fp\fisock\fp\fb)\fp +.indent 7.0 +.tp +.b description +release the reference held by \fisock\fp\&. \fisock\fp must be a +non\-\fbnull\fp pointer that was returned from +\fbbpf_sk_lookup_xxx\fp(). +.tp +.b return +0 on success, or a negative error in case of failure. +.unindent +.tp +.b \fblong bpf_map_push_elem(struct bpf_map *\fp\fimap\fp\fb, const void *\fp\fivalue\fp\fb, u64\fp \fiflags\fp\fb)\fp +.indent 7.0 +.tp +.b description +push an element \fivalue\fp in \fimap\fp\&. \fiflags\fp is one of: +.indent 7.0 +.tp +.b \fbbpf_exist\fp +if the queue/stack is full, the oldest element is +removed to make room for this. +.unindent +.tp +.b return +0 on success, or a negative error in case of failure. +.unindent +.tp +.b \fblong bpf_map_pop_elem(struct bpf_map *\fp\fimap\fp\fb, void *\fp\fivalue\fp\fb)\fp +.indent 7.0 +.tp +.b description +pop an element from \fimap\fp\&. +.tp +.b return +0 on success, or a negative error in case of failure. +.unindent +.tp +.b \fblong bpf_map_peek_elem(struct bpf_map *\fp\fimap\fp\fb, void *\fp\fivalue\fp\fb)\fp +.indent 7.0 +.tp +.b description +get an element from \fimap\fp without removing it. +.tp +.b return +0 on success, or a negative error in case of failure. +.unindent +.tp +.b \fblong bpf_msg_push_data(struct sk_msg_buff *\fp\fimsg\fp\fb, u32\fp \fistart\fp\fb, u32\fp \filen\fp\fb, u64\fp \fiflags\fp\fb)\fp +.indent 7.0 +.tp +.b description +for socket policies, insert \filen\fp bytes into \fimsg\fp at offset +\fistart\fp\&. +.sp +if a program of type \fbbpf_prog_type_sk_msg\fp is run on a +\fimsg\fp it may want to insert metadata or options into the \fimsg\fp\&. +this can later be read and used by any of the lower layer bpf +hooks. +.sp +this helper may fail if under memory pressure (a malloc +fails) in these cases bpf programs will get an appropriate +error and bpf programs will need to handle them. +.tp +.b return +0 on success, or a negative error in case of failure. +.unindent +.tp +.b \fblong bpf_msg_pop_data(struct sk_msg_buff *\fp\fimsg\fp\fb, u32\fp \fistart\fp\fb, u32\fp \filen\fp\fb, u64\fp \fiflags\fp\fb)\fp +.indent 7.0 +.tp +.b description +will remove \filen\fp bytes from a \fimsg\fp starting at byte \fistart\fp\&. +this may result in \fbenomem\fp errors under certain situations if +an allocation and copy are required due to a full ring buffer. +however, the helper will try to avoid doing the allocation +if possible. other errors can occur if input parameters are +invalid either due to \fistart\fp byte not being valid part of \fimsg\fp +payload and/or \fipop\fp value being to large. +.tp +.b return +0 on success, or a negative error in case of failure. +.unindent +.tp +.b \fblong bpf_rc_pointer_rel(void *\fp\fictx\fp\fb, s32\fp \firel_x\fp\fb, s32\fp \firel_y\fp\fb)\fp +.indent 7.0 +.tp +.b description +this helper is used in programs implementing ir decoding, to +report a successfully decoded pointer movement. +.sp +the \fictx\fp should point to the lirc sample as passed into +the program. +.sp +this helper is only available is the kernel was compiled with +the \fbconfig_bpf_lirc_mode2\fp configuration option set to +"\fby\fp". +.tp +.b return +0 +.unindent +.tp +.b \fblong bpf_spin_lock(struct bpf_spin_lock *\fp\filock\fp\fb)\fp +.indent 7.0 +.tp +.b description +acquire a spinlock represented by the pointer \filock\fp, which is +stored as part of a value of a map. taking the lock allows to +safely update the rest of the fields in that value. the +spinlock can (and must) later be released with a call to +\fbbpf_spin_unlock\fp(\filock\fp). +.sp +spinlocks in bpf programs come with a number of restrictions +and constraints: +.indent 7.0 +.ip \(bu 2 +\fbbpf_spin_lock\fp objects are only allowed inside maps of +types \fbbpf_map_type_hash\fp and \fbbpf_map_type_array\fp (this +list could be extended in the future). +.ip \(bu 2 +btf description of the map is mandatory. +.ip \(bu 2 +the bpf program can take one lock at a time, since taking two +or more could cause dead locks. +.ip \(bu 2 +only one \fbstruct bpf_spin_lock\fp is allowed per map element. +.ip \(bu 2 +when the lock is taken, calls (either bpf to bpf or helpers) +are not allowed. +.ip \(bu 2 +the \fbbpf_ld_abs\fp and \fbbpf_ld_ind\fp instructions are not +allowed inside a spinlock\-ed region. +.ip \(bu 2 +the bpf program must call \fbbpf_spin_unlock\fp() to release +the lock, on all execution paths, before it returns. +.ip \(bu 2 +the bpf program can access \fbstruct bpf_spin_lock\fp only via +the \fbbpf_spin_lock\fp() and \fbbpf_spin_unlock\fp() +helpers. loading or storing data into the \fbstruct +bpf_spin_lock\fp \filock\fp\fb;\fp field of a map is not allowed. +.ip \(bu 2 +to use the \fbbpf_spin_lock\fp() helper, the btf description +of the map value must be a struct and have \fbstruct +bpf_spin_lock\fp \fianyname\fp\fb;\fp field at the top level. +nested lock inside another struct is not allowed. +.ip \(bu 2 +the \fbstruct bpf_spin_lock\fp \filock\fp field in a map value must +be aligned on a multiple of 4 bytes in that value. +.ip \(bu 2 +syscall with command \fbbpf_map_lookup_elem\fp does not copy +the \fbbpf_spin_lock\fp field to user space. +.ip \(bu 2 +syscall with command \fbbpf_map_update_elem\fp, or update from +a bpf program, do not update the \fbbpf_spin_lock\fp field. +.ip \(bu 2 +\fbbpf_spin_lock\fp cannot be on the stack or inside a +networking packet (it can only be inside of a map values). +.ip \(bu 2 +\fbbpf_spin_lock\fp is available to root only. +.ip \(bu 2 +tracing programs and socket filter programs cannot use +\fbbpf_spin_lock\fp() due to insufficient preemption checks +(but this may change in the future). +.ip \(bu 2 +\fbbpf_spin_lock\fp is not allowed in inner maps of map\-in\-map. +.unindent +.tp +.b return +0 +.unindent +.tp +.b \fblong bpf_spin_unlock(struct bpf_spin_lock *\fp\filock\fp\fb)\fp +.indent 7.0 +.tp +.b description +release the \filock\fp previously locked by a call to +\fbbpf_spin_lock\fp(\filock\fp). +.tp +.b return +0 +.unindent +.tp +.b \fbstruct bpf_sock *bpf_sk_fullsock(struct bpf_sock *\fp\fisk\fp\fb)\fp +.indent 7.0 +.tp +.b description +this helper gets a \fbstruct bpf_sock\fp pointer such +that all the fields in this \fbbpf_sock\fp can be accessed. +.tp +.b return +a \fbstruct bpf_sock\fp pointer on success, or \fbnull\fp in +case of failure. +.unindent +.tp +.b \fbstruct bpf_tcp_sock *bpf_tcp_sock(struct bpf_sock *\fp\fisk\fp\fb)\fp +.indent 7.0 +.tp +.b description +this helper gets a \fbstruct bpf_tcp_sock\fp pointer from a +\fbstruct bpf_sock\fp pointer. +.tp +.b return +a \fbstruct bpf_tcp_sock\fp pointer on success, or \fbnull\fp in +case of failure. +.unindent +.tp +.b \fblong bpf_skb_ecn_set_ce(struct sk_buff *\fp\fiskb\fp\fb)\fp +.indent 7.0 +.tp +.b description +set ecn (explicit congestion notification) field of ip header +to \fbce\fp (congestion encountered) if current value is \fbect\fp +(ecn capable transport). otherwise, do nothing. works with ipv6 +and ipv4. +.tp +.b return +1 if the \fbce\fp flag is set (either by the current helper call +or because it was already present), 0 if it is not set. +.unindent +.tp +.b \fbstruct bpf_sock *bpf_get_listener_sock(struct bpf_sock *\fp\fisk\fp\fb)\fp +.indent 7.0 +.tp +.b description +return a \fbstruct bpf_sock\fp pointer in \fbtcp_listen\fp state. +\fbbpf_sk_release\fp() is unnecessary and not allowed. +.tp +.b return +a \fbstruct bpf_sock\fp pointer on success, or \fbnull\fp in +case of failure. +.unindent +.tp +.b \fbstruct bpf_sock *bpf_skc_lookup_tcp(void *\fp\fictx\fp\fb, struct bpf_sock_tuple *\fp\fituple\fp\fb, u32\fp \fituple_size\fp\fb, u64\fp \finetns\fp\fb, u64\fp \fiflags\fp\fb)\fp +.indent 7.0 +.tp +.b description +look for tcp socket matching \fituple\fp, optionally in a child +network namespace \finetns\fp\&. the return value must be checked, +and if non\-\fbnull\fp, released via \fbbpf_sk_release\fp(). +.sp +this function is identical to \fbbpf_sk_lookup_tcp\fp(), except +that it also returns timewait or request sockets. use +\fbbpf_sk_fullsock\fp() or \fbbpf_tcp_sock\fp() to access the +full structure. +.sp +this helper is available only if the kernel was compiled with +\fbconfig_net\fp configuration option. +.tp +.b return +pointer to \fbstruct bpf_sock\fp, or \fbnull\fp in case of failure. +for sockets with reuseport option, the \fbstruct bpf_sock\fp +result is from \fireuse\fp\fb\->socks\fp[] using the hash of the +tuple. +.unindent +.tp +.b \fblong bpf_tcp_check_syncookie(struct bpf_sock *\fp\fisk\fp\fb, void *\fp\fiiph\fp\fb, u32\fp \fiiph_len\fp\fb, struct tcphdr *\fp\fith\fp\fb, u32\fp \fith_len\fp\fb)\fp +.indent 7.0 +.tp +.b description +check whether \fiiph\fp and \fith\fp contain a valid syn cookie ack for +the listening socket in \fisk\fp\&. +.sp +\fiiph\fp points to the start of the ipv4 or ipv6 header, while +\fiiph_len\fp contains \fbsizeof\fp(\fbstruct iphdr\fp) or +\fbsizeof\fp(\fbstruct ip6hdr\fp). +.sp +\fith\fp points to the start of the tcp header, while \fith_len\fp +contains \fbsizeof\fp(\fbstruct tcphdr\fp). +.tp +.b return +0 if \fiiph\fp and \fith\fp are a valid syn cookie ack, or a negative +error otherwise. +.unindent +.tp +.b \fblong bpf_sysctl_get_name(struct bpf_sysctl *\fp\fictx\fp\fb, char *\fp\fibuf\fp\fb, size_t\fp \fibuf_len\fp\fb, u64\fp \fiflags\fp\fb)\fp +.indent 7.0 +.tp +.b description +get name of sysctl in /proc/sys/ and copy it into provided by +program buffer \fibuf\fp of size \fibuf_len\fp\&. +.sp +the buffer is always nul terminated, unless it\(aqs zero\-sized. +.sp +if \fiflags\fp is zero, full name (e.g. "net/ipv4/tcp_mem") is +copied. use \fbbpf_f_sysctl_base_name\fp flag to copy base name +only (e.g. "tcp_mem"). +.tp +.b return +number of character copied (not including the trailing nul). +.sp +\fb\-e2big\fp if the buffer wasn\(aqt big enough (\fibuf\fp will contain +truncated name in this case). +.unindent +.tp +.b \fblong bpf_sysctl_get_current_value(struct bpf_sysctl *\fp\fictx\fp\fb, char *\fp\fibuf\fp\fb, size_t\fp \fibuf_len\fp\fb)\fp +.indent 7.0 +.tp +.b description +get current value of sysctl as it is presented in /proc/sys +(incl. newline, etc), and copy it as a string into provided +by program buffer \fibuf\fp of size \fibuf_len\fp\&. +.sp +the whole value is copied, no matter what file position user +space issued e.g. sys_read at. +.sp +the buffer is always nul terminated, unless it\(aqs zero\-sized. +.tp +.b return +number of character copied (not including the trailing nul). +.sp +\fb\-e2big\fp if the buffer wasn\(aqt big enough (\fibuf\fp will contain +truncated name in this case). +.sp +\fb\-einval\fp if current value was unavailable, e.g. because +sysctl is uninitialized and read returns \-eio for it. +.unindent +.tp +.b \fblong bpf_sysctl_get_new_value(struct bpf_sysctl *\fp\fictx\fp\fb, char *\fp\fibuf\fp\fb, size_t\fp \fibuf_len\fp\fb)\fp +.indent 7.0 +.tp +.b description +get new value being written by user space to sysctl (before +the actual write happens) and copy it as a string into +provided by program buffer \fibuf\fp of size \fibuf_len\fp\&. +.sp +user space may write new value at file position > 0. +.sp +the buffer is always nul terminated, unless it\(aqs zero\-sized. +.tp +.b return +number of character copied (not including the trailing nul). +.sp +\fb\-e2big\fp if the buffer wasn\(aqt big enough (\fibuf\fp will contain +truncated name in this case). +.sp +\fb\-einval\fp if sysctl is being read. +.unindent +.tp +.b \fblong bpf_sysctl_set_new_value(struct bpf_sysctl *\fp\fictx\fp\fb, const char *\fp\fibuf\fp\fb, size_t\fp \fibuf_len\fp\fb)\fp +.indent 7.0 +.tp +.b description +override new value being written by user space to sysctl with +value provided by program in buffer \fibuf\fp of size \fibuf_len\fp\&. +.sp +\fibuf\fp should contain a string in same form as provided by user +space on sysctl write. +.sp +user space may write new value at file position > 0. to override +the whole sysctl value file position should be set to zero. +.tp +.b return +0 on success. +.sp +\fb\-e2big\fp if the \fibuf_len\fp is too big. +.sp +\fb\-einval\fp if sysctl is being read. +.unindent +.tp +.b \fblong bpf_strtol(const char *\fp\fibuf\fp\fb, size_t\fp \fibuf_len\fp\fb, u64\fp \fiflags\fp\fb, long *\fp\fires\fp\fb)\fp +.indent 7.0 +.tp +.b description +convert the initial part of the string from buffer \fibuf\fp of +size \fibuf_len\fp to a long integer according to the given base +and save the result in \fires\fp\&. +.sp +the string may begin with an arbitrary amount of white space +(as determined by \fbisspace\fp(3)) followed by a single +optional \(aq\fb\-\fp\(aq sign. +.sp +five least significant bits of \fiflags\fp encode base, other bits +are currently unused. +.sp +base must be either 8, 10, 16, or 0 to detect it automatically +similar to user space \fbstrtol\fp(3). +.tp +.b return +number of characters consumed on success. must be positive but +no more than \fibuf_len\fp\&. +.sp +\fb\-einval\fp if no valid digits were found or unsupported base +was provided. +.sp +\fb\-erange\fp if resulting value was out of range. +.unindent +.tp +.b \fblong bpf_strtoul(const char *\fp\fibuf\fp\fb, size_t\fp \fibuf_len\fp\fb, u64\fp \fiflags\fp\fb, unsigned long *\fp\fires\fp\fb)\fp +.indent 7.0 +.tp +.b description +convert the initial part of the string from buffer \fibuf\fp of +size \fibuf_len\fp to an unsigned long integer according to the +given base and save the result in \fires\fp\&. +.sp +the string may begin with an arbitrary amount of white space +(as determined by \fbisspace\fp(3)). +.sp +five least significant bits of \fiflags\fp encode base, other bits +are currently unused. +.sp +base must be either 8, 10, 16, or 0 to detect it automatically +similar to user space \fbstrtoul\fp(3). +.tp +.b return +number of characters consumed on success. must be positive but +no more than \fibuf_len\fp\&. +.sp +\fb\-einval\fp if no valid digits were found or unsupported base +was provided. +.sp +\fb\-erange\fp if resulting value was out of range. +.unindent +.tp +.b \fbvoid *bpf_sk_storage_get(struct bpf_map *\fp\fimap\fp\fb, struct bpf_sock *\fp\fisk\fp\fb, void *\fp\fivalue\fp\fb, u64\fp \fiflags\fp\fb)\fp +.indent 7.0 +.tp +.b description +get a bpf\-local\-storage from a \fisk\fp\&. +.sp +logically, it could be thought of getting the value from +a \fimap\fp with \fisk\fp as the \fbkey\fp\&. from this +perspective, the usage is not much different from +\fbbpf_map_lookup_elem\fp(\fimap\fp, \fb&\fp\fisk\fp) except this +helper enforces the key must be a full socket and the map must +be a \fbbpf_map_type_sk_storage\fp also. +.sp +underneath, the value is stored locally at \fisk\fp instead of +the \fimap\fp\&. the \fimap\fp is used as the bpf\-local\-storage +"type". the bpf\-local\-storage "type" (i.e. the \fimap\fp) is +searched against all bpf\-local\-storages residing at \fisk\fp\&. +.sp +an optional \fiflags\fp (\fbbpf_sk_storage_get_f_create\fp) can be +used such that a new bpf\-local\-storage will be +created if one does not exist. \fivalue\fp can be used +together with \fbbpf_sk_storage_get_f_create\fp to specify +the initial value of a bpf\-local\-storage. if \fivalue\fp is +\fbnull\fp, the new bpf\-local\-storage will be zero initialized. +.tp +.b return +a bpf\-local\-storage pointer is returned on success. +.sp +\fbnull\fp if not found or there was an error in adding +a new bpf\-local\-storage. +.unindent +.tp +.b \fblong bpf_sk_storage_delete(struct bpf_map *\fp\fimap\fp\fb, struct bpf_sock *\fp\fisk\fp\fb)\fp +.indent 7.0 +.tp +.b description +delete a bpf\-local\-storage from a \fisk\fp\&. +.tp +.b return +0 on success. +.sp +\fb\-enoent\fp if the bpf\-local\-storage cannot be found. +.unindent +.tp +.b \fblong bpf_send_signal(u32\fp \fisig\fp\fb)\fp +.indent 7.0 +.tp +.b description +send signal \fisig\fp to the process of the current task. +the signal may be delivered to any of this process\(aqs threads. +.tp +.b return +0 on success or successfully queued. +.sp +\fb\-ebusy\fp if work queue under nmi is full. +.sp +\fb\-einval\fp if \fisig\fp is invalid. +.sp +\fb\-eperm\fp if no permission to send the \fisig\fp\&. +.sp +\fb\-eagain\fp if bpf program can try again. +.unindent +.tp +.b \fbs64 bpf_tcp_gen_syncookie(struct bpf_sock *\fp\fisk\fp\fb, void *\fp\fiiph\fp\fb, u32\fp \fiiph_len\fp\fb, struct tcphdr *\fp\fith\fp\fb, u32\fp \fith_len\fp\fb)\fp +.indent 7.0 +.tp +.b description +try to issue a syn cookie for the packet with corresponding +ip/tcp headers, \fiiph\fp and \fith\fp, on the listening socket in \fisk\fp\&. +.sp +\fiiph\fp points to the start of the ipv4 or ipv6 header, while +\fiiph_len\fp contains \fbsizeof\fp(\fbstruct iphdr\fp) or +\fbsizeof\fp(\fbstruct ip6hdr\fp). +.sp +\fith\fp points to the start of the tcp header, while \fith_len\fp +contains the length of the tcp header. +.tp +.b return +on success, lower 32 bits hold the generated syn cookie in +followed by 16 bits which hold the mss value for that cookie, +and the top 16 bits are unused. +.sp +on failure, the returned value is one of the following: +.sp +\fb\-einval\fp syn cookie cannot be issued due to error +.sp +\fb\-enoent\fp syn cookie should not be issued (no syn flood) +.sp +\fb\-eopnotsupp\fp kernel configuration does not enable syn cookies +.sp +\fb\-eprotonosupport\fp ip packet version is not 4 or 6 +.unindent +.tp +.b \fblong bpf_skb_output(void *\fp\fictx\fp\fb, struct bpf_map *\fp\fimap\fp\fb, u64\fp \fiflags\fp\fb, void *\fp\fidata\fp\fb, u64\fp \fisize\fp\fb)\fp +.indent 7.0 +.tp +.b description +write raw \fidata\fp blob into a special bpf perf event held by +\fimap\fp of type \fbbpf_map_type_perf_event_array\fp\&. this perf +event must have the following attributes: \fbperf_sample_raw\fp +as \fbsample_type\fp, \fbperf_type_software\fp as \fbtype\fp, and +\fbperf_count_sw_bpf_output\fp as \fbconfig\fp\&. +.sp +the \fiflags\fp are used to indicate the index in \fimap\fp for which +the value must be put, masked with \fbbpf_f_index_mask\fp\&. +alternatively, \fiflags\fp can be set to \fbbpf_f_current_cpu\fp +to indicate that the index of the current cpu core should be +used. +.sp +the value to write, of \fisize\fp, is passed through ebpf stack and +pointed by \fidata\fp\&. +.sp +\fictx\fp is a pointer to in\-kernel struct sk_buff. +.sp +this helper is similar to \fbbpf_perf_event_output\fp() but +restricted to raw_tracepoint bpf programs. +.tp +.b return +0 on success, or a negative error in case of failure. +.unindent +.tp +.b \fblong bpf_probe_read_user(void *\fp\fidst\fp\fb, u32\fp \fisize\fp\fb, const void *\fp\fiunsafe_ptr\fp\fb)\fp +.indent 7.0 +.tp +.b description +safely attempt to read \fisize\fp bytes from user space address +\fiunsafe_ptr\fp and store the data in \fidst\fp\&. +.tp +.b return +0 on success, or a negative error in case of failure. +.unindent +.tp +.b \fblong bpf_probe_read_kernel(void *\fp\fidst\fp\fb, u32\fp \fisize\fp\fb, const void *\fp\fiunsafe_ptr\fp\fb)\fp +.indent 7.0 +.tp +.b description +safely attempt to read \fisize\fp bytes from kernel space address +\fiunsafe_ptr\fp and store the data in \fidst\fp\&. +.tp +.b return +0 on success, or a negative error in case of failure. +.unindent +.tp +.b \fblong bpf_probe_read_user_str(void *\fp\fidst\fp\fb, u32\fp \fisize\fp\fb, const void *\fp\fiunsafe_ptr\fp\fb)\fp +.indent 7.0 +.tp +.b description +copy a nul terminated string from an unsafe user address +\fiunsafe_ptr\fp to \fidst\fp\&. the \fisize\fp should include the +terminating nul byte. in case the string length is smaller than +\fisize\fp, the target is not padded with further nul bytes. if the +string length is larger than \fisize\fp, just \fisize\fp\-1 bytes are +copied and the last byte is set to nul. +.sp +on success, the length of the copied string is returned. this +makes this helper useful in tracing programs for reading +strings, and more importantly to get its length at runtime. see +the following snippet: +.indent 7.0 +.indent 3.5 +.sp +.nf +.ft c +sec("kprobe/sys_open") +void bpf_sys_open(struct pt_regs *ctx) +{ + char buf[pathlen]; // pathlen is defined to 256 + int res = bpf_probe_read_user_str(buf, sizeof(buf), + ctx\->di); + + // consume buf, for example push it to + // user space via bpf_perf_event_output(); we + // can use res (the string length) as event + // size, after checking its boundaries. +} +.ft p +.fi +.unindent +.unindent +.sp +in comparison, using \fbbpf_probe_read_user\fp() helper here +instead to read the string would require to estimate the length +at compile time, and would often result in copying more memory +than necessary. +.sp +another useful use case is when parsing individual process +arguments or individual environment variables navigating +\ficurrent\fp\fb\->mm\->arg_start\fp and \ficurrent\fp\fb\->mm\->env_start\fp: using this helper and the return value, +one can quickly iterate at the right offset of the memory area. +.tp +.b return +on success, the strictly positive length of the string, +including the trailing nul character. on error, a negative +value. +.unindent +.tp +.b \fblong bpf_probe_read_kernel_str(void *\fp\fidst\fp\fb, u32\fp \fisize\fp\fb, const void *\fp\fiunsafe_ptr\fp\fb)\fp +.indent 7.0 +.tp +.b description +copy a nul terminated string from an unsafe kernel address \fiunsafe_ptr\fp +to \fidst\fp\&. same semantics as with \fbbpf_probe_read_user_str\fp() apply. +.tp +.b return +on success, the strictly positive length of the string, including +the trailing nul character. on error, a negative value. +.unindent +.tp +.b \fblong bpf_tcp_send_ack(void *\fp\fitp\fp\fb, u32\fp \fircv_nxt\fp\fb)\fp +.indent 7.0 +.tp +.b description +send out a tcp\-ack. \fitp\fp is the in\-kernel struct \fbtcp_sock\fp\&. +\fircv_nxt\fp is the ack_seq to be sent out. +.tp +.b return +0 on success, or a negative error in case of failure. +.unindent +.tp +.b \fblong bpf_send_signal_thread(u32\fp \fisig\fp\fb)\fp +.indent 7.0 +.tp +.b description +send signal \fisig\fp to the thread corresponding to the current task. +.tp +.b return +0 on success or successfully queued. +.sp +\fb\-ebusy\fp if work queue under nmi is full. +.sp +\fb\-einval\fp if \fisig\fp is invalid. +.sp +\fb\-eperm\fp if no permission to send the \fisig\fp\&. +.sp +\fb\-eagain\fp if bpf program can try again. +.unindent +.tp +.b \fbu64 bpf_jiffies64(void)\fp +.indent 7.0 +.tp +.b description +obtain the 64bit jiffies +.tp +.b return +the 64 bit jiffies +.unindent +.tp +.b \fblong bpf_read_branch_records(struct bpf_perf_event_data *\fp\fictx\fp\fb, void *\fp\fibuf\fp\fb, u32\fp \fisize\fp\fb, u64\fp \fiflags\fp\fb)\fp +.indent 7.0 +.tp +.b description +for an ebpf program attached to a perf event, retrieve the +branch records (\fbstruct perf_branch_entry\fp) associated to \fictx\fp +and store it in the buffer pointed by \fibuf\fp up to size +\fisize\fp bytes. +.tp +.b return +on success, number of bytes written to \fibuf\fp\&. on error, a +negative value. +.sp +the \fiflags\fp can be set to \fbbpf_f_get_branch_records_size\fp to +instead return the number of bytes required to store all the +branch entries. if this flag is set, \fibuf\fp may be null. +.sp +\fb\-einval\fp if arguments invalid or \fbsize\fp not a multiple +of \fbsizeof\fp(\fbstruct perf_branch_entry\fp). +.sp +\fb\-enoent\fp if architecture does not support branch records. +.unindent +.tp +.b \fblong bpf_get_ns_current_pid_tgid(u64\fp \fidev\fp\fb, u64\fp \fiino\fp\fb, struct bpf_pidns_info *\fp\finsdata\fp\fb, u32\fp \fisize\fp\fb)\fp +.indent 7.0 +.tp +.b description +returns 0 on success, values for \fipid\fp and \fitgid\fp as seen from the current +\finamespace\fp will be returned in \finsdata\fp\&. +.tp +.b return +0 on success, or one of the following in case of failure: +.sp +\fb\-einval\fp if dev and inum supplied don\(aqt match dev_t and inode number +with nsfs of current task, or if dev conversion to dev_t lost high bits. +.sp +\fb\-enoent\fp if pidns does not exists for the current task. +.unindent +.tp +.b \fblong bpf_xdp_output(void *\fp\fictx\fp\fb, struct bpf_map *\fp\fimap\fp\fb, u64\fp \fiflags\fp\fb, void *\fp\fidata\fp\fb, u64\fp \fisize\fp\fb)\fp +.indent 7.0 +.tp +.b description +write raw \fidata\fp blob into a special bpf perf event held by +\fimap\fp of type \fbbpf_map_type_perf_event_array\fp\&. this perf +event must have the following attributes: \fbperf_sample_raw\fp +as \fbsample_type\fp, \fbperf_type_software\fp as \fbtype\fp, and +\fbperf_count_sw_bpf_output\fp as \fbconfig\fp\&. +.sp +the \fiflags\fp are used to indicate the index in \fimap\fp for which +the value must be put, masked with \fbbpf_f_index_mask\fp\&. +alternatively, \fiflags\fp can be set to \fbbpf_f_current_cpu\fp +to indicate that the index of the current cpu core should be +used. +.sp +the value to write, of \fisize\fp, is passed through ebpf stack and +pointed by \fidata\fp\&. +.sp +\fictx\fp is a pointer to in\-kernel struct xdp_buff. +.sp +this helper is similar to \fbbpf_perf_eventoutput\fp() but +restricted to raw_tracepoint bpf programs. +.tp +.b return +0 on success, or a negative error in case of failure. +.unindent +.tp +.b \fbu64 bpf_get_netns_cookie(void *\fp\fictx\fp\fb)\fp +.indent 7.0 +.tp +.b description +retrieve the cookie (generated by the kernel) of the network +namespace the input \fictx\fp is associated with. the network +namespace cookie remains stable for its lifetime and provides +a global identifier that can be assumed unique. if \fictx\fp is +null, then the helper returns the cookie for the initial +network namespace. the cookie itself is very similar to that +of \fbbpf_get_socket_cookie\fp() helper, but for network +namespaces instead of sockets. +.tp +.b return +a 8\-byte long opaque number. +.unindent +.tp +.b \fbu64 bpf_get_current_ancestor_cgroup_id(int\fp \fiancestor_level\fp\fb)\fp +.indent 7.0 +.tp +.b description +return id of cgroup v2 that is ancestor of the cgroup associated +with the current task at the \fiancestor_level\fp\&. the root cgroup +is at \fiancestor_level\fp zero and each step down the hierarchy +increments the level. if \fiancestor_level\fp == level of cgroup +associated with the current task, then return value will be the +same as that of \fbbpf_get_current_cgroup_id\fp(). +.sp +the helper is useful to implement policies based on cgroups +that are upper in hierarchy than immediate cgroup associated +with the current task. +.sp +the format of returned id and helper limitations are same as in +\fbbpf_get_current_cgroup_id\fp(). +.tp +.b return +the id is returned or 0 in case the id could not be retrieved. +.unindent +.tp +.b \fblong bpf_sk_assign(struct sk_buff *\fp\fiskb\fp\fb, struct bpf_sock *\fp\fisk\fp\fb, u64\fp \fiflags\fp\fb)\fp +.indent 7.0 +.tp +.b description +helper is overloaded depending on bpf program type. this +description applies to \fbbpf_prog_type_sched_cls\fp and +\fbbpf_prog_type_sched_act\fp programs. +.sp +assign the \fisk\fp to the \fiskb\fp\&. when combined with appropriate +routing configuration to receive the packet towards the socket, +will cause \fiskb\fp to be delivered to the specified socket. +subsequent redirection of \fiskb\fp via \fbbpf_redirect\fp(), +\fbbpf_clone_redirect\fp() or other methods outside of bpf may +interfere with successful delivery to the socket. +.sp +this operation is only valid from tc ingress path. +.sp +the \fiflags\fp argument must be zero. +.tp +.b return +0 on success, or a negative error in case of failure: +.sp +\fb\-einval\fp if specified \fiflags\fp are not supported. +.sp +\fb\-enoent\fp if the socket is unavailable for assignment. +.sp +\fb\-enetunreach\fp if the socket is unreachable (wrong netns). +.sp +\fb\-eopnotsupp\fp if the operation is not supported, for example +a call from outside of tc ingress. +.sp +\fb\-esocktnosupport\fp if the socket type is not supported +(reuseport). +.unindent +.tp +.b \fblong bpf_sk_assign(struct bpf_sk_lookup *\fp\fictx\fp\fb, struct bpf_sock *\fp\fisk\fp\fb, u64\fp \fiflags\fp\fb)\fp +.indent 7.0 +.tp +.b description +helper is overloaded depending on bpf program type. this +description applies to \fbbpf_prog_type_sk_lookup\fp programs. +.sp +select the \fisk\fp as a result of a socket lookup. +.sp +for the operation to succeed passed socket must be compatible +with the packet description provided by the \fictx\fp object. +.sp +l4 protocol (\fbipproto_tcp\fp or \fbipproto_udp\fp) must +be an exact match. while ip family (\fbaf_inet\fp or +\fbaf_inet6\fp) must be compatible, that is ipv6 sockets +that are not v6\-only can be selected for ipv4 packets. +.sp +only tcp listeners and udp unconnected sockets can be +selected. \fisk\fp can also be null to reset any previous +selection. +.sp +\fiflags\fp argument can combination of following values: +.indent 7.0 +.ip \(bu 2 +\fbbpf_sk_lookup_f_replace\fp to override the previous +socket selection, potentially done by a bpf program +that ran before us. +.ip \(bu 2 +\fbbpf_sk_lookup_f_no_reuseport\fp to skip +load\-balancing within reuseport group for the socket +being selected. +.unindent +.sp +on success \fictx\->sk\fp will point to the selected socket. +.tp +.b return +0 on success, or a negative errno in case of failure. +.indent 7.0 +.ip \(bu 2 +\fb\-eafnosupport\fp if socket family (\fisk\->family\fp) is +not compatible with packet family (\fictx\->family\fp). +.ip \(bu 2 +\fb\-eexist\fp if socket has been already selected, +potentially by another program, and +\fbbpf_sk_lookup_f_replace\fp flag was not specified. +.ip \(bu 2 +\fb\-einval\fp if unsupported flags were specified. +.ip \(bu 2 +\fb\-eprototype\fp if socket l4 protocol +(\fisk\->protocol\fp) doesn\(aqt match packet protocol +(\fictx\->protocol\fp). +.ip \(bu 2 +\fb\-esocktnosupport\fp if socket is not in allowed +state (tcp listening or udp unconnected). +.unindent +.unindent +.tp +.b \fbu64 bpf_ktime_get_boot_ns(void)\fp +.indent 7.0 +.tp +.b description +return the time elapsed since system boot, in nanoseconds. +does include the time the system was suspended. +see: \fbclock_gettime\fp(\fbclock_boottime\fp) +.tp +.b return +current \fiktime\fp\&. +.unindent +.tp +.b \fblong bpf_seq_printf(struct seq_file *\fp\fim\fp\fb, const char *\fp\fifmt\fp\fb, u32\fp \fifmt_size\fp\fb, const void *\fp\fidata\fp\fb, u32\fp \fidata_len\fp\fb)\fp +.indent 7.0 +.tp +.b description +\fbbpf_seq_printf\fp() uses seq_file \fbseq_printf\fp() to print +out the format string. +the \fim\fp represents the seq_file. the \fifmt\fp and \fifmt_size\fp are for +the format string itself. the \fidata\fp and \fidata_len\fp are format string +arguments. the \fidata\fp are a \fbu64\fp array and corresponding format string +values are stored in the array. for strings and pointers where pointees +are accessed, only the pointer values are stored in the \fidata\fp array. +the \fidata_len\fp is the size of \fidata\fp in bytes. +.sp +formats \fb%s\fp, \fb%p{i,i}{4,6}\fp requires to read kernel memory. +reading kernel memory may fail due to either invalid address or +valid address but requiring a major memory fault. if reading kernel memory +fails, the string for \fb%s\fp will be an empty string, and the ip +address for \fb%p{i,i}{4,6}\fp will be 0. not returning error to +bpf program is consistent with what \fbbpf_trace_printk\fp() does for now. +.tp +.b return +0 on success, or a negative error in case of failure: +.sp +\fb\-ebusy\fp if per\-cpu memory copy buffer is busy, can try again +by returning 1 from bpf program. +.sp +\fb\-einval\fp if arguments are invalid, or if \fifmt\fp is invalid/unsupported. +.sp +\fb\-e2big\fp if \fifmt\fp contains too many format specifiers. +.sp +\fb\-eoverflow\fp if an overflow happened: the same object will be tried again. +.unindent +.tp +.b \fblong bpf_seq_write(struct seq_file *\fp\fim\fp\fb, const void *\fp\fidata\fp\fb, u32\fp \filen\fp\fb)\fp +.indent 7.0 +.tp +.b description +\fbbpf_seq_write\fp() uses seq_file \fbseq_write\fp() to write the data. +the \fim\fp represents the seq_file. the \fidata\fp and \filen\fp represent the +data to write in bytes. +.tp +.b return +0 on success, or a negative error in case of failure: +.sp +\fb\-eoverflow\fp if an overflow happened: the same object will be tried again. +.unindent +.tp +.b \fbu64 bpf_sk_cgroup_id(struct bpf_sock *\fp\fisk\fp\fb)\fp +.indent 7.0 +.tp +.b description +return the cgroup v2 id of the socket \fisk\fp\&. +.sp +\fisk\fp must be a non\-\fbnull\fp pointer to a full socket, e.g. one +returned from \fbbpf_sk_lookup_xxx\fp(), +\fbbpf_sk_fullsock\fp(), etc. the format of returned id is +same as in \fbbpf_skb_cgroup_id\fp(). +.sp +this helper is available only if the kernel was compiled with +the \fbconfig_sock_cgroup_data\fp configuration option. +.tp +.b return +the id is returned or 0 in case the id could not be retrieved. +.unindent +.tp +.b \fbu64 bpf_sk_ancestor_cgroup_id(struct bpf_sock *\fp\fisk\fp\fb, int\fp \fiancestor_level\fp\fb)\fp +.indent 7.0 +.tp +.b description +return id of cgroup v2 that is ancestor of cgroup associated +with the \fisk\fp at the \fiancestor_level\fp\&. the root cgroup is at +\fiancestor_level\fp zero and each step down the hierarchy +increments the level. if \fiancestor_level\fp == level of cgroup +associated with \fisk\fp, then return value will be same as that +of \fbbpf_sk_cgroup_id\fp(). +.sp +the helper is useful to implement policies based on cgroups +that are upper in hierarchy than immediate cgroup associated +with \fisk\fp\&. +.sp +the format of returned id and helper limitations are same as in +\fbbpf_sk_cgroup_id\fp(). +.tp +.b return +the id is returned or 0 in case the id could not be retrieved. +.unindent +.tp +.b \fblong bpf_ringbuf_output(void *\fp\firingbuf\fp\fb, void *\fp\fidata\fp\fb, u64\fp \fisize\fp\fb, u64\fp \fiflags\fp\fb)\fp +.indent 7.0 +.tp +.b description +copy \fisize\fp bytes from \fidata\fp into a ring buffer \firingbuf\fp\&. +if \fbbpf_rb_no_wakeup\fp is specified in \fiflags\fp, no notification +of new data availability is sent. +if \fbbpf_rb_force_wakeup\fp is specified in \fiflags\fp, notification +of new data availability is sent unconditionally. +.tp +.b return +0 on success, or a negative error in case of failure. +.unindent +.tp +.b \fbvoid *bpf_ringbuf_reserve(void *\fp\firingbuf\fp\fb, u64\fp \fisize\fp\fb, u64\fp \fiflags\fp\fb)\fp +.indent 7.0 +.tp +.b description +reserve \fisize\fp bytes of payload in a ring buffer \firingbuf\fp\&. +.tp +.b return +valid pointer with \fisize\fp bytes of memory available; null, +otherwise. +.unindent +.tp +.b \fbvoid bpf_ringbuf_submit(void *\fp\fidata\fp\fb, u64\fp \fiflags\fp\fb)\fp +.indent 7.0 +.tp +.b description +submit reserved ring buffer sample, pointed to by \fidata\fp\&. +if \fbbpf_rb_no_wakeup\fp is specified in \fiflags\fp, no notification +of new data availability is sent. +if \fbbpf_rb_force_wakeup\fp is specified in \fiflags\fp, notification +of new data availability is sent unconditionally. +.tp +.b return +nothing. always succeeds. +.unindent +.tp +.b \fbvoid bpf_ringbuf_discard(void *\fp\fidata\fp\fb, u64\fp \fiflags\fp\fb)\fp +.indent 7.0 +.tp +.b description +discard reserved ring buffer sample, pointed to by \fidata\fp\&. +if \fbbpf_rb_no_wakeup\fp is specified in \fiflags\fp, no notification +of new data availability is sent. +if \fbbpf_rb_force_wakeup\fp is specified in \fiflags\fp, notification +of new data availability is sent unconditionally. +.tp +.b return +nothing. always succeeds. +.unindent +.tp +.b \fbu64 bpf_ringbuf_query(void *\fp\firingbuf\fp\fb, u64\fp \fiflags\fp\fb)\fp +.indent 7.0 +.tp +.b description +query various characteristics of provided ring buffer. what +exactly is queries is determined by \fiflags\fp: +.indent 7.0 +.ip \(bu 2 +\fbbpf_rb_avail_data\fp: amount of data not yet consumed. +.ip \(bu 2 +\fbbpf_rb_ring_size\fp: the size of ring buffer. +.ip \(bu 2 +\fbbpf_rb_cons_pos\fp: consumer position (can wrap around). +.ip \(bu 2 +\fbbpf_rb_prod_pos\fp: producer(s) position (can wrap around). +.unindent +.sp +data returned is just a momentary snapshot of actual values +and could be inaccurate, so this facility should be used to +power heuristics and for reporting, not to make 100% correct +calculation. +.tp +.b return +requested value, or 0, if \fiflags\fp are not recognized. +.unindent +.tp +.b \fblong bpf_csum_level(struct sk_buff *\fp\fiskb\fp\fb, u64\fp \filevel\fp\fb)\fp +.indent 7.0 +.tp +.b description +change the skbs checksum level by one layer up or down, or +reset it entirely to none in order to have the stack perform +checksum validation. the level is applicable to the following +protocols: tcp, udp, gre, sctp, fcoe. for example, a decap of +| eth | ip | udp | gue | ip | tcp | into | eth | ip | tcp | +through \fbbpf_skb_adjust_room\fp() helper with passing in +\fbbpf_f_adj_room_no_csum_reset\fp flag would require one call +to \fbbpf_csum_level\fp() with \fbbpf_csum_level_dec\fp since +the udp header is removed. similarly, an encap of the latter +into the former could be accompanied by a helper call to +\fbbpf_csum_level\fp() with \fbbpf_csum_level_inc\fp if the +skb is still intended to be processed in higher layers of the +stack instead of just egressing at tc. +.sp +there are three supported level settings at this time: +.indent 7.0 +.ip \(bu 2 +\fbbpf_csum_level_inc\fp: increases skb\->csum_level for skbs +with checksum_unnecessary. +.ip \(bu 2 +\fbbpf_csum_level_dec\fp: decreases skb\->csum_level for skbs +with checksum_unnecessary. +.ip \(bu 2 +\fbbpf_csum_level_reset\fp: resets skb\->csum_level to 0 and +sets checksum_none to force checksum validation by the stack. +.ip \(bu 2 +\fbbpf_csum_level_query\fp: no\-op, returns the current +skb\->csum_level. +.unindent +.tp +.b return +0 on success, or a negative error in case of failure. in the +case of \fbbpf_csum_level_query\fp, the current skb\->csum_level +is returned or the error code \-eacces in case the skb is not +subject to checksum_unnecessary. +.unindent +.tp +.b \fbstruct tcp6_sock *bpf_skc_to_tcp6_sock(void *\fp\fisk\fp\fb)\fp +.indent 7.0 +.tp +.b description +dynamically cast a \fisk\fp pointer to a \fitcp6_sock\fp pointer. +.tp +.b return +\fisk\fp if casting is valid, or null otherwise. +.unindent +.tp +.b \fbstruct tcp_sock *bpf_skc_to_tcp_sock(void *\fp\fisk\fp\fb)\fp +.indent 7.0 +.tp +.b description +dynamically cast a \fisk\fp pointer to a \fitcp_sock\fp pointer. +.tp +.b return +\fisk\fp if casting is valid, or null otherwise. +.unindent +.tp +.b \fbstruct tcp_timewait_sock *bpf_skc_to_tcp_timewait_sock(void *\fp\fisk\fp\fb)\fp +.indent 7.0 +.tp +.b description +dynamically cast a \fisk\fp pointer to a \fitcp_timewait_sock\fp pointer. +.tp +.b return +\fisk\fp if casting is valid, or null otherwise. +.unindent +.tp +.b \fbstruct tcp_request_sock *bpf_skc_to_tcp_request_sock(void *\fp\fisk\fp\fb)\fp +.indent 7.0 +.tp +.b description +dynamically cast a \fisk\fp pointer to a \fitcp_request_sock\fp pointer. +.tp +.b return +\fisk\fp if casting is valid, or null otherwise. +.unindent +.tp +.b \fbstruct udp6_sock *bpf_skc_to_udp6_sock(void *\fp\fisk\fp\fb)\fp +.indent 7.0 +.tp +.b description +dynamically cast a \fisk\fp pointer to a \fiudp6_sock\fp pointer. +.tp +.b return +\fisk\fp if casting is valid, or null otherwise. +.unindent +.tp +.b \fblong bpf_get_task_stack(struct task_struct *\fp\fitask\fp\fb, void *\fp\fibuf\fp\fb, u32\fp \fisize\fp\fb, u64\fp \fiflags\fp\fb)\fp +.indent 7.0 +.tp +.b description +return a user or a kernel stack in bpf program provided buffer. +to achieve this, the helper needs \fitask\fp, which is a valid +pointer to struct task_struct. to store the stacktrace, the +bpf program provides \fibuf\fp with a nonnegative \fisize\fp\&. +.sp +the last argument, \fiflags\fp, holds the number of stack frames to +skip (from 0 to 255), masked with +\fbbpf_f_skip_field_mask\fp\&. the next bits can be used to set +the following flags: +.indent 7.0 +.tp +.b \fbbpf_f_user_stack\fp +collect a user space stack instead of a kernel stack. +.tp +.b \fbbpf_f_user_build_id\fp +collect buildid+offset instead of ips for user stack, +only valid if \fbbpf_f_user_stack\fp is also specified. +.unindent +.sp +\fbbpf_get_task_stack\fp() can collect up to +\fbperf_max_stack_depth\fp both kernel and user frames, subject +to sufficient large buffer size. note that +this limit can be controlled with the \fbsysctl\fp program, and +that it should be manually increased in order to profile long +user stacks (such as stacks for java programs). to do so, use: +.indent 7.0 +.indent 3.5 +.sp +.nf +.ft c +# sysctl kernel.perf_event_max_stack= +.ft p +.fi +.unindent +.unindent +.tp +.b return +a non\-negative value equal to or less than \fisize\fp on success, +or a negative error in case of failure. +.unindent +.unindent +.sh examples +.sp +example usage for most of the ebpf helpers listed in this manual page are +available within the linux kernel sources, at the following locations: +.indent 0.0 +.ip \(bu 2 +\fisamples/bpf/\fp +.ip \(bu 2 +\fitools/testing/selftests/bpf/\fp +.unindent +.sh license +.sp +ebpf programs can have an associated license, passed along with the bytecode +instructions to the kernel when the programs are loaded. the format for that +string is identical to the one in use for kernel modules (dual licenses, such +as "dual bsd/gpl", may be used). some helper functions are only accessible to +programs that are compatible with the gnu privacy license (gpl). +.sp +in order to use such helpers, the ebpf program must be loaded with the correct +license string passed (via \fbattr\fp) to the \fbbpf\fp() system call, and this +generally translates into the c source code of the program containing a line +similar to the following: +.indent 0.0 +.indent 3.5 +.sp +.nf +.ft c +char ____license[] __attribute__((section("license"), used)) = "gpl"; +.ft p +.fi +.unindent +.unindent +.sh implementation +.sp +this manual page is an effort to document the existing ebpf helper functions. +but as of this writing, the bpf sub\-system is under heavy development. new ebpf +program or map types are added, along with new helper functions. some helpers +are occasionally made available for additional program types. so in spite of +the efforts of the community, this page might not be up\-to\-date. if you want to +check by yourself what helper functions exist in your kernel, or what types of +programs they can support, here are some files among the kernel tree that you +may be interested in: +.indent 0.0 +.ip \(bu 2 +\fiinclude/uapi/linux/bpf.h\fp is the main bpf header. it contains the full list +of all helper functions, as well as many other bpf definitions including most +of the flags, structs or constants used by the helpers. +.ip \(bu 2 +\finet/core/filter.c\fp contains the definition of most network\-related helper +functions, and the list of program types from which they can be used. +.ip \(bu 2 +\fikernel/trace/bpf_trace.c\fp is the equivalent for most tracing program\-related +helpers. +.ip \(bu 2 +\fikernel/bpf/verifier.c\fp contains the functions used to check that valid types +of ebpf maps are used with a given helper function. +.ip \(bu 2 +\fikernel/bpf/\fp directory contains other files in which additional helpers are +defined (for cgroups, sockmaps, etc.). +.ip \(bu 2 +the bpftool utility can be used to probe the availability of helper functions +on the system (as well as supported program and map types, and a number of +other parameters). to do so, run \fbbpftool feature probe\fp (see +\fbbpftool\-feature\fp(8) for details). add the \fbunprivileged\fp keyword to +list features available to unprivileged users. +.unindent +.sp +compatibility between helper functions and program types can generally be found +in the files where helper functions are defined. look for the \fbstruct +bpf_func_proto\fp objects and for functions returning them: these functions +contain a list of helpers that a given program type can call. note that the +\fbdefault:\fp label of the \fbswitch ... case\fp used to filter helpers can call +other functions, themselves allowing access to additional helpers. the +requirement for gpl license is also in those \fbstruct bpf_func_proto\fp\&. +.sp +compatibility between helper functions and map types can be found in the +\fbcheck_map_func_compatibility\fp() function in file \fikernel/bpf/verifier.c\fp\&. +.sp +helper functions that invalidate the checks on \fbdata\fp and \fbdata_end\fp +pointers for network processing are listed in function +\fbbpf_helper_changes_pkt_data\fp() in file \finet/core/filter.c\fp\&. +.sh see also +.sp +\fbbpf\fp(2), +\fbbpftool\fp(8), +\fbcgroups\fp(7), +\fbip\fp(8), +\fbperf_event_open\fp(2), +\fbsendmsg\fp(2), +\fbsocket\fp(7), +\fbtc\-bpf\fp(8) +.\" generated by docutils manpage writer. +. +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1993 michael haardt +.\" fri apr 2 11:32:09 met dst 1993 +.\" +.\" and changes copyright (c) 1999 mike coleman (mkc@acm.org) +.\" -- major revision to fully document ptrace semantics per recent linux +.\" kernel (2.2.10) and glibc (2.1.2) +.\" sun nov 7 03:18:35 cst 1999 +.\" +.\" and copyright (c) 2011, denys vlasenko +.\" and copyright (c) 2015, 2016, michael kerrisk +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" modified fri jul 23 23:47:18 1993 by rik faith +.\" modified fri jan 31 16:46:30 1997 by eric s. raymond +.\" modified thu oct 7 17:28:49 1999 by andries brouwer +.\" modified, 27 may 2004, michael kerrisk +.\" added notes on capability requirements +.\" +.\" 2006-03-24, chuck ebbert <76306.1226@compuserve.com> +.\" added ptrace_setoptions, ptrace_geteventmsg, ptrace_getsiginfo, +.\" ptrace_setsiginfo, ptrace_sysemu, ptrace_sysemu_singlestep +.\" (thanks to blaisorblade, daniel jacobowitz and others who helped.) +.\" 2011-09, major update by denys vlasenko +.\" 2015-01, kees cook +.\" added ptrace_o_traceseccomp, ptrace_event_seccomp +.\" +.\" fixme the following are undocumented: +.\" +.\" ptrace_getwmmxregs +.\" ptrace_setwmmxregs +.\" arm +.\" linux 2.6.12 +.\" +.\" ptrace_set_syscall +.\" arm and arm64 +.\" linux 2.6.16 +.\" commit 3f471126ee53feb5e9b210ea2f525ed3bb9b7a7f +.\" author: nicolas pitre +.\" date: sat jan 14 19:30:04 2006 +0000 +.\" +.\" ptrace_getcrunchregs +.\" ptrace_setcrunchregs +.\" arm +.\" linux 2.6.18 +.\" commit 3bec6ded282b331552587267d67a06ed7fd95ddd +.\" author: lennert buytenhek +.\" date: tue jun 27 22:56:18 2006 +0100 +.\" +.\" ptrace_getvfpregs +.\" ptrace_setvfpregs +.\" arm and arm64 +.\" linux 2.6.30 +.\" commit 3d1228ead618b88e8606015cbabc49019981805d +.\" author: catalin marinas +.\" date: wed feb 11 13:12:56 2009 +0100 +.\" +.\" ptrace_gethbpregs +.\" ptrace_sethbpregs +.\" arm and arm64 +.\" linux 2.6.37 +.\" commit 864232fa1a2f8dfe003438ef0851a56722740f3e +.\" author: will deacon +.\" date: fri sep 3 10:42:55 2010 +0100 +.\" +.\" ptrace_singleblock +.\" since at least linux 2.4.0 on various architectures +.\" since linux 2.6.25 on x86 (and others?) +.\" commit 5b88abbf770a0e1975c668743100f42934f385e8 +.\" author: roland mcgrath +.\" date: wed jan 30 13:30:53 2008 +0100 +.\" ptrace: generic ptrace_singleblock +.\" +.\" ptrace_getfpxregs +.\" ptrace_setfpxregs +.\" since at least linux 2.4.0 on various architectures +.\" +.\" ptrace_getfdpic +.\" ptrace_getfdpic_exec +.\" ptrace_getfdpic_interp +.\" blackfin, c6x, frv, sh +.\" first appearance in linux 2.6.11 on frv +.\" +.\" and others that can be found in the arch/*/include/uapi/asm/ptrace files +.\" +.th ptrace 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +ptrace \- process trace +.sh synopsis +.nf +.b #include +.pp +.bi "long ptrace(enum __ptrace_request " request ", pid_t " pid , +.bi " void *" addr ", void *" data ); +.fi +.sh description +the +.br ptrace () +system call provides a means by which one process (the "tracer") +may observe and control the execution of another process (the "tracee"), +and examine and change the tracee's memory and registers. +it is primarily used to implement breakpoint debugging and system +call tracing. +.pp +a tracee first needs to be attached to the tracer. +attachment and subsequent commands are per thread: +in a multithreaded process, +every thread can be individually attached to a +(potentially different) tracer, +or left not attached and thus not debugged. +therefore, "tracee" always means "(one) thread", +never "a (possibly multithreaded) process". +ptrace commands are always sent to +a specific tracee using a call of the form +.pp + ptrace(ptrace_foo, pid, ...) +.pp +where +.i pid +is the thread id of the corresponding linux thread. +.pp +(note that in this page, a "multithreaded process" +means a thread group consisting of threads created using the +.br clone (2) +.b clone_thread +flag.) +.pp +a process can initiate a trace by calling +.br fork (2) +and having the resulting child do a +.br ptrace_traceme , +followed (typically) by an +.br execve (2). +alternatively, one process may commence tracing another process using +.b ptrace_attach +or +.br ptrace_seize . +.pp +while being traced, the tracee will stop each time a signal is delivered, +even if the signal is being ignored. +(an exception is +.br sigkill , +which has its usual effect.) +the tracer will be notified at its next call to +.br waitpid (2) +(or one of the related "wait" system calls); that call will return a +.i status +value containing information that indicates +the cause of the stop in the tracee. +while the tracee is stopped, +the tracer can use various ptrace requests to inspect and modify the tracee. +the tracer then causes the tracee to continue, +optionally ignoring the delivered signal +(or even delivering a different signal instead). +.pp +if the +.b ptrace_o_traceexec +option is not in effect, all successful calls to +.br execve (2) +by the traced process will cause it to be sent a +.b sigtrap +signal, +giving the parent a chance to gain control before the new program +begins execution. +.pp +when the tracer is finished tracing, it can cause the tracee to continue +executing in a normal, untraced mode via +.br ptrace_detach . +.pp +the value of +.i request +determines the action to be performed: +.tp +.b ptrace_traceme +indicate that this process is to be traced by its parent. +a process probably shouldn't make this request if its parent +isn't expecting to trace it. +.ri ( pid , +.ir addr , +and +.ir data +are ignored.) +.ip +the +.b ptrace_traceme +request is used only by the tracee; +the remaining requests are used only by the tracer. +in the following requests, +.i pid +specifies the thread id of the tracee to be acted on. +for requests other than +.br ptrace_attach , +.br ptrace_seize , +.br ptrace_interrupt , +and +.br ptrace_kill , +the tracee must be stopped. +.tp +.br ptrace_peektext ", " ptrace_peekdata +read a word at the address +.i addr +in the tracee's memory, returning the word as the result of the +.br ptrace () +call. +linux does not have separate text and data address spaces, +so these two requests are currently equivalent. +.ri ( data +is ignored; but see notes.) +.tp +.b ptrace_peekuser +.\" ptrace_peekusr in kernel source, but glibc uses ptrace_peekuser, +.\" and that is the name that seems common on other systems. +read a word at offset +.i addr +in the tracee's user area, +which holds the registers and other information about the process +(see +.ir ). +the word is returned as the result of the +.br ptrace () +call. +typically, the offset must be word-aligned, though this might vary by +architecture. +see notes. +.ri ( data +is ignored; but see notes.) +.tp +.br ptrace_poketext ", " ptrace_pokedata +copy the word +.i data +to the address +.i addr +in the tracee's memory. +as for +.br ptrace_peektext +and +.br ptrace_peekdata , +these two requests are currently equivalent. +.tp +.b ptrace_pokeuser +.\" ptrace_pokeusr in kernel source, but glibc uses ptrace_pokeuser, +.\" and that is the name that seems common on other systems. +copy the word +.i data +to offset +.i addr +in the tracee's user area. +as for +.br ptrace_peekuser , +the offset must typically be word-aligned. +in order to maintain the integrity of the kernel, +some modifications to the user area are disallowed. +.\" fixme in the preceding sentence, which modifications are disallowed, +.\" and when they are disallowed, how does user space discover that fact? +.tp +.br ptrace_getregs ", " ptrace_getfpregs +copy the tracee's general-purpose or floating-point registers, +respectively, to the address +.i data +in the tracer. +see +.i +for information on the format of this data. +.ri ( addr +is ignored.) +note that sparc systems have the meaning of +.i data +and +.i addr +reversed; that is, +.i data +is ignored and the registers are copied to the address +.ir addr . +.b ptrace_getregs +and +.b ptrace_getfpregs +are not present on all architectures. +.tp +.br ptrace_getregset " (since linux 2.6.34)" +read the tracee's registers. +.i addr +specifies, in an architecture-dependent way, the type of registers to be read. +.b nt_prstatus +(with numerical value 1) +usually results in reading of general-purpose registers. +if the cpu has, for example, +floating-point and/or vector registers, they can be retrieved by setting +.i addr +to the corresponding +.b nt_foo +constant. +.i data +points to a +.br "struct iovec" , +which describes the destination buffer's location and length. +on return, the kernel modifies +.b iov.len +to indicate the actual number of bytes returned. +.tp +.br ptrace_setregs ", " ptrace_setfpregs +modify the tracee's general-purpose or floating-point registers, +respectively, from the address +.i data +in the tracer. +as for +.br ptrace_pokeuser , +some general-purpose register modifications may be disallowed. +.\" fixme . in the preceding sentence, which modifications are disallowed, +.\" and when they are disallowed, how does user space discover that fact? +.ri ( addr +is ignored.) +note that sparc systems have the meaning of +.i data +and +.i addr +reversed; that is, +.i data +is ignored and the registers are copied from the address +.ir addr . +.b ptrace_setregs +and +.b ptrace_setfpregs +are not present on all architectures. +.tp +.br ptrace_setregset " (since linux 2.6.34)" +modify the tracee's registers. +the meaning of +.i addr +and +.i data +is analogous to +.br ptrace_getregset . +.tp +.br ptrace_getsiginfo " (since linux 2.3.99-pre6)" +retrieve information about the signal that caused the stop. +copy a +.i siginfo_t +structure (see +.br sigaction (2)) +from the tracee to the address +.i data +in the tracer. +.ri ( addr +is ignored.) +.tp +.br ptrace_setsiginfo " (since linux 2.3.99-pre6)" +set signal information: +copy a +.i siginfo_t +structure from the address +.i data +in the tracer to the tracee. +this will affect only signals that would normally be delivered to +the tracee and were caught by the tracer. +it may be difficult to tell +these normal signals from synthetic signals generated by +.br ptrace () +itself. +.ri ( addr +is ignored.) +.tp +.br ptrace_peeksiginfo " (since linux 3.10)" +.\" commit 84c751bd4aebbaae995fe32279d3dba48327bad4 +retrieve +.i siginfo_t +structures without removing signals from a queue. +.i addr +points to a +.i ptrace_peeksiginfo_args +structure that specifies the ordinal position from which +copying of signals should start, +and the number of signals to copy. +.i siginfo_t +structures are copied into the buffer pointed to by +.ir data . +the return value contains the number of copied signals (zero indicates +that there is no signal corresponding to the specified ordinal position). +within the returned +.i siginfo +structures, +the +.ir si_code +field includes information +.rb ( __si_chld , +.br __si_fault , +etc.) that are not otherwise exposed to user space. +.pp +.in +4n +.ex +struct ptrace_peeksiginfo_args { + u64 off; /* ordinal position in queue at which + to start copying signals */ + u32 flags; /* ptrace_peeksiginfo_shared or 0 */ + s32 nr; /* number of signals to copy */ +}; +.ee +.in +.ip +currently, there is only one flag, +.br ptrace_peeksiginfo_shared , +for dumping signals from the process-wide signal queue. +if this flag is not set, +signals are read from the per-thread queue of the specified thread. +.in +.tp +.br ptrace_getsigmask " (since linux 3.11)" +.\" commit 29000caecbe87b6b66f144f72111f0d02fbbf0c1 +place a copy of the mask of blocked signals (see +.br sigprocmask (2)) +in the buffer pointed to by +.ir data , +which should be a pointer to a buffer of type +.ir sigset_t . +the +.i addr +argument contains the size of the buffer pointed to by +.ir data +(i.e., +.ir sizeof(sigset_t) ). +.tp +.br ptrace_setsigmask " (since linux 3.11)" +change the mask of blocked signals (see +.br sigprocmask (2)) +to the value specified in the buffer pointed to by +.ir data , +which should be a pointer to a buffer of type +.ir sigset_t . +the +.i addr +argument contains the size of the buffer pointed to by +.ir data +(i.e., +.ir sizeof(sigset_t) ). +.tp +.br ptrace_setoptions " (since linux 2.4.6; see bugs for caveats)" +set ptrace options from +.ir data . +.ri ( addr +is ignored.) +.ir data +is interpreted as a bit mask of options, +which are specified by the following flags: +.rs +.tp +.br ptrace_o_exitkill " (since linux 3.8)" +.\" commit 992fb6e170639b0849bace8e49bf31bd37c4123 +send a +.b sigkill +signal to the tracee if the tracer exits. +this option is useful for ptrace jailers that +want to ensure that tracees can never escape the tracer's control. +.tp +.br ptrace_o_traceclone " (since linux 2.5.46)" +stop the tracee at the next +.br clone (2) +and automatically start tracing the newly cloned process, +which will start with a +.br sigstop , +or +.b ptrace_event_stop +if +.b ptrace_seize +was used. +a +.br waitpid (2) +by the tracer will return a +.i status +value such that +.ip +.nf + status>>8 == (sigtrap | (ptrace_event_clone<<8)) +.fi +.ip +the pid of the new process can be retrieved with +.br ptrace_geteventmsg . +.ip +this option may not catch +.br clone (2) +calls in all cases. +if the tracee calls +.br clone (2) +with the +.b clone_vfork +flag, +.b ptrace_event_vfork +will be delivered instead +if +.b ptrace_o_tracevfork +is set; otherwise if the tracee calls +.br clone (2) +with the exit signal set to +.br sigchld , +.b ptrace_event_fork +will be delivered if +.b ptrace_o_tracefork +is set. +.tp +.br ptrace_o_traceexec " (since linux 2.5.46)" +stop the tracee at the next +.br execve (2). +a +.br waitpid (2) +by the tracer will return a +.i status +value such that +.ip +.nf + status>>8 == (sigtrap | (ptrace_event_exec<<8)) +.fi +.ip +if the execing thread is not a thread group leader, +the thread id is reset to thread group leader's id before this stop. +since linux 3.0, the former thread id can be retrieved with +.br ptrace_geteventmsg . +.tp +.br ptrace_o_traceexit " (since linux 2.5.60)" +stop the tracee at exit. +a +.br waitpid (2) +by the tracer will return a +.i status +value such that +.ip +.nf + status>>8 == (sigtrap | (ptrace_event_exit<<8)) +.fi +.ip +the tracee's exit status can be retrieved with +.br ptrace_geteventmsg . +.ip +the tracee is stopped early during process exit, +when registers are still available, +allowing the tracer to see where the exit occurred, +whereas the normal exit notification is done after the process +is finished exiting. +even though context is available, +the tracer cannot prevent the exit from happening at this point. +.tp +.br ptrace_o_tracefork " (since linux 2.5.46)" +stop the tracee at the next +.br fork (2) +and automatically start tracing the newly forked process, +which will start with a +.br sigstop , +or +.b ptrace_event_stop +if +.b ptrace_seize +was used. +a +.br waitpid (2) +by the tracer will return a +.i status +value such that +.ip +.nf + status>>8 == (sigtrap | (ptrace_event_fork<<8)) +.fi +.ip +the pid of the new process can be retrieved with +.br ptrace_geteventmsg . +.tp +.br ptrace_o_tracesysgood " (since linux 2.4.6)" +when delivering system call traps, set bit 7 in the signal number +(i.e., deliver +.ir "sigtrap|0x80" ). +this makes it easy for the tracer to distinguish +normal traps from those caused by a system call. +.tp +.br ptrace_o_tracevfork " (since linux 2.5.46)" +stop the tracee at the next +.br vfork (2) +and automatically start tracing the newly vforked process, +which will start with a +.br sigstop , +or +.b ptrace_event_stop +if +.b ptrace_seize +was used. +a +.br waitpid (2) +by the tracer will return a +.i status +value such that +.ip +.nf + status>>8 == (sigtrap | (ptrace_event_vfork<<8)) +.fi +.ip +the pid of the new process can be retrieved with +.br ptrace_geteventmsg . +.tp +.br ptrace_o_tracevforkdone " (since linux 2.5.60)" +stop the tracee at the completion of the next +.br vfork (2). +a +.br waitpid (2) +by the tracer will return a +.i status +value such that +.ip +.nf + status>>8 == (sigtrap | (ptrace_event_vfork_done<<8)) +.fi +.ip +the pid of the new process can (since linux 2.6.18) be retrieved with +.br ptrace_geteventmsg . +.tp +.br ptrace_o_traceseccomp " (since linux 3.5)" +stop the tracee when a +.br seccomp (2) +.br seccomp_ret_trace +rule is triggered. +a +.br waitpid (2) +by the tracer will return a +.i status +value such that +.ip +.nf + status>>8 == (sigtrap | (ptrace_event_seccomp<<8)) +.fi +.ip +while this triggers a +.br ptrace_event +stop, it is similar to a syscall-enter-stop. +for details, see the note on +.b ptrace_event_seccomp +below. +the seccomp event message data (from the +.br seccomp_ret_data +portion of the seccomp filter rule) can be retrieved with +.br ptrace_geteventmsg . +.tp +.br ptrace_o_suspend_seccomp " (since linux 4.3)" +.\" commit 13c4a90119d28cfcb6b5bdd820c233b86c2b0237 +suspend the tracee's seccomp protections. +this applies regardless of mode, and +can be used when the tracee has not yet installed seccomp filters. +that is, a valid use case is to suspend a tracee's seccomp protections +before they are installed by the tracee, +let the tracee install the filters, +and then clear this flag when the filters should be resumed. +setting this option requires that the tracer have the +.br cap_sys_admin +capability, +not have any seccomp protections installed, and not have +.br ptrace_o_suspend_seccomp +set on itself. +.re +.tp +.br ptrace_geteventmsg " (since linux 2.5.46)" +retrieve a message (as an +.ir "unsigned long" ) +about the ptrace event +that just happened, placing it at the address +.i data +in the tracer. +for +.br ptrace_event_exit , +this is the tracee's exit status. +for +.br ptrace_event_fork , +.br ptrace_event_vfork , +.br ptrace_event_vfork_done , +and +.br ptrace_event_clone , +this is the pid of the new process. +for +.br ptrace_event_seccomp , +this is the +.br seccomp (2) +filter's +.br seccomp_ret_data +associated with the triggered rule. +.ri ( addr +is ignored.) +.tp +.b ptrace_cont +restart the stopped tracee process. +if +.i data +is nonzero, +it is interpreted as the number of a signal to be delivered to the tracee; +otherwise, no signal is delivered. +thus, for example, the tracer can control +whether a signal sent to the tracee is delivered or not. +.ri ( addr +is ignored.) +.tp +.br ptrace_syscall ", " ptrace_singlestep +restart the stopped tracee as for +.br ptrace_cont , +but arrange for the tracee to be stopped at +the next entry to or exit from a system call, +or after execution of a single instruction, respectively. +(the tracee will also, as usual, be stopped upon receipt of a signal.) +from the tracer's perspective, the tracee will appear to have been +stopped by receipt of a +.br sigtrap . +so, for +.br ptrace_syscall , +for example, the idea is to inspect +the arguments to the system call at the first stop, +then do another +.b ptrace_syscall +and inspect the return value of the system call at the second stop. +the +.i data +argument is treated as for +.br ptrace_cont . +.ri ( addr +is ignored.) +.tp +.br ptrace_set_syscall " (since linux 2.6.16)" +.\" commit 3f471126ee53feb5e9b210ea2f525ed3bb9b7a7f +when in syscall-enter-stop, +change the number of the system call that is about to +be executed to the number specified in the +.i data +argument. +the +.i addr +argument is ignored. +this request is currently +.\" as of 4.19-rc2 +supported only on arm (and arm64, though only for backwards compatibility), +.\" commit 27aa55c5e5123fa8b8ad0156559d34d7edff58ca +but most other architectures have other means of accomplishing this +(usually by changing the register that the userland code passed the +system call number in). +.\" see change_syscall in tools/testing/selftests/seccomp/seccomp_bpf.c +.\" and also strace's linux/*/set_scno.c files. +.tp +.br ptrace_sysemu ", " ptrace_sysemu_singlestep " (since linux 2.6.14)" +for +.br ptrace_sysemu , +continue and stop on entry to the next system call, +which will not be executed. +see the documentation on syscall-stops below. +for +.br ptrace_sysemu_singlestep , +do the same but also singlestep if not a system call. +this call is used by programs like +user mode linux that want to emulate all the tracee's system calls. +the +.i data +argument is treated as for +.br ptrace_cont . +the +.i addr +argument is ignored. +these requests are currently +.\" as at 3.7 +supported only on x86. +.tp +.br ptrace_listen " (since linux 3.4)" +restart the stopped tracee, but prevent it from executing. +the resulting state of the tracee is similar to a process which +has been stopped by a +.b sigstop +(or other stopping signal). +see the "group-stop" subsection for additional information. +.b ptrace_listen +works only on tracees attached by +.br ptrace_seize . +.tp +.b ptrace_kill +send the tracee a +.b sigkill +to terminate it. +.ri ( addr +and +.i data +are ignored.) +.ip +.i this operation is deprecated; do not use it! +instead, send a +.br sigkill +directly using +.br kill (2) +or +.br tgkill (2). +the problem with +.b ptrace_kill +is that it requires the tracee to be in signal-delivery-stop, +otherwise it may not work +(i.e., may complete successfully but won't kill the tracee). +by contrast, sending a +.b sigkill +directly has no such limitation. +.\" [note from denys vlasenko: +.\" deprecation suggested by oleg nesterov. he prefers to deprecate it +.\" instead of describing (and needing to support) ptrace_kill's quirks.] +.tp +.br ptrace_interrupt " (since linux 3.4)" +stop a tracee. +if the tracee is running or sleeping in kernel space and +.b ptrace_syscall +is in effect, +the system call is interrupted and syscall-exit-stop is reported. +(the interrupted system call is restarted when the tracee is restarted.) +if the tracee was already stopped by a signal and +.b ptrace_listen +was sent to it, +the tracee stops with +.b ptrace_event_stop +and +.i wstopsig(status) +returns the stop signal. +if any other ptrace-stop is generated at the same time (for example, +if a signal is sent to the tracee), this ptrace-stop happens. +if none of the above applies (for example, if the tracee is running in user +space), it stops with +.b ptrace_event_stop +with +.i wstopsig(status) +== +.br sigtrap . +.b ptrace_interrupt +only works on tracees attached by +.br ptrace_seize . +.tp +.b ptrace_attach +attach to the process specified in +.ir pid , +making it a tracee of the calling process. +.\" no longer true (removed by denys vlasenko, 2011, who remarks: +.\" "i think it isn't true in non-ancient 2.4 and in 2.6/3.x. +.\" basically, it's not true for any linux in practical use. +.\" ; the behavior of the tracee is as if it had done a +.\" .br ptrace_traceme . +.\" the calling process actually becomes the parent of the tracee +.\" process for most purposes (e.g., it will receive +.\" notification of tracee events and appears in +.\" .br ps (1) +.\" output as the tracee's parent), but a +.\" .br getppid (2) +.\" by the tracee will still return the pid of the original parent. +the tracee is sent a +.br sigstop , +but will not necessarily have stopped +by the completion of this call; use +.br waitpid (2) +to wait for the tracee to stop. +see the "attaching and detaching" subsection for additional information. +.ri ( addr +and +.i data +are ignored.) +.ip +permission to perform a +.br ptrace_attach +is governed by a ptrace access mode +.b ptrace_mode_attach_realcreds +check; see below. +.tp +.br ptrace_seize " (since linux 3.4)" +.\" +.\" noted by dmitry levin: +.\" +.\" ptrace_seize was introduced by commit v3.1-rc1~308^2~28, but +.\" it had to be used along with a temporary flag ptrace_seize_devel, +.\" which was removed later by commit v3.4-rc1~109^2~20. +.\" +.\" that is, [before] v3.4 we had a test mode of ptrace_seize api, +.\" which was not compatible with the current ptrace_seize api introduced +.\" in linux 3.4. +.\" +attach to the process specified in +.ir pid , +making it a tracee of the calling process. +unlike +.br ptrace_attach , +.b ptrace_seize +does not stop the process. +group-stops are reported as +.b ptrace_event_stop +and +.i wstopsig(status) +returns the stop signal. +automatically attached children stop with +.b ptrace_event_stop +and +.i wstopsig(status) +returns +.b sigtrap +instead of having +.b sigstop +signal delivered to them. +.br execve (2) +does not deliver an extra +.br sigtrap . +only a +.br ptrace_seize d +process can accept +.b ptrace_interrupt +and +.b ptrace_listen +commands. +the "seized" behavior just described is inherited by +children that are automatically attached using +.br ptrace_o_tracefork , +.br ptrace_o_tracevfork , +and +.br ptrace_o_traceclone . +.i addr +must be zero. +.i data +contains a bit mask of ptrace options to activate immediately. +.ip +permission to perform a +.br ptrace_seize +is governed by a ptrace access mode +.b ptrace_mode_attach_realcreds +check; see below. +.\" +.tp +.br ptrace_seccomp_get_filter " (since linux 4.4)" +.\" commit f8e529ed941ba2bbcbf310b575d968159ce7e895 +this operation allows the tracer to dump the tracee's +classic bpf filters. +.ip +.i addr +is an integer specifying the index of the filter to be dumped. +the most recently installed filter has the index 0. +if +.i addr +is greater than the number of installed filters, +the operation fails with the error +.br enoent . +.ip +.i data +is either a pointer to a +.ir "struct sock_filter" +array that is large enough to store the bpf program, +or null if the program is not to be stored. +.ip +upon success, +the return value is the number of instructions in the bpf program. +if +.i data +was null, then this return value can be used to correctly size the +.ir "struct sock_filter" +array passed in a subsequent call. +.ip +this operation fails with the error +.b eacces +if the caller does not have the +.b cap_sys_admin +capability or if the caller is in strict or filter seccomp mode. +if the filter referred to by +.i addr +is not a classic bpf filter, the operation fails with the error +.br emediumtype . +.ip +this operation is available if the kernel was configured with both the +.b config_seccomp_filter +and the +.b config_checkpoint_restore +options. +.tp +.b ptrace_detach +restart the stopped tracee as for +.br ptrace_cont , +but first detach from it. +under linux, a tracee can be detached in this way regardless +of which method was used to initiate tracing. +.ri ( addr +is ignored.) +.\" +.tp +.br ptrace_get_thread_area " (since linux 2.6.0)" +this operation performs a similar task to +.br get_thread_area (2). +it reads the tls entry in the gdt whose index is given in +.ir addr , +placing a copy of the entry into the +.ir "struct user_desc" +pointed to by +.ir data . +(by contrast with +.br get_thread_area (2), +the +.i entry_number +of the +.ir "struct user_desc" +is ignored.) +.tp +.br ptrace_set_thread_area " (since linux 2.6.0)" +this operation performs a similar task to +.br set_thread_area (2). +it sets the tls entry in the gdt whose index is given in +.ir addr , +assigning it the data supplied in the +.ir "struct user_desc" +pointed to by +.ir data . +(by contrast with +.br set_thread_area (2), +the +.i entry_number +of the +.ir "struct user_desc" +is ignored; in other words, +this ptrace operation can't be used to allocate a free tls entry.) +.tp +.br ptrace_get_syscall_info " (since linux 5.3)" +.\" commit 201766a20e30f982ccfe36bebfad9602c3ff574a +retrieve information about the system call that caused the stop. +the information is placed into the buffer pointed by the +.i data +argument, which should be a pointer to a buffer of type +.ir "struct ptrace_syscall_info" . +the +.i addr +argument contains the size of the buffer pointed to +by the +.i data +argument (i.e., +.ir "sizeof(struct ptrace_syscall_info)" ). +the return value contains the number of bytes available +to be written by the kernel. +if the size of the data to be written by the kernel exceeds the size +specified by the +.i addr +argument, the output data is truncated. +.ip +the +.i ptrace_syscall_info +structure contains the following fields: +.ip +.in +4n +.ex +struct ptrace_syscall_info { + __u8 op; /* type of system call stop */ + __u32 arch; /* audit_arch_* value; see seccomp(2) */ + __u64 instruction_pointer; /* cpu instruction pointer */ + __u64 stack_pointer; /* cpu stack pointer */ + union { + struct { /* op == ptrace_syscall_info_entry */ + __u64 nr; /* system call number */ + __u64 args[6]; /* system call arguments */ + } entry; + struct { /* op == ptrace_syscall_info_exit */ + __s64 rval; /* system call return value */ + __u8 is_error; /* system call error flag; + boolean: does rval contain + an error value (\-errcode) or + a nonerror return value? */ + } exit; + struct { /* op == ptrace_syscall_info_seccomp */ + __u64 nr; /* system call number */ + __u64 args[6]; /* system call arguments */ + __u32 ret_data; /* seccomp_ret_data portion + of seccomp_ret_trace + return value */ + } seccomp; + }; +}; +.ee +.in +.ip +the +.ir op , +.ir arch , +.ir instruction_pointer , +and +.i stack_pointer +fields are defined for all kinds of ptrace system call stops. +the rest of the structure is a union; one should read only those fields +that are meaningful for the kind of system call stop specified by the +.ir op +field. +.ip +the +.i op +field has one of the following values (defined in +.ir ) +indicating what type of stop occurred and +which part of the union is filled: +.rs +.tp +.br ptrace_syscall_info_entry +the +.i entry +component of the union contains information relating to a +system call entry stop. +.tp +.br ptrace_syscall_info_exit +the +.i exit +component of the union contains information relating to a +system call exit stop. +.tp +.br ptrace_syscall_info_seccomp +the +.i seccomp +component of the union contains information relating to a +.b ptrace_event_seccomp +stop. +.tp +.br ptrace_syscall_info_none +no component of the union contains relevant information. +.re +.\" +.ss death under ptrace +when a (possibly multithreaded) process receives a killing signal +(one whose disposition is set to +.b sig_dfl +and whose default action is to kill the process), +all threads exit. +tracees report their death to their tracer(s). +notification of this event is delivered via +.br waitpid (2). +.pp +note that the killing signal will first cause signal-delivery-stop +(on one tracee only), +and only after it is injected by the tracer +(or after it was dispatched to a thread which isn't traced), +will death from the signal happen on +.i all +tracees within a multithreaded process. +(the term "signal-delivery-stop" is explained below.) +.pp +.b sigkill +does not generate signal-delivery-stop and +therefore the tracer can't suppress it. +.b sigkill +kills even within system calls +(syscall-exit-stop is not generated prior to death by +.br sigkill ). +the net effect is that +.b sigkill +always kills the process (all its threads), +even if some threads of the process are ptraced. +.pp +when the tracee calls +.br _exit (2), +it reports its death to its tracer. +other threads are not affected. +.pp +when any thread executes +.br exit_group (2), +every tracee in its thread group reports its death to its tracer. +.pp +if the +.b ptrace_o_traceexit +option is on, +.b ptrace_event_exit +will happen before actual death. +this applies to exits via +.br exit (2), +.br exit_group (2), +and signal deaths (except +.br sigkill , +depending on the kernel version; see bugs below), +and when threads are torn down on +.br execve (2) +in a multithreaded process. +.pp +the tracer cannot assume that the ptrace-stopped tracee exists. +there are many scenarios when the tracee may die while stopped (such as +.br sigkill ). +therefore, the tracer must be prepared to handle an +.b esrch +error on any ptrace operation. +unfortunately, the same error is returned if the tracee +exists but is not ptrace-stopped +(for commands which require a stopped tracee), +or if it is not traced by the process which issued the ptrace call. +the tracer needs to keep track of the stopped/running state of the tracee, +and interpret +.b esrch +as "tracee died unexpectedly" only if it knows that the tracee has +been observed to enter ptrace-stop. +note that there is no guarantee that +.i waitpid(wnohang) +will reliably report the tracee's death status if a +ptrace operation returned +.br esrch . +.i waitpid(wnohang) +may return 0 instead. +in other words, the tracee may be "not yet fully dead", +but already refusing ptrace requests. +.pp +the tracer can't assume that the tracee +.i always +ends its life by reporting +.i wifexited(status) +or +.ir wifsignaled(status) ; +there are cases where this does not occur. +for example, if a thread other than thread group leader does an +.br execve (2), +it disappears; +its pid will never be seen again, +and any subsequent ptrace stops will be reported under +the thread group leader's pid. +.ss stopped states +a tracee can be in two states: running or stopped. +for the purposes of ptrace, a tracee which is blocked in a system call +(such as +.br read (2), +.br pause (2), +etc.) +is nevertheless considered to be running, even if the tracee is blocked +for a long time. +the state of the tracee after +.br ptrace_listen +is somewhat of a gray area: it is not in any ptrace-stop (ptrace commands +won't work on it, and it will deliver +.br waitpid (2) +notifications), +but it also may be considered "stopped" because +it is not executing instructions (is not scheduled), and if it was +in group-stop before +.br ptrace_listen , +it will not respond to signals until +.b sigcont +is received. +.pp +there are many kinds of states when the tracee is stopped, and in ptrace +discussions they are often conflated. +therefore, it is important to use precise terms. +.pp +in this manual page, any stopped state in which the tracee is ready +to accept ptrace commands from the tracer is called +.ir ptrace-stop . +ptrace-stops can +be further subdivided into +.ir signal-delivery-stop , +.ir group-stop , +.ir syscall-stop , +.ir "ptrace_event stops" , +and so on. +these stopped states are described in detail below. +.pp +when the running tracee enters ptrace-stop, it notifies its tracer using +.br waitpid (2) +(or one of the other "wait" system calls). +most of this manual page assumes that the tracer waits with: +.pp + pid = waitpid(pid_or_minus_1, &status, __wall); +.pp +ptrace-stopped tracees are reported as returns with +.i pid +greater than 0 and +.i wifstopped(status) +true. +.\" denys vlasenko: +.\" do we require __wall usage, or will just using 0 be ok? (with 0, +.\" i am not 100% sure there aren't ugly corner cases.) are the +.\" rules different if user wants to use waitid? will waitid require +.\" wexited? +.\" +.pp +the +.b __wall +flag does not include the +.b wstopped +and +.b wexited +flags, but implies their functionality. +.pp +setting the +.b wcontinued +flag when calling +.br waitpid (2) +is not recommended: the "continued" state is per-process and +consuming it can confuse the real parent of the tracee. +.pp +use of the +.b wnohang +flag may cause +.br waitpid (2) +to return 0 ("no wait results available yet") +even if the tracer knows there should be a notification. +example: +.pp +.in +4n +.ex +errno = 0; +ptrace(ptrace_cont, pid, 0l, 0l); +if (errno == esrch) { + /* tracee is dead */ + r = waitpid(tracee, &status, __wall | wnohang); + /* r can still be 0 here! */ +} +.ee +.in +.\" fixme . +.\" waitid usage? wnowait? +.\" describe how wait notifications queue (or not queue) +.pp +the following kinds of ptrace-stops exist: signal-delivery-stops, +group-stops, +.b ptrace_event +stops, syscall-stops. +they all are reported by +.br waitpid (2) +with +.i wifstopped(status) +true. +they may be differentiated by examining the value +.ir status>>8 , +and if there is ambiguity in that value, by querying +.br ptrace_getsiginfo . +(note: the +.i wstopsig(status) +macro can't be used to perform this examination, +because it returns the value +.ir "(status>>8)\ &\ 0xff" .) +.ss signal-delivery-stop +when a (possibly multithreaded) process receives any signal except +.br sigkill , +the kernel selects an arbitrary thread which handles the signal. +(if the signal is generated with +.br tgkill (2), +the target thread can be explicitly selected by the caller.) +if the selected thread is traced, it enters signal-delivery-stop. +at this point, the signal is not yet delivered to the process, +and can be suppressed by the tracer. +if the tracer doesn't suppress the signal, +it passes the signal to the tracee in the next ptrace restart request. +this second step of signal delivery is called +.i "signal injection" +in this manual page. +note that if the signal is blocked, +signal-delivery-stop doesn't happen until the signal is unblocked, +with the usual exception that +.b sigstop +can't be blocked. +.pp +signal-delivery-stop is observed by the tracer as +.br waitpid (2) +returning with +.i wifstopped(status) +true, with the signal returned by +.ir wstopsig(status) . +if the signal is +.br sigtrap , +this may be a different kind of ptrace-stop; +see the "syscall-stops" and "execve" sections below for details. +if +.i wstopsig(status) +returns a stopping signal, this may be a group-stop; see below. +.ss signal injection and suppression +after signal-delivery-stop is observed by the tracer, +the tracer should restart the tracee with the call +.pp + ptrace(ptrace_restart, pid, 0, sig) +.pp +where +.b ptrace_restart +is one of the restarting ptrace requests. +if +.i sig +is 0, then a signal is not delivered. +otherwise, the signal +.i sig +is delivered. +this operation is called +.i "signal injection" +in this manual page, to distinguish it from signal-delivery-stop. +.pp +the +.i sig +value may be different from the +.i wstopsig(status) +value: the tracer can cause a different signal to be injected. +.pp +note that a suppressed signal still causes system calls to return +prematurely. +in this case, system calls will be restarted: the tracer will +observe the tracee to reexecute the interrupted system call (or +.br restart_syscall (2) +system call for a few system calls which use a different mechanism +for restarting) if the tracer uses +.br ptrace_syscall . +even system calls (such as +.br poll (2)) +which are not restartable after signal are restarted after +signal is suppressed; +however, kernel bugs exist which cause some system calls to fail with +.b eintr +even though no observable signal is injected to the tracee. +.pp +restarting ptrace commands issued in ptrace-stops other than +signal-delivery-stop are not guaranteed to inject a signal, even if +.i sig +is nonzero. +no error is reported; a nonzero +.i sig +may simply be ignored. +ptrace users should not try to "create a new signal" this way: use +.br tgkill (2) +instead. +.pp +the fact that signal injection requests may be ignored +when restarting the tracee after +ptrace stops that are not signal-delivery-stops +is a cause of confusion among ptrace users. +one typical scenario is that the tracer observes group-stop, +mistakes it for signal-delivery-stop, restarts the tracee with +.pp + ptrace(ptrace_restart, pid, 0, stopsig) +.pp +with the intention of injecting +.ir stopsig , +but +.i stopsig +gets ignored and the tracee continues to run. +.pp +the +.b sigcont +signal has a side effect of waking up (all threads of) +a group-stopped process. +this side effect happens before signal-delivery-stop. +the tracer can't suppress this side effect (it can +only suppress signal injection, which only causes the +.br sigcont +handler to not be executed in the tracee, if such a handler is installed). +in fact, waking up from group-stop may be followed by +signal-delivery-stop for signal(s) +.i other than +.br sigcont , +if they were pending when +.b sigcont +was delivered. +in other words, +.b sigcont +may be not the first signal observed by the tracee after it was sent. +.pp +stopping signals cause (all threads of) a process to enter group-stop. +this side effect happens after signal injection, and therefore can be +suppressed by the tracer. +.pp +in linux 2.4 and earlier, the +.b sigstop +signal can't be injected. +.\" in the linux 2.4 sources, in arch/i386/kernel/signal.c::do_signal(), +.\" there is: +.\" +.\" /* the debugger continued. ignore sigstop. */ +.\" if (signr == sigstop) +.\" continue; +.pp +.b ptrace_getsiginfo +can be used to retrieve a +.i siginfo_t +structure which corresponds to the delivered signal. +.b ptrace_setsiginfo +may be used to modify it. +if +.b ptrace_setsiginfo +has been used to alter +.ir siginfo_t , +the +.i si_signo +field and the +.i sig +parameter in the restarting command must match, +otherwise the result is undefined. +.ss group-stop +when a (possibly multithreaded) process receives a stopping signal, +all threads stop. +if some threads are traced, they enter a group-stop. +note that the stopping signal will first cause signal-delivery-stop +(on one tracee only), and only after it is injected by the tracer +(or after it was dispatched to a thread which isn't traced), +will group-stop be initiated on +.i all +tracees within the multithreaded process. +as usual, every tracee reports its group-stop separately +to the corresponding tracer. +.pp +group-stop is observed by the tracer as +.br waitpid (2) +returning with +.i wifstopped(status) +true, with the stopping signal available via +.ir wstopsig(status) . +the same result is returned by some other classes of ptrace-stops, +therefore the recommended practice is to perform the call +.pp + ptrace(ptrace_getsiginfo, pid, 0, &siginfo) +.pp +the call can be avoided if the signal is not +.br sigstop , +.br sigtstp , +.br sigttin , +or +.br sigttou ; +only these four signals are stopping signals. +if the tracer sees something else, it can't be a group-stop. +otherwise, the tracer needs to call +.br ptrace_getsiginfo . +if +.b ptrace_getsiginfo +fails with +.br einval , +then it is definitely a group-stop. +(other failure codes are possible, such as +.b esrch +("no such process") if a +.b sigkill +killed the tracee.) +.pp +if tracee was attached using +.br ptrace_seize , +group-stop is indicated by +.br ptrace_event_stop : +.ir "status>>16 == ptrace_event_stop" . +this allows detection of group-stops +without requiring an extra +.b ptrace_getsiginfo +call. +.pp +as of linux 2.6.38, +after the tracer sees the tracee ptrace-stop and until it +restarts or kills it, the tracee will not run, +and will not send notifications (except +.b sigkill +death) to the tracer, even if the tracer enters into another +.br waitpid (2) +call. +.pp +the kernel behavior described in the previous paragraph +causes a problem with transparent handling of stopping signals. +if the tracer restarts the tracee after group-stop, +the stopping signal +is effectively ignored\(emthe tracee doesn't remain stopped, it runs. +if the tracer doesn't restart the tracee before entering into the next +.br waitpid (2), +future +.b sigcont +signals will not be reported to the tracer; +this would cause the +.b sigcont +signals to have no effect on the tracee. +.pp +since linux 3.4, there is a method to overcome this problem: instead of +.br ptrace_cont , +a +.b ptrace_listen +command can be used to restart a tracee in a way where it does not execute, +but waits for a new event which it can report via +.br waitpid (2) +(such as when +it is restarted by a +.br sigcont ). +.ss ptrace_event stops +if the tracer sets +.b ptrace_o_trace_* +options, the tracee will enter ptrace-stops called +.b ptrace_event +stops. +.pp +.b ptrace_event +stops are observed by the tracer as +.br waitpid (2) +returning with +.ir wifstopped(status) , +and +.i wstopsig(status) +returns +.br sigtrap +(or for +.br ptrace_event_stop , +returns the stopping signal if tracee is in a group-stop). +an additional bit is set in the higher byte of the status word: +the value +.i status>>8 +will be +.pp + ((ptrace_event_foo<<8) | sigtrap). +.pp +the following events exist: +.tp +.b ptrace_event_vfork +stop before return from +.br vfork (2) +or +.br clone (2) +with the +.b clone_vfork +flag. +when the tracee is continued after this stop, it will wait for child to +exit/exec before continuing its execution +(in other words, the usual behavior on +.br vfork (2)). +.tp +.b ptrace_event_fork +stop before return from +.br fork (2) +or +.br clone (2) +with the exit signal set to +.br sigchld . +.tp +.b ptrace_event_clone +stop before return from +.br clone (2). +.tp +.b ptrace_event_vfork_done +stop before return from +.br vfork (2) +or +.br clone (2) +with the +.b clone_vfork +flag, +but after the child unblocked this tracee by exiting or execing. +.pp +for all four stops described above, +the stop occurs in the parent (i.e., the tracee), +not in the newly created thread. +.br ptrace_geteventmsg +can be used to retrieve the new thread's id. +.tp +.b ptrace_event_exec +stop before return from +.br execve (2). +since linux 3.0, +.br ptrace_geteventmsg +returns the former thread id. +.tp +.b ptrace_event_exit +stop before exit (including death from +.br exit_group (2)), +signal death, or exit caused by +.br execve (2) +in a multithreaded process. +.b ptrace_geteventmsg +returns the exit status. +registers can be examined +(unlike when "real" exit happens). +the tracee is still alive; it needs to be +.br ptrace_cont ed +or +.br ptrace_detach ed +to finish exiting. +.tp +.b ptrace_event_stop +stop induced by +.b ptrace_interrupt +command, or group-stop, or initial ptrace-stop when a new child is attached +(only if attached using +.br ptrace_seize ). +.tp +.b ptrace_event_seccomp +stop triggered by a +.br seccomp (2) +rule on tracee syscall entry when +.br ptrace_o_traceseccomp +has been set by the tracer. +the seccomp event message data (from the +.br seccomp_ret_data +portion of the seccomp filter rule) can be retrieved with +.br ptrace_geteventmsg . +the semantics of this stop are described in +detail in a separate section below. +.pp +.b ptrace_getsiginfo +on +.b ptrace_event +stops returns +.b sigtrap +in +.ir si_signo , +with +.i si_code +set to +.ir "(event<<8)\ |\ sigtrap" . +.ss syscall-stops +if the tracee was restarted by +.br ptrace_syscall +or +.br ptrace_sysemu , +the tracee enters +syscall-enter-stop just prior to entering any system call (which +will not be executed if the restart was using +.br ptrace_sysemu , +regardless of any change made to registers at this point or how the +tracee is restarted after this stop). +no matter which method caused the syscall-entry-stop, +if the tracer restarts the tracee with +.br ptrace_syscall , +the tracee enters syscall-exit-stop when the system call is finished, +or if it is interrupted by a signal. +(that is, signal-delivery-stop never happens between syscall-enter-stop +and syscall-exit-stop; it happens +.i after +syscall-exit-stop.). +if the tracee is continued using any other method (including +.br ptrace_sysemu ), +no syscall-exit-stop occurs. +note that all mentions +.br ptrace_sysemu +apply equally to +.br ptrace_sysemu_singlestep . +.pp +however, even if the tracee was continued using +.br ptrace_syscall , +it is not guaranteed that the next stop will be a syscall-exit-stop. +other possibilities are that the tracee may stop in a +.b ptrace_event +stop (including seccomp stops), exit (if it entered +.br _exit (2) +or +.br exit_group (2)), +be killed by +.br sigkill , +or die silently (if it is a thread group leader, the +.br execve (2) +happened in another thread, +and that thread is not traced by the same tracer; +this situation is discussed later). +.pp +syscall-enter-stop and syscall-exit-stop are observed by the tracer as +.br waitpid (2) +returning with +.i wifstopped(status) +true, and +.i wstopsig(status) +giving +.br sigtrap . +if the +.b ptrace_o_tracesysgood +option was set by the tracer, then +.i wstopsig(status) +will give the value +.ir "(sigtrap\ |\ 0x80)" . +.pp +syscall-stops can be distinguished from signal-delivery-stop with +.b sigtrap +by querying +.br ptrace_getsiginfo +for the following cases: +.tp +.ir si_code " <= 0" +.b sigtrap +was delivered as a result of a user-space action, +for example, a system call +.rb ( tgkill (2), +.br kill (2), +.br sigqueue (3), +etc.), +expiration of a posix timer, +change of state on a posix message queue, +or completion of an asynchronous i/o request. +.tp +.ir si_code " == si_kernel (0x80)" +.b sigtrap +was sent by the kernel. +.tp +.ir si_code " == sigtrap or " si_code " == (sigtrap|0x80)" +this is a syscall-stop. +.pp +however, syscall-stops happen very often (twice per system call), +and performing +.b ptrace_getsiginfo +for every syscall-stop may be somewhat expensive. +.pp +some architectures allow the cases to be distinguished +by examining registers. +for example, on x86, +.i rax +== +.rb \- enosys +in syscall-enter-stop. +since +.b sigtrap +(like any other signal) always happens +.i after +syscall-exit-stop, +and at this point +.i rax +almost never contains +.rb \- enosys , +the +.b sigtrap +looks like "syscall-stop which is not syscall-enter-stop"; +in other words, it looks like a +"stray syscall-exit-stop" and can be detected this way. +but such detection is fragile and is best avoided. +.pp +using the +.b ptrace_o_tracesysgood +option is the recommended method to distinguish syscall-stops +from other kinds of ptrace-stops, +since it is reliable and does not incur a performance penalty. +.pp +syscall-enter-stop and syscall-exit-stop are +indistinguishable from each other by the tracer. +the tracer needs to keep track of the sequence of +ptrace-stops in order to not misinterpret syscall-enter-stop as +syscall-exit-stop or vice versa. +in general, a syscall-enter-stop is +always followed by syscall-exit-stop, +.b ptrace_event +stop, or the tracee's death; +no other kinds of ptrace-stop can occur in between. +however, note that seccomp stops (see below) can cause syscall-exit-stops, +without preceding syscall-entry-stops. +if seccomp is in use, care needs +to be taken not to misinterpret such stops as syscall-entry-stops. +.pp +if after syscall-enter-stop, +the tracer uses a restarting command other than +.br ptrace_syscall , +syscall-exit-stop is not generated. +.pp +.b ptrace_getsiginfo +on syscall-stops returns +.b sigtrap +in +.ir si_signo , +with +.i si_code +set to +.b sigtrap +or +.ir (sigtrap|0x80) . +.\" +.ss ptrace_event_seccomp stops (linux 3.5 to 4.7) +the behavior of +.br ptrace_event_seccomp +stops and their interaction with other kinds +of ptrace stops has changed between kernel versions. +this documents the behavior +from their introduction until linux 4.7 (inclusive). +the behavior in later kernel versions is documented in the next section. +.pp +a +.br ptrace_event_seccomp +stop occurs whenever a +.br seccomp_ret_trace +rule is triggered. +this is independent of which methods was used to restart the system call. +notably, seccomp still runs even if the tracee was restarted using +.br ptrace_sysemu +and this system call is unconditionally skipped. +.pp +restarts from this stop will behave as if the stop had occurred right +before the system call in question. +in particular, both +.br ptrace_syscall +and +.br ptrace_sysemu +will normally cause a subsequent syscall-entry-stop. +however, if after the +.br ptrace_event_seccomp +the system call number is negative, +both the syscall-entry-stop and the system call itself will be skipped. +this means that if the system call number is negative after a +.br ptrace_event_seccomp +and the tracee is restarted using +.br ptrace_syscall , +the next observed stop will be a syscall-exit-stop, +rather than the syscall-entry-stop that might have been expected. +.\" +.ss ptrace_event_seccomp stops (since linux 4.8) +starting with linux 4.8, +.\" commit 93e35efb8de45393cf61ed07f7b407629bf698ea +the +.br ptrace_event_seccomp +stop was reordered to occur between syscall-entry-stop and +syscall-exit-stop. +note that seccomp no longer runs (and no +.b ptrace_event_seccomp +will be reported) if the system call is skipped due to +.br ptrace_sysemu . +.pp +functionally, a +.b ptrace_event_seccomp +stop functions comparably +to a syscall-entry-stop (i.e., continuations using +.br ptrace_syscall +will cause syscall-exit-stops, +the system call number may be changed and any other modified registers +are visible to the to-be-executed system call as well). +note that there may be, +but need not have been a preceding syscall-entry-stop. +.pp +after a +.br ptrace_event_seccomp +stop, seccomp will be rerun, with a +.br seccomp_ret_trace +rule now functioning the same as a +.br seccomp_ret_allow . +specifically, this means that if registers are not modified during the +.br ptrace_event_seccomp +stop, the system call will then be allowed. +.\" +.ss ptrace_singlestep stops +[details of these kinds of stops are yet to be documented.] +.\" +.\" fixme . +.\" document stops occurring with ptrace_singlestep +.\" +.ss informational and restarting ptrace commands +most ptrace commands (all except +.br ptrace_attach , +.br ptrace_seize , +.br ptrace_traceme , +.br ptrace_interrupt , +and +.br ptrace_kill ) +require the tracee to be in a ptrace-stop, otherwise they fail with +.br esrch . +.pp +when the tracee is in ptrace-stop, +the tracer can read and write data to +the tracee using informational commands. +these commands leave the tracee in ptrace-stopped state: +.pp +.in +4n +.ex +ptrace(ptrace_peektext/peekdata/peekuser, pid, addr, 0); +ptrace(ptrace_poketext/pokedata/pokeuser, pid, addr, long_val); +ptrace(ptrace_getregs/getfpregs, pid, 0, &struct); +ptrace(ptrace_setregs/setfpregs, pid, 0, &struct); +ptrace(ptrace_getregset, pid, nt_foo, &iov); +ptrace(ptrace_setregset, pid, nt_foo, &iov); +ptrace(ptrace_getsiginfo, pid, 0, &siginfo); +ptrace(ptrace_setsiginfo, pid, 0, &siginfo); +ptrace(ptrace_geteventmsg, pid, 0, &long_var); +ptrace(ptrace_setoptions, pid, 0, ptrace_o_flags); +.ee +.in +.pp +note that some errors are not reported. +for example, setting signal information +.ri ( siginfo ) +may have no effect in some ptrace-stops, yet the call may succeed +(return 0 and not set +.ir errno ); +querying +.b ptrace_geteventmsg +may succeed and return some random value if current ptrace-stop +is not documented as returning a meaningful event message. +.pp +the call +.pp + ptrace(ptrace_setoptions, pid, 0, ptrace_o_flags); +.pp +affects one tracee. +the tracee's current flags are replaced. +flags are inherited by new tracees created and "auto-attached" via active +.br ptrace_o_tracefork , +.br ptrace_o_tracevfork , +or +.br ptrace_o_traceclone +options. +.pp +another group of commands makes the ptrace-stopped tracee run. +they have the form: +.pp + ptrace(cmd, pid, 0, sig); +.pp +where +.i cmd +is +.br ptrace_cont , +.br ptrace_listen , +.br ptrace_detach , +.br ptrace_syscall , +.br ptrace_singlestep , +.br ptrace_sysemu , +or +.br ptrace_sysemu_singlestep . +if the tracee is in signal-delivery-stop, +.i sig +is the signal to be injected (if it is nonzero). +otherwise, +.i sig +may be ignored. +(when restarting a tracee from a ptrace-stop other than signal-delivery-stop, +recommended practice is to always pass 0 in +.ir sig .) +.ss attaching and detaching +a thread can be attached to the tracer using the call +.pp + ptrace(ptrace_attach, pid, 0, 0); +.pp +or +.pp + ptrace(ptrace_seize, pid, 0, ptrace_o_flags); +.pp +.b ptrace_attach +sends +.b sigstop +to this thread. +if the tracer wants this +.b sigstop +to have no effect, it needs to suppress it. +note that if other signals are concurrently sent to +this thread during attach, +the tracer may see the tracee enter signal-delivery-stop +with other signal(s) first! +the usual practice is to reinject these signals until +.b sigstop +is seen, then suppress +.b sigstop +injection. +the design bug here is that a ptrace attach and a concurrently delivered +.b sigstop +may race and the concurrent +.b sigstop +may be lost. +.\" +.\" fixme describe how to attach to a thread which is already group-stopped. +.pp +since attaching sends +.b sigstop +and the tracer usually suppresses it, this may cause a stray +.b eintr +return from the currently executing system call in the tracee, +as described in the "signal injection and suppression" section. +.pp +since linux 3.4, +.b ptrace_seize +can be used instead of +.br ptrace_attach . +.b ptrace_seize +does not stop the attached process. +if you need to stop +it after attach (or at any other time) without sending it any signals, +use +.b ptrace_interrupt +command. +.pp +the request +.pp + ptrace(ptrace_traceme, 0, 0, 0); +.pp +turns the calling thread into a tracee. +the thread continues to run (doesn't enter ptrace-stop). +a common practice is to follow the +.b ptrace_traceme +with +.pp + raise(sigstop); +.pp +and allow the parent (which is our tracer now) to observe our +signal-delivery-stop. +.pp +if the +.br ptrace_o_tracefork , +.br ptrace_o_tracevfork , +or +.br ptrace_o_traceclone +options are in effect, then children created by, respectively, +.br vfork (2) +or +.br clone (2) +with the +.b clone_vfork +flag, +.br fork (2) +or +.br clone (2) +with the exit signal set to +.br sigchld , +and other kinds of +.br clone (2), +are automatically attached to the same tracer which traced their parent. +.b sigstop +is delivered to the children, causing them to enter +signal-delivery-stop after they exit the system call which created them. +.pp +detaching of the tracee is performed by: +.pp + ptrace(ptrace_detach, pid, 0, sig); +.pp +.b ptrace_detach +is a restarting operation; +therefore it requires the tracee to be in ptrace-stop. +if the tracee is in signal-delivery-stop, a signal can be injected. +otherwise, the +.i sig +parameter may be silently ignored. +.pp +if the tracee is running when the tracer wants to detach it, +the usual solution is to send +.b sigstop +(using +.br tgkill (2), +to make sure it goes to the correct thread), +wait for the tracee to stop in signal-delivery-stop for +.b sigstop +and then detach it (suppressing +.b sigstop +injection). +a design bug is that this can race with concurrent +.br sigstop s. +another complication is that the tracee may enter other ptrace-stops +and needs to be restarted and waited for again, until +.b sigstop +is seen. +yet another complication is to be sure that +the tracee is not already ptrace-stopped, +because no signal delivery happens while it is\(emnot even +.br sigstop . +.\" fixme describe how to detach from a group-stopped tracee so that it +.\" doesn't run, but continues to wait for sigcont. +.pp +if the tracer dies, all tracees are automatically detached and restarted, +unless they were in group-stop. +handling of restart from group-stop is currently buggy, +but the "as planned" behavior is to leave tracee stopped and waiting for +.br sigcont . +if the tracee is restarted from signal-delivery-stop, +the pending signal is injected. +.ss execve(2) under ptrace +.\" clone(2) clone_thread says: +.\" if any of the threads in a thread group performs an execve(2), +.\" then all threads other than the thread group leader are terminated, +.\" and the new program is executed in the thread group leader. +.\" +when one thread in a multithreaded process calls +.br execve (2), +the kernel destroys all other threads in the process, +.\" in kernel 3.1 sources, see fs/exec.c::de_thread() +and resets the thread id of the execing thread to the +thread group id (process id). +(or, to put things another way, when a multithreaded process does an +.br execve (2), +at completion of the call, it appears as though the +.br execve (2) +occurred in the thread group leader, regardless of which thread did the +.br execve (2).) +this resetting of the thread id looks very confusing to tracers: +.ip * 3 +all other threads stop in +.b ptrace_event_exit +stop, if the +.br ptrace_o_traceexit +option was turned on. +then all other threads except the thread group leader report +death as if they exited via +.br _exit (2) +with exit code 0. +.ip * +the execing tracee changes its thread id while it is in the +.br execve (2). +(remember, under ptrace, the "pid" returned from +.br waitpid (2), +or fed into ptrace calls, is the tracee's thread id.) +that is, the tracee's thread id is reset to be the same as its process id, +which is the same as the thread group leader's thread id. +.ip * +then a +.b ptrace_event_exec +stop happens, if the +.br ptrace_o_traceexec +option was turned on. +.ip * +if the thread group leader has reported its +.b ptrace_event_exit +stop by this time, +it appears to the tracer that +the dead thread leader "reappears from nowhere". +(note: the thread group leader does not report death via +.i wifexited(status) +until there is at least one other live thread. +this eliminates the possibility that the tracer will see +it dying and then reappearing.) +if the thread group leader was still alive, +for the tracer this may look as if thread group leader +returns from a different system call than it entered, +or even "returned from a system call even though +it was not in any system call". +if the thread group leader was not traced +(or was traced by a different tracer), then during +.br execve (2) +it will appear as if it has become a tracee of +the tracer of the execing tracee. +.pp +all of the above effects are the artifacts of +the thread id change in the tracee. +.pp +the +.b ptrace_o_traceexec +option is the recommended tool for dealing with this situation. +first, it enables +.br ptrace_event_exec +stop, +which occurs before +.br execve (2) +returns. +in this stop, the tracer can use +.b ptrace_geteventmsg +to retrieve the tracee's former thread id. +(this feature was introduced in linux 3.0.) +second, the +.b ptrace_o_traceexec +option disables legacy +.b sigtrap +generation on +.br execve (2). +.pp +when the tracer receives +.b ptrace_event_exec +stop notification, +it is guaranteed that except this tracee and the thread group leader, +no other threads from the process are alive. +.pp +on receiving the +.b ptrace_event_exec +stop notification, +the tracer should clean up all its internal +data structures describing the threads of this process, +and retain only one data structure\(emone which +describes the single still running tracee, with +.pp + thread id == thread group id == process id. +.pp +example: two threads call +.br execve (2) +at the same time: +.pp +.nf +*** we get syscall-enter-stop in thread 1: ** +pid1 execve("/bin/foo", "foo" +*** we issue ptrace_syscall for thread 1 ** +*** we get syscall-enter-stop in thread 2: ** +pid2 execve("/bin/bar", "bar" +*** we issue ptrace_syscall for thread 2 ** +*** we get ptrace_event_exec for pid0, we issue ptrace_syscall ** +*** we get syscall-exit-stop for pid0: ** +pid0 <... execve resumed> ) = 0 +.fi +.pp +if the +.b ptrace_o_traceexec +option is +.i not +in effect for the execing tracee, +and if the tracee was +.br ptrace_attach ed +rather that +.br ptrace_seize d, +the kernel delivers an extra +.b sigtrap +to the tracee after +.br execve (2) +returns. +this is an ordinary signal (similar to one which can be +generated by +.ir "kill \-trap" ), +not a special kind of ptrace-stop. +employing +.b ptrace_getsiginfo +for this signal returns +.i si_code +set to 0 +.ri ( si_user ). +this signal may be blocked by signal mask, +and thus may be delivered (much) later. +.pp +usually, the tracer (for example, +.br strace (1)) +would not want to show this extra post-execve +.b sigtrap +signal to the user, and would suppress its delivery to the tracee (if +.b sigtrap +is set to +.br sig_dfl , +it is a killing signal). +however, determining +.i which +.b sigtrap +to suppress is not easy. +setting the +.b ptrace_o_traceexec +option or using +.b ptrace_seize +and thus suppressing this extra +.b sigtrap +is the recommended approach. +.ss real parent +the ptrace api (ab)uses the standard unix parent/child signaling over +.br waitpid (2). +this used to cause the real parent of the process to stop receiving +several kinds of +.br waitpid (2) +notifications when the child process is traced by some other process. +.pp +many of these bugs have been fixed, but as of linux 2.6.38 several still +exist; see bugs below. +.pp +as of linux 2.6.38, the following is believed to work correctly: +.ip * 3 +exit/death by signal is reported first to the tracer, then, +when the tracer consumes the +.br waitpid (2) +result, to the real parent (to the real parent only when the +whole multithreaded process exits). +if the tracer and the real parent are the same process, +the report is sent only once. +.sh return value +on success, the +.b ptrace_peek* +requests return the requested data (but see notes), +the +.b ptrace_seccomp_get_filter +request returns the number of instructions in the bpf program, +the +.b ptrace_get_syscall_info +request returns the number of bytes available to be written by the kernel, +and other requests return zero. +.pp +on error, all requests return \-1, and +.i errno +is set to indicate the error. +since the value returned by a successful +.b ptrace_peek* +request may be \-1, the caller must clear +.i errno +before the call, and then check it afterward +to determine whether or not an error occurred. +.sh errors +.tp +.b ebusy +(i386 only) there was an error with allocating or freeing a debug register. +.tp +.b efault +there was an attempt to read from or write to an invalid area in +the tracer's or the tracee's memory, +probably because the area wasn't mapped or accessible. +unfortunately, under linux, different variations of this fault +will return +.b eio +or +.b efault +more or less arbitrarily. +.tp +.b einval +an attempt was made to set an invalid option. +.tp +.b eio +.i request +is invalid, or an attempt was made to read from or +write to an invalid area in the tracer's or the tracee's memory, +or there was a word-alignment violation, +or an invalid signal was specified during a restart request. +.tp +.b eperm +the specified process cannot be traced. +this could be because the +tracer has insufficient privileges (the required capability is +.br cap_sys_ptrace ); +unprivileged processes cannot trace processes that they +cannot send signals to or those running +set-user-id/set-group-id programs, for obvious reasons. +alternatively, the process may already be being traced, +or (on kernels before 2.6.26) be +.br init (1) +(pid 1). +.tp +.b esrch +the specified process does not exist, or is not currently being traced +by the caller, or is not stopped +(for requests that require a stopped tracee). +.sh conforming to +svr4, 4.3bsd. +.sh notes +although arguments to +.br ptrace () +are interpreted according to the prototype given, +glibc currently declares +.br ptrace () +as a variadic function with only the +.i request +argument fixed. +it is recommended to always supply four arguments, +even if the requested operation does not use them, +setting unused/ignored arguments to +.i 0l +or +.ir "(void\ *)\ 0". +.pp +in linux kernels before 2.6.26, +.\" see commit 00cd5c37afd5f431ac186dd131705048c0a11fdb +.br init (1), +the process with pid 1, may not be traced. +.pp +a tracees parent continues to be the tracer even if that tracer calls +.br execve (2). +.pp +the layout of the contents of memory and the user area are +quite operating-system- and architecture-specific. +the offset supplied, and the data returned, +might not entirely match with the definition of +.ir "struct user" . +.\" see http://lkml.org/lkml/2008/5/8/375 +.pp +the size of a "word" is determined by the operating-system variant +(e.g., for 32-bit linux it is 32 bits). +.pp +this page documents the way the +.br ptrace () +call works currently in linux. +its behavior differs significantly on other flavors of unix. +in any case, use of +.br ptrace () +is highly specific to the operating system and architecture. +.\" +.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.\" +.ss ptrace access mode checking +various parts of the kernel-user-space api (not just +.br ptrace () +operations), require so-called "ptrace access mode" checks, +whose outcome determines whether an operation is permitted +(or, in a few cases, causes a "read" operation to return sanitized data). +these checks are performed in cases where one process can +inspect sensitive information about, +or in some cases modify the state of, another process. +the checks are based on factors such as the credentials and capabilities +of the two processes, +whether or not the "target" process is dumpable, +and the results of checks performed by any enabled linux security module +(lsm)\(emfor example, selinux, yama, or smack\(emand by the commoncap lsm +(which is always invoked). +.pp +prior to linux 2.6.27, all access checks were of a single type. +since linux 2.6.27, +.\" commit 006ebb40d3d65338bd74abb03b945f8d60e362bd +two access mode levels are distinguished: +.tp +.br ptrace_mode_read +for "read" operations or other operations that are less dangerous, +such as: +.br get_robust_list (2); +.br kcmp (2); +reading +.ir /proc/[pid]/auxv , +.ir /proc/[pid]/environ , +or +.ir /proc/[pid]/stat ; +or +.br readlink (2) +of a +.ir /proc/[pid]/ns/* +file. +.tp +.br ptrace_mode_attach +for "write" operations, or other operations that are more dangerous, +such as: ptrace attaching +.rb ( ptrace_attach ) +to another process +or calling +.br process_vm_writev (2). +.rb ( ptrace_mode_attach +was effectively the default before linux 2.6.27.) +.\" +.\" regarding the above description of the distinction between +.\" ptrace_mode_read and ptrace_mode_attach, stephen smalley notes: +.\" +.\" that was the intent when the distinction was introduced, but it doesn't +.\" appear to have been properly maintained, e.g. there is now a common +.\" helper lock_trace() that is used for +.\" /proc/pid/{stack,syscall,personality} but checks ptrace_mode_attach, and +.\" ptrace_mode_attach is also used in timerslack_ns_write/show(). likely +.\" should review and make them consistent. there was also some debate +.\" about proper handling of /proc/pid/fd. arguably that one might belong +.\" back in the _attach camp. +.\" +.pp +since linux 4.5, +.\" commit caaee6234d05a58c5b4d05e7bf766131b810a657 +the above access mode checks are combined (ored) with +one of the following modifiers: +.tp +.b ptrace_mode_fscreds +use the caller's filesystem uid and gid (see +.br credentials (7)) +or effective capabilities for lsm checks. +.tp +.b ptrace_mode_realcreds +use the caller's real uid and gid or permitted capabilities for lsm checks. +this was effectively the default before linux 4.5. +.pp +because combining one of the credential modifiers with one of +the aforementioned access modes is typical, +some macros are defined in the kernel sources for the combinations: +.tp +.b ptrace_mode_read_fscreds +defined as +.br "ptrace_mode_read | ptrace_mode_fscreds" . +.tp +.b ptrace_mode_read_realcreds +defined as +.br "ptrace_mode_read | ptrace_mode_realcreds" . +.tp +.b ptrace_mode_attach_fscreds +defined as +.br "ptrace_mode_attach | ptrace_mode_fscreds" . +.tp +.b ptrace_mode_attach_realcreds +defined as +.br "ptrace_mode_attach | ptrace_mode_realcreds" . +.pp +one further modifier can be ored with the access mode: +.tp +.br ptrace_mode_noaudit " (since linux 3.3)" +.\" commit 69f594a38967f4540ce7a29b3fd214e68a8330bd +.\" just for /proc/pid/stat +don't audit this access mode check. +this modifier is employed for ptrace access mode checks +(such as checks when reading +.ir /proc/[pid]/stat ) +that merely cause the output to be filtered or sanitized, +rather than causing an error to be returned to the caller. +in these cases, accessing the file is not a security violation and +there is no reason to generate a security audit record. +this modifier suppresses the generation of +such an audit record for the particular access check. +.pp +note that all of the +.br ptrace_mode_* +constants described in this subsection are kernel-internal, +and not visible to user space. +the constant names are mentioned here in order to label the various kinds of +ptrace access mode checks that are performed for various system calls +and accesses to various pseudofiles (e.g., under +.ir /proc ). +these names are used in other manual pages to provide a simple +shorthand for labeling the different kernel checks. +.pp +the algorithm employed for ptrace access mode checking determines whether +the calling process is allowed to perform the corresponding action +on the target process. +(in the case of opening +.ir /proc/[pid] +files, the "calling process" is the one opening the file, +and the process with the corresponding pid is the "target process".) +the algorithm is as follows: +.ip 1. 3 +if the calling thread and the target thread are in the same +thread group, access is always allowed. +.ip 2. +if the access mode specifies +.br ptrace_mode_fscreds , +then, for the check in the next step, +employ the caller's filesystem uid and gid. +(as noted in +.br credentials (7), +the filesystem uid and gid almost always have the same values +as the corresponding effective ids.) +.ip +otherwise, the access mode specifies +.br ptrace_mode_realcreds , +so use the caller's real uid and gid for the checks in the next step. +(most apis that check the caller's uid and gid use the effective ids. +for historical reasons, the +.br ptrace_mode_realcreds +check uses the real ids instead.) +.ip 3. +deny access if +.i neither +of the following is true: +.rs +.ip \(bu 2 +the real, effective, and saved-set user ids of the target +match the caller's user id, +.ir and +the real, effective, and saved-set group ids of the target +match the caller's group id. +.ip \(bu +the caller has the +.b cap_sys_ptrace +capability in the user namespace of the target. +.re +.ip 4. +deny access if the target process "dumpable" attribute has a value other than 1 +.rb ( suid_dump_user ; +see the discussion of +.br pr_set_dumpable +in +.br prctl (2)), +and the caller does not have the +.br cap_sys_ptrace +capability in the user namespace of the target process. +.ip 5. +the kernel lsm +.ir security_ptrace_access_check () +interface is invoked to see if ptrace access is permitted. +the results depend on the lsm(s). +the implementation of this interface in the commoncap lsm performs +the following steps: +.\" (in cap_ptrace_access_check()): +.rs +.ip a) 3 +if the access mode includes +.br ptrace_mode_fscreds , +then use the caller's +.i effective +capability set +in the following check; +otherwise (the access mode specifies +.br ptrace_mode_realcreds , +so) use the caller's +.i permitted +capability set. +.ip b) +deny access if +.i neither +of the following is true: +.rs +.ip \(bu 2 +the caller and the target process are in the same user namespace, +and the caller's capabilities are a superset of the target process's +.i permitted +capabilities. +.ip \(bu +the caller has the +.b cap_sys_ptrace +capability in the target process's user namespace. +.re +.ip +note that the commoncap lsm does not distinguish between +.b ptrace_mode_read +and +.br ptrace_mode_attach . +.re +.ip 6. +if access has not been denied by any of the preceding steps, +then access is allowed. +.\" +.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.\" +.ss /proc/sys/kernel/yama/ptrace_scope +on systems with the yama linux security module (lsm) installed +(i.e., the kernel was configured with +.br config_security_yama ), +the +.i /proc/sys/kernel/yama/ptrace_scope +file (available since linux 3.4) +.\" commit 2d514487faf188938a4ee4fb3464eeecfbdcf8eb +can be used to restrict the ability to trace a process with +.br ptrace () +(and thus also the ability to use tools such as +.br strace (1) +and +.br gdb (1)). +the goal of such restrictions is to prevent attack escalation whereby +a compromised process can ptrace-attach to other sensitive processes +(e.g., a gpg agent or an ssh session) owned by the user in order +to gain additional credentials that may exist in memory +and thus expand the scope of the attack. +.pp +more precisely, the yama lsm limits two types of operations: +.ip * 3 +any operation that performs a ptrace access mode +.br ptrace_mode_attach +check\(emfor example, +.br ptrace () +.br ptrace_attach . +(see the "ptrace access mode checking" discussion above.) +.ip * +.br ptrace () +.br ptrace_traceme . +.pp +a process that has the +.b cap_sys_ptrace +capability can update the +.ir /proc/sys/kernel/yama/ptrace_scope +file with one of the following values: +.tp +0 ("classic ptrace permissions") +no additional restrictions on operations that perform +.br ptrace_mode_attach +checks (beyond those imposed by the commoncap and other lsms). +.ip +the use of +.br ptrace_traceme +is unchanged. +.tp +1 ("restricted ptrace") [default value] +when performing an operation that requires a +.br ptrace_mode_attach +check, the calling process must either have the +.b cap_sys_ptrace +capability in the user namespace of the target process or +it must have a predefined relationship with the target process. +by default, +the predefined relationship is that the target process +must be a descendant of the caller. +.ip +a target process can employ the +.br prctl (2) +.b pr_set_ptracer +operation to declare an additional pid that is allowed to perform +.br ptrace_mode_attach +operations on the target. +see the kernel source file +.ir documentation/admin\-guide/lsm/yama.rst +.\" commit 90bb766440f2147486a2acc3e793d7b8348b0c22 +(or +.ir documentation/security/yama.txt +before linux 4.13) +for further details. +.ip +the use of +.br ptrace_traceme +is unchanged. +.tp +2 ("admin-only attach") +only processes with the +.b cap_sys_ptrace +capability in the user namespace of the target process may perform +.br ptrace_mode_attach +operations or trace children that employ +.br ptrace_traceme . +.tp +3 ("no attach") +no process may perform +.br ptrace_mode_attach +operations or trace children that employ +.br ptrace_traceme . +.ip +once this value has been written to the file, it cannot be changed. +.pp +with respect to values 1 and 2, +note that creating a new user namespace effectively removes the +protection offered by yama. +this is because a process in the parent user namespace whose effective +uid matches the uid of the creator of a child namespace +has all capabilities (including +.br cap_sys_ptrace ) +when performing operations within the child user namespace +(and further-removed descendants of that namespace). +consequently, when a process tries to use user namespaces to sandbox itself, +it inadvertently weakens the protections offered by the yama lsm. +.\" +.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.\" +.ss c library/kernel differences +at the system call level, the +.br ptrace_peektext , +.br ptrace_peekdata , +and +.br ptrace_peekuser +requests have a different api: they store the result +at the address specified by the +.i data +parameter, and the return value is the error flag. +the glibc wrapper function provides the api given in description above, +with the result being returned via the function return value. +.sh bugs +on hosts with 2.6 kernel headers, +.b ptrace_setoptions +is declared with a different value than the one for 2.4. +this leads to applications compiled with 2.6 kernel +headers failing when run on 2.4 kernels. +this can be worked around by redefining +.b ptrace_setoptions +to +.br ptrace_oldsetoptions , +if that is defined. +.pp +group-stop notifications are sent to the tracer, but not to real parent. +last confirmed on 2.6.38.6. +.pp +if a thread group leader is traced and exits by calling +.br _exit (2), +.\" note from denys vlasenko: +.\" here "exits" means any kind of death - _exit, exit_group, +.\" signal death. signal death and exit_group cases are trivial, +.\" though: since signal death and exit_group kill all other threads +.\" too, "until all other threads exit" thing happens rather soon +.\" in these cases. therefore, only _exit presents observably +.\" puzzling behavior to ptrace users: thread leader _exit's, +.\" but wifexited isn't reported! we are trying to explain here +.\" why it is so. +a +.b ptrace_event_exit +stop will happen for it (if requested), but the subsequent +.b wifexited +notification will not be delivered until all other threads exit. +as explained above, if one of other threads calls +.br execve (2), +the death of the thread group leader will +.i never +be reported. +if the execed thread is not traced by this tracer, +the tracer will never know that +.br execve (2) +happened. +one possible workaround is to +.b ptrace_detach +the thread group leader instead of restarting it in this case. +last confirmed on 2.6.38.6. +.\" fixme . need to test/verify this scenario +.pp +a +.b sigkill +signal may still cause a +.b ptrace_event_exit +stop before actual signal death. +this may be changed in the future; +.b sigkill +is meant to always immediately kill tasks even under ptrace. +last confirmed on linux 3.13. +.pp +some system calls return with +.b eintr +if a signal was sent to a tracee, but delivery was suppressed by the tracer. +(this is very typical operation: it is usually +done by debuggers on every attach, in order to not introduce +a bogus +.br sigstop ). +as of linux 3.2.9, the following system calls are affected +(this list is likely incomplete): +.br epoll_wait (2), +and +.br read (2) +from an +.br inotify (7) +file descriptor. +the usual symptom of this bug is that when you attach to +a quiescent process with the command +.pp +.in +4n +.ex +strace \-p +.ee +.in +.pp +then, instead of the usual +and expected one-line output such as +.pp +.in +4n +.ex +restart_syscall(<... resuming interrupted call ...>_ +.ee +.in +.pp +or +.pp +.in +4n +.ex +select(6, [5], null, [5], null_ +.ee +.in +.pp +('_' denotes the cursor position), you observe more than one line. +for example: +.pp +.in +4n +.ex + clock_gettime(clock_monotonic, {15370, 690928118}) = 0 + epoll_wait(4,_ +.ee +.in +.pp +what is not visible here is that the process was blocked in +.br epoll_wait (2) +before +.br strace (1) +has attached to it. +attaching caused +.br epoll_wait (2) +to return to user space with the error +.br eintr . +in this particular case, the program reacted to +.b eintr +by checking the current time, and then executing +.br epoll_wait (2) +again. +(programs which do not expect such "stray" +.br eintr +errors may behave in an unintended way upon an +.br strace (1) +attach.) +.pp +contrary to the normal rules, the glibc wrapper for +.br ptrace () +can set +.i errno +to zero. +.sh see also +.br gdb (1), +.br ltrace (1), +.br strace (1), +.br clone (2), +.br execve (2), +.br fork (2), +.br gettid (2), +.br prctl (2), +.br seccomp (2), +.br sigaction (2), +.br tgkill (2), +.br vfork (2), +.br waitpid (2), +.br exec (3), +.br capabilities (7), +.br signal (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2002 andries brouwer +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" this replaces an earlier man page written by walter harms +.\" . +.\" +.th assert_perror 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +assert_perror \- test errnum and abort +.sh synopsis +.nf +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "void assert_perror(int " errnum ); +.fi +.sh description +if the macro +.b ndebug +was defined at the moment +.i +was last included, the macro +.br assert_perror () +generates no code, and hence does nothing at all. +otherwise, the macro +.br assert_perror () +prints an error message to standard error and terminates the program +by calling +.br abort (3) +if +.i errnum +is nonzero. +the message contains the filename, function name and +line number of the macro call, and the output of +.ir strerror(errnum) . +.sh return value +no value is returned. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br assert_perror () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +this is a gnu extension. +.sh bugs +the purpose of the assert macros is to help programmers find bugs in +their programs, things that cannot happen unless there was a coding mistake. +however, with system or library calls the situation is rather different, +and error returns can happen, and will happen, and should be tested for. +not by an assert, where the test goes away when +.b ndebug +is defined, +but by proper error handling code. +never use this macro. +.sh see also +.br abort (3), +.br assert (3), +.br exit (3), +.br strerror (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man7/iso_8859-16.7 + +.so man2/fcntl.2 + +.\" copyright (c) 2008 petr baudis +.\" and copyright (c) 2009, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" +.\" 2008-12-08 petr baudis +.\" rewrite the bsd manpage in the linux man pages style and account +.\" for glibc specificities, provide an example. +.\" 2009-01-14 mtk, many edits and changes, rewrote example program. +.\" +.th getifaddrs 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +getifaddrs, freeifaddrs \- get interface addresses +.sh synopsis +.nf +.b #include +.b #include +.pp +.bi "int getifaddrs(struct ifaddrs **" "ifap" ); +.bi "void freeifaddrs(struct ifaddrs *" "ifa" ); +.fi +.sh description +the +.br getifaddrs () +function creates a linked list of structures describing +the network interfaces of the local system, +and stores the address of the first item of the list in +.ir *ifap . +the list consists of +.i ifaddrs +structures, defined as follows: +.pp +.in +4n +.ex +struct ifaddrs { + struct ifaddrs *ifa_next; /* next item in list */ + char *ifa_name; /* name of interface */ + unsigned int ifa_flags; /* flags from siocgifflags */ + struct sockaddr *ifa_addr; /* address of interface */ + struct sockaddr *ifa_netmask; /* netmask of interface */ + union { + struct sockaddr *ifu_broadaddr; + /* broadcast address of interface */ + struct sockaddr *ifu_dstaddr; + /* point\-to\-point destination address */ + } ifa_ifu; +#define ifa_broadaddr ifa_ifu.ifu_broadaddr +#define ifa_dstaddr ifa_ifu.ifu_dstaddr + void *ifa_data; /* address\-specific data */ +}; +.ee +.in +.pp +the +.i ifa_next +field contains a pointer to the next structure on the list, +or null if this is the last item of the list. +.pp +the +.i ifa_name +points to the null-terminated interface name. +.\" the constant +.\" .b if namesize +.\" indicates the maximum length of this field. +.pp +the +.i ifa_flags +field contains the interface flags, as returned by the +.b siocgifflags +.br ioctl (2) +operation (see +.br netdevice (7) +for a list of these flags). +.pp +the +.i ifa_addr +field points to a structure containing the interface address. +(the +.i sa_family +subfield should be consulted to determine the format of the +address structure.) +this field may contain a null pointer. +.pp +the +.i ifa_netmask +field points to a structure containing the netmask associated with +.ir ifa_addr , +if applicable for the address family. +this field may contain a null pointer. +.pp +depending on whether the bit +.b iff_broadcast +or +.b iff_pointopoint +is set in +.i ifa_flags +(only one can be set at a time), +either +.i ifa_broadaddr +will contain the broadcast address associated with +.i ifa_addr +(if applicable for the address family) or +.i ifa_dstaddr +will contain the destination address of the point-to-point interface. +.pp +the +.i ifa_data +field points to a buffer containing address-family-specific data; +this field may be null if there is no such data for this interface. +.pp +the data returned by +.br getifaddrs () +is dynamically allocated and should be freed using +.br freeifaddrs () +when no longer needed. +.sh return value +on success, +.br getifaddrs () +returns zero; +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.br getifaddrs () +may fail and set +.i errno +for any of the errors specified for +.br socket (2), +.br bind (2), +.br getsockname (2), +.br recvmsg (2), +.br sendto (2), +.br malloc (3), +or +.br realloc (3). +.sh versions +the +.br getifaddrs () +function first appeared in glibc 2.3, but before glibc 2.3.3, +the implementation supported only ipv4 addresses; +ipv6 support was added in glibc 2.3.3. +support of address families other than ipv4 is available only +on kernels that support netlink. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br getifaddrs (), +.br freeifaddrs () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +not in posix.1. +this function first appeared in bsdi and is +present on the bsd systems, but with slightly different +semantics documented\(emreturning one entry per interface, +not per address. +this means +.i ifa_addr +and other fields can actually be null if the interface has no address, +and no link-level address is returned if the interface has an ip address +assigned. +also, the way of choosing either +.i ifa_broadaddr +or +.i ifa_dstaddr +differs on various systems. +.\" , but the bsd-derived documentation generally +.\" appears to be confused and obsolete on this point. +.\" i.e., commonly it still says one of them will be null, even if +.\" the ifa_ifu union is already present +.sh notes +the addresses returned on linux will usually be the ipv4 and ipv6 addresses +assigned to the interface, but also one +.b af_packet +address per interface containing lower-level details about the interface +and its physical layer. +in this case, the +.i ifa_data +field may contain a pointer to a +.ir "struct rtnl_link_stats" , +defined in +.ir +(in linux 2.4 and earlier, +.ir "struct net_device_stats" , +defined in +.ir ), +which contains various interface attributes and statistics. +.sh examples +the program below demonstrates the use of +.br getifaddrs (), +.br freeifaddrs (), +and +.br getnameinfo (3). +here is what we see when running this program on one system: +.pp +.in +4n +.ex +$ \fb./a.out\fp +lo af_packet (17) + tx_packets = 524; rx_packets = 524 + tx_bytes = 38788; rx_bytes = 38788 +wlp3s0 af_packet (17) + tx_packets = 108391; rx_packets = 130245 + tx_bytes = 30420659; rx_bytes = 94230014 +em1 af_packet (17) + tx_packets = 0; rx_packets = 0 + tx_bytes = 0; rx_bytes = 0 +lo af_inet (2) + address: <127.0.0.1> +wlp3s0 af_inet (2) + address: <192.168.235.137> +lo af_inet6 (10) + address: <::1> +wlp3s0 af_inet6 (10) + address: +.ee +.in +.ss program source +\& +.ex +#define _gnu_source /* to get defns of ni_maxserv and ni_maxhost */ +#include +#include +#include +#include +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + struct ifaddrs *ifaddr; + int family, s; + char host[ni_maxhost]; + + if (getifaddrs(&ifaddr) == \-1) { + perror("getifaddrs"); + exit(exit_failure); + } + + /* walk through linked list, maintaining head pointer so we + can free list later. */ + + for (struct ifaddrs *ifa = ifaddr; ifa != null; + ifa = ifa\->ifa_next) { + if (ifa\->ifa_addr == null) + continue; + + family = ifa\->ifa_addr\->sa_family; + + /* display interface name and family (including symbolic + form of the latter for the common families). */ + + printf("%\-8s %s (%d)\en", + ifa\->ifa_name, + (family == af_packet) ? "af_packet" : + (family == af_inet) ? "af_inet" : + (family == af_inet6) ? "af_inet6" : "???", + family); + + /* for an af_inet* interface address, display the address. */ + + if (family == af_inet || family == af_inet6) { + s = getnameinfo(ifa\->ifa_addr, + (family == af_inet) ? sizeof(struct sockaddr_in) : + sizeof(struct sockaddr_in6), + host, ni_maxhost, + null, 0, ni_numerichost); + if (s != 0) { + printf("getnameinfo() failed: %s\en", gai_strerror(s)); + exit(exit_failure); + } + + printf("\et\etaddress: <%s>\en", host); + + } else if (family == af_packet && ifa\->ifa_data != null) { + struct rtnl_link_stats *stats = ifa\->ifa_data; + + printf("\et\ettx_packets = %10u; rx_packets = %10u\en" + "\et\ettx_bytes = %10u; rx_bytes = %10u\en", + stats\->tx_packets, stats\->rx_packets, + stats\->tx_bytes, stats\->rx_bytes); + } + } + + freeifaddrs(ifaddr); + exit(exit_success); +} +.ee +.sh see also +.br bind (2), +.br getsockname (2), +.br socket (2), +.br packet (7), +.br ifconfig (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/stailq.3 + +.\" copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de) +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under gpl +.\" %%%license_end +.\" +.\" based on the description in glibc source and infopages +.\" +.\" corrections and additions, aeb +.th argz_add 3 2021-03-22 "" "linux programmer's manual" +.sh name +argz_add, argz_add_sep, argz_append, argz_count, argz_create, +argz_create_sep, argz_delete, argz_extract, argz_insert, +argz_next, argz_replace, argz_stringify \- functions to handle an argz list +.sh synopsis +.nf +.b "#include " +.pp +.bi "error_t argz_add(char **restrict " argz ", size_t *restrict " argz_len ", +.bi " const char *restrict " str ); +.pp +.bi "error_t argz_add_sep(char **restrict " argz \ +", size_t *restrict " argz_len , +.bi " const char *restrict " str ", int " delim ); +.pp +.bi "error_t argz_append(char **restrict " argz ", size_t *restrict " argz_len , +.bi " const char *restrict " buf ", size_t " buf_len ); +.pp +.bi "size_t argz_count(const char *" argz ", size_t " argz_len ); +.pp +.bi "error_t argz_create(char *const " argv "[], char **restrict " argz , +.bi " size_t *restrict " argz_len ); +.pp +.bi "error_t argz_create_sep(const char *restrict " str ", int " sep , +.bi " char **restrict " argz ", size_t *restrict " argz_len ); +.pp +.bi "void argz_delete(char **restrict " argz ", size_t *restrict " argz_len , +.bi " char *restrict " entry ); +.pp +.bi "void argz_extract(const char *restrict " argz ", size_t " argz_len , +.bi " char **restrict " argv ); +.pp +.bi "error_t argz_insert(char **restrict " argz ", size_t *restrict " argz_len , +.bi " char *restrict " before ", const char *restrict " entry ); +.pp +.bi "char *argz_next(const char *restrict " argz ", size_t " argz_len , +.bi " const char *restrict " entry ); +.pp +.bi "error_t argz_replace(char **restrict " argz \ +", size_t *restrict " argz_len , +.bi " const char *restrict " str ", const char *restrict " with , +.bi " unsigned int *restrict " replace_count ); +.pp +.bi "void argz_stringify(char *" argz ", size_t " len ", int " sep ); +.fi +.sh description +these functions are glibc-specific. +.pp +an argz vector is a pointer to a character buffer together with a length. +the intended interpretation of the character buffer is an array +of strings, where the strings are separated by null bytes (\(aq\e0\(aq). +if the length is nonzero, the last byte of the buffer must be a null byte. +.pp +these functions are for handling argz vectors. +the pair (null,0) is an argz vector, and, conversely, +argz vectors of length 0 must have null pointer. +allocation of nonempty argz vectors is done using +.br malloc (3), +so that +.br free (3) +can be used to dispose of them again. +.pp +.br argz_add () +adds the string +.i str +at the end of the array +.ir *argz , +and updates +.i *argz +and +.ir *argz_len . +.pp +.br argz_add_sep () +is similar, but splits the string +.i str +into substrings separated by the delimiter +.ir delim . +for example, one might use this on a unix search path with +delimiter \(aq:\(aq. +.pp +.br argz_append () +appends the argz vector +.ri ( buf ,\ buf_len ) +after +.ri ( *argz ,\ *argz_len ) +and updates +.ir *argz +and +.ir *argz_len . +(thus, +.i *argz_len +will be increased by +.ir buf_len .) +.pp +.br argz_count () +counts the number of strings, that is, +the number of null bytes (\(aq\e0\(aq), in +.ri ( argz ,\ argz_len ). +.pp +.br argz_create () +converts a unix-style argument vector +.ir argv , +terminated by +.ir "(char\ *)\ 0" , +into an argz vector +.ri ( *argz ,\ *argz_len ). +.pp +.br argz_create_sep () +converts the null-terminated string +.i str +into an argz vector +.ri ( *argz ,\ *argz_len ) +by breaking it up at every occurrence of the separator +.ir sep . +.pp +.br argz_delete () +removes the substring pointed to by +.i entry +from the argz vector +.ri ( *argz ,\ *argz_len ) +and updates +.i *argz +and +.ir *argz_len . +.pp +.br argz_extract () +is the opposite of +.br argz_create (). +it takes the argz vector +.ri ( argz ,\ argz_len ) +and fills the array starting at +.i argv +with pointers to the substrings, and a final null, +making a unix-style argv vector. +the array +.i argv +must have room for +.ir argz_count ( argz ", " argz_len ") + 1" +pointers. +.pp +.br argz_insert () +is the opposite of +.br argz_delete (). +it inserts the argument +.i entry +at position +.i before +into the argz vector +.ri ( *argz ,\ *argz_len ) +and updates +.i *argz +and +.ir *argz_len . +if +.i before +is null, then +.i entry +will inserted at the end. +.pp +.br argz_next () +is a function to step through the argz vector. +if +.i entry +is null, the first entry is returned. +otherwise, the entry +following is returned. +it returns null if there is no following entry. +.pp +.br argz_replace () +replaces each occurrence of +.i str +with +.ir with , +reallocating argz as necessary. +if +.i replace_count +is non-null, +.i *replace_count +will be incremented by the number of replacements. +.pp +.br argz_stringify () +is the opposite of +.br argz_create_sep (). +it transforms the argz vector into a normal string by replacing +all null bytes (\(aq\e0\(aq) except the last by +.ir sep . +.sh return value +all argz functions that do memory allocation have a return type of +.ir error_t +(an integer type), +and return 0 for success, and +.b enomem +if an allocation error occurs. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br argz_add (), +.br argz_add_sep (), +.br argz_append (), +.br argz_count (), +.br argz_create (), +.br argz_create_sep (), +.br argz_delete (), +.br argz_extract (), +.br argz_insert (), +.br argz_next (), +.br argz_replace (), +.br argz_stringify () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +these functions are a gnu extension. +.sh bugs +argz vectors without a terminating null byte may lead to +segmentation faults. +.sh see also +.br envz_add (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" opengroup's single unix specification +.\" http://www.unix-systems.org/online.html +.\" +.\" 2000-06-30 correction by yuichi sato +.\" 2000-11-15 aeb, fixed prototype +.\" +.th iconv 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +iconv \- perform character set conversion +.sh synopsis +.nf +.b #include +.pp +.bi "size_t iconv(iconv_t " cd , +.bi " char **restrict " inbuf ", size_t *restrict " inbytesleft , +.bi " char **restrict " outbuf ", size_t *restrict " outbytesleft ); +.fi +.sh description +the +.br iconv () +function converts a sequence of characters in one character encoding +to a sequence of characters in another character encoding. +the +.i cd +argument is a conversion descriptor, +previously created by a call to +.br iconv_open (3); +the conversion descriptor defines the character encodings that +.br iconv () +uses for the conversion. +the +.i inbuf +argument is the address of a variable that points to +the first character of the input sequence; +.i inbytesleft +indicates the number of bytes in that buffer. +the +.i outbuf +argument is the address of a variable that points to +the first byte available in the output buffer; +.i outbytesleft +indicates the number of bytes available in the output buffer. +.pp +the main case is when \fiinbuf\fp is not null and \fi*inbuf\fp is not null. +in this case, the +.br iconv () +function converts the multibyte sequence +starting at \fi*inbuf\fp to a multibyte sequence starting at \fi*outbuf\fp. +at most \fi*inbytesleft\fp bytes, starting at \fi*inbuf\fp, will be read. +at most \fi*outbytesleft\fp bytes, starting at \fi*outbuf\fp, will be written. +.pp +the +.br iconv () +function converts one multibyte character at a time, and for +each character conversion it increments \fi*inbuf\fp and decrements +\fi*inbytesleft\fp by the number of converted input bytes, it increments +\fi*outbuf\fp and decrements \fi*outbytesleft\fp by the number of converted +output bytes, and it updates the conversion state contained in \ficd\fp. +if the character encoding of the input is stateful, the +.br iconv () +function can also convert a sequence of input bytes +to an update to the conversion state without producing any output bytes; +such input is called a \fishift sequence\fp. +the conversion can stop for four reasons: +.ip 1. 3 +an invalid multibyte sequence is encountered in the input. +in this case, +it sets \fierrno\fp to \fbeilseq\fp and returns +.ir (size_t)\ \-1 . +\fi*inbuf\fp +is left pointing to the beginning of the invalid multibyte sequence. +.ip 2. +the input byte sequence has been entirely converted, +that is, \fi*inbytesleft\fp has gone down to 0. +in this case, +.br iconv () +returns the number of +nonreversible conversions performed during this call. +.ip 3. +an incomplete multibyte sequence is encountered in the input, and the +input byte sequence terminates after it. +in this case, it sets \fierrno\fp to +\fbeinval\fp and returns +.ir (size_t)\ \-1 . +\fi*inbuf\fp is left pointing to the +beginning of the incomplete multibyte sequence. +.ip 4. +the output buffer has no more room for the next converted character. +in this case, it sets \fierrno\fp to \fbe2big\fp and returns +.ir (size_t)\ \-1 . +.pp +a different case is when \fiinbuf\fp is null or \fi*inbuf\fp is null, but +\fioutbuf\fp is not null and \fi*outbuf\fp is not null. +in this case, the +.br iconv () +function attempts to set \ficd\fp's conversion state to the +initial state and store a corresponding shift sequence at \fi*outbuf\fp. +at most \fi*outbytesleft\fp bytes, starting at \fi*outbuf\fp, will be written. +if the output buffer has no more room for this reset sequence, it sets +\fierrno\fp to \fbe2big\fp and returns +.ir (size_t)\ \-1 . +otherwise, it increments +\fi*outbuf\fp and decrements \fi*outbytesleft\fp by the number of bytes +written. +.pp +a third case is when \fiinbuf\fp is null or \fi*inbuf\fp is null, and +\fioutbuf\fp is null or \fi*outbuf\fp is null. +in this case, the +.br iconv () +function sets \ficd\fp's conversion state to the initial state. +.sh return value +the +.br iconv () +function returns the number of characters converted in a +nonreversible way during this call; reversible conversions are not counted. +in case of error, +.br iconv () +returns +.ir (size_t)\ \-1 +and sets +.i errno +to indicate the error. +.sh errors +the following errors can occur, among others: +.tp +.b e2big +there is not sufficient room at \fi*outbuf\fp. +.tp +.b eilseq +an invalid multibyte sequence has been encountered in the input. +.tp +.b einval +an incomplete multibyte sequence has been encountered in the input. +.sh versions +this function is available in glibc since version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br iconv () +t} thread safety mt-safe race:cd +.te +.hy +.ad +.sp 1 +.pp +the +.br iconv () +function is mt-safe, as long as callers arrange for +mutual exclusion on the +.i cd +argument. +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +in each series of calls to +.br iconv (), +the last should be one with \fiinbuf\fp or \fi*inbuf\fp equal to null, +in order to flush out any partially converted input. +.pp +although +.i inbuf +and +.i outbuf +are typed as +.ir "char\ **" , +this does not mean that the objects they point can be interpreted +as c strings or as arrays of characters: +the interpretation of character byte sequences is +handled internally by the conversion functions. +in some encodings, a zero byte may be a valid part of a multibyte character. +.pp +the caller of +.br iconv () +must ensure that the pointers passed to the function are suitable +for accessing characters in the appropriate character set. +this includes ensuring correct alignment on platforms that have +tight restrictions on alignment. +.sh see also +.br iconv_close (3), +.br iconv_open (3), +.br iconvconfig (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/readv.2 + +.so man2/posix_fadvise.2 + +.so man3/rpc.3 + +.\" copyright (c) 2006, 2014, michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th fexecve 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +fexecve \- execute program specified via file descriptor +.sh synopsis +.nf +.b #include +.pp +.bi "int fexecve(int " fd ", char *const " argv "[], char *const " envp []); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br fexecve (): +.nf + since glibc 2.10: + _posix_c_source >= 200809l + before glibc 2.10: + _gnu_source +.fi +.sh description +.br fexecve () +performs the same task as +.br execve (2), +with the difference that the file to be executed +is specified via a file descriptor, +.ir fd , +rather than via a pathname. +the file descriptor +.i fd +must be opened read-only +.rb ( o_rdonly ) +or with the +.b o_path +flag +and the caller must have permission to execute the file that it refers to. +.sh return value +a successful call to +.br fexecve () +never returns. +on error, the function does return, with a result value of \-1, and +.i errno +is set to indicate the error. +.sh errors +errors are as for +.br execve (2), +with the following additions: +.tp +.b einval +.i fd +is not a valid file descriptor, or +.i argv +is null, or +.i envp +is null. +.tp +.b enoent +the close-on-exec flag is set on +.ir fd , +and +.i fd +refers to a script. +see bugs. +.tp +.b enosys +the kernel does not provide the +.br execveat (2) +system call, and the +.i /proc +filesystem could not be accessed. +.sh versions +.br fexecve () +is implemented since glibc 2.3.2. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br fexecve () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2008. +this function is not specified in posix.1-2001, +and is not widely available on other systems. +it is specified in posix.1-2008. +.sh notes +on linux with glibc versions 2.26 and earlier, +.br fexecve () +is implemented using the +.br proc (5) +filesystem, so +.i /proc +needs to be mounted and available at the time of the call. +since glibc 2.27, +.\" glibc commit 43ffc53a352a67672210c9dd4959f6c6b7407e60 +if the underlying kernel supports the +.br execveat (2) +system call, then +.br fexecve () +is implemented using that system call, with the benefit that +.ir /proc +does not need to be mounted. +.pp +the idea behind +.br fexecve () +is to allow the caller to verify (checksum) the contents of +an executable before executing it. +simply opening the file, checksumming the contents, and then doing an +.br execve (2) +would not suffice, since, between the two steps, the filename, +or a directory prefix of the pathname, could have been exchanged +(by, for example, modifying the target of a symbolic link). +.br fexecve () +does not mitigate the problem that the +.i contents +of a file could be changed between the checksumming and the call to +.br fexecve (); +for that, the solution is to ensure that the permissions on the file +prevent it from being modified by malicious users. +.pp +the natural idiom when using +.br fexecve () +is to set the close-on-exec flag on +.ir fd , +so that the file descriptor does not leak through to the program +that is executed. +this approach is natural for two reasons. +first, it prevents file descriptors being consumed unnecessarily. +(the executed program normally has no need of a file descriptor +that refers to the program itself.) +second, if +.br fexecve () +is used recursively, +employing the close-on-exec flag prevents the file descriptor exhaustion +that would result from the fact that each step in the recursion would +cause one more file descriptor to be passed to the new program. +(but see bugs.) +.sh bugs +if +.i fd +refers to a script (i.e., it is an executable text file that names +a script interpreter with a first line that begins with the characters +.ir #! ) +and the close-on-exec flag has been set for +.ir fd , +then +.br fexecve () +fails with the error +.br enoent . +this error occurs because, +by the time the script interpreter is executed, +.i fd +has already been closed because of the close-on-exec flag. +thus, the close-on-exec flag can't be set on +.i fd +if it refers to a script, leading to the problems described in notes. +.sh see also +.br execve (2), +.br execveat (2) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/cexp.3 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sat jul 24 18:49:59 1993 by rik faith (faith@cs.unc.edu) +.th memmove 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +memmove \- copy memory area +.sh synopsis +.nf +.b #include +.pp +.bi "void *memmove(void *" dest ", const void *" src ", size_t " n ); +.fi +.sh description +the +.br memmove () +function copies +.i n +bytes from memory area +.i src +to memory area +.ir dest . +the memory areas may overlap: copying takes place as though +the bytes in +.i src +are first copied into a temporary array that does not overlap +.i src +or +.ir dest , +and the bytes are then copied from the temporary array to +.ir dest . +.sh return value +the +.br memmove () +function returns a pointer to +.ir dest . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br memmove () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c89, c99, svr4, 4.3bsd. +.sh see also +.br bcopy (3), +.br bstring (3), +.br memccpy (3), +.br memcpy (3), +.br strcpy (3), +.br strncpy (3), +.br wmemmove (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1997 andries brouwer (aeb@cwi.nl) +.\" and copyright (c) 2007, michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified, 2003-05-26, michael kerrisk, +.\" +.th getresuid 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +getresuid, getresgid \- get real, effective, and saved user/group ids +.sh synopsis +.nf +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "int getresuid(uid_t *" ruid ", uid_t *" euid ", uid_t *" suid ); +.bi "int getresgid(gid_t *" rgid ", gid_t *" egid ", gid_t *" sgid ); +.fi +.sh description +.br getresuid () +returns the real uid, the effective uid, and the saved set-user-id +of the calling process, in the arguments +.ir ruid , +.ir euid , +and +.ir suid , +respectively. +.br getresgid () +performs the analogous task for the process's group ids. +.sh return value +on success, zero is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b efault +one of the arguments specified an address outside the calling program's +address space. +.sh versions +these system calls appeared on linux starting with kernel 2.1.44. +.pp +the prototypes are given by glibc since version 2.3.2, +provided +.b _gnu_source +is defined. +.sh conforming to +these calls are nonstandard; +they also appear on hp-ux and some of the bsds. +.sh notes +the original linux +.br getresuid () +and +.br getresgid () +system calls supported only 16-bit user and group ids. +subsequently, linux 2.4 added +.br getresuid32 () +and +.br getresgid32 (), +supporting 32-bit ids. +the glibc +.br getresuid () +and +.br getresgid () +wrapper functions transparently deal with the variations across kernel versions. +.sh see also +.br getuid (2), +.br setresuid (2), +.br setreuid (2), +.br setuid (2), +.br credentials (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th math_error 7 2021-03-22 "linux" "linux programmer's manual" +.sh name +math_error \- detecting errors from mathematical functions +.sh synopsis +.nf +.b #include +.b #include +.b #include +.fi +.sh description +when an error occurs, +most library functions indicate this fact by returning a special value +(e.g., \-1 or null). +because they typically return a floating-point number, +the mathematical functions declared in +.ir +indicate an error using other mechanisms. +there are two error-reporting mechanisms: +the older one sets +.ir errno ; +the newer one uses the floating-point exception mechanism (the use of +.br feclearexcept (3) +and +.br fetestexcept (3), +as outlined below) +described in +.br fenv (3). +.pp +a portable program that needs to check for an error from a mathematical +function should set +.i errno +to zero, and make the following call +.pp +.in +4n +.ex +feclearexcept(fe_all_except); +.ee +.in +.pp +before calling a mathematical function. +.pp +upon return from the mathematical function, if +.i errno +is nonzero, or the following call (see +.br fenv (3)) +returns nonzero +.pp +.in +4n +.ex +fetestexcept(fe_invalid | fe_divbyzero | fe_overflow | + fe_underflow); +.ee +.in +.pp +.\" enum +.\" { +.\" fe_invalid = 0x01, +.\" __fe_denorm = 0x02, +.\" fe_divbyzero = 0x04, +.\" fe_overflow = 0x08, +.\" fe_underflow = 0x10, +.\" fe_inexact = 0x20 +.\" }; +then an error occurred in the mathematical function. +.pp +the error conditions that can occur for mathematical functions +are described below. +.ss domain error +a +.i domain error +occurs when a mathematical function is supplied with an argument whose +value falls outside the domain for which the function +is defined (e.g., giving a negative argument to +.br log (3)). +when a domain error occurs, +math functions commonly return a nan +(though some functions return a different value in this case); +.i errno +is set to +.br edom , +and an "invalid" +.rb ( fe_invalid ) +floating-point exception is raised. +.ss pole error +a +.i pole error +occurs when the mathematical result of a function is an exact infinity +(e.g., the logarithm of 0 is negative infinity). +when a pole error occurs, +the function returns the (signed) value +.br huge_val , +.br huge_valf , +or +.br huge_vall , +depending on whether the function result type is +.ir double , +.ir float , +or +.ir "long double" . +the sign of the result is that which is mathematically correct for +the function. +.i errno +is set to +.br erange , +and a "divide-by-zero" +.rb ( fe_divbyzero ) +floating-point exception is raised. +.ss range error +a +.i range error +occurs when the magnitude of the function result means that it +cannot be represented in the result type of the function. +the return value of the function depends on whether the range error +was an overflow or an underflow. +.pp +a floating result +.i overflows +if the result is finite, +but is too large to represented in the result type. +when an overflow occurs, +the function returns the value +.br huge_val , +.br huge_valf , +or +.br huge_vall , +depending on whether the function result type is +.ir double , +.ir float , +or +.ir "long double" . +.i errno +is set to +.br erange , +and an "overflow" +.rb ( fe_overflow ) +floating-point exception is raised. +.pp +a floating result +.i underflows +if the result is too small to be represented in the result type. +if an underflow occurs, +a mathematical function typically returns 0.0 +(c99 says a function shall return "an implementation-defined value +whose magnitude is no greater than the smallest normalized +positive number in the specified type"). +.i errno +may be set to +.br erange , +and an "underflow" +.rb ( fe_underflow ) +floating-point exception may be raised. +.pp +some functions deliver a range error if the supplied argument value, +or the correct function result, would be +.ir subnormal . +a subnormal value is one that is nonzero, +but with a magnitude that is so small that +it can't be presented in normalized form +(i.e., with a 1 in the most significant bit of the significand). +the representation of a subnormal number will contain one +or more leading zeros in the significand. +.sh notes +the +.i math_errhandling +identifier specified by c99 and posix.1 is not supported by glibc. +.\" see conformance in the glibc 2.8 (and earlier) source. +this identifier is supposed to indicate which of the two +error-notification mechanisms +.ri ( errno , +exceptions retrievable via +.br fetestexcept (3)) +is in use. +the standards require that at least one be in use, +but permit both to be available. +the current (version 2.8) situation under glibc is messy. +most (but not all) functions raise exceptions on errors. +some also set +.ir errno . +a few functions set +.ir errno , +but don't raise an exception. +a very few functions do neither. +see the individual manual pages for details. +.pp +to avoid the complexities of using +.i errno +and +.br fetestexcept (3) +for error checking, +it is often advised that one should instead check for bad argument +values before each call. +.\" http://www.securecoding.cert.org/confluence/display/seccode/flp32-c.+prevent+or+detect+domain+and+range+errors+in+math+functions +for example, the following code ensures that +.br log (3)'s +argument is not a nan and is not zero (a pole error) or +less than zero (a domain error): +.pp +.in +4n +.ex +double x, r; + +if (isnan(x) || islessequal(x, 0)) { + /* deal with nan / pole error / domain error */ +} + +r = log(x); +.ee +.in +.pp +the discussion on this page does not apply to the complex +mathematical functions (i.e., those declared by +.ir ), +which in general are not required to return errors by c99 +and posix.1. +.pp +the +.br gcc (1) +.i "\-fno\-math\-errno" +option causes the executable to employ implementations of some +mathematical functions that are faster than the standard +implementations, but do not set +.i errno +on error. +(the +.br gcc (1) +.i "\-ffast\-math" +option also enables +.ir "\-fno\-math\-errno" .) +an error can still be tested for using +.br fetestexcept (3). +.sh see also +.br gcc (1), +.br errno (3), +.br fenv (3), +.br fpclassify (3), +.br infinity (3), +.br isgreater (3), +.br matherr (3), +.br nan (3) +.pp +.i "info libc" +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1993 rickard e. faith (faith@cs.unc.edu) +.\" portions extracted from linux/mm/swap.c: +.\" copyright (c) 1991, 1992 linus torvalds +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified 21 aug 1994 by michael chastain : +.\" added text about calling restriction (new in kernel 1.1.20 i believe). +.\" n.b. calling "idle" from user process used to hang process! +.\" modified thu oct 31 14:41:15 1996 by eric s. raymond +.\" " +.th idle 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +idle \- make process 0 idle +.sh synopsis +.nf +.b #include +.pp +.b int idle(void); +.fi +.sh description +.br idle () +is an internal system call used during bootstrap. +it marks the process's pages as swappable, lowers its priority, +and enters the main scheduling loop. +.br idle () +never returns. +.pp +only process 0 may call +.br idle (). +any user process, even a process with superuser permission, +will receive +.br eperm . +.sh return value +.br idle () +never returns for process 0, and always returns \-1 for a user process. +.sh errors +.tp +.b eperm +always, for a user process. +.sh versions +since linux 2.3.13, this system call does not exist anymore. +.sh conforming to +this function is linux-specific, and should not be used in programs +intended to be portable. +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2017, yubin ruan +.\" and copyright (c) 2017, michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th pthread_mutexattr_setrobust 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +pthread_mutexattr_getrobust, pthread_mutexattr_setrobust +\- get and set the robustness attribute of a mutex attributes object +.sh synopsis +.nf +.b #include +.pp +.bi "int pthread_mutexattr_getrobust(const pthread_mutexattr_t *" attr , +.bi " int *" robustness ");" +.bi "int pthread_mutexattr_setrobust(pthread_mutexattr_t *" attr , +.bi " int " robustness ");" +.fi +.pp +compile and link with \fi\-pthread\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br pthread_mutexattr_getrobust (), +.br pthread_mutexattr_setrobust (): +.nf + _posix_c_source >= 200809l +.\" fixme . +.\" but see https://sourceware.org/bugzilla/show_bug.cgi?id=22125 +.fi +.sh description +the +.br pthread_mutexattr_getrobust () +function places the value of the robustness attribute of +the mutex attributes object referred to by +.i attr +in +.ir *robustness . +the +.br pthread_mutexattr_setrobust () +function sets the value of the robustness attribute of +the mutex attributes object referred to by +.i attr +to the value specified in +.ir *robustness . +.pp +the robustness attribute specifies the behavior of the mutex when +the owning thread dies without unlocking the mutex. +the following values are valid for +.ir robustness : +.tp +.br pthread_mutex_stalled +this is the default value for a mutex attributes object. +if a mutex is initialized with the +.br pthread_mutex_stalled +attribute and its owner dies without unlocking it, +the mutex remains locked afterwards and any future attempts to call +.br pthread_mutex_lock (3) +on the mutex will block indefinitely. +.tp +.b pthread_mutex_robust +if a mutex is initialized with the +.br pthread_mutex_robust +attribute and its owner dies without unlocking it, +any future attempts to call +.br pthread_mutex_lock (3) +on this mutex will succeed and return +.b eownerdead +to indicate that the original owner no longer exists and the mutex is in +an inconsistent state. +usually after +.b eownerdead +is returned, the next owner should call +.br pthread_mutex_consistent (3) +on the acquired mutex to make it consistent again before using it any further. +.ip +if the next owner unlocks the mutex using +.br pthread_mutex_unlock (3) +before making it consistent, the mutex will be permanently unusable and any +subsequent attempts to lock it using +.br pthread_mutex_lock (3) +will fail with the error +.br enotrecoverable . +the only permitted operation on such a mutex is +.br pthread_mutex_destroy (3). +.ip +if the next owner terminates before calling +.br pthread_mutex_consistent (3), +further +.br pthread_mutex_lock (3) +operations on this mutex will still return +.br eownerdead . +.pp +note that the +.ir attr +argument of +.br pthread_mutexattr_getrobust () +and +.br pthread_mutexattr_setrobust () +should refer to a mutex attributes object that was initialized by +.br pthread_mutexattr_init (3), +otherwise the behavior is undefined. +.sh return value +on success, these functions return 0. +on error, they return a positive error number. +.pp +in the glibc implementation, +.br pthread_mutexattr_getrobust () +always return zero. +.sh errors +.tp +.b einval +a value other than +.b pthread_mutex_stalled +or +.b pthread_mutex_robust +was passed to +.br pthread_mutexattr_setrobust (). +.sh versions +.br pthread_mutexattr_getrobust () +and +.br pthread_mutexattr_setrobust () +were added to glibc in version 2.12. +.sh conforming to +posix.1-2008. +.sh notes +in the linux implementation, +when using process-shared robust mutexes, a waiting thread also receives the +.b eownerdead +notification if the owner of a robust mutex performs an +.br execve (2) +without first unlocking the mutex. +posix.1 does not specify this detail, +but the same behavior also occurs in at least some +.\" e.g., solaris, according to its manual page +other implementations. +.pp +before the addition of +.br pthread_mutexattr_getrobust () +and +.br pthread_mutexattr_setrobust () +to posix, +glibc defined the following equivalent nonstandard functions if +.br _gnu_source +was defined: +.pp +.nf +.bi "int pthread_mutexattr_getrobust_np(const pthread_mutexattr_t *" attr , +.bi " int *" robustness ");" +.bi "int pthread_mutexattr_setrobust_np(const pthread_mutexattr_t *" attr , +.bi " int " robustness ");" +.fi +.pp +correspondingly, the constants +.b pthread_mutex_stalled_np +and +.b pthread_mutex_robust_np +were also defined. +.pp +these gnu-specific apis, which first appeared in glibc 2.4, +are nowadays obsolete and should not be used in new programs; +since glibc 2.34 these apis are marked as deprecated. +.sh examples +the program below demonstrates the use of the robustness attribute of a +mutex attributes object. +in this program, a thread holding the mutex +dies prematurely without unlocking the mutex. +the main thread subsequently acquires the mutex +successfully and gets the error +.br eownerdead , +after which it makes the mutex consistent. +.pp +the following shell session shows what we see when running this program: +.pp +.in +4n +.ex +$ \fb./a.out\fp +[original owner] setting lock... +[original owner] locked. now exiting without unlocking. +[main] attempting to lock the robust mutex. +[main] pthread_mutex_lock() returned eownerdead +[main] now make the mutex consistent +[main] mutex is now consistent; unlocking +.ee +.in +.ss program source +.ex +#include +#include +#include +#include +#include + +#define handle_error_en(en, msg) \e + do { errno = en; perror(msg); exit(exit_failure); } while (0) + +static pthread_mutex_t mtx; + +static void * +original_owner_thread(void *ptr) +{ + printf("[original owner] setting lock...\en"); + pthread_mutex_lock(&mtx); + printf("[original owner] locked. now exiting without unlocking.\en"); + pthread_exit(null); +} + +int +main(int argc, char *argv[]) +{ + pthread_t thr; + pthread_mutexattr_t attr; + int s; + + pthread_mutexattr_init(&attr); + + pthread_mutexattr_setrobust(&attr, pthread_mutex_robust); + + pthread_mutex_init(&mtx, &attr); + + pthread_create(&thr, null, original_owner_thread, null); + + sleep(2); + + /* "original_owner_thread" should have exited by now. */ + + printf("[main] attempting to lock the robust mutex.\en"); + s = pthread_mutex_lock(&mtx); + if (s == eownerdead) { + printf("[main] pthread_mutex_lock() returned eownerdead\en"); + printf("[main] now make the mutex consistent\en"); + s = pthread_mutex_consistent(&mtx); + if (s != 0) + handle_error_en(s, "pthread_mutex_consistent"); + printf("[main] mutex is now consistent; unlocking\en"); + s = pthread_mutex_unlock(&mtx); + if (s != 0) + handle_error_en(s, "pthread_mutex_unlock"); + + exit(exit_success); + } else if (s == 0) { + printf("[main] pthread_mutex_lock() unexpectedly succeeded\en"); + exit(exit_failure); + } else { + printf("[main] pthread_mutex_lock() unexpectedly failed\en"); + handle_error_en(s, "pthread_mutex_lock"); + } +} +.ee +.sh see also +.ad l +.nh +.br get_robust_list (2), +.br set_robust_list (2), +.br pthread_mutex_consistent (3), +.br pthread_mutex_init (3), +.br pthread_mutex_lock (3), +.br pthreads (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" iso/iec 9899:1999 +.\" +.th towctrans 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +towctrans \- wide-character transliteration +.sh synopsis +.nf +.b #include +.pp +.bi "wint_t towctrans(wint_t " wc ", wctrans_t " desc ); +.fi +.sh description +if +.i wc +is a wide character, the +.br towctrans () +function +translates it according to the transliteration descriptor +.ir desc . +if +.i wc +is +.br weof , +.b weof +is returned. +.pp +.i desc +must be a transliteration descriptor returned by +the +.br wctrans (3) +function. +.sh return value +the +.br towctrans () +function returns the translated wide character, +or +.b weof +if +.i wc +is +.br weof . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br towctrans () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh notes +the behavior of +.br towctrans () +depends on the +.b lc_ctype +category of the +current locale. +.sh see also +.br towlower (3), +.br towupper (3), +.br wctrans (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1993 +.\" the regents of the university of california. all rights reserved. +.\" and copyright (c) 2020 by alejandro colomar +.\" +.\" %%%license_start(bsd_3_clause_ucb) +.\" redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. neither the name of the university nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" this software is provided by the regents and contributors ``as is'' and +.\" any express or implied warranties, including, but not limited to, the +.\" implied warranties of merchantability and fitness for a particular purpose +.\" are disclaimed. in no event shall the regents or contributors be liable +.\" for any direct, indirect, incidental, special, exemplary, or consequential +.\" damages (including, but not limited to, procurement of substitute goods +.\" or services; loss of use, data, or profits; or business interruption) +.\" however caused and on any theory of liability, whether in contract, strict +.\" liability, or tort (including negligence or otherwise) arising in any way +.\" out of the use of this software, even if advised of the possibility of +.\" such damage. +.\" %%%license_end +.\" +.\" +.th queue 7 2021-03-22 "gnu" "linux programmer's manual" +.sh name +queue \- implementations of linked lists and queues +.sh description +the +.i +header file provides a set of macros that +define and operate on the following data structures: +.ip * 3 +singly linked lists (slist) +.ip * +doubly linked lists (list) +.ip * +singly linked tail queues (stailq) +.ip * +doubly linked tail queues (tailq) +.ip * +doubly linked circular queues (circleq) +.pp +all structures support the following functionality: +.ip * 3 +insertion of a new entry at the head of the list. +.ip * +insertion of a new entry after any element in the list. +.ip * +o(1) removal of an entry from the head of the list. +.ip * +forward traversal through the list. +.\".ip * +.\" swapping the contents of two lists. +.pp +code size and execution time +depend on the complexity of the data structure being used, +so programmers should take care to choose the appropriate one. +.ss singly linked lists (slist) +singly linked lists are the simplest +and support only the above functionality. +singly linked lists are ideal for applications with +large datasets and few or no removals, +or for implementing a lifo queue. +singly linked lists add the following functionality: +.ip * 3 +o(n) removal of any entry in the list. +.ss singly linked tail queues (stailq) +singly linked tail queues add the following functionality: +.ip * 3 +entries can be added at the end of a list. +.ip * +o(n) removal of any entry in the list. +.ip * +they may be concatenated. +.pp +however: +.ip * 3 +all list insertions must specify the head of the list. +.ip * +each head entry requires two pointers rather than one. +.pp +singly linked tail queues are ideal for applications with +large datasets and few or no removals, +or for implementing a fifo queue. +.ss doubly linked data structures +all doubly linked types of data structures (lists and tail queues) +additionally allow: +.ip * 3 +insertion of a new entry before any element in the list. +.ip * +o(1) removal of any entry in the list. +.pp +however: +.ip * 3 +each element requires two pointers rather than one. +.ss doubly linked lists (list) +linked lists are the simplest of the doubly linked data structures. +they add the following functionality over the above: +.ip * 3 +they may be traversed backwards. +.pp +however: +.ip * 3 +to traverse backwards, an entry to begin the traversal and the list in +which it is contained must be specified. +.ss doubly linked tail queues (tailq) +tail queues add the following functionality: +.ip * 3 +entries can be added at the end of a list. +.ip * +they may be traversed backwards, from tail to head. +.ip * +they may be concatenated. +.pp +however: +.ip * 3 +all list insertions and removals must specify the head of the list. +.ip * +each head entry requires two pointers rather than one. +.ss doubly linked circular queues (circleq) +circular queues add the following functionality over the above: +.ip * 3 +the first and last entries are connected. +.pp +however: +.ip * 3 +the termination condition for traversal is more complex. +.sh conforming to +not in posix.1, posix.1-2001, or posix.1-2008. +present on the bsds. +.i +macros first appeared in 4.4bsd. +.sh notes +some bsds provide simpleq instead of stailq. +they are identical, but for historical reasons +they were named differently on different bsds. +stailq originated on freebsd, and simpleq originated on netbsd. +for compatibility reasons, some systems provide both sets of macros. +glibc provides both stailq and simpleq, +which are identical except for a missing simpleq equivalent to +.br stailq_concat (). +.sh see also +.br circleq (3), +.br insque (3), +.br list (3), +.br slist (3), +.br stailq (3), +.br tailq (3) +.\" .br tree (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/getutent.3 + +.\" copyright (c) 2008 linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th pthread_setcancelstate 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +pthread_setcancelstate, pthread_setcanceltype \- +set cancelability state and type +.sh synopsis +.nf +.b #include +.pp +.bi "int pthread_setcancelstate(int " state ", int *" oldstate ); +.bi "int pthread_setcanceltype(int " type ", int *" oldtype ); +.pp +compile and link with \fi\-pthread\fp. +.fi +.sh description +the +.br pthread_setcancelstate () +sets the cancelability state of the calling thread to the value +given in +.ir state . +the previous cancelability state of the thread is returned +in the buffer pointed to by +.ir oldstate . +the +.i state +argument must have one of the following values: +.tp +.b pthread_cancel_enable +the thread is cancelable. +this is the default cancelability state in all new threads, +including the initial thread. +the thread's cancelability type determines when a cancelable thread +will respond to a cancellation request. +.tp +.b pthread_cancel_disable +the thread is not cancelable. +if a cancellation request is received, +it is blocked until cancelability is enabled. +.pp +the +.br pthread_setcanceltype () +sets the cancelability type of the calling thread to the value +given in +.ir type . +the previous cancelability type of the thread is returned +in the buffer pointed to by +.ir oldtype . +the +.i type +argument must have one of the following values: +.tp +.b pthread_cancel_deferred +a cancellation request is deferred until the thread next calls +a function that is a cancellation point (see +.br pthreads (7)). +this is the default cancelability type in all new threads, +including the initial thread. +.ip +even with deferred cancellation, a +cancellation point in an asynchronous signal handler may still +be acted upon and the effect is as if it was an asynchronous +cancellation. +.tp +.b pthread_cancel_asynchronous +the thread can be canceled at any time. +(typically, +it will be canceled immediately upon receiving a cancellation request, +but the system doesn't guarantee this.) +.pp +the set-and-get operation performed by each of these functions +is atomic with respect to other threads in the process +calling the same function. +.sh return value +on success, these functions return 0; +on error, they return a nonzero error number. +.sh errors +the +.br pthread_setcancelstate () +can fail with the following error: +.tp +.b einval +invalid value for +.ir state . +.pp +the +.br pthread_setcanceltype () +can fail with the following error: +.tp +.b einval +invalid value for +.ir type . +.\" .sh versions +.\" available since glibc 2.0 +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br pthread_setcancelstate (), +.br pthread_setcanceltype () +t} thread safety t{ +mt-safe +t} +t{ +.br pthread_setcancelstate (), +.br pthread_setcanceltype () +t} async-cancel safety t{ +ac-safe +t} +.te +.hy +.ad +.sp 1 +.hy +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +for details of what happens when a thread is canceled, see +.br pthread_cancel (3). +.pp +briefly disabling cancelability is useful +if a thread performs some critical action +that must not be interrupted by a cancellation request. +beware of disabling cancelability for long periods, +or around operations that may block for long periods, +since that will render the thread unresponsive to cancellation requests. +.ss asynchronous cancelability +setting the cancelability type to +.b pthread_cancel_asynchronous +is rarely useful. +since the thread could be canceled at +.i any +time, it cannot safely reserve resources (e.g., allocating memory with +.br malloc (3)), +acquire mutexes, semaphores, or locks, and so on. +reserving resources is unsafe because the application has no way of +knowing what the state of these resources is when the thread is canceled; +that is, did cancellation occur before the resources were reserved, +while they were reserved, or after they were released? +furthermore, some internal data structures +(e.g., the linked list of free blocks managed by the +.br malloc (3) +family of functions) may be left in an inconsistent state +if cancellation occurs in the middle of the function call. +consequently, clean-up handlers cease to be useful. +.pp +functions that can be safely asynchronously canceled are called +.ir "async-cancel-safe functions" . +posix.1-2001 and posix.1-2008 require only that +.br pthread_cancel (3), +.br pthread_setcancelstate (), +and +.br pthread_setcanceltype () +be async-cancel-safe. +in general, other library functions +can't be safely called from an asynchronously cancelable thread. +.pp +one of the few circumstances in which asynchronous cancelability is useful +is for cancellation of a thread that is in a pure compute-bound loop. +.ss portability notes +the linux threading implementations permit the +.i oldstate +argument of +.br pthread_setcancelstate () +to be null, in which case the information about the previous +cancelability state is not returned to the caller. +many other implementations also permit a null +.i oldstat +argument, +.\" it looks like at least solaris, freebsd and tru64 support this. +but posix.1 does not specify this point, +so portable applications should always specify a non-null value in +.ir oldstate . +a precisely analogous set of statements applies for the +.i oldtype +argument of +.br pthread_setcanceltype (). +.sh examples +see +.br pthread_cancel (3). +.sh see also +.br pthread_cancel (3), +.br pthread_cleanup_push (3), +.br pthread_testcancel (3), +.br pthreads (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/isalpha.3 + +.\" copyright (c) 1983, 1991 the regents of the university of california. +.\" all rights reserved. +.\" +.\" %%%license_start(bsd_4_clause_ucb) +.\" redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. all advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" this product includes software developed by the university of +.\" california, berkeley and its contributors. +.\" 4. neither the name of the university nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" this software is provided by the regents and contributors ``as is'' and +.\" any express or implied warranties, including, but not limited to, the +.\" implied warranties of merchantability and fitness for a particular purpose +.\" are disclaimed. in no event shall the regents or contributors be liable +.\" for any direct, indirect, incidental, special, exemplary, or consequential +.\" damages (including, but not limited to, procurement of substitute goods +.\" or services; loss of use, data, or profits; or business interruption) +.\" however caused and on any theory of liability, whether in contract, strict +.\" liability, or tort (including negligence or otherwise) arising in any way +.\" out of the use of this software, even if advised of the possibility of +.\" such damage. +.\" %%%license_end +.\" +.\" @(#)socketpair.2 6.4 (berkeley) 3/10/91 +.\" +.\" modified 1993-07-24 by rik faith +.\" modified 1996-10-22 by eric s. raymond +.\" modified 2002-07-22 by michael kerrisk +.\" modified 2004-06-17 by michael kerrisk +.\" 2008-10-11, mtk: add description of sock_nonblock and sock_cloexec +.\" +.th socketpair 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +socketpair \- create a pair of connected sockets +.sh synopsis +.nf +.b #include +.pp +.bi "int socketpair(int " domain ", int " type ", int " protocol \ +", int " sv [2]); +.fi +.sh description +the +.br socketpair () +call creates an unnamed pair of connected sockets in the specified +.ir domain , +of the specified +.ir type , +and using the optionally specified +.ir protocol . +for further details of these arguments, see +.br socket (2). +.pp +the file descriptors used in referencing the new sockets are returned in +.i sv[0] +and +.ir sv[1] . +the two sockets are indistinguishable. +.sh return value +on success, zero is returned. +on error, \-1 is returned, +.i errno +is set to indicate the error, and +.i sv +is left unchanged +.pp +on linux (and other systems), +.br socketpair () +does not modify +.i sv +on failure. +a requirement standardizing this behavior was added in posix.1-2008 tc2. +.\" http://austingroupbugs.net/view.php?id=483 +.sh errors +.tp +.b eafnosupport +the specified address family is not supported on this machine. +.tp +.b efault +the address +.i sv +does not specify a valid part of the process address space. +.tp +.b emfile +the per-process limit on the number of open file descriptors has been reached. +.tp +.b enfile +the system-wide limit on the total number of open files has been reached. +.tp +.b eopnotsupp +the specified protocol does not support creation of socket pairs. +.tp +.b eprotonosupport +the specified protocol is not supported on this machine. +.sh conforming to +posix.1-2001, posix.1-2008, 4.4bsd. +.br socketpair () +first appeared in 4.2bsd. +it is generally portable to/from +non-bsd systems supporting clones of the bsd socket layer (including +system\ v variants). +.sh notes +on linux, the only supported domains for this call are +.b af_unix +(or synonymously, +.br af_local ) +and +.b af_tipc +.\" commit: 70b03759e9ecfae400605fa34f3d7154cccbbba3 +(since linux 4.12). +.pp +since linux 2.6.27, +.br socketpair () +supports the +.br sock_nonblock +and +.br sock_cloexec +flags in the +.i type +argument, as described in +.br socket (2). +.sh see also +.br pipe (2), +.br read (2), +.br socket (2), +.br write (2), +.br socket (7), +.br unix (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/rpc.3 + +.\" copyright (c) 2011, hewlett-packard development company, l.p. +.\" written by stephen m. cameron +.\" +.\" %%%license_start(gplv2_oneline) +.\" licensed under gnu general public license version 2 (gplv2) +.\" %%%license_end +.\" +.\" shorthand for double quote that works everywhere. +.ds q \n'34' +.th hpsa 4 2021-03-22 "linux" "linux programmer's manual" +.sh name +hpsa \- hp smart array scsi driver +.sh synopsis +.nf +modprobe hpsa [ hpsa_allow_any=1 ] +.fi +.sh description +.b hpsa +is a scsi driver for hp smart array raid controllers. +.ss options +.ir "hpsa_allow_any=1" : +this option allows the driver to attempt to operate on +any hp smart array hardware raid controller, +even if it is not explicitly known to the driver. +this allows newer hardware to work with older drivers. +typically this is used to allow installation of +operating systems from media that predates the +raid controller, though it may also be used to enable +.b hpsa +to drive older controllers that would normally be handled by the +.br cciss (4) +driver. +these older boards have not been tested and are +not supported with +.br hpsa , +and +.br cciss (4) +should still be used for these. +.ss supported hardware +the +.b hpsa +driver supports the following smart array boards: +.pp +.nf + smart array p700m + smart array p212 + smart array p410 + smart array p410i + smart array p411 + smart array p812 + smart array p712m + smart array p711m + storageworks p1210m +.fi +.pp +.\" commit 135ae6edeb51979d0998daf1357f149a7d6ebb08 +since linux 4.14, the following smart array boards are also supported: +.pp +.nf + smart array 5300 + smart array 5312 + smart array 532 + smart array 5i + smart array 6400 + smart array 6400 em + smart array 641 + smart array 642 + smart array 6i + smart array e200 + smart array e200i + smart array e200i + smart array e200i + smart array e200i + smart array e500 + smart array p400 + smart array p400i + smart array p600 + smart array p700m + smart array p800 +.fi +.ss configuration details +to configure hp smart array controllers, +use the hp array configuration utility (either +.br hpacuxe (8) +or +.br hpacucli (8)) +or the offline rom-based configuration utility (orca) +run from the smart array's option rom at boot time. +.sh files +.ss device nodes +logical drives are accessed via the scsi disk driver +.rb ( sd (4)), +tape drives via the scsi tape driver +.rb ( st (4)), +and +the raid controller via the scsi generic driver +.rb ( sg (4)), +with device nodes named +.ir /dev/sd* , +.ir /dev/st* , +and +.ir /dev/sg* , +respectively. +.ss hpsa-specific host attribute files in /sys +.tp +.i /sys/class/scsi_host/host*/rescan +this is a write-only attribute. +writing to this attribute will cause the driver to scan for +new, changed, or removed devices (e.g., hot-plugged tape drives, +or newly configured or deleted logical drives, etc.) +and notify the scsi midlayer of any changes detected. +normally a rescan is triggered automatically +by hp's array configuration utility (either the gui or the +command-line variety); +thus, for logical drive changes, the user should not +normally have to use this attribute. +this attribute may be useful when hot plugging devices like tape drives, +or entire storage boxes containing preconfigured logical drives. +.tp +.i /sys/class/scsi_host/host*/firmware_revision +this attribute contains the firmware version of the smart array. +.ip +for example: +.ip +.in +4n +.ex +# \fbcd /sys/class/scsi_host/host4\fp +# \fbcat firmware_revision\fp +7.14 +.ee +.in +.\" +.ss hpsa-specific disk attribute files in /sys +.tp +.i /sys/class/scsi_disk/c:b:t:l/device/unique_id +this attribute contains a 32 hex-digit unique id for each logical drive. +.ip +for example: +.ip +.in +4n +.ex +# \fbcd /sys/class/scsi_disk/4:0:0:0/device\fp +# \fbcat unique_id\fp +600508b1001044395355323037570f77 +.ee +.in +.tp +.i /sys/class/scsi_disk/c:b:t:l/device/raid_level +this attribute contains the raid level of each logical drive. +.ip +for example: +.ip +.in +4n +.ex +# \fbcd /sys/class/scsi_disk/4:0:0:0/device\fp +# \fbcat raid_level\fp +raid 0 +.ee +.in +.tp +.i /sys/class/scsi_disk/c:b:t:l/device/lunid +this attribute contains the 16 hex-digit (8 byte) lun id +by which a logical drive or physical device can be addressed. +.ir c : b : t : l +are the controller, bus, target, and lun of the device. +.pp +for example: +.ip +.in +4n +.ex +# \fbcd /sys/class/scsi_disk/4:0:0:0/device\fp +# \fbcat lunid\fp +0x0000004000000000 +.ee +.in +.\" +.ss supported ioctl() operations +for compatibility with applications written for the +.br cciss (4) +driver, many, but +not all of the ioctls supported by the +.br cciss (4) +driver are also supported by the +.b hpsa +driver. +the data structures used by these ioctls are described in +the linux kernel source file +.ir include/linux/cciss_ioctl.h . +.tp +.br cciss_deregdisk ", " cciss_regnewdisk ", " cciss_regnewd +these three ioctls all do exactly the same thing, +which is to cause the driver to rescan for new devices. +this does exactly the same thing as writing to the +hpsa-specific host "rescan" attribute. +.tp +.b cciss_getpciinfo +returns pci domain, bus, device, and function and "board id" (pci subsystem id). +.tp +.b cciss_getdrivver +returns driver version in three bytes encoded as: +.ip +.in +4n +.ex +(major_version << 16) | (minor_version << 8) | + (subminor_version) +.ee +.in +.tp +.br cciss_passthru ", " cciss_big_passthru +allows "bmic" and "ciss" commands to be passed through to the smart array. +these are used extensively by the hp array configuration utility, +snmp storage agents, and so on. +see +.i cciss_vol_status +at +.ur http://cciss.sf.net +.ue +for some examples. +.sh see also +.br cciss (4), +.br sd (4), +.br st (4), +.br cciss_vol_status (8), +.br hpacucli (8), +.br hpacuxe (8), +.pp +.ur http://cciss.sf.net +.ue , +and +.i documentation/scsi/hpsa.txt +and +.i documentation/abi/testing/sysfs\-bus\-pci\-devices\-cciss +in the linux kernel source tree +.\" .sh authors +.\" don brace, steve cameron, tom lawler, mike miller, scott teel +.\" and probably some other people. +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/wprintf.3 + +.\" copyright 2002 ian redfern (redferni@logica.com) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" freebsd 4.4 man pages +.\" +.\" minor additions, aeb, 2013-06-21 +.\" +.th ether_aton 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +ether_aton, ether_ntoa, ether_ntohost, ether_hostton, ether_line, +ether_ntoa_r, ether_aton_r \- ethernet address manipulation routines +.sh synopsis +.nf +.b #include +.pp +.bi "char *ether_ntoa(const struct ether_addr *" addr ); +.bi "struct ether_addr *ether_aton(const char *" asc ); +.pp +.bi "int ether_ntohost(char *" hostname ", const struct ether_addr *" addr ); +.bi "int ether_hostton(const char *" hostname ", struct ether_addr *" addr ); +.pp +.bi "int ether_line(const char *" line ", struct ether_addr *" addr , +.bi " char *" hostname ); +.pp +/* gnu extensions */ +.bi "char *ether_ntoa_r(const struct ether_addr *" addr ", char *" buf ); +.pp +.bi "struct ether_addr *ether_aton_r(const char *" asc , +.bi " struct ether_addr *" addr ); +.fi +.sh description +.br ether_aton () +converts the 48-bit ethernet host address +.i asc +from the standard hex-digits-and-colons notation into binary data in +network byte order and returns a pointer to it in a statically +allocated buffer, which subsequent calls will +overwrite. +.br ether_aton () +returns null if the address is invalid. +.pp +the +.br ether_ntoa () +function converts the ethernet host address +.i addr +given in network byte order to a string in standard +hex-digits-and-colons notation, omitting leading zeros. +the string is returned in a statically allocated buffer, +which subsequent calls will overwrite. +.pp +the +.br ether_ntohost () +function maps an ethernet address to the +corresponding hostname in +.i /etc/ethers +and returns nonzero if it cannot be found. +.pp +the +.br ether_hostton () +function maps a hostname to the +corresponding ethernet address in +.i /etc/ethers +and returns nonzero if it cannot be found. +.pp +the +.br ether_line () +function parses a line in +.i /etc/ethers +format (ethernet address followed by whitespace followed by +hostname; \(aq#\(aq introduces a comment) and returns an address +and hostname pair, or nonzero if it cannot be parsed. +the buffer pointed to by +.i hostname +must be sufficiently long, for example, have the same length as +.ir line . +.pp +the functions +.br ether_ntoa_r () +and +.br ether_aton_r () +are reentrant +thread-safe versions of +.br ether_ntoa () +and +.br ether_aton () +respectively, and do not use static buffers. +.pp +the structure +.i ether_addr +is defined in +.i +as: +.pp +.in +4n +.ex +struct ether_addr { + uint8_t ether_addr_octet[6]; +} +.ee +.in +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br ether_aton (), +.br ether_ntoa () +t} thread safety mt-unsafe +t{ +.br ether_ntohost (), +.br ether_hostton (), +.br ether_line (), +.br ether_ntoa_r (), +.br ether_aton_r () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +4.3bsd, sunos. +.sh bugs +in glibc 2.2.5 and earlier, the implementation of +.br ether_line () +.\" the fix was presumably commit c0a0f9a32c8baa6ab93d00eb42d92c02e9e146d7 +.\" which was in glibc 2.3 +is broken. +.sh see also +.br ethers (5) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man7/iso_8859-1.7 + +.so man2/clock_getres.2 + +.\" copyright (c) 2006 justin pryzby +.\" and copyright (c) 2006 michael kerrisk +.\" +.\" %%%license_start(permissive_misc) +.\" permission is hereby granted, free of charge, to any person obtaining +.\" a copy of this software and associated documentation files (the +.\" "software"), to deal in the software without restriction, including +.\" without limitation the rights to use, copy, modify, merge, publish, +.\" distribute, sublicense, and/or sell copies of the software, and to +.\" permit persons to whom the software is furnished to do so, subject to +.\" the following conditions: +.\" +.\" the above copyright notice and this permission notice shall be +.\" included in all copies or substantial portions of the software. +.\" +.\" the software is provided "as is", without warranty of any kind, +.\" express or implied, including but not limited to the warranties of +.\" merchantability, fitness for a particular purpose and noninfringement. +.\" in no event shall the authors or copyright holders be liable for any +.\" claim, damages or other liability, whether in an action of contract, +.\" tort or otherwise, arising from, out of or in connection with the +.\" software or the use or other dealings in the software. +.\" %%%license_end +.\" +.\" references: +.\" /usr/lib/gcc/i486-linux-gnu/4.1.1/include/stddef.h +.\" glibc-doc +.th offsetof 3 2020-11-01 "gnu" "linux programmer's manual" +.sh name +offsetof \- offset of a structure member +.sh synopsis +.nf +.b #include +.pp +.bi "size_t offsetof(" type ", " member ); +.fi +.sh description +the macro +.br offsetof () +returns the offset of the field +.i member +from the start of the structure +.ir type . +.pp +this macro is useful because the sizes of the fields that compose +a structure can vary across implementations, +and compilers may insert different numbers of padding +bytes between fields. +consequently, an element's offset is not necessarily +given by the sum of the sizes of the previous elements. +.pp +a compiler error will result if +.i member +is not aligned to a byte boundary +(i.e., it is a bit field). +.sh return value +.br offsetof () +returns the offset of the given +.i member +within the given +.ir type , +in units of bytes. +.sh conforming to +posix.1-2001, posix.1-2008, c89, c99. +.sh examples +on a linux/i386 system, when compiled using the default +.br gcc (1) +options, the program below produces the following output: +.pp +.in +4n +.ex +.rb "$" " ./a.out" +offsets: i=0; c=4; d=8 a=16 +sizeof(struct s)=16 +.ee +.in +.ss program source +\& +.ex +#include +#include +#include + +int +main(void) +{ + struct s { + int i; + char c; + double d; + char a[]; + }; + + /* output is compiler dependent */ + + printf("offsets: i=%zu; c=%zu; d=%zu a=%zu\en", + offsetof(struct s, i), offsetof(struct s, c), + offsetof(struct s, d), offsetof(struct s, a)); + printf("sizeof(struct s)=%zu\en", sizeof(struct s)); + + exit(exit_success); +} +.ee +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2016, oracle. all rights reserved. +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.th ioctl_ficlonerange 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +ioctl_ficlonerange, ioctl_ficlone \- share some the data of one file with another file +.sh synopsis +.nf +.br "#include " " /* definition of " ficlone* " constants */" +.b #include +.pp +.bi "int ioctl(int " dest_fd ", ficlonerange, struct file_clone_range *" arg ); +.bi "int ioctl(int " dest_fd ", ficlone, int " src_fd ); +.fi +.sh description +if a filesystem supports files sharing physical storage between multiple +files ("reflink"), this +.br ioctl (2) +operation can be used to make some of the data in the +.i src_fd +file appear in the +.i dest_fd +file by sharing the underlying storage, which is faster than making a separate +physical copy of the data. +both files must reside within the same filesystem. +if a file write should occur to a shared region, +the filesystem must ensure that the changes remain private to the file being +written. +this behavior is commonly referred to as "copy on write". +.pp +this ioctl reflinks up to +.ir src_length +bytes from file descriptor +.ir src_fd +at offset +.ir src_offset +into the file +.ir dest_fd +at offset +.ir dest_offset , +provided that both are files. +if +.ir src_length +is zero, the ioctl reflinks to the end of the source file. +this information is conveyed in a structure of +the following form: +.pp +.in +4n +.ex +struct file_clone_range { + __s64 src_fd; + __u64 src_offset; + __u64 src_length; + __u64 dest_offset; +}; +.ee +.in +.pp +clones are atomic with regards to concurrent writes, so no locks need to be +taken to obtain a consistent cloned copy. +.pp +the +.b ficlone +ioctl clones entire files. +.sh return value +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +error codes can be one of, but are not limited to, the following: +.tp +.b ebadf +.ir src_fd +is not open for reading; +.ir dest_fd +is not open for writing or is open for append-only writes; +or the filesystem which +.ir src_fd +resides on does not support reflink. +.tp +.b einval +the filesystem does not support reflinking the ranges of the given files. +this error can also appear if either file descriptor represents +a device, fifo, or socket. +disk filesystems generally require the offset and length arguments +to be aligned to the fundamental block size. +xfs and btrfs do not support +overlapping reflink ranges in the same file. +.tp +.b eisdir +one of the files is a directory and the filesystem does not support shared +regions in directories. +.tp +.b eopnotsupp +this can appear if the filesystem does not support reflinking either file +descriptor, or if either file descriptor refers to special inodes. +.tp +.b eperm +.ir dest_fd +is immutable. +.tp +.b etxtbsy +one of the files is a swap file. +swap files cannot share storage. +.tp +.b exdev +.ir dest_fd " and " src_fd +are not on the same mounted filesystem. +.sh versions +these ioctl operations first appeared in linux 4.5. +they were previously known as +.b btrfs_ioc_clone +and +.br btrfs_ioc_clone_range , +and were private to btrfs. +.sh conforming to +this api is linux-specific. +.sh notes +because a copy-on-write operation requires the allocation of new storage, the +.br fallocate (2) +operation may unshare shared blocks to guarantee that subsequent writes will +not fail because of lack of disk space. +.sh see also +.br ioctl (2) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/clog.3 + +.\" copyright (c) 2001 andries brouwer +.\" and copyright (c) 2016 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th strverscmp 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +strverscmp \- compare two version strings +.sh synopsis +.nf +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "int strverscmp(const char *" s1 ", const char *" s2 ); +.fi +.sh description +often one has files +.ir jan1 ", " jan2 ", ..., " jan9 ", " jan10 ", ..." +and it feels wrong when +.br ls (1) +orders them +.ir jan1 ", " jan10 ", ..., " jan2 ", ..., " jan9 . +.\" classical solution: "rename jan jan0 jan?" +in order to rectify this, gnu introduced the +.i \-v +option to +.br ls (1), +which is implemented using +.br versionsort (3), +which again uses +.br strverscmp (). +.pp +thus, the task of +.br strverscmp () +is to compare two strings and find the "right" order, while +.br strcmp (3) +finds only the lexicographic order. +this function does not use +the locale category +.br lc_collate , +so is meant mostly for situations +where the strings are expected to be in ascii. +.pp +what this function does is the following. +if both strings are equal, return 0. +otherwise, find the position +between two bytes with the property that before it both strings are equal, +while directly after it there is a difference. +find the largest consecutive digit strings containing (or starting at, +or ending at) this position. +if one or both of these is empty, +then return what +.br strcmp (3) +would have returned (numerical ordering of byte values). +otherwise, compare both digit strings numerically, where digit strings with +one or more leading zeros are interpreted as if they have a decimal point +in front (so that in particular digit strings with more leading zeros +come before digit strings with fewer leading zeros). +thus, the ordering is +.ir 000 ", " 00 ", " 01 ", " 010 ", " 09 ", " 0 ", " 1 ", " 9 ", " 10 . +.sh return value +the +.br strverscmp () +function returns an integer +less than, equal to, or greater than zero if +.i s1 +is found, respectively, to be earlier than, equal to, +or later than +.ir s2 . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br strverscmp () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.\" fixme: the marking is different from that in the glibc manual, +.\" which has: +.\" +.\" strverscmp: mt-safe locale +.\" +.\" glibc manual says strverscmp should have marking locale because it calls +.\" isdigit() multiple times and isdigit() uses locale variable. +.\" but isdigit() has two implementations. with different compiling conditions, +.\" we may call isdigit() in macro, then strverscmp() should not have locale +.\" problem. +.sh conforming to +this function is a gnu extension. +.sh examples +the program below can be used to demonstrate the behavior of +.br strverscmp (). +it uses +.br strverscmp () +to compare the two strings given as its command-line arguments. +an example of its use is the following: +.pp +.in +4n +.ex +$ \fb./a.out jan1 jan10\fp +jan1 < jan10 +.ee +.in +.ss program source +\& +.ex +#define _gnu_source +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + int res; + + if (argc != 3) { + fprintf(stderr, "usage: %s \en", argv[0]); + exit(exit_failure); + } + + res = strverscmp(argv[1], argv[2]); + + printf("%s %s %s\en", argv[1], + (res < 0) ? "<" : (res == 0) ? "==" : ">", argv[2]); + + exit(exit_success); +} +.ee +.sh see also +.br rename (1), +.br strcasecmp (3), +.br strcmp (3), +.br strcoll (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/posix_fadvise.2 + +.\" copyright (c) 2008 linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th pthread_attr_setstacksize 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +pthread_attr_setstacksize, pthread_attr_getstacksize \- set/get stack size +attribute in thread attributes object +.sh synopsis +.nf +.b #include +.pp +.bi "int pthread_attr_setstacksize(pthread_attr_t *" attr \ +", size_t " stacksize ); +.bi "int pthread_attr_getstacksize(const pthread_attr_t *restrict " attr , +.bi " size_t *restrict " stacksize ); +.pp +compile and link with \fi\-pthread\fp. +.fi +.sh description +the +.br pthread_attr_setstacksize () +function sets the stack size attribute of the +thread attributes object referred to by +.i attr +to the value specified in +.ir stacksize . +.pp +the stack size attribute determines the minimum size (in bytes) that +will be allocated for threads created using the thread attributes object +.ir attr . +.pp +the +.br pthread_attr_getstacksize () +function returns the stack size attribute of the +thread attributes object referred to by +.i attr +in the buffer pointed to by +.ir stacksize . +.sh return value +on success, these functions return 0; +on error, they return a nonzero error number. +.sh errors +.br pthread_attr_setstacksize () +can fail with the following error: +.tp +.b einval +the stack size is less than +.br pthread_stack_min +(16384) bytes. +.pp +on some systems, +.\" e.g., macos +.br pthread_attr_setstacksize () +can fail with the error +.b einval +if +.i stacksize +is not a multiple of the system page size. +.sh versions +these functions are provided by glibc since version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br pthread_attr_setstacksize (), +.br pthread_attr_getstacksize () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +for details on the default stack size of new threads, see +.br pthread_create (3). +.pp +a thread's stack size is fixed at the time of thread creation. +only the main thread can dynamically grow its stack. +.pp +the +.br pthread_attr_setstack (3) +function allows an application to set both the size and location +of a caller-allocated stack that is to be used by a thread. +.sh bugs +as at glibc 2.8, +if the specified +.i stacksize +is not a multiple of +.br stack_align +(16 bytes on most architectures), it may be rounded +.ir downward , +in violation of posix.1, which says that the allocated stack will +be at least +.i stacksize +bytes. +.sh examples +see +.br pthread_create (3). +.sh see also +.br getrlimit (2), +.br pthread_attr_init (3), +.br pthread_attr_setguardsize (3), +.br pthread_attr_setstack (3), +.br pthread_create (3), +.br pthreads (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 2001 andries brouwer . +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th fseeko 3 2021-03-22 "" "linux programmer's manual" +.sh name +fseeko, ftello \- seek to or report file position +.sh synopsis +.nf +.b #include +.pp +.bi "int fseeko(file *" stream ", off_t " offset ", int " whence ); +.bi "off_t ftello(file *" stream ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br fseeko (), +.br ftello (): +.nf + _file_offset_bits == 64 || _posix_c_source >= 200112l +.fi +.sh description +the +.br fseeko () +and +.br ftello () +functions are identical to +.br fseek (3) +and +.br ftell (3) +(see +.br fseek (3)), +respectively, except that the +.i offset +argument of +.br fseeko () +and the return value of +.br ftello () +is of type +.i off_t +instead of +.ir long . +.pp +on some architectures, both +.ir off_t +and +.i long +are 32-bit types, but defining +.br _file_offset_bits +with the value 64 (before including +.i any +header files) +will turn +.i off_t +into a 64-bit type. +.sh return value +on successful completion, +.br fseeko () +returns 0, while +.br ftello () +returns the current offset. +otherwise, \-1 is returned and +.i errno +is set to indicate the error. +.sh errors +see the errors in +.br fseek (3). +.sh versions +these functions are available under glibc since version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br fseeko (), +.br ftello () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, susv2. +.sh notes +the declarations of these functions can also be obtained by defining +the obsolete +.b _largefile_source +feature test macro. +.sh see also +.br fseek (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/getmntent.3 + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" iso/iec 9899:1999 +.\" +.th wcsncmp 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +wcsncmp \- compare two fixed-size wide-character strings +.sh synopsis +.nf +.b #include +.pp +.bi "int wcsncmp(const wchar_t *" s1 ", const wchar_t *" s2 ", size_t " n ); +.fi +.sh description +the +.br wcsncmp () +function is the wide-character equivalent of the +.br strncmp (3) +function. +it compares the wide-character string pointed to by +.i s1 +and the +wide-character string pointed to by +.ir s2 , +but at most +.i n +wide +characters from each string. +in each string, the comparison extends only up +to the first occurrence of a null wide character (l\(aq\e0\(aq), if any. +.sh return value +the +.br wcsncmp () +function returns zero if the wide-character strings at +.i s1 +and +.ir s2 , +truncated to at most length +.ir n , +are equal. +it returns an integer greater than zero if at the first differing position +.i i +.ri ( i +< +.ir n ), +the corresponding wide-character +.i s1[i] +is +greater than +.ir s2[i] . +it returns an integer less than zero if at the first +differing position +.i i +.ri ( i +< +.ir n ), +the corresponding +wide-character +.i s1[i] +is less than +.ir s2[i] . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br wcsncmp () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh see also +.br strncmp (3), +.br wcsncasecmp (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/sigtimedwait.2 + +#!/bin/sh +# +# unformat_parens.sh +# +# the manual pages before 2.10 format parentheses +# inconsistently. in some cases they are like: +# +# .b name() +# +# while in others they are like: +# +# .br name () +# +# this script changes instances to the latter format. +# it does not fix all such instances: some will have to be +# done manually. +# +# use the "-n" option for a dry run, in order to see what would be +# done, without actually doing it. +# +###################################################################### +# +# (c) copyright 2005 & 2013, michael kerrisk +# this program is free software; you can redistribute it and/or +# modify it under the terms of the gnu general public license +# as published by the free software foundation; either version 2 +# of the license, or (at your option) any later version. +# +# this program 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 general public license for more details +# (http://www.gnu.org/licenses/gpl-2.0.html). +# +# + +file_base="tmp.$(basename $0)" + +work_dst_file="$file_base.dst" +work_src_file="$file_base.src" + +all_files="$work_dst_file $work_src_file" + +# command-line option processing + +really_do_it=1 +while getopts "n" optname; do + case "$optname" in + n) really_do_it=0; + ;; + *) echo "unknown option: $optarg" + exit 1 + ;; + esac +done + +shift $(( $optind - 1 )) + +# only process files with > 1 line -- single-line files are link files + +for page in $(wc "$@" 2> /dev/null | awk '$1 > 1 {print $4}'| \ + grep -v '^total'); do + + cp $page $work_dst_file + + echo ">>>>>>>>>>>>>>>>>>>>>>>>>" $page "<<<<<<<<<<<<<<<<<<<<<<<<<" + + if false; then + grep '^\.i *[a-z0-9_][a-z0-9_]*()$' $page + grep '^\.b *[a-z0-9_][a-z0-9_]*()$' $page + echo '###' + grep '^\.[bir][bir] *[a-z0-9_][a-z0-9_]*()$' $page + echo '###' + grep '^\.[bir][bir] *[a-z0-9_][a-z0-9_]*() [^"]*$' $page + echo '###' + grep '()\\f[pr]' $page + echo '###' + fi + + cp $work_dst_file $work_src_file + cat $work_src_file | \ + sed \ + -e '/^\.b *[a-z0-9_][a-z0-9_]*() *$/s/^\.b/.br/' \ + -e '/^\.i *[a-z0-9_][a-z0-9_]*() *$/s/^\.i/.ir/' \ + > $work_dst_file + + cp $work_dst_file $work_src_file + cat $work_src_file | \ + sed \ + -e '/^\.[bir][bir] *[a-z0-9_][a-z0-9_]*()$/s/()/ ()/' \ + > $work_dst_file + + cp $work_dst_file $work_src_file + cat $work_src_file | \ + sed \ + -e '/^\.[bir][bir] *[a-z0-9_][a-z0-9_]*() [^"]*$/s/() / ()/' \ + > $work_dst_file + + cp $work_dst_file $work_src_file + cat $work_src_file | \ + sed \ + -e '/()\\fp/s/()\\fp/\\fp()/g' \ + -e '/()\\fr/s/()\\fr/\\fr()/g' \ + > $work_dst_file + + if ! cmp -s $page $work_dst_file; then + diff -u $page $work_dst_file + + if test $really_do_it -ne 0; then + cat $work_dst_file > $page + fi + + else + echo "### nothing changed" + fi +done + +# clean up + +rm -f $all_files +exit 0 + +.so man3/erf.3 + +.\" this page was taken from the 4.4bsd-lite cdrom (bsd license) +.\" +.\" %%%license_start(bsd_oneline_cdrom) +.\" this page was taken from the 4.4bsd-lite cdrom (bsd license) +.\" %%%license_end +.\" +.\" @(#)rpc.5 2.2 88/08/03 4.0 rpcsrc; from 1.4 87/11/27 smi; +.th rpc 5 2021-03-22 "" "linux programmer's manual" +.sh name +rpc \- rpc program number data base +.sh synopsis +.nf +.b /etc/rpc +.fi +.sh description +the +.i rpc +file contains user readable names that +can be used in place of rpc program numbers. +each line has the following information: +.pp +.pd 0 +.ip \(bu 3 +name of server for the rpc program +.ip \(bu +rpc program number +.ip \(bu +aliases +.pd +.pp +items are separated by any number of blanks and/or +tab characters. +a \(aq#\(aq indicates the beginning of a comment; characters from +the \(aq#\(aq to the end of the line are not interpreted by routines +which search the file. +.pp +here is an example of the +.i /etc/rpc +file from the sun rpc source distribution. +.pp +.in +4n +.ex +# +# rpc 88/08/01 4.0 rpcsrc; from 1.12 88/02/07 smi +# +portmapper 100000 portmap sunrpc +rstatd 100001 rstat rstat_svc rup perfmeter +rusersd 100002 rusers +nfs 100003 nfsprog +ypserv 100004 ypprog +mountd 100005 mount showmount +ypbind 100007 +walld 100008 rwall shutdown +yppasswdd 100009 yppasswd +etherstatd 100010 etherstat +rquotad 100011 rquotaprog quota rquota +sprayd 100012 spray +3270_mapper 100013 +rje_mapper 100014 +selection_svc 100015 selnsvc +database_svc 100016 +rexd 100017 rex +alis 100018 +sched 100019 +llockmgr 100020 +nlockmgr 100021 +x25.inr 100022 +statmon 100023 +status 100024 +bootparam 100026 +ypupdated 100028 ypupdate +keyserv 100029 keyserver +tfsd 100037 +nsed 100038 +nsemntd 100039 +.ee +.in +.sh files +.tp +.i /etc/rpc +rpc program number data base +.sh see also +.br getrpcent (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/chmod.2 + +.\" %%%license_start(public_domain) +.\" this page is in the public domain. - aeb +.\" %%%license_end +.\" +.th grantpt 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +grantpt \- grant access to the slave pseudoterminal +.sh synopsis +.nf +.b #include +.pp +.bi "int grantpt(int " fd ");" +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br grantpt (): +.nf + since glibc 2.24: + _xopen_source >= 500 +.\" || (_xopen_source && _xopen_source_extended) + glibc 2.23 and earlier: + _xopen_source +.fi +.sh description +the +.br grantpt () +function changes the mode and owner of the slave pseudoterminal device +corresponding to the master pseudoterminal referred to by the file descriptor +.ir fd . +the user id of the slave is set to the real uid of the calling process. +the group id is set to an unspecified value (e.g., +.ir tty ). +the mode of the slave is set to 0620 (crw\-\-w\-\-\-\-). +.pp +the behavior of +.br grantpt () +is unspecified if a signal handler is installed to catch +.b sigchld +signals. +.sh return value +when successful, +.br grantpt () +returns 0. +otherwise, it returns \-1 and sets +.i errno +to indicate the error. +.sh errors +.tp +.b eacces +the corresponding slave pseudoterminal could not be accessed. +.tp +.b ebadf +the +.i fd +argument is not a valid open file descriptor. +.tp +.b einval +the +.i fd +argument is valid but not associated with a master pseudoterminal. +.sh versions +.br grantpt () +is provided in glibc since version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br grantpt () +t} thread safety mt-safe locale +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +this is part of the unix 98 pseudoterminal support, see +.br pts (4). +.pp +many systems implement this function via a set-user-id helper binary +called "pt_chown". +on linux systems with a devpts filesystem (present since linux 2.2), +the kernel normally sets the correct ownership and permissions +for the pseudoterminal slave when the master is opened +.rb ( posix_openpt (3)), +so that nothing must be done by +.br grantpt (). +thus, no such helper binary is required +(and indeed it is configured to be absent during the +glibc build that is typical on many systems). +.sh see also +.br open (2), +.br posix_openpt (3), +.br ptsname (3), +.br unlockpt (3), +.br pts (4), +.br pty (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/atan.3 + +this package contains linux man pages for sections 1 through 8. some +more information is given in the 'man-pages-x.y.announce' file. + +homepage +======== +for information about the linux man-pages project, see +http://www.kernel.org/doc/man-pages/index.html. + +bug reports and contributing +============================ +if you have corrections and additions to suggest, see +http://www.kernel.org/doc/man-pages/contributing.html +(although there is a mirror of this repository on github, +please don't report issues via the github issue tracker!) + +for further information on contributing, see the contributing file. + +installing and uninstalling +=========================== +"make install" will copy these man pages to /usr/local/share/man/man[1-8]. + +to install to a path different from /usr/local, use +"make install prefix=/install/path". + +"make remove" or "make uninstall" will remove any man page in this +distribution from its destination. use with caution, and remember to +use "prefix" if desired, as with the "install" target. + +to install only a specific man section (mandir) such as man3, use +"make install-man3". similar syntax can be used to uninstall a +specific man section, such as man7: "make uninstall-man7". + +"make" or "make all" will perform "make uninstall" followed by "make +install". + +consider using multiple threads (at least 2) when installing +these man pages, as the makefile is optimized for multiple threads: +"make -j install". + +copyrights +========== +see the 'man-pages-x.y.announce' file. + +.so man2/clone.2 + +.so man4/pts.4 + +.so man3/log1p.3 + +.\" copyright (c) 2007, 2010 michael kerrisk +.\" and copyright (c) 1993 by thomas koenig (ig25@rz.uni-karlsruhe.de) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified sat jul 24 18:34:44 1993 by rik faith (faith@cs.unc.edu) +.\" merged readv.[23], 2002-10-17, aeb +.\" 2007-04-30 mtk, a fairly major rewrite to fix errors and +.\" add more details. +.\" 2010-11-16, mtk, added documentation of preadv() and pwritev() +.\" +.th readv 2 2021-08-27 "linux" "linux programmer's manual" +.sh name +readv, writev, preadv, pwritev, preadv2, pwritev2 \- read or write data into multiple buffers +.sh synopsis +.nf +.b #include +.pp +.bi "ssize_t readv(int " fd ", const struct iovec *" iov ", int " iovcnt ); +.bi "ssize_t writev(int " fd ", const struct iovec *" iov ", int " iovcnt ); +.pp +.bi "ssize_t preadv(int " fd ", const struct iovec *" iov ", int " iovcnt , +.bi " off_t " offset ); +.bi "ssize_t pwritev(int " fd ", const struct iovec *" iov ", int " iovcnt , +.bi " off_t " offset ); +.pp +.bi "ssize_t preadv2(int " fd ", const struct iovec *" iov ", int " iovcnt , +.bi " off_t " offset ", int " flags ); +.bi "ssize_t pwritev2(int " fd ", const struct iovec *" iov ", int " iovcnt , +.bi " off_t " offset ", int " flags ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br preadv (), +.br pwritev (): +.nf + since glibc 2.19: + _default_source + glibc 2.19 and earlier: + _bsd_source +.fi +.sh description +the +.br readv () +system call reads +.i iovcnt +buffers from the file associated with the file descriptor +.i fd +into the buffers described by +.i iov +("scatter input"). +.pp +the +.br writev () +system call writes +.i iovcnt +buffers of data described by +.i iov +to the file associated with the file descriptor +.i fd +("gather output"). +.pp +the pointer +.i iov +points to an array of +.i iovec +structures, +defined in +.i +as: +.pp +.in +4n +.ex +struct iovec { + void *iov_base; /* starting address */ + size_t iov_len; /* number of bytes to transfer */ +}; +.ee +.in +.pp +the +.br readv () +system call works just like +.br read (2) +except that multiple buffers are filled. +.pp +the +.br writev () +system call works just like +.br write (2) +except that multiple buffers are written out. +.pp +buffers are processed in array order. +this means that +.br readv () +completely fills +.i iov[0] +before proceeding to +.ir iov[1] , +and so on. +(if there is insufficient data, then not all buffers pointed to by +.i iov +may be filled.) +similarly, +.br writev () +writes out the entire contents of +.i iov[0] +before proceeding to +.ir iov[1] , +and so on. +.pp +the data transfers performed by +.br readv () +and +.br writev () +are atomic: the data written by +.\" regarding atomicity, see https://bugzilla.kernel.org/show_bug.cgi?id=10596 +.br writev () +is written as a single block that is not intermingled with output +from writes in other processes; +analogously, +.br readv () +is guaranteed to read a contiguous block of data from the file, +regardless of read operations performed in other threads or processes +that have file descriptors referring to the same open file description +(see +.br open (2)). +.ss preadv() and pwritev() +the +.br preadv () +system call combines the functionality of +.br readv () +and +.br pread (2). +it performs the same task as +.br readv (), +but adds a fourth argument, +.ir offset , +which specifies the file offset at which the input operation +is to be performed. +.pp +the +.br pwritev () +system call combines the functionality of +.br writev () +and +.br pwrite (2). +it performs the same task as +.br writev (), +but adds a fourth argument, +.ir offset , +which specifies the file offset at which the output operation +is to be performed. +.pp +the file offset is not changed by these system calls. +the file referred to by +.i fd +must be capable of seeking. +.ss preadv2() and pwritev2() +these system calls are similar to +.br preadv () +and +.br pwritev () +calls, but add a fifth argument, +.ir flags , +which modifies the behavior on a per-call basis. +.pp +unlike +.br preadv () +and +.br pwritev (), +if the +.i offset +argument is \-1, then the current file offset is used and updated. +.pp +the +.i flags +argument contains a bitwise or of zero or more of the following flags: +.tp +.br rwf_dsync " (since linux 4.7)" +.\" commit e864f39569f4092c2b2bc72c773b6e486c7e3bd9 +provide a per-write equivalent of the +.b o_dsync +.br open (2) +flag. +this flag is meaningful only for +.br pwritev2 (), +and its effect applies only to the data range written by the system call. +.tp +.br rwf_hipri " (since linux 4.6)" +high priority read/write. +allows block-based filesystems to use polling of the device, +which provides lower latency, but may use additional resources. +(currently, this feature is usable only on a file descriptor opened using the +.br o_direct +flag.) +.tp +.br rwf_sync " (since linux 4.7)" +.\" commit e864f39569f4092c2b2bc72c773b6e486c7e3bd9 +provide a per-write equivalent of the +.b o_sync +.br open (2) +flag. +this flag is meaningful only for +.br pwritev2 (), +and its effect applies only to the data range written by the system call. +.tp +.br rwf_nowait " (since linux 4.14)" +.\" commit 3239d834847627b6634a4139cf1dc58f6f137a46 +.\" commit 91f9943e1c7b6638f27312d03fe71fcc67b23571 +do not wait for data which is not immediately available. +if this flag is specified, the +.br preadv2 () +system call will return instantly if it would have to read data from +the backing storage or wait for a lock. +if some data was successfully read, it will return the number of bytes read. +if no bytes were read, it will return \-1 and set +.ir errno +to +.br eagain +(but see +.br bugs ). +currently, this flag is meaningful only for +.br preadv2 (). +.tp +.br rwf_append " (since linux 4.16)" +.\" commit e1fc742e14e01d84d9693c4aca4ab23da65811fb +provide a per-write equivalent of the +.b o_append +.br open (2) +flag. +this flag is meaningful only for +.br pwritev2 (), +and its effect applies only to the data range written by the system call. +the +.i offset +argument does not affect the write operation; +the data is always appended to the end of the file. +however, if the +.i offset +argument is \-1, the current file offset is updated. +.sh return value +on success, +.br readv (), +.br preadv (), +and +.br preadv2 () +return the number of bytes read; +.br writev (), +.br pwritev (), +and +.br pwritev2 () +return the number of bytes written. +.pp +note that it is not an error for a successful call to transfer fewer bytes +than requested (see +.br read (2) +and +.br write (2)). +.pp +on error, \-1 is returned, and \fierrno\fp is set to indicate the error. +.sh errors +the errors are as given for +.br read (2) +and +.br write (2). +furthermore, +.br preadv (), +.br preadv2 (), +.br pwritev (), +and +.br pwritev2 () +can also fail for the same reasons as +.br lseek (2). +additionally, the following errors are defined: +.tp +.b einval +the sum of the +.i iov_len +values overflows an +.i ssize_t +value. +.tp +.b einval +the vector count, +.ir iovcnt , +is less than zero or greater than the permitted maximum. +.tp +.b eopnotsupp +an unknown flag is specified in \fiflags\fp. +.sh versions +.br preadv () +and +.br pwritev () +first appeared in linux 2.6.30; library support was added in glibc 2.10. +.pp +.br preadv2 () +and +.br pwritev2 () +first appeared in linux 4.6. +library support was added in glibc 2.26. +.sh conforming to +.br readv (), +.br writev (): +posix.1-2001, posix.1-2008, +4.4bsd (these system calls first appeared in 4.2bsd). +.\" linux libc5 used \fisize_t\fp as the type of the \fiiovcnt\fp argument, +.\" and \fiint\fp as the return type. +.\" the readv/writev system calls were buggy before linux 1.3.40. +.\" (says release.libc.) +.pp +.br preadv (), +.br pwritev (): +nonstandard, but present also on the modern bsds. +.pp +.br preadv2 (), +.br pwritev2 (): +nonstandard linux extension. +.sh notes +posix.1 allows an implementation to place a limit on +the number of items that can be passed in +.ir iov . +an implementation can advertise its limit by defining +.b iov_max +in +.i +or at run time via the return value from +.ir sysconf(_sc_iov_max) . +on modern linux systems, the limit is 1024. +back in linux 2.0 days, this limit was 16. +.\" +.\" +.ss c library/kernel differences +the raw +.br preadv () +and +.br pwritev () +system calls have call signatures that differ slightly from that of the +corresponding gnu c library wrapper functions shown in the synopsis. +the final argument, +.ir offset , +is unpacked by the wrapper functions into two arguments in the system calls: +.pp +.bi " unsigned long " pos_l ", unsigned long " pos +.pp +these arguments contain, respectively, the low order and high order 32 bits of +.ir offset . +.ss historical c library/kernel differences +to deal with the fact that +.b iov_max +was so low on early versions of linux, +the glibc wrapper functions for +.br readv () +and +.br writev () +did some extra work if they detected that the underlying kernel +system call failed because this limit was exceeded. +in the case of +.br readv (), +the wrapper function allocated a temporary buffer large enough +for all of the items specified by +.ir iov , +passed that buffer in a call to +.br read (2), +copied data from the buffer to the locations specified by the +.i iov_base +fields of the elements of +.ir iov , +and then freed the buffer. +the wrapper function for +.br writev () +performed the analogous task using a temporary buffer and a call to +.br write (2). +.pp +the need for this extra effort in the glibc wrapper functions +went away with linux 2.2 and later. +however, glibc continued to provide this behavior until version 2.10. +starting with glibc version 2.9, +the wrapper functions provide this behavior only if the library detects +that the system is running a linux kernel older than version 2.6.18 +(an arbitrarily selected kernel version). +and since glibc 2.20 +(which requires a minimum linux kernel version of 2.6.32), +the glibc wrapper functions always just directly invoke the system calls. +.sh bugs +linux 5.9 and 5.10 have a bug where +.br preadv2() +with the +.br rwf_nowait +flag may return 0 even when not at end of file. +.\" see +.\" +.\" the bug was introduced in +.\" efa8480a831 fs: rwf_nowait should imply iocb_noio +.\"and fixed in +.\" 06c0444290 mm/filemap.c: generic_file_buffered_read() now uses find_get_pages_contig +.sh examples +the following code sample demonstrates the use of +.br writev (): +.pp +.in +4n +.ex +char *str0 = "hello "; +char *str1 = "world\en"; +struct iovec iov[2]; +ssize_t nwritten; + +iov[0].iov_base = str0; +iov[0].iov_len = strlen(str0); +iov[1].iov_base = str1; +iov[1].iov_len = strlen(str1); + +nwritten = writev(stdout_fileno, iov, 2); +.ee +.in +.sh see also +.br pread (2), +.br read (2), +.br write (2) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/rpc.3 + +.so man3/sqrt.3 + +.so man3/rpc.3 + +.\" this man-page is copyright (c) 1997 john s. kallal +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and author(s) of this work. +.\" %%%license_end +.\" +.\" if the you wish to distribute versions of this work under other +.\" conditions than the above, please contact the author(s) at the following +.\" for permission: +.\" +.\" john s. kallal - +.\" email: +.\" mail: 518 kerfoot farm rd, wilmington, de 19803-2444, usa +.\" phone: (302)654-5478 +.\" +.\" $id: initrd.4,v 0.9 1997/11/07 05:05:32 kallal exp kallal $ +.th initrd 4 2021-03-22 "linux" "linux programmer's manual" +.sh name +initrd \- boot loader initialized ram disk +.sh configuration +.i /dev/initrd +is a read-only block device assigned +major number 1 and minor number 250. +typically +.i /dev/initrd +is owned by +root:disk +with mode 0400 (read access by root only). +if the linux system does not have +.i /dev/initrd +already created, it can be created with the following commands: +.pp +.in +4n +.ex +mknod \-m 400 /dev/initrd b 1 250 +chown root:disk /dev/initrd +.ee +.in +.pp +also, support for both "ram disk" and "initial ram disk" +(e.g., +.br config_blk_dev_ram=y +and +.br config_blk_dev_initrd=y ) +must be compiled directly into the linux kernel to use +.ir /dev/initrd . +when using +.ir /dev/initrd , +the ram disk driver cannot be loaded as a module. +.\" +.\" +.\" +.sh description +the special file +.i /dev/initrd +is a read-only block device. +this device is a ram disk that is initialized (e.g., loaded) +by the boot loader before the kernel is started. +the kernel then can use +.ir /dev/initrd "'s" +contents for a two-phase system boot-up. +.pp +in the first boot-up phase, the kernel starts up +and mounts an initial root filesystem from the contents of +.i /dev/initrd +(e.g., ram disk initialized by the boot loader). +in the second phase, additional drivers or other modules +are loaded from the initial root device's contents. +after loading the additional modules, a new root filesystem +(i.e., the normal root filesystem) is mounted from a +different device. +.\" +.\" +.\" +.ss boot-up operation +when booting up with +.br initrd , +the system boots as follows: +.ip 1. 3 +the boot loader loads the kernel program and +.ir /dev/initrd 's +contents into memory. +.ip 2. +on kernel startup, +the kernel uncompresses and copies the contents of the device +.i /dev/initrd +onto device +.i /dev/ram0 +and then frees the memory used by +.ir /dev/initrd . +.ip 3. +the kernel then read-write mounts the device +.i /dev/ram0 +as the initial root filesystem. +.ip 4. +if the indicated normal root filesystem is also the initial +root filesystem (e.g., +.ir /dev/ram0 ) +then the kernel skips to the last step for the usual boot sequence. +.ip 5. +if the executable file +.ir /linuxrc +is present in the initial root filesystem, +.i /linuxrc +is executed with uid 0. +(the file +.i /linuxrc +must have executable permission. +the file +.i /linuxrc +can be any valid executable, including a shell script.) +.ip 6. +if +.i /linuxrc +is not executed or when +.i /linuxrc +terminates, the normal root filesystem is mounted. +(if +.i /linuxrc +exits with any filesystems mounted on the initial root +filesystem, then the behavior of the kernel is +.br unspecified . +see the notes section for the current kernel behavior.) +.ip 7. +if the normal root filesystem has a directory +.ir /initrd , +the device +.i /dev/ram0 +is moved from +.ir / +to +.ir /initrd . +otherwise, if the directory +.ir /initrd +does not exist, the device +.i /dev/ram0 +is unmounted. +(when moved from +.ir / +to +.ir /initrd , +.i /dev/ram0 +is not unmounted and therefore processes can remain running from +.ir /dev/ram0 . +if directory +.i /initrd +does not exist on the normal root filesystem +and any processes remain running from +.ir /dev/ram0 +when +.i /linuxrc +exits, the behavior of the kernel is +.br unspecified . +see the notes section for the current kernel behavior.) +.ip 8. +the usual boot sequence (e.g., invocation of +.ir /sbin/init ) +is performed on the normal root filesystem. +.\" +.\" +.\" +.ss options +the following boot loader options, when used with +.br initrd , +affect the kernel's boot-up operation: +.tp +.bi initrd= "filename" +specifies the file to load as the contents of +.ir /dev/initrd . +for +.b loadlin +this is a command-line option. +for +.b lilo +you have to use this command in the +.b lilo +configuration file +.ir /etc/lilo.config . +the filename specified with this +option will typically be a gzipped filesystem image. +.tp +.b noinitrd +this boot option disables the two-phase boot-up operation. +the kernel performs the usual boot sequence as if +.i /dev/initrd +was not initialized. +with this option, any contents of +.i /dev/initrd +loaded into memory by the boot loader contents are preserved. +this option permits the contents of +.i /dev/initrd +to be any data and need not be limited to a filesystem image. +however, device +.i /dev/initrd +is read-only and can be read only one time after system startup. +.tp +.bi root= "device-name" +specifies the device to be used as the normal root filesystem. +for +.b loadlin +this is a command-line option. +for +.b lilo +this is a boot time option or +can be used as an option line in the +.b lilo +configuration file +.ir /etc/lilo.config . +the device specified by this option must be a mountable +device having a suitable root filesystem. +.\" +.\" +.\" +.ss changing the normal root filesystem +by default, +the kernel's settings +(e.g., set in the kernel file with +.br rdev (8) +or compiled into the kernel file), +or the boot loader option setting +is used for the normal root filesystems. +for an nfs-mounted normal root filesystem, one has to use the +.b nfs_root_name +and +.b nfs_root_addrs +boot options to give the nfs settings. +for more information on nfs-mounted root see the kernel documentation file +.i documentation/filesystems/nfs/nfsroot.txt +.\" commit dc7a08166f3a5f23e79e839a8a88849bd3397c32 +(or +.i documentation/filesystems/nfsroot.txt +before linux 2.6.33). +for more information on setting the root filesystem see also the +.br lilo +and +.br loadlin +documentation. +.pp +it is also possible for the +.i /linuxrc +executable to change the normal root device. +for +.i /linuxrc +to change the normal root device, +.ir /proc +must be mounted. +after mounting +.ir /proc , +.i /linuxrc +changes the normal root device by writing into the proc files +.ir /proc/sys/kernel/real\-root\-dev , +.ir /proc/sys/kernel/nfs\-root\-name , +and +.ir /proc/sys/kernel/nfs\-root\-addrs . +for a physical root device, the root device is changed by having +.i /linuxrc +write the new root filesystem device number into +.ir /proc/sys/kernel/real\-root\-dev . +for an nfs root filesystem, the root device is changed by having +.i /linuxrc +write the nfs setting into files +.ir /proc/sys/kernel/nfs\-root\-name +and +.i /proc/sys/kernel/nfs\-root\-addrs +and then writing 0xff (e.g., the pseudo-nfs-device number) into file +.ir /proc/sys/kernel/real\-root\-dev . +for example, the following shell command line would change +the normal root device to +.ir /dev/hdb1 : +.pp +.in +4n +.ex +echo 0x365 >/proc/sys/kernel/real\-root\-dev +.ee +.in +.pp +for an nfs example, the following shell command lines would change the +normal root device to the nfs directory +.i /var/nfsroot +on a local networked nfs server with ip number 193.8.232.7 for a system with +ip number 193.8.232.2 and named "idefix": +.pp +.in +4n +.ex +echo /var/nfsroot >/proc/sys/kernel/nfs\-root\-name +echo 193.8.232.2:193.8.232.7::255.255.255.0:idefix \e + >/proc/sys/kernel/nfs\-root\-addrs +echo 255 >/proc/sys/kernel/real\-root\-dev +.ee +.in +.pp +.br note : +the use of +.i /proc/sys/kernel/real\-root\-dev +to change the root filesystem is obsolete. +see the linux kernel source file +.i documentation/admin\-guide/initrd.rst +.\" commit 9d85025b0418163fae079c9ba8f8445212de8568 +(or +.i documentation/initrd.txt +before linux 4.10) +as well as +.br pivot_root (2) +and +.br pivot_root (8) +for information on the modern method of changing the root filesystem. +.\" fixme . should this manual page describe the pivot_root mechanism? +.\" +.\" +.\" +.ss usage +the main motivation for implementing +.b initrd +was to allow for modular kernel configuration at system installation. +.pp +a possible system installation scenario is as follows: +.ip 1. 3 +the loader program boots from floppy or other media with a minimal kernel +(e.g., support for +.ir /dev/ram , +.ir /dev/initrd , +and the ext2 filesystem) and loads +.ir /dev/initrd +with a gzipped version of the initial filesystem. +.ip 2. +the executable +.i /linuxrc +determines what is needed to (1) mount the normal root filesystem +(i.e., device type, device drivers, filesystem) and (2) the +distribution media (e.g., cd-rom, network, tape, ...). +this can be done by asking the user, by auto-probing, +or by using a hybrid approach. +.ip 3. +the executable +.i /linuxrc +loads the necessary modules from the initial root filesystem. +.ip 4. +the executable +.i /linuxrc +creates and populates the root filesystem. +(at this stage the normal root filesystem does not have to be a +completed system yet.) +.ip 5. +the executable +.ir /linuxrc +sets +.ir /proc/sys/kernel/real\-root\-dev , +unmounts +.ir /proc , +the normal root filesystem and any other filesystems +it has mounted, and then terminates. +.ip 6. +the kernel then mounts the normal root filesystem. +.ip 7. +now that the filesystem is accessible and intact, +the boot loader can be installed. +.ip 8. +the boot loader is configured to load into +.i /dev/initrd +a filesystem with the set of modules that was used to bring up the system. +(e.g., device +.i /dev/ram0 +can be modified, then unmounted, and finally, the image is written from +.i /dev/ram0 +to a file.) +.ip 9. +the system is now bootable and additional installation tasks can be +performed. +.pp +the key role of +.i /dev/initrd +in the above is to reuse the configuration data during normal system operation +without requiring initial kernel selection, a large generic kernel or, +recompiling the kernel. +.pp +a second scenario is for installations where linux runs on systems with +different hardware configurations in a single administrative network. +in such cases, it may be desirable to use only a small set of kernels +(ideally only one) and to keep the system-specific part of configuration +information as small as possible. +in this case, create a common file +with all needed modules. +then, only the +.i /linuxrc +file or a file executed by +.i /linuxrc +would be different. +.pp +a third scenario is more convenient recovery disks. +because information like the location of the root filesystem +partition is not needed at boot time, the system loaded from +.i /dev/initrd +can use a dialog and/or auto-detection followed by a +possible sanity check. +.pp +last but not least, linux distributions on cd-rom may use +.b initrd +for easy installation from the cd-rom. +the distribution can use +.b loadlin +to directly load +.i /dev/initrd +from cd-rom without the need of any floppies. +the distribution could also use a +.b lilo +boot floppy and then bootstrap a bigger ram disk via +.ir /dev/initrd +from the cd-rom. +.\" +.\" +.\" +.sh files +.i /dev/initrd +.br +.i /dev/ram0 +.br +.i /linuxrc +.br +.i /initrd +.\" +.\" +.\" +.sh notes +.ip 1. 3 +with the current kernel, any filesystems that remain mounted when +.i /dev/ram0 +is moved from +.i / +to +.i /initrd +continue to be accessible. +however, the +.i /proc/mounts +entries are not updated. +.ip 2. +with the current kernel, if directory +.i /initrd +does not exist, then +.i /dev/ram0 +will +.b not +be fully unmounted if +.i /dev/ram0 +is used by any process or has any filesystem mounted on it. +if +.ir /dev/ram0 +is +.b not +fully unmounted, then +.i /dev/ram0 +will remain in memory. +.ip 3. +users of +.i /dev/initrd +should not depend on the behavior given in the above notes. +the behavior may change in future versions of the linux kernel. +.\" +.\" +.\" +.\" .sh authors +.\" the kernel code for device +.\" .br initrd +.\" was written by werner almesberger and +.\" hans lermen . +.\" the code for +.\" .br initrd +.\" was added to the baseline linux kernel in development version 1.3.73. +.sh see also +.br chown (1), +.br mknod (1), +.br ram (4), +.br freeramdisk (8), +.br rdev (8) +.pp +.i documentation/admin\-guide/initrd.rst +.\" commit 9d85025b0418163fae079c9ba8f8445212de8568 +(or +.i documentation/initrd.txt +before linux 4.10) +in the linux kernel source tree, the lilo documentation, +the loadlin documentation, the syslinux documentation +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2016 michael kerrisk +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th setjmp 3 2021-03-22 "" "linux programmer's manual" +.sh name +setjmp, sigsetjmp, longjmp, siglongjmp \- performing a nonlocal goto +.sh synopsis +.nf +.b #include +.pp +.bi "int setjmp(jmp_buf " env ); +.bi "int sigsetjmp(sigjmp_buf " env ", int " savesigs ); +.pp +.bi "noreturn void longjmp(jmp_buf " env ", int " val ); +.bi "noreturn void siglongjmp(sigjmp_buf " env ", int " val ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br setjmp (): +see notes. +.pp +.br sigsetjmp (): +.nf + _posix_c_source +.fi +.sh description +the functions described on this page are used for performing "nonlocal gotos": +transferring execution from one function to a predetermined location +in another function. +the +.br setjmp () +function dynamically establishes the target to which control +will later be transferred, and +.br longjmp () +performs the transfer of execution. +.pp +the +.br setjmp () +function saves various information about the calling environment +(typically, the stack pointer, the instruction pointer, +possibly the values of other registers and the signal mask) +in the buffer +.ir env +for later use by +.br longjmp (). +in this case, +.br setjmp () +returns 0. +.pp +the +.br longjmp () +function uses the information saved in +.ir env +to transfer control back to the point where +.br setjmp () +was called and to restore ("rewind") the stack to its state at the time of the +.br setjmp () +call. +in addition, and depending on the implementation (see notes), +the values of some other registers and the process signal mask +may be restored to their state at the time of the +.br setjmp () +call. +.pp +following a successful +.br longjmp (), +execution continues as if +.br setjmp () +had returned for a second time. +this "fake" return can be distinguished from a true +.br setjmp () +call because the "fake" return returns the value provided in +.ir val . +if the programmer mistakenly passes the value 0 in +.ir val , +the "fake" return will instead return 1. +.ss sigsetjmp() and siglongjmp() +.br sigsetjmp () +and +.br siglongjmp () +also perform nonlocal gotos, but provide predictable handling of +the process signal mask. +.pp +if, and only if, the +.i savesigs +argument provided to +.br sigsetjmp () +is nonzero, the process's current signal mask is saved in +.i env +and will be restored if a +.br siglongjmp () +is later performed with this +.ir env . +.sh return value +.br setjmp () +and +.br sigsetjmp () +return 0 when called directly; +on the "fake" return that occurs after +.br longjmp () +or +.br siglongjmp (), +the nonzero value specified in +.i val +is returned. +.pp +the +.br longjmp () +or +.br siglongjmp () +functions do not return. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br setjmp (), +.br sigsetjmp () +t} thread safety mt-safe +t{ +.br longjmp (), +.br siglongjmp () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +.br setjmp (), +.br longjmp (): +posix.1-2001, posix.1-2008, c89, c99. +.pp +.br sigsetjmp (), +.br siglongjmp (): +posix.1-2001, posix.1-2008. +.sh notes +posix does not specify whether +.br setjmp () +will save the signal mask +(to be later restored during +.br longjmp ()). +in system v it will not. +in 4.3bsd it will, and there +is a function +.br _setjmp () +that will not. +the behavior under linux depends on the glibc version +and the setting of feature test macros. +on linux with glibc versions before 2.19, +.br setjmp () +follows the system v behavior by default, +but the bsd behavior is provided if the +.br _bsd_source +feature test macro is explicitly defined +.\" so that _favor_bsd is triggered +and none of +.br _posix_source , +.br _posix_c_source , +.br _xopen_source , +.\" .br _xopen_source_extended , +.br _gnu_source , +or +.b _svid_source +is defined. +since glibc 2.19, +.ir +exposes only the system v version of +.br setjmp (). +programs that need the bsd semantics should replace calls to +.br setjmp () +with calls to +.br sigsetjmp () +with a nonzero +.i savesigs +argument. +.pp +.br setjmp () +and +.br longjmp () +can be useful for dealing with errors inside deeply nested function calls +or to allow a signal handler to pass control to +a specific point in the program, +rather than returning to the point where the handler interrupted +the main program. +in the latter case, +if you want to portably save and restore signal masks, use +.br sigsetjmp () +and +.br siglongjmp (). +see also the discussion of program readability below. +.pp +the compiler may optimize variables into registers, and +.br longjmp () +may restore the values of other registers in addition to the +stack pointer and program counter. +consequently, the values of automatic variables are unspecified +after a call to +.br longjmp () +if they meet all the following criteria: +.ip \(bu 3 +they are local to the function that made the corresponding +.br setjmp () +call; +.ip \(bu +their values are changed between the calls to +.br setjmp () +and +.br longjmp (); +and +.ip \(bu +they are not declared as +.ir volatile . +.pp +analogous remarks apply for +.br siglongjmp (). +.\" +.ss nonlocal gotos and program readability +while it can be abused, +the traditional c "goto" statement at least has the benefit that lexical cues +(the goto statement and the target label) +allow the programmer to easily perceive the flow of control. +nonlocal gotos provide no such cues: multiple +.br setjmp () +calls might employ the same +.ir jmp_buf +variable so that the content of the variable may change +over the lifetime of the application. +consequently, the programmer may be forced to perform detailed +reading of the code to determine the dynamic target of a particular +.br longjmp () +call. +(to make the programmer's life easier, each +.br setjmp () +call should employ a unique +.ir jmp_buf +variable.) +.pp +adding further difficulty, the +.br setjmp () +and +.br longjmp () +calls may not even be in the same source code module. +.pp +in summary, nonlocal gotos can make programs harder to understand +and maintain, and an alternative should be used if possible. +.\" +.ss caveats +if the function which called +.br setjmp () +returns before +.br longjmp () +is called, the behavior is undefined. +some kind of subtle or unsubtle chaos is sure to result. +.pp +if, in a multithreaded program, a +.br longjmp () +call employs an +.i env +buffer that was initialized by a call to +.br setjmp () +in a different thread, the behavior is undefined. +.\" +.\" the following statement appeared in versions up to posix.1-2008 tc1, +.\" but is set to be removed in posix.1-2008 tc2: +.\" +.\" according to posix.1, if a +.\" .br longjmp () +.\" call is performed from a nested signal handler +.\" (i.e., from a handler that was invoked in response to a signal that was +.\" generated while another signal was already in the process of being +.\" handled), the behavior is undefined. +.pp +posix.1-2008 technical corrigendum 2 adds +.\" http://austingroupbugs.net/view.php?id=516#c1195 +.br longjmp () +and +.br siglongjmp () +to the list of async-signal-safe functions. +however, the standard recommends avoiding the use of these functions +from signal handlers and goes on to point out that +if these functions are called from a signal handler that interrupted +a call to a non-async-signal-safe function (or some equivalent, +such as the steps equivalent to +.br exit (3) +that occur upon a return from the initial call to +.ir main ()), +the behavior is undefined if the program subsequently makes a call to +a non-async-signal-safe function. +the only way of avoiding undefined behavior is to ensure one of the following: +.ip * 3 +after long jumping from the signal handler, +the program does not call any non-async-signal-safe functions +and does not return from the initial call to +.ir main (). +.ip * +any signal whose handler performs a long jump must be blocked during +.i every +call to a non-async-signal-safe function and +no non-async-signal-safe functions are called after +returning from the initial call to +.ir main (). +.sh see also +.br signal (7), +.br signal\-safety (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" iso/iec 9899:1999 +.\" +.th wmemchr 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +wmemchr \- search a wide character in a wide-character array +.sh synopsis +.nf +.b #include +.pp +.bi "wchar_t *wmemchr(const wchar_t *" s ", wchar_t " c ", size_t " n ); +.fi +.sh description +the +.br wmemchr () +function is the wide-character equivalent of the +.br memchr (3) +function. +it searches the +.ir n +wide characters starting at +.i s +for +the first occurrence of the wide character +.ir c . +.sh return value +the +.br wmemchr () +function returns a pointer to the first occurrence of +.i c +among the +.ir n +wide characters starting at +.ir s , +or null if +.i c +does +not occur among these. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br wmemchr () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh see also +.br memchr (3), +.br wcschr (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) international business machines corp., 2006 +.\" +.\" %%%license_start(gplv2+_sw_3_para) +.\" this program is free software; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" this program 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" history: +.\" 2005-09-28, created by arnd bergmann +.\" 2006-06-16, revised by eduardo m. fleury +.\" 2007-07-10, some polishing by mtk +.\" 2007-09-28, updates for newer kernels by jeremy kerr +.\" +.th spu_create 2 2021-03-22 linux "linux programmer's manual" +.sh name +spu_create \- create a new spu context +.sh synopsis +.nf +.br "#include " " /* definition of " spu_* " constants */" +.br "#include " " /* definition of " sys_* " constants */" +.b #include +.pp +.bi "int syscall(sys_spu_create, const char *" pathname \ +", unsigned int " flags , +.bi " mode_t " mode ", int " neighbor_fd ); +.fi +.pp +.ir note : +glibc provides no wrapper for +.br spu_create (), +necessitating the use of +.br syscall (2). +.sh description +the +.br spu_create () +system call is used on powerpc machines that implement the +cell broadband engine architecture in order to access synergistic +processor units (spus). +it creates a new logical context for an spu in +.i pathname +and returns a file descriptor associated with it. +.i pathname +must refer to a nonexistent directory in the mount point of +the spu filesystem +.rb ( spufs ). +if +.br spu_create () +is successful, a directory is created at +.i pathname +and it is populated with the files described in +.br spufs (7). +.pp +when a context is created, +the returned file descriptor can only be passed to +.br spu_run (2), +used as the +.i dirfd +argument to the +.b *at +family of system calls (e.g., +.br openat (2)), +or closed; +other operations are not defined. +a logical spu +context is destroyed (along with all files created within the context's +.i pathname +directory) once the last reference to the context has gone; +this usually occurs when the file descriptor returned by +.br spu_create () +is closed. +.pp +the +.i mode +argument (minus any bits set in the process's +.br umask (2)) +specifies the permissions used for creating the new directory in +.br spufs . +see +.br stat (2) +for a full list of the possible +.i mode +values. +.pp +the +.i neighbor_fd +is used only when the +.b spu_create_affinity_spu +flag is specified; see below. +.pp +the +.i flags +argument can be zero or any bitwise or-ed +combination of the following constants: +.tp +.b spu_create_events_enabled +rather than using signals for reporting dma errors, use the +.i event +argument to +.br spu_run (2). +.tp +.b spu_create_gang +create an spu gang instead of a context. +(a gang is a group of spu contexts that are +functionally related to each other and which share common scheduling +parameters\(empriority and policy. +in the future, gang scheduling may be implemented causing +the group to be switched in and out as a single unit.) +.ip +a new directory will be created at the location specified by the +.i pathname +argument. +this gang may be used to hold other spu contexts, by providing +a pathname that is within the gang directory to further calls to +.br spu_create (). +.tp +.b spu_create_nosched +create a context that is not affected by the spu scheduler. +once the context is run, +it will not be scheduled out until it is destroyed by +the creating process. +.ip +because the context cannot be removed from the spu, some functionality +is disabled for +.br spu_create_nosched +contexts. +only a subset of the files will be +available in this context directory in +.br spufs . +additionally, +.br spu_create_nosched +contexts cannot dump a core file when crashing. +.ip +creating +.br spu_create_nosched +contexts requires the +.b cap_sys_nice +capability. +.tp +.b spu_create_isolate +create an isolated spu context. +isolated contexts are protected from some +ppe (powerpc processing element) +operations, +such as access to the spu local store and the npc register. +.ip +creating +.b spu_create_isolate +contexts also requires the +.b spu_create_nosched +flag. +.tp +.br spu_create_affinity_spu " (since linux 2.6.23)" +.\" commit 8e68e2f248332a9c3fd4f08258f488c209bd3e0c +create a context with affinity to another spu context. +this affinity information is used within the spu scheduling algorithm. +using this flag requires that a file descriptor referring to +the other spu context be passed in the +.i neighbor_fd +argument. +.tp +.br spu_create_affinity_mem " (since linux 2.6.23)" +.\" commit 8e68e2f248332a9c3fd4f08258f488c209bd3e0c +create a context with affinity to system memory. +this affinity information +is used within the spu scheduling algorithm. +.sh return value +on success, +.br spu_create () +returns a new file descriptor. +on failure, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eacces +the current user does not have write access to the +.br spufs (7) +mount point. +.tp +.b eexist +an spu context already exists at the given pathname. +.tp +.b efault +.i pathname +is not a valid string pointer in the +calling process's address space. +.tp +.b einval +.i pathname +is not a directory in the +.br spufs (7) +mount point, or invalid flags have been provided. +.tp +.b eloop +too many symbolic links were found while resolving +.ir pathname . +.tp +.b emfile +the per-process limit on the number of open file descriptors has been reached. +.tp +.b enametoolong +.i pathname +is too long. +.tp +.b enfile +the system-wide limit on the total number of open files has been reached. +.tp +.b enodev +an isolated context was requested, but the hardware does not support +spu isolation. +.tp +.b enoent +part of +.i pathname +could not be resolved. +.tp +.b enomem +the kernel could not allocate all resources required. +.tp +.b enospc +there are not enough spu resources available to create +a new context or the user-specific limit for the number +of spu contexts has been reached. +.tp +.b enosys +the functionality is not provided by the current system, because +either the hardware does not provide spus or the spufs module is not +loaded. +.tp +.b enotdir +a part of +.i pathname +is not a directory. +.tp +.b eperm +the +.b spu_create_nosched +flag has been given, but the user does not have the +.b cap_sys_nice +capability. +.sh files +.i pathname +must point to a location beneath the mount point of +.br spufs . +by convention, it gets mounted in +.ir /spu . +.sh versions +the +.br spu_create () +system call was added to linux in kernel 2.6.16. +.sh conforming to +this call is linux-specific and implemented only on the powerpc +architecture. +programs using this system call are not portable. +.sh notes +.br spu_create () +is meant to be used from libraries that implement a more abstract +interface to spus, not to be used from regular applications. +see +.ur http://www.bsc.es\:/projects\:/deepcomputing\:/linuxoncell/ +.ue +for the recommended libraries. +.pp +prior to the addition of the +.b spu_create_affinity_spu +flag in linux 2.6.23, the +.br spu_create () +system call took only three arguments (i.e., there was no +.i neighbor_fd +argument). +.sh examples +see +.br spu_run (2) +for an example of the use of +.br spu_create () +.sh see also +.br close (2), +.br spu_run (2), +.br capabilities (7), +.br spufs (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2011 christopher yeoh +.\" and copyright (c) 2012 mike frysinger +.\" and copyright (c) 2012 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" commit fcf634098c00dd9cd247447368495f0b79be12d1 +.\" +.th process_vm_readv 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +process_vm_readv, process_vm_writev \- transfer data between process address spaces +.sh synopsis +.nf +.b #include +.pp +.bi "ssize_t process_vm_readv(pid_t " pid , +.bi " const struct iovec *" local_iov , +.bi " unsigned long " liovcnt , +.bi " const struct iovec *" remote_iov , +.bi " unsigned long " riovcnt , +.bi " unsigned long " flags ");" +.bi "ssize_t process_vm_writev(pid_t " pid , +.bi " const struct iovec *" local_iov , +.bi " unsigned long " liovcnt , +.bi " const struct iovec *" remote_iov , +.bi " unsigned long " riovcnt , +.bi " unsigned long " flags ");" +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br process_vm_readv (), +.br process_vm_writev (): +.nf + _gnu_source +.fi +.sh description +these system calls transfer data between the address space +of the calling process ("the local process") and the process identified by +.ir pid +("the remote process"). +the data moves directly between the address spaces of the two processes, +without passing through kernel space. +.pp +the +.br process_vm_readv () +system call transfers data from the remote process to the local process. +the data to be transferred is identified by +.ir remote_iov +and +.ir riovcnt : +.ir remote_iov +is a pointer to an array describing address ranges in the process +.ir pid , +and +.ir riovcnt +specifies the number of elements in +.ir remote_iov . +the data is transferred to the locations specified by +.ir local_iov +and +.ir liovcnt : +.ir local_iov +is a pointer to an array describing address ranges in the calling process, +and +.ir liovcnt +specifies the number of elements in +.ir local_iov . +.pp +the +.br process_vm_writev () +system call is the converse of +.br process_vm_readv ()\(emit +transfers data from the local process to the remote process. +other than the direction of the transfer, the arguments +.ir liovcnt , +.ir local_iov , +.ir riovcnt , +and +.ir remote_iov +have the same meaning as for +.br process_vm_readv (). +.pp +the +.i local_iov +and +.i remote_iov +arguments point to an array of +.i iovec +structures, defined in +.ir +as: +.pp +.in +4n +.ex +struct iovec { + void *iov_base; /* starting address */ + size_t iov_len; /* number of bytes to transfer */ +}; +.ee +.in +.pp +buffers are processed in array order. +this means that +.br process_vm_readv () +completely fills +.i local_iov[0] +before proceeding to +.ir local_iov[1] , +and so on. +likewise, +.i remote_iov[0] +is completely read before proceeding to +.ir remote_iov[1] , +and so on. +.pp +similarly, +.br process_vm_writev () +writes out the entire contents of +.i local_iov[0] +before proceeding to +.ir local_iov[1] , +and it completely fills +.i remote_iov[0] +before proceeding to +.ir remote_iov[1] . +.pp +the lengths of +.i remote_iov[i].iov_len +and +.i local_iov[i].iov_len +do not have to be the same. +thus, it is possible to split a single local buffer +into multiple remote buffers, or vice versa. +.pp +the +.i flags +argument is currently unused and must be set to 0. +.pp +the values specified in the +.i liovcnt +and +.i riovcnt +arguments must be less than or equal to +.br iov_max +(defined in +.i +or accessible via the call +.ir sysconf(_sc_iov_max) ). +.\" in time, glibc might provide a wrapper that works around this limit, +.\" as is done for readv()/writev() +.pp +the count arguments and +.ir local_iov +are checked before doing any transfers. +if the counts are too big, or +.i local_iov +is invalid, +or the addresses refer to regions that are inaccessible to the local process, +none of the vectors will be processed +and an error will be returned immediately. +.pp +note, however, that these system calls do not check the memory regions +in the remote process until just before doing the read/write. +consequently, a partial read/write (see return value) +may result if one of the +.i remote_iov +elements points to an invalid memory region in the remote process. +no further reads/writes will be attempted beyond that point. +keep this in mind when attempting to read data of unknown length +(such as c strings that are null-terminated) from a remote process, +by avoiding spanning memory pages (typically 4\ kib) in a single remote +.i iovec +element. +(instead, split the remote read into two +.i remote_iov +elements and have them merge back into a single write +.i local_iov +entry. +the first read entry goes up to the page boundary, +while the second starts on the next page boundary.) +.pp +permission to read from or write to another process +is governed by a ptrace access mode +.b ptrace_mode_attach_realcreds +check; see +.br ptrace (2). +.sh return value +on success, +.br process_vm_readv () +returns the number of bytes read and +.br process_vm_writev () +returns the number of bytes written. +this return value may be less than the total number of requested bytes, +if a partial read/write occurred. +(partial transfers apply at the granularity of +.i iovec +elements. +these system calls won't perform a partial transfer that splits a single +.i iovec +element.) +the caller should check the return value to determine whether +a partial read/write occurred. +.pp +on error, \-1 is returned and +.i errno +is set to indicate the error. +.sh errors +.tp +.b efault +the memory described by +.i local_iov +is outside the caller's accessible address space. +.tp +.b efault +the memory described by +.i remote_iov +is outside the accessible address space of the process +.ir pid . +.tp +.b einval +the sum of the +.i iov_len +values of either +.i local_iov +or +.i remote_iov +overflows a +.i ssize_t +value. +.tp +.b einval +.i flags +is not 0. +.tp +.b einval +.i liovcnt +or +.i riovcnt +is too large. +.tp +.b enomem +could not allocate memory for internal copies of the +.i iovec +structures. +.tp +.b eperm +the caller does not have permission to access the address space of the process +.ir pid . +.tp +.b esrch +no process with id +.i pid +exists. +.sh versions +these system calls were added in linux 3.2. +support is provided in glibc since version 2.15. +.sh conforming to +these system calls are nonstandard linux extensions. +.sh notes +the data transfers performed by +.br process_vm_readv () +and +.br process_vm_writev () +are not guaranteed to be atomic in any way. +.pp +these system calls were designed to permit fast message passing +by allowing messages to be exchanged with a single copy operation +(rather than the double copy that would be required +when using, for example, shared memory or pipes). +.\" original user is mpi, http://www.mcs.anl.gov/research/projects/mpi/ +.\" see also some benchmarks at http://lwn.net/articles/405284/ +.\" and http://marc.info/?l=linux-mm&m=130105930902915&w=2 +.sh examples +the following code sample demonstrates the use of +.br process_vm_readv (). +it reads 20 bytes at the address 0x10000 from the process with pid 10 +and writes the first 10 bytes into +.i buf1 +and the second 10 bytes into +.ir buf2 . +.pp +.ex +#include + +int +main(void) +{ + struct iovec local[2]; + struct iovec remote[1]; + char buf1[10]; + char buf2[10]; + ssize_t nread; + pid_t pid = 10; /* pid of remote process */ + + local[0].iov_base = buf1; + local[0].iov_len = 10; + local[1].iov_base = buf2; + local[1].iov_len = 10; + remote[0].iov_base = (void *) 0x10000; + remote[0].iov_len = 20; + + nread = process_vm_readv(pid, local, 2, remote, 1, 0); + if (nread != 20) + return 1; + else + return 0; +} +.ee +.sh see also +.br readv (2), +.br writev (2) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/tgamma.3 + +.so man3/endian.3 + +.\" copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de) +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under gpl +.\" %%%license_end +.\" +.\" i had no way the check the functions out +.\" be careful +.th key_setsecret 3 2021-03-22 "" "linux programmer's manual" +.sh name +key_decryptsession, key_encryptsession, key_setsecret, key_gendes, +key_secretkey_is_set \- interfaces to rpc keyserver daemon +.sh synopsis +.nf +.b "#include " +.pp +.bi "int key_decryptsession(char *" remotename ", des_block *" deskey ); +.bi "int key_encryptsession(char *" remotename ", des_block *" deskey ); +.pp +.bi "int key_gendes(des_block *" deskey ); +.pp +.bi "int key_setsecret(char *" key ); +.b "int key_secretkey_is_set(void);" +.fi +.sh description +the functions here are used within the rpc's secure authentication +mechanism (auth_des). +there should be no need for user programs to +use this functions. +.pp +the function +.br key_decryptsession () +uses the (remote) server netname and takes the des key +for decrypting. +it uses the public key of the server and the +secret key associated with the effective uid of the calling process. +.pp +the function +.br key_encryptsession () +is the inverse of +.br key_decryptsession (). +it encrypts the des keys with the public key of the server and +the secret key associated with the effective uid of the calling process. +.pp +the function +.br key_gendes () +is used to ask the keyserver for a secure conversation key. +.pp +the function +.br key_setsecret () +is used to set the key for the effective uid of the calling process. +.pp +the function +.br key_secretkey_is_set () +can be used to determine whether a key has been +set for the effective uid of the calling process. +.sh return value +these functions return 1 on success and 0 on failure. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br key_decryptsession (), +.br key_encryptsession (), +.br key_gendes (), +.br key_setsecret (), +.br key_secretkey_is_set () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh notes +note that we talk about two types of encryption here. +one is asymmetric using a public and secret key. +the other is symmetric, the +64-bit des. +.pp +these routines were part of the linux/doors-project, abandoned by now. +.sh see also +.br crypt (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/strerror.3 + +.\" copyright (c) 1990, 1991 the regents of the university of california. +.\" all rights reserved. +.\" +.\" this code is derived from software contributed to berkeley by +.\" chris torek and the american national standards committee x3, +.\" on information processing systems. +.\" +.\" %%%license_start(bsd_4_clause_ucb) +.\" redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. all advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" this product includes software developed by the university of +.\" california, berkeley and its contributors. +.\" 4. neither the name of the university nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" this software is provided by the regents and contributors ``as is'' and +.\" any express or implied warranties, including, but not limited to, the +.\" implied warranties of merchantability and fitness for a particular purpose +.\" are disclaimed. in no event shall the regents or contributors be liable +.\" for any direct, indirect, incidental, special, exemplary, or consequential +.\" damages (including, but not limited to, procurement of substitute goods +.\" or services; loss of use, data, or profits; or business interruption) +.\" however caused and on any theory of liability, whether in contract, strict +.\" liability, or tort (including negligence or otherwise) arising in any way +.\" out of the use of this software, even if advised of the possibility of +.\" such damage. +.\" %%%license_end +.\" +.\" @(#)fflush.3 5.4 (berkeley) 6/29/91 +.\" +.\" converted for linux, mon nov 29 15:22:01 1993, faith@cs.unc.edu +.\" +.\" modified 2000-07-22 by nicolás lichtmaier +.\" modified 2001-10-16 by john levon +.\" +.th fflush 3 2021-08-27 "gnu" "linux programmer's manual" +.sh name +fflush \- flush a stream +.sh synopsis +.nf +.b #include +.pp +.bi "int fflush(file *" stream ); +.fi +.sh description +for output streams, +.br fflush () +forces a write of all user-space buffered data for the given output or update +.i stream +via the stream's underlying write function. +.pp +for input streams associated with seekable files +(e.g., disk files, but not pipes or terminals), +.br fflush () +discards any buffered data that has been fetched from the underlying file, +but has not been consumed by the application. +.pp +the open status of the stream is unaffected. +.pp +if the +.i stream +argument is null, +.br fflush () +flushes +.i all +open output streams. +.\" mtk: posix specifies that only output streams are flushed for this case. +.\" also verified for glibc by experiment. +.pp +for a nonlocking counterpart, see +.br unlocked_stdio (3). +.sh return value +upon successful completion 0 is returned. +otherwise, +.b eof +is returned and +.i errno +is set to indicate the error. +.sh errors +.tp +.b ebadf +.i stream +is not an open stream, or is not open for writing. +.pp +the function +.br fflush () +may also fail and set +.i errno +for any of the errors specified for +.br write (2). +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br fflush () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c89, c99, posix.1-2001, posix.1-2008. +.pp +posix.1-2001 did not specify the behavior for flushing of input streams, +but the behavior is specified in posix.1-2008. +.sh notes +note that +.br fflush () +flushes only the user-space buffers provided by the c library. +to ensure that the data is physically stored on disk +the kernel buffers must be flushed too, for example, with +.br sync (2) +or +.br fsync (2). +.sh see also +.br fsync (2), +.br sync (2), +.br write (2), +.br fclose (3), +.br fileno (3), +.br fopen (3), +.br fpurge (3), +.br setbuf (3), +.br unlocked_stdio (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/tzset.3 + +.so man3/xdr.3 + +.\" copyright (c) 2006 red hat, inc. all rights reserved. +.\" written by marcela maslanova +.\" and copyright 2013, michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th getunwind 2 2021-03-22 linux "linux programmer's manual" +.sh name +getunwind \- copy the unwind data to caller's buffer +.sh synopsis +.nf +.b #include +.br "#include " " /* definition of " sys_* " constants */" +.b #include +.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 +the +ia-64-specific +.br getunwind () +system call copies the kernel's call frame +unwind data into the buffer pointed to by +.i buf +and returns the size of the unwind data; +this data describes the gate page (kernel code that +is mapped into user space). +.pp +the size of the buffer +.i buf +is specified in +.ir buf_size . +the data is copied only if +.i buf_size +is greater than or equal to the size of the unwind data and +.i buf +is not null; +otherwise, no data is copied, and the call succeeds, +returning the size that would be needed to store the unwind data. +.pp +the first part of the unwind data contains an unwind table. +the rest contains the associated unwind information, in no particular order. +the unwind table contains entries of the following form: +.pp +.in +4n +.ex +u64 start; (64\-bit address of start of function) +u64 end; (64\-bit address of end of function) +u64 info; (buf\-relative offset to unwind info) +.ee +.in +.pp +an entry whose +.i start +value is zero indicates the end of the table. +for more information about the format, see the +.i ia-64 software conventions and runtime architecture +manual. +.sh return value +on success, +.br getunwind () +returns the size of the unwind data. +on error, \-1 is returned and +.i errno +is set to indicate the error. +.sh errors +.br getunwind () +fails with the error +.b efault +if the unwind info can't be stored in the space specified by +.ir buf . +.sh versions +this system call is available since linux 2.4. +.sh conforming to +this system call is linux-specific, +and is available only on the ia-64 architecture. +.sh notes +this system call has been deprecated. +the modern way to obtain the kernel's unwind data is via the +.br vdso (7). +.sh see also +.br getauxval (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1990, 1991 regents of the university of california. +.\" all rights reserved. +.\" +.\" %%%license_start(bsd_4_clause_ucb) +.\" redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. all advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" this product includes software developed by the university of +.\" california, berkeley and its contributors. +.\" 4. neither the name of the university nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" this software is provided by the regents and contributors ``as is'' and +.\" any express or implied warranties, including, but not limited to, the +.\" implied warranties of merchantability and fitness for a particular purpose +.\" are disclaimed. in no event shall the regents or contributors be liable +.\" for any direct, indirect, incidental, special, exemplary, or consequential +.\" damages (including, but not limited to, procurement of substitute goods +.\" or services; loss of use, data, or profits; or business interruption) +.\" however caused and on any theory of liability, whether in contract, strict +.\" liability, or tort (including negligence or otherwise) arising in any way +.\" out of the use of this software, even if advised of the possibility of +.\" such damage. +.\" %%%license_end +.\" +.\" @(#)stdio.3 6.5 (berkeley) 5/6/91 +.\" +.\" converted for linux, mon nov 29 16:07:22 1993, faith@cs.unc.edu +.\" modified, 2001-12-26, aeb +.\" +.th stdio 3 2021-03-22 "" "linux programmer's manual" +.sh name +stdio \- standard input/output library functions +.sh synopsis +.nf +.b #include +.pp +.bi "file *" stdin ; +.bi "file *" stdout ; +.bi "file *" stderr ; +.fi +.sh description +the standard i/o library provides a simple and efficient buffered stream +i/o interface. +input and output is mapped into logical data streams and the +physical i/o characteristics are concealed. +the functions and macros are +listed below; more information is available from the individual man pages. +.pp +a stream is associated with an external file (which may be a physical +device) by +.i opening +a file, which may involve creating a new file. +creating an existing file +causes its former contents to be discarded. +if a file can support positioning requests (such as a disk file, +as opposed to a terminal), then a +.i file position indicator +associated with the stream is positioned at the start of the file (byte +zero), unless the file is opened with append mode. +if append mode is used, +it is unspecified whether the position indicator will be placed at the +start or the end of the file. +the position indicator is maintained by +subsequent reads, writes, and positioning requests. +all input occurs as if the characters were read by successive calls to the +.br fgetc (3) +function; all output takes place as if all characters were written by +successive calls to the +.br fputc (3) +function. +.pp +a file is disassociated from a stream by +.i closing +the file. +output streams are flushed (any unwritten buffer contents are +transferred to the host environment) before the stream is disassociated from +the file. +the value of a pointer to a +.i file +object is indeterminate after a file is closed (garbage). +.pp +a file may be subsequently reopened, by the same or another program +execution, and its contents reclaimed or modified (if it can be +repositioned at the start). +if the main function returns to its original +caller, or the +.br exit (3) +function is called, all open files are closed (hence all output streams are +flushed) before program termination. +other methods of program termination, +such as +.br abort (3) +do not bother about closing files properly. +.pp +at program startup, three text streams are predefined and need not be +opened explicitly: +.i standard input +(for reading conventional input), +.i standard output +(for writing conventional output), and +.i standard error +(for writing diagnostic output). +these streams are abbreviated +.ir stdin , +.ir stdout , +and +.ir stderr . +when opened, the standard error stream is not fully buffered; the standard +input and output streams are fully buffered if and only if the streams do +not refer to an interactive device. +.pp +output streams that refer to terminal devices are always line buffered by +default; pending output to such streams is written automatically whenever +an input stream that refers to a terminal device is read. +in cases where a +large amount of computation is done after printing part of a line on an +output terminal, it is necessary to +.br fflush (3) +the standard output before going off and computing so that the output will +appear. +.pp +the +.i stdio +library is a part of the library +.b libc +and routines are automatically loaded as needed by +.br cc (1). +the +synopsis +sections of the following manual pages indicate which include files are to +be used, what the compiler declaration for the function looks like and +which external variables are of interest. +.pp +the following are defined as macros; these names may not be reused without +first removing their current definitions with +.br #undef : +.br bufsiz , +.br eof , +.br filename_max , +.br fopen_max , +.br l_cuserid , +.br l_ctermid , +.br l_tmpnam , +.br null , +.br seek_end , +.br seek_set , +.br seek_cur , +.br tmp_max , +.br clearerr , +.br feof , +.br ferror , +.br fileno , +.\" not on linux: .br fropen , +.\" not on linux: .br fwopen , +.br getc , +.br getchar , +.br putc , +.br putchar , +.br stderr , +.br stdin , +.br stdout . +function versions of the macro functions +.br feof , +.br ferror , +.br clearerr , +.br fileno , +.br getc , +.br getchar , +.br putc , +and +.b putchar +exist and will be used if the macros definitions are explicitly removed. +.ss list of functions +.nh +.ad l +.ts +; +lb lbx +l l. +function description +_ +\fbclearerr\fp(3) t{ +check and reset stream status +t} +\fbfclose\fp(3) t{ +close a stream +t} +\fbfdopen\fp(3) t{ +stream open functions +t} +\fbfeof\fp(3) t{ +check and reset stream status +t} +\fbferror\fp(3) t{ +check and reset stream status +t} +\fbfflush\fp(3) t{ +flush a stream +t} +\fbfgetc\fp(3) t{ +get next character or word from input stream +t} +\fbfgetpos\fp(3) t{ +reposition a stream +t} +\fbfgets\fp(3) t{ +get a line from a stream +t} +\fbfileno\fp(3) t{ +return the integer descriptor of the argument stream +t} +\fbfopen\fp(3) t{ +stream open functions +t} +\fbfprintf\fp(3) t{ +formatted output conversion +t} +\fbfpurge\fp(3) t{ +flush a stream +t} +\fbfputc\fp(3) t{ +output a character or word to a stream +t} +\fbfputs\fp(3) t{ +output a line to a stream +t} +\fbfread\fp(3) t{ +binary stream input/output +t} +\fbfreopen\fp(3) t{ +stream open functions +t} +\fbfscanf\fp(3) t{ +input format conversion +t} +\fbfseek\fp(3) t{ +reposition a stream +t} +\fbfsetpos\fp(3) t{ +reposition a stream +t} +\fbftell\fp(3) t{ +reposition a stream +t} +\fbfwrite\fp(3) t{ +binary stream input/output +t} +\fbgetc\fp(3) t{ +get next character or word from input stream +t} +\fbgetchar\fp(3) t{ +get next character or word from input stream +t} +\fbgets\fp(3) t{ +get a line from a stream +t} +\fbgetw\fp(3) t{ +get next character or word from input stream +t} +\fbmktemp\fp(3) t{ +make temporary filename (unique) +t} +\fbperror\fp(3) t{ +system error messages +t} +\fbprintf\fp(3) t{ +formatted output conversion +t} +\fbputc\fp(3) t{ +output a character or word to a stream +t} +\fbputchar\fp(3) t{ +output a character or word to a stream +t} +\fbputs\fp(3) t{ +output a line to a stream +t} +\fbputw\fp(3) t{ +output a character or word to a stream +t} +\fbremove\fp(3) t{ +remove directory entry +t} +\fbrewind\fp(3) t{ +reposition a stream +t} +\fbscanf\fp(3) t{ +input format conversion +t} +\fbsetbuf\fp(3) t{ +stream buffering operations +t} +\fbsetbuffer\fp(3) t{ +stream buffering operations +t} +\fbsetlinebuf\fp(3) t{ +stream buffering operations +t} +\fbsetvbuf\fp(3) t{ +stream buffering operations +t} +\fbsprintf\fp(3) t{ +formatted output conversion +t} +\fbsscanf\fp(3) t{ +input format conversion +t} +\fbstrerror\fp(3) t{ +system error messages +t} +\fbsys_errlist\fp(3) t{ +system error messages +t} +\fbsys_nerr\fp(3) t{ +system error messages +t} +\fbtempnam\fp(3) t{ +temporary file routines +t} +\fbtmpfile\fp(3) t{ +temporary file routines +t} +\fbtmpnam\fp(3) t{ +temporary file routines +t} +\fbungetc\fp(3) t{ +un-get character from input stream +t} +\fbvfprintf\fp(3) t{ +formatted output conversion +t} +\fbvfscanf\fp(3) t{ +input format conversion +t} +\fbvprintf\fp(3) t{ +formatted output conversion +t} +\fbvscanf\fp(3) t{ +input format conversion +t} +\fbvsprintf\fp(3) t{ +formatted output conversion +t} +\fbvsscanf\fp(3) t{ +input format conversion +t} +.te +.ad +.hy +.sh conforming to +the +.i stdio +library conforms to c89. +.sh see also +.br close (2), +.br open (2), +.br read (2), +.br write (2), +.br stdout (3), +.br unlocked_stdio (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2005, 2008, michael kerrisk +.\" (a few fragments remain from an earlier (1992) version by +.\" drew eckhardt .) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified by michael haardt +.\" modified 1993-07-23 by rik faith +.\" modified 1996-10-22 by eric s. raymond +.\" modified 2004-06-17 by michael kerrisk +.\" modified 2005, mtk: added an example program +.\" modified 2008-01-09, mtk: rewrote description; minor additions +.\" to example text. +.\" 2008-10-10, mtk: add description of pipe2() +.\" +.th pipe 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +pipe, pipe2 \- create pipe +.sh synopsis +.nf +.b #include +.pp +.bi "int pipe(int " pipefd [2]); +.pp +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.br "#include " " /* definition of " o_* " constants */" +.b #include +.pp +.bi "int pipe2(int " pipefd "[2], int " flags ); +.pp +/* on alpha, ia-64, mips, superh, and sparc/sparc64, pipe() has the + following prototype; see notes */ +.pp +.b #include +.pp +.b struct fd_pair { +.b " long fd[2];" +.b "};" +.b struct fd_pair pipe(void); +.fi +.sh description +.br pipe () +creates a pipe, a unidirectional data channel that +can be used for interprocess communication. +the array +.ir pipefd +is used to return two file descriptors referring to the ends of the pipe. +.ir pipefd[0] +refers to the read end of the pipe. +.ir pipefd[1] +refers to the write end of the pipe. +data written to the write end of the pipe is buffered by the kernel +until it is read from the read end of the pipe. +for further details, see +.br pipe (7). +.pp +if +.ir flags +is 0, then +.br pipe2 () +is the same as +.br pipe (). +the following values can be bitwise ored in +.ir flags +to obtain different behavior: +.tp +.b o_cloexec +set the close-on-exec +.rb ( fd_cloexec ) +flag on the two new file descriptors. +see the description of the same flag in +.br open (2) +for reasons why this may be useful. +.tp +.br o_direct " (since linux 3.4)" +.\" commit 9883035ae7edef3ec62ad215611cb8e17d6a1a5d +create a pipe that performs i/o in "packet" mode. +each +.br write (2) +to the pipe is dealt with as a separate packet, and +.br read (2)s +from the pipe will read one packet at a time. +note the following points: +.rs +.ip * 3 +writes of greater than +.br pipe_buf +bytes (see +.br pipe (7)) +will be split into multiple packets. +the constant +.br pipe_buf +is defined in +.ir . +.ip * +if a +.br read (2) +specifies a buffer size that is smaller than the next packet, +then the requested number of bytes are read, +and the excess bytes in the packet are discarded. +specifying a buffer size of +.br pipe_buf +will be sufficient to read the largest possible packets +(see the previous point). +.ip * +zero-length packets are not supported. +(a +.br read (2) +that specifies a buffer size of zero is a no-op, and returns 0.) +.re +.ip +older kernels that do not support this flag will indicate this via an +.b einval +error. +.ip +since linux 4.5, +.\" commit 0dbf5f20652108106cb822ad7662c786baaa03ff +.\" fixme . but, it is not possible to specify o_direct when opening a fifo +it is possible to change the +.b o_direct +setting of a pipe file descriptor using +.br fcntl (2). +.tp +.b o_nonblock +set the +.br o_nonblock +file status flag on the open file descriptions +referred to by the new file descriptors. +using this flag saves extra calls to +.br fcntl (2) +to achieve the same result. +.sh return value +on success, zero is returned. +on error, \-1 is returned, +.i errno +is set to indicate the error, and +.i pipefd +is left unchanged. +.pp +on linux (and other systems), +.br pipe () +does not modify +.i pipefd +on failure. +a requirement standardizing this behavior was added in posix.1-2008 tc2. +.\" http://austingroupbugs.net/view.php?id=467 +the linux-specific +.br pipe2 () +system call +likewise does not modify +.i pipefd +on failure. +.sh errors +.tp +.b efault +.i pipefd +is not valid. +.tp +.b einval +.rb ( pipe2 ()) +invalid value in +.ir flags . +.tp +.b emfile +the per-process limit on the number of open file descriptors has been reached. +.tp +.b enfile +the system-wide limit on the total number of open files has been reached. +.tp +.b enfile +the user hard limit on memory that can be allocated for pipes +has been reached and the caller is not privileged; see +.br pipe (7). +.sh versions +.br pipe2 () +was added to linux in version 2.6.27; +glibc support is available starting with +version 2.9. +.sh conforming to +.br pipe (): +posix.1-2001, posix.1-2008. +.pp +.br pipe2 () +is linux-specific. +.sh notes +.\" see http://math-atlas.sourceforge.net/devel/assembly/64.psabi.1.33.ps.z +.\" for example, section 3.2.1 "registers and the stack frame". +the system v abi on some architectures allows the use of more than one register +for returning multiple values; several architectures +(namely, alpha, ia-64, mips, superh, and sparc/sparc64) +(ab)use this feature in order to implement the +.br pipe () +system call in a functional manner: +the call doesn't take any arguments and returns +a pair of file descriptors as the return value on success. +the glibc +.br pipe () +wrapper function transparently deals with this. +see +.br syscall (2) +for information regarding registers used for storing second file descriptor. +.sh examples +.\" fork.2 refers to this example program. +the following program creates a pipe, and then +.br fork (2)s +to create a child process; +the child inherits a duplicate set of file +descriptors that refer to the same pipe. +after the +.br fork (2), +each process closes the file descriptors that it doesn't need for the pipe +(see +.br pipe (7)). +the parent then writes the string contained in the program's +command-line argument to the pipe, +and the child reads this string a byte at a time from the pipe +and echoes it on standard output. +.ss program source +.ex +#include +#include +#include +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + int pipefd[2]; + pid_t cpid; + char buf; + + if (argc != 2) { + fprintf(stderr, "usage: %s \en", argv[0]); + exit(exit_failure); + } + + if (pipe(pipefd) == \-1) { + perror("pipe"); + exit(exit_failure); + } + + cpid = fork(); + if (cpid == \-1) { + perror("fork"); + exit(exit_failure); + } + + if (cpid == 0) { /* child reads from pipe */ + close(pipefd[1]); /* close unused write end */ + + while (read(pipefd[0], &buf, 1) > 0) + write(stdout_fileno, &buf, 1); + + write(stdout_fileno, "\en", 1); + close(pipefd[0]); + _exit(exit_success); + + } else { /* parent writes argv[1] to pipe */ + close(pipefd[0]); /* close unused read end */ + write(pipefd[1], argv[1], strlen(argv[1])); + close(pipefd[1]); /* reader will see eof */ + wait(null); /* wait for child */ + exit(exit_success); + } +} +.ee +.sh see also +.br fork (2), +.br read (2), +.br socketpair (2), +.br splice (2), +.br tee (2), +.br vmsplice (2), +.br write (2), +.br popen (3), +.br pipe (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/xdr.3 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sun jul 25 11:01:58 1993 by rik faith (faith@cs.unc.edu) +.\" modified 2001-11-13, aeb +.\" modified 2004-12-01 mtk and martin schulze +.\" +.th tzset 3 2021-03-22 "" "linux programmer's manual" +.sh name +tzset, tzname, timezone, daylight \- initialize time conversion information +.sh synopsis +.nf +.b #include +.pp +.b void tzset(void); +.pp +.bi "extern char *" tzname [2]; +.bi "extern long " timezone ; +.bi "extern int " daylight ; +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br tzset (): +.nf + _posix_c_source +.fi +.pp +.ir tzname : +.nf + _posix_c_source +.fi +.pp +.ir timezone , +.ir daylight : +.nf + _xopen_source + || /* glibc since 2.19: */ _default_source + || /* glibc <= 2.19: */ _svid_source +.fi +.sh description +the +.br tzset () +function initializes the \fitzname\fp variable from the +.b tz +environment variable. +this function is automatically called by the +other time conversion functions that depend on the timezone. +in a system-v-like environment, it will also set the variables \fitimezone\fp +(seconds west of utc) and \fidaylight\fp (to 0 if this timezone does not +have any daylight saving time rules, or to nonzero if there is a time, +past, present, or future when daylight saving time applies). +.pp +if the +.b tz +variable does not appear in the environment, the system timezone is used. +the system timezone is configured by copying, or linking, a file in the +.br tzfile (5) +format to +.ir /etc/localtime . +a timezone database of these files may be located in the system +timezone directory (see the \fbfiles\fp section below). +.pp +if the +.b tz +variable does appear in the environment, but its value is empty, +or its value cannot be interpreted using any of the formats specified +below, then coordinated universal time (utc) is used. +.pp +the value of +.b tz +can be one of two formats. +the first format is a string of characters that directly represent the +timezone to be used: +.pp +.in +4n +.ex +.ir "std offset" [ dst [ offset ][, start [ /time ], end [ /time ]]] +.ee +.in +.pp +there are no spaces in the specification. +the \fistd\fp string specifies an abbreviation for the timezone and must be +three or more alphabetic characters. +when enclosed between the less-than (<) and greater-than (>) signs, the +characters set is expanded to include the plus (+) sign, the minus (-) +sign, and digits. +the \fioffset\fp string immediately +follows \fistd\fp and specifies the time value to be added to the local +time to get coordinated universal time (utc). +the \fioffset\fp is positive +if the local timezone is west of the prime meridian and negative if it is +east. +the hour must be between 0 and 24, and the minutes and seconds 00 and 59: +.pp +.in +4n +.ex +.ri [ + | \- ] hh [ :mm [ :ss ]] +.ee +.in +.pp +the \fidst\fp string and \fioffset\fp specify the name and offset for the +corresponding daylight saving timezone. +if the offset is omitted, +it defaults to one hour ahead of standard time. +.pp +the \fistart\fp field specifies when daylight saving time goes into +effect and the \fiend\fp field specifies when the change is made back to +standard time. +these fields may have the following formats: +.tp +j\fin\fp +this specifies the julian day with \fin\fp between 1 and 365. +leap days are not counted. +in this format, february 29 can't be represented; +february 28 is day 59, and march 1 is always day 60. +.tp +.i n +this specifies the zero-based julian day with \fin\fp between 0 and 365. +february 29 is counted in leap years. +.tp +m\fim\fp.\fiw\fp.\fid\fp +this specifies day \fid\fp (0 <= \fid\fp <= 6) of week \fiw\fp +(1 <= \fiw\fp <= 5) of month \fim\fp (1 <= \fim\fp <= 12). +week 1 is +the first week in which day \fid\fp occurs and week 5 is the last week +in which day \fid\fp occurs. +day 0 is a sunday. +.pp +the \fitime\fp fields specify when, in the local time currently in effect, +the change to the other time occurs. +if omitted, the default is 02:00:00. +.pp +here is an example for new zealand, +where the standard time (nzst) is 12 hours ahead of utc, +and daylight saving time (nzdt), 13 hours ahead of utc, +runs from the first sunday in october to the third sunday in march, +and the changeovers happen at the default time of 02:00:00: +.pp +.in +4n +.ex +tz="nzst\-12:00:00nzdt\-13:00:00,m10.1.0,m3.3.0" +.ee +.in +.pp +the second format specifies that the timezone information should be read +from a file: +.pp +.in +4n +.ex +:[filespec] +.ee +.in +.pp +if the file specification \fifilespec\fp is omitted, or its value cannot +be interpreted, then coordinated universal time (utc) is used. +if \fifilespec\fp is given, it specifies another +.br tzfile (5)-format +file to read the timezone information from. +if \fifilespec\fp does not begin with a \(aq/\(aq, the file specification is +relative to the system timezone directory. +if the colon is omitted each +of the above \fbtz\fp formats will be tried. +.pp +here's an example, once more for new zealand: +.pp +.in +4n +.ex +tz=":pacific/auckland" +.ee +.in +.sh environment +.tp +.b tz +if this variable is set its value takes precedence over the system +configured timezone. +.tp +.b tzdir +if this variable is set its value takes precedence over the system +configured timezone database directory path. +.sh files +.tp +.i /etc/localtime +the system timezone file. +.tp +.i /usr/share/zoneinfo/ +the system timezone database directory. +.tp +.i /usr/share/zoneinfo/posixrules +when a tz string includes a dst timezone without anything following it, +then this file is used for the start/end rules. +it is in the +.br tzfile (5) +format. +by default, the zoneinfo makefile hard links it to the +.ir america/new_york " tzfile." +.pp +above are the current standard file locations, but they are +configurable when glibc is compiled. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br tzset () +t} thread safety mt-safe env locale +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, svr4, 4.3bsd. +.sh notes +4.3bsd had a function +.bi "char *timezone(" zone ", " dst ) +that returned the +name of the timezone corresponding to its first argument (minutes +west of utc). +if the second argument was 0, the standard name was used, +otherwise the daylight saving time version. +.sh see also +.br date (1), +.br gettimeofday (2), +.br time (2), +.br ctime (3), +.br getenv (3), +.br tzfile (5) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2006, 2008 by michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th core 5 2021-03-22 "linux" "linux programmer's manual" +.sh name +core \- core dump file +.sh description +the default action of certain signals is to cause a process to terminate +and produce a +.ir "core dump file" , +a file containing an image of the process's memory at +the time of termination. +this image can be used in a debugger (e.g., +.br gdb (1)) +to inspect the state of the program at the time that it terminated. +a list of the signals which cause a process to dump core can be found in +.br signal (7). +.pp +a process can set its soft +.b rlimit_core +resource limit to place an upper limit on the size of the core dump file +that will be produced if it receives a "core dump" signal; see +.br getrlimit (2) +for details. +.pp +there are various circumstances in which a core dump file is +not produced: +.ip * 3 +the process does not have permission to write the core file. +(by default, the core file is called +.ir core +or +.ir core.pid , +where +.i pid +is the id of the process that dumped core, +and is created in the current working directory. +see below for details on naming.) +writing the core file fails if the directory in which +it is to be created is not writable, +or if a file with the same name exists and +is not writable +or is not a regular file +(e.g., it is a directory or a symbolic link). +.ip * +a (writable, regular) file with the same name as would be used for the +core dump already exists, but there is more than one hard link to that +file. +.ip * +the filesystem where the core dump file would be created is full; +or has run out of inodes; or is mounted read-only; +or the user has reached their quota for the filesystem. +.ip * +the directory in which the core dump file is to be created does +not exist. +.ip * +the +.b rlimit_core +(core file size) or +.b rlimit_fsize +(file size) resource limits for the process are set to zero; see +.br getrlimit (2) +and the documentation of the shell's +.i ulimit +command +.ri ( limit +in +.br csh (1)). +.ip * +the binary being executed by the process does not have read +permission enabled. +(this is a security measure to +ensure that an executable whose contents are not readable +does not produce a\(empossibly readable\(emcore dump containing +an image of the executable.) +.ip * +the process is executing a set-user-id (set-group-id) program +that is owned by a user (group) other than the real user (group) +id of the process, +or the process is executing a program that has file capabilities (see +.br capabilities (7)). +(however, see the description of the +.br prctl (2) +.b pr_set_dumpable +operation, and the description of the +.i /proc/sys/fs/suid_dumpable +.\" fixme . perhaps relocate discussion of /proc/sys/fs/suid_dumpable +.\" and pr_set_dumpable to this page? +file in +.br proc (5).) +.ip * +.i /proc/sys/kernel/core_pattern +is empty and +.i /proc/sys/kernel/core_uses_pid +contains the value 0. +(these files are described below.) +note that if +.i /proc/sys/kernel/core_pattern +is empty and +.i /proc/sys/kernel/core_uses_pid +contains the value 1, +core dump files will have names of the form +.ir .pid , +and such files are hidden unless one uses the +.br ls (1) +.i \-a +option. +.ip * +(since linux 3.7) +.\" commit 046d662f481830e652ac34cd112249adde16452a +the kernel was configured without the +.br config_coredump +option. +.pp +in addition, +a core dump may exclude part of the address space of the process if the +.br madvise (2) +.b madv_dontdump +flag was employed. +.pp +on systems that employ +.br systemd (1) +as the +.i init +framework, core dumps may instead be placed in a location determined by +.br systemd (1). +see below for further details. +.\" +.ss naming of core dump files +by default, a core dump file is named +.ir core , +but the +.i /proc/sys/kernel/core_pattern +file (since linux 2.6 and 2.4.21) +can be set to define a template that is used to name core dump files. +the template can contain % specifiers which are substituted +by the following values when a core file is created: +.pp +.rs 4 +.pd 0 +.tp 4 +%% +a single % character. +.tp +%c +core file size soft resource limit of crashing process (since linux 2.6.24). +.tp +%d +.\" added in git commit 12a2b4b2241e318b4f6df31228e4272d2c2968a1 +dump mode\(emsame as value returned by +.br prctl (2) +.b pr_get_dumpable +(since linux 3.7). +.tp +%e +the process or thread's +.i comm +value, which typically is the same as the executable filename +(without path prefix, and truncated to a maximum of 15 characters), +but may have been modified to be something different; +see the discussion of +.i /proc/[pid]/comm +and +.i /proc/[pid]/task/[tid]/comm +in +.br proc (5). +.tp +%e +pathname of executable, +with slashes (\(aq/\(aq) replaced by exclamation marks (\(aq!\(aq) +(since linux 3.0). +.tp +%g +numeric real gid of dumped process. +.tp +%h +hostname (same as \finodename\fp returned by \fbuname\fp(2)). +.tp +%i +tid of thread that triggered core dump, +as seen in the pid namespace in which the thread resides +.\" commit b03023ecbdb76c1dec86b41ed80b123c22783220 +(since linux 3.18). +.tp +%i +tid of thread that triggered core dump, as seen in the initial pid namespace +.\" commit b03023ecbdb76c1dec86b41ed80b123c22783220 +(since linux 3.18). +.tp +%p +pid of dumped process, +as seen in the pid namespace in which the process resides. +.tp +%p +.\" added in git commit 65aafb1e7484b7434a0c1d4c593191ebe5776a2f +pid of dumped process, as seen in the initial pid namespace +(since linux 3.12). +.tp +%s +number of signal causing dump. +.tp +%t +time of dump, expressed as seconds since the +epoch, 1970-01-01 00:00:00 +0000 (utc). +.tp +%u +numeric real uid of dumped process. +.pd +.re +.pp +a single % at the end of the template is dropped from the +core filename, as is the combination of a % followed by any +character other than those listed above. +all other characters in the template become a literal +part of the core filename. +the template may include \(aq/\(aq characters, which are interpreted +as delimiters for directory names. +the maximum size of the resulting core filename is 128 bytes (64 bytes +in kernels before 2.6.19). +the default value in this file is "core". +for backward compatibility, if +.i /proc/sys/kernel/core_pattern +does not include +.i %p +and +.i /proc/sys/kernel/core_uses_pid +(see below) +is nonzero, then .pid will be appended to the core filename. +.pp +paths are interpreted according to the settings that are active for the +crashing process. +that means the crashing process's mount namespace (see +.br mount_namespaces (7)), +its current working directory (found via +.br getcwd (2)), +and its root directory (see +.br chroot (2)). +.pp +since version 2.4, linux has also provided +a more primitive method of controlling +the name of the core dump file. +if the +.i /proc/sys/kernel/core_uses_pid +file contains the value 0, then a core dump file is simply named +.ir core . +if this file contains a nonzero value, then the core dump file includes +the process id in a name of the form +.ir core.pid . +.pp +since linux 3.6, +.\" 9520628e8ceb69fa9a4aee6b57f22675d9e1b709 +if +.i /proc/sys/fs/suid_dumpable +is set to 2 ("suidsafe"), the pattern must be either an absolute pathname +(starting with a leading \(aq/\(aq character) or a pipe, as defined below. +.ss piping core dumps to a program +since kernel 2.6.19, linux supports an alternate syntax for the +.i /proc/sys/kernel/core_pattern +file. +if the first character of this file is a pipe symbol (\fb|\fp), +then the remainder of the line is interpreted as the command-line for +a user-space program (or script) that is to be executed. +.pp +since kernel 5.3.0, +.\" commit 315c69261dd3fa12dbc830d4fa00d1fad98d3b03 +the pipe template is split on spaces into an argument list +.i before +the template parameters are expanded. +in earlier kernels, the template parameters are expanded first and +the resulting string is split on spaces into an argument list. +this means that in earlier kernels executable names added by the +.i %e +and +.i %e +template parameters could get split into multiple arguments. +so the core dump handler needs to put the executable names as the last +argument and ensure it joins all parts of the executable name using spaces. +executable names with multiple spaces in them are not correctly represented +in earlier kernels, +meaning that the core dump handler needs to use mechanisms to find +the executable name. +.pp +instead of being written to a file, the core dump is given as +standard input to the program. +note the following points: +.ip * 3 +the program must be specified using an absolute pathname (or a +pathname relative to the root directory, \fi/\fp), +and must immediately follow the '|' character. +.ip * +the command-line arguments can include any of +the % specifiers listed above. +for example, to pass the pid of the process that is being dumped, specify +.i %p +in an argument. +.ip * +the process created to run the program runs as user and group +.ir root . +.ip * +running as +.i root +does not confer any exceptional security bypasses. +namely, lsms (e.g., selinux) are still active and may prevent the handler +from accessing details about the crashed process via +.ir /proc/[pid] . +.ip * +the program pathname is interpreted with respect to the initial mount namespace +as it is always executed there. +it is not affected by the settings +(e.g., root directory, mount namespace, current working directory) +of the crashing process. +.ip * +the process runs in the initial namespaces +(pid, mount, user, and so on) +and not in the namespaces of the crashing process. +one can utilize specifiers such as +.i %p +to find the right +.i /proc/[pid] +directory and probe/enter the crashing process's namespaces if needed. +.ip * +the process starts with its current working directory +as the root directory. +if desired, it is possible change to the working directory of +the dumping process by employing the value provided by the +.i %p +specifier to change to the location of the dumping process via +.ir /proc/[pid]/cwd . +.ip * +command-line arguments can be supplied to the +program (since linux 2.6.24), +delimited by white space (up to a total line length of 128 bytes). +.ip * +the +.b rlimit_core +limit is not enforced for core dumps that are piped to a program +via this mechanism. +.\" +.ss /proc/sys/kernel/core_pipe_limit +when collecting core dumps via a pipe to a user-space program, +it can be useful for the collecting program to gather data about +the crashing process from that process's +.ir /proc/[pid] +directory. +in order to do this safely, +the kernel must wait for the program collecting the core dump to exit, +so as not to remove the crashing process's +.ir /proc/[pid] +files prematurely. +this in turn creates the +possibility that a misbehaving collecting program can block +the reaping of a crashed process by simply never exiting. +.pp +since linux 2.6.32, +.\" commit a293980c2e261bd5b0d2a77340dd04f684caff58 +the +.i /proc/sys/kernel/core_pipe_limit +can be used to defend against this possibility. +the value in this file defines how many concurrent crashing +processes may be piped to user-space programs in parallel. +if this value is exceeded, then those crashing processes above this value +are noted in the kernel log and their core dumps are skipped. +.pp +a value of 0 in this file is special. +it indicates that unlimited processes may be captured in parallel, +but that no waiting will take place (i.e., the collecting +program is not guaranteed access to +.ir /proc/ ). +the default value for this file is 0. +.\" +.ss controlling which mappings are written to the core dump +since kernel 2.6.23, the linux-specific +.ir /proc/[pid]/coredump_filter +file can be used to control which memory segments are written to the +core dump file in the event that a core dump is performed for the +process with the corresponding process id. +.pp +the value in the file is a bit mask of memory mapping types (see +.br mmap (2)). +if a bit is set in the mask, then memory mappings of the +corresponding type are dumped; otherwise they are not dumped. +the bits in this file have the following meanings: +.pp +.pd 0 +.rs 4 +.tp +bit 0 +dump anonymous private mappings. +.tp +bit 1 +dump anonymous shared mappings. +.tp +bit 2 +dump file-backed private mappings. +.tp +bit 3 +dump file-backed shared mappings. +.\" file-backed shared mappings of course also update the underlying +.\" mapped file. +.tp +bit 4 (since linux 2.6.24) +dump elf headers. +.tp +bit 5 (since linux 2.6.28) +dump private huge pages. +.tp +bit 6 (since linux 2.6.28) +dump shared huge pages. +.tp +bit 7 (since linux 4.4) +.\" commit ab27a8d04b32b6ee8c30c14c4afd1058e8addc82 +dump private dax pages. +.tp +bit 8 (since linux 4.4) +.\" commit ab27a8d04b32b6ee8c30c14c4afd1058e8addc82 +dump shared dax pages. +.re +.pd +.pp +by default, the following bits are set: 0, 1, 4 (if the +.b config_core_dump_default_elf_headers +kernel configuration option is enabled), and 5. +this default can be modified at boot time using the +.i coredump_filter +boot option. +.pp +the value of this file is displayed in hexadecimal. +(the default value is thus displayed as 33.) +.pp +memory-mapped i/o pages such as frame buffer are never dumped, and +virtual dso +.rb ( vdso (7)) +pages are always dumped, regardless of the +.i coredump_filter +value. +.pp +a child process created via +.br fork (2) +inherits its parent's +.i coredump_filter +value; +the +.i coredump_filter +value is preserved across an +.br execve (2). +.pp +it can be useful to set +.i coredump_filter +in the parent shell before running a program, for example: +.pp +.in +4n +.ex +.rb "$" " echo 0x7 > /proc/self/coredump_filter" +.rb "$" " ./some_program" +.ee +.in +.pp +this file is provided only if the kernel was built with the +.b config_elf_core +configuration option. +.\" +.ss core dumps and systemd +on systems using the +.br systemd (1) +.i init +framework, core dumps may be placed in a location determined by +.br systemd (1). +to do this, +.br systemd (1) +employs the +.i core_pattern +feature that allows piping core dumps to a program. +one can verify this by checking whether core dumps are being piped to the +.br systemd\-coredump (8) +program: +.pp +.in +4n +.ex +$ \fbcat /proc/sys/kernel/core_pattern\fp +|/usr/lib/systemd/systemd\-coredump %p %u %g %s %t %c %e +.ee +.in +.pp +in this case, core dumps will be placed in the location configured for +.br systemd\-coredump (8), +typically as +.br lz4 (1) +compressed files in the directory +.ir /var/lib/systemd/coredump/ . +one can list the core dumps that have been recorded by +.br systemd\-coredump (8) +using +.br coredumpctl (1): +.pp +.ex +$ \fbcoredumpctl list | tail \-5\fp +wed 2017\-10\-11 22:25:30 cest 2748 1000 1000 3 present /usr/bin/sleep +thu 2017\-10\-12 06:29:10 cest 2716 1000 1000 3 present /usr/bin/sleep +thu 2017\-10\-12 06:30:50 cest 2767 1000 1000 3 present /usr/bin/sleep +thu 2017\-10\-12 06:37:40 cest 2918 1000 1000 3 present /usr/bin/cat +thu 2017\-10\-12 08:13:07 cest 2955 1000 1000 3 present /usr/bin/cat +.ee +.pp +the information shown for each core dump includes the date and time +of the dump, the pid, uid, and gid of the dumping process, +the signal number that caused the core dump, +and the pathname of the executable that was being run by the dumped process. +various options to +.br coredumpctl (1) +allow a specified coredump file to be pulled from the +.br systemd (1) +location into a specified file. +for example, to extract the core dump for pid 2955 shown above to a file named +.ir core +in the current directory, one could use: +.pp +.in +4n +.ex +$ \fbcoredumpctl dump 2955 \-o core\fp +.ee +.in +.pp +for more extensive details, see the +.br coredumpctl (1) +manual page. +.pp +to (persistently) disable the +.br systemd (1) +mechanism that archives core dumps, restoring to something more like +traditional linux behavior, one can set an override for the +.br systemd (1) +mechanism, using something like: +.pp +.in +4n +.ex +# \fbecho "kernel.core_pattern=core.%p" > \e\fp +\fb /etc/sysctl.d/50\-coredump.conf\fp +# \fb/lib/systemd/systemd\-sysctl\fp +.ee +.in +.pp +it is also possible to temporarily (i.e., until the next reboot) change the +.i core_pattern +setting using a command such as the following +(which causes the names of core dump files to include the executable name +as well as the number of the signal which triggered the core dump): +.pp +.in +4n +.ex +# \fbsysctl \-w kernel.core_pattern="%e\-%s.core"\fp +.ee +.in +.\" +.sh notes +the +.br gdb (1) +.i gcore +command can be used to obtain a core dump of a running process. +.pp +in linux versions up to and including 2.6.27, +.\" changed with commit 6409324b385f3f63a03645b4422e3be67348d922 +if a multithreaded process (or, more precisely, a process that +shares its memory with another process by being created with the +.b clone_vm +flag of +.br clone (2)) +dumps core, then the process id is always appended to the core filename, +unless the process id was already included elsewhere in the +filename via a +.i %p +specification in +.ir /proc/sys/kernel/core_pattern . +(this is primarily useful when employing the obsolete +linuxthreads implementation, +where each thread of a process has a different pid.) +.\" always including the pid in the name of the core file made +.\" sense for linuxthreads, where each thread had a unique pid, +.\" but doesn't seem to serve any purpose with nptl, where all the +.\" threads in a process share the same pid (as posix.1 requires). +.\" probably the behavior is maintained so that applications using +.\" linuxthreads continue appending the pid (the kernel has no easy +.\" way of telling which threading implementation the user-space +.\" application is using). -- mtk, april 2006 +.sh examples +the program below can be used to demonstrate the use of the +pipe syntax in the +.i /proc/sys/kernel/core_pattern +file. +the following shell session demonstrates the use of this program +(compiled to create an executable named +.ir core_pattern_pipe_test ): +.pp +.in +4n +.ex +.rb "$" " cc \-o core_pattern_pipe_test core_pattern_pipe_test.c" +.rb "$" " su" +password: +.rb "#" " echo \(dq|$pwd/core_pattern_pipe_test %p \ +uid=%u gid=%g sig=%s\(dq > \e" +.b " /proc/sys/kernel/core_pattern" +.rb "#" " exit" +.rb "$" " sleep 100" +.br "\(ha\e" " # type control\-backslash" +quit (core dumped) +.rb "$" " cat core.info" +argc=5 +argc[0]= +argc[1]=<20575> +argc[2]= +argc[3]= +argc[4]= +total bytes in core dump: 282624 +.ee +.in +.ss program source +\& +.ex +/* core_pattern_pipe_test.c */ + +#define _gnu_source +#include +#include +#include +#include +#include +#include + +#define buf_size 1024 + +int +main(int argc, char *argv[]) +{ + ssize_t nread, tot; + char buf[buf_size]; + file *fp; + char cwd[path_max]; + + /* change our current working directory to that of the + crashing process. */ + + snprintf(cwd, path_max, "/proc/%s/cwd", argv[1]); + chdir(cwd); + + /* write output to file "core.info" in that directory. */ + + fp = fopen("core.info", "w+"); + if (fp == null) + exit(exit_failure); + + /* display command\-line arguments given to core_pattern + pipe program. */ + + fprintf(fp, "argc=%d\en", argc); + for (int j = 0; j < argc; j++) + fprintf(fp, "argc[%d]=<%s>\en", j, argv[j]); + + /* count bytes in standard input (the core dump). */ + + tot = 0; + while ((nread = read(stdin_fileno, buf, buf_size)) > 0) + tot += nread; + fprintf(fp, "total bytes in core dump: %zd\en", tot); + + fclose(fp); + exit(exit_success); +} +.ee +.sh see also +.br bash (1), +.br coredumpctl (1), +.br gdb (1), +.br getrlimit (2), +.br mmap (2), +.br prctl (2), +.br sigaction (2), +.br elf (5), +.br proc (5), +.br pthreads (7), +.br signal (7), +.br systemd\-coredump (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/puts.3 + +.so man3/trunc.3 + +.\" copyright (c) 1995 james r. van zandt +.\" sat feb 18 09:11:07 est 1995 +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" modified, sun feb 26 15:08:05 1995, faith@cs.unc.edu +.\" 2007-12-17, samuel thibault : +.\" document the vt_gethifontmask ioctl +.\" " +.th vcs 4 2020-11-01 "linux" "linux programmer's manual" +.sh name +vcs, vcsa \- virtual console memory +.sh description +.i /dev/vcs0 +is a character device with major number 7 and minor number +0, usually with mode 0644 and ownership root:tty. +it refers to the memory of the currently +displayed virtual console terminal. +.pp +.i /dev/vcs[1\-63] +are character devices for virtual console +terminals, they have major number 7 and minor number 1 to 63, usually +mode 0644 and ownership root:tty. +.ir /dev/vcsa[0\-63] +are the same, but +using +.ir "unsigned short" s +(in host byte order) that include attributes, +and prefixed with four bytes giving the screen +dimensions and cursor position: +.ir lines , +.ir columns , +.ir x , +.ir y . +.ri ( x += +.i y += 0 at the top left corner of the screen.) +.pp +when a 512-character font is loaded, +the 9th bit position can be fetched by applying the +.br ioctl (2) +.b vt_gethifontmask +operation +(available in linux kernels 2.6.18 and above) +on +.ir /dev/tty[1\-63] ; +the value is returned in the +.i "unsigned short" +pointed to by the third +.br ioctl (2) +argument. +.pp +these devices replace the screendump +.br ioctl (2) +operations of +.br ioctl_console (2), +so the system +administrator can control access using filesystem permissions. +.pp +the devices for the first eight virtual consoles may be created by: +.pp +.in +4n +.ex +for x in 0 1 2 3 4 5 6 7 8; do + mknod \-m 644 /dev/vcs$x c 7 $x; + mknod \-m 644 /dev/vcsa$x c 7 $[$x+128]; +done +chown root:tty /dev/vcs* +.ee +.in +.pp +no +.br ioctl (2) +requests are supported. +.sh files +.i /dev/vcs[0\-63] +.br +.i /dev/vcsa[0\-63] +.\" .sh author +.\" andries brouwer +.sh versions +introduced with version 1.1.92 of the linux kernel. +.sh examples +you may do a screendump on vt3 by switching to vt1 and typing +.pp +.in +4n +.ex +cat /dev/vcs3 >foo +.ee +.in +.pp +note that the output does not contain +newline characters, so some processing may be required, like +in +.pp +.in +4n +.ex +fold \-w 81 /dev/vcs3 | lpr +.ee +.in +.pp +or (horrors) +.pp +.in +4n +.ex +setterm \-dump 3 \-file /proc/self/fd/1 +.ee +.in +.pp +the +.i /dev/vcsa0 +device is used for braille support. +.pp +this program displays the character and screen attributes under the +cursor of the second virtual console, then changes the background color +there: +.pp +.ex +#include +#include +#include +#include +#include +#include + +int +main(void) +{ + int fd; + char *device = "/dev/vcsa2"; + char *console = "/dev/tty2"; + struct {unsigned char lines, cols, x, y;} scrn; + unsigned short s; + unsigned short mask; + unsigned char attrib; + int ch; + + fd = open(console, o_rdwr); + if (fd < 0) { + perror(console); + exit(exit_failure); + } + if (ioctl(fd, vt_gethifontmask, &mask) < 0) { + perror("vt_gethifontmask"); + exit(exit_failure); + } + (void) close(fd); + fd = open(device, o_rdwr); + if (fd < 0) { + perror(device); + exit(exit_failure); + } + (void) read(fd, &scrn, 4); + (void) lseek(fd, 4 + 2*(scrn.y*scrn.cols + scrn.x), seek_set); + (void) read(fd, &s, 2); + ch = s & 0xff; + if (s & mask) + ch |= 0x100; + attrib = ((s & \(timask) >> 8); + printf("ch=%#03x attrib=%#02x\en", ch, attrib); + s \(ha= 0x1000; + (void) lseek(fd, \-2, seek_cur); + (void) write(fd, &s, 2); + exit(exit_success); +} +.ee +.sh see also +.br ioctl_console (2), +.br tty (4), +.br ttys (4), +.br gpm (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/getlogin.3 + +.\" copyright 2004 andries brouwer . +.\" and copyright 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th scalb 3 2021-03-22 "" "linux programmer's manual" +.sh name +scalb, scalbf, scalbl \- multiply floating-point number +by integral power of radix (obsolete) +.sh synopsis +.nf +.b #include +.pp +.bi "double scalb(double " x ", double " exp ); +.bi "float scalbf(float " x ", float " exp ); +.bi "long double scalbl(long double " x ", long double " exp ); +.fi +.pp +link with \fi\-lm\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br scalb (): +.nf + _xopen_source >= 500 +.\" || _xopen_source && _xopen_source_extended + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.pp +.br scalbf (), +.br scalbl (): +.nf + _xopen_source >= 600 + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.sh description +these functions multiply their first argument +.i x +by +.b flt_radix +(probably 2) +to the power of +.ir exp , +that is: +.pp +.nf + x * flt_radix ** exp +.fi +.pp +the definition of +.b flt_radix +can be obtained by including +.ir . +.\" not in /usr/include but in a gcc lib +.sh return value +on success, these functions return +.ir x +* +.b flt_radix +** +.ir exp . +.pp +if +.i x +or +.i exp +is a nan, a nan is returned. +.pp +if +.i x +is positive infinity (negative infinity), +and +.i exp +is not negative infinity, +positive infinity (negative infinity) is returned. +.pp +if +.i x +is +0 (\-0), and +.i exp +is not positive infinity, +0 (\-0) is returned. +.pp +if +.i x +is zero, and +.i exp +is positive infinity, +a domain error occurs, and +a nan is returned. +.pp +if +.i x +is an infinity, +and +.i exp +is negative infinity, +a domain error occurs, and +a nan is returned. +.pp +if the result overflows, +a range error occurs, +and the functions return +.br huge_val , +.br huge_valf , +or +.br huge_vall , +respectively, with a sign the same as +.ir x . +.pp +if the result underflows, +a range error occurs, +and the functions return zero, with a sign the same as +.ir x . +.sh errors +see +.br math_error (7) +for information on how to determine whether an error has occurred +when calling these functions. +.pp +the following errors can occur: +.tp +domain error: \fix\fp is 0, and \fiexp\fp is positive infinity, \ +or \fix\fp is positive infinity and \fiexp\fp is negative infinity \ +and the other argument is not a nan +.i errno +is set to +.br edom . +an invalid floating-point exception +.rb ( fe_invalid ) +is raised. +.tp +range error, overflow +.i errno +is set to +.br erange . +an overflow floating-point exception +.rb ( fe_overflow ) +is raised. +.tp +range error, underflow +.i errno +is set to +.br erange . +an underflow floating-point exception +.rb ( fe_underflow ) +is raised. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br scalb (), +.br scalbf (), +.br scalbl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +.br scalb () +is specified in posix.1-2001, but marked obsolescent. +posix.1-2008 removes the specification of +.br scalb (), +recommending the use of +.br scalbln (3), +.br scalblnf (3), +or +.br scalblnl (3) +instead. +the +.br scalb () +function is from 4.3bsd. +.pp +.br scalbf () +and +.br scalbl () +are unstandardized; +.br scalbf () +is nevertheless present on several other systems +.\" looking at header files: scalbf() is present on the +.\" bsds, tru64, hp-ux 11, irix 6.5; scalbl() is on hp-ux 11 and tru64. +.sh bugs +before glibc 2.20, +.\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=6803 +.\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=6804 +these functions did not set +.i errno +for domain and range errors. +.sh see also +.br ldexp (3), +.br scalbln (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/printf.3 + +.\" copyright (c) 2016 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th pthread_getattr_default_np 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +pthread_getattr_default_np, pthread_setattr_default_np, \- +get or set default thread-creation attributes +.sh synopsis +.nf +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "int pthread_getattr_default_np(pthread_attr_t *" attr ); +.bi "int pthread_setattr_default_np(const pthread_attr_t *" attr ); +.pp +compile and link with \fi\-pthread\fp. +.fi +.sh description +the +.br pthread_setattr_default_np () +function sets the default attributes used for creation of a new +thread\(emthat is, the attributes that are used when +.br pthread_create (3) +is called with a second argument that is null. +the default attributes are set using the attributes supplied in +.ir *attr , +a previously initialized thread attributes object. +note the following details about the supplied attributes object: +.ip * 3 +the attribute settings in the object must be valid. +.ip * +the +.ir "stack address" +attribute must not be set in the object. +.ip * +setting the +.ir "stack size" +attribute to zero means leave the default stack size unchanged. +.pp +the +.br pthread_getattr_default_np () +function initializes the thread attributes object referred to by +.i attr +so that it contains the default attributes used for thread creation. +.sh errors +.tp +.b einval +.rb ( pthread_setattr_default_np ()) +one of the attribute settings in +.ir attr +is invalid, or the stack address attribute is set in +.ir attr . +.tp +.b enomem +.\" can happen (but unlikely) while trying to allocate memory for cpuset +.rb ( pthread_setattr_default_np ()) +insufficient memory. +.sh versions +these functions are available in glibc since version 2.18. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br pthread_getattr_default_np (), +.br pthread_setattr_default_np () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +these functions are nonstandard gnu extensions; +hence the suffix "_np" (nonportable) in their names. +.sh examples +the program below uses +.br pthread_getattr_default_np () +to fetch the default thread-creation attributes and then displays +various settings from the returned thread attributes object. +when running the program, we see the following output: +.pp +.in +4n +.ex +$ \fb./a.out\fp +stack size: 8388608 +guard size: 4096 +scheduling policy: sched_other +scheduling priority: 0 +detach state: joinable +inherit scheduler: inherit +.ee +.in +.ss program source +\& +.ex +#define _gnu_source +#include +#include +#include +#include + +#define errexiten(en, msg) \e + do { errno = en; perror(msg); \e + exit(exit_failure); } while (0) + +static void +display_pthread_attr(pthread_attr_t *attr) +{ + int s; + size_t stacksize; + size_t guardsize; + int policy; + struct sched_param schedparam; + int detachstate; + int inheritsched; + + s = pthread_attr_getstacksize(attr, &stacksize); + if (s != 0) + errexiten(s, "pthread_attr_getstacksize"); + printf("stack size: %zd\en", stacksize); + + s = pthread_attr_getguardsize(attr, &guardsize); + if (s != 0) + errexiten(s, "pthread_attr_getguardsize"); + printf("guard size: %zd\en", guardsize); + + s = pthread_attr_getschedpolicy(attr, &policy); + if (s != 0) + errexiten(s, "pthread_attr_getschedpolicy"); + printf("scheduling policy: %s\en", + (policy == sched_fifo) ? "sched_fifo" : + (policy == sched_rr) ? "sched_rr" : + (policy == sched_other) ? "sched_other" : "[unknown]"); + + s = pthread_attr_getschedparam(attr, &schedparam); + if (s != 0) + errexiten(s, "pthread_attr_getschedparam"); + printf("scheduling priority: %d\en", schedparam.sched_priority); + + s = pthread_attr_getdetachstate(attr, &detachstate); + if (s != 0) + errexiten(s, "pthread_attr_getdetachstate"); + printf("detach state: %s\en", + (detachstate == pthread_create_detached) ? "detached" : + (detachstate == pthread_create_joinable) ? "joinable" : + "???"); + + s = pthread_attr_getinheritsched(attr, &inheritsched); + if (s != 0) + errexiten(s, "pthread_attr_getinheritsched"); + printf("inherit scheduler: %s\en", + (inheritsched == pthread_inherit_sched) ? "inherit" : + (inheritsched == pthread_explicit_sched) ? "explicit" : + "???"); +} + +int +main(int argc, char *argv[]) +{ + int s; + pthread_attr_t attr; + + s = pthread_getattr_default_np(&attr); + if (s != 0) + errexiten(s, "pthread_getattr_default_np"); + + display_pthread_attr(&attr); + + exit(exit_success); +} +.ee +.sh see also +.ad l +.nh +.br pthread_attr_getaffinity_np (3), +.br pthread_attr_getdetachstate (3), +.br pthread_attr_getguardsize (3), +.br pthread_attr_getinheritsched (3), +.br pthread_attr_getschedparam (3), +.br pthread_attr_getschedpolicy (3), +.br pthread_attr_getscope (3), +.br pthread_attr_getstack (3), +.br pthread_attr_getstackaddr (3), +.br pthread_attr_getstacksize (3), +.br pthread_attr_init (3), +.br pthread_create (3), +.br pthreads (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/stdin.3 + +.so man3/stdio_ext.3 + +.\" copyright 2009 lefteris dimitroulakis +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th armscii-8 7 2020-08-13 "linux" "linux programmer's manual" +.sh name +armscii-8 \- armenian character set encoded in octal, decimal, +and hexadecimal +.sh description +the armenian standard code for information interchange, +8-bit coded character set. +.ss armscii-8 characters +the following table displays the characters in armscii-8 that +are printable and unlisted in the +.br ascii (7) +manual page. +.ts +l l l c lp-1. +oct dec hex char description +_ +240 160 a0   no-break space +242 162 a2 և armenian small ligature ech yiwn +243 163 a3 ։ armenian full stop +244 164 a4 ) right parenthesis +245 165 a5 ( left parenthesis +246 166 a6 » right-pointing double angle quotation mark +247 167 a7 « left-pointing double angle quotation mark +250 168 a8 — em dash +251 169 a9 . full stop +252 170 aa ՝ armenian comma +253 171 ab , comma +254 172 ac - hyphen-minus +255 173 ad ֊ armenian hyphen +256 174 ae … horizontal ellipsis +257 175 af ՜ armenian exclamation mark +260 176 b0 ՛ armenian emphasis mark +261 177 b1 ՞ armenian question mark +262 178 b2 ա armenian capital letter ayb +263 179 b3 ա armenian small letter ayb +264 180 b4 բ armenian capital letter ben +265 181 b5 բ armenian small letter ben +266 182 b6 գ armenian capital letter gim +267 183 b7 գ armenian small letter gim +270 184 b8 դ armenian capital letter da +271 185 b9 դ armenian small letter da +272 186 ba ե armenian capital letter ech +273 187 bb ե armenian small letter ech +274 188 bc զ armenian capital letter za +275 189 bd զ armenian small letter za +276 190 be է armenian capital letter eh +277 191 bf է armenian small letter eh +300 192 c0 ը armenian capital letter et +301 193 c1 ը armenian small letter et +302 194 c2 թ armenian capital letter to +303 195 c3 թ armenian small letter to +304 196 c4 ժ armenian capital letter zhe +305 197 c5 ժ armenian small letter zhe +306 198 c6 ի armenian capital letter ini +307 199 c7 ի armenian small letter ini +310 200 c8 լ armenian capital letter liwn +311 201 c9 լ armenian small letter liwn +312 202 ca խ armenian capital letter xeh +313 203 cb խ armenian small letter xeh +314 204 cc ծ armenian capital letter ca +315 205 cd ծ armenian small letter ca +316 206 ce կ armenian capital letter ken +317 207 cf կ armenian small letter ken +320 208 d0 հ armenian capital letter ho +321 209 d1 հ armenian small letter ho +322 210 d2 ձ armenian capital letter ja +323 211 d3 ձ armenian small letter ja +324 212 d4 ղ armenian capital letter ghad +325 213 d5 ղ armenian small letter ghad +326 214 d6 ճ armenian capital letter cheh +327 215 d7 ճ armenian small letter cheh +330 216 d8 մ armenian capital letter men +331 217 d9 մ armenian small letter men +332 218 da յ armenian capital letter yi +333 219 db յ armenian small letter yi +334 220 dc ն armenian capital letter now +335 221 dd ն armenian small letter now +336 222 de շ armenian capital letter sha +337 223 df շ armenian small letter sha +340 224 e0 ո armenian capital letter vo +341 225 e1 ո armenian small letter vo +342 226 e2 չ armenian capital letter cha +343 227 e3 չ armenian small letter cha +344 228 e4 պ armenian capital letter peh +345 229 e5 պ armenian small letter peh +346 230 e6 ջ armenian capital letter jheh +347 231 e7 ջ armenian small letter jheh +350 232 e8 ռ armenian capital letter ra +351 233 e9 ռ armenian small letter ra +352 234 ea ս armenian capital letter seh +353 235 eb ս armenian small letter seh +354 236 ec վ armenian capital letter vew +355 237 ed վ armenian small letter vew +356 238 ee տ armenian capital letter tiwn +357 239 ef տ armenian small letter tiwn +360 240 f0 ր armenian capital letter reh +361 241 f1 ր armenian small letter reh +362 242 f2 ց armenian capital letter co +363 243 f3 ց armenian small letter co +364 244 f4 ւ armenian capital letter yiwn +365 245 f5 ւ armenian small letter yiwn +366 246 f6 փ armenian capital letter piwr +367 247 f7 փ armenian small letter piwr +370 248 f8 ք armenian capital letter keh +371 249 f9 ք armenian small letter keh +372 250 fa օ armenian capital letter oh +373 251 fb օ armenian small letter oh +374 252 fc ֆ armenian capital letter feh +375 253 fd ֆ armenian small letter feh +376 254 fe ՚ armenian apostrophe +.te +.sh see also +.br ascii (7), +.br charsets (7), +.br utf\-8 (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 2001 andries brouwer . +.\" and copyright 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th rint 3 2021-03-22 "" "linux programmer's manual" +.sh name +nearbyint, nearbyintf, nearbyintl, rint, rintf, rintl \- round +to nearest integer +.sh synopsis +.nf +.b #include +.pp +.bi "double nearbyint(double " x ); +.bi "float nearbyintf(float " x ); +.bi "long double nearbyintl(long double " x ); +.pp +.bi "double rint(double " x ); +.bi "float rintf(float " x ); +.bi "long double rintl(long double " x ); +.fi +.pp +link with \fi\-lm\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br nearbyint (), +.br nearbyintf (), +.br nearbyintl (): +.nf + _posix_c_source >= 200112l || _isoc99_source +.fi +.pp +.br rint (): +.nf + _isoc99_source || _posix_c_source >= 200112l + || _xopen_source >= 500 +.\" || _xopen_source && _xopen_source_extended + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.pp +.br rintf (), +.br rintl (): +.nf + _isoc99_source || _posix_c_source >= 200112l + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.sh description +the +.br nearbyint (), +.br nearbyintf (), +and +.br nearbyintl () +functions round their argument to an integer value in floating-point +format, using the current rounding direction (see +.br fesetround (3)) +and without raising the +.i inexact +exception. +when the current rounding direction is to nearest, these +functions round halfway cases to the even integer in accordance with +ieee-754. +.pp +the +.br rint (), +.br rintf (), +and +.br rintl () +functions do the same, but will raise the +.i inexact +exception +.rb ( fe_inexact , +checkable via +.br fetestexcept (3)) +when the result differs in value from the argument. +.sh return value +these functions return the rounded integer value. +.pp +if +.i x +is integral, +0, \-0, nan, or infinite, +.i x +itself is returned. +.sh errors +no errors occur. +posix.1-2001 documents a range error for overflows, but see notes. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br nearbyint (), +.br nearbyintf (), +.br nearbyintl (), +.br rint (), +.br rintf (), +.br rintl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.sh notes +susv2 and posix.1-2001 contain text about overflow (which might set +.i errno +to +.br erange , +or raise an +.b fe_overflow +exception). +in practice, the result cannot overflow on any current machine, +so this error-handling stuff is just nonsense. +(more precisely, overflow can happen only when the maximum value +of the exponent is smaller than the number of mantissa bits. +for the ieee-754 standard 32-bit and 64-bit floating-point numbers +the maximum value of the exponent is 128 (respectively, 1024), +and the number of mantissa bits is 24 (respectively, 53).) +.pp +if you want to store the rounded value in an integer type, +you probably want to use one of the functions described in +.br lrint (3) +instead. +.sh see also +.br ceil (3), +.br floor (3), +.br lrint (3), +.br round (3), +.br trunc (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1993 michael haardt +.\" (michael@moria.de), +.\" fri apr 2 11:32:09 met dst 1993 +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" modified 1993-07-22 by rik faith +.\" modified 1993-08-10 by alan cox +.\" modified 1998-11-04 by tigran aivazian +.\" modified 2004-05-27, 2004-06-17, 2004-06-23 by michael kerrisk +.\" +.th acct 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +acct \- switch process accounting on or off +.sh synopsis +.ad l +.nf +.b #include +.pp +.bi "int acct(const char *" filename ); +.fi +.ad b +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br acct (): +.nf + since glibc 2.21: +.\" commit 266865c0e7b79d4196e2cc393693463f03c90bd8 + _default_source + in glibc 2.19 and 2.20: + _default_source || (_xopen_source && _xopen_source < 500) + up to and including glibc 2.19: + _bsd_source || (_xopen_source && _xopen_source < 500) +.fi +.sh description +the +.br acct () +system call enables or disables process accounting. +if called with the name of an existing file as its argument, +accounting is turned on, +and records for each terminating process are appended to +.i filename +as it terminates. +an argument of null causes accounting to be turned off. +.sh return value +on success, zero is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eacces +write permission is denied for the specified file, +or search permission is denied for one of the directories +in the path prefix of +.i filename +(see also +.br path_resolution (7)), +or +.i filename +is not a regular file. +.tp +.b efault +.i filename +points outside your accessible address space. +.tp +.b eio +error writing to the file +.ir filename . +.tp +.b eisdir +.i filename +is a directory. +.tp +.b eloop +too many symbolic links were encountered in resolving +.ir filename . +.tp +.b enametoolong +.i filename +was too long. +.tp +.b enfile +the system-wide limit on the total number of open files has been reached. +.tp +.b enoent +the specified file does not exist. +.tp +.b enomem +out of memory. +.tp +.b enosys +bsd process accounting has not been enabled when the operating system +kernel was compiled. +the kernel configuration parameter controlling this feature is +.br config_bsd_process_acct . +.tp +.b enotdir +a component used as a directory in +.i filename +is not in fact a directory. +.tp +.b eperm +the calling process has insufficient privilege to enable process accounting. +on linux, the +.b cap_sys_pacct +capability is required. +.tp +.b erofs +.i filename +refers to a file on a read-only filesystem. +.tp +.b eusers +there are no more free file structures or we ran out of memory. +.sh conforming to +svr4, 4.3bsd (but not posix). +.\" svr4 documents an ebusy error condition, but no eisdir or enosys. +.\" also aix and hp-ux document ebusy (attempt is made +.\" to enable accounting when it is already enabled), as does solaris +.\" (attempt is made to enable accounting using the same file that is +.\" currently being used). +.sh notes +no accounting is produced for programs running when a system crash occurs. +in particular, nonterminating processes are never accounted for. +.pp +the structure of the records written to the accounting file is described in +.br acct (5). +.sh see also +.br acct (5) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/isalpha.3 + +.so man7/system_data_types.7 + +.so man3/rpc.3 + +.so man5/utmp.5 + +.\" copyright (c) 2009 michael kerrisk, +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th pthread_yield 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +pthread_yield \- yield the processor +.sh synopsis +.nf +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.b int pthread_yield(void); +.fi +.pp +compile and link with \fi\-pthread\fp. +.sh description +.br note : +this function is deprecated; see below. +.pp +.br pthread_yield () +causes the calling thread to relinquish the cpu. +the thread is placed at the end of the run queue for its static +priority and another thread is scheduled to run. +for further details, see +.br sched_yield (2) +.sh return value +on success, +.br pthread_yield () +returns 0; +on error, it returns an error number. +.sh errors +on linux, this call always succeeds +(but portable and future-proof applications should nevertheless +handle a possible error return). +.sh versions +since glibc 2.34, this function is marked as deprecated. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br pthread_yield () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +this call is nonstandard, but present on several other systems. +use the standardized +.br sched_yield (2) +instead. +.\" e.g., the bsds, tru64, aix, and irix. +.sh notes +on linux, this function is implemented as a call to +.br sched_yield (2). +.pp +.br pthread_yield () +is intended for use with real-time scheduling policies (i.e., +.br sched_fifo +or +.br sched_rr ). +use of +.br pthread_yield () +with nondeterministic scheduling policies such as +.br sched_other +is unspecified and very likely means your application design is broken. +.sh see also +.br sched_yield (2), +.\" fixme . .br pthread_cond_wait (3), +.br pthreads (7), +.br sched (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/asinh.3 + +.so man2/eventfd.2 + +.\" copyright (c) 2013, peter schiffer +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.th memusagestat 1 2021-03-22 "gnu" "linux programmer's manual" +.sh name +memusagestat \- generate graphic from memory profiling data +.sh synopsis +.nf +.br memusagestat " [\fioption\fr]... \fidatafile\fr [\fioutfile\fr]" +.fi +.sh description +.b memusagestat +creates a png file containing a graphical representation of the +memory profiling data in the file +.ir datafile ; +that file is generated via the +.i \-d +(or +.ir \-\-data ) +option of +.br memusage (1). +.pp +the red line in the graph shows the heap usage (allocated memory) +and the green line shows the stack usage. +the x-scale is either the number of memory-handling function calls or +(if the +.i \-t +option is specified) +time. +.sh options +.tp +.bi \-o\ file \fr,\ \fb\-\-output= file +name of the output file. +.tp +.bi \-s\ string \fr,\ \fb\-\-string= string +use +.i string +as the title inside the output graph. +.tp +.b \-t\fr,\ \fb\-\-time +use time (rather than number of function calls) as the scale for the x axis. +.tp +.b \-t\fr,\ \fb\-\-total +also draw a graph of total memory consumption. +.tp +.bi \-x\ size \fr,\ \fb\-\-x\-size= size +make the output graph +.i size +pixels wide. +.tp +.bi \-y\ size \fr,\ \fb\-\-y\-size= size +make the output graph +.i size +pixels high. +.tp +.b \-?\fr,\ \fb\-\-help +print a help message and exit. +.tp +.b \-\-usage +print a short usage message and exit. +.tp +.b \-v\fr,\ \fb\-\-version +print version information and exit. +.sh bugs +to report bugs, see +.ur http://www.gnu.org/software/libc/bugs.html +.ue +.sh examples +see +.br memusage (1). +.sh see also +.br memusage (1), +.br mtrace (1) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/cpu_set.3 + +.so man3/envz_add.3 + +.so man3/rint.3 + +.so man3/ether_aton.3 + +.so man2/pwrite.2 + +.\" copyright (c) 2001 andries brouwer +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th units 7 2020-08-13 "linux" "linux programmer's manual" +.sh name +units \- decimal and binary prefixes +.sh description +.ss decimal prefixes +the si system of units uses prefixes that indicate powers of ten. +a kilometer is 1000 meter, and a megawatt is 1000000 watt. +below the standard prefixes. +.rs +.ts +l l l. +prefix name value +y yocto 10^\-24 = 0.000000000000000000000001 +z zepto 10^\-21 = 0.000000000000000000001 +a atto 10^\-18 = 0.000000000000000001 +f femto 10^\-15 = 0.000000000000001 +p pico 10^\-12 = 0.000000000001 +n nano 10^\-9 = 0.000000001 +\(mc micro 10^\-6 = 0.000001 +m milli 10^\-3 = 0.001 +c centi 10^\-2 = 0.01 +d deci 10^\-1 = 0.1 +da deka 10^ 1 = 10 +h hecto 10^ 2 = 100 +k kilo 10^ 3 = 1000 +m mega 10^ 6 = 1000000 +g giga 10^ 9 = 1000000000 +t tera 10^12 = 1000000000000 +p peta 10^15 = 1000000000000000 +e exa 10^18 = 1000000000000000000 +z zetta 10^21 = 1000000000000000000000 +y yotta 10^24 = 1000000000000000000000000 +.te +.re +.pp +the symbol for micro is the greek letter mu, often written u +in an ascii context where this greek letter is not available. +see also +.pp +.rs +.ur http://physics.nist.gov\:/cuu\:/units\:/prefixes.html +.ue +.re +.ss binary prefixes +the binary prefixes resemble the decimal ones, +but have an additional \(aqi\(aq +(and "ki" starts with a capital \(aqk\(aq). +the names are formed by taking the +first syllable of the names of the decimal prefix with roughly the same +size, followed by "bi" for "binary". +.rs +.ts +l l l. +prefix name value +ki kibi 2^10 = 1024 +mi mebi 2^20 = 1048576 +gi gibi 2^30 = 1073741824 +ti tebi 2^40 = 1099511627776 +pi pebi 2^50 = 1125899906842624 +ei exbi 2^60 = 1152921504606846976 +.te +.re +.pp +see also +.pp +.ur http://physics.nist.gov\:/cuu\:/units\:/binary.html +.ue +.ss discussion +before these binary prefixes were introduced, it was fairly +common to use k=1000 and k=1024, just like b=bit, b=byte. +unfortunately, the m is capital already, and cannot be +capitalized to indicate binary-ness. +.pp +at first that didn't matter too much, since memory modules +and disks came in sizes that were powers of two, so everyone +knew that in such contexts "kilobyte" and "megabyte" meant +1024 and 1048576 bytes, respectively. +what originally was a +sloppy use of the prefixes "kilo" and "mega" started to become +regarded as the "real true meaning" when computers were involved. +but then disk technology changed, and disk sizes became arbitrary numbers. +after a period of uncertainty all disk manufacturers settled on the +standard, namely k=1000, m=1000\ k, g=1000\ m. +.pp +the situation was messy: in the 14k4 modems, k=1000; in the 1.44\ mb +.\" also common: 14.4k modem +diskettes, m=1024000; and so on. +in 1998 the iec approved the standard +that defines the binary prefixes given above, enabling people +to be precise and unambiguous. +.pp +thus, today, mb = 1000000\ b and mib = 1048576\ b. +.pp +in the free software world programs are slowly +being changed to conform. +when the linux kernel boots and says +.pp +.in +4n +.ex +hda: 120064896 sectors (61473 mb) w/2048kib cache +.ee +.in +.pp +the mb are megabytes and the kib are kibibytes. +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2014 red hat, inc. all rights reserved. +.\" written by david howells (dhowells@redhat.com) +.\" +.\" %%%license_start(gplv2+_sw_onepara) +.\" this program is free software; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license +.\" as published by the free software foundation; either version +.\" 2 of the license, or (at your option) any later version. +.\" %%%license_end +.\" +.th process-keyring 7 2020-08-13 linux "linux programmer's manual" +.sh name +process-keyring \- per-process shared keyring +.sh description +the process keyring is a keyring used to anchor keys on behalf of a process. +it is created only when a process requests it. +the process keyring has the name (description) +.ir _pid . +.pp +a special serial number value, +.br key_spec_process_keyring , +is defined that can be used in lieu of the actual serial number of +the calling process's process keyring. +.pp +from the +.br keyctl (1) +utility, '\fb@p\fp' can be used instead of a numeric key id in +much the same way, but since +.br keyctl (1) +is a program run after forking, this is of no utility. +.pp +a thread created using the +.br clone (2) +.b clone_thread +flag has the same process keyring as the caller of +.br clone (2). +when a new process is created using +.br fork () +it initially has no process keyring. +a process's process keyring is cleared on +.br execve (2). +the process keyring is destroyed when the last +thread that refers to it terminates. +.pp +if a process doesn't have a process keyring when it is accessed, +then the process keyring will be created if the keyring is to be modified; +otherwise, the error +.b enokey +results. +.sh see also +.ad l +.nh +.br keyctl (1), +.br keyctl (3), +.br keyrings (7), +.br persistent\-keyring (7), +.br session\-keyring (7), +.br thread\-keyring (7), +.br user\-keyring (7), +.br user\-session\-keyring (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/ffs.3 + +.so man3/ctime.3 + +.so man3/getutent.3 + +.so man3/sigsetops.3 + +.\" this manpage is copyright (c) 1996 austin donnelly , +.\" with additional material copyright (c) 1995 martin schulze +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" this manpage was made by merging two independently written manpages, +.\" one written by martin schulze (18 oct 95), the other written by +.\" austin donnelly, (9 jan 96). +.\" +.\" thu jan 11 12:14:41 1996 austin donnelly +.\" * merged two services(5) manpages +.\" +.th services 5 2020-04-11 "linux" "linux programmer's manual" +.sh name +services \- internet network services list +.sh description +.b services +is a plain ascii file providing a mapping between human-friendly textual +names for internet services, and their underlying assigned port +numbers and protocol types. +every networking program should look into +this file to get the port number (and protocol) for its service. +the c library routines +.br getservent (3), +.br getservbyname (3), +.br getservbyport (3), +.br setservent (3), +and +.br endservent (3) +support querying this file from programs. +.pp +port numbers are assigned by the iana (internet assigned numbers +authority), and their current policy is to assign both tcp and udp +protocols when assigning a port number. +therefore, most entries will +have two entries, even for tcp-only services. +.pp +port numbers below 1024 (so-called "low numbered" ports) can be +bound to only by root (see +.br bind (2), +.br tcp (7), +and +.br udp (7)). +this is so clients connecting to low numbered ports can trust +that the service running on the port is the standard implementation, +and not a rogue service run by a user of the machine. +well-known port numbers specified by the iana are normally +located in this root-only space. +.pp +the presence of an entry for a service in the +.b services +file does not necessarily mean that the service is currently running +on the machine. +see +.br inetd.conf (5) +for the configuration of internet services offered. +note that not all +networking services are started by +.br inetd (8), +and so won't appear in +.br inetd.conf (5). +in particular, news (nntp) and mail (smtp) servers are often +initialized from the system boot scripts. +.pp +the location of the +.b services +file is defined by +.b _path_services +in +.ir "." +this is usually set to +.ir /etc/services "." +.pp +each line describes one service, and is of the form: +.ip +\f2service-name\ \ \ port\f3/\f2protocol\ \ \ \f1[\f2aliases ...\f1] +.tp +where: +.tp +.i service-name +is the friendly name the service is known by and looked up under. +it is case sensitive. +often, the client program is named after the +.ir service-name "." +.tp +.i port +is the port number (in decimal) to use for this service. +.tp +.i protocol +is the type of protocol to be used. +this field should match an entry +in the +.br protocols (5) +file. +typical values include +.b tcp +and +.br udp . +.tp +.i aliases +is an optional space or tab separated list of other names for this +service. +again, the names are case +sensitive. +.pp +either spaces or tabs may be used to separate the fields. +.pp +comments are started by the hash sign (#) and continue until the end +of the line. +blank lines are skipped. +.pp +the +.i service-name +should begin in the first column of the file, since leading spaces are +not stripped. +.i service-names +can be any printable characters excluding space and tab. +however, a conservative choice of characters should be used to minimize +compatibility problems. +for example, a\-z, 0\-9, and hyphen (\-) would seem a +sensible choice. +.pp +lines not matching this format should not be present in the +file. +(currently, they are silently skipped by +.br getservent (3), +.br getservbyname (3), +and +.br getservbyport (3). +however, this behavior should not be relied on.) +.pp +.\" the following is not true as at glibc 2.8 (a line with a comma is +.\" ignored by getservent()); it's not clear if/when it was ever true. +.\" as a backward compatibility feature, the slash (/) between the +.\" .i port +.\" number and +.\" .i protocol +.\" name can in fact be either a slash or a comma (,). +.\" use of the comma in +.\" modern installations is deprecated. +.\" +this file might be distributed over a network using a network-wide +naming service like yellow pages/nis or bind/hesiod. +.pp +a sample +.b services +file might look like this: +.pp +.in +4n +.ex +netstat 15/tcp +qotd 17/tcp quote +msp 18/tcp # message send protocol +msp 18/udp # message send protocol +chargen 19/tcp ttytst source +chargen 19/udp ttytst source +ftp 21/tcp +# 22 \- unassigned +telnet 23/tcp +.ee +.in +.sh files +.tp +.i /etc/services +the internet network services list +.tp +.i +definition of +.b _path_services +.\" .sh bugs +.\" it's not clear when/if the following was ever true; +.\" it isn't true for glibc 2.8: +.\" there is a maximum of 35 aliases, due to the way the +.\" .br getservent (3) +.\" code is written. +.\" +.\" it's not clear when/if the following was ever true; +.\" it isn't true for glibc 2.8: +.\" lines longer than +.\" .b bufsiz +.\" (currently 1024) characters will be ignored by +.\" .br getservent (3), +.\" .br getservbyname (3), +.\" and +.\" .br getservbyport (3). +.\" however, this will also cause the next line to be mis-parsed. +.sh see also +.br listen (2), +.br endservent (3), +.br getservbyname (3), +.br getservbyport (3), +.br getservent (3), +.br setservent (3), +.br inetd.conf (5), +.br protocols (5), +.br inetd (8) +.pp +assigned numbers rfc, most recently rfc\ 1700, (aka std0002). +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man4/vcs.4 + +.\" this file is derived from unlink.2, which has the following copyright: +.\" +.\" this manpage is copyright (c) 1992 drew eckhardt; +.\" and copyright (c) 1993 ian jackson. +.\" +.\" edited into remove.3 shape by: +.\" graeme w. wilford (g.wilford@ee.surrey.ac.uk) on 13th july 1994 +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th remove 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +remove \- remove a file or directory +.sh synopsis +.nf +.b #include +.pp +.bi "int remove(const char *" pathname ); +.fi +.sh description +.br remove () +deletes a name from the filesystem. +it calls +.br unlink (2) +for files, and +.br rmdir (2) +for directories. +.pp +if the removed name was the +last link to a file and no processes have the file open, the file is +deleted and the space it was using is made available for reuse. +.pp +if the name was the last link to a file, +but any processes still have the file open, +the file will remain in existence until the last file +descriptor referring to it is closed. +.pp +if the name referred to a symbolic link, the link is removed. +.pp +if the name referred to a socket, fifo, or device, the name is removed, +but processes which have the object open may continue to use it. +.sh return value +on success, zero is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +the errors that occur are those for +.br unlink (2) +and +.br rmdir (2). +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br remove () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c89, c99, 4.3bsd. +.\" .sh notes +.\" under libc4 and libc5, +.\" .br remove () +.\" was an alias for +.\" .br unlink (2) +.\" (and hence would not remove directories). +.sh bugs +infelicities in the protocol underlying nfs can cause the unexpected +disappearance of files which are still being used. +.sh see also +.br rm (1), +.br unlink (1), +.br link (2), +.br mknod (2), +.br open (2), +.br rename (2), +.br rmdir (2), +.br unlink (2), +.br mkfifo (3), +.br symlink (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/j0.3 + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" +.th wcpncpy 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +wcpncpy \- copy a fixed-size string of wide characters, +returning a pointer to its end +.sh synopsis +.nf +.b #include +.pp +.bi "wchar_t *wcpncpy(wchar_t *restrict " dest \ +", const wchar_t *restrict " src , +.bi " size_t " n ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br wcpncpy (): +.nf + since glibc 2.10: + _posix_c_source >= 200809l + before glibc 2.10: + _gnu_source +.fi +.sh description +the +.br wcpncpy () +function is the wide-character equivalent +of the +.br stpncpy (3) +function. +it copies at most +.i n +wide characters from the wide-character +string pointed to by +.ir src , +including the terminating null wide (l\(aq\e0\(aq), +to the array pointed to by +.ir dest . +exactly +.i n +wide characters are +written at +.ir dest . +if the length +.ir wcslen(src) +is smaller than +.ir n , +the remaining wide characters in the array pointed to +by +.i dest +are filled with l\(aq\e0\(aq characters. +if the length +.ir wcslen(src) +is greater than or equal +to +.ir n , +the string pointed to by +.i dest +will +not be l\(aq\e0\(aq terminated. +.pp +the strings may not overlap. +.pp +the programmer must ensure that there is room for at least +.i n +wide +characters at +.ir dest . +.sh return value +.br wcpncpy () +returns a pointer to the last wide character written, that is, +.ir dest + n \-1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br wcpncpy () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2008. +.sh see also +.br stpncpy (3), +.br wcsncpy (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/rpc.3 + +.\"this manpage is copyright (c) 2015 anna schumaker +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of +.\" this manual under the conditions for verbatim copying, provided that +.\" the entire resulting derived work is distributed under the terms of +.\" a permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume +.\" no responsibility for errors or omissions, or for damages resulting +.\" from the use of the information contained herein. the author(s) may +.\" not have taken the same level of care in the production of this +.\" manual, which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th copy_file_range 2 2021-08-27 "linux" "linux programmer's manual" +.sh name +copy_file_range \- copy a range of data from one file to another +.sh synopsis +.nf +.b #define _gnu_source +.b #include +.pp +.bi "ssize_t copy_file_range(int " fd_in ", off64_t *" off_in , +.bi " int " fd_out ", off64_t *" off_out , +.bi " size_t " len ", unsigned int " flags ); +.fi +.sh description +the +.br copy_file_range () +system call performs an in-kernel copy between two file descriptors +without the additional cost of transferring data from the kernel to user space +and then back into the kernel. +it copies up to +.i len +bytes of data from the source file descriptor +.i fd_in +to the target file descriptor +.ir fd_out , +overwriting any data that exists within the requested range of the target file. +.pp +the following semantics apply for +.ir off_in , +and similar statements apply to +.ir off_out : +.ip * 3 +if +.i off_in +is null, then bytes are read from +.i fd_in +starting from the file offset, and the file offset is +adjusted by the number of bytes copied. +.ip * +if +.i off_in +is not null, then +.i off_in +must point to a buffer that specifies the starting +offset where bytes from +.i fd_in +will be read. +the file offset of +.i fd_in +is not changed, but +.i off_in +is adjusted appropriately. +.pp +.i fd_in +and +.i fd_out +can refer to the same file. +if they refer to the same file, then the source and target ranges are not +allowed to overlap. +.pp +the +.i flags +argument is provided to allow for future extensions +and currently must be set to 0. +.sh return value +upon successful completion, +.br copy_file_range () +will return the number of bytes copied between files. +this could be less than the length originally requested. +if the file offset of +.i fd_in +is at or past the end of file, no bytes are copied, and +.br copy_file_range () +returns zero. +.pp +on error, +.br copy_file_range () +returns \-1 and +.i errno +is set to indicate the error. +.sh errors +.tp +.b ebadf +one or more file descriptors are not valid. +.tp +.b ebadf +.i fd_in +is not open for reading; or +.i fd_out +is not open for writing. +.tp +.b ebadf +the +.b o_append +flag is set for the open file description (see +.br open (2)) +referred to by the file descriptor +.ir fd_out . +.tp +.b efbig +an attempt was made to write at a position past the maximum file offset the +kernel supports. +.tp +.b efbig +an attempt was made to write a range that exceeds the allowed maximum file size. +the maximum file size differs between filesystem implementations and can be +different from the maximum allowed file offset. +.tp +.b efbig +an attempt was made to write beyond the process's file size resource limit. +this may also result in the process receiving a +.b sigxfsz +signal. +.tp +.b einval +the +.i flags +argument is not 0. +.tp +.b einval +.i fd_in +and +.i fd_out +refer to the same file and the source and target ranges overlap. +.tp +.b einval +either +.i fd_in +or +.i fd_out +is not a regular file. +.tp +.b eio +a low-level i/o error occurred while copying. +.tp +.b eisdir +either +.i fd_in +or +.i fd_out +refers to a directory. +.tp +.b enomem +out of memory. +.tp +.b enospc +there is not enough space on the target filesystem to complete the copy. +.tp +.b eoverflow +the requested source or destination range is too large to represent in the +specified data types. +.tp +.b eperm +.i fd_out +refers to an immutable file. +.tp +.b etxtbsy +either +.i fd_in +or +.i fd_out +refers to an active swap file. +.tp +.b exdev +the files referred to by +.ir fd_in " and " fd_out +are not on the same mounted filesystem (pre linux 5.3). +.sh versions +the +.br copy_file_range () +system call first appeared in linux 4.5, but glibc 2.27 provides a user-space +emulation when it is not available. +.\" https://sourceware.org/git/?p=glibc.git;a=commit;f=posix/unistd.h;h=bad7a0c81f501fbbcc79af9eaa4b8254441c4a1f +.pp +a major rework of the kernel implementation occurred in 5.3. +areas of the api that weren't clearly defined were clarified and the api bounds +are much more strictly checked than on earlier kernels. +applications should target the behaviour and requirements of 5.3 kernels. +.pp +first support for cross-filesystem copies was introduced in linux 5.3. +older kernels will return -exdev when cross-filesystem copies are attempted. +.sh conforming to +the +.br copy_file_range () +system call is a nonstandard linux and gnu extension. +.sh notes +if +.i fd_in +is a sparse file, then +.br copy_file_range () +may expand any holes existing in the requested range. +users may benefit from calling +.br copy_file_range () +in a loop, and using the +.br lseek (2) +.br seek_data +and +.br seek_hole +operations to find the locations of data segments. +.pp +.br copy_file_range () +gives filesystems an opportunity to implement "copy acceleration" techniques, +such as the use of reflinks (i.e., two or more inodes that share +pointers to the same copy-on-write disk blocks) +or server-side-copy (in the case of nfs). +.sh examples +.ex +#define _gnu_source +#include +#include +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + int fd_in, fd_out; + struct stat stat; + off64_t len, ret; + + if (argc != 3) { + fprintf(stderr, "usage: %s \en", argv[0]); + exit(exit_failure); + } + + fd_in = open(argv[1], o_rdonly); + if (fd_in == \-1) { + perror("open (argv[1])"); + exit(exit_failure); + } + + if (fstat(fd_in, &stat) == \-1) { + perror("fstat"); + exit(exit_failure); + } + + len = stat.st_size; + + fd_out = open(argv[2], o_creat | o_wronly | o_trunc, 0644); + if (fd_out == \-1) { + perror("open (argv[2])"); + exit(exit_failure); + } + + do { + ret = copy_file_range(fd_in, null, fd_out, null, len, 0); + if (ret == \-1) { + perror("copy_file_range"); + exit(exit_failure); + } + + len \-= ret; + } while (len > 0 && ret > 0); + + close(fd_in); + close(fd_out); + exit(exit_success); +} +.ee +.sh see also +.br lseek (2), +.br sendfile (2), +.br splice (2) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/msgop.2 + +.\" copyright (c) 2003 andries brouwer (aeb@cwi.nl) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified 2003-08-17 by walter harms +.\" modified 2004-06-23 by michael kerrisk +.\" +.th statfs 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +statfs, fstatfs \- get filesystem statistics +.sh synopsis +.nf +.br "#include " "/* or */" +.pp +.bi "int statfs(const char *" path ", struct statfs *" buf ); +.bi "int fstatfs(int " fd ", struct statfs *" buf ); +.fi +.sh description +the +.br statfs () +system call returns information about a mounted filesystem. +.i path +is the pathname of any file within the mounted filesystem. +.i buf +is a pointer to a +.i statfs +structure defined approximately as follows: +.pp +.in +4n +.ex +struct statfs { + __fsword_t f_type; /* type of filesystem (see below) */ + __fsword_t f_bsize; /* optimal transfer block size */ + fsblkcnt_t f_blocks; /* total data blocks in filesystem */ + fsblkcnt_t f_bfree; /* free blocks in filesystem */ + fsblkcnt_t f_bavail; /* free blocks available to + unprivileged user */ + fsfilcnt_t f_files; /* total inodes in filesystem */ + fsfilcnt_t f_ffree; /* free inodes in filesystem */ + fsid_t f_fsid; /* filesystem id */ + __fsword_t f_namelen; /* maximum length of filenames */ + __fsword_t f_frsize; /* fragment size (since linux 2.6) */ + __fsword_t f_flags; /* mount flags of filesystem + (since linux 2.6.36) */ + __fsword_t f_spare[xxx]; + /* padding bytes reserved for future use */ +}; +.ee +.in +.pp +the following filesystem types may appear in +.ir f_type : +.pp +.in +4n +.ex +adfs_super_magic 0xadf5 +affs_super_magic 0xadff +afs_super_magic 0x5346414f +anon_inode_fs_magic 0x09041934 /* anonymous inode fs (for + pseudofiles that have no name; + e.g., epoll, signalfd, bpf) */ +autofs_super_magic 0x0187 +bdevfs_magic 0x62646576 +befs_super_magic 0x42465331 +bfs_magic 0x1badface +binfmtfs_magic 0x42494e4d +bpf_fs_magic 0xcafe4a11 +btrfs_super_magic 0x9123683e +btrfs_test_magic 0x73727279 +cgroup_super_magic 0x27e0eb /* cgroup pseudo fs */ +cgroup2_super_magic 0x63677270 /* cgroup v2 pseudo fs */ +cifs_magic_number 0xff534d42 +coda_super_magic 0x73757245 +coh_super_magic 0x012ff7b7 +cramfs_magic 0x28cd3d45 +debugfs_magic 0x64626720 +devfs_super_magic 0x1373 /* linux 2.6.17 and earlier */ +devpts_super_magic 0x1cd1 +ecryptfs_super_magic 0xf15f +efivarfs_magic 0xde5e81e4 +efs_super_magic 0x00414a53 +ext_super_magic 0x137d /* linux 2.0 and earlier */ +ext2_old_super_magic 0xef51 +ext2_super_magic 0xef53 +ext3_super_magic 0xef53 +ext4_super_magic 0xef53 +f2fs_super_magic 0xf2f52010 +fuse_super_magic 0x65735546 +futexfs_super_magic 0xbad1dea /* unused */ +hfs_super_magic 0x4244 +hostfs_super_magic 0x00c0ffee +hpfs_super_magic 0xf995e849 +hugetlbfs_magic 0x958458f6 +isofs_super_magic 0x9660 +jffs2_super_magic 0x72b6 +jfs_super_magic 0x3153464a +minix_super_magic 0x137f /* original minix fs */ +minix_super_magic2 0x138f /* 30 char minix fs */ +minix2_super_magic 0x2468 /* minix v2 fs */ +minix2_super_magic2 0x2478 /* minix v2 fs, 30 char names */ +minix3_super_magic 0x4d5a /* minix v3 fs, 60 char names */ +mqueue_magic 0x19800202 /* posix message queue fs */ +msdos_super_magic 0x4d44 +mtd_inode_fs_magic 0x11307854 +ncp_super_magic 0x564c +nfs_super_magic 0x6969 +nilfs_super_magic 0x3434 +nsfs_magic 0x6e736673 +ntfs_sb_magic 0x5346544e +ocfs2_super_magic 0x7461636f +openprom_super_magic 0x9fa1 +overlayfs_super_magic 0x794c7630 +pipefs_magic 0x50495045 +proc_super_magic 0x9fa0 /* /proc fs */ +pstorefs_magic 0x6165676c +qnx4_super_magic 0x002f +qnx6_super_magic 0x68191122 +ramfs_magic 0x858458f6 +reiserfs_super_magic 0x52654973 +romfs_magic 0x7275 +securityfs_magic 0x73636673 +selinux_magic 0xf97cff8c +smack_magic 0x43415d53 +smb_super_magic 0x517b +smb2_magic_number 0xfe534d42 +sockfs_magic 0x534f434b +squashfs_magic 0x73717368 +sysfs_magic 0x62656572 +sysv2_super_magic 0x012ff7b6 +sysv4_super_magic 0x012ff7b5 +tmpfs_magic 0x01021994 +tracefs_magic 0x74726163 +udf_super_magic 0x15013346 +ufs_magic 0x00011954 +usbdevice_super_magic 0x9fa2 +v9fs_magic 0x01021997 +vxfs_super_magic 0xa501fcf5 +xenfs_super_magic 0xabba1974 +xenix_super_magic 0x012ff7b4 +xfs_super_magic 0x58465342 +_xiafs_super_magic 0x012fd16d /* linux 2.0 and earlier */ +.ee +.in +.pp +most of these magic constants are defined in +.ir /usr/include/linux/magic.h , +and some are hardcoded in kernel sources. +.pp +the +.ir f_flags +field is a bit mask indicating mount options for the filesystem. +it contains zero or more of the following bits: +.\" xxx keep this list in sync with statvfs(3) +.tp +.b st_mandlock +mandatory locking is permitted on the filesystem (see +.br fcntl (2)). +.tp +.b st_noatime +do not update access times; see +.br mount (2). +.tp +.b st_nodev +disallow access to device special files on this filesystem. +.tp +.b st_nodiratime +do not update directory access times; see +.br mount (2). +.tp +.b st_noexec +execution of programs is disallowed on this filesystem. +.tp +.b st_nosuid +the set-user-id and set-group-id bits are ignored by +.br exec (3) +for executable files on this filesystem +.tp +.b st_rdonly +this filesystem is mounted read-only. +.tp +.b st_relatime +update atime relative to mtime/ctime; see +.br mount (2). +.tp +.b st_synchronous +writes are synched to the filesystem immediately (see the description of +.b o_sync +in +.br open (2)). +.tp +.br st_nosymfollow " (since linux 5.10)" +.\" dab741e0e02bd3c4f5e2e97be74b39df2523fc6e +symbolic links are not followed when resolving paths; see +.br mount (2). +.pp +nobody knows what +.i f_fsid +is supposed to contain (but see below). +.pp +fields that are undefined for a particular filesystem are set to 0. +.pp +.br fstatfs () +returns the same information about an open file referenced by descriptor +.ir fd . +.sh return value +on success, zero is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eacces +.rb ( statfs ()) +search permission is denied for a component of the path prefix of +.ir path . +(see also +.br path_resolution (7).) +.tp +.b ebadf +.rb ( fstatfs ()) +.i fd +is not a valid open file descriptor. +.tp +.b efault +.i buf +or +.i path +points to an invalid address. +.tp +.b eintr +the call was interrupted by a signal; see +.br signal (7). +.tp +.b eio +an i/o error occurred while reading from the filesystem. +.tp +.b eloop +.rb ( statfs ()) +too many symbolic links were encountered in translating +.ir path . +.tp +.b enametoolong +.rb ( statfs ()) +.i path +is too long. +.tp +.b enoent +.rb ( statfs ()) +the file referred to by +.i path +does not exist. +.tp +.b enomem +insufficient kernel memory was available. +.tp +.b enosys +the filesystem does not support this call. +.tp +.b enotdir +.rb ( statfs ()) +a component of the path prefix of +.i path +is not a directory. +.tp +.b eoverflow +some values were too large to be represented in the returned struct. +.sh conforming to +linux-specific. +the linux +.br statfs () +was inspired by the 4.4bsd one +(but they do not use the same structure). +.sh notes +the +.i __fsword_t +type used for various fields in the +.i statfs +structure definition is a glibc internal type, +not intended for public use. +this leaves the programmer in a bit of a conundrum when trying to copy +or compare these fields to local variables in a program. +using +.i "unsigned\ int" +for such variables suffices on most systems. +.pp +the original linux +.br statfs () +and +.br fstatfs () +system calls were not designed with extremely large file sizes in mind. +subsequently, linux 2.6 +added new +.br statfs64 () +and +.br fstatfs64 () +system calls that employ a new structure, +.ir statfs64 . +the new structure contains the same fields as the original +.i statfs +structure, but the sizes of various fields are increased, +to accommodate large file sizes. +the glibc +.br statfs () +and +.br fstatfs () +wrapper functions transparently deal with the kernel differences. +.pp +some systems have only \fi\fp, other systems also have +\fi\fp, where the former includes the latter. +so it seems +including the former is the best choice. +.pp +lsb has deprecated the library calls +.br statfs () +and +.br fstatfs () +and tells us to use +.br statvfs (3) +and +.br fstatvfs (3) +instead. +.ss the f_fsid field +solaris, irix, and posix have a system call +.br statvfs (2) +that returns a +.i "struct statvfs" +(defined in +.ir ) +containing an +.i "unsigned long" +.ir f_fsid . +linux, sunos, hp-ux, 4.4bsd have a system call +.br statfs () +that returns a +.i "struct statfs" +(defined in +.ir ) +containing a +.i fsid_t +.ir f_fsid , +where +.i fsid_t +is defined as +.ir "struct { int val[2]; }" . +the same holds for freebsd, except that it uses the include file +.ir . +.pp +the general idea is that +.i f_fsid +contains some random stuff such that the pair +.ri ( f_fsid , ino ) +uniquely determines a file. +some operating systems use (a variation on) the device number, +or the device number combined with the filesystem type. +several operating systems restrict giving out the +.i f_fsid +field to the superuser only (and zero it for unprivileged users), +because this field is used in the filehandle of the filesystem +when nfs-exported, and giving it out is a security concern. +.pp +under some operating systems, the +.i fsid +can be used as the second argument to the +.br sysfs (2) +system call. +.sh bugs +from linux 2.6.38 up to and including linux 3.1, +.\" broken in commit ff0c7d15f9787b7e8c601533c015295cc68329f8 +.\" fixed in commit d70ef97baf048412c395bb5d65791d8fe133a52b +.br fstatfs () +failed with the error +.b enosys +for file descriptors created by +.br pipe (2). +.sh see also +.br stat (2), +.br statvfs (3), +.br path_resolution (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/outb.2 + +.\" copyright (c) 2003, 2017 by michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th dl_iterate_phdr 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +dl_iterate_phdr \- walk through list of shared objects +.sh synopsis +.nf +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "int dl_iterate_phdr(" +.bi " int (*" callback ")(struct dl_phdr_info *" info , +.bi " size_t " size ", void *" data ")," +.bi " void *" data ");" +.fi +.sh description +the +.br dl_iterate_phdr () +function allows an application to inquire at run time to find +out which shared objects it has loaded, +and the order in which they were loaded. +.pp +the +.br dl_iterate_phdr () +function walks through the list of an +application's shared objects and calls the function +.i callback +once for each object, +until either all shared objects have been processed or +.i callback +returns a nonzero value. +.pp +each call to +.i callback +receives three arguments: +.ir info , +which is a pointer to a structure containing information +about the shared object; +.ir size , +which is the size of the structure pointed to by +.ir info ; +and +.ir data , +which is a copy of whatever value was passed by the calling +program as the second argument (also named +.ir data ) +in the call to +.br dl_iterate_phdr (). +.pp +the +.i info +argument is a structure of the following type: +.pp +.in +4n +.ex +struct dl_phdr_info { + elfw(addr) dlpi_addr; /* base address of object */ + const char *dlpi_name; /* (null\-terminated) name of + object */ + const elfw(phdr) *dlpi_phdr; /* pointer to array of + elf program headers + for this object */ + elfw(half) dlpi_phnum; /* # of items in \fidlpi_phdr\fp */ + + /* the following fields were added in glibc 2.4, after the first + version of this structure was available. check the \fisize\fp + argument passed to the dl_iterate_phdr callback to determine + whether or not each later member is available. */ + + unsigned long long dlpi_adds; + /* incremented when a new object may + have been added */ + unsigned long long dlpi_subs; + /* incremented when an object may + have been removed */ + size_t dlpi_tls_modid; + /* if there is a pt_tls segment, its module + id as used in tls relocations, else zero */ + void *dlpi_tls_data; + /* the address of the calling thread\(aqs instance + of this module\(aqs pt_tls segment, if it has + one and it has been allocated in the calling + thread, otherwise a null pointer */ +}; +.ee +.in +.pp +(the +.ir elfw () +macro definition turns its argument into the name of an elf data +type suitable for the hardware architecture. +for example, on a 32-bit platform, +.i elfw(addr) +yields the data type name +.ir elf32_addr . +further information on these types can be found in the +.ir " and " +header files.) +.pp +the +.i dlpi_addr +field indicates the base address of the shared object +(i.e., the difference between the virtual memory address of +the shared object and the offset of that object in the file +from which it was loaded). +the +.i dlpi_name +field is a null-terminated string giving the pathname +from which the shared object was loaded. +.pp +to understand the meaning of the +.i dlpi_phdr +and +.i dlpi_phnum +fields, we need to be aware that an elf shared object consists +of a number of segments, each of which has a corresponding +program header describing the segment. +the +.i dlpi_phdr +field is a pointer to an array of the program headers for this +shared object. +the +.i dlpi_phnum +field indicates the size of this array. +.pp +these program headers are structures of the following form: +.pp +.in +4n +.ex +typedef struct { + elf32_word p_type; /* segment type */ + elf32_off p_offset; /* segment file offset */ + elf32_addr p_vaddr; /* segment virtual address */ + elf32_addr p_paddr; /* segment physical address */ + elf32_word p_filesz; /* segment size in file */ + elf32_word p_memsz; /* segment size in memory */ + elf32_word p_flags; /* segment flags */ + elf32_word p_align; /* segment alignment */ +} elf32_phdr; +.ee +.in +.pp +note that we can calculate the location of a particular program header, +.ir x , +in virtual memory using the formula: +.pp +.in +4n +.ex +addr == info\->dlpi_addr + info\->dlpi_phdr[x].p_vaddr; +.ee +.in +.pp +possible values for +.i p_type +include the following (see +.ir +for further details): +.pp +.in +4n +.ex +#define pt_load 1 /* loadable program segment */ +#define pt_dynamic 2 /* dynamic linking information */ +#define pt_interp 3 /* program interpreter */ +#define pt_note 4 /* auxiliary information */ +#define pt_shlib 5 /* reserved */ +#define pt_phdr 6 /* entry for header table itself */ +#define pt_tls 7 /* thread\-local storage segment */ +#define pt_gnu_eh_frame 0x6474e550 /* gcc .eh_frame_hdr segment */ +#define pt_gnu_stack 0x6474e551 /* indicates stack executability */ +.\" for pt_gnu_stack, see http://www.airs.com/blog/archives/518 +#define pt_gnu_relro 0x6474e552 /* read\-only after relocation */ +.ee +.in +.sh return value +the +.br dl_iterate_phdr () +function returns whatever value was returned by the last call to +.ir callback . +.sh versions +.br dl_iterate_phdr () +has been supported in glibc since version 2.2.4. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br dl_iterate_phdr () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +the +.br dl_iterate_phdr () +function is not specified in any standard. +various other systems provide a version of this function, +although details of the returned +.i dl_phdr_info +structure differ. +on the bsds and solaris, the structure includes the fields +.ir dlpi_addr , +.ir dlpi_name , +.ir dlpi_phdr , +and +.ir dlpi_phnum +in addition to other implementation-specific fields. +.sh notes +future versions of the c library may add further fields to the +.ir dl_phdr_info +structure; in that event, the +.i size +argument provides a mechanism for the callback function to discover +whether it is running on a system with added fields. +.pp +the first object visited by +.ir callback +is the main program. +for the main program, the +.i dlpi_name +field will be an empty string. +.sh examples +the following program displays a list of pathnames of the +shared objects it has loaded. +for each shared object, the program lists some information +(virtual address, size, flags, and type) +for each of the objects elf segments. +.pp +the following shell session demonstrates the output +produced by the program on an x86-64 system. +the first shared object for which output is displayed +(where the name is an empty string) +is the main program. +.pp +.in +4n +.ex +$ \fb./a.out\fp +name: "" (9 segments) + 0: [ 0x400040; memsz: 1f8] flags: 0x5; pt_phdr + 1: [ 0x400238; memsz: 1c] flags: 0x4; pt_interp + 2: [ 0x400000; memsz: ac4] flags: 0x5; pt_load + 3: [ 0x600e10; memsz: 240] flags: 0x6; pt_load + 4: [ 0x600e28; memsz: 1d0] flags: 0x6; pt_dynamic + 5: [ 0x400254; memsz: 44] flags: 0x4; pt_note + 6: [ 0x400970; memsz: 3c] flags: 0x4; pt_gnu_eh_frame + 7: [ (nil); memsz: 0] flags: 0x6; pt_gnu_stack + 8: [ 0x600e10; memsz: 1f0] flags: 0x4; pt_gnu_relro +name: "linux\-vdso.so.1" (4 segments) + 0: [0x7ffc6edd1000; memsz: e89] flags: 0x5; pt_load + 1: [0x7ffc6edd1360; memsz: 110] flags: 0x4; pt_dynamic + 2: [0x7ffc6edd17b0; memsz: 3c] flags: 0x4; pt_note + 3: [0x7ffc6edd17ec; memsz: 3c] flags: 0x4; pt_gnu_eh_frame +name: "/lib64/libc.so.6" (10 segments) + 0: [0x7f55712ce040; memsz: 230] flags: 0x5; pt_phdr + 1: [0x7f557145b980; memsz: 1c] flags: 0x4; pt_interp + 2: [0x7f55712ce000; memsz: 1b6a5c] flags: 0x5; pt_load + 3: [0x7f55716857a0; memsz: 9240] flags: 0x6; pt_load + 4: [0x7f5571688b80; memsz: 1f0] flags: 0x6; pt_dynamic + 5: [0x7f55712ce270; memsz: 44] flags: 0x4; pt_note + 6: [0x7f55716857a0; memsz: 78] flags: 0x4; pt_tls + 7: [0x7f557145b99c; memsz: 544c] flags: 0x4; pt_gnu_eh_frame + 8: [0x7f55712ce000; memsz: 0] flags: 0x6; pt_gnu_stack + 9: [0x7f55716857a0; memsz: 3860] flags: 0x4; pt_gnu_relro +name: "/lib64/ld\-linux\-x86\-64.so.2" (7 segments) + 0: [0x7f557168f000; memsz: 20828] flags: 0x5; pt_load + 1: [0x7f55718afba0; memsz: 15a8] flags: 0x6; pt_load + 2: [0x7f55718afe10; memsz: 190] flags: 0x6; pt_dynamic + 3: [0x7f557168f1c8; memsz: 24] flags: 0x4; pt_note + 4: [0x7f55716acec4; memsz: 604] flags: 0x4; pt_gnu_eh_frame + 5: [0x7f557168f000; memsz: 0] flags: 0x6; pt_gnu_stack + 6: [0x7f55718afba0; memsz: 460] flags: 0x4; pt_gnu_relro +.ee +.in +.ss program source +\& +.ex +#define _gnu_source +#include +#include +#include +#include + +static int +callback(struct dl_phdr_info *info, size_t size, void *data) +{ + char *type; + int p_type; + + printf("name: \e"%s\e" (%d segments)\en", info\->dlpi_name, + info\->dlpi_phnum); + + for (int j = 0; j < info\->dlpi_phnum; j++) { + p_type = info\->dlpi_phdr[j].p_type; + type = (p_type == pt_load) ? "pt_load" : + (p_type == pt_dynamic) ? "pt_dynamic" : + (p_type == pt_interp) ? "pt_interp" : + (p_type == pt_note) ? "pt_note" : + (p_type == pt_interp) ? "pt_interp" : + (p_type == pt_phdr) ? "pt_phdr" : + (p_type == pt_tls) ? "pt_tls" : + (p_type == pt_gnu_eh_frame) ? "pt_gnu_eh_frame" : + (p_type == pt_gnu_stack) ? "pt_gnu_stack" : + (p_type == pt_gnu_relro) ? "pt_gnu_relro" : null; + + printf(" %2d: [%14p; memsz:%7jx] flags: %#jx; ", j, + (void *) (info\->dlpi_addr + info\->dlpi_phdr[j].p_vaddr), + (uintmax_t) info\->dlpi_phdr[j].p_memsz, + (uintmax_t) info\->dlpi_phdr[j].p_flags); + if (type != null) + printf("%s\en", type); + else + printf("[other (%#x)]\en", p_type); + } + + return 0; +} + +int +main(int argc, char *argv[]) +{ + dl_iterate_phdr(callback, null); + + exit(exit_success); +} +.ee +.sh see also +.br ldd (1), +.br objdump (1), +.br readelf (1), +.br dladdr (3), +.br dlopen (3), +.br elf (5), +.br ld.so (8) +.pp +.ir "executable and linking format specification" , +available at various locations online. +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1993 michael haardt +.\" (michael@moria.de) +.\" fri apr 2 11:32:09 met dst 1993 +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" modified sat jul 24 15:12:05 1993 by rik faith +.\" modified tue aug 1 16:27 1995 by jochen karrer +.\" +.\" modified tue oct 22 08:11:14 edt 1996 by eric s. raymond +.\" modified mon feb 15 17:28:41 cet 1999 by andries e. brouwer +.\" modified, 27 may 2004, michael kerrisk +.\" added notes on capability requirements +.\" +.th ioperm 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +ioperm \- set port input/output permissions +.sh synopsis +.nf +.b #include +.pp +.bi "int ioperm(unsigned long " from ", unsigned long " num ", int " turn_on ); +.fi +.sh description +.br ioperm () +sets the port access permission bits for the calling thread for +.i num +bits starting from port address +.ir from . +if +.i turn_on +is nonzero, then permission for the specified bits is enabled; +otherwise it is disabled. +if +.i turn_on +is nonzero, the calling thread must be privileged +.rb ( cap_sys_rawio ). +.pp +before linux 2.6.8, +only the first 0x3ff i/o ports could be specified in this manner. +for more ports, the +.br iopl (2) +system call had to be used (with a +.i level +argument of 3). +since linux 2.6.8, 65,536 i/o ports can be specified. +.pp +permissions are inherited by the child created by +.br fork (2) +(but see notes). +permissions are preserved across +.br execve (2); +this is useful for giving port access permissions to unprivileged +programs. +.pp +this call is mostly for the i386 architecture. +on many other architectures it does not exist or will always +return an error. +.sh return value +on success, zero is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b einval +invalid values for +.i from +or +.ir num . +.tp +.b eio +(on powerpc) this call is not supported. +.tp +.b enomem +.\" could not allocate i/o bitmap. +out of memory. +.tp +.b eperm +the calling thread has insufficient privilege. +.sh conforming to +.br ioperm () +is linux-specific and should not be used in programs +intended to be portable. +.sh notes +the +.i /proc/ioports +file shows the i/o ports that are currently allocated on the system. +.pp +before linux 2.4, +permissions were not inherited by a child created by +.br fork (2). +.pp +glibc has an +.br ioperm () +prototype both in +.i +and in +.ir . +avoid the latter, it is available on i386 only. +.sh see also +.br iopl (2), +.br outb (2), +.br capabilities (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/getrpcent_r.3 + +.so man3/dlsym.3 + +.so man3/creal.3 + +.so man2/readv.2 + +.so man3/resolver.3 + +.so man3/fenv.3 + +.\" copyright (c) 1993 michael haardt (michael@moria.de), +.\" fri apr 2 11:32:09 met dst 1993 +.\" and andries brouwer (aeb@cwi.nl), fri feb 14 21:47:50 1997. +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" modified sun jul 25 10:45:30 1993 by rik faith (faith@cs.unc.edu) +.\" modified sun jul 21 21:25:26 1996 by andries brouwer (aeb@cwi.nl) +.\" modified mon oct 21 17:47:19 1996 by eric s. raymond (esr@thyrsus.com) +.\" modified wed aug 27 20:28:58 1997 by nicolás lichtmaier (nick@debian.org) +.\" modified mon sep 21 00:00:26 1998 by andries brouwer (aeb@cwi.nl) +.\" modified wed jan 24 06:37:24 2001 by eric s. raymond (esr@thyrsus.com) +.\" modified thu dec 13 23:53:27 2001 by martin schulze +.\" +.th environ 7 2021-03-22 "linux" "linux programmer's manual" +.sh name +environ \- user environment +.sh synopsis +.nf +.bi "extern char **" environ ; +.fi +.sh description +the variable +.i environ +points to an array of pointers to strings called the "environment". +the last pointer in this array has the value null. +this array of strings is made available to the process by the +.br execve (2) +call when a new program is started. +when a child process is created via +.br fork (2), +it inherits a +.i copy +of its parent's environment. +.pp +by convention, the strings in +.i environ +have the form "\finame\fp\fb=\fp\fivalue\fp". +the name is case-sensitive and may not contain +the character "\fb=\fp". +the value can be anything that can be represented as a string. +the name and the value may not contain an embedded null byte (\(aq\e0\(aq), +since this is assumed to terminate the string. +.pp +environment variables may be placed in the shell's environment by the +.i export +command in +.br sh (1), +or by the +.i setenv +command if you use +.br csh (1). +.pp +the initial environment of the shell is populated in various ways, +such as definitions from +.ir /etc/environment +that are processed by +.br pam_env (8) +for all users at login time (on systems that employ +.br pam (8)). +in addition, various shell initialization scripts, such as the system-wide +.ir /etc/profile +script and per-user initializations script may include commands +that add variables to the shell's environment; +see the manual page of your preferred shell for details. +.pp +bourne-style shells support the syntax +.pp + name=value command +.pp +to create an environment variable definition only in the scope +of the process that executes +.ir command . +multiple variable definitions, separated by white space, may precede +.ir command . +.pp +arguments may also be placed in the +environment at the point of an +.br exec (3). +a c program can manipulate its environment using the functions +.br getenv (3), +.br putenv (3), +.br setenv (3), +and +.br unsetenv (3). +.pp +what follows is a list of environment variables typically seen on a +system. +this list is incomplete and includes only common variables seen +by average users in their day-to-day routine. +environment variables specific to a particular program or library function +are documented in the environment section of the appropriate manual page. +.tp +.b user +the name of the logged-in user (used by some bsd-derived programs). +set at login time, see section notes below. +.tp +.b logname +the name of the logged-in user (used by some system-v derived programs). +set at login time, see section notes below. +.tp +.b home +a user's login directory. +set at login time, see section notes below. +.tp +.b lang +the name of a locale to use for locale categories when not overridden +by +.b lc_all +or more specific environment variables such as +.br lc_collate , +.br lc_ctype , +.br lc_messages , +.br lc_monetary , +.br lc_numeric , +and +.br lc_time +(see +.br locale (7) +for further details of the +.br lc_* +environment variables). +.tp +.b path +the sequence of directory prefixes that +.br sh (1) +and many other +programs employ when searching for an executable file that is specified +as a simple filename (i.a., a pathname that contains no slashes). +the prefixes are separated by colons (\fb:\fp). +the list of prefixes is searched from beginning to end, +by checking the pathname formed by concatenating +a prefix, a slash, and the filename, +until a file with execute permission is found. +.ip +as a legacy feature, a zero-length prefix +(specified as two adjacent colons, or an initial or terminating colon) +is interpreted to mean the current working directory. +however, use of this feature is deprecated, +and posix notes that a conforming application shall use +an explicit pathname (e.g., +.ir . ) +to specify the current working directory. +.ip +analogously to +.br path , +one has +.b cdpath +used by some shells to find the target +of a change directory command, +.b manpath +used by +.br man (1) +to find manual pages, and so on. +.tp +.b pwd +the current working directory. +set by some shells. +.tp +.b shell +the absolute pathname of the user's login shell. +set at login time, see section notes below. +.tp +.b term +the terminal type for which output is to be prepared. +.tp +.b pager +the user's preferred utility to display text files. +any string acceptable as a command-string operand to the +.i sh\ \-c +command shall be valid. +if +.b pager +is null or is not set, +then applications that launch a pager will default to a program such as +.br less (1) +or +.br more (1). +.tp +.br editor / visual +the user's preferred utility to edit text files. +any string acceptable as a command_string operand to the +.i sh\ \-c +command shall be valid. +.\" .tp +.\" .b browser +.\" the user's preferred utility to browse urls. sequence of colon-separated +.\" browser commands. see http://www.catb.org/\(tiesr/browser/ . +.pp +note that the behavior of many programs and library routines is +influenced by the presence or value of certain environment variables. +examples include the following: +.ip * 3 +the variables +.br lang ", " language ", " nlspath ", " locpath , +.br lc_all ", " lc_messages , +and so on influence locale handling; see +.br catopen (3), +.br gettext (3), +and +.br locale (7). +.ip * +.b tmpdir +influences the path prefix of names created by +.br tempnam (3) +and other routines, and the temporary directory used by +.br sort (1) +and other programs. +.ip * +.br ld_library_path ", " ld_preload , +and other +.br ld_* +variables influence the behavior of the dynamic loader/linker. +see also +.br ld.so (8). +.ip * +.b posixly_correct +makes certain programs and library routines follow +the prescriptions of posix. +.ip * +the behavior of +.br malloc (3) +is influenced by +.b malloc_* +variables. +.ip * +the variable +.b hostaliases +gives the name of a file containing aliases +to be used with +.br gethostbyname (3). +.ip * +.br tz " and " tzdir +give timezone information used by +.br tzset (3) +and through that by functions like +.br ctime (3), +.br localtime (3), +.br mktime (3), +.br strftime (3). +see also +.br tzselect (8). +.ip * +.b termcap +gives information on how to address a given terminal +(or gives the name of a file containing such information). +.ip * +.br columns " and " lines +tell applications about the window size, possibly overriding the actual size. +.ip * +.br printer " or " lpdest +may specify the desired printer to use. +see +.br lpr (1). +.sh notes +historically and by standard, +.i environ +must be declared in the user program. +however, as a (nonstandard) programmer convenience, +.i environ +is declared in the header file +.i +if the +.b _gnu_source +feature test macro is defined (see +.br feature_test_macros (7)). +.pp +the +.br prctl (2) +.b pr_set_mm_env_start +and +.b pr_set_mm_env_end +operations can be used to control the location of the process's environment. +.pp +the +.br home , +.br logname , +.br shell , +and +.b user +variables are set when the user is changed via a +session management interface, typically by a program such as +.br login (1) +from a user database (such as +.br passwd (5)). +(switching to the root user using +.br su (1) +may result in a mixed environment where +.b logname +and +.b user +are retained from old user; see the +.br su (1) +manual page.) +.sh bugs +clearly there is a security risk here. +many a system command has been +tricked into mischief by a user who specified unusual values for +.br ifs " or " ld_library_path . +.pp +there is also the risk of name space pollution. +programs like +.i make +and +.i autoconf +allow overriding of default utility names from the +environment with similarly named variables in all caps. +thus one uses +.b cc +to select the desired c compiler (and similarly +.br make , +.br ar , +.br as , +.br fc , +.br ld , +.br lex , +.br rm , +.br yacc , +etc.). +however, in some traditional uses such an environment variable +gives options for the program instead of a pathname. +thus, one has +.b more +and +.br less . +such usage is considered mistaken, and to be avoided in new +programs. +.sh see also +.br bash (1), +.br csh (1), +.br env (1), +.br login (1), +.br printenv (1), +.br sh (1), +.br su (1), +.br tcsh (1), +.br execve (2), +.br clearenv (3), +.br exec (3), +.br getenv (3), +.br putenv (3), +.br setenv (3), +.br unsetenv (3), +.br locale (7), +.br ld.so (8), +.br pam_env (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/rcmd.3 + +.so man7/iso_8859-8.7 + +.so man3/xdr.3 + +.so man3/unlocked_stdio.3 + +.\" copyright (c) 1996 eric s. raymond +.\" and copyright (c) andries brouwer +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" this is combined from many sources, including notes by aeb and +.\" research by esr. portions derive from a writeup by roman czyborra. +.\" +.\" changes also by david starner . +.\" +.th charsets 7 2020-08-13 "linux" "linux programmer's manual" +.sh name +charsets \- character set standards and internationalization +.sh description +this manual page gives an overview on different character set standards +and how they were used on linux before unicode became ubiquitous. +some of this information is still helpful for people working with legacy +systems and documents. +.pp +standards discussed include such as +ascii, gb 2312, iso 8859, jis, koi8-r, ks, and unicode. +.pp +the primary emphasis is on character sets that were actually used by +locale character sets, not the myriad others that could be found in data +from other systems. +.ss ascii +ascii (american standard code for information interchange) is the original +7-bit character set, originally designed for american english. +also known as us-ascii. +it is currently described by the iso 646:1991 irv +(international reference version) standard. +.pp +various ascii variants replacing the dollar sign with other currency +symbols and replacing punctuation with non-english alphabetic +characters to cover german, french, spanish, and others in 7 bits +emerged. +all are deprecated; +glibc does not support locales whose character sets are not true +supersets of ascii. +.pp +as unicode, when using utf-8, is ascii-compatible, plain ascii text +still renders properly on modern utf-8 using systems. +.ss iso 8859 +iso 8859 is a series of 15 8-bit character sets, all of which have ascii +in their low (7-bit) half, invisible control characters in positions +128 to 159, and 96 fixed-width graphics in positions 160\(en255. +.pp +of these, the most important is iso 8859-1 +("latin alphabet no .1" / latin-1). +it was widely adopted and supported by different systems, +and is gradually being replaced with unicode. +the iso 8859-1 characters are also the first 256 characters of unicode. +.pp +console support for the other 8859 character sets is available under +linux through user-mode utilities (such as +.br setfont (8)) +that modify keyboard bindings and the ega graphics +table and employ the "user mapping" font table in the console +driver. +.pp +here are brief descriptions of each set: +.tp +8859-1 (latin-1) +latin-1 covers many west european languages such as albanian, basque, +danish, english, faroese, galician, icelandic, irish, italian, +norwegian, portuguese, spanish, and swedish. +the lack of the ligatures dutch ij/ij, french œ, and old-style „german“ +quotation marks was considered tolerable. +.tp +8859-2 (latin-2) +latin-2 supports many latin-written central and east european +languages such as bosnian, croatian, czech, german, hungarian, polish, +slovak, and slovene. +replacing romanian ș/ț with ş/ţ was considered tolerable. +.tp +8859-3 (latin-3) +latin-3 was designed to cover of esperanto, maltese, and turkish, but +8859-9 later superseded it for turkish. +.tp +8859-4 (latin-4) +latin-4 introduced letters for north european languages such as +estonian, latvian, and lithuanian, but was superseded by 8859-10 and +8859-13. +.tp +8859-5 +cyrillic letters supporting bulgarian, byelorussian, macedonian, +russian, serbian, and (almost completely) ukrainian. +it was never widely used, see the discussion of koi8-r/koi8-u below. +.tp +8859-6 +was created for arabic. +the 8859-6 glyph table is a fixed font of separate +letter forms, but a proper display engine should combine these +using the proper initial, medial, and final forms. +.tp +8859-7 +was created for modern greek in 1987, updated in 2003. +.tp +8859-8 +supports modern hebrew without niqud (punctuation signs). +niqud and full-fledged biblical hebrew were outside the scope of this +character set. +.tp +8859-9 (latin-5) +this is a variant of latin-1 that replaces icelandic letters with +turkish ones. +.tp +8859-10 (latin-6) +latin-6 added the inuit (greenlandic) and sami (lappish) letters that were +missing in latin-4 to cover the entire nordic area. +.tp +8859-11 +supports the thai alphabet and is nearly identical to the tis-620 +standard. +.tp +8859-12 +this set does not exist. +.tp +8859-13 (latin-7) +supports the baltic rim languages; in particular, it includes latvian +characters not found in latin-4. +.tp +8859-14 (latin-8) +this is the celtic character set, covering old irish, manx, gaelic, +welsh, cornish, and breton. +.tp +8859-15 (latin-9) +latin-9 is similar to the widely used latin-1 but replaces some less +common symbols with the euro sign and french and finnish letters that +were missing in latin-1. +.tp +8859-16 (latin-10) +this set covers many southeast european languages, and most +importantly supports romanian more completely than latin-2. +.ss koi8-r / koi8-u +koi8-r is a non-iso character set popular in russia before unicode. +the lower half is ascii; +the upper is a cyrillic character set somewhat better designed than +iso 8859-5. +koi8-u, based on koi8-r, has better support for ukrainian. +neither of these sets are iso-2022 compatible, +unlike the iso 8859 series. +.pp +console support for koi8-r is available under linux through user-mode +utilities that modify keyboard bindings and the ega graphics table, +and employ the "user mapping" font table in the console driver. +.ss gb 2312 +gb 2312 is a mainland chinese national standard character set used +to express simplified chinese. +just like jis x 0208, characters are +mapped into a 94x94 two-byte matrix used to construct euc-cn. +euc-cn +is the most important encoding for linux and includes ascii and +gb 2312. +note that euc-cn is often called as gb, gb 2312, or cn-gb. +.ss big5 +big5 was a popular character set in taiwan to express traditional +chinese. +(big5 is both a character set and an encoding.) +it is a superset of ascii. +non-ascii characters are expressed in two bytes. +bytes 0xa1\(en0xfe are used as leading bytes for two-byte characters. +big5 and its extension were widely used in taiwan and hong kong. +it is not iso 2022 compliant. +.\" thanks to tomohiro kubota for the following sections about +.\" national standards. +.ss jis x 0208 +jis x 0208 is a japanese national standard character set. +though there are some more japanese national standard character sets (like +jis x 0201, jis x 0212, and jis x 0213), this is the most important one. +characters are mapped into a 94x94 two-byte matrix, +whose each byte is in the range 0x21\(en0x7e. +note that jis x 0208 is a character set, not an encoding. +this means that jis x 0208 +itself is not used for expressing text data. +jis x 0208 is used +as a component to construct encodings such as euc-jp, shift_jis, +and iso-2022-jp. +euc-jp is the most important encoding for linux +and includes ascii and jis x 0208. +in euc-jp, jis x 0208 +characters are expressed in two bytes, each of which is the +jis x 0208 code plus 0x80. +.ss ks x 1001 +ks x 1001 is a korean national standard character set. +just as +jis x 0208, characters are mapped into a 94x94 two-byte matrix. +ks x 1001 is used like jis x 0208, as a component +to construct encodings such as euc-kr, johab, and iso-2022-kr. +euc-kr is the most important encoding for linux and includes +ascii and ks x 1001. +ks c 5601 is an older name for ks x 1001. +.ss iso 2022 and iso 4873 +the iso 2022 and 4873 standards describe a font-control model +based on vt100 practice. +this model is (partially) supported +by the linux kernel and by +.br xterm (1). +several iso 2022-based character encodings have been defined, +especially for japanese. +.pp +there are 4 graphic character sets, called g0, g1, g2, and g3, +and one of them is the current character set for codes with +high bit zero (initially g0), and one of them is the current +character set for codes with high bit one (initially g1). +each graphic character set has 94 or 96 characters, and is +essentially a 7-bit character set. +it uses codes either +040\(en0177 (041\(en0176) or 0240\(en0377 (0241\(en0376). +g0 always has size 94 and uses codes 041\(en0176. +.pp +switching between character sets is done using the shift functions +\fb\(han\fp (so or ls1), \fb\(hao\fp (si or ls0), esc n (ls2), esc o (ls3), +esc n (ss2), esc o (ss3), esc \(ti (ls1r), esc } (ls2r), esc | (ls3r). +the function ls\fin\fp makes character set g\fin\fp the current one +for codes with high bit zero. +the function ls\fin\fpr makes character set g\fin\fp the current one +for codes with high bit one. +the function ss\fin\fp makes character set g\fin\fp (\fin\fp=2 or 3) +the current one for the next character only (regardless of the value +of its high order bit). +.pp +a 94-character set is designated as g\fin\fp character set +by an escape sequence esc ( xx (for g0), esc ) xx (for g1), +esc * xx (for g2), esc + xx (for g3), where xx is a symbol +or a pair of symbols found in the iso 2375 international +register of coded character sets. +for example, esc ( @ selects the iso 646 character set as g0, +esc ( a selects the uk standard character set (with pound +instead of number sign), esc ( b selects ascii (with dollar +instead of currency sign), esc ( m selects a character set +for african languages, esc ( ! a selects the cuban character +set, and so on. +.pp +a 96-character set is designated as g\fin\fp character set +by an escape sequence esc \- xx (for g1), esc . xx (for g2) +or esc / xx (for g3). +for example, esc \- g selects the hebrew alphabet as g1. +.pp +a multibyte character set is designated as g\fin\fp character set +by an escape sequence esc $ xx or esc $ ( xx (for g0), +esc $ ) xx (for g1), esc $ * xx (for g2), esc $ + xx (for g3). +for example, esc $ ( c selects the korean character set for g0. +the japanese character set selected by esc $ b has a more +recent version selected by esc & @ esc $ b. +.pp +iso 4873 stipulates a narrower use of character sets, where g0 +is fixed (always ascii), so that g1, g2, and g3 +can be invoked only for codes with the high order bit set. +in particular, \fb\(han\fp and \fb\(hao\fp are not used anymore, esc ( xx +can be used only with xx=b, and esc ) xx, esc * xx, esc + xx +are equivalent to esc \- xx, esc . xx, esc / xx, respectively. +.ss tis-620 +tis-620 is a thai national standard character set and a superset +of ascii. +in the same fashion as the iso 8859 series, thai characters are mapped into +0xa1\(en0xfe. +.ss unicode +unicode (iso 10646) is a standard which aims to unambiguously represent +every character in every human language. +unicode's structure permits 20.1 bits to encode every character. +since most computers don't include 20.1-bit integers, unicode is +usually encoded as 32-bit integers internally and either a series of +16-bit integers (utf-16) (needing two 16-bit integers only when +encoding certain rare characters) or a series of 8-bit bytes (utf-8). +.pp +linux represents unicode using the 8-bit unicode transformation format +(utf-8). +utf-8 is a variable length encoding of unicode. +it uses 1 +byte to code 7 bits, 2 bytes for 11 bits, 3 bytes for 16 bits, 4 bytes +for 21 bits, 5 bytes for 26 bits, 6 bytes for 31 bits. +.pp +let 0,1,x stand for a zero, one, or arbitrary bit. +a byte 0xxxxxxx +stands for the unicode 00000000 0xxxxxxx which codes the same symbol +as the ascii 0xxxxxxx. +thus, ascii goes unchanged into utf-8, and +people using only ascii do not notice any change: not in code, and not +in file size. +.pp +a byte 110xxxxx is the start of a 2-byte code, and 110xxxxx 10yyyyyy +is assembled into 00000xxx xxyyyyyy. +a byte 1110xxxx is the start +of a 3-byte code, and 1110xxxx 10yyyyyy 10zzzzzz is assembled +into xxxxyyyy yyzzzzzz. +(when utf-8 is used to code the 31-bit iso 10646 +then this progression continues up to 6-byte codes.) +.pp +for most texts in iso 8859 character sets, this means that the +characters outside of ascii are now coded with two bytes. +this tends +to expand ordinary text files by only one or two percent. +for russian +or greek texts, this expands ordinary text files by 100%, since text in +those languages is mostly outside of ascii. +for japanese users this means +that the 16-bit codes now in common use will take three bytes. +while there are algorithmic conversions from some character sets +(especially iso 8859-1) to unicode, general conversion requires +carrying around conversion tables, which can be quite large for 16-bit +codes. +.pp +note that utf-8 is self-synchronizing: 10xxxxxx is a tail, any other +byte is the head of a code. +note that the only way ascii bytes occur +in a utf-8 stream, is as themselves. +in particular, there are no +embedded nuls (\(aq\e0\(aq) or \(aq/\(aqs that form part of some larger code. +.pp +since ascii, and, in particular, nul and \(aq/\(aq, are unchanged, the +kernel does not notice that utf-8 is being used. +it does not care at +all what the bytes it is handling stand for. +.pp +rendering of unicode data streams is typically handled through +"subfont" tables which map a subset of unicode to glyphs. +internally +the kernel uses unicode to describe the subfont loaded in video ram. +this means that in the linux console in utf-8 mode, one can use a character +set with 512 different symbols. +this is not enough for japanese, chinese, and +korean, but it is enough for most other purposes. +.sh see also +.br iconv (1), +.br ascii (7), +.br iso_8859\-1 (7), +.br unicode (7), +.br utf\-8 (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/open.2 + +.so man2/outb.2 + +.so man3/drand48_r.3 + +.so man3/ecvt_r.3 + +.so man7/system_data_types.7 + +.so man3/y0.3 + +.\" copyright 2001 walter harms (walter.harms@informatik.uni-oldenburg.de) +.\" and copyright 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified, 2001-12-26, aeb +.\" 2008-09-07, mtk, various rewrites; added an example program. +.\" +.th getdate 3 2021-03-22 "" "linux programmer's manual" +.sh name +getdate, getdate_r \- convert a date-plus-time string to broken-down time +.sh synopsis +.nf +.b "#include " +.pp +.bi "struct tm *getdate(const char *" string ); +.pp +.b "extern int getdate_err;" +.pp +.b "#include " +.pp +.bi "int getdate_r(const char *restrict " string ", struct tm *restrict " res ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br getdate (): +.nf + _xopen_source >= 500 +.\" || _xopen_source && _xopen_source_extended +.fi +.pp +.br getdate_r (): +.nf + _gnu_source +.fi +.sh description +the function +.br getdate () +converts a string representation of a date and time, +contained in the buffer pointed to by +.ir string , +into a broken-down time. +the broken-down time is stored in a +.i tm +structure, and a pointer to this +structure is returned as the function result. +this +.i tm +structure is allocated in static storage, +and consequently it will be overwritten by further calls to +.br getdate (). +.pp +in contrast to +.br strptime (3), +(which has a +.i format +argument), +.br getdate () +uses the formats found in the file +whose full pathname is given in the environment variable +.br datemsk . +the first line in the file that matches the given input string +is used for the conversion. +.pp +the matching is done case insensitively. +superfluous whitespace, either in the pattern or in the string to +be converted, is ignored. +.pp +the conversion specifications that a pattern can contain are those given for +.br strptime (3). +one more conversion specification is specified in posix.1-2001: +.tp +.b %z +timezone name. +.\" fixme is it (still) true that %z is not supported in glibc? +.\" looking at the glibc 2.21 source code, where the implementation uses +.\" strptime(), suggests that it might be supported. +this is not implemented in glibc. +.pp +when +.b %z +is given, the structure containing the broken-down time +is initialized with values corresponding to the current +time in the given timezone. +otherwise, the structure is initialized to the broken-down time +corresponding to the current local time (as by a call to +.br localtime (3)). +.pp +when only the day of the week is given, +the day is taken to be the first such day +on or after today. +.pp +when only the month is given (and no year), the month is taken to +be the first such month equal to or after the current month. +if no day is given, it is the first day of the month. +.pp +when no hour, minute, and second are given, the current +hour, minute, and second are taken. +.pp +if no date is given, but we know the hour, then that hour is taken +to be the first such hour equal to or after the current hour. +.pp +.br getdate_r () +is a gnu extension that provides a reentrant version of +.br getdate (). +rather than using a global variable to report errors and a static buffer +to return the broken down time, +it returns errors via the function result value, +and returns the resulting broken-down time in the +caller-allocated buffer pointed to by the argument +.ir res . +.sh return value +when successful, +.br getdate () +returns a pointer to a +.ir "struct tm" . +otherwise, it returns null and sets the global variable +.ir getdate_err +to one of the error numbers shown below. +changes to +.i errno +are unspecified. +.pp +on success +.br getdate_r () +returns 0; +on error it returns one of the error numbers shown below. +.sh errors +the following errors are returned via +.ir getdate_err +(for +.br getdate ()) +or as the function result (for +.br getdate_r ()): +.tp 4n +.b 1 +the +.b datemsk +environment variable is not defined, or its value is an empty string. +.tp +.b 2 +the template file specified by +.b datemsk +cannot be opened for reading. +.tp +.b 3 +failed to get file status information. +.\" stat() +.tp +.b 4 +the template file is not a regular file. +.tp +.b 5 +an error was encountered while reading the template file. +.tp +.b 6 +memory allocation failed (not enough memory available). +.\" error 6 doesn't seem to occur in glibc +.tp +.b 7 +there is no line in the file that matches the input. +.tp +.b 8 +invalid input specification. +.sh environment +.tp +.b datemsk +file containing format patterns. +.tp +.br tz ", " lc_time +variables used by +.br strptime (3). +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lb lb lbx +l l l. +interface attribute value +t{ +.br getdate () +t} thread safety t{ +mt-unsafe race:getdate env locale +t} +t{ +.br getdate_r () +t} thread safety t{ +mt-safe env locale +t} +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +the posix.1 specification for +.br strptime (3) +contains conversion specifications using the +.b %e +or +.b %o +modifier, while such specifications are not given for +.br getdate (). +in glibc, +.br getdate () +is implemented using +.br strptime (3), +so that precisely the same conversions are supported by both. +.sh examples +the program below calls +.br getdate () +for each of its command-line arguments, +and for each call displays the values in the fields of the returned +.i tm +structure. +the following shell session demonstrates the operation of the program: +.pp +.in +4n +.ex +.rb "$" " tfile=$pwd/tfile" +.rb "$" " echo \(aq%a\(aq > $tfile " " # full name of the day of the week" +.rb "$" " echo \(aq%t\(aq >> $tfile" " # iso date (yyyy\-mm\-dd)" +.rb "$" " echo \(aq%f\(aq >> $tfile" " # time (hh:mm:ss)" +.rb "$" " date" +.rb "$" " export datemsk=$tfile" +.rb "$" " ./a.out tuesday \(aq2009\-12\-28\(aq \(aq12:22:33\(aq" +sun sep 7 06:03:36 cest 2008 +call 1 ("tuesday") succeeded: + tm_sec = 36 + tm_min = 3 + tm_hour = 6 + tm_mday = 9 + tm_mon = 8 + tm_year = 108 + tm_wday = 2 + tm_yday = 252 + tm_isdst = 1 +call 2 ("2009\-12\-28") succeeded: + tm_sec = 36 + tm_min = 3 + tm_hour = 6 + tm_mday = 28 + tm_mon = 11 + tm_year = 109 + tm_wday = 1 + tm_yday = 361 + tm_isdst = 0 +call 3 ("12:22:33") succeeded: + tm_sec = 33 + tm_min = 22 + tm_hour = 12 + tm_mday = 7 + tm_mon = 8 + tm_year = 108 + tm_wday = 0 + tm_yday = 250 + tm_isdst = 1 +.ee +.in +.ss program source +\& +.ex +#define _gnu_source +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + struct tm *tmp; + + for (int j = 1; j < argc; j++) { + tmp = getdate(argv[j]); + + if (tmp == null) { + printf("call %d failed; getdate_err = %d\en", + j, getdate_err); + continue; + } + + printf("call %d (\e"%s\e") succeeded:\en", j, argv[j]); + printf(" tm_sec = %d\en", tmp\->tm_sec); + printf(" tm_min = %d\en", tmp\->tm_min); + printf(" tm_hour = %d\en", tmp\->tm_hour); + printf(" tm_mday = %d\en", tmp\->tm_mday); + printf(" tm_mon = %d\en", tmp\->tm_mon); + printf(" tm_year = %d\en", tmp\->tm_year); + printf(" tm_wday = %d\en", tmp\->tm_wday); + printf(" tm_yday = %d\en", tmp\->tm_yday); + printf(" tm_isdst = %d\en", tmp\->tm_isdst); + } + + exit(exit_success); +} +.ee +.sh see also +.br time (2), +.br localtime (3), +.br setlocale (3), +.br strftime (3), +.br strptime (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/tsearch.3 + +.so man3/stailq.3 + +.so man7/system_data_types.7 + +.so man2/link.2 + +.so man3/sigsetops.3 + +.so man3/finite.3 + +.so man3/stdio_ext.3 + +.so man3/getttyent.3 + +.so man3/cos.3 + +.\" copyright 1993 mitchum dsouza +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified thu dec 13 22:51:19 2001 by martin schulze +.\" modified 2001-12-14 aeb +.\" +.th catopen 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +catopen, catclose \- open/close a message catalog +.sh synopsis +.nf +.b #include +.pp +.bi "nl_catd catopen(const char *" name ", int " flag ); +.bi "int catclose(nl_catd " catalog ); +.fi +.sh description +the function +.br catopen () +opens a message catalog and returns a catalog descriptor. +the descriptor remains valid until +.br catclose () +or +.br execve (2). +if a file descriptor is used to implement catalog descriptors, +then the +.b fd_cloexec +flag will be set. +.pp +the argument +.i name +specifies the name of the message catalog to be opened. +if +.i name +specifies an absolute path (i.e., contains a \(aq/\(aq), +then +.i name +specifies a pathname for the message catalog. +otherwise, the environment variable +.b nlspath +is used with +.i name +substituted for +.b %n +(see +.br locale (7)). +it is unspecified whether +.b nlspath +will be used when the process has root privileges. +if +.b nlspath +does not exist in the environment, +or if a message catalog cannot be opened +in any of the paths specified by it, +then an implementation defined path is used. +this latter default path may depend on the +.b lc_messages +locale setting when the +.i flag +argument is +.b nl_cat_locale +and on the +.b lang +environment variable when the +.i flag +argument is 0. +changing the +.b lc_messages +part of the locale may invalidate +open catalog descriptors. +.pp +the +.i flag +argument to +.br catopen () +is used to indicate the source for the language to use. +if it is set to +.br nl_cat_locale , +then it will use the current locale setting for +.br lc_messages . +otherwise, it will use the +.b lang +environment variable. +.pp +the function +.br catclose () +closes the message catalog identified by +.ir catalog . +it invalidates any subsequent references to the message catalog +defined by +.ir catalog . +.sh return value +the function +.br catopen () +returns a message catalog descriptor of type +.i nl_catd +on success. +on failure, it returns +.ir "(nl_catd)\ \-1" +and sets +.i errno +to indicate the error. +the possible error values include all +possible values for the +.br open (2) +call. +.pp +the function +.br catclose () +returns 0 on success, or \-1 on failure. +.sh environment +.tp +.b lc_messages +may be the source of the +.b lc_messages +locale setting, and thus +determine the language to use if +.i flag +is set to +.br nl_cat_locale . +.tp +.b lang +the language to use if +.i flag +is 0. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br catopen () +t} thread safety mt-safe env +t{ +.br catclose () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.\" in xpg 1987, vol. 3 it says: +.\" .i "the flag argument of catopen is reserved for future use" +.\" .ir "and should be set to 0" . +.\" +.\" it is unclear what the source was for the constants +.\" .b mcloadbyset +.\" and +.\" .b mcloadall +.\" (see below). +.sh notes +the above is the posix.1 description. +the glibc value for +.b nl_cat_locale +is 1. +.\" (compare +.\" .b mcloadall +.\" below.) +the default path varies, but usually looks at a number of places below +.ir /usr/share/locale . +.\" .ss linux notes +.\" these functions are available for linux since libc 4.4.4c. +.\" in the case of linux libc4 and libc5, the catalog descriptor +.\" .i nl_catd +.\" is a +.\" .br mmap (2)'ed +.\" area of memory and not a file descriptor. +.\" the +.\" .i flag +.\" argument to +.\" .br catopen () +.\" should be either +.\" .b mcloadbyset +.\" (=0) or +.\" .b mcloadall +.\" (=1). +.\" the former value indicates that a set from the catalog is to be +.\" loaded when needed, whereas the latter causes the initial call to +.\" .br catopen () +.\" to load the entire catalog into memory. +.\" the default search path varies, but usually looks at a number of places below +.\" .i /etc/locale +.\" and +.\" .ir /usr/lib/locale . +.sh see also +.br catgets (3), +.br setlocale (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/chown.2 + +.so man3/byteorder.3 + +.so man3/circleq.3 + +.\" copyright (c) 2008 linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th pthread_attr_setscope 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +pthread_attr_setscope, pthread_attr_getscope \- set/get contention scope +attribute in thread attributes object +.sh synopsis +.nf +.b #include +.pp +.bi "int pthread_attr_setscope(pthread_attr_t *" attr ", int " scope ); +.bi "int pthread_attr_getscope(const pthread_attr_t *restrict " attr , +.bi " int *restrict " scope ); +.pp +compile and link with \fi\-pthread\fp. +.fi +.sh description +the +.br pthread_attr_setscope () +function sets the contention scope attribute of the +thread attributes object referred to by +.i attr +to the value specified in +.ir scope . +the contention scope attribute defines the set of threads +against which a thread competes for resources such as the cpu. +posix.1 specifies two possible values for +.ir scope : +.tp +.b pthread_scope_system +the thread competes for resources with all other threads +in all processes on the system that are in the same scheduling +allocation domain (a group of one or more processors). +.b pthread_scope_system +threads are scheduled relative to one another +according to their scheduling policy and priority. +.tp +.b pthread_scope_process +the thread competes for resources with all other threads +in the same process that were also created with the +.br pthread_scope_process +contention scope. +.br pthread_scope_process +threads are scheduled relative to other threads in the process +according to their scheduling policy and priority. +posix.1 leaves it unspecified how these threads contend +with other threads in other process on the system or +with other threads in the same process that +were created with the +.b pthread_scope_system +contention scope. +.pp +posix.1 requires that an implementation support at least one of these +contention scopes. +linux supports +.br pthread_scope_system , +but not +.br pthread_scope_process . +.pp +on systems that support multiple contention scopes, then, +in order for the parameter setting made by +.br pthread_attr_setscope () +to have effect when calling +.br pthread_create (3), +the caller must use +.br pthread_attr_setinheritsched (3) +to set the inherit-scheduler attribute of the attributes object +.i attr +to +.br pthread_explicit_sched . +.pp +the +.br pthread_attr_getscope () +function returns the contention scope attribute of the +thread attributes object referred to by +.i attr +in the buffer pointed to by +.ir scope . +.sh return value +on success, these functions return 0; +on error, they return a nonzero error number. +.sh errors +.br pthread_attr_setscope () +can fail with the following errors: +.tp +.b einval +an invalid value was specified in +.ir scope . +.tp +.b enotsup +.ir scope +specified the value +.br pthread_scope_process , +which is not supported on linux. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br pthread_attr_setscope (), +.br pthread_attr_getscope () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +the +.b pthread_scope_system +contention scope typically indicates that a user-space thread is +bound directly to a single kernel-scheduling entity. +this is the case on linux for the obsolete linuxthreads implementation +and the modern nptl implementation, +which are both 1:1 threading implementations. +.pp +posix.1 specifies that the default contention scope is +implementation-defined. +.sh see also +.ad l +.nh +.br pthread_attr_init (3), +.br pthread_attr_setaffinity_np (3), +.br pthread_attr_setinheritsched (3), +.br pthread_attr_setschedparam (3), +.br pthread_attr_setschedpolicy (3), +.br pthread_create (3), +.br pthreads (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2006, janak desai +.\" and copyright (c) 2006, 2012 michael kerrisk +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" licensed under the gpl +.\" %%%license_end +.\" +.\" patch justification: +.\" unshare system call is needed to implement, using pam, +.\" per-security_context and/or per-user namespace to provide +.\" polyinstantiated directories. using unshare and bind mounts, a +.\" pam module can create private namespace with appropriate +.\" directories(based on user's security context) bind mounted on +.\" public directories such as /tmp, thus providing an instance of +.\" /tmp that is based on user's security context. without the +.\" unshare system call, namespace separation can only be achieved +.\" by clone, which would require porting and maintaining all commands +.\" such as login, and su, that establish a user session. +.\" +.th unshare 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +unshare \- disassociate parts of the process execution context +.sh synopsis +.nf +.b #define _gnu_source +.b #include +.pp +.bi "int unshare(int " flags ); +.fi +.sh description +.br unshare () +allows a process (or thread) to disassociate parts of its execution +context that are currently being shared with other processes (or threads). +part of the execution context, such as the mount namespace, is shared +implicitly when a new process is created using +.br fork (2) +or +.br vfork (2), +while other parts, such as virtual memory, may be +shared by explicit request when creating a process or thread using +.br clone (2). +.pp +the main use of +.br unshare () +is to allow a process to control its +shared execution context without creating a new process. +.pp +the +.i flags +argument is a bit mask that specifies which parts of +the execution context should be unshared. +this argument is specified by oring together zero or more +of the following constants: +.tp +.b clone_files +reverse the effect of the +.br clone (2) +.b clone_files +flag. +unshare the file descriptor table, so that the calling process +no longer shares its file descriptors with any other process. +.tp +.b clone_fs +reverse the effect of the +.br clone (2) +.b clone_fs +flag. +unshare filesystem attributes, so that the calling process +no longer shares its root directory +.rb ( chroot (2)), +current directory +.rb ( chdir (2)), +or umask +.rb ( umask (2)) +attributes with any other process. +.tp +.br clone_newcgroup " (since linux 4.6)" +this flag has the same effect as the +.br clone (2) +.b clone_newcgroup +flag. +unshare the cgroup namespace. +use of +.br clone_newcgroup +requires the +.br cap_sys_admin +capability. +.tp +.br clone_newipc " (since linux 2.6.19)" +this flag has the same effect as the +.br clone (2) +.b clone_newipc +flag. +unshare the ipc namespace, +so that the calling process has a private copy of the +ipc namespace which is not shared with any other process. +specifying this flag automatically implies +.br clone_sysvsem +as well. +use of +.br clone_newipc +requires the +.br cap_sys_admin +capability. +.tp +.br clone_newnet " (since linux 2.6.24)" +this flag has the same effect as the +.br clone (2) +.b clone_newnet +flag. +unshare the network namespace, +so that the calling process is moved into a +new network namespace which is not shared +with any previously existing process. +use of +.br clone_newnet +requires the +.br cap_sys_admin +capability. +.tp +.b clone_newns +.\" these flag name are inconsistent: +.\" clone_newns does the same thing in clone(), but clone_vm, +.\" clone_fs, and clone_files reverse the action of the clone() +.\" flags of the same name. +this flag has the same effect as the +.br clone (2) +.b clone_newns +flag. +unshare the mount namespace, +so that the calling process has a private copy of +its namespace which is not shared with any other process. +specifying this flag automatically implies +.b clone_fs +as well. +use of +.br clone_newns +requires the +.br cap_sys_admin +capability. +for further information, see +.br mount_namespaces (7). +.tp +.br clone_newpid " (since linux 3.8)" +this flag has the same effect as the +.br clone (2) +.b clone_newpid +flag. +unshare the pid namespace, +so that the calling process has a new pid namespace for its children +which is not shared with any previously existing process. +the calling process is +.i not +moved into the new namespace. +the first child created by the calling process will have +the process id 1 and will assume the role of +.br init (1) +in the new namespace. +.br clone_newpid +automatically implies +.br clone_thread +as well. +use of +.br clone_newpid +requires the +.br cap_sys_admin +capability. +for further information, see +.br pid_namespaces (7). +.tp +.br clone_newtime " (since linux 5.6)" +unshare the time namespace, +so that the calling process has a new time namespace for its children +which is not shared with any previously existing process. +the calling process is +.i not +moved into the new namespace. +use of +.br clone_newtime +requires the +.br cap_sys_admin +capability. +for further information, see +.br time_namespaces (7). +.tp +.br clone_newuser " (since linux 3.8)" +this flag has the same effect as the +.br clone (2) +.b clone_newuser +flag. +unshare the user namespace, +so that the calling process is moved into a new user namespace +which is not shared with any previously existing process. +as with the child process created by +.br clone (2) +with the +.b clone_newuser +flag, the caller obtains a full set of capabilities in the new namespace. +.ip +.br clone_newuser +requires that the calling process is not threaded; specifying +.br clone_newuser +automatically implies +.br clone_thread . +since linux 3.9, +.\" commit e66eded8309ebf679d3d3c1f5820d1f2ca332c71 +.\" https://lwn.net/articles/543273/ +.br clone_newuser +also automatically implies +.br clone_fs . +.br clone_newuser +requires that the user id and group id +of the calling process are mapped to user ids and group ids in the +user namespace of the calling process at the time of the call. +.ip +for further information on user namespaces, see +.br user_namespaces (7). +.tp +.br clone_newuts " (since linux 2.6.19)" +this flag has the same effect as the +.br clone (2) +.b clone_newuts +flag. +unshare the uts ipc namespace, +so that the calling process has a private copy of the +uts namespace which is not shared with any other process. +use of +.br clone_newuts +requires the +.br cap_sys_admin +capability. +.tp +.br clone_sysvsem " (since linux 2.6.26)" +.\" commit 9edff4ab1f8d82675277a04e359d0ed8bf14a7b7 +this flag reverses the effect of the +.br clone (2) +.b clone_sysvsem +flag. +unshare system\ v semaphore adjustment +.ri ( semadj ) +values, +so that the calling process has a new empty +.i semadj +list that is not shared with any other process. +if this is the last process that has a reference to the process's current +.i semadj +list, then the adjustments in that list are applied +to the corresponding semaphores, as described in +.br semop (2). +.\" clone_newns if clone_sighand is set and signals are also being shared +.\" (i.e., current->signal->count > 1), force clone_thread. +.pp +in addition, +.br clone_thread , +.br clone_sighand , +and +.br clone_vm +can be specified in +.i flags +if the caller is single threaded (i.e., it is not sharing +its address space with another process or thread). +in this case, these flags have no effect. +(note also that specifying +.br clone_thread +automatically implies +.br clone_vm , +and specifying +.br clone_vm +automatically implies +.br clone_sighand .) +.\" as at 3.9, the following forced implications also apply, +.\" although the relevant flags are not yet implemented. +.\" if clone_thread is set force clone_vm. +.\" if clone_vm is set, force clone_sighand. +.\" +if the process is multithreaded, then +the use of these flags results in an error. +.\" see kernel/fork.c::check_unshare_flags() +.pp +if +.i flags +is specified as zero, then +.br unshare () +is a no-op; +no changes are made to the calling process's execution context. +.sh return value +on success, zero returned. +on failure, \-1 is returned and +.i errno +is set to indicate the error. +.sh errors +.tp +.b einval +an invalid bit was specified in +.ir flags . +.tp +.b einval +.br clone_thread , +.br clone_sighand , +or +.br clone_vm +was specified in +.ir flags , +and the caller is multithreaded. +.tp +.b einval +.br clone_newipc +was specified in +.ir flags , +but the kernel was not configured with the +.b config_sysvipc +and +.br config_ipc_ns +options. +.tp +.b einval +.br clone_newnet +was specified in +.ir flags , +but the kernel was not configured with the +.b config_net_ns +option. +.tp +.b einval +.br clone_newpid +was specified in +.ir flags , +but the kernel was not configured with the +.b config_pid_ns +option. +.tp +.b einval +.br clone_newuser +was specified in +.ir flags , +but the kernel was not configured with the +.b config_user_ns +option. +.tp +.b einval +.br clone_newuts +was specified in +.ir flags , +but the kernel was not configured with the +.b config_uts_ns +option. +.tp +.b einval +.br clone_newpid +was specified in +.ir flags , +but the process has previously called +.br unshare () +with the +.br clone_newpid +flag. +.tp +.b enomem +cannot allocate sufficient memory to copy parts of caller's +context that need to be unshared. +.tp +.br enospc " (since linux 3.7)" +.\" commit f2302505775fd13ba93f034206f1e2a587017929 +.b clone_newpid +was specified in flags, +but the limit on the nesting depth of pid namespaces +would have been exceeded; see +.br pid_namespaces (7). +.tp +.br enospc " (since linux 4.9; beforehand " eusers ) +.b clone_newuser +was specified in +.ir flags , +and the call would cause the limit on the number of +nested user namespaces to be exceeded. +see +.br user_namespaces (7). +.ip +from linux 3.11 to linux 4.8, the error diagnosed in this case was +.br eusers . +.tp +.br enospc " (since linux 4.9)" +one of the values in +.i flags +specified the creation of a new user namespace, +but doing so would have caused the limit defined by the corresponding file in +.ir /proc/sys/user +to be exceeded. +for further details, see +.br namespaces (7). +.tp +.b eperm +the calling process did not have the required privileges for this operation. +.tp +.b eperm +.br clone_newuser +was specified in +.ir flags , +but either the effective user id or the effective group id of the caller +does not have a mapping in the parent namespace (see +.br user_namespaces (7)). +.tp +.br eperm " (since linux 3.9)" +.\" commit 3151527ee007b73a0ebd296010f1c0454a919c7d +.b clone_newuser +was specified in +.i flags +and the caller is in a chroot environment +.\" fixme what is the rationale for this restriction? +(i.e., the caller's root directory does not match the root directory +of the mount namespace in which it resides). +.tp +.br eusers " (from linux 3.11 to linux 4.8)" +.b clone_newuser +was specified in +.ir flags , +and the limit on the number of nested user namespaces would be exceeded. +see the discussion of the +.br enospc +error above. +.sh versions +the +.br unshare () +system call was added to linux in kernel 2.6.16. +.sh conforming to +the +.br unshare () +system call is linux-specific. +.sh notes +not all of the process attributes that can be shared when +a new process is created using +.br clone (2) +can be unshared using +.br unshare (). +in particular, as at kernel 3.8, +.\" fixme all of the following needs to be reviewed for the current kernel +.br unshare () +does not implement flags that reverse the effects of +.br clone_sighand , +.\" however, we can do unshare(clone_sighand) if clone_sighand +.\" was not specified when doing clone(); i.e., unsharing +.\" signal handlers is permitted if we are not actually +.\" sharing signal handlers. mtk +.br clone_thread , +or +.br clone_vm . +.\" however, we can do unshare(clone_vm) if clone_vm +.\" was not specified when doing clone(); i.e., unsharing +.\" virtual memory is permitted if we are not actually +.\" sharing virtual memory. mtk +such functionality may be added in the future, if required. +.\" +.\"9) future work +.\"-------------- +.\"the current implementation of unshare does not allow unsharing of +.\"signals and signal handlers. signals are complex to begin with and +.\"to unshare signals and/or signal handlers of a currently running +.\"process is even more complex. if in the future there is a specific +.\"need to allow unsharing of signals and/or signal handlers, it can +.\"be incrementally added to unshare without affecting legacy +.\"applications using unshare. +.\" +.sh examples +the program below provides a simple implementation of the +.br unshare (1) +command, which unshares one or more namespaces and executes the +command supplied in its command-line arguments. +here's an example of the use of this program, +running a shell in a new mount namespace, +and verifying that the original shell and the +new shell are in separate mount namespaces: +.pp +.in +4n +.ex +$ \fbreadlink /proc/$$/ns/mnt\fp +mnt:[4026531840] +$ \fbsudo ./unshare \-m /bin/bash\fp +# \fbreadlink /proc/$$/ns/mnt\fp +mnt:[4026532325] +.ee +.in +.pp +the differing output of the two +.br readlink (1) +commands shows that the two shells are in different mount namespaces. +.ss program source +\& +.ex +/* unshare.c + + a simple implementation of the unshare(1) command: unshare + namespaces and execute a command. +*/ +#define _gnu_source +#include +#include +#include +#include + +/* a simple error\-handling function: print an error message based + on the value in \(aqerrno\(aq and terminate the calling process. */ + +#define errexit(msg) do { perror(msg); exit(exit_failure); \e + } while (0) + +static void +usage(char *pname) +{ + fprintf(stderr, "usage: %s [options] program [arg...]\en", pname); + fprintf(stderr, "options can be:\en"); + fprintf(stderr, " \-c unshare cgroup namespace\en"); + fprintf(stderr, " \-i unshare ipc namespace\en"); + fprintf(stderr, " \-m unshare mount namespace\en"); + fprintf(stderr, " \-n unshare network namespace\en"); + fprintf(stderr, " \-p unshare pid namespace\en"); + fprintf(stderr, " \-t unshare time namespace\en"); + fprintf(stderr, " \-u unshare uts namespace\en"); + fprintf(stderr, " \-u unshare user namespace\en"); + exit(exit_failure); +} + +int +main(int argc, char *argv[]) +{ + int flags, opt; + + flags = 0; + + while ((opt = getopt(argc, argv, "cimnptuu")) != \-1) { + switch (opt) { + case \(aqc\(aq: flags |= clone_newcgroup; break; + case \(aqi\(aq: flags |= clone_newipc; break; + case \(aqm\(aq: flags |= clone_newns; break; + case \(aqn\(aq: flags |= clone_newnet; break; + case \(aqp\(aq: flags |= clone_newpid; break; + case \(aqt\(aq: flags |= clone_newtime; break; + case \(aqu\(aq: flags |= clone_newuts; break; + case \(aqu\(aq: flags |= clone_newuser; break; + default: usage(argv[0]); + } + } + + if (optind >= argc) + usage(argv[0]); + + if (unshare(flags) == \-1) + errexit("unshare"); + + execvp(argv[optind], &argv[optind]); + errexit("execvp"); +} +.ee +.sh see also +.br unshare (1), +.br clone (2), +.br fork (2), +.br kcmp (2), +.br setns (2), +.br vfork (2), +.br namespaces (7) +.pp +.i documentation/userspace\-api/unshare.rst +in the linux kernel source tree +.\" commit f504d47be5e8fa7ecf2bf660b18b42e6960c0eb2 +(or +.i documentation/unshare.txt +before linux 4.12) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/cproj.3 + +.\" %%%license_start(public_domain) +.\" this page is in the public domain +.\" %%%license_end +.\" +.th zic 8 2020-08-13 "" "linux system administration" +.sh name +zic \- timezone compiler +.sh synopsis +.b zic +[ +.i option +\&... ] [ +.i filename +\&... ] +.sh description +.ie '\(lq'' .ds lq \&"\" +.el .ds lq \(lq\" +.ie '\(rq'' .ds rq \&"\" +.el .ds rq \(rq\" +.de q +\\$3\*(lq\\$1\*(rq\\$2 +.. +.ie '\(la'' .ds < < +.el .ds < \(la +.ie '\(ra'' .ds > > +.el .ds > \(ra +.ie \n(.g \{\ +. ds : \: +. ds - \f(cw-\fp +.\} +.el \{\ +. ds : +. ds - \- +.\} +the +.b zic +program reads text from the file(s) named on the command line +and creates the time conversion information files specified in this input. +if a +.i filename +is +.q "\*-" , +standard input is read. +.sh options +.tp +.b "\*-\*-version" +output version information and exit. +.tp +.b \*-\*-help +output short usage message and exit. +.tp +.bi "\*-b " bloat +output backward-compatibility data as specified by +.ir bloat . +if +.i bloat +is +.br fat , +generate additional data entries that work around potential bugs or +incompatibilities in older software, such as software that mishandles +the 64-bit generated data. +if +.i bloat +is +.br slim , +keep the output files small; this can help check for the bugs +and incompatibilities. +although the default is currently +.br fat , +this is intended to change in future +.b zic +versions, as software that mishandles the 64-bit data typically +mishandles timestamps after the year 2038 anyway. +also see the +.b \*-r +option for another way to shrink output size. +.tp +.bi "\*-d " directory +create time conversion information files in the named directory rather than +in the standard directory named below. +.tp +.bi "\*-l " timezone +use +.i timezone +as local time. +.b zic +will act as if the input contained a link line of the form +.sp +.ti +.5i +.ta \w'link\0\0'u +\w'\fitimezone\fp\0\0'u +link \fitimezone\fp localtime +.tp +.bi "\*-l " leapsecondfilename +read leap second information from the file with the given name. +if this option is not used, +no leap second information appears in output files. +.tp +.bi "\*-p " timezone +use +.ir timezone 's +rules when handling nonstandard +tz strings like "eet\*-2eest" that lack transition rules. +.b zic +will act as if the input contained a link line of the form +.sp +.ti +.5i +link \fitimezone\fp posixrules +.sp +this feature is obsolete and poorly supported. +among other things it should not be used for timestamps after the year 2037, +and it should not be combined with +.b "\*-b slim" +if +.ir timezone 's +transitions are at standard time or universal time (ut) instead of local time. +.tp +.br "\*-r " "[\fb@\fp\filo\fp][\fb/@\fp\fihi\fp]" +reduce the size of output files by limiting their applicability +to timestamps in the range from +.i lo +(inclusive) to +.i hi +(exclusive), where +.i lo +and +.i hi +are possibly-signed decimal counts of seconds since the epoch +(1970-01-01 00:00:00 utc). +omitted counts default to extreme values. +for example, +.q "zic \*-r @0" +omits data intended for negative timestamps (i.e., before the epoch), and +.q "zic \*-r @0/@2147483648" +outputs data intended only for nonnegative timestamps that fit into +31-bit signed integers. +on platforms with gnu +.br date , +.q "zic \-r @$(date +%s)" +omits data intended for past timestamps. +also see the +.b "\*-b slim" +option for another way to shrink output size. +.tp +.bi "\*-t " file +when creating local time information, put the configuration link in +the named file rather than in the standard location. +.tp +.b \*-v +be more verbose, and complain about the following situations: +.rs +.pp +the input specifies a link to a link. +.pp +a year that appears in a data file is outside the range +of representable years. +.pp +a time of 24:00 or more appears in the input. +pre-1998 versions of +.b zic +prohibit 24:00, and pre-2007 versions prohibit times greater than 24:00. +.pp +a rule goes past the start or end of the month. +pre-2004 versions of +.b zic +prohibit this. +.pp +a time zone abbreviation uses a +.b %z +format. +pre-2015 versions of +.b zic +do not support this. +.pp +a timestamp contains fractional seconds. +pre-2018 versions of +.b zic +do not support this. +.pp +the input contains abbreviations that are mishandled by pre-2018 versions of +.b zic +due to a longstanding coding bug. +these abbreviations include +.q l +for +.q link , +.q mi +for +.q min , +.q sa +for +.q sat , +and +.q su +for +.q sun . +.pp +the output file does not contain all the information about the +long-term future of a timezone, because the future cannot be summarized as +an extended posix tz string. for example, as of 2019 this problem +occurs for iran's daylight-saving rules for the predicted future, as +these rules are based on the iranian calendar, which cannot be +represented. +.pp +the output contains data that may not be handled properly by client +code designed for older +.b zic +output formats. these compatibility issues affect only timestamps +before 1970 or after the start of 2038. +.pp +the output file contains more than 1200 transitions, +which may be mishandled by some clients. +the current reference client supports at most 2000 transitions; +pre-2014 versions of the reference client support at most 1200 +transitions. +.pp +a time zone abbreviation has fewer than 3 or more than 6 characters. +posix requires at least 3, and requires implementations to support +at least 6. +.pp +an output file name contains a byte that is not an ascii letter, +.q "\*-" , +.q "/" , +or +.q "_" ; +or it contains a file name component that contains more than 14 bytes +or that starts with +.q "\*-" . +.re +.sh files +input files use the format described in this section; output files use +.br tzfile (5) +format. +.pp +input files should be text files, that is, they should be a series of +zero or more lines, each ending in a newline byte and containing at +most 511 bytes, and without any nul bytes. the input text's encoding +is typically utf-8 or ascii; it should have a unibyte representation +for the posix portable character set (ppcs) +\* +and the encoding's non-unibyte characters should consist entirely of +non-ppcs bytes. non-ppcs characters typically occur only in comments: +although output file names and time zone abbreviations can contain +nearly any character, other software will work better if these are +limited to the restricted syntax described under the +.b \*-v +option. +.pp +input lines are made up of fields. +fields are separated from one another by one or more white space characters. +the white space characters are space, form feed, carriage return, newline, +tab, and vertical tab. +leading and trailing white space on input lines is ignored. +an unquoted sharp character (#) in the input introduces a comment which extends +to the end of the line the sharp character appears on. +white space characters and sharp characters may be enclosed in double quotes +(") if they're to be used as part of a field. +any line that is blank (after comment stripping) is ignored. +nonblank lines are expected to be of one of three types: +rule lines, zone lines, and link lines. +.pp +names must be in english and are case insensitive. +they appear in several contexts, and include month and weekday names +and keywords such as +.br "maximum" , +.br "only" , +.br "rolling" , +and +.br "zone" . +a name can be abbreviated by omitting all but an initial prefix; any +abbreviation must be unambiguous in context. +.pp +a rule line has the form +.nf +.ti +.5i +.ta \w'rule\0\0'u +\w'name\0\0'u +\w'from\0\0'u +\w'1973\0\0'u +\w'type\0\0'u +\w'apr\0\0'u +\w'lastsun\0\0'u +\w'2:00w\0\0'u +\w'1:00d\0\0'u +.sp +rule name from to type in on at save letter/s +.sp +for example: +.ti +.5i +.sp +rule us 1967 1973 \*- apr lastsun 2:00w 1:00d d +.sp +.fi +the fields that make up a rule line are: +.tp "\w'letter/s'u" +.b name +gives the name of the rule set that contains this line. +the name must start with a character that is neither +an ascii digit nor +.q \*- +nor +.q + . +to allow for future extensions, +an unquoted name should not contain characters from the set +.q !$%&'()*,/:;<=>?@[\e]\(ha\`{|}\(ti . +.tp +.b from +gives the first year in which the rule applies. +any signed integer year can be supplied; the proleptic gregorian calendar +is assumed, with year 0 preceding year 1. +the word +.b minimum +(or an abbreviation) means the indefinite past. +the word +.b maximum +(or an abbreviation) means the indefinite future. +rules can describe times that are not representable as time values, +with the unrepresentable times ignored; this allows rules to be portable +among hosts with differing time value types. +.tp +.b to +gives the final year in which the rule applies. +in addition to +.b minimum +and +.b maximum +(as above), +the word +.b only +(or an abbreviation) +may be used to repeat the value of the +.b from +field. +.tp +.b type +should be +.q \*- +and is present for compatibility with older versions of +.b zic +in which it could contain year types. +.tp +.b in +names the month in which the rule takes effect. +month names may be abbreviated. +.tp +.b on +gives the day on which the rule takes effect. +recognized forms include: +.nf +.in +.5i +.sp +.ta \w'sun<=25\0\0'u +5 the fifth of the month +lastsun the last sunday in the month +lastmon the last monday in the month +sun>=8 first sunday on or after the eighth +sun<=25 last sunday on or before the 25th +.fi +.in -.5i +.sp +a weekday name (e.g., +.br "sunday" ) +or a weekday name preceded by +.q "last" +(e.g., +.br "lastsunday" ) +may be abbreviated or spelled out in full. +there must be no white space characters within the +.b on +field. +the +.q <= +and +.q >= +constructs can result in a day in the neighboring month; +for example, the in-on combination +.q "oct sun>=31" +stands for the first sunday on or after october 31, +even if that sunday occurs in november. +.tp +.b at +gives the time of day at which the rule takes effect, +relative to 00:00, the start of a calendar day. +recognized forms include: +.nf +.in +.5i +.sp +.ta \w'00:19:32.13\0\0'u +2 time in hours +2:00 time in hours and minutes +01:28:14 time in hours, minutes, and seconds +00:19:32.13 time with fractional seconds +12:00 midday, 12 hours after 00:00 +15:00 3 pm, 15 hours after 00:00 +24:00 end of day, 24 hours after 00:00 +260:00 260 hours after 00:00 +\*-2:30 2.5 hours before 00:00 +\*- equivalent to 0 +.fi +.in -.5i +.sp +although +.b zic +rounds times to the nearest integer second +(breaking ties to the even integer), the fractions may be useful +to other applications requiring greater precision. +the source format does not specify any maximum precision. +any of these forms may be followed by the letter +.b w +if the given time is local or +.q "wall clock" +time, +.b s +if the given time is standard time without any adjustment for daylight saving, +or +.b u +(or +.b g +or +.br z ) +if the given time is universal time; +in the absence of an indicator, +local (wall clock) time is assumed. +these forms ignore leap seconds; for example, +if a leap second occurs at 00:59:60 local time, +.q "1:00" +stands for 3601 seconds after local midnight instead of the usual 3600 seconds. +the intent is that a rule line describes the instants when a +clock/calendar set to the type of time specified in the +.b at +field would show the specified date and time of day. +.tp +.b save +gives the amount of time to be added to local standard time when the rule is in +effect, and whether the resulting time is standard or daylight saving. +this field has the same format as the +.b at +field +except with a different set of suffix letters: +.b s +for standard time and +.b d +for daylight saving time. +the suffix letter is typically omitted, and defaults to +.b s +if the offset is zero and to +.b d +otherwise. +negative offsets are allowed; in ireland, for example, daylight saving +time is observed in winter and has a negative offset relative to +irish standard time. +the offset is merely added to standard time; for example, +.b zic +does not distinguish a 10:30 standard time plus an 0:30 +.b save +from a 10:00 standard time plus a 1:00 +.br save . +.tp +.b letter/s +gives the +.q "variable part" +(for example, the +.q "s" +or +.q "d" +in +.q "est" +or +.q "edt" ) +of time zone abbreviations to be used when this rule is in effect. +if this field is +.q \*- , +the variable part is null. +.pp +a zone line has the form +.sp +.nf +.ti +.5i +.ta \w'zone\0\0'u +\w'asia/amman\0\0'u +\w'stdoff\0\0'u +\w'jordan\0\0'u +\w'format\0\0'u +zone name stdoff rules format [until] +.sp +for example: +.sp +.ti +.5i +zone asia/amman 2:00 jordan ee%st 2017 oct 27 01:00 +.sp +.fi +the fields that make up a zone line are: +.tp "\w'stdoff'u" +.b name +the name of the timezone. +this is the name used in creating the time conversion information file for the +timezone. +it should not contain a file name component +.q ".\&" +or +.q ".." ; +a file name component is a maximal substring that does not contain +.q "/" . +.tp +.b stdoff +the amount of time to add to ut to get standard time, +without any adjustment for daylight saving. +this field has the same format as the +.b at +and +.b save +fields of rule lines; +begin the field with a minus sign if time must be subtracted from ut. +.tp +.b rules +the name of the rules that apply in the timezone or, +alternatively, a field in the same format as a rule-line save column, +giving of the amount of time to be added to local standard time +effect, and whether the resulting time is standard or daylight saving. +if this field is +.b \*- +then standard time always applies. +when an amount of time is given, only the sum of standard time and +this amount matters. +.tp +.b format +the format for time zone abbreviations. +the pair of characters +.b %s +is used to show where the +.q "variable part" +of the time zone abbreviation goes. +alternatively, a format can use the pair of characters +.b %z +to stand for the ut offset in the form +.ri \(+- hh , +.ri \(+- hhmm , +or +.ri \(+- hhmmss , +using the shortest form that does not lose information, where +.ir hh , +.ir mm , +and +.i ss +are the hours, minutes, and seconds east (+) or west (\(mi) of ut. +alternatively, +a slash (/) +separates standard and daylight abbreviations. +to conform to posix, a time zone abbreviation should contain only +alphanumeric ascii characters, +.q "+" +and +.q "\*-". +.tp +.b until +the time at which the ut offset or the rule(s) change for a location. +it takes the form of one to four fields year [month [day [time]]]. +if this is specified, +the time zone information is generated from the given ut offset +and rule change until the time specified, which is interpreted using +the rules in effect just before the transition. +the month, day, and time of day have the same format as the in, on, and at +fields of a rule; trailing fields can be omitted, and default to the +earliest possible value for the missing fields. +.ip +the next line must be a +.q "continuation" +line; this has the same form as a zone line except that the +string +.q "zone" +and the name are omitted, as the continuation line will +place information starting at the time specified as the +.q "until" +information in the previous line in the file used by the previous line. +continuation lines may contain +.q "until" +information, just as zone lines do, indicating that the next line is a further +continuation. +.pp +if a zone changes at the same instant that a rule would otherwise take +effect in the earlier zone or continuation line, the rule is ignored. +a zone or continuation line +.i l +with a named rule set starts with standard time by default: +that is, any of +.ir l 's +timestamps preceding +.ir l 's +earliest rule use the rule in effect after +.ir l 's +first transition into standard time. +in a single zone it is an error if two rules take effect at the same +instant, or if two zone changes take effect at the same instant. +.pp +a link line has the form +.sp +.nf +.ti +.5i +.ta \w'link\0\0'u +\w'europe/istanbul\0\0'u +link target link-name +.sp +for example: +.sp +.ti +.5i +link europe/istanbul asia/istanbul +.sp +.fi +the +.b target +field should appear as the +.b name +field in some zone line. +the +.b link-name +field is used as an alternative name for that zone; +it has the same syntax as a zone line's +.b name +field. +.pp +except for continuation lines, +lines may appear in any order in the input. +however, the behavior is unspecified if multiple zone or link lines +define the same name, or if the source of one link line is the target +of another. +.pp +the file that describes leap seconds can have leap lines and an +expiration line. +leap lines have the following form: +.nf +.ti +.5i +.ta \w'leap\0\0'u +\w'year\0\0'u +\w'month\0\0'u +\w'day\0\0'u +\w'hh:mm:ss\0\0'u +\w'corr\0\0'u +.sp +leap year month day hh:mm:ss corr r/s +.sp +for example: +.ti +.5i +.sp +leap 2016 dec 31 23:59:60 + s +.sp +.fi +the +.br year , +.br month , +.br day , +and +.b hh:mm:ss +fields tell when the leap second happened. +the +.b corr +field +should be +.q "+" +if a second was added +or +.q "\*-" +if a second was skipped. +the +.b r/s +field +should be (an abbreviation of) +.q "stationary" +if the leap second time given by the other fields should be interpreted as utc +or +(an abbreviation of) +.q "rolling" +if the leap second time given by the other fields should be interpreted as +local (wall clock) time. +.pp +the expiration line, if present, has the form: +.nf +.ti +.5i +.ta \w'expires\0\0'u +\w'year\0\0'u +\w'month\0\0'u +\w'day\0\0'u +.sp +expires year month day hh:mm:ss +.sp +for example: +.ti +.5i +.sp +expires 2020 dec 28 00:00:00 +.sp +.fi +the +.br year , +.br month , +.br day , +and +.b hh:mm:ss +fields give the expiration timestamp in utc for the leap second table; +.b zic +outputs this expiration timestamp by truncating the end of the output +file to the timestamp. +if there is no expiration line, +.b zic +also accepts a comment +.q "#expires \fie\fp ...\&" +where +.i e +is the expiration timestamp as a decimal integer count of seconds +since the epoch, not counting leap seconds. +however, the +.q "#expires" +comment is an obsolescent feature, +and the leap second file should use an expiration line +instead of relying on a comment. +.sh "extended example" +here is an extended example of +.b zic +input, intended to illustrate many of its features. +in this example, the eu rules are for the european union +and for its predecessor organization, the european communities. +.br +.ne 22 +.nf +.in +2m +.ta \w'# rule\0\0'u +\w'name\0\0'u +\w'from\0\0'u +\w'1973\0\0'u +\w'type\0\0'u +\w'apr\0\0'u +\w'lastsun\0\0'u +\w'2:00\0\0'u +\w'save\0\0'u +.sp +# rule name from to type in on at save letter/s +rule swiss 1941 1942 \*- may mon>=1 1:00 1:00 s +rule swiss 1941 1942 \*- oct mon>=1 2:00 0 \*- +.sp .5 +rule eu 1977 1980 \*- apr sun>=1 1:00u 1:00 s +rule eu 1977 only \*- sep lastsun 1:00u 0 \*- +rule eu 1978 only \*- oct 1 1:00u 0 \*- +rule eu 1979 1995 \*- sep lastsun 1:00u 0 \*- +rule eu 1981 max \*- mar lastsun 1:00u 1:00 s +rule eu 1996 max \*- oct lastsun 1:00u 0 \*- +.sp +.ta \w'# zone\0\0'u +\w'europe/zurich\0\0'u +\w'0:29:45.50\0\0'u +\w'rules\0\0'u +\w'format\0\0'u +# zone name stdoff rules format [until] +zone europe/zurich 0:34:08 \*- lmt 1853 jul 16 + 0:29:45.50 \*- bmt 1894 jun + 1:00 swiss ce%st 1981 + 1:00 eu ce%st +.sp +link europe/zurich europe/vaduz +.sp +.in +.fi +in this example, the timezone is named europe/zurich but it has an alias +as europe/vaduz. this example says that zurich was 34 minutes and 8 +seconds east of ut until 1853-07-16 at 00:00, when the legal offset +was changed to +.ds o 7 degrees 26 minutes 22.50 seconds +.if \n(.g .if c \(de .if c \(fm .if c \(sd .ds o 7\(de\|26\(fm\|22.50\(sd +\*o, +which works out to 0:29:45.50; +.b zic +treats this by rounding it to 0:29:46. +after 1894-06-01 at 00:00 the ut offset became one hour +and swiss daylight saving rules (defined with lines beginning with +.q "rule swiss") +apply. from 1981 to the present, eu daylight saving rules have +applied, and the utc offset has remained at one hour. +.pp +in 1941 and 1942, daylight saving time applied from the first monday +in may at 01:00 to the first monday in october at 02:00. +the pre-1981 eu daylight-saving rules have no effect +here, but are included for completeness. since 1981, daylight +saving has begun on the last sunday in march at 01:00 utc. +until 1995 it ended the last sunday in september at 01:00 utc, +but this changed to the last sunday in october starting in 1996. +.pp +for purposes of display, +.q "lmt" +and +.q "bmt" +were initially used, respectively. since +swiss rules and later eu rules were applied, the time zone abbreviation +has been cet for standard time and cest for daylight saving +time. +.sh files +.tp +.i /etc/localtime +default local timezone file. +.tp +.i /usr/share/zoneinfo +default timezone information directory. +.sh notes +for areas with more than two types of local time, +you may need to use local standard time in the +.b at +field of the earliest transition time's rule to ensure that +the earliest transition time recorded in the compiled file is correct. +.pp +if, +for a particular timezone, +a clock advance caused by the start of daylight saving +coincides with and is equal to +a clock retreat caused by a change in ut offset, +.b zic +produces a single transition to daylight saving at the new ut offset +without any change in local (wall clock) time. +to get separate transitions +use multiple zone continuation lines +specifying transition instants using universal time. +.sh see also +.br tzfile (5), +.br zdump (8) +.\" this file is in the public domain, so clarified as of +.\" 2009-05-17 by arthur david olson. +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1992 drew eckhardt (drew@cs.colorado.edu), march 28, 1992 +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified by michael haardt +.\" modified 1993-07-21 by rik faith +.\" modified 1995-04-15 by michael chastain : +.\" added 'fchdir'. fixed bugs in error section. +.\" modified 1996-10-21 by eric s. raymond +.\" modified 1997-08-21 by joseph s. myers +.\" modified 2004-06-23 by michael kerrisk +.\" +.th chdir 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +chdir, fchdir \- change working directory +.sh synopsis +.nf +.b #include +.pp +.bi "int chdir(const char *" path ); +.bi "int fchdir(int " fd ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br fchdir (): +.nf + _xopen_source >= 500 +.\" || _xopen_source && _xopen_source_extended + || /* since glibc 2.12: */ _posix_c_source >= 200809l + || /* glibc up to and including 2.19: */ _bsd_source +.fi +.sh description +.br chdir () +changes the current working directory of the calling process to the +directory specified in +.ir path . +.pp +.br fchdir () +is identical to +.br chdir (); +the only difference is that the directory is given as an +open file descriptor. +.sh return value +on success, zero is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +depending on the filesystem, other errors can be returned. +the more +general errors for +.br chdir () +are listed below: +.tp +.b eacces +search permission is denied for one of the components of +.ir path . +(see also +.br path_resolution (7).) +.tp +.b efault +.i path +points outside your accessible address space. +.tp +.b eio +an i/o error occurred. +.tp +.b eloop +too many symbolic links were encountered in resolving +.ir path . +.tp +.b enametoolong +.i path +is too long. +.tp +.b enoent +the directory specified in +.i path +does not exist. +.tp +.b enomem +insufficient kernel memory was available. +.tp +.b enotdir +a component of +.i path +is not a directory. +.pp +the general errors for +.br fchdir () +are listed below: +.tp +.b eacces +search permission was denied on the directory open on +.ir fd . +.tp +.b ebadf +.i fd +is not a valid file descriptor. +.tp +.b enotdir +.i fd +does not refer to a directory. +.sh conforming to +posix.1-2001, posix.1-2008, svr4, 4.4bsd. +.sh notes +the current working directory is the starting point for interpreting +relative pathnames (those not starting with \(aq/\(aq). +.pp +a child process created via +.br fork (2) +inherits its parent's current working directory. +the current working directory is left unchanged by +.br execve (2). +.sh see also +.br chroot (2), +.br getcwd (3), +.br path_resolution (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/list.3 + +.so man8/ld.so.8 + +.so man3/endian.3 + +.so man3/lsearch.3 + +.so man2/unimplemented.2 + +.\" copyright (c) 1993 michael haardt (michael@moria.de), +.\" fri apr 2 11:32:09 met dst 1993 +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" modified sat jul 24 17:00:12 1993 by rik faith (faith@cs.unc.edu) +.th null 4 2015-07-23 "linux" "linux programmer's manual" +.sh name +null, zero \- data sink +.sh description +data written to the +.ir /dev/null +and +.ir /dev/zero +special files is discarded. +.pp +reads from +.ir /dev/null +always return end of file (i.e., +.br read (2) +returns 0), whereas reads from +.ir /dev/zero +always return bytes containing zero (\(aq\e0\(aq characters). +.pp +these devices are typically created by: +.pp +.in +4n +.ex +mknod \-m 666 /dev/null c 1 3 +mknod \-m 666 /dev/zero c 1 5 +chown root:root /dev/null /dev/zero +.ee +.in +.sh files +.i /dev/null +.br +.i /dev/zero +.sh notes +if these devices are not writable and readable for all users, many +programs will act strangely. +.pp +since linux 2.6.31, +.\" commit 2b83868723d090078ac0e2120e06a1cc94dbaef0 +reads from +.ir /dev/zero +are interruptible by signals. +(this change was made to help with bad latencies for large reads from +.ir /dev/zero .) +.sh see also +.br chown (1), +.br mknod (1), +.br full (4) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/getcontext.3 + +.so man7/system_data_types.7 + +.so man3/circleq.3 + +.so man2/unimplemented.2 + +.\" copyright (c) 2021 alejandro colomar +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th max 3 2020-11-01 "linux" "linux programmer's manual" +.sh name +max, min \- maximum or minimum of two values +.sh synopsis +.nf +.b #include +.pp +.bi max( a ", " b ); +.bi min( a ", " b ); +.fi +.sh description +these macros return the maximum or minimum of +.i a +and +.ir b . +.sh return value +these macros return the value of one of their arguments, +possibly converted to a different type (see bugs). +.sh errors +these macros may raise the "invalid" floating-point exception +when any of the arguments is nan. +.sh conforming to +these nonstandard macros are present in glibc and the bsds. +.sh notes +if either of the arguments is of a floating-point type, +you might prefer to use +.br fmax (3) +or +.br fmin (3), +which can handle nan. +.pp +the arguments may be evaluated more than once, or not at all. +.pp +some unix systems might provide these macros in a different header, +or not at all. +.sh bugs +due to the usual arithmetic conversions, +the result of these macros may be very different from either of the arguments. +to avoid this, ensure that both arguments have the same type. +.sh examples +.ex +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + int a, b, x; + + if (argc != 3) { + fprintf(stderr, "usage: %s \en", argv[0]); + exit(exit_failure); + } + + a = atoi(argv[1]); + b = atoi(argv[2]); + x = max(a, b); + printf("max(%d, %d) is %d\en", a, b, x); + + exit(exit_success); +} +.ee +.sh see also +.br fmax (3), +.br fmin (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man7/system_data_types.7 + +.\" copyright (c) 2008 michael kerrisk +.\" and copyright 2003 abhijit menon-sen +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" 2004-05-31, added tgkill, ahu, aeb +.\" 2008-01-15 mtk -- rewrote description +.\" +.th tkill 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +tkill, tgkill \- send a signal to a thread +.sh synopsis +.nf +.br "#include " " /* definition of " sig* " constants */" +.br "#include " " /* definition of " sys_* " constants */" +.b #include +.pp +.bi "int syscall(sys_tkill, pid_t " tid ", int " sig ); +.pp +.b #include +.pp +.bi "int tgkill(pid_t " tgid ", pid_t " tid ", int " sig ); +.fi +.pp +.ir note : +glibc provides no wrapper for +.br tkill (), +necessitating the use of +.br syscall (2). +.sh description +.br tgkill () +sends the signal +.i sig +to the thread with the thread id +.i tid +in the thread group +.ir tgid . +(by contrast, +.br kill (2) +can be used to send a signal only to a process (i.e., thread group) +as a whole, and the signal will be delivered to an arbitrary +thread within that process.) +.pp +.br tkill () +is an obsolete predecessor to +.br tgkill (). +it allows only the target thread id to be specified, +which may result in the wrong thread being signaled if a thread +terminates and its thread id is recycled. +avoid using this system call. +.\" fixme maybe say something about the following: +.\" http://sourceware.org/bugzilla/show_bug.cgi?id=12889 +.\" +.\" quoting rich felker : +.\" +.\" there is a race condition in pthread_kill: it is possible that, +.\" between the time pthread_kill reads the pid/tid from the target +.\" thread descriptor and the time it makes the tgkill syscall, +.\" the target thread terminates and the same tid gets assigned +.\" to a new thread in the same process. +.\" +.\" (the tgkill syscall was designed to eliminate a similar race +.\" condition in tkill, but it only succeeded in eliminating races +.\" where the tid gets reused in a different process, and does not +.\" help if the same tid gets assigned to a new thread in the +.\" same process.) +.\" +.\" the only solution i can see is to introduce a mutex that ensures +.\" that a thread cannot exit while pthread_kill is being called on it. +.\" +.\" note that in most real-world situations, like almost all race +.\" conditions, this one will be extremely rare. to make it +.\" measurable, one could exhaust all but 1-2 available pid values, +.\" possibly by lowering the max pid parameter in /proc, forcing +.\" the same tid to be reused rapidly. +.pp +these are the raw system call interfaces, meant for internal +thread library use. +.sh return value +on success, zero is returned. +on error, \-1 is returned, and \fierrno\fp +is set to indicate the error. +.sh errors +.tp +.b eagain +the +.b rlimit_sigpending +resource limit was reached and +.i sig +is a real-time signal. +.tp +.b eagain +insufficient kernel memory was available and +.i sig +is a real-time signal. +.tp +.b einval +an invalid thread id, thread group id, or signal was specified. +.tp +.b eperm +permission denied. +for the required permissions, see +.br kill (2). +.tp +.b esrch +no process with the specified thread id (and thread group id) exists. +.sh versions +.br tkill () +is supported since linux 2.4.19 / 2.5.4. +.br tgkill () +was added in linux 2.5.75. +.pp +library support for +.br tgkill () +was added to glibc in version 2.30. +.sh conforming to +.br tkill () +and +.br tgkill () +are linux-specific and should not be used +in programs that are intended to be portable. +.sh notes +see the description of +.b clone_thread +in +.br clone (2) +for an explanation of thread groups. +.pp +before glibc 2.30, there was also no wrapper function for +.br tgkill (). +.sh see also +.br clone (2), +.br gettid (2), +.br kill (2), +.br rt_sigqueueinfo (2) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/dprintf.3 + +.\" copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de) +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under gpl +.\" %%%license_end +.\" +.th clog2 3 2021-03-22 "" "linux programmer's manual" +.sh name +clog2, clog2f, clog2l \- base-2 logarithm of a complex number +.sh synopsis +.nf +.b #include +.pp +.bi "double complex clog2(double complex " z ); +.bi "float complex clog2f(float complex " z ); +.bi "long double complex clog2l(long double complex " z ); +.\" .pp +.\" link with \fi\-lm\fp. +.fi +.sh description +the call +.i clog2(z) +is equivalent to +.ir clog(z)/log(2) . +.pp +the other functions perform the same task for +.i float +and +.ir "long double" . +.pp +note that +.i z +close to zero will cause an overflow. +.sh conforming to +these function names are reserved for future use in c99. +.pp +not yet in glibc, as at version 2.19. +.\" but reserved in namespace. +.sh see also +.br cabs (3), +.br cexp (3), +.br clog (3), +.br clog10 (3), +.br complex (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2017 by michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" +.th ioctl_ns 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +ioctl_ns \- ioctl() operations for linux namespaces +.sh description +.\" ============================================================ +.\" +.ss discovering namespace relationships +the following +.br ioctl (2) +operations are provided to allow discovery of namespace relationships (see +.br user_namespaces (7) +and +.br pid_namespaces (7)). +the form of the calls is: +.pp +.in +4n +.ex +new_fd = ioctl(fd, request); +.ee +.in +.pp +in each case, +.i fd +refers to a +.ir /proc/[pid]/ns/* +file. +both operations return a new file descriptor on success. +.tp +.br ns_get_userns " (since linux 4.9)" +.\" commit bcac25a58bfc6bd79191ac5d7afb49bea96da8c9 +.\" commit 6786741dbf99e44fb0c0ed85a37582b8a26f1c3b +returns a file descriptor that refers to the owning user namespace +for the namespace referred to by +.ir fd . +.tp +.br ns_get_parent " (since linux 4.9)" +.\" commit a7306ed8d94af729ecef8b6e37506a1c6fc14788 +returns a file descriptor that refers to the parent namespace of +the namespace referred to by +.ir fd . +this operation is valid only for hierarchical namespaces +(i.e., pid and user namespaces). +for user namespaces, +.br ns_get_parent +is synonymous with +.br ns_get_userns . +.pp +the new file descriptor returned by these operations is opened with the +.br o_rdonly +and +.br o_cloexec +(close-on-exec; see +.br fcntl (2)) +flags. +.pp +by applying +.br fstat (2) +to the returned file descriptor, one obtains a +.i stat +structure whose +.i st_dev +(resident device) and +.i st_ino +(inode number) fields together identify the owning/parent namespace. +this inode number can be matched with the inode number of another +.ir /proc/[pid]/ns/{pid,user} +file to determine whether that is the owning/parent namespace. +.pp +either of these +.br ioctl (2) +operations can fail with the following errors: +.tp +.b eperm +the requested namespace is outside of the caller's namespace scope. +this error can occur if, for example, the owning user namespace is an +ancestor of the caller's current user namespace. +it can also occur on attempts to obtain the parent of the initial +user or pid namespace. +.tp +.b enotty +the operation is not supported by this kernel version. +.pp +additionally, the +.b ns_get_parent +operation can fail with the following error: +.tp +.b einval +.i fd +refers to a nonhierarchical namespace. +.pp +see the examples section for an example of the use of these operations. +.\" ============================================================ +.\" +.ss discovering the namespace type +the +.b ns_get_nstype +.\" commit e5ff5ce6e20ee22511398bb31fb912466cf82a36 +operation (available since linux 4.11) can be used to discover +the type of namespace referred to by the file descriptor +.ir fd : +.pp +.in +4n +.ex +nstype = ioctl(fd, ns_get_nstype); +.ee +.in +.pp +.i fd +refers to a +.ir /proc/[pid]/ns/* +file. +.pp +the return value is one of the +.br clone_new* +values that can be specified to +.br clone (2) +or +.br unshare (2) +in order to create a namespace. +.\" ============================================================ +.\" +.ss discovering the owner of a user namespace +the +.b ns_get_owner_uid +.\" commit 015bb305b8ebe8d601a238ab70ebdc394c7a19ba +operation (available since linux 4.11) can be used to discover +the owner user id of a user namespace (i.e., the effective user id +of the process that created the user namespace). +the form of the call is: +.pp +.in +4n +.ex +uid_t uid; +ioctl(fd, ns_get_owner_uid, &uid); +.ee +.in +.pp +.i fd +refers to a +.ir /proc/[pid]/ns/user +file. +.pp +the owner user id is returned in the +.i uid_t +pointed to by the third argument. +.pp +this operation can fail with the following error: +.tp +.b einval +.i fd +does not refer to a user namespace. +.sh errors +any of the above +.br ioctl () +operations can return the following errors: +.tp +.b enotty +.i fd +does not refer to a +.i /proc/[pid]/ns/* +file. +.sh conforming to +namespaces and the operations described on this page are a linux-specific. +.sh examples +the example shown below uses the +.br ioctl (2) +operations described above to perform simple +discovery of namespace relationships. +the following shell sessions show various examples of the use +of this program. +.pp +trying to get the parent of the initial user namespace fails, +since it has no parent: +.pp +.in +4n +.ex +$ \fb./ns_show /proc/self/ns/user p\fp +the parent namespace is outside your namespace scope +.ee +.in +.pp +create a process running +.br sleep (1) +that resides in new user and uts namespaces, +and show that the new uts namespace is associated with the new user namespace: +.pp +.in +4n +.ex +$ \fbunshare \-uu sleep 1000 &\fp +[1] 23235 +$ \fb./ns_show /proc/23235/ns/uts u\fp +device/inode of owning user namespace is: [0,3] / 4026532448 +$ \fbreadlink /proc/23235/ns/user\fp +user:[4026532448] +.ee +.in +.pp +then show that the parent of the new user namespace in the preceding +example is the initial user namespace: +.pp +.in +4n +.ex +$ \fbreadlink /proc/self/ns/user\fp +user:[4026531837] +$ \fb./ns_show /proc/23235/ns/user p\fp +device/inode of parent namespace is: [0,3] / 4026531837 +.ee +.in +.pp +start a shell in a new user namespace, and show that from within +this shell, the parent user namespace can't be discovered. +similarly, the uts namespace +(which is associated with the initial user namespace) +can't be discovered. +.pp +.in +4n +.ex +$ \fbps1="sh2$ " unshare \-u bash\fp +sh2$ \fb./ns_show /proc/self/ns/user p\fp +the parent namespace is outside your namespace scope +sh2$ \fb./ns_show /proc/self/ns/uts u\fp +the owning user namespace is outside your namespace scope +.ee +.in +.ss program source +\& +.ex +/* ns_show.c + + licensed under the gnu general public license v2 or later. +*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef ns_get_userns +#define nsio 0xb7 +#define ns_get_userns _io(nsio, 0x1) +#define ns_get_parent _io(nsio, 0x2) +#endif + +int +main(int argc, char *argv[]) +{ + int fd, userns_fd, parent_fd; + struct stat sb; + + if (argc < 2) { + fprintf(stderr, "usage: %s /proc/[pid]/ns/[file] [p|u]\en", + argv[0]); + fprintf(stderr, "\endisplay the result of one or both " + "of ns_get_userns (u) or ns_get_parent (p)\en" + "for the specified /proc/[pid]/ns/[file]. if neither " + "\(aqp\(aq nor \(aqu\(aq is specified,\en" + "ns_get_userns is the default.\en"); + exit(exit_failure); + } + + /* obtain a file descriptor for the \(aqns\(aq file specified + in argv[1]. */ + + fd = open(argv[1], o_rdonly); + if (fd == \-1) { + perror("open"); + exit(exit_failure); + } + + /* obtain a file descriptor for the owning user namespace and + then obtain and display the inode number of that namespace. */ + + if (argc < 3 || strchr(argv[2], \(aqu\(aq)) { + userns_fd = ioctl(fd, ns_get_userns); + + if (userns_fd == \-1) { + if (errno == eperm) + printf("the owning user namespace is outside " + "your namespace scope\en"); + else + perror("ioctl\-ns_get_userns"); + exit(exit_failure); + } + + if (fstat(userns_fd, &sb) == \-1) { + perror("fstat\-userns"); + exit(exit_failure); + } + printf("device/inode of owning user namespace is: " + "[%jx,%jx] / %ju\en", + (uintmax_t) major(sb.st_dev), + (uintmax_t) minor(sb.st_dev), + (uintmax_t) sb.st_ino); + + close(userns_fd); + } + + /* obtain a file descriptor for the parent namespace and + then obtain and display the inode number of that namespace. */ + + if (argc > 2 && strchr(argv[2], \(aqp\(aq)) { + parent_fd = ioctl(fd, ns_get_parent); + + if (parent_fd == \-1) { + if (errno == einval) + printf("can\(aq get parent namespace of a " + "nonhierarchical namespace\en"); + else if (errno == eperm) + printf("the parent namespace is outside " + "your namespace scope\en"); + else + perror("ioctl\-ns_get_parent"); + exit(exit_failure); + } + + if (fstat(parent_fd, &sb) == \-1) { + perror("fstat\-parentns"); + exit(exit_failure); + } + printf("device/inode of parent namespace is: [%jx,%jx] / %ju\en", + (uintmax_t) major(sb.st_dev), + (uintmax_t) minor(sb.st_dev), + (uintmax_t) sb.st_ino); + + close(parent_fd); + } + + exit(exit_success); +} +.ee +.sh see also +.br fstat (2), +.br ioctl (2), +.br proc (5), +.br namespaces (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/scalbln.3 + +.so man3/sincos.3 + +.\" copyright 1993 giorgio ciucci (giorgio@crcc.it) +.\" and copyright 2020 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified sun nov 28 17:06:19 1993, rik faith (faith@cs.unc.edu) +.\" with material from luigi p. bai (lpb@softint.com) +.\" portions copyright 1993 luigi p. bai +.\" modified tue oct 22 22:04:23 1996 by eric s. raymond +.\" modified, 5 jan 2002, michael kerrisk +.\" modified, 19 sep 2002, michael kerrisk +.\" added shm_remap flag description +.\" modified, 27 may 2004, michael kerrisk +.\" added notes on capability requirements +.\" modified, 11 nov 2004, michael kerrisk +.\" language and formatting clean-ups +.\" changed wording and placement of sentence regarding attachment +.\" of segments marked for destruction +.\" +.th shmop 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +shmat, shmdt \- system v shared memory operations +.sh synopsis +.nf +.b #include +.pp +.bi "void *shmat(int " shmid ", const void *" shmaddr ", int " shmflg ); +.bi "int shmdt(const void *" shmaddr ); +.fi +.sh description +.ss shmat() +.br shmat () +attaches the system\ v shared memory segment identified by +.i shmid +to the address space of the calling process. +the attaching address is specified by +.i shmaddr +with one of the following criteria: +.ip \(bu 2 +if +.i shmaddr +is null, +the system chooses a suitable (unused) page-aligned address to attach +the segment. +.ip \(bu +if +.i shmaddr +isn't null +and +.b shm_rnd +is specified in +.ir shmflg , +the attach occurs at the address equal to +.i shmaddr +rounded down to the nearest multiple of +.br shmlba . +.ip \(bu +otherwise, +.i shmaddr +must be a page-aligned address at which the attach occurs. +.pp +in addition to +.br shm_rnd , +the following flags may be specified in the +.i shmflg +bit-mask argument: +.tp +.br shm_exec " (linux-specific; since linux 2.6.9)" +allow the contents of the segment to be executed. +the caller must have execute permission on the segment. +.tp +.br shm_rdonly +attach the segment for read-only access. +the process must have read permission for the segment. +if this flag is not specified, +the segment is attached for read and write access, +and the process must have read and write permission for the segment. +there is no notion of a write-only shared memory segment. +.tp +.br shm_remap " (linux-specific)" +this flag specifies +that the mapping of the segment should replace +any existing mapping in the range starting at +.i shmaddr +and continuing for the size of the segment. +(normally, an +.b einval +error would result if a mapping already exists in this address range.) +in this case, +.i shmaddr +must not be null. +.pp +the +.br brk (2) +value of the calling process is not altered by the attach. +the segment will automatically be detached at process exit. +the same segment may be attached as a read and as a read-write +one, and more than once, in the process's address space. +.pp +a successful +.br shmat () +call updates the members of the +.i shmid_ds +structure (see +.br shmctl (2)) +associated with the shared memory segment as follows: +.ip \(bu 2 +.i shm_atime +is set to the current time. +.ip \(bu +.i shm_lpid +is set to the process-id of the calling process. +.ip \(bu +.i shm_nattch +is incremented by one. +.\" +.ss shmdt() +.br shmdt () +detaches the shared memory segment located at the address specified by +.i shmaddr +from the address space of the calling process. +the to-be-detached segment must be currently +attached with +.i shmaddr +equal to the value returned by the attaching +.br shmat () +call. +.pp +on a successful +.br shmdt () +call, the system updates the members of the +.i shmid_ds +structure associated with the shared memory segment as follows: +.ip \(bu 2 +.i shm_dtime +is set to the current time. +.ip \(bu +.i shm_lpid +is set to the process-id of the calling process. +.ip \(bu +.i shm_nattch +is decremented by one. +if it becomes 0 and the segment is marked for deletion, +the segment is deleted. +.sh return value +on success, +.br shmat () +returns the address of the attached shared memory segment; on error, +.i (void\ *)\ \-1 +is returned, and +.i errno +is set to indicate the error. +.pp +on success, +.br shmdt () +returns 0; on error \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.br shmat () +can fail with one of the following errors: +.tp +.b eacces +the calling process does not have the required permissions for +the requested attach type, and does not have the +.b cap_ipc_owner +capability in the user namespace that governs its ipc namespace. +.tp +.b eidrm +\fishmid\fp points to a removed identifier. +.tp +.b einval +invalid +.i shmid +value, unaligned (i.e., not page-aligned and \fbshm_rnd\fp was not +specified) or invalid +.i shmaddr +value, or can't attach segment at +.ir shmaddr , +or +.b shm_remap +was specified and +.i shmaddr +was null. +.tp +.b enomem +could not allocate memory for the descriptor or for the page tables. +.pp +.br shmdt () +can fail with one of the following errors: +.tp +.b einval +there is no shared memory segment attached at +.ir shmaddr ; +or, +.\" the following since 2.6.17-rc1: +.i shmaddr +is not aligned on a page boundary. +.sh conforming to +posix.1-2001, posix.1-2008, svr4. +.\" svr4 documents an additional error condition emfile. +.pp +in svid 3 (or perhaps earlier), +the type of the \fishmaddr\fp argument was changed from +.i "char\ *" +into +.ir "const void\ *" , +and the returned type of +.br shmat () +from +.i "char\ *" +into +.ir "void\ *" . +.sh notes +after a +.br fork (2), +the child inherits the attached shared memory segments. +.pp +after an +.br execve (2), +all attached shared memory segments are detached from the process. +.pp +upon +.br _exit (2), +all attached shared memory segments are detached from the process. +.pp +using +.br shmat () +with +.i shmaddr +equal to null +is the preferred, portable way of attaching a shared memory segment. +be aware that the shared memory segment attached in this way +may be attached at different addresses in different processes. +therefore, any pointers maintained within the shared memory must be +made relative (typically to the starting address of the segment), +rather than absolute. +.pp +on linux, it is possible to attach a shared memory segment even if it +is already marked to be deleted. +however, posix.1 does not specify this behavior and +many other implementations do not support it. +.pp +the following system parameter affects +.br shmat (): +.tp +.b shmlba +segment low boundary address multiple. +when explicitly specifying an attach address in a call to +.br shmat (), +the caller should ensure that the address is a multiple of this value. +this is necessary on some architectures, +in order either to ensure good cpu cache performance or to ensure that +different attaches of the same segment have consistent views +within the cpu cache. +.b shmlba +is normally some multiple of the system page size. +(on many linux architectures, +.b shmlba +is the same as the system page size.) +.pp +the implementation places no intrinsic per-process limit on the +number of shared memory segments +.rb ( shmseg ). +.sh examples +the two programs shown below exchange a string using a shared memory segment. +further details about the programs are given below. +first, we show a shell session demonstrating their use. +.pp +in one terminal window, we run the "reader" program, +which creates a system v shared memory segment and a system v semaphore set. +the program prints out the ids of the created objects, +and then waits for the semaphore to change value. +.pp +.in +4n +.ex +$ \fb./svshm_string_read\fp +shmid = 1114194; semid = 15 +.ee +.in +.pp +in another terminal window, we run the "writer" program. +the "writer" program takes three command-line arguments: +the ids of the shared memory segment and semaphore set created +by the "reader", and a string. +it attaches the existing shared memory segment, +copies the string to the shared memory, and modifies the semaphore value. +.pp +.in +4n +.ex +$ \fb./svshm_string_write 1114194 15 \(aqhello, world\(aq\fp +.ee +.in +.pp +returning to the terminal where the "reader" is running, +we see that the program has ceased waiting on the semaphore +and has printed the string that was copied into the +shared memory segment by the writer: +.pp +.in +4n +.ex +hello, world +.ee +.in +.\" +.ss program source: svshm_string.h +the following header file is included by the "reader" and "writer" programs: +.pp +.in +4n +.ex +/* svshm_string.h + + licensed under gnu general public license v2 or later. +*/ +#include +#include +#include +#include +#include +#include +#include + +#define errexit(msg) do { perror(msg); exit(exit_failure); \e + } while (0) + +union semun { /* used in calls to semctl() */ + int val; + struct semid_ds * buf; + unsigned short * array; +#if defined(__linux__) + struct seminfo * __buf; +#endif +}; + +#define mem_size 4096 +.ee +.in +.\" +.ss program source: svshm_string_read.c +the "reader" program creates a shared memory segment and a semaphore set +containing one semaphore. +it then attaches the shared memory object into its address space +and initializes the semaphore value to 1. +finally, the program waits for the semaphore value to become 0, +and afterwards prints the string that has been copied into the +shared memory segment by the "writer". +.pp +.in +4n +.ex +/* svshm_string_read.c + + licensed under gnu general public license v2 or later. +*/ +#include "svshm_string.h" + +int +main(int argc, char *argv[]) +{ + int semid, shmid; + union semun arg, dummy; + struct sembuf sop; + char *addr; + + /* create shared memory and semaphore set containing one + semaphore. */ + + shmid = shmget(ipc_private, mem_size, ipc_creat | 0600); + if (shmid == \-1) + errexit("shmget"); + + semid = semget(ipc_private, 1, ipc_creat | 0600); + if (semid == \-1) + errexit("semget"); + + /* attach shared memory into our address space. */ + + addr = shmat(shmid, null, shm_rdonly); + if (addr == (void *) \-1) + errexit("shmat"); + + /* initialize semaphore 0 in set with value 1. */ + + arg.val = 1; + if (semctl(semid, 0, setval, arg) == \-1) + errexit("semctl"); + + printf("shmid = %d; semid = %d\en", shmid, semid); + + /* wait for semaphore value to become 0. */ + + sop.sem_num = 0; + sop.sem_op = 0; + sop.sem_flg = 0; + + if (semop(semid, &sop, 1) == \-1) + errexit("semop"); + + /* print the string from shared memory. */ + + printf("%s\en", addr); + + /* remove shared memory and semaphore set. */ + + if (shmctl(shmid, ipc_rmid, null) == \-1) + errexit("shmctl"); + if (semctl(semid, 0, ipc_rmid, dummy) == \-1) + errexit("semctl"); + + exit(exit_success); +} +.ee +.in +.\" +.ss program source: svshm_string_write.c +the writer program takes three command-line arguments: +the ids of the shared memory segment and semaphore set +that have already been created by the "reader", and a string. +it attaches the shared memory segment into its address space, +and then decrements the semaphore value to 0 in order to inform the +"reader" that it can now examine the contents of the shared memory. +.pp +.in +4n +.ex +/* svshm_string_write.c + + licensed under gnu general public license v2 or later. +*/ +#include "svshm_string.h" + +int +main(int argc, char *argv[]) +{ + int semid, shmid; + struct sembuf sop; + char *addr; + size_t len; + + if (argc != 4) { + fprintf(stderr, "usage: %s shmid semid string\en", argv[0]); + exit(exit_failure); + } + + len = strlen(argv[3]) + 1; /* +1 to include trailing \(aq\e0\(aq */ + if (len > mem_size) { + fprintf(stderr, "string is too big!\en"); + exit(exit_failure); + } + + /* get object ids from command\-line. */ + + shmid = atoi(argv[1]); + semid = atoi(argv[2]); + + /* attach shared memory into our address space and copy string + (including trailing null byte) into memory. */ + + addr = shmat(shmid, null, 0); + if (addr == (void *) \-1) + errexit("shmat"); + + memcpy(addr, argv[3], len); + + /* decrement semaphore to 0. */ + + sop.sem_num = 0; + sop.sem_op = \-1; + sop.sem_flg = 0; + + if (semop(semid, &sop, 1) == \-1) + errexit("semop"); + + exit(exit_success); +} +.ee +.in +.sh see also +.br brk (2), +.br mmap (2), +.br shmctl (2), +.br shmget (2), +.br capabilities (7), +.br shm_overview (7), +.br sysvipc (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" this manpage is copyright (c) 2006, michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th feature_test_macros 7 2021-03-22 "linux" "linux programmer's manual" +.sh name +feature_test_macros \- feature test macros +.sh description +feature test macros allow the programmer to control the definitions that +are exposed by system header files when a program is compiled. +.pp +.b note: +in order to be effective, a feature test macro +.ir "must be defined before including any header files" . +this can be done either in the compilation command +.ri ( "cc \-dmacro=value" ) +or by defining the macro within the source code before +including any headers. +the requirement that the macro must be defined before including any +header file exists because header files may freely include one another. +thus, for example, in the following lines, defining the +.b _gnu_source +macro may have no effect because the header +.i +itself includes +.i +(posix explicitly allows this): +.pp +.in +4n +.ex +#include +#define _gnu_source +#include +.ee +.in +.pp +some feature test macros are useful for creating portable applications, +by preventing nonstandard definitions from being exposed. +other macros can be used to expose nonstandard definitions that +are not exposed by default. +.pp +the precise effects of each of the feature test macros described below +can be ascertained by inspecting the +.i +header file. +.br note : +applications do +.i not +need to directly include +.ir ; +indeed, doing so is actively discouraged. +see notes. +.ss specification of feature test macro requirements in manual pages +when a function requires that a feature test macro is defined, +the manual page synopsis typically includes a note of the following form +(this example from the +.br acct (2) +manual page): +.pp +.rs +.b #include +.pp +.bi "int acct(const char *" filename ); +.pp +.rs -4 +.ex +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.ee +.re +.pp +.br acct (): +_bsd_source || (_xopen_source && _xopen_source < 500) +.re +.pp +the +.b || +means that in order to obtain the declaration of +.br acct (2) +from +.ir , +.i either +of the following macro +definitions must be made before including any header files: +.pp +.in +4n +.ex +#define _bsd_source +#define _xopen_source /* or any value < 500 */ +.ee +.in +.pp +alternatively, equivalent definitions can be included in the +compilation command: +.pp +.in +4n +.ex +cc \-d_bsd_source +cc \-d_xopen_source # or any value < 500 +.ee +.in +.pp +note that, as described below, +.br "some feature test macros are defined by default" , +so that it may not always be necessary to +explicitly specify the feature test macro(s) shown in the +synopsis. +.pp +in a few cases, manual pages use a shorthand for expressing the +feature test macro requirements (this example from +.br readahead (2)): +.pp +.rs +4 +.ex +.b #define _gnu_source +.b #include +.pp +.bi "ssize_t readahead(int " fd ", off64_t *" offset ", size_t " count ); +.ee +.re +.pp +this format is employed in cases where only a single +feature test macro can be used to expose the function +declaration, and that macro is not defined by default. +.ss feature test macros understood by glibc +the paragraphs below explain how feature test macros are handled +in glibc 2.\fix\fp, +.i x +> 0. +.pp +first, though, a summary of a few details for the impatient: +.ip * 3 +the macros that you most likely need to use in modern source code are +.br _posix_c_source +(for definitions from various versions of posix.1), +.br _xopen_source +(for definitions from various versions of sus), +.br _gnu_source +(for gnu and/or linux specific stuff), and +.br _default_source +(to get definitions that would normally be provided by default). +.ip * +certain macros are defined with default values. +thus, although one or more macros may be indicated as being +required in the synopsis of a man page, +it may not be necessary to define them explicitly. +full details of the defaults are given later in this man page. +.ip * +defining +.br _xopen_source +with a value of 600 or greater produces the same effects as defining +.br _posix_c_source +with a value of 200112l or greater. +where one sees +.ip +.in +4n +.ex +_posix_c_source >= 200112l +.ee +.in +.ip +in the feature test macro requirements in the synopsis of a man page, +it is implicit that the following has the same effect: +.ip +.in +4n +.ex +_xopen_source >= 600 +.ee +.in +.ip * +defining +.br _xopen_source +with a value of 700 or greater produces the same effects as defining +.br _posix_c_source +with a value of 200809l or greater. +where one sees +.ip +.in +4n +.ex +_posix_c_source >= 200809l +.ee +.in +.ip +in the feature test macro requirements in the synopsis of a man page, +it is implicit that the following has the same effect: +.ip +.in +4n +.ex +_xopen_source >= 700 +.ee +.in +.\" the details in glibc 2.0 are simpler, but combining a +.\" a description of them with the details in later glibc versions +.\" would make for a complicated description. +.pp +glibc understands the following feature test macros: +.tp +.b __strict_ansi__ +iso standard c. +this macro is implicitly defined by +.br gcc (1) +when invoked with, for example, the +.i \-std=c99 +or +.i \-ansi +flag. +.tp +.b _posix_c_source +defining this macro causes header files to expose definitions as follows: +.rs +.ip \(bu 3 +the value 1 exposes definitions conforming to posix.1-1990 and +iso c (1990). +.ip \(bu +the value 2 or greater additionally exposes +definitions for posix.2-1992. +.ip \(bu +the value 199309l or greater additionally exposes +definitions for posix.1b (real-time extensions). +.\" 199506l functionality is available only since glibc 2.1 +.ip \(bu +the value 199506l or greater additionally exposes +definitions for posix.1c (threads). +.ip \(bu +(since glibc 2.3.3) +the value 200112l or greater additionally exposes definitions corresponding +to the posix.1-2001 base specification (excluding the xsi extension). +this value also causes c95 (since glibc 2.12) and +c99 (since glibc 2.10) features to be exposed +(in other words, the equivalent of defining +.br _isoc99_source ). +.ip \(bu +(since glibc 2.10) +the value 200809l or greater additionally exposes definitions corresponding +to the posix.1-2008 base specification (excluding the xsi extension). +.re +.tp +.b _posix_source +defining this obsolete macro with any value is equivalent to defining +.b _posix_c_source +with the value 1. +.ip +since this macro is obsolete, +its usage is generally not documented when discussing +feature test macro requirements in the man pages. +.tp +.b _xopen_source +defining this macro causes header files to expose definitions as follows: +.rs +.ip \(bu 3 +defining with any value exposes +definitions conforming to posix.1, posix.2, and xpg4. +.ip \(bu +the value 500 or greater additionally exposes +definitions for susv2 (unix 98). +.ip \(bu +(since glibc 2.2) the value 600 or greater additionally exposes +definitions for susv3 (unix 03; i.e., the posix.1-2001 base specification +plus the xsi extension) and c99 definitions. +.ip \(bu +(since glibc 2.10) the value 700 or greater additionally exposes +definitions for susv4 (i.e., the posix.1-2008 base specification +plus the xsi extension). +.re +.ip +if +.b __strict_ansi__ +is not defined, or +.br _xopen_source +is defined with a value greater than or equal to 500 +.i and +neither +.b _posix_source +nor +.b _posix_c_source +is explicitly defined, then +the following macros are implicitly defined: +.rs +.ip \(bu 3 +.b _posix_source +is defined with the value 1. +.ip \(bu +.b _posix_c_source +is defined, according to the value of +.br _xopen_source : +.rs +.tp +.br _xopen_source " < 500" +.b _posix_c_source +is defined with the value 2. +.tp +.rb "500 <= " _xopen_source " < 600" +.b _posix_c_source +is defined with the value 199506l. +.tp +.rb "600 <= " _xopen_source " < 700" +.b _posix_c_source +is defined with the value 200112l. +.tp +.rb "700 <= " _xopen_source " (since glibc 2.10)" +.b _posix_c_source +is defined with the value 200809l. +.re +.re +.ip +in addition, defining +.br _xopen_source +with a value of 500 or greater produces the same effects as defining +.br _xopen_source_extended . +.tp +.b _xopen_source_extended +if this macro is defined, +.i and +.b _xopen_source +is defined, then expose definitions corresponding to the xpg4v2 +(susv1) unix extensions (unix 95). +defining +.b _xopen_source +with a value of 500 or more also produces the same effect as defining +.br _xopen_source_extended . +use of +.br _xopen_source_extended +in new source code should be avoided. +.ip +since defining +.b _xopen_source +with a value of 500 or more has the same effect as defining +.br _xopen_source_extended , +the latter (obsolete) feature test macro is generally not described in the +synopsis in man pages. +.tp +.br _isoc99_source " (since glibc 2.1.3)" +exposes declarations consistent with the iso c99 standard. +.ip +earlier glibc 2.1.x versions recognized an equivalent macro named +.b _isoc9x_source +(because the c99 standard had not then been finalized). +although the use of this macro is obsolete, glibc continues +to recognize it for backward compatibility. +.ip +defining +.b _isoc99_source +also exposes iso c (1990) amendment 1 ("c95") definitions. +(the primary change in c95 was support for international character sets.) +.ip +invoking the c compiler with the option +.ir \-std=c99 +produces the same effects as defining this macro. +.tp +.br _isoc11_source " (since glibc 2.16)" +exposes declarations consistent with the iso c11 standard. +defining this macro also enables c99 and c95 features (like +.br _isoc99_source ). +.ip +invoking the c compiler with the option +.ir \-std=c11 +produces the same effects as defining this macro. +.tp +.b _largefile64_source +expose definitions for the alternative api specified by the +lfs (large file summit) as a "transitional extension" to the +single unix specification. +(see +.ur http:\:/\:/opengroup.org\:/platform\:/lfs.html +.ue .) +the alternative api consists of a set of new objects +(i.e., functions and types) whose names are suffixed with "64" +(e.g., +.i off64_t +versus +.ir off_t , +.br lseek64 () +versus +.br lseek (), +etc.). +new programs should not employ this macro; instead +.i _file_offset_bits=64 +should be employed. +.tp +.br _largefile_source +this macro was historically used to expose certain functions (specifically +.br fseeko (3) +and +.br ftello (3)) +that address limitations of earlier apis +.rb ( fseek (3) +and +.br ftell (3)) +that use +.ir "long" +for file offsets. +this macro is implicitly defined if +.br _xopen_source +is defined with a value greater than or equal to 500. +new programs should not employ this macro; +defining +.br _xopen_source +as just described or defining +.b _file_offset_bits +with the value 64 is the preferred mechanism to achieve the same result. +.tp +.b _file_offset_bits +defining this macro with the value 64 +automatically converts references to 32-bit functions and data types +related to file i/o and filesystem operations into references to +their 64-bit counterparts. +this is useful for performing i/o on large files (> 2 gigabytes) +on 32-bit systems. +(defining this macro permits correctly written programs to use +large files with only a recompilation being required.) +.ip +64-bit systems naturally permit file sizes greater than 2 gigabytes, +and on those systems this macro has no effect. +.tp +.br _bsd_source " (deprecated since glibc 2.20)" +defining this macro with any value causes header files to expose +bsd-derived definitions. +.ip +in glibc versions up to and including 2.18, +defining this macro also causes bsd definitions to be preferred in +some situations where standards conflict, unless one or more of +.br _svid_source , +.br _posix_source , +.br _posix_c_source , +.br _xopen_source , +.br _xopen_source_extended , +or +.b _gnu_source +is defined, in which case bsd definitions are disfavored. +since glibc 2.19, +.b _bsd_source +no longer causes bsd definitions to be preferred in case of conflicts. +.ip +since glibc 2.20, this macro is deprecated. +.\" commit c941736c92fa3a319221f65f6755659b2a5e0a20 +.\" commit 498afc54dfee41d33ba519f496e96480badace8e +.\" commit acd7f096d79c181866d56d4aaf3b043e741f1e2c +it now has the same effect as defining +.br _default_source , +but generates a compile-time warning (unless +.br _default_source +.\" commit ade40b10ff5fa59a318cf55b9d8414b758e8df78 +is also defined). +use +.b _default_source +instead. +to allow code that requires +.br _bsd_source +in glibc 2.19 and earlier and +.br _default_source +in glibc 2.20 and later to compile without warnings, define +.i both +.b _bsd_source +and +.br _default_source . +.tp +.br _svid_source " (deprecated since glibc 2.20)" +defining this macro with any value causes header files to expose +system v-derived definitions. +(svid == system v interface definition; see +.br standards (7).) +.ip +since glibc 2.20, this macro is deprecated in the same fashion as +.br _bsd_source . +.tp +.br _default_source " (since glibc 2.19)" +this macro can be defined to ensure that the "default" +definitions are provided even when the defaults would otherwise +be disabled, +as happens when individual macros are explicitly defined, +or the compiler is invoked in one of its "standard" modes (e.g., +.ir "cc\ \-std=c99" ). +defining +.b _default_source +without defining other individual macros +or invoking the compiler in one of its "standard" modes has no effect. +.ip +the "default" definitions comprise those required by posix.1-2008 and iso c99, +as well as various definitions originally derived from bsd and system v. +on glibc 2.19 and earlier, these defaults were approximately equivalent +to explicitly defining the following: +.ip + cc \-d_bsd_source \-d_svid_source \-d_posix_c_source=200809 +.tp +.br _atfile_source " (since glibc 2.4)" +defining this macro with any value causes header files to expose +declarations of a range of functions with the suffix "at"; +see +.br openat (2). +since glibc 2.10, this macro is also implicitly defined if +.br _posix_c_source +is defined with a value greater than or equal to 200809l. +.tp +.b _gnu_source +defining this macro (with any value) implicitly defines +.br _atfile_source , +.br _largefile64_source , +.br _isoc99_source , +.br _xopen_source_extended , +.br _posix_source , +.b _posix_c_source +with the value 200809l +(200112l in glibc versions before 2.10; +199506l in glibc versions before 2.5; +199309l in glibc versions before 2.1) +and +.b _xopen_source +with the value 700 +(600 in glibc versions before 2.10; +500 in glibc versions before 2.2). +in addition, various gnu-specific extensions are also exposed. +.ip +since glibc 2.19, defining +.br _gnu_source +also has the effect of implicitly defining +.br _default_source . +in glibc versions before 2.20, defining +.br _gnu_source +also had the effect of implicitly defining +.br _bsd_source +and +.br _svid_source . +.tp +.b _reentrant +historically, on various c libraries +it was necessary to define this macro in all +multithreaded code. +.\" zack weinberg +.\" there did once exist c libraries where it was necessary. the ones +.\" i remember were proprietary unix vendor libcs from the mid-1990s +.\" you would get completely unlocked stdio without _reentrant. +(some c libraries may still require this.) +in glibc, +this macro also exposed definitions of certain reentrant functions. +.ip +however, glibc has been thread-safe by default for many years; +since glibc 2.3, the only effect of defining +.br _reentrant +has been to enable one or two of the same declarations that +are also enabled by defining +.br _posix_c_source +with a value of 199606l or greater. +.ip +.b _reentrant +is now obsolete. +in glibc 2.25 and later, defining +.b _reentrant +is equivalent to defining +.b _posix_c_source +with the value 199606l. +if a higher posix conformance level is +selected by any other means (such as +.b _posix_c_source +itself, +.br _xopen_source , +.br _default_source , +or +.br _gnu_source ), +then defining +.b _reentrant +has no effect. +.ip +this macro is automatically defined if one compiles with +.ir "cc\ \-pthread" . +.tp +.b _thread_safe +synonym for the (deprecated) +.br _reentrant , +provided for compatibility with some other implementations. +.tp +.br _fortify_source " (since glibc 2.3.4)" +.\" for more detail, see: +.\" http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html +.\" [patch] object size checking to prevent (some) buffer overflows +.\" * from: jakub jelinek +.\" * to: gcc-patches at gcc dot gnu dot org +.\" * date: tue, 21 sep 2004 04:16:40 -0400 +defining this macro causes some lightweight checks to be performed +to detect some buffer overflow errors when employing +various string and memory manipulation functions (for example, +.br memcpy (3), +.br memset (3), +.br stpcpy (3), +.br strcpy (3), +.br strncpy (3), +.br strcat (3), +.br strncat (3), +.br sprintf (3), +.br snprintf (3), +.br vsprintf (3), +.br vsnprintf (3), +.br gets (3), +and wide character variants thereof). +for some functions, argument consistency is checked; +for example, a check is made that +.br open (2) +has been supplied with a +.i mode +argument when the specified flags include +.br o_creat . +not all problems are detected, just some common cases. +.\" look for __use_fortify_level in the header files +.ip +if +.b _fortify_source +is set to 1, with compiler optimization level 1 +.ri ( "gcc\ \-o1" ) +and above, checks that shouldn't change the behavior of +conforming programs are performed. +with +.b _fortify_source +set to 2, some more checking is added, but +some conforming programs might fail. +.\" for example, given the following code +.\" int d; +.\" char buf[1000], buf[1000]; +.\" strcpy(fmt, "hello world\n%n"); +.\" snprintf(buf, sizeof(buf), fmt, &d); +.\" +.\" compiling with "gcc -d_fortify_source=2 -o1" and then running will +.\" cause the following diagnostic at run time at the snprintf() call +.\" +.\" *** %n in writable segment detected *** +.\" aborted (core dumped) +.\" +.ip +some of the checks can be performed at compile time +(via macros logic implemented in header files), +and result in compiler warnings; +other checks take place at run time, +and result in a run-time error if the check fails. +.ip +use of this macro requires compiler support, available with +.br gcc (1) +since version 4.0. +.ss default definitions, implicit definitions, and combining definitions +if no feature test macros are explicitly defined, +then the following feature test macros are defined by default: +.br _bsd_source +(in glibc 2.19 and earlier), +.br _svid_source +(in glibc 2.19 and earlier), +.br _default_source +(since glibc 2.19), +.br _posix_source , +and +.br _posix_c_source =200809l +(200112l in glibc versions before 2.10; +199506l in glibc versions before 2.4; +199309l in glibc versions before 2.1). +.pp +if any of +.br __strict_ansi__ , +.br _isoc99_source , +.br _isoc11_source +(since glibc 2.18), +.br _posix_source , +.br _posix_c_source , +.br _xopen_source , +.br _xopen_source_extended +(in glibc 2.11 and earlier), +.br _bsd_source +(in glibc 2.19 and earlier), +or +.b _svid_source +(in glibc 2.19 and earlier) +is explicitly defined, then +.br _bsd_source , +.br _svid_source , +and +.br _default_source +are not defined by default. +.pp +if +.b _posix_source +and +.b _posix_c_source +are not explicitly defined, +and either +.b __strict_ansi__ +is not defined or +.b _xopen_source +is defined with a value of 500 or more, then +.ip * 3 +.b _posix_source +is defined with the value 1; and +.ip * +.b _posix_c_source +is defined with one of the following values: +.rs 3 +.ip \(bu 3 +2, +if +.b _xopen_source +is defined with a value less than 500; +.ip \(bu +199506l, +if +.b _xopen_source +is defined with a value greater than or equal to 500 and less than 600; +or +.ip \(bu +(since glibc 2.4) 200112l, +if +.b _xopen_source +is defined with a value greater than or equal to 600 and less than 700. +.ip \(bu +(since glibc 2.10) +200809l, +if +.b _xopen_source +is defined with a value greater than or equal to 700. +.ip \(bu +older versions of glibc do not know about the values +200112l and 200809l for +.br _posix_c_source , +and the setting of this macro will depend on the glibc version. +.ip \(bu +if +.b _xopen_source +is undefined, then the setting of +.b _posix_c_source +depends on the glibc version: +199506l, in glibc versions before 2.4; +200112l, in glibc 2.4 to 2.9; and +200809l, since glibc 2.10. +.re +.pp +multiple macros can be defined; the results are additive. +.sh conforming to +posix.1 specifies +.br _posix_c_source , +.br _posix_source , +and +.br _xopen_source . +.pp +.b _xopen_source_extended +was specified by xpg4v2 (aka susv1), but is not present in susv2 and later. +.b _file_offset_bits +is not specified by any standard, +but is employed on some other implementations. +.pp +.br _bsd_source , +.br _svid_source , +.br _default_source , +.br _atfile_source , +.br _gnu_source , +.br _fortify_source , +.br _reentrant , +and +.b _thread_safe +are specific to linux (glibc). +.sh notes +.i +is a linux/glibc-specific header file. +other systems have an analogous file, but typically with a different name. +this header file is automatically included by other header files as +required: it is not necessary to explicitly include it in order to +employ feature test macros. +.pp +according to which of the above feature test macros are defined, +.i +internally defines various other macros that are checked by +other glibc header files. +these macros have names prefixed by two underscores (e.g., +.br __use_misc ). +programs should +.i never +define these macros directly: +instead, the appropriate feature test macro(s) from the +list above should be employed. +.sh examples +the program below can be used to explore how the various +feature test macros are set depending on the glibc version +and what feature test macros are explicitly set. +the following shell session, on a system with glibc 2.10, +shows some examples of what we would see: +.pp +.in +4n +.ex +$ \fbcc ftm.c\fp +$ \fb./a.out\fp +_posix_source defined +_posix_c_source defined: 200809l +_bsd_source defined +_svid_source defined +_atfile_source defined +$ \fbcc \-d_xopen_source=500 ftm.c\fp +$ \fb./a.out\fp +_posix_source defined +_posix_c_source defined: 199506l +_xopen_source defined: 500 +$ \fbcc \-d_gnu_source ftm.c\fp +$ \fb./a.out\fp +_posix_source defined +_posix_c_source defined: 200809l +_isoc99_source defined +_xopen_source defined: 700 +_xopen_source_extended defined +_largefile64_source defined +_bsd_source defined +_svid_source defined +_atfile_source defined +_gnu_source defined +.ee +.in +.ss program source +\& +.ex +/* ftm.c */ + +#include +#include +#include +#include + +int +main(int argc, char *argv[]) +{ +#ifdef _posix_source + printf("_posix_source defined\en"); +#endif + +#ifdef _posix_c_source + printf("_posix_c_source defined: %jdl\en", + (intmax_t) _posix_c_source); +#endif + +#ifdef _isoc99_source + printf("_isoc99_source defined\en"); +#endif + +#ifdef _isoc11_source + printf("_isoc11_source defined\en"); +#endif + +#ifdef _xopen_source + printf("_xopen_source defined: %d\en", _xopen_source); +#endif + +#ifdef _xopen_source_extended + printf("_xopen_source_extended defined\en"); +#endif + +#ifdef _largefile64_source + printf("_largefile64_source defined\en"); +#endif + +#ifdef _file_offset_bits + printf("_file_offset_bits defined: %d\en", _file_offset_bits); +#endif + +#ifdef _bsd_source + printf("_bsd_source defined\en"); +#endif + +#ifdef _svid_source + printf("_svid_source defined\en"); +#endif + +#ifdef _default_source + printf("_default_source defined\en"); +#endif + +#ifdef _atfile_source + printf("_atfile_source defined\en"); +#endif + +#ifdef _gnu_source + printf("_gnu_source defined\en"); +#endif + +#ifdef _reentrant + printf("_reentrant defined\en"); +#endif + +#ifdef _thread_safe + printf("_thread_safe defined\en"); +#endif + +#ifdef _fortify_source + printf("_fortify_source defined\en"); +#endif + + exit(exit_success); +} +.ee +.sh see also +.br libc (7), +.br standards (7), +.br system_data_types (7) +.pp +the section "feature test macros" under +.ir "info libc" . +.\" but beware: the info libc document is out of date (jul 07, mtk) +.pp +.i /usr/include/features.h +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/circleq.3 + +.so man3/isgreater.3 + +.\" copyright (c) 2008 by gerrit renker +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" $id: udplite.7,v 1.12 2008/07/23 15:22:22 gerrit exp gerrit $ +.\" +.th udplite 7 2021-03-22 "linux" "linux programmer's manual" +.sh name +udplite \- lightweight user datagram protocol +.sh synopsis +.nf +.b #include +.\" fixme . see #defines under `bugs', +.\" when glibc supports this, add +.\" #include +.pp +.b sockfd = socket(af_inet, sock_dgram, ipproto_udplite); +.fi +.sh description +this is an implementation of the lightweight user datagram protocol +(udp-lite), as described in rfc\ 3828. +.pp +udp-lite is an extension of udp (rfc\ 768) to support variable-length +checksums. +this has advantages for some types of multimedia transport that +may be able to make use of slightly damaged datagrams, +rather than having them discarded by lower-layer protocols. +.pp +the variable-length checksum coverage is set via a +.br setsockopt (2) +option. +if this option is not set, the only difference from udp is +in using a different ip protocol identifier (iana number 136). +.pp +the udp-lite implementation is a full extension of +.br udp (7)\(emthat +is, it shares the same api and api behavior, and in addition +offers two socket options to control the checksum coverage. +.ss address format +udp-litev4 uses the +.i sockaddr_in +address format described in +.br ip (7). +udp-litev6 uses the +.i sockaddr_in6 +address format described in +.br ipv6 (7). +.ss socket options +to set or get a udp-lite socket option, call +.br getsockopt (2) +to read or +.br setsockopt (2) +to write the option with the option level argument set to +.br ipproto_udplite . +in addition, all +.b ipproto_udp +socket options are valid on a udp-lite socket. +see +.br udp (7) +for more information. +.pp +the following two options are specific to udp-lite. +.tp +.br udplite_send_cscov +this option sets the sender checksum coverage and takes an +.i int +as argument, with a checksum coverage value in the range 0..2^16-1. +.ip +a value of 0 means that the entire datagram is always covered. +values from 1\-7 are illegal (rfc\ 3828, 3.1) and are rounded up to +the minimum coverage of 8. +.ip +with regard to ipv6 jumbograms (rfc\ 2675), the udp-litev6 checksum +coverage is limited to the first 2^16-1 octets, as per rfc\ 3828, 3.5. +higher values are therefore silently truncated to 2^16-1. +if in doubt, the current coverage value can always be queried using +.br getsockopt (2). +.tp +.br udplite_recv_cscov +this is the receiver-side analogue and uses the same argument format +and value range as +.br udplite_send_cscov . +this option is not required to enable traffic with partial checksum +coverage. +its function is that of a traffic filter: when enabled, it +instructs the kernel to drop all packets which have a coverage +.i less +than the specified coverage value. +.ip +when the value of +.b udplite_recv_cscov +exceeds the actual packet coverage, incoming packets are silently dropped, +but may generate a warning message in the system log. +.\" so_no_check exists and is supported by udpv4, but is +.\" commented out in socket(7), hence also commented out here +.\".pp +.\"since udp-lite mandates checksums, checksumming can not be disabled +.\"via the +.\".b so_no_check +.\"option from +.\".br socket (7). +.sh errors +all errors documented for +.br udp (7) +may be returned. +udp-lite does not add further errors. +.sh files +.tp +.i /proc/net/snmp +basic udp-litev4 statistics counters. +.tp +.i /proc/net/snmp6 +basic udp-litev6 statistics counters. +.sh versions +udp-litev4/v6 first appeared in linux 2.6.20. +.sh bugs +.\" fixme . remove this section once glibc supports udp-lite +where glibc support is missing, the following definitions are needed: +.pp +.in +4n +.ex +#define ipproto_udplite 136 +.\" the following two are defined in the kernel in linux/net/udplite.h +#define udplite_send_cscov 10 +#define udplite_recv_cscov 11 +.ee +.in +.sh see also +.br ip (7), +.br ipv6 (7), +.br socket (7), +.br udp (7) +.pp +rfc\ 3828 for the lightweight user datagram protocol (udp-lite). +.pp +.i documentation/networking/udplite.txt +in the linux kernel source tree +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/malloc_hook.3 + +.\" copyright (c) 1992 drew eckhardt (drew@cs.colorado.edu), march 28, 1992 +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified by michael haardt +.\" modified 1993-07-24 by rik faith +.\" modified 2001-03-16 by andries brouwer +.\" modified 2004-05-27 by michael kerrisk +.\" +.th stime 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +stime \- set time +.sh synopsis +.nf +.b #include +.pp +.bi "int stime(const time_t *" t ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br stime (): +.nf + since glibc 2.19: + _default_source + glibc 2.19 and earlier: + _svid_source +.fi +.sh description +.br note : +this function is deprecated; +use +.br clock_settime (2) +instead. +.pp +.br stime () +sets the system's idea of the time and date. +the time, pointed +to by \fit\fp, is measured in seconds since the +epoch, 1970-01-01 00:00:00 +0000 (utc). +.br stime () +may be executed only by the superuser. +.sh return value +on success, zero is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b efault +error in getting information from user space. +.tp +.b eperm +the calling process has insufficient privilege. +under linux, the +.b cap_sys_time +privilege is required. +.sh conforming to +svr4. +.sh notes +starting with glibc 2.31, +this function is no longer available to newly linked applications +and is no longer declared in +.ir . +.sh see also +.br date (1), +.br settimeofday (2), +.br capabilities (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/sigsetops.3 + +.so man3/csqrt.3 + +.so man2/init_module.2 + +.\" copyright (c) 2006 by michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" 28 dec 2006 - initial creation +.\" +.th termio 7 2017-05-03 "linux" "linux programmer's manual" +.sh name +termio \- system v terminal driver interface +.sh description +.b termio +is the name of the old system v terminal driver interface. +this interface defined a +.i termio +structure used to store terminal settings, and a range of +.br ioctl (2) +operations to get and set terminal attributes. +.pp +the +.b termio +interface is now obsolete: posix.1-1990 standardized a modified +version of this interface, under the name +.br termios . +the posix.1 data structure differs slightly from the +system v version, and posix.1 defined a suite of functions +to replace the various +.br ioctl (2) +operations that existed in system v. +(this was done because +.br ioctl (2) +was unstandardized, and its variadic third argument +does not allow argument type checking.) +.pp +if you're looking for a page called "termio", then you can probably +find most of the information that you seek in either +.br termios (3) +or +.br ioctl_tty (2). +.sh see also +.br reset (1), +.br setterm (1), +.br stty (1), +.br ioctl_tty (2), +.br termios (3), +.br tty (4) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/pthread_attr_setschedpolicy.3 + +.so man2/select.2 + +.so man3/sigset.3 + +.\" copyright (c) 2006 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th sem_close 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +sem_close \- close a named semaphore +.sh synopsis +.nf +.b #include +.pp +.bi "int sem_close(sem_t *" sem ); +.fi +.pp +link with \fi\-pthread\fp. +.sh description +.br sem_close () +closes the named semaphore referred to by +.ir sem , +allowing any resources that the system has allocated to +the calling process for this semaphore to be freed. +.sh return value +on success +.br sem_close () +returns 0; on error, \-1 is returned, with +.i errno +set to indicate the error. +.sh errors +.tp +.b einval +.i sem +is not a valid semaphore. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br sem_close () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +all open named semaphores are automatically closed on process +termination, or upon +.br execve (2). +.sh see also +.br sem_getvalue (3), +.br sem_open (3), +.br sem_post (3), +.br sem_unlink (3), +.br sem_wait (3), +.br sem_overview (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1993 michael haardt (michael@moria.de), +.\" fri apr 2 11:32:09 met dst 1993 +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" modified formatting sat jul 24 17:13:38 1993, rik faith (faith@cs.unc.edu) +.\" modified (extensions and corrections) +.\" sun may 1 14:21:25 met dst 1994 michael haardt +.\" if mistakes in the capabilities are found, please send a bug report to: +.\" michael@moria.de +.\" modified mon oct 21 17:47:19 edt 1996 by eric s. raymond (esr@thyrsus.com) +.th termcap 5 2020-08-13 "linux" "linux programmer's manual" +.sh name +termcap \- terminal capability database +.sh description +the termcap database is an obsolete facility for describing the +capabilities of character-cell terminals and printers. +it is retained only for compatibility with old programs; +new programs should use the +.br terminfo (5) +database and associated libraries. +.pp +.i /etc/termcap +is an ascii file (the database master) that lists the capabilities of +many different types of terminals. +programs can read termcap to find +the particular escape codes needed to control the visual attributes of +the terminal actually in use. +(other aspects of the terminal are +handled by +.br stty (1).) +the termcap database is indexed on the +.b term +environment variable. +.pp +termcap entries must be defined on a single logical line, with \(aq\e\(aq +used to suppress the newline. +fields are separated by \(aq:\(aq. +the first field of each entry starts at the left-hand margin, +and contains a list of names for the terminal, separated by \(aq|\(aq. +.pp +the first subfield may (in bsd termcap entries from versions 4.3 and +earlier) contain a short name consisting of two characters. +this short name may consist of capital or small letters. +in 4.4bsd, termcap entries this field is omitted. +.pp +the second subfield (first, in the newer 4.4bsd format) contains the +name used by the environment variable +.br term . +it should be spelled in lowercase letters. +selectable hardware capabilities should be marked +by appending a hyphen and a suffix to this name. +see below for an example. +usual suffixes are w (more than 80 characters wide), am +(automatic margins), nam (no automatic margins), and rv (reverse video +display). +the third subfield contains a long and descriptive name for +this termcap entry. +.pp +subsequent fields contain the terminal capabilities; any continued +capability lines must be indented one tab from the left margin. +.pp +although there is no defined order, it is suggested to write first +boolean, then numeric, and then string capabilities, each sorted +alphabetically without looking at lower or upper spelling. +capabilities of similar functions can be written in one line. +.pp +example for: +.nf +.pp +head line: vt|vt101|dec vt 101 terminal in 80 character mode:\e +head line: vt|vt101-w|dec vt 101 terminal in (wide) 132 character mode:\e +boolean: :bs:\e +numeric: :co#80:\e +string: :sr=\ee[h:\e +.fi +.ss boolean capabilities +.nf +5i printer will not echo on screen +am automatic margins which means automatic line wrap +bs control-h (8 dec.) performs a backspace +bw backspace on left margin wraps to previous line and right margin +da display retained above screen +db display retained below screen +eo a space erases all characters at cursor position +es escape sequences and special characters work in status line +gn generic device +hc this is a hardcopy terminal +hc the cursor is hard to see when not on bottom line +hs has a status line +hz hazeltine bug, the terminal can not print tilde characters +in terminal inserts null bytes, not spaces, to fill whitespace +km terminal has a meta key +mi cursor movement works in insert mode +ms cursor movement works in standout/underline mode +np no pad character +nr ti does not reverse te +nx no padding, must use xon/xoff +os terminal can overstrike +ul terminal underlines although it can not overstrike +xb beehive glitch, f1 sends escape, f2 sends \fb\(hac\fp +xn newline/wraparound glitch +xo terminal uses xon/xoff protocol +xs text typed over standout text will be displayed in standout +xt teleray glitch, destructive tabs and odd standout mode +.fi +.ss numeric capabilities +.nf +co number of columns +db delay in milliseconds for backspace on hardcopy terminals +dc delay in milliseconds for carriage return on hardcopy terminals +df delay in milliseconds for form feed on hardcopy terminals +dn delay in milliseconds for new line on hardcopy terminals +dt delay in milliseconds for tabulator stop on hardcopy terminals +dv delay in milliseconds for vertical tabulator stop on + hardcopy terminals +it difference between tab positions +lh height of soft labels +lm lines of memory +lw width of soft labels +li number of lines +nl number of soft labels +pb lowest baud rate which needs padding +sg standout glitch +ug underline glitch +vt virtual terminal number +ws width of status line if different from screen width +.fi +.ss string capabilities +.nf +!1 shifted save key +!2 shifted suspend key +!3 shifted undo key +#1 shifted help key +#2 shifted home key +#3 shifted input key +#4 shifted cursor left key +%0 redo key +%1 help key +%2 mark key +%3 message key +%4 move key +%5 next-object key +%6 open key +%7 options key +%8 previous-object key +%9 print key +%a shifted message key +%b shifted move key +%c shifted next key +%d shifted options key +%e shifted previous key +%f shifted print key +%g shifted redo key +%h shifted replace key +%i shifted cursor right key +%j shifted resume key +&0 shifted cancel key +&1 reference key +&2 refresh key +&3 replace key +&4 restart key +&5 resume key +&6 save key +&7 suspend key +&8 undo key +&9 shifted begin key +*0 shifted find key +*1 shifted command key +*2 shifted copy key +*3 shifted create key +*4 shifted delete character +*5 shifted delete line +*6 select key +*7 shifted end key +*8 shifted clear line key +*9 shifted exit key +@0 find key +@1 begin key +@2 cancel key +@3 close key +@4 command key +@5 copy key +@6 create key +@7 end key +@8 enter/send key +@9 exit key +al insert one line +al insert %1 lines +ac pairs of block graphic characters to map alternate character set +ae end alternative character set +as start alternative character set for block graphic characters +bc backspace, if not \fb\(hah\fp +bl audio bell +bt move to previous tab stop +cb clear from beginning of line to cursor +cc dummy command character +cd clear to end of screen +ce clear to end of line +ch move cursor horizontally only to column %1 +cl clear screen and cursor home +cm cursor move to row %1 and column %2 (on screen) +cm move cursor to row %1 and column %2 (in memory) +cr carriage return +cs scroll region from line %1 to %2 +ct clear tabs +cv move cursor vertically only to line %1 +dc delete one character +dc delete %1 characters +dl delete one line +dl delete %1 lines +dm begin delete mode +do cursor down one line +do cursor down #1 lines +ds disable status line +ea enable alternate character set +ec erase %1 characters starting at cursor +ed end delete mode +ei end insert mode +ff formfeed character on hardcopy terminals +fs return character to its position before going to status line +f1 the string sent by function key f11 +f2 the string sent by function key f12 +f3 the string sent by function key f13 +\&... \&... +f9 the string sent by function key f19 +fa the string sent by function key f20 +fb the string sent by function key f21 +\&... \&... +fz the string sent by function key f45 +fa the string sent by function key f46 +fb the string sent by function key f47 +\&... \&... +fr the string sent by function key f63 +hd move cursor a half line down +ho cursor home +hu move cursor a half line up +i1 initialization string 1 at login +i3 initialization string 3 at login +is initialization string 2 at login +ic insert one character +ic insert %1 characters +if initialization file +im begin insert mode +ip insert pad time and needed special characters after insert +ip initialization program +k1 upper left key on keypad +k2 center key on keypad +k3 upper right key on keypad +k4 bottom left key on keypad +k5 bottom right key on keypad +k0 function key 0 +k1 function key 1 +k2 function key 2 +k3 function key 3 +k4 function key 4 +k5 function key 5 +k6 function key 6 +k7 function key 7 +k8 function key 8 +k9 function key 9 +k; function key 10 +ka clear all tabs key +ka insert line key +kb backspace key +kb back tab stop +kc clear screen key +kd cursor down key +kd key for delete character under cursor +ke turn keypad off +ke key for clear to end of line +kf key for scrolling forward/down +kh cursor home key +kh cursor hown down key +ki insert character/insert mode key +kl cursor left key +kl key for delete line +km key for exit insert mode +kn key for next page +kp key for previous page +kr cursor right key +kr key for scrolling backward/up +ks turn keypad on +ks clear to end of screen key +kt clear this tab key +kt set tab here key +ku cursor up key +l0 label of zeroth function key, if not f0 +l1 label of first function key, if not f1 +l2 label of first function key, if not f2 +\&... \&... +la label of tenth function key, if not f10 +le cursor left one character +ll move cursor to lower left corner +le cursor left %1 characters +lf turn soft labels off +lo turn soft labels on +mb start blinking +mc clear soft margins +md start bold mode +me end all mode like so, us, mb, md, and mr +mh start half bright mode +mk dark mode (characters invisible) +ml set left soft margin +mm put terminal in meta mode +mo put terminal out of meta mode +mp turn on protected attribute +mr start reverse mode +mr set right soft margin +nd cursor right one character +nw carriage return command +pc padding character +pf turn printer off +pk program key %1 to send string %2 as if typed by user +pl program key %1 to execute string %2 in local mode +pn program soft label %1 to show string %2 +po turn the printer on +po turn the printer on for %1 (<256) bytes +ps print screen contents on printer +px program key %1 to send string %2 to computer +r1 reset string 1 to set terminal to sane modes +r2 reset string 2 to set terminal to sane modes +r3 reset string 3 to set terminal to sane modes +ra disable automatic margins +rc restore saved cursor position +rf reset string filename +rf request for input from terminal +ri cursor right %1 characters +rp repeat character %1 for %2 times +rp padding after character sent in replace mode +rs reset string +rx turn off xon/xoff flow control +sa set %1 %2 %3 %4 %5 %6 %7 %8 %9 attributes +sa enable automatic margins +sc save cursor position +se end standout mode +sf normal scroll one line +sf normal scroll %1 lines +so start standout mode +sr reverse scroll +sr scroll back %1 lines +st set tabulator stop in all rows at current column +sx turn on xon/xoff flow control +ta move to next hardware tab +tc read in terminal description from another entry +te end program that uses cursor motion +ti begin program that uses cursor motion +ts move cursor to column %1 of status line +uc underline character under cursor and move cursor right +ue end underlining +up cursor up one line +up cursor up %1 lines +us start underlining +vb visible bell +ve normal cursor visible +vi cursor invisible +vs standout cursor +wi set window from line %1 to %2 and column %3 to %4 +xf xoff character if not \fb\(has\fp +.fi +.pp +there are several ways of defining the control codes for string capabilities: +.pp +every normal character represents itself, +except \(aq\(ha\(aq, \(aq\e\(aq, and \(aq%\(aq. +.pp +a \fb\(hax\fp means control-x. +control-a equals 1 decimal. +.pp +\ex means a special code. +x can be one of the following characters: +.rs +e escape (27) +.br +n linefeed (10) +.br +r carriage return (13) +.br +t tabulation (9) +.br +b backspace (8) +.br +f form feed (12) +.br +0 null character. +a \exxx specifies the octal character xxx. +.re +.ip i +increments parameters by one. +.ip r +single parameter capability +.ip + +add value of next character to this parameter and do binary output +.ip 2 +do ascii output of this parameter with a field with of 2 +.ip d +do ascii output of this parameter with a field with of 3 +.ip % +print a \(aq%\(aq +.pp +if you use binary output, then you should avoid the null character (\(aq\e0\(aq) +because it terminates the string. +you should reset tabulator expansion +if a tabulator can be the binary output of a parameter. +.ip warning: +the above metacharacters for parameters may be wrong: they document minix +termcap which may not be compatible with linux termcap. +.pp +the block graphic characters can be specified by three string capabilities: +.ip as +start the alternative charset +.ip ae +end the alternative charset +.ip ac +pairs of characters. +the first character is the name of the block graphic +symbol and the second characters is its definition. +.pp +the following names are available: +.pp +.nf ++ right arrow (>) +, left arrow (<) +\&. down arrow (v) +0 full square (#) +i lantern (#) +- upper arrow (\(ha) +\&' rhombus (+) +a chess board (:) +f degree (') +g plus-minus (#) +h square (#) +j right bottom corner (+) +k right upper corner (+) +l left upper corner (+) +m left bottom corner (+) +n cross (+) +o upper horizontal line (-) +q middle horizontal line (-) +s bottom horizontal line (_) +t left tee (+) +u right tee (+) +v bottom tee (+) +w normal tee (+) +x vertical line (|) +\(ti paragraph (???) +.fi +.pp +the values in parentheses are suggested defaults which are used by the +.ir curses +library, if the capabilities are missing. +.sh see also +.br ncurses (3), +.br termcap (3), +.br terminfo (5) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/scalb.3 + +.so man3/getspnam.3 + +.so man3/mcheck.3 + +.\" copyright (c) 2012 chandan apsangi +.\" and copyright (c) 2013 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th pthread_setname_np 3 2021-08-27 "linux" "linux programmer's manual" +.sh name +pthread_setname_np, pthread_getname_np \- set/get the name of a thread +.sh synopsis +.nf +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "int pthread_setname_np(pthread_t " thread ", const char *" name ); +.bi "int pthread_getname_np(pthread_t " thread ", char *" name ", size_t " len ); +.fi +.pp +compile and link with \fi\-pthread\fp. +.sh description +by default, all the threads created using +.br pthread_create () +inherit the program name. +the +.br pthread_setname_np () +function can be used to set a unique name for a thread, +which can be useful for debugging +multithreaded applications. +the thread name is a meaningful c language string, whose length is +restricted to 16 characters, including the terminating null byte (\(aq\e0\(aq). +the +.i thread +argument specifies the thread whose name is to be changed; +.i name +specifies the new name. +.pp +the +.br pthread_getname_np () +function can be used to retrieve the name of the thread. +the +.i thread +argument specifies the thread whose name is to be retrieved. +the buffer +.i name +is used to return the thread name; +.i len +specifies the number of bytes available in +.ir name . +the buffer specified by +.i name +should be at least 16 characters in length. +the returned thread name in the output buffer will be null terminated. +.sh return value +on success, these functions return 0; +on error, they return a nonzero error number. +.sh errors +the +.br pthread_setname_np () +function can fail with the following error: +.tp +.b erange +the length of the string specified pointed to by +.i name +exceeds the allowed limit. +.pp +the +.br pthread_getname_np () +function can fail with the following error: +.tp +.b erange +the buffer specified by +.i name +and +.i len +is too small to hold the thread name. +.pp +if either of these functions fails to open +.ir /proc/self/task/[tid]/comm , +then the call may fail with one of the errors described in +.br open (2). +.sh versions +these functions first appeared in glibc in version 2.12. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br pthread_setname_np (), +.br pthread_getname_np () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +these functions are nonstandard gnu extensions; +hence the suffix "_np" (nonportable) in the names. +.sh notes +.br pthread_setname_np () +internally writes to the thread-specific +.i comm +file under the +.ir /proc +filesystem: +.ir /proc/self/task/[tid]/comm . +.br pthread_getname_np () +retrieves it from the same location. +.sh examples +the program below demonstrates the use of +.br pthread_setname_np () +and +.br pthread_getname_np (). +.pp +the following shell session shows a sample run of the program: +.pp +.in +4n +.ex +.rb "$" " ./a.out" +created a thread. default name is: a.out +the thread name after setting it is threadfoo. +\fb\(haz\fp # suspend the program +[1]+ stopped ./a.out +.rb "$ " "ps h \-c a.out \-o \(aqpid tid cmd comm\(aq" + pid tid cmd command + 5990 5990 ./a.out a.out + 5990 5991 ./a.out threadfoo +.rb "$ " "cat /proc/5990/task/5990/comm" +a.out +.rb "$ " "cat /proc/5990/task/5991/comm" +threadfoo +.ee +.in +.ss program source +\& +.ex +#define _gnu_source +#include +#include +#include +#include +#include +#include + +#define namelen 16 + +#define errexiten(en, msg) \e + do { errno = en; perror(msg); \e + exit(exit_failure); } while (0) + +static void * +threadfunc(void *parm) +{ + sleep(5); // allow main program to set the thread name + return null; +} + +int +main(int argc, char *argv[]) +{ + pthread_t thread; + int rc; + char thread_name[namelen]; + + rc = pthread_create(&thread, null, threadfunc, null); + if (rc != 0) + errexiten(rc, "pthread_create"); + + rc = pthread_getname_np(thread, thread_name, namelen); + if (rc != 0) + errexiten(rc, "pthread_getname_np"); + + printf("created a thread. default name is: %s\en", thread_name); + rc = pthread_setname_np(thread, (argc > 1) ? argv[1] : "threadfoo"); + if (rc != 0) + errexiten(rc, "pthread_setname_np"); + + sleep(2); + + rc = pthread_getname_np(thread, thread_name, namelen); + if (rc != 0) + errexiten(rc, "pthread_getname_np"); + printf("the thread name after setting it is %s.\en", thread_name); + + rc = pthread_join(thread, null); + if (rc != 0) + errexiten(rc, "pthread_join"); + + printf("done\en"); + exit(exit_success); +} +.ee +.sh see also +.ad l +.nh +.br prctl (2), +.br pthread_create (3), +.br pthreads (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/strtoul.3 + +.\" copyright (c) 2001, 2017 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" aeb, various minor fixes +.th sigaltstack 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +sigaltstack \- set and/or get signal stack context +.sh synopsis +.nf +.b #include +.pp +.bi "int sigaltstack(const stack_t *restrict " ss \ +", stack_t *restrict " old_ss ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br sigaltstack (): +.nf + _xopen_source >= 500 +.\" || _xopen_source && _xopen_source_extended + || /* since glibc 2.12: */ _posix_c_source >= 200809l + || /* glibc <= 2.19: */ _bsd_source +.fi +.sh description +.br sigaltstack () +allows a thread to define a new alternate +signal stack and/or retrieve the state of an existing +alternate signal stack. +an alternate signal stack is used during the +execution of a signal handler if the establishment of that handler (see +.br sigaction (2)) +requested it. +.pp +the normal sequence of events for using an alternate signal stack +is the following: +.tp 3 +1. +allocate an area of memory to be used for the alternate +signal stack. +.tp +2. +use +.br sigaltstack () +to inform the system of the existence and +location of the alternate signal stack. +.tp +3. +when establishing a signal handler using +.br sigaction (2), +inform the system that the signal handler should be executed +on the alternate signal stack by +specifying the \fbsa_onstack\fp flag. +.pp +the \fiss\fp argument is used to specify a new +alternate signal stack, while the \fiold_ss\fp argument +is used to retrieve information about the currently +established signal stack. +if we are interested in performing just one +of these tasks, then the other argument can be specified as null. +.pp +the +.i stack_t +type used to type the arguments of this function is defined as follows: +.pp +.in +4n +.ex +typedef struct { + void *ss_sp; /* base address of stack */ + int ss_flags; /* flags */ + size_t ss_size; /* number of bytes in stack */ +} stack_t; +.ee +.in +.pp +to establish a new alternate signal stack, +the fields of this structure are set as follows: +.tp +.i ss.ss_flags +this field contains either 0, or the following flag: +.rs +.tp +.br ss_autodisarm " (since linux 4.7)" +.\" commit 2a74213838104a41588d86fd5e8d344972891ace +.\" see tools/testing/selftests/sigaltstack/sas.c in kernel sources +clear the alternate signal stack settings on entry to the signal handler. +when the signal handler returns, +the previous alternate signal stack settings are restored. +.ip +this flag was added in order to make it safe +to switch away from the signal handler with +.br swapcontext (3). +without this flag, a subsequently handled signal will corrupt +the state of the switched-away signal handler. +on kernels where this flag is not supported, +.br sigaltstack () +fails with the error +.br einval +when this flag is supplied. +.re +.tp +.i ss.ss_sp +this field specifies the starting address of the stack. +when a signal handler is invoked on the alternate stack, +the kernel automatically aligns the address given in \fiss.ss_sp\fp +to a suitable address boundary for the underlying hardware architecture. +.tp +.i ss.ss_size +this field specifies the size of the stack. +the constant \fbsigstksz\fp is defined to be large enough +to cover the usual size requirements for an alternate signal stack, +and the constant \fbminsigstksz\fp defines the minimum +size required to execute a signal handler. +.pp +to disable an existing stack, specify \fiss.ss_flags\fp +as \fbss_disable\fp. +in this case, the kernel ignores any other flags in +.ir ss.ss_flags +and the remaining fields +in \fiss\fp. +.pp +if \fiold_ss\fp is not null, then it is used to return information about +the alternate signal stack which was in effect prior to the +call to +.br sigaltstack (). +the \fiold_ss.ss_sp\fp and \fiold_ss.ss_size\fp fields return the starting +address and size of that stack. +the \fiold_ss.ss_flags\fp may return either of the following values: +.tp +.b ss_onstack +the thread is currently executing on the alternate signal stack. +(note that it is not possible +to change the alternate signal stack if the thread is +currently executing on it.) +.tp +.b ss_disable +the alternate signal stack is currently disabled. +.ip +alternatively, this value is returned if the thread is currently +executing on an alternate signal stack that was established using the +.b ss_autodisarm +flag. +in this case, it is safe to switch away from the signal handler with +.br swapcontext (3). +it is also possible to set up a different alternative signal stack +using a further call to +.br sigaltstack (). +.\" fixme was it intended that one can set up a different alternative +.\" signal stack in this scenario? (in passing, if one does this, the +.\" sigaltstack(null, &old_ss) now returns old_ss.ss_flags==ss_autodisarm +.\" rather than old_ss.ss_flags==ss_disable. the api design here seems +.\" confusing... +.tp +.b ss_autodisarm +the alternate signal stack has been marked to be autodisarmed +as described above. +.pp +by specifying +.i ss +as null, and +.i old_ss +as a non-null value, one can obtain the current settings for +the alternate signal stack without changing them. +.sh return value +.br sigaltstack () +returns 0 on success, or \-1 on failure with +\fierrno\fp set to indicate the error. +.sh errors +.tp +.b efault +either \fiss\fp or \fiold_ss\fp is not null and points to an area +outside of the process's address space. +.tp +.b einval +\fiss\fp is not null and the \fiss_flags\fp field contains +an invalid flag. +.tp +.b enomem +the specified size of the new alternate signal stack +.i ss.ss_size +was less than +.br minsigstksz . +.tp +.b eperm +an attempt was made to change the alternate signal stack while +it was active (i.e., the thread was already executing +on the current alternate signal stack). +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br sigaltstack () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, susv2, svr4. +.pp +the +.b ss_autodisarm +flag is a linux extension. +.sh notes +the most common usage of an alternate signal stack is to handle the +.b sigsegv +signal that is generated if the space available for the +standard stack is exhausted: in this case, a signal handler for +.b sigsegv +cannot be invoked on the standard stack; if we wish to handle it, +we must use an alternate signal stack. +.pp +establishing an alternate signal stack is useful if a thread +expects that it may exhaust its standard stack. +this may occur, for example, because the stack grows so large +that it encounters the upwardly growing heap, or it reaches a +limit established by a call to \fbsetrlimit(rlimit_stack, &rlim)\fp. +if the standard stack is exhausted, the kernel sends +the thread a \fbsigsegv\fp signal. +in these circumstances the only way to catch this signal is +on an alternate signal stack. +.pp +on most hardware architectures supported by linux, stacks grow +downward. +.br sigaltstack () +automatically takes account +of the direction of stack growth. +.pp +functions called from a signal handler executing on an alternate +signal stack will also use the alternate signal stack. +(this also applies to any handlers invoked for other signals while +the thread is executing on the alternate signal stack.) +unlike the standard stack, the system does not +automatically extend the alternate signal stack. +exceeding the allocated size of the alternate signal stack will +lead to unpredictable results. +.pp +a successful call to +.br execve (2) +removes any existing alternate +signal stack. +a child process created via +.br fork (2) +inherits a copy of its parent's alternate signal stack settings. +the same is also true for a child process created using +.br clone (2), +unless the clone flags include +.br clone_vm +and do not include +.br clone_vfork , +in which case any alternate signal stack that was established in the parent +is disabled in the child process. +.pp +.br sigaltstack () +supersedes the older +.br sigstack () +call. +for backward compatibility, glibc also provides +.br sigstack (). +all new applications should be written using +.br sigaltstack (). +.ss history +4.2bsd had a +.br sigstack () +system call. +it used a slightly +different struct, and had the major disadvantage that the caller +had to know the direction of stack growth. +.sh bugs +in linux 2.2 and earlier, the only flag that could be specified +in +.i ss.sa_flags +was +.br ss_disable . +in the lead up to the release of the linux 2.4 kernel, +.\" linux 2.3.40 +.\" after quite a bit of web and mail archive searching, +.\" i could not find the patch on any mailing list, and i +.\" could find no place where the rationale for this change +.\" explained -- mtk +a change was made to allow +.br sigaltstack () +to allow +.i ss.ss_flags==ss_onstack +with the same meaning as +.ir "ss.ss_flags==0" +(i.e., the inclusion of +.b ss_onstack +in +.i ss.ss_flags +is a no-op). +on other implementations, and according to posix.1, +.b ss_onstack +appears only as a reported flag in +.ir old_ss.ss_flags . +on linux, there is no need ever to specify +.b ss_onstack +in +.ir ss.ss_flags , +and indeed doing so should be avoided on portability grounds: +various other systems +.\" see the source code of illumos and freebsd, for example. +give an error if +.b ss_onstack +is specified in +.ir ss.ss_flags . +.sh examples +the following code segment demonstrates the use of +.br sigaltstack () +(and +.br sigaction (2)) +to install an alternate signal stack that is employed by a handler +for the +.br sigsegv +signal: +.pp +.in +4n +.ex +stack_t ss; + +ss.ss_sp = malloc(sigstksz); +if (ss.ss_sp == null) { + perror("malloc"); + exit(exit_failure); +} + +ss.ss_size = sigstksz; +ss.ss_flags = 0; +if (sigaltstack(&ss, null) == \-1) { + perror("sigaltstack"); + exit(exit_failure); +} + +sa.sa_flags = sa_onstack; +sa.sa_handler = handler(); /* address of a signal handler */ +sigemptyset(&sa.sa_mask); +if (sigaction(sigsegv, &sa, null) == \-1) { + perror("sigaction"); + exit(exit_failure); +} +.ee +.in +.sh see also +.br execve (2), +.br setrlimit (2), +.br sigaction (2), +.br siglongjmp (3), +.br sigsetjmp (3), +.br signal (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/stat.2 + +.so man7/system_data_types.7 + +.\" copyright (c) 2019 by michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" +.th uts_namespaces 7 2019-11-19 "linux" "linux programmer's manual" +.sh name +uts_namespaces \- overview of linux uts namespaces +.sh description +uts namespaces provide isolation of two system identifiers: +the hostname and the nis domain name. +these identifiers are set using +.br sethostname (2) +and +.br setdomainname (2), +and can be retrieved using +.br uname (2), +.br gethostname (2), +and +.br getdomainname (2). +changes made to these identifiers are visible to all other +processes in the same uts namespace, +but are not visible to processes in other uts namespaces. +.pp +.pp +when a process creates a new uts namespace using +.br clone (2) +or +.br unshare (2) +with the +.br clone_newuts +flag, the hostname and domain of the new uts namespace are copied +from the corresponding values in the caller's uts namespace. +.pp +use of uts namespaces requires a kernel that is configured with the +.b config_uts_ns +option. +.sh see also +.br nsenter (1), +.br unshare (1), +.br clone (2), +.br getdomainname (2), +.br gethostname (2), +.br setns (2), +.br uname (2), +.br unshare (2), +.br namespaces (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/dlopen.3 + +.\" copyright (c) 1983, 1991, 1993 +.\" the regents of the university of california. all rights reserved. +.\" +.\" %%%license_start(bsd_4_clause_ucb) +.\" redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. all advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" this product includes software developed by the university of +.\" california, berkeley and its contributors. +.\" 4. neither the name of the university nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" this software is provided by the regents and contributors ``as is'' and +.\" any express or implied warranties, including, but not limited to, the +.\" implied warranties of merchantability and fitness for a particular purpose +.\" are disclaimed. in no event shall the regents or contributors be liable +.\" for any direct, indirect, incidental, special, exemplary, or consequential +.\" damages (including, but not limited to, procurement of substitute goods +.\" or services; loss of use, data, or profits; or business interruption) +.\" however caused and on any theory of liability, whether in contract, strict +.\" liability, or tort (including negligence or otherwise) arising in any way +.\" out of the use of this software, even if advised of the possibility of +.\" such damage. +.\" %%%license_end +.\" +.\" @(#)rexec.3 8.1 (berkeley) 6/4/93 +.\" $freebsd: src/lib/libcompat/4.3/rexec.3,v 1.12 2004/07/02 23:52:14 ru exp $ +.\" +.\" taken from freebsd 5.4; not checked against linux reality (mtk) +.\" +.\" 2013-06-21, mtk, converted from mdoc to man macros +.\" +.th rexec 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +rexec, rexec_af \- return stream to a remote command +.sh synopsis +.nf +.b #include +.pp +.bi "int rexec(char **restrict " ahost ", int " inport , +.bi " const char *restrict " user ", const char *restrict " passwd , +.bi " const char *restrict " cmd ", int *restrict " fd2p ); +.bi "int rexec_af(char **restrict " ahost ", int " inport , +.bi " const char *restrict " user ", const char *restrict " passwd , +.bi " const char *restrict " cmd ", int *restrict " fd2p , +.bi " sa_family_t " af ); +.fi +.pp +.br rexec (), +.br rexec_af (): +.nf + since glibc 2.19: + _default_source + in glibc up to and including 2.19: + _bsd_source +.fi +.sh description +this interface is obsoleted by +.br rcmd (3). +.pp +the +.br rexec () +function +looks up the host +.ir *ahost +using +.br gethostbyname (3), +returning \-1 if the host does not exist. +otherwise, +.ir *ahost +is set to the standard name of the host. +if a username and password are both specified, then these +are used to authenticate to the foreign host; otherwise +the environment and then the +.i .netrc +file in user's +home directory are searched for appropriate information. +if all this fails, the user is prompted for the information. +.pp +the port +.i inport +specifies which well-known darpa internet port to use for +the connection; the call +.i "getservbyname(""exec"", ""tcp"")" +(see +.br getservent (3)) +will return a pointer to a structure that contains the necessary port. +the protocol for connection is described in detail in +.br rexecd (8). +.pp +if the connection succeeds, +a socket in the internet domain of type +.br sock_stream +is returned to +the caller, and given to the remote command as +.ir stdin +and +.ir stdout . +if +.i fd2p +is nonzero, then an auxiliary channel to a control +process will be setup, and a file descriptor for it will be placed +in +.ir *fd2p . +the control process will return diagnostic +output from the command (unit 2) on this channel, and will also +accept bytes on this channel as being unix signal numbers, to be +forwarded to the process group of the command. +the diagnostic +information returned does not include remote authorization failure, +as the secondary connection is set up after authorization has been +verified. +if +.i fd2p +is 0, then the +.ir stderr +(unit 2 of the remote +command) will be made the same as the +.ir stdout +and no +provision is made for sending arbitrary signals to the remote process, +although you may be able to get its attention by using out-of-band data. +.ss rexec_af() +the +.br rexec () +function works over ipv4 +.rb ( af_inet ). +by contrast, the +.br rexec_af () +function provides an extra argument, +.ir af , +that allows the caller to select the protocol. +this argument can be specified as +.br af_inet , +.br af_inet6 , +or +.br af_unspec +(to allow the implementation to select the protocol). +.sh versions +the +.br rexec_af () +function was added to glibc in version 2.2. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br rexec (), +.br rexec_af () +t} thread safety mt-unsafe +.te +.hy +.ad +.sp 1 +.sh conforming to +these functions are not in posix.1. +the +.br rexec () +function first appeared in +4.2bsd, and is present on the bsds, solaris, and many other systems. +the +.br rexec_af () +function is more recent, and less widespread. +.sh bugs +the +.br rexec () +function sends the unencrypted password across the network. +.pp +the underlying service is considered a big security hole and therefore +not enabled on many sites; see +.br rexecd (8) +for explanations. +.sh see also +.br rcmd (3), +.br rexecd (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/y0.3 + +.\" derived from text written by martin schulze (or taken from glibc.info) +.\" and text written by paul thompson - both copyright 2002. +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th login 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +login, logout \- write utmp and wtmp entries +.sh synopsis +.nf +.b #include +.pp +.bi "void login(const struct utmp *" ut ); +.bi "int logout(const char *" ut_line ); +.fi +.pp +link with \fi\-lutil\fp. +.sh description +the utmp file records who is currently using the system. +the wtmp file records all logins and logouts. +see +.br utmp (5). +.pp +the function +.br login () +takes the supplied +.ir "struct utmp" , +.ir ut , +and writes it to both the utmp and the wtmp file. +.pp +the function +.br logout () +clears the entry in the utmp file again. +.ss gnu details +more precisely, +.br login () +takes the argument +.i ut +struct, fills the field +.i ut\->ut_type +(if there is such a field) with the value +.br user_process , +and fills the field +.i ut\->ut_pid +(if there is such a field) with the process id of the calling process. +then it tries to fill the field +.ir ut\->ut_line . +it takes the first of +.ir stdin , +.ir stdout , +.i stderr +that is a terminal, and +stores the corresponding pathname minus a possible leading +.i /dev/ +into this field, and then writes the struct to the utmp file. +on the other hand, +if no terminal name was found, this field is filled with "???" +and the struct is not written to the utmp file. +after this, the struct is written to the wtmp file. +.pp +the +.br logout () +function searches the utmp file for an entry matching the +.i ut_line +argument. +if a record is found, it is updated by zeroing out the +.i ut_name +and +.i ut_host +fields, updating the +.i ut_tv +timestamp field and setting +.i ut_type +(if there is such a field) to +.br dead_process . +.sh return value +the +.br logout () +function returns 1 if the entry was successfully written to the +database, or 0 if an error occurred. +.sh files +.tp +.i /var/run/utmp +user accounting database, configured through +.b _path_utmp +in +.i +.tp +.i /var/log/wtmp +user accounting log file, configured through +.b _path_wtmp +in +.i +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lb lb lbx +l l l. +interface attribute value +t{ +.br login (), +.br logout () +t} thread safety t{ +mt-unsafe race:utent +sig:alrm timer +t} +.te +.hy +.ad +.sp 1 +in the above table, +.i utent +in +.i race:utent +signifies that if any of the functions +.br setutent (3), +.br getutent (3), +or +.br endutent (3) +are used in parallel in different threads of a program, +then data races could occur. +.br login () +and +.br logout () +calls those functions, +so we use race:utent to remind users. +.sh conforming to +not in posix.1. +present on the bsds. +.sh notes +note that the +member +.i ut_user +of +.i struct utmp +is called +.i ut_name +in bsd. +therefore, +.i ut_name +is defined as an alias for +.i ut_user +in +.ir . +.sh see also +.br getutent (3), +.br utmp (5) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/circleq.3 + +.\" this manpage is copyright (c) 2006 jens axboe +.\" and copyright (c) 2006 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th splice 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +splice \- splice data to/from a pipe +.sh synopsis +.nf +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "ssize_t splice(int " fd_in ", off64_t *" off_in ", int " fd_out , +.bi " off64_t *" off_out ", size_t " len \ +", unsigned int " flags ); +.\" return type was long before glibc 2.7 +.fi +.sh description +.br splice () +moves data between two file descriptors +without copying between kernel address space and user address space. +it transfers up to +.i len +bytes of data from the file descriptor +.i fd_in +to the file descriptor +.ir fd_out , +where one of the file descriptors must refer to a pipe. +.pp +the following semantics apply for +.i fd_in +and +.ir off_in : +.ip * 3 +if +.i fd_in +refers to a pipe, then +.i off_in +must be null. +.ip * +if +.i fd_in +does not refer to a pipe and +.i off_in +is null, then bytes are read from +.i fd_in +starting from the file offset, +and the file offset is adjusted appropriately. +.ip * +if +.i fd_in +does not refer to a pipe and +.i off_in +is not null, then +.i off_in +must point to a buffer which specifies the starting +offset from which bytes will be read from +.ir fd_in ; +in this case, the file offset of +.i fd_in +is not changed. +.pp +analogous statements apply for +.i fd_out +and +.ir off_out . +.pp +the +.i flags +argument is a bit mask that is composed by oring together +zero or more of the following values: +.tp +.b splice_f_move +attempt to move pages instead of copying. +this is only a hint to the kernel: +pages may still be copied if the kernel cannot move the +pages from the pipe, or if +the pipe buffers don't refer to full pages. +the initial implementation of this flag was buggy: +therefore starting in linux 2.6.21 it is a no-op +(but is still permitted in a +.br splice () +call); +in the future, a correct implementation may be restored. +.tp +.b splice_f_nonblock +do not block on i/o. +this makes the splice pipe operations nonblocking, but +.br splice () +may nevertheless block because the file descriptors that +are spliced to/from may block (unless they have the +.b o_nonblock +flag set). +.tp +.b splice_f_more +more data will be coming in a subsequent splice. +this is a helpful hint when +the +.i fd_out +refers to a socket (see also the description of +.b msg_more +in +.br send (2), +and the description of +.b tcp_cork +in +.br tcp (7)). +.tp +.b splice_f_gift +unused for +.br splice (); +see +.br vmsplice (2). +.sh return value +upon successful completion, +.br splice () +returns the number of bytes +spliced to or from the pipe. +.pp +a return value of 0 means end of input. +if +.i fd_in +refers to a pipe, then this means that there was no data to transfer, +and it would not make sense to block because there are no writers +connected to the write end of the pipe. +.pp +on error, +.br splice () +returns \-1 and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eagain +.b splice_f_nonblock +was specified in +.ir flags +or one of the file descriptors had been marked as nonblocking +.rb ( o_nonblock ) , +and the operation would block. +.tp +.b ebadf +one or both file descriptors are not valid, +or do not have proper read-write mode. +.tp +.b einval +the target filesystem doesn't support splicing. +.tp +.b einval +the target file is opened in append mode. +.\" the append-mode error is given since 2.6.27; in earlier kernels, +.\" splice() in append mode was broken +.tp +.b einval +neither of the file descriptors refers to a pipe. +.tp +.b einval +an offset was given for nonseekable device (e.g., a pipe). +.tp +.b einval +.i fd_in +and +.i fd_out +refer to the same pipe. +.tp +.b enomem +out of memory. +.tp +.b espipe +either +.i off_in +or +.i off_out +was not null, but the corresponding file descriptor refers to a pipe. +.sh versions +the +.br splice () +system call first appeared in linux 2.6.17; +library support was added to glibc in version 2.5. +.sh conforming to +this system call is linux-specific. +.sh notes +the three system calls +.br splice (), +.br vmsplice (2), +and +.br tee (2), +provide user-space programs with full control over an arbitrary +kernel buffer, implemented within the kernel using the same type +of buffer that is used for a pipe. +in overview, these system calls perform the following tasks: +.ip \(bu 2 +.br splice () +moves data from the buffer to an arbitrary file descriptor, or vice versa, +or from one buffer to another. +.ip \(bu +.br tee (2) +"copies" the data from one buffer to another. +.ip \(bu +.br vmsplice (2) +"copies" data from user space into the buffer. +.pp +though we talk of copying, actual copies are generally avoided. +the kernel does this by implementing a pipe buffer as a set +of reference-counted pointers to pages of kernel memory. +the kernel creates "copies" of pages in a buffer by creating new +pointers (for the output buffer) referring to the pages, +and increasing the reference counts for the pages: +only pointers are copied, not the pages of the buffer. +.\" +.\" linus: now, imagine using the above in a media server, for example. +.\" let's say that a year or two has passed, so that the video drivers +.\" have been updated to be able to do the splice thing, and what can +.\" you do? you can: +.\" +.\" - splice from the (mpeg or whatever - let's just assume that the video +.\" input is either digital or does the encoding on its own - like they +.\" pretty much all do) video input into a pipe (remember: no copies - the +.\" video input will just dma directly into memory, and splice will just +.\" set up the pages in the pipe buffer) +.\" - tee that pipe to split it up +.\" - splice one end to a file (ie "save the compressed stream to disk") +.\" - splice the other end to a real-time video decoder window for your +.\" real-time viewing pleasure. +.\" +.\" linus: now, the advantage of splice()/tee() is that you can +.\" do zero-copy movement of data, and unlike sendfile() you can +.\" do it on _arbitrary_ data (and, as shown by "tee()", it's more +.\" than just sending the data to somebody else: you can duplicate +.\" the data and choose to forward it to two or more different +.\" users - for things like logging etc.). +.\" +.pp +in linux 2.6.30 and earlier, +exactly one of +.i fd_in +and +.i fd_out +was required to be a pipe. +since linux 2.6.31, +.\" commit 7c77f0b3f9208c339a4b40737bb2cb0f0319bb8d +both arguments may refer to pipes. +.sh examples +see +.br tee (2). +.sh see also +.br copy_file_range (2), +.br sendfile (2), +.br tee (2), +.br vmsplice (2), +.br pipe (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2019 by michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" +.th ipc_namespaces 7 2019-08-02 "linux" "linux programmer's manual" +.sh name +ipc_namespaces \- overview of linux ipc namespaces +.sh description +ipc namespaces isolate certain ipc resources, +namely, system v ipc objects (see +.br sysvipc (7)) +and (since linux 2.6.30) +.\" commit 7eafd7c74c3f2e67c27621b987b28397110d643f +.\" https://lwn.net/articles/312232/ +posix message queues (see +.br mq_overview (7)). +the common characteristic of these ipc mechanisms is that ipc +objects are identified by mechanisms other than filesystem +pathnames. +.pp +each ipc namespace has its own set of system v ipc identifiers and +its own posix message queue filesystem. +objects created in an ipc namespace are visible to all other processes +that are members of that namespace, +but are not visible to processes in other ipc namespaces. +.pp +the following +.i /proc +interfaces are distinct in each ipc namespace: +.ip * 3 +the posix message queue interfaces in +.ir /proc/sys/fs/mqueue . +.ip * +the system v ipc interfaces in +.ir /proc/sys/kernel , +namely: +.ir msgmax , +.ir msgmnb , +.ir msgmni , +.ir sem , +.ir shmall , +.ir shmmax , +.ir shmmni , +and +.ir shm_rmid_forced . +.ip * +the system v ipc interfaces in +.ir /proc/sysvipc . +.pp +when an ipc namespace is destroyed +(i.e., when the last process that is a member of the namespace terminates), +all ipc objects in the namespace are automatically destroyed. +.pp +use of ipc namespaces requires a kernel that is configured with the +.b config_ipc_ns +option. +.sh see also +.br nsenter (1), +.br unshare (1), +.br clone (2), +.br setns (2), +.br unshare (2), +.br mq_overview (7), +.br namespaces (7), +.br sysvipc (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/stailq.3 + +.so man7/iso_8859-3.7 + +.\" copyright (c) 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th end 3 2020-06-09 "gnu" "linux programmer's manual" +.sh name +etext, edata, end \- end of program segments +.sh synopsis +.nf +.bi extern " etext" ; +.bi extern " edata" ; +.bi extern " end" ; +.fi +.sh description +the addresses of these symbols indicate the end of various program +segments: +.tp +.i etext +this is the first address past the end of the text segment +(the program code). +.tp +.i edata +this is the first address past the end of the +initialized data segment. +.tp +.i end +this is the first address past the end of the +uninitialized data segment (also known as the bss segment). +.sh conforming to +although these symbols have long been provided on most unix systems, +they are not standardized; use with caution. +.sh notes +the program must explicitly declare these symbols; +they are not defined in any header file. +.pp +on some systems the names of these symbols are preceded by underscores, +thus: +.ir _etext , +.ir _edata , +and +.ir _end . +these symbols are also defined for programs compiled on linux. +.pp +at the start of program execution, +the program break will be somewhere near +.ir &end +(perhaps at the start of the following page). +however, the break will change as memory is allocated via +.br brk (2) +or +.br malloc (3). +use +.br sbrk (2) +with an argument of zero to find the current value of the program break. +.sh examples +when run, the program below produces output such as the following: +.pp +.in +4n +.ex +.rb "$" " ./a.out" +first address past: + program text (etext) 0x8048568 + initialized data (edata) 0x804a01c + uninitialized data (end) 0x804a024 +.ee +.in +.ss program source +\& +.ex +#include +#include + +extern char etext, edata, end; /* the symbols must have some type, + or "gcc \-wall" complains */ + +int +main(int argc, char *argv[]) +{ + printf("first address past:\en"); + printf(" program text (etext) %10p\en", &etext); + printf(" initialized data (edata) %10p\en", &edata); + printf(" uninitialized data (end) %10p\en", &end); + + exit(exit_success); +} +.ee +.sh see also +.br objdump (1), +.br readelf (1), +.br sbrk (2), +.br elf (5) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1995, thomas k. dyas +.\" and copyright (c) 2013, 2019, michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" created 1995-08-06 thomas k. dyas +.\" modified 2000-07-01 aeb +.\" modified 2002-07-23 aeb +.\" modified, 27 may 2004, michael kerrisk +.\" added notes on capability requirements +.\" +.th setfsuid 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +setfsuid \- set user identity used for filesystem checks +.sh synopsis +.nf +.b #include +.pp +.bi "int setfsuid(uid_t " fsuid ); +.fi +.sh description +on linux, a process has both a filesystem user id and an effective user id. +the (linux-specific) filesystem user id is used +for permissions checking when accessing filesystem objects, +while the effective user id is used for various other kinds +of permissions checks (see +.br credentials (7)). +.pp +normally, the value of the process's filesystem user id +is the same as the value of its effective user id. +this is so, because whenever a process's effective user id is changed, +the kernel also changes the filesystem user id to be the same as +the new value of the effective user id. +a process can cause the value of its filesystem user id to diverge +from its effective user id by using +.br setfsuid () +to change its filesystem user id to the value given in +.ir fsuid . +.pp +explicit calls to +.br setfsuid () +and +.br setfsgid (2) +are (were) usually used only by programs such as the linux nfs server that +need to change what user and group id is used for file access without a +corresponding change in the real and effective user and group ids. +a change in the normal user ids for a program such as the nfs server +is (was) a security hole that can expose it to unwanted signals. +(however, this issue is historical; see below.) +.pp +.br setfsuid () +will succeed only if the caller is the superuser or if +.i fsuid +matches either the caller's real user id, effective user id, +saved set-user-id, or current filesystem user id. +.sh return value +on both success and failure, +this call returns the previous filesystem user id of the caller. +.sh versions +this system call is present in linux since version 1.2. +.\" this system call is present since linux 1.1.44 +.\" and in libc since libc 4.7.6. +.sh conforming to +.br setfsuid () +is linux-specific and should not be used in programs intended +to be portable. +.sh notes +at the time when this system call was introduced, one process +could send a signal to another process with the same effective user id. +this meant that if a privileged process changed its effective user id +for the purpose of file permission checking, +then it could become vulnerable to receiving signals +sent by another (unprivileged) process with the same user id. +the filesystem user id attribute was thus added to allow a process to +change its user id for the purposes of file permission checking without +at the same time becoming vulnerable to receiving unwanted signals. +since linux 2.0, signal permission handling is different (see +.br kill (2)), +with the result that a process can change its effective user id +without being vulnerable to receiving signals from unwanted processes. +thus, +.br setfsuid () +is nowadays unneeded and should be avoided in new applications +(likewise for +.br setfsgid (2)). +.pp +the original linux +.br setfsuid () +system call supported only 16-bit user ids. +subsequently, linux 2.4 added +.br setfsuid32 () +supporting 32-bit ids. +the glibc +.br setfsuid () +wrapper function transparently deals with the variation across kernel versions. +.ss c library/kernel differences +in glibc 2.15 and earlier, +when the wrapper for this system call determines that the argument can't be +passed to the kernel without integer truncation (because the kernel +is old and does not support 32-bit user ids), +it will return \-1 and set \fierrno\fp to +.b einval +without attempting +the system call. +.sh bugs +no error indications of any kind are returned to the caller, +and the fact that both successful and unsuccessful calls return +the same value makes it impossible to directly determine +whether the call succeeded or failed. +instead, the caller must resort to looking at the return value +from a further call such as +.ir setfsuid(\-1) +(which will always fail), in order to determine if a preceding call to +.br setfsuid () +changed the filesystem user id. +at the very +least, +.b eperm +should be returned when the call fails (because the caller lacks the +.b cap_setuid +capability). +.sh see also +.br kill (2), +.br setfsgid (2), +.br capabilities (7), +.br credentials (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/setaliasent.3 + +.so man3/getrpcent_r.3 + +.\" copyright 2009 lefteris dimitroulakis (edimitro@tee.gr) +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th iso_8859-4 7 2020-08-13 "linux" "linux programmer's manual" +.sh name +iso_8859-4 \- iso 8859-4 character set encoded in octal, decimal, +and hexadecimal +.sh description +the iso 8859 standard includes several 8-bit extensions to the ascii +character set (also known as iso 646-irv). +iso 8859-4 encodes the +characters used in scandinavian and baltic languages. +.ss iso 8859 alphabets +the full set of iso 8859 alphabets includes: +.ts +l l. +iso 8859-1 west european languages (latin-1) +iso 8859-2 central and east european languages (latin-2) +iso 8859-3 southeast european and miscellaneous languages (latin-3) +iso 8859-4 scandinavian/baltic languages (latin-4) +iso 8859-5 latin/cyrillic +iso 8859-6 latin/arabic +iso 8859-7 latin/greek +iso 8859-8 latin/hebrew +iso 8859-9 latin-1 modification for turkish (latin-5) +iso 8859-10 lappish/nordic/eskimo languages (latin-6) +iso 8859-11 latin/thai +iso 8859-13 baltic rim languages (latin-7) +iso 8859-14 celtic (latin-8) +iso 8859-15 west european languages (latin-9) +iso 8859-16 romanian (latin-10) +.te +.ss iso 8859-4 characters +the following table displays the characters in iso 8859-4 that +are printable and unlisted in the +.br ascii (7) +manual page. +.ts +l l l c lp-1. +oct dec hex char description +_ +240 160 a0   no-break space +241 161 a1 ą latin capital letter a with ogonek +242 162 a2 ĸ latin small letter kra (greenlandic) +243 163 a3 ŗ latin capital letter r with cedilla +244 164 a4 ¤ currency sign +245 165 a5 ĩ latin capital letter i with tilde +246 166 a6 ļ latin capital letter l with cedilla +247 167 a7 § section sign +250 168 a8 ¨ diaeresis +251 169 a9 š latin capital letter s with caron +252 170 aa ē latin capital letter e with macron +253 171 ab ģ latin capital letter g with cedilla +254 172 ac ŧ latin capital letter t with stroke +255 173 ad ­ soft hyphen +256 174 ae ž latin capital letter z with caron +257 175 af ¯ macron +260 176 b0 ° degree sign +261 177 b1 ą latin small letter a with ogonek +262 178 b2 ˛ ogonek +263 179 b3 ŗ latin small letter r with cedilla +264 180 b4 ´ acute accent +265 181 b5 ĩ latin small letter i with tilde +266 182 b6 ļ latin small letter l with cedilla +267 183 b7 ˇ caron +270 184 b8 ¸ cedilla +271 185 b9 š latin small letter s with caron +272 186 ba ē latin small letter e with macron +273 187 bb ģ latin small letter g with cedilla +274 188 bc ŧ latin small letter t with stroke +275 189 bd ŋ latin capital letter eng +276 190 be ž latin small letter z with caron +277 191 bf ŋ latin small letter eng +300 192 c0 ā latin capital letter a with macron +301 193 c1 á latin capital letter a with acute +302 194 c2 â latin capital letter a with circumflex +303 195 c3 ã latin capital letter a with tilde +304 196 c4 ä latin capital letter a with diaeresis +305 197 c5 å latin capital letter a with ring above +306 198 c6 æ latin capital letter ae +307 199 c7 į latin capital letter i with ogonek +310 200 c8 č latin capital letter c with caron +311 201 c9 é latin capital letter e with acute +312 202 ca ę latin capital letter e with ogonek +313 203 cb ë latin capital letter e with diaeresis +314 204 cc ė latin capital letter e with dot above +315 205 cd í latin capital letter i with acute +316 206 ce î latin capital letter i with circumflex +317 207 cf ī latin capital letter i with macron +320 208 d0 đ latin capital letter d with stroke +321 209 d1 ņ latin capital letter n with cedilla +322 210 d2 ō latin capital letter o with macron +323 211 d3 ķ latin capital letter k with cedilla +324 212 d4 ô latin capital letter o with circumflex +325 213 d5 õ latin capital letter o with tilde +326 214 d6 ö latin capital letter o with diaeresis +327 215 d7 × multiplication sign +330 216 d8 ø latin capital letter o with stroke +331 217 d9 ų latin capital letter u with ogonek +332 218 da ú latin capital letter u with acute +333 219 db û latin capital letter u with circumflex +334 220 dc ü latin capital letter u with diaeresis +335 221 dd ũ latin capital letter u with tilde +336 222 de ū latin capital letter u with macron +337 223 df ß latin small letter sharp s +340 224 e0 ā latin small letter a with macron +341 225 e1 á latin small letter a with acute +342 226 e2 â latin small letter a with circumflex +343 227 e3 ã latin small letter a with tilde +344 228 e4 ä latin small letter a with diaeresis +345 229 e5 å latin small letter a with ring above +346 230 e6 æ latin small letter ae +347 231 e7 į latin small letter i with ogonek +350 232 e8 č latin small letter c with caron +351 233 e9 é latin small letter e with acute +352 234 ea ę latin small letter e with ogonek +353 235 eb ë latin small letter e with diaeresis +354 236 ec ė latin small letter e with dot above +355 237 ed í latin small letter i with acute +356 238 ee î latin small letter i with circumflex +357 239 ef ī latin small letter i with macron +360 240 f0 đ latin small letter d with stroke +361 241 f1 ņ latin small letter n with cedilla +362 242 f2 ō latin small letter o with macron +363 243 f3 ķ latin small letter k with cedilla +364 244 f4 ô latin small letter o with circumflex +365 245 f5 õ latin small letter o with tilde +366 246 f6 ö latin small letter o with diaeresis +367 247 f7 ÷ division sign +370 248 f8 ø latin small letter o with stroke +371 249 f9 ų latin small letter u with ogonek +372 250 fa ú latin small letter u with acute +373 251 fb û latin small letter u with circumflex +374 252 fc ü latin small letter u with diaeresis +375 253 fd ũ latin small letter u with tilde +376 254 fe ū latin small letter u with macron +377 255 ff ˙ dot above +.te +.sh notes +iso 8859-4 is also known as latin-4. +.sh see also +.br ascii (7), +.br charsets (7), +.br utf\-8 (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2019 michael kerrisk +.\" a very few fragments remain from an earlier page written by +.\" werner almesberger in 2000 +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th pivot_root 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +pivot_root \- change the root mount +.sh synopsis +.nf +.br "#include " " /* definition of " sys_* " constants */" +.b #include +.pp +.bi "int syscall(sys_pivot_root, const char *" new_root \ +", const char *" put_old ); +.fi +.pp +.ir note : +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. +more precisely, it moves the root mount to the +directory \fiput_old\fp and makes \finew_root\fp the new root mount. +the calling process must have the +.b cap_sys_admin +capability in the user namespace that owns the caller's mount namespace. +.pp +.br pivot_root () +changes the root directory and the current working directory +of each process or thread in the same mount namespace to +.i new_root +if they point to the old root directory. +(see also notes.) +on the other hand, +.br pivot_root () +does not change the caller's current working directory +(unless it is on the old root directory), +and thus it should be followed by a +\fbchdir("/")\fp call. +.pp +the following restrictions apply: +.ip \- 3 +.ir new_root +and +.ir put_old +must be directories. +.ip \- +.i new_root +and +.i put_old +must not be on the same mount as the current root. +.ip \- +\fiput_old\fp must be at or underneath \finew_root\fp; +that is, adding some nonnegative +number of "\fi/..\fp" prefixes to the pathname pointed to by +.i put_old +must yield the same directory as \finew_root\fp. +.ip \- +.i new_root +must be a path to a mount point, but can't be +.ir """/""" . +a path that is not already a mount point can be converted into one by +bind mounting the path onto itself. +.ip \- +the propagation type of the parent mount of +.ir new_root +and the parent mount of the current root directory must not be +.br ms_shared ; +similarly, if +.i put_old +is an existing mount point, its propagation type must not be +.br ms_shared . +these restrictions ensure that +.br pivot_root () +never propagates any changes to another mount namespace. +.ip \- +the current root directory must be a mount point. +.sh return value +on success, zero is returned. +on error, \-1 is returned, and +\fierrno\fp is set to indicate the error. +.sh errors +.br pivot_root () +may fail with any of the same errors as +.br stat (2). +additionally, it may fail with the following errors: +.tp +.b ebusy +.\" reconfirmed that the following error occurs on linux 5.0 by +.\" specifying 'new_root' as "/rootfs" and 'put_old' as +.\" "/rootfs/oldrootfs", and *not* bind mounting "/rootfs" on top of +.\" itself. of course, this is an odd situation, since a later check +.\" in the kernel code will in any case yield einval if 'new_root' is +.\" not a mount point. however, when the system call was first added, +.\" 'new_root' was not required to be a mount point. so, this +.\" error is nowadays probably just the result of crufty accumulation. +.\" this error can also occur if we bind mount "/" on top of itself +.\" and try to specify "/" as the 'new' (again, an odd situation). so, +.\" the ebusy check in the kernel does still seem necessary to prevent +.\" that case. furthermore, the "or put_old" piece is probably +.\" redundant text (although the check is in the kernel), since, +.\" in another check, 'put_old' is required to be under 'new_root'. +.i new_root +or +.i put_old +is on the current root mount. +(this error covers the pathological case where +.i new_root +is +.ir """/""" .) +.tp +.b einval +.i new_root +is not a mount point. +.tp +.b einval +\fiput_old\fp is not at or underneath \finew_root\fp. +.tp +.b einval +the current root directory is not a mount point +(because of an earlier +.br chroot (2)). +.tp +.b einval +the current root is on the rootfs (initial ramfs) mount; see notes. +.tp +.b einval +either the mount point at +.ir new_root , +or the parent mount of that mount point, +has propagation type +.br ms_shared . +.tp +.b einval +.i put_old +is a mount point and has the propagation type +.br ms_shared . +.tp +.b enotdir +\finew_root\fp or \fiput_old\fp is not a directory. +.tp +.b eperm +the calling process does not have the +.b cap_sys_admin +capability. +.sh versions +.br pivot_root () +was introduced in linux 2.3.41. +.sh conforming to +.br pivot_root () +is linux-specific and hence is not portable. +.sh notes +a command-line interface for this system call is provided by +.br pivot_root (8). +.pp +.br pivot_root () +allows the caller to switch to a new root filesystem while at the same time +placing the old root mount at a location under +.i new_root +from where it can subsequently be unmounted. +(the fact that it moves all processes that have a root directory +or current working directory on the old root directory to the +new root frees the old root directory of users, +allowing the old root mount to be unmounted more easily.) +.pp +one use of +.br pivot_root () +is during system startup, when the +system mounts a temporary root filesystem (e.g., an +.br initrd (4)), +then mounts the real root filesystem, and eventually turns the latter into +the root directory of all relevant processes and threads. +a modern use is to set up a root filesystem during +the creation of a container. +.pp +the fact that +.br pivot_root () +modifies process root and current working directories in the +manner noted in description +is necessary in order to prevent kernel threads from keeping the old +root mount busy with their root and current working directories, +even if they never access +the filesystem in any way. +.pp +the rootfs (initial ramfs) cannot be +.br pivot_root ()ed. +the recommended method of changing the root filesystem in this case is +to delete everything in rootfs, overmount rootfs with the new root, attach +.ir stdin / stdout / stderr +to the new +.ir /dev/console , +and exec the new +.br init (1). +helper programs for this process exist; see +.br switch_root (8). +.\" +.ss pivot_root(\(dq.\(dq, \(dq.\(dq) +.i new_root +and +.i put_old +may be the same directory. +in particular, the following sequence allows a pivot-root operation +without needing to create and remove a temporary directory: +.pp +.in +4n +.ex +chdir(new_root); +pivot_root(".", "."); +umount2(".", mnt_detach); +.ee +.in +.pp +this sequence succeeds because the +.br pivot_root () +call stacks the old root mount point +on top of the new root mount point at +.ir / . +at that point, the calling process's root directory and current +working directory refer to the new root mount point +.ri ( new_root ). +during the subsequent +.br umount () +call, resolution of +.ir """.""" +starts with +.i new_root +and then moves up the list of mounts stacked at +.ir / , +with the result that old root mount point is unmounted. +.\" +.ss historical notes +for many years, this manual page carried the following text: +.rs +.pp +.br pivot_root () +may or may not change the current root and the current +working directory of any processes or threads which use the old +root directory. +the caller of +.br pivot_root () +must ensure that processes with root or current working directory +at the old root operate correctly in either case. +an easy way to ensure this is to change their +root and current working directory to \finew_root\fp before invoking +.br pivot_root (). +.re +.pp +this text, written before the system call implementation was +even finalized in the kernel, was probably intended to warn users +at that time that the implementation might change before final release. +however, the behavior stated in description +has remained consistent since this system call +was first implemented and will not change now. +.sh examples +.\" fixme +.\" would it be better, because simpler, to use unshare(2) +.\" rather than clone(2) in the example below? +the program below demonstrates the use of +.br pivot_root () +inside a mount namespace that is created using +.br clone (2). +after pivoting to the root directory named in the program's +first command-line argument, the child created by +.br clone (2) +then executes the program named in the remaining command-line arguments. +.pp +we demonstrate the program by creating a directory that will serve as +the new root filesystem and placing a copy of the (statically linked) +.br busybox (1) +executable in that directory. +.pp +.in +4n +.ex +$ \fbmkdir /tmp/rootfs\fp +$ \fbls \-id /tmp/rootfs\fp # show inode number of new root directory +319459 /tmp/rootfs +$ \fbcp $(which busybox) /tmp/rootfs\fp +$ \fbps1=\(aqbbsh$ \(aq sudo ./pivot_root_demo /tmp/rootfs /busybox sh\fp +bbsh$ \fbpath=/\fp +bbsh$ \fbbusybox ln busybox ln\fp +bbsh$ \fbln busybox echo\fp +bbsh$ \fbln busybox ls\fp +bbsh$ \fbls\fp +busybox echo ln ls +bbsh$ \fbls \-id /\fp # compare with inode number above +319459 / +bbsh$ \fbecho \(aqhello world\(aq\fp +hello world +.ee +.in +.ss program source +\& +.pp +.ex +/* pivot_root_demo.c */ + +#define _gnu_source +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define errexit(msg) do { perror(msg); exit(exit_failure); \e + } while (0) + +static int +pivot_root(const char *new_root, const char *put_old) +{ + return syscall(sys_pivot_root, new_root, put_old); +} + +#define stack_size (1024 * 1024) + +static int /* startup function for cloned child */ +child(void *arg) +{ + char **args = arg; + char *new_root = args[0]; + const char *put_old = "/oldrootfs"; + char path[path_max]; + + /* ensure that \(aqnew_root\(aq and its parent mount don\(aqt have + shared propagation (which would cause pivot_root() to + return an error), and prevent propagation of mount + events to the initial mount namespace. */ + + if (mount(null, "/", null, ms_rec | ms_private, null) == \-1) + errexit("mount\-ms_private"); + + /* ensure that \(aqnew_root\(aq is a mount point. */ + + if (mount(new_root, new_root, null, ms_bind, null) == \-1) + errexit("mount\-ms_bind"); + + /* create directory to which old root will be pivoted. */ + + snprintf(path, sizeof(path), "%s/%s", new_root, put_old); + if (mkdir(path, 0777) == \-1) + errexit("mkdir"); + + /* and pivot the root filesystem. */ + + if (pivot_root(new_root, path) == \-1) + errexit("pivot_root"); + + /* switch the current working directory to "/". */ + + if (chdir("/") == \-1) + errexit("chdir"); + + /* unmount old root and remove mount point. */ + + if (umount2(put_old, mnt_detach) == \-1) + perror("umount2"); + if (rmdir(put_old) == \-1) + perror("rmdir"); + + /* execute the command specified in argv[1]... */ + + execv(args[1], &args[1]); + errexit("execv"); +} + +int +main(int argc, char *argv[]) +{ + /* create a child process in a new mount namespace. */ + + char *stack = mmap(null, stack_size, prot_read | prot_write, + map_private | map_anonymous | map_stack, \-1, 0); + if (stack == map_failed) + errexit("mmap"); + + if (clone(child, stack + stack_size, + clone_newns | sigchld, &argv[1]) == \-1) + errexit("clone"); + + /* parent falls through to here; wait for child. */ + + if (wait(null) == \-1) + errexit("wait"); + + exit(exit_success); +} +.ee +.sh see also +.br chdir (2), +.br chroot (2), +.br mount (2), +.br stat (2), +.br initrd (4), +.br mount_namespaces (7), +.br pivot_root (8), +.br switch_root (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1999 suse gmbh nuernberg, germany +.\" author: thorsten kukuk +.\" +.\" %%%license_start(gplv2+_sw_3_para) +.\" this program is free software; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of the +.\" license, or (at your option) any later version. +.\" +.\" this program 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 +.\" general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" 2008-12-05 petr baudis +.\" rewrite the notes section to reflect modern reality +.\" +.th nscd 8 2015-05-07 "gnu" "linux programmer's manual" +.sh name +nscd \- name service cache daemon +.sh description +.b nscd +is a daemon that provides a cache for the most common name service +requests. +the default configuration file, +.ir /etc/nscd.conf , +determines the behavior of the cache daemon. +see +.br nscd.conf (5). +.pp +.b nscd +provides caching for accesses of the +.br passwd (5), +.br group (5), +.br hosts (5) +.br services (5) +and +.i netgroup +databases through standard libc interfaces, such as +.br getpwnam (3), +.br getpwuid (3), +.br getgrnam (3), +.br getgrgid (3), +.br gethostbyname (3), +and others. +.pp +there are two caches for each database: +a positive one for items found, and a negative one +for items not found. +each cache has a separate ttl (time-to-live) +period for its data. +note that the shadow file is specifically not cached. +.br getspnam (3) +calls remain uncached as a result. +.sh options +.tp +.b "\-\-help" +will give you a list with all options and what they do. +.sh notes +the daemon will try to watch for changes in configuration files +appropriate for each database (e.g., +.i /etc/passwd +for the +.i passwd +database or +.i /etc/hosts +and +.i /etc/resolv.conf +for the +.i hosts +database), and flush the cache when these are changed. +however, this will happen only after a short delay (unless the +.br inotify (7) +mechanism is available and glibc 2.9 or later is available), +and this auto-detection does not cover configuration files +required by nonstandard nss modules, if any are specified in +.ir /etc/nsswitch.conf . +in that case, you need to run the following command +after changing the configuration file of the database so that +.b nscd +invalidates its cache: +.pp +.in +4n +.ex +$ \fbnscd \-i\fp \fi\fp +.ee +.in +.sh see also +.br nscd.conf (5), +.br nsswitch.conf (5) +.\" .sh author +.\" .b nscd +.\" was written by thorsten kukuk and ulrich drepper. +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1993 luigi p. bai (lpb@softint.com) july 28, 1993 +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified wed jul 28 10:57:35 1993, rik faith +.\" modified sun nov 28 16:43:30 1993, rik faith +.\" with material from giorgio ciucci +.\" portions copyright 1993 giorgio ciucci +.\" modified tue oct 22 22:03:17 1996 by eric s. raymond +.\" modified, 8 jan 2003, michael kerrisk, +.\" removed eidrm from errors - that can't happen... +.\" modified, 27 may 2004, michael kerrisk +.\" added notes on capability requirements +.\" modified, 11 nov 2004, michael kerrisk +.\" language and formatting clean-ups +.\" added notes on /proc files +.\" +.th shmget 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +shmget \- allocates a system v shared memory segment +.sh synopsis +.nf +.ad l +.b #include +.pp +.bi "int shmget(key_t " key ", size_t " size ", int " shmflg ); +.ad b +.fi +.sh description +.br shmget () +returns the identifier of the system\ v shared memory segment +associated with the value of the argument +.ir key . +it may be used either to obtain the identifier of a previously created +shared memory segment (when +.i shmflg +is zero and +.i key +does not have the value +.br ipc_private ), +or to create a new set. +.pp +a new shared memory segment, with size equal to the value of +.i size +rounded up to a multiple of +.br page_size , +is created if +.i key +has the value +.b ipc_private +or +.i key +isn't +.br ipc_private , +no shared memory segment corresponding to +.i key +exists, and +.b ipc_creat +is specified in +.ir shmflg . +.pp +if +.i shmflg +specifies both +.b ipc_creat +and +.b ipc_excl +and a shared memory segment already exists for +.ir key , +then +.br shmget () +fails with +.i errno +set to +.br eexist . +(this is analogous to the effect of the combination +.b o_creat | o_excl +for +.br open (2).) +.pp +the value +.i shmflg +is composed of: +.tp +.b ipc_creat +create a new segment. +if this flag is not used, then +.br shmget () +will find the segment associated with \fikey\fp and check to see if +the user has permission to access the segment. +.tp +.b ipc_excl +this flag is used with +.b ipc_creat +to ensure that this call creates the segment. +if the segment already exists, the call fails. +.tp +.br shm_hugetlb " (since linux 2.6)" +allocate the segment using "huge" pages. +see the linux kernel source file +.i documentation/admin\-guide/mm/hugetlbpage.rst +for further information. +.tp +.br shm_huge_2mb ", " shm_huge_1gb " (since linux 3.8)" +.\" see https://lwn.net/articles/533499/ +used in conjunction with +.b shm_hugetlb +to select alternative hugetlb page sizes (respectively, 2\ mb and 1\ gb) +on systems that support multiple hugetlb page sizes. +.ip +more generally, the desired huge page size can be configured by encoding +the base-2 logarithm of the desired page size in the six bits at the offset +.br shm_huge_shift . +thus, the above two constants are defined as: +.ip +.in +4n +.ex +#define shm_huge_2mb (21 << shm_huge_shift) +#define shm_huge_1gb (30 << shm_huge_shift) +.ee +.in +.ip +for some additional details, +see the discussion of the similarly named constants in +.br mmap (2). +.tp +.br shm_noreserve " (since linux 2.6.15)" +this flag serves the same purpose as the +.br mmap (2) +.b map_noreserve +flag. +do not reserve swap space for this segment. +when swap space is reserved, one has the guarantee +that it is possible to modify the segment. +when swap space is not reserved one might get +.b sigsegv +upon a write +if no physical memory is available. +see also the discussion of the file +.i /proc/sys/vm/overcommit_memory +in +.br proc (5). +.\" as at 2.6.17-rc2, this flag has no effect if shm_hugetlb was also +.\" specified. +.pp +in addition to the above flags, the least significant 9 bits of +.i shmflg +specify the permissions granted to the owner, group, and others. +these bits have the same format, and the same +meaning, as the +.i mode +argument of +.br open (2). +presently, execute permissions are not used by the system. +.pp +when a new shared memory segment is created, +its contents are initialized to zero values, and +its associated data structure, +.i shmid_ds +(see +.br shmctl (2)), +is initialized as follows: +.ip \(bu 2 +.i shm_perm.cuid +and +.i shm_perm.uid +are set to the effective user id of the calling process. +.ip \(bu +.i shm_perm.cgid +and +.i shm_perm.gid +are set to the effective group id of the calling process. +.ip \(bu +the least significant 9 bits of +.i shm_perm.mode +are set to the least significant 9 bit of +.ir shmflg . +.ip \(bu +.i shm_segsz +is set to the value of +.ir size . +.ip \(bu +.ir shm_lpid , +.ir shm_nattch , +.ir shm_atime , +and +.i shm_dtime +are set to 0. +.ip \(bu +.i shm_ctime +is set to the current time. +.pp +if the shared memory segment already exists, the permissions are +verified, and a check is made to see if it is marked for destruction. +.sh return value +on success, a valid shared memory identifier is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eacces +the user does not have permission to access the +shared memory segment, and does not have the +.b cap_ipc_owner +capability in the user namespace that governs its ipc namespace. +.tp +.b eexist +.br ipc_creat +and +.br ipc_excl +were specified in +.ir shmflg , +but a shared memory segment already exists for +.ir key . +.tp +.b einval +a new segment was to be created and +.i size +is less than +.b shmmin +or greater than +.br shmmax . +.tp +.b einval +a segment for the given +.i key +exists, but \fisize\fp is greater than the size +of that segment. +.tp +.b enfile +.\" [2.6.7] shmem_zero_setup()-->shmem_file_setup()-->get_empty_filp() +the system-wide limit on the total number of open files has been reached. +.tp +.b enoent +no segment exists for the given \fikey\fp, and +.b ipc_creat +was not specified. +.tp +.b enomem +no memory could be allocated for segment overhead. +.tp +.b enospc +all possible shared memory ids have been taken +.rb ( shmmni ), +or allocating a segment of the requested +.i size +would cause the system to exceed the system-wide limit on shared memory +.rb ( shmall ). +.tp +.b eperm +the +.b shm_hugetlb +flag was specified, but the caller was not privileged (did not have the +.b cap_ipc_lock +capability) +and is not a member of the +.i sysctl_hugetlb_shm_group +group; see the description of +.i /proc/sys/vm/sysctl_hugetlb_shm_group +in +.br proc (5). +.sh conforming to +posix.1-2001, posix.1-2008, svr4. +.\" svr4 documents an additional error condition eexist. +.pp +.b shm_hugetlb +and +.b shm_noreserve +are linux extensions. +.sh notes +.b ipc_private +isn't a flag field but a +.i key_t +type. +if this special value is used for +.ir key , +the system call ignores all but the least significant 9 bits of +.i shmflg +and creates a new shared memory segment. +.\" +.ss shared memory limits +the following limits on shared memory segment resources affect the +.br shmget () +call: +.tp +.b shmall +system-wide limit on the total amount of shared memory, +measured in units of the system page size. +.ip +on linux, this limit can be read and modified via +.ir /proc/sys/kernel/shmall . +since linux 3.16, +.\" commit 060028bac94bf60a65415d1d55a359c3a17d5c31 +the default value for this limit is: +.ip + ulong_max - 2^24 +.ip +the effect of this value +(which is suitable for both 32-bit and 64-bit systems) +is to impose no limitation on allocations. +this value, rather than +.br ulong_max , +was chosen as the default to prevent some cases where historical +applications simply raised the existing limit without first checking +its current value. +such applications would cause the value to overflow if the limit was set at +.br ulong_max . +.ip +from linux 2.4 up to linux 3.15, +the default value for this limit was: +.ip + shmmax / page_size * (shmmni / 16) +.ip +if +.b shmmax +and +.b shmmni +were not modified, then multiplying the result of this formula +by the page size (to get a value in bytes) yielded a value of 8\ gb +as the limit on the total memory used by all shared memory segments. +.tp +.b shmmax +maximum size in bytes for a shared memory segment. +.ip +on linux, this limit can be read and modified via +.ir /proc/sys/kernel/shmmax . +since linux 3.16, +.\" commit 060028bac94bf60a65415d1d55a359c3a17d5c31 +the default value for this limit is: +.ip + ulong_max - 2^24 +.ip +the effect of this value +(which is suitable for both 32-bit and 64-bit systems) +is to impose no limitation on allocations. +see the description of +.br shmall +for a discussion of why this default value (rather than +.br ulong_max ) +is used. +.ip +from linux 2.2 up to linux 3.15, the default value of +this limit was 0x2000000 (32\ mb). +.ip +because it is not possible to map just part of a shared memory segment, +the amount of virtual memory places another limit on the maximum size of a +usable segment: +for example, on i386 the largest segments that can be mapped have a +size of around 2.8\ gb, and on x86-64 the limit is around 127 tb. +.tp +.b shmmin +minimum size in bytes for a shared memory segment: implementation +dependent (currently 1 byte, though +.b page_size +is the effective minimum size). +.tp +.b shmmni +system-wide limit on the number of shared memory segments. +in linux 2.2, the default value for this limit was 128; +since linux 2.4, the default value is 4096. +.ip +on linux, this limit can be read and modified via +.ir /proc/sys/kernel/shmmni . +.\" kernels between 2.4.x and 2.6.8 had an off-by-one error that meant +.\" that we could create one more segment than shmmni -- mtk +.\" this /proc file is not available in linux 2.2 and earlier -- mtk +.pp +the implementation has no specific limits for the per-process maximum +number of shared memory segments +.rb ( shmseg ). +.ss linux notes +until version 2.3.30, linux would return +.b eidrm +for a +.br shmget () +on a shared memory segment scheduled for deletion. +.sh bugs +the name choice +.b ipc_private +was perhaps unfortunate, +.b ipc_new +would more clearly show its function. +.sh examples +see +.br shmop (2). +.sh see also +.br memfd_create (2), +.br shmat (2), +.br shmctl (2), +.br shmdt (2), +.br ftok (3), +.br capabilities (7), +.br shm_overview (7), +.br sysvipc (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2002 robert love +.\" and copyright (c) 2006, 2015 michael kerrisk +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" 2002-11-19 robert love - initial version +.\" 2004-04-20 mtk - fixed description of return value +.\" 2004-04-22 aeb - added glibc prototype history +.\" 2005-05-03 mtk - noted that sched_setaffinity may cause thread +.\" migration and that cpu affinity is a per-thread attribute. +.\" 2006-02-03 mtk -- major rewrite +.\" 2008-11-12, mtk, removed cpu_*() macro descriptions to a +.\" separate cpu_set(3) page. +.\" +.th sched_setaffinity 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +sched_setaffinity, sched_getaffinity \- \ +set and get a thread's cpu affinity mask +.sh synopsis +.nf +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "int sched_setaffinity(pid_t " pid ", size_t " cpusetsize , +.bi " const cpu_set_t *" mask ); +.bi "int sched_getaffinity(pid_t " pid ", size_t " cpusetsize , +.bi " cpu_set_t *" mask ); +.fi +.sh description +a thread's cpu affinity mask determines the set of cpus on which +it is eligible to run. +on a multiprocessor system, setting the cpu affinity mask +can be used to obtain performance benefits. +for example, +by dedicating one cpu to a particular thread +(i.e., setting the affinity mask of that thread to specify a single cpu, +and setting the affinity mask of all other threads to exclude that cpu), +it is possible to ensure maximum execution speed for that thread. +restricting a thread to run on a single cpu also avoids +the performance cost caused by the cache invalidation that occurs +when a thread ceases to execute on one cpu and then +recommences execution on a different cpu. +.pp +a cpu affinity mask is represented by the +.i cpu_set_t +structure, a "cpu set", pointed to by +.ir mask . +a set of macros for manipulating cpu sets is described in +.br cpu_set (3). +.pp +.br sched_setaffinity () +sets the cpu affinity mask of the thread whose id is +.i pid +to the value specified by +.ir mask . +if +.i pid +is zero, then the calling thread is used. +the argument +.i cpusetsize +is the length (in bytes) of the data pointed to by +.ir mask . +normally this argument would be specified as +.ir "sizeof(cpu_set_t)" . +.pp +if the thread specified by +.i pid +is not currently running on one of the cpus specified in +.ir mask , +then that thread is migrated to one of the cpus specified in +.ir mask . +.pp +.br sched_getaffinity () +writes the affinity mask of the thread whose id is +.i pid +into the +.i cpu_set_t +structure pointed to by +.ir mask . +the +.i cpusetsize +argument specifies the size (in bytes) of +.ir mask . +if +.i pid +is zero, then the mask of the calling thread is returned. +.sh return value +on success, +.br sched_setaffinity () +and +.br sched_getaffinity () +return 0 (but see "c library/kernel differences" below, +which notes that the underlying +.br sched_getaffinity () +differs in its return value). +on failure, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b efault +a supplied memory address was invalid. +.tp +.b einval +the affinity bit mask +.i mask +contains no processors that are currently physically on the system +and permitted to the thread according to any restrictions that +may be imposed by +.i cpuset +cgroups or the "cpuset" mechanism described in +.br cpuset (7). +.tp +.b einval +.rb ( sched_getaffinity () +and, in kernels before 2.6.9, +.br sched_setaffinity ()) +.i cpusetsize +is smaller than the size of the affinity mask used by the kernel. +.tp +.b eperm +.rb ( sched_setaffinity ()) +the calling thread does not have appropriate privileges. +the caller needs an effective user id equal to the real user id +or effective user id of the thread identified by +.ir pid , +or it must possess the +.b cap_sys_nice +capability in the user namespace of the thread +.ir pid . +.tp +.b esrch +the thread whose id is \fipid\fp could not be found. +.sh versions +the cpu affinity system calls were introduced in linux kernel 2.5.8. +the system call wrappers were introduced in glibc 2.3. +initially, the glibc interfaces included a +.i cpusetsize +argument, typed as +.ir "unsigned int" . +in glibc 2.3.3, the +.i cpusetsize +argument was removed, but was then restored in glibc 2.3.4, with type +.ir size_t . +.sh conforming to +these system calls are linux-specific. +.sh notes +after a call to +.br sched_setaffinity (), +the set of cpus on which the thread will actually run is +the intersection of the set specified in the +.i mask +argument and the set of cpus actually present on the system. +the system may further restrict the set of cpus on which the thread +runs if the "cpuset" mechanism described in +.br cpuset (7) +is being used. +these restrictions on the actual set of cpus on which the thread +will run are silently imposed by the kernel. +.pp +there are various ways of determining the number of cpus +available on the system, including: inspecting the contents of +.ir /proc/cpuinfo ; +using +.br sysconf (3) +to obtain the values of the +.br _sc_nprocessors_conf +and +.br _sc_nprocessors_onln +parameters; and inspecting the list of cpu directories under +.ir /sys/devices/system/cpu/ . +.pp +.br sched (7) +has a description of the linux scheduling scheme. +.pp +the affinity mask is a per-thread attribute that can be +adjusted independently for each of the threads in a thread group. +the value returned from a call to +.br gettid (2) +can be passed in the argument +.ir pid . +specifying +.i pid +as 0 will set the attribute for the calling thread, +and passing the value returned from a call to +.br getpid (2) +will set the attribute for the main thread of the thread group. +(if you are using the posix threads api, then use +.br pthread_setaffinity_np (3) +instead of +.br sched_setaffinity ().) +.pp +the +.i isolcpus +boot option can be used to isolate one or more cpus at boot time, +so that no processes are scheduled onto those cpus. +following the use of this boot option, +the only way to schedule processes onto the isolated cpus is via +.br sched_setaffinity () +or the +.br cpuset (7) +mechanism. +for further information, see the kernel source file +.ir documentation/admin\-guide/kernel\-parameters.txt . +as noted in that file, +.i isolcpus +is the preferred mechanism of isolating cpus +(versus the alternative of manually setting the cpu affinity +of all processes on the system). +.pp +a child created via +.br fork (2) +inherits its parent's cpu affinity mask. +the affinity mask is preserved across an +.br execve (2). +.ss c library/kernel differences +this manual page describes the glibc interface for the cpu affinity calls. +the actual system call interface is slightly different, with the +.i mask +being typed as +.ir "unsigned long\ *" , +reflecting the fact that the underlying implementation of cpu +sets is a simple bit mask. +.pp +on success, the raw +.br sched_getaffinity () +system call returns the number of bytes placed copied into the +.i mask +buffer; +this will be the minimum of +.i cpusetsize +and the size (in bytes) of the +.i cpumask_t +data type that is used internally by the kernel to +represent the cpu set bit mask. +.ss handling systems with large cpu affinity masks +the underlying system calls (which represent cpu masks as bit masks of type +.ir "unsigned long\ *" ) +impose no restriction on the size of the cpu mask. +however, the +.i cpu_set_t +data type used by glibc has a fixed size of 128 bytes, +meaning that the maximum cpu number that can be represented is 1023. +.\" fixme . see https://sourceware.org/bugzilla/show_bug.cgi?id=15630 +.\" and https://sourceware.org/ml/libc-alpha/2013-07/msg00288.html +if the kernel cpu affinity mask is larger than 1024, +then calls of the form: +.pp + sched_getaffinity(pid, sizeof(cpu_set_t), &mask); +.pp +fail with the error +.br einval , +the error produced by the underlying system call for the case where the +.i mask +size specified in +.i cpusetsize +is smaller than the size of the affinity mask used by the kernel. +(depending on the system cpu topology, the kernel affinity mask can +be substantially larger than the number of active cpus in the system.) +.pp +when working on systems with large kernel cpu affinity masks, +one must dynamically allocate the +.i mask +argument (see +.br cpu_alloc (3)). +currently, the only way to do this is by probing for the size +of the required mask using +.br sched_getaffinity () +calls with increasing mask sizes (until the call does not fail with the error +.br einval ). +.pp +be aware that +.br cpu_alloc (3) +may allocate a slightly larger cpu set than requested +(because cpu sets are implemented as bit masks allocated in units of +.ir sizeof(long) ). +consequently, +.br sched_getaffinity () +can set bits beyond the requested allocation size, because the kernel +sees a few additional bits. +therefore, the caller should iterate over the bits in the returned set, +counting those which are set, and stop upon reaching the value returned by +.br cpu_count (3) +(rather than iterating over the number of bits +requested to be allocated). +.sh examples +the program below creates a child process. +the parent and child then each assign themselves to a specified cpu +and execute identical loops that consume some cpu time. +before terminating, the parent waits for the child to complete. +the program takes three command-line arguments: +the cpu number for the parent, +the cpu number for the child, +and the number of loop iterations that both processes should perform. +.pp +as the sample runs below demonstrate, the amount of real and cpu time +consumed when running the program will depend on intra-core caching effects +and whether the processes are using the same cpu. +.pp +we first employ +.br lscpu (1) +to determine that this (x86) +system has two cores, each with two cpus: +.pp +.in +4n +.ex +$ \fblscpu | egrep \-i \(aqcore.*:|socket\(aq\fp +thread(s) per core: 2 +core(s) per socket: 2 +socket(s): 1 +.ee +.in +.pp +we then time the operation of the example program for three cases: +both processes running on the same cpu; +both processes running on different cpus on the same core; +and both processes running on different cpus on different cores. +.pp +.in +4n +.ex +$ \fbtime \-p ./a.out 0 0 100000000\fp +real 14.75 +user 3.02 +sys 11.73 +$ \fbtime \-p ./a.out 0 1 100000000\fp +real 11.52 +user 3.98 +sys 19.06 +$ \fbtime \-p ./a.out 0 3 100000000\fp +real 7.89 +user 3.29 +sys 12.07 +.ee +.in +.ss program source +\& +.ex +#define _gnu_source +#include +#include +#include +#include +#include + +#define errexit(msg) do { perror(msg); exit(exit_failure); \e + } while (0) + +int +main(int argc, char *argv[]) +{ + cpu_set_t set; + int parentcpu, childcpu; + int nloops; + + if (argc != 4) { + fprintf(stderr, "usage: %s parent\-cpu child\-cpu num\-loops\en", + argv[0]); + exit(exit_failure); + } + + parentcpu = atoi(argv[1]); + childcpu = atoi(argv[2]); + nloops = atoi(argv[3]); + + cpu_zero(&set); + + switch (fork()) { + case \-1: /* error */ + errexit("fork"); + + case 0: /* child */ + cpu_set(childcpu, &set); + + if (sched_setaffinity(getpid(), sizeof(set), &set) == \-1) + errexit("sched_setaffinity"); + + for (int j = 0; j < nloops; j++) + getppid(); + + exit(exit_success); + + default: /* parent */ + cpu_set(parentcpu, &set); + + if (sched_setaffinity(getpid(), sizeof(set), &set) == \-1) + errexit("sched_setaffinity"); + + for (int j = 0; j < nloops; j++) + getppid(); + + wait(null); /* wait for child to terminate */ + exit(exit_success); + } +} +.ee +.sh see also +.ad l +.nh +.br lscpu (1), +.br nproc (1), +.br taskset (1), +.br clone (2), +.br getcpu (2), +.br getpriority (2), +.br gettid (2), +.br nice (2), +.br sched_get_priority_max (2), +.br sched_get_priority_min (2), +.br sched_getscheduler (2), +.br sched_setscheduler (2), +.br setpriority (2), +.br cpu_set (3), +.br get_nprocs (3), +.br pthread_setaffinity_np (3), +.br sched_getcpu (3), +.br capabilities (7), +.br cpuset (7), +.br sched (7), +.br numactl (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/unlocked_stdio.3 + +.\" copyright (c) 2003 andries brouwer (aeb@cwi.nl) +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th getgrent_r 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +getgrent_r, fgetgrent_r \- get group file entry reentrantly +.sh synopsis +.nf +.b #include +.pp +.bi "int getgrent_r(struct group *restrict " gbuf , +.bi " char *restrict " buf ", size_t " buflen , +.bi " struct group **restrict " gbufp ); +.bi "int fgetgrent_r(file *restrict " stream ", struct group *restrict " gbuf , +.bi " char *restrict " buf ", size_t " buflen , +.bi " struct group **restrict " gbufp ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br getgrent_r (): +.nf + _gnu_source +.fi +.\" fixme . the ftm requirements seem inconsistent here. file a glibc bug? +.pp +.br fgetgrent_r (): + since glibc 2.19: + _default_source + glibc 2.19 and earlier: + _svid_source +.sh description +the functions +.br getgrent_r () +and +.br fgetgrent_r () +are the reentrant versions of +.br getgrent (3) +and +.br fgetgrent (3). +the former reads the next group entry from the stream initialized by +.br setgrent (3). +the latter reads the next group entry from +.ir stream . +.pp +the \figroup\fp structure is defined in +.i +as follows: +.pp +.in +4n +.ex +struct group { + char *gr_name; /* group name */ + char *gr_passwd; /* group password */ + gid_t gr_gid; /* group id */ + char **gr_mem; /* null\-terminated array of pointers + to names of group members */ +}; +.ee +.in +.pp +for more information about the fields of this structure, see +.br group (5). +.pp +the nonreentrant functions return a pointer to static storage, +where this static storage contains further pointers to group +name, password, and members. +the reentrant functions described here return all of that in +caller-provided buffers. +first of all there is the buffer +.i gbuf +that can hold a \fistruct group\fp. +and next the buffer +.i buf +of size +.i buflen +that can hold additional strings. +the result of these functions, the \fistruct group\fp read from the stream, +is stored in the provided buffer +.ir *gbuf , +and a pointer to this \fistruct group\fp is returned in +.ir *gbufp . +.sh return value +on success, these functions return 0 and +.i *gbufp +is a pointer to the \fistruct group\fp. +on error, these functions return an error value and +.i *gbufp +is null. +.sh errors +.tp +.b enoent +no more entries. +.tp +.b erange +insufficient buffer space supplied. +try again with larger buffer. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lb lb lbx +l l l. +interface attribute value +t{ +.br getgrent_r () +t} thread safety t{ +mt-unsafe race:grent locale +t} +t{ +.br fgetgrent_r () +t} thread safety t{ +mt-safe +t} +.te +.hy +.ad +.sp 1 +in the above table, +.i grent +in +.i race:grent +signifies that if any of the functions +.br setgrent (3), +.br getgrent (3), +.br endgrent (3), +or +.br getgrent_r () +are used in parallel in different threads of a program, +then data races could occur. +.sh conforming to +these functions are gnu extensions, done in a style resembling +the posix version of functions like +.br getpwnam_r (3). +other systems use the prototype +.pp +.in +4n +.ex +struct group *getgrent_r(struct group *grp, char *buf, + int buflen); +.ee +.in +.pp +or, better, +.pp +.in +4n +.ex +int getgrent_r(struct group *grp, char *buf, int buflen, + file **gr_fp); +.ee +.in +.sh notes +the function +.br getgrent_r () +is not really reentrant since it shares the reading position +in the stream with all other threads. +.sh examples +.ex +#define _gnu_source +#include +#include +#include +#include +#define buflen 4096 + +int +main(void) +{ + struct group grp; + struct group *grpp; + char buf[buflen]; + int i; + + setgrent(); + while (1) { + i = getgrent_r(&grp, buf, sizeof(buf), &grpp); + if (i) + break; + printf("%s (%jd):", grpp\->gr_name, (intmax_t) grpp\->gr_gid); + for (int j = 0; ; j++) { + if (grpp\->gr_mem[j] == null) + break; + printf(" %s", grpp\->gr_mem[j]); + } + printf("\en"); + } + endgrent(); + exit(exit_success); +} +.ee +.\" perhaps add error checking - should use strerror_r +.\" #include +.\" #include +.\" if (i) { +.\" if (i == enoent) +.\" break; +.\" printf("getgrent_r: %s", strerror(i)); +.\" exit(exit_failure); +.\" } +.sh see also +.br fgetgrent (3), +.br getgrent (3), +.br getgrgid (3), +.br getgrnam (3), +.br putgrent (3), +.br group (5) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/stailq.3 + +.so man2/signalfd.2 + +.so man2/wait.2 + +.so man3/ctan.3 + +.so man3/argz_add.3 + +.so man2/set_thread_area.2 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" and copyright 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified 1993-07-24 by rik faith (faith@cs.unc.edu) +.\" modified 1996-06-08 by aeb +.\" modified 2002-07-27 by walter harms +.\" (walter.harms@informatik.uni-oldenburg.de) +.\" +.th cosh 3 2021-03-22 "" "linux programmer's manual" +.sh name +cosh, coshf, coshl \- hyperbolic cosine function +.sh synopsis +.nf +.b #include +.pp +.bi "double cosh(double " x ); +.bi "float coshf(float " x ); +.bi "long double coshl(long double " x ); +.fi +.pp +link with \fi\-lm\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br coshf (), +.br coshl (): +.nf + _isoc99_source || _posix_c_source >= 200112l + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.sh description +these functions return the hyperbolic cosine of +.ir x , +which is defined mathematically as: +.pp +.nf + cosh(x) = (exp(x) + exp(\-x)) / 2 +.fi +.sh return value +on success, these functions return the hyperbolic cosine of +.ir x . +.pp +if +.i x +is a nan, a nan is returned. +.pp +if +.i x +is +0 or \-0, 1 is returned. +.pp +if +.i x +is positive infinity or negative infinity, +positive infinity is returned. +.pp +if the result overflows, +a range error occurs, +and the functions return +.rb + huge_val , +.rb + huge_valf , +or +.rb + huge_vall , +respectively. +.sh errors +see +.br math_error (7) +for information on how to determine whether an error has occurred +when calling these functions. +.pp +the following errors can occur: +.tp +range error: result overflow +.i errno +is set to +.br erange . +an overflow floating-point exception +.rb ( fe_overflow ) +is raised. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br cosh (), +.br coshf (), +.br coshl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.pp +the variant returning +.i double +also conforms to +svr4, 4.3bsd. +.sh bugs +in glibc version 2.3.4 and earlier, +an overflow floating-point +.rb ( fe_overflow ) +exception is not raised when an overflow occurs. +.sh see also +.br acosh (3), +.br asinh (3), +.br atanh (3), +.br ccos (3), +.br sinh (3), +.br tanh (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" iso/iec 9899:1999 +.\" +.th mbtowc 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +mbtowc \- convert a multibyte sequence to a wide character +.sh synopsis +.nf +.b #include +.pp +.bi "int mbtowc(wchar_t *restrict " pwc ", const char *restrict " s \ +", size_t " n ); +.fi +.sh description +the main case for this function is when +.ir s +is not null and +.i pwc +is +not null. +in this case, the +.br mbtowc () +function inspects at most +.i n +bytes of the multibyte string starting at +.ir s , +extracts the next complete +multibyte character, converts it to a wide character and stores it at +.ir *pwc . +it updates an internal shift state known only to the +.br mbtowc () +function. +if +.i s +does not point to a null byte (\(aq\e0\(aq), it returns the number +of bytes that were consumed from +.ir s , +otherwise it returns 0. +.pp +if the +.ir n +bytes starting at +.i s +do not contain a complete multibyte +character, or if they contain an invalid multibyte sequence, +.br mbtowc () +returns \-1. +this can happen even if +.i n +>= +.ir mb_cur_max , +if the multibyte string contains redundant shift sequences. +.pp +a different case is when +.ir s +is not null but +.i pwc +is null. +in this case, the +.br mbtowc () +function behaves as above, except that it does not +store the converted wide character in memory. +.pp +a third case is when +.i s +is null. +in this case, +.ir pwc +and +.i n +are +ignored. +the +.br mbtowc () +function +.\" the dinkumware doc and the single unix specification say this, but +.\" glibc doesn't implement this. +resets the shift state, only known to this function, +to the initial state, and +returns nonzero if the encoding has nontrivial shift state, or zero if the +encoding is stateless. +.sh return value +if +.i s +is not null, the +.br mbtowc () +function returns the number of +consumed bytes starting at +.ir s , +or 0 if +.i s +points to a null byte, +or \-1 upon failure. +.pp +if +.i s +is null, the +.br mbtowc () +function +returns nonzero if the encoding +has nontrivial shift state, or zero if the encoding is stateless. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br mbtowc () +t} thread safety mt-unsafe race +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh notes +the behavior of +.br mbtowc () +depends on the +.b lc_ctype +category of the +current locale. +.pp +this function is not multithread safe. +the function +.br mbrtowc (3) +provides +a better interface to the same functionality. +.sh see also +.br mb_cur_max (3), +.br mblen (3), +.br mbrtowc (3), +.br mbstowcs (3), +.br wcstombs (3), +.br wctomb (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/symlink.2 + +.\" copyright (c) 1983, 1991 the regents of the university of california. +.\" all rights reserved. +.\" +.\" %%%license_start(bsd_4_clause_ucb) +.\" redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. all advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" this product includes software developed by the university of +.\" california, berkeley and its contributors. +.\" 4. neither the name of the university nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" this software is provided by the regents and contributors ``as is'' and +.\" any express or implied warranties, including, but not limited to, the +.\" implied warranties of merchantability and fitness for a particular purpose +.\" are disclaimed. in no event shall the regents or contributors be liable +.\" for any direct, indirect, incidental, special, exemplary, or consequential +.\" damages (including, but not limited to, procurement of substitute goods +.\" or services; loss of use, data, or profits; or business interruption) +.\" however caused and on any theory of liability, whether in contract, strict +.\" liability, or tort (including negligence or otherwise) arising in any way +.\" out of the use of this software, even if advised of the possibility of +.\" such damage. +.\" %%%license_end +.\" +.\" @(#)truncate.2 6.9 (berkeley) 3/10/91 +.\" +.\" modified 1993-07-24 by rik faith +.\" modified 1996-10-22 by eric s. raymond +.\" modified 1998-12-21 by andries brouwer +.\" modified 2002-01-07 by michael kerrisk +.\" modified 2002-04-06 by andries brouwer +.\" modified 2004-06-23 by michael kerrisk +.\" +.th truncate 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +truncate, ftruncate \- truncate a file to a specified length +.sh synopsis +.nf +.b #include +.pp +.bi "int truncate(const char *" path ", off_t " length ); +.bi "int ftruncate(int " fd ", off_t " length ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br truncate (): +.nf + _xopen_source >= 500 +.\" || _xopen_source && _xopen_source_extended + || /* since glibc 2.12: */ _posix_c_source >= 200809l + || /* glibc <= 2.19: */ _bsd_source +.fi +.pp +.br ftruncate (): +.nf + _xopen_source >= 500 +.\" || _xopen_source && _xopen_source_extended + || /* since glibc 2.3.5: */ _posix_c_source >= 200112l + || /* glibc <= 2.19: */ _bsd_source +.fi +.sh description +the +.br truncate () +and +.br ftruncate () +functions cause the regular file named by +.i path +or referenced by +.i fd +to be truncated to a size of precisely +.i length +bytes. +.pp +if the file previously was larger than this size, the extra data is lost. +if the file previously was shorter, it is extended, and +the extended part reads as null bytes (\(aq\e0\(aq). +.pp +the file offset is not changed. +.pp +if the size changed, then the st_ctime and st_mtime fields +(respectively, time of last status change and +time of last modification; see +.br inode (7)) +for the file are updated, +and the set-user-id and set-group-id mode bits may be cleared. +.pp +with +.br ftruncate (), +the file must be open for writing; with +.br truncate (), +the file must be writable. +.sh return value +on success, zero is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +for +.br truncate (): +.tp +.b eacces +search permission is denied for a component of the path prefix, +or the named file is not writable by the user. +(see also +.br path_resolution (7).) +.tp +.b efault +the argument +.i path +points outside the process's allocated address space. +.tp +.b efbig +the argument +.i length +is larger than the maximum file size. (xsi) +.tp +.b eintr +while blocked waiting to complete, +the call was interrupted by a signal handler; see +.br fcntl (2) +and +.br signal (7). +.tp +.b einval +the argument +.i length +is negative or larger than the maximum file size. +.tp +.b eio +an i/o error occurred updating the inode. +.tp +.b eisdir +the named file is a directory. +.tp +.b eloop +too many symbolic links were encountered in translating the pathname. +.tp +.b enametoolong +a component of a pathname exceeded 255 characters, +or an entire pathname exceeded 1023 characters. +.tp +.b enoent +the named file does not exist. +.tp +.b enotdir +a component of the path prefix is not a directory. +.tp +.b eperm +.\" this happens for at least msdos and vfat filesystems +.\" on kernel 2.6.13 +the underlying filesystem does not support extending +a file beyond its current size. +.tp +.b eperm +the operation was prevented by a file seal; see +.br fcntl (2). +.tp +.b erofs +the named file resides on a read-only filesystem. +.tp +.b etxtbsy +the file is an executable file that is being executed. +.pp +for +.br ftruncate () +the same errors apply, but instead of things that can be wrong with +.ir path , +we now have things that can be wrong with the file descriptor, +.ir fd : +.tp +.b ebadf +.i fd +is not a valid file descriptor. +.tp +.br ebadf " or " einval +.i fd +is not open for writing. +.tp +.b einval +.i fd +does not reference a regular file or a posix shared memory object. +.tp +.br einval " or " ebadf +the file descriptor +.i fd +is not open for writing. +posix permits, and portable applications should handle, +either error for this case. +(linux produces +.br einval .) +.sh conforming to +posix.1-2001, posix.1-2008, +4.4bsd, svr4 (these calls first appeared in 4.2bsd). +.\" posix.1-1996 has +.\" .br ftruncate (). +.\" posix.1-2001 also has +.\" .br truncate (), +.\" as an xsi extension. +.\" .lp +.\" svr4 documents additional +.\" .br truncate () +.\" error conditions emfile, emultihp, enfile, enolink. svr4 documents for +.\" .br ftruncate () +.\" an additional eagain error condition. +.sh notes +.br ftruncate () +can also be used to set the size of a posix shared memory object; see +.br shm_open (3). +.pp +the details in description are for xsi-compliant systems. +for non-xsi-compliant systems, the posix standard allows +two behaviors for +.br ftruncate () +when +.i length +exceeds the file length +(note that +.br truncate () +is not specified at all in such an environment): +either returning an error, or extending the file. +like most unix implementations, linux follows the xsi requirement +when dealing with native filesystems. +however, some nonnative filesystems do not permit +.br truncate () +and +.br ftruncate () +to be used to extend a file beyond its current length: +a notable example on linux is vfat. +.\" at the very least: osf/1, solaris 7, and freebsd conform, mtk, jan 2002 +.pp +the original linux +.br truncate () +and +.br ftruncate () +system calls were not designed to handle large file offsets. +consequently, linux 2.4 added +.br truncate64 () +and +.br ftruncate64 () +system calls that handle large files. +however, these details can be ignored by applications using glibc, whose +wrapper functions transparently employ the more recent system calls +where they are available. +.pp +on some 32-bit architectures, +the calling signature for these system calls differ, +for the reasons described in +.br syscall (2). +.sh bugs +a header file bug in glibc 2.12 meant that the minimum value of +.\" http://sourceware.org/bugzilla/show_bug.cgi?id=12037 +.br _posix_c_source +required to expose the declaration of +.br ftruncate () +was 200809l instead of 200112l. +this has been fixed in later glibc versions. +.sh see also +.br truncate (1), +.br open (2), +.br stat (2), +.br path_resolution (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/strdup.3 + +.so man3/creal.3 + +.so man3/program_invocation_name.3 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sat jul 24 18:11:47 1993 by rik faith (faith@cs.unc.edu) +.\" 2007-06-15, marc boyer + mtk +.\" improve discussion of strncat(). +.th strcat 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +strcat, strncat \- concatenate two strings +.sh synopsis +.nf +.b #include +.pp +.bi "char *strcat(char *restrict " dest ", const char *restrict " src ); +.bi "char *strncat(char *restrict " dest ", const char *restrict " src \ +", size_t " n ); +.fi +.sh description +the +.br strcat () +function appends the +.i src +string to the +.i dest +string, +overwriting the terminating null byte (\(aq\e0\(aq) at the end of +.ir dest , +and then adds a terminating null byte. +the strings may not overlap, and the +.i dest +string must have +enough space for the result. +if +.i dest +is not large enough, program behavior is unpredictable; +.ir "buffer overruns are a favorite avenue for attacking secure programs" . +.pp +the +.br strncat () +function is similar, except that +.ip * 3 +it will use at most +.i n +bytes from +.ir src ; +and +.ip * +.i src +does not need to be null-terminated if it contains +.i n +or more bytes. +.pp +as with +.br strcat (), +the resulting string in +.i dest +is always null-terminated. +.pp +if +.ir src +contains +.i n +or more bytes, +.br strncat () +writes +.i n+1 +bytes to +.i dest +.ri ( n +from +.i src +plus the terminating null byte). +therefore, the size of +.i dest +must be at least +.ir "strlen(dest)+n+1" . +.pp +a simple implementation of +.br strncat () +might be: +.pp +.in +4n +.ex +char * +strncat(char *dest, const char *src, size_t n) +{ + size_t dest_len = strlen(dest); + size_t i; + + for (i = 0 ; i < n && src[i] != \(aq\e0\(aq ; i++) + dest[dest_len + i] = src[i]; + dest[dest_len + i] = \(aq\e0\(aq; + + return dest; +} +.ee +.in +.sh return value +the +.br strcat () +and +.br strncat () +functions return a pointer to the resulting string +.ir dest . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br strcat (), +.br strncat () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c89, c99, svr4, 4.3bsd. +.sh notes +some systems (the bsds, solaris, and others) provide the following function: +.pp + size_t strlcat(char *dest, const char *src, size_t size); +.pp +this function appends the null-terminated string +.i src +to the string +.ir dest , +copying at most +.ir "size\-strlen(dest)\-1" +from +.ir src , +and adds a terminating null byte to the result, +.i unless +.ir size +is less than +.ir strlen(dest) . +this function fixes the buffer overrun problem of +.br strcat (), +but the caller must still handle the possibility of data loss if +.i size +is too small. +the function returns the length of the string +.br strlcat () +tried to create; if the return value is greater than or equal to +.ir size , +data loss occurred. +if data loss matters, the caller +.i must +either check the arguments before the call, or test the function return value. +.br strlcat () +is not present in glibc and is not standardized by posix, +.\" https://lwn.net/articles/506530/ +but is available on linux via the +.ir libbsd +library. +.\" +.sh examples +because +.br strcat () +and +.br strncat () +must find the null byte that terminates the string +.i dest +using a search that starts at the beginning of the string, +the execution time of these functions +scales according to the length of the string +.ir dest . +this can be demonstrated by running the program below. +(if the goal is to concatenate many strings to one target, +then manually copying the bytes from each source string +while maintaining a pointer to the end of the target string +will provide better performance.) +.\" +.ss program source +\& +.ex +#include +#include +#include +#include + +int +main(int argc, char *argv[]) +{ +#define lim 4000000 + char p[lim + 1]; /* +1 for terminating null byte */ + time_t base; + + base = time(null); + p[0] = \(aq\e0\(aq; + + for (int j = 0; j < lim; j++) { + if ((j % 10000) == 0) + printf("%d %jd\en", j, (intmax_t) (time(null) \- base)); + strcat(p, "a"); + } +} +.ee +.\" +.sh see also +.br bcopy (3), +.br memccpy (3), +.br memcpy (3), +.br strcpy (3), +.br string (3), +.br strncpy (3), +.br wcscat (3), +.br wcsncat (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de) +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under gpl +.\" %%%license_end +.\" +.th ccosh 3 2021-03-22 "" "linux programmer's manual" +.sh name +ccosh, ccoshf, ccoshl \- complex hyperbolic cosine +.sh synopsis +.nf +.b #include +.pp +.bi "double complex ccosh(double complex " z ");" +.bi "float complex ccoshf(float complex " z ");" +.bi "long double complex ccoshl(long double complex " z ");" +.pp +link with \fi\-lm\fp. +.fi +.sh description +these functions calculate the complex hyperbolic cosine of +.ir z . +.pp +the complex hyperbolic cosine function is defined as: +.pp +.nf + ccosh(z) = (exp(z)+exp(\-z))/2 +.fi +.sh versions +these functions first appeared in glibc in version 2.1. +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.sh see also +.br cabs (3), +.br cacosh (3), +.br csinh (3), +.br ctanh (3), +.br complex (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" %%%license_start(public_domain) +.\" this text is in the public domain. +.\" %%%license_end +.\" +.th nfsservctl 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +nfsservctl \- syscall interface to kernel nfs daemon +.sh synopsis +.nf +.b #include +.pp +.bi "long nfsservctl(int " cmd ", struct nfsctl_arg *" argp , +.bi " union nfsctl_res *" resp ); +.fi +.sh description +.ir note : +since linux 3.1, this system call no longer exists. +it has been replaced by a set of files in the +.i nfsd +filesystem; see +.br nfsd (7). +.pp +.in +4n +.ex +/* + * these are the commands understood by nfsctl(). + */ +#define nfsctl_svc 0 /* this is a server process. */ +#define nfsctl_addclient 1 /* add an nfs client. */ +#define nfsctl_delclient 2 /* remove an nfs client. */ +#define nfsctl_export 3 /* export a filesystem. */ +#define nfsctl_unexport 4 /* unexport a filesystem. */ +#define nfsctl_ugidupdate 5 /* update a client\(aqs uid/gid map + (only in linux 2.4.x and earlier). */ +#define nfsctl_getfh 6 /* get a file handle (used by mountd) + (only in linux 2.4.x and earlier). */ + +struct nfsctl_arg { + int ca_version; /* safeguard */ + union { + struct nfsctl_svc u_svc; + struct nfsctl_client u_client; + struct nfsctl_export u_export; + struct nfsctl_uidmap u_umap; + struct nfsctl_fhparm u_getfh; + unsigned int u_debug; + } u; +} + +union nfsctl_res { + struct knfs_fh cr_getfh; + unsigned int cr_debug; +}; +.ee +.in +.sh return value +on success, zero is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh versions +this system call was removed from the linux kernel in version 3.1. +library support was removed from glibc in version 2.28. +.sh conforming to +this call is linux-specific. +.sh see also +.br nfsd (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2015 by michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" +.th nptl 7 2015-08-08 "linux" "linux programmer's manual" +.sh name +nptl \- native posix threads library +.sh description +nptl (native posix threads library) +is the gnu c library posix threads implementation that is used on modern +linux systems. +.\" +.ss nptl and signals +nptl makes internal use of the first two real-time signals +(signal numbers 32 and 33). +one of these signals is used to support thread cancellation and posix timers +(see +.br timer_create (2)); +the other is used as part of a mechanism that ensures all threads in +a process always have the same uids and gids, as required by posix. +these signals cannot be used in applications. +.pp +to prevent accidental use of these signals in applications, +which might interfere with the operation of the nptl implementation, +various glibc library functions and system call wrapper functions +attempt to hide these signals from applications, +as follows: +.ip * 3 +.b sigrtmin +is defined with the value 34 (rather than 32). +.ip * +the +.br sigwaitinfo (2), +.br sigtimedwait (2), +and +.br sigwait (3) +interfaces silently ignore requests to wait for these two signals +if they are specified in the signal set argument of these calls. +.ip * +the +.br sigprocmask (2) +and +.br pthread_sigmask (3) +interfaces silently ignore attempts to block these two signals. +.ip * +the +.br sigaction (2), +.br pthread_kill (3), +and +.br pthread_sigqueue (3) +interfaces fail with the error +.b einval +(indicating an invalid signal number) if these signals are specified. +.ip * +.br sigfillset (3) +does not include these two signals when it creates a full signal set. +.\" +.ss nptl and process credential changes +at the linux kernel level, +credentials (user and group ids) are a per-thread attribute. +however, posix requires that all of the posix threads in a process +have the same credentials. +to accommodate this requirement, +the nptl implementation wraps all of the system calls that +change process credentials with functions that, +in addition to invoking the underlying system call, +arrange for all other threads in the process to also change their credentials. +.pp +the implementation of each of these system calls involves the use of +a real-time signal that is sent (using +.br tgkill (2)) +to each of the other threads that must change its credentials. +before sending these signals, the thread that is changing credentials +saves the new credential(s) and records the system call being employed +in a global buffer. +a signal handler in the receiving thread(s) fetches this information and +then uses the same system call to change its credentials. +.pp +wrapper functions employing this technique are provided for +.br setgid (2), +.br setuid (2), +.br setegid (2), +.br seteuid (2), +.br setregid (2), +.br setreuid (2), +.br setresgid (2), +.br setresuid (2), +and +.br setgroups (2). +.\" fixme . +.\" maybe say something about vfork() not being serialized wrt set*id() apis? +.\" https://sourceware.org/bugzilla/show_bug.cgi?id=14749 +.sh conforming to +for details of the conformance of nptl to the posix standard, see +.br pthreads (7). +.sh notes +posix says +.\" see posix.1-2008 specification of pthread_mutexattr_init() +that any thread in any process with access to the memory +containing a process-shared +.rb ( pthread_process_shared ) +mutex can operate on that mutex. +however, on 64-bit x86 systems, the mutex definition for x86-64 +is incompatible with the mutex definition for i386, +.\" see sysdeps/x86/bits/pthreadtypes.h +meaning that 32-bit and 64-bit binaries can't share mutexes on x86-64 systems. +.sh see also +.br credentials (7), +.br pthreads (7), +.br signal (7), +.br standards (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1992 drew eckhardt (drew@cs.colorado.edu), march 28, 1992 +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified by michael haardt +.\" modified 1993-07-24 by rik faith +.\" modified 1995-07-22 by michael chastain +.\" modified 1995-07-23 by aeb +.\" modified 1996-10-22 by eric s. raymond +.\" modified 1998-09-08 by aeb +.\" modified 2004-06-17 by michael kerrisk +.\" modified 2004-10-10 by aeb +.\" 2004-12-14 mtk, anand kumria: added new errors +.\" 2007-06-22 ivana varekova , mtk +.\" update text describing limit on number of swap files. +.\" +.\" fixme linux 3.11 added swap_flag_discard_once and swap_flag_discard_pages +.\" commit dcf6b7ddd7df8965727746f89c59229b23180e5a +.\" author: rafael aquini +.\" date: wed jul 3 15:02:46 2013 -0700 +.\" +.th swapon 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +swapon, swapoff \- start/stop swapping to file/device +.sh synopsis +.nf +.b #include +.pp +.bi "int swapon(const char *" path ", int " swapflags ); +.bi "int swapoff(const char *" path ); +.fi +.sh description +.br swapon () +sets the swap area to the file or block device specified by +.ir path . +.br swapoff () +stops swapping to the file or block device specified by +.ir path . +.pp +if the +.b swap_flag_prefer +flag is specified in the +.br swapon () +.i swapflags +argument, the new swap area will have a higher priority than default. +the priority is encoded within +.i swapflags +as: +.pp +.in +4n +.ex +.i "(prio << swap_flag_prio_shift) & swap_flag_prio_mask" +.ee +.in +.pp +if the +.b swap_flag_discard +flag is specified in the +.br swapon () +.i swapflags +argument, freed swap pages will be discarded before they are reused, +if the swap device supports the discard or trim operation. +(this may improve performance on some solid state devices, +but often it does not.) +see also notes. +.pp +these functions may be used only by a privileged process (one having the +.b cap_sys_admin +capability). +.ss priority +each swap area has a priority, either high or low. +the default priority is low. +within the low-priority areas, +newer areas are even lower priority than older areas. +.pp +all priorities set with +.i swapflags +are high-priority, higher than default. +they may have any nonnegative value chosen by the caller. +higher numbers mean higher priority. +.pp +swap pages are allocated from areas in priority order, +highest priority first. +for areas with different priorities, +a higher-priority area is exhausted before using a lower-priority area. +if two or more areas have the same priority, +and it is the highest priority available, +pages are allocated on a round-robin basis between them. +.pp +as of linux 1.3.6, the kernel usually follows these rules, +but there are exceptions. +.sh return value +on success, zero is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b ebusy +(for +.br swapon ()) +the specified +.i path +is already being used as a swap area. +.tp +.b einval +the file +.i path +exists, but refers neither to a regular file nor to a block device; +.tp +.b einval +.rb ( swapon ()) +the indicated path does not contain a valid swap signature or +resides on an in-memory filesystem such as +.br tmpfs (5). +.tp +.br einval " (since linux 3.4)" +.rb ( swapon ()) +an invalid flag value was specified in +.ir swapflags . +.tp +.b einval +.rb ( swapoff ()) +.i path +is not currently a swap area. +.tp +.b enfile +the system-wide limit on the total number of open files has been reached. +.tp +.b enoent +the file +.i path +does not exist. +.tp +.b enomem +the system has insufficient memory to start swapping. +.tp +.b eperm +the caller does not have the +.b cap_sys_admin +capability. +alternatively, the maximum number of swap files are already in use; +see notes below. +.sh conforming to +these functions are linux-specific and should not be used in programs +intended to be portable. +the second +.i swapflags +argument was introduced in linux 1.3.2. +.sh notes +the partition or path must be prepared with +.br mkswap (8). +.pp +there is an upper limit on the number of swap files that may be used, +defined by the kernel constant +.br max_swapfiles . +before kernel 2.4.10, +.b max_swapfiles +has the value 8; +since kernel 2.4.10, it has the value 32. +since kernel 2.6.18, the limit is decreased by 2 (thus: 30) +if the kernel is built with the +.b config_migration +option +(which reserves two swap table entries for the page migration features of +.br mbind (2) +and +.br migrate_pages (2)). +since kernel 2.6.32, the limit is further decreased by 1 +if the kernel is built with the +.b config_memory_failure +option. +.pp +discard of swap pages was introduced in kernel 2.6.29, +then made conditional +on the +.b swap_flag_discard +flag in kernel 2.6.36, +.\" to be precise: 2.6.35.5 +which still discards the +entire swap area when +.br swapon () +is called, even if that flag bit is not set. +.sh see also +.br mkswap (8), +.br swapoff (8), +.br swapon (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/circleq.3 + +.so man3/lgamma.3 + +.so man3/resolver.3 + +.so man3/significand.3 + +.\" copyright (c) 2009 linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th libc 7 2016-12-12 "linux" "linux programmer's manual" +.sh name +libc \- overview of standard c libraries on linux +.sh description +the term "libc" is commonly used as a shorthand for +the "standard c library", +a library of standard functions that can be used by all c programs +(and sometimes by programs in other languages). +because of some history (see below), use of the term "libc" +to refer to the standard c library is somewhat ambiguous on linux. +.ss glibc +by far the most widely used c library on linux is the gnu c library +.ur http://www.gnu.org\:/software\:/libc/ +.ue , +often referred to as +.ir glibc . +this is the c library that is nowadays used in all +major linux distributions. +it is also the c library whose details are documented +in the relevant pages of the +.i man-pages +project (primarily in section 3 of the manual). +documentation of glibc is also available in the glibc manual, +available via the command +.ir "info libc" . +release 1.0 of glibc was made in september 1992. +(there were earlier 0.x releases.) +the next major release of glibc was 2.0, at the beginning of 1997. +.pp +the pathname +.i /lib/libc.so.6 +(or something similar) is normally a symbolic link that +points to the location of the glibc library, +and executing this pathname will cause glibc to display +various information about the version installed on your system. +.ss linux libc +in the early to mid 1990s, there was for a while +.ir "linux libc" , +a fork of glibc 1.x created by linux developers who felt that glibc +development at the time was not sufficing for the needs of linux. +often, this library was referred to (ambiguously) as just "libc". +linux libc released major versions 2, 3, 4, and 5, +as well as many minor versions of those releases. +linux libc4 was the last version to use the a.out binary format, +and the first version to provide (primitive) shared library support. +linux libc 5 was the first version to support the elf binary format; +this version used the shared library soname +.ir libc.so.5 . +for a while, +linux libc was the standard c library in many linux distributions. +.pp +however, notwithstanding the original motivations of the linux libc effort, +by the time glibc 2.0 was released (in 1997), +it was clearly superior to linux libc, +and all major linux distributions that had been using linux libc +soon switched back to glibc. +to avoid any confusion with linux libc versions, +glibc 2.0 and later used the shared library soname +.ir libc.so.6 . +.pp +since the switch from linux libc to glibc 2.0 occurred long ago, +.i man-pages +no longer takes care to document linux libc details. +nevertheless, the history is visible in vestiges of information +about linux libc that remain in a few manual pages, +in particular, references to +.ir libc4 +and +.ir libc5 . +.ss other c libraries +there are various other less widely used c libraries for linux. +these libraries are generally smaller than glibc, +both in terms of features and memory footprint, +and often intended for building small binaries, +perhaps targeted at development for embedded linux systems. +among such libraries are +.ur http://www.uclibc.org/ +.i uclibc +.ue , +.ur http://www.fefe.de/dietlibc/ +.i dietlibc +.ue , +and +.ur http://www.musl\-libc.org/ +.i "musl libc" +.ue . +details of these libraries are covered by the +.i man-pages +project, where they are known. +.sh see also +.br syscalls (2), +.br getauxval (3), +.br proc (5), +.br feature_test_macros (7), +.br man\-pages (7), +.br standards (7), +.br vdso (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/scanf.3 + +.\" copyright (c) 1983, 1991 the regents of the university of california. +.\" all rights reserved. +.\" +.\" %%%license_start(bsd_4_clause_ucb) +.\" redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. all advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" this product includes software developed by the university of +.\" california, berkeley and its contributors. +.\" 4. neither the name of the university nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" this software is provided by the regents and contributors ``as is'' and +.\" any express or implied warranties, including, but not limited to, the +.\" implied warranties of merchantability and fitness for a particular purpose +.\" are disclaimed. in no event shall the regents or contributors be liable +.\" for any direct, indirect, incidental, special, exemplary, or consequential +.\" damages (including, but not limited to, procurement of substitute goods +.\" or services; loss of use, data, or profits; or business interruption) +.\" however caused and on any theory of liability, whether in contract, strict +.\" liability, or tort (including negligence or otherwise) arising in any way +.\" out of the use of this software, even if advised of the possibility of +.\" such damage. +.\" %%%license_end +.\" +.\" @(#)getpeername.2 6.5 (berkeley) 3/10/91 +.\" +.\" modified sat jul 24 16:37:50 1993 by rik faith +.\" modified thu jul 30 14:37:50 1993 by martin schulze +.\" modified sun mar 28 21:26:46 1999 by andries brouwer +.\" modified 17 jul 2002, michael kerrisk +.\" added 'socket' to name, so that "man -k socket" will show this page. +.\" +.th getpeername 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +getpeername \- get name of connected peer socket +.sh synopsis +.nf +.b #include +.pp +.bi "int getpeername(int " sockfd ", struct sockaddr *restrict " addr , +.bi " socklen_t *restrict " addrlen ); +.fi +.sh description +.br getpeername () +returns the address of the peer connected to the socket +.ir sockfd , +in the buffer pointed to by +.ir addr . +the +.i addrlen +argument should be initialized to indicate the amount of space pointed to +by +.ir addr . +on return it contains the actual size of the name returned (in bytes). +the name is truncated if the buffer provided is too small. +.pp +the returned address is truncated if the buffer provided is too small; +in this case, +.i addrlen +will return a value greater than was supplied to the call. +.sh return value +on success, zero is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b ebadf +the argument +.i sockfd +is not a valid file descriptor. +.tp +.b efault +the +.i addr +argument points to memory not in a valid part of the +process address space. +.tp +.b einval +.i addrlen +is invalid (e.g., is negative). +.tp +.b enobufs +insufficient resources were available in the system +to perform the operation. +.tp +.b enotconn +the socket is not connected. +.tp +.b enotsock +the file descriptor +.i sockfd +does not refer to a socket. +.sh conforming to +posix.1-2001, posix.1-2008, svr4, 4.4bsd +.rb ( getpeername () +first appeared in 4.2bsd). +.sh notes +for background on the +.i socklen_t +type, see +.br accept (2). +.pp +for stream sockets, once a +.br connect (2) +has been performed, either socket can call +.br getpeername () +to obtain the address of the peer socket. +on the other hand, datagram sockets are connectionless. +calling +.br connect (2) +on a datagram socket merely sets the peer address for outgoing +datagrams sent with +.br write (2) +or +.br recv (2). +the caller of +.br connect (2) +can use +.br getpeername () +to obtain the peer address that it earlier set for the socket. +however, the peer socket is unaware of this information, and calling +.br getpeername () +on the peer socket will return no useful information (unless a +.br connect (2) +call was also executed on the peer). +note also that the receiver of a datagram can obtain +the address of the sender when using +.br recvfrom (2). +.sh see also +.br accept (2), +.br bind (2), +.br getsockname (2), +.br ip (7), +.br socket (7), +.br unix (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/frexp.3 + +.\" copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de) +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under gpl +.\" %%%license_end +.\" +.th creal 3 2021-03-22 "" "linux programmer's manual" +.sh name +creal, crealf, creall \- get real part of a complex number +.sh synopsis +.nf +.b #include +.pp +.bi "double creal(double complex " z ); +.bi "float crealf(float complex " z ); +.bi "long double creall(long double complex " z ); +.pp +link with \fi\-lm\fp. +.fi +.sh description +these functions return the real part of the complex number +.ir z . +.pp +one has: +.pp +.nf + z = creal(z) + i * cimag(z) +.fi +.sh versions +these functions first appeared in glibc in version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br creal (), +.br crealf (), +.br creall () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.sh notes +the gcc supports also __real__. +that is a gnu extension. +.sh see also +.br cabs (3), +.br cimag (3), +.br complex (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sun jul 25 10:54:31 1993, rik faith (faith@cs.unc.edu) +.th string 3 2021-03-22 "" "linux programmer's manual" +.sh name +stpcpy, strcasecmp, strcat, strchr, strcmp, strcoll, strcpy, strcspn, +strdup, strfry, strlen, strncat, strncmp, strncpy, strncasecmp, strpbrk, +strrchr, strsep, strspn, strstr, strtok, strxfrm, index, rindex +\- string operations +.sh synopsis +.b #include +.tp +.bi "int strcasecmp(const char *" s1 ", const char *" s2 ); +compare the strings +.i s1 +and +.i s2 +ignoring case. +.tp +.bi "int strncasecmp(const char *" s1 ", const char *" s2 ", size_t " n ); +compare the first +.i n +bytes of the strings +.i s1 +and +.i s2 +ignoring case. +.tp +.bi "char *index(const char *" s ", int " c ); +return a pointer to the first occurrence of the character +.i c +in the string +.ir s . +.tp +.bi "char *rindex(const char *" s ", int " c ); +return a pointer to the last occurrence of the character +.i c +in the string +.ir s . +.tp +.b #include +.tp +.bi "char *stpcpy(char *restrict " dest ", const char *restrict " src ); +copy a string from +.i src +to +.ir dest , +returning a pointer to the end of the resulting string at +.ir dest . +.tp +.bi "char *strcat(char *restrict " dest ", const char *restrict " src ); +append the string +.i src +to the string +.ir dest , +returning a pointer +.ir dest . +.tp +.bi "char *strchr(const char *" s ", int " c ); +return a pointer to the first occurrence of the character +.i c +in the string +.ir s . +.tp +.bi "int strcmp(const char *" s1 ", const char *" s2 ); +compare the strings +.i s1 +with +.ir s2 . +.tp +.bi "int strcoll(const char *" s1 ", const char *" s2 ); +compare the strings +.i s1 +with +.i s2 +using the current locale. +.tp +.bi "char *strcpy(char *restrict " dest ", const char *restrict " src ); +copy the string +.i src +to +.ir dest , +returning a pointer to the start of +.ir dest . +.tp +.bi "size_t strcspn(const char *" s ", const char *" reject ); +calculate the length of the initial segment of the string +.i s +which does not contain any of bytes in the string +.ir reject , +.tp +.bi "char *strdup(const char *" s ); +return a duplicate of the string +.i s +in memory allocated using +.br malloc (3). +.tp +.bi "char *strfry(char *" string ); +randomly swap the characters in +.ir string . +.tp +.bi "size_t strlen(const char *" s ); +return the length of the string +.ir s . +.tp +.bi "char *strncat(char *restrict " dest ", const char *restrict " src \ +", size_t " n ); +append at most +.i n +bytes from the string +.i src +to the string +.ir dest , +returning a pointer to +.ir dest . +.tp +.bi "int strncmp(const char *" s1 ", const char *" s2 ", size_t " n ); +compare at most +.i n +bytes of the strings +.i s1 +and +.ir s2 . +.tp +.bi "char *strncpy(char *restrict " dest ", const char *restrict " src \ +", size_t " n ); +copy at most +.i n +bytes from string +.i src +to +.ir dest , +returning a pointer to the start of +.ir dest . +.tp +.bi "char *strpbrk(const char *" s ", const char *" accept ); +return a pointer to the first occurrence in the string +.i s +of one of the bytes in the string +.ir accept . +.tp +.bi "char *strrchr(const char *" s ", int " c ); +return a pointer to the last occurrence of the character +.i c +in the string +.ir s . +.tp +.bi "char *strsep(char **restrict " stringp ", const char *restrict " delim ); +extract the initial token in +.i stringp +that is delimited by one of the bytes in +.ir delim . +.tp +.bi "size_t strspn(const char *" s ", const char *" accept ); +calculate the length of the starting segment in the string +.i s +that consists entirely of bytes in +.ir accept . +.tp +.bi "char *strstr(const char *" haystack ", const char *" needle ); +find the first occurrence of the substring +.i needle +in the string +.ir haystack , +returning a pointer to the found substring. +.tp +.bi "char *strtok(char *restrict " s ", const char *restrict " delim ); +extract tokens from the string +.i s +that are delimited by one of the bytes in +.ir delim . +.tp +.bi "size_t strxfrm(char *restrict " dst ", const char *restrict " src \ +", size_t " n ); +transforms +.i src +to the current locale and copies the first +.i n +bytes to +.ir dst . +.sh description +the string functions perform operations on null-terminated +strings. +see the individual man pages for descriptions of each function. +.sh see also +.br bstring (3), +.br index (3), +.br rindex (3), +.br stpcpy (3), +.br strcasecmp (3), +.br strcat (3), +.br strchr (3), +.br strcmp (3), +.br strcoll (3), +.br strcpy (3), +.br strcspn (3), +.br strdup (3), +.br strfry (3), +.br strlen (3), +.br strncasecmp (3), +.br strncat (3), +.br strncmp (3), +.br strncpy (3), +.br strpbrk (3), +.br strrchr (3), +.br strsep (3), +.br strspn (3), +.br strstr (3), +.br strtok (3), +.br strxfrm (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2014 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th newlocale 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +newlocale, freelocale \- create, modify, and free a locale object +.sh synopsis +.nf +.b #include +.pp +.bi "locale_t newlocale(int " category_mask ", const char *" locale , +.bi " locale_t " base ); +.bi "void freelocale(locale_t " locobj ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br newlocale (), +.br freelocale (): +.nf + since glibc 2.10: + _xopen_source >= 700 + before glibc 2.10: + _gnu_source +.fi +.sh description +the +.br newlocale () +function creates a new locale object, or modifies an existing object, +returning a reference to the new or modified object as the function result. +whether the call creates a new object or modifies an existing object +is determined by the value of +.ir base : +.ip * 3 +if +.i base +is +.ir "(locale_t)\ 0" , +a new object is created. +.ip * +if +.i base +refers to valid existing locale object +(i.e., an object returned by a previous call to +.br newlocale () +or +.br duplocale (3)), +then that object is modified by the call. +if the call is successful, the contents of +.i base +are unspecified (in particular, the object referred to by +.i base +may be freed, and a new object created). +therefore, the caller should ensure that it stops using +.i base +before the call to +.br newlocale (), +and should subsequently refer to the modified object via the +reference returned as the function result. +if the call fails, the contents of +.i base +remain valid and unchanged. +.pp +if +.i base +is the special locale object +.br lc_global_locale +(see +.br duplocale (3)), +or is not +.ir "(locale_t)\ 0" +and is not a valid locale object handle, +the behavior is undefined. +.pp +the +.i category_mask +argument is a bit mask that specifies the locale categories +that are to be set in a newly created locale object +or modified in an existing object. +the mask is constructed by a bitwise or of the constants +.br lc_address_mask , +.br lc_ctype_mask , +.br lc_collate_mask , +.br lc_identification_mask , +.br lc_measurement_mask , +.br lc_messages_mask , +.br lc_monetary_mask , +.br lc_numeric_mask , +.br lc_name_mask , +.br lc_paper_mask , +.br lc_telephone_mask , +and +.br lc_time_mask . +alternatively, the mask can be specified as +.br lc_all_mask , +which is equivalent to oring all of the preceding constants. +.pp +for each category specified in +.ir category_mask , +the locale data from +.i locale +will be used in the object returned by +.br newlocale (). +if a new locale object is being created, +data for all categories not specified in +.ir category_mask +is taken from the default ("posix") locale. +.pp +the following preset values of +.i locale +are defined for all categories that can be specified in +.ir category_mask : +.tp +"posix" +a minimal locale environment for c language programs. +.tp +"c" +equivalent to "posix". +.tp +"" +an implementation-defined native environment +corresponding to the values of the +.br lc_* +and +.b lang +environment variables (see +.br locale (7)). +.ss freelocale() +the +.br freelocale () +function deallocates the resources associated with +.ir locobj , +a locale object previously returned by a call to +.br newlocale () +or +.br duplocale (3). +if +.i locobj +is +.br lc_global_locale +or is not valid locale object handle, the results are undefined. +.pp +once a locale object has been freed, +the program should make no further use of it. +.sh return value +on success, +.br newlocale () +returns a handle that can be used in calls to +.br duplocale (3), +.br freelocale (), +and other functions that take a +.i locale_t +argument. +on error, +.br newlocale () +returns +.ir "(locale_t)\ 0", +and sets +.i errno +to indicate the error. +.sh errors +.tp +.b einval +one or more bits in +.i category_mask +do not correspond to a valid locale category. +.tp +.b einval +.i locale +is null. +.tp +.b enoent +.i locale +is not a string pointer referring to a valid locale. +.tp +.b enomem +insufficient memory to create a locale object. +.sh versions +the +.br newlocale () +and +.br freelocale () +functions first appeared in version 2.3 of the gnu c library. +.sh conforming to +posix.1-2008. +.sh notes +each locale object created by +.br newlocale () +should be deallocated using +.br freelocale (). +.sh examples +the program below takes up to two command-line arguments, +which each identify locales. +the first argument is required, and is used to set the +.b lc_numeric +category in a locale object created using +.br newlocale (). +the second command-line argument is optional; +if it is present, it is used to set the +.b lc_time +category of the locale object. +.pp +having created and initialized the locale object, +the program then applies it using +.br uselocale (3), +and then tests the effect of the locale changes by: +.ip 1. 3 +displaying a floating-point number with a fractional part. +this output will be affected by the +.b lc_numeric +setting. +in many european-language locales, +the fractional part of the number is separated from the integer part +using a comma, rather than a period. +.ip 2. +displaying the date. +the format and language of the output will be affected by the +.b lc_time +setting. +.pp +the following shell sessions show some example runs of this program. +.pp +set the +.b lc_numeric +category to +.ir fr_fr +(french): +.pp +.in +4n +.ex +$ \fb./a.out fr_fr\fp +123456,789 +fri mar 7 00:25:08 2014 +.ee +.in +.pp +set the +.b lc_numeric +category to +.ir fr_fr +(french), +and the +.b lc_time +category to +.ir it_it +(italian): +.pp +.in +4n +.ex +$ \fb./a.out fr_fr it_it\fp +123456,789 +ven 07 mar 2014 00:26:01 cet +.ee +.in +.pp +specify the +.b lc_time +setting as an empty string, +which causes the value to be taken from environment variable settings +(which, here, specify +.ir mi_nz , +new zealand māori): +.pp +.in +4n +.ex +$ lc_all=mi_nz ./a.out fr_fr "" +123456,789 +te paraire, te 07 o poutū\-te\-rangi, 2014 00:38:44 cet +.ee +.in +.ss program source +.ex +#define _xopen_source 700 +#include +#include +#include +#include + +#define errexit(msg) do { perror(msg); exit(exit_failure); \e + } while (0) + +int +main(int argc, char *argv[]) +{ + char buf[100]; + time_t t; + size_t s; + struct tm *tm; + locale_t loc, nloc; + + if (argc < 2) { + fprintf(stderr, "usage: %s locale1 [locale2]\en", argv[0]); + exit(exit_failure); + } + + /* create a new locale object, taking the lc_numeric settings + from the locale specified in argv[1]. */ + + loc = newlocale(lc_numeric_mask, argv[1], (locale_t) 0); + if (loc == (locale_t) 0) + errexit("newlocale"); + + /* if a second command\-line argument was specified, modify the + locale object to take the lc_time settings from the locale + specified in argv[2]. we assign the result of this newlocale() + call to \(aqnloc\(aq rather than \(aqloc\(aq, since in some cases, we might + want to preserve \(aqloc\(aq if this call fails. */ + + if (argc > 2) { + nloc = newlocale(lc_time_mask, argv[2], loc); + if (nloc == (locale_t) 0) + errexit("newlocale"); + loc = nloc; + } + + /* apply the newly created locale to this thread. */ + + uselocale(loc); + + /* test effect of lc_numeric. */ + + printf("%8.3f\en", 123456.789); + + /* test effect of lc_time. */ + + t = time(null); + tm = localtime(&t); + if (tm == null) + errexit("time"); + + s = strftime(buf, sizeof(buf), "%c", tm); + if (s == 0) + errexit("strftime"); + + printf("%s\en", buf); + + /* free the locale object. */ + + uselocale(lc_global_handle); /* so \(aqloc\(aq is no longer in use */ + freelocale(loc); + + exit(exit_success); +} +.ee +.sh see also +.br locale (1), +.br duplocale (3), +.br setlocale (3), +.br uselocale (3), +.br locale (5), +.br locale (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th gnu_get_libc_version 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +gnu_get_libc_version, gnu_get_libc_release \- get glibc version and release +.sh synopsis +.nf +.b #include +.pp +.b const char *gnu_get_libc_version(void); +.b const char *gnu_get_libc_release(void); +.fi +.sh description +the function +.br gnu_get_libc_version () +returns a string that identifies the glibc version available on the system. +.pp +the function +.br gnu_get_libc_release () +returns a string indicates the release status of the glibc version +available on the system. +this will be a string such as +.ir "stable" . +.sh versions +these functions first appeared in glibc in version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br gnu_get_libc_version (), +.br gnu_get_libc_release () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +these functions are glibc-specific. +.sh examples +when run, the program below will produce output such as the following: +.pp +.in +4n +.ex +.rb "$" " ./a.out" +gnu libc version: 2.8 +gnu libc release: stable +.ee +.in +.ss program source +\& +.ex +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + printf("gnu libc version: %s\en", gnu_get_libc_version()); + printf("gnu libc release: %s\en", gnu_get_libc_release()); + exit(exit_success); +} +.ee +.sh see also +.br confstr (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) markus kuhn, 1996, 2001 +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" 1995-11-26 markus kuhn +.\" first version written +.\" 2001-05-11 markus kuhn +.\" update +.\" +.th utf-8 7 2019-03-06 "gnu" "linux programmer's manual" +.sh name +utf-8 \- an ascii compatible multibyte unicode encoding +.sh description +the unicode 3.0 character set occupies a 16-bit code space. +the most obvious +unicode encoding (known as ucs-2) +consists of a sequence of 16-bit words. +such strings can contain\(emas part of many 16-bit characters\(embytes +such as \(aq\e0\(aq or \(aq/\(aq, which have a +special meaning in filenames and other c library function arguments. +in addition, the majority of unix tools expect ascii files and can't +read 16-bit words as characters without major modifications. +for these reasons, +ucs-2 is not a suitable external encoding of unicode +in filenames, text files, environment variables, and so on. +the iso 10646 universal character set (ucs), +a superset of unicode, occupies an even larger code +space\(em31\ bits\(emand the obvious +ucs-4 encoding for it (a sequence of 32-bit words) has the same problems. +.pp +the utf-8 encoding of unicode and ucs +does not have these problems and is the common way in which +unicode is used on unix-style operating systems. +.ss properties +the utf-8 encoding has the following nice properties: +.tp 0.2i +* +ucs +characters 0x00000000 to 0x0000007f (the classic us-ascii +characters) are encoded simply as bytes 0x00 to 0x7f (ascii +compatibility). +this means that files and strings which contain only +7-bit ascii characters have the same encoding under both +ascii +and +utf-8 . +.tp +* +all ucs characters greater than 0x7f are encoded as a multibyte sequence +consisting only of bytes in the range 0x80 to 0xfd, so no ascii +byte can appear as part of another character and there are no +problems with, for example, \(aq\e0\(aq or \(aq/\(aq. +.tp +* +the lexicographic sorting order of ucs-4 strings is preserved. +.tp +* +all possible 2^31 ucs codes can be encoded using utf-8. +.tp +* +the bytes 0xc0, 0xc1, 0xfe, and 0xff are never used in the utf-8 encoding. +.tp +* +the first byte of a multibyte sequence which represents a single non-ascii +ucs character is always in the range 0xc2 to 0xfd and indicates how long +this multibyte sequence is. +all further bytes in a multibyte sequence +are in the range 0x80 to 0xbf. +this allows easy resynchronization and +makes the encoding stateless and robust against missing bytes. +.tp +* +utf-8 encoded ucs characters may be up to six bytes long, however the +unicode standard specifies no characters above 0x10ffff, so unicode characters +can be only up to four bytes long in +utf-8. +.ss encoding +the following byte sequences are used to represent a character. +the sequence to be used depends on the ucs code number of the character: +.tp 0.4i +0x00000000 \- 0x0000007f: +.ri 0 xxxxxxx +.tp +0x00000080 \- 0x000007ff: +.ri 110 xxxxx +.ri 10 xxxxxx +.tp +0x00000800 \- 0x0000ffff: +.ri 1110 xxxx +.ri 10 xxxxxx +.ri 10 xxxxxx +.tp +0x00010000 \- 0x001fffff: +.ri 11110 xxx +.ri 10 xxxxxx +.ri 10 xxxxxx +.ri 10 xxxxxx +.tp +0x00200000 \- 0x03ffffff: +.ri 111110 xx +.ri 10 xxxxxx +.ri 10 xxxxxx +.ri 10 xxxxxx +.ri 10 xxxxxx +.tp +0x04000000 \- 0x7fffffff: +.ri 1111110 x +.ri 10 xxxxxx +.ri 10 xxxxxx +.ri 10 xxxxxx +.ri 10 xxxxxx +.ri 10 xxxxxx +.pp +the +.i xxx +bit positions are filled with the bits of the character code number in +binary representation, most significant bit first (big-endian). +only the shortest possible multibyte sequence +which can represent the code number of the character can be used. +.pp +the ucs code values 0xd800\(en0xdfff (utf-16 surrogates) as well as 0xfffe and +0xffff (ucs noncharacters) should not appear in conforming utf-8 streams. according +to rfc 3629 no point above u+10ffff should be used, which limits characters to four +bytes. +.ss example +the unicode character 0xa9 = 1010 1001 (the copyright sign) is encoded +in utf-8 as +.pp +.rs +11000010 10101001 = 0xc2 0xa9 +.re +.pp +and character 0x2260 = 0010 0010 0110 0000 (the "not equal" symbol) is +encoded as: +.pp +.rs +11100010 10001001 10100000 = 0xe2 0x89 0xa0 +.re +.ss application notes +users have to select a utf-8 locale, for example with +.pp +.rs +export lang=en_gb.utf-8 +.re +.pp +in order to activate the utf-8 support in applications. +.pp +application software that has to be aware of the used character +encoding should always set the locale with for example +.pp +.rs +setlocale(lc_ctype, "") +.re +.pp +and programmers can then test the expression +.pp +.rs +strcmp(nl_langinfo(codeset), "utf-8") == 0 +.re +.pp +to determine whether a utf-8 locale has been selected and whether +therefore all plaintext standard input and output, terminal +communication, plaintext file content, filenames, and environment +variables are encoded in utf-8. +.pp +programmers accustomed to single-byte encodings such as us-ascii or iso 8859 +have to be aware that two assumptions made so far are no longer valid +in utf-8 locales. +firstly, a single byte does not necessarily correspond any +more to a single character. +secondly, since modern terminal emulators in utf-8 +mode also support chinese, japanese, and korean +double-width characters as well as nonspacing combining characters, +outputting a single character does not necessarily advance the cursor +by one position as it did in ascii. +library functions such as +.br mbsrtowcs (3) +and +.br wcswidth (3) +should be used today to count characters and cursor positions. +.pp +the official esc sequence to switch from an iso 2022 +encoding scheme (as used for instance by vt100 terminals) to +utf-8 is esc % g +("\ex1b%g"). +the corresponding return sequence from +utf-8 to iso 2022 is esc % @ ("\ex1b%@"). +other iso 2022 sequences (such as +for switching the g0 and g1 sets) are not applicable in utf-8 mode. +.ss security +the unicode and ucs standards require that producers of utf-8 +shall use the shortest form possible, for example, producing a two-byte +sequence with first byte 0xc0 is nonconforming. +unicode 3.1 has added the requirement that conforming programs must not accept +non-shortest forms in their input. +this is for security reasons: if +user input is checked for possible security violations, a program +might check only for the ascii +version of "/../" or ";" or nul and overlook that there are many +non-ascii ways to represent these things in a non-shortest utf-8 +encoding. +.ss standards +iso/iec 10646-1:2000, unicode 3.1, rfc\ 3629, plan 9. +.\" .sh author +.\" markus kuhn +.sh see also +.br locale (1), +.br nl_langinfo (3), +.br setlocale (3), +.br charsets (7), +.br unicode (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2001 andreas dilger (adilger@turbolinux.com) +.\" and copyright (c) 2017 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th slabinfo 5 2021-03-22 "" "linux programmer's manual" +.sh name +slabinfo \- kernel slab allocator statistics +.sh synopsis +.nf +.b cat /proc/slabinfo +.fi +.sh description +frequently used objects in the linux kernel +(buffer heads, inodes, dentries, etc.) +have their own cache. +the file +.i /proc/slabinfo +gives statistics on these caches. +the following (edited) output shows an example of the +contents of this file: +.pp +.ex +$ \fbsudo cat /proc/slabinfo\fp +slabinfo \- version: 2.1 +# name ... +sigqueue 100 100 160 25 1 : tunables 0 0 0 : slabdata 4 4 0 +sighand_cache 355 405 2112 15 8 : tunables 0 0 0 : slabdata 27 27 0 +kmalloc\-8192 96 96 8192 4 8 : tunables 0 0 0 : slabdata 24 24 0 +\&... +.ee +.pp +the first line of output includes a version number, +which allows an application that is reading the file to handle changes +in the file format. +(see versions, below.) +the next line lists the names of the columns in the remaining lines. +.pp +each of the remaining lines displays information about a specified cache. +following the cache name, +the output shown in each line shows three components for each cache: +.ip * 3 +statistics +.ip * +tunables +.ip * +slabdata +.pp +the statistics are as follows: +.tp +.i active_objs +the number of objects that are currently active (i.e., in use). +.tp +.i num_objs +the total number of allocated objects +(i.e., objects that are both in use and not in use). +.tp +.i objsize +the size of objects in this slab, in bytes. +.tp +.i objperslab +the number of objects stored in each slab. +.tp +.i pagesperslab +the number of pages allocated for each slab. +.pp +the +.i tunables +entries in each line show tunable parameters for the corresponding cache. +when using the default slub allocator, there are no tunables, the +.i /proc/slabinfo +file is not writable, and the value 0 is shown in these fields. +when using the older slab allocator, +the tunables for a particular cache can be set by writing +lines of the following form to +.ir /proc/slabinfo : +.pp +.in +4n +.ex +# \fbecho \(aqname limit batchcount sharedfactor\(aq > /proc/slabinfo\fp +.ee +.in +.pp +here, +.i name +is the cache name, and +.ir limit , +.ir batchcount , +and +.ir sharedfactor +are integers defining new values for the corresponding tunables. +the +.i limit +value should be a positive value, +.i batchcount +should be a positive value that is less than or equal to +.ir limit , +and +.i sharedfactor +should be nonnegative. +if any of the specified values is invalid, +the cache settings are left unchanged. +.pp +the +.i tunables +entries in each line contain the following fields: +.tp +.i limit +the maximum number of objects that will be cached. +.\" https://lwn.net/articles/56360/ +.\" this is the limit on the number of free objects that can be stored +.\" in the per-cpu free list for this slab cache. +.tp +.i batchcount +on smp systems, this specifies the number of objects to transfer at one time +when refilling the available object list. +.\" https://lwn.net/articles/56360/ +.\" on smp systems, when we refill the available object list, instead +.\" of doing one object at a time, we do batch-count objects at a time. +.tp +.i sharedfactor +[to be documented] +.\" +.pp +the +.i slabdata +entries in each line contain the following fields: +.tp +.i active_slabs +the number of active slabs. +.tp +.i nums_slabs +the total number of slabs. +.tp +.i sharedavail +[to be documented] +.pp +note that because of object alignment and slab cache overhead, +objects are not normally packed tightly into pages. +pages with even one in-use object are considered in-use and cannot be +freed. +.pp +kernels configured with +.b config_debug_slab +will also have additional statistics fields in each line, +and the first line of the file will contain the string "(statistics)". +the statistics field include : the high water mark of active +objects; the number of times objects have been allocated; +the number of times the cache has grown (new pages added +to this cache); the number of times the cache has been +reaped (unused pages removed from this cache); and the +number of times there was an error allocating new pages +to this cache. +.\" +.\" smp systems will also have "(smp)" in the first line of +.\" output, and will have two additional columns for each slab, +.\" reporting the slab allocation policy for the cpu-local +.\" cache (to reduce the need for inter-cpu synchronization +.\" when allocating objects from the cache). +.\" the first column is the per-cpu limit: the maximum number of objects that +.\" will be cached for each cpu. +.\" the second column is the +.\" batchcount: the maximum number of free objects in the +.\" global cache that will be transferred to the per-cpu cache +.\" if it is empty, or the number of objects to be returned +.\" to the global cache if the per-cpu cache is full. +.\" +.\" if both slab cache statistics and smp are defined, there +.\" will be four additional columns, reporting the per-cpu +.\" cache statistics. +.\" the first two are the per-cpu cache +.\" allocation hit and miss counts: the number of times an +.\" object was or was not available in the per-cpu cache +.\" for allocation. +.\" the next two are the per-cpu cache free +.\" hit and miss counts: the number of times a freed object +.\" could or could not fit within the per-cpu cache limit, +.\" before flushing objects to the global cache. +.sh versions +the +.i /proc/slabinfo +file first appeared in linux 2.1.23. +the file is versioned, +and over time there have been a number of versions with different layouts: +.tp +1.0 +present throughout the linux 2.2.x kernel series. +.tp +1.1 +present in the linux 2.4.x kernel series. +.\" first appeared in 2.4.0-test3 +.tp +1.2 +a format that was briefly present in the linux 2.5 development series. +.\" from 2.5.45 to 2.5.70 +.tp +2.0 +present in linux 2.6.x kernels up to and including linux 2.6.9. +.\" first appeared in 2.5.71 +.tp +2.1 +the current format, which first appeared in linux 2.6.10. +.sh notes +only root can read and (if the kernel was configured with +.br config_slab ) +write the +.ir /proc/slabinfo +file. +.pp +the total amount of memory allocated to the slab/slub cache is shown in the +.i slab +field of +.ir /proc/meminfo . +.sh see also +.br slabtop (1) +.pp +the kernel source file +.ir documentation/vm/slub.txt +and +.ir tools/vm/slabinfo.c . +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/unlocked_stdio.3 + +.so man3/rcmd.3 + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" iso/iec 9899:1999 +.\" +.th wcslen 3 2021-08-27 "gnu" "linux programmer's manual" +.sh name +wcslen \- determine the length of a wide-character string +.sh synopsis +.nf +.b #include +.pp +.bi "size_t wcslen(const wchar_t *" s ); +.fi +.sh description +the +.br wcslen () +function is the wide-character equivalent +of the +.br strlen (3) +function. +it determines the length of the wide-character string pointed to +by +.ir s , +excluding the terminating null wide character (l\(aq\e0\(aq). +.sh return value +the +.br wcslen () +function returns the +number of wide characters in +.ir s . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br wcslen () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh notes +in cases where the input buffer may not contain +a terminating null wide character, +.br wcsnlen (3) +should be used instead. +.sh see also +.br strlen (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/semop.2 + +.so man3/xdr.3 + +.\" this page was taken from the 4.4bsd-lite cdrom (bsd license) +.\" +.\" %%%license_start(bsd_oneline_cdrom) +.\" this page was taken from the 4.4bsd-lite cdrom (bsd license) +.\" %%%license_end +.\" +.\" @(#)xdr.3n 2.2 88/08/03 4.0 rpcsrc; from 1.16 88/03/14 smi +.\" +.\" 2007-12-30, mtk, convert function prototypes to modern c syntax +.\" +.th xdr 3 2021-03-22 "" "linux programmer's manual" +.sh name +xdr \- library routines for external data representation +.sh synopsis and description +these routines allow c programmers to describe +arbitrary data structures in a machine-independent fashion. +data for remote procedure calls are transmitted using these +routines. +.pp +the prototypes below are declared in +.i +and make use of the following types: +.pp +.rs 4 +.ex +.bi "typedef int " bool_t ; +.pp +.bi "typedef bool_t (*" xdrproc_t ")(xdr *, void *,...);" +.ee +.re +.pp +for the declaration of the +.i xdr +type, see +.ir . +.pp +.nf +.bi "bool_t xdr_array(xdr *" xdrs ", char **" arrp ", unsigned int *" sizep , +.bi " unsigned int " maxsize ", unsigned int " elsize , +.bi " xdrproc_t " elproc ); +.fi +.ip +a filter primitive that translates between variable-length arrays +and their corresponding external representations. +the argument +.i arrp +is the address of the pointer to the array, while +.i sizep +is the address of the element count of the array; +this element count cannot exceed +.ir maxsize . +the argument +.i elsize +is the +.i sizeof +each of the array's elements, and +.i elproc +is an xdr filter that translates between +the array elements' c form, and their external +representation. +this routine returns one if it succeeds, zero otherwise. +.pp +.nf +.bi "bool_t xdr_bool(xdr *" xdrs ", bool_t *" bp ); +.fi +.ip +a filter primitive that translates between booleans (c +integers) +and their external representations. +when encoding data, this +filter produces values of either one or zero. +this routine returns one if it succeeds, zero otherwise. +.pp +.nf +.bi "bool_t xdr_bytes(xdr *" xdrs ", char **" sp ", unsigned int *" sizep , +.bi " unsigned int " maxsize ); +.fi +.ip +a filter primitive that translates between counted byte +strings and their external representations. +the argument +.i sp +is the address of the string pointer. +the length of the +string is located at address +.ir sizep ; +strings cannot be longer than +.ir maxsize . +this routine returns one if it succeeds, zero otherwise. +.pp +.nf +.bi "bool_t xdr_char(xdr *" xdrs ", char *" cp ); +.fi +.ip +a filter primitive that translates between c characters +and their external representations. +this routine returns one if it succeeds, zero otherwise. +note: encoded characters are not packed, and occupy 4 bytes each. +for arrays of characters, it is worthwhile to +consider +.br xdr_bytes (), +.br xdr_opaque (), +or +.br xdr_string (). +.pp +.nf +.bi "void xdr_destroy(xdr *" xdrs ); +.fi +.ip +a macro that invokes the destroy routine associated with the xdr stream, +.ir xdrs . +destruction usually involves freeing private data structures +associated with the stream. +using +.i xdrs +after invoking +.br xdr_destroy () +is undefined. +.pp +.nf +.bi "bool_t xdr_double(xdr *" xdrs ", double *" dp ); +.fi +.ip +a filter primitive that translates between c +.i double +precision numbers and their external representations. +this routine returns one if it succeeds, zero otherwise. +.pp +.nf +.bi "bool_t xdr_enum(xdr *" xdrs ", enum_t *" ep ); +.fi +.ip +a filter primitive that translates between c +.ir enum s +(actually integers) and their external representations. +this routine returns one if it succeeds, zero otherwise. +.pp +.nf +.bi "bool_t xdr_float(xdr *" xdrs ", float *" fp ); +.fi +.ip +a filter primitive that translates between c +.ir float s +and their external representations. +this routine returns one if it succeeds, zero otherwise. +.pp +.nf +.bi "void xdr_free(xdrproc_t " proc ", char *" objp ); +.fi +.ip +generic freeing routine. +the first argument is the xdr routine for the object being freed. +the second argument is a pointer to the object itself. +note: the pointer passed to this routine is +.i not +freed, but what it points to +.i is +freed (recursively). +.pp +.nf +.bi "unsigned int xdr_getpos(xdr *" xdrs ); +.fi +.ip +a macro that invokes the get-position routine +associated with the xdr stream, +.ir xdrs . +the routine returns an unsigned integer, +which indicates the position of the xdr byte stream. +a desirable feature of xdr +streams is that simple arithmetic works with this number, +although the xdr stream instances need not guarantee this. +.pp +.nf +.bi "long *xdr_inline(xdr *" xdrs ", int " len ); +.fi +.ip +a macro that invokes the inline routine associated with the xdr stream, +.ir xdrs . +the routine returns a pointer +to a contiguous piece of the stream's buffer; +.i len +is the byte length of the desired buffer. +note: pointer is cast to +.ir "long\ *" . +.ip +warning: +.br xdr_inline () +may return null (0) +if it cannot allocate a contiguous piece of a buffer. +therefore the behavior may vary among stream instances; +it exists for the sake of efficiency. +.pp +.nf +.bi "bool_t xdr_int(xdr *" xdrs ", int *" ip ); +.fi +.ip +a filter primitive that translates between c integers +and their external representations. +this routine returns one if it succeeds, zero otherwise. +.pp +.nf +.bi "bool_t xdr_long(xdr *" xdrs ", long *" lp ); +.fi +.ip +a filter primitive that translates between c +.i long +integers and their external representations. +this routine returns one if it succeeds, zero otherwise. +.pp +.nf +.bi "void xdrmem_create(xdr *" xdrs ", char *" addr ", unsigned int " size , +.bi " enum xdr_op " op ); +.fi +.ip +this routine initializes the xdr stream object pointed to by +.ir xdrs . +the stream's data is written to, or read from, +a chunk of memory at location +.i addr +whose length is no more than +.i size +bytes long. +the +.i op +determines the direction of the xdr stream (either +.br xdr_encode , +.br xdr_decode , +or +.br xdr_free ). +.pp +.nf +.bi "bool_t xdr_opaque(xdr *" xdrs ", char *" cp ", unsigned int " cnt ); +.fi +.ip +a filter primitive that translates between fixed size opaque data +and its external representation. +the argument +.i cp +is the address of the opaque object, and +.i cnt +is its size in bytes. +this routine returns one if it succeeds, zero otherwise. +.pp +.nf +.bi "bool_t xdr_pointer(xdr *" xdrs ", char **" objpp , +.bi " unsigned int " objsize ", xdrproc_t " xdrobj ); +.fi +.ip +like +.br xdr_reference () +except that it serializes null pointers, whereas +.br xdr_reference () +does not. +thus, +.br xdr_pointer () +can represent +recursive data structures, such as binary trees or +linked lists. +.pp +.nf +.bi "void xdrrec_create(xdr *" xdrs ", unsigned int " sendsize , +.bi " unsigned int " recvsize ", char *" handle , +.bi " int (*" readit ")(char *, char *, int)," +.bi " int (*" writeit ")(char *, char *, int));" +.fi +.ip +this routine initializes the xdr stream object pointed to by +.ir xdrs . +the stream's data is written to a buffer of size +.ir sendsize ; +a value of zero indicates the system should use a suitable default. +the stream's data is read from a buffer of size +.ir recvsize ; +it too can be set to a suitable default by passing a zero value. +when a stream's output buffer is full, +.i writeit +is called. +similarly, when a stream's input buffer is empty, +.i readit +is called. +the behavior of these two routines is similar to +the system calls +.br read (2) +and +.br write (2), +except that +.i handle +is passed to the former routines as the first argument. +note: the xdr stream's +.i op +field must be set by the caller. +.ip +warning: to read from an xdr stream created by this api, +you'll need to call +.br xdrrec_skiprecord () +first before calling any other xdr apis. +this inserts additional bytes in the stream to provide +record boundary information. +also, xdr streams created with different +.br xdr*_create +apis are not compatible for the same reason. +.pp +.nf +.bi "bool_t xdrrec_endofrecord(xdr *" xdrs ", int " sendnow ); +.fi +.ip +this routine can be invoked only on streams created by +.br xdrrec_create (). +the data in the output buffer is marked as a completed record, +and the output buffer is optionally written out if +.i sendnow +is nonzero. +this routine returns one if it succeeds, zero otherwise. +.pp +.nf +.bi "bool_t xdrrec_eof(xdr *" xdrs ); +.fi +.ip +this routine can be invoked only on streams created by +.br xdrrec_create (). +after consuming the rest of the current record in the stream, +this routine returns one if the stream has no more input, +zero otherwise. +.pp +.nf +.bi "bool_t xdrrec_skiprecord(xdr *" xdrs ); +.fi +.ip +this routine can be invoked only on +streams created by +.br xdrrec_create (). +it tells the xdr implementation that the rest of the current record +in the stream's input buffer should be discarded. +this routine returns one if it succeeds, zero otherwise. +.pp +.nf +.bi "bool_t xdr_reference(xdr *" xdrs ", char **" pp ", unsigned int " size , +.bi " xdrproc_t " proc ); +.fi +.ip +a primitive that provides pointer chasing within structures. +the argument +.i pp +is the address of the pointer; +.i size +is the +.i sizeof +the structure that +.i *pp +points to; and +.i proc +is an xdr procedure that filters the structure +between its c form and its external representation. +this routine returns one if it succeeds, zero otherwise. +.ip +warning: this routine does not understand null pointers. +use +.br xdr_pointer () +instead. +.pp +.nf +.bi "xdr_setpos(xdr *" xdrs ", unsigned int " pos ); +.fi +.ip +a macro that invokes the set position routine associated with +the xdr stream +.ir xdrs . +the argument +.i pos +is a position value obtained from +.br xdr_getpos (). +this routine returns one if the xdr stream could be repositioned, +and zero otherwise. +.ip +warning: it is difficult to reposition some types of xdr +streams, so this routine may fail with one +type of stream and succeed with another. +.pp +.nf +.bi "bool_t xdr_short(xdr *" xdrs ", short *" sp ); +.fi +.ip +a filter primitive that translates between c +.i short +integers and their external representations. +this routine returns one if it succeeds, zero otherwise. +.pp +.nf +.bi "void xdrstdio_create(xdr *" xdrs ", file *" file ", enum xdr_op " op ); +.fi +.ip +this routine initializes the xdr stream object pointed to by +.ir xdrs . +the xdr stream data is written to, or read from, the +.i stdio +stream +.ir file . +the argument +.i op +determines the direction of the xdr stream (either +.br xdr_encode , +.br xdr_decode , +or +.br xdr_free ). +.ip +warning: the destroy routine associated with such xdr streams calls +.br fflush (3) +on the +.i file +stream, but never +.br fclose (3). +.pp +.nf +.bi "bool_t xdr_string(xdr *" xdrs ", char **" sp ", unsigned int " maxsize ); +.fi +.ip +a filter primitive that translates between c strings and +their corresponding external representations. +strings cannot be longer than +.ir maxsize . +note: +.i sp +is the address of the string's pointer. +this routine returns one if it succeeds, zero otherwise. +.pp +.nf +.bi "bool_t xdr_u_char(xdr *" xdrs ", unsigned char *" ucp ); +.fi +.ip +a filter primitive that translates between +.i unsigned +c characters and their external representations. +this routine returns one if it succeeds, zero otherwise. +.pp +.nf +.bi "bool_t xdr_u_int(xdr *" xdrs ", unsigned int *" up ); +.fi +.ip +a filter primitive that translates between c +.i unsigned +integers and their external representations. +this routine returns one if it succeeds, zero otherwise. +.pp +.nf +.bi "bool_t xdr_u_long(xdr *" xdrs ", unsigned long *" ulp ); +.fi +.ip +a filter primitive that translates between c +.i "unsigned long" +integers and their external representations. +this routine returns one if it succeeds, zero otherwise. +.pp +.nf +.bi "bool_t xdr_u_short(xdr *" xdrs ", unsigned short *" usp ); +.fi +.ip +a filter primitive that translates between c +.i "unsigned short" +integers and their external representations. +this routine returns one if it succeeds, zero otherwise. +.pp +.nf +.bi "bool_t xdr_union(xdr *" xdrs ", enum_t *" dscmp ", char *" unp , +.bi " const struct xdr_discrim *" choices , +.bi " xdrproc_t " defaultarm "); /* may equal null */" +.fi +.ip +a filter primitive that translates between a discriminated c +.i union +and its corresponding external representation. +it first +translates the discriminant of the union located at +.ir dscmp . +this discriminant is always an +.ir enum_t . +next the union located at +.i unp +is translated. +the argument +.i choices +is a pointer to an array of +.br xdr_discrim () +structures. +each structure contains an ordered pair of +.ri [ value , proc ]. +if the union's discriminant is equal to the associated +.ir value , +then the +.i proc +is called to translate the union. +the end of the +.br xdr_discrim () +structure array is denoted by a routine of value null. +if the discriminant is not found in the +.i choices +array, then the +.i defaultarm +procedure is called (if it is not null). +returns one if it succeeds, zero otherwise. +.pp +.nf +.bi "bool_t xdr_vector(xdr *" xdrs ", char *" arrp ", unsigned int " size , +.bi " unsigned int " elsize ", xdrproc_t " elproc ); +.fi +.ip +a filter primitive that translates between fixed-length arrays +and their corresponding external representations. +the argument +.i arrp +is the address of the pointer to the array, while +.i size +is the element count of the array. +the argument +.i elsize +is the +.i sizeof +each of the array's elements, and +.i elproc +is an xdr filter that translates between +the array elements' c form, and their external +representation. +this routine returns one if it succeeds, zero otherwise. +.pp +.nf +.bi "bool_t xdr_void(void);" +.fi +.ip +this routine always returns one. +it may be passed to rpc routines that require a function argument, +where nothing is to be done. +.pp +.nf +.bi "bool_t xdr_wrapstring(xdr *" xdrs ", char **" sp ); +.fi +.ip +a primitive that calls +.b "xdr_string(xdrs, sp,maxun.unsigned );" +where +.b maxun.unsigned +is the maximum value of an unsigned integer. +.br xdr_wrapstring () +is handy because the rpc package passes a maximum of two xdr +routines as arguments, and +.br xdr_string (), +one of the most frequently used primitives, requires three. +returns one if it succeeds, zero otherwise. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br xdr_array (), +.br xdr_bool (), +.br xdr_bytes (), +.br xdr_char (), +.br xdr_destroy (), +.br xdr_double (), +.br xdr_enum (), +.br xdr_float (), +.br xdr_free (), +.br xdr_getpos (), +.br xdr_inline (), +.br xdr_int (), +.br xdr_long (), +.br xdrmem_create (), +.br xdr_opaque (), +.br xdr_pointer (), +.br xdrrec_create (), +.br xdrrec_eof (), +.br xdrrec_endofrecord (), +.br xdrrec_skiprecord (), +.br xdr_reference (), +.br xdr_setpos (), +.br xdr_short (), +.br xdrstdio_create (), +.br xdr_string (), +.br xdr_u_char (), +.br xdr_u_int (), +.br xdr_u_long (), +.br xdr_u_short (), +.br xdr_union (), +.br xdr_vector (), +.br xdr_void (), +.br xdr_wrapstring () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh see also +.br rpc (3) +.pp +the following manuals: +.rs +external data representation standard: protocol specification +.br +external data representation: sun technical notes +.br +.ir "xdr: external data representation standard" , +rfc\ 1014, sun microsystems, inc., +usc-isi. +.re +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2016 intel corporation +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and author of this work. +.\" %%%license_end +.\" +.th pkey_alloc 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +pkey_alloc, pkey_free \- allocate or free a protection key +.sh synopsis +.nf +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "int pkey_alloc(unsigned int " flags ", unsigned int " access_rights ");" +.bi "int pkey_free(int " pkey ");" +.fi +.sh description +.br pkey_alloc () +allocates a protection key (pkey) and allows it to be passed to +.br pkey_mprotect (2). +.pp +the +.br pkey_alloc () +.i flags +is reserved for future use and currently must always be specified as 0. +.pp +the +.br pkey_alloc () +.i access_rights +argument may contain zero or more disable operations: +.tp +.b pkey_disable_access +disable all data access to memory covered by the returned protection key. +.tp +.b pkey_disable_write +disable write access to memory covered by the returned protection key. +.pp +.br pkey_free () +frees a protection key and makes it available for later +allocations. +after a protection key has been freed, it may no longer be used +in any protection-key-related operations. +.pp +an application should not call +.br pkey_free () +on any protection key which has been assigned to an address +range by +.br pkey_mprotect (2) +and which is still in use. +the behavior in this case is undefined and may result in an error. +.sh return value +on success, +.br pkey_alloc () +returns a positive protection key value. +on success, +.br pkey_free () +returns zero. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b einval +.ir pkey , +.ir flags , +or +.i access_rights +is invalid. +.tp +.b enospc +.rb ( pkey_alloc ()) +all protection keys available for the current process have +been allocated. +the number of keys available is architecture-specific and +implementation-specific and may be reduced by kernel-internal use +of certain keys. +there are currently 15 keys available to user programs on x86. +.ip +this error will also be returned if the processor or operating system +does not support protection keys. +applications should always be prepared to handle this error, since +factors outside of the application's control can reduce the number +of available pkeys. +.sh versions +.br pkey_alloc () +and +.br pkey_free () +were added to linux in kernel 4.9; +library support was added in glibc 2.27. +.sh conforming to +the +.br pkey_alloc () +and +.br pkey_free () +system calls are linux-specific. +.sh notes +.br pkey_alloc () +is always safe to call regardless of whether or not the operating system +supports protection keys. +it can be used in lieu of any other mechanism for detecting pkey support +and will simply fail with the error +.b enospc +if the operating system has no pkey support. +.pp +the kernel guarantees that the contents of the hardware rights +register (pkru) will be preserved only for allocated protection +keys. +any time a key is unallocated (either before the first call +returning that key from +.br pkey_alloc () +or after it is freed via +.br pkey_free ()), +the kernel may make arbitrary changes to the parts of the +rights register affecting access to that key. +.sh examples +see +.br pkeys (7). +.sh see also +.br pkey_mprotect (2), +.br pkeys (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1993 rickard e. faith (faith@cs.unc.edu) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified 1997-08-25 by nicolás lichtmaier +.\" modified 2004-06-17 by michael kerrisk +.\" modified 2008-11-27 by mtk +.\" +.th getdomainname 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +getdomainname, setdomainname \- get/set nis domain name +.sh synopsis +.nf +.b #include +.pp +.bi "int getdomainname(char *" name ", size_t " len ); +.bi "int setdomainname(const char *" name ", size_t " len ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br getdomainname (), +.br setdomainname (): +.nf + since glibc 2.21: +.\" commit 266865c0e7b79d4196e2cc393693463f03c90bd8 + _default_source + in glibc 2.19 and 2.20: + _default_source || (_xopen_source && _xopen_source < 500) + up to and including glibc 2.19: + _bsd_source || (_xopen_source && _xopen_source < 500) +.fi +.sh description +these functions are used to access or to change the nis domain name of the +host system. +more precisely, they operate on the nis domain name associated with the calling +process's uts namespace. +.pp +.br setdomainname () +sets the domain name to the value given in the character array +.ir name . +the +.i len +argument specifies the number of bytes in +.ir name . +(thus, +.i name +does not require a terminating null byte.) +.pp +.br getdomainname () +returns the null-terminated domain name in the character array +.ir name , +which has a length of +.i len +bytes. +if the null-terminated domain name requires more than \filen\fp bytes, +.br getdomainname () +returns the first \filen\fp bytes (glibc) or gives an error (libc). +.sh return value +on success, zero is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.br setdomainname () +can fail with the following errors: +.tp +.b efault +.i name +pointed outside of user address space. +.tp +.b einval +.i len +was negative or too large. +.tp +.b eperm +the caller did not have the +.b cap_sys_admin +capability in the user namespace associated with its uts namespace (see +.br namespaces (7)). +.pp +.br getdomainname () +can fail with the following errors: +.tp +.b einval +for +.br getdomainname () +under libc: +.i name +is null or +.i name +is longer than +.i len +bytes. +.sh conforming to +posix does not specify these calls. +.\" but they appear on most systems... +.sh notes +since linux 1.0, the limit on the length of a domain name, +including the terminating null byte, is 64 bytes. +in older kernels, it was 8 bytes. +.pp +on most linux architectures (including x86), +there is no +.br getdomainname () +system call; instead, glibc implements +.br getdomainname () +as a library function that returns a copy of the +.i domainname +field returned from a call to +.br uname (2). +.sh see also +.br gethostname (2), +.br sethostname (2), +.br uname (2), +.br uts_namespaces (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sat jul 24 18:00:10 1993 by rik faith (faith@cs.unc.edu) +.\" modified mon jan 20 12:04:18 1997 by andries brouwer (aeb@cwi.nl) +.\" modified tue jan 23 20:23:07 2001 by andries brouwer (aeb@cwi.nl) +.\" +.th strsep 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +strsep \- extract token from string +.sh synopsis +.nf +.b #include +.pp +.bi "char *strsep(char **restrict " stringp ", const char *restrict " delim ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br strsep (): +.nf + since glibc 2.19: + _default_source + glibc 2.19 and earlier: + _bsd_source +.fi +.sh description +if +.i *stringp +is null, the +.br strsep () +function returns null +and does nothing else. +otherwise, this function finds the first token +in the string +.ir *stringp , +that is delimited by one of the bytes in the string +.ir delim . +this token is terminated by overwriting the delimiter +with a null byte (\(aq\e0\(aq), +and +.i *stringp +is updated to point past the token. +in case no delimiter was found, the token is taken to be +the entire string +.ir *stringp , +and +.i *stringp +is made null. +.sh return value +the +.br strsep () +function returns a pointer to the token, +that is, it returns the original value of +.ir *stringp . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br strsep () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +4.4bsd. +.sh notes +the +.br strsep () +function was introduced as a replacement for +.br strtok (3), +since the latter cannot handle empty fields. +however, +.br strtok (3) +conforms to c89/c99 and hence is more portable. +.sh bugs +be cautious when using this function. +if you do use it, note that: +.ip * 2 +this function modifies its first argument. +.ip * +this function cannot be used on constant strings. +.ip * +the identity of the delimiting character is lost. +.sh see also +.br index (3), +.br memchr (3), +.br rindex (3), +.br strchr (3), +.br string (3), +.br strpbrk (3), +.br strspn (3), +.br strstr (3), +.br strtok (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/stat.2 + +.\" copyright 1993 rickard e. faith (faith@cs.unc.edu) +.\" and copyright 2005-2007, michael kerrisk +.\" portions extracted from /usr/include/sys/socket.h, which does not have +.\" any authorship information in it. it is probably available under the gpl. +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" +.\" other portions are from the 6.9 (berkeley) 3/10/91 man page: +.\" +.\" copyright (c) 1983 the regents of the university of california. +.\" all rights reserved. +.\" +.\" %%%license_start(bsd_4_clause_ucb) +.\" redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. all advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" this product includes software developed by the university of +.\" california, berkeley and its contributors. +.\" 4. neither the name of the university nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" this software is provided by the regents and contributors ``as is'' and +.\" any express or implied warranties, including, but not limited to, the +.\" implied warranties of merchantability and fitness for a particular purpose +.\" are disclaimed. in no event shall the regents or contributors be liable +.\" for any direct, indirect, incidental, special, exemplary, or consequential +.\" damages (including, but not limited to, procurement of substitute goods +.\" or services; loss of use, data, or profits; or business interruption) +.\" however caused and on any theory of liability, whether in contract, strict +.\" liability, or tort (including negligence or otherwise) arising in any way +.\" out of the use of this software, even if advised of the possibility of +.\" such damage. +.\" %%%license_end +.\" +.\" modified mon oct 21 23:05:29 edt 1996 by eric s. raymond +.\" modified 1998 by andi kleen +.\" $id: bind.2,v 1.3 1999/04/23 19:56:07 freitag exp $ +.\" modified 2004-06-23 by michael kerrisk +.\" +.th bind 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +bind \- bind a name to a socket +.sh synopsis +.nf +.b #include +.pp +.bi "int bind(int " sockfd ", const struct sockaddr *" addr , +.bi " socklen_t " addrlen ); +.fi +.sh description +when a socket is created with +.br socket (2), +it exists in a name space (address family) but has no address assigned to it. +.br bind () +assigns the address specified by +.i addr +to the socket referred to by the file descriptor +.ir sockfd . +.i addrlen +specifies the size, in bytes, of the address structure pointed to by +.ir addr . +traditionally, this operation is called \(lqassigning a name to a socket\(rq. +.pp +it is normally necessary to assign a local address using +.br bind () +before a +.b sock_stream +socket may receive connections (see +.br accept (2)). +.pp +the rules used in name binding vary between address families. +consult the manual entries in section 7 for detailed information. +for +.br af_inet , +see +.br ip (7); +for +.br af_inet6 , +see +.br ipv6 (7); +for +.br af_unix , +see +.br unix (7); +for +.br af_appletalk , +see +.br ddp (7); +for +.br af_packet , +see +.br packet (7); +for +.br af_x25 , +see +.br x25 (7); +and for +.br af_netlink , +see +.br netlink (7). +.pp +the actual structure passed for the +.i addr +argument will depend on the address family. +the +.i sockaddr +structure is defined as something like: +.pp +.in +4n +.ex +struct sockaddr { + sa_family_t sa_family; + char sa_data[14]; +} +.ee +.in +.pp +the only purpose of this structure is to cast the structure +pointer passed in +.i addr +in order to avoid compiler warnings. +see examples below. +.sh return value +on success, zero is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eacces +.\" e.g., privileged port in af_inet domain +the address is protected, and the user is not the superuser. +.tp +.b eaddrinuse +the given address is already in use. +.tp +.b eaddrinuse +(internet domain sockets) +the port number was specified as zero in the socket address structure, +but, upon attempting to bind to an ephemeral port, +it was determined that all port numbers in the ephemeral port range +are currently in use. +see the discussion of +.i /proc/sys/net/ipv4/ip_local_port_range +.br ip (7). +.tp +.b ebadf +.i sockfd +is not a valid file descriptor. +.tp +.b einval +the socket is already bound to an address. +.\" this may change in the future: see +.\" .i linux/unix/sock.c for details. +.tp +.b einval +.i addrlen +is wrong, or +.i addr +is not a valid address for this socket's domain. +.tp +.b enotsock +the file descriptor +.i sockfd +does not refer to a socket. +.pp +the following errors are specific to unix domain +.rb ( af_unix ) +sockets: +.tp +.b eacces +search permission is denied on a component of the path prefix. +(see also +.br path_resolution (7).) +.tp +.b eaddrnotavail +a nonexistent interface was requested or the requested +address was not local. +.tp +.b efault +.i addr +points outside the user's accessible address space. +.tp +.b eloop +too many symbolic links were encountered in resolving +.ir addr . +.tp +.b enametoolong +.i addr +is too long. +.tp +.b enoent +a component in the directory prefix of the socket pathname does not exist. +.tp +.b enomem +insufficient kernel memory was available. +.tp +.b enotdir +a component of the path prefix is not a directory. +.tp +.b erofs +the socket inode would reside on a read-only filesystem. +.sh conforming to +posix.1-2001, posix.1-2008, svr4, 4.4bsd +.rb ( bind () +first appeared in 4.2bsd). +.\" svr4 documents an additional +.\" .b enosr +.\" general error condition, and +.\" additional +.\" .b eio +.\" and +.\" .b eisdir +.\" unix-domain error conditions. +.sh notes +for background on the +.i socklen_t +type, see +.br accept (2). +.sh bugs +the transparent proxy options are not described. +.\" fixme document transparent proxy options +.sh examples +an example of the use of +.br bind () +with internet domain sockets can be found in +.br getaddrinfo (3). +.pp +the following example shows how to bind a stream socket in the unix +.rb ( af_unix ) +domain, and accept connections: +.\" listen.7 refers to this example. +.\" accept.7 refers to this example. +.\" unix.7 refers to this example. +.pp +.ex +#include +#include +#include +#include +#include + +#define my_sock_path "/somepath" +#define listen_backlog 50 + +#define handle_error(msg) \e + do { perror(msg); exit(exit_failure); } while (0) + +int +main(int argc, char *argv[]) +{ + int sfd, cfd; + struct sockaddr_un my_addr, peer_addr; + socklen_t peer_addr_size; + + sfd = socket(af_unix, sock_stream, 0); + if (sfd == \-1) + handle_error("socket"); + + memset(&my_addr, 0, sizeof(my_addr)); + my_addr.sun_family = af_unix; + strncpy(my_addr.sun_path, my_sock_path, + sizeof(my_addr.sun_path) \- 1); + + if (bind(sfd, (struct sockaddr *) &my_addr, + sizeof(my_addr)) == \-1) + handle_error("bind"); + + if (listen(sfd, listen_backlog) == \-1) + handle_error("listen"); + + /* now we can accept incoming connections one + at a time using accept(2). */ + + peer_addr_size = sizeof(peer_addr); + cfd = accept(sfd, (struct sockaddr *) &peer_addr, + &peer_addr_size); + if (cfd == \-1) + handle_error("accept"); + + /* code to deal with incoming connection(s)... */ + + /* when no longer required, the socket pathname, my_sock_path + should be deleted using unlink(2) or remove(3). */ +} +.ee +.sh see also +.br accept (2), +.br connect (2), +.br getsockname (2), +.br listen (2), +.br socket (2), +.br getaddrinfo (3), +.br getifaddrs (3), +.br ip (7), +.br ipv6 (7), +.br path_resolution (7), +.br socket (7), +.br unix (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2003 free software foundation, inc. +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" this file is distributed according to the gnu general public license. +.\" %%%license_end +.\" +.th io_destroy 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +io_destroy \- destroy an asynchronous i/o context +.sh synopsis +.nf +.br "#include " " /* definition of " aio_context_t " */" +.br "#include " " /* definition of " sys_* " constants */" +.b #include +.pp +.bi "int syscall(sys_io_destroy, aio_context_t " ctx_id ); +.fi +.pp +.ir note : +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. +the wrapper function provided by +.i libaio +uses a different type for the +.i ctx_id +argument. +see notes. +.pp +the +.br io_destroy () +system call +will attempt to cancel all outstanding asynchronous i/o operations against +.ir ctx_id , +will block on the completion of all operations +that could not be canceled, and will destroy the +.ir ctx_id . +.sh return value +on success, +.br io_destroy () +returns 0. +for the failure return, see notes. +.sh errors +.tp +.b efault +the context pointed to is invalid. +.tp +.b einval +the aio context specified by \fictx_id\fp is invalid. +.tp +.b enosys +.br io_destroy () +is not implemented on this architecture. +.sh versions +the asynchronous i/o system calls first appeared in linux 2.5. +.sh conforming to +.br io_destroy () +is linux-specific and should not be used in programs +that are intended to be portable. +.sh notes +you probably want to use the +.br io_destroy () +wrapper function provided by +.\" http://git.fedorahosted.org/git/?p=libaio.git +.ir libaio . +.pp +note that the +.i libaio +wrapper function uses a different type +.ri ( io_context_t ) +.\" but glibc is confused, since uses 'io_context_t' to declare +.\" the system call. +for the +.i ctx_id +argument. +note also that the +.i libaio +wrapper does not follow the usual c library conventions for indicating errors: +on error it returns a negated error number +(the negative of one of the values listed in errors). +if the system call is invoked via +.br syscall (2), +then the return value follows the usual conventions for +indicating an error: \-1, with +.i errno +set to a (positive) value that indicates the error. +.sh see also +.br io_cancel (2), +.br io_getevents (2), +.br io_setup (2), +.br io_submit (2), +.br aio (7) +.\" .sh author +.\" kent yoder. +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/removexattr.2 + +.so man3/nextafter.3 + +.\" from henry spencer's regex package (as found in the apache +.\" distribution). the package carries the following copyright: +.\" +.\" copyright 1992, 1993, 1994 henry spencer. all rights reserved. +.\" %%%license_start(misc) +.\" this software is not subject to any license of the american telephone +.\" and telegraph company or of the regents of the university of california. +.\" +.\" permission is granted to anyone to use this software for any purpose +.\" on any computer system, and to alter it and redistribute it, subject +.\" to the following restrictions: +.\" +.\" 1. the author is not responsible for the consequences of use of this +.\" software, no matter how awful, even if they arise from flaws in it. +.\" +.\" 2. the origin of this software must not be misrepresented, either by +.\" explicit claim or by omission. since few users ever read sources, +.\" credits must appear in the documentation. +.\" +.\" 3. altered versions must be plainly marked as such, and must not be +.\" misrepresented as being the original software. since few users +.\" ever read sources, credits must appear in the documentation. +.\" +.\" 4. this notice may not be removed or altered. +.\" %%%license_end +.\" +.\" in order to comply with `credits must appear in the documentation' +.\" i added an author paragraph below - aeb. +.\" +.\" in the default nroff environment there is no dagger \(dg. +.\" +.\" 2005-05-11 removed discussion of `[[:<:]]' and `[[:>:]]', which +.\" appear not to be in the glibc implementation of regcomp +.\" +.ie t .ds dg \(dg +.el .ds dg (!) +.th regex 7 2020-08-13 "" "linux programmer's manual" +.sh name +regex \- posix.2 regular expressions +.sh description +regular expressions ("re"s), +as defined in posix.2, come in two forms: +modern res (roughly those of +.ir egrep ; +posix.2 calls these "extended" res) +and obsolete res (roughly those of +.br ed (1); +posix.2 "basic" res). +obsolete res mostly exist for backward compatibility in some old programs; +they will be discussed at the end. +posix.2 leaves some aspects of re syntax and semantics open; +"\*(dg" marks decisions on these aspects that +may not be fully portable to other posix.2 implementations. +.pp +a (modern) re is one\*(dg or more nonempty\*(dg \fibranches\fr, +separated by \(aq|\(aq. +it matches anything that matches one of the branches. +.pp +a branch is one\*(dg or more \fipieces\fr, concatenated. +it matches a match for the first, followed by a match for the second, +and so on. +.pp +a piece is an \fiatom\fr possibly followed +by a single\*(dg \(aq*\(aq, \(aq+\(aq, \(aq?\(aq, or \fibound\fr. +an atom followed by \(aq*\(aq +matches a sequence of 0 or more matches of the atom. +an atom followed by \(aq+\(aq +matches a sequence of 1 or more matches of the atom. +an atom followed by \(aq?\(aq +matches a sequence of 0 or 1 matches of the atom. +.pp +a \fibound\fr is \(aq{\(aq followed by an unsigned decimal integer, +possibly followed by \(aq,\(aq +possibly followed by another unsigned decimal integer, +always followed by \(aq}\(aq. +the integers must lie between 0 and +.b re_dup_max +(255\*(dg) inclusive, +and if there are two of them, the first may not exceed the second. +an atom followed by a bound containing one integer \fii\fr +and no comma matches +a sequence of exactly \fii\fr matches of the atom. +an atom followed by a bound +containing one integer \fii\fr and a comma matches +a sequence of \fii\fr or more matches of the atom. +an atom followed by a bound +containing two integers \fii\fr and \fij\fr matches +a sequence of \fii\fr through \fij\fr (inclusive) matches of the atom. +.pp +an atom is a regular expression enclosed in "\fi()\fp" +(matching a match for the regular expression), +an empty set of "\fi()\fp" (matching the null string)\*(dg, +a \fibracket expression\fr (see below), \(aq.\(aq +(matching any single character), \(aq\(ha\(aq (matching the null string at the +beginning of a line), \(aq$\(aq (matching the null string at the +end of a line), a \(aq\e\(aq followed by one of the characters +"\fi\(ha.[$()|*+?{\e\fp" +(matching that character taken as an ordinary character), +a \(aq\e\(aq followed by any other character\*(dg +(matching that character taken as an ordinary character, +as if the \(aq\e\(aq had not been present\*(dg), +or a single character with no other significance (matching that character). +a \(aq{\(aq followed by a character other than a digit is an ordinary +character, not the beginning of a bound\*(dg. +it is illegal to end an re with \(aq\e\(aq. +.pp +a \fibracket expression\fr is a list of characters enclosed in "\fi[]\fp". +it normally matches any single character from the list (but see below). +if the list begins with \(aq\(ha\(aq, +it matches any single character +(but see below) \finot\fr from the rest of the list. +if two characters in the list are separated by \(aq\-\(aq, this is shorthand +for the full \firange\fr of characters between those two (inclusive) in the +collating sequence, +for example, "\fi[0\-9]\fp" in ascii matches any decimal digit. +it is illegal\*(dg for two ranges to share an +endpoint, for example, "\fia\-c\-e\fp". +ranges are very collating-sequence-dependent, +and portable programs should avoid relying on them. +.pp +to include a literal \(aq]\(aq in the list, make it the first character +(following a possible \(aq\(ha\(aq). +to include a literal \(aq\-\(aq, make it the first or last character, +or the second endpoint of a range. +to use a literal \(aq\-\(aq as the first endpoint of a range, +enclose it in "\fi[.\fp" and "\fi.]\fp" +to make it a collating element (see below). +with the exception of these and some combinations using \(aq[\(aq (see next +paragraphs), all other special characters, including \(aq\e\(aq, lose their +special significance within a bracket expression. +.pp +within a bracket expression, a collating element (a character, +a multicharacter sequence that collates as if it were a single character, +or a collating-sequence name for either) +enclosed in "\fi[.\fp" and "\fi.]\fp" stands for the +sequence of characters of that collating element. +the sequence is a single element of the bracket expression's list. +a bracket expression containing a multicharacter collating element +can thus match more than one character, +for example, if the collating sequence includes a "ch" collating element, +then the re "\fi[[.ch.]]*c\fp" matches the first five characters +of "chchcc". +.pp +within a bracket expression, a collating element enclosed in "\fi[=\fp" and +"\fi=]\fp" is an equivalence class, standing for the sequences of characters +of all collating elements equivalent to that one, including itself. +(if there are no other equivalent collating elements, +the treatment is as if the enclosing delimiters +were "\fi[.\fp" and "\fi.]\fp".) +for example, if o and \o'o\(ha' are the members of an equivalence class, +then "\fi[[=o=]]\fp", "\fi[[=\o'o\(ha'=]]\fp", +and "\fi[o\o'o\(ha']\fp" are all synonymous. +an equivalence class may not\*(dg be an endpoint +of a range. +.pp +within a bracket expression, the name of a \ficharacter class\fr enclosed +in "\fi[:\fp" and "\fi:]\fp" stands for the list +of all characters belonging to that +class. +standard character class names are: +.pp +.rs +.ts +l l l. +alnum digit punct +alpha graph space +blank lower upper +cntrl print xdigit +.te +.re +.pp +these stand for the character classes defined in +.br wctype (3). +a locale may provide others. +a character class may not be used as an endpoint of a range. +.\" as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=295666 +.\" the following does not seem to apply in the glibc implementation +.\" .pp +.\" there are two special cases\*(dg of bracket expressions: +.\" the bracket expressions "\fi[[:<:]]\fp" and "\fi[[:>:]]\fp" match +.\" the null string at the beginning and end of a word respectively. +.\" a word is defined as a sequence of +.\" word characters +.\" which is neither preceded nor followed by +.\" word characters. +.\" a word character is an +.\" .i alnum +.\" character (as defined by +.\" .br wctype (3)) +.\" or an underscore. +.\" this is an extension, +.\" compatible with but not specified by posix.2, +.\" and should be used with +.\" caution in software intended to be portable to other systems. +.pp +in the event that an re could match more than one substring of a given +string, +the re matches the one starting earliest in the string. +if the re could match more than one substring starting at that point, +it matches the longest. +subexpressions also match the longest possible substrings, subject to +the constraint that the whole match be as long as possible, +with subexpressions starting earlier in the re taking priority over +ones starting later. +note that higher-level subexpressions thus take priority over +their lower-level component subexpressions. +.pp +match lengths are measured in characters, not collating elements. +a null string is considered longer than no match at all. +for example, +"\fibb*\fp" matches the three middle characters of "abbbc", +"\fi(wee|week)(knights|nights)\fp" +matches all ten characters of "weeknights", +when "\fi(.*).*\fp" is matched against "abc" the parenthesized subexpression +matches all three characters, and +when "\fi(a*)*\fp" is matched against "bc" +both the whole re and the parenthesized +subexpression match the null string. +.pp +if case-independent matching is specified, +the effect is much as if all case distinctions had vanished from the +alphabet. +when an alphabetic that exists in multiple cases appears as an +ordinary character outside a bracket expression, it is effectively +transformed into a bracket expression containing both cases, +for example, \(aqx\(aq becomes "\fi[xx]\fp". +when it appears inside a bracket expression, all case counterparts +of it are added to the bracket expression, so that, for example, "\fi[x]\fp" +becomes "\fi[xx]\fp" and "\fi[\(hax]\fp" becomes "\fi[\(haxx]\fp". +.pp +no particular limit is imposed on the length of res\*(dg. +programs intended to be portable should not employ res longer +than 256 bytes, +as an implementation can refuse to accept such res and remain +posix-compliant. +.pp +obsolete ("basic") regular expressions differ in several respects. +\(aq|\(aq, \(aq+\(aq, and \(aq?\(aq are +ordinary characters and there is no equivalent +for their functionality. +the delimiters for bounds are "\fi\e{\fp" and "\fi\e}\fp", +with \(aq{\(aq and \(aq}\(aq by themselves ordinary characters. +the parentheses for nested subexpressions are "\fi\e(\fp" and "\fi\e)\fp", +with \(aq(\(aq and \(aq)\(aq by themselves ordinary characters. +\(aq\(ha\(aq is an ordinary character except at the beginning of the +re or\*(dg the beginning of a parenthesized subexpression, +\(aq$\(aq is an ordinary character except at the end of the +re or\*(dg the end of a parenthesized subexpression, +and \(aq*\(aq is an ordinary character if it appears at the beginning of the +re or the beginning of a parenthesized subexpression +(after a possible leading \(aq\(ha\(aq). +.pp +finally, there is one new type of atom, a \fiback reference\fr: +\(aq\e\(aq followed by a nonzero decimal digit \fid\fr +matches the same sequence of characters +matched by the \fid\frth parenthesized subexpression +(numbering subexpressions by the positions of their opening parentheses, +left to right), +so that, for example, "\fi\e([bc]\e)\e1\fp" matches "bb" or "cc" but not "bc". +.sh bugs +having two kinds of res is a botch. +.pp +the current posix.2 spec says that \(aq)\(aq is an ordinary character in +the absence of an unmatched \(aq(\(aq; +this was an unintentional result of a wording error, +and change is likely. +avoid relying on it. +.pp +back references are a dreadful botch, +posing major problems for efficient implementations. +they are also somewhat vaguely defined +(does +"\fia\e(\e(b\e)*\e2\e)*d\fp" match "abbbd"?). +avoid using them. +.pp +posix.2's specification of case-independent matching is vague. +the "one case implies all cases" definition given above +is current consensus among implementors as to the right interpretation. +.\" as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=295666 +.\" the following does not seem to apply in the glibc implementation +.\" .pp +.\" the syntax for word boundaries is incredibly ugly. +.sh author +.\" sigh... the page license means we must have the author's name +.\" in the formatted output. +this page was taken from henry spencer's regex package. +.sh see also +.br grep (1), +.br regex (3) +.pp +posix.2, section 2.8 (regular expression notation). +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man7/system_data_types.7 + +.\" copyright (c) 2008 linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th pthread_create 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +pthread_create \- create a new thread +.sh synopsis +.nf +.b #include +.pp +.bi "int pthread_create(pthread_t *restrict " thread , +.bi " const pthread_attr_t *restrict " attr , +.bi " void *(*" start_routine ")(void *)," +.bi " void *restrict " arg ); +.fi +.pp +compile and link with \fi\-pthread\fp. +.sh description +the +.br pthread_create () +function starts a new thread in the calling process. +the new thread starts execution by invoking +.ir start_routine (); +.ir arg +is passed as the sole argument of +.ir start_routine (). +.pp +the new thread terminates in one of the following ways: +.ip * 2 +it calls +.br pthread_exit (3), +specifying an exit status value that is available to another thread +in the same process that calls +.br pthread_join (3). +.ip * +it returns from +.ir start_routine (). +this is equivalent to calling +.br pthread_exit (3) +with the value supplied in the +.i return +statement. +.ip * +it is canceled (see +.br pthread_cancel (3)). +.ip * +any of the threads in the process calls +.br exit (3), +or the main thread performs a return from +.ir main (). +this causes the termination of all threads in the process. +.pp +the +.i attr +argument points to a +.i pthread_attr_t +structure whose contents are used at thread creation time to +determine attributes for the new thread; +this structure is initialized using +.br pthread_attr_init (3) +and related functions. +if +.i attr +is null, +then the thread is created with default attributes. +.pp +before returning, a successful call to +.br pthread_create () +stores the id of the new thread in the buffer pointed to by +.ir thread ; +this identifier is used to refer to the thread +in subsequent calls to other pthreads functions. +.pp +the new thread inherits a copy of the creating thread's signal mask +.rb ( pthread_sigmask (3)). +the set of pending signals for the new thread is empty +.rb ( sigpending (2)). +the new thread does not inherit the creating thread's +alternate signal stack +.rb ( sigaltstack (2)). +.pp +the new thread inherits the calling thread's floating-point environment +.rb ( fenv (3)). +.pp +the initial value of the new thread's cpu-time clock is 0 +(see +.br pthread_getcpuclockid (3)). +.\" clock_thread_cputime_id in clock_gettime(2) +.ss linux-specific details +the new thread inherits copies of the calling thread's capability sets +(see +.br capabilities (7)) +and cpu affinity mask (see +.br sched_setaffinity (2)). +.sh return value +on success, +.br pthread_create () +returns 0; +on error, it returns an error number, and the contents of +.ir *thread +are undefined. +.sh errors +.tp +.b eagain +insufficient resources to create another thread. +.tp +.b eagain +.\" note! the following should match the description in fork(2) +a system-imposed limit on the number of threads was encountered. +there are a number of limits that may trigger this error: the +.br rlimit_nproc +soft resource limit (set via +.br setrlimit (2)), +which limits the number of processes and threads for a real user id, +was reached; +the kernel's system-wide limit on the number of processes and threads, +.ir /proc/sys/kernel/threads\-max , +was reached (see +.br proc (5)); +or the maximum number of pids, +.ir /proc/sys/kernel/pid_max , +was reached (see +.br proc (5)). +.tp +.b einval +invalid settings in +.ir attr . +.tp +.\" fixme . test the following +.b eperm +no permission to set the scheduling policy and parameters specified in +.ir attr . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br pthread_create () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +see +.br pthread_self (3) +for further information on the thread id returned in +.ir *thread +by +.br pthread_create (). +unless real-time scheduling policies are being employed, +after a call to +.br pthread_create (), +it is indeterminate which thread\(emthe caller or the new thread\(emwill +next execute. +.pp +a thread may either be +.i joinable +or +.ir detached . +if a thread is joinable, then another thread can call +.br pthread_join (3) +to wait for the thread to terminate and fetch its exit status. +only when a terminated joinable thread has been joined are +the last of its resources released back to the system. +when a detached thread terminates, +its resources are automatically released back to the system: +it is not possible to join with the thread in order to obtain +its exit status. +making a thread detached is useful for some types of daemon threads +whose exit status the application does not need to care about. +by default, a new thread is created in a joinable state, unless +.i attr +was set to create the thread in a detached state (using +.br pthread_attr_setdetachstate (3)). +.pp +under the nptl threading implementation, if the +.br rlimit_stack +soft resource limit +.ir "at the time the program started" +has any value other than "unlimited", +then it determines the default stack size of new threads. +using +.br pthread_attr_setstacksize (3), +the stack size attribute can be explicitly set in the +.i attr +argument used to create a thread, +in order to obtain a stack size other than the default. +if the +.br rlimit_stack +resource limit is set to "unlimited", +a per-architecture value is used for the stack size. +here is the value for a few architectures: +.rs +.ts +allbox; +lb lb +l r. +architecture default stack size +i386 2 mb +ia-64 32 mb +powerpc 4 mb +s/390 2 mb +sparc-32 2 mb +sparc-64 4 mb +x86_64 2 mb +.te +.re +.sh bugs +in the obsolete linuxthreads implementation, +each of the threads in a process has a different process id. +this is in violation of the posix threads specification, +and is the source of many other nonconformances to the standard; see +.br pthreads (7). +.sh examples +the program below demonstrates the use of +.br pthread_create (), +as well as a number of other functions in the pthreads api. +.pp +in the following run, +on a system providing the nptl threading implementation, +the stack size defaults to the value given by the +"stack size" resource limit: +.pp +.in +4n +.ex +.rb "$" " ulimit \-s" +8192 # the stack size limit is 8 mb (0x800000 bytes) +.rb "$" " ./a.out hola salut servus" +thread 1: top of stack near 0xb7dd03b8; argv_string=hola +thread 2: top of stack near 0xb75cf3b8; argv_string=salut +thread 3: top of stack near 0xb6dce3b8; argv_string=servus +joined with thread 1; returned value was hola +joined with thread 2; returned value was salut +joined with thread 3; returned value was servus +.ee +.in +.pp +in the next run, the program explicitly sets a stack size of 1\ mb (using +.br pthread_attr_setstacksize (3)) +for the created threads: +.pp +.in +4n +.ex +.rb "$" " ./a.out \-s 0x100000 hola salut servus" +thread 1: top of stack near 0xb7d723b8; argv_string=hola +thread 2: top of stack near 0xb7c713b8; argv_string=salut +thread 3: top of stack near 0xb7b703b8; argv_string=servus +joined with thread 1; returned value was hola +joined with thread 2; returned value was salut +joined with thread 3; returned value was servus +.ee +.in +.ss program source +\& +.ex +#include +#include +#include +#include +#include +#include +#include + +#define handle_error_en(en, msg) \e + do { errno = en; perror(msg); exit(exit_failure); } while (0) + +#define handle_error(msg) \e + do { perror(msg); exit(exit_failure); } while (0) + +struct thread_info { /* used as argument to thread_start() */ + pthread_t thread_id; /* id returned by pthread_create() */ + int thread_num; /* application\-defined thread # */ + char *argv_string; /* from command\-line argument */ +}; + +/* thread start function: display address near top of our stack, + and return upper\-cased copy of argv_string. */ + +static void * +thread_start(void *arg) +{ + struct thread_info *tinfo = arg; + char *uargv; + + printf("thread %d: top of stack near %p; argv_string=%s\en", + tinfo\->thread_num, (void *) &tinfo, tinfo\->argv_string); + + uargv = strdup(tinfo\->argv_string); + if (uargv == null) + handle_error("strdup"); + + for (char *p = uargv; *p != \(aq\e0\(aq; p++) + *p = toupper(*p); + + return uargv; +} + +int +main(int argc, char *argv[]) +{ + int s, opt, num_threads; + pthread_attr_t attr; + ssize_t stack_size; + void *res; + + /* the "\-s" option specifies a stack size for our threads. */ + + stack_size = \-1; + while ((opt = getopt(argc, argv, "s:")) != \-1) { + switch (opt) { + case \(aqs\(aq: + stack_size = strtoul(optarg, null, 0); + break; + + default: + fprintf(stderr, "usage: %s [\-s stack\-size] arg...\en", + argv[0]); + exit(exit_failure); + } + } + + num_threads = argc \- optind; + + /* initialize thread creation attributes. */ + + s = pthread_attr_init(&attr); + if (s != 0) + handle_error_en(s, "pthread_attr_init"); + + if (stack_size > 0) { + s = pthread_attr_setstacksize(&attr, stack_size); + if (s != 0) + handle_error_en(s, "pthread_attr_setstacksize"); + } + + /* allocate memory for pthread_create() arguments. */ + + struct thread_info *tinfo = calloc(num_threads, sizeof(*tinfo)); + if (tinfo == null) + handle_error("calloc"); + + /* create one thread for each command\-line argument. */ + + for (int tnum = 0; tnum < num_threads; tnum++) { + tinfo[tnum].thread_num = tnum + 1; + tinfo[tnum].argv_string = argv[optind + tnum]; + + /* the pthread_create() call stores the thread id into + corresponding element of tinfo[]. */ + + s = pthread_create(&tinfo[tnum].thread_id, &attr, + &thread_start, &tinfo[tnum]); + if (s != 0) + handle_error_en(s, "pthread_create"); + } + + /* destroy the thread attributes object, since it is no + longer needed. */ + + s = pthread_attr_destroy(&attr); + if (s != 0) + handle_error_en(s, "pthread_attr_destroy"); + + /* now join with each thread, and display its returned value. */ + + for (int tnum = 0; tnum < num_threads; tnum++) { + s = pthread_join(tinfo[tnum].thread_id, &res); + if (s != 0) + handle_error_en(s, "pthread_join"); + + printf("joined with thread %d; returned value was %s\en", + tinfo[tnum].thread_num, (char *) res); + free(res); /* free memory allocated by thread */ + } + + free(tinfo); + exit(exit_success); +} +.ee +.sh see also +.ad l +.nh +.br getrlimit (2), +.br pthread_attr_init (3), +.br pthread_cancel (3), +.br pthread_detach (3), +.br pthread_equal (3), +.br pthread_exit (3), +.br pthread_getattr_np (3), +.br pthread_join (3), +.br pthread_self (3), +.br pthread_setattr_default_np (3), +.br pthreads (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" +.\" corrected, aeb, 990824 +.th stpncpy 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +stpncpy \- copy a fixed-size string, returning a pointer to its end +.sh synopsis +.nf +.b #include +.pp +.bi "char *stpncpy(char *restrict " dest ", const char *restrict " src \ +", size_t " n ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br stpncpy (): +.nf + since glibc 2.10: + _posix_c_source >= 200809l + before glibc 2.10: + _gnu_source +.fi +.sh description +the +.br stpncpy () +function copies at most +.i n +characters from the string +pointed to by +.ir src , +including the terminating null byte (\(aq\e0\(aq), +to the array pointed to by +.ir dest . +exactly +.i n +characters are written at +.ir dest . +if the length +.i strlen(src) +is smaller than +.ir n , +the +remaining characters in the array pointed to by +.i dest +are filled +with null bytes (\(aq\e0\(aq), +if the length +.i strlen(src) +is greater than or equal to +.ir n , +the string pointed to by +.i dest +will +not be null-terminated. +.pp +the strings may not overlap. +.pp +the programmer must ensure that there is room for at least +.i n +characters +at +.ir dest . +.sh return value +.br stpncpy () +returns a pointer to the terminating null byte +in +.ir dest , +or, if +.i dest +is not null-terminated, +.ir dest + n . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br stpncpy () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +this function was added to posix.1-2008. +before that, it was a gnu extension. +it first appeared in version 1.07 of the gnu c library in 1993. +.sh see also +.br strncpy (3), +.br wcpncpy (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/setregid.2 + +.so man3/clog.3 + +.\" copyright 2001 john levon +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" additions, aeb, 2001-10-17. +.th clearenv 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +clearenv \- clear the environment +.sh synopsis +.nf +.b #include +.pp +.b "int clearenv(void);" +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br clearenv (): +.nf + /* glibc since 2.19: */ _default_source + || /* glibc <= 2.19: */ _svid_source || _bsd_source +.fi +.sh description +the +.br clearenv () +function clears the environment of all name-value +pairs and sets the value of the external variable +.i environ +to null. +after this call, new variables can be added to the environment using +.br putenv (3) +and +.br setenv (3). +.sh return value +the +.br clearenv () +function returns zero on success, and a nonzero +value on failure. +.\" most versions of unix return -1 on error, or do not even have errors. +.\" glibc info and the watcom c library document "a nonzero value". +.sh versions +available since glibc 2.0. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br clearenv () +t} thread safety mt-unsafe const:env +.te +.hy +.ad +.sp 1 +.sh conforming to +various unix variants (dg/ux, hp-ux, qnx, ...). +posix.9 (bindings for fortran77). +posix.1-1996 did not accept +.br clearenv () +and +.br putenv (3), +but changed its mind and scheduled these functions for some +later issue of this standard (see \[sc]b.4.6.1). +however, posix.1-2001 +adds only +.br putenv (3), +and rejected +.br clearenv (). +.sh notes +on systems where +.br clearenv () +is unavailable, the assignment +.pp +.in +4n +.ex +environ = null; +.ee +.in +.pp +will probably do. +.pp +the +.br clearenv () +function may be useful in security-conscious applications that want to +precisely control the environment that is passed to programs +executed using +.br exec (3). +the application would do this by first clearing the environment +and then adding select environment variables. +.pp +note that the main effect of +.br clearenv () +is to adjust the value of the pointer +.br environ (7); +this function does not erase the contents of the buffers +containing the environment definitions. +.pp +the dg/ux and tru64 man pages write: if +.i environ +has been modified by anything other than the +.br putenv (3), +.br getenv (3), +or +.br clearenv () +functions, then +.br clearenv () +will return an error and the process environment will remain unchanged. +.\" .lp +.\" hp-ux has a enomem error return. +.sh see also +.br getenv (3), +.br putenv (3), +.br setenv (3), +.br unsetenv (3), +.br environ (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1980, 1991 regents of the university of california. +.\" and copyright (c) 2011, michael kerrisk +.\" all rights reserved. +.\" +.\" %%%license_start(bsd_4_clause_ucb) +.\" redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. all advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" this product includes software developed by the university of +.\" california, berkeley and its contributors. +.\" 4. neither the name of the university nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" this software is provided by the regents and contributors ``as is'' and +.\" any express or implied warranties, including, but not limited to, the +.\" implied warranties of merchantability and fitness for a particular purpose +.\" are disclaimed. in no event shall the regents or contributors be liable +.\" for any direct, indirect, incidental, special, exemplary, or consequential +.\" damages (including, but not limited to, procurement of substitute goods +.\" or services; loss of use, data, or profits; or business interruption) +.\" however caused and on any theory of liability, whether in contract, strict +.\" liability, or tort (including negligence or otherwise) arising in any way +.\" out of the use of this software, even if advised of the possibility of +.\" such damage. +.\" %%%license_end +.\" +.\" @(#)lseek.2 6.5 (berkeley) 3/10/91 +.\" +.\" modified 1993-07-23 by rik faith +.\" modified 1995-06-10 by andries brouwer +.\" modified 1996-10-31 by eric s. raymond +.\" modified 1998-01-17 by michael haardt +.\" +.\" modified 2001-09-24 by michael haardt +.\" modified 2003-08-21 by andries brouwer +.\" 2011-09-18, mtk, added seek_data + seek_hole +.\" +.th lseek 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +lseek \- reposition read/write file offset +.sh synopsis +.nf +.b #include +.pp +.bi "off_t lseek(int " fd ", off_t " offset ", int " whence ); +.fi +.sh description +.br lseek () +repositions the file offset of the open file description +associated with the file descriptor +.i fd +to the argument +.i offset +according to the directive +.i whence +as follows: +.tp +.b seek_set +the file offset is set to +.i offset +bytes. +.tp +.b seek_cur +the file offset is set to its current location plus +.i offset +bytes. +.tp +.b seek_end +the file offset is set to the size of the file plus +.i offset +bytes. +.pp +.br lseek () +allows the file offset to be set beyond the end +of the file (but this does not change the size of the file). +if data is later written at this point, subsequent reads of the data +in the gap (a "hole") return null bytes (\(aq\e0\(aq) until +data is actually written into the gap. +.ss seeking file data and holes +since version 3.1, linux supports the following additional values for +.ir whence : +.tp +.b seek_data +adjust the file offset to the next location +in the file greater than or equal to +.i offset +containing data. +if +.i offset +points to data, +then the file offset is set to +.ir offset . +.tp +.b seek_hole +adjust the file offset to the next hole in the file +greater than or equal to +.ir offset . +if +.i offset +points into the middle of a hole, +then the file offset is set to +.ir offset . +if there is no hole past +.ir offset , +then the file offset is adjusted to the end of the file +(i.e., there is an implicit hole at the end of any file). +.pp +in both of the above cases, +.br lseek () +fails if +.i offset +points past the end of the file. +.pp +these operations allow applications to map holes in a sparsely +allocated file. +this can be useful for applications such as file backup tools, +which can save space when creating backups and preserve holes, +if they have a mechanism for discovering holes. +.pp +for the purposes of these operations, a hole is a sequence of zeros that +(normally) has not been allocated in the underlying file storage. +however, a filesystem is not obliged to report holes, +so these operations are not a guaranteed mechanism for +mapping the storage space actually allocated to a file. +(furthermore, a sequence of zeros that actually has been written +to the underlying storage may not be reported as a hole.) +in the simplest implementation, +a filesystem can support the operations by making +.br seek_hole +always return the offset of the end of the file, +and making +.br seek_data +always return +.ir offset +(i.e., even if the location referred to by +.i offset +is a hole, +it can be considered to consist of data that is a sequence of zeros). +.\" https://lkml.org/lkml/2011/4/22/79 +.\" http://lwn.net/articles/440255/ +.\" http://blogs.oracle.com/bonwick/entry/seek_hole_and_seek_data +.pp +the +.br _gnu_source +feature test macro must be defined in order to obtain the definitions of +.br seek_data +and +.br seek_hole +from +.ir . +.pp +the +.br seek_hole +and +.br seek_data +operations are supported for the following filesystems: +.ip * 3 +btrfs (since linux 3.1) +.ip * 3 +ocfs (since linux 3.2) +.\" commit 93862d5e1ab875664c6cc95254fc365028a48bb1 +.ip * +xfs (since linux 3.5) +.ip * +ext4 (since linux 3.8) +.ip * +.br tmpfs (5) +(since linux 3.8) +.ip * +nfs (since linux 3.18) +.\" commit 1c6dcbe5ceff81c2cf8d929646af675cd59fe7c0 +.\" commit 24bab491220faa446d945624086d838af41d616c +.ip * +fuse (since linux 4.5) +.\" commit 0b5da8db145bfd44266ac964a2636a0cf8d7c286 +.ip * +gfs2 (since linux 4.15) +.\" commit 3a27411cb4bc3ce31db228e3569ad01b462a4310 +.sh return value +upon successful completion, +.br lseek () +returns the resulting offset location as measured in bytes from the +beginning of the file. +on error, the value \fi(off_t)\ \-1\fp is returned and +.i errno +is set to indicate the error. +.sh errors +.tp +.b ebadf +.i fd +is not an open file descriptor. +.tp +.b einval +.i whence +is not valid. +or: the resulting file offset would be negative, +or beyond the end of a seekable device. +.\" some systems may allow negative offsets for character devices +.\" and/or for remote filesystems. +.tp +.b enxio +.i whence +is +.b seek_data +or +.br seek_hole , +and +.i offset +is beyond the end of the file, or +.i whence +is +.b seek_data +and +.i offset +is within a hole at the end of the file. +.tp +.b eoverflow +.\" hp-ux 11 says einval for this case (but posix.1 says eoverflow) +the resulting file offset cannot be represented in an +.ir off_t . +.tp +.b espipe +.i fd +is associated with a pipe, socket, or fifo. +.sh conforming to +posix.1-2001, posix.1-2008, svr4, 4.3bsd. +.pp +.br seek_data +and +.br seek_hole +are nonstandard extensions also present in solaris, +freebsd, and dragonfly bsd; +they are proposed for inclusion in the next posix revision (issue 8). +.\" fixme . review http://austingroupbugs.net/view.php?id=415 in the future +.sh notes +see +.br open (2) +for a discussion of the relationship between file descriptors, +open file descriptions, and files. +.pp +if the +.b o_append +file status flag is set on the open file description, +then a +.br write (2) +.i always +moves the file offset to the end of the file, regardless of the use of +.br lseek (). +.pp +the +.i off_t +data type is a signed integer data type specified by posix.1. +.pp +some devices are incapable of seeking and posix does not specify which +devices must support +.br lseek (). +.pp +on linux, using +.br lseek () +on a terminal device fails with the error +\fbespipe\fp. +.\" other systems return the number of written characters, +.\" using seek_set to set the counter. (of written characters.) +.sh see also +.br dup (2), +.br fallocate (2), +.br fork (2), +.br open (2), +.br fseek (3), +.br lseek64 (3), +.br posix_fallocate (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/getgid.2 + +.so man3/resolver.3 + +.so man2/eventfd.2 + +.\" copyright (c) 2003 andries brouwer (aeb@cwi.nl) +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th aio_error 3 2021-03-22 "" "linux programmer's manual" +.sh name +aio_error \- get error status of asynchronous i/o operation +.sh synopsis +.nf +.b "#include " +.pp +.bi "int aio_error(const struct aiocb *" aiocbp ); +.pp +link with \fi\-lrt\fp. +.fi +.sh description +the +.br aio_error () +function returns the error status for the asynchronous i/o request +with control block pointed to by +.ir aiocbp . +(see +.br aio (7) +for a description of the +.i aiocb +structure.) +.sh return value +this function returns one of the following: +.ip * 3 +.br einprogress , +if the request has not been +completed yet. +.ip * +.br ecanceled , +if the request was canceled. +.ip * +0, if the request completed successfully. +.ip * +a positive error number, if the asynchronous i/o operation failed. +this is the same value that would have been stored in the +.i errno +variable in the case of a synchronous +.br read (2), +.br write (2), +.br fsync (2), +or +.br fdatasync (2) +call. +.sh errors +.tp +.b einval +.i aiocbp +does not point at a control block for an asynchronous i/o request +of which the return status (see +.br aio_return (3)) +has not been retrieved yet. +.tp +.b enosys +.br aio_error () +is not implemented. +.sh versions +the +.br aio_error () +function is available since glibc 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br aio_error () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh examples +see +.br aio (7). +.sh see also +.br aio_cancel (3), +.br aio_fsync (3), +.br aio_read (3), +.br aio_return (3), +.br aio_suspend (3), +.br aio_write (3), +.br lio_listio (3), +.br aio (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man7/system_data_types.7 + +.\" copyright (c) 1992 drew eckhardt (drew@cs.colorado.edu), march 28, 1992 +.\" and copyright (c) 2006, 2014 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified by michael haardt +.\" modified 1993-07-21 by rik faith +.\" modified 1997-01-12 by michael haardt +.\" : nfs details +.\" modified 2004-06-23 by michael kerrisk +.\" +.th chmod 2 2021-08-27 "linux" "linux programmer's manual" +.sh name +chmod, fchmod, fchmodat \- change permissions of a file +.sh synopsis +.nf +.b #include +.pp +.bi "int chmod(const char *" pathname ", mode_t " mode ); +.bi "int fchmod(int " fd ", mode_t " mode ); +.pp +.br "#include " " /* definition of at_* constants */" +.b #include +.pp +.bi "int fchmodat(int " dirfd ", const char *" pathname ", mode_t " \ +mode ", int " flags ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.nf +.br fchmod (): + since glibc 2.24: + _posix_c_source >= 199309l +.\" || (_xopen_source && _xopen_source_extended) + glibc 2.19 to 2.23 + _posix_c_source + glibc 2.16 to 2.19: + _bsd_source || _posix_c_source + glibc 2.12 to 2.16: + _bsd_source || _xopen_source >= 500 + || _posix_c_source >= 200809l + glibc 2.11 and earlier: + _bsd_source || _xopen_source >= 500 +.\" || (_xopen_source && _xopen_source_extended) +.fi +.pp +.br fchmodat (): +.nf + since glibc 2.10: + _posix_c_source >= 200809l + before glibc 2.10: + _atfile_source +.fi +.sh description +the +.br chmod () +and +.br fchmod () +system calls change a file's mode bits. +(the file mode consists of the file permission bits plus the set-user-id, +set-group-id, and sticky bits.) +these system calls differ only in how the file is specified: +.ip * 2 +.br chmod () +changes the mode of the file specified whose pathname is given in +.ir pathname , +which is dereferenced if it is a symbolic link. +.ip * +.br fchmod () +changes the mode of the file referred to by the open file descriptor +.ir fd . +.pp +the new file mode is specified in +.ir mode , +which is a bit mask created by oring together zero or +more of the following: +.tp 18 +.br s_isuid " (04000)" +set-user-id (set process effective user id on +.br execve (2)) +.tp +.br s_isgid " (02000)" +set-group-id (set process effective group id on +.br execve (2); +mandatory locking, as described in +.br fcntl (2); +take a new file's group from parent directory, as described in +.br chown (2) +and +.br mkdir (2)) +.tp +.br s_isvtx " (01000)" +sticky bit (restricted deletion flag, as described in +.br unlink (2)) +.tp +.br s_irusr " (00400)" +read by owner +.tp +.br s_iwusr " (00200)" +write by owner +.tp +.br s_ixusr " (00100)" +execute/search by owner ("search" applies for directories, +and means that entries within the directory can be accessed) +.tp +.br s_irgrp " (00040)" +read by group +.tp +.br s_iwgrp " (00020)" +write by group +.tp +.br s_ixgrp " (00010)" +execute/search by group +.tp +.br s_iroth " (00004)" +read by others +.tp +.br s_iwoth " (00002)" +write by others +.tp +.br s_ixoth " (00001)" +execute/search by others +.pp +the effective uid of the calling process must match the owner of the file, +or the process must be privileged (linux: it must have the +.b cap_fowner +capability). +.pp +if the calling process is not privileged (linux: does not have the +.b cap_fsetid +capability), and the group of the file does not match +the effective group id of the process or one of its +supplementary group ids, the +.b s_isgid +bit will be turned off, +but this will not cause an error to be returned. +.pp +as a security measure, depending on the filesystem, +the set-user-id and set-group-id execution bits +may be turned off if a file is written. +(on linux, this occurs if the writing process does not have the +.b cap_fsetid +capability.) +on some filesystems, only the superuser can set the sticky bit, +which may have a special meaning. +for the sticky bit, and for set-user-id and set-group-id bits on +directories, see +.br inode (7). +.pp +on nfs filesystems, restricting the permissions will immediately influence +already open files, because the access control is done on the server, but +open files are maintained by the client. +widening the permissions may be +delayed for other clients if attribute caching is enabled on them. +.\" +.\" +.ss fchmodat() +the +.br fchmodat () +system call operates in exactly the same way as +.br chmod (), +except for the differences described here. +.pp +if the pathname given in +.i pathname +is relative, then it is interpreted relative to the directory +referred to by the file descriptor +.i dirfd +(rather than relative to the current working directory of +the calling process, as is done by +.br chmod () +for a relative pathname). +.pp +if +.i pathname +is relative and +.i dirfd +is the special value +.br at_fdcwd , +then +.i pathname +is interpreted relative to the current working +directory of the calling process (like +.br chmod ()). +.pp +if +.i pathname +is absolute, then +.i dirfd +is ignored. +.pp +.i flags +can either be 0, or include the following flag: +.tp +.b at_symlink_nofollow +if +.i pathname +is a symbolic link, do not dereference it: +instead operate on the link itself. +this flag is not currently implemented. +.pp +see +.br openat (2) +for an explanation of the need for +.br fchmodat (). +.sh return value +on success, zero is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +depending on the filesystem, +errors other than those listed below can be returned. +.pp +the more general errors for +.br chmod () +are listed below: +.tp +.b eacces +search permission is denied on a component of the path prefix. +(see also +.br path_resolution (7).) +.tp +.b ebadf +.rb ( fchmod ()) +the file descriptor +.i fd +is not valid. +.tp +.b ebadf +.rb ( fchmodat ()) +.i pathname +is relative but +.i dirfd +is neither +.b at_fdcwd +nor a valid file descriptor. +.tp +.b efault +.i pathname +points outside your accessible address space. +.tp +.b einval +.rb ( fchmodat ()) +invalid flag specified in +.ir flags . +.tp +.b eio +an i/o error occurred. +.tp +.b eloop +too many symbolic links were encountered in resolving +.ir pathname . +.tp +.b enametoolong +.i pathname +is too long. +.tp +.b enoent +the file does not exist. +.tp +.b enomem +insufficient kernel memory was available. +.tp +.b enotdir +a component of the path prefix is not a directory. +.tp +.b enotdir +.rb ( fchmodat ()) +.i pathname +is relative and +.i dirfd +is a file descriptor referring to a file other than a directory. +.tp +.b enotsup +.rb ( fchmodat ()) +.i flags +specified +.br at_symlink_nofollow , +which is not supported. +.tp +.b eperm +the effective uid does not match the owner of the file, +and the process is not privileged (linux: it does not have the +.b cap_fowner +capability). +.tp +.b eperm +the file is marked immutable or append-only. +(see +.br ioctl_iflags (2).) +.tp +.b erofs +the named file resides on a read-only filesystem. +.sh versions +.br fchmodat () +was added to linux in kernel 2.6.16; +library support was added to glibc in version 2.4. +.sh conforming to +.br chmod (), +.br fchmod (): +4.4bsd, svr4, posix.1-2001i, posix.1-2008. +.pp +.br fchmodat (): +posix.1-2008. +.sh notes +.ss c library/kernel differences +the gnu c library +.br fchmodat () +wrapper function implements the posix-specified +interface described in this page. +this interface differs from the underlying linux system call, which does +.i not +have a +.i flags +argument. +.ss glibc notes +on older kernels where +.br fchmodat () +is unavailable, the glibc wrapper function falls back to the use of +.br chmod (). +when +.i pathname +is a relative pathname, +glibc constructs a pathname based on the symbolic link in +.ir /proc/self/fd +that corresponds to the +.ir dirfd +argument. +.sh see also +.br chmod (1), +.br chown (2), +.br execve (2), +.br open (2), +.br stat (2), +.br inode (7), +.br path_resolution (7), +.br symlink (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2016, ibm corporation. +.\" written by mike rapoport +.\" and copyright (c) 2017 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th userfaultfd 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +userfaultfd \- create a file descriptor for handling page faults in user space +.sh synopsis +.nf +.br "#include " " /* definition of " o_* " constants */" +.br "#include " " /* definition of " sys_* " constants */" +.b #include +.pp +.bi "int syscall(sys_userfaultfd, int " flags ); +.fi +.pp +.ir note : +glibc provides no wrapper for +.br userfaultfd (), +necessitating the use of +.br syscall (2). +.sh description +.br userfaultfd () +creates a new userfaultfd object that can be used for delegation of page-fault +handling to a user-space application, +and returns a file descriptor that refers to the new object. +the new userfaultfd object is configured using +.br ioctl (2). +.pp +once the userfaultfd object is configured, the application can use +.br read (2) +to receive userfaultfd notifications. +the reads from userfaultfd may be blocking or non-blocking, +depending on the value of +.i flags +used for the creation of the userfaultfd or subsequent calls to +.br fcntl (2). +.pp +the following values may be bitwise ored in +.ir flags +to change the behavior of +.br userfaultfd (): +.tp +.br o_cloexec +enable the close-on-exec flag for the new userfaultfd file descriptor. +see the description of the +.b o_cloexec +flag in +.br open (2). +.tp +.br o_nonblock +enables non-blocking operation for the userfaultfd object. +see the description of the +.br o_nonblock +flag in +.br open (2). +.pp +when the last file descriptor referring to a userfaultfd object is closed, +all memory ranges that were registered with the object are unregistered +and unread events are flushed. +.\" +.pp +userfaultfd supports two modes of registration: +.tp +.br uffdio_register_mode_missing " (since 4.10)" +when registered with +.b uffdio_register_mode_missing +mode, user-space will receive a page-fault notification +when a missing page is accessed. +the faulted thread will be stopped from execution until the page fault is +resolved from user-space by either an +.b uffdio_copy +or an +.b uffdio_zeropage +ioctl. +.tp +.br uffdio_register_mode_wp " (since 5.7)" +when registered with +.b uffdio_register_mode_wp +mode, user-space will receive a page-fault notification +when a write-protected page is written. +the faulted thread will be stopped from execution +until user-space write-unprotects the page using an +.b uffdio_writeprotect +ioctl. +.pp +multiple modes can be enabled at the same time for the same memory range. +.pp +since linux 4.14, a userfaultfd page-fault notification can selectively embed +faulting thread id information into the notification. +one needs to enable this feature explicitly using the +.b uffd_feature_thread_id +feature bit when initializing the userfaultfd context. +by default, thread id reporting is disabled. +.ss usage +the userfaultfd mechanism is designed to allow a thread in a multithreaded +program to perform user-space paging for the other threads in the process. +when a page fault occurs for one of the regions registered +to the userfaultfd object, +the faulting thread is put to sleep and +an event is generated that can be read via the userfaultfd file descriptor. +the fault-handling thread reads events from this file descriptor and services +them using the operations described in +.br ioctl_userfaultfd (2). +when servicing the page fault events, +the fault-handling thread can trigger a wake-up for the sleeping thread. +.pp +it is possible for the faulting threads and the fault-handling threads +to run in the context of different processes. +in this case, these threads may belong to different programs, +and the program that executes the faulting threads +will not necessarily cooperate with the program that handles the page faults. +in such non-cooperative mode, +the process that monitors userfaultfd and handles page faults +needs to be aware of the changes in the virtual memory layout +of the faulting process to avoid memory corruption. +.pp +since linux 4.11, +userfaultfd can also notify the fault-handling threads about changes +in the virtual memory layout of the faulting process. +in addition, if the faulting process invokes +.br fork (2), +the userfaultfd objects associated with the parent may be duplicated +into the child process and the userfaultfd monitor will be notified +(via the +.b uffd_event_fork +described below) +about the file descriptor associated with the userfault objects +created for the child process, +which allows the userfaultfd monitor to perform user-space paging +for the child process. +unlike page faults which have to be synchronous and require an +explicit or implicit wakeup, +all other events are delivered asynchronously and +the non-cooperative process resumes execution as +soon as the userfaultfd manager executes +.br read (2). +the userfaultfd manager should carefully synchronize calls to +.b uffdio_copy +with the processing of events. +.pp +the current asynchronous model of the event delivery is optimal for +single threaded non-cooperative userfaultfd manager implementations. +.\" regarding the preceding sentence, mike rapoport says: +.\" the major point here is that current events delivery model could be +.\" problematic for multi-threaded monitor. i even suspect that it would be +.\" impossible to ensure synchronization between page faults and non-page +.\" fault events in multi-threaded monitor. +.\" .pp +.\" fixme elaborate about non-cooperating mode, describe its limitations +.\" for kernels before 4.11, features added in 4.11 +.\" and limitations remaining in 4.11 +.\" maybe it's worth adding a dedicated sub-section... +.\" +.pp +since linux 5.7, userfaultfd is able to do +synchronous page dirty tracking using the new write-protect register mode. +one should check against the feature bit +.b uffd_feature_pagefault_flag_wp +before using this feature. +similar to the original userfaultfd missing mode, the write-protect mode will +generate a userfaultfd notification when the protected page is written. +the user needs to resolve the page fault by unprotecting the faulted page and +kicking the faulted thread to continue. +for more information, +please refer to the "userfaultfd write-protect mode" section. +.\" +.ss userfaultfd operation +after the userfaultfd object is created with +.br userfaultfd (), +the application must enable it using the +.b uffdio_api +.br ioctl (2) +operation. +this operation allows a handshake between the kernel and user space +to determine the api version and supported features. +this operation must be performed before any of the other +.br ioctl (2) +operations described below (or those operations fail with the +.br einval +error). +.pp +after a successful +.b uffdio_api +operation, +the application then registers memory address ranges using the +.b uffdio_register +.br ioctl (2) +operation. +after successful completion of a +.b uffdio_register +operation, +a page fault occurring in the requested memory range, and satisfying +the mode defined at the registration time, will be forwarded by the kernel to +the user-space application. +the application can then use the +.b uffdio_copy +or +.b uffdio_zeropage +.br ioctl (2) +operations to resolve the page fault. +.pp +since linux 4.14, if the application sets the +.b uffd_feature_sigbus +feature bit using the +.b uffdio_api +.br ioctl (2), +no page-fault notification will be forwarded to user space. +instead a +.b sigbus +signal is delivered to the faulting process. +with this feature, +userfaultfd can be used for robustness purposes to simply catch +any access to areas within the registered address range that do not +have pages allocated, without having to listen to userfaultfd events. +no userfaultfd monitor will be required for dealing with such memory +accesses. +for example, this feature can be useful for applications that +want to prevent the kernel from automatically allocating pages and filling +holes in sparse files when the hole is accessed through a memory mapping. +.pp +the +.b uffd_feature_sigbus +feature is implicitly inherited through +.br fork (2) +if used in combination with +.br uffd_feature_fork . +.pp +details of the various +.br ioctl (2) +operations can be found in +.br ioctl_userfaultfd (2). +.pp +since linux 4.11, events other than page-fault may enabled during +.b uffdio_api +operation. +.pp +up to linux 4.11, +userfaultfd can be used only with anonymous private memory mappings. +since linux 4.11, +userfaultfd can be also used with hugetlbfs and shared memory mappings. +.\" +.ss userfaultfd write-protect mode (since 5.7) +since linux 5.7, userfaultfd supports write-protect mode. +the user needs to first check availability of this feature using +.b uffdio_api +ioctl against the feature bit +.b uffd_feature_pagefault_flag_wp +before using this feature. +.pp +to register with userfaultfd write-protect mode, the user needs to initiate the +.b uffdio_register +ioctl with mode +.b uffdio_register_mode_wp +set. +note that it is legal to monitor the same memory range with multiple modes. +for example, the user can do +.b uffdio_register +with the mode set to +.br "uffdio_register_mode_missing | uffdio_register_mode_wp" . +when there is only +.b uffdio_register_mode_wp +registered, user-space will +.i not +receive any notification when a missing page is written. +instead, user-space will receive a write-protect page-fault notification +only when an existing but write-protected page got written. +.pp +after the +.b uffdio_register +ioctl completed with +.b uffdio_register_mode_wp +mode set, +the user can write-protect any existing memory within the range using the ioctl +.b uffdio_writeprotect +where +.i uffdio_writeprotect.mode +should be set to +.br uffdio_writeprotect_mode_wp . +.pp +when a write-protect event happens, +user-space will receive a page-fault notification whose +.i uffd_msg.pagefault.flags +will be with +.b uffd_pagefault_flag_wp +flag set. +note: since only writes can trigger this kind of fault, +write-protect notifications will always have the +.b uffd_pagefault_flag_write +bit set along with the +.br uffd_pagefault_flag_wp +bit. +.pp +to resolve a write-protection page fault, the user should initiate another +.b uffdio_writeprotect +ioctl, whose +.i uffd_msg.pagefault.flags +should have the flag +.b uffdio_writeprotect_mode_wp +cleared upon the faulted page or range. +.pp +write-protect mode supports only private anonymous memory. +.ss reading from the userfaultfd structure +each +.br read (2) +from the userfaultfd file descriptor returns one or more +.i uffd_msg +structures, each of which describes a page-fault event +or an event required for the non-cooperative userfaultfd usage: +.pp +.in +4n +.ex +struct uffd_msg { + __u8 event; /* type of event */ + ... + union { + struct { + __u64 flags; /* flags describing fault */ + __u64 address; /* faulting address */ + union { + __u32 ptid; /* thread id of the fault */ + } feat; + } pagefault; + + struct { /* since linux 4.11 */ + __u32 ufd; /* userfault file descriptor + of the child process */ + } fork; + + struct { /* since linux 4.11 */ + __u64 from; /* old address of remapped area */ + __u64 to; /* new address of remapped area */ + __u64 len; /* original mapping length */ + } remap; + + struct { /* since linux 4.11 */ + __u64 start; /* start address of removed area */ + __u64 end; /* end address of removed area */ + } remove; + ... + } arg; + + /* padding fields omitted */ +} __packed; +.ee +.in +.pp +if multiple events are available and the supplied buffer is large enough, +.br read (2) +returns as many events as will fit in the supplied buffer. +if the buffer supplied to +.br read (2) +is smaller than the size of the +.i uffd_msg +structure, the +.br read (2) +fails with the error +.br einval . +.pp +the fields set in the +.i uffd_msg +structure are as follows: +.tp +.i event +the type of event. +depending of the event type, +different fields of the +.i arg +union represent details required for the event processing. +the non-page-fault events are generated only when appropriate feature +is enabled during api handshake with +.b uffdio_api +.br ioctl (2). +.ip +the following values can appear in the +.i event +field: +.rs +.tp +.br uffd_event_pagefault " (since linux 4.3)" +a page-fault event. +the page-fault details are available in the +.i pagefault +field. +.tp +.br uffd_event_fork " (since linux 4.11)" +generated when the faulting process invokes +.br fork (2) +(or +.br clone (2) +without the +.br clone_vm +flag). +the event details are available in the +.i fork +field. +.\" fixme describe duplication of userfault file descriptor during fork +.tp +.br uffd_event_remap " (since linux 4.11)" +generated when the faulting process invokes +.br mremap (2). +the event details are available in the +.i remap +field. +.tp +.br uffd_event_remove " (since linux 4.11)" +generated when the faulting process invokes +.br madvise (2) +with +.br madv_dontneed +or +.br madv_remove +advice. +the event details are available in the +.i remove +field. +.tp +.br uffd_event_unmap " (since linux 4.11)" +generated when the faulting process unmaps a memory range, +either explicitly using +.br munmap (2) +or implicitly during +.br mmap (2) +or +.br mremap (2). +the event details are available in the +.i remove +field. +.re +.tp +.i pagefault.address +the address that triggered the page fault. +.tp +.i pagefault.flags +a bit mask of flags that describe the event. +for +.br uffd_event_pagefault , +the following flag may appear: +.rs +.tp +.b uffd_pagefault_flag_write +if the address is in a range that was registered with the +.b uffdio_register_mode_missing +flag (see +.br ioctl_userfaultfd (2)) +and this flag is set, this a write fault; +otherwise it is a read fault. +.tp +.b uffd_pagefault_flag_wp +if the address is in a range that was registered with the +.b uffdio_register_mode_wp +flag, when this bit is set, it means it is a write-protect fault. +otherwise it is a page-missing fault. +.re +.tp +.i pagefault.feat.pid +the thread id that triggered the page fault. +.tp +.i fork.ufd +the file descriptor associated with the userfault object +created for the child created by +.br fork (2). +.tp +.i remap.from +the original address of the memory range that was remapped using +.br mremap (2). +.tp +.i remap.to +the new address of the memory range that was remapped using +.br mremap (2). +.tp +.i remap.len +the original length of the memory range that was remapped using +.br mremap (2). +.tp +.i remove.start +the start address of the memory range that was freed using +.br madvise (2) +or unmapped +.tp +.i remove.end +the end address of the memory range that was freed using +.br madvise (2) +or unmapped +.pp +a +.br read (2) +on a userfaultfd file descriptor can fail with the following errors: +.tp +.b einval +the userfaultfd object has not yet been enabled using the +.br uffdio_api +.br ioctl (2) +operation +.pp +if the +.b o_nonblock +flag is enabled in the associated open file description, +the userfaultfd file descriptor can be monitored with +.br poll (2), +.br select (2), +and +.br epoll (7). +when events are available, the file descriptor indicates as readable. +if the +.b o_nonblock +flag is not enabled, then +.br poll (2) +(always) indicates the file as having a +.br pollerr +condition, and +.br select (2) +indicates the file descriptor as both readable and writable. +.\" fixme what is the reason for this seemingly odd behavior with respect +.\" to the o_nonblock flag? (see userfaultfd_poll() in fs/userfaultfd.c). +.\" something needs to be said about this. +.sh return value +on success, +.br userfaultfd () +returns a new file descriptor that refers to the userfaultfd object. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b einval +an unsupported value was specified in +.ir flags . +.tp +.br emfile +the per-process limit on the number of open file descriptors has been +reached +.tp +.b enfile +the system-wide limit on the total number of open files has been +reached. +.tp +.b enomem +insufficient kernel memory was available. +.tp +.br eperm " (since linux 5.2)" +.\" cefdca0a86be517bc390fc4541e3674b8e7803b0 +the caller is not privileged (does not have the +.b cap_sys_ptrace +capability in the initial user namespace), and +.i /proc/sys/vm/unprivileged_userfaultfd +has the value 0. +.sh versions +the +.br userfaultfd () +system call first appeared in linux 4.3. +.pp +the support for hugetlbfs and shared memory areas and +non-page-fault events was added in linux 4.11 +.sh conforming to +.br userfaultfd () +is linux-specific and should not be used in programs intended to be +portable. +.sh notes +the userfaultfd mechanism can be used as an alternative to +traditional user-space paging techniques based on the use of the +.br sigsegv +signal and +.br mmap (2). +it can also be used to implement lazy restore +for checkpoint/restore mechanisms, +as well as post-copy migration to allow (nearly) uninterrupted execution +when transferring virtual machines and linux containers +from one host to another. +.sh bugs +if the +.b uffd_feature_event_fork +is enabled and a system call from the +.br fork (2) +family is interrupted by a signal or failed, a stale userfaultfd descriptor +might be created. +in this case, a spurious +.b uffd_event_fork +will be delivered to the userfaultfd monitor. +.sh examples +the program below demonstrates the use of the userfaultfd mechanism. +the program creates two threads, one of which acts as the +page-fault handler for the process, for the pages in a demand-page zero +region created using +.br mmap (2). +.pp +the program takes one command-line argument, +which is the number of pages that will be created in a mapping +whose page faults will be handled via userfaultfd. +after creating a userfaultfd object, +the program then creates an anonymous private mapping of the specified size +and registers the address range of that mapping using the +.b uffdio_register +.br ioctl (2) +operation. +the program then creates a second thread that will perform the +task of handling page faults. +.pp +the main thread then walks through the pages of the mapping fetching +bytes from successive pages. +because the pages have not yet been accessed, +the first access of a byte in each page will trigger a page-fault event +on the userfaultfd file descriptor. +.pp +each of the page-fault events is handled by the second thread, +which sits in a loop processing input from the userfaultfd file descriptor. +in each loop iteration, the second thread first calls +.br poll (2) +to check the state of the file descriptor, +and then reads an event from the file descriptor. +all such events should be +.b uffd_event_pagefault +events, +which the thread handles by copying a page of data into +the faulting region using the +.b uffdio_copy +.br ioctl (2) +operation. +.pp +the following is an example of what we see when running the program: +.pp +.in +4n +.ex +$ \fb./userfaultfd_demo 3\fp +address returned by mmap() = 0x7fd30106c000 + +fault_handler_thread(): + poll() returns: nready = 1; pollin = 1; pollerr = 0 + uffd_event_pagefault event: flags = 0; address = 7fd30106c00f + (uffdio_copy.copy returned 4096) +read address 0x7fd30106c00f in main(): a +read address 0x7fd30106c40f in main(): a +read address 0x7fd30106c80f in main(): a +read address 0x7fd30106cc0f in main(): a + +fault_handler_thread(): + poll() returns: nready = 1; pollin = 1; pollerr = 0 + uffd_event_pagefault event: flags = 0; address = 7fd30106d00f + (uffdio_copy.copy returned 4096) +read address 0x7fd30106d00f in main(): b +read address 0x7fd30106d40f in main(): b +read address 0x7fd30106d80f in main(): b +read address 0x7fd30106dc0f in main(): b + +fault_handler_thread(): + poll() returns: nready = 1; pollin = 1; pollerr = 0 + uffd_event_pagefault event: flags = 0; address = 7fd30106e00f + (uffdio_copy.copy returned 4096) +read address 0x7fd30106e00f in main(): c +read address 0x7fd30106e40f in main(): c +read address 0x7fd30106e80f in main(): c +read address 0x7fd30106ec0f in main(): c +.ee +.in +.ss program source +\& +.ex +/* userfaultfd_demo.c + + licensed under the gnu general public license version 2 or later. +*/ +#define _gnu_source +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define errexit(msg) do { perror(msg); exit(exit_failure); \e + } while (0) + +static int page_size; + +static void * +fault_handler_thread(void *arg) +{ + static struct uffd_msg msg; /* data read from userfaultfd */ + static int fault_cnt = 0; /* number of faults so far handled */ + long uffd; /* userfaultfd file descriptor */ + static char *page = null; + struct uffdio_copy uffdio_copy; + ssize_t nread; + + uffd = (long) arg; + + /* create a page that will be copied into the faulting region. */ + + if (page == null) { + page = mmap(null, page_size, prot_read | prot_write, + map_private | map_anonymous, \-1, 0); + if (page == map_failed) + errexit("mmap"); + } + + /* loop, handling incoming events on the userfaultfd + file descriptor. */ + + for (;;) { + + /* see what poll() tells us about the userfaultfd. */ + + struct pollfd pollfd; + int nready; + pollfd.fd = uffd; + pollfd.events = pollin; + nready = poll(&pollfd, 1, \-1); + if (nready == \-1) + errexit("poll"); + + printf("\enfault_handler_thread():\en"); + printf(" poll() returns: nready = %d; " + "pollin = %d; pollerr = %d\en", nready, + (pollfd.revents & pollin) != 0, + (pollfd.revents & pollerr) != 0); + + /* read an event from the userfaultfd. */ + + nread = read(uffd, &msg, sizeof(msg)); + if (nread == 0) { + printf("eof on userfaultfd!\en"); + exit(exit_failure); + } + + if (nread == \-1) + errexit("read"); + + /* we expect only one kind of event; verify that assumption. */ + + if (msg.event != uffd_event_pagefault) { + fprintf(stderr, "unexpected event on userfaultfd\en"); + exit(exit_failure); + } + + /* display info about the page\-fault event. */ + + printf(" uffd_event_pagefault event: "); + printf("flags = %"prix64"; ", msg.arg.pagefault.flags); + printf("address = %"prix64"\en", msg.arg.pagefault.address); + + /* copy the page pointed to by \(aqpage\(aq into the faulting + region. vary the contents that are copied in, so that it + is more obvious that each fault is handled separately. */ + + memset(page, \(aqa\(aq + fault_cnt % 20, page_size); + fault_cnt++; + + uffdio_copy.src = (unsigned long) page; + + /* we need to handle page faults in units of pages(!). + so, round faulting address down to page boundary. */ + + uffdio_copy.dst = (unsigned long) msg.arg.pagefault.address & + \(ti(page_size \- 1); + uffdio_copy.len = page_size; + uffdio_copy.mode = 0; + uffdio_copy.copy = 0; + if (ioctl(uffd, uffdio_copy, &uffdio_copy) == \-1) + errexit("ioctl\-uffdio_copy"); + + printf(" (uffdio_copy.copy returned %"prid64")\en", + uffdio_copy.copy); + } +} + +int +main(int argc, char *argv[]) +{ + long uffd; /* userfaultfd file descriptor */ + char *addr; /* start of region handled by userfaultfd */ + uint64_t len; /* length of region handled by userfaultfd */ + pthread_t thr; /* id of thread that handles page faults */ + struct uffdio_api uffdio_api; + struct uffdio_register uffdio_register; + int s; + + if (argc != 2) { + fprintf(stderr, "usage: %s num\-pages\en", argv[0]); + exit(exit_failure); + } + + page_size = sysconf(_sc_page_size); + len = strtoull(argv[1], null, 0) * page_size; + + /* create and enable userfaultfd object. */ + + uffd = syscall(__nr_userfaultfd, o_cloexec | o_nonblock); + if (uffd == \-1) + errexit("userfaultfd"); + + uffdio_api.api = uffd_api; + uffdio_api.features = 0; + if (ioctl(uffd, uffdio_api, &uffdio_api) == \-1) + errexit("ioctl\-uffdio_api"); + + /* create a private anonymous mapping. the memory will be + demand\-zero paged\-\-that is, not yet allocated. when we + actually touch the memory, it will be allocated via + the userfaultfd. */ + + addr = mmap(null, len, prot_read | prot_write, + map_private | map_anonymous, \-1, 0); + if (addr == map_failed) + errexit("mmap"); + + printf("address returned by mmap() = %p\en", addr); + + /* register the memory range of the mapping we just created for + handling by the userfaultfd object. in mode, we request to track + missing pages (i.e., pages that have not yet been faulted in). */ + + uffdio_register.range.start = (unsigned long) addr; + uffdio_register.range.len = len; + uffdio_register.mode = uffdio_register_mode_missing; + if (ioctl(uffd, uffdio_register, &uffdio_register) == \-1) + errexit("ioctl\-uffdio_register"); + + /* create a thread that will process the userfaultfd events. */ + + s = pthread_create(&thr, null, fault_handler_thread, (void *) uffd); + if (s != 0) { + errno = s; + errexit("pthread_create"); + } + + /* main thread now touches memory in the mapping, touching + locations 1024 bytes apart. this will trigger userfaultfd + events for all pages in the region. */ + + int l; + l = 0xf; /* ensure that faulting address is not on a page + boundary, in order to test that we correctly + handle that case in fault_handling_thread(). */ + while (l < len) { + char c = addr[l]; + printf("read address %p in main(): ", addr + l); + printf("%c\en", c); + l += 1024; + usleep(100000); /* slow things down a little */ + } + + exit(exit_success); +} +.ee +.sh see also +.br fcntl (2), +.br ioctl (2), +.br ioctl_userfaultfd (2), +.br madvise (2), +.br mmap (2) +.pp +.ir documentation/admin\-guide/mm/userfaultfd.rst +in the linux kernel source tree +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/argz_add.3 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sat jul 24 19:48:17 1993 by rik faith (faith@cs.unc.edu) +.th difftime 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +difftime \- calculate time difference +.sh synopsis +.nf +.b #include +.pp +.bi "double difftime(time_t " time1 ", time_t " time0 ); +.fi +.sh description +the +.br difftime () +function returns the number of seconds elapsed +between time \fitime1\fp and time \fitime0\fp, represented as a +.ir double . +each of the times is specified in calendar time, which means its +value is a measurement (in seconds) relative to the +epoch, 1970-01-01 00:00:00 +0000 (utc). +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br difftime () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c89, c99, svr4, 4.3bsd. +.sh notes +on a posix system, +.i time_t +is an arithmetic type, and one could just +define +.pp +.in +4n +.ex +#define difftime(t1,t0) (double)(t1 \- t0) +.ee +.in +.pp +when the possible overflow in the subtraction is not a concern. +.sh see also +.br date (1), +.br gettimeofday (2), +.br time (2), +.br ctime (3), +.br gmtime (3), +.br localtime (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/fmax.3 + +.so man3/cabs.3 + +.\" this man page is copyright (c) 1999 andi kleen . +.\" +.\" %%%license_start(verbatim_one_para) +.\" permission is granted to distribute possibly modified copies +.\" of this page provided the header is included verbatim, +.\" and in case of nontrivial modification author and date +.\" of the modification is added to the header. +.\" %%%license_end +.\" +.\" $id: udp.7,v 1.7 2000/01/22 01:55:05 freitag exp $ +.\" +.th udp 7 2021-03-22 "linux" "linux programmer's manual" +.sh name +udp \- user datagram protocol for ipv4 +.sh synopsis +.nf +.b #include +.b #include +.b #include +.pp +.b udp_socket = socket(af_inet, sock_dgram, 0); +.fi +.sh description +this is an implementation of the user datagram protocol +described in rfc\ 768. +it implements a connectionless, unreliable datagram packet service. +packets may be reordered or duplicated before they arrive. +udp generates and checks checksums to catch transmission errors. +.pp +when a udp socket is created, +its local and remote addresses are unspecified. +datagrams can be sent immediately using +.br sendto (2) +or +.br sendmsg (2) +with a valid destination address as an argument. +when +.br connect (2) +is called on the socket, the default destination address is set and +datagrams can now be sent using +.br send (2) +or +.br write (2) +without specifying a destination address. +it is still possible to send to other destinations by passing an +address to +.br sendto (2) +or +.br sendmsg (2). +in order to receive packets, the socket can be bound to a local +address first by using +.br bind (2). +otherwise, the socket layer will automatically assign +a free local port out of the range defined by +.i /proc/sys/net/ipv4/ip_local_port_range +and bind the socket to +.br inaddr_any . +.pp +all receive operations return only one packet. +when the packet is smaller than the passed buffer, only that much +data is returned; when it is bigger, the packet is truncated and the +.b msg_trunc +flag is set. +.b msg_waitall +is not supported. +.pp +ip options may be sent or received using the socket options described in +.br ip (7). +they are processed by the kernel only when the appropriate +.i /proc +parameter +is enabled (but still passed to the user even when it is turned off). +see +.br ip (7). +.pp +when the +.b msg_dontroute +flag is set on sending, the destination address must refer to a local +interface address and the packet is sent only to that interface. +.pp +by default, linux udp does path mtu (maximum transmission unit) discovery. +this means the kernel +will keep track of the mtu to a specific target ip address and return +.b emsgsize +when a udp packet write exceeds it. +when this happens, the application should decrease the packet size. +path mtu discovery can be also turned off using the +.b ip_mtu_discover +socket option or the +.i /proc/sys/net/ipv4/ip_no_pmtu_disc +file; see +.br ip (7) +for details. +when turned off, udp will fragment outgoing udp packets +that exceed the interface mtu. +however, disabling it is not recommended +for performance and reliability reasons. +.ss address format +udp uses the ipv4 +.i sockaddr_in +address format described in +.br ip (7). +.ss error handling +all fatal errors will be passed to the user as an error return even +when the socket is not connected. +this includes asynchronous errors +received from the network. +you may get an error for an earlier packet +that was sent on the same socket. +this behavior differs from many other bsd socket implementations +which don't pass any errors unless the socket is connected. +linux's behavior is mandated by +.br rfc\ 1122 . +.pp +for compatibility with legacy code, in linux 2.0 and 2.2 +it was possible to set the +.b so_bsdcompat +.b sol_socket +option to receive remote errors only when the socket has been +connected (except for +.b eproto +and +.br emsgsize ). +locally generated errors are always passed. +support for this socket option was removed in later kernels; see +.br socket (7) +for further information. +.pp +when the +.b ip_recverr +option is enabled, all errors are stored in the socket error queue, +and can be received by +.br recvmsg (2) +with the +.b msg_errqueue +flag set. +.ss /proc interfaces +system-wide udp parameter settings can be accessed by files in the directory +.ir /proc/sys/net/ipv4/ . +.tp +.ir udp_mem " (since linux 2.6.25)" +this is a vector of three integers governing the number +of pages allowed for queueing by all udp sockets. +.rs +.tp +.i min +below this number of pages, udp is not bothered about its +memory appetite. +when the amount of memory allocated by udp exceeds +this number, udp starts to moderate memory usage. +.tp +.i pressure +this value was introduced to follow the format of +.ir tcp_mem +(see +.br tcp (7)). +.tp +.i max +number of pages allowed for queueing by all udp sockets. +.re +.ip +defaults values for these three items are +calculated at boot time from the amount of available memory. +.tp +.ir udp_rmem_min " (integer; default value: page_size; since linux 2.6.25)" +minimal size, in bytes, of receive buffers used by udp sockets in moderation. +each udp socket is able to use the size for receiving data, +even if total pages of udp sockets exceed +.i udp_mem +pressure. +.tp +.ir udp_wmem_min " (integer; default value: page_size; since linux 2.6.25)" +minimal size, in bytes, of send buffer used by udp sockets in moderation. +each udp socket is able to use the size for sending data, +even if total pages of udp sockets exceed +.i udp_mem +pressure. +.ss socket options +to set or get a udp socket option, call +.br getsockopt (2) +to read or +.br setsockopt (2) +to write the option with the option level argument set to +.br ipproto_udp . +unless otherwise noted, +.i optval +is a pointer to an +.ir int . +.pp +following is a list of udp-specific socket options. +for details of some other socket options that are also applicable +for udp sockets, see +.br socket (7). +.tp +.br udp_cork " (since linux 2.5.44)" +if this option is enabled, then all data output on this socket +is accumulated into a single datagram that is transmitted when +the option is disabled. +this option should not be used in code intended to be +portable. +.\" fixme document udp_encap (new in kernel 2.5.67) +.\" from include/linux/udp.h: +.\" udp_encap_espinudp_non_ike draft-ietf-ipsec-nat-t-ike-00/01 +.\" udp_encap_espinudp draft-ietf-ipsec-udp-encaps-06 +.\" udp_encap_l2tpinudp rfc2661 +.\" fixme document udp_no_check6_tx and udp_no_check6_rx, added in linux 3.16 +.ss ioctls +these ioctls can be accessed using +.br ioctl (2). +the correct syntax is: +.pp +.rs +.nf +.bi int " value"; +.ib error " = ioctl(" udp_socket ", " ioctl_type ", &" value ");" +.fi +.re +.tp +.br fionread " (" siocinq ) +gets a pointer to an integer as argument. +returns the size of the next pending datagram in the integer in bytes, +or 0 when no datagram is pending. +.b warning: +using +.br fionread , +it is impossible to distinguish the case where no datagram is pending +from the case where the next pending datagram contains zero bytes of data. +it is safer to use +.br select (2), +.br poll (2), +or +.br epoll (7) +to distinguish these cases. +.\" see http://www.securiteam.com/unixfocus/5kp0i15iko.html +.\" "gnunet dos (udp socket unreachable)", 14 may 2006 +.tp +.br tiocoutq " (" siocoutq ) +returns the number of data bytes in the local send queue. +supported only with linux 2.4 and above. +.pp +in addition, all ioctls documented in +.br ip (7) +and +.br socket (7) +are supported. +.sh errors +all errors documented for +.br socket (7) +or +.br ip (7) +may be returned by a send or receive on a udp socket. +.tp +.b econnrefused +no receiver was associated with the destination address. +this might be caused by a previous packet sent over the socket. +.sh versions +.b ip_recverr +is a new feature in linux 2.2. +.\" .sh credits +.\" this man page was written by andi kleen. +.sh see also +.br ip (7), +.br raw (7), +.br socket (7), +.br udplite (7) +.pp +the kernel source file +.ir documentation/networking/ip\-sysctl.txt . +.pp +rfc\ 768 for the user datagram protocol. +.br +rfc\ 1122 for the host requirements. +.br +rfc\ 1191 for a description of path mtu discovery. +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/hsearch.3 + +.so man3/rpc.3 + +.\" copyright 1993 rickard e. faith (faith@cs.unc.edu) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified 1995-07-22 by michael chastain : +.\" 'gethostname' is real system call on linux/alpha. +.\" modified 1997-01-31 by eric s. raymond +.\" modified 2000-06-04, 2001-12-15 by aeb +.\" modified 2004-06-17 by mtk +.\" modified 2008-11-27 by mtk +.\" +.th gethostname 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +gethostname, sethostname \- get/set hostname +.sh synopsis +.nf +.b #include +.pp +.bi "int gethostname(char *" name ", size_t " len ); +.bi "int sethostname(const char *" name ", size_t " len ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br gethostname (): +.nf + _xopen_source >= 500 || _posix_c_source >= 200112l + || /* glibc 2.19 and earlier */ _bsd_source +.\" the above is something of a simplification +.\" also in glibc before 2.3 there was a bit churn +.fi +.pp +.br sethostname (): +.nf + since glibc 2.21: +.\" commit 266865c0e7b79d4196e2cc393693463f03c90bd8 + _default_source + in glibc 2.19 and 2.20: + _default_source || (_xopen_source && _xopen_source < 500) + up to and including glibc 2.19: + _bsd_source || (_xopen_source && _xopen_source < 500) +.fi +.sh description +these system calls are used to access or to change the system hostname. +more precisely, they operate on the hostname associated with the calling +process's uts namespace. +.pp +.br sethostname () +sets the hostname to the value given in the character array +.ir name . +the +.i len +argument specifies the number of bytes in +.ir name . +(thus, +.i name +does not require a terminating null byte.) +.pp +.br gethostname () +returns the null-terminated hostname in the character array +.ir name , +which has a length of +.i len +bytes. +if the null-terminated hostname is too large to fit, +then the name is truncated, and no error is returned (but see notes below). +posix.1 says that if such truncation occurs, +then it is unspecified whether the returned buffer +includes a terminating null byte. +.sh return value +on success, zero is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b efault +.i name +is an invalid address. +.tp +.b einval +.i len +is negative +.\" can't occur for gethostbyname() wrapper, since 'len' has an +.\" unsigned type; can occur for the underlying system call. +or, for +.br sethostname (), +.i len +is larger than the maximum allowed size. +.tp +.b enametoolong +.rb "(glibc " gethostname ()) +.i len +is smaller than the actual size. +(before version 2.1, glibc uses +.br einval +for this case.) +.tp +.b eperm +for +.br sethostname (), +the caller did not have the +.b cap_sys_admin +capability in the user namespace associated with its uts namespace (see +.br namespaces (7)). +.sh conforming to +svr4, 4.4bsd (these interfaces first appeared in 4.2bsd). +posix.1-2001 and posix.1-2008 specify +.br gethostname () +but not +.br sethostname (). +.sh notes +susv2 guarantees that "host names are limited to 255 bytes". +posix.1 guarantees that "host names (not including +the terminating null byte) are limited to +.b host_name_max +bytes". +on linux, +.b host_name_max +is defined with the value 64, which has been the limit since linux 1.0 +(earlier kernels imposed a limit of 8 bytes). +.ss c library/kernel differences +the gnu c library does not employ the +.br gethostname () +system call; instead, it implements +.br gethostname () +as a library function that calls +.br uname (2) +and copies up to +.i len +bytes from the returned +.i nodename +field into +.ir name . +having performed the copy, the function then checks if the length of the +.i nodename +was greater than or equal to +.ir len , +and if it is, then the function returns \-1 with +.i errno +set to +.br enametoolong ; +in this case, a terminating null byte is not included in the returned +.ir name . +.pp +versions of glibc before 2.2 +.\" at least glibc 2.0 and 2.1, older versions not checked +handle the case where the length of the +.i nodename +was greater than or equal to +.i len +differently: nothing is copied into +.i name +and the function returns \-1 with +.i errno +set to +.br enametoolong . +.sh see also +.br hostname (1), +.br getdomainname (2), +.br setdomainname (2), +.br uname (2), +.br uts_namespaces (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" and copyright 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified 1993-07-24 by rik faith (faith@cs.unc.edu) +.\" modified 2002-07-27 by walter harms +.\" (walter.harms@informatik.uni-oldenburg.de) +.\" +.th atan2 3 2021-03-22 "" "linux programmer's manual" +.sh name +atan2, atan2f, atan2l \- arc tangent function of two variables +.sh synopsis +.nf +.b #include +.pp +.bi "double atan2(double " y ", double " x ); +.bi "float atan2f(float " y ", float " x ); +.bi "long double atan2l(long double " y ", long double " x ); +.fi +.pp +link with \fi\-lm\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br atan2f (), +.br atan2l (): +.nf + _isoc99_source || _posix_c_source >= 200112l + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.sh description +these functions calculate the principal value of the arc tangent of +.ir y/x , +using the signs of the two arguments to determine +the quadrant of the result. +.sh return value +on success, these functions return the principal value of the arc tangent of +.ir y/x +in radians; the return value is in the range [\-pi,\ pi]. +.pp +if +.i y +is +0 (\-0) and +.i x +is less than 0, +pi (\-pi) is returned. +.pp +if +.i y +is +0 (\-0) and +.i x +is greater than 0, +0 (\-0) is returned. +.pp +if +.i y +is less than 0 and +.i x +is +0 or \-0, \-pi/2 is returned. +.pp +if +.i y +is greater than 0 and +.i x +is +0 or \-0, pi/2 is returned. +.pp +.\" posix.1 says: +.\" if +.\" .i x +.\" is 0, a pole error shall not occur. +.\" +if either +.i x +or +.i y +is nan, a nan is returned. +.pp +.\" posix.1 says: +.\" if the result underflows, a range error may occur and +.\" .i y/x +.\" should be returned. +.\" +if +.i y +is +0 (\-0) and +.i x +is \-0, +pi (\-pi) is returned. +.pp +if +.i y +is +0 (\-0) and +.i x +is +0, +0 (\-0) is returned. +.pp +if +.i y +is a finite value greater (less) than 0, and +.i x +is negative infinity, +pi (\-pi) is returned. +.pp +if +.i y +is a finite value greater (less) than 0, and +.i x +is positive infinity, +0 (\-0) is returned. +.pp +if +.i y +is positive infinity (negative infinity), and +.i x +is finite, +pi/2 (\-pi/2) is returned. +.pp +if +.i y +is positive infinity (negative infinity) and +.i x +is negative infinity, +3*pi/4 (\-3*pi/4) is returned. +.pp +if +.i y +is positive infinity (negative infinity) and +.i x +is positive infinity, +pi/4 (\-pi/4) is returned. +.\" +.\" posix.1 says: +.\" if both arguments are 0, a domain error shall not occur. +.sh errors +no errors occur. +.\" posix.1 documents an optional underflow error +.\" glibc 2.8 does not do this. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br atan2 (), +.br atan2f (), +.br atan2l () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.pp +the variant returning +.i double +also conforms to +svr4, 4.3bsd, c89. +.sh see also +.br acos (3), +.br asin (3), +.br atan (3), +.br carg (3), +.br cos (3), +.br sin (3), +.br tan (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1980, 1991, 1993 +.\" the regents of the university of california. all rights reserved. +.\" +.\" %%%license_start(bsd_4_clause_ucb) +.\" redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. all advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" this product includes software developed by the university of +.\" california, berkeley and its contributors. +.\" 4. neither the name of the university nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" this software is provided by the regents and contributors ``as is'' and +.\" any express or implied warranties, including, but not limited to, the +.\" implied warranties of merchantability and fitness for a particular purpose +.\" are disclaimed. in no event shall the regents or contributors be liable +.\" for any direct, indirect, incidental, special, exemplary, or consequential +.\" damages (including, but not limited to, procurement of substitute goods +.\" or services; loss of use, data, or profits; or business interruption) +.\" however caused and on any theory of liability, whether in contract, strict +.\" liability, or tort (including negligence or otherwise) arising in any way +.\" out of the use of this software, even if advised of the possibility of +.\" such damage. +.\" %%%license_end +.\" +.\" @(#)syscall.2 8.1 (berkeley) 6/16/93 +.\" +.\" +.\" 2002-03-20 christoph hellwig +.\" - adopted for linux +.\" 2015-01-17, kees cook +.\" added mips and arm64. +.\" +.th syscall 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +syscall \- indirect system call +.sh synopsis +.nf +.br "#include " " /* definition of " sys_* " constants */" +.b #include +.pp +.bi "long syscall(long " number ", ...);" +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br syscall (): +.nf + since glibc 2.19: + _default_source + before glibc 2.19: + _bsd_source || _svid_source +.fi +.sh description +.br syscall () +is a small library function that invokes +the system call whose assembly language +interface has the specified +.i number +with the specified arguments. +employing +.br syscall () +is useful, for example, +when invoking a system call that has no wrapper function in the c library. +.pp +.br syscall () +saves cpu registers before making the system call, +restores the registers upon return from the system call, +and stores any error returned by the system call in +.br errno (3). +.pp +symbolic constants for system call numbers can be found in the header file +.ir . +.sh return value +the return value is defined by the system call being invoked. +in general, a 0 return value indicates success. +a \-1 return value indicates an error, +and an error number is stored in +.ir errno . +.sh notes +.br syscall () +first appeared in +4bsd. +.ss architecture-specific requirements +each architecture abi has its own requirements on how +system call arguments are passed to the kernel. +for system calls that have a glibc wrapper (e.g., most system calls), +glibc handles the details of copying arguments to the right registers +in a manner suitable for the architecture. +however, when using +.br syscall () +to make a system call, +the caller might need to handle architecture-dependent details; +this requirement is most commonly encountered on certain 32-bit architectures. +.pp +for example, on the arm architecture embedded abi (eabi), a +64-bit value (e.g., +.ir "long long" ) +must be aligned to an even register pair. +thus, using +.br syscall () +instead of the wrapper provided by glibc, +the +.br readahead (2) +system call would be invoked as follows on the arm architecture with the eabi +in little endian mode: +.pp +.in +4n +.ex +syscall(sys_readahead, fd, 0, + (unsigned int) (offset & 0xffffffff), + (unsigned int) (offset >> 32), + count); +.ee +.in +.pp +since the offset argument is 64 bits, and the first argument +.ri ( fd ) +is passed in +.ir r0 , +the caller must manually split and align the 64-bit value +so that it is passed in the +.ir r2 / r3 +register pair. +that means inserting a dummy value into +.i r1 +(the second argument of 0). +care also must be taken so that the split follows endian conventions +(according to the c abi for the platform). +.pp +similar issues can occur on mips with the o32 abi, +on powerpc and parisc with the 32-bit abi, and on xtensa. +.\" mike frysinger: this issue ends up forcing mips +.\" o32 to take 7 arguments to syscall() +.pp +.\" see arch/parisc/kernel/sys_parisc.c. +note that while the parisc c abi also uses aligned register pairs, +it uses a shim layer to hide the issue from user space. +.pp +the affected system calls are +.br fadvise64_64 (2), +.br ftruncate64 (2), +.br posix_fadvise (2), +.br pread64 (2), +.br pwrite64 (2), +.br readahead (2), +.br sync_file_range (2), +and +.br truncate64 (2). +.pp +.\" you need to look up the syscalls directly in the kernel source to see if +.\" they should be in this list. for example, look at fs/read_write.c and +.\" the function signatures that do: +.\" ..., unsigned long, pos_l, unsigned long, pos_h, ... +.\" if they use off_t, then they most likely do not belong in this list. +this does not affect syscalls that manually split and assemble 64-bit values +such as +.br _llseek (2), +.br preadv (2), +.br preadv2 (2), +.br pwritev (2), +and +.br pwritev2 (2). +welcome to the wonderful world of historical baggage. +.ss architecture calling conventions +every architecture has its own way of invoking and passing arguments to the +kernel. +the details for various architectures are listed in the two tables below. +.pp +the first table lists the instruction used to transition to kernel mode +(which might not be the fastest or best way to transition to the kernel, +so you might have to refer to +.br vdso (7)), +the register used to indicate the system call number, +the register(s) used to return the system call result, +and the register used to signal an error. +.if t \{\ +.ft cw +\} +.ts +l2 l2 l2 l2 l1 l2 l. +arch/abi instruction system ret ret error notes + call # val val2 +_ +alpha callsys v0 v0 a4 a3 1, 6 +arc trap0 r8 r0 - - +arm/oabi swi nr - r0 - - 2 +arm/eabi swi 0x0 r7 r0 r1 - +arm64 svc #0 w8 x0 x1 - +blackfin excpt 0x0 p0 r0 - - +i386 int $0x80 eax eax edx - +ia64 break 0x100000 r15 r8 r9 r10 1, 6 +m68k trap #0 d0 d0 - - +microblaze brki r14,8 r12 r3 - - +mips syscall v0 v0 v1 a3 1, 6 +nios2 trap r2 r2 - r7 +parisc ble 0x100(%sr2, %r0) r20 r28 - - +powerpc sc r0 r3 - r0 1 +powerpc64 sc r0 r3 - cr0.so 1 +riscv ecall a7 a0 a1 - +s390 svc 0 r1 r2 r3 - 3 +s390x svc 0 r1 r2 r3 - 3 +superh trapa #31 r3 r0 r1 - 4, 6 +sparc/32 t 0x10 g1 o0 o1 psr/csr 1, 6 +sparc/64 t 0x6d g1 o0 o1 psr/csr 1, 6 +tile swint1 r10 r00 - r01 1 +x86-64 syscall rax rax rdx - 5 +x32 syscall rax rax rdx - 5 +xtensa syscall a2 a2 - - +.te +.pp +notes: +.ip [1] 4 +on a few architectures, +a register is used as a boolean +(0 indicating no error, and \-1 indicating an error) to signal that the +system call failed. +the actual error value is still contained in the return register. +on sparc, the carry bit +.ri ( csr ) +in the processor status register +.ri ( psr ) +is used instead of a full register. +on powerpc64, the summary overflow bit +.ri ( so ) +in field 0 of the condition register +.ri ( cr0 ) +is used. +.ip [2] +.i nr +is the system call number. +.ip [3] +for s390 and s390x, +.i nr +(the system call number) may be passed directly with +.i "svc\ nr" +if it is less than 256. +.ip [4] +on superh additional trap numbers are supported for historic reasons, but +.br trapa #31 +is the recommended "unified" abi. +.ip [5] +the x32 abi shares syscall table with x86-64 abi, but there are some +nuances: +.rs +.ip \(bu 3 +in order to indicate that a system call is called under the x32 abi, +an additional bit, +.br __x32_syscall_bit , +is bitwise-ored with the system call number. +the abi used by a process affects some process behaviors, +including signal handling or system call restarting. +.ip \(bu +since x32 has different sizes for +.i long +and pointer types, layouts of some (but not all; +.i struct timeval +or +.i struct rlimit +are 64-bit, for example) structures are different. +in order to handle this, +additional system calls are added to the system call table, +starting from number 512 +(without the +.br __x32_syscall_bit ). +for example, +.b __nr_readv +is defined as 19 for the x86-64 abi and as +.ir __x32_syscall_bit " | " \fb515\fp +for the x32 abi. +most of these additional system calls are actually identical +to the system calls used for providing i386 compat. +there are some notable exceptions, however, such as +.br preadv2 (2), +which uses +.i struct iovec +entities with 4-byte pointers and sizes ("compat_iovec" in kernel terms), +but passes an 8-byte +.i pos +argument in a single register and not two, as is done in every other abi. +.re +.ip [6] +some architectures +(namely, alpha, ia-64, mips, superh, sparc/32, and sparc/64) +use an additional register ("retval2" in the above table) +to pass back a second return value from the +.br pipe (2) +system call; +alpha uses this technique in the architecture-specific +.br getxpid (2), +.br getxuid (2), +and +.br getxgid (2) +system calls as well. +other architectures do not use the second return value register +in the system call interface, even if it is defined in the system v abi. +.if t \{\ +.in +.ft p +\} +.pp +the second table shows the registers used to pass the system call arguments. +.if t \{\ +.ft cw +\} +.ts +l l2 l2 l2 l2 l2 l2 l2 l. +arch/abi arg1 arg2 arg3 arg4 arg5 arg6 arg7 notes +_ +alpha a0 a1 a2 a3 a4 a5 - +arc r0 r1 r2 r3 r4 r5 - +arm/oabi r0 r1 r2 r3 r4 r5 r6 +arm/eabi r0 r1 r2 r3 r4 r5 r6 +arm64 x0 x1 x2 x3 x4 x5 - +blackfin r0 r1 r2 r3 r4 r5 - +i386 ebx ecx edx esi edi ebp - +ia64 out0 out1 out2 out3 out4 out5 - +m68k d1 d2 d3 d4 d5 a0 - +microblaze r5 r6 r7 r8 r9 r10 - +mips/o32 a0 a1 a2 a3 - - - 1 +mips/n32,64 a0 a1 a2 a3 a4 a5 - +nios2 r4 r5 r6 r7 r8 r9 - +parisc r26 r25 r24 r23 r22 r21 - +powerpc r3 r4 r5 r6 r7 r8 r9 +powerpc64 r3 r4 r5 r6 r7 r8 - +riscv a0 a1 a2 a3 a4 a5 - +s390 r2 r3 r4 r5 r6 r7 - +s390x r2 r3 r4 r5 r6 r7 - +superh r4 r5 r6 r7 r0 r1 r2 +sparc/32 o0 o1 o2 o3 o4 o5 - +sparc/64 o0 o1 o2 o3 o4 o5 - +tile r00 r01 r02 r03 r04 r05 - +x86-64 rdi rsi rdx r10 r8 r9 - +x32 rdi rsi rdx r10 r8 r9 - +xtensa a6 a3 a4 a5 a8 a9 - +.te +.pp +notes: +.ip [1] 4 +the mips/o32 system call convention passes +arguments 5 through 8 on the user stack. +.if t \{\ +.in +.ft p +\} +.pp +note that these tables don't cover the entire calling convention\(emsome +architectures may indiscriminately clobber other registers not listed here. +.sh examples +.ex +#define _gnu_source +#include +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + pid_t tid; + + tid = syscall(sys_gettid); + syscall(sys_tgkill, getpid(), tid, sighup); +} +.ee +.sh see also +.br _syscall (2), +.br intro (2), +.br syscalls (2), +.br errno (3), +.br vdso (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man8/ld.so.8 + +.so man3/ttyname.3 + +.\" copyright (c) 2016, ibm corporation. +.\" written by wainer dos santos moschetta +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of +.\" this manual under the conditions for verbatim copying, provided that +.\" the entire resulting derived work is distributed under the terms of +.\" a permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume. +.\" no responsibility for errors or omissions, or for damages resulting. +.\" from the use of the information contained herein. the author(s) may. +.\" not have taken the same level of care in the production of this. +.\" manual, which is licensed free of charge, as they might when working. +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" glibc 2.25 source code and manual. +.\" c99 standard document. +.\" iso/iec ts 18661-1 technical specification. +.\" snprintf and other man.3 pages. +.\" +.th strfromd 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +strfromd, strfromf, strfroml \- convert a floating-point value into +a string +.sh synopsis +.nf +.b #include +.pp +.bi "int strfromd(char *restrict " str ", size_t " n , +.bi " const char *restrict " format ", double " fp ");" +.bi "int strfromf(char *restrict " str ", size_t " n , +.bi " const char *restrict " format ", float "fp ");" +.bi "int strfroml(char *restrict " str ", size_t " n , +.bi " const char *restrict " format ", long double " fp ");" +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br strfromd (), +.br strfromf (), +.br strfroml (): +.nf + __stdc_want_iec_60559_bfp_ext__ +.fi +.sh description +these functions convert a floating-point value, +.ir fp , +into a string of characters, +.ir str , +with a configurable +.ir format +string. +at most +.i n +characters are stored into +.ir str . +.pp +the terminating null byte ('\e0') is written if and only if +.i n +is sufficiently large, otherwise the written string is truncated at +.i n +characters. +.pp +the +.br strfromd (), +.br strfromf (), +and +.br strfroml () +functions are equivalent to +.pp +.in +4n +.ex +snprintf(str, n, format, fp); +.ee +.in +.pp +except for the +.i format +string. +.ss format of the format string +the +.i format +string must start with the character \(aq%\(aq. +this is followed by an optional precision which starts with the period +character (.), followed by an optional decimal integer. +if no integer is specified after the period character, +a precision of zero is used. +finally, the format string should have one of the conversion specifiers +.br a , +.br a , +.br e , +.br e , +.br f , +.br f , +.br g , +or +.br g . +.pp +the conversion specifier is applied based on the floating-point type +indicated by the function suffix. +therefore, unlike +.br snprintf (), +the format string does not have a length modifier character. +see +.br snprintf (3) +for a detailed description of these conversion specifiers. +.pp +the implementation conforms to the c99 standard on conversion of nan and +infinity values: +.pp +.rs +if +.i fp +is a nan, +nan, or \-nan, and +.br f +(or +.br a , +.br e , +.br g ) +is the conversion specifier, the conversion is to "nan", "nan", or "\-nan", +respectively. +if +.b f +(or +.br a , +.br e , +.br g ) +is the conversion specifier, the conversion is to "nan" or "\-nan". +.pp +likewise if +.i fp +is infinity, it is converted to [\-]inf or [\-]inf. +.re +.pp +a malformed +.i format +string results in undefined behavior. +.sh return value +the +.br strfromd (), +.br strfromf (), +and +.br strfroml () +functions return the number of characters that would have been written in +.i str +if +.i n +had enough space, +not counting the terminating null byte. +thus, a return value of +.i n +or greater means that the output was truncated. +.sh versions +the +.br strfromd (), +.br strfromf (), +and +.br strfroml () +functions are available in glibc since version 2.25. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7) +and the +.b posix safety concepts +section in gnu c library manual. +.pp +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br strfromd (), +.br strfromf (), +.br strfroml () +t} thread safety mt-safe locale +\^ async-signal safety as-unsafe heap +\^ async-cancel safety ac-unsafe mem +.te +.hy +.ad +.sp 1 +note: these attributes are preliminary. +.sh conforming to +c99, iso/iec ts 18661-1. +.sh notes +the +.br strfromd (), +.br strfromf (), +and +.br strfroml () +functions take account of the +.b lc_numeric +category of the current locale. +.sh examples +to convert the value 12.1 as a float type to a string using decimal +notation, resulting in "12.100000": +.pp +.in +4n +.ex +#define __stdc_want_iec_60559_bfp_ext__ +#include +int ssize = 10; +char s[ssize]; +strfromf(s, ssize, "%f", 12.1); +.ee +.in +.pp +to convert the value 12.3456 as a float type to a string using +decimal notation with two digits of precision, resulting in "12.35": +.pp +.in +4n +.ex +#define __stdc_want_iec_60559_bfp_ext__ +#include +int ssize = 10; +char s[ssize]; +strfromf(s, ssize, "%.2f", 12.3456); +.ee +.in +.pp +to convert the value 12.345e19 as a double type to a string using +scientific notation with zero digits of precision, resulting in "1e+20": +.pp +.in +4n +.ex +#define __stdc_want_iec_60559_bfp_ext__ +#include +int ssize = 10; +char s[ssize]; +strfromd(s, ssize, "%.e", 12.345e19); +.ee +.in +.sh see also +.br atof (3), +.br snprintf (3), +.br strtod (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/shmop.2 + +.so man3/isalpha.3 + +.\" copyright 2009 lefteris dimitroulakis +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" 2009-01-15, mtk, some edits +.\" +.th koi8-u 7 2020-08-13 "linux" "linux programmer's manual" +.sh name +koi8-u \- ukrainian character set encoded in octal, decimal, +and hexadecimal +.sh description +rfc\ 2310 defines an 8-bit character set, koi8-u. +koi8-u encodes the +characters used in ukrainian and byelorussian. +.ss koi8-u characters +the following table displays the characters in koi8-u that +are printable and unlisted in the +.br ascii (7) +manual page. +.ts +l l l c lp-1. +oct dec hex char description +_ +200 128 80 ─ box drawings light horizontal +201 129 81 │ box drawings light vertical +202 130 82 ┌ box drawings light down and right +203 131 83 ┐ box drawings light down and left +204 132 84 └ box drawings light up and right +205 133 85 ┘ box drawings light up and left +206 134 86 ├ box drawings light vertical and right +207 135 87 ┤ box drawings light vertical and left +210 136 88 ┬ box drawings light down and horizontal +211 137 89 ┴ box drawings light up and horizontal +212 138 8a ┼ box drawings light vertical and horizontal +213 139 8b ▀ upper half block +214 140 8c ▄ lower half block +215 141 8d █ full block +216 142 8e ▌ left half block +217 143 8f ▐ right half block +220 144 90 ░ light shade +221 145 91 ▒ medium shade +222 146 92 ▓ dark shade +223 147 93 ⌠ top half integral +224 148 94 ■ black square +225 149 95 ∙ bullet operator +226 150 96 √ square root +227 151 97 ≈ almost equal to +230 152 98 ≤ less-than or equal to +231 153 99 ≥ greater-than or equal to +232 154 9a   no-break space +233 155 9b ⌡ bottom half integral +234 156 9c ° degree sign +235 157 9d ² superscript two +236 158 9e · middle dot +237 159 9f ÷ division sign +240 160 a0 ═ box drawings double horizontal +241 161 a1 ║ box drawings double vertical +242 162 a2 ╒ box drawings down single and right double +243 163 a3 ё cyrillic small letter io +244 164 a4 є cyrillic small letter ukrainian ie +245 165 a5 ╔ box drawings double down and right +246 166 a6 і t{ +cyrillic small letter +.br +byelorussian-ukrainian i +t} +247 167 a7 ї cyrillic small letter yi (ukrainian) +250 168 a8 ╗ box drawings double down and left +251 169 a9 ╘ box drawings up single and right double +252 170 aa ╙ box drawings up double and right single +253 171 ab ╚ box drawings double up and right +254 172 ac ╛ box drawings up single and left double +255 173 ad ґ cyrillic small letter ghe with upturn +256 174 ae ╝ box drawings double up and left +257 175 af ╞ box drawings vertical single and right double +260 176 b0 ╟ box drawings vertical double and right single +261 177 b1 ╠ box drawings double vertical and right +262 178 b2 ╡ box drawings vertical single and left double +263 179 b3 ё cyrillic capital letter io +264 180 b4 є cyrillic capital letter ukrainian ie +265 181 b5 ╣ box drawings double vertical and left +266 182 b6 і t{ +cyrillic capital letter +.br +byelorussian-ukrainian i +t} +267 183 b7 ї cyrillic capital letter yi (ukrainian) +270 184 b8 ╦ box drawings double down and horizontal +271 185 b9 ╧ box drawings up single and horizontal double +272 186 ba ╨ box drawings up double and horizontal single +273 187 bb ╩ box drawings double up and horizontal +274 188 bc ╪ t{ +box drawings vertical single +.br +and horizontal double +t} +275 189 bd ґ cyrillic capital letter ghe with upturn +276 190 be ╬ box drawings double vertical and horizontal +277 191 bf © copyright sign +300 192 c0 ю cyrillic small letter yu +301 193 c1 а cyrillic small letter a +302 194 c2 б cyrillic small letter be +303 195 c3 ц cyrillic small letter tse +304 196 c4 д cyrillic small letter de +305 197 c5 е cyrillic small letter ie +306 198 c6 ф cyrillic small letter ef +307 199 c7 г cyrillic small letter ghe +310 200 c8 х cyrillic small letter ha +311 201 c9 и cyrillic small letter i +312 202 ca й cyrillic small letter short i +313 203 cb к cyrillic small letter ka +314 204 cc л cyrillic small letter el +315 205 cd м cyrillic small letter em +316 206 ce н cyrillic small letter en +317 207 cf о cyrillic small letter o +320 208 d0 п cyrillic small letter pe +321 209 d1 я cyrillic small letter ya +322 210 d2 р cyrillic small letter er +323 211 d3 с cyrillic small letter es +324 212 d4 т cyrillic small letter te +325 213 d5 у cyrillic small letter u +326 214 d6 ж cyrillic small letter zhe +327 215 d7 в cyrillic small letter ve +330 216 d8 ь cyrillic small letter soft sign +331 217 d9 ы cyrillic small letter yeru +332 218 da з cyrillic small letter ze +333 219 db ш cyrillic small letter sha +334 220 dc э cyrillic small letter e +335 221 dd щ cyrillic small letter shcha +336 222 de ч cyrillic small letter che +337 223 df ъ cyrillic small letter hard sign +340 224 e0 ю cyrillic capital letter yu +341 225 e1 а cyrillic capital letter a +342 226 e2 б cyrillic capital letter be +343 227 e3 ц cyrillic capital letter tse +344 228 e4 д cyrillic capital letter de +345 229 e5 е cyrillic capital letter ie +346 230 e6 ф cyrillic capital letter ef +347 231 e7 г cyrillic capital letter ghe +350 232 e8 х cyrillic capital letter ha +351 233 e9 и cyrillic capital letter i +352 234 ea й cyrillic capital letter short i +353 235 eb к cyrillic capital letter ka +354 236 ec л cyrillic capital letter el +355 237 ed м cyrillic capital letter em +356 238 ee н cyrillic capital letter en +357 239 ef о cyrillic capital letter o +360 240 f0 п cyrillic capital letter pe +361 241 f1 я cyrillic capital letter ya +362 242 f2 р cyrillic capital letter er +363 243 f3 с cyrillic capital letter es +364 244 f4 т cyrillic capital letter te +365 245 f5 у cyrillic capital letter u +366 246 f6 ж cyrillic capital letter zhe +367 247 f7 в cyrillic capital letter ve +370 248 f8 ь cyrillic capital letter soft sign +371 249 f9 ы cyrillic capital letter yeru +372 250 fa з cyrillic capital letter ze +373 251 fb ш cyrillic capital letter sha +374 252 fc э cyrillic capital letter e +375 253 fd щ cyrillic capital letter shcha +376 254 fe ч cyrillic capital letter che +377 255 ff ъ cyrillic capital letter hard sign +.te +.sh notes +the differences from koi8-r are in the hex positions +a4, a6, a7, ad, b4, b6, b7, and bd. +.sh see also +.br ascii (7), +.br charsets (7), +.br cp1251 (7), +.br iso_8859\-5 (7), +.br koi8\-r (7), +.br utf\-8 (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sat jul 24 18:45:17 1993 by rik faith (faith@cs.unc.edu) +.th psignal 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +psignal, psiginfo \- print signal description +.sh synopsis +.nf +.b #include +.pp +.bi "void psignal(int " sig ", const char *" s ); +.bi "void psiginfo(const siginfo_t *" pinfo ", const char *" s ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br psignal (): + since glibc 2.19: + _default_source + glibc 2.19 and earlier: + _bsd_source || _svid_source +.pp +.br psiginfo (): +.nf + _posix_c_source >= 200809l +.fi +.sh description +the +.br psignal () +function displays a message on \fistderr\fp +consisting of the string \fis\fp, a colon, a space, a string +describing the signal number \fisig\fp, and a trailing newline. +if the string \fis\fp is null or empty, the colon and space are omitted. +if \fisig\fp is invalid, +the message displayed will indicate an unknown signal. +.pp +the +.br psiginfo () +function is like +.br psignal (), +except that it displays information about the signal described by +.ir pinfo , +which should point to a valid +.i siginfo_t +structure. +as well as the signal description, +.br psiginfo () +displays information about the origin of the signal, +and other information relevant to the signal +(e.g., the relevant memory address for hardware-generated signals, +the child process id for +.br sigchld , +and the user id and process id of the sender, for signals set using +.br kill (2) +or +.br sigqueue (3)). +.sh return value +the +.br psignal () +and +.br psiginfo () +functions return no value. +.sh versions +the +.br psiginfo () +function was added to glibc in version 2.10. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br psignal (), +.br psiginfo () +t} thread safety mt-safe locale +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2008, 4.3bsd. +.sh bugs +in glibc versions up to 2.12, +.br psiginfo () +had the following bugs: +.ip * 3 +in some circumstances, a trailing newline is not printed. +.\" fixme . http://sourceware.org/bugzilla/show_bug.cgi?id=12107 +.\" reportedly now fixed; check glibc 2.13 +.ip * +additional details are not displayed for real-time signals. +.\" fixme . http://sourceware.org/bugzilla/show_bug.cgi?id=12108 +.\" reportedly now fixed; check glibc 2.13 +.sh see also +.br sigaction (2), +.br perror (3), +.br strsignal (3), +.br signal (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/unimplemented.2 + +.so man3/cproj.3 + +.so man3/list.3 + +.\" copyright 1993 rickard e. faith (faith@cs.unc.edu) +.\" copyright 1997 andries e. brouwer (aeb@cwi.nl) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th vm86 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +vm86old, vm86 \- enter virtual 8086 mode +.sh synopsis +.nf +.b #include +.pp +.bi "int vm86old(struct vm86_struct *" info ); +.bi "int vm86(unsigned long " fn ", struct vm86plus_struct *" v86 ); +.fi +.sh description +the system call +.br vm86 () +was introduced in linux 0.97p2. +in linux 2.1.15 and 2.0.28, it was renamed to +.br vm86old (), +and a new +.br vm86 () +was introduced. +the definition of +.ir "struct vm86_struct" +was changed +in 1.1.8 and 1.1.9. +.pp +these calls cause the process to enter vm86 mode (virtual-8086 in intel +literature), and are used by +.br dosemu . +.pp +vm86 mode is an emulation of real mode within a protected mode task. +.sh return value +on success, zero is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b efault +this return value is specific to i386 and indicates a problem with getting +user-space data. +.tp +.b enosys +this return value indicates the call is not implemented on the present +architecture. +.tp +.b eperm +saved kernel stack exists. +(this is a kernel sanity check; the saved +stack should exist only within vm86 mode itself.) +.sh conforming to +this call is specific to linux on 32-bit intel processors, +and should not be used in programs intended to be portable. +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/malloc_hook.3 + +.so man3/xdr.3 + +.so man7/system_data_types.7 + +.so man2/setpgid.2 + +.so man3/isgreater.3 + +.so man3/nextup.3 + +.\" copyright (c) 2008 linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th pthread_setschedprio 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +pthread_setschedprio \- set scheduling priority of a thread +.sh synopsis +.nf +.b #include +.pp +.bi "int pthread_setschedprio(pthread_t " thread ", int " prio ); +.pp +compile and link with \fi\-pthread\fp. +.fi +.sh description +the +.br pthread_setschedprio () +function sets the scheduling priority of the thread +.i thread +to the value specified in +.ir prio . +(by contrast +.br pthread_setschedparam (3) +changes both the scheduling policy and priority of a thread.) +.\" fixme . nptl/pthread_setschedprio.c has the following +.\" /* if the thread should have higher priority because of some +.\" pthread_prio_protect mutexes it holds, adjust the priority. */ +.\" eventually (perhaps after writing the mutexattr pages), we +.\" may want to add something on the topic to this page. +.\" nptl/pthread_setschedparam.c has a similar case. +.sh return value +on success, this function returns 0; +on error, it returns a nonzero error number. +if +.br pthread_setschedprio () +fails, the scheduling priority of +.i thread +is not changed. +.sh errors +.tp +.b einval +.i prio +is not valid for the scheduling policy of the specified thread. +.tp +.b eperm +the caller does not have appropriate privileges +to set the specified priority. +.tp +.b esrch +no thread with the id +.i thread +could be found. +.pp +posix.1 also documents an +.b enotsup +("attempt was made to set the priority +to an unsupported value") error for +.br pthread_setschedparam (3). +.sh versions +this function is available in glibc since version 2.3.4. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br pthread_setschedprio () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +for a description of the permissions required to, and the effect of, +changing a thread's scheduling priority, +and details of the permitted ranges for priorities +in each scheduling policy, see +.br sched (7). +.sh see also +.ad l +.nh +.br getrlimit (2), +.br sched_get_priority_min (2), +.br pthread_attr_init (3), +.br pthread_attr_setinheritsched (3), +.br pthread_attr_setschedparam (3), +.br pthread_attr_setschedpolicy (3), +.br pthread_create (3), +.br pthread_self (3), +.br pthread_setschedparam (3), +.br pthreads (7), +.br sched (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/sysctl.2 + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" iso/iec 9899:1999 +.\" +.th wprintf 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +wprintf, fwprintf, swprintf, vwprintf, vfwprintf, vswprintf \- formatted +wide-character output conversion +.sh synopsis +.nf +.b #include +.b #include +.pp +.bi "int wprintf(const wchar_t *restrict " format ", ...);" +.bi "int fwprintf(file *restrict " stream , +.bi " const wchar_t *restrict " format ", ...);" +.bi "int swprintf(wchar_t *restrict " wcs ", size_t " maxlen , +.bi " const wchar_t *restrict " format ", ...);" +.pp +.bi "int vwprintf(const wchar_t *restrict " format ", va_list " args ); +.bi "int vfwprintf(file *restrict " stream , +.bi " const wchar_t *restrict " format ", va_list " args ); +.bi "int vswprintf(wchar_t *restrict " wcs ", size_t " maxlen , +.bi " const wchar_t *restrict " format ", va_list " args ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +all functions shown above: +.\" .br wprintf (), +.\" .br fwprintf (), +.\" .br swprintf (), +.\" .br vwprintf (), +.\" .br vfwprintf (), +.\" .br vswprintf (): +.nf + _xopen_source >= 500 || _isoc99_source + || _posix_c_source >= 200112l +.fi +.sh description +the +.br wprintf () +family of functions is +the wide-character equivalent of the +.br printf (3) +family of functions. +it performs formatted output of wide +characters. +.pp +the +.br wprintf () +and +.br vwprintf () +functions +perform wide-character output to +.ir stdout . +.i stdout +must not be byte oriented; see +.br fwide (3) +for more information. +.pp +the +.br fwprintf () +and +.br vfwprintf () +functions +perform wide-character output to +.ir stream . +.i stream +must not be byte oriented; see +.br fwide (3) +for more information. +.pp +the +.br swprintf () +and +.br vswprintf () +functions +perform wide-character output +to an array of wide characters. +the programmer must ensure that there is +room for at least +.i maxlen +wide +characters at +.ir wcs . +.pp +these functions are like +the +.br printf (3), +.br vprintf (3), +.br fprintf (3), +.br vfprintf (3), +.br sprintf (3), +.br vsprintf (3) +functions except for the +following differences: +.tp +.b \(bu +the +.i format +string is a wide-character string. +.tp +.b \(bu +the output consists of wide characters, not bytes. +.tp +.b \(bu +.br swprintf () +and +.br vswprintf () +take a +.i maxlen +argument, +.br sprintf (3) +and +.br vsprintf (3) +do not. +.rb ( snprintf (3) +and +.br vsnprintf (3) +take a +.i maxlen +argument, but these functions do not return \-1 upon +buffer overflow on linux.) +.pp +the treatment of the conversion characters +.br c +and +.b s +is different: +.tp +.b c +if no +.b l +modifier is present, the +.i int +argument is converted to a wide character by a call to the +.br btowc (3) +function, and the resulting wide character is written. +if an +.b l +modifier is present, the +.i wint_t +(wide character) argument is written. +.tp +.b s +if no +.b l +modifier is present: the +.i "const\ char\ *" +argument is expected to be a pointer to an array of character type +(pointer to a string) containing a multibyte character sequence beginning +in the initial shift state. +characters from the array are converted to +wide characters (each by a call to the +.br mbrtowc (3) +function with a conversion state starting in the initial state before +the first byte). +the resulting wide characters are written up to +(but not including) the terminating null wide character (l\(aq\e0\(aq). +if a precision is +specified, no more wide characters than the number specified are written. +note that the precision determines the number of +.i wide characters +written, not the number of +.i bytes +or +.ir "screen positions" . +the array must contain a terminating null byte (\(aq\e0\(aq), +unless a precision is given +and it is so small that the number of converted wide characters reaches it +before the end of the array is reached. +if an +.b l +modifier is present: the +.i "const\ wchar_t\ *" +argument is expected to be a pointer to an array of wide characters. +wide characters from the array are written up to (but not including) a +terminating null wide character. +if a precision is specified, no more than +the number specified are written. +the array must contain a terminating null +wide character, unless a precision is given and it is smaller than or equal +to the number of wide characters in the array. +.sh return value +the functions return the number of wide characters written, excluding the +terminating null wide character in +case of the functions +.br swprintf () +and +.br vswprintf (). +they return \-1 when an error occurs. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br wprintf (), +.br fwprintf (), +.br swprintf (), +.br vwprintf (), +.br vfwprintf (), +.br vswprintf () +t} thread safety mt-safe locale +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh notes +the behavior of +.br wprintf () +et al. depends +on the +.b lc_ctype +category of the +current locale. +.pp +if the +.i format +string contains non-ascii wide characters, the program +will work correctly only if the +.b lc_ctype +category of the current locale at +run time is the same as the +.b lc_ctype +category of the current locale at +compile time. +this is because the +.i wchar_t +representation is platform- and locale-dependent. +(the glibc represents +wide characters using their unicode (iso-10646) code point, but other +platforms don't do this. +also, the use of c99 universal character names +of the form \eunnnn does not solve this problem.) +therefore, in +internationalized programs, the +.i format +string should consist of ascii +wide characters only, or should be constructed at run time in an +internationalized way (e.g., using +.br gettext (3) +or +.br iconv (3), +followed by +.br mbstowcs (3)). +.sh see also +.br fprintf (3), +.br fputwc (3), +.br fwide (3), +.br printf (3), +.br snprintf (3) +.\" .br wscanf (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de) +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under gpl +.\" %%%license_end +.\" +.\" adapted glibc info page +.\" +.\" this should run as 'guru meditation' (amiga joke :) +.\" the function is quite complex and deserves an example +.\" +.\" polished, aeb, 2003-11-01 +.th fmtmsg 3 2021-03-22 "" "linux programmer's manual" +.sh name +fmtmsg \- print formatted error messages +.sh synopsis +.nf +.b #include +.pp +.bi "int fmtmsg(long " classification ", const char *" label , +.bi " int " severity ", const char *" text , +.bi " const char *" action ", const char *" tag ); +.fi +.sh description +this function displays a message described by its arguments on the device(s) +specified in the +.i classification +argument. +for messages written to +.ir stderr , +the format depends on the +.b msgverb +environment variable. +.pp +the +.i label +argument identifies the source of the message. +the string must consist +of two colon separated parts where the first part has not more +than 10 and the second part not more than 14 characters. +.pp +the +.i text +argument describes the condition of the error. +.pp +the +.i action +argument describes possible steps to recover from the error. +if it is printed, it is prefixed by "to fix: ". +.pp +the +.i tag +argument is a reference to the online documentation where more +information can be found. +it should contain the +.i label +value and a unique identification number. +.ss dummy arguments +each of the arguments can have a dummy value. +the dummy classification value +.b mm_nullmc +(0l) does not specify any output, so nothing is printed. +the dummy severity value +.b no_sev +(0) says that no severity is supplied. +the values +.br mm_nulllbl , +.br mm_nulltxt , +.br mm_nullact , +.b mm_nulltag +are synonyms for +.ir "((char\ *)\ 0)" , +the empty string, and +.b mm_nullsev +is a synonym for +.br no_sev . +.ss the classification argument +the +.i classification +argument is the sum of values describing 4 types of information. +.pp +the first value defines the output channel. +.tp 12n +.b mm_print +output to +.ir stderr . +.tp +.b mm_console +output to the system console. +.tp +.b "mm_print | mm_console" +output to both. +.pp +the second value is the source of the error: +.tp 12n +.b mm_hard +a hardware error occurred. +.tp +.b mm_firm +a firmware error occurred. +.tp +.b mm_soft +a software error occurred. +.pp +the third value encodes the detector of the problem: +.tp 12n +.b mm_appl +it is detected by an application. +.tp +.b mm_util +it is detected by a utility. +.tp +.b mm_opsys +it is detected by the operating system. +.pp +the fourth value shows the severity of the incident: +.tp 12n +.b mm_recover +it is a recoverable error. +.tp +.b mm_nrecov +it is a nonrecoverable error. +.ss the severity argument +the +.i severity +argument can take one of the following values: +.tp 12n +.b mm_nosev +no severity is printed. +.tp +.b mm_halt +this value is printed as halt. +.tp +.b mm_error +this value is printed as error. +.tp +.b mm_warning +this value is printed as warning. +.tp +.b mm_info +this value is printed as info. +.pp +the numeric values are between 0 and 4. +using +.br addseverity (3) +or the environment variable +.b sev_level +you can add more levels and strings to print. +.sh return value +the function can return 4 values: +.tp 12n +.b mm_ok +everything went smooth. +.tp +.b mm_notok +complete failure. +.tp +.b mm_nomsg +error writing to +.ir stderr . +.tp +.b mm_nocon +error writing to the console. +.sh environment +the environment variable +.b msgverb +("message verbosity") can be used to suppress parts of +the output to +.ir stderr . +(it does not influence output to the console.) +when this variable is defined, is non-null, and is a colon-separated +list of valid keywords, then only the parts of the message corresponding +to these keywords is printed. +valid keywords are "label", "severity", "text", "action", and "tag". +.pp +the environment variable +.b sev_level +can be used to introduce new severity levels. +by default, only the five severity levels described +above are available. +any other numeric value would make +.br fmtmsg () +print nothing. +if the user puts +.b sev_level +with a format like +.pp +.rs +sev_level=[description[:description[:...]]] +.re +.pp +in the environment of the process before the first call to +.br fmtmsg (), +where each description is of the form +.pp +.rs +severity-keyword,level,printstring +.re +.pp +then +.br fmtmsg () +will also accept the indicated values for the level (in addition to +the standard levels 0\(en4), and use the indicated printstring when +such a level occurs. +.pp +the severity-keyword part is not used by +.br fmtmsg () +but it has to be present. +the level part is a string representation of a number. +the numeric value must be a number greater than 4. +this value must be used in the severity argument of +.br fmtmsg () +to select this class. +it is not possible to overwrite +any of the predefined classes. +the printstring +is the string printed when a message of this class is processed by +.br fmtmsg (). +.sh versions +.br fmtmsg () +is provided in glibc since version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lb lb lbx +l l l. +interface attribute value +t{ +.br fmtmsg () +t} thread safety t{ +glibc\ >=\ 2.16: mt-safe; +glibc\ <\ 2.16: mt-unsafe +t} +.te +.hy +.ad +.sp 1 +.pp +before glibc 2.16, the +.br fmtmsg () +function uses a static variable that is not protected, +so it is not thread-safe. +.pp +since glibc 2.16, +.\" modified in commit 7724defcf8873116fe4efab256596861eef21a94 +the +.br fmtmsg () +function uses a lock to protect the static variable, so it is thread-safe. +.sh conforming to +the functions +.br fmtmsg () +and +.br addseverity (3), +and environment variables +.b msgverb +and +.b sev_level +come from system v. +.pp +the function +.br fmtmsg () +and the environment variable +.b msgverb +are described in posix.1-2001 and posix.1-2008. +.sh notes +system v and unixware man pages tell us that these functions +have been replaced by "pfmt() and addsev()" or by "pfmt(), +vpfmt(), lfmt(), and vlfmt()", and will be removed later. +.sh examples +.ex +#include +#include +#include + +int +main(void) +{ + long class = mm_print | mm_soft | mm_opsys | mm_recover; + int err; + + err = fmtmsg(class, "util\-linux:mount", mm_error, + "unknown mount option", "see mount(8).", + "util\-linux:mount:017"); + switch (err) { + case mm_ok: + break; + case mm_notok: + printf("nothing printed\en"); + break; + case mm_nomsg: + printf("nothing printed to stderr\en"); + break; + case mm_nocon: + printf("no console output\en"); + break; + default: + printf("unknown error from fmtmsg()\en"); + } + exit(exit_success); +} +.ee +.pp +the output should be: +.pp +.in +4n +.ex +util\-linux:mount: error: unknown mount option +to fix: see mount(8). util\-linux:mount:017 +.ee +.in +.pp +and after +.pp +.in +4n +.ex +msgverb=text:action; export msgverb +.ee +.in +.pp +the output becomes: +.pp +.in +4n +.ex +unknown mount option +to fix: see mount(8). +.ee +.in +.sh see also +.br addseverity (3), +.br perror (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/strdup.3 + +.so man3/getspnam.3 + +.so man3/getgrent.3 + +.so man3/scalb.3 + +.\" copyright (c) 2005, 2013 michael kerrisk +.\" a few fragments from an earlier (1996) version by +.\" andries brouwer (aeb@cwi.nl) remain. +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" rewritten old page, 960210, aeb@cwi.nl +.\" updated, added strtok_r. 2000-02-13 nicolás lichtmaier +.\" 2005-11-17, mtk: substantial parts rewritten +.\" 2013-05-19, mtk: added much further detail on the operation of strtok() +.\" +.th strtok 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +strtok, strtok_r \- extract tokens from strings +.sh synopsis +.nf +.b #include +.pp +.bi "char *strtok(char *restrict " str ", const char *restrict " delim ); +.bi "char *strtok_r(char *restrict " str ", const char *restrict " delim , +.bi " char **restrict " saveptr ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br strtok_r (): +.nf + _posix_c_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.sh description +the +.br strtok () +function breaks a string into a sequence of zero or more nonempty tokens. +on the first call to +.br strtok (), +the string to be parsed should be +specified in +.ir str . +in each subsequent call that should parse the same string, +.i str +must be null. +.pp +the +.i delim +argument specifies a set of bytes that +delimit the tokens in the parsed string. +the caller may specify different strings in +.i delim +in successive +calls that parse the same string. +.pp +each call to +.br strtok () +returns a pointer to a +null-terminated string containing the next token. +this string does not include the delimiting byte. +if no more tokens are found, +.br strtok () +returns null. +.pp +a sequence of calls to +.br strtok () +that operate on the same string maintains a pointer +that determines the point from which to start searching for the next token. +the first call to +.br strtok () +sets this pointer to point to the first byte of the string. +the start of the next token is determined by scanning forward +for the next nondelimiter byte in +.ir str . +if such a byte is found, it is taken as the start of the next token. +if no such byte is found, +then there are no more tokens, and +.br strtok () +returns null. +(a string that is empty or that contains only delimiters +will thus cause +.br strtok () +to return null on the first call.) +.pp +the end of each token is found by scanning forward until either +the next delimiter byte is found or until the +terminating null byte (\(aq\e0\(aq) is encountered. +if a delimiter byte is found, it is overwritten with +a null byte to terminate the current token, and +.br strtok () +saves a pointer to the following byte; +that pointer will be used as the starting point +when searching for the next token. +in this case, +.br strtok () +returns a pointer to the start of the found token. +.pp +from the above description, +it follows that a sequence of two or more contiguous delimiter bytes in +the parsed string is considered to be a single delimiter, and that +delimiter bytes at the start or end of the string are ignored. +put another way: the tokens returned by +.br strtok () +are always nonempty strings. +thus, for example, given the string "\fiaaa;;bbb,\fp", +successive calls to +.br strtok () +that specify the delimiter string "\fi;,\fp" +would return the strings "\fiaaa\fp" and "\fibbb\fp", +and then a null pointer. +.pp +the +.br strtok_r () +function is a reentrant version of +.br strtok (). +the +.i saveptr +argument is a pointer to a +.ir "char\ *" +variable that is used internally by +.br strtok_r () +in order to maintain context between successive calls that parse the +same string. +.pp +on the first call to +.br strtok_r (), +.i str +should point to the string to be parsed, and the value of +.i *saveptr +is ignored (but see notes). +in subsequent calls, +.i str +should be null, and +.i saveptr +(and the buffer that it points to) +should be unchanged since the previous call. +.pp +different strings may be parsed concurrently using sequences of calls to +.br strtok_r () +that specify different +.i saveptr +arguments. +.sh return value +the +.br strtok () +and +.br strtok_r () +functions return a pointer to +the next token, or null if there are no more tokens. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br strtok () +t} thread safety mt-unsafe race:strtok +t{ +.br strtok_r () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +.tp +.br strtok () +posix.1-2001, posix.1-2008, c89, c99, svr4, 4.3bsd. +.tp +.br strtok_r () +posix.1-2001, posix.1-2008. +.sh notes +on some implementations, +.\" tru64, according to its manual page +.i *saveptr +is required to be null on the first call to +.br strtok_r () +that is being used to parse +.ir str . +.sh bugs +be cautious when using these functions. +if you do use them, note that: +.ip * 2 +these functions modify their first argument. +.ip * +these functions cannot be used on constant strings. +.ip * +the identity of the delimiting byte is lost. +.ip * +the +.br strtok () +function uses a static buffer while parsing, so it's not thread safe. +use +.br strtok_r () +if this matters to you. +.sh examples +the program below uses nested loops that employ +.br strtok_r () +to break a string into a two-level hierarchy of tokens. +the first command-line argument specifies the string to be parsed. +the second argument specifies the delimiter byte(s) +to be used to separate that string into "major" tokens. +the third argument specifies the delimiter byte(s) +to be used to separate the "major" tokens into subtokens. +.pp +an example of the output produced by this program is the following: +.pp +.in +4n +.ex +.rb "$" " ./a.out \(aqa/bbb///cc;xxx:yyy:\(aq \(aq:;\(aq \(aq/\(aq" +1: a/bbb///cc + \-\-> a + \-\-> bbb + \-\-> cc +2: xxx + \-\-> xxx +3: yyy + \-\-> yyy +.ee +.in +.ss program source +\& +.ex +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + char *str1, *str2, *token, *subtoken; + char *saveptr1, *saveptr2; + + if (argc != 4) { + fprintf(stderr, "usage: %s string delim subdelim\en", + argv[0]); + exit(exit_failure); + } + + for (int j = 1, str1 = argv[1]; ; j++, str1 = null) { + token = strtok_r(str1, argv[2], &saveptr1); + if (token == null) + break; + printf("%d: %s\en", j, token); + + for (str2 = token; ; str2 = null) { + subtoken = strtok_r(str2, argv[3], &saveptr2); + if (subtoken == null) + break; + printf("\t \-\-> %s\en", subtoken); + } + } + + exit(exit_success); +} +.ee +.pp +another example program using +.br strtok () +can be found in +.br getaddrinfo_a (3). +.sh see also +.br index (3), +.br memchr (3), +.br rindex (3), +.br strchr (3), +.br string (3), +.br strpbrk (3), +.br strsep (3), +.br strspn (3), +.br strstr (3), +.br wcstok (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/clog10.3 + +.so man3/resolver.3 + +.so man3/mallinfo.3 + +.\" copyright 2003,2004 andi kleen, suse labs. +.\" and copyright 2007 lee schermerhorn, hewlett packard +.\" +.\" %%%license_start(verbatim_prof) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" 2006-02-03, mtk, substantial wording changes and other improvements +.\" 2007-08-27, lee schermerhorn +.\" more precise specification of behavior. +.\" +.\" fixme +.\" linux 3.8 added mpol_mf_lazy, which needs to be documented. +.\" does it also apply for move_pages()? +.\" +.\" commit b24f53a0bea38b266d219ee651b22dba727c44ae +.\" author: lee schermerhorn +.\" date: thu oct 25 14:16:32 2012 +0200 +.\" +.th mbind 2 2021-03-22 linux "linux programmer's manual" +.sh name +mbind \- set memory policy for a memory range +.sh synopsis +.nf +.b "#include " +.pp +.bi "long mbind(void *" addr ", unsigned long " len ", int " mode , +.bi " const unsigned long *" nodemask ", unsigned long " maxnode , +.bi " unsigned int " flags ); +.pp +link with \fi\-lnuma\fp. +.fi +.pp +.ir note : +there is no glibc wrapper for this system call; see notes. +.sh description +.br mbind () +sets the numa memory policy, +which consists of a policy mode and zero or more nodes, +for the memory range starting with +.i addr +and continuing for +.i len +bytes. +the memory policy defines from which node memory is allocated. +.pp +if the memory range specified by the +.ir addr " and " len +arguments includes an "anonymous" region of memory\(emthat is +a region of memory created using the +.br mmap (2) +system call with the +.br map_anonymous \(emor +a memory-mapped file, mapped using the +.br mmap (2) +system call with the +.b map_private +flag, pages will be allocated only according to the specified +policy when the application writes (stores) to the page. +for anonymous regions, an initial read access will use a shared +page in the kernel containing all zeros. +for a file mapped with +.br map_private , +an initial read access will allocate pages according to the +memory policy of the thread that causes the page to be allocated. +this may not be the thread that called +.br mbind (). +.pp +the specified policy will be ignored for any +.b map_shared +mappings in the specified memory range. +rather the pages will be allocated according to the memory policy +of the thread that caused the page to be allocated. +again, this may not be the thread that called +.br mbind (). +.pp +if the specified memory range includes a shared memory region +created using the +.br shmget (2) +system call and attached using the +.br shmat (2) +system call, +pages allocated for the anonymous or shared memory region will +be allocated according to the policy specified, regardless of which +process attached to the shared memory segment causes the allocation. +if, however, the shared memory region was created with the +.b shm_hugetlb +flag, +the huge pages will be allocated according to the policy specified +only if the page allocation is caused by the process that calls +.br mbind () +for that region. +.pp +by default, +.br mbind () +has an effect only for new allocations; if the pages inside +the range have been already touched before setting the policy, +then the policy has no effect. +this default behavior may be overridden by the +.b mpol_mf_move +and +.b mpol_mf_move_all +flags described below. +.pp +the +.i mode +argument must specify one of +.br mpol_default , +.br mpol_bind , +.br mpol_interleave , +.br mpol_preferred , +or +.br mpol_local +(which are described in detail below). +all policy modes except +.b mpol_default +require the caller to specify the node or nodes to which the mode applies, +via the +.i nodemask +argument. +.pp +the +.i mode +argument may also include an optional +.ir "mode flag" . +the supported +.i "mode flags" +are: +.tp +.br mpol_f_static_nodes " (since linux-2.6.26)" +a nonempty +.i nodemask +specifies physical node ids. +linux does not remap the +.i nodemask +when the thread moves to a different cpuset context, +nor when the set of nodes allowed by the thread's +current cpuset context changes. +.tp +.br mpol_f_relative_nodes " (since linux-2.6.26)" +a nonempty +.i nodemask +specifies node ids that are relative to the set of +node ids allowed by the thread's current cpuset. +.pp +.i nodemask +points to a bit mask of nodes containing up to +.i maxnode +bits. +the bit mask size is rounded to the next multiple of +.ir "sizeof(unsigned long)" , +but the kernel will use bits only up to +.ir maxnode . +a null value of +.i nodemask +or a +.i maxnode +value of zero specifies the empty set of nodes. +if the value of +.i maxnode +is zero, +the +.i nodemask +argument is ignored. +where a +.i nodemask +is required, it must contain at least one node that is on-line, +allowed by the thread's current cpuset context +(unless the +.b mpol_f_static_nodes +mode flag is specified), +and contains memory. +.pp +the +.i mode +argument must include one of the following values: +.tp +.b mpol_default +this mode requests that any nondefault policy be removed, +restoring default behavior. +when applied to a range of memory via +.br mbind (), +this means to use the thread memory policy, +which may have been set with +.br set_mempolicy (2). +if the mode of the thread memory policy is also +.br mpol_default , +the system-wide default policy will be used. +the system-wide default policy allocates +pages on the node of the cpu that triggers the allocation. +for +.br mpol_default , +the +.i nodemask +and +.i maxnode +arguments must be specify the empty set of nodes. +.tp +.b mpol_bind +this mode specifies a strict policy that restricts memory allocation to +the nodes specified in +.ir nodemask . +if +.i nodemask +specifies more than one node, page allocations will come from +the node with sufficient free memory that is closest to +the node where the allocation takes place. +pages will not be allocated from any node not specified in the +ir nodemask . +(before linux 2.6.26, +.\" commit 19770b32609b6bf97a3dece2529089494cbfc549 +page allocations came from +the node with the lowest numeric node id first, until that node +contained no free memory. +allocations then came from the node with the next highest +node id specified in +.i nodemask +and so forth, until none of the specified nodes contained free memory.) +.tp +.b mpol_interleave +this mode specifies that page allocations be interleaved across the +set of nodes specified in +.ir nodemask . +this optimizes for bandwidth instead of latency +by spreading out pages and memory accesses to those pages across +multiple nodes. +to be effective the memory area should be fairly large, +at least 1\ mb or bigger with a fairly uniform access pattern. +accesses to a single page of the area will still be limited to +the memory bandwidth of a single node. +.tp +.b mpol_preferred +this mode sets the preferred node for allocation. +the kernel will try to allocate pages from this +node first and fall back to other nodes if the +preferred nodes is low on free memory. +if +.i nodemask +specifies more than one node id, the first node in the +mask will be selected as the preferred node. +if the +.i nodemask +and +.i maxnode +arguments specify the empty set, then the memory is allocated on +the node of the cpu that triggered the allocation. +.tp +.br mpol_local " (since linux 3.8)" +.\" commit 479e2802d09f1e18a97262c4c6f8f17ae5884bd8 +.\" commit f2a07f40dbc603c15f8b06e6ec7f768af67b424f +this mode specifies "local allocation"; the memory is allocated on +the node of the cpu that triggered the allocation (the "local node"). +the +.i nodemask +and +.i maxnode +arguments must specify the empty set. +if the "local node" is low on free memory, +the kernel will try to allocate memory from other nodes. +the kernel will allocate memory from the "local node" +whenever memory for this node is available. +if the "local node" is not allowed by the thread's current cpuset context, +the kernel will try to allocate memory from other nodes. +the kernel will allocate memory from the "local node" whenever +it becomes allowed by the thread's current cpuset context. +by contrast, +.b mpol_default +reverts to the memory policy of the thread (which may be set via +.br set_mempolicy (2)); +that policy may be something other than "local allocation". +.pp +if +.b mpol_mf_strict +is passed in +.i flags +and +.i mode +is not +.br mpol_default , +then the call fails with the error +.b eio +if the existing pages in the memory range don't follow the policy. +.\" according to the kernel code, the following is not true +.\" --lee schermerhorn +.\" in 2.6.16 or later the kernel will also try to move pages +.\" to the requested node with this flag. +.pp +if +.b mpol_mf_move +is specified in +.ir flags , +then the kernel will attempt to move all the existing pages +in the memory range so that they follow the policy. +pages that are shared with other processes will not be moved. +if +.b mpol_mf_strict +is also specified, then the call fails with the error +.b eio +if some pages could not be moved. +.pp +if +.b mpol_mf_move_all +is passed in +.ir flags , +then the kernel will attempt to move all existing pages in the memory range +regardless of whether other processes use the pages. +the calling thread must be privileged +.rb ( cap_sys_nice ) +to use this flag. +if +.b mpol_mf_strict +is also specified, then the call fails with the error +.b eio +if some pages could not be moved. +.\" --------------------------------------------------------------- +.sh return value +on success, +.br mbind () +returns 0; +on error, \-1 is returned and +.i errno +is set to indicate the error. +.\" --------------------------------------------------------------- +.sh errors +.\" i think i got all of the error returns. --lee schermerhorn +.tp +.b efault +part or all of the memory range specified by +.i nodemask +and +.i maxnode +points outside your accessible address space. +or, there was an unmapped hole in the specified memory range specified by +.ir addr +and +.ir len . +.tp +.b einval +an invalid value was specified for +.i flags +or +.ir mode ; +or +.i addr + len +was less than +.ir addr ; +or +.i addr +is not a multiple of the system page size. +or, +.i mode +is +.b mpol_default +and +.i nodemask +specified a nonempty set; +or +.i mode +is +.b mpol_bind +or +.b mpol_interleave +and +.i nodemask +is empty. +or, +.i maxnode +exceeds a kernel-imposed limit. +.\" as at 2.6.23, this limit is "a page worth of bits", e.g., +.\" 8 * 4096 bits, assuming a 4kb page size. +or, +.i nodemask +specifies one or more node ids that are +greater than the maximum supported node id. +or, none of the node ids specified by +.i nodemask +are on-line and allowed by the thread's current cpuset context, +or none of the specified nodes contain memory. +or, the +.i mode +argument specified both +.b mpol_f_static_nodes +and +.br mpol_f_relative_nodes . +.tp +.b eio +.b mpol_mf_strict +was specified and an existing page was already on a node +that does not follow the policy; +or +.b mpol_mf_move +or +.b mpol_mf_move_all +was specified and the kernel was unable to move all existing +pages in the range. +.tp +.b enomem +insufficient kernel memory was available. +.tp +.b eperm +the +.i flags +argument included the +.b mpol_mf_move_all +flag and the caller does not have the +.b cap_sys_nice +privilege. +.\" --------------------------------------------------------------- +.sh versions +the +.br mbind () +system call was added to the linux kernel in version 2.6.7. +.sh conforming to +this system call is linux-specific. +.sh notes +glibc does not provide a wrapper for this system call. +for information on library support, see +.br numa (7). +.pp +numa policy is not supported on a memory-mapped file range +that was mapped with the +.b map_shared +flag. +.pp +the +.b mpol_default +mode can have different effects for +.br mbind () +and +.br set_mempolicy (2). +when +.b mpol_default +is specified for +.br set_mempolicy (2), +the thread's memory policy reverts to the system default policy +or local allocation. +when +.b mpol_default +is specified for a range of memory using +.br mbind (), +any pages subsequently allocated for that range will use +the thread's memory policy, as set by +.br set_mempolicy (2). +this effectively removes the explicit policy from the +specified range, "falling back" to a possibly nondefault +policy. +to select explicit "local allocation" for a memory range, +specify a +.i mode +of +.b mpol_local +or +.b mpol_preferred +with an empty set of nodes. +this method will work for +.br set_mempolicy (2), +as well. +.pp +support for huge page policy was added with 2.6.16. +for interleave policy to be effective on huge page mappings the +policied memory needs to be tens of megabytes or larger. +.pp +before linux 5.7. +.\" commit dcf1763546d76c372f3136c8d6b2b6e77f140cf0 +.b mpol_mf_strict +was ignored on huge page mappings. +.pp +.b mpol_mf_move +and +.b mpol_mf_move_all +are available only on linux 2.6.16 and later. +.sh see also +.br get_mempolicy (2), +.br getcpu (2), +.br mmap (2), +.br set_mempolicy (2), +.br shmat (2), +.br shmget (2), +.br numa (3), +.br cpuset (7), +.br numa (7), +.br numactl (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/encrypt.3 + +.so man3/fts.3 + +.so man3/atan2.3 + +.so man3/stailq.3 + +.\" copyright (c) 1993 michael haardt (michael@moria.de), +.\" fri apr 2 11:32:09 met dst 1993 +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" modified sat jul 24 17:01:11 1993 by rik faith (faith@cs.unc.edu) +.th ram 4 1992-11-21 "linux" "linux programmer's manual" +.sh name +ram \- ram disk device +.sh description +the +.i ram +device is a block device to access the ram disk in raw mode. +.pp +it is typically created by: +.pp +.in +4n +.ex +mknod \-m 660 /dev/ram b 1 1 +chown root:disk /dev/ram +.ee +.in +.sh files +.i /dev/ram +.sh see also +.br chown (1), +.br mknod (1), +.br mount (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/strtoul.3 + +.\" copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de) +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under gpl +.\" %%%license_end +.\" +.\" heavily based on glibc infopages, copyright free software foundation +.\" +.th significand 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +significand, significandf, significandl \- +get mantissa of floating-point number +.sh synopsis +.nf +.b #include +.pp +.bi "double significand(double " x ); +.bi "float significandf(float " x ); +.bi "long double significandl(long double " x ); +.fi +.pp +link with \fi\-lm\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br significand (), +.br significandf (), +.br significandl (): +.nf + /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.sh description +these functions return the mantissa of +.i x +scaled to the range [1,2). +they are equivalent to +.pp +.in +4n +.ex +scalb(x, (double) \-ilogb(x)) +.ee +.in +.pp +this function exists mainly for use in certain standardized tests +for ieee 754 conformance. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br significand (), +.br significandf (), +.br significandl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +these functions are nonstandard; the +.i double +version is available on a number of other systems. +.\" .sh history +.\" this function came from bsd. +.sh see also +.br ilogb (3), +.br scalb (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/fstat.2 + +.so man3/getutent.3 + +.so man3/setnetgrent.3 + +.\" copyright 2004 andries brouwer . +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th infinity 3 2020-12-21 "" "linux programmer's manual" +.sh name +infinity, nan, huge_val, huge_valf, huge_vall \- floating-point constants +.sh synopsis +.nf +.br "#define _isoc99_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.b infinity +.pp +.b nan +.pp +.b huge_val +.b huge_valf +.b huge_vall +.fi +.sh description +the macro +.b infinity +expands to a +.i float +constant representing positive infinity. +.pp +the macro +.b nan +expands to a +.i float +constant representing a quiet nan +(when supported). +a +.i quiet +nan is a nan ("not-a-number") that does not raise exceptions +when it is used in arithmetic. +the opposite is a +.i signaling +nan. +see iec 60559:1989. +.pp +the macros +.br huge_val , +.br huge_valf , +.b huge_vall +expand to constants of types +.ir double , +.ir float , +and +.ir "long double" , +respectively, +that represent a large positive value, possibly positive infinity. +.sh conforming to +c99. +.pp +on a glibc system, the macro +.b huge_val +is always available. +availability of the +.b nan +macro can be tested using +.br "#ifdef nan" , +and similarly for +.br infinity , +.br huge_valf , +.br huge_vall . +they will be defined by +.i +if +.b _isoc99_source +or +.b _gnu_source +is defined, or +.b __stdc_version__ +is defined +and has a value not less than 199901l. +.sh see also +.br fpclassify (3), +.br math_error (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/wprintf.3 + +.so man3/isalpha.3 + +.so man3/pthread_cleanup_push_defer_np.3 + +.\" copyright (c) 2014, heinrich schuchardt +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of +.\" this manual under the conditions for verbatim copying, provided that +.\" the entire resulting derived work is distributed under the terms of +.\" a permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume +.\" no responsibility for errors or omissions, or for damages resulting +.\" from the use of the information contained herein. the author(s) may +.\" not have taken the same level of care in the production of this +.\" manual, which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.th ioctl_fat 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +ioctl_fat \- manipulating the fat filesystem +.sh synopsis +.nf +.br "#include " " /* definition of [" v ] fat_* " and" +.br " attr_* " constants */" +.b #include +.pp +.bi "int ioctl(int " fd ", fat_ioctl_get_attributes, uint32_t *" attr ); +.bi "int ioctl(int " fd ", fat_ioctl_set_attributes, uint32_t *" attr ); +.bi "int ioctl(int " fd ", fat_ioctl_get_volume_id, uint32_t *" id ); +.bi "int ioctl(int " fd ", vfat_ioctl_readdir_both," +.bi " struct __fat_dirent " entry [2]); +.bi "int ioctl(int " fd ", vfat_ioctl_readdir_short," +.bi " struct __fat_dirent " entry [2]); +.fi +.sh description +the +.br ioctl (2) +system call can be used to read and write metadata of fat filesystems that +are not accessible using other system calls. +.ss reading and setting file attributes +files and directories in the fat filesystem possess an attribute bit mask that +can be read with +.b fat_ioctl_get_attributes +and written with +.br fat_ioctl_set_attributes . +.pp +the +.i fd +argument contains a file descriptor for a file or directory. +it is sufficient to create the file descriptor by calling +.br open (2) +with the +.b o_rdonly +flag. +.pp +the +.i attr +argument contains a pointer to a bit mask. +the bits of the bit mask are: +.tp +.b attr_ro +this bit specifies that the file or directory is read-only. +.tp +.b attr_hidden +this bit specifies that the file or directory is hidden. +.tp +.b attr_sys +this bit specifies that the file is a system file. +.tp +.b attr_volume +this bit specifies that the file is a volume label. +this attribute is read-only. +.tp +.b attr_dir +this bit specifies that this is a directory. +this attribute is read-only. +.tp +.b attr_arch +this bit indicates that this file or directory should be archived. +it is set when a file is created or modified. +it is reset by an archiving system. +.pp +the zero value +.b attr_none +can be used to indicate that no attribute bit is set. +.ss reading the volume id +fat filesystems are identified by a volume id. +the volume id can be read with +.br fat_ioctl_get_volume_id . +.pp +the +.i fd +argument can be a file descriptor for any file or directory of the +filesystem. +it is sufficient to create the file descriptor by calling +.br open (2) +with the +.b o_rdonly +flag. +.pp +the +.i id +argument is a pointer to the field that will be filled with the volume id. +typically the volume id is displayed to the user as a group of two +16-bit fields: +.pp +.in +4n +.ex +printf("volume id %04x\-%04x\en", id >> 16, id & 0xffff); +.ee +.in +.ss reading short filenames of a directory +a file or directory on a fat filesystem always has a short filename +consisting of up to 8 capital letters, optionally followed by a period +and up to 3 capital letters for the file extension. +if the actual filename does not fit into this scheme, it is stored +as a long filename of up to 255 utf-16 characters. +.pp +the short filenames in a directory can be read with +.br vfat_ioctl_readdir_short . +.b vfat_ioctl_readdir_both +reads both the short and the long filenames. +.pp +the +.i fd +argument must be a file descriptor for a directory. +it is sufficient to create the file descriptor by calling +.br open (2) +with the +.b o_rdonly +flag. +the file descriptor can be used only once to iterate over the directory +entries by calling +.br ioctl (2) +repeatedly. +.pp +the +.i entry +argument is a two-element array of the following structures: +.pp +.in +4n +.ex +struct __fat_dirent { + long d_ino; + __kernel_off_t d_off; + uint32_t short d_reclen; + char d_name[256]; +}; +.ee +.in +.pp +the first entry in the array is for the short filename. +the second entry is for the long filename. +.pp +the +.i d_ino +and +.i d_off +fields are filled only for long filenames. +the +.i d_ino +field holds the inode number of the directory. +the +.i d_off +field holds the offset of the file entry in the directory. +as these values are not available for short filenames, the user code should +simply ignore them. +.pp +the field +.i d_reclen +contains the length of the filename in the field +.ir d_name . +to keep backward compatibility, a length of 0 for the short filename signals +that the end of the directory has been reached. +however, the preferred method for detecting the end of the directory +is to test the +.br ioctl (2) +return value. +if no long filename exists, field +.i d_reclen +is set to 0 and +.i d_name +is a character string of length 0 for the long filename. +.sh return value +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.pp +for +.b vfat_ioctl_readdir_both +and +.b vfat_ioctl_readdir_short +a return value of 1 signals that a new directory entry has been read and +a return value of 0 signals that the end of the directory has been reached. +.sh errors +.tp +.b enoent +this error is returned by +.b vfat_ioctl_readdir_both +and +.b vfat_ioctl_readdir_short +if the file descriptor +.i fd +refers to a removed, but still open directory. +.tp +.b enotdir +this error is returned by +.b vfat_ioctl_readdir_both +and +.b vfat_ioctl_readdir_short +if the file descriptor +.i fd +does not refer to a directory. +.tp +.b enotty +the file descriptor +.i fd +does not refer to an object in a fat filesystem. +.pp +for further error values, see +.br ioctl (2). +.sh versions +.br vfat_ioctl_readdir_both +and +.b vfat_ioctl_readdir_short +first appeared in linux 2.0. +.pp +.br fat_ioctl_get_attributes +and +.br fat_ioctl_set_attributes +first appeared +.\" just before we got git history +in linux 2.6.12. +.pp +.b fat_ioctl_get_volume_id +was introduced in version 3.11 +.\" commit 6e5b93ee55d401f1619092fb675b57c28c9ed7ec +of the linux kernel. +.sh conforming to +this api is linux-specific. +.sh examples +.ss toggling the archive flag +the following program demonstrates the usage of +.br ioctl (2) +to manipulate file attributes. +the program reads and displays the archive attribute of a file. +after inverting the value of the attribute, +the program reads and displays the attribute again. +.pp +the following was recorded when applying the program for the file +.ir /mnt/user/foo : +.pp +.in +4n +.ex +# ./toggle_fat_archive_flag /mnt/user/foo +archive flag is set +toggling archive flag +archive flag is not set +.ee +.in +.ss program source (toggle_fat_archive_flag.c) +\& +.ex +#include +#include +#include +#include +#include +#include +#include + +/* + * read file attributes of a file on a fat filesystem. + * output the state of the archive flag. + */ +static uint32_t +readattr(int fd) +{ + uint32_t attr; + int ret; + + ret = ioctl(fd, fat_ioctl_get_attributes, &attr); + if (ret == \-1) { + perror("ioctl"); + exit(exit_failure); + } + + if (attr & attr_arch) + printf("archive flag is set\en"); + else + printf("archive flag is not set\en"); + + return attr; +} + +int +main(int argc, char *argv[]) +{ + uint32_t attr; + int fd; + int ret; + + if (argc != 2) { + printf("usage: %s filename\en", argv[0]); + exit(exit_failure); + } + + fd = open(argv[1], o_rdonly); + if (fd == \-1) { + perror("open"); + exit(exit_failure); + } + + /* + * read and display the fat file attributes. + */ + attr = readattr(fd); + + /* + * invert archive attribute. + */ + printf("toggling archive flag\en"); + attr \(ha= attr_arch; + + /* + * write the changed fat file attributes. + */ + ret = ioctl(fd, fat_ioctl_set_attributes, &attr); + if (ret == \-1) { + perror("ioctl"); + exit(exit_failure); + } + + /* + * read and display the fat file attributes. + */ + readattr(fd); + + close(fd); + + exit(exit_success); +} +.ee +.\" +.ss reading the volume id +the following program demonstrates the use of +.br ioctl (2) +to display the volume id of a fat filesystem. +.pp +the following output was recorded when applying the program for +directory +.ir /mnt/user : +.pp +.in +4n +.ex +$ ./display_fat_volume_id /mnt/user +volume id 6443\-6241 +.ee +.in +.ss program source (display_fat_volume_id.c) +\& +.ex +#include +#include +#include +#include +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + uint32_t id; + int fd; + int ret; + + if (argc != 2) { + printf("usage: %s filename\en", argv[0]); + exit(exit_failure); + } + + fd = open(argv[1], o_rdonly); + if (fd == \-1) { + perror("open"); + exit(exit_failure); + } + + /* + * read volume id. + */ + ret = ioctl(fd, fat_ioctl_get_volume_id, &id); + if (ret == \-1) { + perror("ioctl"); + exit(exit_failure); + } + + /* + * format the output as two groups of 16 bits each. + */ + printf("volume id %04x\-%04x\en", id >> 16, id & 0xffff); + + close(fd); + + exit(exit_success); +} +.ee +.\" +.ss listing a directory +the following program demonstrates the use of +.br ioctl (2) +to list a directory. +.pp +the following was recorded when applying the program to the directory +.ir /mnt/user : +.pp +.in +4n +.ex +$ \fb./fat_dir /mnt/user\fp +\[char46] \-> \(aq\(aq +\[char46]. \-> \(aq\(aq +alongf\(ti1.txt \-> \(aqa long filename.txt\(aq +upper.txt \-> \(aq\(aq +lower.txt \-> \(aqlower.txt\(aq +.ee +.in +.\" +.ss program source +.in +4n +.ex +#include +#include +#include +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + struct __fat_dirent entry[2]; + int fd; + int ret; + + if (argc != 2) { + printf("usage: %s directory\en", argv[0]); + exit(exit_failure); + } + + /* + * open file descriptor for the directory. + */ + fd = open(argv[1], o_rdonly | o_directory); + if (fd == \-1) { + perror("open"); + exit(exit_failure); + } + + for (;;) { + + /* + * read next directory entry. + */ + ret = ioctl( fd, vfat_ioctl_readdir_both, entry); + + /* + * if an error occurs, the return value is \-1. + * if the end of the directory list has been reached, + * the return value is 0. + * for backward compatibility the end of the directory + * list is also signaled by d_reclen == 0. + */ + if (ret < 1) + break; + + /* + * write both the short name and the long name. + */ + printf("%s \-> \(aq%s\(aq\en", entry[0].d_name, entry[1].d_name); + } + + if (ret == \-1) { + perror("vfat_ioctl_readdir_both"); + exit(exit_failure); + } + + /* + * close the file descriptor. + */ + close(fd); + + exit(exit_success); +} +.ee +.in +.sh see also +.br ioctl (2) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1996 andries brouwer +.\" and copyright (c) 2006, 2007 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified 1997-01-31 by eric s. raymond +.\" modified 2000-03-25 by jim van zandt +.\" modified 2001-10-04 by john levon +.\" modified 2003-02-02 by andi kleen +.\" modified 2003-05-21 by michael kerrisk +.\" map_locked works from 2.5.37 +.\" modified 2004-06-17 by michael kerrisk +.\" modified 2004-09-11 by aeb +.\" modified 2004-12-08, from eric estievenart +.\" modified 2004-12-08, mtk, formatting tidy-ups +.\" modified 2006-12-04, mtk, various parts rewritten +.\" 2007-07-10, mtk, added an example program. +.\" 2008-11-18, mtk, document map_stack +.\" +.th mmap 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +mmap, munmap \- map or unmap files or devices into memory +.sh synopsis +.nf +.b #include +.pp +.bi "void *mmap(void *" addr ", size_t " length \ +", int " prot ", int " flags , +.bi " int " fd ", off_t " offset ); +.bi "int munmap(void *" addr ", size_t " length ); +.fi +.pp +see notes for information on feature test macro requirements. +.sh description +.br mmap () +creates a new mapping in the virtual address space of +the calling process. +the starting address for the new mapping is specified in +.ir addr . +the +.i length +argument specifies the length of the mapping (which must be greater than 0). +.pp +if +.i addr +is null, +then the kernel chooses the (page-aligned) address +at which to create the mapping; +this is the most portable method of creating a new mapping. +if +.i addr +is not null, +then the kernel takes it as a hint about where to place the mapping; +on linux, the kernel will pick a nearby page boundary (but always above +or equal to the value specified by +.ir /proc/sys/vm/mmap_min_addr ) +and attempt to create the mapping there. +if another mapping already exists there, the kernel picks a new address that +may or may not depend on the hint. +.\" before linux 2.6.24, the address was rounded up to the next page +.\" boundary; since 2.6.24, it is rounded down! +the address of the new mapping is returned as the result of the call. +.pp +the contents of a file mapping (as opposed to an anonymous mapping; see +.b map_anonymous +below), are initialized using +.i length +bytes starting at offset +.i offset +in the file (or other object) referred to by the file descriptor +.ir fd . +.i offset +must be a multiple of the page size as returned by +.ir sysconf(_sc_page_size) . +.pp +after the +.br mmap () +call has returned, the file descriptor, +.ir fd , +can be closed immediately without invalidating the mapping. +.pp +the +.i prot +argument describes the desired memory protection of the mapping +(and must not conflict with the open mode of the file). +it is either +.b prot_none +or the bitwise or of one or more of the following flags: +.tp 1.1i +.b prot_exec +pages may be executed. +.tp +.b prot_read +pages may be read. +.tp +.b prot_write +pages may be written. +.tp +.b prot_none +pages may not be accessed. +.\" +.ss the flags argument +the +.i flags +argument determines whether updates to the mapping +are visible to other processes mapping the same region, +and whether updates are carried through to the underlying file. +this behavior is determined by including exactly one +of the following values in +.ir flags : +.tp +.b map_shared +share this mapping. +updates to the mapping are visible to other processes mapping the same region, +and (in the case of file-backed mappings) +are carried through to the underlying file. +(to precisely control when updates are carried through +to the underlying file requires the use of +.br msync (2).) +.tp +.br map_shared_validate " (since linux 4.15)" +this flag provides the same behavior as +.b map_shared +except that +.b map_shared +mappings ignore unknown flags in +.ir flags . +by contrast, when creating a mapping using +.br map_shared_validate , +the kernel verifies all passed flags are known and fails the +mapping with the error +.br eopnotsupp +for unknown flags. +this mapping type is also required to be able to use some mapping flags +(e.g., +.br map_sync ). +.tp +.b map_private +create a private copy-on-write mapping. +updates to the mapping are not visible to other processes +mapping the same file, and are not carried through to +the underlying file. +it is unspecified whether changes made to the file after the +.br mmap () +call are visible in the mapped region. +.pp +both +.b map_shared +and +.b map_private +are described in posix.1-2001 and posix.1-2008. +.b map_shared_validate +is a linux extension. +.pp +in addition, zero or more of the following values can be ored in +.ir flags : +.tp +.br map_32bit " (since linux 2.4.20, 2.6)" +put the mapping into the first 2 gigabytes of the process address space. +this flag is supported only on x86-64, for 64-bit programs. +it was added to allow thread stacks to be allocated somewhere +in the first 2\ gb of memory, +so as to improve context-switch performance on some early +64-bit processors. +.\" see http://lwn.net/articles/294642 "tangled up in threads", 19 aug 08 +modern x86-64 processors no longer have this performance problem, +so use of this flag is not required on those systems. +the +.b map_32bit +flag is ignored when +.b map_fixed +is set. +.tp +.b map_anon +synonym for +.br map_anonymous ; +provided for compatibility with other implementations. +.tp +.b map_anonymous +the mapping is not backed by any file; +its contents are initialized to zero. +the +.i fd +argument is ignored; +however, some implementations require +.i fd +to be \-1 if +.b map_anonymous +(or +.br map_anon ) +is specified, +and portable applications should ensure this. +the +.i offset +argument should be zero. +.\" see the pgoff overflow check in do_mmap(). +.\" see the offset check in sys_mmap in arch/x86/kernel/sys_x86_64.c. +the use of +.b map_anonymous +in conjunction with +.b map_shared +is supported on linux only since kernel 2.4. +.tp +.b map_denywrite +this flag is ignored. +.\" introduced in 1.1.36, removed in 1.3.24. +(long ago\(emlinux 2.0 and earlier\(emit signaled +that attempts to write to the underlying file should fail with +.br etxtbsy . +but this was a source of denial-of-service attacks.) +.tp +.b map_executable +this flag is ignored. +.\" introduced in 1.1.38, removed in 1.3.24. flag tested in proc_follow_link. +.\" (long ago, it signaled that the underlying file is an executable. +.\" however, that information was not really used anywhere.) +.\" linus talked about dos related to map_executable, but he was thinking of +.\" map_denywrite? +.tp +.b map_file +compatibility flag. +ignored. +.\" on some systems, this was required as the opposite of +.\" map_anonymous -- mtk, 1 may 2007 +.tp +.b map_fixed +don't interpret +.i addr +as a hint: place the mapping at exactly that address. +.i addr +must be suitably aligned: for most architectures a multiple of the page +size is sufficient; however, some architectures may impose additional +restrictions. +if the memory region specified by +.i addr +and +.i length +overlaps pages of any existing mapping(s), then the overlapped +part of the existing mapping(s) will be discarded. +if the specified address cannot be used, +.br mmap () +will fail. +.ip +software that aspires to be portable should use the +.br map_fixed +flag with care, +keeping in mind that the exact layout of a process's memory mappings +is allowed to change significantly between kernel versions, +c library versions, and operating system releases. +.ir "carefully read the discussion of this flag in notes!" +.tp +.br map_fixed_noreplace " (since linux 4.17)" +.\" commit a4ff8e8620d3f4f50ac4b41e8067b7d395056843 +this flag provides behavior that is similar to +.b map_fixed +with respect to the +.i addr +enforcement, but differs in that +.b map_fixed_noreplace +never clobbers a preexisting mapped range. +if the requested range would collide with an existing mapping, +then this call fails with the error +.b eexist. +this flag can therefore be used as a way to atomically +(with respect to other threads) attempt to map an address range: +one thread will succeed; all others will report failure. +.ip +note that older kernels which do not recognize the +.br map_fixed_noreplace +flag will typically (upon detecting a collision with a preexisting mapping) +fall back to a "non-\c +.b map_fixed\c +" type of behavior: +they will return an address that is different from the requested address. +therefore, backward-compatible software +should check the returned address against the requested address. +.tp +.b map_growsdown +this flag is used for stacks. +it indicates to the kernel virtual memory system that the mapping +should extend downward in memory. +the return address is one page lower than the memory area that is +actually created in the process's virtual address space. +touching an address in the "guard" page below the mapping will cause +the mapping to grow by a page. +this growth can be repeated until the mapping grows to within a +page of the high end of the next lower mapping, +at which point touching the "guard" page will result in a +.b sigsegv +signal. +.tp +.br map_hugetlb " (since linux 2.6.32)" +allocate the mapping using "huge" pages. +see the linux kernel source file +.i documentation/admin\-guide/mm/hugetlbpage.rst +for further information, as well as notes, below. +.tp +.br map_huge_2mb ", " map_huge_1gb " (since linux 3.8)" +.\" see https://lwn.net/articles/533499/ +used in conjunction with +.b map_hugetlb +to select alternative hugetlb page sizes (respectively, 2\ mb and 1\ gb) +on systems that support multiple hugetlb page sizes. +.ip +more generally, the desired huge page size can be configured by encoding +the base-2 logarithm of the desired page size in the six bits at the offset +.br map_huge_shift . +(a value of zero in this bit field provides the default huge page size; +the default huge page size can be discovered via the +.i hugepagesize +field exposed by +.ir /proc/meminfo .) +thus, the above two constants are defined as: +.ip +.in +4n +.ex +#define map_huge_2mb (21 << map_huge_shift) +#define map_huge_1gb (30 << map_huge_shift) +.ee +.in +.ip +the range of huge page sizes that are supported by the system +can be discovered by listing the subdirectories in +.ir /sys/kernel/mm/hugepages . +.tp +.br map_locked " (since linux 2.5.37)" +mark the mapped region to be locked in the same way as +.br mlock (2). +this implementation will try to populate (prefault) the whole range but the +.br mmap () +call doesn't fail with +.b enomem +if this fails. +therefore major faults might happen later on. +so the semantic is not as strong as +.br mlock (2). +one should use +.br mmap () +plus +.br mlock (2) +when major faults are not acceptable after the initialization of the mapping. +the +.br map_locked +flag is ignored in older kernels. +.\" if set, the mapped pages will not be swapped out. +.tp +.br map_nonblock " (since linux 2.5.46)" +this flag is meaningful only in conjunction with +.br map_populate . +don't perform read-ahead: +create page tables entries only for pages +that are already present in ram. +since linux 2.6.23, +.\" commit 54cb8821de07f2ffcd28c380ce9b93d5784b40d7 +this flag causes +.br map_populate +to do nothing. +one day, the combination of +.br map_populate +and +.br map_nonblock +may be reimplemented. +.tp +.b map_noreserve +do not reserve swap space for this mapping. +when swap space is reserved, one has the guarantee +that it is possible to modify the mapping. +when swap space is not reserved one might get +.b sigsegv +upon a write +if no physical memory is available. +see also the discussion of the file +.i /proc/sys/vm/overcommit_memory +in +.br proc (5). +in kernels before 2.6, this flag had effect only for +private writable mappings. +.tp +.br map_populate " (since linux 2.5.46)" +populate (prefault) page tables for a mapping. +for a file mapping, this causes read-ahead on the file. +this will help to reduce blocking on page faults later. +the +.br mmap () +call doesn't fail if the mapping cannot be populated (for example, due +to limitations on the number of mapped huge pages when using +.br map_hugetlb ). +.br map_populate +is supported for private mappings only since linux 2.6.23. +.tp +.br map_stack " (since linux 2.6.27)" +allocate the mapping at an address suitable for a process +or thread stack. +.ip +this flag is currently a no-op on linux. +however, by employing this flag, applications can ensure that +they transparently obtain support if the flag +is implemented in the future. +thus, it is used in the glibc threading implementation to allow for +the fact that some architectures may (later) require special treatment +for stack allocations. +.\" see http://lwn.net/articles/294642 "tangled up in threads", 19 aug 08 +.\" commit cd98a04a59e2f94fa64d5bf1e26498d27427d5e7 +.\" http://thread.gmane.org/gmane.linux.kernel/720412 +.\" "pthread_create() slow for many threads; also time to revisit 64b +.\" context switch optimization?" +a further reason to employ this flag is portability: +.br map_stack +exists (and has an effect) on some other systems (e.g., some of the bsds). +.tp +.br map_sync " (since linux 4.15)" +this flag is available only with the +.b map_shared_validate +mapping type; +mappings of type +.b map_shared +will silently ignore this flag. +this flag is supported only for files supporting dax +(direct mapping of persistent memory). +for other files, creating a mapping with this flag results in an +.b eopnotsupp +error. +.ip +shared file mappings with this flag provide the guarantee that while +some memory is mapped writable in the address space of the process, +it will be visible in the same file at the same offset even after +the system crashes or is rebooted. +in conjunction with the use of appropriate cpu instructions, +this provides users of such mappings with a more efficient way +of making data modifications persistent. +.tp +.br map_uninitialized " (since linux 2.6.33)" +don't clear anonymous pages. +this flag is intended to improve performance on embedded devices. +this flag is honored only if the kernel was configured with the +.b config_mmap_allow_uninitialized +option. +because of the security implications, +that option is normally enabled only on embedded devices +(i.e., devices where one has complete control of the contents of user memory). +.pp +of the above flags, only +.b map_fixed +is specified in posix.1-2001 and posix.1-2008. +however, most systems also support +.b map_anonymous +(or its synonym +.br map_anon ). +.\" fixme . for later review when issue 8 is one day released... +.\" posix may add map_anon in the future +.\" http://austingroupbugs.net/tag_view_page.php?tag_id=8 +.\" http://austingroupbugs.net/view.php?id=850 +.ss munmap() +the +.br munmap () +system call deletes the mappings for the specified address range, and +causes further references to addresses within the range to generate +invalid memory references. +the region is also automatically unmapped +when the process is terminated. +on the other hand, closing the file +descriptor does not unmap the region. +.pp +the address +.i addr +must be a multiple of the page size (but +.i length +need not be). +all pages containing a part +of the indicated range are unmapped, and subsequent references +to these pages will generate +.br sigsegv . +it is not an error if the +indicated range does not contain any mapped pages. +.sh return value +on success, +.br mmap () +returns a pointer to the mapped area. +on error, the value +.b map_failed +(that is, +.ir "(void\ *)\ \-1" ) +is returned, and +.i errno +is set to indicate the error. +.pp +on success, +.br munmap () +returns 0. +on failure, it returns \-1, and +.i errno +is set to indicate the error (probably to +.br einval ). +.sh errors +.tp +.b eacces +a file descriptor refers to a non-regular file. +or a file mapping was requested, but +.i fd +is not open for reading. +or +.b map_shared +was requested and +.b prot_write +is set, but +.i fd +is not open in read/write +.rb ( o_rdwr ) +mode. +or +.b prot_write +is set, but the file is append-only. +.tp +.b eagain +the file has been locked, or too much memory has been locked (see +.br setrlimit (2)). +.tp +.b ebadf +.i fd +is not a valid file descriptor (and +.b map_anonymous +was not set). +.tp +.b eexist +.br map_fixed_noreplace +was specified in +.ir flags , +and the range covered by +.ir addr +and +.ir length +clashes with an existing mapping. +.tp +.b einval +we don't like +.ir addr , +.ir length , +or +.i offset +(e.g., they are too large, or not aligned on a page boundary). +.tp +.b einval +(since linux 2.6.12) +.i length +was 0. +.tp +.b einval +.i flags +contained none of +.br map_private , +.br map_shared , +or +.br map_shared_validate . +.tp +.b enfile +.\" this is for shared anonymous segments +.\" [2.6.7] shmem_zero_setup()-->shmem_file_setup()-->get_empty_filp() +the system-wide limit on the total number of open files has been reached. +.\" .tp +.\" .b enoexec +.\" a file could not be mapped for reading. +.tp +.b enodev +the underlying filesystem of the specified file does not support +memory mapping. +.tp +.b enomem +no memory is available. +.tp +.b enomem +the process's maximum number of mappings would have been exceeded. +this error can also occur for +.br munmap (), +when unmapping a region in the middle of an existing mapping, +since this results in two smaller mappings on either side of +the region being unmapped. +.tp +.b enomem +(since linux 4.7) +the process's +.b rlimit_data +limit, described in +.br getrlimit (2), +would have been exceeded. +.tp +.b eoverflow +on 32-bit architecture together with the large file extension +(i.e., using 64-bit +.ir off_t ): +the number of pages used for +.i length +plus number of pages used for +.i offset +would overflow +.i "unsigned long" +(32 bits). +.tp +.b eperm +the +.i prot +argument asks for +.b prot_exec +but the mapped area belongs to a file on a filesystem that +was mounted no-exec. +.\" (since 2.4.25 / 2.6.0.) +.tp +.b eperm +the operation was prevented by a file seal; see +.br fcntl (2). +.tp +.b eperm +the +.b map_hugetlb +flag was specified, but the caller was not privileged (did not have the +.b cap_ipc_lock +capability) +and is not a member of the +.i sysctl_hugetlb_shm_group +group; see the description of +.i /proc/sys/vm/sysctl_hugetlb_shm_group +in +.tp +.b etxtbsy +.b map_denywrite +was set but the object specified by +.i fd +is open for writing. +.pp +use of a mapped region can result in these signals: +.tp +.b sigsegv +attempted write into a region mapped as read-only. +.tp +.b sigbus +attempted access to a page of the buffer that lies beyond the +end of the mapped file. +for an explanation of the treatment of the bytes in the page that +corresponds to the end of a mapped file that is not a multiple +of the page size, see notes. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br mmap (), +.br munmap () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, svr4, 4.4bsd. +.\" svr4 documents additional error codes enxio and enodev. +.\" susv2 documents additional error codes emfile and eoverflow. +.pp +on posix systems on which +.br mmap (), +.br msync (2), +and +.br munmap () +are available, +.b _posix_mapped_files +is defined in \fi\fp to a value greater than 0. +(see also +.br sysconf (3).) +.\" posix.1-2001: it shall be defined to -1 or 0 or 200112l. +.\" -1: unavailable, 0: ask using sysconf(). +.\" glibc defines it to 1. +.sh notes +memory mapped by +.br mmap () +is preserved across +.br fork (2), +with the same attributes. +.pp +a file is mapped in multiples of the page size. +for a file that is not +a multiple of the page size, +the remaining bytes in the partial page at the end of the mapping +are zeroed when mapped, +and modifications to that region are not written out to the file. +the effect of +changing the size of the underlying file of a mapping on the pages that +correspond to added or removed regions of the file is unspecified. +.pp +on some hardware architectures (e.g., i386), +.b prot_write +implies +.br prot_read . +it is architecture dependent whether +.b prot_read +implies +.b prot_exec +or not. +portable programs should always set +.b prot_exec +if they intend to execute code in the new mapping. +.pp +the portable way to create a mapping is to specify +.i addr +as 0 (null), and omit +.b map_fixed +from +.ir flags . +in this case, the system chooses the address for the mapping; +the address is chosen so as not to conflict with any existing mapping, +and will not be 0. +if the +.b map_fixed +flag is specified, and +.i addr +is 0 (null), then the mapped address will be 0 (null). +.pp +certain +.i flags +constants are defined only if suitable feature test macros are defined +(possibly by default): +.br _default_source +with glibc 2.19 or later; +or +.br _bsd_source +or +.br _svid_source +in glibc 2.19 and earlier. +(employing +.br _gnu_source +also suffices, +and requiring that macro specifically would have been more logical, +since these flags are all linux-specific.) +the relevant flags are: +.br map_32bit , +.br map_anonymous +(and the synonym +.br map_anon ), +.br map_denywrite , +.br map_executable , +.br map_file , +.br map_growsdown , +.br map_hugetlb , +.br map_locked , +.br map_nonblock , +.br map_noreserve , +.br map_populate , +and +.br map_stack . +.pp +an application can determine which pages of a mapping are +currently resident in the buffer/page cache using +.br mincore (2). +.\" +.ss using map_fixed safely +the only safe use for +.br map_fixed +is where the address range specified by +.ir addr +and +.i length +was previously reserved using another mapping; +otherwise, the use of +.br map_fixed +is hazardous because it forcibly removes preexisting mappings, +making it easy for a multithreaded process to corrupt its own address space. +.pp +for example, suppose that thread a looks through +.i /proc//maps +in order to locate an unused address range that it can map using +.br map_fixed , +while thread b simultaneously acquires part or all of that same +address range. +when thread a subsequently employs +.br mmap(map_fixed) , +it will effectively clobber the mapping that thread b created. +in this scenario, +thread b need not create a mapping directly; simply making a library call +that, internally, uses +.br dlopen (3) +to load some other shared library, will suffice. +the +.br dlopen (3) +call will map the library into the process's address space. +furthermore, almost any library call may be implemented in a way that +adds memory mappings to the address space, either with this technique, +or by simply allocating memory. +examples include +.br brk (2), +.br malloc (3), +.br pthread_create (3), +and the pam libraries +.ur http://www.linux-pam.org +.ue . +.pp +since linux 4.17, a multithreaded program can use the +.br map_fixed_noreplace +flag to avoid the hazard described above +when attempting to create a mapping at a fixed address +that has not been reserved by a preexisting mapping. +.\" +.ss timestamps changes for file-backed mappings +for file-backed mappings, the +.i st_atime +field for the mapped file may be updated at any time between the +.br mmap () +and the corresponding unmapping; the first reference to a mapped +page will update the field if it has not been already. +.pp +the +.i st_ctime +and +.i st_mtime +field for a file mapped with +.b prot_write +and +.b map_shared +will be updated after +a write to the mapped region, and before a subsequent +.br msync (2) +with the +.b ms_sync +or +.b ms_async +flag, if one occurs. +.\" +.ss huge page (huge tlb) mappings +for mappings that employ huge pages, the requirements for the arguments of +.br mmap () +and +.br munmap () +differ somewhat from the requirements for mappings +that use the native system page size. +.pp +for +.br mmap (), +.i offset +must be a multiple of the underlying huge page size. +the system automatically aligns +.i length +to be a multiple of the underlying huge page size. +.pp +for +.br munmap (), +.ir addr , +and +.i length +must both be a multiple of the underlying huge page size. +.\" +.ss c library/kernel differences +this page describes the interface provided by the glibc +.br mmap () +wrapper function. +originally, this function invoked a system call of the same name. +since kernel 2.4, that system call has been superseded by +.br mmap2 (2), +and nowadays +.\" since around glibc 2.1/2.2, depending on the platform. +the glibc +.br mmap () +wrapper function invokes +.br mmap2 (2) +with a suitably adjusted value for +.ir offset . +.sh bugs +on linux, there are no guarantees like those suggested above under +.br map_noreserve . +by default, any process can be killed +at any moment when the system runs out of memory. +.pp +in kernels before 2.6.7, the +.b map_populate +flag has effect only if +.i prot +is specified as +.br prot_none . +.pp +susv3 specifies that +.br mmap () +should fail if +.i length +is 0. +however, in kernels before 2.6.12, +.br mmap () +succeeded in this case: no mapping was created and the call returned +.ir addr . +since kernel 2.6.12, +.br mmap () +fails with the error +.b einval +for this case. +.pp +posix specifies that the system shall always +zero fill any partial page at the end +of the object and that system will never write any modification of the +object beyond its end. +on linux, when you write data to such partial page after the end +of the object, the data stays in the page cache even after the file +is closed and unmapped +and even though the data is never written to the file itself, +subsequent mappings may see the modified content. +in some cases, this could be fixed by calling +.br msync (2) +before the unmap takes place; +however, this doesn't work on +.br tmpfs (5) +(for example, when using the posix shared memory interface documented in +.br shm_overview (7)). +.sh examples +.\" fixme . add an example here that uses an anonymous shared region for +.\" ipc between parent and child. +the following program prints part of the file specified in +its first command-line argument to standard output. +the range of bytes to be printed is specified via offset and length +values in the second and third command-line arguments. +the program creates a memory mapping of the required +pages of the file and then uses +.br write (2) +to output the desired bytes. +.ss program source +.ex +#include +#include +#include +#include +#include +#include + +#define handle_error(msg) \e + do { perror(msg); exit(exit_failure); } while (0) + +int +main(int argc, char *argv[]) +{ + char *addr; + int fd; + struct stat sb; + off_t offset, pa_offset; + size_t length; + ssize_t s; + + if (argc < 3 || argc > 4) { + fprintf(stderr, "%s file offset [length]\en", argv[0]); + exit(exit_failure); + } + + fd = open(argv[1], o_rdonly); + if (fd == \-1) + handle_error("open"); + + if (fstat(fd, &sb) == \-1) /* to obtain file size */ + handle_error("fstat"); + + offset = atoi(argv[2]); + pa_offset = offset & \(ti(sysconf(_sc_page_size) \- 1); + /* offset for mmap() must be page aligned */ + + if (offset >= sb.st_size) { + fprintf(stderr, "offset is past end of file\en"); + exit(exit_failure); + } + + if (argc == 4) { + length = atoi(argv[3]); + if (offset + length > sb.st_size) + length = sb.st_size \- offset; + /* can\(aqt display bytes past end of file */ + + } else { /* no length arg ==> display to end of file */ + length = sb.st_size \- offset; + } + + addr = mmap(null, length + offset \- pa_offset, prot_read, + map_private, fd, pa_offset); + if (addr == map_failed) + handle_error("mmap"); + + s = write(stdout_fileno, addr + offset \- pa_offset, length); + if (s != length) { + if (s == \-1) + handle_error("write"); + + fprintf(stderr, "partial write"); + exit(exit_failure); + } + + munmap(addr, length + offset \- pa_offset); + close(fd); + + exit(exit_success); +} +.ee +.sh see also +.br ftruncate (2), +.br getpagesize (2), +.br memfd_create (2), +.br mincore (2), +.br mlock (2), +.br mmap2 (2), +.br mprotect (2), +.br mremap (2), +.br msync (2), +.br remap_file_pages (2), +.br setrlimit (2), +.br shmat (2), +.br userfaultfd (2), +.br shm_open (3), +.br shm_overview (7) +.pp +the descriptions of the following files in +.br proc (5): +.ir /proc/[pid]/maps , +.ir /proc/[pid]/map_files , +and +.ir /proc/[pid]/smaps . +.pp +b.o. gallmeister, posix.4, o'reilly, pp. 128\(en129 and 389\(en391. +.\" +.\" repeat after me: private read-only mappings are 100% equivalent to +.\" shared read-only mappings. no ifs, buts, or maybes. -- linus +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" contributed by niki a. rahimi, ltc security development +.\" narahimi@us.ibm.com +.\" +.\" %%%license_start(freely_redistributable) +.\" may be freely distributed and modified. +.\" %%%license_end +.\" +.th pciconfig_read 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +pciconfig_read, pciconfig_write, pciconfig_iobase \- pci device information handling +.sh synopsis +.nf +.b #include +.pp +.bi "int pciconfig_read(unsigned long " bus ", unsigned long " dfn , +.bi " unsigned long " off ", unsigned long " len , +.bi " unsigned char *" buf ); +.bi "int pciconfig_write(unsigned long " bus ", unsigned long " dfn , +.bi " unsigned long " off ", unsigned long " len , +.bi " unsigned char *" buf ); +.bi "int pciconfig_iobase(int " which ", unsigned long " bus , +.bi " unsigned long " devfn ); +.fi +.sh description +most of the interaction with pci devices is already handled by the +kernel pci layer, +and thus these calls should not normally need to be accessed from user space. +.tp +.br pciconfig_read () +reads to +.i buf +from device +.i dev +at offset +.i off +value. +.tp +.br pciconfig_write () +writes from +.i buf +to device +.i dev +at offset +.i off +value. +.tp +.br pciconfig_iobase () +you pass it a bus/devfn pair and get a physical address for either the +memory offset (for things like prep, this is 0xc0000000), +the io base for pio cycles, or the isa holes if any. +.sh return value +.tp +.br pciconfig_read () +on success, zero is returned. +on error, \-1 is returned and +.i errno +is set to indicate the error. +.tp +.br pciconfig_write () +on success, zero is returned. +on error, \-1 is returned and +.i errno +is set to indicate the error. +.tp +.br pciconfig_iobase () +returns information on locations of various i/o +regions in physical memory according to the +.i which +value. +values for +.i which +are: +.br iobase_bridge_number , +.br iobase_memory , +.br iobase_io , +.br iobase_isa_io , +.br iobase_isa_mem . +.sh errors +.tp +.b einval +.i len +value is invalid. +this does not apply to +.br pciconfig_iobase (). +.tp +.b eio +i/o error. +.tp +.b enodev +for +.br pciconfig_iobase (), +"hose" value is null. +for the other calls, could not find a slot. +.tp +.b enosys +the system has not implemented these calls +.rb ( config_pci +not defined). +.tp +.b eopnotsupp +this return value is valid only for +.br pciconfig_iobase (). +it is returned if the value for +.i which +is invalid. +.tp +.b eperm +user does not have the +.b cap_sys_admin +capability. +this does not apply to +.br pciconfig_iobase (). +.sh conforming to +these calls are linux-specific, available since linux 2.0.26/2.1.11. +.sh see also +.br capabilities (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2003 free software foundation, inc. +.\" copyright (c) 2015 andrew lutomirski +.\" author: kent yoder +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" this file is distributed according to the gnu general public license. +.\" %%%license_end +.\" +.th set_thread_area 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +get_thread_area, set_thread_area \- manipulate thread-local storage information +.sh synopsis +.nf +.br "#include " " /* definition of " sys_* " constants */" +.b #include +.pp +.b #if defined __i386__ || defined __x86_64__ +.br "# include " " /* definition of " "struct user_desc" " */" +.pp +.bi "int syscall(sys_get_thread_area, struct user_desc *" u_info ); +.bi "int syscall(sys_set_thread_area, struct user_desc *" u_info ); +.pp +.b #elif defined __m68k__ +.pp +.b "int syscall(sys_get_thread_area);" +.bi "int syscall(sys_set_thread_area, unsigned long " tp ); +.pp +.b #elif defined __mips__ +.pp +.bi "int syscall(sys_set_thread_area, unsigned long " addr ); +.pp +.b #endif +.fi +.pp +.ir note : +glibc provides no wrappers for these system calls, +necessitating the use of +.br syscall (2). +.sh description +these calls provide architecture-specific support for a thread-local storage +implementation. +at the moment, +.br set_thread_area () +is available on m68k, mips, and x86 (both 32-bit and 64-bit variants); +.br get_thread_area () +is available on m68k and x86. +.pp +on m68k and mips, +.br set_thread_area () +allows storing an arbitrary pointer (provided in the +.b tp +argument on m68k and in the +.b addr +argument on mips) +in the kernel data structure associated with the calling thread; +this pointer can later be retrieved using +.br get_thread_area () +(see also notes +for information regarding obtaining the thread pointer on mips). +.pp +on x86, linux dedicates three global descriptor table (gdt) entries for +thread-local storage. +for more information about the gdt, see the +intel software developer's manual or the amd architecture programming manual. +.pp +both of these system calls take an argument that is a pointer +to a structure of the following type: +.pp +.in +4n +.ex +struct user_desc { + unsigned int entry_number; + unsigned int base_addr; + unsigned int limit; + unsigned int seg_32bit:1; + unsigned int contents:2; + unsigned int read_exec_only:1; + unsigned int limit_in_pages:1; + unsigned int seg_not_present:1; + unsigned int useable:1; +#ifdef __x86_64__ + unsigned int lm:1; +#endif +}; +.ee +.in +.pp +.br get_thread_area () +reads the gdt entry indicated by +.i u_info\->entry_number +and fills in the rest of the fields in +.ir u_info . +.pp +.br set_thread_area () +sets a tls entry in the gdt. +.pp +the tls array entry set by +.br set_thread_area () +corresponds to the value of +.i u_info\->entry_number +passed in by the user. +if this value is in bounds, +.br set_thread_area () +writes the tls descriptor pointed to by +.i u_info +into the thread's tls array. +.pp +when +.br set_thread_area () +is passed an +.i entry_number +of \-1, it searches for a free tls entry. +if +.br set_thread_area () +finds a free tls entry, the value of +.i u_info\->entry_number +is set upon return to show which entry was changed. +.pp +a +.i user_desc +is considered "empty" if +.i read_exec_only +and +.i seg_not_present +are set to 1 and all of the other fields are 0. +if an "empty" descriptor is passed to +.br set_thread_area (), +the corresponding tls entry will be cleared. +see bugs for additional details. +.pp +since linux 3.19, +.br set_thread_area () +cannot be used to write non-present segments, 16-bit segments, or code +segments, although clearing a segment is still acceptable. +.sh return value +on x86, these system calls +return 0 on success, and \-1 on failure, with +.i errno +set to indicate the error. +.pp +on mips and m68k, +.br set_thread_area () +always returns 0. +on m68k, +.br get_thread_area () +returns the thread area pointer value +(previously set via +.br set_thread_area ()). +.sh errors +.tp +.b efault +\fiu_info\fp is an invalid pointer. +.tp +.b einval +\fiu_info\->entry_number\fp is out of bounds. +.tp +.b enosys +.br get_thread_area () +or +.br set_thread_area () +was invoked as a 64-bit system call. +.tp +.b esrch +.rb ( set_thread_area ()) +a free tls entry could not be located. +.sh versions +.br set_thread_area () +first appeared in linux 2.5.29. +.br get_thread_area () +first appeared in linux 2.5.32. +.sh conforming to +.br set_thread_area () +and +.br get_thread_area () +are linux-specific and should not be used in programs that are intended +to be portable. +.sh notes +these system calls are generally intended for use only by threading libraries. +.pp +.br arch_prctl (2) +can interfere with +.br set_thread_area () +on x86. +see +.br arch_prctl (2) +for more details. +this is not normally a problem, as +.br arch_prctl (2) +is normally used only by 64-bit programs. +.pp +on mips, the current value of the thread area pointer can be obtained +using the instruction: +.pp +.in +4n +.ex +rdhwr dest, $29 +.ee +.in +.pp +this instruction traps and is handled by kernel. +.sh bugs +on 64-bit kernels before linux 3.19, +.\" commit e30ab185c490e9a9381385529e0fd32f0a399495 +one of the padding bits in +.ir user_desc , +if set, would prevent the descriptor from being considered empty (see +.br modify_ldt (2)). +as a result, the only reliable way to clear a tls entry is to use +.br memset (3) +to zero the entire +.i user_desc +structure, including padding bits, and then to set the +.i read_exec_only +and +.i seg_not_present +bits. +on linux 3.19, a +.i user_desc +consisting entirely of zeros except for +.i entry_number +will also be interpreted as a request to clear a tls entry, but this +behaved differently on older kernels. +.pp +prior to linux 3.19, the ds and es segment registers must not reference +tls entries. +.sh see also +.br arch_prctl (2), +.br modify_ldt (2), +.br ptrace (2) +.rb ( ptrace_get_thread_area " and " ptrace_set_thread_area ) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/rpc.3 + +.so man2/sigsuspend.2 + +.\" copyright (c) markus kuhn, 1995, 2001 +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" 1995-11-26 markus kuhn +.\" first version written +.\" 2001-05-11 markus kuhn +.\" update +.\" +.th unicode 7 2021-03-22 "gnu" "linux programmer's manual" +.sh name +unicode \- universal character set +.sh description +the international standard iso 10646 defines the +universal character set (ucs). +ucs contains all characters of all other character set standards. +it also guarantees "round-trip compatibility"; +in other words, +conversion tables can be built such that no information is lost +when a string is converted from any other encoding to ucs and back. +.pp +ucs contains the characters required to represent practically all +known languages. +this includes not only the latin, greek, cyrillic, +hebrew, arabic, armenian, and georgian scripts, but also chinese, +japanese and korean han ideographs as well as scripts such as +hiragana, katakana, hangul, devanagari, bengali, gurmukhi, gujarati, +oriya, tamil, telugu, kannada, malayalam, thai, lao, khmer, bopomofo, +tibetan, runic, ethiopic, canadian syllabics, cherokee, mongolian, +ogham, myanmar, sinhala, thaana, yi, and others. +for scripts not yet +covered, research on how to best encode them for computer usage is +still going on and they will be added eventually. +this might +eventually include not only hieroglyphs and various historic +indo-european languages, but even some selected artistic scripts such +as tengwar, cirth, and klingon. +ucs also covers a large number of +graphical, typographical, mathematical, and scientific symbols, +including those provided by tex, postscript, apl, ms-dos, ms-windows, +macintosh, ocr fonts, as well as many word processing and publishing +systems, and more are being added. +.pp +the ucs standard (iso 10646) describes a +31-bit character set architecture +consisting of 128 24-bit +.ir groups , +each divided into 256 16-bit +.i planes +made up of 256 8-bit +.i rows +with 256 +.i column +positions, one for each character. +part 1 of the standard (iso 10646-1) +defines the first 65534 code positions (0x0000 to 0xfffd), which form +the +.ir "basic multilingual plane" +(bmp), that is plane 0 in group 0. +part 2 of the standard (iso 10646-2) +adds characters to group 0 outside the bmp in several +.i "supplementary planes" +in the range 0x10000 to 0x10ffff. +there are no plans to add characters +beyond 0x10ffff to the standard, therefore of the entire code space, +only a small fraction of group 0 will ever be actually used in the +foreseeable future. +the bmp contains all characters found in the +commonly used other character sets. +the supplemental planes added by +iso 10646-2 cover only more exotic characters for special scientific, +dictionary printing, publishing industry, higher-level protocol and +enthusiast needs. +.pp +the representation of each ucs character as a 2-byte word is referred +to as the ucs-2 form (only for bmp characters), +whereas ucs-4 is the representation of each character by a 4-byte word. +in addition, there exist two encoding forms utf-8 +for backward compatibility with ascii processing software and utf-16 +for the backward-compatible handling of non-bmp characters up to +0x10ffff by ucs-2 software. +.pp +the ucs characters 0x0000 to 0x007f are identical to those of the +classic us-ascii +character set and the characters in the range 0x0000 to 0x00ff +are identical to those in +iso 8859-1 (latin-1). +.ss combining characters +some code points in ucs +have been assigned to +.ir "combining characters" . +these are similar to the nonspacing accent keys on a typewriter. +a combining character just adds an accent to the previous character. +the most important accented characters have codes of their own in ucs, +however, the combining character mechanism allows us to add accents +and other diacritical marks to any character. +the combining characters +always follow the character which they modify. +for example, the german +character umlaut-a ("latin capital letter a with diaeresis") can +either be represented by the precomposed ucs code 0x00c4, or +alternatively as the combination of a normal "latin capital letter a" +followed by a "combining diaeresis": 0x0041 0x0308. +.pp +combining characters are essential for instance for encoding the thai +script or for mathematical typesetting and users of the international +phonetic alphabet. +.ss implementation levels +as not all systems are expected to support advanced mechanisms like +combining characters, iso 10646-1 specifies the following three +.i implementation levels +of ucs: +.tp 0.9i +level 1 +combining characters and hangul jamo +(a variant encoding of the korean script, where a hangul syllable +glyph is coded as a triplet or pair of vowel/consonant codes) are not +supported. +.tp +level 2 +in addition to level 1, combining characters are now allowed for some +languages where they are essential (e.g., thai, lao, hebrew, +arabic, devanagari, malayalam). +.tp +level 3 +all ucs characters are supported. +.pp +the unicode 3.0 standard +published by the unicode consortium +contains exactly the ucs basic multilingual plane +at implementation level 3, as described in iso 10646-1:2000. +unicode 3.1 added the supplemental planes of iso 10646-2. +the unicode standard and +technical reports published by the unicode consortium provide much +additional information on the semantics and recommended usages of +various characters. +they provide guidelines and algorithms for +editing, sorting, comparing, normalizing, converting, and displaying +unicode strings. +.ss unicode under linux +under gnu/linux, the c type +.i wchar_t +is a signed 32-bit integer type. +its values are always interpreted +by the c library as ucs +code values (in all locales), a convention that is signaled by the gnu +c library to applications by defining the constant +.b __stdc_iso_10646__ +as specified in the iso c99 standard. +.pp +ucs/unicode can be used just like ascii in input/output streams, +terminal communication, plaintext files, filenames, and environment +variables in the ascii compatible utf-8 multibyte encoding. +to signal the use of utf-8 as the character +encoding to all applications, a suitable +.i locale +has to be selected via environment variables (e.g., +"lang=en_gb.utf-8"). +.pp +the +.b nl_langinfo(codeset) +function returns the name of the selected encoding. +library functions such as +.br wctomb (3) +and +.br mbsrtowcs (3) +can be used to transform the internal +.i wchar_t +characters and strings into the system character encoding and back +and +.br wcwidth (3) +tells how many positions (0\(en2) the cursor is advanced by the +output of a character. +.ss private use areas (pua) +in the basic multilingual plane, +the range 0xe000 to 0xf8ff will never be assigned to any characters by +the standard and is reserved for private usage. +for the linux +community, this private area has been subdivided further into the +range 0xe000 to 0xefff which can be used individually by any end-user +and the linux zone in the range 0xf000 to 0xf8ff where extensions are +coordinated among all linux users. +the registry of the characters +assigned to the linux zone is maintained by lanana and the registry +itself is +.i documentation/admin\-guide/unicode.rst +in the linux kernel sources +.\" commit 9d85025b0418163fae079c9ba8f8445212de8568 +(or +.i documentation/unicode.txt +before linux 4.10). +.pp +two other planes are reserved for private usage, plane 15 +(supplementary private use area-a, range 0xf0000 to 0xffffd) +and plane 16 (supplementary private use area-b, range +0x100000 to 0x10fffd). +.ss literature +.ip * 3 +information technology \(em universal multiple-octet coded character +set (ucs) \(em part 1: architecture and basic multilingual plane. +international standard iso/iec 10646-1, international organization +for standardization, geneva, 2000. +.ip +this is the official specification of ucs. +available from +.ur http://www.iso.ch/ +.ue . +.ip * +the unicode standard, version 3.0. +the unicode consortium, addison-wesley, +reading, ma, 2000, isbn 0-201-61633-5. +.ip * +s.\& harbison, g.\& steele. c: a reference manual. fourth edition, +prentice hall, englewood cliffs, 1995, isbn 0-13-326224-3. +.ip +a good reference book about the c programming language. +the fourth +edition covers the 1994 amendment 1 to the iso c90 standard, which +adds a large number of new c library functions for handling wide and +multibyte character encodings, but it does not yet cover iso c99, +which improved wide and multibyte character support even further. +.ip * +unicode technical reports. +.rs +.ur http://www.unicode.org\:/reports/ +.ue +.re +.ip * +markus kuhn: utf-8 and unicode faq for unix/linux. +.rs +.ur http://www.cl.cam.ac.uk\:/\(timgk25\:/unicode.html +.ue +.re +.ip * +bruno haible: unicode howto. +.rs +.ur http://www.tldp.org\:/howto\:/unicode\-howto.html +.ue +.re +.\" .sh author +.\" markus kuhn +.sh see also +.br locale (1), +.br setlocale (3), +.br charsets (7), +.br utf\-8 (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2015 william woodruff (william@tuffbizz.com) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th get_phys_pages 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +get_phys_pages, get_avphys_pages \- get total and available physical +page counts +.sh synopsis +.nf +.b "#include " +.pp +.b long get_phys_pages(void); +.b long get_avphys_pages(void); +.fi +.sh description +the function +.br get_phys_pages () +returns the total number of physical pages of memory available on the system. +.pp +the function +.br get_avphys_pages () +returns the number of currently available physical pages of memory on the +system. +.sh return value +on success, +these functions return a nonnegative value as given in description. +on failure, they return \-1 and set +.i errno +to indicate the error. +.sh errors +.tp +.b enosys +the system could not provide the required information +(possibly because the +.i /proc +filesystem was not mounted). +.sh conforming to +these functions are gnu extensions. +.sh notes +before glibc 2.23, +these functions obtained the required information by scanning the +.i memtotal +and +.i memfree +fields of +.ir /proc/meminfo . +since glibc 2.23, +these functions obtain the required information by calling +.br sysinfo (2). +.pp +the following +.br sysconf (3) +calls provide a portable means of obtaining the same information as the +functions described on this page. +.pp +.in +4n +.ex +total_pages = sysconf(_sc_phys_pages); /* total pages */ +avl_pages = sysconf(_sc_avphys_pages); /* available pages */ +.ee +.in +.sh examples +the following example shows how +.br get_phys_pages () +and +.br get_avphys_pages () +can be used. +.pp +.ex +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + printf("this system has %ld pages of physical memory and " + "%ld pages of physical memory available.\en", + get_phys_pages(), get_avphys_pages()); + exit(exit_success); +} +.ee +.sh see also +.br sysconf (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/ether_aton.3 + +.\" copyright (c) 2003 andries brouwer (aeb@cwi.nl) +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th aio_read 3 2021-03-22 "" "linux programmer's manual" +.sh name +aio_read \- asynchronous read +.sh synopsis +.nf +.b "#include " +.pp +.bi "int aio_read(struct aiocb *" aiocbp ); +.pp +link with \fi\-lrt\fp. +.fi +.sh description +the +.br aio_read () +function queues the i/o request described by the buffer pointed to by +.ir aiocbp . +this function is the asynchronous analog of +.br read (2). +the arguments of the call +.pp + read(fd, buf, count) +.pp +correspond (in order) to the fields +.ir aio_fildes , +.ir aio_buf , +and +.ir aio_nbytes +of the structure pointed to by +.ir aiocbp . +(see +.br aio (7) +for a description of the +.i aiocb +structure.) +.pp +the data is read starting at the absolute position +.ir aiocbp\->aio_offset , +regardless of the file offset. +after the call, +the value of the file offset is unspecified. +.pp +the "asynchronous" means that this call returns as soon as the +request has been enqueued; the read may or may not have completed +when the call returns. +one tests for completion using +.br aio_error (3). +the return status of a completed i/o operation can be obtained by +.br aio_return (3). +asynchronous notification of i/o completion can be obtained by setting +.ir aiocbp\->aio_sigevent +appropriately; see +.br sigevent (7) +for details. +.pp +if +.b _posix_prioritized_io +is defined, and this file supports it, +then the asynchronous operation is submitted at a priority equal +to that of the calling process minus +.ir aiocbp\->aio_reqprio . +.pp +the field +.i aiocbp\->aio_lio_opcode +is ignored. +.pp +no data is read from a regular file beyond its maximum offset. +.sh return value +on success, 0 is returned. +on error, the request is not enqueued, \-1 +is returned, and +.i errno +is set to indicate the error. +if an error is detected only later, it will +be reported via +.br aio_return (3) +(returns status \-1) and +.br aio_error (3) +(error status\(emwhatever one would have gotten in +.ir errno , +such as +.br ebadf ). +.sh errors +.tp +.b eagain +out of resources. +.tp +.b ebadf +.i aio_fildes +is not a valid file descriptor open for reading. +.tp +.b einval +one or more of +.ir aio_offset , +.ir aio_reqprio , +or +.i aio_nbytes +are invalid. +.tp +.b enosys +.br aio_read () +is not implemented. +.tp +.b eoverflow +the file is a regular file, we start reading before end-of-file +and want at least one byte, but the starting position is past +the maximum offset for this file. +.sh versions +the +.br aio_read () +function is available since glibc 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br aio_read () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +it is a good idea to zero out the control block before use. +the control block must not be changed while the read operation +is in progress. +the buffer area being read into +.\" or the control block of the operation +must not be accessed during the operation or undefined results may occur. +the memory areas involved must remain valid. +.pp +simultaneous i/o operations specifying the same +.i aiocb +structure produce undefined results. +.sh examples +see +.br aio (7). +.sh see also +.br aio_cancel (3), +.br aio_error (3), +.br aio_fsync (3), +.br aio_return (3), +.br aio_suspend (3), +.br aio_write (3), +.br lio_listio (3), +.br aio (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1993 rickard e. faith (faith@cs.unc.edu) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th getpid 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +getpid, getppid \- get process identification +.sh synopsis +.nf +.b #include +.pp +.b pid_t getpid(void); +.b pid_t getppid(void); +.fi +.sh description +.br getpid () +returns the process id (pid) of the calling process. +(this is often used by +routines that generate unique temporary filenames.) +.pp +.br getppid () +returns the process id of the parent of the calling process. +this will be either the id of the process that created this process using +.br fork (), +or, if that process has already terminated, +the id of the process to which this process has been reparented (either +.br init (1) +or a "subreaper" process defined via the +.br prctl (2) +.br pr_set_child_subreaper +operation). +.sh errors +these functions are always successful. +.sh conforming to +posix.1-2001, posix.1-2008, 4.3bsd, svr4. +.sh notes +if the caller's parent is in a different pid namespace (see +.br pid_namespaces (7)), +.br getppid () +returns 0. +.pp +from a kernel perspective, +the pid (which is shared by all of the threads in a multithreaded process) +is sometimes also known as the thread group id (tgid). +this contrasts with the kernel thread id (tid), +which is unique for each thread. +for further details, see +.br gettid (2) +and the discussion of the +.br clone_thread +flag in +.br clone (2). +.\" +.ss c library/kernel differences +from glibc version 2.3.4 up to and including version 2.24, +the glibc wrapper function for +.br getpid () +cached pids, +with the goal of avoiding additional system calls when a process calls +.br getpid () +repeatedly. +normally this caching was invisible, +but its correct operation relied on support in the wrapper functions for +.br fork (2), +.br vfork (2), +and +.br clone (2): +if an application bypassed the glibc wrappers for these system calls by using +.br syscall (2), +then a call to +.br getpid () +in the child would return the wrong value +(to be precise: it would return the pid of the parent process). +.\" the following program demonstrates this "feature": +.\" +.\" #define _gnu_source +.\" #include +.\" #include +.\" #include +.\" #include +.\" #include +.\" #include +.\" +.\" int +.\" main(int argc, char *argv[]) +.\" { +.\" /* the following statement fills the getpid() cache */ +.\" +.\" printf("parent pid = %ld\n", (intmax_t) getpid()); +.\" +.\" if (syscall(sys_fork) == 0) { +.\" if (getpid() != syscall(sys_getpid)) +.\" printf("child getpid() mismatch: getpid()=%jd; " +.\" "syscall(sys_getpid)=%ld\n", +.\" (intmax_t) getpid(), (long) syscall(sys_getpid)); +.\" exit(exit_success); +.\" } +.\" wait(null); +.\"} +in addition, there were cases where +.br getpid () +could return the wrong value even when invoking +.br clone (2) +via the glibc wrapper function. +(for a discussion of one such case, see bugs in +.br clone (2).) +furthermore, the complexity of the caching code had been +the source of a few bugs within glibc over the years. +.pp +because of the aforementioned problems, +since glibc version 2.25, the pid cache is removed: +.\" commit c579f48edba88380635ab98cb612030e3ed8691e +.\" https://sourceware.org/glibc/wiki/release/2.25#pid_cache_removal +calls to +.br getpid () +always invoke the actual system call, rather than returning a cached value. +.\" fixme . +.\" review progress of https://bugzilla.redhat.com/show_bug.cgi?id=1469757 +.pp +on alpha, instead of a pair of +.br getpid () +and +.br getppid () +system calls, a single +.br getxpid () +system call is provided, which returns a pair of pid and parent pid. +the glibc +.br getpid () +and +.br getppid () +wrapper functions transparently deal with this. +see +.br syscall (2) +for details regarding register mapping. +.sh see also +.br clone (2), +.br fork (2), +.br gettid (2), +.br kill (2), +.br exec (3), +.br mkstemp (3), +.br tempnam (3), +.br tmpfile (3), +.br tmpnam (3), +.br credentials (7), +.br pid_namespaces (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/access.2 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sat jul 24 17:52:15 1993 by rik faith (faith@cs.unc.edu) +.\" modified 2001-12-15, aeb +.th swab 3 2021-03-22 "" "linux programmer's manual" +.sh name +swab \- swap adjacent bytes +.sh synopsis +.nf +.br "#define _xopen_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "void swab(const void *restrict " from ", void *restrict " to \ +", ssize_t " n ); +.fi +.sh description +the +.br swab () +function copies +.i n +bytes from the array pointed +to by +.i from +to the array pointed to by +.ir to , +exchanging +adjacent even and odd bytes. +this function is used to exchange data +between machines that have different low/high byte ordering. +.pp +this function does nothing when +.i n +is negative. +when +.i n +is positive and odd, it handles +.i n\-1 +bytes +as above, and does something unspecified with the last byte. +(in other words, +.i n +should be even.) +.sh return value +the +.br swab () +function returns no value. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br swab () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, svr4, 4.3bsd. +.sh see also +.br bstring (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th sched_getcpu 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +sched_getcpu \- determine cpu on which the calling thread is running +.sh synopsis +.nf +.b #include +.pp +.b int sched_getcpu(void); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br sched_getcpu (): +.nf + since glibc 2.14: + _gnu_source + before glibc 2.14: + _bsd_source || _svid_source + /* _gnu_source also suffices */ +.fi +.sh description +.br sched_getcpu () +returns the number of the cpu on which the calling thread is currently executing. +.sh return value +on success, +.br sched_getcpu () +returns a nonnegative cpu number. +on error, \-1 is returned and +.i errno +is set to indicate the error. +.sh errors +.tp +.b enosys +this kernel does not implement +.br getcpu (2). +.sh versions +this function is available since glibc 2.6. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br sched_getcpu () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +.br sched_getcpu () +is glibc-specific. +.sh notes +the call +.pp +.in +4n +.ex +cpu = sched_getcpu(); +.ee +.in +.pp +is equivalent to the following +.br getcpu (2) +call: +.pp +.in +4n +.ex +int c, s; +s = getcpu(&c, null, null); +cpu = (s == \-1) ? s : c; +.ee +.in +.sh see also +.br getcpu (2), +.br sched (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/getitimer.2 + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" iso/iec 9899:1999 +.\" +.th wctype 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +wctype \- wide-character classification +.sh synopsis +.nf +.b #include +.pp +.bi "wctype_t wctype(const char *" name ); +.fi +.sh description +the +.i wctype_t +type represents a property which a wide character may or +may not have. +in other words, it represents a class of wide characters. +this type's nature is implementation-dependent, but the special value +.i "(wctype_t) 0" +denotes an invalid property. +nonzero +.i wctype_t +values +can be passed to the +.br iswctype (3) +function +to actually test whether a given +wide character has the property. +.pp +the +.br wctype () +function returns a property, given by its name. +the set of +valid names depends on the +.b lc_ctype +category of the current locale, but the +following names are valid in all locales. +.pp +.nf + "alnum" \- realizes the \fbisalnum\fp(3) classification function + "alpha" \- realizes the \fbisalpha\fp(3) classification function + "blank" \- realizes the \fbisblank\fp(3) classification function + "cntrl" \- realizes the \fbiscntrl\fp(3) classification function + "digit" \- realizes the \fbisdigit\fp(3) classification function + "graph" \- realizes the \fbisgraph\fp(3) classification function + "lower" \- realizes the \fbislower\fp(3) classification function + "print" \- realizes the \fbisprint\fp(3) classification function + "punct" \- realizes the \fbispunct\fp(3) classification function + "space" \- realizes the \fbisspace\fp(3) classification function + "upper" \- realizes the \fbisupper\fp(3) classification function + "xdigit" \- realizes the \fbisxdigit\fp(3) classification function +.fi +.sh return value +the +.br wctype () +function returns a property descriptor +if the +.i name +is valid. +otherwise, it returns +.ir "(wctype_t) 0" . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br wctype () +t} thread safety mt-safe locale +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh notes +the behavior of +.br wctype () +depends on the +.b lc_ctype +category of the +current locale. +.sh see also +.br iswctype (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man7/libc.7 + +.so man3/fseeko.3 + +.\" copyright (c) 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th matherr 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +matherr \- svid math library exception handling +.sh synopsis +.nf +.b #include +.pp +.bi "int matherr(struct exception *" exc ); +.pp +.b extern _lib_version_type _lib_version; +.fi +.pp +link with \fi\-lm\fp. +.sh description +.ir note : +the mechanism described in this page is no longer supported by glibc. +before glibc 2.27, it had been marked as obsolete. +since glibc 2.27, +.\" glibc commit 813378e9fe17e029caf627cab76fe23eb46815fa +the mechanism has been removed altogether. +new applications should use the techniques described in +.br math_error (7) +and +.br fenv (3). +this page documents the +.br matherr () +mechanism as an aid for maintaining and porting older applications. +.pp +the system v interface definition (svid) specifies that various +math functions should invoke a function called +.br matherr () +if a math exception is detected. +this function is called before the math function returns; +after +.br matherr () +returns, the system then returns to the math function, +which in turn returns to the caller. +.pp +to employ +.br matherr (), +the programmer must define the +.b _svid_source +feature test macro +(before including +.i any +header files), +and assign the value +.b _svid_ +to the external variable +.br _lib_version . +.pp +the system provides a default version of +.br matherr (). +this version does nothing, and returns zero +(see below for the significance of this). +the default +.br matherr () +can be overridden by a programmer-defined +version, which will be invoked when an exception occurs. +the function is invoked with one argument, a pointer to an +.i exception +structure, defined as follows: +.pp +.in +4n +.ex +struct exception { + int type; /* exception type */ + char *name; /* name of function causing exception */ + double arg1; /* 1st argument to function */ + double arg2; /* 2nd argument to function */ + double retval; /* function return value */ +} +.ee +.in +.pp +the +.i type +field has one of the following values: +.tp 12 +.b domain +a domain error occurred (the function argument was outside the range +for which the function is defined). +the return value depends on the function; +.i errno +is set to +.br edom . +.tp +.b sing +a pole error occurred (the function result is an infinity). +the return value in most cases is +.b huge +(the largest single precision floating-point number), +appropriately signed. +in most cases, +.i errno +is set to +.br edom . +.tp +.b overflow +an overflow occurred. +in most cases, the value +.b huge +is returned, and +.i errno +is set to +.br erange . +.tp +.b underflow +an underflow occurred. +0.0 is returned, and +.i errno +is set to +.br erange . +.tp +.b tloss +total loss of significance. +0.0 is returned, and +.i errno +is set to +.br erange . +.tp +.b ploss +partial loss of significance. +this value is unused on glibc +(and many other systems). +.pp +the +.i arg1 +and +.i arg2 +fields are the arguments supplied to the function +.ri ( arg2 +is undefined for functions that take only one argument). +.pp +the +.i retval +field specifies the return value that the math +function will return to its caller. +the programmer-defined +.br matherr () +can modify this field to change the return value of the math function. +.pp +if the +.br matherr () +function returns zero, then the system sets +.i errno +as described above, and may print an error message on standard error +(see below). +.pp +if the +.br matherr () +function returns a nonzero value, then the system does not set +.ir errno , +and doesn't print an error message. +.ss math functions that employ matherr() +the table below lists the functions and circumstances in which +.br matherr () +is called. +the "type" column indicates the value assigned to +.i exc\->type +when calling +.br matherr (). +the "result" column is the default return value assigned to +.ir exc\->retval . +.pp +the "msg?" and "errno" columns describe the default behavior if +.br matherr () +returns zero. +if the "msg?" columns contains "y", +then the system prints an error message on standard error. +.pp +the table uses the following notations and abbreviations: +.pp +.rs +.ts +l l. +x first argument to function +y second argument to function +fin finite value for argument +neg negative value for argument +int integral value for argument +o/f result overflowed +u/f result underflowed +|x| absolute value of x +x_tloss is a constant defined in \fi\fp +.te +.re +.\" details below from glibc 2.8's sysdeps/ieee754/k_standard.c +.\" a subset of cases were test by experimental programs. +.ts +lb lb lb cb lb +l l l c l. +function type result msg? errno +acos(|x|>1) domain huge y edom +asin(|x|>1) domain huge y edom +atan2(0,0) domain huge y edom +acosh(x<1) domain nan y edom \" retval is 0.0/0.0 +atanh(|x|>1) domain nan y edom \" retval is 0.0/0.0 +atanh(|x|==1) sing (x>0.0)? y edom \" retval is x/0.0 +\ \ huge_val : +\ \ \-huge_val +cosh(fin) o/f overflow huge n erange +sinh(fin) o/f overflow (x>0.0) ? n erange +\ \ huge : \-huge +sqrt(x<0) domain 0.0 y edom +hypot(fin,fin) o/f overflow huge n erange +exp(fin) o/f overflow huge n erange +exp(fin) u/f underflow 0.0 n erange +exp2(fin) o/f overflow huge n erange +exp2(fin) u/f underflow 0.0 n erange +exp10(fin) o/f overflow huge n erange +exp10(fin) u/f underflow 0.0 n erange +j0(|x|>x_tloss) tloss 0.0 y erange +j1(|x|>x_tloss) tloss 0.0 y erange +jn(|x|>x_tloss) tloss 0.0 y erange +y0(x>x_tloss) tloss 0.0 y erange +y1(x>x_tloss) tloss 0.0 y erange +yn(x>x_tloss) tloss 0.0 y erange +y0(0) domain \-huge y edom +y0(x<0) domain \-huge y edom +y1(0) domain \-huge y edom +y1(x<0) domain \-huge y edom +yn(n,0) domain \-huge y edom +yn(x<0) domain \-huge y edom +lgamma(fin) o/f overflow huge n erange +lgamma(\-int) or sing huge y edom +\ \ lgamma(0) +tgamma(fin) o/f overflow huge_val n erange +tgamma(\-int) sing nan y edom +tgamma(0) sing copysign( y erange +\ \ huge_val,x) +log(0) sing \-huge y edom +log(x<0) domain \-huge y edom +log2(0) sing \-huge n edom \" different from log() +log2(x<0) domain \-huge n edom \" different from log() +log10(0) sing \-huge y edom +log10(x<0) domain \-huge y edom +pow(0.0,0.0) domain 0.0 y edom +pow(x,y) o/f overflow huge n erange +pow(x,y) u/f underflow 0.0 n erange +pow(nan,0.0) domain x n edom +0**neg domain 0.0 y edom \" +0 and -0 +neg**non-int domain 0.0 y edom +scalb() o/f overflow (x>0.0) ? n erange +\ \ huge_val : +\ \ \-huge_val +scalb() u/f underflow copysign( n erange +\ \ \ \ 0.0,x) +fmod(x,0) domain x y edom +remainder(x,0) domain nan y edom \" retval is 0.0/0.0 +.te +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br matherr () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh examples +the example program demonstrates the use of +.br matherr () +when calling +.br log (3). +the program takes up to three command-line arguments. +the first argument is the floating-point number to be given to +.br log (3). +if the optional second argument is provided, then +.b _lib_version +is set to +.b _svid_ +so that +.br matherr () +is called, and the integer supplied in the +command-line argument is used as the return value from +.br matherr (). +if the optional third command-line argument is supplied, +then it specifies an alternative return value that +.br matherr () +should assign as the return value of the math function. +.pp +the following example run, where +.br log (3) +is given an argument of 0.0, does not use +.br matherr (): +.pp +.in +4n +.ex +.rb "$" " ./a.out 0.0" +errno: numerical result out of range +x=\-inf +.ee +.in +.pp +in the following run, +.br matherr () +is called, and returns 0: +.pp +.in +4n +.ex +.rb "$" " ./a.out 0.0 0" +matherr sing exception in log() function + args: 0.000000, 0.000000 + retval: \-340282346638528859811704183484516925440.000000 +log: sing error +errno: numerical argument out of domain +x=\-340282346638528859811704183484516925440.000000 +.ee +.in +.pp +the message "log: sing error" was printed by the c library. +.pp +in the following run, +.br matherr () +is called, and returns a nonzero value: +.pp +.in +4n +.ex +.rb "$" " ./a.out 0.0 1" +matherr sing exception in log() function + args: 0.000000, 0.000000 + retval: \-340282346638528859811704183484516925440.000000 +x=\-340282346638528859811704183484516925440.000000 +.ee +.in +.pp +in this case, the c library did not print a message, and +.i errno +was not set. +.pp +in the following run, +.br matherr () +is called, changes the return value of the math function, +and returns a nonzero value: +.pp +.in +4n +.ex +.rb "$" " ./a.out 0.0 1 12345.0" +matherr sing exception in log() function + args: 0.000000, 0.000000 + retval: \-340282346638528859811704183484516925440.000000 +x=12345.000000 +.ee +.in +.ss program source +\& +.ex +#define _svid_source +#include +#include +#include +#include + +static int matherr_ret = 0; /* value that matherr() + should return */ +static int change_retval = 0; /* should matherr() change + function\(aqs return value? */ +static double new_retval; /* new function return value */ + +int +matherr(struct exception *exc) +{ + fprintf(stderr, "matherr %s exception in %s() function\en", + (exc\->type == domain) ? "domain" : + (exc\->type == overflow) ? "overflow" : + (exc\->type == underflow) ? "underflow" : + (exc\->type == sing) ? "sing" : + (exc\->type == tloss) ? "tloss" : + (exc\->type == ploss) ? "ploss" : "???", + exc\->name); + fprintf(stderr, " args: %f, %f\en", + exc\->arg1, exc\->arg2); + fprintf(stderr, " retval: %f\en", exc\->retval); + + if (change_retval) + exc\->retval = new_retval; + + return matherr_ret; +} + +int +main(int argc, char *argv[]) +{ + double x; + + if (argc < 2) { + fprintf(stderr, "usage: %s " + " [ []]\en", argv[0]); + exit(exit_failure); + } + + if (argc > 2) { + _lib_version = _svid_; + matherr_ret = atoi(argv[2]); + } + + if (argc > 3) { + change_retval = 1; + new_retval = atof(argv[3]); + } + + x = log(atof(argv[1])); + if (errno != 0) + perror("errno"); + + printf("x=%f\en", x); + exit(exit_success); +} +.ee +.sh see also +.br fenv (3), +.br math_error (7), +.br standards (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" iso/iec 9899:1999 +.\" +.th fputws 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +fputws \- write a wide-character string to a file stream +.sh synopsis +.nf +.b #include +.pp +.bi "int fputws(const wchar_t *restrict " ws ", file *restrict " stream ); +.fi +.sh description +the +.br fputws () +function is the wide-character equivalent of +the +.br fputs (3) +function. +it writes the wide-character string starting at \fiws\fp, up to but +not including the terminating null wide character (l\(aq\e0\(aq), to \fistream\fp. +.pp +for a nonlocking counterpart, see +.br unlocked_stdio (3). +.sh return value +the +.br fputws () +function returns a +nonnegative integer if the operation was +successful, or \-1 to indicate an error. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br fputws () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh notes +the behavior of +.br fputws () +depends on the +.b lc_ctype +category of the +current locale. +.pp +in the absence of additional information passed to the +.br fopen (3) +call, it is +reasonable to expect that +.br fputws () +will actually write the multibyte +string corresponding to the wide-character string \fiws\fp. +.sh see also +.br fputwc (3), +.br unlocked_stdio (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/get_robust_list.2 + +.so man3/atanh.3 + +.so man3/if_nametoindex.3 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" and copyright 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified 1993-07-24 by rik faith (faith@cs.unc.edu) +.\" modified 2002-07-27 by walter harms +.\" (walter.harms@informatik.uni-oldenburg.de) +.th cos 3 2021-03-22 "" "linux programmer's manual" +.sh name +cos, cosf, cosl \- cosine function +.sh synopsis +.nf +.b #include +.pp +.bi "double cos(double " x ); +.bi "float cosf(float " x ); +.bi "long double cosl(long double " x ); +.fi +.pp +link with \fi\-lm\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br cosf (), +.br cosl (): +.nf + _isoc99_source || _posix_c_source >= 200112l + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.sh description +these functions return the cosine of +.ir x , +where +.i x +is +given in radians. +.sh return value +on success, these functions return the cosine of +.ir x . +.pp +if +.i x +is a nan, a nan is returned. +.pp +if +.i x +is positive infinity or negative infinity, +a domain error occurs, +and a nan is returned. +.sh errors +see +.br math_error (7) +for information on how to determine whether an error has occurred +when calling these functions. +.pp +the following errors can occur: +.tp +domain error: \fix\fp is an infinity +.i errno +is set to +.br edom +(but see bugs). +an invalid floating-point exception +.rb ( fe_invalid ) +is raised. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br cos (), +.br cosf (), +.br cosl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.pp +the variant returning +.i double +also conforms to +svr4, 4.3bsd. +.sh bugs +before version 2.10, the glibc implementation did not set +.\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=6780 +.i errno +to +.b edom +when a domain error occurred. +.sh see also +.br acos (3), +.br asin (3), +.br atan (3), +.br atan2 (3), +.br ccos (3), +.br sin (3), +.br sincos (3), +.br tan (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/abs.3 + +.so man3/xdr.3 + +.so man3/rpc.3 + +.so man3/cbrt.3 + +.\" copyright (c) 2014 marko myllynen +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th iconvconfig 8 2021-08-27 "gnu" "linux system administration" +.sh name +iconvconfig \- create iconv module configuration cache +.sh synopsis +.b iconvconfig +.ri [ options ] +.ri [ directory ]... +.sh description +the +.br iconv (3) +function internally uses +.i gconv +modules to convert to and from a character set. +a configuration file is used to determine the needed modules +for a conversion. +loading and parsing such a configuration file would slow down +programs that use +.br iconv (3), +so a caching mechanism is employed. +.pp +the +.b iconvconfig +program reads iconv module configuration files and writes +a fast-loading gconv module configuration cache file. +.pp +in addition to the system provided gconv modules, the user can specify +custom gconv module directories with the environment variable +.br gconv_path . +however, iconv module configuration caching is used only when +the environment variable +.br gconv_path +is not set. +.sh options +.tp +.b "\-\-nostdlib" +do not search the system default gconv directory, +only the directories provided on the command line. +.tp +.bi \-o " outputfile" ", \-\-output=" outputfile +use +.i outputfile +for output instead of the system default cache location. +.tp +.bi \-\-prefix= pathname +set the prefix to be prepended to the system pathnames. +see files, below. +by default, the prefix is empty. +setting the prefix to +.ir foo , +the gconv module configuration would be read from +.ir foo/usr/lib/gconv/gconv\-modules +and the cache would be written to +.ir foo/usr/lib/gconv/gconv\-modules.cache . +.tp +.br \-? ", " \-\-help +print a usage summary and exit. +.tp +.b "\-\-usage" +print a short usage summary and exit. +.tp +.br \-v ", " \-\-version +print the version number, license, and disclaimer of warranty for +.br iconv . +.sh exit status +zero on success, nonzero on errors. +.sh files +.tp +.i /usr/lib/gconv +usual default gconv module path. +.tp +.i /usr/lib/gconv/gconv\-modules +usual system default gconv module configuration file. +.tp +.i /usr/lib/gconv/gconv\-modules.cache +usual system gconv module configuration cache. +.pp +depending on the architecture, +the above files may instead be located at directories with the path prefix +.ir /usr/lib64 . +.sh see also +.br iconv (1), +.br iconv (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/stat.2 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" +.\" modified sat jul 24 19:22:14 1993 by rik faith (faith@cs.unc.edu) +.\" modified mon may 27 21:37:47 1996 by martin schulze (joey@linux.de) +.\" +.th getpwent 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +getpwent, setpwent, endpwent \- get password file entry +.sh synopsis +.nf +.b #include +.b #include +.pp +.b struct passwd *getpwent(void); +.b void setpwent(void); +.b void endpwent(void); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br getpwent (), +.br setpwent (), +.br endpwent (): +.nf + _xopen_source >= 500 +.\" || _xopen_source && _xopen_source_extended + || /* glibc since 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.sh description +the +.br getpwent () +function returns a pointer to a structure containing +the broken-out fields of a record from the password database +(e.g., the local password file +.ir /etc/passwd , +nis, and ldap). +the first time +.br getpwent () +is called, it returns the first entry; thereafter, it returns successive +entries. +.pp +the +.br setpwent () +function rewinds to the beginning +of the password database. +.pp +the +.br endpwent () +function is used to close the password database +after all processing has been performed. +.pp +the \fipasswd\fp structure is defined in \fi\fp as follows: +.pp +.in +4n +.ex +struct passwd { + char *pw_name; /* username */ + char *pw_passwd; /* user password */ + uid_t pw_uid; /* user id */ + gid_t pw_gid; /* group id */ + char *pw_gecos; /* user information */ + char *pw_dir; /* home directory */ + char *pw_shell; /* shell program */ +}; +.ee +.in +.pp +for more information about the fields of this structure, see +.br passwd (5). +.sh return value +the +.br getpwent () +function returns a pointer to a +.i passwd +structure, or null if +there are no more entries or an error occurred. +if an error occurs, +.i errno +is set to indicate the error. +if one wants to check +.i errno +after the call, it should be set to zero before the call. +.pp +the return value may point to a static area, and may be overwritten +by subsequent calls to +.br getpwent (), +.br getpwnam (3), +or +.br getpwuid (3). +(do not pass the returned pointer to +.br free (3).) +.sh errors +.tp +.b eintr +a signal was caught; see +.br signal (7). +.tp +.b eio +i/o error. +.tp +.b emfile +the per-process limit on the number of open file descriptors has been reached. +.tp +.b enfile +the system-wide limit on the total number of open files has been reached. +.tp +.b enomem +.\" not in posix +insufficient memory to allocate +.i passwd +structure. +.\" to allocate the passwd structure, or to allocate buffers +.tp +.b erange +insufficient buffer space supplied. +.sh files +.tp +.i /etc/passwd +local password database file +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lb lb lbx +l l l. +interface attribute value +t{ +.br getpwent () +t} thread safety t{ +mt-unsafe race:pwent +race:pwentbuf locale +t} +t{ +.br setpwent (), +.br endpwent () +t} thread safety t{ +mt-unsafe race:pwent locale +t} +.te +.hy +.ad +.sp 1 +in the above table, +.i pwent +in +.i race:pwent +signifies that if any of the functions +.br setpwent (), +.br getpwent (), +or +.br endpwent () +are used in parallel in different threads of a program, +then data races could occur. +.sh conforming to +posix.1-2001, posix.1-2008, svr4, 4.3bsd. +the +.i pw_gecos +field is not specified in posix, but is present on most implementations. +.sh see also +.br fgetpwent (3), +.br getpw (3), +.br getpwent_r (3), +.br getpwnam (3), +.br getpwuid (3), +.br putpwent (3), +.br passwd (5) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man7/system_data_types.7 + +.\" copyright (c) 1995 michael chastain (mec@shell.portal.com), 15 april 1995. +.\" and copyright (c) 2014, 2016 michael kerrisk +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" modified 1997-01-31 by eric s. raymond +.\" modified 1997-07-30 by paul slootman +.\" modified 2004-05-27 by michael kerrisk +.\" +.th adjtimex 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +adjtimex, clock_adjtime, ntp_adjtime \- tune kernel clock +.sh synopsis +.nf +.b #include +.pp +.bi "int adjtimex(struct timex *" "buf" ); +.pp +.bi "int clock_adjtime(clockid_t " clk_id, " struct timex *" "buf" ); +.pp +.bi "int ntp_adjtime(struct timex *" buf ); +.fi +.sh description +linux uses david l.\& mills' clock adjustment algorithm (see rfc\ 5905). +the system call +.br adjtimex () +reads and optionally sets adjustment parameters for this algorithm. +it takes a pointer to a +.i timex +structure, updates kernel parameters from (selected) field values, +and returns the same structure updated with the current kernel values. +this structure is declared as follows: +.pp +.in +4n +.ex +struct timex { + int modes; /* mode selector */ + long offset; /* time offset; nanoseconds, if sta_nano + status flag is set, otherwise + microseconds */ + long freq; /* frequency offset; see notes for units */ + long maxerror; /* maximum error (microseconds) */ + long esterror; /* estimated error (microseconds) */ + int status; /* clock command/status */ + long constant; /* pll (phase\-locked loop) time constant */ + long precision; /* clock precision + (microseconds, read\-only) */ + long tolerance; /* clock frequency tolerance (read\-only); + see notes for units */ + struct timeval time; + /* current time (read\-only, except for + adj_setoffset); upon return, time.tv_usec + contains nanoseconds, if sta_nano status + flag is set, otherwise microseconds */ + long tick; /* microseconds between clock ticks */ + long ppsfreq; /* pps (pulse per second) frequency + (read\-only); see notes for units */ + long jitter; /* pps jitter (read\-only); nanoseconds, if + sta_nano status flag is set, otherwise + microseconds */ + int shift; /* pps interval duration + (seconds, read\-only) */ + long stabil; /* pps stability (read\-only); + see notes for units */ + long jitcnt; /* pps count of jitter limit exceeded + events (read\-only) */ + long calcnt; /* pps count of calibration intervals + (read\-only) */ + long errcnt; /* pps count of calibration errors + (read\-only) */ + long stbcnt; /* pps count of stability limit exceeded + events (read\-only) */ + int tai; /* tai offset, as set by previous adj_tai + operation (seconds, read\-only, + since linux 2.6.26) */ + /* further padding bytes to allow for future expansion */ +}; +.ee +.in +.pp +the +.i modes +field determines which parameters, if any, to set. +(as described later in this page, +the constants used for +.br ntp_adjtime () +are equivalent but differently named.) +it is a bit mask containing a +.ri bitwise- or +combination of zero or more of the following bits: +.tp +.br adj_offset +set time offset from +.ir buf.offset . +since linux 2.6.26, +.\" commit 074b3b87941c99bc0ce35385b5817924b1ed0c23 +the supplied value is clamped to the range (\-0.5s, +0.5s). +in older kernels, an +.b einval +error occurs if the supplied value is out of range. +.tp +.br adj_frequency +set frequency offset from +.ir buf.freq . +since linux 2.6.26, +.\" commit 074b3b87941c99bc0ce35385b5817924b1ed0c23 +the supplied value is clamped to the range (\-32768000, +32768000). +in older kernels, an +.b einval +error occurs if the supplied value is out of range. +.tp +.br adj_maxerror +set maximum time error from +.ir buf.maxerror . +.tp +.br adj_esterror +set estimated time error from +.ir buf.esterror . +.tp +.br adj_status +set clock status bits from +.ir buf.status . +a description of these bits is provided below. +.tp +.br adj_timeconst +set pll time constant from +.ir buf.constant . +if the +.b sta_nano +status flag (see below) is clear, the kernel adds 4 to this value. +.tp +.br adj_setoffset " (since linux 2.6.39)" +.\" commit 094aa1881fdc1b8889b442eb3511b31f3ec2b762 +.\" author: richard cochran +add +.i buf.time +to the current time. +if +.i buf.status +includes the +.b adj_nano +flag, then +.i buf.time.tv_usec +is interpreted as a nanosecond value; +otherwise it is interpreted as microseconds. +.ip +the value of +.i buf.time +is the sum of its two fields, but the +field +.i buf.time.tv_usec +must always be nonnegative. +the following example shows how to +normalize a +.i timeval +with nanosecond resolution. +.ip +.in +4n +.ex +while (buf.time.tv_usec < 0) { + buf.time.tv_sec \-= 1; + buf.time.tv_usec += 1000000000; +} +.ee +.in +.tp +.br adj_micro " (since linux 2.6.26)" +.\" commit eea83d896e318bda54be2d2770d2c5d6668d11db +.\" author: roman zippel +select microsecond resolution. +.tp +.br adj_nano " (since linux 2.6.26)" +.\" commit eea83d896e318bda54be2d2770d2c5d6668d11db +.\" author: roman zippel +select nanosecond resolution. +only one of +.br adj_micro +and +.br adj_nano +should be specified. +.tp +.br adj_tai " (since linux 2.6.26)" +.\" commit 153b5d054ac2d98ea0d86504884326b6777f683d +set tai (atomic international time) offset from +.ir buf.constant . +.ip +.br adj_tai +should not be used in conjunction with +.br adj_timeconst , +since the latter mode also employs the +.ir buf.constant +field. +.ip +for a complete explanation of tai +and the difference between tai and utc, see +.ur http://www.bipm.org/en/bipm/tai/tai.html +.i bipm +.ue +.tp +.br adj_tick +set tick value from +.ir buf.tick . +.pp +alternatively, +.i modes +can be specified as either of the following (multibit mask) values, +in which case other bits should not be specified in +.ir modes : +.\" in general, the other bits are ignored, but adj_offset_singleshot 0x8001 +.\" ored with adj_nano (0x2000) gives 0xa0001 == adj_offset_ss_read!! +.tp +.br adj_offset_singleshot +.\" in user space, adj_offset_singleshot is 0x8001 +.\" in kernel space it is 0x0001, and must be anded with adj_adjtime (0x8000) +old-fashioned +.br adjtime (3): +(gradually) adjust time by value specified in +.ir buf.offset , +which specifies an adjustment in microseconds. +.tp +.br adj_offset_ss_read " (functional since linux 2.6.28)" +.\" in user space, adj_offset_ss_read is 0xa001 +.\" in kernel space there is adj_offset_readonly (0x2000) anded with +.\" adj_adjtime (0x8000) and adj_offset_singleshot (0x0001) to give 0xa001) +return (in +.ir buf.offset ) +the remaining amount of time to be adjusted after an earlier +.br adj_offset_singleshot +operation. +this feature was added in linux 2.6.24, +.\" commit 52bfb36050c8529d9031d2c2513b281a360922ec +but did not work correctly +.\" commit 916c7a855174e3b53d182b97a26b2e27a29726a1 +until linux 2.6.28. +.pp +ordinary users are restricted to a value of either 0 or +.b adj_offset_ss_read +for +.ir modes . +only the superuser may set any parameters. +.pp +the +.i buf.status +field is a bit mask that is used to set and/or retrieve status +bits associated with the ntp implementation. +some bits in the mask are both readable and settable, +while others are read-only. +.tp +.br sta_pll " (read-write)" +enable phase-locked loop (pll) updates via +.br adj_offset . +.tp +.br sta_ppsfreq " (read-write)" +enable pps (pulse-per-second) frequency discipline. +.tp +.br sta_ppstime " (read-write)" +enable pps time discipline. +.tp +.br sta_fll " (read-write)" +select frequency-locked loop (fll) mode. +.tp +.br sta_ins " (read-write)" +insert a leap second after the last second of the utc day, +thus extending the last minute of the day by one second. +leap-second insertion will occur each day, so long as this flag remains set. +.\" john stultz; +.\" usually this is written as extending the day by one second, +.\" which is represented as: +.\" 23:59:59 +.\" 23:59:60 +.\" 00:00:00 +.\" +.\" but since posix cannot represent 23:59:60, we repeat the last second: +.\" 23:59:59 + time_ins +.\" 23:59:59 + time_oop +.\" 00:00:00 + time_wait +.\" +.tp +.br sta_del " (read-write)" +delete a leap second at the last second of the utc day. +.\" john stultz: +.\" similarly the progression here is: +.\" 23:59:57 + time_del +.\" 23:59:58 + time_del +.\" 00:00:00 + time_wait +leap second deletion will occur each day, so long as this flag +remains set. +.\" fixme does there need to be a statement that it is nonsensical to set +.\" to set both sta_ins and sta_del? +.tp +.br sta_unsync " (read-write)" +clock unsynchronized. +.tp +.br sta_freqhold " (read-write)" +hold frequency. +.\" following text from john stultz: +normally adjustments made via +.b adj_offset +result in dampened frequency adjustments also being made. +so a single call corrects the current offset, +but as offsets in the same direction are made repeatedly, +the small frequency adjustments will accumulate to fix the long-term skew. +.ip +this flag prevents the small frequency adjustment from being made +when correcting for an +.b adj_offset +value. +.\" according to the kernel application program interface document, +.\" sta_freqhold is not used by the ntp version 4 daemon +.tp +.br sta_ppssignal " (read-only)" +a valid pps (pulse-per-second) signal is present. +.tp +.br sta_ppsjitter " (read-only)" +pps signal jitter exceeded. +.tp +.br sta_ppswander " (read-only)" +pps signal wander exceeded. +.tp +.br sta_ppserror " (read-only)" +pps signal calibration error. +.tp +.br sta_clockerr " (read-only)" +clock hardware fault. +.\" not set in current kernel (4.5), but checked in a few places +.tp +.br sta_nano " (read-only; since linux 2.6.26)" +.\" commit eea83d896e318bda54be2d2770d2c5d6668d11db +.\" author: roman zippel +resolution (0 = microsecond, 1 = nanoseconds). +set via +.br adj_nano , +cleared via +.br adj_micro . +.tp +.br sta_mode " (since linux 2.6.26)" +.\" commit eea83d896e318bda54be2d2770d2c5d6668d11db +.\" author: roman zippel +mode (0 = phase locked loop, 1 = frequency locked loop). +.tp +.br sta_clk " (read-only; since linux 2.6.26)" +.\" commit eea83d896e318bda54be2d2770d2c5d6668d11db +.\" author: roman zippel +clock source (0 = a, 1 = b); currently unused. +.pp +attempts to set read-only +.i status +bits are silently ignored. +.\" +.ss clock_adjtime () +the +.br clock_adjtime () +system call (added in linux 2.6.39) behaves like +.br adjtimex () +but takes an additional +.ir clk_id +argument to specify the particular clock on which to act. +.ss ntp_adjtime () +the +.br ntp_adjtime () +library function +(described in the ntp "kernel application program api", kapi) +is a more portable interface for performing the same task as +.br adjtimex (). +other than the following points, it is identical to +.br adjtimex (): +.ip * 3 +the constants used in +.i modes +are prefixed with "mod_" rather than "adj_", and have the same suffixes (thus, +.br mod_offset , +.br mod_frequency , +and so on), other than the exceptions noted in the following points. +.ip * +.br mod_clka +is the synonym for +.br adj_offset_singleshot . +.ip * +.br mod_clkb +is the synonym for +.br adj_tick . +.ip * +the is no synonym for +.br adj_offset_ss_read , +which is not described in the kapi. +.sh return value +on success, +.br adjtimex () +and +.br ntp_adjtime () +return the clock state; that is, one of the following values: +.tp 12 +.br time_ok +clock synchronized, no leap second adjustment pending. +.tp +.br time_ins +indicates that a leap second will be added at the end of the utc day. +.tp +.br time_del +indicates that a leap second will be deleted at the end of the utc day. +.tp +.br time_oop +insertion of a leap second is in progress. +.tp +.br time_wait +a leap-second insertion or deletion has been completed. +this value will be returned until the next +.br adj_status +operation clears the +.b sta_ins +and +.b sta_del +flags. +.tp +.br time_error +the system clock is not synchronized to a reliable server. +this value is returned when any of the following holds true: +.rs +.ip * 3 +either +.b sta_unsync +or +.b sta_clockerr +is set. +.ip * +.b sta_ppssignal +is clear and either +.b sta_ppsfreq +or +.b sta_ppstime +is set. +.ip * +.b sta_ppstime +and +.b sta_ppsjitter +are both set. +.ip * +.b sta_ppsfreq +is set and either +.b sta_ppswander +or +.b sta_ppsjitter +is set. +.re +.ip +the symbolic name +.b time_bad +is a synonym for +.br time_error , +provided for backward compatibility. +.pp +note that starting with linux 3.4, +.\" commit 6b43ae8a619d17c4935c3320d2ef9e92bdeed05d changed to asynchronous +.\" operation, so we can no longer rely on the return code. +the call operates asynchronously and the return value usually will +not reflect a state change caused by the call itself. +.pp +on failure, these calls return \-1 and set +.ir errno +to indicate the error. +.sh errors +.tp +.b efault +.i buf +does not point to writable memory. +.tp +.br einval " (kernels before linux 2.6.26)" +an attempt was made to set +.i buf.freq +to a value outside the range (\-33554432, +33554432). +.\" from a quick glance, it appears there was no clamping or range check +.\" for buf.freq in kernels before 2.0 +.tp +.br einval " (kernels before linux 2.6.26)" +an attempt was made to set +.i buf.offset +to a value outside the permitted range. +in kernels before linux 2.0, the permitted range was (\-131072, +131072). +from linux 2.0 onwards, the permitted range was (\-512000, +512000). +.tp +.b einval +an attempt was made to set +.i buf.status +to a value other than those listed above. +.tp +.b einval +the +.i clk_id +given to +.br clock_adjtime () +is invalid for one of two reasons. +either the system-v style hard-coded +positive clock id value is out of range, or the dynamic +.i clk_id +does not refer to a valid instance of a clock object. +see +.br clock_gettime (2) +for a discussion of dynamic clocks. +.tp +.b einval +an attempt was made to set +.i buf.tick +to a value outside the range +.rb 900000/ hz +to +.rb 1100000/ hz , +where +.b hz +is the system timer interrupt frequency. +.tp +.b enodev +the hot-pluggable device (like usb for example) represented by a +dynamic +.i clk_id +has disappeared after its character device was opened. +see +.br clock_gettime (2) +for a discussion of dynamic clocks. +.tp +.b eopnotsupp +the given +.i clk_id +does not support adjustment. +.tp +.b eperm +.i buf.modes +is neither 0 nor +.br adj_offset_ss_read , +and the caller does not have sufficient privilege. +under linux, the +.b cap_sys_time +capability is required. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br ntp_adjtime () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +none of these interfaces is described in posix.1 +.pp +.br adjtimex () +and +.br clock_adjtime () +are linux-specific and should not be used in programs +intended to be portable. +.pp +the preferred api for the ntp daemon is +.br ntp_adjtime (). +.sh notes +in struct +.ir timex , +.ir freq , +.ir ppsfreq , +and +.i stabil +are ppm (parts per million) with a 16-bit fractional part, +which means that a value of 1 in one of those fields +actually means 2^-16 ppm, and 2^16=65536 is 1 ppm. +this is the case for both input values (in the case of +.ir freq ) +and output values. +.pp +the leap-second processing triggered by +.b sta_ins +and +.b sta_del +is done by the kernel in timer context. +thus, it will take one tick into the second +for the leap second to be inserted or deleted. +.sh see also +.br clock_gettime (2), +.br clock_settime (2), +.br settimeofday (2), +.br adjtime (3), +.br ntp_gettime (3), +.br capabilities (7), +.br time (7), +.br adjtimex (8), +.br hwclock (8) +.pp +.ad l +.ur http://www.slac.stanford.edu/comp/unix/\:package/\:rtems/\:src/\:ssrlapps/\:ntpnanoclock/\:api.htm +ntp "kernel application program interface" +.ue +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/rcmd.3 + +.so man2/fstatat.2 + +.so man3/slist.3 + +.\" copyright (c) 2012 by michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th malloc_get_state 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +malloc_get_state, malloc_set_state \- record and restore state of malloc implementation +.sh synopsis +.nf +.b #include +.pp +.bi "void *malloc_get_state(void);" +.bi "int malloc_set_state(void *" state ); +.fi +.sh description +.ir note : +these function are removed in glibc version 2.25. +.pp +the +.br malloc_get_state () +function records the current state of all +.br malloc (3) +internal bookkeeping variables +(but not the actual contents of the heap +or the state of +.br malloc_hook (3) +functions pointers). +the state is recorded in a system-dependent opaque data structure +dynamically allocated via +.br malloc (3), +and a pointer to that data structure is returned as the function result. +(it is the caller's responsibility to +.br free (3) +this memory.) +.pp +the +.br malloc_set_state () +function restores the state of all +.br malloc (3) +internal bookkeeping variables to the values recorded in +the opaque data structure pointed to by +.ir state . +.sh return value +on success, +.br malloc_get_state () +returns a pointer to a newly allocated opaque data structure. +on error (for example, memory could not be allocated for the data structure), +.br malloc_get_state () +returns null. +.pp +on success, +.br malloc_set_state () +returns 0. +if the implementation detects that +.i state +does not point to a correctly formed data structure, +.\" if(ms->magic != malloc_state_magic) return -1; +.br malloc_set_state () +returns \-1. +if the implementation detects that +the version of the data structure referred to by +.i state +is a more recent version than this implementation knows about, +.\" /* must fail if the major version is too high. */ +.\" if((ms->version & ~0xffl) > (malloc_state_version & ~0xffl)) return -2; +.br malloc_set_state () +returns \-2. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br malloc_get_state (), +.br malloc_set_state () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +these functions are gnu extensions. +.sh notes +these functions are useful when using this +.br malloc (3) +implementation as part of a shared library, +and the heap contents are saved/restored via some other method. +this technique is used by gnu emacs to implement its "dumping" function. +.pp +hook function pointers are never saved or restored by these +functions, with two exceptions: +if malloc checking (see +.br mallopt (3)) +was in use when +.br malloc_get_state () +was called, then +.br malloc_set_state () +resets malloc checking hooks +.\" i.e., calls __malloc_check_init() +if possible; +.\" i.e., malloc checking is not already in use +.\" and the caller requested malloc checking +if malloc checking was not in use in the recorded state, +but the caller has requested malloc checking, +then the hooks are reset to 0. +.sh see also +.br malloc (3), +.br mallopt (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" iso/iec 9899:1999 +.\" +.th iswlower 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +iswlower \- test for lowercase wide character +.sh synopsis +.nf +.b #include +.pp +.bi "int iswlower(wint_t " wc ); +.fi +.sh description +the +.br iswlower () +function is the wide-character equivalent of the +.br islower (3) +function. +it tests whether +.i wc +is a wide character +belonging to the wide-character class "lower". +.pp +the wide-character class "lower" is a subclass of the wide-character class +"alpha", and therefore also a subclass +of the wide-character class "alnum", of +the wide-character class "graph" and of the wide-character class "print". +.pp +being a subclass of the wide-character class "print", +the wide-character class +"lower" is disjoint from the wide-character class "cntrl". +.pp +being a subclass of the wide-character class "graph", +the wide-character class "lower" is disjoint from the +wide-character class "space" and its subclass "blank". +.pp +being a subclass of the wide-character class "alnum", +the wide-character class +"lower" is disjoint from the wide-character class "punct". +.pp +being a subclass of the wide-character class "alpha", +the wide-character class +"lower" is disjoint from the wide-character class "digit". +.pp +the wide-character class "lower" contains at least +those characters +.i wc +which are equal to +.i towlower(wc) +and different from +.ir towupper(wc) . +.pp +the wide-character class "lower" always contains +at least the letters \(aqa\(aq to \(aqz\(aq. +.sh return value +the +.br iswlower () +function returns nonzero +if +.i wc +is a wide character +belonging to the wide-character class "lower". +otherwise, it returns zero. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br iswlower () +t} thread safety mt-safe locale +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh notes +the behavior of +.br iswlower () +depends on the +.b lc_ctype +category of the +current locale. +.pp +this function is not very appropriate for dealing with unicode characters, +because unicode knows about three cases: upper, lower, and title case. +.sh see also +.br islower (3), +.br iswctype (3), +.br towlower (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" this manpage is copyright (c) 1992 drew eckhardt; +.\" and copyright (c) 1993 michael haardt, ian jackson. +.\" and copyright (c) 2004, 2006, 2007, 2014 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified 1993-07-21 rik faith (faith@cs.unc.edu) +.\" modified 1994-08-21 by michael chastain (mec@shell.portal.com): +.\" removed note about old kernel (pre-1.1.44) using wrong id on path. +.\" modified 1996-03-18 by martin schulze (joey@infodrom.north.de): +.\" stated more clearly how it behaves with symbolic links. +.\" added correction due to nick duffek (nsd@bbc.com), aeb, 960426 +.\" modified 1996-09-07 by michael haardt: +.\" restrictions for nfs +.\" modified 1997-09-09 by joseph s. myers +.\" modified 1998-01-13 by michael haardt: +.\" using access is often insecure +.\" modified 2001-10-16 by aeb +.\" modified 2002-04-23 by roger luethi +.\" modified 2004-06-23 by michael kerrisk +.\" 2007-06-10, mtk, various parts rewritten, and added bugs section. +.\" +.th access 2 2021-08-27 "linux" "linux programmer's manual" +.sh name +access, faccessat, faccessat2 \- check user's permissions for a file +.sh synopsis +.nf +.b #include +.pp +.bi "int access(const char *" pathname ", int " mode ); +.pp +.br "#include " " /* definition of " at_* " constants */" +.b #include +.pp +.bi "int faccessat(int " dirfd ", const char *" pathname ", int " \ +mode ", int " flags ); + /* but see c library/kernel differences, below */ +.pp +.br "#include " " /* definition of " at_* " constants */" +.br "#include " " /* definition of " sys_* " constants */" +.b #include +.pp +.bi "int syscall(sys_faccessat2," +.bi " int " dirfd ", const char *" pathname ", int " mode \ +", int " flags ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br faccessat (): +.nf + since glibc 2.10: + _posix_c_source >= 200809l + before glibc 2.10: + _atfile_source +.fi +.sh description +.br access () +checks whether the calling process can access the file +.ir pathname . +if +.i pathname +is a symbolic link, it is dereferenced. +.pp +the +.i mode +specifies the accessibility check(s) to be performed, +and is either the value +.br f_ok , +.\" f_ok is defined as 0 on every system that i know of. +or a mask consisting of the bitwise or of one or more of +.br r_ok ", " w_ok ", and " x_ok . +.b f_ok +tests for the existence of the file. +.br r_ok ", " w_ok ", and " x_ok +test whether the file exists and grants read, write, and +execute permissions, respectively. +.pp +the check is done using the calling process's +.i real +uid and gid, rather than the effective ids as is done when +actually attempting an operation (e.g., +.br open (2)) +on the file. +similarly, for the root user, the check uses the set of +permitted capabilities rather than the set of effective +capabilities; and for non-root users, the check uses an empty set +of capabilities. +.pp +this allows set-user-id programs and capability-endowed programs +to easily determine the invoking user's authority. +in other words, +.br access () +does not answer the "can i read/write/execute this file?" question. +it answers a slightly different question: +"(assuming i'm a setuid binary) can +.i the user who invoked me +read/write/execute this file?", +which gives set-user-id programs the possibility to +prevent malicious users from causing them to read files +which users shouldn't be able to read. +.pp +if the calling process is privileged (i.e., its real uid is zero), +then an +.b x_ok +check is successful for a regular file if execute permission +is enabled for any of the file owner, group, or other. +.ss faccessat() +.br faccessat () +operates in exactly the same way as +.br access (), +except for the differences described here. +.pp +if the pathname given in +.i pathname +is relative, then it is interpreted relative to the directory +referred to by the file descriptor +.i dirfd +(rather than relative to the current working directory of +the calling process, as is done by +.br access () +for a relative pathname). +.pp +if +.i pathname +is relative and +.i dirfd +is the special value +.br at_fdcwd , +then +.i pathname +is interpreted relative to the current working +directory of the calling process (like +.br access ()). +.pp +if +.i pathname +is absolute, then +.i dirfd +is ignored. +.pp +.i flags +is constructed by oring together zero or more of the following values: +.tp +.b at_eaccess +perform access checks using the effective user and group ids. +by default, +.br faccessat () +uses the real ids (like +.br access ()). +.tp +.b at_symlink_nofollow +if +.i pathname +is a symbolic link, do not dereference it: +instead return information about the link itself. +.pp +see +.br openat (2) +for an explanation of the need for +.br faccessat (). +.\" +.ss faccessat2() +the description of +.br faccessat () +given above corresponds to posix.1 and +to the implementation provided by glibc. +however, the glibc implementation was an imperfect emulation (see bugs) +that papered over the fact that the raw linux +.br faccessat () +system call does not have a +.i flags +argument. +to allow for a proper implementation, linux 5.8 added the +.br faccessat2 () +system call, which supports the +.i flags +argument and allows a correct implementation of the +.br faccessat () +wrapper function. +.sh return value +on success (all requested permissions granted, or +.i mode +is +.b f_ok +and the file exists), zero is returned. +on error (at least one bit in +.i mode +asked for a permission that is denied, or +.i mode +is +.b f_ok +and the file does not exist, or some other error occurred), +\-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eacces +the requested access would be denied to the file, or search permission +is denied for one of the directories in the path prefix of +.ir pathname . +(see also +.br path_resolution (7).) +.tp +.b ebadf +.rb ( faccessat ()) +.i pathname +is relative but +.i dirfd +is neither +.b at_fdcwd +.rb ( faccessat ()) +nor a valid file descriptor. +.tp +.b efault +.i pathname +points outside your accessible address space. +.tp +.b einval +.i mode +was incorrectly specified. +.tp +.b einval +.rb ( faccessat ()) +invalid flag specified in +.ir flags . +.tp +.b eio +an i/o error occurred. +.tp +.b eloop +too many symbolic links were encountered in resolving +.ir pathname . +.tp +.b enametoolong +.i pathname +is too long. +.tp +.b enoent +a component of +.i pathname +does not exist or is a dangling symbolic link. +.tp +.b enomem +insufficient kernel memory was available. +.tp +.b enotdir +a component used as a directory in +.i pathname +is not, in fact, a directory. +.tp +.b enotdir +.rb ( faccessat ()) +.i pathname +is relative and +.i dirfd +is a file descriptor referring to a file other than a directory. +.tp +.b erofs +write permission was requested for a file on a read-only filesystem. +.tp +.b etxtbsy +write access was requested to an executable which is being +executed. +.sh versions +.br faccessat () +was added to linux in kernel 2.6.16; +library support was added to glibc in version 2.4. +.pp +.br faccessat2 () +was added to linux in version 5.8. +.sh conforming to +.br access (): +svr4, 4.3bsd, posix.1-2001, posix.1-2008. +.pp +.br faccessat (): +posix.1-2008. +.pp +.br faccessat2 (): +linux-specific. +.sh notes +.br warning : +using these calls to check if a user is authorized to, for example, +open a file before actually doing so using +.br open (2) +creates a security hole, because the user might exploit the short time +interval between checking and opening the file to manipulate it. +.br "for this reason, the use of this system call should be avoided" . +(in the example just described, +a safer alternative would be to temporarily switch the process's +effective user id to the real id and then call +.br open (2).) +.pp +.br access () +always dereferences symbolic links. +if you need to check the permissions on a symbolic link, use +.br faccessat () +with the flag +.br at_symlink_nofollow . +.pp +these calls return an error if any of the access types in +.i mode +is denied, even if some of the other access types in +.i mode +are permitted. +.pp +if the calling process has appropriate privileges (i.e., is superuser), +posix.1-2001 permits an implementation to indicate success for an +.b x_ok +check even if none of the execute file permission bits are set. +.\" hpu-ux 11 and tru64 5.1 do this. +linux does not do this. +.pp +a file is accessible only if the permissions on each of the +directories in the path prefix of +.i pathname +grant search (i.e., execute) access. +if any directory is inaccessible, then the +.br access () +call fails, regardless of the permissions on the file itself. +.pp +only access bits are checked, not the file type or contents. +therefore, if a directory is found to be writable, +it probably means that files can be created in the directory, +and not that the directory can be written as a file. +similarly, a dos file may be reported as executable, but the +.br execve (2) +call will still fail. +.pp +these calls +may not work correctly on nfsv2 filesystems with uid mapping enabled, +because uid mapping is done on the server and hidden from the client, +which checks permissions. +(nfs versions 3 and higher perform the check on the server.) +similar problems can occur to fuse mounts. +.\" +.\" +.ss c library/kernel differences +the raw +.br faccessat () +system call takes only the first three arguments. +the +.b at_eaccess +and +.b at_symlink_nofollow +flags are actually implemented within the glibc wrapper function for +.br faccessat (). +if either of these flags is specified, then the wrapper function employs +.br fstatat (2) +to determine access permissions, but see bugs. +.\" +.ss glibc notes +on older kernels where +.br faccessat () +is unavailable (and when the +.b at_eaccess +and +.b at_symlink_nofollow +flags are not specified), +the glibc wrapper function falls back to the use of +.br access (). +when +.i pathname +is a relative pathname, +glibc constructs a pathname based on the symbolic link in +.ir /proc/self/fd +that corresponds to the +.ir dirfd +argument. +.sh bugs +because the linux kernel's +.br faccessat () +system call does not support a +.i flags +argument, the glibc +.br faccessat () +wrapper function provided in glibc 2.32 and earlier +emulates the required functionality using +a combination of the +.br faccessat () +system call and +.br fstatat (2). +however, this emulation does not take acls into account. +starting with glibc 2.33, the wrapper function avoids this bug +by making use of the +.br faccessat2 () +system call where it is provided by the underlying kernel. +.pp +in kernel 2.4 (and earlier) there is some strangeness in the handling of +.b x_ok +tests for superuser. +if all categories of execute permission are disabled +for a nondirectory file, then the only +.br access () +test that returns \-1 is when +.i mode +is specified as just +.br x_ok ; +if +.b r_ok +or +.b w_ok +is also specified in +.ir mode , +then +.br access () +returns 0 for such files. +.\" this behavior appears to have been an implementation accident. +early 2.6 kernels (up to and including 2.6.3) +also behaved in the same way as kernel 2.4. +.pp +in kernels before 2.6.20, +these calls ignored the effect of the +.b ms_noexec +flag if it was used to +.br mount (2) +the underlying filesystem. +since kernel 2.6.20, the +.b ms_noexec +flag is honored. +.sh see also +.br chmod (2), +.br chown (2), +.br open (2), +.br setgid (2), +.br setuid (2), +.br stat (2), +.br euidaccess (3), +.br credentials (7), +.br path_resolution (7), +.br symlink (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2006 red hat, inc. all rights reserved. +.\" written by ivana varekova +.\" and copyright (c) 2017, michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" fixme something could be added to this page (or exit(2)) +.\" about exit_robust_list processing +.\" +.th get_robust_list 2 2021-03-22 linux "linux system calls" +.sh name +get_robust_list, set_robust_list \- get/set list of robust futexes +.sh synopsis +.nf +.br "#include " \ +" /* definition of " "struct robust_list_head" " */" +.br "#include " " /* definition of " sys_* " constants */" +.b #include +.pp +.bi "long syscall(sys_get_robust_list, int " pid , +.bi " struct robust_list_head **" head_ptr ", size_t *" len_ptr ); +.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: +the kernel knows only about the location of the head of the list. +a thread can inform the kernel of the location of its robust futex list using +.br set_robust_list (). +the address of a thread's robust futex list can be obtained using +.br get_robust_list (). +.pp +the purpose of the robust futex list is to ensure that if a thread +accidentally fails to unlock a futex before terminating or calling +.br execve (2), +another thread that is waiting on that futex is notified that +the former owner of the futex has died. +this notification consists of two pieces: the +.br futex_owner_died +bit is set in the futex word, and the kernel performs a +.br futex (2) +.br futex_wake +operation on one of the threads waiting on the futex. +.pp +the +.br get_robust_list () +system call returns the head of the robust futex list of the thread +whose thread id is specified in +.ir pid . +if +.i pid +is 0, +the head of the list for the calling thread is returned. +the list head is stored in the location pointed to by +.ir head_ptr . +the size of the object pointed to by +.i **head_ptr +is stored in +.ir len_ptr . +.pp +permission to employ +.br get_robust_list () +is governed by a ptrace access mode +.b ptrace_mode_read_realcreds +check; see +.br ptrace (2). +.pp +the +.br set_robust_list () +system call requests the kernel to record the head of the list of +robust futexes owned by the calling thread. +the +.i head +argument is the list head to record. +the +.i len +argument should be +.ir sizeof(*head) . +.sh return value +the +.br set_robust_list () +and +.br get_robust_list () +system calls return zero when the operation is successful, +an error code otherwise. +.sh errors +the +.br set_robust_list () +system call can fail with the following error: +.tp +.b einval +.i len +does not equal +.ir "sizeof(struct\ robust_list_head)" . +.pp +the +.br get_robust_list () +system call can fail with the following errors: +.tp +.b efault +the head of the robust futex list can't be stored at the location +.ir head . +.tp +.b eperm +the calling process does not have permission to see the robust futex list of +the thread with the thread id +.ir pid , +and does not have the +.br cap_sys_ptrace +capability. +.tp +.b esrch +no thread with the thread id +.i pid +could be found. +.sh versions +these system calls were added in linux 2.6.17. +.sh notes +these system calls are not needed by normal applications. +.pp +a thread can have only one robust futex list; +therefore applications that wish +to use this functionality should use the robust mutexes provided by glibc. +.pp +in the initial implementation, +a thread waiting on a futex was notified that the owner had died +only if the owner terminated. +starting with linux 2.6.28, +.\" commit 8141c7f3e7aee618312fa1c15109e1219de784a7 +notification was extended to include the case where the owner performs an +.br execve (2). +.pp +the thread ids mentioned in the main text are +.i kernel +thread ids of the kind returned by +.br clone (2) +and +.br gettid (2). +.sh see also +.br futex (2), +.br pthread_mutexattr_setrobust (3) +.pp +.ir documentation/robust\-futexes.txt +and +.ir documentation/robust\-futex\-abi.txt +in the linux kernel source tree +.\" http://lwn.net/articles/172149/ +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2008 linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th pthread_attr_setdetachstate 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +pthread_attr_setdetachstate, pthread_attr_getdetachstate \- +set/get detach state attribute in thread attributes object +.sh synopsis +.nf +.b #include +.pp +.bi "int pthread_attr_setdetachstate(pthread_attr_t *" attr \ +", int " detachstate ); +.bi "int pthread_attr_getdetachstate(const pthread_attr_t *" attr , +.bi " int *" detachstate ); +.pp +compile and link with \fi\-pthread\fp. +.fi +.sh description +the +.br pthread_attr_setdetachstate () +function sets the detach state attribute of the +thread attributes object referred to by +.ir attr +to the value specified in +.ir detachstate . +the detach state attribute determines whether a thread created using +the thread attributes object +.i attr +will be created in a joinable or a detached state. +.pp +the following values may be specified in +.ir detachstate : +.tp +.b pthread_create_detached +threads that are created using +.i attr +will be created in a detached state. +.tp +.b pthread_create_joinable +threads that are created using +.i attr +will be created in a joinable state. +.pp +the default setting of the detach state attribute in a newly initialized +thread attributes object is +.br pthread_create_joinable . +.pp +the +.br pthread_attr_getdetachstate () +returns the detach state attribute of the thread attributes object +.ir attr +in the buffer pointed to by +.ir detachstate . +.sh return value +on success, these functions return 0; +on error, they return a nonzero error number. +.sh errors +.br pthread_attr_setdetachstate () +can fail with the following error: +.tp +.b einval +an invalid value was specified in +.ir detachstate . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br pthread_attr_setdetachstate (), +.br pthread_attr_getdetachstate () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +see +.br pthread_create (3) +for more details on detached and joinable threads. +.pp +a thread that is created in a joinable state should +eventually either be joined using +.br pthread_join (3) +or detached using +.br pthread_detach (3); +see +.br pthread_create (3). +.pp +it is an error to specify the thread id of +a thread that was created in a detached state +in a later call to +.br pthread_detach (3) +or +.br pthread_join (3). +.sh examples +see +.br pthread_attr_init (3). +.sh see also +.br pthread_attr_init (3), +.br pthread_create (3), +.br pthread_detach (3), +.br pthread_join (3), +.br pthreads (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2006 justin pryzby +.\" +.\" %%%license_start(permissive_misc) +.\" permission is hereby granted, free of charge, to any person obtaining +.\" a copy of this software and associated documentation files (the +.\" "software"), to deal in the software without restriction, including +.\" without limitation the rights to use, copy, modify, merge, publish, +.\" distribute, sublicense, and/or sell copies of the software, and to +.\" permit persons to whom the software is furnished to do so, subject to +.\" the following conditions: +.\" +.\" the above copyright notice and this permission notice shall be +.\" included in all copies or substantial portions of the software. +.\" +.\" the software is provided "as is", without warranty of any kind, +.\" express or implied, including but not limited to the warranties of +.\" merchantability, fitness for a particular purpose and noninfringement. +.\" in no event shall the authors or copyright holders be liable for any +.\" claim, damages or other liability, whether in an action of contract, +.\" tort or otherwise, arising from, out of or in connection with the +.\" software or the use or other dealings in the software. +.\" %%%license_end +.\" +.\" references: +.\" glibc manual and source +.\" +.\" 2006-05-19, mtk, various edits and example program +.\" +.th rpmatch 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +rpmatch \- determine if the answer to a question is affirmative or negative +.sh synopsis +.nf +.b #include +.pp +.bi "int rpmatch(const char *" response ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br rpmatch (): +.nf + since glibc 2.19: + _default_source + glibc 2.19 and earlier: + _svid_source +.fi +.sh description +.br rpmatch () +handles a user response to yes or no questions, with +support for internationalization. +.pp +.i response +should be a null-terminated string containing a +user-supplied response, perhaps obtained with +.br fgets (3) +or +.br getline (3). +.pp +the user's language preference is taken into account per the +environment variables +.br lang , +.br lc_messages , +and +.br lc_all , +if the program has called +.br setlocale (3) +to effect their changes. +.pp +regardless of the locale, responses matching +.b \(ha[yy] +are always accepted as affirmative, and those matching +.b \(ha[nn] +are always accepted as negative. +.sh return value +after examining +.ir response , +.br rpmatch () +returns 0 for a recognized negative response ("no"), 1 +for a recognized positive response ("yes"), and \-1 when the value +of +.i response +is unrecognized. +.sh errors +a return value of \-1 may indicate either an invalid input, or some +other error. +it is incorrect to only test if the return value is nonzero. +.pp +.br rpmatch () +can fail for any of the reasons that +.br regcomp (3) +or +.br regexec (3) +can fail; the cause of the error +is not available from +.i errno +or anywhere else, but indicates a +failure of the regex engine (but this case is indistinguishable from +that of an unrecognized value of +.ir response ). +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br rpmatch () +t} thread safety mt-safe locale +.te +.hy +.ad +.sp 1 +.sh conforming to +.br rpmatch () +is not required by any standard, but +is available on a few other systems. +.\" it is available on at least aix 5.1 and freebsd 6.0. +.sh bugs +the +.br rpmatch () +implementation looks at only the first character +of +.ir response . +as a consequence, "nyes" returns 0, and +"ynever; not in a million years" returns 1. +it would be preferable to accept input strings much more +strictly, for example (using the extended regular +expression notation described in +.br regex (7)): +.b \(ha([yy]|yes|yes)$ +and +.br \(ha([nn]|no|no)$ . +.sh examples +the following program displays the results when +.br rpmatch () +is applied to the string given in the program's command-line argument. +.pp +.ex +#define _svid_source +#include +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + if (argc != 2 || strcmp(argv[1], "\-\-help") == 0) { + fprintf(stderr, "%s response\en", argv[0]); + exit(exit_failure); + } + + setlocale(lc_all, ""); + printf("rpmatch() returns: %d\en", rpmatch(argv[1])); + exit(exit_success); +} +.ee +.sh see also +.br fgets (3), +.br getline (3), +.br nl_langinfo (3), +.br regcomp (3), +.br setlocale (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sat jul 24 18:29:11 1993 by rik faith (faith@cs.unc.edu) +.\" modified 11 june 1995 by andries brouwer (aeb@cwi.nl) +.th rewinddir 3 2021-03-22 "" "linux programmer's manual" +.sh name +rewinddir \- reset directory stream +.sh synopsis +.nf +.b #include +.b #include +.pp +.bi "void rewinddir(dir *" dirp ); +.fi +.sh description +the +.br rewinddir () +function resets the position of the directory +stream +.i dirp +to the beginning of the directory. +.sh return value +the +.br rewinddir () +function returns no value. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br rewinddir () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, svr4, 4.3bsd. +.sh see also +.br closedir (3), +.br opendir (3), +.br readdir (3), +.br scandir (3), +.br seekdir (3), +.br telldir (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/xdr.3 + +.so man2/getuid.2 + +.so man3/envz_add.3 + +.\" copyright (c) 2001 andries brouwer +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th timegm 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +timegm, timelocal \- inverses of gmtime and localtime +.sh synopsis +.nf +.b #include +.pp +.bi "time_t timelocal(struct tm *" tm ); +.bi "time_t timegm(struct tm *" tm ); +.pp +.fi +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br timelocal (), +.br timegm (): +.nf + since glibc 2.19: + _default_source + glibc 2.19 and earlier: + _bsd_source || _svid_source +.fi +.sh description +the functions +.br timelocal () +and +.br timegm () +are the inverses of +.br localtime (3) +and +.br gmtime (3). +both functions take a broken-down time and convert it to calendar time +(seconds since the epoch, 1970-01-01 00:00:00 +0000, utc). +the difference between the two functions is that +.br timelocal () +takes the local timezone into account when doing the conversion, while +.br timegm () +takes the input value to be coordinated universal time (utc). +.sh return value +on success, +these functions return the calendar time (seconds since the epoch), +expressed as a value of type +.ir time_t . +on error, they return the value +.i (time_t)\ \-1 +and set +.i errno +to indicate the error. +.sh errors +.tp +.b eoverflow +the result cannot be represented. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br timelocal (), +.br timegm () +t} thread safety mt-safe env locale +.te +.hy +.ad +.sp 1 +.sh conforming to +these functions are nonstandard gnu extensions +that are also present on the bsds. +avoid their use. +.sh notes +the +.br timelocal () +function is equivalent to the posix standard function +.br mktime (3). +there is no reason to ever use it. +.sh see also +.br gmtime (3), +.br localtime (3), +.br mktime (3), +.br tzset (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/updwtmp.3 + +.\" copyright (c) 2006 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th sem_wait 3 2021-08-27 "linux" "linux programmer's manual" +.sh name +sem_wait, sem_timedwait, sem_trywait \- lock a semaphore +.sh synopsis +.nf +.b #include +.pp +.bi "int sem_wait(sem_t *" sem ); +.bi "int sem_trywait(sem_t *" sem ); +.bi "int sem_timedwait(sem_t *restrict " sem , +.bi " const struct timespec *restrict " abs_timeout ); +.fi +.pp +link with \fi\-pthread\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br sem_timedwait (): +.nf + _posix_c_source >= 200112l +.fi +.sh description +.br sem_wait () +decrements (locks) the semaphore pointed to by +.ir sem . +if the semaphore's value is greater than zero, +then the decrement proceeds, and the function returns, immediately. +if the semaphore currently has the value zero, +then the call blocks until either it becomes possible to perform +the decrement (i.e., the semaphore value rises above zero), +or a signal handler interrupts the call. +.pp +.br sem_trywait () +is the same as +.br sem_wait (), +except that if the decrement cannot be immediately performed, +then call returns an error +.ri ( errno +set to +.br eagain ) +instead of blocking. +.pp +.br sem_timedwait () +is the same as +.br sem_wait (), +except that +.i abs_timeout +specifies a limit on the amount of time that the call +should block if the decrement cannot be immediately performed. +the +.i abs_timeout +argument points to a structure that specifies an absolute timeout +in seconds and nanoseconds since the epoch, 1970-01-01 00:00:00 +0000 (utc). +this structure is defined as follows: +.pp +.in +4n +.ex +struct timespec { + time_t tv_sec; /* seconds */ + long tv_nsec; /* nanoseconds [0 .. 999999999] */ +}; +.ee +.in +.pp +if the timeout has already expired by the time of the call, +and the semaphore could not be locked immediately, +then +.br sem_timedwait () +fails with a timeout error +.ri ( errno +set to +.br etimedout ). +.pp +if the operation can be performed immediately, then +.br sem_timedwait () +never fails with a timeout error, regardless of the value of +.ir abs_timeout . +furthermore, the validity of +.i abs_timeout +is not checked in this case. +.sh return value +all of these functions return 0 on success; +on error, the value of the semaphore is left unchanged, +\-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eagain +.rb ( sem_trywait ()) +the operation could not be performed without blocking (i.e., the +semaphore currently has the value zero). +.tp +.b eintr +the call was interrupted by a signal handler; see +.br signal (7). +.tp +.b einval +.i sem +is not a valid semaphore. +.tp +.b einval +.rb ( sem_timedwait ()) +the value of +.i abs_timeout.tv_nsecs +is less than 0, or greater than or equal to 1000 million. +.tp +.b etimedout +.rb ( sem_timedwait ()) +the call timed out before the semaphore could be locked. +.\" posix.1-2001 also allows edeadlk -- "a deadlock condition +.\" was detected", but this does not occur on linux(?). +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br sem_wait (), +.br sem_trywait (), +.br sem_timedwait () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh examples +the (somewhat trivial) program shown below operates on an +unnamed semaphore. +the program expects two command-line arguments. +the first argument specifies a seconds value that is used to +set an alarm timer to generate a +.b sigalrm +signal. +this handler performs a +.br sem_post (3) +to increment the semaphore that is being waited on in +.i main() +using +.br sem_timedwait (). +the second command-line argument specifies the length +of the timeout, in seconds, for +.br sem_timedwait (). +the following shows what happens on two different runs of the program: +.pp +.in +4n +.ex +.rb "$" " ./a.out 2 3" +about to call sem_timedwait() +sem_post() from handler +sem_timedwait() succeeded +.rb "$" " ./a.out 2 1" +about to call sem_timedwait() +sem_timedwait() timed out +.ee +.in +.ss program source +\& +.ex +#include +#include +#include +#include +#include +#include +#include +#include + +sem_t sem; + +#define handle_error(msg) \e + do { perror(msg); exit(exit_failure); } while (0) + +static void +handler(int sig) +{ + write(stdout_fileno, "sem_post() from handler\en", 24); + if (sem_post(&sem) == \-1) { + write(stderr_fileno, "sem_post() failed\en", 18); + _exit(exit_failure); + } +} + +int +main(int argc, char *argv[]) +{ + struct sigaction sa; + struct timespec ts; + int s; + + if (argc != 3) { + fprintf(stderr, "usage: %s \en", + argv[0]); + exit(exit_failure); + } + + if (sem_init(&sem, 0, 0) == \-1) + handle_error("sem_init"); + + /* establish sigalrm handler; set alarm timer using argv[1]. */ + + sa.sa_handler = handler; + sigemptyset(&sa.sa_mask); + sa.sa_flags = 0; + if (sigaction(sigalrm, &sa, null) == \-1) + handle_error("sigaction"); + + alarm(atoi(argv[1])); + + /* calculate relative interval as current time plus + number of seconds given argv[2]. */ + + if (clock_gettime(clock_realtime, &ts) == \-1) + handle_error("clock_gettime"); + + ts.tv_sec += atoi(argv[2]); + + printf("main() about to call sem_timedwait()\en"); + while ((s = sem_timedwait(&sem, &ts)) == \-1 && errno == eintr) + continue; /* restart if interrupted by handler. */ + + /* check what happened. */ + + if (s == \-1) { + if (errno == etimedout) + printf("sem_timedwait() timed out\en"); + else + perror("sem_timedwait"); + } else + printf("sem_timedwait() succeeded\en"); + + exit((s == 0) ? exit_success : exit_failure); +} +.ee +.sh see also +.br clock_gettime (2), +.br sem_getvalue (3), +.br sem_post (3), +.br sem_overview (7), +.br time (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1993 giorgio ciucci (giorgio@crcc.it) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified 2001-11-28, by michael kerrisk, +.\" changed data type of proj_id; minor fixes +.\" aeb: further fixes; added notes. +.\" +.th ftok 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +ftok \- convert a pathname and a project identifier to a system v ipc key +.sh synopsis +.nf +.b #include +.fi +.pp +.bi "key_t ftok(const char *" pathname ", int " proj_id ); +.sh description +the +.br ftok () +function uses the identity of the file named by the given +.i pathname +(which must refer to an existing, accessible file) +and the least significant 8 bits of +.i proj_id +(which must be nonzero) to generate a +.i key_t +type system v ipc key, suitable for use with +.br msgget (2), +.br semget (2), +or +.br shmget (2). +.pp +the resulting value is the same for all pathnames that +name the same file, when the same value of +.i proj_id +is used. +the value returned should be different when the +(simultaneously existing) files or the project ids differ. +.sh return value +on success, the generated +.i key_t +value is returned. +on failure \-1 is returned, with +.i errno +indicating the error as for the +.br stat (2) +system call. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br ftok () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +on some ancient systems, the prototype was: +.pp +.in +4n +.ex +.bi "key_t ftok(char *" pathname ", char " proj_id ); +.ee +.in +.pp +today, +.i proj_id +is an +.ir int , +but still only 8 bits are used. +typical usage has an ascii character +.ir proj_id , +that is why the behavior is said to be undefined when +.i proj_id +is zero. +.pp +of course, no guarantee can be given that the resulting +.i key_t +is unique. +typically, a best-effort attempt combines the given +.i proj_id +byte, the lower 16 bits of the inode number, and the +lower 8 bits of the device number into a 32-bit result. +collisions may easily happen, for example between files on +.i /dev/hda1 +and files on +.ir /dev/sda1 . +.sh examples +see +.br semget (2). +.sh see also +.br msgget (2), +.br semget (2), +.br shmget (2), +.br stat (2), +.br sysvipc (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/j0.3 + +.so man2/sigreturn.2 + +.so man2/mknod.2 + +.so man3/stailq.3 + +.\" copyright (c) 2010 michael kerrisk +.\" based on a proposal from stephan mueller +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of +.\" this manual under the conditions for verbatim copying, provided that +.\" the entire resulting derived work is distributed under the terms of +.\" a permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume +.\" no responsibility for errors or omissions, or for damages resulting +.\" from the use of the information contained herein. the author(s) may +.\" not have taken the same level of care in the production of this +.\" manual, which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" various pieces of text taken from the kernel source and the commentary +.\" in kernel commit fa28237cfcc5827553044cbd6ee52e33692b0faa +.\" both written by paul mackerras +.\" +.th subpage_prot 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +subpage_prot \- define a subpage protection for an address range +.sh synopsis +.nf +.br "#include " " /* definition of " sys_* " constants */" +.b #include +.pp +.bi "int syscall(sys_subpage_prot, unsigned long " addr ", unsigned long " len , +.bi " uint32_t *" map ); +.fi +.pp +.ir note : +glibc provides no wrapper for +.br subpage_prot (), +necessitating the use of +.br syscall (2). +.sh description +the powerpc-specific +.br subpage_prot () +system call provides the facility to control the access +permissions on individual 4\ kb subpages on systems configured with +a page size of 64\ kb. +.pp +the protection map is applied to the memory pages in the region starting at +.i addr +and continuing for +.i len +bytes. +both of these arguments must be aligned to a 64-kb boundary. +.pp +the protection map is specified in the buffer pointed to by +.ir map . +the map has 2 bits per 4\ kb subpage; +thus each 32-bit word specifies the protections of 16 4\ kb subpages +inside a 64\ kb page +(so, the number of 32-bit words pointed to by +.i map +should equate to the number of 64-kb pages specified by +.ir len ). +each 2-bit field in the protection map is either 0 to allow any access, +1 to prevent writes, or 2 or 3 to prevent all accesses. +.sh return value +on success, +.br subpage_prot () +returns 0. +otherwise, one of the error codes specified below is returned. +.sh errors +.tp +.b efault +the buffer referred to by +.i map +is not accessible. +.tp +.b einval +the +.i addr +or +.i len +arguments are incorrect. +both of these arguments must be aligned to a multiple of the system page size, +and they must not refer to a region outside of the +address space of the process or to a region that consists of huge pages. +.tp +.b enomem +out of memory. +.sh versions +this system call is provided on the powerpc architecture +since linux 2.6.25. +the system call is provided only if the kernel is configured with +.br config_ppc_64k_pages . +no library support is provided. +.sh conforming to +this system call is linux-specific. +.sh notes +normal page protections (at the 64-kb page level) also apply; +the subpage protection mechanism is an additional constraint, +so putting 0 in a 2-bit field won't allow writes to a page that is otherwise +write-protected. +.ss rationale +this system call is provided to assist writing emulators that +operate using 64-kb pages on powerpc systems. +when emulating systems such as x86, which uses a smaller page size, +the emulator can no longer use the memory-management unit (mmu) +and normal system calls for controlling page protections. +(the emulator could emulate the mmu by checking and possibly remapping +the address for each memory access in software, but that is slow.) +the idea is that the emulator supplies an array of protection masks +to apply to a specified range of virtual addresses. +these masks are applied at the level where hardware page-table entries (ptes) +are inserted into the hardware page table based on the linux ptes, +so the linux ptes are not affected. +implicit in this is that the regions of the address space that are +protected are switched to use 4-kb hardware pages rather than 64-kb +hardware pages (on machines with hardware 64-kb page support). +.\" in the initial implementation, it was the case that: +.\" in fact the whole process is switched to use 4 kb hardware pages when the +.\" subpage_prot system call is used, but this could be improved in future +.\" to switch only the affected segments. +.\" but paul mackerass says (oct 2010): i'm pretty sure we now only switch +.\" the affected segment, not the whole process. +.sh see also +.br mprotect (2), +.br syscall (2) +.pp +.ir documentation/admin\-guide/mm/hugetlbpage.rst +in the linux kernel source tree +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/error.3 + +.\" copyright (c) 1993 michael haardt (michael@moria.de), +.\" fri apr 2 11:32:09 met dst 1993 +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" modified sat jul 24 17:08:16 1993 by rik faith +.\" modified mon oct 21 17:47:19 edt 1996 by eric s. raymond +.th motd 5 1992-12-29 "linux" "linux programmer's manual" +.sh name +motd \- message of the day +.sh description +the contents of +.i /etc/motd +are displayed by +.br login (1) +after a successful login but just before it executes the login shell. +.pp +the abbreviation "motd" stands for "message of the day", and this file +has been traditionally used for exactly that (it requires much less disk +space than mail to all users). +.sh files +.i /etc/motd +.sh see also +.br login (1), +.br issue (5) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/unlocked_stdio.3 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" and copyright 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified 1993-07-24 by rik faith (faith@cs.unc.edu) +.\" modified 1996-06-08 by aeb +.\" modified 2002-07-27 by walter harms +.\" (walter.harms@informatik.uni-oldenburg.de) +.\" +.th sinh 3 2021-03-22 "" "linux programmer's manual" +.sh name +sinh, sinhf, sinhl \- hyperbolic sine function +.sh synopsis +.nf +.b #include +.pp +.bi "double sinh(double " x ); +.bi "float sinhf(float " x ); +.bi "long double sinhl(long double " x ); +.fi +.pp +link with \fi\-lm\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br sinhf (), +.br sinhl (): +.nf + _isoc99_source || _posix_c_source >= 200112l + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.sh description +these functions return the hyperbolic sine of +.ir x , +which +is defined mathematically as: +.pp +.nf + sinh(x) = (exp(x) \- exp(\-x)) / 2 +.fi +.sh return value +on success, these functions return the hyperbolic sine of +.ir x . +.pp +if +.i x +is a nan, a nan is returned. +.pp +if +.i x +is +0 (\-0), +0 (\-0) is returned. +.pp +if +.i x +is positive infinity (negative infinity), +positive infinity (negative infinity) is returned. +.pp +if the result overflows, +a range error occurs, +and the functions return +.br huge_val , +.br huge_valf , +or +.br huge_vall , +respectively, with the same sign as +.ir x . +.\" +.\" posix.1-2001 documents an optional range error (underflow) +.\" for subnormal x; +.\" glibc 2.8 does not do this. +.sh errors +see +.br math_error (7) +for information on how to determine whether an error has occurred +when calling these functions. +.pp +the following errors can occur: +.tp +range error: result overflow +.i errno +is set to +.br erange . +an overflow floating-point exception +.rb ( fe_overflow ) +is raised. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br sinh (), +.br sinhf (), +.br sinhl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.pp +the variant returning +.i double +also conforms to +svr4, 4.3bsd, c89. +.sh see also +.br acosh (3), +.br asinh (3), +.br atanh (3), +.br cosh (3), +.br csinh (3), +.br tanh (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/flockfile.3 + +.so man3/strcasecmp.3 + +.so man3/getspnam.3 + +.so man3/cpu_set.3 + +.so man7/system_data_types.7 + +.\" copyright (c) 1995 michael chastain (mec@duracef.shout.net), 22 july 1995. +.\" copyright (c) 2015 andrew lutomirski +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th modify_ldt 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +modify_ldt \- get or set a per-process ldt entry +.sh synopsis +.nf +.br "#include " " /* definition of " "struct user_desc" " */" +.br "#include " " /* definition of " sys_* " constants */" +.b #include +.pp +.bi "int syscall(sys_modify_ldt, int " func ", void *" ptr , +.bi " unsigned long " bytecount ); +.fi +.pp +.ir note : +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. +the ldt +is an array of segment descriptors that can be referenced by user code. +linux allows processes to configure a per-process (actually per-mm) ldt. +for more information about the ldt, see the intel software developer's +manual or the amd architecture programming manual. +.pp +when +.i func +is 0, +.br modify_ldt () +reads the ldt into the memory pointed to by +.ir ptr . +the number of bytes read is the smaller of +.i bytecount +and the actual size of the ldt, although the kernel may act as though +the ldt is padded with additional trailing zero bytes. +on success, +.br modify_ldt () +will return the number of bytes read. +.pp +when +.i func +is 1 or 0x11, +.br modify_ldt () +modifies the ldt entry indicated by +.ir ptr\->entry_number . +.i ptr +points to a +.i user_desc +structure +and +.i bytecount +must equal the size of this structure. +.pp +the +.i user_desc +structure is defined in \fi\fp as: +.pp +.in +4n +.ex +struct user_desc { + unsigned int entry_number; + unsigned int base_addr; + unsigned int limit; + unsigned int seg_32bit:1; + unsigned int contents:2; + unsigned int read_exec_only:1; + unsigned int limit_in_pages:1; + unsigned int seg_not_present:1; + unsigned int useable:1; +}; +.ee +.in +.pp +in linux 2.4 and earlier, this structure was named +.ir modify_ldt_ldt_s . +.pp +the +.i contents +field is the segment type (data, expand-down data, non-conforming code, or +conforming code). +the other fields match their descriptions in the cpu manual, although +.br modify_ldt () +cannot set the hardware-defined "accessed" bit described in the cpu manual. +.pp +a +.i user_desc +is considered "empty" if +.i read_exec_only +and +.i seg_not_present +are set to 1 and all of the other fields are 0. +an ldt entry can be cleared by setting it to an "empty" +.i user_desc +or, if +.i func +is 1, by setting both +.i base +and +.i limit +to 0. +.pp +a conforming code segment (i.e., one with +.ir contents==3 ) +will be rejected if +.i +func +is 1 or if +.i seg_not_present +is 0. +.pp +when +.i func +is 2, +.br modify_ldt () +will read zeros. +this appears to be a leftover from linux 2.4. +.sh return value +on success, +.br modify_ldt () +returns either the actual number of bytes read (for reading) +or 0 (for writing). +on failure, +.br modify_ldt () +returns \-1 and sets +.i errno +to indicate the error. +.sh errors +.tp +.b efault +.i ptr +points outside the address space. +.tp +.b einval +.i ptr +is 0, +or +.i func +is 1 and +.i bytecount +is not equal to the size of the structure +.ir user_desc , +or +.i func +is 1 or 0x11 and the new ldt entry has invalid values. +.tp +.b enosys +.i func +is neither 0, 1, 2, nor 0x11. +.sh conforming to +this call is linux-specific and should not be used in programs intended +to be portable. +.sh notes +.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. +threading libraries should use +.br set_thread_area (2) +or +.br arch_prctl (2) +instead, except on extremely old kernels that do not support those system +calls. +.pp +the normal use for +.br modify_ldt () +is to run legacy 16-bit or segmented 32-bit code. +not all kernels allow 16-bit segments to be installed, however. +.pp +even on 64-bit kernels, +.br modify_ldt () +cannot be used to create a long mode (i.e., 64-bit) code segment. +the undocumented field "lm" in +.ir user_desc +is not useful, and, despite its name, +does not result in a long mode segment. +.sh bugs +on 64-bit kernels before linux 3.19, +.\" commit e30ab185c490e9a9381385529e0fd32f0a399495 +setting the "lm" bit in +.ir user_desc +prevents the descriptor from being considered empty. +keep in mind that the +"lm" bit does not exist in the 32-bit headers, but these buggy kernels +will still notice the bit even when set in a 32-bit process. +.sh see also +.br arch_prctl (2), +.br set_thread_area (2), +.br vm86 (2) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man7/queue.7 + +.\" copyright 2001 andries brouwer . +.\" and copyright 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th round 3 2021-03-22 "" "linux programmer's manual" +.sh name +round, roundf, roundl \- round to nearest integer, away from zero +.sh synopsis +.nf +.b #include +.pp +.bi "double round(double " x ); +.bi "float roundf(float " x ); +.bi "long double roundl(long double " x ); +.fi +.pp +link with \fi\-lm\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br round (), +.br roundf (), +.br roundl (): +.nf + _isoc99_source || _posix_c_source >= 200112l +.fi +.sh description +these functions round +.i x +to the nearest integer, but +round halfway cases away from zero (regardless of the current rounding +direction, see +.br fenv (3)), +instead of to the nearest even integer like +.br rint (3). +.pp +for example, +.ir round(0.5) +is 1.0, and +.ir round(\-0.5) +is \-1.0. +.sh return value +these functions return the rounded integer value. +.pp +if +.i x +is integral, +0, \-0, nan, or infinite, +.i x +itself is returned. +.sh errors +no errors occur. +posix.1-2001 documents a range error for overflows, but see notes. +.sh versions +these functions first appeared in glibc in version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br round (), +.br roundf (), +.br roundl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.sh notes +posix.1-2001 contains text about overflow (which might set +.i errno +to +.br erange , +or raise an +.b fe_overflow +exception). +in practice, the result cannot overflow on any current machine, +so this error-handling stuff is just nonsense. +.\" the posix.1-2001 application usage section discusses this point. +(more precisely, overflow can happen only when the maximum value +of the exponent is smaller than the number of mantissa bits. +for the ieee-754 standard 32-bit and 64-bit floating-point numbers +the maximum value of the exponent is 128 (respectively, 1024), +and the number of mantissa bits is 24 (respectively, 53).) +.pp +if you want to store the rounded value in an integer type, +you probably want to use one of the functions described in +.br lround (3) +instead. +.sh see also +.br ceil (3), +.br floor (3), +.br lround (3), +.br nearbyint (3), +.br rint (3), +.br trunc (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th clock_getcpuclockid 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +clock_getcpuclockid \- obtain id of a process cpu-time clock +.sh synopsis +.b #include +.nf +.pp +.bi "int clock_getcpuclockid(pid_t " pid ", clockid_t *" clockid ); +.fi +.pp +link with \fi\-lrt\fp (only for glibc versions before 2.17). +.pp +.ad l +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br clock_getcpuclockid (): +.nf + _posix_c_source >= 200112l +.fi +.sh description +the +.br clock_getcpuclockid () +function obtains the id of the cpu-time clock of the process whose id is +.ir pid , +and returns it in the location pointed to by +.ir clockid . +if +.i pid +is zero, then the clock id of the cpu-time clock +of the calling process is returned. +.sh return value +on success, +.br clock_getcpuclockid () +returns 0; +on error, it returns one of the positive error numbers listed in errors. +.sh errors +.tp +.b enosys +the kernel does not support obtaining the per-process +cpu-time clock of another process, and +.i pid +does not specify the calling process. +.tp +.b eperm +the caller does not have permission to access +the cpu-time clock of the process specified by +.ir pid . +(specified in posix.1-2001; +does not occur on linux unless the kernel does not support +obtaining the per-process cpu-time clock of another process.) +.tp +.b esrch +there is no process with the id +.ir pid . +.sh versions +the +.br clock_getcpuclockid () +function is available in glibc since version 2.2. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br clock_getcpuclockid () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +calling +.br clock_gettime (2) +with the clock id obtained by a call to +.br clock_getcpuclockid () +with a +.i pid +of 0, +is the same as using the clock id +.br clock_process_cputime_id . +.sh examples +the example program below obtains the +cpu-time clock id of the process whose id is given on the command line, +and then uses +.br clock_gettime (2) +to obtain the time on that clock. +an example run is the following: +.pp +.in +4n +.ex +.rb "$" " ./a.out 1" " # show cpu clock of init process" +cpu\-time clock for pid 1 is 2.213466748 seconds +.ee +.in +.ss program source +\& +.ex +#define _xopen_source 600 +#include +#include +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + clockid_t clockid; + struct timespec ts; + + if (argc != 2) { + fprintf(stderr, "%s \en", argv[0]); + exit(exit_failure); + } + + if (clock_getcpuclockid(atoi(argv[1]), &clockid) != 0) { + perror("clock_getcpuclockid"); + exit(exit_failure); + } + + if (clock_gettime(clockid, &ts) == \-1) { + perror("clock_gettime"); + exit(exit_failure); + } + + printf("cpu\-time clock for pid %s is %jd.%09ld seconds\en", + argv[1], (intmax_t) ts.tv_sec, ts.tv_nsec); + exit(exit_success); +} +.ee +.sh see also +.br clock_getres (2), +.br timer_create (2), +.br pthread_getcpuclockid (3), +.br time (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/pthread_mutexattr_getpshared.3 + +.so man3/rpc.3 + +.\" copyright (c) 2005 by michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th sigvec 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +sigvec, sigblock, sigsetmask, siggetmask, sigmask \- bsd signal api +.sh synopsis +.nf +.b #include +.pp +.bi "int sigvec(int " sig ", const struct sigvec *" vec ", struct sigvec *" ovec ); +.pp +.bi "int sigmask(int " signum ); +.pp +.bi "int sigblock(int " mask ); +.bi "int sigsetmask(int " mask ); +.b int siggetmask(void); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +all functions shown above: +.nf + since glibc 2.19: + _default_source + glibc 2.19 and earlier: + _bsd_source +.fi +.sh description +these functions are provided in glibc as a compatibility interface +for programs that make use of the historical bsd signal api. +this api is obsolete: new applications should use the posix signal api +.rb ( sigaction (2), +.br sigprocmask (2), +etc.). +.pp +the +.br sigvec () +function sets and/or gets the disposition of the signal +.i sig +(like the posix +.br sigaction (2)). +if +.i vec +is not null, it points to a +.i sigvec +structure that defines the new disposition for +.ir sig . +if +.i ovec +is not null, it points to a +.i sigvec +structure that is used to return the previous disposition of +.ir sig . +to obtain the current disposition of +.i sig +without changing it, specify null for +.ir vec , +and a non-null pointer for +.ir ovec . +.pp +the dispositions for +.b sigkill +and +.b sigstop +cannot be changed. +.pp +the +.i sigvec +structure has the following form: +.pp +.in +4n +.ex +struct sigvec { + void (*sv_handler)(int); /* signal disposition */ + int sv_mask; /* signals to be blocked in handler */ + int sv_flags; /* flags */ +}; +.ee +.in +.pp +the +.i sv_handler +field specifies the disposition of the signal, and is either: +the address of a signal handler function; +.br sig_dfl , +meaning the default disposition applies for the signal; or +.br sig_ign , +meaning that the signal is ignored. +.pp +if +.i sv_handler +specifies the address of a signal handler, then +.i sv_mask +specifies a mask of signals that are to be blocked while +the handler is executing. +in addition, the signal for which the handler is invoked is +also blocked. +attempts to block +.b sigkill +or +.b sigstop +are silently ignored. +.pp +if +.i sv_handler +specifies the address of a signal handler, then the +.i sv_flags +field specifies flags controlling what happens when the handler is called. +this field may contain zero or more of the following flags: +.tp +.b sv_interrupt +if the signal handler interrupts a blocking system call, +then upon return from the handler the system call is not restarted: +instead it fails with the error +.br eintr . +if this flag is not specified, then system calls are restarted +by default. +.tp +.b sv_resethand +reset the disposition of the signal to the default +before calling the signal handler. +if this flag is not specified, then the handler remains established +until explicitly removed by a later call to +.br sigvec () +or until the process performs an +.br execve (2). +.tp +.b sv_onstack +handle the signal on the alternate signal stack +(historically established under bsd using the obsolete +.br sigstack () +function; the posix replacement is +.br sigaltstack (2)). +.pp +the +.br sigmask () +macro constructs and returns a "signal mask" for +.ir signum . +for example, we can initialize the +.i vec.sv_mask +field given to +.br sigvec () +using code such as the following: +.pp +.in +4n +.ex +vec.sv_mask = sigmask(sigquit) | sigmask(sigabrt); + /* block sigquit and sigabrt during + handler execution */ +.ee +.in +.pp +the +.br sigblock () +function adds the signals in +.i mask +to the process's signal mask +(like posix +.ir sigprocmask(sig_block) ), +and returns the process's previous signal mask. +attempts to block +.b sigkill +or +.b sigstop +are silently ignored. +.pp +the +.br sigsetmask () +function sets the process's signal mask to the value given in +.i mask +(like posix +.ir sigprocmask(sig_setmask) ), +and returns the process's previous signal mask. +.pp +the +.br siggetmask () +function returns the process's current signal mask. +this call is equivalent to +.ir sigblock(0) . +.sh return value +the +.br sigvec () +function returns 0 on success; on error, it returns \-1 and sets +.i errno +to indicate the error. +.pp +the +.br sigblock () +and +.br sigsetmask () +functions return the previous signal mask. +.pp +the +.br sigmask () +macro returns the signal mask for +.ir signum . +.sh errors +see the errors under +.br sigaction (2) +and +.br sigprocmask (2). +.sh versions +starting with version 2.21, the gnu c library no longer exports the +.br sigvec () +function as part of the abi. +(to ensure backward compatibility, +the glibc symbol versioning scheme continues to export the interface +to binaries linked against older versions of the library.) +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br sigvec (), +.br sigmask (), +.br sigblock (), +.br sigsetmask (), +.br siggetmask () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +all of these functions were in +4.3bsd, except +.br siggetmask (), +whose origin is unclear. +these functions are obsolete: do not use them in new programs. +.sh notes +on 4.3bsd, the +.br signal () +function provided reliable semantics (as when calling +.br sigvec () +with +.i vec.sv_mask +equal to 0). +on system v, +.br signal () +provides unreliable semantics. +posix.1 leaves these aspects of +.br signal () +unspecified. +see +.br signal (2) +for further details. +.pp +in order to wait for a signal, +bsd and system v both provided a function named +.br sigpause (3), +but this function has a different argument on the two systems. +see +.br sigpause (3) +for details. +.sh see also +.br kill (2), +.br pause (2), +.br sigaction (2), +.br signal (2), +.br sigprocmask (2), +.br raise (3), +.br sigpause (3), +.br sigset (3), +.br signal (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" +.th wcscasecmp 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +wcscasecmp \- compare two wide-character strings, ignoring case +.sh synopsis +.nf +.b #include +.pp +.bi "int wcscasecmp(const wchar_t *" s1 ", const wchar_t *" s2 ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br wcscasecmp (): +.nf + since glibc 2.10: + _posix_c_source >= 200809l + before glibc 2.10: + _gnu_source +.fi +.sh description +the +.br wcscasecmp () +function is the wide-character equivalent of the +.br strcasecmp (3) +function. +it compares the wide-character string pointed to +by +.i s1 +and the wide-character string pointed to by +.ir s2 , +ignoring +case differences +.rb ( towupper (3), +.br towlower (3)). +.sh return value +the +.br wcscasecmp () +function returns zero if the wide-character strings at +.i s1 +and +.i s2 +are equal except for case distinctions. +it returns a +positive integer if +.i s1 +is greater than +.ir s2 , +ignoring case. +it +returns a negative integer if +.i s1 +is smaller +than +.ir s2 , +ignoring case. +.sh versions +the +.br wcscasecmp () +function is provided in glibc since version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br wcscasecmp () +t} thread safety mt-safe locale +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2008. +this function is not specified in posix.1-2001, +and is not widely available on other systems. +.sh notes +the behavior of +.br wcscasecmp () +depends on the +.b lc_ctype +category of the +current locale. +.sh see also +.br strcasecmp (3), +.br wcscmp (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/rpc.3 + +.so man3/scandir.3 + +.so man3/sigsetops.3 + +.so man3/getfsent.3 + +.so man3/getenv.3 + +.so man7/iso_8859-5.7 + +.\" copyright (c) 2006 red hat, inc. all rights reserved. +.\" author: ulrich drepper +.\" +.\" %%%license_start(gplv2_misc) +.\" this copyrighted material is made available to anyone wishing to use, +.\" modify, copy, or redistribute it subject to the terms and conditions of the +.\" gnu general public license v.2. +.\" +.\" this program 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 general public license for +.\" more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th nss 5 2020-06-09 "linux" "linux programmer's manual" +.sh name +nss \- name service switch configuration file +.sh description +each call to a function which retrieves data from a system database +like the password or group database is handled by the name service +switch implementation in the gnu c library. +the various services +provided are implemented by independent modules, each of which +naturally varies widely from the other. +.pp +the default implementations coming with the gnu c library are by +default conservative and do not use unsafe data. +this might be very costly in some situations, especially when the databases +are large. +some modules allow the system administrator to request +taking shortcuts if these are known to be safe. +it is then the system administrator's responsibility to ensure the assumption +is correct. +.pp +there are other modules where the implementation changed over time. +if an implementation used to sacrifice speed for memory consumption, +it might create problems if the preference is switched. +.pp +the +.i /etc/default/nss +file contains a number of variable assignments. +each variable controls the behavior of one or more +nss modules. +white spaces are ignored. +lines beginning with \(aq#\(aq +are treated as comments. +.pp +the variables currently recognized are: +.tp +\fbnetid_authoritative =\fr \fitrue\fr|\fifalse\fr +if set to true, the nis backend for the +.br initgroups (3) +function will accept the information +from the +.i netid.byname +nis map as authoritative. +this can speed up the function significantly if the +.i group.byname +map is large. +the content of the +.i netid.byname +map is used \fbas is\fr. +the system administrator has to make sure it is correctly generated. +.tp +\fbservices_authoritative =\fr \fitrue\fr|\fifalse\fr +if set to true, the nis backend for the +.br getservbyname (3) +and +.br getservbyname_r (3) +functions will assume that the +.i services.byservicename +nis map exists and is authoritative, particularly +that it contains both keys with /proto and without /proto for both +primary service names and service aliases. +the system administrator has to make sure it is correctly generated. +.tp +\fbsetent_batch_read =\fr \fitrue\fr|\fifalse\fr +if set to true, the nis backend for the +.br setpwent (3) +and +.br setgrent (3) +functions will read the entire database at once and then +hand out the requests one by one from memory with every corresponding +.br getpwent (3) +or +.br getgrent (3) +call respectively. +otherwise, each +.br getpwent (3) +or +.br getgrent (3) +call might result in a network communication with the server to get +the next entry. +.sh files +\fi/etc/default/nss\fr +.sh examples +the default configuration corresponds to the following configuration file: +.pp +.in +4n +.ex +netid_authoritative=false +services_authoritative=false +setent_batch_read=false +.ee +.in +.\" .sh author +.\" ulrich drepper +.\" +.sh see also +\finsswitch.conf\fr +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de) +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under gpl +.\" %%%license_end +.\" +.\" 2002-07-27 walter harms +.\" this was done with the help of the glibc manual +.\" +.th isgreater 3 2021-03-22 "" "linux programmer's manual" +.sh name +isgreater, isgreaterequal, isless, islessequal, islessgreater, +isunordered \- floating-point relational tests without exception for nan +.sh synopsis +.nf +.b #include +.pp +.bi "int isgreater(" x ", " y ); +.bi "int isgreaterequal(" x ", " y ); +.bi "int isless(" x ", " y ); +.bi "int islessequal(" x ", " y ); +.bi "int islessgreater(" x ", " y ); +.bi "int isunordered(" x ", " y ); +.fi +.pp +link with \fi\-lm\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.nf + all functions described here: + _isoc99_source || _posix_c_source >= 200112l +.fi +.sh description +the normal relational operations (like +.br < , +"less than") +fail if one of the operands is nan. +this will cause an exception. +to avoid this, c99 defines the macros listed below. +.pp +these macros are guaranteed to evaluate their arguments only once. +the arguments must be of real floating-point type (note: do not pass +integer values as arguments to these macros, since the arguments will +.i not +be promoted to real-floating types). +.tp +.br isgreater () +determines \fi(x)\ >\ (y)\fp without an exception +if +.ir x +or +.i y +is nan. +.tp +.br isgreaterequal () +determines \fi(x)\ >=\ (y)\fp without an exception +if +.ir x +or +.i y +is nan. +.tp +.br isless () +determines \fi(x)\ <\ (y)\fp without an exception +if +.ir x +or +.i y +is nan. +.tp +.br islessequal () +determines \fi(x)\ <=\ (y)\fp without an exception +if +.ir x +or +.i y +is nan. +.tp +.br islessgreater () +determines \fi(x)\ < (y) || (x) >\ (y)\fp +without an exception if +.ir x +or +.i y +is nan. +this macro is not equivalent to \fix\ !=\ y\fp because that expression is +true if +.ir x +or +.i y +is nan. +.tp +.br isunordered () +determines whether its arguments are unordered, that is, whether +at least one of the arguments is a nan. +.sh return value +the macros other than +.br isunordered () +return the result of the relational comparison; +these macros return 0 if either argument is a nan. +.pp +.br isunordered () +returns 1 if +.ir x +or +.i y +is nan and 0 otherwise. +.sh errors +no errors occur. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br isgreater (), +.br isgreaterequal (), +.br isless (), +.br islessequal (), +.br islessgreater (), +.br isunordered () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh notes +not all hardware supports these functions, +and where hardware support isn't provided, they will be emulated by macros. +this will result in a performance penalty. +don't use these functions if nan is of no concern for you. +.sh see also +.br fpclassify (3), +.br isnan (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/lrint.3 + +.\" %%%license_start(public_domain) +.\" this is in the public domain +.\" %%%license_end +.\" various parts: +.\" copyright (c) 2007-9, 2013, 2016 michael kerrisk +.\" +.th ld.so 8 2021-08-27 "gnu" "linux programmer's manual" +.sh name +ld.so, ld\-linux.so \- dynamic linker/loader +.sh synopsis +the dynamic linker can be run either indirectly by running some +dynamically linked program or shared object +(in which case no command-line options +to the dynamic linker can be passed and, in the elf case, the dynamic linker +which is stored in the +.b .interp +section of the program is executed) or directly by running: +.pp +.i /lib/ld\-linux.so.* +[options] [program [arguments]] +.sh description +the programs +.b ld.so +and +.b ld\-linux.so* +find and load the shared objects (shared libraries) needed by a program, +prepare the program to run, and then run it. +.pp +linux binaries require dynamic linking (linking at run time) +unless the +.b \-static +option was given to +.br ld (1) +during compilation. +.pp +the program +.b ld.so +handles a.out binaries, a binary format used long ago. +the program +.b ld\-linux.so* +(\fi/lib/ld\-linux.so.1\fp for libc5, \fi/lib/ld\-linux.so.2\fp for glibc2) +handles binaries that are in the more modern elf format. +both programs have the same behavior, and use the same +support files and programs +.rb ( ldd (1), +.br ldconfig (8), +and +.ir /etc/ld.so.conf ). +.pp +when resolving shared object dependencies, +the dynamic linker first inspects each dependency +string to see if it contains a slash (this can occur if +a shared object pathname containing slashes was specified at link time). +if a slash is found, then the dependency string is interpreted as +a (relative or absolute) pathname, +and the shared object is loaded using that pathname. +.pp +if a shared object dependency does not contain a slash, +then it is searched for in the following order: +.ip o 3 +using the directories specified in the +dt_rpath dynamic section attribute +of the binary if present and dt_runpath attribute does not exist. +use of dt_rpath is deprecated. +.ip o +using the environment variable +.br ld_library_path , +unless the executable is being run in secure-execution mode (see below), +in which case this variable is ignored. +.ip o +using the directories specified in the +dt_runpath dynamic section attribute +of the binary if present. +such directories are searched only to +find those objects required by dt_needed (direct dependencies) entries +and do not apply to those objects' children, +which must themselves have their own dt_runpath entries. +this is unlike dt_rpath, which is applied +to searches for all children in the dependency tree. +.ip o +from the cache file +.ir /etc/ld.so.cache , +which contains a compiled list of candidate shared objects previously found +in the augmented library path. +if, however, the binary was linked with the +.b \-z nodeflib +linker option, shared objects in the default paths are skipped. +shared objects installed in hardware capability directories (see below) +are preferred to other shared objects. +.ip o +in the default path +.ir /lib , +and then +.ir /usr/lib . +(on some 64-bit architectures, the default paths for 64-bit shared objects are +.ir /lib64 , +and then +.ir /usr/lib64 .) +if the binary was linked with the +.b \-z nodeflib +linker option, this step is skipped. +.\" +.ss dynamic string tokens +in several places, the dynamic linker expands dynamic string tokens: +.ip o 3 +in the environment variables +.br ld_library_path , +.br ld_preload , +and +.br ld_audit , +.ip o 3 +inside the values of the dynamic section tags +.br dt_needed , +.br dt_rpath , +.br dt_runpath , +.br dt_audit , +and +.br dt_depaudit +of elf binaries, +.ip o 3 +in the arguments to the +.b ld.so +command line options +.br \-\-audit , +.br \-\-library\-path , +and +.b \-\-preload +(see below), and +.ip o 3 +in the filename arguments to the +.br dlopen (3) +and +.br dlmopen (3) +functions. +.pp +the substituted tokens are as follows: +.tp +.ir $origin " (or equivalently " ${origin} ) +this expands to +the directory containing the program or shared object. +thus, an application located in +.i somedir/app +could be compiled with +.ip +.in +4n +.ex +gcc \-wl,\-rpath,\(aq$origin/../lib\(aq +.ee +.in +.ip +so that it finds an associated shared object in +.i somedir/lib +no matter where +.i somedir +is located in the directory hierarchy. +this facilitates the creation of "turn-key" applications that +do not need to be installed into special directories, +but can instead be unpacked into any directory +and still find their own shared objects. +.tp +.ir $lib " (or equivalently " ${lib} ) +this expands to +.i lib +or +.i lib64 +depending on the architecture +(e.g., on x86-64, it expands to +.ir lib64 +and +on x86-32, it expands to +.ir lib ). +.tp +.ir $platform " (or equivalently " ${platform} ) +this expands to a string corresponding to the processor type +of the host system (e.g., "x86_64"). +on some architectures, the linux kernel doesn't provide a platform +string to the dynamic linker. +the value of this string is taken from the +.br at_platform +value in the auxiliary vector (see +.br getauxval (3)). +.\" to get an idea of the places that $platform would match, +.\" look at the output of the following: +.\" +.\" mkdir /tmp/d +.\" ld_library_path=/tmp/d strace -e open /bin/date 2>&1 | grep /tmp/d +.\" +.\" ld.so lets names be abbreviated, so $o will work for $origin; +.\" don't do this!! +.pp +note that the dynamic string tokens have to be quoted properly when +set from a shell, +to prevent their expansion as shell or environment variables. +.sh options +.tp +.br \-\-argv0 " \fistring\fp (since glibc 2.33)" +set +.i argv[0] +to the value +.i string +before running the program. +.tp +.bi \-\-audit " list" +use objects named in +.i list +as auditors. +the objects in +.i list +are delimited by colons. +.tp +.b \-\-inhibit\-cache +do not use +.ir /etc/ld.so.cache . +.tp +.bi \-\-library\-path " path" +use +.i path +instead of +.b ld_library_path +environment variable setting (see below). +the names +.ir origin , +.ir lib , +and +.ir platform +are interpreted as for the +.br ld_library_path +environment variable. +.tp +.bi \-\-inhibit\-rpath " list" +ignore rpath and runpath information in object names in +.ir list . +this option is ignored when running in secure-execution mode (see below). +the objects in +.i list +are delimited by colons or spaces. +.tp +.b \-\-list +list all dependencies and how they are resolved. +.tp +.br \-\-list\-tunables " (since 2.33)" +print the names and values of all tunables, +along with the minimum and maximum allowed values. +.tp +.br \-\-preload " \filist\fp (since glibc 2.30)" +preload the objects specified in +.ir list . +the objects in +.i list +are delimited by colons or spaces. +the objects are preloaded as explained in the description of the +.br ld_preload +environment variable below. +.ip +by contrast with +.br ld_preload , +the +.br \-\-preload +option provides a way to perform preloading for a single executable +without affecting preloading performed in any child process that executes +a new program. +.tp +.b \-\-verify +verify that program is dynamically linked and this dynamic linker can handle +it. +.sh environment +various environment variables influence the operation of the dynamic linker. +.\" +.ss secure-execution mode +for security reasons, +if the dynamic linker determines that a binary should be +run in secure-execution mode, +the effects of some environment variables are voided or modified, +and furthermore those environment variables are stripped from the environment, +so that the program does not even see the definitions. +some of these environment variables affect the operation of +the dynamic linker itself, and are described below. +other environment variables treated in this way include: +.br gconv_path , +.br getconf_dir , +.br hostaliases , +.br localdomain , +.br locpath , +.br malloc_trace , +.br nis_path , +.br nlspath , +.br resolv_host_conf , +.br res_options , +.br tmpdir , +and +.br tzdir . +.pp +a binary is executed in secure-execution mode if the +.b at_secure +entry in the auxiliary vector (see +.br getauxval (3)) +has a nonzero value. +this entry may have a nonzero value for various reasons, including: +.ip * 3 +the process's real and effective user ids differ, +or the real and effective group ids differ. +this typically occurs as a result of executing +a set-user-id or set-group-id program. +.ip * +a process with a non-root user id executed a binary that +conferred capabilities to the process. +.ip * +a nonzero value may have been set by a linux security module. +.\" +.ss environment variables +among the more important environment variables are the following: +.tp +.br ld_assume_kernel " (since glibc 2.2.3)" +each shared object can inform the dynamic linker of the minimum kernel abi +version that it requires. +(this requirement is encoded in an elf note section that is viewable via +.ir "readelf\ \-n" +as a section labeled +.br nt_gnu_abi_tag .) +at run time, +the dynamic linker determines the abi version of the running kernel and +will reject loading shared objects that specify minimum abi versions +that exceed that abi version. +.ip +.br ld_assume_kernel +can be used to +cause the dynamic linker to assume that it is running on a system with +a different kernel abi version. +for example, the following command line causes the +dynamic linker to assume it is running on linux 2.2.5 when loading +the shared objects required by +.ir myprog : +.ip +.in +4n +.ex +$ \fbld_assume_kernel=2.2.5 ./myprog\fp +.ee +.in +.ip +on systems that provide multiple versions of a shared object +(in different directories in the search path) that have +different minimum kernel abi version requirements, +.br ld_assume_kernel +can be used to select the version of the object that is used +(dependent on the directory search order). +.ip +historically, the most common use of the +.br ld_assume_kernel +feature was to manually select the older +linuxthreads posix threads implementation on systems that provided both +linuxthreads and nptl +(which latter was typically the default on such systems); +see +.br pthreads (7). +.tp +.br ld_bind_now " (since glibc 2.1.1)" +if set to a nonempty string, +causes the dynamic linker to resolve all symbols +at program startup instead of deferring function call resolution to the point +when they are first referenced. +this is useful when using a debugger. +.tp +.b ld_library_path +a list of directories in which to search for +elf libraries at execution time. +the items in the list are separated by either colons or semicolons, +and there is no support for escaping either separator. +a zero-length directory name indicates the current working directory. +.ip +this variable is ignored in secure-execution mode. +.ip +within the pathnames specified in +.br ld_library_path , +the dynamic linker expands the tokens +.ir $origin , +.ir $lib , +and +.ir $platform +(or the versions using curly braces around the names) +as described above in +.ir "dynamic string tokens" . +thus, for example, +the following would cause a library to be searched for in either the +.i lib +or +.i lib64 +subdirectory below the directory containing the program to be executed: +.ip +.in +4n +.ex +$ \fbld_library_path=\(aq$origin/$lib\(aq prog\fp +.ee +.in +.ip +(note the use of single quotes, which prevent expansion of +.i $origin +and +.i $lib +as shell variables!) +.tp +.b ld_preload +a list of additional, user-specified, elf shared +objects to be loaded before all others. +this feature can be used to selectively override functions +in other shared objects. +.ip +the items of the list can be separated by spaces or colons, +and there is no support for escaping either separator. +the objects are searched for using the rules given under description. +objects are searched for and added to the link map in the left-to-right +order specified in the list. +.ip +in secure-execution mode, +preload pathnames containing slashes are ignored. +furthermore, shared objects are preloaded only +from the standard search directories and only +if they have set-user-id mode bit enabled (which is not typical). +.ip +within the names specified in the +.br ld_preload +list, the dynamic linker understands the tokens +.ir $origin , +.ir $lib , +and +.ir $platform +(or the versions using curly braces around the names) +as described above in +.ir "dynamic string tokens" . +(see also the discussion of quoting under the description of +.br ld_library_path .) +.\" tested with the following: +.\" +.\" ld_preload='$lib/libmod.so' ld_library_path=. ./prog +.\" +.\" which will preload the libmod.so in 'lib' or 'lib64', using it +.\" in preference to the version in '.'. +.ip +there are various methods of specifying libraries to be preloaded, +and these are handled in the following order: +.rs +.ip (1) 4 +the +.br ld_preload +environment variable. +.ip (2) +the +.b \-\-preload +command-line option when invoking the dynamic linker directly. +.ip (3) +the +.i /etc/ld.so.preload +file (described below). +.re +.tp +.br ld_trace_loaded_objects +if set (to any value), causes the program to list its dynamic +dependencies, as if run by +.br ldd (1), +instead of running normally. +.pp +then there are lots of more or less obscure variables, +many obsolete or only for internal use. +.tp +.br ld_audit " (since glibc 2.4)" +a list of user-specified, elf shared objects +to be loaded before all others in a separate linker namespace +(i.e., one that does not intrude upon the normal symbol bindings that +would occur in the process) +these objects can be used to audit the operation of the dynamic linker. +the items in the list are colon-separated, +and there is no support for escaping the separator. +.ip +.b ld_audit +is ignored in secure-execution mode. +.ip +the dynamic linker will notify the audit +shared objects at so-called auditing checkpoints\(emfor example, +loading a new shared object, resolving a symbol, +or calling a symbol from another shared object\(emby +calling an appropriate function within the audit shared object. +for details, see +.br rtld\-audit (7). +the auditing interface is largely compatible with that provided on solaris, +as described in its +.ir "linker and libraries guide" , +in the chapter +.ir "runtime linker auditing interface" . +.ip +within the names specified in the +.br ld_audit +list, the dynamic linker understands the tokens +.ir $origin , +.ir $lib , +and +.ir $platform +(or the versions using curly braces around the names) +as described above in +.ir "dynamic string tokens" . +(see also the discussion of quoting under the description of +.br ld_library_path .) +.ip +since glibc 2.13, +.\" commit 8e9f92e9d5d7737afdacf79b76d98c4c42980508 +in secure-execution mode, +names in the audit list that contain slashes are ignored, +and only shared objects in the standard search directories that +have the set-user-id mode bit enabled are loaded. +.tp +.br ld_bind_not " (since glibc 2.1.95)" +if this environment variable is set to a nonempty string, +do not update the got (global offset table) and plt (procedure linkage table) +after resolving a function symbol. +by combining the use of this variable with +.br ld_debug +(with the categories +.ir bindings +and +.ir symbols ), +one can observe all run-time function bindings. +.tp +.br ld_debug " (since glibc 2.1)" +output verbose debugging information about operation of the dynamic linker. +the content of this variable is one of more of the following categories, +separated by colons, commas, or (if the value is quoted) spaces: +.rs +.tp 12 +.i help +specifying +.ir help +in the value of this variable does not run the specified program, +and displays a help message about which categories can be specified in this +environment variable. +.tp +.i all +print all debugging information (except +.ir statistics +and +.ir unused ; +see below). +.tp +.i bindings +display information about which definition each symbol is bound to. +.tp +.i files +display progress for input file. +.tp +.i libs +display library search paths. +.tp +.i reloc +display relocation processing. +.tp +.i scopes +display scope information. +.tp +.i statistics +display relocation statistics. +.tp +.i symbols +display search paths for each symbol look-up. +.tp +.i unused +determine unused dsos. +.tp +.i versions +display version dependencies. +.re +.ip +since glibc 2.3.4, +.b ld_debug +is ignored in secure-execution mode, unless the file +.ir /etc/suid\-debug +exists (the content of the file is irrelevant). +.tp +.br ld_debug_output " (since glibc 2.1)" +by default, +.b ld_debug +output is written to standard error. +if +.b ld_debug_output +is defined, then output is written to the pathname specified by its value, +with the suffix "." (dot) followed by the process id appended to the pathname. +.ip +.b ld_debug_output +is ignored in secure-execution mode. +.tp +.br ld_dynamic_weak " (since glibc 2.1.91)" +by default, when searching shared libraries to resolve a symbol reference, +the dynamic linker will resolve to the first definition it finds. +.ip +old glibc versions (before 2.2), provided a different behavior: +if the linker found a symbol that was weak, +it would remember that symbol and +keep searching in the remaining shared libraries. +if it subsequently found a strong definition of the same symbol, +then it would instead use that definition. +(if no further symbol was found, +then the dynamic linker would use the weak symbol that it initially found.) +.ip +the old glibc behavior was nonstandard. +(standard practice is that the distinction between +weak and strong symbols should have effect only at static link time.) +in glibc 2.2, +.\" more precisely 2.1.92 +.\" see weak handling +.\" https://www.sourceware.org/ml/libc-hacker/2000-06/msg00029.html +.\" to: gnu libc hacker +.\" subject: weak handling +.\" from: ulrich drepper +.\" date: 07 jun 2000 20:08:12 -0700 +.\" reply-to: drepper at cygnus dot com (ulrich drepper) +the dynamic linker was modified to provide the current behavior +(which was the behavior that was provided by most other implementations +at that time). +.ip +defining the +.b ld_dynamic_weak +environment variable (with any value) provides +the old (nonstandard) glibc behavior, +whereby a weak symbol in one shared library may be overridden by +a strong symbol subsequently discovered in another shared library. +(note that even when this variable is set, +a strong symbol in a shared library will not override +a weak definition of the same symbol in the main program.) +.ip +since glibc 2.3.4, +.b ld_dynamic_weak +is ignored in secure-execution mode. +.tp +.br ld_hwcap_mask " (since glibc 2.1)" +mask for hardware capabilities. +.tp +.br ld_origin_path " (since glibc 2.1)" +path where the binary is found. +.\" used only if $origin can't be determined by normal means +.\" (from the origin path saved at load time, or from /proc/self/exe)? +.ip +since glibc 2.4, +.b ld_origin_path +is ignored in secure-execution mode. +.tp +.br ld_pointer_guard " (glibc from 2.4 to 2.22)" +set to 0 to disable pointer guarding. +any other value enables pointer guarding, which is also the default. +pointer guarding is a security mechanism whereby some pointers to code +stored in writable program memory (return addresses saved by +.br setjmp (3) +or function pointers used by various glibc internals) are mangled +semi-randomly to make it more difficult for an attacker to hijack +the pointers for use in the event of a buffer overrun or +stack-smashing attack. +since glibc 2.23, +.\" commit a014cecd82b71b70a6a843e250e06b541ad524f7 +.b ld_pointer_guard +can no longer be used to disable pointer guarding, +which is now always enabled. +.tp +.br ld_profile " (since glibc 2.1)" +the name of a (single) shared object to be profiled, +specified either as a pathname or a soname. +profiling output is appended to the file whose name is: +"\fi$ld_profile_output\fp/\fi$ld_profile\fp.profile". +.ip +since glibc 2.2.5, +.br ld_profile +is ignored in secure-execution mode. +.tp +.br ld_profile_output " (since glibc 2.1)" +directory where +.b ld_profile +output should be written. +if this variable is not defined, or is defined as an empty string, +then the default is +.ir /var/tmp . +.ip +.b ld_profile_output +is ignored in secure-execution mode; instead +.ir /var/profile +is always used. +(this detail is relevant only before glibc 2.2.5, +since in later glibc versions, +.b ld_profile +is also ignored in secure-execution mode.) +.tp +.br ld_show_auxv " (since glibc 2.1)" +if this environment variable is defined (with any value), +show the auxiliary array passed up from the kernel (see also +.br getauxval (3)). +.ip +since glibc 2.3.4, +.b ld_show_auxv +is ignored in secure-execution mode. +.tp +.br ld_trace_prelinking " (since glibc 2.4)" +if this environment variable is defined, +trace prelinking of the object whose name is assigned to +this environment variable. +(use +.br ldd (1) +to get a list of the objects that might be traced.) +if the object name is not recognized, +.\" (this is what seems to happen, from experimenting) +then all prelinking activity is traced. +.tp +.br ld_use_load_bias " (since glibc 2.3.3)" +.\" http://sources.redhat.com/ml/libc-hacker/2003-11/msg00127.html +.\" subject: [patch] support ld_use_load_bias +.\" jakub jelinek +by default (i.e., if this variable is not defined), +executables and prelinked +shared objects will honor base addresses of their dependent shared objects +and (nonprelinked) position-independent executables (pies) +and other shared objects will not honor them. +if +.b ld_use_load_bias +is defined with the value 1, both executables and pies +will honor the base addresses. +if +.b ld_use_load_bias +is defined with the value 0, +neither executables nor pies will honor the base addresses. +.ip +since glibc 2.3.3, this variable is ignored in secure-execution mode. +.tp +.br ld_verbose " (since glibc 2.1)" +if set to a nonempty string, +output symbol versioning information about the +program if the +.b ld_trace_loaded_objects +environment variable has been set. +.tp +.br ld_warn " (since glibc 2.1.3)" +if set to a nonempty string, warn about unresolved symbols. +.tp +.br ld_prefer_map_32bit_exec " (x86-64 only; since glibc 2.23)" +according to the intel silvermont software optimization guide, for 64-bit +applications, branch prediction performance can be negatively impacted +when the target of a branch is more than 4\ gb away from the branch. +if this environment variable is set (to any value), +the dynamic linker +will first try to map executable pages using the +.br mmap (2) +.br map_32bit +flag, and fall back to mapping without that flag if that attempt fails. +nb: map_32bit will map to the low 2\ gb (not 4\ gb) of the address space. +.ip +because +.b map_32bit +reduces the address range available for address space layout +randomization (aslr), +.b ld_prefer_map_32bit_exec +is always disabled in secure-execution mode. +.sh files +.tp +.i /lib/ld.so +a.out dynamic linker/loader +.tp +.ir /lib/ld\-linux.so. { 1 , 2 } +elf dynamic linker/loader +.tp +.i /etc/ld.so.cache +file containing a compiled list of directories in which to search for +shared objects and an ordered list of candidate shared objects. +see +.br ldconfig (8). +.tp +.i /etc/ld.so.preload +file containing a whitespace-separated list of elf shared objects to +be loaded before the program. +see the discussion of +.br ld_preload +above. +if both +.br ld_preload +and +.i /etc/ld.so.preload +are employed, the libraries specified by +.br ld_preload +are preloaded first. +.i /etc/ld.so.preload +has a system-wide effect, +causing the specified libraries to be preloaded for +all programs that are executed on the system. +(this is usually undesirable, +and is typically employed only as an emergency remedy, for example, +as a temporary workaround to a library misconfiguration issue.) +.tp +.i lib*.so* +shared objects +.sh notes +.ss hardware capabilities +some shared objects are compiled using hardware-specific instructions which do +not exist on every cpu. +such objects should be installed in directories whose names define the +required hardware capabilities, such as +.ir /usr/lib/sse2/ . +the dynamic linker checks these directories against the hardware of the +machine and selects the most suitable version of a given shared object. +hardware capability directories can be cascaded to combine cpu features. +the list of supported hardware capability names depends on the cpu. +the following names are currently recognized: +.\" presumably, this info comes from sysdeps/i386/dl-procinfo.c and +.\" similar files +.tp +.b alpha +ev4, ev5, ev56, ev6, ev67 +.tp +.b mips +loongson2e, loongson2f, octeon, octeon2 +.tp +.b powerpc +4xxmac, altivec, arch_2_05, arch_2_06, booke, cellbe, dfp, efpdouble, efpsingle, +fpu, ic_snoop, mmu, notb, pa6t, power4, power5, power5+, power6x, ppc32, ppc601, +ppc64, smt, spe, ucache, vsx +.tp +.b sparc +flush, muldiv, stbar, swap, ultra3, v9, v9v, v9v2 +.tp +.b s390 +dfp, eimm, esan3, etf3enh, g5, highgprs, hpage, ldisp, msa, stfle, +z900, z990, z9-109, z10, zarch +.tp +.b x86 (32-bit only) +acpi, apic, clflush, cmov, cx8, dts, fxsr, ht, i386, i486, i586, i686, mca, mmx, +mtrr, pat, pbe, pge, pn, pse36, sep, ss, sse, sse2, tm +.sh see also +.br ld (1), +.br ldd (1), +.br pldd (1), +.br sprof (1), +.br dlopen (3), +.br getauxval (3), +.br elf (5), +.br capabilities (7), +.br rtld\-audit (7), +.br ldconfig (8), +.br sln (8) +.\" .sh authors +.\" ld.so: david engel, eric youngdale, peter macdonald, hongjiu lu, linus +.\" torvalds, lars wirzenius and mitch d'souza +.\" ld\-linux.so: roland mcgrath, ulrich drepper and others. +.\" +.\" in the above, (libc5) stands for david engel's ld.so/ld\-linux.so. +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/syslog.2 + +.so man3/crypt.3 + +.so man3/exp2.3 + +.so man3/termios.3 + +.so man3/ilogb.3 + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification +.\" http://www.unix-systems.org/online.html +.\" iso/iec 9899:1999 +.\" +.\" modified tue oct 16 23:18:40 bst 2001 by john levon +.th fgetwc 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +fgetwc, getwc \- read a wide character from a file stream +.sh synopsis +.nf +.b #include +.b #include +.pp +.bi "wint_t fgetwc(file *" stream ); +.bi "wint_t getwc(file *" stream ); +.fi +.sh description +the +.br fgetwc () +function is the wide-character equivalent +of the +.br fgetc (3) +function. +it reads a wide character from \fistream\fp and returns it. +if the end of stream is reached, or if \fiferror(stream)\fp becomes true, +it returns +.br weof . +if a wide-character conversion error occurs, it sets +\fierrno\fp to \fbeilseq\fp and returns +.br weof . +.pp +the +.br getwc () +function or macro functions identically to +.br fgetwc (). +it may be implemented as a macro, and may evaluate its argument +more than once. +there is no reason ever to use it. +.pp +for nonlocking counterparts, see +.br unlocked_stdio (3). +.sh return value +on success, +.br fgetwc () +returns the next wide-character from the stream. +otherwise, +.b weof +is returned, and +.i errno +is set to indicate the error. +.sh errors +apart from the usual ones, there is +.tp +.b eilseq +the data obtained from the input stream does not +form a valid character. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br fgetwc (), +.br getwc () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh notes +the behavior of +.br fgetwc () +depends on the +.b lc_ctype +category of the +current locale. +.pp +in the absence of additional information passed to the +.br fopen (3) +call, it is +reasonable to expect that +.br fgetwc () +will actually read a multibyte sequence +from the stream and then convert it to a wide character. +.sh see also +.br fgetws (3), +.br fputwc (3), +.br ungetwc (3), +.br unlocked_stdio (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2020 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th seccomp_unotify 2 2021-06-20 "linux" "linux programmer's manual" +.sh name +seccomp_unotify \- seccomp user-space notification mechanism +.sh synopsis +.nf +.b #include +.b #include +.b #include +.pp +.bi "int seccomp(unsigned int " operation ", unsigned int " flags \ +", void *" args ); +.pp +.b #include +.pp +.bi "int ioctl(int " fd ", seccomp_ioctl_notif_recv," +.bi " struct seccomp_notif *" req ); +.bi "int ioctl(int " fd ", seccomp_ioctl_notif_send," +.bi " struct seccomp_notif_resp *" resp ); +.bi "int ioctl(int " fd ", seccomp_ioctl_notif_id_valid, __u64 *" id ); +.bi "int ioctl(int " fd ", seccomp_ioctl_notif_addfd," +.bi " struct seccomp_notif_addfd *" addfd ); +.fi +.sh description +this page describes the user-space notification mechanism provided by the +secure computing (seccomp) facility. +as well as the use of the +.b seccomp_filter_flag_new_listener +flag, the +.br seccomp_ret_user_notif +action value, and the +.b seccomp_get_notif_sizes +operation described in +.br seccomp (2), +this mechanism involves the use of a number of related +.br ioctl (2) +operations (described below). +.\" +.ss overview +in conventional usage of a seccomp filter, +the decision about how to treat a system call is made by the filter itself. +by contrast, the user-space notification mechanism allows +the seccomp filter to delegate +the handling of the system call to another user-space process. +note that this mechanism is explicitly +.b not +intended as a method implementing security policy; see notes. +.pp +in the discussion that follows, +the thread(s) on which the seccomp filter is installed is (are) +referred to as the +.ir target , +and the process that is notified by the user-space notification +mechanism is referred to as the +.ir supervisor . +.pp +a suitably privileged supervisor can use the user-space notification +mechanism to perform actions on behalf of the target. +the advantage of the user-space notification mechanism is that +the supervisor will +usually be able to retrieve information about the target and the +performed system call that the seccomp filter itself cannot. +(a seccomp filter is limited in the information it can obtain and +the actions that it can perform because it +is running on a virtual machine inside the kernel.) +.pp +an overview of the steps performed by the target and the supervisor +is as follows: +.\"------------------------------------- +.ip 1. 3 +the target establishes a seccomp filter in the usual manner, +but with two differences: +.rs +.ip \(bu 2 +the +.br seccomp (2) +.i flags +argument includes the flag +.br seccomp_filter_flag_new_listener . +consequently, the return value of the (successful) +.br seccomp (2) +call is a new "listening" +file descriptor that can be used to receive notifications. +only one "listening" seccomp filter can be installed for a thread. +.\" fixme +.\" is the last sentence above correct? +.\" +.\" kees cook (25 oct 2020) notes: +.\" +.\" i like this limitation, but i expect that it'll need to change in the +.\" future. even with lsms, we see the need for arbitrary stacking, and the +.\" idea of there being only 1 supervisor will eventually break down. right +.\" now there is only 1 because only container managers are using this +.\" feature. but if some daemon starts using it to isolate some thread, +.\" suddenly it might break if a container manager is trying to listen to it +.\" too, etc. i expect it won't be needed soon, but i do think it'll change. +.\" +.ip \(bu +in cases where it is appropriate, the seccomp filter returns the action value +.br seccomp_ret_user_notif . +this return value will trigger a notification event. +.re +.\"------------------------------------- +.ip 2. +in order that the supervisor can obtain notifications +using the listening file descriptor, +(a duplicate of) that file descriptor must be passed from +the target to the supervisor. +one way in which this could be done is by passing the file descriptor +over a unix domain socket connection between the target and the supervisor +(using the +.br scm_rights +ancillary message type described in +.br unix (7)). +another way to do this is through the use of +.br pidfd_getfd (2). +.\" jann horn: +.\" instead of using unix domain sockets to send the fd to the +.\" parent, i think you could also use clone3() with +.\" flags==clone_files|sigchld, dup2() the seccomp fd to an fd +.\" that was reserved in the parent, call unshare(clone_files) +.\" in the child after setting up the seccomp fd, and wake +.\" up the parent with something like pthread_cond_signal()? +.\" i'm not sure whether that'd look better or worse in the +.\" end though, so maybe just ignore this comment. +.\"------------------------------------- +.ip 3. +the supervisor will receive notification events +on the listening file descriptor. +these events are returned as structures of type +.ir seccomp_notif . +because this structure and its size may evolve over kernel versions, +the supervisor must first determine the size of this structure +using the +.br seccomp (2) +.b seccomp_get_notif_sizes +operation, which returns a structure of type +.ir seccomp_notif_sizes . +the supervisor allocates a buffer of size +.i seccomp_notif_sizes.seccomp_notif +bytes to receive notification events. +in addition,the supervisor allocates another buffer of size +.i seccomp_notif_sizes.seccomp_notif_resp +bytes for the response (a +.i struct seccomp_notif_resp +structure) +that it will provide to the kernel (and thus the target). +.\"------------------------------------- +.ip 4. +the target then performs its workload, +which includes system calls that will be controlled by the seccomp filter. +whenever one of these system calls causes the filter to return the +.b seccomp_ret_user_notif +action value, the kernel does +.i not +(yet) execute the system call; +instead, execution of the target is temporarily blocked inside +the kernel (in a sleep state that is interruptible by signals) +and a notification event is generated on the listening file descriptor. +.\"------------------------------------- +.ip 5. +the supervisor can now repeatedly monitor the +listening file descriptor for +.br seccomp_ret_user_notif -triggered +events. +to do this, the supervisor uses the +.b seccomp_ioctl_notif_recv +.br ioctl (2) +operation to read information about a notification event; +this operation blocks until an event is available. +the operation returns a +.i seccomp_notif +structure containing information about the system call +that is being attempted by the target. +(as described in notes, +the file descriptor can also be monitored with +.br select (2), +.br poll (2), +or +.br epoll (7).) +.\" fixme +.\" christian brauner: +.\" +.\" do we support o_nonblock with seccomp_ioctl_notif_recv and if +.\" not should we? +.\" +.\" michael kerrisk: +.\" +.\" a quick test suggests that o_nonblock has no effect on the blocking +.\" behavior of seccomp_ioctl_notif_recv. +. +.\"------------------------------------- +.ip 6. +the +.i seccomp_notif +structure returned by the +.b seccomp_ioctl_notif_recv +operation includes the same information (a +.i seccomp_data +structure) that was passed to the seccomp filter. +this information allows the supervisor to discover the system call number and +the arguments for the target's system call. +in addition, the notification event contains the id of the thread +that triggered the notification and a unique cookie value that +is used in subsequent +.b seccomp_ioctl_notif_id_valid +and +.b seccomp_ioctl_notif_send +operations. +.ip +the information in the notification can be used to discover the +values of pointer arguments for the target's system call. +(this is something that can't be done from within a seccomp filter.) +one way in which the supervisor can do this is to open the corresponding +.i /proc/[tid]/mem +file (see +.br proc (5)) +and read bytes from the location that corresponds to one of +the pointer arguments whose value is supplied in the notification event. +.\" tycho andersen mentioned that there are alternatives to /proc/pid/mem, +.\" such as ptrace() and /proc/pid/map_files +(the supervisor must be careful to avoid +a race condition that can occur when doing this; +see the description of the +.br seccomp_ioctl_notif_id_valid +.br ioctl (2) +operation below.) +in addition, +the supervisor can access other system information that is visible +in user space but which is not accessible from a seccomp filter. +.\"------------------------------------- +.ip 7. +having obtained information as per the previous step, +the supervisor may then choose to perform an action in response +to the target's system call +(which, as noted above, is not executed when the seccomp filter returns the +.b seccomp_ret_user_notif +action value). +.ip +one example use case here relates to containers. +the target may be located inside a container where +it does not have sufficient capabilities to mount a filesystem +in the container's mount namespace. +however, the supervisor may be a more privileged process that +does have sufficient capabilities to perform the mount operation. +.\"------------------------------------- +.ip 8. +the supervisor then sends a response to the notification. +the information in this response is used by the kernel to construct +a return value for the target's system call and provide +a value that will be assigned to the +.i errno +variable of the target. +.ip +the response is sent using the +.b seccomp_ioctl_notif_send +.br ioctl (2) +operation, which is used to transmit a +.i seccomp_notif_resp +structure to the kernel. +this structure includes a cookie value that the supervisor obtained in the +.i seccomp_notif +structure returned by the +.b seccomp_ioctl_notif_recv +operation. +this cookie value allows the kernel to associate the response with the +target. +this structure must include the cookie value that the supervisor +obtained in the +.i seccomp_notif +structure returned by the +.b seccomp_ioctl_notif_recv +operation; +the cookie allows the kernel to associate the response with the target. +.\"------------------------------------- +.ip 9. +once the notification has been sent, +the system call in the target thread unblocks, +returning the information that was provided by the supervisor +in the notification response. +.\"------------------------------------- +.pp +as a variation on the last two steps, +the supervisor can send a response that tells the kernel that it +should execute the target thread's system call; see the discussion of +.br seccomp_user_notif_flag_continue , +below. +.\" +.sh ioctl operations +the following +.br ioctl (2) +operations are supported by the seccomp user-space +notification file descriptor. +for each of these operations, the first (file descriptor) argument of +.br ioctl (2) +is the listening file descriptor returned by a call to +.br seccomp (2) +with the +.br seccomp_filter_flag_new_listener +flag. +.\" +.ss seccomp_ioctl_notif_recv +the +.b seccomp_ioctl_notif_recv +operation (available since linux 5.0) is used to obtain a user-space +notification event. +if no such event is currently pending, +the operation blocks until an event occurs. +the third +.br ioctl (2) +argument is a pointer to a structure of the following form +which contains information about the event. +this structure must be zeroed out before the call. +.pp +.in +4n +.ex +struct seccomp_notif { + __u64 id; /* cookie */ + __u32 pid; /* tid of target thread */ + __u32 flags; /* currently unused (0) */ + struct seccomp_data data; /* see seccomp(2) */ +}; +.ee +.in +.pp +the fields in this structure are as follows: +.tp +.i id +this is a cookie for the notification. +each such cookie is guaranteed to be unique for the corresponding +seccomp filter. +.rs +.ip \(bu 2 +the cookie can be used with the +.b seccomp_ioctl_notif_id_valid +.br ioctl (2) +operation described below. +.ip \(bu +when returning a notification response to the kernel, +the supervisor must include the cookie value in the +.ir seccomp_notif_resp +structure that is specified as the argument of the +.br seccomp_ioctl_notif_send +operation. +.re +.tp +.i pid +this is the thread id of the target thread that triggered +the notification event. +.tp +.i flags +this is a bit mask of flags providing further information on the event. +in the current implementation, this field is always zero. +.tp +.i data +this is a +.i seccomp_data +structure containing information about the system call that +triggered the notification. +this is the same structure that is passed to the seccomp filter. +see +.br seccomp (2) +for details of this structure. +.pp +on success, this operation returns 0; on failure, \-1 is returned, and +.i errno +is set to indicate the cause of the error. +this operation can fail with the following errors: +.tp +.br einval " (since linux 5.5)" +.\" commit 2882d53c9c6f3b8311d225062522f03772cf0179 +the +.i seccomp_notif +structure that was passed to the call contained nonzero fields. +.tp +.b enoent +the target thread was killed by a signal as the notification information +was being generated, +or the target's (blocked) system call was interrupted by a signal handler. +.\" fixme +.\" from my experiments, +.\" it appears that if a seccomp_ioctl_notif_recv is done after +.\" the target thread terminates, then the ioctl() simply +.\" blocks (rather than returning an error to indicate that the +.\" target no longer exists). +.\" +.\" i found that surprising, and it required some contortions in +.\" the example program. it was not possible to code my sigchld +.\" handler (which reaps the zombie when the worker/target +.\" terminates) to simply set a flag checked in the main +.\" handlenotifications() loop, since this created an +.\" unavoidable race where the child might terminate just after +.\" i had checked the flag, but before i blocked (forever!) in the +.\" seccomp_ioctl_notif_recv operation. instead, i had to code +.\" the signal handler to simply call _exit(2) in order to +.\" terminate the parent process (the supervisor). +.\" +.\" is this expected behavior? it seems to me rather +.\" desirable that seccomp_ioctl_notif_recv should give an error +.\" if the target has terminated. +.\" +.\" jann posted a patch to rectify this, but there was no response +.\" (lore link: https://bit.ly/3jvubxk) to his question about fixing +.\" this issue. (i've tried building with the patch, but encountered +.\" an issue with the target process entering d state after a signal.) +.\" +.\" for now, this behavior is documented in bugs. +.\" +.\" kees cook commented: let's change [this] asap! +.\" +.ss seccomp_ioctl_notif_id_valid +the +.b seccomp_ioctl_notif_id_valid +operation (available since linux 5.0) is used to check that a notification id +returned by an earlier +.b seccomp_ioctl_notif_recv +operation is still valid +(i.e., that the target still exists and its system call +is still blocked waiting for a response). +.pp +the third +.br ioctl (2) +argument is a pointer to the cookie +.ri ( id ) +returned by the +.b seccomp_ioctl_notif_recv +operation. +.pp +this operation is necessary to avoid race conditions that can occur when the +.i pid +returned by the +.b seccomp_ioctl_notif_recv +operation terminates, and that process id is reused by another process. +an example of this kind of race is the following +.ip 1. 3 +a notification is generated on the listening file descriptor. +the returned +.i seccomp_notif +contains the tid of the target thread (in the +.i pid +field of the structure). +.ip 2. +the target terminates. +.ip 3. +another thread or process is created on the system that by chance reuses the +tid that was freed when the target terminated. +.ip 4. +the supervisor +.br open (2)s +the +.ir /proc/[tid]/mem +file for the tid obtained in step 1, with the intention of (say) +inspecting the memory location(s) that containing the argument(s) of +the system call that triggered the notification in step 1. +.pp +in the above scenario, the risk is that the supervisor may try +to access the memory of a process other than the target. +this race can be avoided by following the call to +.br open (2) +with a +.b seccomp_ioctl_notif_id_valid +operation to verify that the process that generated the notification +is still alive. +(note that if the target terminates after the latter step, +a subsequent +.br read (2) +from the file descriptor may return 0, indicating end of file.) +.\" jann horn: +.\" the pid can be reused, but the /proc/$pid directory is +.\" internally not associated with the numeric pid, but, +.\" conceptually speaking, with a specific incarnation of the +.\" pid, or something like that. (actually, it is associated +.\" with the "struct pid", which is not reused, instead of the +.\" numeric pid. +.pp +see notes for a discussion of other cases where +.b seccomp_ioctl_notif_id_valid +checks must be performed. +.pp +on success (i.e., the notification id is still valid), +this operation returns 0. +on failure (i.e., the notification id is no longer valid), +\-1 is returned, and +.i errno +is set to +.br enoent . +.\" +.ss seccomp_ioctl_notif_send +the +.b seccomp_ioctl_notif_send +operation (available since linux 5.0) +is used to send a notification response back to the kernel. +the third +.br ioctl (2) +argument of this structure is a pointer to a structure of the following form: +.pp +.in +4n +.ex +struct seccomp_notif_resp { + __u64 id; /* cookie value */ + __s64 val; /* success return value */ + __s32 error; /* 0 (success) or negative error number */ + __u32 flags; /* see below */ +}; +.ee +.in +.pp +the fields of this structure are as follows: +.tp +.i id +this is the cookie value that was obtained using the +.b seccomp_ioctl_notif_recv +operation. +this cookie value allows the kernel to correctly associate this response +with the system call that triggered the user-space notification. +.tp +.i val +this is the value that will be used for a spoofed +success return for the target's system call; see below. +.tp +.i error +this is the value that will be used as the error number +.ri ( errno ) +for a spoofed error return for the target's system call; see below. +.tp +.i flags +this is a bit mask that includes zero or more of the following flags: +.rs +.tp +.br seccomp_user_notif_flag_continue " (since linux 5.5)" +tell the kernel to execute the target's system call. +.\" commit fb3c5386b382d4097476ce9647260fc89b34afdb +.re +.pp +two kinds of response are possible: +.ip \(bu 2 +a response to the kernel telling it to execute the +target's system call. +in this case, the +.i flags +field includes +.b seccomp_user_notif_flag_continue +and the +.i error +and +.i val +fields must be zero. +.ip +this kind of response can be useful in cases where the supervisor needs +to do deeper analysis of the target's system call than is possible +from a seccomp filter (e.g., examining the values of pointer arguments), +and, having decided that the system call does not require emulation +by the supervisor, the supervisor wants the system call to +be executed normally in the target. +.ip +the +.b seccomp_user_notif_flag_continue +flag should be used with caution; see notes. +.ip \(bu +a spoofed return value for the target's system call. +in this case, the kernel does not execute the target's system call, +instead causing the system call to return a spoofed value as specified by +fields of the +.i seccomp_notif_resp +structure. +the supervisor should set the fields of this structure as follows: +.rs +.ip + 3 +.i flags +does not contain +.br seccomp_user_notif_flag_continue . +.ip + +.i error +is set either to 0 for a spoofed "success" return or to a negative +error number for a spoofed "failure" return. +in the former case, the kernel causes the target's system call +to return the value specified in the +.i val +field. +in the latter case, the kernel causes the target's system call +to return \-1, and +.i errno +is assigned the negated +.i error +value. +.ip + +.i val +is set to a value that will be used as the return value for a spoofed +"success" return for the target's system call. +the value in this field is ignored if the +.i error +field contains a nonzero value. +.\" fixme +.\" kees cook suggested: +.\" +.\" strictly speaking, this is architecture specific, but +.\" all architectures do it this way. should seccomp enforce +.\" val == 0 when err != 0 ? +.\" +.\" christian brauner +.\" +.\" feels like it should, at least for the send ioctl where we already +.\" verify that val and err are both 0 when continue is specified (as you +.\" pointed out correctly above). +.re +.pp +on success, this operation returns 0; on failure, \-1 is returned, and +.i errno +is set to indicate the cause of the error. +this operation can fail with the following errors: +.tp +.b einprogress +a response to this notification has already been sent. +.tp +.b einval +an invalid value was specified in the +.i flags field. +.tp +.b +.b einval +the +.i flags +field contained +.br seccomp_user_notif_flag_continue , +and the +.i error +or +.i val +field was not zero. +.tp +.b enoent +the blocked system call in the target +has been interrupted by a signal handler +or the target has terminated. +.\" jann horn notes: +.\" you could also get this [enoent] if a response has already +.\" been sent, instead of einprogress - the only difference is +.\" whether the target thread has picked up the response yet +.\" +.ss seccomp_ioctl_notif_addfd +the +.b seccomp_ioctl_notif_addfd +operation (available since linux 5.9) +allows the supervisor to install a file descriptor +into the target's file descriptor table. +much like the use of +.br scm_rights +messages described in +.br unix (7), +this operation is semantically equivalent to duplicating +a file descriptor from the supervisor's file descriptor table +into the target's file descriptor table. +.pp +the +.br seccomp_ioctl_notif_addfd +operation permits the supervisor to emulate a target system call (such as +.br socket (2) +or +.br openat (2)) +that generates a file descriptor. +the supervisor can perform the system call that generates +the file descriptor (and associated open file description) +and then use this operation to allocate +a file descriptor that refers to the same open file description in the target. +(for an explanation of open file descriptions, see +.br open (2).) +.pp +once this operation has been performed, +the supervisor can close its copy of the file descriptor. +.pp +in the target, +the received file descriptor is subject to the same +linux security module (lsm) checks as are applied to a file descriptor +that is received in an +.br scm_rights +ancillary message. +if the file descriptor refers to a socket, +it inherits the cgroup version 1 network controller settings +.ri ( classid +and +.ir netprioidx ) +of the target. +.pp +the third +.br ioctl (2) +argument is a pointer to a structure of the following form: +.pp +.in +4n +.ex +struct seccomp_notif_addfd { + __u64 id; /* cookie value */ + __u32 flags; /* flags */ + __u32 srcfd; /* local file descriptor number */ + __u32 newfd; /* 0 or desired file descriptor + number in target */ + __u32 newfd_flags; /* flags to set on target file + descriptor */ +}; +.ee +.in +.pp +the fields in this structure are as follows: +.tp +.i id +this field should be set to the notification id +(cookie value) that was obtained via +.br seccomp_ioctl_notif_recv . +.tp +.i flags +this field is a bit mask of flags that modify the behavior of the operation. +currently, only one flag is supported: +.rs +.tp +.br seccomp_addfd_flag_setfd +when allocating the file descriptor in the target, +use the file descriptor number specified in the +.i newfd +field. +.tp +.br seccomp_addfd_flag_send " (since linux 5.14)" +.\" commit 0ae71c7720e3ae3aabd2e8a072d27f7bd173d25c +perform the equivalent of +.b seccomp_ioctl_notif_addfd +plus +.b seccomp_ioctl_notif_send +as an atomic operation. +on successful invocation, the target process's +.i errno +will be 0 +and the return value will be the file descriptor number +that was allocated in the target. +if allocating the file descriptor in the target fails, +the target's system call continues to be blocked +until a successful response is sent. +.re +.tp +.i srcfd +this field should be set to the number of the file descriptor +in the supervisor that is to be duplicated. +.tp +.i newfd +this field determines which file descriptor number is allocated in the target. +if the +.br seccomp_addfd_flag_setfd +flag is set, +then this field specifies which file descriptor number should be allocated. +if this file descriptor number is already open in the target, +it is atomically closed and reused. +if the descriptor duplication fails due to an lsm check, or if +.i srcfd +is not a valid file descriptor, +the file descriptor +.i newfd +will not be closed in the target process. +.ip +if the +.br seccomp_addfd_flag_setfd +flag it not set, then this field must be 0, +and the kernel allocates the lowest unused file descriptor number +in the target. +.tp +.i newfd_flags +this field is a bit mask specifying flags that should be set on +the file descriptor that is received in the target process. +currently, only the following flag is implemented: +.rs +.tp +.b o_cloexec +set the close-on-exec flag on the received file descriptor. +.re +.pp +on success, this +.br ioctl (2) +call returns the number of the file descriptor that was allocated +in the target. +assuming that the emulated system call is one that returns +a file descriptor as its function result (e.g., +.br socket (2)), +this value can be used as the return value +.ri ( resp.val ) +that is supplied in the response that is subsequently sent with the +.br seccomp_ioctl_notif_send +operation. +.pp +on error, \-1 is returned and +.i errno +is set to indicate the cause of the error. +.pp +this operation can fail with the following errors: +.tp +.b ebadf +allocating the file descriptor in the target would cause the target's +.br rlimit_nofile +limit to be exceeded (see +.br getrlimit (2)). +.tp +.b ebusy +if the flag +.b seccomp_ioctl_notif_send +is used, this means the operation can't proceed until other +.b seccomp_ioctl_notif_addfd +requests are processed. +.tp +.b einprogress +the user-space notification specified in the +.i id +field exists but has not yet been fetched (by a +.br seccomp_ioctl_notif_recv ) +or has already been responded to (by a +.br seccomp_ioctl_notif_send ). +.tp +.b einval +an invalid flag was specified in the +.i flags +or +.i newfd_flags +field, or the +.i newfd +field is nonzero and the +.b seccomp_addfd_flag_setfd +flag was not specified in the +.i flags +field. +.tp +.b emfile +the file descriptor number specified in +.i newfd +exceeds the limit specified in +.ir /proc/sys/fs/nr_open . +.tp +.b enoent +the blocked system call in the target +has been interrupted by a signal handler +or the target has terminated. +.pp +here is some sample code (with error handling omitted) that uses the +.b seccomp_addfd_flag_setfd +operation (here, to emulate a call to +.br openat (2)): +.pp +.ex +.in +4n +int fd, removefd; + +fd = openat(req->data.args[0], path, req->data.args[2], + req->data.args[3]); + +struct seccomp_notif_addfd addfd; +addfd.id = req->id; /* cookie from seccomp_ioctl_notif_recv */ +addfd.srcfd = fd; +addfd.newfd = 0; +addfd.flags = 0; +addfd.newfd_flags = o_cloexec; + +targetfd = ioctl(notifyfd, seccomp_ioctl_notif_addfd, &addfd); + +close(fd); /* no longer needed in supervisor */ + +struct seccomp_notif_resp *resp; + /* code to allocate 'resp' omitted */ +resp->id = req->id; +resp->error = 0; /* "success" */ +resp->val = targetfd; +resp->flags = 0; +ioctl(notifyfd, seccomp_ioctl_notif_send, resp); +.in +.ee +.sh notes +one example use case for the user-space notification +mechanism is to allow a container manager +(a process which is typically running with more privilege than +the processes inside the container) +to mount block devices or create device nodes for the container. +the mount use case provides an example of where the +.br seccomp_user_notif_flag_continue +.br ioctl (2) +operation is useful. +upon receiving a notification for the +.br mount (2) +system call, the container manager (the "supervisor") can distinguish +a request to mount a block filesystem +(which would not be possible for a "target" process inside the container) +and mount that file system. +if, on the other hand, the container manager detects that the operation +could be performed by the process inside the container +(e.g., a mount of a +.br tmpfs (5) +filesystem), it can notify the kernel that the target process's +.br mount (2) +system call can continue. +.\" +.ss select()/poll()/epoll semantics +the file descriptor returned when +.br seccomp (2) +is employed with the +.b seccomp_filter_flag_new_listener +flag can be monitored using +.br poll (2), +.br epoll (7), +and +.br select (2). +these interfaces indicate that the file descriptor is ready as follows: +.ip \(bu 2 +when a notification is pending, +these interfaces indicate that the file descriptor is readable. +following such an indication, a subsequent +.b seccomp_ioctl_notif_recv +.br ioctl (2) +will not block, returning either information about a notification +or else failing with the error +.b eintr +if the target has been killed by a signal or its system call +has been interrupted by a signal handler. +.ip \(bu +after the notification has been received (i.e., by the +.b seccomp_ioctl_notif_recv +.br ioctl (2) +operation), these interfaces indicate that the file descriptor is writable, +meaning that a notification response can be sent using the +.b seccomp_ioctl_notif_send +.br ioctl (2) +operation. +.ip \(bu +after the last thread using the filter has terminated and been reaped using +.br waitpid (2) +(or similar), +the file descriptor indicates an end-of-file condition (readable in +.br select (2); +.br pollhup / epollhup +in +.br poll (2)/ +.br epoll_wait (2)). +.ss design goals; use of seccomp_user_notif_flag_continue +the intent of the user-space notification feature is +to allow system calls to be performed on behalf of the target. +the target's system call should either be handled by the supervisor or +allowed to continue normally in the kernel (where standard security +policies will be applied). +.pp +.br "note well" : +this mechanism must not be used to make security policy decisions +about the system call, +which would be inherently race-prone for reasons described next. +.pp +the +.b seccomp_user_notif_flag_continue +flag must be used with caution. +if set by the supervisor, the target's system call will continue. +however, there is a time-of-check, time-of-use race here, +since an attacker could exploit the interval of time where the target is +blocked waiting on the "continue" response to do things such as +rewriting the system call arguments. +.pp +note furthermore that a user-space notifier can be bypassed if +the existing filters allow the use of +.br seccomp (2) +or +.br prctl (2) +to install a filter that returns an action value with a higher precedence than +.b seccomp_ret_user_notif +(see +.br seccomp (2)). +.pp +it should thus be absolutely clear that the +seccomp user-space notification mechanism +.b can not +be used to implement a security policy! +it should only ever be used in scenarios where a more privileged process +supervises the system calls of a lesser privileged target to +get around kernel-enforced security restrictions when +the supervisor deems this safe. +in other words, +in order to continue a system call, the supervisor should be sure that +another security mechanism or the kernel itself will sufficiently block +the system call if its arguments are rewritten to something unsafe. +.\" +.ss caveats regarding the use of /proc/[tid]/mem +the discussion above noted the need to use the +.br seccomp_ioctl_notif_id_valid +.br ioctl (2) +when opening the +.ir /proc/[tid]/mem +file of the target +to avoid the possibility of accessing the memory of the wrong process +in the event that the target terminates and its id +is recycled by another (unrelated) thread. +however, the use of this +.br ioctl (2) +operation is also necessary in other situations, +as explained in the following paragraphs. +.pp +consider the following scenario, where the supervisor +tries to read the pathname argument of a target's blocked +.br mount (2) +system call: +.ip \(bu 2 +from one of its functions +.ri ( func() ), +the target calls +.br mount (2), +which triggers a user-space notification and causes the target to block. +.ip \(bu +the supervisor receives the notification, opens +.ir /proc/[tid]/mem , +and (successfully) performs the +.br seccomp_ioctl_notif_id_valid +check. +.ip \(bu +the target receives a signal, which causes the +.br mount (2) +to abort. +.ip \(bu +the signal handler executes in the target, and returns. +.ip \(bu +upon return from the handler, the execution of +.i func() +resumes, and it returns (and perhaps other functions are called, +overwriting the memory that had been used for the stack frame of +.ir func() ). +.ip \(bu +using the address provided in the notification information, +the supervisor reads from the target's memory location that used to +contain the pathname. +.ip \(bu +the supervisor now calls +.br mount (2) +with some arbitrary bytes obtained in the previous step. +.pp +the conclusion from the above scenario is this: +since the target's blocked system call may be interrupted by a signal handler, +the supervisor must be written to expect that the +target may abandon its system call at +.b any +time; +in such an event, any information that the supervisor obtained from +the target's memory must be considered invalid. +.pp +to prevent such scenarios, +every read from the target's memory must be separated from use of +the bytes so obtained by a +.br seccomp_ioctl_notif_id_valid +check. +in the above example, the check would be placed between the two final steps. +an example of such a check is shown in examples. +.pp +following on from the above, it should be clear that +a write by the supervisor into the target's memory can +.b never +be considered safe. +.\" +.ss caveats regarding blocking system calls +suppose that the target performs a blocking system call (e.g., +.br accept (2)) +that the supervisor should handle. +the supervisor might then in turn execute the same blocking system call. +.pp +in this scenario, +it is important to note that if the target's system call is now +interrupted by a signal, the supervisor is +.i not +informed of this. +if the supervisor does not take suitable steps to +actively discover that the target's system call has been canceled, +various difficulties can occur. +taking the example of +.br accept (2), +the supervisor might remain blocked in its +.br accept (2) +holding a port number that the target +(which, after the interruption by the signal handler, +perhaps closed its listening socket) might expect to be able to reuse in a +.br bind (2) +call. +.pp +therefore, when the supervisor wishes to emulate a blocking system call, +it must do so in such a way that it gets informed if the target's +system call is interrupted by a signal handler. +for example, if the supervisor itself executes the same +blocking system call, then it could employ a separate thread +that uses the +.b seccomp_ioctl_notif_id_valid +operation to check if the target is still blocked in its system call. +alternatively, in the +.br accept (2) +example, the supervisor might use +.br poll (2) +to monitor both the notification file descriptor +(so as to discover when the target's +.br accept (2) +call has been interrupted) and the listening file descriptor +(so as to know when a connection is available). +.pp +if the target's system call is interrupted, +the supervisor must take care to release resources (e.g., file descriptors) +that it acquired on behalf of the target. +.\" +.ss interaction with sa_restart signal handlers +consider the following scenario: +.ip \(bu 2 +the target process has used +.br sigaction (2) +to install a signal handler with the +.b sa_restart +flag. +.ip \(bu +the target has made a system call that triggered a seccomp +user-space notification and the target is currently blocked +until the supervisor sends a notification response. +.ip \(bu +a signal is delivered to the target and the signal handler is executed. +.ip \(bu +when (if) the supervisor attempts to send a notification response, the +.b seccomp_ioctl_notif_send +.br ioctl (2)) +operation will fail with the +.br enoent +error. +.pp +in this scenario, the kernel will restart the target's system call. +consequently, the supervisor will receive another user-space notification. +thus, depending on how many times the blocked system call +is interrupted by a signal handler, +the supervisor may receive multiple notifications for +the same instance of a system call in the target. +.pp +one oddity is that system call restarting as described in this scenario +will occur even for the blocking system calls listed in +.br signal (7) +that would +.b never +normally be restarted by the +.br sa_restart +flag. +.\" fixme +.\" about the above, kees cook commented: +.\" +.\" does this need fixing? i imagine the correct behavior for this case +.\" would be a response to _send of einprogress and the target would see +.\" eintr normally? +.\" +.\" i mean, it's not like seccomp doesn't already expose weirdness with +.\" syscall restarts. not even arm64 compat agrees[3] with arm32 in this +.\" regard. :( +. +.\" fixme +.\" michael kerrisk: +.\" i wonder about the effect of this oddity for system calls that +.\" are normally nonrestartable because they have timeouts. my +.\" understanding is that the kernel doesn't restart those system +.\" calls because it's impossible for the kernel to restart the call +.\" with the right timeout value. i wonder what happens when those +.\" system calls are restarted in the scenario we're discussing.) +.pp +furthermore, if the supervisor response is a file descriptor +added with +.br seccomp_ioctl_notif_addfd , +then the flag +.b seccomp_addfd_flag_send +can be used to atomically add the file descriptor and return that value, +making sure no file descriptors are inadvertently leaked into the target. +.sh bugs +if a +.br seccomp_ioctl_notif_recv +.br ioctl (2) +operation +.\" or a poll/epoll/select +is performed after the target terminates, then the +.br ioctl (2) +call simply blocks (rather than returning an error to indicate that the +target no longer exists). +.\" fixme +.\" comment from kees cook: +.\" +.\" i want this fixed. it caused me no end of pain when building the +.\" selftests, and ended up spawning my implementing a global test timeout +.\" in kselftest. :p before the usage counter refactor, there was no sane +.\" way to deal with this, but now i think we're close. +.\" +.sh examples +the (somewhat contrived) program shown below demonstrates the use of +the interfaces described in this page. +the program creates a child process that serves as the "target" process. +the child process installs a seccomp filter that returns the +.b seccomp_ret_user_notif +action value if a call is made to +.br mkdir (2). +the child process then calls +.br mkdir (2) +once for each of the supplied command-line arguments, +and reports the result returned by the call. +after processing all arguments, the child process terminates. +.pp +the parent process acts as the supervisor, listening for the notifications +that are generated when the target process calls +.br mkdir (2). +when such a notification occurs, +the supervisor examines the memory of the target process (using +.ir /proc/[pid]/mem ) +to discover the pathname argument that was supplied to the +.br mkdir (2) +call, and performs one of the following actions: +.ip \(bu 2 +if the pathname begins with the prefix "/tmp/", +then the supervisor attempts to create the specified directory, +and then spoofs a return for the target process based on the return +value of the supervisor's +.br mkdir (2) +call. +in the event that that call succeeds, +the spoofed success return value is the length of the pathname. +.ip \(bu +if the pathname begins with "./" (i.e., it is a relative pathname), +the supervisor sends a +.b seccomp_user_notif_flag_continue +response to the kernel to say that the kernel should execute +the target process's +.br mkdir (2) +call. +.ip \(bu +if the pathname begins with some other prefix, +the supervisor spoofs an error return for the target process, +so that the target process's +.br mkdir (2) +call appears to fail with the error +.br eopnotsupp +("operation not supported"). +additionally, if the specified pathname is exactly "/bye", +then the supervisor terminates. +.pp +this program can be used to demonstrate various aspects of the +behavior of the seccomp user-space notification mechanism. +to help aid such demonstrations, +the program logs various messages to show the operation +of the target process (lines prefixed "t:") and the supervisor +(indented lines prefixed "s:"). +.pp +in the following example, the target attempts to create the directory +.ir /tmp/x . +upon receiving the notification, the supervisor creates the directory on the +target's behalf, +and spoofs a success return to be received by the target process's +.br mkdir (2) +call. +.pp +.in +4n +.ex +$ \fb./seccomp_unotify /tmp/x\fp +t: pid = 23168 + +t: about to mkdir("/tmp/x") + s: got notification (id 0x17445c4a0f4e0e3c) for pid 23168 + s: executing: mkdir("/tmp/x", 0700) + s: success! spoofed return = 6 + s: sending response (flags = 0; val = 6; error = 0) +t: success: mkdir(2) returned 6 + +t: terminating + s: target has terminated; bye +.ee +.in +.pp +in the above output, note that the spoofed return value seen by the target +process is 6 (the length of the pathname +.ir /tmp/x ), +whereas a normal +.br mkdir (2) +call returns 0 on success. +.pp +in the next example, the target attempts to create a directory using the +relative pathname +.ir ./sub . +since this pathname starts with "./", +the supervisor sends a +.b seccomp_user_notif_flag_continue +response to the kernel, +and the kernel then (successfully) executes the target process's +.br mkdir (2) +call. +.pp +.in +4n +.ex +$ \fb./seccomp_unotify ./sub\fp +t: pid = 23204 + +t: about to mkdir("./sub") + s: got notification (id 0xddb16abe25b4c12) for pid 23204 + s: target can execute system call + s: sending response (flags = 0x1; val = 0; error = 0) +t: success: mkdir(2) returned 0 + +t: terminating + s: target has terminated; bye +.ee +.in +.pp +if the target process attempts to create a directory with +a pathname that doesn't start with "." and doesn't begin with the prefix +"/tmp/", then the supervisor spoofs an error return +.rb ( eopnotsupp , +"operation not supported") +for the target's +.br mkdir (2) +call (which is not executed): +.pp +.in +4n +.ex +$ \fb./seccomp_unotify /xxx\fp +t: pid = 23178 + +t: about to mkdir("/xxx") + s: got notification (id 0xe7dc095d1c524e80) for pid 23178 + s: spoofing error response (operation not supported) + s: sending response (flags = 0; val = 0; error = \-95) +t: error: mkdir(2): operation not supported + +t: terminating + s: target has terminated; bye +.ee +.in +.pp +in the next example, +the target process attempts to create a directory with the pathname +.br /tmp/nosuchdir/b . +upon receiving the notification, +the supervisor attempts to create that directory, but the +.br mkdir (2) +call fails because the directory +.br /tmp/nosuchdir +does not exist. +consequently, the supervisor spoofs an error return that passes the error +that it received back to the target process's +.br mkdir (2) +call. +.pp +.in +4n +.ex +$ \fb./seccomp_unotify /tmp/nosuchdir/b\fp +t: pid = 23199 + +t: about to mkdir("/tmp/nosuchdir/b") + s: got notification (id 0x8744454293506046) for pid 23199 + s: executing: mkdir("/tmp/nosuchdir/b", 0700) + s: failure! (errno = 2; no such file or directory) + s: sending response (flags = 0; val = 0; error = \-2) +t: error: mkdir(2): no such file or directory + +t: terminating + s: target has terminated; bye +.ee +.in +.pp +if the supervisor receives a notification and sees that the +argument of the target's +.br mkdir (2) +is the string "/bye", then (as well as spoofing an +.b eopnotsupp +error), the supervisor terminates. +if the target process subsequently executes another +.br mkdir (2) +that triggers its seccomp filter to return the +.b seccomp_ret_user_notif +action value, then the kernel causes the target process's system call to +fail with the error +.b enosys +("function not implemented"). +this is demonstrated by the following example: +.pp +.in +4n +.ex +$ \fb./seccomp_unotify /bye /tmp/y\fp +t: pid = 23185 + +t: about to mkdir("/bye") + s: got notification (id 0xa81236b1d2f7b0f4) for pid 23185 + s: spoofing error response (operation not supported) + s: sending response (flags = 0; val = 0; error = \-95) + s: terminating ********** +t: error: mkdir(2): operation not supported + +t: about to mkdir("/tmp/y") +t: error: mkdir(2): function not implemented + +t: terminating +.ee +.in +.\" +.ss program source +.ex +#define _gnu_source +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define errexit(msg) do { perror(msg); exit(exit_failure); \e + } while (0) + +/* send the file descriptor \(aqfd\(aq over the connected unix domain socket + \(aqsockfd\(aq. returns 0 on success, or \-1 on error. */ + +static int +sendfd(int sockfd, int fd) +{ + struct msghdr msgh; + struct iovec iov; + int data; + struct cmsghdr *cmsgp; + + /* allocate a char array of suitable size to hold the ancillary data. + however, since this buffer is in reality a \(aqstruct cmsghdr\(aq, use a + union to ensure that it is suitably aligned. */ + union { + char buf[cmsg_space(sizeof(int))]; + /* space large enough to hold an \(aqint\(aq */ + struct cmsghdr align; + } controlmsg; + + /* the \(aqmsg_name\(aq field can be used to specify the address of the + destination socket when sending a datagram. however, we do not + need to use this field because \(aqsockfd\(aq is a connected socket. */ + + msgh.msg_name = null; + msgh.msg_namelen = 0; + + /* on linux, we must transmit at least one byte of real data in + order to send ancillary data. we transmit an arbitrary integer + whose value is ignored by recvfd(). */ + + msgh.msg_iov = &iov; + msgh.msg_iovlen = 1; + iov.iov_base = &data; + iov.iov_len = sizeof(int); + data = 12345; + + /* set \(aqmsghdr\(aq fields that describe ancillary data */ + + msgh.msg_control = controlmsg.buf; + msgh.msg_controllen = sizeof(controlmsg.buf); + + /* set up ancillary data describing file descriptor to send */ + + cmsgp = cmsg_firsthdr(&msgh); + cmsgp\->cmsg_level = sol_socket; + cmsgp\->cmsg_type = scm_rights; + cmsgp\->cmsg_len = cmsg_len(sizeof(int)); + memcpy(cmsg_data(cmsgp), &fd, sizeof(int)); + + /* send real plus ancillary data */ + + if (sendmsg(sockfd, &msgh, 0) == \-1) + return \-1; + + return 0; +} + +/* receive a file descriptor on a connected unix domain socket. returns + the received file descriptor on success, or \-1 on error. */ + +static int +recvfd(int sockfd) +{ + struct msghdr msgh; + struct iovec iov; + int data, fd; + ssize_t nr; + + /* allocate a char buffer for the ancillary data. see the comments + in sendfd() */ + union { + char buf[cmsg_space(sizeof(int))]; + struct cmsghdr align; + } controlmsg; + struct cmsghdr *cmsgp; + + /* the \(aqmsg_name\(aq field can be used to obtain the address of the + sending socket. however, we do not need this information. */ + + msgh.msg_name = null; + msgh.msg_namelen = 0; + + /* specify buffer for receiving real data */ + + msgh.msg_iov = &iov; + msgh.msg_iovlen = 1; + iov.iov_base = &data; /* real data is an \(aqint\(aq */ + iov.iov_len = sizeof(int); + + /* set \(aqmsghdr\(aq fields that describe ancillary data */ + + msgh.msg_control = controlmsg.buf; + msgh.msg_controllen = sizeof(controlmsg.buf); + + /* receive real plus ancillary data; real data is ignored */ + + nr = recvmsg(sockfd, &msgh, 0); + if (nr == \-1) + return \-1; + + cmsgp = cmsg_firsthdr(&msgh); + + /* check the validity of the \(aqcmsghdr\(aq */ + + if (cmsgp == null || + cmsgp\->cmsg_len != cmsg_len(sizeof(int)) || + cmsgp\->cmsg_level != sol_socket || + cmsgp\->cmsg_type != scm_rights) { + errno = einval; + return \-1; + } + + /* return the received file descriptor to our caller */ + + memcpy(&fd, cmsg_data(cmsgp), sizeof(int)); + return fd; +} + +static void +sigchldhandler(int sig) +{ + char msg[] = "\ets: target has terminated; bye\en"; + + write(stdout_fileno, msg, sizeof(msg) - 1); + _exit(exit_success); +} + +static int +seccomp(unsigned int operation, unsigned int flags, void *args) +{ + return syscall(__nr_seccomp, operation, flags, args); +} + +/* the following is the x86\-64\-specific bpf boilerplate code for checking + that the bpf program is running on the right architecture + abi. at + completion of these instructions, the accumulator contains the system + call number. */ + +/* for the x32 abi, all system call numbers have bit 30 set */ + +#define x32_syscall_bit 0x40000000 + +#define x86_64_check_arch_and_load_syscall_nr \e + bpf_stmt(bpf_ld | bpf_w | bpf_abs, \e + (offsetof(struct seccomp_data, arch))), \e + bpf_jump(bpf_jmp | bpf_jeq | bpf_k, audit_arch_x86_64, 0, 2), \e + bpf_stmt(bpf_ld | bpf_w | bpf_abs, \e + (offsetof(struct seccomp_data, nr))), \e + bpf_jump(bpf_jmp | bpf_jge | bpf_k, x32_syscall_bit, 0, 1), \e + bpf_stmt(bpf_ret | bpf_k, seccomp_ret_kill_process) + +/* installnotifyfilter() installs a seccomp filter that generates + user\-space notifications (seccomp_ret_user_notif) when the process + calls mkdir(2); the filter allows all other system calls. + + the function return value is a file descriptor from which the + user\-space notifications can be fetched. */ + +static int +installnotifyfilter(void) +{ + struct sock_filter filter[] = { + x86_64_check_arch_and_load_syscall_nr, + + /* mkdir() triggers notification to user\-space supervisor */ + + bpf_jump(bpf_jmp | bpf_jeq | bpf_k, __nr_mkdir, 0, 1), + bpf_stmt(bpf_ret + bpf_k, seccomp_ret_user_notif), + + /* every other system call is allowed */ + + bpf_stmt(bpf_ret | bpf_k, seccomp_ret_allow), + }; + + struct sock_fprog prog = { + .len = sizeof(filter) / sizeof(filter[0]), + .filter = filter, + }; + + /* install the filter with the seccomp_filter_flag_new_listener flag; + as a result, seccomp() returns a notification file descriptor. */ + + int notifyfd = seccomp(seccomp_set_mode_filter, + seccomp_filter_flag_new_listener, &prog); + if (notifyfd == \-1) + errexit("seccomp\-install\-notify\-filter"); + + return notifyfd; +} + +/* close a pair of sockets created by socketpair() */ + +static void +closesocketpair(int sockpair[2]) +{ + if (close(sockpair[0]) == \-1) + errexit("closesocketpair\-close\-0"); + if (close(sockpair[1]) == \-1) + errexit("closesocketpair\-close\-1"); +} + +/* implementation of the target process; create a child process that: + + (1) installs a seccomp filter with the + seccomp_filter_flag_new_listener flag; + (2) writes the seccomp notification file descriptor returned from + the previous step onto the unix domain socket, \(aqsockpair[0]\(aq; + (3) calls mkdir(2) for each element of \(aqargv\(aq. + + the function return value in the parent is the pid of the child + process; the child does not return from this function. */ + +static pid_t +targetprocess(int sockpair[2], char *argv[]) +{ + pid_t targetpid = fork(); + if (targetpid == \-1) + errexit("fork"); + + if (targetpid > 0) /* in parent, return pid of child */ + return targetpid; + + /* child falls through to here */ + + printf("t: pid = %ld\en", (long) getpid()); + + /* install seccomp filter(s) */ + + if (prctl(pr_set_no_new_privs, 1, 0, 0, 0)) + errexit("prctl"); + + int notifyfd = installnotifyfilter(); + + /* pass the notification file descriptor to the tracing process over + a unix domain socket */ + + if (sendfd(sockpair[0], notifyfd) == \-1) + errexit("sendfd"); + + /* notification and socket fds are no longer needed in target */ + + if (close(notifyfd) == \-1) + errexit("close\-target\-notify\-fd"); + + closesocketpair(sockpair); + + /* perform a mkdir() call for each of the command\-line arguments */ + + for (char **ap = argv; *ap != null; ap++) { + printf("\ent: about to mkdir(\e"%s\e")\en", *ap); + + int s = mkdir(*ap, 0700); + if (s == \-1) + perror("t: error: mkdir(2)"); + else + printf("t: success: mkdir(2) returned %d\en", s); + } + + printf("\ent: terminating\en"); + exit(exit_success); +} + +/* check that the notification id provided by a seccomp_ioctl_notif_recv + operation is still valid. it will no longer be valid if the target + process has terminated or is no longer blocked in the system call that + generated the notification (because it was interrupted by a signal). + + this operation can be used when doing such things as accessing + /proc/pid files in the target process in order to avoid toctou race + conditions where the pid that is returned by seccomp_ioctl_notif_recv + terminates and is reused by another process. */ + +static bool +cookieisvalid(int notifyfd, uint64_t id) +{ + return ioctl(notifyfd, seccomp_ioctl_notif_id_valid, &id) == 0; +} + +/* access the memory of the target process in order to fetch the + pathname referred to by the system call argument \(aqargnum\(aq in + \(aqreq\->data.args[]\(aq. the pathname is returned in \(aqpath\(aq, + a buffer of \(aqlen\(aq bytes allocated by the caller. + + returns true if the pathname is successfully fetched, and false + otherwise. for possible causes of failure, see the comments below. */ + +static bool +gettargetpathname(struct seccomp_notif *req, int notifyfd, + int argnum, char *path, size_t len) +{ + char procmempath[path_max]; + + snprintf(procmempath, sizeof(procmempath), "/proc/%d/mem", req\->pid); + + int procmemfd = open(procmempath, o_rdonly | o_cloexec); + if (procmemfd == \-1) + return false; + + /* check that the process whose info we are accessing is still alive + and blocked in the system call that caused the notification. + if the seccomp_ioctl_notif_id_valid operation (performed in + cookieisvalid()) succeeded, we know that the /proc/pid/mem file + descriptor that we opened corresponded to the process for which we + received a notification. if that process subsequently terminates, + then read() on that file descriptor will return 0 (eof). */ + + if (!cookieisvalid(notifyfd, req\->id)) { + close(procmemfd); + return false; + } + + /* read bytes at the location containing the pathname argument */ + + ssize_t nread = pread(procmemfd, path, len, req\->data.args[argnum]); + + close(procmemfd); + + if (nread <= 0) + return false; + + /* once again check that the notification id is still valid. the + case we are particularly concerned about here is that just + before we fetched the pathname, the target\(aqs blocked system + call was interrupted by a signal handler, and after the handler + returned, the target carried on execution (past the interrupted + system call). in that case, we have no guarantees about what we + are reading, since the target\(aqs memory may have been arbitrarily + changed by subsequent operations. */ + + if (!cookieisvalid(notifyfd, req\->id)) { + perror("\ets: notification id check failed!!!"); + return false; + } + + /* even if the target\(aqs system call was not interrupted by a signal, + we have no guarantees about what was in the memory of the target + process. (the memory may have been modified by another thread, or + even by an external attacking process.) we therefore treat the + buffer returned by pread() as untrusted input. the buffer should + contain a terminating null byte; if not, then we will trigger an + error for the target process. */ + + if (strnlen(path, nread) < nread) + return true; + + return false; +} + +/* allocate buffers for the seccomp user\-space notification request and + response structures. it is the caller\(aqs responsibility to free the + buffers returned via \(aqreq\(aq and \(aqresp\(aq. */ + +static void +allocseccompnotifbuffers(struct seccomp_notif **req, + struct seccomp_notif_resp **resp, + struct seccomp_notif_sizes *sizes) +{ + /* discover the sizes of the structures that are used to receive + notifications and send notification responses, and allocate + buffers of those sizes. */ + + if (seccomp(seccomp_get_notif_sizes, 0, sizes) == \-1) + errexit("seccomp\-seccomp_get_notif_sizes"); + + *req = malloc(sizes\->seccomp_notif); + if (*req == null) + errexit("malloc\-seccomp_notif"); + + /* when allocating the response buffer, we must allow for the fact + that the user\-space binary may have been built with user\-space + headers where \(aqstruct seccomp_notif_resp\(aq is bigger than the + response buffer expected by the (older) kernel. therefore, we + allocate a buffer that is the maximum of the two sizes. this + ensures that if the supervisor places bytes into the response + structure that are past the response size that the kernel expects, + then the supervisor is not touching an invalid memory location. */ + + size_t resp_size = sizes\->seccomp_notif_resp; + if (sizeof(struct seccomp_notif_resp) > resp_size) + resp_size = sizeof(struct seccomp_notif_resp); + + *resp = malloc(resp_size); + if (resp == null) + errexit("malloc\-seccomp_notif_resp"); + +} + +/* handle notifications that arrive via the seccomp_ret_user_notif file + descriptor, \(aqnotifyfd\(aq. */ + +static void +handlenotifications(int notifyfd) +{ + struct seccomp_notif_sizes sizes; + struct seccomp_notif *req; + struct seccomp_notif_resp *resp; + char path[path_max]; + + allocseccompnotifbuffers(&req, &resp, &sizes); + + /* loop handling notifications */ + + for (;;) { + + /* wait for next notification, returning info in \(aq*req\(aq */ + + memset(req, 0, sizes.seccomp_notif); + if (ioctl(notifyfd, seccomp_ioctl_notif_recv, req) == \-1) { + if (errno == eintr) + continue; + errexit("\ets: ioctl\-seccomp_ioctl_notif_recv"); + } + + printf("\ets: got notification (id %#llx) for pid %d\en", + req\->id, req\->pid); + + /* the only system call that can generate a notification event + is mkdir(2). nevertheless, we check that the notified system + call is indeed mkdir() as kind of future\-proofing of this + code in case the seccomp filter is later modified to + generate notifications for other system calls. */ + + if (req\->data.nr != __nr_mkdir) { + printf("\ets: notification contained unexpected " + "system call number; bye!!!\en"); + exit(exit_failure); + } + + bool pathok = gettargetpathname(req, notifyfd, 0, path, + sizeof(path)); + + /* prepopulate some fields of the response */ + + resp\->id = req\->id; /* response includes notification id */ + resp\->flags = 0; + resp\->val = 0; + + /* if gettargetpathname() failed, trigger an einval error + response (sending this response may yield an error if the + failure occurred because the notification id was no longer + valid); if the directory is in /tmp, then create it on behalf + of the supervisor; if the pathname starts with \(aq.\(aq, tell the + kernel to let the target process execute the mkdir(); + otherwise, give an error for a directory pathname in any other + location. */ + + if (!pathok) { + resp->error = -einval; + printf("\ets: spoofing error for invalid pathname (%s)\en", + strerror(-resp->error)); + } else if (strncmp(path, "/tmp/", strlen("/tmp/")) == 0) { + printf("\ets: executing: mkdir(\e"%s\e", %#llo)\en", + path, req\->data.args[1]); + + if (mkdir(path, req\->data.args[1]) == 0) { + resp\->error = 0; /* "success" */ + resp\->val = strlen(path); /* used as return value of + mkdir() in target */ + printf("\ets: success! spoofed return = %lld\en", + resp\->val); + } else { + + /* if mkdir() failed in the supervisor, pass the error + back to the target */ + + resp\->error = \-errno; + printf("\ets: failure! (errno = %d; %s)\en", errno, + strerror(errno)); + } + } else if (strncmp(path, "./", strlen("./")) == 0) { + resp\->error = resp\->val = 0; + resp\->flags = seccomp_user_notif_flag_continue; + printf("\ets: target can execute system call\en"); + } else { + resp\->error = \-eopnotsupp; + printf("\ets: spoofing error response (%s)\en", + strerror(\-resp\->error)); + } + + /* send a response to the notification */ + + printf("\ets: sending response " + "(flags = %#x; val = %lld; error = %d)\en", + resp\->flags, resp\->val, resp\->error); + + if (ioctl(notifyfd, seccomp_ioctl_notif_send, resp) == \-1) { + if (errno == enoent) + printf("\ets: response failed with enoent; " + "perhaps target process\(aqs syscall was " + "interrupted by a signal?\en"); + else + perror("ioctl\-seccomp_ioctl_notif_send"); + } + + /* if the pathname is just "/bye", then the supervisor breaks out + of the loop and terminates. this allows us to see what happens + if the target process makes further calls to mkdir(2). */ + + if (strcmp(path, "/bye") == 0) + break; + } + + free(req); + free(resp); + printf("\ets: terminating **********\en"); + exit(exit_failure); +} + +/* implementation of the supervisor process: + + (1) obtains the notification file descriptor from \(aqsockpair[1]\(aq + (2) handles notifications that arrive on that file descriptor. */ + +static void +supervisor(int sockpair[2]) +{ + int notifyfd = recvfd(sockpair[1]); + if (notifyfd == \-1) + errexit("recvfd"); + + closesocketpair(sockpair); /* we no longer need the socket pair */ + + handlenotifications(notifyfd); +} + +int +main(int argc, char *argv[]) +{ + int sockpair[2]; + + setbuf(stdout, null); + + if (argc < 2) { + fprintf(stderr, "at least one pathname argument is required\en"); + exit(exit_failure); + } + + /* create a unix domain socket that is used to pass the seccomp + notification file descriptor from the target process to the + supervisor process. */ + + if (socketpair(af_unix, sock_stream, 0, sockpair) == \-1) + errexit("socketpair"); + + /* create a child process\-\-the "target"\-\-that installs seccomp + filtering. the target process writes the seccomp notification + file descriptor onto \(aqsockpair[0]\(aq and then calls mkdir(2) for + each directory in the command\-line arguments. */ + + (void) targetprocess(sockpair, &argv[optind]); + + /* catch sigchld when the target terminates, so that the + supervisor can also terminate. */ + + struct sigaction sa; + sa.sa_handler = sigchldhandler; + sa.sa_flags = 0; + sigemptyset(&sa.sa_mask); + if (sigaction(sigchld, &sa, null) == \-1) + errexit("sigaction"); + + supervisor(sockpair); + + exit(exit_success); +} +.ee +.sh see also +.br ioctl (2), +.br pidfd_getfd (2), +.br pidfd_open (2), +.br seccomp (2) +.pp +a further example program can be found in the kernel source file +.ir samples/seccomp/user-trap.c . +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2003 andries brouwer (aeb@cwi.nl) +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th getpwent_r 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +getpwent_r, fgetpwent_r \- get passwd file entry reentrantly +.sh synopsis +.nf +.b #include +.pp +.bi "int getpwent_r(struct passwd *restrict " pwbuf , +.bi " char *restrict " buf ", size_t " buflen , +.bi " struct passwd **restrict " pwbufp ); +.bi "int fgetpwent_r(file *restrict " stream \ +", struct passwd *restrict " pwbuf , +.bi " char *restrict " buf ", size_t " buflen , +.bi " struct passwd **restrict " pwbufp ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br getpwent_r (), +.nf + since glibc 2.19: + _default_source + glibc 2.19 and earlier: + _bsd_source || _svid_source +.fi +.pp +.br fgetpwent_r (): +.nf + since glibc 2.19: + _default_source + glibc 2.19 and earlier: + _svid_source +.fi +.sh description +the functions +.br getpwent_r () +and +.br fgetpwent_r () +are the reentrant versions of +.br getpwent (3) +and +.br fgetpwent (3). +the former reads the next passwd entry from the stream initialized by +.br setpwent (3). +the latter reads the next passwd entry from +.ir stream . +.pp +the \fipasswd\fp structure is defined in +.i +as follows: +.pp +.in +4n +.ex +struct passwd { + char *pw_name; /* username */ + char *pw_passwd; /* user password */ + uid_t pw_uid; /* user id */ + gid_t pw_gid; /* group id */ + char *pw_gecos; /* user information */ + char *pw_dir; /* home directory */ + char *pw_shell; /* shell program */ +}; +.ee +.in +.pp +for more information about the fields of this structure, see +.br passwd (5). +.pp +the nonreentrant functions return a pointer to static storage, +where this static storage contains further pointers to user +name, password, gecos field, home directory and shell. +the reentrant functions described here return all of that in +caller-provided buffers. +first of all there is the buffer +.i pwbuf +that can hold a \fistruct passwd\fp. +and next the buffer +.i buf +of size +.i buflen +that can hold additional strings. +the result of these functions, the \fistruct passwd\fp read from the stream, +is stored in the provided buffer +.ir *pwbuf , +and a pointer to this \fistruct passwd\fp is returned in +.ir *pwbufp . +.sh return value +on success, these functions return 0 and +.i *pwbufp +is a pointer to the \fistruct passwd\fp. +on error, these functions return an error value and +.i *pwbufp +is null. +.sh errors +.tp +.b enoent +no more entries. +.tp +.b erange +insufficient buffer space supplied. +try again with larger buffer. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lb lb lbx +l l l. +interface attribute value +t{ +.br getpwent_r () +t} thread safety t{ +mt-unsafe race:pwent locale +t} +t{ +.br fgetpwent_r () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +in the above table, +.i pwent +in +.i race:pwent +signifies that if any of the functions +.br setpwent (), +.br getpwent (), +.br endpwent (), +or +.br getpwent_r () +are used in parallel in different threads of a program, +then data races could occur. +.sh conforming to +these functions are gnu extensions, done in a style resembling +the posix version of functions like +.br getpwnam_r (3). +other systems use the prototype +.pp +.in +4n +.ex +struct passwd * +getpwent_r(struct passwd *pwd, char *buf, int buflen); +.ee +.in +.pp +or, better, +.pp +.in +4n +.ex +int +getpwent_r(struct passwd *pwd, char *buf, int buflen, + file **pw_fp); +.ee +.in +.sh notes +the function +.br getpwent_r () +is not really reentrant since it shares the reading position +in the stream with all other threads. +.sh examples +.ex +#define _gnu_source +#include +#include +#include +#define buflen 4096 + +int +main(void) +{ + struct passwd pw; + struct passwd *pwp; + char buf[buflen]; + int i; + + setpwent(); + while (1) { + i = getpwent_r(&pw, buf, sizeof(buf), &pwp); + if (i) + break; + printf("%s (%jd)\ethome %s\etshell %s\en", pwp\->pw_name, + (intmax_t) pwp\->pw_uid, pwp\->pw_dir, pwp\->pw_shell); + } + endpwent(); + exit(exit_success); +} +.ee +.\" perhaps add error checking - should use strerror_r +.\" #include +.\" #include +.\" if (i) { +.\" if (i == enoent) +.\" break; +.\" printf("getpwent_r: %s", strerror(i)); +.\" exit(exit_success); +.\" } +.sh see also +.br fgetpwent (3), +.br getpw (3), +.br getpwent (3), +.br getpwnam (3), +.br getpwuid (3), +.br putpwent (3), +.br passwd (5) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/resolver.3 + +.\" copyright (c) 2017 by michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th sysfs 5 2021-03-22 "linux" "linux programmer's manual" +.sh name +sysfs \- a filesystem for exporting kernel objects +.sh description +the +.b sysfs +filesystem is a pseudo-filesystem which provides an interface to +kernel data structures. +(more precisely, the files and directories in +.b sysfs +provide a view of the +.ir kobject +structures defined internally within the kernel.) +the files under +.b sysfs +provide information about devices, kernel modules, filesystems, +and other kernel components. +.pp +the +.b sysfs +filesystem is commonly mounted at +.ir /sys . +typically, it is mounted automatically by the system, +but it can also be mounted manually using a command such as: +.pp +.in +4n +.ex +mount \-t sysfs sysfs /sys +.ee +.in +.pp +many of the files in the +.b sysfs +filesystem are read-only, +but some files are writable, allowing kernel variables to be changed. +to avoid redundancy, +symbolic links are heavily used to connect entries across the filesystem tree. +.\" +.ss files and directories +the following list describes some of the files and directories under the +.i /sys +hierarchy. +.tp +.ir /sys/block +this subdirectory contains one symbolic link for each block device +that has been discovered on the system. +the symbolic links point to corresponding directories under +.ir /sys/devices . +.tp +.ir /sys/bus +this directory contains one subdirectory for each of the bus types +in the kernel. +inside each of these directories are two subdirectories: +.rs +.tp +.ir devices +this subdirectory contains symbolic links to entries in +.ir /sys/devices +that correspond to the devices discovered on this bus. +.tp +.ir drivers +this subdirectory contains one subdirectory for each device driver +that is loaded on this bus. +.re +.tp +.ir /sys/class +this subdirectory contains a single layer of further subdirectories +for each of the device classes that have been registered on the system +(e.g., terminals, network devices, block devices, graphics devices, +sound devices, and so on). +inside each of these subdirectories are symbolic links for each of the +devices in this class. +these symbolic links refer to entries in the +.ir /sys/devices +directory. +.tp +.ir /sys/class/net +each of the entries in this directory is a symbolic link +representing one of the real or virtual networking devices +that are visible in the network namespace of the process +that is accessing the directory. +each of these symbolic links refers to entries in the +.ir /sys/devices +directory. +.tp +.ir /sys/dev +this directory contains two subdirectories +.ir block / +and +.ir char/ , +corresponding, respectively, +to the block and character devices on the system. +inside each of these subdirectories are symbolic links with names of the form +.ir major-id : minor-id , +where the id values correspond to the major and minor id of a specific device. +each symbolic link points to the +.b sysfs +directory for a device. +the symbolic links inside +.ir /sys/dev +thus provide an easy way to look up the +.b sysfs +interface using the device ids returned by a call to +.br stat (2) +(or similar). +.ip +the following shell session shows an example from +.ir /sys/dev : +.ip +.in +4n +.ex +$ \fbstat \-c "%t %t" /dev/null\fp +1 3 +$ \fbreadlink /sys/dev/char/1\e:3\fp +\&../../devices/virtual/mem/null +$ \fbls \-fd /sys/devices/virtual/mem/null\fp +/sys/devices/virtual/mem/null/ +$ \fbls \-d1 /sys/devices/virtual/mem/null/*\fp +/sys/devices/virtual/mem/null/dev +/sys/devices/virtual/mem/null/power/ +/sys/devices/virtual/mem/null/subsystem@ +/sys/devices/virtual/mem/null/uevent +.ee +.in +.tp +.ir /sys/devices +this is a directory that contains a filesystem representation of +the kernel device tree, +which is a hierarchy of +.i device +structures within the kernel. +.tp +.ir /sys/firmware +this subdirectory contains interfaces for viewing and manipulating +firmware-specific objects and attributes. +.tp +.ir /sys/fs +this directory contains subdirectories for some filesystems. +a filesystem will have a subdirectory here only if it chose +to explicitly create the subdirectory. +.tp +.ir /sys/fs/cgroup +this directory conventionally is used as a mount point for a +.br tmpfs (5) +filesystem containing mount points for +.br cgroups (7) +filesystems. +.tp +.ir /sys/fs/smackfs +the directory contains configuration files for the smack lsm. +see the kernel source file +.ir documentation/admin\-guide/lsm/smack.rst . +.tp +.ir /sys/hypervisor +[to be documented] +.tp +.ir /sys/kernel +this subdirectory contains various files and subdirectories that provide +information about the running kernel. +.tp +.ir /sys/kernel/cgroup/ +for information about the files in this directory, see +.br cgroups (7). +.tp +.ir /sys/kernel/debug/tracing +mount point for the +.i tracefs +filesystem used by the kernel's +.i ftrace +facility. +(for information on +.ir ftrace , +see the kernel source file +.ir documentation/trace/ftrace.txt .) +.tp +.ir /sys/kernel/mm +this subdirectory contains various files and subdirectories that provide +information about the kernel's memory management subsystem. +.tp +.ir /sys/kernel/mm/hugepages +this subdirectory contains one subdirectory for each of the +huge page sizes that the system supports. +the subdirectory name indicates the huge page size (e.g., +.ir hugepages\-2048kb ). +within each of these subdirectories is a set of files +that can be used to view and (in some cases) change settings +associated with that huge page size. +for further information, see the kernel source file +.ir documentation/admin\-guide/mm/hugetlbpage.rst . +.tp +.ir /sys/module +this subdirectory contains one subdirectory +for each module that is loaded into the kernel. +the name of each directory is the name of the module. +in each of the subdirectories, there may be following files: +.rs +.tp +.i coresize +[to be documented] +.tp +.i initsize +[to be documented] +.tp +.i initstate +[to be documented] +.tp +.i refcnt +[to be documented] +.tp +.i srcversion +[to be documented] +.tp +.i taint +[to be documented] +.tp +.i uevent +[to be documented] +.tp +.i version +[to be documented] +.re +.ip +in each of the subdirectories, there may be following subdirectories: +.rs +.tp +.i drivers +[to be documented] +.tp +.i holders +[to be documented] +.tp +.i notes +[to be documented] +.tp +.i parameters +this directory contains one file for each module parameter, +with each file containing the value of the corresponding parameter. +some of these files are writable, allowing the +.tp +.i sections +this subdirectories contains files with information about module sections. +this information is mainly used for debugging. +.tp +.i +[to be documented] +.re +.tp +.ir /sys/power +[to be documented] +.sh versions +the +.b sysfs +filesystem first appeared in linux 2.6.0. +.sh conforming to +the +.b sysfs +filesystem is linux-specific. +.sh notes +this manual page is incomplete, possibly inaccurate, and is the kind +of thing that needs to be updated very often. +.sh see also +.br proc (5), +.br udev (7) +.pp +p.\& mochel. (2005). +.ir "the sysfs filesystem" . +proceedings of the 2005 ottawa linux symposium. +.\" https://www.kernel.org/pub/linux/kernel/people/mochel/doc/papers/ols-2005/mochel.pdf +.pp +the kernel source file +.i documentation/filesystems/sysfs.txt +and various other files in +.ir documentation/abi +and +.ir documentation/*/sysfs.txt +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/lround.3 + +.so man3/endian.3 + +.so man3/xdr.3 + +.\" copyright (c) 2008 linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th pthread_exit 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +pthread_exit \- terminate calling thread +.sh synopsis +.nf +.b #include +.pp +.bi "noreturn void pthread_exit(void *" retval ); +.pp +compile and link with \fi\-pthread\fp. +.fi +.sh description +the +.br pthread_exit () +function terminates the calling thread and returns a value via +.i retval +that (if the thread is joinable) +is available to another thread in the same process that calls +.br pthread_join (3). +.pp +any clean-up handlers established by +.br pthread_cleanup_push (3) +that have not yet been popped, +are popped (in the reverse of the order in which they were pushed) +and executed. +if the thread has any thread-specific data, then, +after the clean-up handlers have been executed, +the corresponding destructor functions are called, +in an unspecified order. +.pp +when a thread terminates, +process-shared resources (e.g., mutexes, condition variables, +semaphores, and file descriptors) are not released, +and functions registered using +.br atexit (3) +are not called. +.pp +after the last thread in a process terminates, +the process terminates as by calling +.br exit (3) +with an exit status of zero; +thus, process-shared resources +are released and functions registered using +.br atexit (3) +are called. +.sh return value +this function does not return to the caller. +.sh errors +this function always succeeds. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br pthread_exit () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +performing a return from the start function of any thread other +than the main thread results in an implicit call to +.br pthread_exit (), +using the function's return value as the thread's exit status. +.pp +to allow other threads to continue execution, +the main thread should terminate by calling +.br pthread_exit () +rather than +.br exit (3). +.pp +the value pointed to by +.ir retval +should not be located on the calling thread's stack, +since the contents of that stack are undefined after the thread terminates. +.sh bugs +currently, +.\" linux 2.6.27 +there are limitations in the kernel implementation logic for +.br wait (2)ing +on a stopped thread group with a dead thread group leader. +this can manifest in problems such as a locked terminal if a stop signal is +sent to a foreground process whose thread group leader has already called +.br pthread_exit (). +.\" fixme . review a later kernel to see if this gets fixed +.\" http://thread.gmane.org/gmane.linux.kernel/611611 +.\" http://marc.info/?l=linux-kernel&m=122525468300823&w=2 +.sh see also +.br pthread_create (3), +.br pthread_join (3), +.br pthreads (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1995 paul gortmaker +.\" (gpg109@rsphy1.anu.edu.au) +.\" wed nov 29 10:58:54 est 1995 +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th outb 2 2020-11-01 "linux" "linux programmer's manual" +.sh name +outb, outw, outl, outsb, outsw, outsl, +inb, inw, inl, insb, insw, insl, +outb_p, outw_p, outl_p, inb_p, inw_p, inl_p \- port i/o +.sh synopsis +.nf +.b #include +.pp +.bi "unsigned char inb(unsigned short " port ); +.bi "unsigned char inb_p(unsigned short " port ); +.bi "unsigned short inw(unsigned short " port ); +.bi "unsigned short inw_p(unsigned short " port ); +.bi "unsigned int inl(unsigned short " port ); +.bi "unsigned int inl_p(unsigned short " port ); +.pp +.bi "void outb(unsigned char " value ", unsigned short " port ); +.bi "void outb_p(unsigned char " value ", unsigned short " port ); +.bi "void outw(unsigned short " value ", unsigned short " port ); +.bi "void outw_p(unsigned short " value ", unsigned short " port ); +.bi "void outl(unsigned int " value ", unsigned short " port ); +.bi "void outl_p(unsigned int " value ", unsigned short " port ); +.pp +.bi "void insb(unsigned short " port ", void *" addr , +.bi " unsigned long " count ); +.bi "void insw(unsigned short " port ", void *" addr , +.bi " unsigned long " count ); +.bi "void insl(unsigned short " port ", void *" addr , +.bi " unsigned long " count ); +.bi "void outsb(unsigned short " port ", const void *" addr , +.bi " unsigned long " count ); +.bi "void outsw(unsigned short " port ", const void *" addr , +.bi " unsigned long " count ); +.bi "void outsl(unsigned short " port ", const void *" addr , +.bi " unsigned long " count ); +.fi +.sh description +this family of functions is used to do low-level port input and output. +the out* functions do port output, the in* functions do port input; +the b-suffix functions are byte-width and the w-suffix functions +word-width; the _p-suffix functions pause until the i/o completes. +.pp +they are primarily designed for internal kernel use, +but can be used from user space. +.\" , given the following information +.\" in addition to that given in +.\" .br outb (9). +.pp +you must compile with \fb\-o\fp or \fb\-o2\fp or similar. +the functions +are defined as inline macros, and will not be substituted in without +optimization enabled, causing unresolved references at link time. +.pp +you use +.br ioperm (2) +or alternatively +.br iopl (2) +to tell the kernel to allow the user space application to access the +i/o ports in question. +failure to do this will cause the application +to receive a segmentation fault. +.sh conforming to +.br outb () +and friends are hardware-specific. +the +.i value +argument is passed first and the +.i port +argument is passed second, +which is the opposite order from most dos implementations. +.sh see also +.br ioperm (2), +.br iopl (2) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1995 james r. van zandt +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" changed tue sep 19 01:49:29 1995, aeb: moved from man2 to man3 +.\" added ref to /etc/utmp, added bugs section, etc. +.\" modified 2003 walter harms, aeb - added getlogin_r, note on stdin use +.th getlogin 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +getlogin, getlogin_r, cuserid \- get username +.sh synopsis +.nf +.b #include +.pp +.b "char *getlogin(void);" +.bi "int getlogin_r(char *" buf ", size_t " bufsize ); +.pp +.b #include +.pp +.bi "char *cuserid(char *" string ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br getlogin_r (): +.nf +.\" deprecated: _reentrant || + _posix_c_source >= 199506l +.fi +.pp +.br cuserid (): +.nf + since glibc 2.24: + (_xopen_source && ! (_posix_c_source >= 200112l) + || _gnu_source + up to and including glibc 2.23: + _xopen_source +.fi +.sh description +.br getlogin () +returns a pointer to a string containing the name of +the user logged in on the controlling terminal of the process, or a +null pointer if this information cannot be determined. +the string is +statically allocated and might be overwritten on subsequent calls to +this function or to +.br cuserid (). +.pp +.br getlogin_r () +returns this same username in the array +.i buf +of size +.ir bufsize . +.pp +.br cuserid () +returns a pointer to a string containing a username +associated with the effective user id of the process. +if \fistring\fp +is not a null pointer, it should be an array that can hold at least +\fbl_cuserid\fp characters; the string is returned in this array. +otherwise, a pointer to a string in a static area is returned. +this +string is statically allocated and might be overwritten on subsequent +calls to this function or to +.br getlogin (). +.pp +the macro \fbl_cuserid\fp is an integer constant that indicates how +long an array you might need to store a username. +\fbl_cuserid\fp is declared in \fi\fp. +.pp +these functions let your program identify positively the user who is +running +.rb ( cuserid ()) +or the user who logged in this session +.rb ( getlogin ()). +(these can differ when set-user-id programs are involved.) +.pp +for most purposes, it is more useful to use the environment variable +\fblogname\fp to find out who the user is. +this is more flexible +precisely because the user can set \fblogname\fp arbitrarily. +.sh return value +.br getlogin () +returns a pointer to the username when successful, +and null on failure, with +.i errno +set to indicate the error. +.br getlogin_r () +returns 0 when successful, and nonzero on failure. +.sh errors +posix specifies: +.tp +.b emfile +the per-process limit on the number of open file descriptors has been reached. +.tp +.b enfile +the system-wide limit on the total number of open files has been reached. +.tp +.b enxio +the calling process has no controlling terminal. +.tp +.b erange +(getlogin_r) +the length of the username, including the terminating null byte (\(aq\e0\(aq), +is larger than +.ir bufsize . +.pp +linux/glibc also has: +.tp +.b enoent +there was no corresponding entry in the utmp-file. +.tp +.b enomem +insufficient memory to allocate passwd structure. +.tp +.b enotty +standard input didn't refer to a terminal. +(see bugs.) +.sh files +.tp +\fi/etc/passwd\fp +password database file +.tp +\fi/var/run/utmp\fp +(traditionally \fi/etc/utmp\fp; +some libc versions used \fi/var/adm/utmp\fp) +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lb lb lbx +l l l. +interface attribute value +t{ +.br getlogin () +t} thread safety t{ +mt-unsafe race:getlogin race:utent +sig:alrm timer locale +t} +t{ +.br getlogin_r () +t} thread safety t{ +mt-unsafe race:utent sig:alrm timer +locale +t} +t{ +.br cuserid () +t} thread safety t{ +mt-unsafe race:cuserid/!string locale +t} +.te +.hy +.ad +.sp 1 +in the above table, +.i utent +in +.i race:utent +signifies that if any of the functions +.br setutent (3), +.br getutent (3), +or +.br endutent (3) +are used in parallel in different threads of a program, +then data races could occur. +.br getlogin () +and +.br getlogin_r () +call those functions, +so we use race:utent to remind users. +.sh conforming to +.br getlogin () +and +.br getlogin_r (): +posix.1-2001, posix.1-2008. +.pp +system v has a +.br cuserid () +function which uses the real +user id rather than the effective user id. +the +.br cuserid () +function +was included in the 1988 version of posix, +but removed from the 1990 version. +it was present in susv2, but removed in posix.1-2001. +.pp +openbsd has +.br getlogin () +and +.br setlogin (), +and a username +associated with a session, even if it has no controlling terminal. +.sh bugs +unfortunately, it is often rather easy to fool +.br getlogin (). +sometimes it does not work at all, because some program messed up +the utmp file. +often, it gives only the first 8 characters of +the login name. +the user currently logged in on the controlling terminal +of our program need not be the user who started it. +avoid +.br getlogin () +for security-related purposes. +.pp +note that glibc does not follow the posix specification and uses +.i stdin +instead of +.ir /dev/tty . +a bug. +(other recent systems, like sunos 5.8 and hp-ux 11.11 and freebsd 4.8 +all return the login name also when +.i stdin +is redirected.) +.pp +nobody knows precisely what +.br cuserid () +does; avoid it in portable programs. +or avoid it altogether: use +.i getpwuid(geteuid()) +instead, if that is +what you meant. +.b do not use +.br cuserid (). +.sh see also +.br logname (1), +.br geteuid (2), +.br getuid (2), +.br utmp (5) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/bzero.3 + +.so man2/recv.2 + +.so man3/xdr.3 + +.so man3/rpc.3 + +.so man3/drand48_r.3 + +.\" copyright (c) 2001 andries brouwer (aeb@cwi.nl) +.\" and copyright (c) 2006 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" 2006-08-02, mtk, added example program +.\" +.th makecontext 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +makecontext, swapcontext \- manipulate user context +.sh synopsis +.nf +.b #include +.pp +.bi "void makecontext(ucontext_t *" ucp ", void (*" func ")(), int " argc \ +", ...);" +.bi "int swapcontext(ucontext_t *restrict " oucp , +.bi " const ucontext_t *restrict " ucp ); +.fi +.sh description +in a system v-like environment, one has the type +.i ucontext_t +(defined in +.i +and described in +.br getcontext (3)) +and the four functions +.br getcontext (3), +.br setcontext (3), +.br makecontext (), +and +.br swapcontext () +that allow user-level context switching +between multiple threads of control within a process. +.pp +the +.br makecontext () +function modifies the context pointed to +by \fiucp\fp (which was obtained from a call to +.br getcontext (3)). +before invoking +.br makecontext (), +the caller must allocate a new stack +for this context and assign its address to \fiucp\->uc_stack\fp, +and define a successor context and +assign its address to \fiucp\->uc_link\fp. +.pp +when this context is later activated (using +.br setcontext (3) +or +.br swapcontext ()) +the function \fifunc\fp is called, +and passed the series of integer +.ri ( int ) +arguments that follow +.ir argc ; +the caller must specify the number of these arguments in +.ir argc . +when this function returns, the successor context is activated. +if the successor context pointer is null, the thread exits. +.pp +the +.br swapcontext () +function saves the current context in +the structure pointed to by \fioucp\fp, and then activates the +context pointed to by \fiucp\fp. +.sh return value +when successful, +.br swapcontext () +does not return. +(but we may return later, in case \fioucp\fp is +activated, in which case it looks like +.br swapcontext () +returns 0.) +on error, +.br swapcontext () +returns \-1 and sets +.i errno +to indicate the error. +.sh errors +.tp +.b enomem +insufficient stack space left. +.sh versions +.br makecontext () +and +.br swapcontext () +are provided in glibc since version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lb lb lbx +l l l. +interface attribute value +t{ +.br makecontext () +t} thread safety t{ +mt-safe race:ucp +t} +t{ +.br swapcontext () +t} thread safety t{ +mt-safe race:oucp race:ucp +t} +.te +.hy +.ad +.sp 1 +.sh conforming to +susv2, posix.1-2001. +posix.1-2008 removes the specifications of +.br makecontext () +and +.br swapcontext (), +citing portability issues, and +recommending that applications be rewritten to use posix threads instead. +.sh notes +the interpretation of \fiucp\->uc_stack\fp is just as in +.br sigaltstack (2), +namely, this struct contains the start and length of a memory area +to be used as the stack, regardless of the direction of growth of +the stack. +thus, it is not necessary for the user program to +worry about this direction. +.pp +on architectures where +.i int +and pointer types are the same size +(e.g., x86-32, where both types are 32 bits), +you may be able to get away with passing pointers as arguments to +.br makecontext () +following +.ir argc . +however, doing this is not guaranteed to be portable, +is undefined according to the standards, +and won't work on architectures where pointers are larger than +.ir int s. +nevertheless, starting with version 2.8, glibc makes some changes to +.br makecontext (), +to permit this on some 64-bit architectures (e.g., x86-64). +.sh examples +the example program below demonstrates the use of +.br getcontext (3), +.br makecontext (), +and +.br swapcontext (). +running the program produces the following output: +.pp +.in +4n +.ex +.rb "$" " ./a.out" +main: swapcontext(&uctx_main, &uctx_func2) +func2: started +func2: swapcontext(&uctx_func2, &uctx_func1) +func1: started +func1: swapcontext(&uctx_func1, &uctx_func2) +func2: returning +func1: returning +main: exiting +.ee +.in +.ss program source +\& +.ex +#include +#include +#include + +static ucontext_t uctx_main, uctx_func1, uctx_func2; + +#define handle_error(msg) \e + do { perror(msg); exit(exit_failure); } while (0) + +static void +func1(void) +{ + printf("func1: started\en"); + printf("func1: swapcontext(&uctx_func1, &uctx_func2)\en"); + if (swapcontext(&uctx_func1, &uctx_func2) == \-1) + handle_error("swapcontext"); + printf("func1: returning\en"); +} + +static void +func2(void) +{ + printf("func2: started\en"); + printf("func2: swapcontext(&uctx_func2, &uctx_func1)\en"); + if (swapcontext(&uctx_func2, &uctx_func1) == \-1) + handle_error("swapcontext"); + printf("func2: returning\en"); +} + +int +main(int argc, char *argv[]) +{ + char func1_stack[16384]; + char func2_stack[16384]; + + if (getcontext(&uctx_func1) == \-1) + handle_error("getcontext"); + uctx_func1.uc_stack.ss_sp = func1_stack; + uctx_func1.uc_stack.ss_size = sizeof(func1_stack); + uctx_func1.uc_link = &uctx_main; + makecontext(&uctx_func1, func1, 0); + + if (getcontext(&uctx_func2) == \-1) + handle_error("getcontext"); + uctx_func2.uc_stack.ss_sp = func2_stack; + uctx_func2.uc_stack.ss_size = sizeof(func2_stack); + /* successor context is f1(), unless argc > 1 */ + uctx_func2.uc_link = (argc > 1) ? null : &uctx_func1; + makecontext(&uctx_func2, func2, 0); + + printf("main: swapcontext(&uctx_main, &uctx_func2)\en"); + if (swapcontext(&uctx_main, &uctx_func2) == \-1) + handle_error("swapcontext"); + + printf("main: exiting\en"); + exit(exit_success); +} +.ee +.sh see also +.br sigaction (2), +.br sigaltstack (2), +.br sigprocmask (2), +.br getcontext (3), +.br sigsetjmp (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/unlocked_stdio.3 + +.so man3/getrpcent.3 + +.so man3/rpc.3 + +.so man3/mkfifo.3 + +.\" copyright (c) 2003 andries brouwer (aeb@cwi.nl) +.\" and copyright (c) 2010 michael kerrisk +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th aio_suspend 3 2021-03-22 "" "linux programmer's manual" +.sh name +aio_suspend \- wait for asynchronous i/o operation or timeout +.sh synopsis +.nf +.pp +.b "#include " +.pp +.bi "int aio_suspend(const struct aiocb *const " aiocb_list "[], int " nitems , +.bi " const struct timespec *restrict " timeout ); +.pp +link with \fi\-lrt\fp. +.fi +.sh description +the +.br aio_suspend () +function suspends the calling thread until one of the following occurs: +.ip * 3 +one or more of the asynchronous i/o requests in the list +.i aiocb_list +has completed. +.ip * +a signal is delivered. +.ip * +.i timeout +is not null and the specified time interval has passed. +(for details of the +.i timespec +structure, see +.br nanosleep (2).) +.pp +the +.i nitems +argument specifies the number of items in +.ir aiocb_list . +each item in the list pointed to by +.i aiocb_list +must be either null (and then is ignored), +or a pointer to a control block on which i/o was initiated using +.br aio_read (3), +.br aio_write (3), +or +.br lio_listio (3). +(see +.br aio (7) +for a description of the +.i aiocb +structure.) +.pp +if +.b clock_monotonic +is supported, this clock is used to measure +the timeout interval (see +.br clock_gettime (2)). +.sh return value +if this function returns after completion of one of the i/o +requests specified in +.ir aiocb_list , +0 is returned. +otherwise, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eagain +the call timed out before any of the indicated operations +had completed. +.tp +.b eintr +the call was ended by signal +(possibly the completion signal of one of the operations we were +waiting for); see +.br signal (7). +.tp +.b enosys +.br aio_suspend () +is not implemented. +.sh versions +the +.br aio_suspend () +function is available since glibc 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br aio_suspend () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.pp +posix doesn't specify the parameters to be +.ir restrict ; +that is specific to glibc. +.sh notes +one can achieve polling by using a non-null +.i timeout +that specifies a zero time interval. +.pp +if one or more of the asynchronous i/o operations specified in +.ir aiocb_list +has already completed at the time of the call to +.br aio_suspend (), +then the call returns immediately. +.pp +to determine which i/o operations have completed +after a successful return from +.br aio_suspend (), +use +.br aio_error (3) +to scan the list of +.i aiocb +structures pointed to by +.ir aiocb_list . +.sh bugs +the glibc implementation of +.br aio_suspend () +is not async-signal-safe, +.\" fixme . https://sourceware.org/bugzilla/show_bug.cgi?id=13172 +in violation of the requirements of posix.1. +.sh see also +.br aio_cancel (3), +.br aio_error (3), +.br aio_fsync (3), +.br aio_read (3), +.br aio_return (3), +.br aio_write (3), +.br lio_listio (3), +.br aio (7), +.br time (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/setenv.3 + +.so man2/unimplemented.2 + +.\" copyright (c) 2015 serge hallyn +.\" and copyright (c) 2016, 2017 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th cgroups 7 2021-08-27 "linux" "linux programmer's manual" +.sh name +cgroups \- linux control groups +.sh description +control groups, usually referred to as cgroups, +are a linux kernel feature which allow processes to +be organized into hierarchical groups whose usage of +various types of resources can then be limited and monitored. +the kernel's cgroup interface is provided through +a pseudo-filesystem called cgroupfs. +grouping is implemented in the core cgroup kernel code, +while resource tracking and limits are implemented in +a set of per-resource-type subsystems (memory, cpu, and so on). +.\" +.ss terminology +a +.i cgroup +is a collection of processes that are bound to a set of +limits or parameters defined via the cgroup filesystem. +.pp +a +.i subsystem +is a kernel component that modifies the behavior of +the processes in a cgroup. +various subsystems have been implemented, making it possible to do things +such as limiting the amount of cpu time and memory available to a cgroup, +accounting for the cpu time used by a cgroup, +and freezing and resuming execution of the processes in a cgroup. +subsystems are sometimes also known as +.ir "resource controllers" +(or simply, controllers). +.pp +the cgroups for a controller are arranged in a +.ir hierarchy . +this hierarchy is defined by creating, removing, and +renaming subdirectories within the cgroup filesystem. +at each level of the hierarchy, attributes (e.g., limits) can be defined. +the limits, control, and accounting provided by cgroups generally have +effect throughout the subhierarchy underneath the cgroup where the +attributes are defined. +thus, for example, the limits placed on +a cgroup at a higher level in the hierarchy cannot be exceeded +by descendant cgroups. +.\" +.ss cgroups version 1 and version 2 +the initial release of the cgroups implementation was in linux 2.6.24. +over time, various cgroup controllers have been added +to allow the management of various types of resources. +however, the development of these controllers was largely uncoordinated, +with the result that many inconsistencies arose between controllers +and management of the cgroup hierarchies became rather complex. +a longer description of these problems can be found in the kernel +source file +.ir documentation/admin\-guide/cgroup\-v2.rst +(or +.ir documentation/cgroup\-v2.txt +in linux 4.17 and earlier). +.pp +because of the problems with the initial cgroups implementation +(cgroups version 1), +starting in linux 3.10, work began on a new, +orthogonal implementation to remedy these problems. +initially marked experimental, and hidden behind the +.i "\-o\ __devel__sane_behavior" +mount option, the new version (cgroups version 2) +was eventually made official with the release of linux 4.5. +differences between the two versions are described in the text below. +the file +.ir cgroup.sane_behavior , +present in cgroups v1, is a relic of this mount option. +the file always reports "0" and is only retained for backward compatibility. +.pp +although cgroups v2 is intended as a replacement for cgroups v1, +the older system continues to exist +(and for compatibility reasons is unlikely to be removed). +currently, cgroups v2 implements only a subset of the controllers +available in cgroups v1. +the two systems are implemented so that both v1 controllers and +v2 controllers can be mounted on the same system. +thus, for example, it is possible to use those controllers +that are supported under version 2, +while also using version 1 controllers +where version 2 does not yet support those controllers. +the only restriction here is that a controller can't be simultaneously +employed in both a cgroups v1 hierarchy and in the cgroups v2 hierarchy. +.\" +.sh cgroups version 1 +under cgroups v1, each controller may be mounted against a separate +cgroup filesystem that provides its own hierarchical organization of the +processes on the system. +it is also possible to comount multiple (or even all) cgroups v1 controllers +against the same cgroup filesystem, meaning that the comounted controllers +manage the same hierarchical organization of processes. +.pp +for each mounted hierarchy, +the directory tree mirrors the control group hierarchy. +each control group is represented by a directory, with each of its child +control cgroups represented as a child directory. +for instance, +.ir /user/joe/1.session +represents control group +.ir 1.session , +which is a child of cgroup +.ir joe , +which is a child of +.ir /user . +under each cgroup directory is a set of files which can be read or +written to, reflecting resource limits and a few general cgroup +properties. +.\" +.ss tasks (threads) versus processes +in cgroups v1, a distinction is drawn between +.i processes +and +.ir tasks . +in this view, a process can consist of multiple tasks +(more commonly called threads, from a user-space perspective, +and called such in the remainder of this man page). +in cgroups v1, it is possible to independently manipulate +the cgroup memberships of the threads in a process. +.pp +the cgroups v1 ability to split threads across different cgroups +caused problems in some cases. +for example, it made no sense for the +.i memory +controller, +since all of the threads of a process share a single address space. +because of these problems, +the ability to independently manipulate the cgroup memberships +of the threads in a process was removed in the initial cgroups v2 +implementation, and subsequently restored in a more limited form +(see the discussion of "thread mode" below). +.\" +.ss mounting v1 controllers +the use of cgroups requires a kernel built with the +.br config_cgroup +option. +in addition, each of the v1 controllers has an associated +configuration option that must be set in order to employ that controller. +.pp +in order to use a v1 controller, +it must be mounted against a cgroup filesystem. +the usual place for such mounts is under a +.br tmpfs (5) +filesystem mounted at +.ir /sys/fs/cgroup . +thus, one might mount the +.i cpu +controller as follows: +.pp +.in +4n +.ex +mount \-t cgroup \-o cpu none /sys/fs/cgroup/cpu +.ee +.in +.pp +it is possible to comount multiple controllers against the same hierarchy. +for example, here the +.ir cpu +and +.ir cpuacct +controllers are comounted against a single hierarchy: +.pp +.in +4n +.ex +mount \-t cgroup \-o cpu,cpuacct none /sys/fs/cgroup/cpu,cpuacct +.ee +.in +.pp +comounting controllers has the effect that a process is in the same cgroup for +all of the comounted controllers. +separately mounting controllers allows a process to +be in cgroup +.i /foo1 +for one controller while being in +.i /foo2/foo3 +for another. +.pp +it is possible to comount all v1 controllers against the same hierarchy: +.pp +.in +4n +.ex +mount \-t cgroup \-o all cgroup /sys/fs/cgroup +.ee +.in +.pp +(one can achieve the same result by omitting +.ir "\-o all" , +since it is the default if no controllers are explicitly specified.) +.pp +it is not possible to mount the same controller +against multiple cgroup hierarchies. +for example, it is not possible to mount both the +.i cpu +and +.i cpuacct +controllers against one hierarchy, and to mount the +.i cpu +controller alone against another hierarchy. +it is possible to create multiple mount with exactly +the same set of comounted controllers. +however, in this case all that results is multiple mount points +providing a view of the same hierarchy. +.pp +note that on many systems, the v1 controllers are automatically mounted under +.ir /sys/fs/cgroup ; +in particular, +.br systemd (1) +automatically creates such mounts. +.\" +.ss unmounting v1 controllers +a mounted cgroup filesystem can be unmounted using the +.br umount (8) +command, as in the following example: +.pp +.in +4n +.ex +umount /sys/fs/cgroup/pids +.ee +.in +.pp +.ir "but note well" : +a cgroup filesystem is unmounted only if it is not busy, +that is, it has no child cgroups. +if this is not the case, then the only effect of the +.br umount (8) +is to make the mount invisible. +thus, to ensure that the mount is really removed, +one must first remove all child cgroups, +which in turn can be done only after all member processes +have been moved from those cgroups to the root cgroup. +.\" +.ss cgroups version 1 controllers +each of the cgroups version 1 controllers is governed +by a kernel configuration option (listed below). +additionally, the availability of the cgroups feature is governed by the +.br config_cgroups +kernel configuration option. +.tp +.ir cpu " (since linux 2.6.24; " \fbconfig_cgroup_sched\fp ) +cgroups can be guaranteed a minimum number of "cpu shares" +when a system is busy. +this does not limit a cgroup's cpu usage if the cpus are not busy. +for further information, see +.ir documentation/scheduler/sched\-design\-cfs.rst +(or +.ir documentation/scheduler/sched\-design\-cfs.txt +in linux 5.2 and earlier). +.ip +in linux 3.2, +this controller was extended to provide cpu "bandwidth" control. +if the kernel is configured with +.br config_cfs_bandwidth , +then within each scheduling period +(defined via a file in the cgroup directory), it is possible to define +an upper limit on the cpu time allocated to the processes in a cgroup. +this upper limit applies even if there is no other competition for the cpu. +further information can be found in the kernel source file +.ir documentation/scheduler/sched\-bwc.rst +(or +.ir documentation/scheduler/sched\-bwc.txt +in linux 5.2 and earlier). +.tp +.ir cpuacct " (since linux 2.6.24; " \fbconfig_cgroup_cpuacct\fp ) +this provides accounting for cpu usage by groups of processes. +.ip +further information can be found in the kernel source file +.ir documentation/admin\-guide/cgroup\-v1/cpuacct.rst +(or +.ir documentation/cgroup\-v1/cpuacct.txt +in linux 5.2 and earlier). +.tp +.ir cpuset " (since linux 2.6.24; " \fbconfig_cpusets\fp ) +this cgroup can be used to bind the processes in a cgroup to +a specified set of cpus and numa nodes. +.ip +further information can be found in the kernel source file +.ir documentation/admin\-guide/cgroup\-v1/cpusets.rst +(or +.ir documentation/cgroup\-v1/cpusets.txt +in linux 5.2 and earlier). +. +.tp +.ir memory " (since linux 2.6.25; " \fbconfig_memcg\fp ) +the memory controller supports reporting and limiting of process memory, kernel +memory, and swap used by cgroups. +.ip +further information can be found in the kernel source file +.ir documentation/admin\-guide/cgroup\-v1/memory.rst +(or +.ir documentation/cgroup\-v1/memory.txt +in linux 5.2 and earlier). +.tp +.ir devices " (since linux 2.6.26; " \fbconfig_cgroup_device\fp ) +this supports controlling which processes may create (mknod) devices as +well as open them for reading or writing. +the policies may be specified as allow-lists and deny-lists. +hierarchy is enforced, so new rules must not +violate existing rules for the target or ancestor cgroups. +.ip +further information can be found in the kernel source file +.ir documentation/admin\-guide/cgroup\-v1/devices.rst +(or +.ir documentation/cgroup\-v1/devices.txt +in linux 5.2 and earlier). +.tp +.ir freezer " (since linux 2.6.28; " \fbconfig_cgroup_freezer\fp ) +the +.ir freezer +cgroup can suspend and restore (resume) all processes in a cgroup. +freezing a cgroup +.i /a +also causes its children, for example, processes in +.ir /a/b , +to be frozen. +.ip +further information can be found in the kernel source file +.ir documentation/admin\-guide/cgroup\-v1/freezer\-subsystem.rst +(or +.ir documentation/cgroup\-v1/freezer\-subsystem.txt +in linux 5.2 and earlier). +.tp +.ir net_cls " (since linux 2.6.29; " \fbconfig_cgroup_net_classid\fp ) +this places a classid, specified for the cgroup, on network packets +created by a cgroup. +these classids can then be used in firewall rules, +as well as used to shape traffic using +.br tc (8). +this applies only to packets +leaving the cgroup, not to traffic arriving at the cgroup. +.ip +further information can be found in the kernel source file +.ir documentation/admin\-guide/cgroup\-v1/net_cls.rst +(or +.ir documentation/cgroup\-v1/net_cls.txt +in linux 5.2 and earlier). +.tp +.ir blkio " (since linux 2.6.33; " \fbconfig_blk_cgroup\fp ) +the +.i blkio +cgroup controls and limits access to specified block devices by +applying io control in the form of throttling and upper limits against leaf +nodes and intermediate nodes in the storage hierarchy. +.ip +two policies are available. +the first is a proportional-weight time-based division +of disk implemented with cfq. +this is in effect for leaf nodes using cfq. +the second is a throttling policy which specifies +upper i/o rate limits on a device. +.ip +further information can be found in the kernel source file +.ir documentation/admin\-guide/cgroup\-v1/blkio\-controller.rst +(or +.ir documentation/cgroup\-v1/blkio\-controller.txt +in linux 5.2 and earlier). +.tp +.ir perf_event " (since linux 2.6.39; " \fbconfig_cgroup_perf\fp ) +this controller allows +.i perf +monitoring of the set of processes grouped in a cgroup. +.ip +further information can be found in the kernel source files +.tp +.ir net_prio " (since linux 3.3; " \fbconfig_cgroup_net_prio\fp ) +this allows priorities to be specified, per network interface, for cgroups. +.ip +further information can be found in the kernel source file +.ir documentation/admin\-guide/cgroup\-v1/net_prio.rst +(or +.ir documentation/cgroup\-v1/net_prio.txt +in linux 5.2 and earlier). +.tp +.ir hugetlb " (since linux 3.5; " \fbconfig_cgroup_hugetlb\fp ) +this supports limiting the use of huge pages by cgroups. +.ip +further information can be found in the kernel source file +.ir documentation/admin\-guide/cgroup\-v1/hugetlb.rst +(or +.ir documentation/cgroup\-v1/hugetlb.txt +in linux 5.2 and earlier). +.tp +.ir pids " (since linux 4.3; " \fbconfig_cgroup_pids\fp ) +this controller permits limiting the number of process that may be created +in a cgroup (and its descendants). +.ip +further information can be found in the kernel source file +.ir documentation/admin\-guide/cgroup\-v1/pids.rst +(or +.ir documentation/cgroup\-v1/pids.txt +in linux 5.2 and earlier). +.tp +.ir rdma " (since linux 4.11; " \fbconfig_cgroup_rdma\fp ) +the rdma controller permits limiting the use of +rdma/ib-specific resources per cgroup. +.ip +further information can be found in the kernel source file +.ir documentation/admin\-guide/cgroup\-v1/rdma.rst +(or +.ir documentation/cgroup\-v1/rdma.txt +in linux 5.2 and earlier). +.\" +.ss creating cgroups and moving processes +a cgroup filesystem initially contains a single root cgroup, '/', +which all processes belong to. +a new cgroup is created by creating a directory in the cgroup filesystem: +.pp +.in +4n +.ex +mkdir /sys/fs/cgroup/cpu/cg1 +.ee +.in +.pp +this creates a new empty cgroup. +.pp +a process may be moved to this cgroup by writing its pid into the cgroup's +.i cgroup.procs +file: +.pp +.in +4n +.ex +echo $$ > /sys/fs/cgroup/cpu/cg1/cgroup.procs +.ee +.in +.pp +only one pid at a time should be written to this file. +.pp +writing the value 0 to a +.ir cgroup.procs +file causes the writing process to be moved to the corresponding cgroup. +.pp +when writing a pid into the +.ir cgroup.procs , +all threads in the process are moved into the new cgroup at once. +.pp +within a hierarchy, a process can be a member of exactly one cgroup. +writing a process's pid to a +.ir cgroup.procs +file automatically removes it from the cgroup of +which it was previously a member. +.pp +the +.i cgroup.procs +file can be read to obtain a list of the processes that are +members of a cgroup. +the returned list of pids is not guaranteed to be in order. +nor is it guaranteed to be free of duplicates. +(for example, a pid may be recycled while reading from the list.) +.pp +in cgroups v1, an individual thread can be moved to +another cgroup by writing its thread id +(i.e., the kernel thread id returned by +.br clone (2) +and +.br gettid (2)) +to the +.ir tasks +file in a cgroup directory. +this file can be read to discover the set of threads +that are members of the cgroup. +.\" +.ss removing cgroups +to remove a cgroup, +it must first have no child cgroups and contain no (nonzombie) processes. +so long as that is the case, one can simply +remove the corresponding directory pathname. +note that files in a cgroup directory cannot and need not be +removed. +.\" +.ss cgroups v1 release notification +two files can be used to determine whether the kernel provides +notifications when a cgroup becomes empty. +a cgroup is considered to be empty when it contains no child +cgroups and no member processes. +.pp +a special file in the root directory of each cgroup hierarchy, +.ir release_agent , +can be used to register the pathname of a program that may be invoked when +a cgroup in the hierarchy becomes empty. +the pathname of the newly empty cgroup (relative to the cgroup mount point) +is provided as the sole command-line argument when the +.ir release_agent +program is invoked. +the +.ir release_agent +program might remove the cgroup directory, +or perhaps repopulate it with a process. +.pp +the default value of the +.ir release_agent +file is empty, meaning that no release agent is invoked. +.pp +the content of the +.i release_agent +file can also be specified via a mount option when the +cgroup filesystem is mounted: +.pp +.in +4n +.ex +mount \-o release_agent=pathname ... +.ee +.in +.pp +whether or not the +.ir release_agent +program is invoked when a particular cgroup becomes empty is determined +by the value in the +.ir notify_on_release +file in the corresponding cgroup directory. +if this file contains the value 0, then the +.ir release_agent +program is not invoked. +if it contains the value 1, the +.ir release_agent +program is invoked. +the default value for this file in the root cgroup is 0. +at the time when a new cgroup is created, +the value in this file is inherited from the corresponding file +in the parent cgroup. +.\" +.ss cgroup v1 named hierarchies +in cgroups v1, +it is possible to mount a cgroup hierarchy that has no attached controllers: +.pp +.in +4n +.ex +mount \-t cgroup \-o none,name=somename none /some/mount/point +.ee +.in +.pp +multiple instances of such hierarchies can be mounted; +each hierarchy must have a unique name. +the only purpose of such hierarchies is to track processes. +(see the discussion of release notification below.) +an example of this is the +.i name=systemd +cgroup hierarchy that is used by +.br systemd (1) +to track services and user sessions. +.pp +since linux 5.0, the +.i cgroup_no_v1 +kernel boot option (described below) can be used to disable cgroup v1 +named hierarchies, by specifying +.ir cgroup_no_v1=named . +.\" +.sh cgroups version 2 +in cgroups v2, +all mounted controllers reside in a single unified hierarchy. +while (different) controllers may be simultaneously +mounted under the v1 and v2 hierarchies, +it is not possible to mount the same controller simultaneously +under both the v1 and the v2 hierarchies. +.pp +the new behaviors in cgroups v2 are summarized here, +and in some cases elaborated in the following subsections. +.ip 1. 3 +cgroups v2 provides a unified hierarchy against +which all controllers are mounted. +.ip 2. +"internal" processes are not permitted. +with the exception of the root cgroup, processes may reside +only in leaf nodes (cgroups that do not themselves contain child cgroups). +the details are somewhat more subtle than this, and are described below. +.ip 3. +active cgroups must be specified via the files +.ir cgroup.controllers +and +.ir cgroup.subtree_control . +.ip 4. +the +.i tasks +file has been removed. +in addition, the +.i cgroup.clone_children +file that is employed by the +.i cpuset +controller has been removed. +.ip 5. +an improved mechanism for notification of empty cgroups is provided by the +.ir cgroup.events +file. +.pp +for more changes, see the +.ir documentation/admin\-guide/cgroup\-v2.rst +file in the kernel source +(or +.ir documentation/cgroup\-v2.txt +in linux 4.17 and earlier). +. +.pp +some of the new behaviors listed above saw subsequent modification with +the addition in linux 4.14 of "thread mode" (described below). +.\" +.ss cgroups v2 unified hierarchy +in cgroups v1, the ability to mount different controllers +against different hierarchies was intended to allow great flexibility +for application design. +in practice, though, +the flexibility turned out to be less useful than expected, +and in many cases added complexity. +therefore, in cgroups v2, +all available controllers are mounted against a single hierarchy. +the available controllers are automatically mounted, +meaning that it is not necessary (or possible) to specify the controllers +when mounting the cgroup v2 filesystem using a command such as the following: +.pp +.in +4n +.ex +mount \-t cgroup2 none /mnt/cgroup2 +.ee +.in +.pp +a cgroup v2 controller is available only if it is not currently in use +via a mount against a cgroup v1 hierarchy. +or, to put things another way, it is not possible to employ +the same controller against both a v1 hierarchy and the unified v2 hierarchy. +this means that it may be necessary first to unmount a v1 controller +(as described above) before that controller is available in v2. +since +.br systemd (1) +makes heavy use of some v1 controllers by default, +it can in some cases be simpler to boot the system with +selected v1 controllers disabled. +to do this, specify the +.ir cgroup_no_v1=list +option on the kernel boot command line; +.i list +is a comma-separated list of the names of the controllers to disable, +or the word +.i all +to disable all v1 controllers. +(this situation is correctly handled by +.br systemd (1), +which falls back to operating without the specified controllers.) +.pp +note that on many modern systems, +.br systemd (1) +automatically mounts the +.i cgroup2 +filesystem at +.i /sys/fs/cgroup/unified +during the boot process. +.\" +.ss cgroups v2 mount options +the following options +.ri ( "mount \-o" ) +can be specified when mounting the group v2 filesystem: +.tp +.ir nsdelegate " (since linux 4.15)" +treat cgroup namespaces as delegation boundaries. +for details, see below. +.tp +.ir memory_localevents " (since linux 5.2)" +.\" commit 9852ae3fe5293264f01c49f2571ef7688f7823ce +the +.i memory.events +should show statistics only for the cgroup itself, +and not for any descendant cgroups. +this was the behavior before linux 5.2. +starting in linux 5.2, +the default behavior is to include statistics for descendant cgroups in +.ir memory.events , +and this mount option can be used to revert to the legacy behavior. +this option is system wide and can be set on mount or +modified through remount only from the initial mount namespace; +it is silently ignored in noninitial namespaces. +.\" +.ss cgroups v2 controllers +the following controllers, documented in the kernel source file +.ir documentation/admin\-guide/cgroup\-v2.rst +(or +.ir documentation/cgroup\-v2.txt +in linux 4.17 and earlier), +are supported in cgroups version 2: +.tp +.ir cpu " (since linux 4.15)" +this is the successor to the version 1 +.i cpu +and +.i cpuacct +controllers. +.tp +.ir cpuset " (since linux 5.0)" +this is the successor of the version 1 +.i cpuset +controller. +.tp +.ir freezer " (since linux 5.2)" +.\" commit 76f969e8948d82e78e1bc4beb6b9465908e74873 +this is the successor of the version 1 +.i freezer +controller. +.tp +.ir hugetlb " (since linux 5.6)" +this is the successor of the version 1 +.i hugetlb +controller. +.tp +.ir io " (since linux 4.5)" +this is the successor of the version 1 +.i blkio +controller. +.tp +.ir memory " (since linux 4.5)" +this is the successor of the version 1 +.i memory +controller. +.tp +.ir perf_event " (since linux 4.11)" +this is the same as the version 1 +.i perf_event +controller. +.tp +.ir pids " (since linux 4.5)" +this is the same as the version 1 +.i pids +controller. +.tp +.ir rdma " (since linux 4.11)" +this is the same as the version 1 +.i rdma +controller. +.pp +there is no direct equivalent of the +.i net_cls +and +.i net_prio +controllers from cgroups version 1. +instead, support has been added to +.br iptables (8) +to allow ebpf filters that hook on cgroup v2 pathnames to make decisions +about network traffic on a per-cgroup basis. +.pp +the v2 +.i devices +controller provides no interface files; +instead, device control is gated by attaching an ebpf +.rb ( bpf_cgroup_device ) +program to a v2 cgroup. +.\" +.ss cgroups v2 subtree control +each cgroup in the v2 hierarchy contains the following two files: +.tp +.ir cgroup.controllers +this read-only file exposes a list of the controllers that are +.i available +in this cgroup. +the contents of this file match the contents of the +.i cgroup.subtree_control +file in the parent cgroup. +.tp +.i cgroup.subtree_control +this is a list of controllers that are +.ir active +.ri ( enabled ) +in the cgroup. +the set of controllers in this file is a subset of the set in the +.ir cgroup.controllers +of this cgroup. +the set of active controllers is modified by writing strings to this file +containing space-delimited controller names, +each preceded by '+' (to enable a controller) +or '\-' (to disable a controller), as in the following example: +.ip +.in +4n +.ex +echo \(aq+pids \-memory\(aq > x/y/cgroup.subtree_control +.ee +.in +.ip +an attempt to enable a controller +that is not present in +.i cgroup.controllers +leads to an +.b enoent +error when writing to the +.i cgroup.subtree_control +file. +.pp +because the list of controllers in +.i cgroup.subtree_control +is a subset of those +.ir cgroup.controllers , +a controller that has been disabled in one cgroup in the hierarchy +can never be re-enabled in the subtree below that cgroup. +.pp +a cgroup's +.i cgroup.subtree_control +file determines the set of controllers that are exercised in the +.i child +cgroups. +when a controller (e.g., +.ir pids ) +is present in the +.i cgroup.subtree_control +file of a parent cgroup, +then the corresponding controller-interface files (e.g., +.ir pids.max ) +are automatically created in the children of that cgroup +and can be used to exert resource control in the child cgroups. +.\" +.ss cgroups v2 """no internal processes""" rule +cgroups v2 enforces a so-called "no internal processes" rule. +roughly speaking, this rule means that, +with the exception of the root cgroup, processes may reside +only in leaf nodes (cgroups that do not themselves contain child cgroups). +this avoids the need to decide how to partition resources between +processes which are members of cgroup a and processes in child cgroups of a. +.pp +for instance, if cgroup +.i /cg1/cg2 +exists, then a process may reside in +.ir /cg1/cg2 , +but not in +.ir /cg1 . +this is to avoid an ambiguity in cgroups v1 +with respect to the delegation of resources between processes in +.i /cg1 +and its child cgroups. +the recommended approach in cgroups v2 is to create a subdirectory called +.i leaf +for any nonleaf cgroup which should contain processes, but no child cgroups. +thus, processes which previously would have gone into +.i /cg1 +would now go into +.ir /cg1/leaf . +this has the advantage of making explicit +the relationship between processes in +.i /cg1/leaf +and +.ir /cg1 's +other children. +.pp +the "no internal processes" rule is in fact more subtle than stated above. +more precisely, the rule is that a (nonroot) cgroup can't both +(1) have member processes, and +(2) distribute resources into child cgroups\(emthat is, have a nonempty +.i cgroup.subtree_control +file. +thus, it +.i is +possible for a cgroup to have both member processes and child cgroups, +but before controllers can be enabled for that cgroup, +the member processes must be moved out of the cgroup +(e.g., perhaps into the child cgroups). +.pp +with the linux 4.14 addition of "thread mode" (described below), +the "no internal processes" rule has been relaxed in some cases. +.\" +.ss cgroups v2 cgroup.events file +each nonroot cgroup in the v2 hierarchy contains a read-only file, +.ir cgroup.events , +whose contents are key-value pairs +(delimited by newline characters, with the key and value separated by spaces) +providing state information about the cgroup: +.pp +.in +4n +.ex +$ \fbcat mygrp/cgroup.events\fp +populated 1 +frozen 0 +.ee +.in +.pp +the following keys may appear in this file: +.tp +.ir populated +the value of this key is either 1, +if this cgroup or any of its descendants has member processes, +or otherwise 0. +.tp +.ir frozen " (since linux 5.2)" +.\" commit 76f969e8948d82e78e1bc4beb6b9465908e7487 +the value of this key is 1 if this cgroup is currently frozen, +or 0 if it is not. +.pp +the +.ir cgroup.events +file can be monitored, in order to receive notification when the value of +one of its keys changes. +such monitoring can be done using +.br inotify (7), +which notifies changes as +.br in_modify +events, or +.br poll (2), +which notifies changes by returning the +.b pollpri +and +.b pollerr +bits in the +.ir revents +field. +.\" +.ss cgroup v2 release notification +cgroups v2 provides a new mechanism for obtaining notification +when a cgroup becomes empty. +the cgroups v1 +.ir release_agent +and +.ir notify_on_release +files are removed, and replaced by the +.i populated +key in the +.ir cgroup.events +file. +this key either has the value 0, +meaning that the cgroup (and its descendants) +contain no (nonzombie) member processes, +or 1, meaning that the cgroup (or one of its descendants) +contains member processes. +.pp +the cgroups v2 release-notification mechanism +offers the following advantages over the cgroups v1 +.ir release_agent +mechanism: +.ip * 3 +it allows for cheaper notification, +since a single process can monitor multiple +.ir cgroup.events +files (using the techniques described earlier). +by contrast, the cgroups v1 mechanism requires the expense of creating +a process for each notification. +.ip * +notification for different cgroup subhierarchies can be delegated +to different processes. +by contrast, the cgroups v1 mechanism allows only one release agent +for an entire hierarchy. +.\" +.ss cgroups v2 cgroup.stat file +.\" commit ec39225cca42c05ac36853d11d28f877fde5c42e +each cgroup in the v2 hierarchy contains a read-only +.ir cgroup.stat +file (first introduced in linux 4.14) +that consists of lines containing key-value pairs. +the following keys currently appear in this file: +.tp +.i nr_descendants +this is the total number of visible (i.e., living) descendant cgroups +underneath this cgroup. +.tp +.i nr_dying_descendants +this is the total number of dying descendant cgroups +underneath this cgroup. +a cgroup enters the dying state after being deleted. +it remains in that state for an undefined period +(which will depend on system load) +while resources are freed before the cgroup is destroyed. +note that the presence of some cgroups in the dying state is normal, +and is not indicative of any problem. +.ip +a process can't be made a member of a dying cgroup, +and a dying cgroup can't be brought back to life. +.\" +.ss limiting the number of descendant cgroups +each cgroup in the v2 hierarchy contains the following files, +which can be used to view and set limits on the number +of descendant cgroups under that cgroup: +.tp +.ir cgroup.max.depth " (since linux 4.14)" +.\" commit 1a926e0bbab83bae8207d05a533173425e0496d1 +this file defines a limit on the depth of nesting of descendant cgroups. +a value of 0 in this file means that no descendant cgroups can be created. +an attempt to create a descendant whose nesting level exceeds +the limit fails +.ri ( mkdir (2) +fails with the error +.br eagain ). +.ip +writing the string +.ir """max""" +to this file means that no limit is imposed. +the default value in this file is +.ir """max""" . +.tp +.ir cgroup.max.descendants " (since linux 4.14)" +.\" commit 1a926e0bbab83bae8207d05a533173425e0496d1 +this file defines a limit on the number of live descendant cgroups that +this cgroup may have. +an attempt to create more descendants than allowed by the limit fails +.ri ( mkdir (2) +fails with the error +.br eagain ). +.ip +writing the string +.ir """max""" +to this file means that no limit is imposed. +the default value in this file is +.ir """max""" . +.\" +.sh cgroups delegation: delegating a hierarchy to a less privileged user +in the context of cgroups, +delegation means passing management of some subtree +of the cgroup hierarchy to a nonprivileged user. +cgroups v1 provides support for delegation based on file permissions +in the cgroup hierarchy but with less strict containment rules than v2 +(as noted below). +cgroups v2 supports delegation with containment by explicit design. +the focus of the discussion in this section is on delegation in cgroups v2, +with some differences for cgroups v1 noted along the way. +.pp +some terminology is required in order to describe delegation. +a +.i delegater +is a privileged user (i.e., root) who owns a parent cgroup. +a +.i delegatee +is a nonprivileged user who will be granted the permissions needed +to manage some subhierarchy under that parent cgroup, +known as the +.ir "delegated subtree" . +.pp +to perform delegation, +the delegater makes certain directories and files writable by the delegatee, +typically by changing the ownership of the objects to be the user id +of the delegatee. +assuming that we want to delegate the hierarchy rooted at (say) +.i /dlgt_grp +and that there are not yet any child cgroups under that cgroup, +the ownership of the following is changed to the user id of the delegatee: +.tp +.ir /dlgt_grp +changing the ownership of the root of the subtree means that any new +cgroups created under the subtree (and the files they contain) +will also be owned by the delegatee. +.tp +.ir /dlgt_grp/cgroup.procs +changing the ownership of this file means that the delegatee +can move processes into the root of the delegated subtree. +.tp +.ir /dlgt_grp/cgroup.subtree_control " (cgroups v2 only)" +changing the ownership of this file means that the delegatee +can enable controllers (that are present in +.ir /dlgt_grp/cgroup.controllers ) +in order to further redistribute resources at lower levels in the subtree. +(as an alternative to changing the ownership of this file, +the delegater might instead add selected controllers to this file.) +.tp +.ir /dlgt_grp/cgroup.threads " (cgroups v2 only)" +changing the ownership of this file is necessary if a threaded subtree +is being delegated (see the description of "thread mode", below). +this permits the delegatee to write thread ids to the file. +(the ownership of this file can also be changed when delegating +a domain subtree, but currently this serves no purpose, +since, as described below, it is not possible to move a thread between +domain cgroups by writing its thread id to the +.ir cgroup.threads +file.) +.ip +in cgroups v1, the corresponding file that should instead be delegated is the +.i tasks +file. +.pp +the delegater should +.i not +change the ownership of any of the controller interfaces files (e.g., +.ir pids.max , +.ir memory.high ) +in +.ir dlgt_grp . +those files are used from the next level above the delegated subtree +in order to distribute resources into the subtree, +and the delegatee should not have permission to change +the resources that are distributed into the delegated subtree. +.pp +see also the discussion of the +.ir /sys/kernel/cgroup/delegate +file in notes for information about further delegatable files in cgroups v2. +.pp +after the aforementioned steps have been performed, +the delegatee can create child cgroups within the delegated subtree +(the cgroup subdirectories and the files they contain +will be owned by the delegatee) +and move processes between cgroups in the subtree. +if some controllers are present in +.ir dlgt_grp/cgroup.subtree_control , +or the ownership of that file was passed to the delegatee, +the delegatee can also control the further redistribution +of the corresponding resources into the delegated subtree. +.\" +.ss cgroups v2 delegation: nsdelegate and cgroup namespaces +starting with linux 4.13, +.\" commit 5136f6365ce3eace5a926e10f16ed2a233db5ba9 +there is a second way to perform cgroup delegation in the cgroups v2 hierarchy. +this is done by mounting or remounting the cgroup v2 filesystem with the +.i nsdelegate +mount option. +for example, if the cgroup v2 filesystem has already been mounted, +we can remount it with the +.i nsdelegate +option as follows: +.pp +.in +4n +.ex +mount \-t cgroup2 \-o remount,nsdelegate \e + none /sys/fs/cgroup/unified +.ee +.in +.\" +.\" alternatively, we could boot the kernel with the options: +.\" +.\" cgroup_no_v1=all systemd.legacy_systemd_cgroup_controller +.\" +.\" the effect of the latter option is to prevent systemd from employing +.\" its "hybrid" cgroup mode, where it tries to make use of cgroups v2. +.pp +the effect of this mount option is to cause cgroup namespaces +to automatically become delegation boundaries. +more specifically, +the following restrictions apply for processes inside the cgroup namespace: +.ip * 3 +writes to controller interface files in the root directory of the namespace +will fail with the error +.br eperm . +processes inside the cgroup namespace can still write to delegatable +files in the root directory of the cgroup namespace such as +.ir cgroup.procs +and +.ir cgroup.subtree_control , +and can create subhierarchy underneath the root directory. +.ip * +attempts to migrate processes across the namespace boundary are denied +(with the error +.br enoent ). +processes inside the cgroup namespace can still +(subject to the containment rules described below) +move processes between cgroups +.i within +the subhierarchy under the namespace root. +.pp +the ability to define cgroup namespaces as delegation boundaries +makes cgroup namespaces more useful. +to understand why, suppose that we already have one cgroup hierarchy +that has been delegated to a nonprivileged user, +.ir cecilia , +using the older delegation technique described above. +suppose further that +.i cecilia +wanted to further delegate a subhierarchy +under the existing delegated hierarchy. +(for example, the delegated hierarchy might be associated with +an unprivileged container run by +.ir cecilia .) +even if a cgroup namespace was employed, +because both hierarchies are owned by the unprivileged user +.ir cecilia , +the following illegitimate actions could be performed: +.ip * 3 +a process in the inferior hierarchy could change the +resource controller settings in the root directory of that hierarchy. +(these resource controller settings are intended to allow control to +be exercised from the +.i parent +cgroup; +a process inside the child cgroup should not be allowed to modify them.) +.ip * +a process inside the inferior hierarchy could move processes +into and out of the inferior hierarchy if the cgroups in the +superior hierarchy were somehow visible. +.pp +employing the +.i nsdelegate +mount option prevents both of these possibilities. +.pp +the +.i nsdelegate +mount option only has an effect when performed in +the initial mount namespace; +in other mount namespaces, the option is silently ignored. +.pp +.ir note : +on some systems, +.br systemd (1) +automatically mounts the cgroup v2 filesystem. +in order to experiment with the +.i nsdelegate +operation, it may be useful to boot the kernel with +the following command-line options: +.pp +.in +4n +.ex +cgroup_no_v1=all systemd.legacy_systemd_cgroup_controller +.ee +.in +.pp +these options cause the kernel to boot with the cgroups v1 controllers +disabled (meaning that the controllers are available in the v2 hierarchy), +and tells +.br systemd (1) +not to mount and use the cgroup v2 hierarchy, +so that the v2 hierarchy can be manually mounted +with the desired options after boot-up. +.\" +.ss cgroup delegation containment rules +some delegation +.ir "containment rules" +ensure that the delegatee can move processes between cgroups within the +delegated subtree, +but can't move processes from outside the delegated subtree into +the subtree or vice versa. +a nonprivileged process (i.e., the delegatee) can write the pid of +a "target" process into a +.ir cgroup.procs +file only if all of the following are true: +.ip * 3 +the writer has write permission on the +.i cgroup.procs +file in the destination cgroup. +.ip * +the writer has write permission on the +.i cgroup.procs +file in the nearest common ancestor of the source and destination cgroups. +note that in some cases, +the nearest common ancestor may be the source or destination cgroup itself. +this requirement is not enforced for cgroups v1 hierarchies, +with the consequence that containment in v1 is less strict than in v2. +(for example, in cgroups v1 the user that owns two distinct +delegated subhierarchies can move a process between the hierarchies.) +.ip * +if the cgroup v2 filesystem was mounted with the +.i nsdelegate +option, the writer must be able to see the source and destination cgroups +from its cgroup namespace. +.ip * +in cgroups v1: +the effective uid of the writer (i.e., the delegatee) matches the +real user id or the saved set-user-id of the target process. +before linux 4.11, +.\" commit 576dd464505fc53d501bb94569db76f220104d28 +this requirement also applied in cgroups v2 +(this was a historical requirement inherited from cgroups v1 +that was later deemed unnecessary, +since the other rules suffice for containment in cgroups v2.) +.pp +.ir note : +one consequence of these delegation containment rules is that the +unprivileged delegatee can't place the first process into +the delegated subtree; +instead, the delegater must place the first process +(a process owned by the delegatee) into the delegated subtree. +.\" +.sh cgroups version 2 thread mode +among the restrictions imposed by cgroups v2 that were not present +in cgroups v1 are the following: +.ip * 3 +.ir "no thread-granularity control" : +all of the threads of a process must be in the same cgroup. +.ip * +.ir "no internal processes" : +a cgroup can't both have member processes and +exercise controllers on child cgroups. +.pp +both of these restrictions were added because +the lack of these restrictions had caused problems +in cgroups v1. +in particular, the cgroups v1 ability to allow thread-level granularity +for cgroup membership made no sense for some controllers. +(a notable example was the +.i memory +controller: since threads share an address space, +it made no sense to split threads across different +.i memory +cgroups.) +.pp +notwithstanding the initial design decision in cgroups v2, +there were use cases for certain controllers, notably the +.ir cpu +controller, +for which thread-level granularity of control was meaningful and useful. +to accommodate such use cases, linux 4.14 added +.i "thread mode" +for cgroups v2. +.pp +thread mode allows the following: +.ip * 3 +the creation of +.ir "threaded subtrees" +in which the threads of a process may +be spread across cgroups inside the tree. +(a threaded subtree may contain multiple multithreaded processes.) +.ip * +the concept of +.ir "threaded controllers", +which can distribute resources across the cgroups in a threaded subtree. +.ip * +a relaxation of the "no internal processes rule", +so that, within a threaded subtree, +a cgroup can both contain member threads and +exercise resource control over child cgroups. +.pp +with the addition of thread mode, +each nonroot cgroup now contains a new file, +.ir cgroup.type , +that exposes, and in some circumstances can be used to change, +the "type" of a cgroup. +this file contains one of the following type values: +.tp +.i "domain" +this is a normal v2 cgroup that provides process-granularity control. +if a process is a member of this cgroup, +then all threads of the process are (by definition) in the same cgroup. +this is the default cgroup type, +and provides the same behavior that was provided for +cgroups in the initial cgroups v2 implementation. +.tp +.i "threaded" +this cgroup is a member of a threaded subtree. +threads can be added to this cgroup, +and controllers can be enabled for the cgroup. +.tp +.i "domain threaded" +this is a domain cgroup that serves as the root of a threaded subtree. +this cgroup type is also known as "threaded root". +.tp +.i "domain invalid" +this is a cgroup inside a threaded subtree +that is in an "invalid" state. +processes can't be added to the cgroup, +and controllers can't be enabled for the cgroup. +the only thing that can be done with this cgroup (other than deleting it) +is to convert it to a +.ir threaded +cgroup by writing the string +.ir """threaded""" +to the +.i cgroup.type +file. +.ip +the rationale for the existence of this "interim" type +during the creation of a threaded subtree +(rather than the kernel simply immediately converting all cgroups +under the threaded root to the type +.ir threaded ) +is to allow for +possible future extensions to the thread mode model +.\" +.ss threaded versus domain controllers +with the addition of threads mode, +cgroups v2 now distinguishes two types of resource controllers: +.ip * 3 +.i threaded +.\" in the kernel source, look for ".threaded[ \t]*= true" in +.\" initializations of struct cgroup_subsys +controllers: these controllers support thread-granularity for +resource control and can be enabled inside threaded subtrees, +with the result that the corresponding controller-interface files +appear inside the cgroups in the threaded subtree. +as at linux 4.19, the following controllers are threaded: +.ir cpu , +.ir perf_event , +and +.ir pids . +.ip * +.i domain +controllers: these controllers support only process granularity +for resource control. +from the perspective of a domain controller, +all threads of a process are always in the same cgroup. +domain controllers can't be enabled inside a threaded subtree. +.\" +.ss creating a threaded subtree +there are two pathways that lead to the creation of a threaded subtree. +the first pathway proceeds as follows: +.ip 1. 3 +we write the string +.ir """threaded""" +to the +.i cgroup.type +file of a cgroup +.ir y/z +that currently has the type +.ir domain . +this has the following effects: +.rs +.ip * 3 +the type of the cgroup +.ir y/z +becomes +.ir threaded . +.ip * +the type of the parent cgroup, +.ir y , +becomes +.ir "domain threaded" . +the parent cgroup is the root of a threaded subtree +(also known as the "threaded root"). +.ip * +all other cgroups under +.ir y +that were not already of type +.ir threaded +(because they were inside already existing threaded subtrees +under the new threaded root) +are converted to type +.ir "domain invalid" . +any subsequently created cgroups under +.i y +will also have the type +.ir "domain invalid" . +.re +.ip 2. +we write the string +.ir """threaded""" +to each of the +.ir "domain invalid" +cgroups under +.ir y , +in order to convert them to the type +.ir threaded . +as a consequence of this step, all threads under the threaded root +now have the type +.ir threaded +and the threaded subtree is now fully usable. +the requirement to write +.ir """threaded""" +to each of these cgroups is somewhat cumbersome, +but allows for possible future extensions to the thread-mode model. +.pp +the second way of creating a threaded subtree is as follows: +.ip 1. 3 +in an existing cgroup, +.ir z , +that currently has the type +.ir domain , +we (1) enable one or more threaded controllers and +(2) make a process a member of +.ir z . +(these two steps can be done in either order.) +this has the following consequences: +.rs +.ip * 3 +the type of +.i z +becomes +.ir "domain threaded" . +.ip * +all of the descendant cgroups of +.i x +that were not already of type +.ir threaded +are converted to type +.ir "domain invalid" . +.re +.ip 2. +as before, we make the threaded subtree usable by writing the string +.ir """threaded""" +to each of the +.ir "domain invalid" +cgroups under +.ir y , +in order to convert them to the type +.ir threaded . +.pp +one of the consequences of the above pathways to creating a threaded subtree +is that the threaded root cgroup can be a parent only to +.i threaded +(and +.ir "domain invalid" ) +cgroups. +the threaded root cgroup can't be a parent of a +.i domain +cgroups, and a +.i threaded +cgroup +can't have a sibling that is a +.i domain +cgroup. +.\" +.ss using a threaded subtree +within a threaded subtree, threaded controllers can be enabled +in each subgroup whose type has been changed to +.ir threaded ; +upon doing so, the corresponding controller interface files +appear in the children of that cgroup. +.pp +a process can be moved into a threaded subtree by writing its pid to the +.i cgroup.procs +file in one of the cgroups inside the tree. +this has the effect of making all of the threads +in the process members of the corresponding cgroup +and makes the process a member of the threaded subtree. +the threads of the process can then be spread across +the threaded subtree by writing their thread ids (see +.br gettid (2)) +to the +.i cgroup.threads +files in different cgroups inside the subtree. +the threads of a process must all reside in the same threaded subtree. +.pp +as with writing to +.ir cgroup.procs , +some containment rules apply when writing to the +.i cgroup.threads +file: +.ip * 3 +the writer must have write permission on the +cgroup.threads +file in the destination cgroup. +.ip * +the writer must have write permission on the +.i cgroup.procs +file in the common ancestor of the source and destination cgroups. +(in some cases, +the common ancestor may be the source or destination cgroup itself.) +.ip * +the source and destination cgroups must be in the same threaded subtree. +(outside a threaded subtree, an attempt to move a thread by writing +its thread id to the +.i cgroup.threads +file in a different +.i domain +cgroup fails with the error +.br eopnotsupp .) +.pp +the +.i cgroup.threads +file is present in each cgroup (including +.i domain +cgroups) and can be read in order to discover the set of threads +that is present in the cgroup. +the set of thread ids obtained when reading this file +is not guaranteed to be ordered or free of duplicates. +.pp +the +.i cgroup.procs +file in the threaded root shows the pids of all processes +that are members of the threaded subtree. +the +.i cgroup.procs +files in the other cgroups in the subtree are not readable. +.pp +domain controllers can't be enabled in a threaded subtree; +no controller-interface files appear inside the cgroups underneath the +threaded root. +from the point of view of a domain controller, +threaded subtrees are invisible: +a multithreaded process inside a threaded subtree appears to a domain +controller as a process that resides in the threaded root cgroup. +.pp +within a threaded subtree, the "no internal processes" rule does not apply: +a cgroup can both contain member processes (or thread) +and exercise controllers on child cgroups. +.\" +.ss rules for writing to cgroup.type and creating threaded subtrees +a number of rules apply when writing to the +.i cgroup.type +file: +.ip * 3 +only the string +.ir """threaded""" +may be written. +in other words, the only explicit transition that is possible is to convert a +.i domain +cgroup to type +.ir threaded . +.ip * +the effect of writing +.ir """threaded""" +depends on the current value in +.ir cgroup.type , +as follows: +.rs +.ip \(bu 3 +.ir domain +or +.ir "domain threaded" : +start the creation of a threaded subtree +(whose root is the parent of this cgroup) via +the first of the pathways described above; +.ip \(bu +.ir "domain\ invalid" : +convert this cgroup (which is inside a threaded subtree) to a usable (i.e., +.ir threaded ) +state; +.ip \(bu +.ir threaded : +no effect (a "no-op"). +.re +.ip * +we can't write to a +.i cgroup.type +file if the parent's type is +.ir "domain invalid" . +in other words, the cgroups of a threaded subtree must be converted to the +.i threaded +state in a top-down manner. +.pp +there are also some constraints that must be satisfied +in order to create a threaded subtree rooted at the cgroup +.ir x : +.ip * 3 +there can be no member processes in the descendant cgroups of +.ir x . +(the cgroup +.i x +can itself have member processes.) +.ip * +no domain controllers may be enabled in +.ir x 's +.ir cgroup.subtree_control +file. +.pp +if any of the above constraints is violated, then an attempt to write +.ir """threaded""" +to a +.ir cgroup.type +file fails with the error +.br enotsup . +.\" +.ss the """domain threaded""" cgroup type +according to the pathways described above, +the type of a cgroup can change to +.ir "domain threaded" +in either of the following cases: +.ip * 3 +the string +.ir """threaded""" +is written to a child cgroup. +.ip * +a threaded controller is enabled inside the cgroup and +a process is made a member of the cgroup. +.pp +a +.ir "domain threaded" +cgroup, +.ir x , +can revert to the type +.ir domain +if the above conditions no longer hold true\(emthat is, if all +.i threaded +child cgroups of +.i x +are removed and either +.i x +no longer has threaded controllers enabled or +no longer has member processes. +.pp +when a +.ir "domain threaded" +cgroup +.ir x +reverts to the type +.ir domain : +.ip * 3 +all +.ir "domain invalid" +descendants of +.i x +that are not in lower-level threaded subtrees revert to the type +.ir domain . +.ip * +the root cgroups in any lower-level threaded subtrees revert to the type +.ir "domain threaded" . +.\" +.ss exceptions for the root cgroup +the root cgroup of the v2 hierarchy is treated exceptionally: +it can be the parent of both +.i domain +and +.i threaded +cgroups. +if the string +.i """threaded""" +is written to the +.i cgroup.type +file of one of the children of the root cgroup, then +.ip * 3 +the type of that cgroup becomes +.ir threaded . +.ip * +the type of any descendants of that cgroup that +are not part of lower-level threaded subtrees changes to +.ir "domain invalid" . +.pp +note that in this case, there is no cgroup whose type becomes +.ir "domain threaded" . +(notionally, the root cgroup can be considered as the threaded root +for the cgroup whose type was changed to +.ir threaded .) +.pp +the aim of this exceptional treatment for the root cgroup is to +allow a threaded cgroup that employs the +.i cpu +controller to be placed as high as possible in the hierarchy, +so as to minimize the (small) cost of traversing the cgroup hierarchy. +.\" +.ss the cgroups v2 """cpu""" controller and realtime threads +as at linux 4.19, the cgroups v2 +.i cpu +controller does not support control of realtime threads +(specifically threads scheduled under any of the policies +.br sched_fifo , +.br sched_rr , +described +.br sched_deadline ; +see +.br sched (7)). +therefore, the +.i cpu +controller can be enabled in the root cgroup only +if all realtime threads are in the root cgroup. +(if there are realtime threads in nonroot cgroups, then a +.br write (2) +of the string +.ir """+cpu""" +to the +.i cgroup.subtree_control +file fails with the error +.br einval .) +.pp +on some systems, +.br systemd (1) +places certain realtime threads in nonroot cgroups in the v2 hierarchy. +on such systems, +these threads must first be moved to the root cgroup before the +.i cpu +controller can be enabled. +.\" +.sh errors +the following errors can occur for +.br mount (2): +.tp +.b ebusy +an attempt to mount a cgroup version 1 filesystem specified neither the +.i name= +option (to mount a named hierarchy) nor a controller name (or +.ir all ). +.sh notes +a child process created via +.br fork (2) +inherits its parent's cgroup memberships. +a process's cgroup memberships are preserved across +.br execve (2). +.pp +the +.br clone3 (2) +.b clone_into_cgroup +flag can be used to create a child process that begins its life in +a different version 2 cgroup from the parent process. +.\" +.ss /proc files +.tp +.ir /proc/cgroups " (since linux 2.6.24)" +this file contains information about the controllers +that are compiled into the kernel. +an example of the contents of this file (reformatted for readability) +is the following: +.ip +.in +4n +.ex +#subsys_name hierarchy num_cgroups enabled +cpuset 4 1 1 +cpu 8 1 1 +cpuacct 8 1 1 +blkio 6 1 1 +memory 3 1 1 +devices 10 84 1 +freezer 7 1 1 +net_cls 9 1 1 +perf_event 5 1 1 +net_prio 9 1 1 +hugetlb 0 1 0 +pids 2 1 1 +.ee +.in +.ip +the fields in this file are, from left to right: +.rs +.ip 1. 3 +the name of the controller. +.ip 2. +the unique id of the cgroup hierarchy on which this controller is mounted. +if multiple cgroups v1 controllers are bound to the same hierarchy, +then each will show the same hierarchy id in this field. +the value in this field will be 0 if: +.rs 5 +.ip a) 3 +the controller is not mounted on a cgroups v1 hierarchy; +.ip b) +the controller is bound to the cgroups v2 single unified hierarchy; or +.ip c) +the controller is disabled (see below). +.re +.ip 3. +the number of control groups in this hierarchy using this controller. +.ip 4. +this field contains the value 1 if this controller is enabled, +or 0 if it has been disabled (via the +.ir cgroup_disable +kernel command-line boot parameter). +.re +.tp +.ir /proc/[pid]/cgroup " (since linux 2.6.24)" +this file describes control groups to which the process +with the corresponding pid belongs. +the displayed information differs for +cgroups version 1 and version 2 hierarchies. +.ip +for each cgroup hierarchy of which the process is a member, +there is one entry containing three colon-separated fields: +.ip +.in +4n +.ex +hierarchy\-id:controller\-list:cgroup\-path +.ee +.in +.ip +for example: +.ip +.in +4n +.ex +5:cpuacct,cpu,cpuset:/daemons +.ee +.in +.ip +the colon-separated fields are, from left to right: +.rs +.ip 1. 3 +for cgroups version 1 hierarchies, +this field contains a unique hierarchy id number +that can be matched to a hierarchy id in +.ir /proc/cgroups . +for the cgroups version 2 hierarchy, this field contains the value 0. +.ip 2. +for cgroups version 1 hierarchies, +this field contains a comma-separated list of the controllers +bound to the hierarchy. +for the cgroups version 2 hierarchy, this field is empty. +.ip 3. +this field contains the pathname of the control group in the hierarchy +to which the process belongs. +this pathname is relative to the mount point of the hierarchy. +.re +.\" +.ss /sys/kernel/cgroup files +.tp +.ir /sys/kernel/cgroup/delegate " (since linux 4.15)" +.\" commit 01ee6cfb1483fe57c9cbd8e73817dfbf9bacffd3 +this file exports a list of the cgroups v2 files +(one per line) that are delegatable +(i.e., whose ownership should be changed to the user id of the delegatee). +in the future, the set of delegatable files may change or grow, +and this file provides a way for the kernel to inform +user-space applications of which files must be delegated. +as at linux 4.15, one sees the following when inspecting this file: +.ip +.in +4n +.ex +$ \fbcat /sys/kernel/cgroup/delegate\fp +cgroup.procs +cgroup.subtree_control +cgroup.threads +.ee +.in +.tp +.ir /sys/kernel/cgroup/features " (since linux 4.15)" +.\" commit 5f2e673405b742be64e7c3604ed4ed3ac14f35ce +over time, the set of cgroups v2 features that are provided by the +kernel may change or grow, +or some features may not be enabled by default. +this file provides a way for user-space applications to discover what +features the running kernel supports and has enabled. +features are listed one per line: +.ip +.in +4n +.ex +$ \fbcat /sys/kernel/cgroup/features\fp +nsdelegate +memory_localevents +.ee +.in +.ip +the entries that can appear in this file are: +.rs +.tp +.ir memory_localevents " (since linux 5.2)" +the kernel supports the +.i memory_localevents +mount option. +.tp +.ir nsdelegate " (since linux 4.15)" +the kernel supports the +.i nsdelegate +mount option. +.re +.sh see also +.br prlimit (1), +.br systemd (1), +.br systemd\-cgls (1), +.br systemd\-cgtop (1), +.br clone (2), +.br ioprio_set (2), +.br perf_event_open (2), +.br setrlimit (2), +.br cgroup_namespaces (7), +.br cpuset (7), +.br namespaces (7), +.br sched (7), +.br user_namespaces (7) +.pp +the kernel source file +.ir documentation/admin\-guide/cgroup\-v2.rst . +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" this man page is copyright (c) 1998 alan cox. +.\" +.\" %%%license_start(verbatim_one_para) +.\" permission is granted to distribute possibly modified copies +.\" of this page provided the header is included verbatim, +.\" and in case of nontrivial modification author and date +.\" of the modification is added to the header. +.\" %%%license_end +.\" +.\" $id: ddp.7,v 1.3 1999/05/13 11:33:22 freitag exp $ +.\" +.th ddp 7 2021-03-22 "linux" "linux programmer's manual" +.sh name +ddp \- linux appletalk protocol implementation +.sh synopsis +.nf +.b #include +.b #include +.pp +.ib ddp_socket " = socket(af_appletalk, sock_dgram, 0);" +.ib raw_socket " = socket(af_appletalk, sock_raw, " protocol ");" +.fi +.sh description +linux implements the appletalk protocols described in +.ir "inside appletalk" . +only the ddp layer and aarp are present in +the kernel. +they are designed to be used via the +.b netatalk +protocol +libraries. +this page documents the interface for those who wish or need to +use the ddp layer directly. +.pp +the communication between appletalk and the user program works using a +bsd-compatible socket interface. +for more information on sockets, see +.br socket (7). +.pp +an appletalk socket is created by calling the +.br socket (2) +function with a +.b af_appletalk +socket family argument. +valid socket types are +.b sock_dgram +to open a +.b ddp +socket or +.b sock_raw +to open a +.b raw +socket. +.i protocol +is the appletalk protocol to be received or sent. +for +.b sock_raw +you must specify +.br atproto_ddp . +.pp +raw sockets may be opened only by a process with effective user id 0 +or when the process has the +.b cap_net_raw +capability. +.ss address format +an appletalk socket address is defined as a combination of a network number, +a node number, and a port number. +.pp +.in +4n +.ex +struct at_addr { + unsigned short s_net; + unsigned char s_node; +}; + +struct sockaddr_atalk { + sa_family_t sat_family; /* address family */ + unsigned char sat_port; /* port */ + struct at_addr sat_addr; /* net/node */ +}; +.ee +.in +.pp +.i sat_family +is always set to +.br af_appletalk . +.i sat_port +contains the port. +the port numbers below 129 are known as +.ir "reserved ports" . +only processes with the effective user id 0 or the +.b cap_net_bind_service +capability may +.br bind (2) +to these sockets. +.i sat_addr +is the host address. +the +.i net +member of +.i struct at_addr +contains the host network in network byte order. +the value of +.b at_anynet +is a +wildcard and also implies \(lqthis network.\(rq +the +.i node +member of +.i struct at_addr +contains the host node number. +the value of +.b at_anynode +is a +wildcard and also implies \(lqthis node.\(rq the value of +.b ataddr_bcast +is a link +local broadcast address. +.\" fixme . this doesn't make sense [johnl] +.ss socket options +no protocol-specific socket options are supported. +.ss /proc interfaces +ip supports a set of +.i /proc +interfaces to configure some global appletalk parameters. +the parameters can be accessed by reading or writing files in the directory +.ir /proc/sys/net/atalk/ . +.tp +.i aarp\-expiry\-time +the time interval (in seconds) before an aarp cache entry expires. +.tp +.i aarp\-resolve\-time +the time interval (in seconds) before an aarp cache entry is resolved. +.tp +.i aarp\-retransmit\-limit +the number of retransmissions of an aarp query before the node is declared +dead. +.tp +.i aarp\-tick\-time +the timer rate (in seconds) for the timer driving aarp. +.pp +the default values match the specification and should never need to be +changed. +.ss ioctls +all ioctls described in +.br socket (7) +apply to ddp. +.\" fixme . add a section about multicasting +.sh errors +.tp +.b eacces +the user tried to execute an operation without the necessary permissions. +these include sending to a broadcast address without +having the broadcast flag set, +and trying to bind to a reserved port without effective user id 0 or +.br cap_net_bind_service . +.tp +.b eaddrinuse +tried to bind to an address already in use. +.tp +.b eaddrnotavail +a nonexistent interface was requested or the requested source address was +not local. +.tp +.b eagain +operation on a nonblocking socket would block. +.tp +.b ealready +a connection operation on a nonblocking socket is already in progress. +.tp +.b econnaborted +a connection was closed during an +.br accept (2). +.tp +.b ehostunreach +no routing table entry matches the destination address. +.tp +.b einval +invalid argument passed. +.tp +.b eisconn +.br connect (2) +was called on an already connected socket. +.tp +.b emsgsize +datagram is bigger than the ddp mtu. +.tp +.b enodev +network device not available or not capable of sending ip. +.tp +.b enoent +.b siocgstamp +was called on a socket where no packet arrived. +.tp +.br enomem " and " enobufs +not enough memory available. +.tp +.b enopkg +a kernel subsystem was not configured. +.tp +.br enoprotoopt " and " eopnotsupp +invalid socket option passed. +.tp +.b enotconn +the operation is defined only on a connected socket, but the socket wasn't +connected. +.tp +.b eperm +user doesn't have permission to set high priority, +make a configuration change, +or send signals to the requested process or group. +.tp +.b epipe +the connection was unexpectedly closed or shut down by the other end. +.tp +.b esocktnosupport +the socket was unconfigured, or an unknown socket type was requested. +.sh versions +appletalk is supported by linux 2.0 or higher. +the +.i /proc +interfaces exist since linux 2.2. +.sh notes +be very careful with the +.b so_broadcast +option; it is not privileged in linux. +it is easy to overload the network +with careless sending to broadcast addresses. +.ss compatibility +the basic appletalk socket interface is compatible with +.b netatalk +on bsd-derived systems. +many bsd systems fail to check +.b so_broadcast +when sending broadcast frames; this can lead to compatibility problems. +.pp +the +raw +socket mode is unique to linux and exists to support the alternative cap +package and appletalk monitoring tools more easily. +.sh bugs +there are too many inconsistent error values. +.pp +the ioctls used to configure routing tables, devices, +aarp tables, and other devices are not yet described. +.sh see also +.br recvmsg (2), +.br sendmsg (2), +.br capabilities (7), +.br socket (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/drand48.3 + +.so man3/getprotoent.3 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sat jul 24 21:48:06 1993 by rik faith (faith@cs.unc.edu) +.th getnetent 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +getnetent, getnetbyname, getnetbyaddr, setnetent, endnetent \- +get network entry +.sh synopsis +.nf +.b #include +.pp +.b struct netent *getnetent(void); +.pp +.bi "struct netent *getnetbyname(const char *" name ); +.bi "struct netent *getnetbyaddr(uint32_t " net ", int " type ); +.pp +.bi "void setnetent(int " stayopen ); +.b void endnetent(void); +.fi +.sh description +the +.br getnetent () +function reads the next entry from the networks database +and returns a +.i netent +structure containing +the broken-out fields from the entry. +a connection is opened to the database if necessary. +.pp +the +.br getnetbyname () +function returns a +.i netent +structure +for the entry from the database +that matches the network +.ir name . +.pp +the +.br getnetbyaddr () +function returns a +.i netent +structure +for the entry from the database +that matches the network number +.i net +of type +.ir type . +the +.i net +argument must be in host byte order. +.pp +the +.br setnetent () +function opens a connection to the database, +and sets the next entry to the first entry. +if +.i stayopen +is nonzero, +then the connection to the database +will not be closed between calls to one of the +.br getnet* () +functions. +.pp +the +.br endnetent () +function closes the connection to the database. +.pp +the +.i netent +structure is defined in +.i +as follows: +.pp +.in +4n +.ex +struct netent { + char *n_name; /* official network name */ + char **n_aliases; /* alias list */ + int n_addrtype; /* net address type */ + uint32_t n_net; /* network number */ +} +.ee +.in +.pp +the members of the +.i netent +structure are: +.tp +.i n_name +the official name of the network. +.tp +.i n_aliases +a null-terminated list of alternative names for the network. +.tp +.i n_addrtype +the type of the network number; always +.br af_inet . +.tp +.i n_net +the network number in host byte order. +.sh return value +the +.br getnetent (), +.br getnetbyname (), +and +.br getnetbyaddr () +functions return a pointer to a +statically allocated +.i netent +structure, or a null pointer if an +error occurs or the end of the file is reached. +.sh files +.tp +.i /etc/networks +networks database file +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lb lb lbx +l l l. +interface attribute value +t{ +.br getnetent () +t} thread safety t{ +mt-unsafe race:netent +race:netentbuf env locale +t} +t{ +.br getnetbyname () +t} thread safety t{ +mt-unsafe race:netbyname +env locale +t} +t{ +.br getnetbyaddr () +t} thread safety t{ +mt-unsafe race:netbyaddr +locale +t} +t{ +.br setnetent (), +.br endnetent () +t} thread safety t{ +mt-unsafe race:netent env +locale +t} +.te +.hy +.ad +.sp 1 +in the above table, +.i netent +in +.i race:netent +signifies that if any of the functions +.br setnetent (), +.br getnetent (), +or +.br endnetent () +are used in parallel in different threads of a program, +then data races could occur. +.sh conforming to +posix.1-2001, posix.1-2008, 4.3bsd. +.sh notes +in glibc versions before 2.2, the +.i net +argument of +.br getnetbyaddr () +was of type +.ir long . +.sh see also +.br getnetent_r (3), +.br getprotoent (3), +.br getservent (3) +.\" .br networks (5) +.br +rfc\ 1101 +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/tsearch.3 + +.\" copyright 1995 yggdrasil computing, incorporated. +.\" and copyright 2015 michael kerrisk +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th dlerror 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +dlerror \- obtain error diagnostic for functions in the dlopen api +.sh synopsis +.nf +.b #include +.pp +.b "char *dlerror(void);" +.pp +link with \fi\-ldl\fp. +.fi +.sh description +the +.br dlerror () +function returns a human-readable, +null-terminated string describing the most recent error +that occurred from a call to one of the functions in the dlopen api +since the last call to +.br dlerror (). +the returned string does +.i not +include a trailing newline. +.pp +.br dlerror () +returns null if no errors have occurred since initialization or since +it was last called. +.sh versions +.br dlerror () +is present in glibc 2.0 and later. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br dlerror () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001. +.sh notes +the message returned by +.br dlerror () +may reside in a statically allocated buffer that is +overwritten by subsequent +.br dlerror () +calls. +.\" .lp +.\" the string returned by +.\" .br dlerror () +.\" should not be modified. +.\" some systems give the prototype as +.\" .sp +.\" .in +5 +.\" .b "const char *dlerror(void);" +.\" .in +.ss history +this function is part of the dlopen api, derived from sunos. +.sh examples +see +.br dlopen (3). +.sh see also +.br dladdr (3), +.br dlinfo (3), +.br dlopen (3), +.br dlsym (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sat jul 24 17:57:50 1993 by rik faith (faith@cs.unc.edu) +.th strspn 3 2021-03-22 "" "linux programmer's manual" +.sh name +strspn, strcspn \- get length of a prefix substring +.sh synopsis +.nf +.b #include +.pp +.bi "size_t strspn(const char *" s ", const char *" accept ); +.bi "size_t strcspn(const char *" s ", const char *" reject ); +.fi +.sh description +the +.br strspn () +function calculates the length (in bytes) of the initial +segment of +.i s +which consists entirely of bytes in +.ir accept . +.pp +the +.br strcspn () +function calculates the length of the initial +segment of +.i s +which consists entirely of bytes not in +.ir reject . +.sh return value +the +.br strspn () +function returns the number of bytes in +the initial segment of +.i s +which consist only of bytes +from +.ir accept . +.pp +the +.br strcspn () +function returns the number of bytes in +the initial segment of +.i s +which are not in the string +.ir reject . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br strspn (), +.br strcspn () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c89, c99, svr4, 4.3bsd. +.sh see also +.br index (3), +.br memchr (3), +.br rindex (3), +.br strchr (3), +.br string (3), +.br strpbrk (3), +.br strsep (3), +.br strstr (3), +.br strtok (3), +.br wcscspn (3), +.br wcsspn (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/ioctl_console.2 +.\" link for old name of this page + +.so man3/posix_memalign.3 + +.so man3/futimes.3 + +.so man2/epoll_wait.2 + +.so man3/getmntent.3 + +.\" copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de) +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under gpl +.\" %%%license_end +.\" +.th ccos 3 2021-03-22 "" "linux programmer's manual" +.sh name +ccos, ccosf, ccosl \- complex cosine function +.sh synopsis +.nf +.b #include +.pp +.bi "double complex ccos(double complex " z ");" +.bi "float complex ccosf(float complex " z ");" +.bi "long double complex ccosl(long double complex " z ");" +.pp +link with \fi\-lm\fp. +.fi +.sh description +these functions calculate the complex cosine of +.ir z . +.pp +the complex cosine function is defined as: +.pp +.nf + ccos(z) = (exp(i * z) + exp(\-i * z)) / 2 +.fi +.sh versions +these functions first appeared in glibc in version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br ccos (), +.br ccosf (), +.br ccosl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.sh see also +.br cabs (3), +.br cacos (3), +.br csin (3), +.br ctan (3), +.br complex (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +#!/bin/sh +# +# find_repeated_words.sh +# +# a simple script for finding instances of repeated consecutive words +# in manual pages -- human inspection can then determine if these +# are real errors in the text. +# +# usage: sh find_repeated_words.sh [file...] +# +###################################################################### +# +# (c) copyright 2007 & 2013, michael kerrisk +# this program is free software; you can redistribute it and/or +# modify it under the terms of the gnu general public license +# as published by the free software foundation; either version 2 +# of the license, or (at your option) any later version. +# +# this program 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 general public license for more details +# (http://www.gnu.org/licenses/gpl-2.0.html). +# +# + +for file in "$@" ; do + # do not process files that are redirects. + grep -qe "^\.so man.*" "$file" + if test $? -ne 0; then + words=$(manwidth=2000 man -l "$file" 2> /dev/null | col -b | \ + tr ' \008' '\012' | sed -e '/^$/d' | \ + sed 's/ *$//' | + awk 'begin {p=""} {if (p==$0) print p; p=$0}' | \ + grep '[a-za-z]' | tr '\012' ' ') + if test -n "$words"; then + echo "$file: $words" + fi + fi +done + +.so man2/stat.2 + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" iso/iec 9899:1999 +.\" +.th fputwc 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +fputwc, putwc \- write a wide character to a file stream +.sh synopsis +.nf +.b #include +.b #include +.pp +.bi "wint_t fputwc(wchar_t " wc ", file *" stream ); +.bi "wint_t putwc(wchar_t " wc ", file *" stream ); +.fi +.sh description +the +.br fputwc () +function is the wide-character +equivalent of the +.br fputc (3) +function. +it writes the wide character \fiwc\fp to \fistream\fp. +if +\fiferror(stream)\fp becomes true, it returns +.br weof . +if a wide-character conversion error occurs, +it sets \fierrno\fp to \fbeilseq\fp and returns +.br weof . +otherwise, it returns \fiwc\fp. +.pp +the +.br putwc () +function or macro functions identically to +.br fputwc (). +it may be implemented as a macro, and may evaluate its argument +more than once. +there is no reason ever to use it. +.pp +for nonlocking counterparts, see +.br unlocked_stdio (3). +.sh return value +on success, +.br fputwc () +function returns +.ir wc . +otherwise, +.b weof +is returned, and +.i errno +is set to indicate the error. +.sh errors +apart from the usual ones, there is +.tp +.b eilseq +conversion of \fiwc\fp to the stream's encoding fails. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br fputwc (), +.br putwc () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh notes +the behavior of +.br fputwc () +depends on the +.b lc_ctype +category of the +current locale. +.pp +in the absence of additional information passed to the +.br fopen (3) +call, it is +reasonable to expect that +.br fputwc () +will actually write the multibyte +sequence corresponding to the wide character \fiwc\fp. +.sh see also +.br fgetwc (3), +.br fputws (3), +.br unlocked_stdio (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1993 rickard e. faith +.\" and copyright (c) 1994 andries e. brouwer +.\" and copyright (c) 2002, 2005, 2016 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified 1996-11-04 by eric s. raymond +.\" modified 2001-10-13 by michael kerrisk +.\" added note on historical behavior of ms_nosuid +.\" modified 2002-05-16 by michael kerrisk +.\" extensive changes and additions +.\" modified 2002-05-27 by aeb +.\" modified 2002-06-11 by michael kerrisk +.\" enhanced descriptions of ms_move, ms_bind, and ms_remount +.\" modified 2004-06-17 by michael kerrisk +.\" 2005-05-18, mtk, added mnt_expire, plus a few other tidy-ups. +.\" 2008-10-06, mtk: move umount*() material into separate umount.2 page. +.\" 2008-10-06, mtk: add discussion of namespaces. +.\" +.th mount 2 2021-08-27 "linux" "linux programmer's manual" +.sh name +mount \- mount filesystem +.sh synopsis +.nf +.b "#include " +.pp +.bi "int mount(const char *" source ", const char *" target , +.bi " const char *" filesystemtype ", unsigned long " mountflags , +.bi " const void *" data ); +.fi +.sh description +.br mount () +attaches the filesystem specified by +.i source +(which is often a pathname referring to a device, +but can also be the pathname of a directory or file, +or a dummy string) to the location (a directory or file) +specified by the pathname in +.ir target . +.pp +appropriate privilege (linux: the +.b cap_sys_admin +capability) is required to mount filesystems. +.pp +values for the +.i filesystemtype +argument supported by the kernel are listed in +.i /proc/filesystems +(e.g., "btrfs", "ext4", "jfs", "xfs", "vfat", "fuse", +"tmpfs", "cgroup", "proc", "mqueue", "nfs", "cifs", "iso9660"). +further types may become available when the appropriate modules +are loaded. +.pp +the +.i data +argument is interpreted by the different filesystems. +typically it is a string of comma-separated options +understood by this filesystem. +see +.br mount (8) +for details of the options available for each filesystem type. +this argument may be specified as null, if there are no options. +.pp +a call to +.br mount () +performs one of a number of general types of operation, +depending on the bits specified in +.ir mountflags . +the choice of which operation to perform is determined by +testing the bits set in +.ir mountflags , +with the tests being conducted in the order listed here: +.ip * 3 +remount an existing mount: +.ir mountflags +includes +.br ms_remount . +.ip * +create a bind mount: +.ir mountflags +includes +.br ms_bind . +.ip * +change the propagation type of an existing mount: +.ir mountflags +includes one of +.br ms_shared , +.br ms_private , +.br ms_slave , +or +.br ms_unbindable . +.ip * +move an existing mount to a new location: +.ir mountflags +includes +.br ms_move . +.ip * +create a new mount: +.ir mountflags +includes none of the above flags. +.pp +each of these operations is detailed later in this page. +further flags may be specified in +.ir mountflags +to modify the behavior of +.br mount (), +as described below. +.\" +.ss additional mount flags +the list below describes the additional flags that can be specified in +.ir mountflags . +note that some operation types ignore some or all of these flags, +as described later in this page. +.\" +.\" fixme 2.6.25 added ms_i_version, which needs to be documented. +.\" commit 7a224228ed79d587ece2304869000aad1b8e97dd +.\" (this is a per-superblock flag) +.\" +.tp +.br ms_dirsync " (since linux 2.5.19)" +make directory changes on this filesystem synchronous. +(this property can be obtained for individual directories +or subtrees using +.br chattr (1).) +.tp +.br ms_lazytime " (since linux 4.0)" +.\" commit 0ae45f63d4ef8d8eeec49c7d8b44a1775fff13e8 +.\" commit fe032c422c5ba562ba9c2d316f55e258e03259c6 +.\" commit a26f49926da938f47561f386be56a83dd37a496d +reduce on-disk updates of inode timestamps (atime, mtime, ctime) +by maintaining these changes only in memory. +the on-disk timestamps are updated only when: +.rs +.ip (a) 4 +the inode needs to be updated for some change unrelated to file timestamps; +.ip (b) +the application employs +.br fsync (2), +.br syncfs (2), +or +.br sync (2); +.ip (c) +an undeleted inode is evicted from memory; or +.ip (d) +more than 24 hours have passed since the inode was written to disk. +.re +.ip +this mount option significantly reduces writes +needed to update the inode's timestamps, especially mtime and atime. +however, in the event of a system crash, the atime and mtime fields +on disk might be out of date by up to 24 hours. +.ip +examples of workloads where this option could be of significant benefit +include frequent random writes to preallocated files, +as well as cases where the +.b ms_strictatime +mount option is also enabled. +(the advantage of combining +.br ms_strictatime +and +.br ms_lazytime +is that +.br stat (2) +will return the correctly updated atime, but the atime updates +will be flushed to disk only in the cases listed above.) +.tp +.b ms_mandlock +permit mandatory locking on files in this filesystem. +(mandatory locking must still be enabled on a per-file basis, +as described in +.br fcntl (2).) +since linux 4.5, +.\" commit 95ace75414f312f9a7b93d873f386987b92a5301 +this mount option requires the +.b cap_sys_admin +capability and a kernel configured with the +.b config_mandatory_file_locking +option. +.tp +.b ms_noatime +do not update access times for (all types of) files on this filesystem. +.tp +.b ms_nodev +do not allow access to devices (special files) on this filesystem. +.tp +.b ms_nodiratime +do not update access times for directories on this filesystem. +this flag provides a subset of the functionality provided by +.br ms_noatime ; +that is, +.br ms_noatime +implies +.br ms_nodiratime . +.tp +.b ms_noexec +do not allow programs to be executed from this filesystem. +.\" (possibly useful for a filesystem that contains non-linux executables. +.\" often used as a security feature, e.g., to make sure that restricted +.\" users cannot execute files uploaded using ftp or so.) +.tp +.b ms_nosuid +do not honor set-user-id and set-group-id bits or file capabilities +when executing programs from this filesystem. +in addition, selinux domain +transitions require the permission +.ir nosuid_transition , +which in turn needs +also the policy capability +.ir nnp_nosuid_transition . +.\" (this is a security feature to prevent users executing set-user-id and +.\" set-group-id programs from removable disk devices.) +.tp +.b ms_rdonly +mount filesystem read-only. +.tp +.br ms_rec " (since linux 2.4.11)" +used in conjunction with +.br ms_bind +to create a recursive bind mount, +and in conjunction with the propagation type flags to recursively change +the propagation type of all of the mounts in a subtree. +see below for further details. +.tp +.br ms_relatime " (since linux 2.6.20)" +when a file on this filesystem is accessed, +update the file's last access time (atime) only if the current value +of atime is less than or equal to the file's last modification time (mtime) +or last status change time (ctime). +this option is useful for programs, such as +.br mutt (1), +that need to know when a file has been read since it was last modified. +since linux 2.6.30, the kernel defaults to the behavior provided +by this flag (unless +.br ms_noatime +was specified), and the +.b ms_strictatime +flag is required to obtain traditional semantics. +in addition, since linux 2.6.30, +the file's last access time is always updated if it +is more than 1 day old. +.\" matthew garrett notes in the patch that added this behavior +.\" that this lets utilities such as tmpreaper (which deletes +.\" files based on last access time) work correctly. +.tp +.br ms_silent " (since linux 2.6.17)" +suppress the display of certain +.ri ( printk ()) +warning messages in the kernel log. +this flag supersedes the misnamed and obsolete +.br ms_verbose +flag (available since linux 2.4.12), which has the same meaning. +.tp +.br ms_strictatime " (since linux 2.6.30)" +always update the last access time (atime) when files on this +filesystem are accessed. +(this was the default behavior before linux 2.6.30.) +specifying this flag overrides the effect of setting the +.br ms_noatime +and +.br ms_relatime +flags. +.tp +.b ms_synchronous +make writes on this filesystem synchronous (as though +the +.b o_sync +flag to +.br open (2) +was specified for all file opens to this filesystem). +.tp +.br ms_nosymfollow " (since linux 5.10)" +.\" dab741e0e02bd3c4f5e2e97be74b39df2523fc6e +do not follow symbolic links when resolving paths. +symbolic links can still be created, +and +.br readlink (1), +.br readlink (2), +.br realpath (1), +and +.br realpath (3) +all still work properly. +.pp +from linux 2.4 onward, some of the above flags are +settable on a per-mount basis, +while others apply to the superblock of the mounted filesystem, +meaning that all mounts of the same filesystem share those flags. +(previously, all of the flags were per-superblock.) +.pp +the per-mount-point flags are as follows: +.ip * 3 +since linux 2.4: +.br ms_nodev ", " ms_noexec ", and " ms_nosuid +flags are settable on a per-mount-point basis. +.ip * +additionally, since linux 2.6.16: +.b ms_noatime +and +.br ms_nodiratime . +.ip * +additionally, since linux 2.6.20: +.br ms_relatime . +.pp +the following flags are per-superblock: +.br ms_dirsync , +.br ms_lazytime , +.br ms_mandlock , +.br ms_silent , +and +.br ms_synchronous . +.\" and ms_i_version? +the initial settings of these flags are determined on the first +mount of the filesystem, and will be shared by all subsequent mounts +of the same filesystem. +subsequently, the settings of the flags can be changed +via a remount operation (see below). +such changes will be visible via all mounts associated +with the filesystem. +.pp +since linux 2.6.16, +.b ms_rdonly +can be set or cleared on a per-mount-point basis as well as on +the underlying filesystem superblock. +the mounted filesystem will be writable only if neither the filesystem +nor the mountpoint are flagged as read-only. +.\" +.ss remounting an existing mount +an existing mount may be remounted by specifying +.b ms_remount +in +.ir mountflags . +this allows you to change the +.i mountflags +and +.i data +of an existing mount without having to unmount and remount the filesystem. +.i target +should be the same value specified in the initial +.br mount () +call. +.pp +the +.i source +and +.i filesystemtype +arguments are ignored. +.pp +the +.i mountflags +and +.i data +arguments should match the values used in the original +.br mount () +call, except for those parameters that are being deliberately changed. +.pp +the following +.i mountflags +can be changed: +.br ms_lazytime , +.\" fixme +.\" ms_lazytime seems to be available only on a few filesystems, +.\" and on ext4, it seems (from experiment that this flag +.\" can only be enabled (but not disabled) on a remount. +.\" the following code in ext4_remount() (kernel 4.17) seems to +.\" confirm this: +.\" +.\" if (*flags & sb_lazytime) +.\" sb->s_flags |= sb_lazytime; +.br ms_mandlock , +.br ms_noatime , +.br ms_nodev , +.br ms_nodiratime , +.br ms_noexec , +.br ms_nosuid , +.br ms_relatime , +.br ms_rdonly , +.br ms_strictatime +(whose effect is to clear the +.br ms_noatime +and +.br ms_relatime +flags), +and +.br ms_synchronous . +attempts to change the setting of the +.\" see the definition of ms_rmt_mask in include/uapi/linux/fs.h, +.\" which excludes ms_dirsync and ms_silent, although sb_dirsync +.\" and sb_silent are split out as per-superblock flags in do_mount() +.\" (linux 4.17 source code) +.br ms_dirsync +and +.br ms_silent +flags during a remount are silently ignored. +note that changes to per-superblock flags are visible via +all mounts of the associated filesystem +(because the per-superblock flags are shared by all mounts). +.pp +since linux 3.17, +.\" commit ffbc6f0ead47fa5a1dc9642b0331cb75c20a640e +if none of +.br ms_noatime , +.br ms_nodiratime , +.br ms_relatime , +or +.br ms_strictatime +is specified in +.ir mountflags , +then the remount operation preserves the existing values of these flags +(rather than defaulting to +.br ms_relatime ). +.pp +since linux 2.6.26, the +.b ms_remount +flag can be used with +.b ms_bind +to modify only the per-mount-point flags. +.\" see https://lwn.net/articles/281157/ +this is particularly useful for setting or clearing the "read-only" +flag on a mount without changing the underlying filesystem. +specifying +.ir mountflags +as: +.pp +.in +4n +.ex +ms_remount | ms_bind | ms_rdonly +.ee +.in +.pp +will make access through this mountpoint read-only, without affecting +other mounts. +.\" +.ss creating a bind mount +if +.i mountflags +includes +.br ms_bind +(available since linux 2.4), +.\" since 2.4.0-test9 +then perform a bind mount. +a bind mount makes a file or a directory subtree visible at +another point within the single directory hierarchy. +bind mounts may cross filesystem boundaries and span +.br chroot (2) +jails. +.pp +the +.ir filesystemtype +and +.ir data +arguments are ignored. +.pp +the remaining bits (other than +.br ms_rec , +described below) in the +.i mountflags +argument are also ignored. +(the bind mount has the same mount options as +the underlying mount.) +however, see the discussion of remounting above, +for a method of making an existing bind mount read-only. +.pp +by default, when a directory is bind mounted, +only that directory is mounted; +if there are any submounts under the directory tree, +they are not bind mounted. +if the +.br ms_rec +flag is also specified, then a recursive bind mount operation is performed: +all submounts under the +.i source +subtree (other than unbindable mounts) +are also bind mounted at the corresponding location in the +.i target +subtree. +.\" +.ss changing the propagation type of an existing mount +if +.ir mountflags +includes one of +.br ms_shared , +.br ms_private , +.br ms_slave , +or +.br ms_unbindable +(all available since linux 2.6.15), +then the propagation type of an existing mount is changed. +if more than one of these flags is specified, an error results. +.pp +the only other flags that can be specified while changing +the propagation type are +.br ms_rec +(described below) and +.br ms_silent +(which is ignored). +.pp +the +.ir source , +.ir filesystemtype , +and +.ir data +arguments are ignored. +.pp +the meanings of the propagation type flags are as follows: +.tp +.br ms_shared +make this mount shared. +mount and unmount events immediately under this mount will propagate +to the other mounts that are members of this mount's peer group. +propagation here means that the same mount or unmount will automatically +occur under all of the other mounts in the peer group. +conversely, mount and unmount events that take place under +peer mounts will propagate to this mount. +.tp +.br ms_private +make this mount private. +mount and unmount events do not propagate into or out of this mount. +.tp +.br ms_slave +if this is a shared mount that is a member of a peer group +that contains other members, convert it to a slave mount. +if this is a shared mount that is a member of a peer group +that contains no other members, convert it to a private mount. +otherwise, the propagation type of the mount is left unchanged. +.ip +when a mount is a slave, +mount and unmount events propagate into this mount from +the (master) shared peer group of which it was formerly a member. +mount and unmount events under this mount do not propagate to any peer. +.ip +a mount can be the slave of another peer group +while at the same time sharing mount and unmount events +with a peer group of which it is a member. +.tp +.br ms_unbindable +make this mount unbindable. +this is like a private mount, +and in addition this mount can't be bind mounted. +when a recursive bind mount +.rb ( mount () +with the +.br ms_bind +and +.br ms_rec +flags) is performed on a directory subtree, +any unbindable mounts within the subtree are automatically pruned +(i.e., not replicated) +when replicating that subtree to produce the target subtree. +.pp +by default, changing the propagation type affects only the +.i target +mount. +if the +.b ms_rec +flag is also specified in +.ir mountflags , +then the propagation type of all mounts under +.ir target +is also changed. +.pp +for further details regarding mount propagation types +(including the default propagation type assigned to new mounts), see +.br mount_namespaces (7). +.\" +.ss moving a mount +if +.i mountflags +contains the flag +.br ms_move +(available since linux 2.4.18), +then move a subtree: +.i source +specifies an existing mount and +.i target +specifies the new location to which that mount is to be relocated. +the move is atomic: at no point is the subtree unmounted. +.pp +the remaining bits in the +.ir mountflags +argument are ignored, as are the +.ir filesystemtype +and +.ir data +arguments. +.\" +.ss creating a new mount +if none of +.br ms_remount , +.br ms_bind , +.br ms_move , +.br ms_shared , +.br ms_private , +.br ms_slave , +or +.br ms_unbindable +is specified in +.ir mountflags , +then +.br mount () +performs its default action: creating a new mount. +.ir source +specifies the source for the new mount, and +.ir target +specifies the directory at which to create the mount point. +.pp +the +.i filesystemtype +and +.i data +arguments are employed, and further bits may be specified in +.ir mountflags +to modify the behavior of the call. +.\" +.sh return value +on success, zero is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +the error values given below result from filesystem type independent +errors. +each filesystem type may have its own special errors and its +own special behavior. +see the linux kernel source code for details. +.tp +.b eacces +a component of a path was not searchable. +(see also +.br path_resolution (7).) +.tp +.b eacces +mounting a read-only filesystem was attempted without giving the +.b ms_rdonly +flag. +.ip +the filesystem may be read-only for various reasons, including: +it resides on a read-only optical disk; +it is resides on a device with a physical switch that has been set to +mark the device read-only; +the filesystem implementation was compiled with read-only support; +or errors were detected when initially mounting the filesystem, +so that it was marked read-only +and can't be remounted as read-write (until the errors are fixed). +.ip +some filesystems instead return the error +.br erofs +on an attempt to mount a read-only filesystem. +.tp +.b eacces +the block device +.i source +is located on a filesystem mounted with the +.b ms_nodev +option. +.\" mtk: probably: write permission is required for ms_bind, with +.\" the error eperm if not present; cap_dac_override is required. +.tp +.b ebusy +an attempt was made to stack a new mount directly on +top of an existing mount point that was created in this +mount namespace with the same +.i source +and +.ir target . +.tp +.b ebusy +.i source +cannot be remounted read-only, +because it still holds files open for writing. +.tp +.b efault +one of the pointer arguments points outside the user address space. +.tp +.b einval +.i source +had an invalid superblock. +.tp +.b einval +a remount operation +.rb ( ms_remount ) +was attempted, but +.i source +was not already mounted on +.ir target . +.tp +.b einval +a move operation +.rb ( ms_move ) +was attempted, but the mount tree under +.i source +includes unbindable mounts and +.i target +is a mount that has propagation type +.br ms_shared . +.tp +.b einval +a move operation +.rb ( ms_move ) +was attempted, but the parent mount of +.i source +mount has propagation type +.br ms_shared . +.tp +.b einval +a move operation +.rb ( ms_move ) +was attempted, but +.i source +was not a mount, or was \(aq/\(aq. +.tp +.b einval +a bind operation +.rb ( ms_bind ) +was requested where +.i source +referred a mount namespace magic link (i.e., a +.i /proc/[pid]/ns/mnt +magic link or a bind mount to such a link) +and the propagation type of the parent mount of +.i target +was +.br ms_shared , +.\" see commit 8823c079ba7136dc1948d6f6dcb5f8022bde438e +but propagation of the requested bind mount could lead to a circular +dependency that might prevent the mount namespace from ever being freed. +.tp +.b einval +.i mountflags +includes more than one of +.br ms_shared , +.br ms_private , +.br ms_slave , +or +.br ms_unbindable . +.tp +.b einval +.i mountflags +includes +.br ms_shared , +.br ms_private , +.br ms_slave , +or +.br ms_unbindable +and also includes a flag other than +.br ms_rec +or +.br ms_silent . +.tp +.br einval +an attempt was made to bind mount an unbindable mount. +.tp +.br einval +in an unprivileged mount namespace +(i.e., a mount namespace owned by a user namespace +that was created by an unprivileged user), +a bind mount operation +.rb ( ms_bind ) +was attempted without specifying +.rb ( ms_rec ), +which would have revealed the filesystem tree underneath one of +the submounts of the directory being bound. +.tp +.b eloop +too many links encountered during pathname resolution. +.tp +.b eloop +a move operation was attempted, and +.i target +is a descendant of +.ir source . +.tp +.b emfile +(in case no block device is required:) +table of dummy devices is full. +.tp +.b enametoolong +a pathname was longer than +.br maxpathlen . +.tp +.b enodev +.i filesystemtype +not configured in the kernel. +.tp +.b enoent +a pathname was empty or had a nonexistent component. +.tp +.b enomem +the kernel could not allocate a free page to copy filenames or data into. +.tp +.b enotblk +.i source +is not a block device (and a device was required). +.tp +.b enotdir +.ir target , +or a prefix of +.ir source , +is not a directory. +.tp +.b enxio +the major number of the block device +.i source +is out of range. +.tp +.b eperm +the caller does not have the required privileges. +.tp +.b eperm +an attempt was made to modify +.rb ( ms_remount ) +the +.br ms_rdonly , +.br ms_nosuid , +or +.br ms_noexec +flag, or one of the "atime" flags +.rb ( ms_noatime , +.br ms_nodiratime , +.br ms_relatime ) +of an existing mount, but the mount is locked; see +.br mount_namespaces (7). +.tp +.b erofs +mounting a read-only filesystem was attempted without giving the +.b ms_rdonly +flag. +see +.br eacces , +above. +.sh versions +the definitions of +.br ms_dirsync , +.br ms_move , +.br ms_private , +.br ms_rec , +.br ms_relatime , +.br ms_shared , +.br ms_slave , +.br ms_strictatime , +and +.br ms_unbindable +were added to glibc headers in version 2.12. +.\" +.sh conforming to +this function is linux-specific and should not be used in +programs intended to be portable. +.sh notes +since linux 2.4 a single filesystem can be mounted at +multiple mount points, and multiple mounts can be stacked +on the same mount point. +.\" multiple mounts on same mount point: since 2.3.99pre7. +.pp +the +.i mountflags +argument may have the magic number 0xc0ed (\fbms_mgc_val\fp) +in the top 16 bits. +(all of the other flags discussed in description +occupy the low order 16 bits of +.ir mountflags .) +specifying +.br ms_mgc_val +was required in kernel versions prior to 2.4, +but since linux 2.4 is no longer required and is ignored if specified. +.pp +the original +.b ms_sync +flag was renamed +.b ms_synchronous +in 1.1.69 +when a different +.b ms_sync +was added to \fi\fp. +.pp +before linux 2.4 an attempt to execute a set-user-id or set-group-id program +on a filesystem mounted with +.b ms_nosuid +would fail with +.br eperm . +since linux 2.4 the set-user-id and set-group-id bits are +just silently ignored in this case. +.\" the change is in patch-2.4.0-prerelease. +.\" +.ss mount namespaces +starting with kernel 2.4.19, linux provides mount namespaces. +a mount namespace is the set of filesystem mounts that +are visible to a process. +mount namespaces can be (and usually are) +shared between multiple processes, +and changes to the namespace (i.e., mounts and unmounts) by one process +are visible to all other processes sharing the same namespace. +(the pre-2.4.19 linux situation can be considered as one in which +a single namespace was shared by every process on the system.) +.pp +a child process created by +.br fork (2) +shares its parent's mount namespace; +the mount namespace is preserved across an +.br execve (2). +.pp +a process can obtain a private mount namespace if: +it was created using the +.br clone (2) +.br clone_newns +flag, +in which case its new namespace is initialized to be a +.i copy +of the namespace of the process that called +.br clone (2); +or it calls +.br unshare (2) +with the +.br clone_newns +flag, +which causes the caller's mount namespace to obtain a private copy +of the namespace that it was previously sharing with other processes, +so that future mounts and unmounts by the caller are invisible +to other processes (except child processes that the caller +subsequently creates) and vice versa. +.pp +for further details on mount namespaces, see +.br mount_namespaces (7). +.\" +.ss parental relationship between mounts +each mount has a parent mount. +the overall parental relationship of all mounts defines +the single directory hierarchy seen by the processes within a mount namespace. +.pp +the parent of a new mount is defined when the mount is created. +in the usual case, +the parent of a new mount is the mount of the filesystem +containing the directory or file at which the new mount is attached. +in the case where a new mount is stacked on top of an existing mount, +the parent of the new mount is the previous mount that was stacked +at that location. +.pp +the parental relationship between mounts can be discovered via the +.i /proc/[pid]/mountinfo +file (see below). +.\" +.ss /proc/[pid]/mounts and /proc/[pid]/mountinfo +the linux-specific +.i /proc/[pid]/mounts +file exposes the list of mounts in the mount +namespace of the process with the specified id. +the +.i /proc/[pid]/mountinfo +file exposes even more information about mounts, +including the propagation type and mount id information that makes it +possible to discover the parental relationship between mounts. +see +.br proc (5) +and +.br mount_namespaces (7) +for details of this file. +.sh see also +.br mountpoint (1), +.br chroot (2), +.br ioctl_iflags (2), +.br mount_settatr (2), +.br pivot_root (2), +.br umount (2), +.br mount_namespaces (7), +.br path_resolution (7), +.br findmnt (8), +.br lsblk (8), +.br mount (8), +.br umount (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +for general information about how to contribute, see: +https://www.kernel.org/doc/man-pages/contributing.html + +for information on how to send patches, see: +https://www.kernel.org/doc/man-pages/patches.html + +for a description of the preferred layout of manual pages, +as well as some style guide notes, see: + + $ man 7 man-pages + +for information about reporting bugs, see: +https://www.kernel.org/doc/man-pages/reporting_bugs.html + +.\" copyright (c) 2012 by michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th mcheck 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +mcheck, mcheck_check_all, mcheck_pedantic, mprobe \- heap consistency checking +.sh synopsis +.nf +.b #include +.pp +.bi "int mcheck(void (*" abortfunc ")(enum mcheck_status " mstatus )); +.bi "int mcheck_pedantic(void (*" abortfunc ")(enum mcheck_status " mstatus )); +.b void mcheck_check_all(void); +.pp +.bi "enum mcheck_status mprobe(void *" ptr ); +.fi +.sh description +the +.br mcheck () +function installs a set of debugging hooks for the +.br malloc (3) +family of memory-allocation functions. +these hooks cause certain consistency checks to be performed +on the state of the heap. +the checks can detect application errors such as freeing a block of memory +more than once or corrupting the bookkeeping data structures +that immediately precede a block of allocated memory. +.pp +to be effective, the +.br mcheck () +function must be called before the first call to +.br malloc (3) +or a related function. +in cases where this is difficult to ensure, linking the program with +.ir \-lmcheck +inserts an implicit call to +.br mcheck () +(with a null argument) +before the first call to a memory-allocation function. +.pp +the +.br mcheck_pedantic () +function is similar to +.br mcheck (), +but performs checks on all allocated blocks whenever +one of the memory-allocation functions is called. +this can be very slow! +.pp +the +.br mcheck_check_all () +function causes an immediate check on all allocated blocks. +this call is effective only if +.br mcheck () +is called beforehand. +.pp +if the system detects an inconsistency in the heap, +the caller-supplied function pointed to by +.i abortfunc +is invoked with a single argument, +.ir mstatus , +that indicates what type of inconsistency was detected. +if +.i abortfunc +is null, a default function prints an error message on +.ir stderr +and calls +.br abort (3). +.pp +the +.br mprobe () +function performs a consistency check on +the block of allocated memory pointed to by +.ir ptr . +the +.br mcheck () +function should be called beforehand (otherwise +.br mprobe () +returns +.br mcheck_disabled ). +.pp +the following list describes the values returned by +.br mprobe () +or passed as the +.i mstatus +argument when +.i abortfunc +is invoked: +.tp +.br mcheck_disabled " (" mprobe "() only)" +.br mcheck () +was not called before the first memory allocation function was called. +consistency checking is not possible. +.tp +.br mcheck_ok " (" mprobe "() only)" +no inconsistency detected. +.tp +.b mcheck_head +memory preceding an allocated block was clobbered. +.tp +.b mcheck_tail +memory following an allocated block was clobbered. +.tp +.b +mcheck_free +a block of memory was freed twice. +.sh return value +.br mcheck () +and +.br mcheck_pedantic () +return 0 on success, or \-1 on error. +.sh versions +the +.br mcheck_pedantic () +and +.br mcheck_check_all () +functions are available since glibc 2.2. +the +.br mcheck () +and +.br mprobe () +functions are present since at least glibc 2.0 +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br mcheck (), +.br mcheck_pedantic (), +.br mcheck_check_all (), +.br mprobe () +t} thread safety t{ +mt-unsafe race:mcheck +const:malloc_hooks +t} +.te +.hy +.ad +.sp 1 +.sh conforming to +these functions are gnu extensions. +.sh notes +linking a program with +.i \-lmcheck +and using the +.b malloc_check_ +environment variable (described in +.br mallopt (3)) +cause the same kinds of errors to be detected. +but, using +.b malloc_check_ +does not require the application to be relinked. +.\" but is malloc_check_ slower? +.sh examples +the program below calls +.br mcheck () +with a null argument and then frees the same block of memory twice. +the following shell session demonstrates what happens +when running the program: +.pp +.in +4n +.ex +.rb "$" " ./a.out" +about to free + +about to free a second time +block freed twice +aborted (core dumped) +.ee +.in +.ss program source +\& +.ex +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + char *p; + + if (mcheck(null) != 0) { + fprintf(stderr, "mcheck() failed\en"); + + exit(exit_failure); + } + + p = malloc(1000); + + fprintf(stderr, "about to free\en"); + free(p); + fprintf(stderr, "\enabout to free a second time\en"); + free(p); + + exit(exit_success); +} +.ee +.sh see also +.br malloc (3), +.br mallopt (3), +.br mtrace (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/ctime.3 + +.\" copyright (c) 2014 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th sprof 1 2020-11-01 "linux" "linux user manual" +.sh name +sprof \- read and display shared object profiling data +.sh synopsis +.nf +.br sprof " [\fioption\fp]... \fishared-object-path\fp \ +[\fiprofile-data-path\fp]" +.fi +.sh description +the +.b sprof +command displays a profiling summary for the +shared object (shared library) specified as its first command-line argument. +the profiling summary is created using previously generated +profiling data in the (optional) second command-line argument. +if the profiling data pathname is omitted, then +.b sprof +will attempt to deduce it using the soname of the shared object, +looking for a file with the name +.i .profile +in the current directory. +.sh options +the following command-line options specify the profile output +to be produced: +.tp +.br \-c ", " \-\-call\-pairs +print a list of pairs of call paths for the interfaces exported +by the shared object, +along with the number of times each path is used. +.tp +.br \-p ", " \-\-flat\-profile +generate a flat profile of all of the functions in the monitored object, +with counts and ticks. +.tp +.br \-q ", " \-\-graph +generate a call graph. +.pp +if none of the above options is specified, +then the default behavior is to display a flat profile and a call graph. +.pp +the following additional command-line options are available: +.tp +.br \-? ", " \-\-help +display a summary of command-line options and arguments and exit. +.tp +.b \-\-usage +display a short usage message and exit. +.tp +.br \-v ", " \-\-version +display the program version and exit. +.sh conforming to +the +.b sprof +command is a gnu extension, not present in posix.1. +.sh examples +the following example demonstrates the use of +.br sprof . +the example consists of a main program that calls two functions +in a shared object. +first, the code of the main program: +.pp +.in +4n +.ex +$ \fbcat prog.c\fp +#include + +void x1(void); +void x2(void); + +int +main(int argc, char *argv[]) +{ + x1(); + x2(); + exit(exit_success); +} +.ee +.in +.pp +the functions +.ir x1 () +and +.ir x2 () +are defined in the following source file that is used to +construct the shared object: +.pp +.in +4n +.ex +$ \fbcat libdemo.c\fp +#include + +void +consumecpu1(int lim) +{ + for (int j = 0; j < lim; j++) + getppid(); +} + +void +x1(void) { + for (int j = 0; j < 100; j++) + consumecpu1(200000); +} + +void +consumecpu2(int lim) +{ + for (int j = 0; j < lim; j++) + getppid(); +} + +void +x2(void) +{ + for (int j = 0; j < 1000; j++) + consumecpu2(10000); +} +.ee +.in +.pp +now we construct the shared object with the real name +.ir libdemo.so.1.0.1 , +and the soname +.ir libdemo.so.1 : +.pp +.in +4n +.ex +$ \fbcc \-g \-fpic \-shared \-wl,\-soname,libdemo.so.1 \e\fp + \fb\-o libdemo.so.1.0.1 libdemo.c\fp +.ee +.in +.pp +then we construct symbolic links for the library soname and +the library linker name: +.pp +.in +4n +.ex +$ \fbln \-sf libdemo.so.1.0.1 libdemo.so.1\fp +$ \fbln \-sf libdemo.so.1 libdemo.so\fp +.ee +.in +.pp +next, we compile the main program, linking it against the shared object, +and then list the dynamic dependencies of the program: +.pp +.in +4n +.ex +$ \fbcc \-g \-o prog prog.c \-l. \-ldemo\fp +$ \fbldd prog\fp + linux\-vdso.so.1 => (0x00007fff86d66000) + libdemo.so.1 => not found + libc.so.6 => /lib64/libc.so.6 (0x00007fd4dc138000) + /lib64/ld\-linux\-x86\-64.so.2 (0x00007fd4dc51f000) +.ee +.in +.pp +in order to get profiling information for the shared object, +we define the environment variable +.b ld_profile +with the soname of the library: +.pp +.in +4n +.ex +$ \fbexport ld_profile=libdemo.so.1\fp +.ee +.in +.pp +we then define the environment variable +.b ld_profile_output +with the pathname of the directory where profile output should be written, +and create that directory if it does not exist already: +.pp +.in +4n +.ex +$ \fbexport ld_profile_output=$(pwd)/prof_data\fp +$ \fbmkdir \-p $ld_profile_output\fp +.ee +.in +.pp +.b ld_profile +causes profiling output to be +.i appended +to the output file if it already exists, +so we ensure that there is no preexisting profiling data: +.pp +.in +4n +.ex +$ \fbrm \-f $ld_profile_output/$ld_profile.profile\fp +.ee +.in +.pp +we then run the program to produce the profiling output, +which is written to a file in the directory specified in +.br ld_profile_output : +.pp +.in +4n +.ex +$ \fbld_library_path=. ./prog\fp +$ \fbls prof_data\fp +libdemo.so.1.profile +.ee +.in +.pp +we then use the +.b sprof \-p +option to generate a flat profile with counts and ticks: +.pp +.in +4n +.ex +$ \fbsprof \-p libdemo.so.1 $ld_profile_output/libdemo.so.1.profile\fp +flat profile: + +each sample counts as 0.01 seconds. + % cumulative self self total + time seconds seconds calls us/call us/call name + 60.00 0.06 0.06 100 600.00 consumecpu1 + 40.00 0.10 0.04 1000 40.00 consumecpu2 + 0.00 0.10 0.00 1 0.00 x1 + 0.00 0.10 0.00 1 0.00 x2 +.ee +.in +.pp +the +.b sprof \-q +option generates a call graph: +.pp +.in +4n +.ex +$ \fbsprof \-q libdemo.so.1 $ld_profile_output/libdemo.so.1.profile\fp + +index % time self children called name + + 0.00 0.00 100/100 x1 [1] +[0] 100.0 0.00 0.00 100 consumecpu1 [0] +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- + 0.00 0.00 1/1 +[1] 0.0 0.00 0.00 1 x1 [1] + 0.00 0.00 100/100 consumecpu1 [0] +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- + 0.00 0.00 1000/1000 x2 [3] +[2] 0.0 0.00 0.00 1000 consumecpu2 [2] +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- + 0.00 0.00 1/1 +[3] 0.0 0.00 0.00 1 x2 [3] + 0.00 0.00 1000/1000 consumecpu2 [2] +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- +.ee +.in +.pp +above and below, the "" strings represent identifiers that +are outside of the profiled object (in this example, these are instances of +.ir main() ). +.pp +the +.b sprof \-c +option generates a list of call pairs and the number of their occurrences: +.pp +.in +4n +.ex +$ \fbsprof \-c libdemo.so.1 $ld_profile_output/libdemo.so.1.profile\fp + x1 1 +x1 consumecpu1 100 + x2 1 +x2 consumecpu2 1000 +.ee +.in +.sh see also +.br gprof (1), +.br ldd (1), +.br ld.so (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) andreas gruenbacher, february 2001 +.\" copyright (c) silicon graphics inc, september 2001 +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th setxattr 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +setxattr, lsetxattr, fsetxattr \- set an extended attribute value +.sh synopsis +.fam c +.nf +.b #include +.pp +.bi "int setxattr(const char\ *" path ", const char\ *" name , +.bi " const void\ *" value ", size_t " size ", int " flags ); +.bi "int lsetxattr(const char\ *" path ", const char\ *" name , +.bi " const void\ *" value ", size_t " size ", int " flags ); +.bi "int fsetxattr(int " fd ", const char\ *" name , +.bi " const void\ *" value ", size_t " size ", int " flags ); +.fi +.fam t +.sh description +extended attributes are +.ir name :\c +.i value +pairs associated with inodes (files, directories, symbolic links, etc.). +they are extensions to the normal attributes which are associated +with all inodes in the system (i.e., the +.br stat (2) +data). +a complete overview of extended attributes concepts can be found in +.br xattr (7). +.pp +.br setxattr () +sets the +.i value +of the extended attribute identified by +.i name +and associated with the given +.i path +in the filesystem. +the +.i size +argument specifies the size (in bytes) of +.ir value ; +a zero-length value is permitted. +.pp +.br lsetxattr () +is identical to +.br setxattr (), +except in the case of a symbolic link, where the extended attribute is +set on the link itself, not the file that it refers to. +.pp +.br fsetxattr () +is identical to +.br setxattr (), +only the extended attribute is set on the open file referred to by +.i fd +(as returned by +.br open (2)) +in place of +.ir path . +.pp +an extended attribute name is a null-terminated string. +the +.i name +includes a namespace prefix; there may be several, disjoint +namespaces associated with an individual inode. +the +.i value +of an extended attribute is a chunk of arbitrary textual or +binary data of specified length. +.pp +by default +(i.e., +.ir flags +is zero), +the extended attribute will be created if it does not exist, +or the value will be replaced if the attribute already exists. +to modify these semantics, one of the following values can be specified in +.ir flags : +.tp +.b xattr_create +perform a pure create, which fails if the named attribute exists already. +.tp +.b xattr_replace +perform a pure replace operation, +which fails if the named attribute does not already exist. +.sh return value +on success, zero is returned. +on failure, \-1 is returned and +.i errno +is set to indicate the error. +.sh errors +.tp +.b edquot +disk quota limits meant that +there is insufficient space remaining to store the extended attribute. +.tp +.b eexist +.b xattr_create +was specified, and the attribute exists already. +.tp +.b enodata +.b xattr_replace +was specified, and the attribute does not exist. +.\" .rb ( enoattr +.\" is defined to be a synonym for +.\" .br enodata +.\" in +.\" .ir .) +.tp +.b enospc +there is insufficient space remaining to store the extended attribute. +.tp +.b enotsup +the namespace prefix of +.i name +is not valid. +.tp +.b enotsup +extended attributes are not supported by the filesystem, or are disabled, +.tp +.b eperm +the file is marked immutable or append-only. +(see +.br ioctl_iflags (2).) +.pp +in addition, the errors documented in +.br stat (2) +can also occur. +.tp +.b erange +the size of +.i name +or +.i value +exceeds a filesystem-specific limit. +.sh versions +these system calls have been available on linux since kernel 2.4; +glibc support is provided since version 2.3. +.sh conforming to +these system calls are linux-specific. +.\" .sh authors +.\" andreas gruenbacher, +.\" .ri < a.gruenbacher@computer.org > +.\" and the sgi xfs development team, +.\" .ri < linux-xfs@oss.sgi.com >. +.\" please send any bug reports or comments to these addresses. +.sh see also +.br getfattr (1), +.br setfattr (1), +.br getxattr (2), +.br listxattr (2), +.br open (2), +.br removexattr (2), +.br stat (2), +.br symlink (7), +.br xattr (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/makedev.3 + +.so man7/iso_8859-14.7 + +.so man2/poll.2 + +.\" copyright 2004 andries brouwer . +.\" and copyright 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th scalbln 3 2021-03-22 "" "linux programmer's manual" +.sh name +scalbn, scalbnf, scalbnl, scalbln, scalblnf, scalblnl \- +multiply floating-point number by integral power of radix +.sh synopsis +.nf +.b #include +.pp +.bi "double scalbln(double " x ", long " exp ); +.bi "float scalblnf(float " x ", long " exp ); +.bi "long double scalblnl(long double " x ", long " exp ); +.pp +.bi "double scalbn(double " x ", int " exp ); +.bi "float scalbnf(float " x ", int " exp ); +.bi "long double scalbnl(long double " x ", int " exp ); +.fi +.pp +link with \fi\-lm\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br scalbln (), +.br scalblnf (), +.br scalblnl (): +.nf + _isoc99_source || _posix_c_source >= 200112l + || /* since glibc 2.19: */ _default_source +.fi +.pp +.br scalbn (), +.br scalbnf (), +.br scalbnl (): +.nf + _isoc99_source || _posix_c_source >= 200112l + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.sh description +these functions multiply their first argument +.i x +by +.b flt_radix +(probably 2) +to the power of +.ir exp , +that is: +.pp +.nf + x * flt_radix ** exp +.fi +.pp +the definition of +.b flt_radix +can be obtained by including +.ir . +.\" not in /usr/include but in a gcc lib +.sh return value +on success, these functions return +.ir x +* +.b flt_radix +** +.ir exp . +.pp +if +.i x +is a nan, a nan is returned. +.pp +if +.i x +is positive infinity (negative infinity), +positive infinity (negative infinity) is returned. +.pp +if +.i x +is +0 (\-0), +0 (\-0) is returned. +.pp +if the result overflows, +a range error occurs, +and the functions return +.br huge_val , +.br huge_valf , +or +.br huge_vall , +respectively, with a sign the same as +.ir x . +.pp +if the result underflows, +a range error occurs, +and the functions return zero, with a sign the same as +.ir x . +.sh errors +see +.br math_error (7) +for information on how to determine whether an error has occurred +when calling these functions. +.pp +the following errors can occur: +.tp +range error, overflow +.\" .i errno +.\" is set to +.\" .br erange . +an overflow floating-point exception +.rb ( fe_overflow ) +is raised. +.tp +range error, underflow +.i errno +is set to +.br erange . +an underflow floating-point exception +.rb ( fe_underflow ) +is raised. +.sh versions +these functions first appeared in glibc in version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br scalbn (), +.br scalbnf (), +.br scalbnl (), +.br scalbln (), +.br scalblnf (), +.br scalblnl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.sh notes +these functions differ from the obsolete functions described in +.br scalb (3) +in the type of their second argument. +the functions described on this page have a second argument +of an integral type, while those in +.br scalb (3) +have a second argument of type +.ir double . +.pp +if +.b flt_radix +equals 2 (which is usual), then +.br scalbn () +is equivalent to +.br ldexp (3). +.sh bugs +before glibc 2.20, +.\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=6803 +these functions did not set +.i errno +for range errors. +.sh see also +.br ldexp (3), +.br scalb (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" written by oron peled . +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" may be distributed subject to the gpl. +.\" %%%license_end +.\" +.\" i tried to be as much generic in the description as possible: +.\" - general boot sequence is applicable to almost any +.\" os/machine (dos/pc, linux/pc, solaris/sparc, cms/s390) +.\" - kernel and init(1) is applicable to almost any unix/linux +.\" - boot scripts are applicable to sysv-r4 based unix/linux +.\" +.\" modified 2004-11-03 patch from martin schulze +.\" +.th boot 7 2015-03-11 "linux" "linux programmer's manual" +.sh name +boot \- system bootup process based on unix system v release 4 +.sh description +the \fbbootup process\fr (or "\fbboot sequence\fr") varies in details +among systems, but can be roughly divided into phases controlled by +the following components: +.ip 1. 4 +hardware +.ip 2. 4 +operating system (os) loader +.ip 3. 4 +kernel +.ip 4. 4 +root user-space process (\fiinit\fr and \fiinittab\fr) +.ip 5. 4 +boot scripts +.pp +each of these is described below in more detail. +.ss hardware +after power-on or hard reset, control is given +to a program stored in read-only memory (normally +prom); for historical reasons involving the personal +computer, this program is often called "the \fbbios\fr". +.pp +this program normally performs a basic self-test of the +machine and accesses nonvolatile memory to read +further parameters. +this memory in the pc is +battery-backed cmos memory, so most people +refer to it as "the \fbcmos\fr"; outside +of the pc world, it is usually called "the \fbnvram\fr" +(nonvolatile ram). +.pp +the parameters stored in the nvram vary among +systems, but as a minimum, they should specify +which device can supply an os loader, or at least which +devices may be probed for one; such a device is known as "the +\fbboot device\fr". +the hardware boot stage loads the os loader from a fixed position on +the boot device, and then transfers control to it. +.tp +note: +the device from which the os loader is read may be attached via a network, in which +case the details of booting are further specified by protocols such as +dhcp, tftp, pxe, etherboot, etc. +.ss os loader +the main job of the os loader is to locate the kernel +on some device, load it, and run it. +most os loaders allow +interactive use, in order to enable specification of an alternative +kernel (maybe a backup in case the one last compiled +isn't functioning) and to pass optional parameters +to the kernel. +.pp +in a traditional pc, the os loader is located in the initial 512-byte block +of the boot device; this block is known as "the \fbmbr\fr" +(master boot record). +.pp +in most systems, the os loader is very +limited due to various constraints. +even on non-pc systems, +there are some limitations on the size and complexity +of this loader, but the size limitation of the pc mbr +(512 bytes, including the partition table) makes it +almost impossible to squeeze much functionality into it. +.pp +therefore, most systems split the role of loading the os between +a primary os loader and a secondary os loader; this secondary +os loader may be located within a larger portion of persistent +storage, such as a disk partition. +.pp +in linux, the os loader is often either +.br lilo (8) +or +.br grub (8). +.ss kernel +when the kernel is loaded, it initializes various components of +the computer and operating system; each portion of software +responsible for such a task is usually consider "a \fbdriver\fr" for +the applicable component. +the kernel starts the virtual memory +swapper (it is a kernel process, called "kswapd" in a modern linux +kernel), and mounts some filesystem at the root path, +.ir / . +.pp +some of the parameters that may be passed to the kernel +relate to these activities (for example, the default root filesystem +can be overridden); for further information +on linux kernel parameters, read +.br bootparam (7). +.pp +only then does the kernel create the initial userland +process, which is given the number 1 as its +.b pid +(process id). +traditionally, this process executes the +program +.ir /sbin/init , +to which are passed the parameters that haven't already been +handled by the kernel. +.ss root user-space process +.tp +note: +the following description applies to an os based on unix system v release 4. +however, a number of widely used systems have adopted a related but +fundamentally different approach known as +.br systemd (1), +for which the bootup process is detailed in its associated +.br bootup (7). +.pp +when +.i /sbin/init +starts, it reads +.i /etc/inittab +for further instructions. +this file defines what should be run when the +.i /sbin/init +program is instructed to enter a particular \firun-level\fr, giving +the administrator an easy way to establish an environment +for some usage; each run-level is associated with a set of services +(for example, run-level \fbs\fr is \fisingle-user\fr mode, +and run-level \fb2\fr entails running most network services). +.pp +the administrator may change the current +run-level via +.br init (1), +and query the current run-level via +.br runlevel (8). +.pp +however, since it is not convenient to manage individual services +by editing this file, +.i /etc/inittab +only bootstraps a set of scripts +that actually start/stop the individual services. +.ss boot scripts +.tp +note: +the following description applies to an os based on unix system v release 4. +however, a number of widely used systems (slackware linux, freebsd, openbsd) +have a somewhat different scheme for boot scripts. +.pp +for each managed service (mail, nfs server, cron, etc.), there is +a single startup script located in a specific directory +.ri ( /etc/init.d +in most versions of linux). +each of these scripts accepts as a single argument +the word "start" (causing it to start the service) or the word +\&"stop" (causing it to stop the service). +the script may optionally +accept other "convenience" parameters (e.g., "restart" to stop and then +start, "status" to display the service status, etc.). +running the script +without parameters displays the possible arguments. +.ss sequencing directories +to make specific scripts start/stop at specific run-levels and in a +specific order, there are \fisequencing directories\fr, normally +of the form \fi/etc/rc[0\-6s].d\fr. +in each of these directories, +there are links (usually symbolic) to the scripts in the \fi/etc/init.d\fr +directory. +.pp +a primary script (usually \fi/etc/rc\fr) is called from +.br inittab (5); +this primary script calls each service's script via a link in the +relevant sequencing directory. +each link whose name begins with \(aqs\(aq is called with +the argument "start" (thereby starting the service). +each link whose name begins with \(aqk\(aq is called with +the argument "stop" (thereby stopping the service). +.pp +to define the starting or stopping order within the same run-level, +the name of a link contains an \fborder-number\fr. +also, for clarity, the name of a link usually +ends with the name of the service to which it refers. +for example, +the link \fi/etc/rc2.d/s80sendmail\fr starts the sendmail service on +runlevel 2. +this happens after \fi/etc/rc2.d/s12syslog\fr is run +but before \fi/etc/rc2.d/s90xfs\fr is run. +.pp +to manage these links is to manage the boot order and run-levels; +under many systems, there are tools to help with this task +(e.g., +.br chkconfig (8)). +.ss boot configuration +a program that provides a service is often called a "\fbdaemon\fr". +usually, a daemon may receive various command-line options +and parameters. +to allow a system administrator to change these +inputs without editing an entire boot script, +some separate configuration file is used, and is located in a specific +directory where an associated boot script may find it +(\fi/etc/sysconfig\fr on older red hat systems). +.pp +in older unix systems, such a file contained the actual command line +options for a daemon, but in modern linux systems (and also +in hp-ux), it just contains shell variables. +a boot script in \fi/etc/init.d\fr reads and includes its configuration +file (that is, it "\fbsources\fr" its configuration file) and then uses +the variable values. +.sh files +.ir /etc/init.d/ , +.ir /etc/rc[s0\-6].d/ , +.i /etc/sysconfig/ +.sh see also +.br init (1), +.br systemd (1), +.br inittab (5), +.br bootparam (7), +.br bootup (7), +.br runlevel (8), +.br shutdown (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/pthread_attr_init.3 + +.\" copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de) +.\" and copyright 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under gpl +.\" %%%license_end +.\" +.\" based on glibc infopages +.\" +.th nextafter 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +nextafter, nextafterf, nextafterl, nexttoward, nexttowardf, nexttowardl \- +floating-point number manipulation +.sh synopsis +.nf +.b #include +.pp +.bi "double nextafter(double " x ", double " y ); +.bi "float nextafterf(float " x ", float " y ); +.bi "long double nextafterl(long double " x ", long double " y ); +.pp +.bi "double nexttoward(double " x ", long double " y ); +.bi "float nexttowardf(float " x ", long double " y ); +.bi "long double nexttowardl(long double " x ", long double " y ); +.fi +.pp +link with \fi\-lm\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br nextafter (): +.nf + _isoc99_source || _posix_c_source >= 200112l + || _xopen_source >= 500 +.\" || _xopen_source && _xopen_source_extended + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.pp +.br nextafterf (), +.br nextafterl (): +.nf + _isoc99_source || _posix_c_source >= 200112l + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.pp +.br nexttoward (), +.br nexttowardf (), +.br nexttowardl (): +.nf + _xopen_source >= 600 || _isoc99_source + || _posix_c_source >= 200112l +.fi +.sh description +the +.br nextafter (), +.br nextafterf (), +and +.br nextafterl () +functions return the next representable floating-point value following +.i x +in the direction of +.ir y . +if +.i y +is less than +.ir x , +these functions will return the largest representable number less than +.ir x . +.pp +if +.i x +equals +.ir y , +the functions return +.ir y . +.pp +the +.br nexttoward (), +.br nexttowardf (), +and +.br nexttowardl () +functions do the same as the corresponding +.br nextafter () +functions, except that they have a +.i "long double" +second argument. +.sh return value +on success, +these functions return the next representable floating-point value after +.i x +in the direction of +.ir y . +.pp +if +.i x +equals +.ir y , +then +.i y +(cast to the same type as +.ir x ) +is returned. +.pp +if +.i x +or +.i y +is a nan, +a nan is returned. +.pp +if +.i x +is finite, +.\" e.g., dbl_max +and the result would overflow, +a range error occurs, +and the functions return +.br huge_val , +.br huge_valf , +or +.br huge_vall , +respectively, with the correct mathematical sign. +.pp +if +.i x +is not equal to +.ir y , +and the correct function result would be subnormal, zero, or underflow, +a range error occurs, +and either the correct value (if it can be represented), +or 0.0, is returned. +.sh errors +see +.br math_error (7) +for information on how to determine whether an error has occurred +when calling these functions. +.pp +the following errors can occur: +.tp +range error: result overflow +.\" e.g., nextafter(dbl_max, huge_val); +.i errno +is set to +.br erange . +an overflow floating-point exception +.rb ( fe_overflow ) +is raised. +.tp +range error: result is subnormal or underflows +.\" e.g., nextafter(dbl_min, 0.0); +.i errno +is set to +.br erange . +an underflow floating-point exception +.rb ( fe_underflow ) +is raised. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br nextafter (), +.br nextafterf (), +.br nextafterl (), +.br nexttoward (), +.br nexttowardf (), +.br nexttowardl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +this function is defined in iec 559 (and the appendix with +recommended functions in ieee 754/ieee 854). +.sh bugs +in glibc version 2.5 and earlier, these functions do not raise an underflow +floating-point +.rb ( fe_underflow ) +exception when an underflow occurs. +.pp +before glibc version 2.23 +.\" https://www.sourceware.org/bugzilla/show_bug.cgi?id=6799 +these functions did not set +.ir errno . +.sh see also +.br nearbyint (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/cpu_set.3 + +.\" copyright (c) 1983, 1987 the regents of the university of california. +.\" all rights reserved. +.\" +.\" @(#)mailaddr.7 6.5 (berkeley) 2/14/89 +.\" +.\" extensively rewritten by arnt gulbrandsen . my +.\" changes are placed under the same copyright as the original bsd page. +.\" +.\" adjusted by arnt gulbrandsen in 2004 to +.\" account for changes since 1995. route-addrs are now even less +.\" common, etc. some minor wording improvements. same copyright. +.\" +.\" %%%license_start(permissive_misc) +.\" redistribution and use in source and binary forms are permitted +.\" provided that the above copyright notice and this paragraph are +.\" duplicated in all such forms and that any documentation, +.\" advertising materials, and other materials related to such +.\" distribution and use acknowledge that the software was developed +.\" by the university of california, berkeley. the name of the +.\" university may not be used to endorse or promote products derived +.\" from this software without specific prior written permission. +.\" this software is provided ``as is'' and without any express or +.\" implied warranties, including, without limitation, the implied +.\" warranties of merchantability and fitness for a particular purpose. +.\" %%%license_end +.\" +.th mailaddr 7 2020-08-13 "linux" "linux user's manual" +.uc 5 +.sh name +mailaddr \- mail addressing description +.sh description +.nh +this manual page gives a brief introduction to smtp mail addresses, +as used on the internet. +these addresses are in the general format +.pp + user@domain +.pp +where a domain is a hierarchical dot-separated list of subdomains. +these examples are valid forms of the same address: +.pp + john.doe@monet.example.com +.br + john doe +.br + john.doe@monet.example.com (john doe) +.pp +the domain part ("monet.example.com") is a mail-accepting domain. +it can be a host and in the past it usually was, but it doesn't have to be. +the domain part is not case sensitive. +.pp +the local part ("john.doe") is often a username, +but its meaning is defined by the local software. +sometimes it is case sensitive, +although that is unusual. +if you see a local-part that looks like garbage, +it is usually because of a gateway between an internal e-mail +system and the net, here are some examples: +.pp + "surname/admd=telemail/c=us/o=hp/prmd=hp"@some.where +.br + user%something@some.where +.br + machine!machine!name@some.where +.br + i2461572@some.where +.pp +(these are, respectively, an x.400 gateway, a gateway to an arbitrary +internal mail system that lacks proper internet support, an uucp +gateway, and the last one is just boring username policy.) +.pp +the real-name part ("john doe") can either be placed before +<>, or in () at the end. +(strictly speaking the two aren't the same, +but the difference is beyond the scope of this page.) +the name may have to be quoted using "", for example, if it contains ".": +.pp + "john q. doe" +.ss abbreviation +some mail systems let users abbreviate the domain name. +for instance, +users at example.com may get away with "john.doe@monet" to +send mail to john doe. +.i "this behavior is deprecated." +sometimes it works, but you should not depend on it. +.ss route-addrs +in the past, sometimes one had to route a message through +several hosts to get it to its final destination. +addresses which show these relays are termed "route-addrs". +these use the syntax: +.pp + <@hosta,@hostb:user@hostc> +.pp +this specifies that the message should be sent to hosta, +from there to hostb, and finally to hostc. +many hosts disregard route-addrs and send directly to hostc. +.pp +route-addrs are very unusual now. +they occur sometimes in old mail archives. +it is generally possible to ignore all but the "user@hostc" +part of the address to determine the actual address. +.ss postmaster +every site is required to have a user or user alias designated +"postmaster" to which problems with the mail system may be +addressed. +the "postmaster" address is not case sensitive. +.sh files +.i /etc/aliases +.br +.i \(ti/.forward +.sh see also +.br mail (1), +.br aliases (5), +.br forward (5), +.br sendmail (8) +.pp +.ur http://www.ietf.org\:/rfc\:/rfc5322.txt +ietf rfc\ 5322 +.ue +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man7/system_data_types.7 + +.so man2/dup.2 + +.so man3/tailq.3 + +.\" copyright (c) 2017, michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th pthread_spin_init 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +pthread_spin_init, pthread_spin_destroy \- initialize or destroy a spin lock +.sh synopsis +.nf +.b #include +.pp +.bi "int pthread_spin_init(pthread_spinlock_t *" lock ", int " pshared ");" +.bi "int pthread_spin_destroy(pthread_spinlock_t *" lock ");" +.fi +.pp +compile and link with \fi\-pthread\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br pthread_spin_init (), +.br pthread_spin_destroy (): +.nf + _posix_c_source >= 200112l +.fi +.sh description +.ir "general note" : +most programs should use mutexes +instead of spin locks. +spin locks are primarily useful in conjunction with real-time +scheduling policies. +see notes. +.pp +the +.br pthread_spin_init () +function allocates any resources required for the use of +the spin lock referred to by +.i lock +and initializes the lock to be in the unlocked state. +the +.i pshared +argument must have one of the following values: +.tp +.b pthread_process_private +the spin lock is to be operated on only by threads in the same process +as the thread that calls +.br pthread_spin_init (). +(attempting to share the spin lock between processes +results in undefined behavior.) +.tp +.b pthread_process_shared +the spin lock may be operated on by any thread in any process that +has access to the memory containing the lock +(i.e., the lock may be in a shared memory object that is +shared among multiple processes). +.pp +calling +.br pthread_spin_init () +on a spin lock that has already been initialized results +in undefined behavior. +.pp +the +.br pthread_spin_destroy () +function destroys a previously initialized spin lock, +freeing any resources that were allocated for that lock. +destroying a spin lock that has not been previously been initialized +or destroying a spin lock while another thread holds the lock +results in undefined behavior. +.pp +once a spin lock has been destroyed, +performing any operation on the lock other than +once more initializing it with +.br pthread_spin_init () +results in undefined behavior. +.pp +the result of performing operations such as +.br pthread_spin_lock (3), +.br pthread_spin_unlock (3), +and +.br pthread_spin_destroy () +on +.i copies +of the object referred to by +.i lock +is undefined. +.sh return value +on success, there functions return zero. +on failure, they return an error number. +in the event that +.br pthread_spin_init () +fails, the lock is not initialized. +.sh errors +.br pthread_spin_init () +may fail with the following errors: +.\" these errors don't occur on the glibc implementation +.tp +.b eagain +the system has insufficient resources to initialize +a new spin lock. +.tp +.b enomem +insufficient memory to initialize the spin lock. +.sh versions +these functions first appeared in glibc in version 2.2. +.sh conforming to +posix.1-2001. +.pp +support for process-shared spin locks is a posix option. +the option is supported in the glibc implementation. +.sh notes +spin locks should be employed in conjunction with +real-time scheduling policies +.rb ( sched_fifo , +or possibly +.br sched_rr ). +use of spin locks with nondeterministic scheduling policies such as +.br sched_other +probably indicates a design mistake. +the problem is that if a thread operating under such a policy +is scheduled off the cpu while it holds a spin lock, +then other threads will waste time spinning on the lock +until the lock holder is once more rescheduled and releases the lock. +.pp +if threads create a deadlock situation while employing spin locks, +those threads will spin forever consuming cpu time. +.pp +user-space spin locks are +.i not +applicable as a general locking solution. +they are, by definition, +prone to priority inversion and unbounded spin times. +a programmer using spin locks must be exceptionally careful not +only in the code, but also in terms of system configuration, +thread placement, and priority assignment. +.\" fixme . when pthread_mutex_adaptive_np is one day document +.\" make reference to it here +.sh see also +.ad l +.nh +.br pthread_mutex_init (3), +.br pthread_mutex_lock (3), +.br pthread_spin_lock (3), +.br pthread_spin_unlock (3), +.br pthreads (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/umount.2 + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" iso/iec 9899:1999 +.\" +.th mbsinit 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +mbsinit \- test for initial shift state +.sh synopsis +.nf +.b #include +.pp +.bi "int mbsinit(const mbstate_t *" ps ); +.fi +.sh description +character conversion between the multibyte representation and the wide +character representation uses conversion state, of type +.ir mbstate_t . +conversion of a string uses a finite-state machine; when it is interrupted +after the complete conversion of a number of characters, it may need to +save a state for processing the remaining characters. +such a conversion +state is needed for the sake of encodings such as iso-2022 and utf-7. +.pp +the initial state is the state at the beginning of conversion of a string. +there are two kinds of state: the one used by multibyte to wide character +conversion functions, such as +.br mbsrtowcs (3), +and the one used by wide +character to multibyte conversion functions, such as +.br wcsrtombs (3), +but they both fit in a +.ir mbstate_t , +and they both have the same +representation for an initial state. +.pp +for 8-bit encodings, all states are equivalent to the initial state. +for multibyte encodings like utf-8, euc-*, big5, or sjis, the wide character +to multibyte conversion functions never produce non-initial states, but the +multibyte to wide-character conversion functions like +.br mbrtowc (3) +do +produce non-initial states when interrupted in the middle of a character. +.pp +one possible way to create an +.i mbstate_t +in initial state is to set it to zero: +.pp +.in +4n +.ex +mbstate_t state; +memset(&state, 0, sizeof(state)); +.ee +.in +.pp +on linux, the following works as well, but might generate compiler warnings: +.pp +.in +4n +.ex +mbstate_t state = { 0 }; +.ee +.in +.pp +the function +.br mbsinit () +tests whether +.i *ps +corresponds to an +initial state. +.sh return value +.br mbsinit () +returns nonzero if +.i *ps +is an initial state, or if +.i ps +is null. +otherwise, it returns 0. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br mbsinit () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh notes +the behavior of +.br mbsinit () +depends on the +.b lc_ctype +category of the +current locale. +.sh see also +.br mbrlen (3), +.br mbrtowc (3), +.br mbsrtowcs (3), +.br wcrtomb (3), +.br wcsrtombs (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/modf.3 + +.\" copyright (c) 2007 michael kerrisk +.\" and copyright (c) 1995 michael shields . +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and author of this work. +.\" %%%license_end +.\" +.\" modified 1996-10-22 by eric s. raymond +.\" modified 1997-05-31 by andries brouwer +.\" modified 2003-08-24 by andries brouwer +.\" modified 2004-08-16 by andi kleen +.\" 2007-06-02, mtk: fairly substantial rewrites and additions, and +.\" a much improved example program. +.\" +.th mprotect 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +mprotect, pkey_mprotect \- set protection on a region of memory +.sh synopsis +.nf +.b #include +.pp +.bi "int mprotect(void *" addr ", size_t " len ", int " prot ); +.pp +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "int pkey_mprotect(void *" addr ", size_t " len ", int " prot ", int " pkey ");" +.fi +.sh description +.br mprotect () +changes the access protections for the calling process's memory pages +containing any part of the address range in the +interval [\fiaddr\fp,\ \fiaddr\fp+\filen\fp\-1]. +.i addr +must be aligned to a page boundary. +.pp +if the calling process tries to access memory in a manner +that violates the protections, then the kernel generates a +.b sigsegv +signal for the process. +.pp +.i prot +is a combination of the following access flags: +.b prot_none +or a bitwise-or of the other values in the following list: +.tp +.b prot_none +the memory cannot be accessed at all. +.tp +.b prot_read +the memory can be read. +.tp +.b prot_write +the memory can be modified. +.tp +.b prot_exec +the memory can be executed. +.tp +.br prot_sem " (since linux 2.5.7)" +the memory can be used for atomic operations. +this flag was introduced as part of the +.br futex (2) +implementation (in order to guarantee the ability to perform atomic +operations required by commands such as +.br futex_wait ), +but is not currently used in on any architecture. +.tp +.br prot_sao " (since linux 2.6.26)" +.\" commit aba46c5027cb59d98052231b36efcbbde9c77a1d +.\" commit ef3d3246a0d06be622867d21af25f997aeeb105f +the memory should have strong access ordering. +this feature is specific to +the powerpc architecture +(version 2.06 of the architecture specification adds the sao cpu feature, +and it is available on power 7 or powerpc a2, for example). +.pp +additionally (since linux 2.6.0), +.i prot +can have one of the following flags set: +.tp +.\" mm/mmap.c: +.\" vm_flags |= calc_vm_prot_bits(prot, pkey) | calc_vm_flag_bits(flags) | +.\" mm->def_flags | vm_mayread | vm_maywrite | vm_mayexec; +.\" and calc_vm_flag_bits converts only growsdown/denywrite/locked. +.b prot_growsup +apply the protection mode up to the end of a mapping +that grows upwards. +(such mappings are created for the stack area on +architectures\(emfor example, hp-parisc\(emthat +have an upwardly growing stack.) +.\" the vma is one that was marked with vm_growsup by the kernel +.\" when the stack was created. note that (unlike vm_growsdown), +.\" there is no mmap() flag (analogous to map_growsdown) for +.\" creating a vma that is marked vm_growsup. +.tp +.b prot_growsdown +apply the protection mode down to the beginning of a mapping +that grows downward +(which should be a stack segment or a segment mapped with the +.b map_growsdown +flag set). +.pp +like +.br mprotect (), +.br pkey_mprotect () +changes the protection on the pages specified by +.ir addr +and +.ir len . +the +.i pkey +argument specifies the protection key (see +.br pkeys (7)) +to assign to the memory. +the protection key must be allocated with +.br pkey_alloc (2) +before it is passed to +.br pkey_mprotect (). +for an example of the use of this system call, see +.br pkeys (7). +.sh return value +on success, +.br mprotect () +and +.br pkey_mprotect () +return zero. +on error, these system calls return \-1, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eacces +the memory cannot be given the specified access. +this can happen, for example, if you +.br mmap (2) +a file to which you have read-only access, then ask +.br mprotect () +to mark it +.br prot_write . +.tp +.b einval +\fiaddr\fp is not a valid pointer, +or not a multiple of the system page size. +.tp +.br einval +.rb ( pkey_mprotect ()) +\fipkey\fp has not been allocated with +.br pkey_alloc (2) +.tp +.br einval +both +.br prot_growsup +and +.br prot_growsdown +were specified in +.ir prot . +.tp +.br einval +invalid flags specified in +.ir prot . +.tp +.br einval +(powerpc architecture) +.b prot_sao +was specified in +.ir prot , +but sao hardware feature is not available. +.tp +.b enomem +internal kernel structures could not be allocated. +.tp +.b enomem +addresses in the range +.ri [ addr , +.ir addr + len \-1] +are invalid for the address space of the process, +or specify one or more pages that are not mapped. +(before kernel 2.4.19, the error +.br efault +was incorrectly produced for these cases.) +.tp +.b enomem +changing the protection of a memory region would result in the total number of +mappings with distinct attributes (e.g., read versus read/write protection) +exceeding the allowed maximum. +.\" i.e., the number of vmas would exceed the 64 kb maximum +(for example, making the protection of a range +.br prot_read +in the middle of a region currently protected as +.br prot_read|prot_write +would result in three mappings: +two read/write mappings at each end and a read-only mapping in the middle.) +.sh versions +.br pkey_mprotect () +first appeared in linux 4.9; +library support was added in glibc 2.27. +.sh conforming to +.br mprotect (): +posix.1-2001, posix.1-2008, svr4. +.\" svr4 defines an additional error +.\" code eagain. the svr4 error conditions don't map neatly onto linux's. +posix says that the behavior of +.br mprotect () +is unspecified if it is applied to a region of memory that +was not obtained via +.br mmap (2). +.pp +.br pkey_mprotect () +is a nonportable linux extension. +.sh notes +on linux, it is always permissible to call +.br mprotect () +on any address in a process's address space (except for the +kernel vsyscall area). +in particular, it can be used +to change existing code mappings to be writable. +.pp +whether +.b prot_exec +has any effect different from +.b prot_read +depends on processor architecture, kernel version, and process state. +if +.b read_implies_exec +is set in the process's personality flags (see +.br personality (2)), +specifying +.b prot_read +will implicitly add +.br prot_exec . +.pp +on some hardware architectures (e.g., i386), +.b prot_write +implies +.br prot_read . +.pp +posix.1 says that an implementation may permit access +other than that specified in +.ir prot , +but at a minimum can allow write access only if +.b prot_write +has been set, and must not allow any access if +.b prot_none +has been set. +.pp +applications should be careful when mixing use of +.br mprotect () +and +.br pkey_mprotect (). +on x86, when +.br mprotect () +is used with +.ir prot +set to +.b prot_exec +a pkey may be allocated and set on the memory implicitly +by the kernel, but only when the pkey was 0 previously. +.pp +on systems that do not support protection keys in hardware, +.br pkey_mprotect () +may still be used, but +.ir pkey +must be set to \-1. +when called this way, the operation of +.br pkey_mprotect () +is equivalent to +.br mprotect (). +.sh examples +.\" sigaction.2 refers to this example +the program below demonstrates the use of +.br mprotect (). +the program allocates four pages of memory, makes the third +of these pages read-only, and then executes a loop that walks upward +through the allocated region modifying bytes. +.pp +an example of what we might see when running the program is the +following: +.pp +.in +4n +.ex +.rb "$" " ./a.out" +start of region: 0x804c000 +got sigsegv at address: 0x804e000 +.ee +.in +.ss program source +\& +.ex +#include +#include +#include +#include +#include +#include +#include + +#define handle_error(msg) \e + do { perror(msg); exit(exit_failure); } while (0) + +static char *buffer; + +static void +handler(int sig, siginfo_t *si, void *unused) +{ + /* note: calling printf() from a signal handler is not safe + (and should not be done in production programs), since + printf() is not async\-signal\-safe; see signal\-safety(7). + nevertheless, we use printf() here as a simple way of + showing that the handler was called. */ + + printf("got sigsegv at address: %p\en", si\->si_addr); + exit(exit_failure); +} + +int +main(int argc, char *argv[]) +{ + int pagesize; + struct sigaction sa; + + sa.sa_flags = sa_siginfo; + sigemptyset(&sa.sa_mask); + sa.sa_sigaction = handler; + if (sigaction(sigsegv, &sa, null) == \-1) + handle_error("sigaction"); + + pagesize = sysconf(_sc_page_size); + if (pagesize == \-1) + handle_error("sysconf"); + + /* allocate a buffer aligned on a page boundary; + initial protection is prot_read | prot_write. */ + + buffer = memalign(pagesize, 4 * pagesize); + if (buffer == null) + handle_error("memalign"); + + printf("start of region: %p\en", buffer); + + if (mprotect(buffer + pagesize * 2, pagesize, + prot_read) == \-1) + handle_error("mprotect"); + + for (char *p = buffer ; ; ) + *(p++) = \(aqa\(aq; + + printf("loop completed\en"); /* should never happen */ + exit(exit_success); +} +.ee +.sh see also +.br mmap (2), +.br sysconf (3), +.br pkeys (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1993 by thomas koenig (ig25@rz.uni-karlsruhe.de) +.\" and copyright (c) 2004 by michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified sat jul 24 13:32:44 1993 by rik faith (faith@cs.unc.edu) +.\" modified mon jun 23 14:09:52 1997 by aeb - add eintr. +.\" modified tue jul 7 12:26:42 1998 by aeb - changed return value wait3 +.\" modified 2004-11-11, michael kerrisk +.\" rewrote much of this page, and removed much duplicated text, +.\" replacing with pointers to wait.2 +.\" +.th wait4 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +wait3, wait4 \- wait for process to change state, bsd style +.sh synopsis +.nf +.b #include +.pp +.bi "pid_t wait3(int *" "wstatus" ", int " options ", struct rusage *" rusage ); +.bi "pid_t wait4(pid_t " pid ", int *" wstatus ", int " options , +.bi " struct rusage *" rusage ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br wait3 (): +.nf + since glibc 2.26: + _default_source + || (_xopen_source >= 500 && + ! (_posix_c_source >= 200112l + || _xopen_source >= 600)) + from glibc 2.19 to 2.25: + _default_source || _xopen_source >= 500 + glibc 2.19 and earlier: + _bsd_source || _xopen_source >= 500 +.\" || _xopen_source && _xopen_source_extended +.fi +.pp +.br wait4 (): +.nf + since glibc 2.19: + _default_source + glibc 2.19 and earlier: + _bsd_source +.fi +.sh description +these functions are nonstandard; in new programs, the use of +.br waitpid (2) +or +.br waitid (2) +is preferable. +.pp +the +.br wait3 () +and +.br wait4 () +system calls are similar to +.br waitpid (2), +but additionally return resource usage information about the +child in the structure pointed to by +.ir rusage . +.pp +other than the use of the +.i rusage +argument, the following +.br wait3 () +call: +.pp +.in +4n +.ex +wait3(wstatus, options, rusage); +.ee +.in +.pp +is equivalent to: +.pp +.in +4n +.ex +waitpid(\-1, wstatus, options); +.ee +.in +.pp +similarly, the following +.br wait4 () +call: +.pp +.in +4n +.ex +wait4(pid, wstatus, options, rusage); +.ee +.in +.pp +is equivalent to: +.pp +.in +4n +.ex +waitpid(pid, wstatus, options); +.ee +.in +.pp +in other words, +.br wait3 () +waits of any child, while +.br wait4 () +can be used to select a specific child, or children, on which to wait. +see +.br wait (2) +for further details. +.pp +if +.i rusage +is not null, the +.i struct rusage +to which it points will be filled with accounting information +about the child. +see +.br getrusage (2) +for details. +.sh return value +as for +.br waitpid (2). +.sh errors +as for +.br waitpid (2). +.sh conforming to +4.3bsd. +.pp +susv1 included a specification of +.br wait3 (); +susv2 included +.br wait3 (), +but marked it legacy; +susv3 removed it. +.sh notes +including +.i +is not required these days, but increases portability. +(indeed, +.i +defines the +.i rusage +structure with fields of type +.i struct timeval +defined in +.ir .) +.ss c library/kernel differences +on linux, +.br wait3 () +is a library function implemented on top of the +.br wait4 () +system call. +.sh see also +.br fork (2), +.br getrusage (2), +.br sigaction (2), +.br signal (2), +.br wait (2), +.br signal (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/rpc.3 + +.\" copyright (c) 1993 by thomas koenig (ig25@rz.uni-karlsruhe.de) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified sat jul 24 17:35:15 1993 by rik faith +.\" modified sun feb 19 22:02:32 1995 by rik faith +.\" modified tue oct 22 23:28:12 1996 by eric s. raymond +.\" modified sun jan 26 21:56:56 1997 by ralph schleicher +.\" +.\" modified mon jun 16 20:24:58 1997 by nicolás lichtmaier +.\" modified sun oct 18 22:11:28 1998 by joseph s. myers +.\" modified mon nov 16 17:24:47 1998 by andries brouwer +.\" modified thu nov 16 23:28:25 2000 by david a. wheeler +.\" +.\" +.\" "nroff" ("man") (or "tbl") needs a long page to avoid warnings +.\" from "grotty" (at imagined page breaks). bug in grotty? +.if n .pl 1000v +.th suffixes 7 2020-08-13 "linux" "linux programmer's manual" +.sh name +suffixes \- list of file suffixes +.sh description +it is customary to indicate the contents of a file with the file suffix, +which (typically) consists of a period, followed by one or more letters. +many standard utilities, such as compilers, use this to recognize the type of +file they are dealing with. +the +.br make (1) +utility is driven by rules based on file suffix. +.pp +following is a list of suffixes which are likely to be found on a +linux system. +.pp +.ts +l | l +_ | _ +li | l . +suffix file type + ,v files for rcs (revision control system) + - backup file + .c c++ source code, equivalent to \fi.cc\fp + .f fortran source with \fbcpp\fp(1) directives + or file compressed using freeze + .s assembler source with \fbcpp\fp(1) directives + .y file compressed using yabba + .z file compressed using \fbcompress\fp(1) + .[0\-9]+gf tex generic font files + .[0\-9]+pk tex packed font files + .[1\-9] manual page for the corresponding section + .[1\-9][a-z] manual page for section plus subsection + .a static object code library + .ad x application default resource file + .ada ada source (may be body, spec, or combination) + .adb ada body source + .ads ada spec source + .afm postscript font metrics + .al perl autoload file + .am \fbautomake\fp(1) input file + .arc \fbarc\fp(1) archive + .arj \fbarj\fp(1) archive + .asc pgp ascii-armored data + .asm (gnu) assembler source file + .au audio sound file + .aux latex auxiliary file + .avi (msvideo) movie + .awk awk language program + .b lilo boot loader image + .bak backup file + .bash \fbbash\fp(1) shell script + .bb basic block list data produced by + gcc \-ftest\-coverage + .bbg basic block graph data produced by + gcc \-ftest\-coverage + .bbl bibtex output + .bdf x font file + .bib tex bibliographic database, bibtex input + .bm bitmap source + .bmp bitmap + .bz2 file compressed using \fbbzip2\fp(1) + .c c source + .cat message catalog files + .cc c++ source + .cf configuration file + .cfg configuration file + .cgi www content generating script or program + .cls latex class definition + .class java compiled byte-code + .conf configuration file + .config configuration file + .cpp equivalent to \fi.cc\fr + .csh \fbcsh\fp(1) shell script + .cxx equivalent to \fi.cc\fr + .dat data file + .deb debian software package + .def modula-2 source for definition modules + .def other definition files + .desc initial part of mail message unpacked with + \fbmunpack\fp(1) + .diff file differences (\fbdiff\fp(1) command output) + .dir dbm data base directory file + .doc documentation file + .dsc debian source control (source package) + .dtx latex package source file + .dvi tex's device independent output + .el emacs-lisp source + .elc compiled emacs-lisp source + .eps encapsulated postscript + .exp expect source code + .f fortran source + .f77 fortran 77 source + .f90 fortran 90 source + .fas precompiled common-lisp + .fi fortran include files + .fig fig image file (used by \fbxfig\fp(1)) + .fmt tex format file + .gif compuserve graphics image file format + .gmo gnu format message catalog + .gsf ghostscript fonts + .gz file compressed using \fbgzip\fp(1) + .h c or c++ header files + .help help file + .hf equivalent to \fi.help\fp + .hlp equivalent to \fi.help\fp + .htm poor man's \fi.html\fp + .html html document used with the world wide web + .hqx 7-bit encoded macintosh file + .i c source after preprocessing + .icon bitmap source + .idx reference or datum-index file for hypertext + or database system + .image bitmap source + .in configuration template, especially for gnu autoconf + .info files for the emacs info browser + .info-[0\-9]+ split info files + .ins latex package install file for docstrip + .itcl itcl source code; + itcl ([incr tcl]) is an oo extension of tcl + .java a java source file + .jpeg joint photographic experts group format + .jpg poor man's \fi.jpeg\fp + .kmap \fblyx\fp(1) keymap + .l equivalent to \fi.lex\fp or \fi.lisp\fp + .lex \fblex\fp(1) or \fbflex\fp(1) files + .lha lharc archive + .lib common-lisp library + .lisp lisp source + .ln files for use with \fblint\fp(1) + .log log file, in particular produced by tex + .lsm linux software map entry + .lsp common-lisp source + .lzh lharc archive + .m objective-c source code + .m4 \fbm4\fp(1) source + .mac macro files for various programs + .man manual page (usually source rather than formatted) + .map map files for various programs + .me nroff source using the me macro package + .mf metafont (font generator for tex) source + .mgp magicpoint file + .mm sources for \fbgroff\fp(1) in mm - format + .mo message catalog binary file + .mod modula-2 source for implementation modules + .mov (quicktime) movie + .mp metapost source + .mp2 mpeg layer 2 (audio) file + .mp3 mpeg layer 3 (audio) file + .mpeg movie file + .o object file + .old old or backup file + .orig backup (original) version of a file, from \fbpatch\fp(1) + .out output file, often executable program (a.out) + .p pascal source + .pag dbm data base data file + .patch file differences for \fbpatch\fp(1) + .pbm portable bitmap format + .pcf x11 font files + .pdf adobe portable data format + (use acrobat/\fbacroread\fp or \fbxpdf\fp) + .perl perl source (see .ph, .pl, and .pm) + .pfa postscript font definition files, ascii format + .pfb postscript font definition files, binary format + .pgm portable greymap format + .pgp pgp binary data + .ph perl header file + .php php program file + .php3 php3 program file + .pid file to store daemon pid (e.g., crond.pid) + .pl tex property list file or perl library file + .pm perl module + .png portable network graphics file + .po message catalog source + .pod \fbperldoc\fp(1) file + .ppm portable pixmap format + .pr bitmap source + .ps postscript file + .py python source + .pyc compiled python + .qt quicktime movie + .r ratfor source (obsolete) + .rej patches that \fbpatch\fp(1) couldn't apply + .rpm rpm software package + .rtf rich text format file + .rules rules for something + .s assembler source + .sa stub libraries for a.out shared libraries + .sc \fbsc\fp(1) spreadsheet commands + .scm scheme source code + .sed sed source file + .sgml sgml source file + .sh \fbsh\fp(1) scripts + .shar archive created by the \fbshar\fp(1) utility + .so shared library or dynamically loadable object + .sql sql source + .sqml sqml schema or query program + .sty latex style files + .sym modula-2 compiled definition modules + .tar archive created by the \fbtar\fp(1) utility + .tar.z tar(1) archive compressed with \fbcompress\fp(1) + .tar.bz2 tar(1) archive compressed with \fbbzip2\fp(1) + .tar.gz tar(1) archive compressed with \fbgzip\fp(1) + .taz tar(1) archive compressed with \fbcompress\fp(1) + .tcl tcl source code + .tex tex or latex source + .texi equivalent to \fi.texinfo\fp + .texinfo texinfo documentation source + .text text file + .tfm tex font metric file + .tgz tar archive compressed with \fbgzip\fp(1) + .tif poor man's \fi.tiff\fp + .tiff tagged image file format + .tk tcl/tk script + .tmp temporary file + .tmpl template files + .txt equivalent to \fi.text\fp + .uu equivalent to \fi.uue\fp + .uue binary file encoded with \fbuuencode\fp(1) + .vf tex virtual font file + .vpl tex virtual property list file + .w silvio levi's cweb + .wav wave sound file + .web donald knuth's web + .wml source file for web meta language + .xbm x11 bitmap source + .xcf gimp graphic + .xml extended markup language file + .xpm x11 pixmap source + .xs perl xsub file produced by h2xs + .xsl xsl stylesheet + .y \fbyacc\fp(1) or \fbbison\fp(1) (parser generator) files + .z file compressed using \fbpack\fp(1) (or an old \fbgzip\fp(1)) + .zip \fbzip\fp(1) archive + .zoo \fbzoo\fp(1) archive + \(ti emacs or \fbpatch\fp(1) backup file + rc startup (`run control') file, e.g., \fi.newsrc\fp +.te +.sh conforming to +general unix conventions. +.sh bugs +this list is not exhaustive. +.sh see also +.br file (1), +.br make (1) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/tailq.3 + +.\" copyright (c) 1993 michael haardt, (michael@moria.de) +.\" and copyright 2006, 2008, michael kerrisk +.\" fri apr 2 11:32:09 met dst 1993 +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" modified wed jul 21 19:52:58 1993 by rik faith +.\" modified sun aug 21 17:40:38 1994 by rik faith +.\" +.th brk 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +brk, sbrk \- change data segment size +.sh synopsis +.nf +.b #include +.pp +.bi "int brk(void *" addr ); +.bi "void *sbrk(intptr_t " increment ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br brk (), +.br sbrk (): +.nf + since glibc 2.19: + _default_source + || ((_xopen_source >= 500) && + ! (_posix_c_source >= 200112l)) +.\" (_xopen_source >= 500 || +.\" _xopen_source && _xopen_source_extended) && + from glibc 2.12 to 2.19: + _bsd_source || _svid_source + || ((_xopen_source >= 500) && + ! (_posix_c_source >= 200112l)) +.\" (_xopen_source >= 500 || +.\" _xopen_source && _xopen_source_extended) && + before glibc 2.12: + _bsd_source || _svid_source || _xopen_source >= 500 +.\" || _xopen_source && _xopen_source_extended +.fi +.sh description +.br brk () +and +.br sbrk () +change the location of the +.ir "program break" , +which defines the end of the process's data segment +(i.e., the program break is the first location after the end of the +uninitialized data segment). +increasing the program break has the effect of +allocating memory to the process; +decreasing the break deallocates memory. +.pp +.br brk () +sets the end of the data segment to the value specified by +.ir addr , +when that value is reasonable, the system has enough memory, +and the process does not exceed its maximum data size (see +.br setrlimit (2)). +.pp +.br sbrk () +increments the program's data space by +.i increment +bytes. +calling +.br sbrk () +with an +.i increment +of 0 can be used to find the current location of the program break. +.sh return value +on success, +.br brk () +returns zero. +on error, \-1 is returned, and +.i errno +is set to +.br enomem . +.pp +on success, +.br sbrk () +returns the previous program break. +(if the break was increased, +then this value is a pointer to the start of the newly allocated memory). +on error, +.i "(void\ *)\ \-1" +is returned, and +.i errno +is set to +.br enomem . +.sh conforming to +4.3bsd; susv1, marked legacy in susv2, removed in posix.1-2001. +.\" +.\" .br brk () +.\" and +.\" .br sbrk () +.\" are not defined in the c standard and are deliberately excluded from the +.\" posix.1-1990 standard (see paragraphs b.1.1.1.3 and b.8.3.3). +.sh notes +avoid using +.br brk () +and +.br sbrk (): +the +.br malloc (3) +memory allocation package is the +portable and comfortable way of allocating memory. +.pp +various systems use various types for the argument of +.br sbrk (). +common are \fiint\fp, \fissize_t\fp, \fiptrdiff_t\fp, \fiintptr_t\fp. +.\" one sees +.\" \fiint\fp (e.g., xpgv4, du 4.0, hp-ux 11, freebsd 4.0, openbsd 3.2), +.\" \fissize_t\fp (osf1 2.0, irix 5.3, 6.5), +.\" \fiptrdiff_t\fp (libc4, libc5, ulibc, glibc 2.0, 2.1), +.\" \fiintptr_t\fp (e.g., xpgv5, aix, sunos 5.8, 5.9, freebsd 4.7, netbsd 1.6, +.\" tru64 5.1, glibc2.2). +.ss c library/kernel differences +the return value described above for +.br brk () +is the behavior provided by the glibc wrapper function for the linux +.br brk () +system call. +(on most other implementations, the return value from +.br brk () +is the same; this return value was also specified in susv2.) +however, +the actual linux system call returns the new program break on success. +on failure, the system call returns the current break. +the glibc wrapper function does some work +(i.e., checks whether the new break is less than +.ir addr ) +to provide the 0 and \-1 return values described above. +.pp +on linux, +.br sbrk () +is implemented as a library function that uses the +.br brk () +system call, and does some internal bookkeeping so that it can +return the old break value. +.sh see also +.br execve (2), +.br getrlimit (2), +.br end (3), +.br malloc (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2012 tomáš pospíšek (tpo_deb@sourcepole.ch), +.\" fri, 03 nov 2012 22:35:33 +0100 +.\" and copyright (c) 2012 eric w. biederman +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, write to the free +.\" software foundation, inc., 59 temple place, suite 330, boston, ma 02111, +.\" usa. +.\" %%%license_end +.\" +.\" +.th veth 4 2021-03-22 "linux" "linux programmer's manual" +.sh name +veth \- virtual ethernet device +.sh description +the +.b veth +devices are virtual ethernet devices. +they can act as tunnels between network namespaces to create +a bridge to a physical network device in another namespace, +but can also be used as standalone network devices. +.pp +.b veth +devices are always created in interconnected pairs. +a pair can be created using the command: +.pp +.in +4n +.ex +# ip link add type veth peer name +.ee +.in +.pp +in the above, +.i p1-name +and +.i p2-name +are the names assigned to the two connected end points. +.pp +packets transmitted on one device in the pair are immediately received on +the other device. +when either devices is down the link state of the pair is down. +.pp +.b veth +device pairs are useful for combining the network +facilities of the kernel together in interesting ways. +a particularly interesting use case is to place one end of a +.b veth +pair in one network namespace and the other end in another network namespace, +thus allowing communication between network namespaces. +to do this, one can provide the +.b netns +parameter when creating the interfaces: +.pp +.in +4n +.ex +# ip link add netns type veth peer netns +.ee +.in +.pp +or, for an existing +.b veth +pair, move one side to the other namespace: +.pp +.in +4n +.ex +# ip link set netns +.ee +.in +.pp +.br ethtool (8) +can be used to find the peer of a +.b veth +network interface, using commands something like: +.pp +.in +4n +.ex +# \fbip link add ve_a type veth peer name ve_b\fp # create veth pair +# \fbethtool \-s ve_a\fp # discover interface index of peer +nic statistics: + peer_ifindex: 16 +# \fbip link | grep \(aq\(ha16:\(aq\fp # look up interface +16: ve_b@ve_a: mtu 1500 qdisc ... +.ee +.in +.sh "see also" +.br clone (2), +.br network_namespaces (7), +.br ip (8), +.br ip\-link (8), +.br ip\-netns (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2009 linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" 2009-01-12, mtk, created +.\" +.th rtld-audit 7 2020-11-01 "linux" "linux programmer's manual" +.sh name +rtld-audit \- auditing api for the dynamic linker +.sh synopsis +.nf +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b #include +.fi +.sh description +the gnu dynamic linker (run-time linker) +provides an auditing api that allows an application +to be notified when various dynamic linking events occur. +this api is very similar to the auditing interface provided by the +solaris run-time linker. +the necessary constants and prototypes are defined by including +.ir . +.pp +to use this interface, the programmer creates a shared library +that implements a standard set of function names. +not all of the functions need to be implemented: in most cases, +if the programmer is not interested in a particular class of auditing event, +then no implementation needs to be provided for the corresponding +auditing function. +.pp +to employ the auditing interface, the environment variable +.br ld_audit +must be defined to contain a colon-separated list of shared libraries, +each of which can implement (parts of) the auditing api. +when an auditable event occurs, +the corresponding function is invoked in each library, +in the order that the libraries are listed. +.ss la_version() +\& +.nf +.bi "unsigned int la_version(unsigned int " version ); +.fi +.pp +this is the only function that +.i must +be defined by an auditing library: +it performs the initial handshake between the dynamic linker and +the auditing library. +when invoking this function, the dynamic linker passes, in +.ir version , +the highest version of the auditing interface that the linker supports. +.pp +a typical implementation of this function simply returns the constant +.br lav_current , +which indicates the version of +.i +that was used to build the audit module. +if the dynamic linker does +not support this version of the audit interface, it will refuse to +activate this audit module. +if the function returns zero, the dynamic +linker also does not activate this audit module. +.pp +in order to enable backwards compatibility with older dynamic linkers, +an audit module can examine the +.i version +argument and return an earlier version than +.br lav_current , +assuming the module can adjust its implementation to match the +requirements of the previous version of the audit interface. +the +.b la_version +function should not return the value of +.i version +without further checks because it could correspond to an interface +that does not match the +.i +definitions used to build the audit module. +.ss la_objsearch() +\& +.nf +.bi "char *la_objsearch(const char *" name ", uintptr_t *" cookie , +.bi " unsigned int " flag ); +.fi +.pp +the dynamic linker invokes this function to inform the auditing library +that it is about to search for a shared object. +the +.i name +argument is the filename or pathname that is to be searched for. +.i cookie +identifies the shared object that initiated the search. +.i flag +is set to one of the following values: +.tp 17 +.b la_ser_orig +this is the original name that is being searched for. +typically, this name comes from an elf +.b dt_needed +entry, or is the +.i filename +argument given to +.br dlopen (3). +.tp +.b la_ser_libpath +.i name +was created using a directory specified in +.br ld_library_path . +.tp +.b la_ser_runpath +.i name +was created using a directory specified in an elf +.b dt_rpath +or +.b dt_runpath +list. +.tp +.b la_ser_config +.i name +was found via the +.br ldconfig (8) +cache +.ri ( /etc/ld.so.cache ). +.tp +.b la_ser_default +.i name +was found via a search of one of the default directories. +.tp +.b la_ser_secure +.i name +is specific to a secure object (unused on linux). +.pp +as its function result, +.br la_objsearch () +returns the pathname that the dynamic linker should use +for further processing. +if null is returned, then this pathname is ignored for further processing. +if this audit library simply intends to monitor search paths, then +.i name +should be returned. +.ss la_activity() +\& +.nf +.bi "void la_activity( uintptr_t *" cookie ", unsigned int "flag ); +.fi +.pp +the dynamic linker calls this function to inform the auditing library +that link-map activity is occurring. +.i cookie +identifies the object at the head of the link map. +when the dynamic linker invokes this function, +.i flag +is set to one of the following values: +.tp 19 +.b la_act_add +new objects are being added to the link map. +.tp +.b la_act_delete +objects are being removed from the link map. +.tp +.b la_act_consistent +link-map activity has been completed: the map is once again consistent. +.ss la_objopen() +\& +.nf +.bi "unsigned int la_objopen(struct link_map *" map ", lmid_t " lmid , +.bi " uintptr_t *" cookie ); +.fi +.pp +the dynamic linker calls this function when a new shared object is loaded. +the +.i map +argument is a pointer to a link-map structure that describes the object. +the +.i lmid +field has one of the following values +.tp 17 +.b lm_id_base +link map is part of the initial namespace. +.tp +.b lm_id_newlm +link map is part of a new namespace requested via +.br dlmopen (3). +.pp +.i cookie +is a pointer to an identifier for this object. +the identifier is provided to later calls to functions +in the auditing library in order to identify this object. +this identifier is initialized to point to object's link map, +but the audit library can change the identifier to some other value +that it may prefer to use to identify the object. +.pp +as its return value, +.br la_objopen () +returns a bit mask created by oring zero or more of the +following constants, +which allow the auditing library to select the objects to be monitored by +.br la_symbind* (): +.tp 17 +.b la_flg_bindto +audit symbol bindings to this object. +.tp +.b la_flg_bindfrom +audit symbol bindings from this object. +.pp +a return value of 0 from +.br la_objopen () +indicates that no symbol bindings should be audited for this object. +.ss la_objclose() +\& +.nf +.bi "unsigned int la_objclose(uintptr_t *" cookie ); +.fi +.pp +the dynamic linker invokes this function after any finalization +code for the object has been executed, +before the object is unloaded. +the +.i cookie +argument is the identifier obtained from a previous invocation of +.br la_objopen (). +.pp +in the current implementation, the value returned by +.br la_objclose () +is ignored. +.ss la_preinit() +\& +.nf +.bi "void la_preinit(uintptr_t *" cookie ); +.fi +.pp +the dynamic linker invokes this function after all shared objects +have been loaded, before control is passed to the application +(i.e., before calling +.ir main ()). +note that +.ir main () +may still later dynamically load objects using +.br dlopen (3). +.ss la_symbind*() +\& +.nf +.bi "uintptr_t la_symbind32(elf32_sym *" sym ", unsigned int " ndx , +.bi " uintptr_t *" refcook ", uintptr_t *" defcook , +.bi " unsigned int *" flags ", const char *" symname ); +.bi "uintptr_t la_symbind64(elf64_sym *" sym ", unsigned int " ndx , +.bi " uintptr_t *" refcook ", uintptr_t *" defcook , +.bi " unsigned int *" flags ", const char *" symname ); +.fi +.pp +the dynamic linker invokes one of these functions +when a symbol binding occurs between two shared objects +that have been marked for auditing notification by +.br la_objopen (). +the +.br la_symbind32 () +function is employed on 32-bit platforms; +the +.br la_symbind64 () +function is employed on 64-bit platforms. +.pp +the +.i sym +argument is a pointer to a structure +that provides information about the symbol being bound. +the structure definition is shown in +.ir . +among the fields of this structure, +.i st_value +indicates the address to which the symbol is bound. +.pp +the +.i ndx +argument gives the index of the symbol in the symbol table +of the bound shared object. +.pp +the +.i refcook +argument identifies the shared object that is making the symbol reference; +this is the same identifier that is provided to the +.br la_objopen () +function that returned +.br la_flg_bindfrom . +the +.i defcook +argument identifies the shared object that defines the referenced symbol; +this is the same identifier that is provided to the +.br la_objopen () +function that returned +.br la_flg_bindto . +.pp +the +.i symname +argument points a string containing the name of the symbol. +.pp +the +.i flags +argument is a bit mask that both provides information about the symbol +and can be used to modify further auditing of this +plt (procedure linkage table) entry. +the dynamic linker may supply the following bit values in this argument: +.\" la_symb_structcall appears to be unused +.tp 22 +.b la_symb_dlsym +the binding resulted from a call to +.br dlsym (3). +.tp +.b la_symb_altvalue +a previous +.br la_symbind* () +call returned an alternate value for this symbol. +.pp +by default, if the auditing library implements +.br la_pltenter () +and +.br la_pltexit () +functions (see below), then these functions are invoked, after +.br la_symbind (), +for plt entries, each time the symbol is referenced. +.\" pltenter/pltexit are called for non-dynamically loaded libraries, +.\" but don't seem to be called for dynamically loaded libs? +.\" is this the same on solaris? +the following flags can be ored into +.ir *flags +to change this default behavior: +.tp 22 +.b la_symb_nopltenter +don't call +.br la_pltenter () +for this symbol. +.tp 22 +.b la_symb_nopltexit +don't call +.br la_pltexit () +for this symbol. +.pp +the return value of +.br la_symbind32 () +and +.br la_symbind64 () +is the address to which control should be passed after the function returns. +if the auditing library is simply monitoring symbol bindings, +then it should return +.ir sym\->st_value . +a different value may be returned if the library wishes to direct control +to an alternate location. +.ss la_pltenter() +the precise name and argument types for this function +depend on the hardware platform. +(the appropriate definition is supplied by +.ir .) +here is the definition for x86-32: +.pp +.nf +.bi "elf32_addr la_i86_gnu_pltenter(elf32_sym *" sym ", unsigned int " ndx , +.bi " uintptr_t *" refcook ", uintptr_t *" defcook , +.bi " la_i86_regs *" regs ", unsigned int *" flags , +.bi " const char *" symname ", long *" framesizep ); +.fi +.pp +this function is invoked just before a plt entry is called, +between two shared objects that have been marked for binding notification. +.pp +the +.ir sym , +.ir ndx , +.ir refcook , +.ir defcook , +and +.ir symname +are as for +.br la_symbind* (). +.pp +the +.i regs +argument points to a structure (defined in +.ir ) +containing the values of registers to be used for +the call to this plt entry. +.pp +the +.i flags +argument points to a bit mask that conveys information about, +and can be used to modify subsequent auditing of, this plt entry, as for +.br la_symbind* (). +.pp +.\" fixme . is the following correct? +the +.ir framesizep +argument points to a +.ir "long\ int" +buffer that can be used to explicitly set the frame size +used for the call to this plt entry. +if different +.br la_pltenter () +invocations for this symbol return different values, +then the maximum returned value is used. +the +.br la_pltexit () +function is called only if this buffer is +explicitly set to a suitable value. +.pp +the return value of +.br la_pltenter () +is as for +.br la_symbind* (). +.ss la_pltexit() +the precise name and argument types for this function +depend on the hardware platform. +(the appropriate definition is supplied by +.ir .) +here is the definition for x86-32: +.pp +.nf +.bi "unsigned int la_i86_gnu_pltexit(elf32_sym *" sym ", unsigned int " ndx , +.bi " uintptr_t *" refcook ", uintptr_t *" defcook , +.bi " const la_i86_regs *" inregs ", la_i86_retval *" outregs , +.bi " const char *" symname ); +.fi +.pp +this function is called when a plt entry, +made between two shared objects that have been marked +for binding notification, returns. +the function is called just before control returns to the caller +of the plt entry. +.pp +the +.ir sym , +.ir ndx , +.ir refcook , +.ir defcook , +and +.ir symname +are as for +.br la_symbind* (). +.pp +the +.i inregs +argument points to a structure (defined in +.ir ) +containing the values of registers used for the call to this plt entry. +the +.i outregs +argument points to a structure (defined in +.ir ) +containing return values for the call to this plt entry. +these values can be modified by the caller, +and the changes will be visible to the caller of the plt entry. +.pp +in the current gnu implementation, the return value of +.br la_pltexit () +is ignored. +.\" this differs from solaris, where an audit library that monitors +.\" symbol binding should return the value of the 'retval' argument +.\" (not provided by gnu, but equivalent to returning outregs->lrv_eax +.\" on (say) x86-32). +.sh conforming to +this api is nonstandard, but very similar to the solaris api, +described in the solaris +.ir "linker and libraries guide" , +in the chapter +.ir "runtime linker auditing interface" . +.sh notes +note the following differences from the solaris dynamic linker +auditing api: +.ip * 3 +the solaris +.br la_objfilter () +interface is not supported by the gnu implementation. +.ip * +the solaris +.br la_symbind32 () +and +.br la_pltexit () +functions do not provide a +.i symname +argument. +.ip * +the solaris +.br la_pltexit () +function does not provide +.i inregs +and +.i outregs +arguments (but does provide a +.ir retval +argument with the function return value). +.sh bugs +in glibc versions up to and include 2.9, +specifying more than one audit library in +.b ld_audit +results in a run-time crash. +this is reportedly fixed in glibc 2.10. +.\" fixme . specifying multiple audit libraries doesn't work on gnu. +.\" my simple tests on solaris work okay, but not on linux -- mtk, jan 2009 +.\" glibc bug filed: http://sourceware.org/bugzilla/show_bug.cgi?id=9733 +.\" reportedly, this is fixed on 16 mar 2009 (i.e., for glibc 2.10) +.sh examples +.ex +#include +#include + +unsigned int +la_version(unsigned int version) +{ + printf("la_version(): version = %u; lav_current = %u\en", + version, lav_current); + + return lav_current; +} + +char * +la_objsearch(const char *name, uintptr_t *cookie, unsigned int flag) +{ + printf("la_objsearch(): name = %s; cookie = %p", name, cookie); + printf("; flag = %s\en", + (flag == la_ser_orig) ? "la_ser_orig" : + (flag == la_ser_libpath) ? "la_ser_libpath" : + (flag == la_ser_runpath) ? "la_ser_runpath" : + (flag == la_ser_default) ? "la_ser_default" : + (flag == la_ser_config) ? "la_ser_config" : + (flag == la_ser_secure) ? "la_ser_secure" : + "???"); + + return name; +} + +void +la_activity (uintptr_t *cookie, unsigned int flag) +{ + printf("la_activity(): cookie = %p; flag = %s\en", cookie, + (flag == la_act_consistent) ? "la_act_consistent" : + (flag == la_act_add) ? "la_act_add" : + (flag == la_act_delete) ? "la_act_delete" : + "???"); +} + +unsigned int +la_objopen(struct link_map *map, lmid_t lmid, uintptr_t *cookie) +{ + printf("la_objopen(): loading \e"%s\e"; lmid = %s; cookie=%p\en", + map\->l_name, + (lmid == lm_id_base) ? "lm_id_base" : + (lmid == lm_id_newlm) ? "lm_id_newlm" : + "???", + cookie); + + return la_flg_bindto | la_flg_bindfrom; +} + +unsigned int +la_objclose (uintptr_t *cookie) +{ + printf("la_objclose(): %p\en", cookie); + + return 0; +} + +void +la_preinit(uintptr_t *cookie) +{ + printf("la_preinit(): %p\en", cookie); +} + +uintptr_t +la_symbind32(elf32_sym *sym, unsigned int ndx, uintptr_t *refcook, + uintptr_t *defcook, unsigned int *flags, const char *symname) +{ + printf("la_symbind32(): symname = %s; sym\->st_value = %p\en", + symname, sym\->st_value); + printf(" ndx = %u; flags = %#x", ndx, *flags); + printf("; refcook = %p; defcook = %p\en", refcook, defcook); + + return sym\->st_value; +} + +uintptr_t +la_symbind64(elf64_sym *sym, unsigned int ndx, uintptr_t *refcook, + uintptr_t *defcook, unsigned int *flags, const char *symname) +{ + printf("la_symbind64(): symname = %s; sym\->st_value = %p\en", + symname, sym\->st_value); + printf(" ndx = %u; flags = %#x", ndx, *flags); + printf("; refcook = %p; defcook = %p\en", refcook, defcook); + + return sym\->st_value; +} + +elf32_addr +la_i86_gnu_pltenter(elf32_sym *sym, unsigned int ndx, + uintptr_t *refcook, uintptr_t *defcook, la_i86_regs *regs, + unsigned int *flags, const char *symname, long *framesizep) +{ + printf("la_i86_gnu_pltenter(): %s (%p)\en", symname, sym\->st_value); + + return sym\->st_value; +} +.ee +.sh see also +.br ldd (1), +.br dlopen (3), +.br ld.so (8), +.br ldconfig (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1995 peter tobias +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" this file may be distributed under the gnu general public license. +.\" %%%license_end +.th hosts.equiv 5 2020-06-09 "linux" "linux programmer's manual" +.sh name +hosts.equiv \- list of hosts and users that are granted "trusted" +.b r +command access to your system +.sh description +the file +.i /etc/hosts.equiv +allows or denies hosts and users to use +the \fbr\fp-commands (e.g., +.br rlogin , +.br rsh , +or +.br rcp ) +without +supplying a password. +.pp +the file uses the following format: +.tp +\fi+|[\-]hostname|+@netgroup|\-@netgroup\fp \fi[+|[\-]username|+@netgroup|\-@netgroup]\fp +.pp +the +.i hostname +is the name of a host which is logically equivalent +to the local host. +users logged into that host are allowed to access +like-named user accounts on the local host without supplying a password. +the +.i hostname +may be (optionally) preceded by a plus (+) sign. +if the plus sign is used alone, it allows any host to access your system. +you can explicitly deny access to a host by preceding the +.i hostname +by a minus (\-) sign. +users from that host must always supply additional credentials, +including possibly a password. +for security reasons you should always +use the fqdn of the hostname and not the short hostname. +.pp +the +.i username +entry grants a specific user access to all user +accounts (except root) without supplying a password. +that means the +user is not restricted to like-named accounts. +the +.i username +may +be (optionally) preceded by a plus (+) sign. +you can also explicitly +deny access to a specific user by preceding the +.i username +with +a minus (\-) sign. +this says that the user is not trusted no matter +what other entries for that host exist. +.pp +netgroups can be specified by preceding the netgroup by an @ sign. +.pp +be extremely careful when using the plus (+) sign. +a simple typographical +error could result in a standalone plus sign. +a standalone plus sign is +a wildcard character that means "any host"! +.sh files +.i /etc/hosts.equiv +.sh notes +some systems will honor the contents of this file only when it has owner +root and no write permission for anybody else. +some exceptionally +paranoid systems even require that there be no other hard links to the file. +.pp +modern systems use the pluggable authentication modules library (pam). +with pam a standalone plus sign is considered a wildcard +character which means "any host" only when the word +.i promiscuous +is added to the auth component line in your pam file for +the particular service +.rb "(e.g., " rlogin ). +.sh examples +below are some example +.i /etc/host.equiv +or +.i \(ti/.rhosts +files. +.pp +allow any user to log in from any host: +.pp + + +.pp +allow any user from +.i host +with a matching local account to log in: +.pp + host +.pp +note: the use of +.i +host +is never a valid syntax, +including attempting to specify that any user from the host is allowed. +.pp +allow any user from +.i host +to log in: +.pp + host + +.pp +note: this is distinct from the previous example +since it does not require a matching local account. +.pp +allow +.i user +from +.i host +to log in as any non-root user: +.pp + host user +.pp +allow all users with matching local accounts from +.i host +to log in except for +.ir baduser : +.pp + host \-baduser + host +.pp +deny all users from +.ir host : +.pp + \-host +.pp +note: the use of +.i "\-host\ \-user" +is never a valid syntax, +including attempting to specify that a particular user from the host +is not trusted. +.pp +allow all users with matching local accounts on all hosts in a +.ir netgroup : +.pp + +@netgroup +.pp +disallow all users on all hosts in a +.ir netgroup : +.pp + \-@netgroup +.pp +allow all users in a +.i netgroup +to log in from +.i host +as any non-root user: +.pp + host +@netgroup +.pp +allow all users with matching local accounts on all hosts in a +.i netgroup +except +.ir baduser : +.pp + +@netgroup \-baduser + +@netgroup +.pp +note: the deny statements must always precede the allow statements because +the file is processed sequentially until the first matching rule is found. +.sh see also +.br rhosts (5), +.br rlogind (8), +.br rshd (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/sched_get_priority_max.2 + +.so man3/endian.3 + +.\" this manpage is copyright (c) 1992 drew eckhardt; +.\" and copyright (c) 1993 michael haardt, ian jackson; +.\" and copyright (c) 1998 jamie lokier; +.\" and copyright (c) 2002-2010, 2014 michael kerrisk; +.\" and copyright (c) 2014 jeff layton +.\" and copyright (c) 2014 david herrmann +.\" and copyright (c) 2017 jens axboe +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified 1993-07-24 by rik faith +.\" modified 1995-09-26 by andries brouwer +.\" and again on 960413 and 980804 and 981223. +.\" modified 1998-12-11 by jamie lokier +.\" applied correction by christian ehrhardt - aeb, 990712 +.\" modified 2002-04-23 by michael kerrisk +.\" added note on f_setfl and o_direct +.\" complete rewrite + expansion of material on file locking +.\" incorporated description of f_notify, drawing on +.\" stephen rothwell's notes in documentation/dnotify.txt. +.\" added description of f_setlease and f_getlease +.\" corrected and polished, aeb, 020527. +.\" modified 2004-03-03 by michael kerrisk +.\" modified description of file leases: fixed some errors of detail +.\" replaced the term "lease contestant" by "lease breaker" +.\" modified, 27 may 2004, michael kerrisk +.\" added notes on capability requirements +.\" modified 2004-12-08, added o_noatime after note from martin pool +.\" 2004-12-10, mtk, noted f_getown bug after suggestion from aeb. +.\" 2005-04-08 jamie lokier , mtk +.\" described behavior of f_setown/f_setsig in +.\" multithreaded processes, and generally cleaned +.\" up the discussion of f_setown. +.\" 2005-05-20, johannes nicolai , +.\" mtk: noted f_setown bug for socket file descriptor in linux 2.4 +.\" and earlier. added text on permissions required to send signal. +.\" 2009-09-30, michael kerrisk +.\" note obsolete f_setown behavior with threads. +.\" document f_setown_ex and f_getown_ex +.\" 2010-06-17, michael kerrisk +.\" document f_setpipe_sz and f_getpipe_sz. +.\" 2014-07-08, david herrmann +.\" document f_add_seals and f_get_seals +.\" 2017-06-26, jens axboe +.\" document f_{get,set}_rw_hint and f_{get,set}_file_rw_hint +.\" +.th fcntl 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +fcntl \- manipulate file descriptor +.sh synopsis +.nf +.b #include +.pp +.bi "int fcntl(int " fd ", int " cmd ", ... /* " arg " */ );" +.fi +.sh description +.br fcntl () +performs one of the operations described below on the open file descriptor +.ir fd . +the operation is determined by +.ir cmd . +.pp +.br fcntl () +can take an optional third argument. +whether or not this argument is required is determined by +.ir cmd . +the required argument type is indicated in parentheses after each +.i cmd +name (in most cases, the required type is +.ir int , +and we identify the argument using the name +.ir arg ), +or +.i void +is specified if the argument is not required. +.pp +certain of the operations below are supported only since a particular +linux kernel version. +the preferred method of checking whether the host kernel supports +a particular operation is to invoke +.br fcntl () +with the desired +.ir cmd +value and then test whether the call failed with +.br einval , +indicating that the kernel does not recognize this value. +.ss duplicating a file descriptor +.tp +.br f_dupfd " (\fiint\fp)" +duplicate the file descriptor +.ir fd +using the lowest-numbered available file descriptor greater than or equal to +.ir arg . +this is different from +.br dup2 (2), +which uses exactly the file descriptor specified. +.ip +on success, the new file descriptor is returned. +.ip +see +.br dup (2) +for further details. +.tp +.br f_dupfd_cloexec " (\fiint\fp; since linux 2.6.24)" +as for +.br f_dupfd , +but additionally set the +close-on-exec flag for the duplicate file descriptor. +specifying this flag permits a program to avoid an additional +.br fcntl () +.b f_setfd +operation to set the +.b fd_cloexec +flag. +for an explanation of why this flag is useful, +see the description of +.b o_cloexec +in +.br open (2). +.ss file descriptor flags +the following commands manipulate the flags associated with +a file descriptor. +currently, only one such flag is defined: +.br fd_cloexec , +the close-on-exec flag. +if the +.b fd_cloexec +bit is set, +the file descriptor will automatically be closed during a successful +.br execve (2). +(if the +.br execve (2) +fails, the file descriptor is left open.) +if the +.b fd_cloexec +bit is not set, the file descriptor will remain open across an +.br execve (2). +.tp +.br f_getfd " (\fivoid\fp)" +return (as the function result) the file descriptor flags; +.i arg +is ignored. +.tp +.br f_setfd " (\fiint\fp)" +set the file descriptor flags to the value specified by +.ir arg . +.pp +in multithreaded programs, using +.br fcntl () +.b f_setfd +to set the close-on-exec flag at the same time as another thread performs a +.br fork (2) +plus +.br execve (2) +is vulnerable to a race condition that may unintentionally leak +the file descriptor to the program executed in the child process. +see the discussion of the +.br o_cloexec +flag in +.br open (2) +for details and a remedy to the problem. +.ss file status flags +each open file description has certain associated status flags, +initialized by +.br open (2) +.\" or +.\" .br creat (2), +and possibly modified by +.br fcntl (). +duplicated file descriptors +(made with +.br dup (2), +.br fcntl (f_dupfd), +.br fork (2), +etc.) refer to the same open file description, and thus +share the same file status flags. +.pp +the file status flags and their semantics are described in +.br open (2). +.tp +.br f_getfl " (\fivoid\fp)" +return (as the function result) +the file access mode and the file status flags; +.i arg +is ignored. +.tp +.br f_setfl " (\fiint\fp)" +set the file status flags to the value specified by +.ir arg . +file access mode +.rb ( o_rdonly ", " o_wronly ", " o_rdwr ) +and file creation flags +(i.e., +.br o_creat ", " o_excl ", " o_noctty ", " o_trunc ) +in +.i arg +are ignored. +on linux, this command can change only the +.br o_append , +.br o_async , +.br o_direct , +.br o_noatime , +and +.b o_nonblock +flags. +it is not possible to change the +.br o_dsync +and +.br o_sync +flags; see bugs, below. +.ss advisory record locking +linux implements traditional ("process-associated") unix record locks, +as standardized by posix. +for a linux-specific alternative with better semantics, +see the discussion of open file description locks below. +.pp +.br f_setlk , +.br f_setlkw , +and +.br f_getlk +are used to acquire, release, and test for the existence of record +locks (also known as byte-range, file-segment, or file-region locks). +the third argument, +.ir lock , +is a pointer to a structure that has at least the following fields +(in unspecified order). +.pp +.in +4n +.ex +struct flock { + ... + short l_type; /* type of lock: f_rdlck, + f_wrlck, f_unlck */ + short l_whence; /* how to interpret l_start: + seek_set, seek_cur, seek_end */ + off_t l_start; /* starting offset for lock */ + off_t l_len; /* number of bytes to lock */ + pid_t l_pid; /* pid of process blocking our lock + (set by f_getlk and f_ofd_getlk) */ + ... +}; +.ee +.in +.pp +the +.ir l_whence ", " l_start ", and " l_len +fields of this structure specify the range of bytes we wish to lock. +bytes past the end of the file may be locked, +but not bytes before the start of the file. +.pp +.i l_start +is the starting offset for the lock, and is interpreted +relative to either: +the start of the file (if +.i l_whence +is +.br seek_set ); +the current file offset (if +.i l_whence +is +.br seek_cur ); +or the end of the file (if +.i l_whence +is +.br seek_end ). +in the final two cases, +.i l_start +can be a negative number provided the +offset does not lie before the start of the file. +.pp +.i l_len +specifies the number of bytes to be locked. +if +.i l_len +is positive, then the range to be locked covers bytes +.i l_start +up to and including +.ir l_start + l_len \-1. +specifying 0 for +.i l_len +has the special meaning: lock all bytes starting at the +location specified by +.ir l_whence " and " l_start +through to the end of file, no matter how large the file grows. +.pp +posix.1-2001 allows (but does not require) +an implementation to support a negative +.i l_len +value; if +.i l_len +is negative, the interval described by +.i lock +covers bytes +.ir l_start + l_len +up to and including +.ir l_start \-1. +this is supported by linux since kernel versions 2.4.21 and 2.5.49. +.pp +the +.i l_type +field can be used to place a read +.rb ( f_rdlck ) +or a write +.rb ( f_wrlck ) +lock on a file. +any number of processes may hold a read lock (shared lock) +on a file region, but only one process may hold a write lock +(exclusive lock). +an exclusive lock excludes all other locks, +both shared and exclusive. +a single process can hold only one type of lock on a file region; +if a new lock is applied to an already-locked region, +then the existing lock is converted to the new lock type. +(such conversions may involve splitting, shrinking, or coalescing with +an existing lock if the byte range specified by the new lock does not +precisely coincide with the range of the existing lock.) +.tp +.br f_setlk " (\fistruct flock *\fp)" +acquire a lock (when +.i l_type +is +.b f_rdlck +or +.br f_wrlck ) +or release a lock (when +.i l_type +is +.br f_unlck ) +on the bytes specified by the +.ir l_whence ", " l_start ", and " l_len +fields of +.ir lock . +if a conflicting lock is held by another process, +this call returns \-1 and sets +.i errno +to +.b eacces +or +.br eagain . +(the error returned in this case differs across implementations, +so posix requires a portable application to check for both errors.) +.tp +.br f_setlkw " (\fistruct flock *\fp)" +as for +.br f_setlk , +but if a conflicting lock is held on the file, then wait for that +lock to be released. +if a signal is caught while waiting, then the call is interrupted +and (after the signal handler has returned) +returns immediately (with return value \-1 and +.i errno +set to +.br eintr ; +see +.br signal (7)). +.tp +.br f_getlk " (\fistruct flock *\fp)" +on input to this call, +.i lock +describes a lock we would like to place on the file. +if the lock could be placed, +.br fcntl () +does not actually place it, but returns +.b f_unlck +in the +.i l_type +field of +.i lock +and leaves the other fields of the structure unchanged. +.ip +if one or more incompatible locks would prevent +this lock being placed, then +.br fcntl () +returns details about one of those locks in the +.ir l_type ", " l_whence ", " l_start ", and " l_len +fields of +.ir lock . +if the conflicting lock is a traditional (process-associated) record lock, +then the +.i l_pid +field is set to the pid of the process holding that lock. +if the conflicting lock is an open file description lock, then +.i l_pid +is set to \-1. +note that the returned information +may already be out of date by the time the caller inspects it. +.pp +in order to place a read lock, +.i fd +must be open for reading. +in order to place a write lock, +.i fd +must be open for writing. +to place both types of lock, open a file read-write. +.pp +when placing locks with +.br f_setlkw , +the kernel detects +.ir deadlocks , +whereby two or more processes have their +lock requests mutually blocked by locks held by the other processes. +for example, suppose process a holds a write lock on byte 100 of a file, +and process b holds a write lock on byte 200. +if each process then attempts to lock the byte already +locked by the other process using +.br f_setlkw , +then, without deadlock detection, +both processes would remain blocked indefinitely. +when the kernel detects such deadlocks, +it causes one of the blocking lock requests to immediately fail with the error +.br edeadlk ; +an application that encounters such an error should release +some of its locks to allow other applications to proceed before +attempting regain the locks that it requires. +circular deadlocks involving more than two processes are also detected. +note, however, that there are limitations to the kernel's +deadlock-detection algorithm; see bugs. +.pp +as well as being removed by an explicit +.br f_unlck , +record locks are automatically released when the process terminates. +.pp +record locks are not inherited by a child created via +.br fork (2), +but are preserved across an +.br execve (2). +.pp +because of the buffering performed by the +.br stdio (3) +library, the use of record locking with routines in that package +should be avoided; use +.br read (2) +and +.br write (2) +instead. +.pp +the record locks described above are associated with the process +(unlike the open file description locks described below). +this has some unfortunate consequences: +.ip * 3 +if a process closes +.i any +file descriptor referring to a file, +then all of the process's locks on that file are released, +regardless of the file descriptor(s) on which the locks were obtained. +.\" (additional file descriptors referring to the same file +.\" may have been obtained by calls to +.\" .br open "(2), " dup "(2), " dup2 "(2), or " fcntl ().) +this is bad: it means that a process can lose its locks on +a file such as +.i /etc/passwd +or +.i /etc/mtab +when for some reason a library function decides to open, read, +and close the same file. +.ip * +the threads in a process share locks. +in other words, +a multithreaded program can't use record locking to ensure +that threads don't simultaneously access the same region of a file. +.pp +open file description locks solve both of these problems. +.ss open file description locks (non-posix) +open file description locks are advisory byte-range locks whose operation is +in most respects identical to the traditional record locks described above. +this lock type is linux-specific, +and available since linux 3.15. +(there is a proposal with the austin group +.\" fixme . review progress into posix +.\" http://austingroupbugs.net/view.php?id=768 +to include this lock type in the next revision of posix.1.) +for an explanation of open file descriptions, see +.br open (2). +.pp +the principal difference between the two lock types +is that whereas traditional record locks +are associated with a process, +open file description locks are associated with the +open file description on which they are acquired, +much like locks acquired with +.br flock (2). +consequently (and unlike traditional advisory record locks), +open file description locks are inherited across +.br fork (2) +(and +.br clone (2) +with +.br clone_files ), +and are only automatically released on the last close +of the open file description, +instead of being released on any close of the file. +.pp +conflicting lock combinations +(i.e., a read lock and a write lock or two write locks) +where one lock is an open file description lock and the other +is a traditional record lock conflict +even when they are acquired by the same process on the same file descriptor. +.pp +open file description locks placed via the same open file description +(i.e., via the same file descriptor, +or via a duplicate of the file descriptor created by +.br fork (2), +.br dup (2), +.br fcntl () +.br f_dupfd , +and so on) are always compatible: +if a new lock is placed on an already locked region, +then the existing lock is converted to the new lock type. +(such conversions may result in splitting, shrinking, or coalescing with +an existing lock as discussed above.) +.pp +on the other hand, open file description locks may conflict with +each other when they are acquired via different open file descriptions. +thus, the threads in a multithreaded program can use +open file description locks to synchronize access to a file region +by having each thread perform its own +.br open (2) +on the file and applying locks via the resulting file descriptor. +.pp +as with traditional advisory locks, the third argument to +.br fcntl (), +.ir lock , +is a pointer to an +.ir flock +structure. +by contrast with traditional record locks, the +.i l_pid +field of that structure must be set to zero +when using the commands described below. +.pp +the commands for working with open file description locks are analogous +to those used with traditional locks: +.tp +.br f_ofd_setlk " (\fistruct flock *\fp)" +acquire an open file description lock (when +.i l_type +is +.b f_rdlck +or +.br f_wrlck ) +or release an open file description lock (when +.i l_type +is +.br f_unlck ) +on the bytes specified by the +.ir l_whence ", " l_start ", and " l_len +fields of +.ir lock . +if a conflicting lock is held by another process, +this call returns \-1 and sets +.i errno +to +.br eagain . +.tp +.br f_ofd_setlkw " (\fistruct flock *\fp)" +as for +.br f_ofd_setlk , +but if a conflicting lock is held on the file, then wait for that lock to be +released. +if a signal is caught while waiting, then the call is interrupted +and (after the signal handler has returned) returns immediately +(with return value \-1 and +.i errno +set to +.br eintr ; +see +.br signal (7)). +.tp +.br f_ofd_getlk " (\fistruct flock *\fp)" +on input to this call, +.i lock +describes an open file description lock we would like to place on the file. +if the lock could be placed, +.br fcntl () +does not actually place it, but returns +.b f_unlck +in the +.i l_type +field of +.i lock +and leaves the other fields of the structure unchanged. +if one or more incompatible locks would prevent this lock being placed, +then details about one of these locks are returned via +.ir lock , +as described above for +.br f_getlk . +.pp +in the current implementation, +.\" commit 57b65325fe34ec4c917bc4e555144b4a94d9e1f7 +no deadlock detection is performed for open file description locks. +(this contrasts with process-associated record locks, +for which the kernel does perform deadlock detection.) +.\" +.ss mandatory locking +.ir warning : +the linux implementation of mandatory locking is unreliable. +see bugs below. +because of these bugs, +and the fact that the feature is believed to be little used, +since linux 4.5, mandatory locking has been made an optional feature, +governed by a configuration option +.rb ( config_mandatory_file_locking ). +this is an initial step toward removing this feature completely. +.pp +by default, both traditional (process-associated) and open file description +record locks are advisory. +advisory locks are not enforced and are useful only between +cooperating processes. +.pp +both lock types can also be mandatory. +mandatory locks are enforced for all processes. +if a process tries to perform an incompatible access (e.g., +.br read (2) +or +.br write (2)) +on a file region that has an incompatible mandatory lock, +then the result depends upon whether the +.b o_nonblock +flag is enabled for its open file description. +if the +.b o_nonblock +flag is not enabled, then +the system call is blocked until the lock is removed +or converted to a mode that is compatible with the access. +if the +.b o_nonblock +flag is enabled, then the system call fails with the error +.br eagain . +.pp +to make use of mandatory locks, mandatory locking must be enabled +both on the filesystem that contains the file to be locked, +and on the file itself. +mandatory locking is enabled on a filesystem +using the "\-o mand" option to +.br mount (8), +or the +.b ms_mandlock +flag for +.br mount (2). +mandatory locking is enabled on a file by disabling +group execute permission on the file and enabling the set-group-id +permission bit (see +.br chmod (1) +and +.br chmod (2)). +.pp +mandatory locking is not specified by posix. +some other systems also support mandatory locking, +although the details of how to enable it vary across systems. +.\" +.ss lost locks +when an advisory lock is obtained on a networked filesystem such as +nfs it is possible that the lock might get lost. +this may happen due to administrative action on the server, or due to a +network partition (i.e., loss of network connectivity with the server) +which lasts long enough for the server to assume +that the client is no longer functioning. +.pp +when the filesystem determines that a lock has been lost, future +.br read (2) +or +.br write (2) +requests may fail with the error +.br eio . +this error will persist until the lock is removed or the file +descriptor is closed. +since linux 3.12, +.\" commit ef1820f9be27b6ad158f433ab38002ab8131db4d +this happens at least for nfsv4 (including all minor versions). +.pp +some versions of unix send a signal +.rb ( siglost ) +in this circumstance. +linux does not define this signal, and does not provide any +asynchronous notification of lost locks. +.\" +.ss managing signals +.br f_getown , +.br f_setown , +.br f_getown_ex , +.br f_setown_ex , +.br f_getsig , +and +.b f_setsig +are used to manage i/o availability signals: +.tp +.br f_getown " (\fivoid\fp)" +return (as the function result) +the process id or process group id currently receiving +.b sigio +and +.b sigurg +signals for events on file descriptor +.ir fd . +process ids are returned as positive values; +process group ids are returned as negative values (but see bugs below). +.i arg +is ignored. +.tp +.br f_setown " (\fiint\fp)" +set the process id or process group id that will receive +.b sigio +and +.b sigurg +signals for events on the file descriptor +.ir fd . +the target process or process group id is specified in +.ir arg . +a process id is specified as a positive value; +a process group id is specified as a negative value. +most commonly, the calling process specifies itself as the owner +(that is, +.i arg +is specified as +.br getpid (2)). +.ip +as well as setting the file descriptor owner, +one must also enable generation of signals on the file descriptor. +this is done by using the +.br fcntl () +.b f_setfl +command to set the +.b o_async +file status flag on the file descriptor. +subsequently, a +.b sigio +signal is sent whenever input or output becomes possible +on the file descriptor. +the +.br fcntl () +.b f_setsig +command can be used to obtain delivery of a signal other than +.br sigio . +.ip +sending a signal to the owner process (group) specified by +.b f_setown +is subject to the same permissions checks as are described for +.br kill (2), +where the sending process is the one that employs +.b f_setown +(but see bugs below). +if this permission check fails, then the signal is +silently discarded. +.ir note : +the +.br f_setown +operation records the caller's credentials at the time of the +.br fcntl () +call, +and it is these saved credentials that are used for the permission checks. +.ip +if the file descriptor +.i fd +refers to a socket, +.b f_setown +also selects +the recipient of +.b sigurg +signals that are delivered when out-of-band +data arrives on that socket. +.rb ( sigurg +is sent in any situation where +.br select (2) +would report the socket as having an "exceptional condition".) +.\" the following appears to be rubbish. it doesn't seem to +.\" be true according to the kernel source, and i can write +.\" a program that gets a terminal-generated sigio even though +.\" it is not the foreground process group of the terminal. +.\" -- mtk, 8 apr 05 +.\" +.\" if the file descriptor +.\" .i fd +.\" refers to a terminal device, then sigio +.\" signals are sent to the foreground process group of the terminal. +.ip +the following was true in 2.6.x kernels up to and including +kernel 2.6.11: +.rs +.ip +if a nonzero value is given to +.b f_setsig +in a multithreaded process running with a threading library +that supports thread groups (e.g., nptl), +then a positive value given to +.b f_setown +has a different meaning: +.\" the relevant place in the (2.6) kernel source is the +.\" 'switch' in fs/fcntl.c::send_sigio_to_task() -- mtk, apr 2005 +instead of being a process id identifying a whole process, +it is a thread id identifying a specific thread within a process. +consequently, it may be necessary to pass +.b f_setown +the result of +.br gettid (2) +instead of +.br getpid (2) +to get sensible results when +.b f_setsig +is used. +(in current linux threading implementations, +a main thread's thread id is the same as its process id. +this means that a single-threaded program can equally use +.br gettid (2) +or +.br getpid (2) +in this scenario.) +note, however, that the statements in this paragraph do not apply +to the +.b sigurg +signal generated for out-of-band data on a socket: +this signal is always sent to either a process or a process group, +depending on the value given to +.br f_setown . +.\" send_sigurg()/send_sigurg_to_task() bypasses +.\" kill_fasync()/send_sigio()/send_sigio_to_task() +.\" to directly call send_group_sig_info() +.\" -- mtk, apr 2005 (kernel 2.6.11) +.re +.ip +the above behavior was accidentally dropped in linux 2.6.12, +and won't be restored. +from linux 2.6.32 onward, use +.br f_setown_ex +to target +.b sigio +and +.b sigurg +signals at a particular thread. +.tp +.br f_getown_ex " (\fistruct f_owner_ex *\fp) (since linux 2.6.32)" +return the current file descriptor owner settings +as defined by a previous +.br f_setown_ex +operation. +the information is returned in the structure pointed to by +.ir arg , +which has the following form: +.ip +.in +4n +.ex +struct f_owner_ex { + int type; + pid_t pid; +}; +.ee +.in +.ip +the +.i type +field will have one of the values +.br f_owner_tid , +.br f_owner_pid , +or +.br f_owner_pgrp . +the +.i pid +field is a positive integer representing a thread id, process id, +or process group id. +see +.b f_setown_ex +for more details. +.tp +.br f_setown_ex " (\fistruct f_owner_ex *\fp) (since linux 2.6.32)" +this operation performs a similar task to +.br f_setown . +it allows the caller to direct i/o availability signals +to a specific thread, process, or process group. +the caller specifies the target of signals via +.ir arg , +which is a pointer to a +.ir f_owner_ex +structure. +the +.i type +field has one of the following values, which define how +.i pid +is interpreted: +.rs +.tp +.br f_owner_tid +send the signal to the thread whose thread id +(the value returned by a call to +.br clone (2) +or +.br gettid (2)) +is specified in +.ir pid . +.tp +.br f_owner_pid +send the signal to the process whose id +is specified in +.ir pid . +.tp +.br f_owner_pgrp +send the signal to the process group whose id +is specified in +.ir pid . +(note that, unlike with +.br f_setown , +a process group id is specified as a positive value here.) +.re +.tp +.br f_getsig " (\fivoid\fp)" +return (as the function result) +the signal sent when input or output becomes possible. +a value of zero means +.b sigio +is sent. +any other value (including +.br sigio ) +is the +signal sent instead, and in this case additional info is available to +the signal handler if installed with +.br sa_siginfo . +.i arg +is ignored. +.tp +.br f_setsig " (\fiint\fp)" +set the signal sent when input or output becomes possible +to the value given in +.ir arg . +a value of zero means to send the default +.b sigio +signal. +any other value (including +.br sigio ) +is the signal to send instead, and in this case additional info +is available to the signal handler if installed with +.br sa_siginfo . +.\" +.\" the following was true only up until 2.6.11: +.\" +.\" additionally, passing a nonzero value to +.\" .b f_setsig +.\" changes the signal recipient from a whole process to a specific thread +.\" within a process. +.\" see the description of +.\" .b f_setown +.\" for more details. +.ip +by using +.b f_setsig +with a nonzero value, and setting +.b sa_siginfo +for the +signal handler (see +.br sigaction (2)), +extra information about i/o events is passed to +the handler in a +.i siginfo_t +structure. +if the +.i si_code +field indicates the source is +.br si_sigio , +the +.i si_fd +field gives the file descriptor associated with the event. +otherwise, +there is no indication which file descriptors are pending, and you +should use the usual mechanisms +.rb ( select (2), +.br poll (2), +.br read (2) +with +.b o_nonblock +set etc.) to determine which file descriptors are available for i/o. +.ip +note that the file descriptor provided in +.i si_fd +is the one that was specified during the +.br f_setsig +operation. +this can lead to an unusual corner case. +if the file descriptor is duplicated +.rb ( dup (2) +or similar), and the original file descriptor is closed, +then i/o events will continue to be generated, but the +.i si_fd +field will contain the number of the now closed file descriptor. +.ip +by selecting a real time signal (value >= +.br sigrtmin ), +multiple i/o events may be queued using the same signal numbers. +(queuing is dependent on available memory.) +extra information is available +if +.b sa_siginfo +is set for the signal handler, as above. +.ip +note that linux imposes a limit on the +number of real-time signals that may be queued to a +process (see +.br getrlimit (2) +and +.br signal (7)) +and if this limit is reached, then the kernel reverts to +delivering +.br sigio , +and this signal is delivered to the entire +process rather than to a specific thread. +.\" see fs/fcntl.c::send_sigio_to_task() (2.4/2.6) sources -- mtk, apr 05 +.pp +using these mechanisms, a program can implement fully asynchronous i/o +without using +.br select (2) +or +.br poll (2) +most of the time. +.pp +the use of +.br o_async +is specific to bsd and linux. +the only use of +.br f_getown +and +.b f_setown +specified in posix.1 is in conjunction with the use of the +.b sigurg +signal on sockets. +(posix does not specify the +.br sigio +signal.) +.br f_getown_ex , +.br f_setown_ex , +.br f_getsig , +and +.b f_setsig +are linux-specific. +posix has asynchronous i/o and the +.i aio_sigevent +structure to achieve similar things; these are also available +in linux as part of the gnu c library (glibc). +.ss leases +.b f_setlease +and +.b f_getlease +(linux 2.4 onward) are used to establish a new lease, +and retrieve the current lease, on the open file description +referred to by the file descriptor +.ir fd . +a file lease provides a mechanism whereby the process holding +the lease (the "lease holder") is notified (via delivery of a signal) +when a process (the "lease breaker") tries to +.br open (2) +or +.br truncate (2) +the file referred to by that file descriptor. +.tp +.br f_setlease " (\fiint\fp)" +set or remove a file lease according to which of the following +values is specified in the integer +.ir arg : +.rs +.tp +.b f_rdlck +take out a read lease. +this will cause the calling process to be notified when +the file is opened for writing or is truncated. +.\" the following became true in kernel 2.6.10: +.\" see the man-pages-2.09 changelog for further info. +a read lease can be placed only on a file descriptor that +is opened read-only. +.tp +.b f_wrlck +take out a write lease. +this will cause the caller to be notified when +the file is opened for reading or writing or is truncated. +a write lease may be placed on a file only if there are no +other open file descriptors for the file. +.tp +.b f_unlck +remove our lease from the file. +.re +.pp +leases are associated with an open file description (see +.br open (2)). +this means that duplicate file descriptors (created by, for example, +.br fork (2) +or +.br dup (2)) +refer to the same lease, and this lease may be modified +or released using any of these descriptors. +furthermore, the lease is released by either an explicit +.b f_unlck +operation on any of these duplicate file descriptors, or when all +such file descriptors have been closed. +.pp +leases may be taken out only on regular files. +an unprivileged process may take out a lease only on a file whose +uid (owner) matches the filesystem uid of the process. +a process with the +.b cap_lease +capability may take out leases on arbitrary files. +.tp +.br f_getlease " (\fivoid\fp)" +indicates what type of lease is associated with the file descriptor +.i fd +by returning either +.br f_rdlck ", " f_wrlck ", or " f_unlck , +indicating, respectively, a read lease , a write lease, or no lease. +.i arg +is ignored. +.pp +when a process (the "lease breaker") performs an +.br open (2) +or +.br truncate (2) +that conflicts with a lease established via +.br f_setlease , +the system call is blocked by the kernel and +the kernel notifies the lease holder by sending it a signal +.rb ( sigio +by default). +the lease holder should respond to receipt of this signal by doing +whatever cleanup is required in preparation for the file to be +accessed by another process (e.g., flushing cached buffers) and +then either remove or downgrade its lease. +a lease is removed by performing an +.b f_setlease +command specifying +.i arg +as +.br f_unlck . +if the lease holder currently holds a write lease on the file, +and the lease breaker is opening the file for reading, +then it is sufficient for the lease holder to downgrade +the lease to a read lease. +this is done by performing an +.b f_setlease +command specifying +.i arg +as +.br f_rdlck . +.pp +if the lease holder fails to downgrade or remove the lease within +the number of seconds specified in +.ir /proc/sys/fs/lease\-break\-time , +then the kernel forcibly removes or downgrades the lease holder's lease. +.pp +once a lease break has been initiated, +.b f_getlease +returns the target lease type (either +.b f_rdlck +or +.br f_unlck , +depending on what would be compatible with the lease breaker) +until the lease holder voluntarily downgrades or removes the lease or +the kernel forcibly does so after the lease break timer expires. +.pp +once the lease has been voluntarily or forcibly removed or downgraded, +and assuming the lease breaker has not unblocked its system call, +the kernel permits the lease breaker's system call to proceed. +.pp +if the lease breaker's blocked +.br open (2) +or +.br truncate (2) +is interrupted by a signal handler, +then the system call fails with the error +.br eintr , +but the other steps still occur as described above. +if the lease breaker is killed by a signal while blocked in +.br open (2) +or +.br truncate (2), +then the other steps still occur as described above. +if the lease breaker specifies the +.b o_nonblock +flag when calling +.br open (2), +then the call immediately fails with the error +.br ewouldblock , +but the other steps still occur as described above. +.pp +the default signal used to notify the lease holder is +.br sigio , +but this can be changed using the +.b f_setsig +command to +.br fcntl (). +if a +.b f_setsig +command is performed (even one specifying +.br sigio ), +and the signal +handler is established using +.br sa_siginfo , +then the handler will receive a +.i siginfo_t +structure as its second argument, and the +.i si_fd +field of this argument will hold the file descriptor of the leased file +that has been accessed by another process. +(this is useful if the caller holds leases against multiple files.) +.ss file and directory change notification (dnotify) +.tp +.br f_notify " (\fiint\fp)" +(linux 2.4 onward) +provide notification when the directory referred to by +.i fd +or any of the files that it contains is changed. +the events to be notified are specified in +.ir arg , +which is a bit mask specified by oring together zero or more of +the following bits: +.pp +.rs +.pd 0 +.tp +.b dn_access +a file was accessed +.rb ( read (2), +.br pread (2), +.br readv (2), +and similar) +.tp +.b dn_modify +a file was modified +.rb ( write (2), +.br pwrite (2), +.br writev (2), +.br truncate (2), +.br ftruncate (2), +and similar). +.tp +.b dn_create +a file was created +.rb ( open (2), +.br creat (2), +.br mknod (2), +.br mkdir (2), +.br link (2), +.br symlink (2), +.br rename (2) +into this directory). +.tp +.b dn_delete +a file was unlinked +.rb ( unlink (2), +.br rename (2) +to another directory, +.br rmdir (2)). +.tp +.b dn_rename +a file was renamed within this directory +.rb ( rename (2)). +.tp +.b dn_attrib +the attributes of a file were changed +.rb ( chown (2), +.br chmod (2), +.br utime (2), +.br utimensat (2), +and similar). +.pd +.re +.ip +(in order to obtain these definitions, the +.b _gnu_source +feature test macro must be defined before including +.i any +header files.) +.ip +directory notifications are normally "one-shot", and the application +must reregister to receive further notifications. +alternatively, if +.b dn_multishot +is included in +.ir arg , +then notification will remain in effect until explicitly removed. +.ip +.\" the following does seem a poor api-design choice... +a series of +.b f_notify +requests is cumulative, with the events in +.i arg +being added to the set already monitored. +to disable notification of all events, make an +.b f_notify +call specifying +.i arg +as 0. +.ip +notification occurs via delivery of a signal. +the default signal is +.br sigio , +but this can be changed using the +.b f_setsig +command to +.br fcntl (). +(note that +.b sigio +is one of the nonqueuing standard signals; +switching to the use of a real-time signal means that +multiple notifications can be queued to the process.) +in the latter case, the signal handler receives a +.i siginfo_t +structure as its second argument (if the handler was +established using +.br sa_siginfo ) +and the +.i si_fd +field of this structure contains the file descriptor which +generated the notification (useful when establishing notification +on multiple directories). +.ip +especially when using +.br dn_multishot , +a real time signal should be used for notification, +so that multiple notifications can be queued. +.ip +.b note: +new applications should use the +.i inotify +interface (available since kernel 2.6.13), +which provides a much superior interface for obtaining notifications of +filesystem events. +see +.br inotify (7). +.ss changing the capacity of a pipe +.tp +.br f_setpipe_sz " (\fiint\fp; since linux 2.6.35)" +change the capacity of the pipe referred to by +.i fd +to be at least +.i arg +bytes. +an unprivileged process can adjust the pipe capacity to any value +between the system page size and the limit defined in +.ir /proc/sys/fs/pipe\-max\-size +(see +.br proc (5)). +attempts to set the pipe capacity below the page size are silently +rounded up to the page size. +attempts by an unprivileged process to set the pipe capacity above the limit in +.ir /proc/sys/fs/pipe\-max\-size +yield the error +.br eperm ; +a privileged process +.rb ( cap_sys_resource ) +can override the limit. +.ip +when allocating the buffer for the pipe, +the kernel may use a capacity larger than +.ir arg , +if that is convenient for the implementation. +(in the current implementation, +the allocation is the next higher power-of-two page-size multiple +of the requested size.) +the actual capacity (in bytes) that is set is returned as the function result. +.ip +attempting to set the pipe capacity smaller than the amount +of buffer space currently used to store data produces the error +.br ebusy . +.ip +note that because of the way the pages of the pipe buffer +are employed when data is written to the pipe, +the number of bytes that can be written may be less than the nominal size, +depending on the size of the writes. +.tp +.br f_getpipe_sz " (\fivoid\fp; since linux 2.6.35)" +return (as the function result) the capacity of the pipe referred to by +.ir fd . +.\" +.ss file sealing +file seals limit the set of allowed operations on a given file. +for each seal that is set on a file, +a specific set of operations will fail with +.b eperm +on this file from now on. +the file is said to be sealed. +the default set of seals depends on the type of the underlying +file and filesystem. +for an overview of file sealing, a discussion of its purpose, +and some code examples, see +.br memfd_create (2). +.pp +currently, +file seals can be applied only to a file descriptor returned by +.br memfd_create (2) +(if the +.b mfd_allow_sealing +was employed). +on other filesystems, all +.br fcntl () +operations that operate on seals will return +.br einval . +.pp +seals are a property of an inode. +thus, all open file descriptors referring to the same inode share +the same set of seals. +furthermore, seals can never be removed, only added. +.tp +.br f_add_seals " (\fiint\fp; since linux 3.17)" +add the seals given in the bit-mask argument +.i arg +to the set of seals of the inode referred to by the file descriptor +.ir fd . +seals cannot be removed again. +once this call succeeds, the seals are enforced by the kernel immediately. +if the current set of seals includes +.br f_seal_seal +(see below), then this call will be rejected with +.br eperm . +adding a seal that is already set is a no-op, in case +.b f_seal_seal +is not set already. +in order to place a seal, the file descriptor +.i fd +must be writable. +.tp +.br f_get_seals " (\fivoid\fp; since linux 3.17)" +return (as the function result) the current set of seals +of the inode referred to by +.ir fd . +if no seals are set, 0 is returned. +if the file does not support sealing, \-1 is returned and +.i errno +is set to +.br einval . +.pp +the following seals are available: +.tp +.br f_seal_seal +if this seal is set, any further call to +.br fcntl () +with +.b f_add_seals +fails with the error +.br eperm . +therefore, this seal prevents any modifications to the set of seals itself. +if the initial set of seals of a file includes +.br f_seal_seal , +then this effectively causes the set of seals to be constant and locked. +.tp +.br f_seal_shrink +if this seal is set, the file in question cannot be reduced in size. +this affects +.br open (2) +with the +.b o_trunc +flag as well as +.br truncate (2) +and +.br ftruncate (2). +those calls fail with +.b eperm +if you try to shrink the file in question. +increasing the file size is still possible. +.tp +.br f_seal_grow +if this seal is set, the size of the file in question cannot be increased. +this affects +.br write (2) +beyond the end of the file, +.br truncate (2), +.br ftruncate (2), +and +.br fallocate (2). +these calls fail with +.b eperm +if you use them to increase the file size. +if you keep the size or shrink it, those calls still work as expected. +.tp +.br f_seal_write +if this seal is set, you cannot modify the contents of the file. +note that shrinking or growing the size of the file is +still possible and allowed. +.\" one or more other seals are typically used with f_seal_write +.\" because, given a file with the f_seal_write seal set, then, +.\" while it would no longer be possible to (say) write zeros into +.\" the last 100 bytes of a file, it would still be possible +.\" to (say) shrink the file by 100 bytes using ftruncate(), and +.\" then increase the file size by 100 bytes, which would have +.\" the effect of replacing the last hundred bytes by zeros. +.\" +thus, this seal is normally used in combination with one of the other seals. +this seal affects +.br write (2) +and +.br fallocate (2) +(only in combination with the +.b falloc_fl_punch_hole +flag). +those calls fail with +.b eperm +if this seal is set. +furthermore, trying to create new shared, writable memory-mappings via +.br mmap (2) +will also fail with +.br eperm . +.ip +using the +.b f_add_seals +operation to set the +.b f_seal_write +seal fails with +.b ebusy +if any writable, shared mapping exists. +such mappings must be unmapped before you can add this seal. +furthermore, if there are any asynchronous i/o operations +.rb ( io_submit (2)) +pending on the file, +all outstanding writes will be discarded. +.tp +.br f_seal_future_write " (since linux 5.1)" +the effect of this seal is similar to +.br f_seal_write , +but the contents of the file can still be modified via +shared writable mappings that were created prior to the seal being set. +any attempt to create a new writable mapping on the file via +.br mmap (2) +will fail with +.br eperm . +likewise, an attempt to write to the file via +.br write (2) +will fail with +.br eperm . +.ip +using this seal, +one process can create a memory buffer that it can continue to modify +while sharing that buffer on a "read-only" basis with other processes. +.\" +.ss file read/write hints +write lifetime hints can be used to inform the kernel about the relative +expected lifetime of writes on a given inode or +via a particular open file description. +(see +.br open (2) +for an explanation of open file descriptions.) +in this context, the term "write lifetime" means +the expected time the data will live on media, before +being overwritten or erased. +.pp +an application may use the different hint values specified below to +separate writes into different write classes, +so that multiple users or applications running on a single storage back-end +can aggregate their i/o patterns in a consistent manner. +however, there are no functional semantics implied by these flags, +and different i/o classes can use the write lifetime hints +in arbitrary ways, so long as the hints are used consistently. +.pp +the following operations can be applied to the file descriptor, +.ir fd : +.tp +.br f_get_rw_hint " (\fiuint64_t *\fp; since linux 4.13)" +returns the value of the read/write hint associated with the underlying inode +referred to by +.ir fd . +.tp +.br f_set_rw_hint " (\fiuint64_t *\fp; since linux 4.13)" +sets the read/write hint value associated with the +underlying inode referred to by +.ir fd . +this hint persists until either it is explicitly modified or +the underlying filesystem is unmounted. +.tp +.br f_get_file_rw_hint " (\fiuint64_t *\fp; since linux 4.13)" +returns the value of the read/write hint associated with +the open file description referred to by +.ir fd . +.tp +.br f_set_file_rw_hint " (\fiuint64_t *\fp; since linux 4.13)" +sets the read/write hint value associated with the open file description +referred to by +.ir fd . +.pp +if an open file description has not been assigned a read/write hint, +then it shall use the value assigned to the inode, if any. +.pp +the following read/write +hints are valid since linux 4.13: +.tp +.br rwh_write_life_not_set +no specific hint has been set. +this is the default value. +.tp +.br rwh_write_life_none +no specific write lifetime is associated with this file or inode. +.tp +.br rwh_write_life_short +data written to this inode or via this open file description +is expected to have a short lifetime. +.tp +.br rwh_write_life_medium +data written to this inode or via this open file description +is expected to have a lifetime longer than +data written with +.br rwh_write_life_short . +.tp +.br rwh_write_life_long +data written to this inode or via this open file description +is expected to have a lifetime longer than +data written with +.br rwh_write_life_medium . +.tp +.br rwh_write_life_extreme +data written to this inode or via this open file description +is expected to have a lifetime longer than +data written with +.br rwh_write_life_long . +.pp +all the write-specific hints are relative to each other, +and no individual absolute meaning should be attributed to them. +.sh return value +for a successful call, the return value depends on the operation: +.tp +.b f_dupfd +the new file descriptor. +.tp +.b f_getfd +value of file descriptor flags. +.tp +.b f_getfl +value of file status flags. +.tp +.b f_getlease +type of lease held on file descriptor. +.tp +.b f_getown +value of file descriptor owner. +.tp +.b f_getsig +value of signal sent when read or write becomes possible, or zero +for traditional +.b sigio +behavior. +.tp +.br f_getpipe_sz ", " f_setpipe_sz +the pipe capacity. +.tp +.br f_get_seals +a bit mask identifying the seals that have been set +for the inode referred to by +.ir fd . +.tp +all other commands +zero. +.pp +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.br eacces " or " eagain +operation is prohibited by locks held by other processes. +.tp +.b eagain +the operation is prohibited because the file has been memory-mapped by +another process. +.tp +.b ebadf +.i fd +is not an open file descriptor +.tp +.b ebadf +.i cmd +is +.b f_setlk +or +.b f_setlkw +and the file descriptor open mode doesn't match with the +type of lock requested. +.tp +.br ebusy +.i cmd +is +.br f_setpipe_sz +and the new pipe capacity specified in +.i arg +is smaller than the amount of buffer space currently +used to store data in the pipe. +.tp +.b ebusy +.i cmd +is +.br f_add_seals , +.ir arg +includes +.br f_seal_write , +and there exists a writable, shared mapping on the file referred to by +.ir fd . +.tp +.b edeadlk +it was detected that the specified +.b f_setlkw +command would cause a deadlock. +.tp +.b efault +.i lock +is outside your accessible address space. +.tp +.b eintr +.i cmd +is +.br f_setlkw +or +.br f_ofd_setlkw +and the operation was interrupted by a signal; see +.br signal (7). +.tp +.b eintr +.i cmd +is +.br f_getlk , +.br f_setlk , +.br f_ofd_getlk , +or +.br f_ofd_setlk , +and the operation was interrupted by a signal before the lock was checked or +acquired. +most likely when locking a remote file (e.g., locking over +nfs), but can sometimes happen locally. +.tp +.b einval +the value specified in +.i cmd +is not recognized by this kernel. +.tp +.b einval +.i cmd +is +.br f_add_seals +and +.i arg +includes an unrecognized sealing bit. +.tp +.br einval +.i cmd +is +.br f_add_seals +or +.br f_get_seals +and the filesystem containing the inode referred to by +.i fd +does not support sealing. +.tp +.b einval +.i cmd +is +.br f_dupfd +and +.i arg +is negative or is greater than the maximum allowable value +(see the discussion of +.br rlimit_nofile +in +.br getrlimit (2)). +.tp +.b einval +.i cmd +is +.br f_setsig +and +.i arg +is not an allowable signal number. +.tp +.b einval +.i cmd +is +.br f_ofd_setlk , +.br f_ofd_setlkw , +or +.br f_ofd_getlk , +and +.i l_pid +was not specified as zero. +.tp +.b emfile +.i cmd +is +.br f_dupfd +and the per-process limit on the number of open file descriptors +has been reached. +.tp +.b enolck +too many segment locks open, lock table is full, or a remote locking +protocol failed (e.g., locking over nfs). +.tp +.b enotdir +.b f_notify +was specified in +.ir cmd , +but +.ir fd +does not refer to a directory. +.tp +.br eperm +.i cmd +is +.br f_setpipe_sz +and the soft or hard user pipe limit has been reached; see +.br pipe (7). +.tp +.b eperm +attempted to clear the +.b o_append +flag on a file that has the append-only attribute set. +.tp +.b eperm +.i cmd +was +.br f_add_seals , +but +.i fd +was not open for writing +or the current set of seals on the file already includes +.br f_seal_seal . +.sh conforming to +svr4, 4.3bsd, posix.1-2001. +only the operations +.br f_dupfd , +.br f_getfd , +.br f_setfd , +.br f_getfl , +.br f_setfl , +.br f_getlk , +.br f_setlk , +and +.br f_setlkw +are specified in posix.1-2001. +.pp +.br f_getown +and +.b f_setown +are specified in posix.1-2001. +(to get their definitions, define either +.\" .br _bsd_source , +.\" or +.br _xopen_source +with the value 500 or greater, or +.br _posix_c_source +with the value 200809l or greater.) +.pp +.b f_dupfd_cloexec +is specified in posix.1-2008. +(to get this definition, define +.b _posix_c_source +with the value 200809l or greater, or +.b _xopen_source +with the value 700 or greater.) +.pp +.br f_getown_ex , +.br f_setown_ex , +.br f_setpipe_sz , +.br f_getpipe_sz , +.br f_getsig , +.br f_setsig , +.br f_notify , +.br f_getlease , +and +.b f_setlease +are linux-specific. +(define the +.b _gnu_source +macro to obtain these definitions.) +.\" .pp +.\" svr4 documents additional eio, enolink and eoverflow error conditions. +.pp +.br f_ofd_setlk , +.br f_ofd_setlkw , +and +.br f_ofd_getlk +are linux-specific (and one must define +.br _gnu_source +to obtain their definitions), +but work is being done to have them included in the next version of posix.1. +.pp +.br f_add_seals +and +.br f_get_seals +are linux-specific. +.\" fixme . once glibc adds support, add a note about ftm requirements +.sh notes +the errors returned by +.br dup2 (2) +are different from those returned by +.br f_dupfd . +.\" +.ss file locking +the original linux +.br fcntl () +system call was not designed to handle large file offsets +(in the +.i flock +structure). +consequently, an +.br fcntl64 () +system call was added in linux 2.4. +the newer system call employs a different structure for file locking, +.ir flock64 , +and corresponding commands, +.br f_getlk64 , +.br f_setlk64 , +and +.br f_setlkw64 . +however, these details can be ignored by applications using glibc, whose +.br fcntl () +wrapper function transparently employs the more recent system call +where it is available. +.\" +.ss record locks +since kernel 2.0, there is no interaction between the types of lock +placed by +.br flock (2) +and +.br fcntl (). +.pp +several systems have more fields in +.i "struct flock" +such as, for example, +.ir l_sysid +(to identify the machine where the lock is held). +.\" e.g., solaris 8 documents this field in fcntl(2), and irix 6.5 +.\" documents it in fcntl(5). mtk, may 2007 +.\" also, freebsd documents it (apr 2014). +clearly, +.i l_pid +alone is not going to be very useful if the process holding the lock +may live on a different machine; +on linux, while present on some architectures (such as mips32), +this field is not used. +.pp +the original linux +.br fcntl () +system call was not designed to handle large file offsets +(in the +.i flock +structure). +consequently, an +.br fcntl64 () +system call was added in linux 2.4. +the newer system call employs a different structure for file locking, +.ir flock64 , +and corresponding commands, +.br f_getlk64 , +.br f_setlk64 , +and +.br f_setlkw64 . +however, these details can be ignored by applications using glibc, whose +.br fcntl () +wrapper function transparently employs the more recent system call +where it is available. +.ss record locking and nfs +before linux 3.12, if an nfsv4 client +loses contact with the server for a period of time +(defined as more than 90 seconds with no communication), +.\" +.\" neil brown: with nfsv3 the failure mode is the reverse. if +.\" the server loses contact with a client then any lock stays in place +.\" indefinitely ("why can't i read my mail"... i remember it well). +.\" +it might lose and regain a lock without ever being aware of the fact. +(the period of time after which contact is assumed lost is known as +the nfsv4 leasetime. +on a linux nfs server, this can be determined by looking at +.ir /proc/fs/nfsd/nfsv4leasetime , +which expresses the period in seconds. +the default value for this file is 90.) +.\" +.\" jeff layton: +.\" note that this is not a firm timeout. the server runs a job +.\" periodically to clean out expired stateful objects, and it's likely +.\" that there is some time (maybe even up to another whole lease period) +.\" between when the timeout expires and the job actually runs. if the +.\" client gets a renew in there within that window, its lease will be +.\" renewed and its state preserved. +.\" +this scenario potentially risks data corruption, +since another process might acquire a lock in the intervening period +and perform file i/o. +.pp +since linux 3.12, +.\" commit ef1820f9be27b6ad158f433ab38002ab8131db4d +if an nfsv4 client loses contact with the server, +any i/o to the file by a process which "thinks" it holds +a lock will fail until that process closes and reopens the file. +a kernel parameter, +.ir nfs.recover_lost_locks , +can be set to 1 to obtain the pre-3.12 behavior, +whereby the client will attempt to recover lost locks +when contact is reestablished with the server. +because of the attendant risk of data corruption, +.\" commit f6de7a39c181dfb8a2c534661a53c73afb3081cd +this parameter defaults to 0 (disabled). +.sh bugs +.ss f_setfl +it is not possible to use +.br f_setfl +to change the state of the +.br o_dsync +and +.br o_sync +flags. +.\" fixme . according to posix.1-2001, o_sync should also be modifiable +.\" via fcntl(2), but currently linux does not permit this +.\" see http://bugzilla.kernel.org/show_bug.cgi?id=5994 +attempts to change the state of these flags are silently ignored. +.ss f_getown +a limitation of the linux system call conventions on some +architectures (notably i386) means that if a (negative) +process group id to be returned by +.b f_getown +falls in the range \-1 to \-4095, then the return value is wrongly +interpreted by glibc as an error in the system call; +.\" glibc source: sysdeps/unix/sysv/linux/i386/sysdep.h +that is, the return value of +.br fcntl () +will be \-1, and +.i errno +will contain the (positive) process group id. +the linux-specific +.br f_getown_ex +operation avoids this problem. +.\" mtk, dec 04: some limited testing on alpha and ia64 seems to +.\" indicate that any negative pgid value will cause f_getown +.\" to misinterpret the return as an error. some other architectures +.\" seem to have the same range check as i386. +since glibc version 2.11, glibc makes the kernel +.b f_getown +problem invisible by implementing +.b f_getown +using +.br f_getown_ex . +.ss f_setown +in linux 2.4 and earlier, there is bug that can occur +when an unprivileged process uses +.b f_setown +to specify the owner +of a socket file descriptor +as a process (group) other than the caller. +in this case, +.br fcntl () +can return \-1 with +.i errno +set to +.br eperm , +even when the owner process (group) is one that the caller +has permission to send signals to. +despite this error return, the file descriptor owner is set, +and signals will be sent to the owner. +.\" +.ss deadlock detection +the deadlock-detection algorithm employed by the kernel when dealing with +.br f_setlkw +requests can yield both +false negatives (failures to detect deadlocks, +leaving a set of deadlocked processes blocked indefinitely) +and false positives +.rb ( edeadlk +errors when there is no deadlock). +for example, +the kernel limits the lock depth of its dependency search to 10 steps, +meaning that circular deadlock chains that exceed +that size will not be detected. +in addition, the kernel may falsely indicate a deadlock +when two or more processes created using the +.br clone (2) +.b clone_files +flag place locks that appear (to the kernel) to conflict. +.\" +.ss mandatory locking +the linux implementation of mandatory locking +is subject to race conditions which render it unreliable: +.\" http://marc.info/?l=linux-kernel&m=119013491707153&w=2 +.\" +.\" reconfirmed by jeff layton +.\" from: jeff layton redhat.com> +.\" subject: re: status of fcntl() mandatory locking +.\" newsgroups: gmane.linux.file-systems +.\" date: 2014-04-28 10:07:57 gmt +.\" http://thread.gmane.org/gmane.linux.file-systems/84481/focus=84518 +a +.br write (2) +call that overlaps with a lock may modify data after the mandatory lock is +acquired; +a +.br read (2) +call that overlaps with a lock may detect changes to data that were made +only after a write lock was acquired. +similar races exist between mandatory locks and +.br mmap (2). +it is therefore inadvisable to rely on mandatory locking. +.sh see also +.br dup2 (2), +.br flock (2), +.br open (2), +.br socket (2), +.br lockf (3), +.br capabilities (7), +.br feature_test_macros (7), +.br lslocks (8) +.pp +.ir locks.txt , +.ir mandatory\-locking.txt , +and +.i dnotify.txt +in the linux kernel source directory +.ir documentation/filesystems/ +(on older kernels, these files are directly under the +.i documentation/ +directory, and +.i mandatory\-locking.txt +is called +.ir mandatory.txt ) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/getutent.3 + +.\" copyright 2000 sam varshavchik +.\" and copyright (c) 2008 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references: rfc 2553 +.th inet_pton 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +inet_pton \- convert ipv4 and ipv6 addresses from text to binary form +.sh synopsis +.nf +.b #include +.pp +.bi "int inet_pton(int " af ", const char *restrict " src \ +", void *restrict " dst ); +.fi +.sh description +this function converts the character string +.i src +into a network address structure in the +.i af +address family, then +copies +the network address structure to +.ir dst . +the +.i af +argument must be either +.b af_inet +or +.br af_inet6 . +.ir dst +is written in network byte order. +.pp +the following address families are currently supported: +.tp +.b af_inet +.i src +points to a character string containing an ipv4 network address in +dotted-decimal format, "\fiddd.ddd.ddd.ddd\fp", where +.i ddd +is a decimal number of up to three digits in the range 0 to 255. +the address is converted to a +.i struct in_addr +and copied to +.ir dst , +which must be +.i sizeof(struct in_addr) +(4) bytes (32 bits) long. +.tp +.b af_inet6 +.i src +points to a character string containing an ipv6 network address. +the address is converted to a +.i struct in6_addr +and copied to +.ir dst , +which must be +.i sizeof(struct in6_addr) +(16) bytes (128 bits) long. +the allowed formats for ipv6 addresses follow these rules: +.rs +.ip 1. 3 +the preferred format is +.ir x:x:x:x:x:x:x:x . +this form consists of eight hexadecimal numbers, +each of which expresses a 16-bit value (i.e., each +.i x +can be up to 4 hex digits). +.ip 2. +a series of contiguous zero values in the preferred format +can be abbreviated to +.ir :: . +only one instance of +.i :: +can occur in an address. +for example, the loopback address +.i 0:0:0:0:0:0:0:1 +can be abbreviated as +.ir ::1 . +the wildcard address, consisting of all zeros, can be written as +.ir :: . +.ip 3. +an alternate format is useful for expressing ipv4-mapped ipv6 addresses. +this form is written as +.ir x:x:x:x:x:x:d.d.d.d , +where the six leading +.ir x s +are hexadecimal values that define the six most-significant +16-bit pieces of the address (i.e., 96 bits), and the +.ir d s +express a value in dotted-decimal notation that +defines the least significant 32 bits of the address. +an example of such an address is +.ir ::ffff:204.152.189.116 . +.re +.ip +see rfc 2373 for further details on the representation of ipv6 addresses. +.sh return value +.br inet_pton () +returns 1 on success (network address was successfully converted). +0 is returned if +.i src +does not contain a character string representing a valid network +address in the specified address family. +if +.i af +does not contain a valid address family, \-1 is returned and +.i errno +is set to +.br eafnosupport . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br inet_pton () +t} thread safety mt-safe locale +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +unlike +.br inet_aton (3) +and +.br inet_addr (3), +.br inet_pton () +supports ipv6 addresses. +on the other hand, +.br inet_pton () +accepts only ipv4 addresses in dotted-decimal notation, whereas +.br inet_aton (3) +and +.br inet_addr (3) +allow the more general numbers-and-dots notation (hexadecimal +and octal number formats, and formats that don't require all +four bytes to be explicitly written). +for an interface that handles both ipv6 addresses, and ipv4 +addresses in numbers-and-dots notation, see +.br getaddrinfo (3). +.sh bugs +.b af_inet6 +does not recognize ipv4 addresses. +an explicit ipv4-mapped ipv6 address must be supplied in +.i src +instead. +.sh examples +the program below demonstrates the use of +.br inet_pton () +and +.br inet_ntop (3). +here are some example runs: +.pp +.in +4n +.ex +.rb "$" " ./a.out i6 0:0:0:0:0:0:0:0" +:: +.rb "$" " ./a.out i6 1:0:0:0:0:0:0:8" +1::8 +.rb "$" " ./a.out i6 0:0:0:0:0:ffff:204.152.189.116" +::ffff:204.152.189.116 +.ee +.in +.ss program source +\& +.ex +#include +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + unsigned char buf[sizeof(struct in6_addr)]; + int domain, s; + char str[inet6_addrstrlen]; + + if (argc != 3) { + fprintf(stderr, "usage: %s {i4|i6|} string\en", argv[0]); + exit(exit_failure); + } + + domain = (strcmp(argv[1], "i4") == 0) ? af_inet : + (strcmp(argv[1], "i6") == 0) ? af_inet6 : atoi(argv[1]); + + s = inet_pton(domain, argv[2], buf); + if (s <= 0) { + if (s == 0) + fprintf(stderr, "not in presentation format"); + else + perror("inet_pton"); + exit(exit_failure); + } + + if (inet_ntop(domain, buf, str, inet6_addrstrlen) == null) { + perror("inet_ntop"); + exit(exit_failure); + } + + printf("%s\en", str); + + exit(exit_success); +} +.ee +.sh see also +.br getaddrinfo (3), +.br inet (3), +.br inet_ntop (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/stailq.3 + +.so man3/cpu_set.3 + +.\" $openbsd: elf.5,v 1.12 2003/10/27 20:23:58 jmc exp $ +.\"copyright (c) 1999 jeroen ruigrok van der werven +.\"all rights reserved. +.\" +.\" %%%license_start(permissive_misc) +.\"redistribution and use in source and binary forms, with or without +.\"modification, are permitted provided that the following conditions +.\"are met: +.\"1. redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\"2. redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\"this software is provided by the author and contributors ``as is'' and +.\"any express or implied warranties, including, but not limited to, the +.\"implied warranties of merchantability and fitness for a particular purpose +.\"are disclaimed. in no event shall the author or contributors be liable +.\"for any direct, indirect, incidental, special, exemplary, or consequential +.\"damages (including, but not limited to, procurement of substitute goods +.\"or services; loss of use, data, or profits; or business interruption) +.\"however caused and on any theory of liability, whether in contract, strict +.\"liability, or tort (including negligence or otherwise) arising in any way +.\"out of the use of this software, even if advised of the possibility of +.\"such damage. +.\" %%%license_end +.\" +.\" $freebsd: src/share/man/man5/elf.5,v 1.21 2001/10/01 16:09:23 ru exp $ +.\" +.\" slightly adapted - aeb, 2004-01-01 +.\" 2005-07-15, mike frysinger , various fixes +.\" 2007-10-11, mike frysinger , various fixes +.\" 2007-12-08, mtk, converted from mdoc to man macros +.\" +.th elf 5 2021-03-22 "linux" "linux programmer's manual" +.sh name +elf \- format of executable and linking format (elf) files +.sh synopsis +.nf +.\" .b #include +.b #include +.fi +.sh description +the header file +.i +defines the format of elf executable binary files. +amongst these files are +normal executable files, relocatable object files, core files, and shared +objects. +.pp +an executable file using the elf file format consists of an elf header, +followed by a program header table or a section header table, or both. +the elf header is always at offset zero of the file. +the program header +table and the section header table's offset in the file are defined in the +elf header. +the two tables describe the rest of the particularities of +the file. +.pp +.\" applications which wish to process elf binary files for their native +.\" architecture only should include +.\" .i +.\" in their source code. +.\" these applications should need to refer to +.\" all the types and structures by their generic names +.\" "elf_xxx" +.\" and to the macros by +.\" elf_xxx". +.\" applications written this way can be compiled on any architecture, +.\" regardless of whether the host is 32-bit or 64-bit. +.\" .pp +.\" should an application need to process elf files of an unknown +.\" architecture, then the application needs to explicitly use either +.\" "elf32_xxx" +.\" or +.\" "elf64_xxx" +.\" type and structure names. +.\" likewise, the macros need to be identified by +.\" "elf32_xxx" +.\" or +.\" "elf64_xxx". +.\" .pp +this header file describes the above mentioned headers as c structures +and also includes structures for dynamic sections, relocation sections and +symbol tables. +.\" +.ss basic types +the following types are used for n-bit architectures (n=32,64, +.i elfn +stands for +.i elf32 +or +.ir elf64 , +.i uintn_t +stands for +.i uint32_t +or +.ir uint64_t ): +.pp +.in +4n +.ex +elfn_addr unsigned program address, uintn_t +elfn_off unsigned file offset, uintn_t +elfn_section unsigned section index, uint16_t +elfn_versym unsigned version symbol information, uint16_t +elf_byte unsigned char +elfn_half uint16_t +elfn_sword int32_t +elfn_word uint32_t +elfn_sxword int64_t +elfn_xword uint64_t +.\" elf32_size unsigned object size +.ee +.in +.pp +(note: the *bsd terminology is a bit different. +there, +.i elf64_half +is +twice as large as +.ir elf32_half , +and +.i elf64quarter +is used for +.ir uint16_t . +in order to avoid confusion these types are replaced by explicit ones +in the below.) +.pp +all data structures that the file format defines follow the +"natural" +size and alignment guidelines for the relevant class. +if necessary, +data structures contain explicit padding to ensure 4-byte alignment +for 4-byte objects, to force structure sizes to a multiple of 4, and so on. +.\" +.ss elf header (ehdr) +the elf header is described by the type +.i elf32_ehdr +or +.ir elf64_ehdr : +.pp +.in +4n +.ex +#define ei_nident 16 + +typedef struct { + unsigned char e_ident[ei_nident]; + uint16_t e_type; + uint16_t e_machine; + uint32_t e_version; + elfn_addr e_entry; + elfn_off e_phoff; + elfn_off e_shoff; + uint32_t e_flags; + uint16_t e_ehsize; + uint16_t e_phentsize; + uint16_t e_phnum; + uint16_t e_shentsize; + uint16_t e_shnum; + uint16_t e_shstrndx; +} elfn_ehdr; +.ee +.in +.pp +the fields have the following meanings: +.\" +.\" +.tp +.ir e_ident +this array of bytes specifies how to interpret the file, +independent of the processor or the file's remaining contents. +within this array everything is named by macros, which start with +the prefix +.br ei_ +and may contain values which start with the prefix +.br elf . +the following macros are defined: +.rs +.tp +.br ei_mag0 +the first byte of the magic number. +it must be filled with +.br elfmag0 . +(0: 0x7f) +.tp +.br ei_mag1 +the second byte of the magic number. +it must be filled with +.br elfmag1 . +(1: \(aqe\(aq) +.tp +.br ei_mag2 +the third byte of the magic number. +it must be filled with +.br elfmag2 . +(2: \(aql\(aq) +.tp +.br ei_mag3 +the fourth byte of the magic number. +it must be filled with +.br elfmag3 . +(3: \(aqf\(aq) +.tp +.br ei_class +the fifth byte identifies the architecture for this binary: +.rs +.tp 14 +.pd 0 +.br elfclassnone +this class is invalid. +.tp +.br elfclass32 +this defines the 32-bit architecture. +it supports machines with files +and virtual address spaces up to 4 gigabytes. +.tp +.br elfclass64 +this defines the 64-bit architecture. +.pd +.re +.tp +.br ei_data +the sixth byte specifies the data encoding of the processor-specific +data in the file. +currently, these encodings are supported: +.rs 9 +.tp 14 +.pd 0 +.br elfdatanone +unknown data format. +.tp +.br elfdata2lsb +two's complement, little-endian. +.tp +.br elfdata2msb +two's complement, big-endian. +.pd +.re +.tp +.br ei_version +the seventh byte is the version number of the elf specification: +.ip +.pd 0 +.rs +.tp 14 +.br ev_none +invalid version. +.tp +.br ev_current +current version. +.pd +.re +.\".el +.tp +.br ei_osabi +the eighth byte identifies the operating system +and abi to which the object is targeted. +some fields in other elf structures have flags +and values that have platform-specific meanings; +the interpretation of those fields is determined by the value of this byte. +for example: +.rs +.tp 21 +.pd 0 +.br elfosabi_none +same as elfosabi_sysv +.\" 0 +.tp +.br elfosabi_sysv +unix system v abi +.\" 0 +.\" synonym: elfosabi_none +.tp +.br elfosabi_hpux +hp-ux abi +.\" 1 +.tp +.br elfosabi_netbsd +netbsd abi +.\" 2 +.tp +.br elfosabi_linux +linux abi +.\" 3 +.\" .tp +.\" .br elfosabi_hurd +.\" hurd abi +.\" 4 +.\" .tp +.\" .br elfosabi_86open +.\" 86open common ia32 abi +.\" 5 +.tp +.br elfosabi_solaris +solaris abi +.\" 6 +.\" .tp +.\" .br elfosabi_monterey +.\" monterey project abi +.\" now replaced by +.\" elfosabi_aix +.\" 7 +.tp +.br elfosabi_irix +irix abi +.\" 8 +.tp +.br elfosabi_freebsd +freebsd abi +.\" 9 +.tp +.br elfosabi_tru64 +tru64 unix abi +.\" 10 +.\" elfosabi_modesto +.\" 11 +.\" elfosabi_openbsd +.\" 12 +.tp +.br elfosabi_arm +arm architecture abi +.\" 97 +.tp +.br elfosabi_standalone +stand-alone (embedded) abi +.\" 255 +.pd +.re +.tp +.br ei_abiversion +the ninth byte identifies the version of the abi +to which the object is targeted. +this field is used to distinguish among incompatible versions of an abi. +the interpretation of this version number +is dependent on the abi identified by the +.b ei_osabi +field. +applications conforming to this specification use the value 0. +.tp +.br ei_pad +start of padding. +these bytes are reserved and set to zero. +programs +which read them should ignore them. +the value for +.b ei_pad +will change in +the future if currently unused bytes are given meanings. +.\" as reported by yuri kozlov and confirmed by mike frysinger, ei_brand is +.\" not in gabi (http://www.sco.com/developers/gabi/latest/ch4.eheader.html) +.\" it looks to be a bsdism +.\" .tp +.\" .br ei_brand +.\" start of architecture identification. +.tp +.br ei_nident +the size of the +.i e_ident +array. +.re +.tp +.ir e_type +this member of the structure identifies the object file type: +.rs +.tp 16 +.pd 0 +.br et_none +an unknown type. +.tp +.br et_rel +a relocatable file. +.tp +.br et_exec +an executable file. +.tp +.br et_dyn +a shared object. +.tp +.br et_core +a core file. +.pd +.re +.tp +.ir e_machine +this member specifies the required architecture for an individual file. +for example: +.rs +.tp 16 +.pd 0 +.br em_none +an unknown machine +.\" 0 +.tp +.br em_m32 +at&t we 32100 +.\" 1 +.tp +.br em_sparc +sun microsystems sparc +.\" 2 +.tp +.br em_386 +intel 80386 +.\" 3 +.tp +.br em_68k +motorola 68000 +.\" 4 +.tp +.br em_88k +motorola 88000 +.\" 5 +.\" .tp +.\" .br em_486 +.\" intel 80486 +.\" 6 +.tp +.br em_860 +intel 80860 +.\" 7 +.tp +.br em_mips +mips rs3000 (big-endian only) +.\" 8 +.\" em_s370 +.\" 9 +.\" .tp +.\" .br em_mips_rs4_be +.\" mips rs4000 (big-endian only). deprecated +.\" 10 +.\" em_mips_rs3_le (mips r3000 little-endian) +.\" 10 +.tp +.br em_parisc +hp/pa +.\" 15 +.tp +.br em_sparc32plus +sparc with enhanced instruction set +.\" 18 +.tp +.br em_ppc +powerpc +.\" 20 +.tp +.br em_ppc64 +powerpc 64-bit +.\" 21 +.tp +.br em_s390 +ibm s/390 +.\" 22 +.tp +.br em_arm +advanced risc machines +.\" 40 +.tp +.br em_sh +renesas superh +.\" 42 +.tp +.br em_sparcv9 +sparc v9 64-bit +.\" 43 +.tp +.br em_ia_64 +intel itanium +.\" 50 +.tp +.br em_x86_64 +amd x86-64 +.\" 62 +.tp +.br em_vax +dec vax +.\" 75 +.\" em_cris +.\" 76 +.\" .tp +.\" .br em_alpha +.\" compaq [dec] alpha +.\" .tp +.\" .br em_alpha_exp +.\" compaq [dec] alpha with enhanced instruction set +.pd +.re +.tp +.ir e_version +this member identifies the file version: +.rs +.tp 16 +.pd 0 +.br ev_none +invalid version +.tp +.br ev_current +current version +.pd +.re +.tp +.ir e_entry +this member gives the virtual address to which the system first transfers +control, thus starting the process. +if the file has no associated entry +point, this member holds zero. +.tp +.ir e_phoff +this member holds the program header table's file offset in bytes. +if +the file has no program header table, this member holds zero. +.tp +.ir e_shoff +this member holds the section header table's file offset in bytes. +if the +file has no section header table, this member holds zero. +.tp +.ir e_flags +this member holds processor-specific flags associated with the file. +flag names take the form ef_`machine_flag'. +currently, no flags have been defined. +.tp +.ir e_ehsize +this member holds the elf header's size in bytes. +.tp +.ir e_phentsize +this member holds the size in bytes of one entry in the file's +program header table; all entries are the same size. +.tp +.ir e_phnum +this member holds the number of entries in the program header +table. +thus the product of +.ir e_phentsize +and +.ir e_phnum +gives the table's size +in bytes. +if a file has no program header, +.ir e_phnum +holds the value zero. +.ip +if the number of entries in the program header table is +larger than or equal to +.\" this is a linux extension, added in linux 2.6.34. +.br pn_xnum +(0xffff), this member holds +.br pn_xnum +(0xffff) and the real number of entries in the program header table is held +in the +.ir sh_info +member of the initial entry in section header table. +otherwise, the +.ir sh_info +member of the initial entry contains the value zero. +.rs +.tp +.br pn_xnum +this is defined as 0xffff, the largest number +.ir e_phnum +can have, specifying where the actual number of program headers is assigned. +.pd +.re +.tp +.ir e_shentsize +this member holds a sections header's size in bytes. +a section header is one +entry in the section header table; all entries are the same size. +.tp +.ir e_shnum +this member holds the number of entries in the section header table. +thus +the product of +.ir e_shentsize +and +.ir e_shnum +gives the section header table's size in bytes. +if a file has no section +header table, +.ir e_shnum +holds the value of zero. +.ip +if the number of entries in the section header table is +larger than or equal to +.br shn_loreserve +(0xff00), +.ir e_shnum +holds the value zero and the real number of entries in the section header +table is held in the +.ir sh_size +member of the initial entry in section header table. +otherwise, the +.ir sh_size +member of the initial entry in the section header table holds +the value zero. +.tp +.ir e_shstrndx +this member holds the section header table index of the entry associated +with the section name string table. +if the file has no section name string +table, this member holds the value +.br shn_undef . +.ip +if the index of section name string table section is +larger than or equal to +.br shn_loreserve +(0xff00), this member holds +.br shn_xindex +(0xffff) and the real index of the section name string table section +is held in the +.ir sh_link +member of the initial entry in section header table. +otherwise, the +.ir sh_link +member of the initial entry in section header table contains the value zero. +.\" +.ss program header (phdr) +an executable or shared object file's program header table is an array of +structures, each describing a segment or other information the system needs +to prepare the program for execution. +an object file +.ir segment +contains one or more +.ir sections . +program headers are meaningful only for executable and shared object files. +a file specifies its own program header size with the elf header's +.ir e_phentsize +and +.ir e_phnum +members. +the elf program header is described by the type +.i elf32_phdr +or +.i elf64_phdr +depending on the architecture: +.pp +.in +4n +.ex +typedef struct { + uint32_t p_type; + elf32_off p_offset; + elf32_addr p_vaddr; + elf32_addr p_paddr; + uint32_t p_filesz; + uint32_t p_memsz; + uint32_t p_flags; + uint32_t p_align; +} elf32_phdr; +.ee +.in +.pp +.in +4n +.ex +typedef struct { + uint32_t p_type; + uint32_t p_flags; + elf64_off p_offset; + elf64_addr p_vaddr; + elf64_addr p_paddr; + uint64_t p_filesz; + uint64_t p_memsz; + uint64_t p_align; +} elf64_phdr; +.ee +.in +.pp +the main difference between the 32-bit and the 64-bit program header lies +in the location of the +.ir p_flags +member in the total struct. +.tp +.ir p_type +this member of the structure indicates what kind of segment this array +element describes or how to interpret the array element's information. +.rs 10 +.tp +.br pt_null +the array element is unused and the other members' values are undefined. +this lets the program header have ignored entries. +.tp +.br pt_load +the array element specifies a loadable segment, described by +.ir p_filesz +and +.ir p_memsz . +the bytes from the file are mapped to the beginning of the memory +segment. +if the segment's memory size +.ir p_memsz +is larger than the file size +.ir p_filesz , +the +"extra" +bytes are defined to hold the value 0 and to follow the segment's +initialized area. +the file size may not be larger than the memory size. +loadable segment entries in the program header table appear in ascending +order, sorted on the +.ir p_vaddr +member. +.tp +.br pt_dynamic +the array element specifies dynamic linking information. +.tp +.br pt_interp +the array element specifies the location and size of a null-terminated +pathname to invoke as an interpreter. +this segment type is meaningful +only for executable files (though it may occur for shared objects). +however it may not occur more than once in a file. +if it is present, it must precede any loadable segment entry. +.tp +.br pt_note +the array element specifies the location of notes (elfn_nhdr). +.tp +.br pt_shlib +this segment type is reserved but has unspecified semantics. +programs that +contain an array element of this type do not conform to the abi. +.tp +.br pt_phdr +the array element, if present, +specifies the location and size of the program header table itself, +both in the file and in the memory image of the program. +this segment type may not occur more than once in a file. +moreover, it may +occur only if the program header table is part of the memory image of the +program. +if it is present, it must precede any loadable segment entry. +.tp +.br pt_loproc ", " pt_hiproc +values in the inclusive range +.rb [ pt_loproc ", " pt_hiproc ] +are reserved for processor-specific semantics. +.tp +.br pt_gnu_stack +gnu extension which is used by the linux kernel to control the state of the +stack via the flags set in the +.ir p_flags +member. +.re +.tp +.ir p_offset +this member holds the offset from the beginning of the file at which +the first byte of the segment resides. +.tp +.ir p_vaddr +this member holds the virtual address at which the first byte of the +segment resides in memory. +.tp +.ir p_paddr +on systems for which physical addressing is relevant, this member is +reserved for the segment's physical address. +under +bsd +this member is +not used and must be zero. +.tp +.ir p_filesz +this member holds the number of bytes in the file image of the segment. +it may be zero. +.tp +.ir p_memsz +this member holds the number of bytes in the memory image of the segment. +it may be zero. +.tp +.ir p_flags +this member holds a bit mask of flags relevant to the segment: +.rs +.tp +.pd 0 +.br pf_x +an executable segment. +.tp +.br pf_w +a writable segment. +.tp +.br pf_r +a readable segment. +.pd +.re +.ip +a text segment commonly has the flags +.br pf_x +and +.br pf_r . +a data segment commonly has +.br pf_w +and +.br pf_r . +.tp +.ir p_align +this member holds the value to which the segments are aligned in memory +and in the file. +loadable process segments must have congruent values for +.ir p_vaddr +and +.ir p_offset , +modulo the page size. +values of zero and one mean no alignment is required. +otherwise, +.ir p_align +should be a positive, integral power of two, and +.ir p_vaddr +should equal +.ir p_offset , +modulo +.ir p_align . +.\" +.ss section header (shdr) +a file's section header table lets one locate all the file's sections. +the +section header table is an array of +.i elf32_shdr +or +.i elf64_shdr +structures. +the +elf header's +.ir e_shoff +member gives the byte offset from the beginning of the file to the section +header table. +.ir e_shnum +holds the number of entries the section header table contains. +.ir e_shentsize +holds the size in bytes of each entry. +.pp +a section header table index is a subscript into this array. +some section +header table indices are reserved: +the initial entry and the indices between +.b shn_loreserve +and +.br shn_hireserve . +the initial entry is used in elf extensions for +.ir e_phnum , +.ir e_shnum , +and +.ir e_shstrndx ; +in other cases, each field in the initial entry is set to zero. +an object file does not have sections for +these special indices: +.tp +.br shn_undef +this value marks an undefined, missing, irrelevant, +or otherwise meaningless section reference. +.tp +.br shn_loreserve +this value specifies the lower bound of the range of reserved indices. +.tp +.br shn_loproc ", " shn_hiproc +values greater in the inclusive range +.rb [ shn_loproc ", " shn_hiproc ] +are reserved for processor-specific semantics. +.tp +.br shn_abs +this value specifies the absolute value for the corresponding reference. +for +example, a symbol defined relative to section number +.br shn_abs +has an absolute value and is not affected by relocation. +.tp +.br shn_common +symbols defined relative to this section are common symbols, +such as fortran common or unallocated c external variables. +.tp +.br shn_hireserve +this value specifies the upper bound of the range of reserved indices. +the +system reserves indices between +.br shn_loreserve +and +.br shn_hireserve , +inclusive. +the section header table does not contain entries for the +reserved indices. +.pp +the section header has the following structure: +.pp +.in +4n +.ex +typedef struct { + uint32_t sh_name; + uint32_t sh_type; + uint32_t sh_flags; + elf32_addr sh_addr; + elf32_off sh_offset; + uint32_t sh_size; + uint32_t sh_link; + uint32_t sh_info; + uint32_t sh_addralign; + uint32_t sh_entsize; +} elf32_shdr; +.ee +.in +.pp +.in +4n +.ex +typedef struct { + uint32_t sh_name; + uint32_t sh_type; + uint64_t sh_flags; + elf64_addr sh_addr; + elf64_off sh_offset; + uint64_t sh_size; + uint32_t sh_link; + uint32_t sh_info; + uint64_t sh_addralign; + uint64_t sh_entsize; +} elf64_shdr; +.ee +.in +.pp +no real differences exist between the 32-bit and 64-bit section headers. +.tp +.ir sh_name +this member specifies the name of the section. +its value is an index +into the section header string table section, giving the location of +a null-terminated string. +.tp +.ir sh_type +this member categorizes the section's contents and semantics. +.rs +.tp +.br sht_null +this value marks the section header as inactive. +it does not +have an associated section. +other members of the section header +have undefined values. +.tp +.br sht_progbits +this section holds information defined by the program, whose +format and meaning are determined solely by the program. +.tp +.br sht_symtab +this section holds a symbol table. +typically, +.br sht_symtab +provides symbols for link editing, though it may also be used +for dynamic linking. +as a complete symbol table, it may contain +many symbols unnecessary for dynamic linking. +an object file can +also contain a +.br sht_dynsym +section. +.tp +.br sht_strtab +this section holds a string table. +an object file may have multiple +string table sections. +.tp +.br sht_rela +this section holds relocation entries with explicit addends, such +as type +.ir elf32_rela +for the 32-bit class of object files. +an object may have multiple +relocation sections. +.tp +.br sht_hash +this section holds a symbol hash table. +an object participating in +dynamic linking must contain a symbol hash table. +an object file may +have only one hash table. +.tp +.br sht_dynamic +this section holds information for dynamic linking. +an object file may +have only one dynamic section. +.tp +.br sht_note +this section holds notes (elfn_nhdr). +.tp +.br sht_nobits +a section of this type occupies no space in the file but otherwise +resembles +.br sht_progbits . +although this section contains no bytes, the +.ir sh_offset +member contains the conceptual file offset. +.tp +.br sht_rel +this section holds relocation offsets without explicit addends, such +as type +.ir elf32_rel +for the 32-bit class of object files. +an object file may have multiple +relocation sections. +.tp +.br sht_shlib +this section is reserved but has unspecified semantics. +.tp +.br sht_dynsym +this section holds a minimal set of dynamic linking symbols. +an +object file can also contain a +.br sht_symtab +section. +.tp +.br sht_loproc ", " sht_hiproc +values in the inclusive range +.rb [ sht_loproc ", " sht_hiproc ] +are reserved for processor-specific semantics. +.tp +.br sht_louser +this value specifies the lower bound of the range of indices reserved for +application programs. +.tp +.br sht_hiuser +this value specifies the upper bound of the range of indices reserved for +application programs. +section types between +.br sht_louser +and +.br sht_hiuser +may be used by the application, without conflicting with current or future +system-defined section types. +.re +.tp +.ir sh_flags +sections support one-bit flags that describe miscellaneous attributes. +if a flag bit is set in +.ir sh_flags , +the attribute is +"on" +for the section. +otherwise, the attribute is +"off" +or does not apply. +undefined attributes are set to zero. +.rs +.tp +.br shf_write +this section contains data that should be writable during process +execution. +.tp +.br shf_alloc +this section occupies memory during process execution. +some control +sections do not reside in the memory image of an object file. +this +attribute is off for those sections. +.tp +.br shf_execinstr +this section contains executable machine instructions. +.tp +.br shf_maskproc +all bits included in this mask are reserved for processor-specific +semantics. +.re +.tp +.ir sh_addr +if this section appears in the memory image of a process, this member +holds the address at which the section's first byte should reside. +otherwise, the member contains zero. +.tp +.ir sh_offset +this member's value holds the byte offset from the beginning of the file +to the first byte in the section. +one section type, +.br sht_nobits , +occupies no space in the file, and its +.ir sh_offset +member locates the conceptual placement in the file. +.tp +.ir sh_size +this member holds the section's size in bytes. +unless the section type +is +.br sht_nobits , +the section occupies +.ir sh_size +bytes in the file. +a section of type +.br sht_nobits +may have a nonzero size, but it occupies no space in the file. +.tp +.ir sh_link +this member holds a section header table index link, whose interpretation +depends on the section type. +.tp +.ir sh_info +this member holds extra information, whose interpretation depends on the +section type. +.tp +.ir sh_addralign +some sections have address alignment constraints. +if a section holds a +doubleword, the system must ensure doubleword alignment for the entire +section. +that is, the value of +.ir sh_addr +must be congruent to zero, modulo the value of +.ir sh_addralign . +only zero and positive integral powers of two are allowed. +the value 0 or 1 means that the section has no alignment constraints. +.tp +.ir sh_entsize +some sections hold a table of fixed-sized entries, such as a symbol table. +for such a section, this member gives the size in bytes for each entry. +this member contains zero if the section does not hold a table of +fixed-size entries. +.pp +various sections hold program and control information: +.tp +.ir .bss +this section holds uninitialized data that contributes to the program's +memory image. +by definition, the system initializes the data with zeros +when the program begins to run. +this section is of type +.br sht_nobits . +the attribute types are +.br shf_alloc +and +.br shf_write . +.tp +.ir .comment +this section holds version control information. +this section is of type +.br sht_progbits . +no attribute types are used. +.tp +.ir .ctors +this section holds initialized pointers to the c++ constructor functions. +this section is of type +.br sht_progbits . +the attribute types are +.br shf_alloc +and +.br shf_write . +.tp +.ir .data +this section holds initialized data that contribute to the program's +memory image. +this section is of type +.br sht_progbits . +the attribute types are +.br shf_alloc +and +.br shf_write . +.tp +.ir .data1 +this section holds initialized data that contribute to the program's +memory image. +this section is of type +.br sht_progbits . +the attribute types are +.br shf_alloc +and +.br shf_write . +.tp +.ir .debug +this section holds information for symbolic debugging. +the contents +are unspecified. +this section is of type +.br sht_progbits . +no attribute types are used. +.tp +.ir .dtors +this section holds initialized pointers to the c++ destructor functions. +this section is of type +.br sht_progbits . +the attribute types are +.br shf_alloc +and +.br shf_write . +.tp +.ir .dynamic +this section holds dynamic linking information. +the section's attributes +will include the +.br shf_alloc +bit. +whether the +.br shf_write +bit is set is processor-specific. +this section is of type +.br sht_dynamic . +see the attributes above. +.tp +.ir .dynstr +this section holds strings needed for dynamic linking, most commonly +the strings that represent the names associated with symbol table entries. +this section is of type +.br sht_strtab . +the attribute type used is +.br shf_alloc . +.tp +.ir .dynsym +this section holds the dynamic linking symbol table. +this section is of type +.br sht_dynsym . +the attribute used is +.br shf_alloc . +.tp +.ir .fini +this section holds executable instructions that contribute to the process +termination code. +when a program exits normally the system arranges to +execute the code in this section. +this section is of type +.br sht_progbits . +the attributes used are +.br shf_alloc +and +.br shf_execinstr . +.tp +.ir .gnu.version +this section holds the version symbol table, an array of +.i elfn_half +elements. +this section is of type +.br sht_gnu_versym . +the attribute type used is +.br shf_alloc . +.tp +.ir .gnu.version_d +this section holds the version symbol definitions, a table of +.i elfn_verdef +structures. +this section is of type +.br sht_gnu_verdef . +the attribute type used is +.br shf_alloc . +.tp +.ir .gnu.version_r +this section holds the version symbol needed elements, a table of +.i elfn_verneed +structures. +this section is of +type +.br sht_gnu_versym . +the attribute type used is +.br shf_alloc . +.tp +.ir .got +this section holds the global offset table. +this section is of type +.br sht_progbits . +the attributes are processor-specific. +.tp +.ir .hash +this section holds a symbol hash table. +this section is of type +.br sht_hash . +the attribute used is +.br shf_alloc . +.tp +.ir .init +this section holds executable instructions that contribute to the process +initialization code. +when a program starts to run the system arranges to execute +the code in this section before calling the main program entry point. +this section is of type +.br sht_progbits . +the attributes used are +.br shf_alloc +and +.br shf_execinstr . +.tp +.ir .interp +this section holds the pathname of a program interpreter. +if the file has +a loadable segment that includes the section, the section's attributes will +include the +.br shf_alloc +bit. +otherwise, that bit will be off. +this section is of type +.br sht_progbits . +.tp +.ir .line +this section holds line number information for symbolic debugging, +which describes the correspondence between the program source and +the machine code. +the contents are unspecified. +this section is of type +.br sht_progbits . +no attribute types are used. +.tp +.ir .note +this section holds various notes. +this section is of type +.br sht_note . +no attribute types are used. +.tp +.ir .note.abi\-tag +this section is used to declare the expected run-time abi of the elf image. +it may include the operating system name and its run-time versions. +this section is of type +.br sht_note . +the only attribute used is +.br shf_alloc . +.tp +.ir .note.gnu.build\-id +this section is used to hold an id that uniquely identifies +the contents of the elf image. +different files with the same build id should contain the same executable +content. +see the +.br \-\-build\-id +option to the gnu linker (\fbld\fr (1)) for more details. +this section is of type +.br sht_note . +the only attribute used is +.br shf_alloc . +.tp +.ir .note.gnu\-stack +this section is used in linux object files for declaring stack attributes. +this section is of type +.br sht_progbits . +the only attribute used is +.br shf_execinstr . +this indicates to the gnu linker that the object file requires an +executable stack. +.tp +.ir .note.openbsd.ident +openbsd native executables usually contain this section +to identify themselves so the kernel can bypass any compatibility +elf binary emulation tests when loading the file. +.tp +.ir .plt +this section holds the procedure linkage table. +this section is of type +.br sht_progbits . +the attributes are processor-specific. +.tp +.ir .relname +this section holds relocation information as described below. +if the file +has a loadable segment that includes relocation, the section's attributes +will include the +.br shf_alloc +bit. +otherwise, the bit will be off. +by convention, +"name" +is supplied by the section to which the relocations apply. +thus a relocation +section for +.br .text +normally would have the name +.br .rel.text . +this section is of type +.br sht_rel . +.tp +.ir .relaname +this section holds relocation information as described below. +if the file +has a loadable segment that includes relocation, the section's attributes +will include the +.br shf_alloc +bit. +otherwise, the bit will be off. +by convention, +"name" +is supplied by the section to which the relocations apply. +thus a relocation +section for +.br .text +normally would have the name +.br .rela.text . +this section is of type +.br sht_rela . +.tp +.ir .rodata +this section holds read-only data that typically contributes to a +nonwritable segment in the process image. +this section is of type +.br sht_progbits . +the attribute used is +.br shf_alloc . +.tp +.ir .rodata1 +this section holds read-only data that typically contributes to a +nonwritable segment in the process image. +this section is of type +.br sht_progbits . +the attribute used is +.br shf_alloc . +.tp +.ir .shstrtab +this section holds section names. +this section is of type +.br sht_strtab . +no attribute types are used. +.tp +.ir .strtab +this section holds strings, most commonly the strings that represent the +names associated with symbol table entries. +if the file has a loadable +segment that includes the symbol string table, the section's attributes +will include the +.br shf_alloc +bit. +otherwise, the bit will be off. +this section is of type +.br sht_strtab . +.tp +.ir .symtab +this section holds a symbol table. +if the file has a loadable segment +that includes the symbol table, the section's attributes will include +the +.br shf_alloc +bit. +otherwise, the bit will be off. +this section is of type +.br sht_symtab . +.tp +.ir .text +this section holds the +"text", +or executable instructions, of a program. +this section is of type +.br sht_progbits . +the attributes used are +.br shf_alloc +and +.br shf_execinstr . +.\" +.ss string and symbol tables +string table sections hold null-terminated character sequences, commonly +called strings. +the object file uses these strings to represent symbol +and section names. +one references a string as an index into the string +table section. +the first byte, which is index zero, is defined to hold +a null byte (\(aq\e0\(aq). +similarly, a string table's last byte is defined to +hold a null byte, ensuring null termination for all strings. +.pp +an object file's symbol table holds information needed to locate and +relocate a program's symbolic definitions and references. +a symbol table +index is a subscript into this array. +.pp +.in +4n +.ex +typedef struct { + uint32_t st_name; + elf32_addr st_value; + uint32_t st_size; + unsigned char st_info; + unsigned char st_other; + uint16_t st_shndx; +} elf32_sym; +.ee +.in +.pp +.in +4n +.ex +typedef struct { + uint32_t st_name; + unsigned char st_info; + unsigned char st_other; + uint16_t st_shndx; + elf64_addr st_value; + uint64_t st_size; +} elf64_sym; +.ee +.in +.pp +the 32-bit and 64-bit versions have the same members, just in a different +order. +.tp +.ir st_name +this member holds an index into the object file's symbol string table, +which holds character representations of the symbol names. +if the value +is nonzero, it represents a string table index that gives the symbol +name. +otherwise, the symbol has no name. +.tp +.ir st_value +this member gives the value of the associated symbol. +.tp +.ir st_size +many symbols have associated sizes. +this member holds zero if the symbol +has no size or an unknown size. +.tp +.ir st_info +this member specifies the symbol's type and binding attributes: +.rs +.tp +.br stt_notype +the symbol's type is not defined. +.tp +.br stt_object +the symbol is associated with a data object. +.tp +.br stt_func +the symbol is associated with a function or other executable code. +.tp +.br stt_section +the symbol is associated with a section. +symbol table entries of +this type exist primarily for relocation and normally have +.br stb_local +bindings. +.tp +.br stt_file +by convention, the symbol's name gives the name of the source file +associated with the object file. +a file symbol has +.br stb_local +bindings, its section index is +.br shn_abs , +and it precedes the other +.br stb_local +symbols of the file, if it is present. +.tp +.br stt_loproc ", " stt_hiproc +values in the inclusive range +.rb [ stt_loproc ", " stt_hiproc ] +are reserved for processor-specific semantics. +.tp +.br stb_local +local symbols are not visible outside the object file containing their +definition. +local symbols of the same name may exist in multiple files +without interfering with each other. +.tp +.br stb_global +global symbols are visible to all object files being combined. +one file's +definition of a global symbol will satisfy another file's undefined +reference to the same symbol. +.tp +.br stb_weak +weak symbols resemble global symbols, but their definitions have lower +precedence. +.tp +.br stb_loproc ", " stb_hiproc +values in the inclusive range +.rb [ stb_loproc ", " stb_hiproc ] +are reserved for processor-specific semantics. +.re +.ip +there are macros for packing and unpacking the binding and type fields: +.rs +.tp +.br elf32_st_bind( \fiinfo\fp ) ", " elf64_st_bind( \fiinfo\fp ) +extract a binding from an +.i st_info +value. +.tp +.br elf32_st_type( \fiinfo ) ", " elf64_st_type( \fiinfo\fp ) +extract a type from an +.i st_info +value. +.tp +.br elf32_st_info( \fibind\fp ", " \fitype\fp ) ", " \ +elf64_st_info( \fibind\fp ", " \fitype\fp ) +convert a binding and a type into an +.i st_info +value. +.re +.tp +.ir st_other +this member defines the symbol visibility. +.rs +.tp +.pd 0 +.br stv_default +default symbol visibility rules. +global and weak symbols are available to other modules; +references in the local module can be interposed +by definitions in other modules. +.tp +.br stv_internal +processor-specific hidden class. +.tp +.br stv_hidden +symbol is unavailable to other modules; +references in the local module always resolve to the local symbol +(i.e., the symbol can't be interposed by definitions in other modules). +.tp +.br stv_protected +symbol is available to other modules, +but references in the local module always resolve to the local symbol. +.pd +.pp +there are macros for extracting the visibility type: +.pp +.br elf32_st_visibility (other) +or +.br elf64_st_visibility (other) +.re +.tp +.ir st_shndx +every symbol table entry is +"defined" +in relation to some section. +this member holds the relevant section +header table index. +.\" +.ss relocation entries (rel & rela) +relocation is the process of connecting symbolic references with +symbolic definitions. +relocatable files must have information that +describes how to modify their section contents, thus allowing executable +and shared object files to hold the right information for a process's +program image. +relocation entries are these data. +.pp +relocation structures that do not need an addend: +.pp +.in +4n +.ex +typedef struct { + elf32_addr r_offset; + uint32_t r_info; +} elf32_rel; +.ee +.in +.pp +.in +4n +.ex +typedef struct { + elf64_addr r_offset; + uint64_t r_info; +} elf64_rel; +.ee +.in +.pp +relocation structures that need an addend: +.pp +.in +4n +.ex +typedef struct { + elf32_addr r_offset; + uint32_t r_info; + int32_t r_addend; +} elf32_rela; +.ee +.in +.pp +.in +4n +.ex +typedef struct { + elf64_addr r_offset; + uint64_t r_info; + int64_t r_addend; +} elf64_rela; +.ee +.in +.tp +.ir r_offset +this member gives the location at which to apply the relocation action. +for a relocatable file, the value is the byte offset from the beginning +of the section to the storage unit affected by the relocation. +for an +executable file or shared object, the value is the virtual address of +the storage unit affected by the relocation. +.tp +.ir r_info +this member gives both the symbol table index with respect to which the +relocation must be made and the type of relocation to apply. +relocation +types are processor-specific. +when the text refers to a relocation +entry's relocation type or symbol table index, it means the result of +applying +.br elf[32|64]_r_type +or +.br elf[32|64]_r_sym , +respectively, to the entry's +.ir r_info +member. +.tp +.ir r_addend +this member specifies a constant addend used to compute the value to be +stored into the relocatable field. +.\" +.ss dynamic tags (dyn) +the +.i .dynamic +section contains a series of structures that hold relevant +dynamic linking information. +the +.i d_tag +member controls the interpretation +of +.ir d_un . +.pp +.in +4n +.ex +typedef struct { + elf32_sword d_tag; + union { + elf32_word d_val; + elf32_addr d_ptr; + } d_un; +} elf32_dyn; +extern elf32_dyn _dynamic[]; +.ee +.in +.pp +.in +4n +.ex +typedef struct { + elf64_sxword d_tag; + union { + elf64_xword d_val; + elf64_addr d_ptr; + } d_un; +} elf64_dyn; +extern elf64_dyn _dynamic[]; +.ee +.in +.tp +.ir d_tag +this member may have any of the following values: +.rs +.tp 12 +.br dt_null +marks end of dynamic section +.tp +.br dt_needed +string table offset to name of a needed library +.tp +.br dt_pltrelsz +size in bytes of plt relocation entries +.tp +.br dt_pltgot +address of plt and/or got +.tp +.br dt_hash +address of symbol hash table +.tp +.br dt_strtab +address of string table +.tp +.br dt_symtab +address of symbol table +.tp +.br dt_rela +address of rela relocation table +.tp +.br dt_relasz +size in bytes of the rela relocation table +.tp +.br dt_relaent +size in bytes of a rela relocation table entry +.tp +.br dt_strsz +size in bytes of string table +.tp +.br dt_syment +size in bytes of a symbol table entry +.tp +.br dt_init +address of the initialization function +.tp +.br dt_fini +address of the termination function +.tp +.br dt_soname +string table offset to name of shared object +.tp +.br dt_rpath +string table offset to library search path (deprecated) +.tp +.br dt_symbolic +alert linker to search this shared object before the executable for symbols +.tp +.br dt_rel +address of rel relocation table +.tp +.br dt_relsz +size in bytes of rel relocation table +.tp +.br dt_relent +size in bytes of a rel table entry +.tp +.br dt_pltrel +type of relocation entry to which the plt refers (rela or rel) +.tp +.br dt_debug +undefined use for debugging +.tp +.br dt_textrel +absence of this entry indicates that no relocation entries should +apply to a nonwritable segment +.tp +.br dt_jmprel +address of relocation entries associated solely with the plt +.tp +.br dt_bind_now +instruct dynamic linker to process all relocations before +transferring control to the executable +.tp +.br dt_runpath +string table offset to library search path +.tp +.br dt_loproc ", " dt_hiproc +values in the inclusive range +.rb [ dt_loproc ", " dt_hiproc ] +are reserved for processor-specific semantics +.re +.tp +.ir d_val +this member represents integer values with various interpretations. +.tp +.ir d_ptr +this member represents program virtual addresses. +when interpreting +these addresses, the actual address should be computed based on the +original file value and memory base address. +files do not contain +relocation entries to fixup these addresses. +.tp +.i _dynamic +array containing all the dynamic structures in the +.i .dynamic +section. +this is automatically populated by the linker. +.\" gabi elf reference for note sections: +.\" http://www.sco.com/developers/gabi/latest/ch5.pheader.html#note_section +.\" +.\" note that it implies the sizes and alignments of notes depend on the elf +.\" size (e.g. 32-bit elfs have three 4-byte words and use 4-byte alignment +.\" while 64-bit elfs use 8-byte words & alignment), but that is not the case +.\" in the real world. notes always have three 4-byte words as can be seen +.\" in the source links below (remember that elf64_word is a 32-bit quantity). +.\" glibc: https://sourceware.org/git/?p=glibc.git;a=blob;f=elf/elf.h;h=9e59b3275917549af0cebe1f2de9ded3b7b10bf2#l1173 +.\" binutils: https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=binutils/readelf.c;h=274ddd17266aef6e4ad1f67af8a13a21500ff2af#l15943 +.\" linux: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/elf.h?h=v4.8#n422 +.\" solaris: https://docs.oracle.com/cd/e23824_01/html/819-0690/chapter6-18048.html +.\" freebsd: https://svnweb.freebsd.org/base/head/sys/sys/elf_common.h?revision=303677&view=markup#l33 +.\" netbsd: https://www.netbsd.org/docs/kernel/elf-notes.html +.\" openbsd: https://github.com/openbsd/src/blob/master/sys/sys/exec_elf.h#l533 +.\" +.ss notes (nhdr) +elf notes allow for appending arbitrary information for the system to use. +they are largely used by core files +.ri ( e_type +of +.br et_core ), +but many projects define their own set of extensions. +for example, +the gnu tool chain uses elf notes to pass information from +the linker to the c library. +.pp +note sections contain a series of notes (see the +.i struct +definitions below). +each note is followed by the name field (whose length is defined in +\fin_namesz\fr) and then by the descriptor field (whose length is defined in +\fin_descsz\fr) and whose starting address has a 4 byte alignment. +neither field is defined in the note struct due to their arbitrary lengths. +.pp +an example for parsing out two consecutive notes should clarify their layout +in memory: +.pp +.in +4n +.ex +void *memory, *name, *desc; +elf64_nhdr *note, *next_note; + +/* the buffer is pointing to the start of the section/segment. */ +note = memory; + +/* if the name is defined, it follows the note. */ +name = note\->n_namesz == 0 ? null : memory + sizeof(*note); + +/* if the descriptor is defined, it follows the name + (with alignment). */ + +desc = note\->n_descsz == 0 ? null : + memory + sizeof(*note) + align_up(note\->n_namesz, 4); + +/* the next note follows both (with alignment). */ +next_note = memory + sizeof(*note) + + align_up(note\->n_namesz, 4) + + align_up(note\->n_descsz, 4); +.ee +.in +.pp +keep in mind that the interpretation of +.i n_type +depends on the namespace defined by the +.i n_namesz +field. +if the +.i n_namesz +field is not set (e.g., is 0), then there are two sets of notes: +one for core files and one for all other elf types. +if the namespace is unknown, then tools will usually fallback to these sets +of notes as well. +.pp +.in +4n +.ex +typedef struct { + elf32_word n_namesz; + elf32_word n_descsz; + elf32_word n_type; +} elf32_nhdr; +.ee +.in +.pp +.in +4n +.ex +typedef struct { + elf64_word n_namesz; + elf64_word n_descsz; + elf64_word n_type; +} elf64_nhdr; +.ee +.in +.tp +.ir n_namesz +the length of the name field in bytes. +the contents will immediately follow this note in memory. +the name is null terminated. +for example, if the name is "gnu", then +.i n_namesz +will be set to 4. +.tp +.ir n_descsz +the length of the descriptor field in bytes. +the contents will immediately follow the name field in memory. +.tp +.ir n_type +depending on the value of the name field, this member may have any of the +following values: +.rs +.tp 5 +.b core files (e_type = et_core) +notes used by all core files. +these are highly operating system or architecture specific and often require +close coordination with kernels, c libraries, and debuggers. +these are used when the namespace is the default (i.e., +.i n_namesz +will be set to 0), or a fallback when the namespace is unknown. +.rs +.tp 21 +.pd 0 +.b nt_prstatus +prstatus struct +.tp +.b nt_fpregset +fpregset struct +.tp +.b nt_prpsinfo +prpsinfo struct +.tp +.b nt_prxreg +prxregset struct +.tp +.b nt_taskstruct +task structure +.tp +.b nt_platform +string from sysinfo(si_platform) +.tp +.b nt_auxv +auxv array +.tp +.b nt_gwindows +gwindows struct +.tp +.b nt_asrs +asrset struct +.tp +.b nt_pstatus +pstatus struct +.tp +.b nt_psinfo +psinfo struct +.tp +.b nt_prcred +prcred struct +.tp +.b nt_utsname +utsname struct +.tp +.b nt_lwpstatus +lwpstatus struct +.tp +.b nt_lwpsinfo +lwpinfo struct +.tp +.b nt_prfpxreg +fprxregset struct +.tp +.b nt_siginfo +siginfo_t (size might increase over time) +.tp +.b nt_file +contains information about mapped files +.tp +.b nt_prxfpreg +user_fxsr_struct +.tp +.b nt_ppc_vmx +powerpc altivec/vmx registers +.tp +.b nt_ppc_spe +powerpc spe/evr registers +.tp +.b nt_ppc_vsx +powerpc vsx registers +.tp +.b nt_386_tls +i386 tls slots (struct user_desc) +.tp +.b nt_386_ioperm +x86 io permission bitmap (1=deny) +.tp +.b nt_x86_xstate +x86 extended state using xsave +.tp +.b nt_s390_high_gprs +s390 upper register halves +.tp +.b nt_s390_timer +s390 timer register +.tp +.b nt_s390_todcmp +s390 time-of-day (tod) clock comparator register +.tp +.b nt_s390_todpreg +s390 time-of-day (tod) programmable register +.tp +.b nt_s390_ctrs +s390 control registers +.tp +.b nt_s390_prefix +s390 prefix register +.tp +.b nt_s390_last_break +s390 breaking event address +.tp +.b nt_s390_system_call +s390 system call restart data +.tp +.b nt_s390_tdb +s390 transaction diagnostic block +.tp +.b nt_arm_vfp +arm vfp/neon registers +.tp +.b nt_arm_tls +arm tls register +.tp +.b nt_arm_hw_break +arm hardware breakpoint registers +.tp +.b nt_arm_hw_watch +arm hardware watchpoint registers +.tp +.b nt_arm_system_call +arm system call number +.pd +.re +.tp +.b n_name = gnu +extensions used by the gnu tool chain. +.rs +.tp +.b nt_gnu_abi_tag +operating system (os) abi information. +the desc field will be 4 words: +.ip +.pd 0 +.rs +.ip \(bu 2 +word 0: os descriptor +(\fbelf_note_os_linux\fr, \fbelf_note_os_gnu\fr, and so on)` +.ip \(bu +word 1: major version of the abi +.ip \(bu +word 2: minor version of the abi +.ip \(bu +word 3: subminor version of the abi +.re +.pd +.tp +.b nt_gnu_hwcap +synthetic hwcap information. +the desc field begins with two words: +.ip +.pd 0 +.rs +.ip \(bu 2 +word 0: number of entries +.ip \(bu +word 1: bit mask of enabled entries +.re +.pd +.ip +then follow variable-length entries, one byte followed by a null-terminated +hwcap name string. +the byte gives the bit number to test if enabled, (1u << bit) & bit mask. +.tp +.b nt_gnu_build_id +unique build id as generated by the gnu +.br ld (1) +.br \-\-build\-id +option. +the desc consists of any nonzero number of bytes. +.tp +.b nt_gnu_gold_version +the desc contains the gnu gold linker version used. +.re +.tp +.b default/unknown namespace (e_type != et_core) +these are used when the namespace is the default (i.e., +.i n_namesz +will be set to 0), or a fallback when the namespace is unknown. +.rs +.tp 12 +.pd 0 +.b nt_version +a version string of some sort. +.tp +.b nt_arch +architecture information. +.pd +.re +.re +.sh notes +.\" openbsd +.\" elf support first appeared in +.\" openbsd 1.2, +.\" although not all supported platforms use it as the native +.\" binary file format. +elf first appeared in +system v. +the elf format is an adopted standard. +.pp +the extensions for +.ir e_phnum , +.ir e_shnum , +and +.ir e_shstrndx +respectively are +linux extensions. +sun, bsd, and amd64 also support them; for further information, +look under see also. +.\" .sh authors +.\" the original version of this manual page was written by +.\" .an jeroen ruigrok van der werven +.\" .aq asmodai@freebsd.org +.\" with inspiration from bsdi's +.\" .bsx +.\" .nm elf +.\" man page. +.sh see also +.br as (1), +.br elfedit (1), +.br gdb (1), +.br ld (1), +.br nm (1), +.br objcopy (1), +.br objdump (1), +.br patchelf (1), +.br readelf (1), +.br size (1), +.br strings (1), +.br strip (1), +.br execve (2), +.br dl_iterate_phdr (3), +.br core (5), +.br ld.so (8) +.pp +hewlett-packard, +.ir "elf-64 object file format" . +.pp +santa cruz operation, +.ir "system v application binary interface" . +.pp +unix system laboratories, +"object files", +.ir "executable and linking format (elf)" . +.pp +sun microsystems, +.ir "linker and libraries guide" . +.pp +amd64 abi draft, +.ir "system v application binary interface amd64 architecture processor supplement" . +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2008, linux foundation, written by michael kerrisk +.\" +.\" and copyright 2003,2004 andi kleen, suse labs. +.\" numa_maps material copyright (c) 2005 silicon graphics incorporated. +.\" christoph lameter, . +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th numa 7 2021-03-22 "linux" "linux programmer's manual" +.sh name +numa \- overview of non-uniform memory architecture +.sh description +non-uniform memory access (numa) refers to multiprocessor systems +whose memory is divided into multiple memory nodes. +the access time of a memory node depends on +the relative locations of the accessing cpu and the accessed node. +(this contrasts with a symmetric multiprocessor system, +where the access time for all of the memory is the same for all cpus.) +normally, each cpu on a numa system has a local memory node whose +contents can be accessed faster than the memory in +the node local to another cpu +or the memory on a bus shared by all cpus. +.ss numa system calls +the linux kernel implements the following numa-related system calls: +.br get_mempolicy (2), +.br mbind (2), +.br migrate_pages (2), +.br move_pages (2), +and +.br set_mempolicy (2). +however, applications should normally use the interface provided by +.ir libnuma ; +see "library support" below. +.ss /proc/[number]/numa_maps (since linux 2.6.14) +.\" see also changelog-2.6.14 +this file displays information about a process's +numa memory policy and allocation. +.pp +each line contains information about a memory range used by the process, +displaying\(emamong other information\(emthe effective memory policy for +that memory range and on which nodes the pages have been allocated. +.pp +.i numa_maps +is a read-only file. +when +.i /proc//numa_maps +is read, the kernel will scan the virtual address space of the +process and report how memory is used. +one line is displayed for each unique memory range of the process. +.pp +the first field of each line shows the starting address of the memory range. +this field allows a correlation with the contents of the +.i /proc//maps +file, +which contains the end address of the range and other information, +such as the access permissions and sharing. +.pp +the second field shows the memory policy currently in effect for the +memory range. +note that the effective policy is not necessarily the policy +installed by the process for that memory range. +specifically, if the process installed a "default" policy for that range, +the effective policy for that range will be the process policy, +which may or may not be "default". +.pp +the rest of the line contains information about the pages allocated in +the memory range, as follows: +.tp +.i n= +the number of pages allocated on +.ir . +.i +includes only pages currently mapped by the process. +page migration and memory reclaim may have temporarily unmapped pages +associated with this memory range. +these pages may show up again only after the process has +attempted to reference them. +if the memory range represents a shared memory area or file mapping, +other processes may currently have additional pages mapped in a +corresponding memory range. +.tp +.i file= +the file backing the memory range. +if the file is mapped as private, write accesses may have generated +cow (copy-on-write) pages in this memory range. +these pages are displayed as anonymous pages. +.tp +.i heap +memory range is used for the heap. +.tp +.i stack +memory range is used for the stack. +.tp +.i huge +huge memory range. +the page counts shown are huge pages and not regular sized pages. +.tp +.i anon= +the number of anonymous page in the range. +.tp +.i dirty= +number of dirty pages. +.tp +.i mapped= +total number of mapped pages, if different from +.ir dirty +and +.i anon +pages. +.tp +.i mapmax= +maximum mapcount (number of processes mapping a single page) encountered +during the scan. +this may be used as an indicator of the degree of sharing occurring in a +given memory range. +.tp +.i swapcache= +number of pages that have an associated entry on a swap device. +.tp +.i active= +the number of pages on the active list. +this field is shown only if different from the number of pages in this range. +this means that some inactive pages exist in the memory range that may be +removed from memory by the swapper soon. +.tp +.i writeback= +number of pages that are currently being written out to disk. +.sh conforming to +no standards govern numa interfaces. +.sh notes +the linux numa system calls and +.i /proc +interface are available only +if the kernel was configured and built with the +.br config_numa +option. +.ss library support +link with \fi\-lnuma\fp +to get the system call definitions. +.i libnuma +and the required +.i +header are available in the +.i numactl +package. +.pp +however, applications should not use these system calls directly. +instead, the higher level interface provided by the +.br numa (3) +functions in the +.i numactl +package is recommended. +the +.i numactl +package is available at +.ur ftp://oss.sgi.com\:/www\:/projects\:/libnuma\:/download/ +.ue . +the package is also included in some linux distributions. +some distributions include the development library and header +in the separate +.i numactl\-devel +package. +.sh see also +.br get_mempolicy (2), +.br mbind (2), +.br move_pages (2), +.br set_mempolicy (2), +.br numa (3), +.br cpuset (7), +.br numactl (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1993 +.\" the regents of the university of california. all rights reserved. +.\" and copyright (c) 2020 by alejandro colomar +.\" +.\" %%%license_start(bsd_3_clause_ucb) +.\" redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. neither the name of the university nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" this software is provided by the regents and contributors ``as is'' and +.\" any express or implied warranties, including, but not limited to, the +.\" implied warranties of merchantability and fitness for a particular purpose +.\" are disclaimed. in no event shall the regents or contributors be liable +.\" for any direct, indirect, incidental, special, exemplary, or consequential +.\" damages (including, but not limited to, procurement of substitute goods +.\" or services; loss of use, data, or profits; or business interruption) +.\" however caused and on any theory of liability, whether in contract, strict +.\" liability, or tort (including negligence or otherwise) arising in any way +.\" out of the use of this software, even if advised of the possibility of +.\" such damage. +.\" %%%license_end +.\" +.\" +.th circleq 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +circleq_empty, +circleq_entry, +circleq_first, +circleq_foreach, +circleq_foreach_reverse, +circleq_head, +circleq_head_initializer, +circleq_init, +circleq_insert_after, +circleq_insert_before, +circleq_insert_head, +circleq_insert_tail, +circleq_last, +circleq_loop_next, +circleq_loop_prev, +circleq_next, +circleq_prev, +circleq_remove +\- implementation of a doubly linked circular queue +.sh synopsis +.nf +.b #include +.pp +.b circleq_entry(type); +.pp +.b circleq_head(headname, type); +.bi "circleq_head circleq_head_initializer(circleq_head " head ); +.bi "void circleq_init(circleq_head *" head ); +.pp +.bi "int circleq_empty(circleq_head *" head ); +.pp +.bi "void circleq_insert_head(circleq_head *" head , +.bi " struct type *" elm ", circleq_entry " name ); +.bi "void circleq_insert_tail(circleq_head *" head , +.bi " struct type *" elm ", circleq_entry " name ); +.bi "void circleq_insert_before(circleq_head *" head ", struct type *" listelm , +.bi " struct type *" elm ", circleq_entry " name ); +.bi "void circleq_insert_after(circleq_head *" head ", struct type *" listelm , +.bi " struct type *" elm ", circleq_entry " name ); +.pp +.bi "struct type *circleq_first(circleq_head *" head ); +.bi "struct type *circleq_last(circleq_head *" head ); +.bi "struct type *circleq_prev(struct type *" elm ", circleq_entry " name ); +.bi "struct type *circleq_next(struct type *" elm ", circleq_entry " name ); +.bi "struct type *circleq_loop_prev(circleq_head *" head , +.bi " struct type *" elm ", circleq_entry " name ); +.bi "struct type *circleq_loop_next(circleq_head *" head , +.bi " struct type *" elm ", circleq_entry " name ); +.pp +.bi "circleq_foreach(struct type *" var ", circleq_head *" head , +.bi " circleq_entry " name ); +.bi "circleq_foreach_reverse(struct type *" var ", circleq_head *" head , +.bi " circleq_entry " name ); +.pp +.bi "void circleq_remove(circleq_head *" head ", struct type *" elm , +.bi " circleq_entry " name ); +.fi +.sh description +these macros define and operate on doubly linked circular queues. +.pp +in the macro definitions, +.i type +is the name of a user-defined structure, +that must contain a field of type +.ir circleq_entry , +named +.ir name . +the argument +.i headname +is the name of a user-defined structure +that must be declared using the macro +.br circleq_head (). +.ss creation +a circular queue is headed by a structure defined by the +.br circleq_head () +macro. +this structure contains a pair of pointers, +one to the first element in the queue +and the other to the last element in the queue. +the elements are doubly linked +so that an arbitrary element can be removed without traversing the queue. +new elements can be added to the queue +after an existing element, +before an existing element, +at the head of the queue, +or at the end of the queue. +a +.i circleq_head +structure is declared as follows: +.pp +.in +4 +.ex +circleq_head(headname, type) head; +.ee +.in +.pp +where +.i struct headname +is the structure to be defined, and +.i struct type +is the type of the elements to be linked into the queue. +a pointer to the head of the queue can later be declared as: +.pp +.in +4 +.ex +struct headname *headp; +.ee +.in +.pp +(the names +.i head +and +.i headp +are user selectable.) +.pp +.br circleq_entry () +declares a structure that connects the elements in the queue. +.pp +.br circleq_head_initializer () +evaluates to an initializer for the queue +.ir head . +.pp +.br circleq_init () +initializes the queue referenced by +.ir head . +.pp +.br circleq_empty () +evaluates to true if there are no items on the queue. +.ss insertion +.br circleq_insert_head () +inserts the new element +.i elm +at the head of the queue. +.pp +.br circleq_insert_tail () +inserts the new element +.i elm +at the end of the queue. +.pp +.br circleq_insert_before () +inserts the new element +.i elm +before the element +.ir listelm . +.pp +.br circleq_insert_after () +inserts the new element +.i elm +after the element +.ir listelm . +.ss traversal +.br circleq_first () +returns the first item on the queue. +.pp +.br circleq_last () +returns the last item on the queue. +.pp +.br circleq_prev () +returns the previous item on the queue, or +.i &head +if this item is the first one. +.pp +.br circleq_next () +returns the next item on the queue, or +.i &head +if this item is the last one. +.pp +.br circleq_loop_prev () +returns the previous item on the queue. +if +.i elm +is the first element on the queue, the last element is returned. +.pp +.br circleq_loop_next () +returns the next item on the queue. +if +.i elm +is the last element on the queue, the first element is returned. +.pp +.br circleq_foreach () +traverses the queue referenced by +.i head +in the forward direction, assigning each element in turn to +.ir var . +.i var +is set to +.i &head +if the loop completes normally, or if there were no elements. +.pp +.br circleq_foreach_reverse () +traverses the queue referenced by +.i head +in the reverse direction, +assigning each element in turn to +.ir var . +.ss removal +.br circleq_remove () +removes the element +.i elm +from the queue. +.sh return value +.br circleq_empty () +returns nonzero if the queue is empty, +and zero if the queue contains at least one entry. +.pp +.br circleq_first (), +.br circleq_last (), +.br circleq_loop_prev (), +and +.br circleq_loop_next () +return a pointer to the first, last, previous, or next +.i type +structure, respectively. +.pp +.br circleq_prev (), +and +.br circleq_next () +are similar to their +.br circleq_loop_* () +counterparts, +except that if the argument is the first or last element, respectively, +they return +.ir &head . +.pp +.br circleq_head_initializer () +returns an initializer that can be assigned to the queue +.ir head . +.sh conforming to +not in posix.1, posix.1-2001, or posix.1-2008. +present on the bsds +(circleq macros first appeared in 4.4bsd). +.sh bugs +.br circleq_foreach () +and +.br circleq_foreach_reverse () +don't allow +.i var +to be removed or freed within the loop, +as it would interfere with the traversal. +.br circleq_foreach_safe () +and +.br circleq_foreach_reverse_safe (), +which are present on the bsds but are not present in glibc, +fix this limitation by allowing +.i var +to safely be removed from the list and freed from within the loop +without interfering with the traversal. +.sh examples +.ex +#include +#include +#include +#include + +struct entry { + int data; + circleq_entry(entry) entries; /* queue */ +}; + +circleq_head(circlehead, entry); + +int +main(void) +{ + struct entry *n1, *n2, *n3, *np; + struct circlehead head; /* queue head */ + int i; + + circleq_init(&head); /* initialize the queue */ + + n1 = malloc(sizeof(struct entry)); /* insert at the head */ + circleq_insert_head(&head, n1, entries); + + n1 = malloc(sizeof(struct entry)); /* insert at the tail */ + circleq_insert_tail(&head, n1, entries); + + n2 = malloc(sizeof(struct entry)); /* insert after */ + circleq_insert_after(&head, n1, n2, entries); + + n3 = malloc(sizeof(struct entry)); /* insert before */ + circleq_insert_before(&head, n2, n3, entries); + + circleq_remove(&head, n2, entries); /* deletion */ + free(n2); + /* forward traversal */ + i = 0; + circleq_foreach(np, &head, entries) + np\->data = i++; + /* reverse traversal */ + circleq_foreach_reverse(np, &head, entries) + printf("%i\en", np\->data); + /* queue deletion */ + n1 = circleq_first(&head); + while (n1 != (void *)&head) { + n2 = circleq_next(n1, entries); + free(n1); + n1 = n2; + } + circleq_init(&head); + + exit(exit_success); +} +.ee +.sh see also +.br insque (3), +.br queue (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/newlocale.3 + +.so man3/xdr.3 + +.so man2/chown.2 + +.so man3/stailq.3 + +.so man3/tzset.3 + +.so man3/lgamma.3 + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" iso/iec 9899:1999 +.\" +.th ungetwc 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +ungetwc \- push back a wide character onto a file stream +.sh synopsis +.nf +.b #include +.pp +.bi "wint_t ungetwc(wint_t " wc ", file *" stream ); +.fi +.sh description +the +.br ungetwc () +function is the wide-character equivalent of the +.br ungetc (3) +function. +it pushes back a wide character onto +.i stream +and returns it. +.pp +if +.i wc +is +.br weof , +it returns +.br weof . +if +.i wc +is an invalid wide character, +it sets +.i errno +to +.b eilseq +and returns +.br weof . +.pp +if +.i wc +is a valid wide character, it is pushed back onto the stream +and thus becomes available for future wide-character read operations. +the file-position indicator is decremented by one or more. +the end-of-file +indicator is cleared. +the backing storage of the file is not affected. +.pp +note: +.i wc +need not be the last wide-character read from the stream; +it can be any other valid wide character. +.pp +if the implementation supports multiple push-back operations in a row, the +pushed-back wide characters will be read in reverse order; however, only one +level of push-back is guaranteed. +.sh return value +the +.br ungetwc () +function returns +.i wc +when successful, or +.b weof +upon +failure. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br ungetwc () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh notes +the behavior of +.br ungetwc () +depends on the +.b lc_ctype +category of the +current locale. +.sh see also +.br fgetwc (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1995 by jim van zandt +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th tsearch 3 2021-08-27 "gnu" "linux programmer's manual" +.sh name +tsearch, tfind, tdelete, twalk, twalk_r, tdestroy \- manage a binary search tree +.sh synopsis +.nf +.b #include +.pp +.bi "typedef enum { preorder, postorder, endorder, leaf } visit;" +.pp +.bi "void *tsearch(const void *" key ", void **" rootp , +.bi " int (*" compar ")(const void *, const void *));" +.bi "void *tfind(const void *" key ", void *const *" rootp , +.bi " int (*" compar ")(const void *, const void *));" +.bi "void *tdelete(const void *restrict " key ", void **restrict " rootp , +.bi " int (*" compar ")(const void *, const void *));" +.bi "void twalk(const void *" root , +.bi " void (*" action ")(const void *" nodep ", visit " which , +.bi " int " depth )); +.pp +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "void twalk_r(const void *" root , +.bi " void (*" action ")(const void *" nodep ", visit " which , +.bi " void *" closure ), +.bi " void *" closure ); +.bi "void tdestroy(void *" root ", void (*" free_node ")(void *" nodep )); +.fi +.sh description +.br tsearch (), +.br tfind (), +.br twalk (), +and +.br tdelete () +manage a +binary search tree. +they are generalized from knuth (6.2.2) algorithm t. +the first field in each node of the tree is a pointer to the +corresponding data item. +(the calling program must store the actual data.) +.i compar +points to a comparison routine, which takes +pointers to two items. +it should return an integer which is negative, +zero, or positive, depending on whether the first item is less than, +equal to, or greater than the second. +.pp +.br tsearch () +searches the tree for an item. +.i key +points to the item to be searched for. +.i rootp +points to a variable which points to the root of the tree. +if the tree is empty, +then the variable that +.i rootp +points to should be set to null. +if the item is found in the tree, then +.br tsearch () +returns a pointer +to the corresponding tree node. +(in other words, +.br tsearch () +returns a pointer to a pointer to the data item.) +if the item is not found, then +.br tsearch () +adds it, and returns a +pointer to the corresponding tree node. +.pp +.br tfind () +is like +.br tsearch (), +except that if the item is not +found, then +.br tfind () +returns null. +.pp +.br tdelete () +deletes an item from the tree. +its arguments are the same as for +.br tsearch (). +.pp +.br twalk () +performs depth-first, left-to-right traversal of a binary +tree. +.i root +points to the starting node for the traversal. +if that node is not the root, then only part of the tree will be visited. +.br twalk () +calls the user function +.i action +each time a node is +visited (that is, three times for an internal node, and once for a +leaf). +.ir action , +in turn, takes three arguments. +the first argument is a pointer to the node being visited. +the structure of the node is unspecified, +but it is possible to cast the pointer to a pointer-to-pointer-to-element +in order to access the element stored within the node. +the application must not modify the structure pointed to by this argument. +the second argument is an integer which +takes one of the values +.br preorder , +.br postorder , +or +.b endorder +depending on whether this is the first, second, or +third visit to the internal node, +or the value +.b leaf +if this is the single visit to a leaf node. +(these symbols are defined in +.ir .) +the third argument is the depth of the node; +the root node has depth zero. +.pp +(more commonly, +.br preorder , +.br postorder , +and +.b endorder +are known as +.br preorder , +.br inorder , +and +.br postorder : +before visiting the children, after the first and before the second, +and after visiting the children. +thus, the choice of name +.b post\%order +is rather confusing.) +.pp +.br twalk_r () +is similar to +.br twalk (), +but instead of the +.i depth +argument, the +.i closure +argument pointer is passed to each invocation of the action callback, +unchanged. +this pointer can be used to pass information to and from +the callback function in a thread-safe fashion, without resorting +to global variables. +.pp +.br tdestroy () +removes the whole tree pointed to by +.ir root , +freeing all resources allocated by the +.br tsearch () +function. +for the data in each tree node the function +.i free_node +is called. +the pointer to the data is passed as the argument to the function. +if no such work is necessary, +.i free_node +must point to a function +doing nothing. +.sh return value +.br tsearch () +returns a pointer to a matching node in the tree, or to +the newly added node, or null if there was insufficient memory +to add the item. +.br tfind () +returns a pointer to the node, or +null if no match is found. +if there are multiple items that match the key, +the item whose node is returned is unspecified. +.pp +.br tdelete () +returns a pointer to the parent of the node deleted, or +null if the item was not found. +if the deleted node was the root node, +.br tdelete () +returns a dangling pointer that must not be accessed. +.pp +.br tsearch (), +.br tfind (), +and +.br tdelete () +also +return null if +.i rootp +was null on entry. +.sh versions +.br twalk_r () +is available in glibc since version 2.30. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br tsearch (), +.br tfind (), +.br tdelete () +t} thread safety mt-safe race:rootp +t{ +.br twalk () +t} thread safety mt-safe race:root +t{ +.br twalk_r () +t} thread safety mt-safe race:root +t{ +.br tdestroy () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, svr4. +the functions +.br tdestroy () +and +.br twalk_r () +are gnu extensions. +.sh notes +.br twalk () +takes a pointer to the root, while the other functions +take a pointer to a variable which points to the root. +.pp +.br tdelete () +frees the memory required for the node in the tree. +the user is responsible for freeing the memory for the corresponding +data. +.pp +the example program depends on the fact that +.br twalk () +makes no +further reference to a node after calling the user function with +argument "endorder" or "leaf". +this works with the gnu library +implementation, but is not in the system v documentation. +.sh examples +the following program inserts twelve random numbers into a binary +tree, where duplicate numbers are collapsed, then prints the numbers +in order. +.pp +.ex +#define _gnu_source /* expose declaration of tdestroy() */ +#include +#include +#include +#include +#include + +static void *root = null; + +static void * +xmalloc(size_t n) +{ + void *p; + p = malloc(n); + if (p) + return p; + fprintf(stderr, "insufficient memory\en"); + exit(exit_failure); +} + +static int +compare(const void *pa, const void *pb) +{ + if (*(int *) pa < *(int *) pb) + return \-1; + if (*(int *) pa > *(int *) pb) + return 1; + return 0; +} + +static void +action(const void *nodep, visit which, int depth) +{ + int *datap; + + switch (which) { + case preorder: + break; + case postorder: + datap = *(int **) nodep; + printf("%6d\en", *datap); + break; + case endorder: + break; + case leaf: + datap = *(int **) nodep; + printf("%6d\en", *datap); + break; + } +} + +int +main(void) +{ + int **val; + + srand(time(null)); + for (int i = 0; i < 12; i++) { + int *ptr = xmalloc(sizeof(*ptr)); + *ptr = rand() & 0xff; + val = tsearch(ptr, &root, compare); + if (val == null) + exit(exit_failure); + else if (*val != ptr) + free(ptr); + } + twalk(root, action); + tdestroy(root, free); + exit(exit_success); +} +.ee +.sh see also +.br bsearch (3), +.br hsearch (3), +.br lsearch (3), +.br qsort (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" and copyright 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified 1993-07-24 by rik faith (faith@cs.unc.edu) +.\" modified 1995-08-14 by arnt gulbrandsen +.\" modified 2002-07-27 by walter harms +.\" (walter.harms@informatik.uni-oldenburg.de) +.\" +.th log 3 2021-03-22 "" "linux programmer's manual" +.sh name +log, logf, logl \- natural logarithmic function +.sh synopsis +.nf +.b #include +.pp +.bi "double log(double " x ); +.bi "float logf(float " x ); +.bi "long double logl(long double " x ); +.fi +.pp +link with \fi\-lm\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br logf (), +.br logl (): +.nf + _isoc99_source || _posix_c_source >= 200112l + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.sh description +these functions return the natural logarithm of +.ir x . +.sh return value +on success, these functions return the natural logarithm of +.ir x . +.pp +if +.i x +is a nan, +a nan is returned. +.pp +if +.i x +is 1, the result is +0. +.pp +if +.i x +is positive infinity, +positive infinity is returned. +.pp +if +.i x +is zero, +then a pole error occurs, and the functions return +.rb \- huge_val , +.rb \- huge_valf , +or +.rb \- huge_vall , +respectively. +.pp +if +.i x +is negative (including negative infinity), then +a domain error occurs, and a nan (not a number) is returned. +.sh errors +see +.br math_error (7) +for information on how to determine whether an error has occurred +when calling these functions. +.pp +the following errors can occur: +.tp +domain error: \fix\fp is negative +.i errno +is set to +.br edom . +an invalid floating-point exception +.rb ( fe_invalid ) +is raised. +.tp +pole error: \fix\fp is zero +.i errno +is set to +.br erange . +a divide-by-zero floating-point exception +.rb ( fe_divbyzero ) +is raised. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br log (), +.br logf (), +.br logl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.pp +the variant returning +.i double +also conforms to +svr4, 4.3bsd, c89. +.sh bugs +in glibc 2.5 and earlier, +taking the +.br log () +of a nan produces a bogus invalid floating-point +.rb ( fe_invalid ) +exception. +.sh see also +.br cbrt (3), +.br clog (3), +.br log10 (3), +.br log1p (3), +.br log2 (3), +.br sqrt (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/getspnam.3 + +.so man2/mkdir.2 + +.\" copyright (c) 1990, 1993 +.\" the regents of the university of california. all rights reserved. +.\" +.\" %%%license_start(bsd_4_clause_ucb) +.\" redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. all advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" this product includes software developed by the university of +.\" california, berkeley and its contributors. +.\" 4. neither the name of the university nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" this software is provided by the regents and contributors ``as is'' and +.\" any express or implied warranties, including, but not limited to, the +.\" implied warranties of merchantability and fitness for a particular purpose +.\" are disclaimed. in no event shall the regents or contributors be liable +.\" for any direct, indirect, incidental, special, exemplary, or consequential +.\" damages (including, but not limited to, procurement of substitute goods +.\" or services; loss of use, data, or profits; or business interruption) +.\" however caused and on any theory of liability, whether in contract, strict +.\" liability, or tort (including negligence or otherwise) arising in any way +.\" out of the use of this software, even if advised of the possibility of +.\" such damage. +.\" %%%license_end +.\" +.\" @(#)mpool.3 8.1 (berkeley) 6/4/93 +.\" +.th mpool 3 2021-03-22 "" "linux programmer's manual" +.uc 7 +.sh name +mpool \- shared memory buffer pool +.sh synopsis +.nf +.b #include +.b #include +.pp +.bi "mpool *mpool_open(dbt *" key ", int " fd ", pgno_t " pagesize \ +", pgno_t " maxcache ); +.pp +.bi "void mpool_filter(mpool *" mp ", void (*pgin)(void *, pgno_t, void *)," +.bi " void (*" pgout ")(void *, pgno_t, void *)," +.bi " void *" pgcookie ); +.pp +.bi "void *mpool_new(mpool *" mp ", pgno_t *" pgnoaddr ); +.bi "void *mpool_get(mpool *" mp ", pgno_t " pgno ", unsigned int " flags ); +.bi "int mpool_put(mpool *" mp ", void *" pgaddr ", unsigned int " flags ); +.pp +.bi "int mpool_sync(mpool *" mp ); +.bi "int mpool_close(mpool *" mp ); +.fi +.sh description +.ir "note well" : +this page documents interfaces provided in glibc up until version 2.1. +since version 2.2, glibc no longer provides these interfaces. +probably, you are looking for the apis provided by the +.i libdb +library instead. +.pp +.i mpool +is the library interface intended to provide page oriented buffer management +of files. +the buffers may be shared between processes. +.pp +the function +.br mpool_open () +initializes a memory pool. +the +.i key +argument is the byte string used to negotiate between multiple +processes wishing to share buffers. +if the file buffers are mapped in shared memory, all processes using +the same key will share the buffers. +if +.i key +is null, the buffers are mapped into private memory. +the +.i fd +argument is a file descriptor for the underlying file, which must be seekable. +if +.i key +is non-null and matches a file already being mapped, the +.i fd +argument is ignored. +.pp +the +.i pagesize +argument is the size, in bytes, of the pages into which the file is broken up. +the +.i maxcache +argument is the maximum number of pages from the underlying file to cache +at any one time. +this value is not relative to the number of processes which share a file's +buffers, but will be the largest value specified by any of the processes +sharing the file. +.pp +the +.br mpool_filter () +function is intended to make transparent input and output processing of the +pages possible. +if the +.i pgin +function is specified, it is called each time a buffer is read into the memory +pool from the backing file. +if the +.i pgout +function is specified, it is called each time a buffer is written into the +backing file. +both functions are called with the +.i pgcookie +pointer, the page number and a pointer to the page to being read or written. +.pp +the function +.br mpool_new () +takes an +.i mpool +pointer and an address as arguments. +if a new page can be allocated, a pointer to the page is returned and +the page number is stored into the +.i pgnoaddr +address. +otherwise, null is returned and +.i errno +is set. +.pp +the function +.br mpool_get () +takes an +.i mpool +pointer and a page number as arguments. +if the page exists, a pointer to the page is returned. +otherwise, null is returned and +.i errno +is set. +the +.i flags +argument is not currently used. +.pp +the function +.br mpool_put () +unpins the page referenced by +.ir pgaddr . +.i pgaddr +must be an address previously returned by +.br mpool_get () +or +.br mpool_new (). +the flag value is specified by oring +any of the following values: +.tp +.b mpool_dirty +the page has been modified and needs to be written to the backing file. +.pp +.br mpool_put () +returns 0 on success and \-1 if an error occurs. +.pp +the function +.br mpool_sync () +writes all modified pages associated with the +.i mpool +pointer to the +backing file. +.br mpool_sync () +returns 0 on success and \-1 if an error occurs. +.pp +the +.br mpool_close () +function free's up any allocated memory associated with the memory pool +cookie. +modified pages are +.b not +written to the backing file. +.br mpool_close () +returns 0 on success and \-1 if an error occurs. +.sh errors +the +.br mpool_open () +function may fail and set +.i errno +for any of the errors specified for the library routine +.br malloc (3). +.pp +the +.br mpool_get () +function may fail and set +.i errno +for the following: +.tp 15 +.b einval +the requested record doesn't exist. +.pp +the +.br mpool_new () +and +.br mpool_get () +functions may fail and set +.i errno +for any of the errors specified for the library routines +.br read (2), +.br write (2), +and +.br malloc (3). +.pp +the +.br mpool_sync () +function may fail and set +.i errno +for any of the errors specified for the library routine +.br write (2). +.pp +the +.br mpool_close () +function may fail and set +.i errno +for any of the errors specified for the library routine +.br free (3). +.sh conforming to +not in posix.1. +present on the bsds. +.sh see also +.br btree (3), +.br dbopen (3), +.br hash (3), +.br recno (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/casin.3 + +.so man3/cacos.3 + +.so man3/popen.3 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" and copyright 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sat jul 24 19:08:17 1993 by rik faith (faith@cs.unc.edu) +.\" modified 2002-08-25, aeb +.\" modified 2004-11-12 as per suggestion by fabian kreutz/aeb +.\" 2008-07-24, mtk, moved yxx() material into separate y0.3 page +.\" +.th j0 3 2021-03-22 "" "linux programmer's manual" +.sh name +j0, j0f, j0l, j1, j1f, j1l, jn, jnf, jnl \- +bessel functions of the first kind +.sh synopsis +.nf +.b #include +.pp +.bi "double j0(double " x ); +.bi "double j1(double " x ); +.bi "double jn(int " n ", double " x ); +.pp +.bi "float j0f(float " x ); +.bi "float j1f(float " x ); +.bi "float jnf(int " n ", float " x ); +.pp +.bi "long double j0l(long double " x ); +.bi "long double j1l(long double " x ); +.bi "long double jnl(int " n ", long double " x ); +.fi +.pp +link with \fi\-lm\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br j0 (), +.br j1 (), +.br jn (): +.nf + _xopen_source + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _svid_source || _bsd_source +.fi +.pp +.br j0f (), +.br j0l (), +.br j1f (), +.br j1l (), +.br jnf (), +.br jnl (): +.nf + _xopen_source >= 600 + || (_isoc99_source && _xopen_source) + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _svid_source || _bsd_source +.fi +.sh description +the +.br j0 () +and +.br j1 () +functions return bessel functions of +.i x +of the first kind of orders 0 and 1, respectively. +the +.br jn () +function +returns the bessel function of +.i x +of the first kind of order +.ir n . +.pp +the +.br j0f (), +.br j1f (), +and +.br jnf (), +functions are versions that take and return +.i float +values. +the +.br j0l (), +.br j1l (), +and +.br jnl () +functions are versions that take and return +.i "long double" +values. +.sh return value +on success, these functions return the appropriate +bessel value of the first kind for +.ir x . +.pp +if +.i x +is a nan, a nan is returned. +.pp +if +.i x +is too large in magnitude, +or the result underflows, +a range error occurs, +and the return value is 0. +.sh errors +see +.br math_error (7) +for information on how to determine whether an error has occurred +when calling these functions. +.pp +the following errors can occur: +.tp +range error: result underflow, or \fix\fp is too large in magnitude +.i errno +is set to +.br erange . +.pp +these functions do not raise exceptions for +.br fetestexcept (3). +.\" e.g., j0(1.5e16) +.\" this is intentional. +.\" see http://sources.redhat.com/bugzilla/show_bug.cgi?id=6805 +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br j0 (), +.br j0f (), +.br j0l () +t} thread safety mt-safe +t{ +.br j1 (), +.br j1f (), +.br j1l () +t} thread safety mt-safe +t{ +.br jn (), +.br jnf (), +.br jnl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +the functions returning +.i double +conform to svr4, 4.3bsd, +posix.1-2001, and posix.1-2008. +the others are nonstandard functions that also exist on the bsds. +.sh bugs +there are errors of up to 2e\-16 in the values returned by +.br j0 (), +.br j1 (), +and +.br jn () +for values of +.i x +between \-8 and 8. +.sh see also +.br y0 (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified mon mar 29 22:41:16 1993, david metcalfe +.\" modified sat jul 24 21:35:16 1993, rik faith (faith@cs.unc.edu) +.th bsearch 3 2021-08-27 "" "linux programmer's manual" +.sh name +bsearch \- binary search of a sorted array +.sh synopsis +.nf +.b #include +.pp +.bi "void *bsearch(const void *" key ", const void *" base , +.bi " size_t " nmemb ", size_t " size , +.bi " int (*" compar ")(const void *, const void *));" +.fi +.sh description +the +.br bsearch () +function searches an array of +.i nmemb +objects, +the initial member of which is pointed to by +.ir base , +for a member +that matches the object pointed to by +.ir key . +the size of each member +of the array is specified by +.ir size . +.pp +the contents of the array should be in ascending sorted order according +to the comparison function referenced by +.ir compar . +the +.i compar +routine is expected to have two arguments which point to the +.i key +object and to an array member, in that order, and should return an integer +less than, equal to, or greater than zero if the +.i key +object is found, +respectively, to be less than, to match, or be greater than the array +member. +.sh return value +the +.br bsearch () +function returns a pointer to a matching member of the +array, or null if no match is found. +if there are multiple elements that +match the key, the element returned is unspecified. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br bsearch () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c89, c99, svr4, 4.3bsd. +.sh examples +the example below first sorts an array of structures using +.br qsort (3), +then retrieves desired elements using +.br bsearch (). +.pp +.ex +#include +#include +#include + +struct mi { + int nr; + char *name; +} months[] = { + { 1, "jan" }, { 2, "feb" }, { 3, "mar" }, { 4, "apr" }, + { 5, "may" }, { 6, "jun" }, { 7, "jul" }, { 8, "aug" }, + { 9, "sep" }, {10, "oct" }, {11, "nov" }, {12, "dec" } +}; + +#define nr_of_months (sizeof(months)/sizeof(months[0])) + +static int +compmi(const void *m1, const void *m2) +{ + const struct mi *mi1 = m1; + const struct mi *mi2 = m2; + return strcmp(mi1\->name, mi2\->name); +} + +int +main(int argc, char *argv[]) +{ + qsort(months, nr_of_months, sizeof(months[0]), compmi); + for (int i = 1; i < argc; i++) { + struct mi key; + struct mi *res; + + key.name = argv[i]; + res = bsearch(&key, months, nr_of_months, + sizeof(months[0]), compmi); + if (res == null) + printf("\(aq%s\(aq: unknown month\en", argv[i]); + else + printf("%s: month #%d\en", res\->name, res\->nr); + } + exit(exit_success); +} +.ee +.\" this example referred to in qsort.3 +.sh see also +.br hsearch (3), +.br lsearch (3), +.br qsort (3), +.br tsearch (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de) +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under gpl +.\" %%%license_end +.\" +.\" this was done with the help of the glibc manual. +.\" +.\" 2004-10-31, aeb, corrected +.th fpclassify 3 2021-03-22 "" "linux programmer's manual" +.sh name +fpclassify, isfinite, isnormal, isnan, isinf \- floating-point +classification macros +.sh synopsis +.nf +.b #include +.pp +.bi "int fpclassify(" x ); +.bi "int isfinite(" x ); +.bi "int isnormal(" x ); +.bi "int isnan(" x ); +.bi "int isinf(" x ); +.fi +.pp +link with \fi\-lm\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.\" i haven't fully grokked the source to determine the ftm requirements; +.\" in part, the following has been tested by experiment. +.br fpclassify (), +.br isfinite (), +.br isnormal (): +.nf + _isoc99_source || _posix_c_source >= 200112l +.fi +.pp +.br isnan (): +.nf + _isoc99_source || _posix_c_source >= 200112l + || _xopen_source + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.pp +.br isinf (): +.nf + _isoc99_source || _posix_c_source >= 200112l + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.sh description +floating point numbers can have special values, such as +infinite or nan. +with the macro +.bi fpclassify( x ) +you can find out what type +.i x +is. +the macro takes any floating-point expression as argument. +the result is one of the following values: +.tp 14 +.b fp_nan +.i x +is "not a number". +.tp +.b fp_infinite +.i x +is either positive infinity or negative infinity. +.tp +.b fp_zero +.i x +is zero. +.tp +.b fp_subnormal +.i x +is too small to be represented in normalized format. +.tp +.b fp_normal +if nothing of the above is correct then it must be a +normal floating-point number. +.pp +the other macros provide a short answer to some standard questions. +.tp 14 +.bi isfinite( x ) +returns a nonzero value if +.br +(fpclassify(x) != fp_nan && fpclassify(x) != fp_infinite) +.tp +.bi isnormal( x ) +returns a nonzero value if +(fpclassify(x) == fp_normal) +.tp +.bi isnan( x ) +returns a nonzero value if +(fpclassify(x) == fp_nan) +.tp +.bi isinf( x ) +returns 1 if +.i x +is positive infinity, and \-1 if +.i x +is negative infinity. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br fpclassify (), +.br isfinite (), +.br isnormal (), +.br isnan (), +.br isinf () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.pp +for +.br isinf (), +the standards merely say that the return value is nonzero +if and only if the argument has an infinite value. +.sh notes +in glibc 2.01 and earlier, +.br isinf () +returns a nonzero value (actually: 1) if +.i x +is positive infinity or negative infinity. +(this is all that c99 requires.) +.sh see also +.br finite (3), +.br infinity (3), +.br isgreater (3), +.br signbit (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" (c)copyright 1999-2003 marvell(r) -- linux@syskonnect.de +.\" sk98lin.4 1.1 2003/12/17 10:03:18 +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual;if not, see +.\" . +.\" %%%license_end +.\" +.\" this manpage can be viewed using `groff -tascii -man sk98lin.4 | less` +.\" +.th sk98lin 4 2020-08-13 "linux" "linux programmer's manual" +.sh name +sk98lin \- marvell/syskonnect gigabit ethernet driver v6.21 +.sh synopsis +.b insmod sk98lin.o +.rb [ speed_a=\c +.ir i,j,... ] +.rb [ speed_b=\c +.ir i,j,... ] +.rb [ autoneg_a=\c +.ir i,j,... ] +.rb [ autoneg_b=\c +.ir i,j,... ] +.rb [ dupcap_a=\c +.ir i,j,... ] +.rb [ dupcap_b=\c +.ir i,j,... ] +.rb [ flowctrl_a=\c +.ir i,j,... ] +.rb [ flowctrl_b=\c +.ir i,j,... ] +.rb [ role_a=\c +.ir i,j,... ] +.rb [ role_b=\c +.ir i,j,... ] +.rb [ contype=\c +.ir i,j,... ] +.rb [ moderation=\c +.ir i,j,... ] +.rb [ intspersec=\c +.ir i,j,... ] +.rb [ prefport=\c +.ir i,j,... ] +.rb [ rlmtmode=\c +.ir i,j,... ] +.sh description +.ad l +.hy 0 +.br note : +this obsolete driver was removed from the kernel in version 2.6.26. +.pp +.b sk98lin +is the gigabit ethernet driver for +marvell and syskonnect network adapter cards. +it supports syskonnect sk-98xx/sk-95xx +compliant gigabit ethernet adapter and +any yukon compliant chipset. +.pp +when loading the driver using insmod, +parameters for the network adapter cards +might be stated as a sequence of comma separated commands. +if for instance two network adapters are installed and autonegotiation on +port a of the first adapter should be on, +but on the port a of the second adapter switched off, one must enter: +.pp + insmod sk98lin.o autoneg_a=on,off +.pp +after +.b sk98lin +is bound to one or more adapter cards and the +.i /proc +filesystem is mounted on your system, a dedicated statistics file +will be created in the folder +.i /proc/net/sk98lin +for all ports of the installed network adapter cards. +those files are named +.ir eth[x] , +where +.i x +is the number of the interface that has been assigned to a +dedicated port by the system. +.pp +if loading is finished, any desired ip address can be +assigned to the respective +.i eth[x] +interface using the +.br ifconfig (8) +command. +this causes the adapter to connect to the ethernet and to display a status +message on the console saying "ethx: network connection up using port y" +followed by the configured or detected connection parameters. +.pp +the +.b sk98lin +also supports large frames (also called jumbo frames). +using jumbo frames can improve throughput tremendously when +transferring large amounts of data. +to enable large frames, the mtu (maximum transfer unit) size +for an interface is to be set to a high value. +the default mtu size is 1500 and can be changed up to 9000 (bytes). +setting the mtu size can be done when assigning the ip address +to the interface or later by using the +.br ifconfig (8) +command with the mtu parameter. +if for instance eth0 needs an ip +address and a large frame mtu size, +the following two commands might be used: +.pp + ifconfig eth0 10.1.1.1 + ifconfig eth0 mtu 9000 +.pp +those two commands might even be combined into one: +.pp + ifconfig eth0 10.1.1.1 mtu 9000 +.pp +note that large frames can be used only if permitted by +your network infrastructure. +this means, that any switch being used in your ethernet must +also support large frames. +quite some switches support large frames, +but need to be configured to do so. +most of the times, their default setting is to support only +standard frames with an mtu size of 1500 (bytes). +in addition to the switches inside the network, +all network adapters that are to be used must also be +enabled regarding jumbo frames. +if an adapter is not set to receive large frames, it will simply drop them. +.pp +switching back to the standard ethernet frame size can be done by using the +.br ifconfig (8) +command again: +.pp + ifconfig eth0 mtu 1500 +.pp +the marvell/syskonnect gigabit ethernet driver for linux is able to +support vlan and link aggregation according to +ieee standards 802.1, 802.1q, and 802.3ad. +those features are available only after installation of open source modules +which can be found on the internet: +.pp +.ir vlan \c +: +.ur http://www.candelatech.com\:/\(tigreear\:/vlan.html +.ue +.br +.i link +.ir aggregation \c +: +.ur http://www.st.rim.or.jp\:/\(tiyumo +.ue +.pp +note that marvell/syskonnect does not offer any support for these +open source modules and does not take the responsibility for any +kind of failures or problems arising when using these modules. +.ss parameters +.tp +.bi speed_a= i,j,... +this parameter is used to set the speed capabilities of port a of an +adapter card. +it is valid only for yukon copper adapters. +possible values are: +.ir 10 , +.ir 100 , +.ir 1000 , +or +.ir auto ; +.i auto +is the default. +usually, the speed is negotiated between the two ports +during link establishment. +if this fails, +a port can be forced to a specific setting with this parameter. +.tp +.bi speed_b= i,j,... +this parameter is used to set the speed capabilities of port b of +an adapter card. +it is valid only for yukon copper adapters. +possible values are: +.ir 10 , +.ir 100 , +.ir 1000 , +or +.ir auto ; +.i auto +is the default. +usually, the speed is negotiated between the two ports during link +establishment. +if this fails, +a port can be forced to a specific setting with this parameter. +.tp +.bi autoneg_a= i,j,... +enables or disables the use of autonegotiation of port a of an adapter card. +possible values are: +.ir on , +.ir off , +or +.ir sense ; +.i on +is the default. +the +.i sense +mode automatically detects whether the link partner supports +auto-negotiation or not. +.tp +.bi autoneg_b= i,j,... +enables or disables the use of autonegotiation of port b of an adapter card. +possible values are: +.ir on , +.ir off , +or +.ir sense ; +.i on +is the default. +the +.i sense +mode automatically detects whether the link partner supports +auto-negotiation or not. +.tp +.bi dupcap_a= i,j,... +this parameter indicates the duplex mode to be used for port a +of an adapter card. +possible values are: +.ir half , +.ir full , +or +.ir both ; +.i both +is the default. +this parameter is relevant only if autoneg_a of port a is not set to +.ir sense . +if autoneg_a is set to +.ir on , +all three values of dupcap_a ( +.ir half , +.ir full , +or +.ir both ) +might be stated. +if autoneg_a is set to +.ir off , +only dupcap_a values +.i full +and +.i half +are allowed. +this dupcap_a parameter is useful if your link partner does not +support all possible duplex combinations. +.tp +.bi dupcap_b= i,j,... +this parameter indicates the duplex mode to be used for port b +of an adapter card. +possible values are: +.ir half , +.ir full , +or +.ir both ; +.i both +is the default. +this parameter is relevant only if autoneg_b of port b is not set to +.ir sense . +if autoneg_b is set to +.ir on , +all three values of dupcap_b ( +.ir half , +.ir full , +or +.ir both ) +might be stated. +if autoneg_b is set to +.ir off , +only dupcap_b values +.i full +and +.i half +are allowed. +this dupcap_b parameter is useful if your link partner does not +support all possible duplex combinations. +.tp +.bi flowctrl_a= i,j,... +this parameter can be used to set the flow control capabilities the +port reports during auto-negotiation. +possible values are: +.ir sym , +.ir symorrem , +.ir locsend , +or +.ir none ; +.i symorrem +is the default. +the different modes have the following meaning: +.ip +.i sym += symmetric + both link partners are allowed to send pause frames +.br +.i symorrem += symmetricorremote + both or only remote partner are allowed to send pause frames +.br +.i locsend += localsend + only local link partner is allowed to send pause frames +.br +.i none += none + no link partner is allowed to send pause frames +.ip +note that this parameter is ignored if autoneg_a is set to +.ir off . +.tp +.bi flowctrl_b= i,j,... +this parameter can be used to set the flow control capabilities the +port reports during auto-negotiation. +possible values are: +.ir sym , +.ir symorrem , +.ir locsend , +or +.ir none ; +.i symorrem +is the default. +the different modes have the following meaning: +.ip +.i sym += symmetric + both link partners are allowed to send pause frames +.br +.i symorrem += symmetricorremote + both or only remote partner are allowed to send pause frames +.br +.i locsend += localsend + only local link partner is allowed to send pause frames +.br +.i none += none + no link partner is allowed to send pause frames +.br +.ip +note that this parameter is ignored if autoneg_b is set to +.ir off . +.tp +.bi role_a= i,j,... +this parameter is valid only for 1000base-t adapter cards. +for two 1000base-t ports to communicate, +one must take the role of the master (providing timing information), +while the other must be the slave. +possible values are: +.ir auto , +.ir master , +or +.ir slave ; +.i auto +is the default. +usually, the role of a port is negotiated between two ports during +link establishment, but if that fails the port a of an adapter card +can be forced to a specific setting with this parameter. +.tp +.bi role_b= i,j,... +this parameter is valid only for 1000base-t adapter cards. +for two 1000base-t ports to communicate, one must take +the role of the master (providing timing information), +while the other must be the slave. +possible values are: +.ir auto , +.ir master , +or +.ir slave ; +.i auto +is the default. +usually, the role of a port is negotiated between +two ports during link establishment, but if that fails +the port b of an adapter card can be forced to a +specific setting with this parameter. +.tp +.bi contype= i,j,... +this parameter is a combination of all five per-port parameters +within one single parameter. +this simplifies the configuration of both ports of an adapter card. +the different values of this variable reflect the +most meaningful combinations of port parameters. +possible values and their corresponding combination of per-port parameters: +.ip +.ts +lb lb lb lb lb lb +l l l l l l. +contype dupcap autoneg flowctrl role speed +\fiauto\fp both on symorrem auto auto +\fi100fd\fp full off none auto 100 +\fi100hd\fp half off none auto 100 +\fi10fd\fp full off none auto 10 +\fi10hd\fp half off none auto 10 +.te +.ip +stating any other port parameter together with this +.i contype +parameter will result in a merged configuration of those settings. +this is due to +the fact, that the per-port parameters (e.g., +.ir speed_a ) +have a higher priority than the combined variable +.ir contype . +.tp +.bi moderation= i,j,... +interrupt moderation is employed to limit the maximum number of interrupts +the driver has to serve. +that is, one or more interrupts (which indicate any transmit or +receive packet to be processed) are queued until the driver processes them. +when queued interrupts are to be served, is determined by the +.i intspersec +parameter, which is explained later below. +possible moderation modes are: +.ir none , +.ir static , +or +.ir dynamic ; +.i none +is the default. +the different modes have the following meaning: +.ip +.i none +no interrupt moderation is applied on the adapter card. +therefore, each transmit or receive interrupt is served immediately +as soon as it appears on the interrupt line of the adapter card. +.ip +.i static +interrupt moderation is applied on the adapter card. +all transmit and receive interrupts are queued until +a complete moderation interval ends. +if such a moderation interval ends, all queued interrupts +are processed in one big bunch without any delay. +the term +.i static +reflects the fact, that interrupt moderation is always enabled, +regardless how much network load is currently passing via a +particular interface. +in addition, the duration of the moderation interval has a fixed +length that never changes while the driver is operational. +.ip +.i dynamic +interrupt moderation might be applied on the adapter card, +depending on the load of the system. +if the driver detects that the system load is too high, +the driver tries to shield the system against too much network +load by enabling interrupt moderation. +if\(emat a later time\(emthe cpu utilization decreases +again (or if the network load is negligible), the interrupt +moderation will automatically be disabled. +.ip +interrupt moderation should be used when the driver has to +handle one or more interfaces with a high network load, +which\(emas a consequence\(emleads also to a high cpu utilization. +when moderation is applied in such high network load situations, +cpu load might be reduced by 20\(en30% on slow computers. +.ip +note that the drawback of using interrupt moderation is an increase of +the round-trip-time (rtt), due to the queuing and serving of +interrupts at dedicated moderation times. +.tp +.bi intspersec= i,j,... +this parameter determines the length of any interrupt moderation interval. +assuming that static interrupt moderation is to be used, an +.i intspersec +parameter value of 2000 will lead to an interrupt moderation interval of +500 microseconds. +possible values for this parameter are in the range of +30...40000 (interrupts per second). +the default value is 2000. +.ip +this parameter is used only if either static or dynamic interrupt moderation +is enabled on a network adapter card. +this parameter is ignored if no moderation is applied. +.ip +note that the duration of the moderation interval is to be chosen with care. +at first glance, selecting a very long duration (e.g., only 100 interrupts per +second) seems to be meaningful, but the increase of packet-processing delay +is tremendous. +on the other hand, selecting a very short moderation time might +compensate the use of any moderation being applied. +.tp +.bi prefport= i,j,... +this parameter is used to force the preferred port to +a or b (on dual-port network adapters). +the preferred port is the one that is used if both ports a and b are +detected as fully functional. +possible values are: +.i a +or +.ir b ; +.i a +is the default. +.tp +.bi rlmtmode= i,j,... +rlmt monitors the status of the port. +if the link of the active port fails, +rlmt switches immediately to the standby link. +the virtual link is maintained as long as at least one "physical" link is up. +this parameters states how rlmt should monitor both ports. +possible values are: +.ir checklinkstate , +.ir checklocalport , +.ir checkseg , +or +.ir dualnet ; +.i checklinkstate +is the default. +the different modes have the following meaning: +.ip +.i checklinkstate +check link state only: rlmt uses the link state reported by the adapter +hardware for each individual port to determine whether a port can be used +for all network traffic or not. +.ip +.i checklocalport +in this mode, rlmt monitors the network path between the two +ports of an adapter by regularly exchanging packets between them. +this mode requires a network configuration in which the +two ports are able to "see" each other (i.e., there +must not be any router between the ports). +.ip +.i checkseg +check local port and segmentation: +this mode supports the same functions as the checklocalport +mode and additionally checks network segmentation between the ports. +therefore, this mode is to be used only if gigabit ethernet +switches are installed on the network that have been +configured to use the spanning tree protocol. +.ip +.i dualnet +in this mode, ports a and b are used as separate devices. +if you have a dual port adapter, port a will be configured as +.ir eth[x] +and port b as +.ir eth[x+1] . +both ports can be used independently with distinct ip addresses. +the preferred port setting is not used. +rlmt is turned off. +.ip +note that rlmt modes +.i checklocalport +and +.i checklinkstate +are designed to operate in configurations where a +network path between the ports on one adapter exists. +moreover, they are not designed to work where adapters are +connected back-to-back. +.sh files +.tp +.i /proc/net/sk98lin/eth[x] +the statistics file of a particular interface of an adapter card. +it contains generic information about the adapter card plus a detailed +summary of all transmit and receive counters. +.tp +.i /usr/src/linux/documentation/networking/sk98lin.txt +this is the +.i readme +file of the +.i sk98lin +driver. +it contains a detailed installation howto and describes all parameters +of the driver. +it denotes also common problems and provides the solution to them. +.sh bugs +report any bugs to linux@syskonnect.de +.\" .sh authors +.\" ralph roesler \(em rroesler@syskonnect.de +.\" .br +.\" mirko lindner \(em mlindner@syskonnect.de +.sh see also +.br ifconfig (8), +.br insmod (8), +.br modprobe (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2008 linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th pthread_attr_init 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +pthread_attr_init, pthread_attr_destroy \- initialize and destroy +thread attributes object +.sh synopsis +.nf +.b #include +.pp +.bi "int pthread_attr_init(pthread_attr_t *" attr ); +.bi "int pthread_attr_destroy(pthread_attr_t *" attr ); +.pp +compile and link with \fi\-pthread\fp. +.fi +.sh description +the +.br pthread_attr_init () +function initializes the thread attributes object pointed to by +.ir attr +with default attribute values. +after this call, individual attributes of the object can be set +using various related functions (listed under see also), +and then the object can be used in one or more +.br pthread_create (3) +calls that create threads. +.pp +calling +.br pthread_attr_init () +on a thread attributes object that has already been initialized +results in undefined behavior. +.pp +when a thread attributes object is no longer required, +it should be destroyed using the +.br pthread_attr_destroy () +function. +destroying a thread attributes object has no effect +on threads that were created using that object. +.pp +once a thread attributes object has been destroyed, +it can be reinitialized using +.br pthread_attr_init (). +any other use of a destroyed thread attributes object +has undefined results. +.sh return value +on success, these functions return 0; +on error, they return a nonzero error number. +.sh errors +posix.1 documents an +.b enomem +error for +.br pthread_attr_init (); +on linux these functions always succeed +(but portable and future-proof applications should nevertheless +handle a possible error return). +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br pthread_attr_init (), +.br pthread_attr_destroy () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +the +.i pthread_attr_t +type should be treated as opaque: +any access to the object other than via pthreads functions +is nonportable and produces undefined results. +.sh examples +the program below optionally makes use of +.br pthread_attr_init () +and various related functions to initialize a thread attributes +object that is used to create a single thread. +once created, the thread uses the +.br pthread_getattr_np (3) +function (a nonstandard gnu extension) to retrieve the thread's +attributes, and then displays those attributes. +.pp +if the program is run with no command-line argument, +then it passes null as the +.i attr +argument of +.br pthread_create (3), +so that the thread is created with default attributes. +running the program on linux/x86-32 with the nptl threading implementation, +we see the following: +.pp +.in +4n +.ex +.\" results from glibc 2.8, suse 11.0; oct 2008 +.rb "$" " ulimit \-s" " # no stack limit ==> default stack size is 2 mb" +unlimited +.rb "$" " ./a.out" +thread attributes: + detach state = pthread_create_joinable + scope = pthread_scope_system + inherit scheduler = pthread_inherit_sched + scheduling policy = sched_other + scheduling priority = 0 + guard size = 4096 bytes + stack address = 0x40196000 + stack size = 0x201000 bytes +.ee +.in +.pp +when we supply a stack size as a command-line argument, +the program initializes a thread attributes object, +sets various attributes in that object, +and passes a pointer to the object in the call to +.br pthread_create (3). +running the program on linux/x86-32 with the nptl threading implementation, +we see the following: +.pp +.in +4n +.ex +.\" results from glibc 2.8, suse 11.0; oct 2008 +.rb "$" " ./a.out 0x3000000" +posix_memalign() allocated at 0x40197000 +thread attributes: + detach state = pthread_create_detached + scope = pthread_scope_system + inherit scheduler = pthread_explicit_sched + scheduling policy = sched_other + scheduling priority = 0 + guard size = 0 bytes + stack address = 0x40197000 + stack size = 0x3000000 bytes +.ee +.in +.ss program source +\& +.ex +#define _gnu_source /* to get pthread_getattr_np() declaration */ +#include +#include +#include +#include +#include + +#define handle_error_en(en, msg) \e + do { errno = en; perror(msg); exit(exit_failure); } while (0) + +static void +display_pthread_attr(pthread_attr_t *attr, char *prefix) +{ + int s, i; + size_t v; + void *stkaddr; + struct sched_param sp; + + s = pthread_attr_getdetachstate(attr, &i); + if (s != 0) + handle_error_en(s, "pthread_attr_getdetachstate"); + printf("%sdetach state = %s\en", prefix, + (i == pthread_create_detached) ? "pthread_create_detached" : + (i == pthread_create_joinable) ? "pthread_create_joinable" : + "???"); + + s = pthread_attr_getscope(attr, &i); + if (s != 0) + handle_error_en(s, "pthread_attr_getscope"); + printf("%sscope = %s\en", prefix, + (i == pthread_scope_system) ? "pthread_scope_system" : + (i == pthread_scope_process) ? "pthread_scope_process" : + "???"); + + s = pthread_attr_getinheritsched(attr, &i); + if (s != 0) + handle_error_en(s, "pthread_attr_getinheritsched"); + printf("%sinherit scheduler = %s\en", prefix, + (i == pthread_inherit_sched) ? "pthread_inherit_sched" : + (i == pthread_explicit_sched) ? "pthread_explicit_sched" : + "???"); + + s = pthread_attr_getschedpolicy(attr, &i); + if (s != 0) + handle_error_en(s, "pthread_attr_getschedpolicy"); + printf("%sscheduling policy = %s\en", prefix, + (i == sched_other) ? "sched_other" : + (i == sched_fifo) ? "sched_fifo" : + (i == sched_rr) ? "sched_rr" : + "???"); + + s = pthread_attr_getschedparam(attr, &sp); + if (s != 0) + handle_error_en(s, "pthread_attr_getschedparam"); + printf("%sscheduling priority = %d\en", prefix, sp.sched_priority); + + s = pthread_attr_getguardsize(attr, &v); + if (s != 0) + handle_error_en(s, "pthread_attr_getguardsize"); + printf("%sguard size = %zu bytes\en", prefix, v); + + s = pthread_attr_getstack(attr, &stkaddr, &v); + if (s != 0) + handle_error_en(s, "pthread_attr_getstack"); + printf("%sstack address = %p\en", prefix, stkaddr); + printf("%sstack size = %#zx bytes\en", prefix, v); +} + +static void * +thread_start(void *arg) +{ + int s; + pthread_attr_t gattr; + + /* pthread_getattr_np() is a non\-standard gnu extension that + retrieves the attributes of the thread specified in its + first argument. */ + + s = pthread_getattr_np(pthread_self(), &gattr); + if (s != 0) + handle_error_en(s, "pthread_getattr_np"); + + printf("thread attributes:\en"); + display_pthread_attr(&gattr, "\et"); + + exit(exit_success); /* terminate all threads */ +} + +int +main(int argc, char *argv[]) +{ + pthread_t thr; + pthread_attr_t attr; + pthread_attr_t *attrp; /* null or &attr */ + int s; + + attrp = null; + + /* if a command\-line argument was supplied, use it to set the + stack\-size attribute and set a few other thread attributes, + and set attrp pointing to thread attributes object. */ + + if (argc > 1) { + size_t stack_size; + void *sp; + + attrp = &attr; + + s = pthread_attr_init(&attr); + if (s != 0) + handle_error_en(s, "pthread_attr_init"); + + s = pthread_attr_setdetachstate(&attr, pthread_create_detached); + if (s != 0) + handle_error_en(s, "pthread_attr_setdetachstate"); + + s = pthread_attr_setinheritsched(&attr, pthread_explicit_sched); + if (s != 0) + handle_error_en(s, "pthread_attr_setinheritsched"); + + stack_size = strtoul(argv[1], null, 0); + + s = posix_memalign(&sp, sysconf(_sc_pagesize), stack_size); + if (s != 0) + handle_error_en(s, "posix_memalign"); + + printf("posix_memalign() allocated at %p\en", sp); + + s = pthread_attr_setstack(&attr, sp, stack_size); + if (s != 0) + handle_error_en(s, "pthread_attr_setstack"); + } + + s = pthread_create(&thr, attrp, &thread_start, null); + if (s != 0) + handle_error_en(s, "pthread_create"); + + if (attrp != null) { + s = pthread_attr_destroy(attrp); + if (s != 0) + handle_error_en(s, "pthread_attr_destroy"); + } + + pause(); /* terminates when other thread calls exit() */ +} +.ee +.sh see also +.ad l +.nh +.br pthread_attr_setaffinity_np (3), +.br pthread_attr_setdetachstate (3), +.br pthread_attr_setguardsize (3), +.br pthread_attr_setinheritsched (3), +.br pthread_attr_setschedparam (3), +.br pthread_attr_setschedpolicy (3), +.br pthread_attr_setscope (3), +.br pthread_attr_setsigmask_np (3), +.br pthread_attr_setstack (3), +.br pthread_attr_setstackaddr (3), +.br pthread_attr_setstacksize (3), +.br pthread_create (3), +.br pthread_getattr_np (3), +.br pthread_setattr_default_np (3), +.br pthreads (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/fseek.3 + +.\" copyright (c) 2008 linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th pthread_attr_setsigmask_np 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +pthread_attr_setsigmask_np, pthread_attr_getsigmask_np \- set/get +signal mask attribute in thread attributes object +.sh synopsis +.nf +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "int pthread_attr_setsigmask_np(pthread_attr_t *" attr , +.bi " const sigset_t *" sigmask ); +.bi "int pthread_attr_getsigmask_np(const pthread_attr_t *" attr , +.bi " sigset_t *" sigmask ); +.pp +compile and link with \fi\-pthread\fp. +.fi +.sh description +the +.br pthread_attr_setsigmask_np () +function sets the signal mask attribute of the +thread attributes object referred to by +.i attr +to the value specified in +.ir *sigmask . +if +.i sigmask +is specified as null, then any existing signal mask attribute in +.i attr +is unset. +.pp +the +.br pthread_attr_getsigmask_np () +function returns the signal mask attribute of the thread attributes object +referred to by +.ir attr +in the buffer pointed to by +.ir sigmask . +if the signal mask attribute is currently unset, +then this function returns the special value +.b pthread_attr_no_sigmask_np +as its result. +.sh return value +the +.br pthread_attr_setsigmask_np () +function returns 0 on success, or a nonzero error number on failure. +.pp +the +.br pthread_attr_getsigmask_np () +function returns either 0 or +.br pthread_attr_no_sigmask_np . +when 0 is returned, the signal mask attribute is returned via +.ir sigmask . +a return value of +.b pthread_attr_no_sigmask_np +indicates that the signal mask attribute is not set in +.ir attr . +.pp +on error, these functions return a positive error number. +.sh errors +.tp +.b enomem +.rb ( pthread_attr_setsigmask_np ()) +could not allocate memory. +.sh versions +these functions are provided by glibc since version 2.32. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br pthread_attr_setsigmask_np (), +.br pthread_attr_getsigmask_np () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +these functions are nonstandard gnu extensions; +hence the suffix "_np" (nonportable) in the names. +.sh notes +the signal mask attribute determines the signal mask that will be assigned to +a thread created using the thread attributes object +.ir attr . +if this attribute is not set, then a thread created using +.i attr +will inherit a copy of the creating thread's signal mask. +.pp +for more details on signal masks, see +.br sigprocmask (2). +for a description of a set of macros +that can be used to manipulate and inspect signal sets, see +.br sigsetops (3). +.pp +in the absence of +.br pthread_attr_setsigmask_np () +it is possible to create a thread with a desired signal mask as follows: +.ip \(bu 2 +the creating thread uses +.br pthread_sigmask (3) +to save its current signal mask and set its mask to block all signals. +.ip \(bu +the new thread is then created using +.br pthread_create (); +the new thread will inherit the creating thread's signal mask. +.ip \(bu +the new thread sets its signal mask to the desired value using +.br pthread_sigmask (3). +.ip \(bu +the creating thread restores its signal mask to the original value. +.pp +following the above steps, +there is no possibility for the new thread to receive a signal +before it has adjusted its signal mask to the desired value. +.sh see also +.br sigprocmask (2), +.br pthread_attr_init (3), +.br pthread_sigmask (3), +.br pthreads (7), +.br signal (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 7/93 by darren senn +.\" and copyright (c) 2016, michael kerrisk +.\" based on a similar page copyright 1992 by rick faith +.\" +.\" %%%license_start(freely_redistributable) +.\" may be freely distributed and modified +.\" %%%license_end +.\" +.\" modified tue oct 22 00:22:35 edt 1996 by eric s. raymond +.\" 2005-04-06 mtk, matthias lang +.\" noted max_sec_in_jiffies ceiling +.\" +.th getitimer 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +getitimer, setitimer \- get or set value of an interval timer +.sh synopsis +.nf +.b #include +.pp +.bi "int getitimer(int " which ", struct itimerval *" curr_value ); +.bi "int setitimer(int " which ", const struct itimerval *restrict " new_value , +.bi " struct itimerval *restrict " old_value ); +.fi +.sh description +these system calls provide access to interval timers, that is, +timers that initially expire at some point in the future, +and (optionally) at regular intervals after that. +when a timer expires, a signal is generated for the calling process, +and the timer is reset to the specified interval +(if the interval is nonzero). +.pp +three types of timers\(emspecified via the +.ir which +argument\(emare provided, +each of which counts against a different clock and +generates a different signal on timer expiration: +.tp +.b itimer_real +this timer counts down in real (i.e., wall clock) time. +at each expiration, a +.b sigalrm +signal is generated. +.tp +.b itimer_virtual +this timer counts down against the user-mode cpu time consumed by the process. +(the measurement includes cpu time consumed by all threads in the process.) +at each expiration, a +.b sigvtalrm +signal is generated. +.tp +.b itimer_prof +this timer counts down against the total (i.e., both user and system) +cpu time consumed by the process. +(the measurement includes cpu time consumed by all threads in the process.) +at each expiration, a +.b sigprof +signal is generated. +.ip +in conjunction with +.br itimer_virtual , +this timer can be used to profile user and system cpu time +consumed by the process. +.pp +a process has only one of each of the three types of timers. +.pp +timer values are defined by the following structures: +.pp +.in +4n +.ex +struct itimerval { + struct timeval it_interval; /* interval for periodic timer */ + struct timeval it_value; /* time until next expiration */ +}; + +struct timeval { + time_t tv_sec; /* seconds */ + suseconds_t tv_usec; /* microseconds */ +}; +.ee +.in +.\" +.ss getitimer() +the function +.br getitimer () +places the current value of the timer specified by +.ir which +in the buffer pointed to by +.ir curr_value . +.pp +the +.ir it_value +substructure is populated with the amount of time remaining until +the next expiration of the specified timer. +this value changes as the timer counts down, and will be reset to +.ir it_interval +when the timer expires. +if both fields of +.ir it_value +are zero, then this timer is currently disarmed (inactive). +.pp +the +.ir it_interval +substructure is populated with the timer interval. +if both fields of +.ir it_interval +are zero, then this is a single-shot timer (i.e., it expires just once). +.ss setitimer() +the function +.br setitimer () +arms or disarms the timer specified by +.ir which , +by setting the timer to the value specified by +.ir new_value . +if +.i old_value +is non-null, +the buffer it points to is used to return the previous value of the timer +(i.e., the same information that is returned by +.br getitimer ()). +.pp +if either field in +.ir new_value.it_value +is nonzero, +then the timer is armed to initially expire at the specified time. +if both fields in +.ir new_value.it_value +are zero, then the timer is disarmed. +.pp +the +.ir new_value.it_interval +field specifies the new interval for the timer; +if both of its subfields are zero, the timer is single-shot. +.sh return value +on success, zero is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b efault +.ir new_value , +.ir old_value , +or +.i curr_value +is not valid a pointer. +.tp +.b einval +.i which +is not one of +.br itimer_real , +.br itimer_virtual , +or +.br itimer_prof ; +or (since linux 2.6.22) one of the +.i tv_usec +fields in the structure pointed to by +.i new_value +contains a value outside the range 0 to 999999. +.sh conforming to +posix.1-2001, svr4, 4.4bsd (this call first appeared in 4.2bsd). +posix.1-2008 marks +.br getitimer () +and +.br setitimer () +obsolete, recommending the use of the posix timers api +.rb ( timer_gettime (2), +.br timer_settime (2), +etc.) instead. +.sh notes +timers will never expire before the requested time, +but may expire some (short) time afterward, which depends +on the system timer resolution and on the system load; see +.br time (7). +(but see bugs below.) +if the timer expires while the process is active (always true for +.br itimer_virtual ), +the signal will be delivered immediately when generated. +.pp +a child created via +.br fork (2) +does not inherit its parent's interval timers. +interval timers are preserved across an +.br execve (2). +.pp +posix.1 leaves the +interaction between +.br setitimer () +and the three interfaces +.br alarm (2), +.br sleep (3), +and +.br usleep (3) +unspecified. +.pp +the standards are silent on the meaning of the call: +.pp + setitimer(which, null, &old_value); +.pp +many systems (solaris, the bsds, and perhaps others) +treat this as equivalent to: +.pp + getitimer(which, &old_value); +.pp +in linux, this is treated as being equivalent to a call in which the +.i new_value +fields are zero; that is, the timer is disabled. +.ir "don't use this linux misfeature" : +it is nonportable and unnecessary. +.sh bugs +the generation and delivery of a signal are distinct, and +only one instance of each of the signals listed above may be pending +for a process. +under very heavy loading, an +.b itimer_real +timer may expire before the signal from a previous expiration +has been delivered. +the second signal in such an event will be lost. +.pp +on linux kernels before 2.6.16, timer values are represented in jiffies. +if a request is made set a timer with a value whose jiffies +representation exceeds +.b max_sec_in_jiffies +(defined in +.ir include/linux/jiffies.h ), +then the timer is silently truncated to this ceiling value. +on linux/i386 (where, since linux 2.6.13, +the default jiffy is 0.004 seconds), +this means that the ceiling value for a timer is +approximately 99.42 days. +since linux 2.6.16, +the kernel uses a different internal representation for times, +and this ceiling is removed. +.pp +on certain systems (including i386), +linux kernels before version 2.6.12 have a bug which will produce +premature timer expirations of up to one jiffy under some circumstances. +this bug is fixed in kernel 2.6.12. +.\" 4 jul 2005: it looks like this bug may remain in 2.4.x. +.\" http://lkml.org/lkml/2005/7/1/165 +.pp +posix.1-2001 says that +.br setitimer () +should fail if a +.i tv_usec +value is specified that is outside of the range 0 to 999999. +however, in kernels up to and including 2.6.21, +linux does not give an error, but instead silently +adjusts the corresponding seconds value for the timer. +from kernel 2.6.22 onward, +this nonconformance has been repaired: +an improper +.i tv_usec +value results in an +.b einval +error. +.\" bugzilla report 25 apr 2006: +.\" http://bugzilla.kernel.org/show_bug.cgi?id=6443 +.\" "setitimer() should reject noncanonical arguments" +.sh see also +.br gettimeofday (2), +.br sigaction (2), +.br signal (2), +.br timer_create (2), +.br timerfd_create (2), +.br time (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man5/filesystems.5 + +.\" copyright (c) 1983, 1990, 1991 the regents of the university of california. +.\" all rights reserved. +.\" +.\" %%%license_start(bsd_4_clause_ucb) +.\" redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. all advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" this product includes software developed by the university of +.\" california, berkeley and its contributors. +.\" 4. neither the name of the university nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" this software is provided by the regents and contributors ``as is'' and +.\" any express or implied warranties, including, but not limited to, the +.\" implied warranties of merchantability and fitness for a particular purpose +.\" are disclaimed. in no event shall the regents or contributors be liable +.\" for any direct, indirect, incidental, special, exemplary, or consequential +.\" damages (including, but not limited to, procurement of substitute goods +.\" or services; loss of use, data, or profits; or business interruption) +.\" however caused and on any theory of liability, whether in contract, strict +.\" liability, or tort (including negligence or otherwise) arising in any way +.\" out of the use of this software, even if advised of the possibility of +.\" such damage. +.\" %%%license_end +.\" +.\" modified 1993-07-24 by rik faith +.\" modified 1996-10-21 by eric s. raymond +.\" modified 1998-2000 by andi kleen to match linux 2.2 reality +.\" modified 2002-04-23 by roger luethi +.\" modified 2004-06-17 by michael kerrisk +.\" 2008-12-04, mtk, add documentation of accept4() +.\" +.th accept 2 2021-08-27 "linux" "linux programmer's manual" +.sh name +accept, accept4 \- accept a connection on a socket +.sh synopsis +.nf +.b #include +.pp +.bi "int accept(int " sockfd ", struct sockaddr *restrict " addr , +.bi " socklen_t *restrict " addrlen ); +.pp +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "int accept4(int " sockfd ", struct sockaddr *restrict " addr , +.bi " socklen_t *restrict " addrlen ", int " flags ); +.fi +.sh description +the +.br accept () +system call is used with connection-based socket types +.rb ( sock_stream , +.br sock_seqpacket ). +it extracts the first connection request on the queue of pending +connections for the listening socket, +.ir sockfd , +creates a new connected socket, and returns a new file +descriptor referring to that socket. +the newly created socket is not in the listening state. +the original socket +.i sockfd +is unaffected by this call. +.pp +the argument +.i sockfd +is a socket that has been created with +.br socket (2), +bound to a local address with +.br bind (2), +and is listening for connections after a +.br listen (2). +.pp +the argument +.i addr +is a pointer to a +.i sockaddr +structure. +this structure is filled in with the address of the peer socket, +as known to the communications layer. +the exact format of the address returned +.i addr +is determined by the socket's address family (see +.br socket (2) +and the respective protocol man pages). +when +.i addr +is null, nothing is filled in; in this case, +.i addrlen +is not used, and should also be null. +.pp +the +.i addrlen +argument is a value-result argument: +the caller must initialize it to contain the +size (in bytes) of the structure pointed to by +.ir addr ; +on return it will contain the actual size of the peer address. +.pp +the returned address is truncated if the buffer provided is too small; +in this case, +.i addrlen +will return a value greater than was supplied to the call. +.pp +if no pending +connections are present on the queue, and the socket is not marked as +nonblocking, +.br accept () +blocks the caller until a connection is present. +if the socket is marked +nonblocking and no pending connections are present on the queue, +.br accept () +fails with the error +.br eagain +or +.br ewouldblock . +.pp +in order to be notified of incoming connections on a socket, you can use +.br select (2), +.br poll (2), +or +.br epoll (7). +a readable event will be delivered when a new connection is attempted and you +may then call +.br accept () +to get a socket for that connection. +alternatively, you can set the socket to deliver +.b sigio +when activity occurs on a socket; see +.br socket (7) +for details. +.pp +if +.ir flags +is 0, then +.br accept4 () +is the same as +.br accept (). +the following values can be bitwise ored in +.ir flags +to obtain different behavior: +.tp 16 +.b sock_nonblock +set the +.br o_nonblock +file status flag on the open file description (see +.br open (2)) +referred to by the new file descriptor. +using this flag saves extra calls to +.br fcntl (2) +to achieve the same result. +.tp +.b sock_cloexec +set the close-on-exec +.rb ( fd_cloexec ) +flag on the new file descriptor. +see the description of the +.b o_cloexec +flag in +.br open (2) +for reasons why this may be useful. +.sh return value +on success, +these system calls return a file descriptor +for the accepted socket (a nonnegative integer). +on error, \-1 is returned, +.i errno +is set to indicate the error, and +.i addrlen +is left unchanged. +.ss error handling +linux +.br accept () +(and +.br accept4 ()) +passes already-pending network errors on the new socket +as an error code from +.br accept (). +this behavior differs from other bsd socket +implementations. +for reliable operation the application should detect +the network errors defined for the protocol after +.br accept () +and treat +them like +.b eagain +by retrying. +in the case of tcp/ip, these are +.br enetdown , +.br eproto , +.br enoprotoopt , +.br ehostdown , +.br enonet , +.br ehostunreach , +.br eopnotsupp , +and +.br enetunreach . +.sh errors +.tp +.br eagain " or " ewouldblock +.\" actually eagain on linux +the socket is marked nonblocking and no connections are +present to be accepted. +posix.1-2001 and posix.1-2008 +allow either error to be returned for this case, +and do not require these constants to have the same value, +so a portable application should check for both possibilities. +.tp +.b ebadf +.i sockfd +is not an open file descriptor. +.tp +.b econnaborted +a connection has been aborted. +.tp +.b efault +the +.i addr +argument is not in a writable part of the user address space. +.tp +.b eintr +the system call was interrupted by a signal that was caught +before a valid connection arrived; see +.br signal (7). +.tp +.b einval +socket is not listening for connections, or +.i addrlen +is invalid (e.g., is negative). +.tp +.b einval +.rb ( accept4 ()) +invalid value in +.ir flags . +.tp +.b emfile +the per-process limit on the number of open file descriptors has been reached. +.tp +.b enfile +the system-wide limit on the total number of open files has been reached. +.tp +.br enobufs ", " enomem +not enough free memory. +this often means that the memory allocation is limited by the socket buffer +limits, not by the system memory. +.tp +.b enotsock +the file descriptor +.i sockfd +does not refer to a socket. +.tp +.b eopnotsupp +the referenced socket is not of type +.br sock_stream . +.tp +.b eperm +firewall rules forbid connection. +.tp +.b eproto +protocol error. +.pp +in addition, network errors for the new socket and as defined +for the protocol may be returned. +various linux kernels can +return other errors such as +.br enosr , +.br esocktnosupport , +.br eprotonosupport , +.br etimedout . +the value +.b erestartsys +may be seen during a trace. +.sh versions +the +.br accept4 () +system call is available starting with linux 2.6.28; +support in glibc is available starting with version 2.10. +.sh conforming to +.br accept (): +posix.1-2001, posix.1-2008, +svr4, 4.4bsd +.rb ( accept () +first appeared in 4.2bsd). +.\" the bsd man page documents five possible error returns +.\" (ebadf, enotsock, eopnotsupp, ewouldblock, efault). +.\" posix.1-2001 documents errors +.\" eagain, ebadf, econnaborted, eintr, einval, emfile, +.\" enfile, enobufs, enomem, enotsock, eopnotsupp, eproto, ewouldblock. +.\" in addition, susv2 documents efault and enosr. +.pp +.br accept4 () +is a nonstandard linux extension. +.pp +on linux, the new socket returned by +.br accept () +does \finot\fp inherit file status flags such as +.b o_nonblock +and +.b o_async +from the listening socket. +this behavior differs from the canonical bsd sockets implementation. +.\" some testing seems to show that tru64 5.1 and hp-ux 11 also +.\" do not inherit file status flags -- mtk jun 05 +portable programs should not rely on inheritance or noninheritance +of file status flags and always explicitly set all required flags on +the socket returned from +.br accept (). +.sh notes +there may not always be a connection waiting after a +.b sigio +is delivered or +.br select (2), +.br poll (2), +or +.br epoll (7) +return a readability event because the connection might have been +removed by an asynchronous network error or another thread before +.br accept () +is called. +if this happens, then the call will block waiting for the next +connection to arrive. +to ensure that +.br accept () +never blocks, the passed socket +.i sockfd +needs to have the +.b o_nonblock +flag set (see +.br socket (7)). +.pp +for certain protocols which require an explicit confirmation, +such as decnet, +.br accept () +can be thought of as merely dequeuing the next connection request and not +implying confirmation. +confirmation can be implied by +a normal read or write on the new file descriptor, and rejection can be +implied by closing the new socket. +currently, only decnet has these semantics on linux. +.\" +.ss the socklen_t type +in the original bsd sockets implementation (and on other older systems) +.\" such as linux libc4 and libc5, sunos 4, sgi +the third argument of +.br accept () +was declared as an \fiint\ *\fp. +a posix.1g draft +standard wanted to change it into a \fisize_t\ *\fpc; +.\" sunos 5 has 'size_t *' +later posix standards and glibc 2.x have +.ir "socklen_t\ * ". +.sh examples +see +.br bind (2). +.sh see also +.br bind (2), +.br connect (2), +.br listen (2), +.br select (2), +.br socket (2), +.br socket (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" peter memishian -- meem@gnu.ai.mit.edu +.\" $id: insque.3,v 1.2 1996/10/30 21:03:39 meem exp meem $ +.\" and copyright (c) 2010, michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code (5.4.7) +.\" solaris 2.x, osf/1, and hp-ux manpages +.\" curry's "unix systems programming for svr4" (o'reilly & associates 1996) +.\" +.\" changed to posix, 2003-08-11, aeb+wh +.\" mtk, 2010-09-09: noted glibc 2.4 bug, added info on circular +.\" lists, added example program +.\" +.th insque 3 2021-03-22 "" "linux programmer's manual" +.sh name +insque, remque \- insert/remove an item from a queue +.sh synopsis +.nf +.b #include +.pp +.bi "void insque(void *" elem ", void *" prev ); +.bi "void remque(void *" elem ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br insque (), +.br remque (): +.nf + _xopen_source >= 500 +.\" || _xopen_source && _xopen_source_extended + || /* glibc since 2.19: */ _default_source + || /* glibc <= 2.19: */ _svid_source +.fi +.sh description +the +.br insque () +and +.br remque () +functions manipulate doubly linked lists. +each element in the list is a structure of +which the first two elements are a forward and a +backward pointer. +the linked list may be linear (i.e., null forward pointer at +the end of the list and null backward pointer at the start of the list) +or circular. +.pp +the +.br insque () +function inserts the element pointed to by \fielem\fp +immediately after the element pointed to by \fiprev\fp. +.pp +if the list is linear, then the call +.i "insque(elem, null)" +can be used to insert the initial list element, +and the call sets the forward and backward pointers of +.i elem +to null. +.pp +if the list is circular, +the caller should ensure that the forward and backward pointers of the +first element are initialized to point to that element, +and the +.i prev +argument of the +.br insque () +call should also point to the element. +.pp +the +.br remque () +function removes the element pointed to by \fielem\fp from the +doubly linked list. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br insque (), +.br remque () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +on ancient systems, +.\" e.g., sunos, linux libc4 and libc5 +the arguments of these functions were of type \fistruct qelem *\fp, +defined as: +.pp +.in +4n +.ex +struct qelem { + struct qelem *q_forw; + struct qelem *q_back; + char q_data[1]; +}; +.ee +.in +.pp +this is still what you will get if +.b _gnu_source +is defined before +including \fi\fp. +.pp +the location of the prototypes for these functions differs among several +versions of unix. +the above is the posix version. +some systems place them in \fi\fp. +.\" linux libc4 and libc 5 placed them +.\" in \fi\fp. +.sh bugs +in glibc 2.4 and earlier, it was not possible to specify +.i prev +as null. +consequently, to build a linear list, the caller had to build a list +using an initial call that contained the first two elements of the list, +with the forward and backward pointers in each element suitably initialized. +.sh examples +the program below demonstrates the use of +.br insque (). +here is an example run of the program: +.pp +.in +4n +.ex +.rb "$ " "./a.out \-c a b c" +traversing completed list: + a + b + c +that was a circular list +.ee +.in +.ss program source +\& +.ex +#include +#include +#include +#include + +struct element { + struct element *forward; + struct element *backward; + char *name; +}; + +static struct element * +new_element(void) +{ + struct element *e = malloc(sizeof(*e)); + if (e == null) { + fprintf(stderr, "malloc() failed\en"); + exit(exit_failure); + } + + return e; +} + +int +main(int argc, char *argv[]) +{ + struct element *first, *elem, *prev; + int circular, opt, errfnd; + + /* the "\-c" command\-line option can be used to specify that the + list is circular. */ + + errfnd = 0; + circular = 0; + while ((opt = getopt(argc, argv, "c")) != \-1) { + switch (opt) { + case \(aqc\(aq: + circular = 1; + break; + default: + errfnd = 1; + break; + } + } + + if (errfnd || optind >= argc) { + fprintf(stderr, "usage: %s [\-c] string...\en", argv[0]); + exit(exit_failure); + } + + /* create first element and place it in the linked list. */ + + elem = new_element(); + first = elem; + + elem\->name = argv[optind]; + + if (circular) { + elem\->forward = elem; + elem\->backward = elem; + insque(elem, elem); + } else { + insque(elem, null); + } + + /* add remaining command\-line arguments as list elements. */ + + while (++optind < argc) { + prev = elem; + + elem = new_element(); + elem\->name = argv[optind]; + insque(elem, prev); + } + + /* traverse the list from the start, printing element names. */ + + printf("traversing completed list:\en"); + elem = first; + do { + printf(" %s\en", elem\->name); + elem = elem\->forward; + } while (elem != null && elem != first); + + if (elem == first) + printf("that was a circular list\en"); + + exit(exit_success); +} +.ee +.sh see also +.br queue (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/outb.2 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sun jul 25 10:54:03 1993 by rik faith (faith@cs.unc.edu) +.\" fixed typo, aeb, 950823 +.\" 2002-02-22, joey, mihtjel: added strtoull() +.\" +.th strtoul 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +strtoul, strtoull, strtouq \- convert a string to an unsigned long integer +.sh synopsis +.nf +.b #include +.pp +.bi "unsigned long strtoul(const char *restrict " nptr , +.bi " char **restrict " endptr ", int " base ); +.bi "unsigned long long strtoull(const char *restrict " nptr , +.bi " char **restrict " endptr ", int " base ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br strtoull (): +.nf + _isoc99_source + || /* glibc <= 2.19: */ _svid_source || _bsd_source +.fi +.sh description +the +.br strtoul () +function converts the initial part of the string +in +.i nptr +to an +.i "unsigned long" +value according to the +given +.ir base , +which must be between 2 and 36 inclusive, or be +the special value 0. +.pp +the string may begin with an arbitrary amount of white space (as +determined by +.br isspace (3)) +followed by a single optional \(aq+\(aq or \(aq\-\(aq +sign. +if +.i base +is zero or 16, the string may then include a +"0x" prefix, and the number will be read in base 16; otherwise, a +zero +.i base +is taken as 10 (decimal) unless the next character +is \(aq0\(aq, in which case it is taken as 8 (octal). +.pp +the remainder of the string is converted to an +.i "unsigned long" +value in the obvious manner, +stopping at the first character which is not a +valid digit in the given base. +(in bases above 10, the letter \(aqa\(aq in +either uppercase or lowercase represents 10, \(aqb\(aq represents 11, and so +forth, with \(aqz\(aq representing 35.) +.pp +if +.i endptr +is not null, +.br strtoul () +stores the address of the +first invalid character in +.ir *endptr . +if there were no digits at +all, +.br strtoul () +stores the original value of +.i nptr +in +.i *endptr +(and returns 0). +in particular, if +.i *nptr +is not \(aq\e0\(aq but +.i **endptr +is \(aq\e0\(aq on return, the entire string is valid. +.pp +the +.br strtoull () +function works just like the +.br strtoul () +function but returns an +.i "unsigned long long" +value. +.sh return value +the +.br strtoul () +function returns either the result of the conversion +or, if there was a leading minus sign, the negation of the result of the +conversion represented as an unsigned value, +unless the original (nonnegated) value would overflow; in +the latter case, +.br strtoul () +returns +.b ulong_max +and sets +.i errno +to +.br erange . +precisely the same holds for +.br strtoull () +(with +.b ullong_max +instead of +.br ulong_max ). +.sh errors +.tp +.b einval +(not in c99) +the given +.i base +contains an unsupported value. +.tp +.b erange +the resulting value was out of range. +.pp +the implementation may also set +.ir errno +to +.b einval +in case +no conversion was performed (no digits seen, and 0 returned). +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br strtoul (), +.br strtoull (), +.br strtouq () +t} thread safety mt-safe locale +.te +.hy +.ad +.sp 1 +.sh conforming to +.br strtoul (): +posix.1-2001, posix.1-2008, c89, c99 svr4. +.pp +.br strtoull (): +posix.1-2001, posix.1-2008, c99. +.sh notes +since +.br strtoul () +can legitimately return 0 or +.b ulong_max +.rb ( ullong_max +for +.br strtoull ()) +on both success and failure, the calling program should set +.i errno +to 0 before the call, +and then determine if an error occurred by checking whether +.i errno +has a nonzero value after the call. +.pp +in locales other than the "c" locale, other strings may be accepted. +(for example, the thousands separator of the current locale may be +supported.) +.pp +bsd also has +.pp +.in +4n +.ex +.bi "u_quad_t strtouq(const char *" nptr ", char **" endptr ", int " base ); +.ee +.in +.pp +with completely analogous definition. +depending on the wordsize of the current architecture, this +may be equivalent to +.br strtoull () +or to +.br strtoul (). +.pp +negative values are considered valid input and are +silently converted to the equivalent +.i "unsigned long" +value. +.sh examples +see the example on the +.br strtol (3) +manual page; +the use of the functions described in this manual page is similar. +.sh see also +.br a64l (3), +.br atof (3), +.br atoi (3), +.br atol (3), +.br strtod (3), +.br strtol (3), +.br strtoumax (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/__ppc_yield.3 + +.\" copyright (c) 2017, oracle. all rights reserved. +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.th ioctl_getfsmap 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +ioctl_getfsmap \- retrieve the physical layout of the filesystem +.sh synopsis +.nf +.br "#include " "/* definition of " fs_ioc_getfsmap , +.br " fm?_of_*" ", and " *fmr_own_* " constants */" +.b #include +.pp +.bi "int ioctl(int " fd ", fs_ioc_getfsmap, struct fsmap_head * " arg ); +.fi +.sh description +this +.br ioctl (2) +operation retrieves physical extent mappings for a filesystem. +this information can be used to discover which files are mapped to a physical +block, examine free space, or find known bad blocks, among other things. +.pp +the sole argument to this operation should be a pointer to a single +.ir "struct fsmap_head" ":" +.pp +.in +4n +.ex +struct fsmap { + __u32 fmr_device; /* device id */ + __u32 fmr_flags; /* mapping flags */ + __u64 fmr_physical; /* device offset of segment */ + __u64 fmr_owner; /* owner id */ + __u64 fmr_offset; /* file offset of segment */ + __u64 fmr_length; /* length of segment */ + __u64 fmr_reserved[3]; /* must be zero */ +}; + +struct fsmap_head { + __u32 fmh_iflags; /* control flags */ + __u32 fmh_oflags; /* output flags */ + __u32 fmh_count; /* # of entries in array incl. input */ + __u32 fmh_entries; /* # of entries filled in (output) */ + __u64 fmh_reserved[6]; /* must be zero */ + + struct fsmap fmh_keys[2]; /* low and high keys for + the mapping search */ + struct fsmap fmh_recs[]; /* returned records */ +}; +.ee +.in +.pp +the two +.i fmh_keys +array elements specify the lowest and highest reverse-mapping +key for which the application would like physical mapping +information. +a reverse mapping key consists of the tuple (device, block, owner, offset). +the owner and offset fields are part of the key because some filesystems +support sharing physical blocks between multiple files and +therefore may return multiple mappings for a given physical block. +.pp +filesystem mappings are copied into the +.i fmh_recs +array, which immediately follows the header data. +.\" +.ss fields of struct fsmap_head +the +.i fmh_iflags +field is a bit mask passed to the kernel to alter the output. +no flags are currently defined, so the caller must set this value to zero. +.pp +the +.i fmh_oflags +field is a bit mask of flags set by the kernel concerning the returned mappings. +if +.b fmh_of_dev_t +is set, then the +.i fmr_device +field represents a +.i dev_t +structure containing the major and minor numbers of the block device. +.pp +the +.i fmh_count +field contains the number of elements in the array being passed to the +kernel. +if this value is 0, +.i fmh_entries +will be set to the number of records that would have been returned had +the array been large enough; +no mapping information will be returned. +.pp +the +.i fmh_entries +field contains the number of elements in the +.i fmh_recs +array that contain useful information. +.pp +the +.i fmh_reserved +fields must be set to zero. +.\" +.ss keys +the two key records in +.i fsmap_head.fmh_keys +specify the lowest and highest extent records in the keyspace that the caller +wants returned. +a filesystem that can share blocks between files likely requires the tuple +.ri "(" "device" ", " "physical" ", " "owner" ", " "offset" ", " "flags" ")" +to uniquely index any filesystem mapping record. +classic non-sharing filesystems might be able to identify any record with only +.ri "(" "device" ", " "physical" ", " "flags" ")." +for example, if the low key is set to (8:0, 36864, 0, 0, 0), the filesystem will +only return records for extents starting at or above 36\ kib on disk. +if the high key is set to (8:0, 1048576, 0, 0, 0), only records below 1\ mib will +be returned. +the format of +.i fmr_device +in the keys must match the format of the same field in the output records, +as defined below. +by convention, the field +.i fsmap_head.fmh_keys[0] +must contain the low key and +.i fsmap_head.fmh_keys[1] +must contain the high key for the request. +.pp +for convenience, if +.i fmr_length +is set in the low key, it will be added to +.ir fmr_block " or " fmr_offset +as appropriate. +the caller can take advantage of this subtlety to set up subsequent calls +by copying +.i fsmap_head.fmh_recs[fsmap_head.fmh_entries \- 1] +into the low key. +the function +.i fsmap_advance +(defined in +.ir linux/fsmap.h ) +provides this functionality. +.\" +.ss fields of struct fsmap +the +.i fmr_device +field uniquely identifies the underlying storage device. +if the +.b fmh_of_dev_t +flag is set in the header's +.i fmh_oflags +field, this field contains a +.i dev_t +from which major and minor numbers can be extracted. +if the flag is not set, this field contains a value that must be unique +for each unique storage device. +.pp +the +.i fmr_physical +field contains the disk address of the extent in bytes. +.pp +the +.i fmr_owner +field contains the owner of the extent. +this is an inode number unless +.b fmr_of_special_owner +is set in the +.i fmr_flags +field, in which case the value is determined by the filesystem. +see the section below about owner values for more details. +.pp +the +.i fmr_offset +field contains the logical address in the mapping record in bytes. +this field has no meaning if the +.br fmr_of_special_owner " or " fmr_of_extent_map +flags are set in +.ir fmr_flags "." +.pp +the +.i fmr_length +field contains the length of the extent in bytes. +.pp +the +.i fmr_flags +field is a bit mask of extent state flags. +the bits are: +.rs 0.4i +.tp +.b fmr_of_prealloc +the extent is allocated but not yet written. +.tp +.b fmr_of_attr_fork +this extent contains extended attribute data. +.tp +.b fmr_of_extent_map +this extent contains extent map information for the owner. +.tp +.b fmr_of_shared +parts of this extent may be shared. +.tp +.b fmr_of_special_owner +the +.i fmr_owner +field contains a special value instead of an inode number. +.tp +.b fmr_of_last +this is the last record in the data set. +.re +.pp +the +.i fmr_reserved +field will be set to zero. +.\" +.ss owner values +generally, the value of the +.i fmr_owner +field for non-metadata extents should be an inode number. +however, filesystems are under no obligation to report inode numbers; +they may instead report +.b fmr_own_unknown +if the inode number cannot easily be retrieved, if the caller lacks +sufficient privilege, if the filesystem does not support stable +inode numbers, or for any other reason. +if a filesystem wishes to condition the reporting of inode numbers based +on process capabilities, it is strongly urged that the +.b cap_sys_admin +capability be used for this purpose. +.tp +the following special owner values are generic to all filesystems: +.rs 0.4i +.tp +.b fmr_own_free +free space. +.tp +.b fmr_own_unknown +this extent is in use but its owner is not known or not easily retrieved. +.tp +.b fmr_own_metadata +this extent is filesystem metadata. +.re +.pp +xfs can return the following special owner values: +.rs 0.4i +.tp +.b xfs_fmr_own_free +free space. +.tp +.b xfs_fmr_own_unknown +this extent is in use but its owner is not known or not easily retrieved. +.tp +.b xfs_fmr_own_fs +static filesystem metadata which exists at a fixed address. +these are the ag superblock, the agf, the agfl, and the agi headers. +.tp +.b xfs_fmr_own_log +the filesystem journal. +.tp +.b xfs_fmr_own_ag +allocation group metadata, such as the free space btrees and the +reverse mapping btrees. +.tp +.b xfs_fmr_own_inobt +the inode and free inode btrees. +.tp +.b xfs_fmr_own_inodes +inode records. +.tp +.b xfs_fmr_own_refc +reference count information. +.tp +.b xfs_fmr_own_cow +this extent is being used to stage a copy-on-write. +.tp +.b xfs_fmr_own_defective: +this extent has been marked defective either by the filesystem or the +underlying device. +.re +.pp +ext4 can return the following special owner values: +.rs 0.4i +.tp +.b ext4_fmr_own_free +free space. +.tp +.b ext4_fmr_own_unknown +this extent is in use but its owner is not known or not easily retrieved. +.tp +.b ext4_fmr_own_fs +static filesystem metadata which exists at a fixed address. +this is the superblock and the group descriptors. +.tp +.b ext4_fmr_own_log +the filesystem journal. +.tp +.b ext4_fmr_own_inodes +inode records. +.tp +.b ext4_fmr_own_blkbm +block bit map. +.tp +.b ext4_fmr_own_inobm +inode bit map. +.re +.sh return value +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +the error placed in +.i errno +can be one of, but is not limited to, the following: +.tp +.b ebadf +.ir fd +is not open for reading. +.tp +.b ebadmsg +the filesystem has detected a checksum error in the metadata. +.tp +.b efault +the pointer passed in was not mapped to a valid memory address. +.tp +.b einval +the array is not long enough, the keys do not point to a valid part of +the filesystem, the low key points to a higher point in the filesystem's +physical storage address space than the high key, or a nonzero value +was passed in one of the fields that must be zero. +.tp +.b enomem +insufficient memory to process the request. +.tp +.b eopnotsupp +the filesystem does not support this command. +.tp +.b euclean +the filesystem metadata is corrupt and needs repair. +.sh versions +the +.b fs_ioc_getfsmap +operation first appeared in linux 4.12. +.sh conforming to +this api is linux-specific. +not all filesystems support it. +.sh examples +see +.i io/fsmap.c +in the +.i xfsprogs +distribution for a sample program. +.sh see also +.br ioctl (2) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/xdr.3 + +.so man2/mlock.2 + +.\" copyright (c) 2015, ibm corporation. +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of +.\" this manual under the conditions for verbatim copying, provided that +.\" the entire resulting derived work is distributed under the terms of +.\" a permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume. +.\" no responsibility for errors or omissions, or for damages resulting. +.\" from the use of the information contained herein. the author(s) may. +.\" not have taken the same level of care in the production of this. +.\" manual, which is licensed free of charge, as they might when working. +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th __ppc_yield 3 2021-03-22 "gnu c library" "linux programmer's\ +manual" +.sh name +__ppc_yield, __ppc_mdoio, __ppc_mdoom \- +hint the processor to release shared resources +.sh synopsis +.nf +.b #include +.pp +.b void __ppc_yield(void); +.b void __ppc_mdoio(void); +.b void __ppc_mdoom(void); +.fi +.sh description +these functions +provide hints about the usage of resources that are shared with other +processors on the power architecture. +they can be used, for example, if a program waiting on a lock intends +to divert the shared resources to be used by other processors. +.pp +.br __ppc_yield () +provides a hint that performance will probably be improved if shared +resources dedicated to the executing processor are released for use by +other processors. +.pp +.br __ppc_mdoio () +provides a hint that performance will probably be improved if shared +resources dedicated to the executing processor are released until all +outstanding storage accesses to caching-inhibited storage have been +completed. +.pp +.br __ppc_mdoom () +provides a hint that performance will probably be improved if shared +resources dedicated to the executing processor are released until all +outstanding storage accesses to cacheable storage for which the data +is not in the cache have been completed. +.sh versions +these functions first appeared in glibc in version 2.18. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br __ppc_yield (), +.br __ppc_mdoio (), +.br __ppc_mdoom () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +these functions are nonstandard gnu extensions. +.sh see also +.br __ppc_set_ppr_med (3) +.pp +.ir "power isa, book\ ii - section\ 3.2 (""or"" architecture)" +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1993 by thomas koenig (ig25@rz.uni-karlsruhe.de) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified wed jul 28 11:12:17 1993 by rik faith (faith@cs.unc.edu) +.\" modified mon may 13 23:08:50 1996 by martin schulze (joey@linux.de) +.\" modified 11 may 1998 by joseph s. myers (jsm28@cam.ac.uk) +.\" modified 990912 by aeb +.\" 2007-10-10 mtk +.\" added description of glob_tilde_nomatch +.\" expanded the description of various flags +.\" various wording fixes. +.\" +.th glob 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +glob, globfree \- find pathnames matching a pattern, free memory from glob() +.sh synopsis +.nf +.b #include +.pp +.bi "int glob(const char *restrict " pattern ", int " flags , +.bi " int (*" errfunc ")(const char *" epath ", int " eerrno ), +.bi " glob_t *restrict " pglob ); +.bi "void globfree(glob_t *" pglob ); +.fi +.sh description +the +.br glob () +function searches for all the pathnames matching +.i pattern +according to the rules used by the shell (see +.br glob (7)). +no tilde expansion or parameter substitution is done; if you want +these, use +.br wordexp (3). +.pp +the +.br globfree () +function frees the dynamically allocated storage from an earlier call +to +.br glob (). +.pp +the results of a +.br glob () +call are stored in the structure pointed to by +.ir pglob . +this structure is of type +.i glob_t +(declared in +.ir ) +and includes the following elements defined by posix.2 (more may be +present as an extension): +.pp +.in +4n +.ex +typedef struct { + size_t gl_pathc; /* count of paths matched so far */ + char **gl_pathv; /* list of matched pathnames. */ + size_t gl_offs; /* slots to reserve in \figl_pathv\fp. */ +} glob_t; +.ee +.in +.pp +results are stored in dynamically allocated storage. +.pp +the argument +.i flags +is made up of the bitwise or of zero or more the following symbolic +constants, which modify the behavior of +.br glob (): +.tp +.b glob_err +return upon a read error (because a directory does not +have read permission, for example). +by default, +.br glob () +attempts carry on despite errors, +reading all of the directories that it can. +.tp +.b glob_mark +append a slash to each path which corresponds to a directory. +.tp +.b glob_nosort +don't sort the returned pathnames. +the only reason to do this is to save processing time. +by default, the returned pathnames are sorted. +.tp +.b glob_dooffs +reserve +.i pglob\->gl_offs +slots at the beginning of the list of strings in +.ir pglob\->pathv . +the reserved slots contain null pointers. +.tp +.b glob_nocheck +if no pattern matches, return the original pattern. +by default, +.br glob () +returns +.b glob_nomatch +if there are no matches. +.tp +.b glob_append +append the results of this call to the vector of results +returned by a previous call to +.br glob (). +do not set this flag on the first invocation of +.br glob (). +.tp +.b glob_noescape +don't allow backslash (\(aq\e\(aq) to be used as an escape +character. +normally, a backslash can be used to quote the following character, +providing a mechanism to turn off the special meaning +metacharacters. +.pp +.i flags +may also include any of the following, which are gnu +extensions and not defined by posix.2: +.tp +.b glob_period +allow a leading period to be matched by metacharacters. +by default, metacharacters can't match a leading period. +.tp +.b glob_altdirfunc +use alternative functions +.ir pglob\->gl_closedir , +.ir pglob\->gl_readdir , +.ir pglob\->gl_opendir , +.ir pglob\->gl_lstat ", and" +.i pglob\->gl_stat +for filesystem access instead of the normal library +functions. +.tp +.b glob_brace +expand +.br csh (1) +style brace expressions of the form +.br {a,b} . +brace expressions can be nested. +thus, for example, specifying the pattern +"{foo/{,cat,dog},bar}" would return the same results as four separate +.br glob () +calls using the strings: +"foo/", +"foo/cat", +"foo/dog", +and +"bar". +.tp +.b glob_nomagic +if the pattern contains no metacharacters, +then it should be returned as the sole matching word, +even if there is no file with that name. +.tp +.b glob_tilde +carry out tilde expansion. +if a tilde (\(aq\(ti\(aq) is the only character in the pattern, +or an initial tilde is followed immediately by a slash (\(aq/\(aq), +then the home directory of the caller is substituted for +the tilde. +if an initial tilde is followed by a username (e.g., "\(tiandrea/bin"), +then the tilde and username are substituted by the home directory +of that user. +if the username is invalid, or the home directory cannot be +determined, then no substitution is performed. +.tp +.b glob_tilde_check +this provides behavior similar to that of +.br glob_tilde . +the difference is that if the username is invalid, or the +home directory cannot be determined, then +instead of using the pattern itself as the name, +.br glob () +returns +.br glob_nomatch +to indicate an error. +.tp +.b glob_onlydir +this is a +.i hint +to +.br glob () +that the caller is interested only in directories that match the pattern. +if the implementation can easily determine file-type information, +then nondirectory files are not returned to the caller. +however, the caller must still check that returned files +are directories. +(the purpose of this flag is merely to optimize performance when +the caller is interested only in directories.) +.pp +if +.i errfunc +is not null, +it will be called in case of an error with the arguments +.ir epath , +a pointer to the path which failed, and +.ir eerrno , +the value of +.i errno +as returned from one of the calls to +.br opendir (3), +.br readdir (3), +or +.br stat (2). +if +.i errfunc +returns nonzero, or if +.b glob_err +is set, +.br glob () +will terminate after the call to +.ir errfunc . +.pp +upon successful return, +.i pglob\->gl_pathc +contains the number of matched pathnames and +.i pglob\->gl_pathv +contains a pointer to the list of pointers to matched pathnames. +the list of pointers is terminated by a null pointer. +.pp +it is possible to call +.br glob () +several times. +in that case, the +.b glob_append +flag has to be set in +.i flags +on the second and later invocations. +.pp +as a gnu extension, +.i pglob\->gl_flags +is set to the flags specified, +.br or ed +with +.b glob_magchar +if any metacharacters were found. +.sh return value +on successful completion, +.br glob () +returns zero. +other possible returns are: +.tp +.b glob_nospace +for running out of memory, +.tp +.b glob_aborted +for a read error, and +.tp +.b glob_nomatch +for no found matches. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lb lb lbx +l l l. +interface attribute value +t{ +.br glob () +t} thread safety t{ +mt-unsafe race:utent env +sig:alrm timer locale +t} +t{ +.br globfree () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +in the above table, +.i utent +in +.i race:utent +signifies that if any of the functions +.br setutent (3), +.br getutent (3), +or +.br endutent (3) +are used in parallel in different threads of a program, +then data races could occur. +.br glob () +calls those functions, +so we use race:utent to remind users. +.sh conforming to +posix.1-2001, posix.1-2008, posix.2. +.sh notes +the structure elements +.i gl_pathc +and +.i gl_offs +are declared as +.i size_t +in glibc 2.1, as they should be according to posix.2, +but are declared as +.i int +in glibc 2.0. +.sh bugs +the +.br glob () +function may fail due to failure of underlying function calls, such as +.br malloc (3) +or +.br opendir (3). +these will store their error code in +.ir errno . +.sh examples +one example of use is the following code, which simulates typing +.pp +.in +4n +.ex +ls \-l *.c ../*.c +.ee +.in +.pp +in the shell: +.pp +.in +4n +.ex +glob_t globbuf; + +globbuf.gl_offs = 2; +glob("*.c", glob_dooffs, null, &globbuf); +glob("../*.c", glob_dooffs | glob_append, null, &globbuf); +globbuf.gl_pathv[0] = "ls"; +globbuf.gl_pathv[1] = "\-l"; +execvp("ls", &globbuf.gl_pathv[0]); +.ee +.in +.sh see also +.br ls (1), +.br sh (1), +.br stat (2), +.br exec (3), +.br fnmatch (3), +.br malloc (3), +.br opendir (3), +.br readdir (3), +.br wordexp (3), +.br glob (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/inet.3 + +.so man3/envz_add.3 + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" iso/iec 9899:1999 +.\" +.th iswalpha 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +iswalpha \- test for alphabetic wide character +.sh synopsis +.nf +.b #include +.pp +.bi "int iswalpha(wint_t " wc ); +.fi +.sh description +the +.br iswalpha () +function is the wide-character equivalent of the +.br isalpha (3) +function. +it tests whether +.i wc +is a wide character +belonging to the wide-character class "alpha". +.pp +the wide-character class "alpha" is a subclass of the +wide-character class "alnum", +and therefore also a subclass of the wide-character class "graph" and +of the wide-character class "print". +.pp +being a subclass of the wide-character class "print", +the wide-character class +"alpha" is disjoint from the wide-character class "cntrl". +.pp +being a subclass of the wide-character class "graph", +the wide-character class "alpha" is disjoint from +the wide-character class "space" and its subclass "blank". +.pp +being a subclass of the wide-character class "alnum", +the wide-character class "alpha" is disjoint from the +wide-character class "punct". +.pp +the wide-character class "alpha" is disjoint from the wide-character class +"digit". +.pp +the wide-character class "alpha" contains the wide-character classes "upper" +and "lower". +.pp +the wide-character class "alpha" always contains at least the +letters \(aqa\(aq to \(aqz\(aq and \(aqa\(aq to \(aqz\(aq. +.sh return value +the +.br iswalpha () +function returns nonzero +if +.i wc +is a wide character +belonging to the wide-character class "alpha". +otherwise, it returns zero. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br iswalpha () +t} thread safety mt-safe locale +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh notes +the behavior of +.br iswalpha () +depends on the +.b lc_ctype +category of the +current locale. +.sh see also +.br isalpha (3), +.br iswctype (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1996 andries brouwer (aeb@cwi.nl) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th msync 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +msync \- synchronize a file with a memory map +.sh synopsis +.nf +.b #include +.pp +.bi "int msync(void *" addr ", size_t " length ", int " flags ); +.fi +.sh description +.br msync () +flushes changes made to the in-core copy of a file that was mapped +into memory using +.br mmap (2) +back to the filesystem. +without use of this call, +there is no guarantee that changes are written back before +.br munmap (2) +is called. +to be more precise, the part of the file that +corresponds to the memory area starting at +.i addr +and having length +.i length +is updated. +.pp +the +.i flags +argument should specify exactly one of +.br ms_async +and +.br ms_sync , +and may additionally include the +.b ms_invalidate +bit. +these bits have the following meanings: +.tp +.b ms_async +specifies that an update be scheduled, but the call returns immediately. +.tp +.b ms_sync +requests an update and waits for it to complete. +.tp +.b ms_invalidate +.\" since linux 2.4, this seems to be a no-op (other than the +.\" ebusy check for vm_locked). +asks to invalidate other mappings of the same file +(so that they can be updated with the fresh values just written). +.sh return value +on success, zero is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b ebusy +.b ms_invalidate +was specified in +.ir flags , +and a memory lock exists for the specified address range. +.tp +.b einval +.i addr +is not a multiple of pagesize; or any bit other than +.br ms_async " | " ms_invalidate " | " ms_sync +is set in +.ir flags ; +or both +.b ms_sync +and +.b ms_async +are set in +.ir flags . +.tp +.b enomem +the indicated memory (or part of it) was not mapped. +.sh conforming to +posix.1-2001, posix.1-2008. +.pp +this call was introduced in linux 1.3.21, and then used +.b efault +instead of +.br enomem . +in linux 2.4.19, this was changed to the posix value +.br enomem . +.pp +on posix systems on which +.br msync () +is available, both +.b _posix_mapped_files +and +.b _posix_synchronized_io +are defined in +.i +to a value greater than 0. +(see also +.br sysconf (3).) +.\" posix.1-2001: it shall be defined to -1 or 0 or 200112l. +.\" -1: unavailable, 0: ask using sysconf(). +.\" glibc defines them to 1. +.sh notes +according to posix, either +.br ms_sync +or +.br ms_async +must be specified in +.ir flags , +and indeed failure to include one of these flags will cause +.br msync () +to fail on some systems. +however, linux permits a call to +.br msync () +that specifies neither of these flags, +with semantics that are (currently) equivalent to specifying +.br ms_async . +(since linux 2.6.19, +.\" commit 204ec841fbea3e5138168edbc3a76d46747cc987 +.br ms_async +is in fact a no-op, since the kernel properly tracks dirty +pages and flushes them to storage as necessary.) +notwithstanding the linux behavior, +portable, future-proof applications should ensure that they specify either +.br ms_sync +or +.br ms_async +in +.ir flags . +.sh see also +.br mmap (2) +.pp +b.o. gallmeister, posix.4, o'reilly, pp. 128\(en129 and 389\(en391. +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/fpathconf.3 + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification +.\" http://www.unix-systems.org/online.html +.\" iso/iec 9899:1999 +.\" +.th putwchar 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +putwchar \- write a wide character to standard output +.sh synopsis +.nf +.b #include +.pp +.bi "wint_t putwchar(wchar_t " wc ); +.fi +.sh description +the +.br putwchar () +function is the wide-character equivalent of the +.br putchar (3) +function. +it writes the wide character +.i wc +to +.ir stdout . +if +.i ferror(stdout) +becomes true, it returns +.br weof . +if a wide character +conversion error occurs, it sets +.ir errno +to +.b eilseq +and returns +.br weof . +otherwise, it returns +.ir wc . +.pp +for a nonlocking counterpart, see +.br unlocked_stdio (3). +.sh return value +the +.br putwchar () +function returns +.i wc +if no error occurred, or +.b weof +to indicate an error. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br putwchar () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh notes +the behavior of +.br putwchar () +depends on the +.b lc_ctype +category of the +current locale. +.pp +it is reasonable to expect that +.br putwchar () +will actually write +the multibyte sequence corresponding to the wide character +.ir wc . +.sh see also +.br fputwc (3), +.br unlocked_stdio (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 2005, 2012, 2016 michael kerrisk +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under the gpl. +.\" %%%license_end +.\" +.th fmemopen 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +fmemopen \- open memory as stream +.sh synopsis +.nf +.b #include +.pp +.bi "file *fmemopen(void *"buf ", size_t "size ", const char *" mode ");" +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br fmemopen (): +.nf + since glibc 2.10: + _posix_c_source >= 200809l + before glibc 2.10: + _gnu_source +.fi +.sh description +the +.br fmemopen () +function opens a stream that permits the access specified by +.ir mode . +the stream allows i/o to be performed on the string or memory buffer +pointed to by +.ir buf . +.pp +the +.i mode +argument specifies the semantics of i/o on the stream, +and is one of the following: +.tp +.i r +the stream is opened for reading. +.tp +.i w +the stream is opened for writing. +.tp +.i a +append; open the stream for writing, +with the initial buffer position set to the first null byte. +.tp +.i r+ +open the stream for reading and writing. +.tp +.i w+ +open the stream for reading and writing. +the buffer contents are truncated +(i.e., \(aq\e0\(aq is placed in the first byte of the buffer). +.tp +.i a+ +append; open the stream for reading and writing, +with the initial buffer position set to the first null byte. +.pp +the stream maintains the notion of a current position, +the location where the next i/o operation will be performed. +the current position is implicitly updated by i/o operations. +it can be explicitly updated using +.br fseek (3), +and determined using +.br ftell (3). +in all modes other than append, +the initial position is set to the start of the buffer. +in append mode, if no null byte is found within the buffer, +then the initial position is +.ir size+1 . +.pp +if +.i buf +is specified as null, then +.br fmemopen () +allocates a buffer of +.i size +bytes. +this is useful for an application that wants to write data to +a temporary buffer and then read it back again. +the initial position is set to the start of the buffer. +the buffer is automatically freed when the stream is closed. +note that the caller has no way to obtain a pointer to the +temporary buffer allocated by this call (but see +.br open_memstream (3)). +.pp +if +.i buf +is not null, then it should point to a buffer of at least +.i len +bytes allocated by the caller. +.pp +when a stream that has been opened for writing is flushed +.rb ( fflush (3)) +or closed +.rb ( fclose (3)), +a null byte is written at the end of the buffer if there is space. +the caller should ensure that an extra byte is available in the +buffer +(and that +.i size +counts that byte) +to allow for this. +.pp +in a stream opened for reading, +null bytes (\(aq\e0\(aq) in the buffer do not cause read +operations to return an end-of-file indication. +a read from the buffer will indicate end-of-file +only when the current buffer position advances +.i size +bytes past the start of the buffer. +.pp +write operations take place either at the current position +(for modes other than append), or at the current size of the stream +(for append modes). +.pp +attempts to write more than +.i size +bytes to the buffer result in an error. +by default, such errors will be visible +(by the absence of data) only when the +.i stdio +buffer is flushed. +disabling buffering with the following call +may be useful to detect errors at the time of an output operation: +.pp + setbuf(stream, null); +.sh return value +upon successful completion, +.br fmemopen () +returns a +.i file +pointer. +otherwise, null is returned and +.i errno +is set to indicate the error. +.sh versions +.br fmemopen () +was already available in glibc 1.0.x. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br fmemopen (), +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2008. +this function is not specified in posix.1-2001, +and is not widely available on other systems. +.pp +posix.1-2008 specifies that \(aqb\(aq in +.ir mode +shall be ignored. +however, technical corrigendum 1 +.\" http://austingroupbugs.net/view.php?id=396 +adjusts the standard to allow implementation-specific treatment for this case, +thus permitting the glibc treatment of \(aqb\(aq. +.sh notes +there is no file descriptor associated with the file stream +returned by this function +(i.e., +.br fileno (3) +will return an error if called on the returned stream). +.pp +with version 2.22, binary mode (see below) was removed, +many longstanding bugs in the implementation of +.br fmemopen () +were fixed, and a new versioned symbol was created for this interface. +.\" +.ss binary mode +from version 2.9 to 2.21, the glibc implementation of +.br fmemopen () +supported a "binary" mode, +enabled by specifying the letter \(aqb\(aq as the second character in +.ir mode . +in this mode, +writes don't implicitly add a terminating null byte, and +.br fseek (3) +.b seek_end +is relative to the end of the buffer (i.e., the value specified by the +.i size +argument), rather than the current string length. +.pp +an api bug afflicted the implementation of binary mode: +to specify binary mode, the \(aqb\(aq must be the +.i second +character in +.ir mode . +thus, for example, "wb+" has the desired effect, but "w+b" does not. +this is inconsistent with the treatment of +.\" http://sourceware.org/bugzilla/show_bug.cgi?id=12836 +.ir mode +by +.br fopen (3). +.pp +binary mode was removed in glibc 2.22; a \(aqb\(aq specified in +.i mode +has no effect. +.sh bugs +in versions of glibc before 2.22, if +.i size +is specified as zero, +.br fmemopen () +fails with the error +.br einval . +.\" http://sourceware.org/bugzilla/show_bug.cgi?id=11216 +it would be more consistent if this case successfully created +a stream that then returned end-of-file on the first attempt at reading; +since version 2.22, the glibc implementation provides that behavior. +.pp +in versions of glibc before 2.22, +specifying append mode ("a" or "a+") for +.br fmemopen () +sets the initial buffer position to the first null byte, but +.\" http://sourceware.org/bugzilla/show_bug.cgi?id=13152 +(if the current position is reset to a location other than +the end of the stream) +does not force subsequent writes to append at the end of the stream. +this bug is fixed in glibc 2.22. +.pp +in versions of glibc before 2.22, if the +.i mode +argument to +.br fmemopen () +specifies append ("a" or "a+"), and the +.i size +argument does not cover a null byte in +.ir buf , +then, according to posix.1-2008, +the initial buffer position should be set to +the next byte after the end of the buffer. +however, in this case the glibc +.\" http://sourceware.org/bugzilla/show_bug.cgi?id=13151 +.br fmemopen () +sets the buffer position to \-1. +this bug is fixed in glibc 2.22. +.pp +in versions of glibc before 2.22, +.\" https://sourceware.org/bugzilla/show_bug.cgi?id=14292 +when a call to +.br fseek (3) +with a +.i whence +value of +.b seek_end +was performed on a stream created by +.br fmemopen (), +the +.i offset +was +.ir subtracted +from the end-of-stream position, instead of being added. +this bug is fixed in glibc 2.22. +.pp +the glibc 2.9 addition of "binary" mode for +.br fmemopen () +.\" http://sourceware.org/bugzilla/show_bug.cgi?id=6544 +silently changed the abi: previously, +.br fmemopen () +ignored \(aqb\(aq in +.ir mode . +.sh examples +the program below uses +.br fmemopen () +to open an input buffer, and +.br open_memstream (3) +to open a dynamically sized output buffer. +the program scans its input string (taken from the program's +first command-line argument) reading integers, +and writes the squares of these integers to the output buffer. +an example of the output produced by this program is the following: +.pp +.in +4n +.ex +.rb "$" " ./a.out \(aq1 23 43\(aq" +size=11; ptr=1 529 1849 +.ee +.in +.ss program source +\& +.ex +#define _gnu_source +#include +#include +#include + +#define handle_error(msg) \e + do { perror(msg); exit(exit_failure); } while (0) + +int +main(int argc, char *argv[]) +{ + file *out, *in; + int v, s; + size_t size; + char *ptr; + + if (argc != 2) { + fprintf(stderr, "usage: %s \(aq...\(aq\en", argv[0]); + exit(exit_failure); + } + + in = fmemopen(argv[1], strlen(argv[1]), "r"); + if (in == null) + handle_error("fmemopen"); + + out = open_memstream(&ptr, &size); + if (out == null) + handle_error("open_memstream"); + + for (;;) { + s = fscanf(in, "%d", &v); + if (s <= 0) + break; + + s = fprintf(out, "%d ", v * v); + if (s == \-1) + handle_error("fprintf"); + } + + fclose(in); + fclose(out); + + printf("size=%zu; ptr=%s\en", size, ptr); + + free(ptr); + exit(exit_success); +} +.ee +.sh see also +.br fopen (3), +.br fopencookie (3), +.br open_memstream (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1996 free software foundation, inc. +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" this file is distributed according to the gnu general public license. +.\" %%%license_end +.\" +.\" 2006-02-09, some reformatting by luc van oostenryck; some +.\" reformatting and rewordings by mtk +.\" +.th create_module 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +create_module \- create a loadable module entry +.sh synopsis +.nf +.b #include +.pp +.bi "caddr_t create_module(const char *" name ", size_t " size ); +.fi +.pp +.ir note : +no declaration of this system call is provided in glibc headers; see notes. +.sh description +.ir note : +this system call is present only in kernels before linux 2.6. +.pp +.br create_module () +attempts to create a loadable module entry and reserve the kernel memory +that will be needed to hold the module. +this system call requires privilege. +.sh return value +on success, returns the kernel address at which the module will reside. +on error, \-1 is returned and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eexist +a module by that name already exists. +.tp +.b efault +.i name +is outside the program's accessible address space. +.tp +.b einval +the requested size is too small even for the module header information. +.tp +.b enomem +the kernel could not allocate a contiguous block of memory large +enough for the module. +.tp +.b enosys +.br create_module () +is not supported in this version of the kernel +(e.g., the kernel is version 2.6 or later). +.tp +.b eperm +the caller was not privileged +(did not have the +.b cap_sys_module +capability). +.sh versions +this system call is present on linux only up until kernel 2.4; +it was removed in linux 2.6. +.\" removed in linux 2.5.48 +.sh conforming to +.br create_module () +is linux-specific. +.sh notes +this obsolete system call is not supported by glibc. +no declaration is provided in glibc headers, but, through a quirk of history, +glibc versions before 2.23 did export an abi for this system call. +therefore, in order to employ this system call, +it was sufficient to manually declare the interface in your code; +alternatively, you could invoke the system call using +.br syscall (2). +.sh see also +.br delete_module (2), +.br init_module (2), +.br query_module (2) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/pthread_attr_setstackaddr.3 + +.so man3/cabs.3 + +.so man3/rand.3 + +.\" copyright (c) 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th fopencookie 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +fopencookie \- opening a custom stream +.sh synopsis +.nf +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "file *fopencookie(void *restrict " cookie ", const char *restrict " mode , +.bi " cookie_io_functions_t " io_funcs ); +.fi +.sh description +the +.br fopencookie () +function allows the programmer to create a custom implementation +for a standard i/o stream. +this implementation can store the stream's data at a location of +its own choosing; for example, +.br fopencookie () +is used to implement +.br fmemopen (3), +which provides a stream interface to data that is stored in a +buffer in memory. +.pp +in order to create a custom stream the programmer must: +.ip * 3 +implement four "hook" functions that are used internally by the +standard i/o library when performing i/o on the stream. +.ip * +define a "cookie" data type, +a structure that provides bookkeeping information +(e.g., where to store data) used by the aforementioned hook functions. +the standard i/o package knows nothing about the contents of this cookie +(thus it is typed as +.ir "void\ *" +when passed to +.br fopencookie ()), +but automatically supplies the cookie +as the first argument when calling the hook functions. +.ip * +call +.br fopencookie () +to open a new stream and associate the cookie and hook functions +with that stream. +.pp +the +.br fopencookie () +function serves a purpose similar to +.br fopen (3): +it opens a new stream and returns a pointer to a +.i file +object that is used to operate on that stream. +.pp +the +.i cookie +argument is a pointer to the caller's cookie structure +that is to be associated with the new stream. +this pointer is supplied as the first argument when the standard i/o +library invokes any of the hook functions described below. +.pp +the +.i mode +argument serves the same purpose as for +.br fopen (3). +the following modes are supported: +.ir r , +.ir w , +.ir a , +.ir r+ , +.ir w+ , +and +.ir a+ . +see +.br fopen (3) +for details. +.pp +the +.i io_funcs +argument is a structure that contains four fields pointing to the +programmer-defined hook functions that are used to implement this stream. +the structure is defined as follows +.pp +.in +4n +.ex +typedef struct { + cookie_read_function_t *read; + cookie_write_function_t *write; + cookie_seek_function_t *seek; + cookie_close_function_t *close; +} cookie_io_functions_t; +.ee +.in +.pp +the four fields are as follows: +.tp +.i cookie_read_function_t *read +this function implements read operations for the stream. +when called, it receives three arguments: +.ip + ssize_t read(void *cookie, char *buf, size_t size); +.ip +the +.i buf +and +.i size +arguments are, respectively, +a buffer into which input data can be placed and the size of that buffer. +as its function result, the +.i read +function should return the number of bytes copied into +.ir buf , +0 on end of file, or \-1 on error. +the +.i read +function should update the stream offset appropriately. +.ip +if +.i *read +is a null pointer, +then reads from the custom stream always return end of file. +.tp +.i cookie_write_function_t *write +this function implements write operations for the stream. +when called, it receives three arguments: +.ip + ssize_t write(void *cookie, const char *buf, size_t size); +.ip +the +.i buf +and +.i size +arguments are, respectively, +a buffer of data to be output to the stream and the size of that buffer. +as its function result, the +.i write +function should return the number of bytes copied from +.ir buf , +or 0 on error. +(the function must not return a negative value.) +the +.i write +function should update the stream offset appropriately. +.ip +if +.i *write +is a null pointer, +then output to the stream is discarded. +.tp +.i cookie_seek_function_t *seek +this function implements seek operations on the stream. +when called, it receives three arguments: +.ip + int seek(void *cookie, off64_t *offset, int whence); +.ip +the +.i *offset +argument specifies the new file offset depending on which +of the following three values is supplied in +.ir whence : +.rs +.tp +.b seek_set +the stream offset should be set +.i *offset +bytes from the start of the stream. +.tp +.b seek_cur +.i *offset +should be added to the current stream offset. +.tp +.b seek_end +the stream offset should be set to the size of the stream plus +.ir *offset . +.re +.ip +before returning, the +.i seek +function should update +.i *offset +to indicate the new stream offset. +.ip +as its function result, the +.i seek +function should return 0 on success, and \-1 on error. +.ip +if +.i *seek +is a null pointer, +then it is not possible to perform seek operations on the stream. +.tp +.i cookie_close_function_t *close +this function closes the stream. +the hook function can do things such as freeing buffers allocated +for the stream. +when called, it receives one argument: +.ip + int close(void *cookie); +.ip +the +.i cookie +argument is the cookie that the programmer supplied when calling +.br fopencookie (). +.ip +as its function result, the +.i close +function should return 0 on success, and +.b eof +on error. +.ip +if +.i *close +is null, then no special action is performed when the stream is closed. +.sh return value +on success +.br fopencookie () +returns a pointer to the new stream. +on error, null is returned. +.\" .sh errors +.\" it's not clear if errno ever gets set... +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br fopencookie () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +this function is a nonstandard gnu extension. +.sh examples +the program below implements a custom stream whose functionality +is similar (but not identical) to that available via +.br fmemopen (3). +it implements a stream whose data is stored in a memory buffer. +the program writes its command-line arguments to the stream, +and then seeks through the stream reading two out of every +five characters and writing them to standard output. +the following shell session demonstrates the use of the program: +.pp +.in +4n +.ex +.rb "$" " ./a.out \(aqhello world\(aq" +/he/ +/ w/ +/d/ +reached end of file +.ee +.in +.pp +note that a more general version of the program below +could be improved to more robustly handle various error situations +(e.g., opening a stream with a cookie that already has an open stream; +closing a stream that has already been closed). +.ss program source +\& +.ex +#define _gnu_source +#include +#include +#include +#include +#include + +#define init_buf_size 4 + +struct memfile_cookie { + char *buf; /* dynamically sized buffer for data */ + size_t allocated; /* size of buf */ + size_t endpos; /* number of characters in buf */ + off_t offset; /* current file offset in buf */ +}; + +ssize_t +memfile_write(void *c, const char *buf, size_t size) +{ + char *new_buff; + struct memfile_cookie *cookie = c; + + /* buffer too small? keep doubling size until big enough. */ + + while (size + cookie\->offset > cookie\->allocated) { + new_buff = realloc(cookie\->buf, cookie\->allocated * 2); + if (new_buff == null) { + return \-1; + } else { + cookie\->allocated *= 2; + cookie\->buf = new_buff; + } + } + + memcpy(cookie\->buf + cookie\->offset, buf, size); + + cookie\->offset += size; + if (cookie\->offset > cookie\->endpos) + cookie\->endpos = cookie\->offset; + + return size; +} + +ssize_t +memfile_read(void *c, char *buf, size_t size) +{ + ssize_t xbytes; + struct memfile_cookie *cookie = c; + + /* fetch minimum of bytes requested and bytes available. */ + + xbytes = size; + if (cookie\->offset + size > cookie\->endpos) + xbytes = cookie\->endpos \- cookie\->offset; + if (xbytes < 0) /* offset may be past endpos */ + xbytes = 0; + + memcpy(buf, cookie\->buf + cookie\->offset, xbytes); + + cookie\->offset += xbytes; + return xbytes; +} + +int +memfile_seek(void *c, off64_t *offset, int whence) +{ + off64_t new_offset; + struct memfile_cookie *cookie = c; + + if (whence == seek_set) + new_offset = *offset; + else if (whence == seek_end) + new_offset = cookie\->endpos + *offset; + else if (whence == seek_cur) + new_offset = cookie\->offset + *offset; + else + return \-1; + + if (new_offset < 0) + return \-1; + + cookie\->offset = new_offset; + *offset = new_offset; + return 0; +} + +int +memfile_close(void *c) +{ + struct memfile_cookie *cookie = c; + + free(cookie\->buf); + cookie\->allocated = 0; + cookie\->buf = null; + + return 0; +} + +int +main(int argc, char *argv[]) +{ + cookie_io_functions_t memfile_func = { + .read = memfile_read, + .write = memfile_write, + .seek = memfile_seek, + .close = memfile_close + }; + file *stream; + struct memfile_cookie mycookie; + size_t nread; + char buf[1000]; + + /* set up the cookie before calling fopencookie(). */ + + mycookie.buf = malloc(init_buf_size); + if (mycookie.buf == null) { + perror("malloc"); + exit(exit_failure); + } + + mycookie.allocated = init_buf_size; + mycookie.offset = 0; + mycookie.endpos = 0; + + stream = fopencookie(&mycookie, "w+", memfile_func); + if (stream == null) { + perror("fopencookie"); + exit(exit_failure); + } + + /* write command\-line arguments to our file. */ + + for (int j = 1; j < argc; j++) + if (fputs(argv[j], stream) == eof) { + perror("fputs"); + exit(exit_failure); + } + + /* read two bytes out of every five, until eof. */ + + for (long p = 0; ; p += 5) { + if (fseek(stream, p, seek_set) == \-1) { + perror("fseek"); + exit(exit_failure); + } + nread = fread(buf, 1, 2, stream); + if (nread == 0) { + if (ferror(stream) != 0) { + fprintf(stderr, "fread failed\en"); + exit(exit_failure); + } + printf("reached end of file\en"); + break; + } + + printf("/%.*s/\en", (int) nread, buf); + } + + exit(exit_success); +} +.ee +.sh see also +.br fclose (3), +.br fmemopen (3), +.br fopen (3), +.br fseek (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/isalpha.3 + +.so man3/rpc.3 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sat jul 24 19:49:27 1993 by rik faith (faith@cs.unc.edu) +.\" modified fri apr 26 12:38:55 met dst 1996 by martin schulze (joey@linux.de) +.\" modified 2001-11-13, aeb +.\" modified 2001-12-13, joey, aeb +.\" modified 2004-11-16, mtk +.\" +.th ctime 3 2021-03-22 "" "linux programmer's manual" +.sh name +asctime, ctime, gmtime, localtime, mktime, asctime_r, ctime_r, gmtime_r, +localtime_r \- transform date and time to broken-down time or ascii +.sh synopsis +.nf +.b #include +.pp +.bi "char *asctime(const struct tm *" tm ); +.bi "char *asctime_r(const struct tm *restrict " tm ", char *restrict " buf ); +.pp +.bi "char *ctime(const time_t *" timep ); +.bi "char *ctime_r(const time_t *restrict " timep ", char *restrict " buf ); +.pp +.bi "struct tm *gmtime(const time_t *" timep ); +.bi "struct tm *gmtime_r(const time_t *restrict " timep , +.bi " struct tm *restrict " result ); +.pp +.bi "struct tm *localtime(const time_t *" timep ); +.bi "struct tm *localtime_r(const time_t *restrict " timep , +.bi " struct tm *restrict " result ); +.pp +.bi "time_t mktime(struct tm *" tm ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br asctime_r (), +.br ctime_r (), +.br gmtime_r (), +.br localtime_r (): +.nf + _posix_c_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.sh description +the +.br ctime (), +.br gmtime (), +and +.br localtime () +functions all take +an argument of data type \fitime_t\fp, which represents calendar time. +when interpreted as an absolute time value, it represents the number of +seconds elapsed since the epoch, 1970-01-01 00:00:00 +0000 (utc). +.pp +the +.br asctime () +and +.br mktime () +functions both take an argument +representing broken-down time, which is a representation +separated into year, month, day, and so on. +.pp +broken-down time is stored +in the structure \fitm\fp, which is defined in \fi\fp as follows: +.pp +.in +4n +.ex +struct tm { + int tm_sec; /* seconds (0\-60) */ + int tm_min; /* minutes (0\-59) */ + int tm_hour; /* hours (0\-23) */ + int tm_mday; /* day of the month (1\-31) */ + int tm_mon; /* month (0\-11) */ + int tm_year; /* year \- 1900 */ + int tm_wday; /* day of the week (0\-6, sunday = 0) */ + int tm_yday; /* day in the year (0\-365, 1 jan = 0) */ + int tm_isdst; /* daylight saving time */ +}; +.ee +.in +.pp +the members of the \fitm\fp structure are: +.tp 10 +.i tm_sec +the number of seconds after the minute, normally in the range 0 to 59, +but can be up to 60 to allow for leap seconds. +.tp +.i tm_min +the number of minutes after the hour, in the range 0 to 59. +.tp +.i tm_hour +the number of hours past midnight, in the range 0 to 23. +.tp +.i tm_mday +the day of the month, in the range 1 to 31. +.tp +.i tm_mon +the number of months since january, in the range 0 to 11. +.tp +.i tm_year +the number of years since 1900. +.tp +.i tm_wday +the number of days since sunday, in the range 0 to 6. +.tp +.i tm_yday +the number of days since january 1, in the range 0 to 365. +.tp +.i tm_isdst +a flag that indicates whether daylight saving time is in effect at the +time described. +the value is positive if daylight saving time is in +effect, zero if it is not, and negative if the information is not +available. +.pp +the call +.bi ctime( t ) +is equivalent to +.bi asctime(localtime( t )) \fr. +it converts the calendar time \fit\fp into a +null-terminated string of the form +.pp +.in +4n +.ex +"wed jun 30 21:49:08 1993\en" +.ee +.in +.pp +the abbreviations for the days of the week are "sun", "mon", "tue", "wed", +"thu", "fri", and "sat". +the abbreviations for the months are "jan", +"feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", and +"dec". +the return value points to a statically allocated string which +might be overwritten by subsequent calls to any of the date and time +functions. +the function also sets the external +variables \fitzname\fp, \fitimezone\fp, and \fidaylight\fp (see +.br tzset (3)) +with information about the current timezone. +the reentrant version +.br ctime_r () +does the same, but stores the +string in a user-supplied buffer +which should have room for at least 26 bytes. +it need not +set \fitzname\fp, \fitimezone\fp, and \fidaylight\fp. +.pp +the +.br gmtime () +function converts the calendar time \fitimep\fp to +broken-down time representation, expressed in coordinated universal time +(utc). +it may return null when the year does not fit into an integer. +the return value points to a statically allocated struct which might be +overwritten by subsequent calls to any of the date and time functions. +the +.br gmtime_r () +function does the same, but stores the data in a +user-supplied struct. +.pp +the +.br localtime () +function converts the calendar time \fitimep\fp to +broken-down time representation, +expressed relative to the user's specified timezone. +the function acts as if it called +.br tzset (3) +and sets the external variables \fitzname\fp with +information about the current timezone, \fitimezone\fp with the difference +between coordinated universal time (utc) and local standard time in +seconds, and \fidaylight\fp to a nonzero value if daylight savings +time rules apply during some part of the year. +the return value points to a statically allocated struct which might be +overwritten by subsequent calls to any of the date and time functions. +the +.br localtime_r () +function does the same, but stores the data in a +user-supplied struct. +it need not set \fitzname\fp, \fitimezone\fp, and \fidaylight\fp. +.pp +the +.br asctime () +function converts the broken-down time value +\fitm\fp into a null-terminated string with the same format as +.br ctime (). +the return value points to a statically allocated string which might be +overwritten by subsequent calls to any of the date and time functions. +the +.br asctime_r () +function does the same, but stores the string in +a user-supplied buffer which should have room for at least 26 bytes. +.pp +the +.br mktime () +function converts a broken-down time structure, expressed +as local time, to calendar time representation. +the function ignores +the values supplied by the caller in the +.i tm_wday +and +.i tm_yday +fields. +the value specified in the +.i tm_isdst +field informs +.br mktime () +whether or not daylight saving time (dst) +is in effect for the time supplied in the +.i tm +structure: +a positive value means dst is in effect; +zero means that dst is not in effect; +and a negative value means that +.br mktime () +should (use timezone information and system databases to) +attempt to determine whether dst is in effect at the specified time. +.pp +the +.br mktime () +function modifies the fields of the +.ir tm +structure as follows: +.i tm_wday +and +.i tm_yday +are set to values determined from the contents of the other fields; +if structure members are outside their valid interval, they will be +normalized (so that, for example, 40 october is changed into 9 november); +.i tm_isdst +is set (regardless of its initial value) +to a positive value or to 0, respectively, +to indicate whether dst is or is not in effect at the specified time. +calling +.br mktime () +also sets the external variable \fitzname\fp with +information about the current timezone. +.pp +if the specified broken-down +time cannot be represented as calendar time (seconds since the epoch), +.br mktime () +returns +.i (time_t)\ \-1 +and does not alter the +members of the broken-down time structure. +.sh return value +on success, +.br gmtime () +and +.br localtime () +return a pointer to a +.ir "struct\ tm" . +.pp +on success, +.br gmtime_r () +and +.br localtime_r () +return the address of the structure pointed to by +.ir result . +.pp +on success, +.br asctime () +and +.br ctime () +return a pointer to a string. +.pp +on success, +.br asctime_r () +and +.br ctime_r () +return a pointer to the string pointed to by +.ir buf . +.pp +on success, +.br mktime () +returns the calendar time (seconds since the epoch), +expressed as a value of type +.ir time_t . +.pp +on error, +.br mktime () +returns the value +.ir "(time_t)\ \-1" . +the remaining functions return null on error. +on error, +.i errno +is set to indicate the error. +.sh errors +.tp +.b eoverflow +the result cannot be represented. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lb lb lbx +l l l. +interface attribute value +t{ +.br asctime () +t} thread safety t{ +mt-unsafe race:asctime locale +t} +t{ +.br asctime_r () +t} thread safety t{ +mt-safe locale +t} +t{ +.br ctime () +t} thread safety t{ +mt-unsafe race:tmbuf +race:asctime env locale +t} +t{ +.br ctime_r (), +.br gmtime_r (), +.br localtime_r (), +.br mktime () +t} thread safety t{ +mt-safe env locale +t} +t{ +.br gmtime (), +.br localtime () +t} thread safety t{ +mt-unsafe race:tmbuf env locale +t} +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001. +c89 and c99 specify +.br asctime (), +.br ctime (), +.br gmtime (), +.br localtime (), +and +.br mktime (). +posix.1-2008 marks +.br asctime (), +.br asctime_r (), +.br ctime (), +and +.br ctime_r () +as obsolete, +recommending the use of +.br strftime (3) +instead. +.pp +posix doesn't specify the parameters of +.br ctime_r () +to be +.ir restrict ; +that is specific to glibc. +.sh notes +the four functions +.br asctime (), +.br ctime (), +.br gmtime (), +and +.br localtime () +return a pointer to static data and hence are not thread-safe. +the thread-safe versions, +.br asctime_r (), +.br ctime_r (), +.br gmtime_r (), +and +.br localtime_r (), +are specified by susv2. +.pp +posix.1-2001 says: +"the +.br asctime (), +.br ctime (), +.br gmtime (), +and +.br localtime () +functions shall return values in one of two static objects: +a broken-down time structure and an array of type +.ir char . +execution of any of the functions may overwrite the information returned +in either of these objects by any of the other functions." +this can occur in the glibc implementation. +.pp +in many implementations, including glibc, a 0 in +.i tm_mday +is interpreted as meaning the last day of the preceding month. +.pp +the glibc version of \fistruct tm\fp has additional fields +.pp +.in +4n +.ex +long tm_gmtoff; /* seconds east of utc */ +const char *tm_zone; /* timezone abbreviation */ +.ee +.in +.pp +defined when +.b _bsd_source +was set before including +.ir . +this is a bsd extension, present in 4.3bsd-reno. +.pp +according to posix.1-2001, +.br localtime () +is required to behave as though +.br tzset (3) +was called, while +.br localtime_r () +does not have this requirement. +.\" see http://thread.gmane.org/gmane.comp.time.tz/2034/ +for portable code, +.br tzset (3) +should be called before +.br localtime_r (). +.sh see also +.br date (1), +.br gettimeofday (2), +.br time (2), +.br utime (2), +.br clock (3), +.br difftime (3), +.br strftime (3), +.br strptime (3), +.br timegm (3), +.br tzset (3), +.br time (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2011, hewlett-packard development company, l.p. +.\" written by stephen m. cameron +.\" +.\" %%%license_start(gplv2_oneline) +.\" licensed under gnu general public license version 2 (gplv2) +.\" %%%license_end +.\" +.\" shorthand for double quote that works everywhere. +.ds q \n'34' +.th cciss 4 2021-03-22 "linux" "linux programmer's manual" +.sh name +cciss \- hp smart array block driver +.sh synopsis +.nf +modprobe cciss [ cciss_allow_hpsa=1 ] +.fi +.sh description +.\" commit 253d2464df446456c0bba5ed4137a7be0b278aa8 +.br note : +this obsolete driver was removed from the kernel in version 4.14, +as it is superseded by the +.br hpsa (4) +driver in newer kernels. +.pp +.b cciss +is a block driver for older hp smart array raid controllers. +.ss options +.ir "cciss_allow_hpsa=1" : +this option prevents the +.b cciss +driver from attempting to drive any controllers that the +.br hpsa (4) +driver is capable of controlling, which is to say, the +.b cciss +driver is restricted by this option to the following controllers: +.pp +.nf + smart array 5300 + smart array 5i + smart array 532 + smart array 5312 + smart array 641 + smart array 642 + smart array 6400 + smart array 6400 em + smart array 6i + smart array p600 + smart array p400i + smart array e200i + smart array e200 + smart array e200i + smart array e200i + smart array e200i + smart array e500 +.fi +.ss supported hardware +the +.b cciss +driver supports the following smart array boards: +.pp +.nf + smart array 5300 + smart array 5i + smart array 532 + smart array 5312 + smart array 641 + smart array 642 + smart array 6400 + smart array 6400 u320 expansion module + smart array 6i + smart array p600 + smart array p800 + smart array e400 + smart array p400i + smart array e200 + smart array e200i + smart array e500 + smart array p700m + smart array p212 + smart array p410 + smart array p410i + smart array p411 + smart array p812 + smart array p712m + smart array p711m +.fi +.ss configuration details +to configure hp smart array controllers, +use the hp array configuration utility +(either +.br hpacuxe (8) +or +.br hpacucli (8)) +or the offline rom-based configuration utility (orca) +run from the smart array's option rom at boot time. +.sh files +.ss device nodes +the device naming scheme is as follows: +.pp +major numbers: +.pp + 104 cciss0 + 105 cciss1 + 106 cciss2 + 105 cciss3 + 108 cciss4 + 109 cciss5 + 110 cciss6 + 111 cciss7 +.pp +minor numbers: +.pp +.ex + b7 b6 b5 b4 b3 b2 b1 b0 + |\-\-\-\-+\-\-\-\-| |\-\-\-\-+\-\-\-\-| + | | + | +\-\-\-\-\-\-\-\- partition id (0=wholedev, 1\-15 partition) + | + +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- logical volume number +.ee +.pp +the device naming scheme is: +.ts +li l. +/dev/cciss/c0d0 controller 0, disk 0, whole device +/dev/cciss/c0d0p1 controller 0, disk 0, partition 1 +/dev/cciss/c0d0p2 controller 0, disk 0, partition 2 +/dev/cciss/c0d0p3 controller 0, disk 0, partition 3 + +/dev/cciss/c1d1 controller 1, disk 1, whole device +/dev/cciss/c1d1p1 controller 1, disk 1, partition 1 +/dev/cciss/c1d1p2 controller 1, disk 1, partition 2 +/dev/cciss/c1d1p3 controller 1, disk 1, partition 3 +.te +.ss files in /proc +the files +.i /proc/driver/cciss/cciss[0\-9]+ +contain information about +the configuration of each controller. +for example: +.pp +.in +4n +.ex +$ \fbcd /proc/driver/cciss\fp +$ \fbls \-l\fp +total 0 +-rw\-r\-\-r\-\- 1 root root 0 2010\-09\-10 10:38 cciss0 +-rw\-r\-\-r\-\- 1 root root 0 2010\-09\-10 10:38 cciss1 +-rw\-r\-\-r\-\- 1 root root 0 2010\-09\-10 10:38 cciss2 +$ \fbcat cciss2\fp +cciss2: hp smart array p800 controller +board id: 0x3223103c +firmware version: 7.14 +irq: 16 +logical drives: 1 +current q depth: 0 +current # commands on controller: 0 +max q depth since init: 1 +max # commands on controller since init: 2 +max sg entries since init: 32 +sequential access devices: 0 + +cciss/c2d0: 36.38gb raid 0 +.ee +.in +.\" +.ss files in /sys +.tp +.i /sys/bus/pci/devices//ccissx/cxdy/model +displays the scsi inquiry page 0 model for logical drive +.i y +of controller +.ir x . +.tp +.i /sys/bus/pci/devices//ccissx/cxdy/rev +displays the scsi inquiry page 0 revision for logical drive +.i y +of controller +.ir x . +.tp +.i /sys/bus/pci/devices//ccissx/cxdy/unique_id +displays the scsi inquiry page 83 serial number for logical drive +.i y +of controller +.ir x . +.tp +.i /sys/bus/pci/devices//ccissx/cxdy/vendor +displays the scsi inquiry page 0 vendor for logical drive +.i y +of controller +.ir x . +.tp +.i /sys/bus/pci/devices//ccissx/cxdy/block:cciss!cxdy +a symbolic link to +.ir /sys/block/cciss!cxdy . +.tp +.i /sys/bus/pci/devices//ccissx/rescan +when this file is written to, the driver rescans the controller +to discover any new, removed, or modified logical drives. +.tp +.i /sys/bus/pci/devices//ccissx/resettable +a value of 1 displayed in this file indicates that +the "reset_devices=1" kernel parameter (used by +.br kdump ) +is honored by this controller. +a value of 0 indicates that the +"reset_devices=1" kernel parameter will not be honored. +some models of smart array are not able to honor this parameter. +.tp +.i /sys/bus/pci/devices//ccissx/cxdy/lunid +displays the 8-byte lun id used to address logical drive +.i y +of controller +.ir x . +.tp +.i /sys/bus/pci/devices//ccissx/cxdy/raid_level +displays the raid level of logical drive +.i y +of controller +.ir x . +.tp +.i /sys/bus/pci/devices//ccissx/cxdy/usage_count +displays the usage count (number of opens) of logical drive +.i y +of controller +.ir x . +.ss scsi tape drive and medium changer support +scsi sequential access devices and medium changer devices are supported and +appropriate device nodes are automatically created (e.g., +.ir /dev/st0 , +.ir /dev/st1 , +etc.; see +.br st (4) +for more details.) +you must enable "scsi tape drive support for smart array 5xxx" and +"scsi support" in your kernel configuration to be able to use scsi +tape drives with your smart array 5xxx controller. +.pp +additionally, note that the driver will not engage the scsi core at +init time. +the driver must be directed to dynamically engage the scsi core via the +.i /proc +filesystem entry, +which the "block" side of the driver creates as +.i /proc/driver/cciss/cciss* +at run time. +this is because at driver init time, +the scsi core may not yet be initialized (because the driver is a block +driver) and attempting to register it with the scsi core in such a case +would cause a hang. +this is best done via an initialization script +(typically in +.ir /etc/init.d , +but could vary depending on distribution). +for example: +.pp +.in +4n +.ex +for x in /proc/driver/cciss/cciss[0\-9]* +do + echo "engage scsi" > $x +done +.ee +.in +.pp +once the scsi core is engaged by the driver, it cannot be disengaged +(except by unloading the driver, if it happens to be linked as a module.) +.pp +note also that if no sequential access devices or medium changers are +detected, the scsi core will not be engaged by the action of the above +script. +.ss hot plug support for scsi tape drives +hot plugging of scsi tape drives is supported, with some caveats. +the +.b cciss +driver must be informed that changes to the scsi bus +have been made. +this may be done via the +.i /proc +filesystem. +for example: +.pp + echo "rescan" > /proc/scsi/cciss0/1 +.pp +this causes the driver to: +.rs +.ip 1. 3 +query the adapter about changes to the +physical scsi buses and/or fiber channel arbitrated loop, and +.ip 2. +make note of any new or removed sequential access devices +or medium changers. +.re +.pp +the driver will output messages indicating which +devices have been added or removed and the controller, bus, target, and +lun used to address each device. +the driver then notifies the scsi midlayer +of these changes. +.pp +note that the naming convention of the +.i /proc +filesystem entries +contains a number in addition to the driver name +(e.g., "cciss0" +instead of just "cciss", which you might expect). +.pp +note: +.i only +sequential access devices and medium changers are presented +as scsi devices to the scsi midlayer by the +.b cciss +driver. +specifically, physical scsi disk drives are +.i not +presented to the scsi midlayer. +the only disk devices that are presented to the kernel are logical +drives that the array controller constructs from regions on +the physical drives. +the logical drives are presented to the block layer +(not to the scsi midlayer). +it is important for the driver to prevent the kernel from accessing the +physical drives directly, since these drives are used by the array +controller to construct the logical drives. +.ss scsi error handling for tape drives and medium changers +the linux scsi midlayer provides an error-handling protocol that +is initiated whenever a scsi command fails to complete within a +certain amount of time (which can vary depending on the command). +the +.b cciss +driver participates in this protocol to some extent. +the normal protocol is a four-step process: +.ip * 3 +first, the device is told to abort the command. +.ip * +if that doesn't work, the device is reset. +.ip * +if that doesn't work, the scsi bus is reset. +.ip * +if that doesn't work, the host bus adapter is reset. +.pp +the +.b cciss +driver is a block +driver as well as a scsi driver and only the tape drives and medium +changers are presented to the scsi midlayer. +furthermore, unlike more +straightforward scsi drivers, disk i/o continues through the block +side during the scsi error-recovery process. +therefore, the +.b cciss +driver implements only the first two of these actions, +aborting the command, and resetting the device. +note also that most tape drives will not oblige +in aborting commands, and sometimes it appears they will not even +obey a reset command, though in most circumstances they will. +if the command cannot be aborted and the device cannot be +reset, the device will be set offline. +.pp +in the event that the error-handling code is triggered and a tape drive is +successfully reset or the tardy command is successfully aborted, the +tape drive may still not allow i/o to continue until some command +is issued that positions the tape to a known position. +typically you must rewind the tape (by issuing +.i "mt \-f /dev/st0 rewind" +for example) before i/o can proceed again to a tape drive that was reset. +.sh see also +.br hpsa (4), +.br cciss_vol_status (8), +.br hpacucli (8), +.br hpacuxe (8) +.pp +.ur http://cciss.sf.net +.ue , +and +.i documentation/blockdev/cciss.txt +and +.i documentation/abi/testing/sysfs\-bus\-pci\-devices\-cciss +in the linux kernel source tree +.\" .sh authors +.\" don brace, steve cameron, chase maupin, mike miller, michael ni, +.\" charles white, francis wiran +.\" and probably some other people. +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2017, michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th pthread_mutexattr_getpshared 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +pthread_mutexattr_getpshared, pthread_mutexattr_setpshared \- get/set +process-shared mutex attribute +.sh synopsis +.nf +.b #include +.pp +.bi "int pthread_mutexattr_getpshared(" +.bi " const pthread_mutexattr_t *restrict " attr , +.bi " int *restrict " pshared ); +.bi "int pthread_mutexattr_setpshared(pthread_mutexattr_t *" attr , +.bi " int " pshared ); +.fi +.pp +compile and link with \fi\-pthread\fp. +.sh description +these functions get and set the process-shared attribute +in a mutex attributes object. +this attribute must be appropriately set to ensure correct, +efficient operation of a mutex created using this attributes object. +.pp +the process-shared attribute can have one of the following values: +.tp +.b pthread_process_private +mutexes created with this attributes object are to be shared +only among threads in the same process that initialized the mutex. +this is the default value for the process-shared mutex attribute. +.tp +.b pthread_process_shared +mutexes created with this attributes object can be shared between +any threads that have access to the memory containing the object, +including threads in different processes. +.pp +.br pthread_mutexattr_getpshared () +places the value of the process-shared attribute of +the mutex attributes object referred to by +.ir attr +in the location pointed to by +.ir pshared . +.pp +.br pthread_mutexattr_setpshared () +sets the value of the process-shared attribute of +the mutex attributes object referred to by +.ir attr +to the value specified in +.br pshared . +.pp +if +.i attr +does not refer to an initialized mutex attributes object, +the behavior is undefined. +.sh return value +on success, these functions return 0. +on error, they return a positive error number. +.sh errors +.br pthread_mutexattr_setpshared () +can fail with the following errors: +.tp +.b einval +the value specified in +.i pshared +is invalid. +.tp +.b enotsup +.i pshared is +.br pthread_process_shared +but the implementation does not support process-shared mutexes. +.sh conforming to +posix.1-2001, posix.1-2008. +.sh see also +.ad l +.nh +.br pthread_mutexattr_init (3), +.br pthreads (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man7/iso_8859-3.7 + +.\" copyright (c) 1990, 1991 the regents of the university of california. +.\" all rights reserved. +.\" +.\" this code is derived from software contributed to berkeley by +.\" the american national standards committee x3, on information +.\" processing systems. +.\" +.\" %%%license_start(bsd_4_clause_ucb) +.\" redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. all advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" this product includes software developed by the university of +.\" california, berkeley and its contributors. +.\" 4. neither the name of the university nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" this software is provided by the regents and contributors ``as is'' and +.\" any express or implied warranties, including, but not limited to, the +.\" implied warranties of merchantability and fitness for a particular purpose +.\" are disclaimed. in no event shall the regents or contributors be liable +.\" for any direct, indirect, incidental, special, exemplary, or consequential +.\" damages (including, but not limited to, procurement of substitute goods +.\" or services; loss of use, data, or profits; or business interruption) +.\" however caused and on any theory of liability, whether in contract, strict +.\" liability, or tort (including negligence or otherwise) arising in any way +.\" out of the use of this software, even if advised of the possibility of +.\" such damage. +.\" %%%license_end +.\" +.\" @(#)stdarg.3 6.8 (berkeley) 6/29/91 +.\" +.\" converted for linux, mon nov 29 15:11:11 1993, faith@cs.unc.edu +.\" additions, 2001-10-14, aeb +.\" +.th stdarg 3 2021-03-22 "" "linux programmer's manual" +.sh name +stdarg, va_start, va_arg, va_end, va_copy \- variable argument lists +.sh synopsis +.nf +.b #include +.pp +.bi "void va_start(va_list " ap ", " last ); +.ib type " va_arg(va_list " ap ", " type ); +.bi "void va_end(va_list " ap ); +.bi "void va_copy(va_list " dest ", va_list " src ); +.fi +.sh description +a function may be called with a varying number of arguments of varying +types. +the include file +.i +declares a type +.i va_list +and defines three macros for stepping through a list of arguments whose +number and types are not known to the called function. +.pp +the called function must declare an object of type +.i va_list +which is used by the macros +.br va_start (), +.br va_arg (), +and +.br va_end (). +.ss va_start() +the +.br va_start () +macro initializes +.i ap +for subsequent use by +.br va_arg () +and +.br va_end (), +and must be called first. +.pp +the argument +.i last +is the name of the last argument before the variable argument list, that is, +the last argument of which the calling function knows the type. +.pp +because the address of this argument may be used in the +.br va_start () +macro, it should not be declared as a register variable, +or as a function or an array type. +.ss va_arg() +the +.br va_arg () +macro expands to an expression that has the type and value of the next +argument in the call. +the argument +.i ap +is the +.i va_list +.i ap +initialized by +.br va_start (). +each call to +.br va_arg () +modifies +.i ap +so that the next call returns the next argument. +the argument +.i type +is a type name specified so that the type of a pointer to an object that +has the specified type can be obtained simply by adding a * to +.ir type . +.pp +the first use of the +.br va_arg () +macro after that of the +.br va_start () +macro returns the argument after +.ir last . +successive invocations return the values of the remaining arguments. +.pp +if there is no next argument, or if +.i type +is not compatible with the type of the actual next argument (as promoted +according to the default argument promotions), random errors will occur. +.pp +if +.i ap +is passed to a function that uses +.bi va_arg( ap , type ), +then the value of +.i ap +is undefined after the return of that function. +.ss va_end() +each invocation of +.br va_start () +must be matched by a corresponding invocation of +.br va_end () +in the same function. +after the call +.bi va_end( ap ) +the variable +.i ap +is undefined. +multiple traversals of the list, each +bracketed by +.br va_start () +and +.br va_end () +are possible. +.br va_end () +may be a macro or a function. +.ss va_copy() +the +.br va_copy () +macro copies the (previously initialized) variable argument list +.i src +to +.ir dest . +the behavior is as if +.br va_start () +were applied to +.ir dest +with the same +.i last +argument, followed by the same number of +.br va_arg () +invocations that was used to reach the current state of +.ir src . +.pp +.\" proposal from clive@demon.net, 1997-02-28 +an obvious implementation would have a +.i va_list +be a pointer to the stack frame of the variadic function. +in such a setup (by far the most common) there seems +nothing against an assignment +.pp +.in +4n +.ex +va_list aq = ap; +.ee +.in +.pp +unfortunately, there are also systems that make it an +array of pointers (of length 1), and there one needs +.pp +.in +4n +.ex +va_list aq; +*aq = *ap; +.ee +.in +.pp +finally, on systems where arguments are passed in registers, +it may be necessary for +.br va_start () +to allocate memory, store the arguments there, and also +an indication of which argument is next, so that +.br va_arg () +can step through the list. +now +.br va_end () +can free the allocated memory again. +to accommodate this situation, c99 adds a macro +.br va_copy (), +so that the above assignment can be replaced by +.pp +.in +4n +.ex +va_list aq; +va_copy(aq, ap); +\&... +va_end(aq); +.ee +.in +.pp +each invocation of +.br va_copy () +must be matched by a corresponding invocation of +.br va_end () +in the same function. +some systems that do not supply +.br va_copy () +have +.b __va_copy +instead, since that was the name used in the draft proposal. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br va_start (), +.br va_end (), +.br va_copy () +t} thread safety mt-safe +t{ +.br va_arg () +t} thread safety mt-safe race:ap +.te +.hy +.ad +.sp 1 +.sh conforming to +the +.br va_start (), +.br va_arg (), +and +.br va_end () +macros conform to c89. +c99 defines the +.br va_copy () +macro. +.sh bugs +unlike the historical +.b varargs +macros, the +.b stdarg +macros do not permit programmers to code a function with no fixed +arguments. +this problem generates work mainly when converting +.b varargs +code to +.b stdarg +code, but it also creates difficulties for variadic functions that wish to +pass all of their arguments on to a function that takes a +.i va_list +argument, such as +.br vfprintf (3). +.sh examples +the function +.i foo +takes a string of format characters and prints out the argument associated +with each format character based on the type. +.pp +.ex +#include +#include + +void +foo(char *fmt, ...) /* \(aq...\(aq is c syntax for a variadic function */ + +{ + va_list ap; + int d; + char c; + char *s; + + va_start(ap, fmt); + while (*fmt) + switch (*fmt++) { + case \(aqs\(aq: /* string */ + s = va_arg(ap, char *); + printf("string %s\en", s); + break; + case \(aqd\(aq: /* int */ + d = va_arg(ap, int); + printf("int %d\en", d); + break; + case \(aqc\(aq: /* char */ + /* need a cast here since va_arg only + takes fully promoted types */ + c = (char) va_arg(ap, int); + printf("char %c\en", c); + break; + } + va_end(ap); +} +.ee +.sh see also +.br vprintf (3), +.br vscanf (3), +.br vsyslog (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sat jul 24 19:26:03 1993 by rik faith (faith@cs.unc.edu) +.th getprotoent 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +getprotoent, getprotobyname, getprotobynumber, setprotoent, +endprotoent \- get protocol entry +.sh synopsis +.nf +.b #include +.pp +.b struct protoent *getprotoent(void); +.pp +.bi "struct protoent *getprotobyname(const char *" name ); +.bi "struct protoent *getprotobynumber(int " proto ); +.pp +.bi "void setprotoent(int " stayopen ); +.b void endprotoent(void); +.fi +.sh description +the +.br getprotoent () +function reads the next entry from the protocols database (see +.br protocols (5)) +and returns a +.i protoent +structure +containing the broken-out fields from the entry. +a connection is opened to the database if necessary. +.pp +the +.br getprotobyname () +function returns a +.i protoent +structure +for the entry from the database +that matches the protocol name +.ir name . +a connection is opened to the database if necessary. +.pp +the +.br getprotobynumber () +function returns a +.i protoent +structure +for the entry from the database +that matches the protocol number +.ir number . +a connection is opened to the database if necessary. +.pp +the +.br setprotoent () +function opens a connection to the database, +and sets the next entry to the first entry. +if +.i stayopen +is nonzero, +then the connection to the database +will not be closed between calls to one of the +.br getproto* () +functions. +.pp +the +.br endprotoent () +function closes the connection to the database. +.pp +the +.i protoent +structure is defined in +.i +as follows: +.pp +.in +4n +.ex +struct protoent { + char *p_name; /* official protocol name */ + char **p_aliases; /* alias list */ + int p_proto; /* protocol number */ +} +.ee +.in +.pp +the members of the +.i protoent +structure are: +.tp +.i p_name +the official name of the protocol. +.tp +.i p_aliases +a null-terminated list of alternative names for the protocol. +.tp +.i p_proto +the protocol number. +.sh return value +the +.br getprotoent (), +.br getprotobyname (), +and +.br getprotobynumber () +functions return a pointer to a +statically allocated +.i protoent +structure, or a null pointer if an +error occurs or the end of the file is reached. +.sh files +.pd 0 +.tp +.i /etc/protocols +protocol database file +.pd +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lb lb lbx +l l l. +interface attribute value +t{ +.br getprotoent () +t} thread safety t{ +mt-unsafe race:protoent +race:protoentbuf locale +t} +t{ +.br getprotobyname () +t} thread safety t{ +mt-unsafe race:protobyname +locale +t} +t{ +.br getprotobynumber () +t} thread safety t{ +mt-unsafe race:protobynumber +locale +t} +t{ +.br setprotoent (), +.br endprotoent () +t} thread safety t{ +mt-unsafe race:protoent +locale +t} +.te +.hy +.ad +.sp 1 +in the above table, +.i protoent +in +.i race:protoent +signifies that if any of the functions +.br setprotoent (), +.br getprotoent (), +or +.br endprotoent () +are used in parallel in different threads of a program, +then data races could occur. +.sh conforming to +posix.1-2001, posix.1-2008, 4.3bsd. +.sh see also +.br getnetent (3), +.br getprotoent_r (3), +.br getservent (3), +.br protocols (5) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/resolver.3 + +.so man3/getpwent.3 + +.so man3/fmin.3 + +.\" copyright (c) 2007 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" 2007-10-23 mtk: moved the _syscalln specific material to the +.\" new _syscall(2) page, and substantially enhanced and rewrote +.\" the remaining material on this page. +.\" +.th intro 2 2021-08-27 "linux" "linux programmer's manual" +.sh name +intro \- introduction to system calls +.sh description +section 2 of the manual describes the linux system calls. +a system call is an entry point into the linux kernel. +usually, system calls are not invoked directly: +instead, most system calls have corresponding c library +wrapper functions which perform the steps required +(e.g., trapping to kernel mode) in order to invoke +the system call. +thus, making a system call looks the same as invoking a normal +library function. +.pp +in many cases, the c library wrapper function does nothing more than: +.ip * 3 +copying arguments and the unique system call number to the +registers where the kernel expects them; +.ip * +trapping to kernel mode, +at which point the kernel does the real work of the system call; +.ip * +setting +.i errno +if the system call returns an error number when the kernel returns the +cpu to user mode. +.pp +however, in a few cases, a wrapper function may do rather more than this, +for example, performing some preprocessing +of the arguments before trapping to kernel mode, +or postprocessing of values returned by the system call. +where this is the case, the manual pages in section 2 generally +try to note the details of both the (usually gnu) c library api +interface and the raw system call. +most commonly, the main description will focus on the c library interface, +and differences for the system call are covered in the notes section. +.pp +for a list of the linux system calls, see +.br syscalls (2). +.sh return value +on error, most system calls return a negative error number +(i.e., the negated value of one of the constants described in +.br errno (3)). +the c library wrapper hides this detail from the caller: when a +system call returns a negative value, the wrapper copies the +absolute value into the +.i errno +variable, and returns \-1 as the return value of the wrapper. +.pp +the value returned by a successful system call depends on the call. +many system calls return 0 on success, but some can return nonzero +values from a successful call. +the details are described in the individual manual pages. +.pp +in some cases, +the programmer must define a feature test macro in order to obtain +the declaration of a system call from the header file specified +in the man page synopsis section. +(where required, these feature test macros must be defined before including +.i any +header files.) +in such cases, the required macro is described in the man page. +for further information on feature test macros, see +.br feature_test_macros (7). +.sh conforming to +certain terms and abbreviations are used to indicate unix variants +and standards to which calls in this section conform. +see +.br standards (7). +.sh notes +.ss calling directly +in most cases, it is unnecessary to invoke a system call directly, +but there are times when the standard c library does not implement +a nice wrapper function for you. +in this case, the programmer must manually invoke the system call using +.br syscall (2). +historically, this was also possible using one of the _syscall macros +described in +.br _syscall (2). +.ss authors and copyright conditions +look at the header of the manual page source for the author(s) and copyright +conditions. +note that these can be different from page to page! +.sh see also +.ad l +.nh +.br _syscall (2), +.br syscall (2), +.br syscalls (2), +.br errno (3), +.br intro (3), +.br capabilities (7), +.br credentials (7), +.br feature_test_macros (7), +.br mq_overview (7), +.br path_resolution (7), +.br pipe (7), +.br pty (7), +.br sem_overview (7), +.br shm_overview (7), +.br signal (7), +.br socket (7), +.br standards (7), +.br symlink (7), +.br system_data_types (7), +.br sysvipc (7), +.br time (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man7/system_data_types.7 + +.\" copyright (c) 2001 andries brouwer . +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th stdio_ext 3 2021-03-22 "" "linux programmer's manual" +.sh name +__fbufsize, __flbf, __fpending, __fpurge, __freadable, +__freading, __fsetlocking, __fwritable, __fwriting, _flushlbf \- +interfaces to stdio file structure +.sh synopsis +.nf +.b #include +.b #include +.pp +.bi "size_t __fbufsize(file *" stream ); +.bi "size_t __fpending(file *" stream ); +.bi "int __flbf(file *" stream ); +.bi "int __freadable(file *" stream ); +.bi "int __fwritable(file *" stream ); +.bi "int __freading(file *" stream ); +.bi "int __fwriting(file *" stream ); +.bi "int __fsetlocking(file *" stream ", int " type ); +.b "void _flushlbf(void);" +.bi "void __fpurge(file *" stream ); +.fi +.sh description +solaris introduced routines to allow portable access to the +internals of the +.i file +structure, and glibc also implemented these. +.pp +the +.br __fbufsize () +function returns the size of the buffer currently used +by the given stream. +.pp +the +.br __fpending () +function returns the number of bytes in the output buffer. +for wide-oriented streams the unit is wide characters. +this function is undefined on buffers in reading mode, +or opened read-only. +.pp +the +.br __flbf () +function returns a nonzero value if the stream is line-buffered, +and zero otherwise. +.pp +the +.br __freadable () +function returns a nonzero value if the stream allows reading, +and zero otherwise. +.pp +the +.br __fwritable () +function returns a nonzero value if the stream allows writing, +and zero otherwise. +.pp +the +.br __freading () +function returns a nonzero value if the stream is read-only, or +if the last operation on the stream was a read operation, +and zero otherwise. +.pp +the +.br __fwriting () +function returns a nonzero value if the stream is write-only (or +append-only), or if the last operation on the stream was a write +operation, and zero otherwise. +.pp +the +.br __fsetlocking () +function can be used to select the desired type of locking on the stream. +it returns the current type. +the +.i type +argument can take the following three values: +.tp +.b fsetlocking_internal +perform implicit locking around every operation on the given stream +(except for the *_unlocked ones). +this is the default. +.tp +.b fsetlocking_bycaller +the caller will take care of the locking (possibly using +.br flockfile (3) +in case there is more than one thread), and the stdio routines +will not do locking until the state is reset to +.br fsetlocking_internal . +.tp +.b fsetlocking_query +don't change the type of locking. +(only return it.) +.pp +the +.br _flushlbf () +function flushes all line-buffered streams. +(presumably so that +output to a terminal is forced out, say before reading keyboard input.) +.pp +the +.br __fpurge () +function discards the contents of the stream's buffer. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br __fbufsize (), +.br __fpending (), +.br __fpurge (), +.br __fsetlocking () +t} thread safety mt-safe race:stream +t{ +.br __flbf (), +.br __freadable (), +.br __freading (), +.br __fwritable (), +.br __fwriting (), +.br _flushlbf () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh see also +.br flockfile (3), +.br fpurge (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2002 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" added note on self-signaling, aeb, 2002-06-07 +.\" added note on cap_kill, mtk, 2004-06-16 +.\" +.th sigqueue 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +sigqueue \- queue a signal and data to a process +.sh synopsis +.nf +.b #include +.pp +.bi "int sigqueue(pid_t " pid ", int " sig ", const union sigval " value ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br sigqueue (): +.nf + _posix_c_source >= 199309l +.fi +.sh description +.br sigqueue () +sends the signal specified in +.i sig +to the process whose pid is given in +.ir pid . +the permissions required to send a signal are the same as for +.br kill (2). +as with +.br kill (2), +the null signal (0) can be used to check if a process with a given +pid exists. +.pp +the +.i value +argument is used to specify an accompanying item of data (either an integer +or a pointer value) to be sent with the signal, and has the following type: +.pp +.in +4n +.ex +union sigval { + int sival_int; + void *sival_ptr; +}; +.ee +.in +.pp +if the receiving process has installed a handler for this signal using the +.b sa_siginfo +flag to +.br sigaction (2), +then it can obtain this data via the +.i si_value +field of the +.i siginfo_t +structure passed as the second argument to the handler. +furthermore, the +.i si_code +field of that structure will be set to +.br si_queue . +.sh return value +on success, +.br sigqueue () +returns 0, indicating that the signal was successfully +queued to the receiving process. +otherwise, \-1 is returned and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eagain +the limit of signals which may be queued has been reached. +(see +.br signal (7) +for further information.) +.tp +.b einval +.i sig +was invalid. +.tp +.b eperm +the process does not have permission to send the signal +to the receiving process. +for the required permissions, see +.br kill (2). +.tp +.b esrch +no process has a pid matching +.ir pid . +.sh versions +.br sigqueue () +and the underlying +.br rt_sigqueueinfo (2) +system call first appeared in linux 2.2. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br sigqueue () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +if this function results in the sending of a signal to the process +that invoked it, and that signal was not blocked by the calling thread, +and no other threads were willing to handle this signal (either by +having it unblocked, or by waiting for it using +.br sigwait (3)), +then at least some signal must be delivered to this thread before this +function returns. +.ss c library/kernel differences +on linux, +.br sigqueue () +is implemented using the +.br rt_sigqueueinfo (2) +system call. +the system call differs in its third argument, which is the +.i siginfo_t +structure that will be supplied to the receiving process's +signal handler or returned by the receiving process's +.br sigtimedwait (2) +call. +inside the glibc +.br sigqueue () +wrapper, this argument, +.ir uinfo , +is initialized as follows: +.pp +.in +4n +.ex +uinfo.si_signo = sig; /* argument supplied to sigqueue() */ +uinfo.si_code = si_queue; +uinfo.si_pid = getpid(); /* process id of sender */ +uinfo.si_uid = getuid(); /* real uid of sender */ +uinfo.si_value = val; /* argument supplied to sigqueue() */ +.ee +.in +.sh see also +.br kill (2), +.br rt_sigqueueinfo (2), +.br sigaction (2), +.br signal (2), +.br pthread_sigqueue (3), +.br sigwait (3), +.br signal (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/_exit.2 + +.\" copyright (c) 2021 suren baghdasaryan +.\" and copyright (c) 2021 minchan kim +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" commit ecb8ac8b1f146915aa6b96449b66dd48984caacc +.\" +.th process_madvise 2 2021-06-20 "linux" "linux programmer's manual" +.sh name +process_madvise \- give advice about use of memory to a process +.sh synopsis +.nf +.br "#include " " /* definition of " madv_* " constants */" +.br "#include " " /* definition of " sys_* " constants */" +.br "#include " " /* definition of " "struct iovec" " type */" +.b #include +.pp +.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 : +glibc provides no wrapper for +.br process_madvise (), +necessitating the use of +.br syscall (2). +.\" fixme: see +.sh description +the +.br process_madvise() +system call is used to give advice or directions to the kernel about the +address ranges of another process or of the calling process. +it provides the advice for the address ranges described by +.i iovec +and +.ir vlen . +the goal of such advice is to improve system or application performance. +.pp +the +.i pidfd +argument is a pid file descriptor (see +.br pidfd_open (2)) +that specifies the process to which the advice is to be applied. +.pp +the pointer +.i iovec +points to an array of +.i iovec +structures, defined in +.ir +as: +.pp +.in +4n +.ex +struct iovec { + void *iov_base; /* starting address */ + size_t iov_len; /* length of region */ +}; +.ee +.in +.pp +the +.i iovec +structure describes address ranges beginning at +.i iov_base +address and with the size of +.i iov_len +bytes. +.pp +the +.i vlen +specifies the number of elements in the +.i iovec +structure. +this value must be less than or equal to +.br iov_max +(defined in +.i +or accessible via the call +.ir sysconf(_sc_iov_max) ). +.pp +the +.i advice +argument is one of the following values: +.tp +.br madv_cold +see +.br madvise (2). +.tp +.br madv_pageout +see +.br madvise (2). +.pp +the +.i flags +argument is reserved for future use; currently, this argument must be +specified as 0. +.pp +the +.i vlen +and +.i iovec +arguments are checked before applying any advice. +if +.i vlen +is too big, or +.i iovec +is invalid, +then an error will be returned immediately and no advice will be applied. +.pp +the advice might be applied to only a part of +.i iovec +if one of its elements points to an invalid memory region in the +remote process. +no further elements will be processed beyond that point. +(see the discussion regarding partial advice in return value.) +.pp +permission to apply advice to another process is governed by a +ptrace access mode +.b ptrace_mode_read_realcreds +check (see +.br ptrace (2)); +in addition, +because of the performance implications of applying the advice, +the caller must have the +.b cap_sys_admin +capability. +.sh return value +on success, +.br process_madvise () +returns the number of bytes advised. +this return value may be less than the total number of requested bytes, +if an error occurred after some +.i iovec +elements were already processed. +the caller should check the return value to determine whether a partial +advice occurred. +.pp +on error, \-1 is returned and +.i errno +is set to indicate the error. +.sh errors +.tp +.b ebadf +.i pidfd +is not a valid pid file descriptor. +.tp +.b efault +the memory described by +.i iovec +is outside the accessible address space of the process referred to by +.ir pidfd . +.tp +.b einval +.i flags +is not 0. +.tp +.b einval +the sum of the +.i iov_len +values of +.i iovec +overflows a +.i ssize_t +value. +.tp +.b einval +.i vlen +is too large. +.tp +.b enomem +could not allocate memory for internal copies of the +.i iovec +structures. +.tp +.b eperm +the caller does not have permission to access the address space of the process +.ir pidfd . +.tp +.b esrch +the target process does not exist (i.e., it has terminated and been waited on). +.sh versions +this system call first appeared in linux 5.10. +.\" commit ecb8ac8b1f146915aa6b96449b66dd48984caacc +support for this system call is optional, +depending on the setting of the +.b config_advise_syscalls +configuration option. +.sh conforming to +the +.br process_madvise () +system call is linux-specific. +.sh see also +.br madvise (2), +.br pidfd_open (2), +.br process_vm_readv (2), +.br process_vm_write (2) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/sched_setaffinity.2 + +.so man2/llseek.2 + +.so man3/fpurge.3 + +.so man3/stdarg.3 + + + +.so man3/pthread_attr_setschedparam.3 + +.so man3/unlocked_stdio.3 + +.\" copyright (c) 2001 martin schulze +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" 2008-09-04, mtk, taken from debian downstream, with a few light edits +.\" +.th networks 5 2008-09-04 "gnu/linux" "linux system administration" +.sh name +networks \- network name information +.sh description +the file +.i /etc/networks +is a plain ascii file that describes known darpa networks and symbolic +names for these networks. +each line represents a network and has the following structure: +.pp +.rs +.i name number aliases ... +.re +.pp +where the fields are delimited by spaces or tabs. +empty lines are ignored. +the hash character (\fb#\fp) indicates the start of a comment: +this character, and the remaining characters up to +the end of the current line, +are ignored by library functions that process the file. +.pp +the field descriptions are: +.tp +.i name +the symbolic name for the network. +network names can contain any printable characters except +white-space characters or the comment character. +.tp +.i number +the official number for this network in numbers-and-dots notation (see +.br inet (3)). +the trailing ".0" (for the host component of the network address) may be omitted. +.tp +.i aliases +optional aliases for the network. +.pp +.pp +this file is read by the +.br route (8) +and +.br netstat (8) +utilities. +only class a, b, or c networks are supported, partitioned networks +(i.e., network/26 or network/28) are not supported by this file. +.sh files +.tp +.i /etc/networks +the networks definition file. +.sh see also +.br getnetbyaddr (3), +.br getnetbyname (3), +.br getnetent (3), +.br netstat (8), +.br route (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1980, 1991 regents of the university of california. +.\" all rights reserved. +.\" +.\" %%%license_start(bsd_4_clause_ucb) +.\" redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. all advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" this product includes software developed by the university of +.\" california, berkeley and its contributors. +.\" 4. neither the name of the university nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" this software is provided by the regents and contributors ``as is'' and +.\" any express or implied warranties, including, but not limited to, the +.\" implied warranties of merchantability and fitness for a particular purpose +.\" are disclaimed. in no event shall the regents or contributors be liable +.\" for any direct, indirect, incidental, special, exemplary, or consequential +.\" damages (including, but not limited to, procurement of substitute goods +.\" or services; loss of use, data, or profits; or business interruption) +.\" however caused and on any theory of liability, whether in contract, strict +.\" liability, or tort (including negligence or otherwise) arising in any way +.\" out of the use of this software, even if advised of the possibility of +.\" such damage. +.\" %%%license_end +.\" +.\" @(#)killpg.2 6.5 (berkeley) 3/10/91 +.\" +.\" modified fri jul 23 21:55:01 1993 by rik faith +.\" modified tue oct 22 08:11:14 edt 1996 by eric s. raymond +.\" modified 2004-06-16 by michael kerrisk +.\" added notes on cap_kill +.\" modified 2004-06-21 by aeb +.\" +.th killpg 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +killpg \- send signal to a process group +.sh synopsis +.nf +.b #include +.pp +.bi "int killpg(int " pgrp ", int " sig ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br killpg (): +.nf + _xopen_source >= 500 +.\" || _xopen_source && _xopen_source_extended + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source +.fi +.sh description +.br killpg () +sends the signal +.i sig +to the process group +.ir pgrp . +see +.br signal (7) +for a list of signals. +.pp +if +.i pgrp +is 0, +.br killpg () +sends the signal to the calling process's process group. +(posix says: if +.i pgrp +is less than or equal to 1, the behavior is undefined.) +.pp +for the permissions required to send a signal to another process, see +.br kill (2). +.sh return value +on success, zero is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b einval +.i sig +is not a valid signal number. +.tp +.b eperm +the process does not have permission to send the signal +to any of the target processes. +for the required permissions, see +.br kill (2). +.tp +.b esrch +no process can be found in the process group specified by +.ir pgrp . +.tp +.b esrch +the process group was given as 0 but the sending process does not +have a process group. +.sh conforming to +posix.1-2001, posix.1-2008, svr4, 4.4bsd +.rb ( killpg () +first appeared in 4bsd). +.sh notes +there are various differences between the permission checking +in bsd-type systems and system\ v-type systems. +see the posix rationale for +.br kill (3p). +a difference not mentioned by posix concerns the return +value +.br eperm : +bsd documents that no signal is sent and +.b eperm +returned when the permission check failed for at least one target process, +while posix documents +.b eperm +only when the permission check failed for all target processes. +.ss c library/kernel differences +on linux, +.br killpg () +is implemented as a library function that makes the call +.ir "kill(\-pgrp,\ sig)" . +.sh see also +.br getpgrp (2), +.br kill (2), +.br signal (2), +.br capabilities (7), +.br credentials (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/pthread_spin_lock.3 + +.so man3/endian.3 + +.\" copyright (c) 2019 by michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th pidfd_open 2 2021-08-27 "linux" "linux programmer's manual" +.sh name +pidfd_open \- obtain a file descriptor that refers to a process +.sh synopsis +.nf +.br "#include " " /* definition of " sys_* " constants */" +.b #include +.pp +.bi "int syscall(sys_pidfd_open, pid_t " pid ", unsigned int " flags ); +.fi +.pp +.ir note : +glibc provides no wrapper for +.br pidfd_open (), +necessitating the use of +.br syscall (2). +.sh description +the +.br pidfd_open () +system call creates a file descriptor that refers to +the process whose pid is specified in +.ir pid . +the file descriptor is returned as the function result; +the close-on-exec flag is set on the file descriptor. +.pp +the +.i flags +argument either has the value 0, or contains the following flag: +.tp +.br pidfd_nonblock " (since linux 5.10)" +.\" commit 4da9af0014b51c8b015ed8c622440ef28912efe6 +return a nonblocking file descriptor. +if the process referred to by the file descriptor has not yet terminated, +then an attempt to wait on the file descriptor using +.br waitid (2) +will immediately return the error +.br eagain +rather than blocking. +.sh return value +on success, +.br pidfd_open () +returns a file descriptor (a nonnegative integer). +on error, \-1 is returned and +.i errno +is set to indicate the error. +.sh errors +.tp +.b einval +.i flags +is not valid. +.tp +.b einval +.i pid +is not valid. +.tp +.b emfile +the per-process limit on the number of open file descriptors has been reached +(see the description of +.br rlimit_nofile +in +.br getrlimit (2)). +.tp +.b enfile +the system-wide limit on the total number of open files has been reached. +.tp +.b enodev +the anonymous inode filesystem is not available in this kernel. +.tp +.b enomem +insufficient kernel memory was available. +.tp +.b esrch +the process specified by +.i pid +does not exist. +.sh versions +.br pidfd_open () +first appeared in linux 5.3. +.sh conforming to +.br pidfd_open () +is linux specific. +.sh notes +the following code sequence can be used to obtain a file descriptor +for the child of +.br fork (2): +.pp +.in +4n +.ex +pid = fork(); +if (pid > 0) { /* if parent */ + pidfd = pidfd_open(pid, 0); + ... +} +.ee +.in +.pp +even if the child has already terminated by the time of the +.br pidfd_open () +call, its pid will not have been recycled and the returned +file descriptor will refer to the resulting zombie process. +note, however, that this is guaranteed only if the following +conditions hold true: +.ip \(bu 2 +the disposition of +.br sigchld +has not been explicitly set to +.br sig_ign +(see +.br sigaction (2)); +.ip \(bu +the +.br sa_nocldwait +flag was not specified while establishing a handler for +.br sigchld +or while setting the disposition of that signal to +.br sig_dfl +(see +.br sigaction (2)); +and +.ip \(bu +the zombie process was not reaped elsewhere in the program +(e.g., either by an asynchronously executed signal handler or by +.br wait (2) +or similar in another thread). +.pp +if any of these conditions does not hold, +then the child process (along with a pid file descriptor that refers to it) +should instead be created using +.br clone (2) +with the +.br clone_pidfd +flag. +.\" +.ss use cases for pid file descriptors +a pid file descriptor returned by +.br pidfd_open () +(or by +.br clone (2) +with the +.br clone_pid +flag) can be used for the following purposes: +.ip \(bu 2 +the +.br pidfd_send_signal (2) +system call can be used to send a signal to the process referred to by +a pid file descriptor. +.ip \(bu +a pid file descriptor can be monitored using +.br poll (2), +.br select (2), +and +.br epoll (7). +when the process that it refers to terminates, +these interfaces indicate the file descriptor as readable. +note, however, that in the current implementation, +nothing can be read from the file descriptor +.rb ( read (2) +on the file descriptor fails with the error +.br einval ). +.ip \(bu +if the pid file descriptor refers to a child of the calling process, +then it can be waited on using +.br waitid (2). +.ip \(bu +the +.br pidfd_getfd (2) +system call can be used to obtain a duplicate of a file descriptor +of another process referred to by a pid file descriptor. +.ip \(bu +a pid file descriptor can be used as the argument of +.br setns (2) +in order to move into one or more of the same namespaces as the process +referred to by the file descriptor. +.ip \(bu +a pid file descriptor can be used as the argument of +.br process_madvise (2) +in order to provide advice on the memory usage patterns of the process +referred to by the file descriptor. +.pp +the +.br pidfd_open () +system call is the preferred way of obtaining a pid file descriptor +for an already existing process. +the alternative is to obtain a file descriptor by opening a +.i /proc/[pid] +directory. +however, the latter technique is possible only if the +.br proc (5) +filesystem is mounted; +furthermore, the file descriptor obtained in this way is +.i not +pollable and can't be waited on with +.br waitid (2). +.sh examples +the program below opens a pid file descriptor for the +process whose pid is specified as its command-line argument. +it then uses +.br poll (2) +to monitor the file descriptor for process exit, as indicated by an +.br epollin +event. +.\" +.ss program source +\& +.ex +#define _gnu_source +#include +#include +#include +#include +#include +#include + +#ifndef __nr_pidfd_open +#define __nr_pidfd_open 434 /* system call # on most architectures */ +#endif + +static int +pidfd_open(pid_t pid, unsigned int flags) +{ + return syscall(__nr_pidfd_open, pid, flags); +} + +int +main(int argc, char *argv[]) +{ + struct pollfd pollfd; + int pidfd, ready; + + if (argc != 2) { + fprintf(stderr, "usage: %s \en", argv[0]); + exit(exit_success); + } + + pidfd = pidfd_open(atoi(argv[1]), 0); + if (pidfd == \-1) { + perror("pidfd_open"); + exit(exit_failure); + } + + pollfd.fd = pidfd; + pollfd.events = pollin; + + ready = poll(&pollfd, 1, \-1); + if (ready == \-1) { + perror("poll"); + exit(exit_failure); + } + + printf("events (%#x): pollin is %sset\en", pollfd.revents, + (pollfd.revents & pollin) ? "" : "not "); + + close(pidfd); + exit(exit_success); +} +.ee +.sh see also +.br clone (2), +.br kill (2), +.br pidfd_getfd (2), +.br pidfd_send_signal (2), +.br poll (2), +.br process_madvise (2), +.br select (2), +.br setns (2), +.br waitid (2), +.br epoll (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 2009 lefteris dimitroulakis (edimitro@tee.gr) +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" eli zaretskii made valuable suggestions +.\" +.th iso_8859-8 7 2020-08-13 "linux" "linux programmer's manual" +.sh name +iso_8859-8 \- iso 8859-8 character set encoded in octal, decimal, +and hexadecimal +.sh description +the iso 8859 standard includes several 8-bit extensions to the ascii +character set (also known as iso 646-irv). +iso 8859-8 encodes the +characters used in modern hebrew. +.ss iso 8859 alphabets +the full set of iso 8859 alphabets includes: +.ts +l l. +iso 8859-1 west european languages (latin-1) +iso 8859-2 central and east european languages (latin-2) +iso 8859-3 southeast european and miscellaneous languages (latin-3) +iso 8859-4 scandinavian/baltic languages (latin-4) +iso 8859-5 latin/cyrillic +iso 8859-6 latin/arabic +iso 8859-7 latin/greek +iso 8859-8 latin/hebrew +iso 8859-9 latin-1 modification for turkish (latin-5) +iso 8859-10 lappish/nordic/eskimo languages (latin-6) +iso 8859-11 latin/thai +iso 8859-13 baltic rim languages (latin-7) +iso 8859-14 celtic (latin-8) +iso 8859-15 west european languages (latin-9) +iso 8859-16 romanian (latin-10) +.te +.ss iso 8859-8 characters +the following table displays the characters in iso 8859-8 that +are printable and unlisted in the +.br ascii (7) +manual page. +.ts +l l l c lp-1. +oct dec hex char description +_ +240 160 a0 no-break space +242 162 a2 ¢ cent sign +243 163 a3 £ pound sign +244 164 a4 ¤ currency sign +245 165 a5 ¥ yen sign +246 166 a6 ¦ broken bar +247 167 a7 § section sign +250 168 a8 ¨ diaeresis +251 169 a9 © copyright sign +252 170 aa × multiplication sign +253 171 ab « left-pointing double angle quotation mark +254 172 ac ¬ not sign +255 173 ad ­ soft hyphen +256 174 ae ® registered sign +257 175 af ¯ macron +260 176 b0 ° degree sign +261 177 b1 ± plus-minus sign +262 178 b2 ² superscript two +263 179 b3 ³ superscript three +264 180 b4 ´ acute accent +265 181 b5 µ micro sign +266 182 b6 ¶ pilcrow sign +267 183 b7 · middle dot +270 184 b8 ¸ cedilla +271 185 b9 ¹ superscript one +272 186 ba ÷ division sign +273 187 bb » right-pointing double angle quotation mark +274 188 bc ¼ vulgar fraction one quarter +275 189 bd ½ vulgar fraction one half +276 190 be ¾ vulgar fraction three quarters +337 223 df ‗ double low line +340 224 e0 א hebrew letter alef +341 225 e1 ב hebrew letter bet +342 226 e2 ג hebrew letter gimel +343 227 e3 ד hebrew letter dalet +344 228 e4 ה hebrew letter he +345 229 e5 ו hebrew letter vav +346 230 e6 ז hebrew letter zayin +347 231 e7 ח hebrew letter het +350 232 e8 ט hebrew letter tet +351 233 e9 י hebrew letter yod +352 234 ea ך hebrew letter final kaf +353 235 eb כ hebrew letter kaf +354 236 ec ל hebrew letter lamed +355 237 ed ם hebrew letter final mem +356 238 ee מ hebrew letter mem +357 239 ef ן hebrew letter final nun +360 240 f0 נ hebrew letter nun +361 241 f1 ס hebrew letter samekh +362 242 f2 ע hebrew letter ayin +363 243 f3 ף hebrew letter final pe +364 244 f4 פ hebrew letter pe +365 245 f5 ץ hebrew letter final tsadi +366 246 f6 צ hebrew letter tsadi +367 247 f7 ק hebrew letter qof +370 248 f8 ר hebrew letter resh +371 249 f9 ש hebrew letter shin +372 250 fa ת hebrew letter tav +375 253 fd ‎ left-to-right mark +376 254 fe ‏ right-to-left mark +.te +.sh notes +iso 8859-8 was also known as iso-ir-138. +iso 8859-8 includes neither short vowels nor diacritical marks, +and yiddish is not provided for. +.sh see also +.br ascii (7), +.br charsets (7), +.br utf\-8 (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/sincos.3 + +.so man3/unlocked_stdio.3 + +.\" copyright (c) 1995, thomas k. dyas +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" created wed aug 9 1995 thomas k. dyas +.\" +.th sysfs 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +sysfs \- get filesystem type information +.sh synopsis +.nf +.bi "int sysfs(int " option ", const char *" fsname ); +.bi "int sysfs(int " option ", unsigned int " fs_index ", char *" buf ); +.bi "int sysfs(int " option ); +.fi +.sh description +.br "note" : +if you are looking for information about the +.b sysfs +filesystem that is normally mounted at +.ir /sys , +see +.br sysfs (5). +.pp +the (obsolete) +.br sysfs () +system call returns information about the filesystem types +currently present in the kernel. +the specific form of the +.br sysfs () +call and the information returned depends on the +.i option +in effect: +.tp 3 +.b 1 +translate the filesystem identifier string +.i fsname +into a filesystem type index. +.tp +.b 2 +translate the filesystem type index +.i fs_index +into a null-terminated filesystem identifier string. +this string will +be written to the buffer pointed to by +.ir buf . +make sure that +.i buf +has enough space to accept the string. +.tp +.b 3 +return the total number of filesystem types currently present in the +kernel. +.pp +the numbering of the filesystem type indexes begins with zero. +.sh return value +on success, +.br sysfs () +returns the filesystem index for option +.br 1 , +zero for option +.br 2 , +and the number of currently configured filesystems for option +.br 3 . +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b efault +.ri "either " fsname " or " buf +is outside your accessible address space. +.tp +.b einval +.i fsname +is not a valid filesystem type identifier; +.i fs_index +is out-of-bounds; +.i option +is invalid. +.sh conforming to +svr4. +.sh notes +this system-v derived system call is obsolete; don't use it. +on systems with +.ir /proc , +the same information can be obtained via +.ir /proc ; +use that interface instead. +.sh bugs +there is no libc or glibc support. +there is no way to guess how large \fibuf\fp should be. +.sh see also +.br proc (5), +.br sysfs (5) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1983, 1991 the regents of the university of california. +.\" all rights reserved. +.\" +.\" %%%license_start(bsd_4_clause_ucb) +.\" redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. all advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" this product includes software developed by the university of +.\" california, berkeley and its contributors. +.\" 4. neither the name of the university nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" this software is provided by the regents and contributors ``as is'' and +.\" any express or implied warranties, including, but not limited to, the +.\" implied warranties of merchantability and fitness for a particular purpose +.\" are disclaimed. in no event shall the regents or contributors be liable +.\" for any direct, indirect, incidental, special, exemplary, or consequential +.\" damages (including, but not limited to, procurement of substitute goods +.\" or services; loss of use, data, or profits; or business interruption) +.\" however caused and on any theory of liability, whether in contract, strict +.\" liability, or tort (including negligence or otherwise) arising in any way +.\" out of the use of this software, even if advised of the possibility of +.\" such damage. +.\" %%%license_end +.\" +.\" @(#)getsockname.2 6.4 (berkeley) 3/10/91 +.\" +.\" modified sat jul 24 16:30:29 1993 by rik faith +.\" modified tue oct 22 00:22:35 edt 1996 by eric s. raymond +.\" modified sun mar 28 21:26:46 1999 by andries brouwer +.\" +.th getsockname 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +getsockname \- get socket name +.sh synopsis +.nf +.b #include +.pp +.bi "int getsockname(int " sockfd ", struct sockaddr *restrict " addr , +.bi " socklen_t *restrict " addrlen ); +.fi +.sh description +.br getsockname () +returns the current address to which the socket +.i sockfd +is bound, in the buffer pointed to by +.ir addr . +the +.i addrlen +argument should be initialized to indicate +the amount of space (in bytes) pointed to by +.ir addr . +on return it contains the actual size of the socket address. +.pp +the returned address is truncated if the buffer provided is too small; +in this case, +.i addrlen +will return a value greater than was supplied to the call. +.sh return value +on success, zero is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b ebadf +the argument +.i sockfd +is not a valid file descriptor. +.tp +.b efault +the +.i addr +argument points to memory not in a valid part of the +process address space. +.tp +.b einval +.i addrlen +is invalid (e.g., is negative). +.tp +.b enobufs +insufficient resources were available in the system +to perform the operation. +.tp +.b enotsock +the file descriptor +.i sockfd +does not refer to a socket. +.sh conforming to +posix.1-2001, posix.1-2008, svr4, 4.4bsd +.rb ( getsockname () +first appeared in 4.2bsd). +.\" svr4 documents additional enomem +.\" and enosr error codes. +.sh notes +for background on the +.i socklen_t +type, see +.br accept (2). +.sh see also +.br bind (2), +.br socket (2), +.br getifaddrs (3), +.br ip (7), +.br socket (7), +.br unix (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/unimplemented.2 + +.so man3/max.3 + +.\" copyright (c), 1994, graeme w. wilford. (wilf.) +.\" and copyright (c) 2010, 2015, michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" fri jul 29th 12:56:44 bst 1994 wilf. +.\" modified 1997-01-31 by eric s. raymond +.\" modified 2002-03-09 by aeb +.\" +.th setgid 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +setgid \- set group identity +.sh synopsis +.nf +.b #include +.pp +.bi "int setgid(gid_t " gid ); +.fi +.sh description +.br setgid () +sets the effective group id of the calling process. +if the calling process is privileged (more precisely: has the +.b cap_setgid +capability in its user namespace), +the real gid and saved set-group-id are also set. +.pp +under linux, +.br setgid () +is implemented like the posix version with the +.b _posix_saved_ids +feature. +this allows a set-group-id program that is not set-user-id-root +to drop all of its group +privileges, do some un-privileged work, and then reengage the original +effective group id in a secure manner. +.sh return value +on success, zero is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b einval +the group id specified in +.i gid +is not valid in this user namespace. +.tp +.b eperm +the calling process is not privileged (does not have the +\fbcap_setgid\fp capability in its user namespace), and +.i gid +does not match the real group id or saved set-group-id of +the calling process. +.sh conforming to +posix.1-2001, posix.1-2008, svr4. +.sh notes +the original linux +.br setgid () +system call supported only 16-bit group ids. +subsequently, linux 2.4 added +.br setgid32 () +supporting 32-bit ids. +the glibc +.br setgid () +wrapper function transparently deals with the variation across kernel versions. +.\" +.ss c library/kernel differences +at the kernel level, user ids and group ids are a per-thread attribute. +however, posix requires that all threads in a process +share the same credentials. +the nptl threading implementation handles the posix requirements by +providing wrapper functions for +the various system calls that change process uids and gids. +these wrapper functions (including the one for +.br setgid ()) +employ a signal-based technique to ensure +that when one thread changes credentials, +all of the other threads in the process also change their credentials. +for details, see +.br nptl (7). +.sh see also +.br getgid (2), +.br setegid (2), +.br setregid (2), +.br capabilities (7), +.br credentials (7), +.br user_namespaces (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/timeradd.3 + +.so man3/abs.3 + +.so man3/endian.3 + +.so man3/unlocked_stdio.3 + +.so man3/inet.3 + +.\" copyright 2001 andries brouwer . +.\" and copyright 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th lrint 3 2021-03-22 "" "linux programmer's manual" +.sh name +lrint, lrintf, lrintl, llrint, llrintf, llrintl \- round to nearest integer +.sh synopsis +.nf +.b #include +.pp +.bi "long lrint(double " x ); +.bi "long lrintf(float " x ); +.bi "long lrintl(long double " x ); +.pp +.bi "long long llrint(double " x ); +.bi "long long llrintf(float " x ); +.bi "long long llrintl(long double " x ); +.fi +.pp +link with \fi\-lm\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +all functions shown above: +.nf + _isoc99_source || _posix_c_source >= 200112l +.fi +.sh description +these functions round their argument to the nearest integer value, +using the current rounding direction (see +.br fesetround (3)). +.pp +note that unlike the +.br rint (3) +family of functions, +the return type of these functions differs from +that of their arguments. +.sh return value +these functions return the rounded integer value. +.pp +if +.i x +is a nan or an infinity, +or the rounded value is too large to be stored in a +.i long +.ri ( "long long" +in the case of the +.b ll* +functions), +then a domain error occurs, and the return value is unspecified. +.\" the return value is -(long_max - 1) or -(llong_max -1) +.sh errors +see +.br math_error (7) +for information on how to determine whether an error has occurred +when calling these functions. +.pp +the following errors can occur: +.tp +domain error: \fix\fp is a nan or infinite, or the rounded value is too large +.\" .i errno +.\" is set to +.\" .br edom . +an invalid floating-point exception +.rb ( fe_invalid ) +is raised. +.pp +these functions do not set +.ir errno . +.\" fixme . is it intentional that these functions do not set errno? +.\" bug raised: http://sources.redhat.com/bugzilla/show_bug.cgi?id=6798 +.sh versions +these functions first appeared in glibc in version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br lrint (), +.br lrintf (), +.br lrintl (), +.br llrint (), +.br llrintf (), +.br llrintl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.sh see also +.br ceil (3), +.br floor (3), +.br lround (3), +.br nearbyint (3), +.br rint (3), +.br round (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1992 drew eckhardt , march 28, 1992 +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified by michael haardt +.\" modified 1993-07-24 by rik faith +.\" modified 1996-11-04 by eric s. raymond +.\" modified 2001-06-04 by aeb +.\" modified 2004-05-27 by michael kerrisk +.\" +.th nice 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +nice \- change process priority +.sh synopsis +.nf +.b #include +.pp +.bi "int nice(int " inc ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br nice (): +.nf + _xopen_source + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.sh description +.br nice () +adds +.i inc +to the nice value for the calling thread. +(a higher nice value means a lower priority.) +.pp +the range of the nice value is +19 (low priority) to \-20 (high priority). +attempts to set a nice value outside the range are clamped to the range. +.pp +traditionally, only a privileged process could lower the nice value +(i.e., set a higher priority). +however, since linux 2.6.12, an unprivileged process can decrease +the nice value of a target process that has a suitable +.br rlimit_nice +soft limit; see +.br getrlimit (2) +for details. +.sh return value +on success, the new nice value is returned (but see notes below). +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.pp +a successful call can legitimately return \-1. +to detect an error, set +.i errno +to 0 before the call, and check whether it is nonzero after +.br nice () +returns \-1. +.sh errors +.tp +.b eperm +the calling process attempted to increase its priority by +supplying a negative +.i inc +but has insufficient privileges. +under linux, the +.b cap_sys_nice +capability is required. +(but see the discussion of the +.b rlimit_nice +resource limit in +.br setrlimit (2).) +.sh conforming to +posix.1-2001, posix.1-2008, svr4, 4.3bsd. +however, the raw system call and (g)libc +(earlier than glibc 2.2.4) return value is nonstandard, see below. +.\" svr4 documents an additional +.\" .b einval +.\" error code. +.sh notes +for further details on the nice value, see +.br sched (7). +.pp +.ir note : +the addition of the "autogroup" feature in linux 2.6.38 means that +the nice value no longer has its traditional effect in many circumstances. +for details, see +.br sched (7). +.\" +.ss c library/kernel differences +posix.1 specifies that +.br nice () +should return the new nice value. +however, the raw linux system call returns 0 on success. +likewise, the +.br nice () +wrapper function provided in glibc 2.2.3 and earlier returns 0 on success. +.pp +since glibc 2.2.4, the +.br nice () +wrapper function provided by glibc provides conformance to posix.1 by calling +.br getpriority (2) +to obtain the new nice value, which is then returned to the caller. +.sh see also +.br nice (1), +.br renice (1), +.br fork (2), +.br getpriority (2), +.br getrlimit (2), +.br setpriority (2), +.br capabilities (7), +.br sched (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/if_nameindex.3 + +.so man3/circleq.3 + +.so man3/resolver.3 + +.so man3/ether_aton.3 + +.so man3/catan.3 + +.\" this manpage is copyright (c) 1992 drew eckhardt; +.\" and copyright (c) 1993 michael haardt, ian jackson. +.\" and copyright (c) 2007 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified sat jul 24 13:35:59 1993 by rik faith +.\" modified sun nov 28 17:19:01 1993 by rik faith +.\" modified sat jan 13 12:58:08 1996 by michael haardt +.\" +.\" modified sun jul 21 18:59:33 1996 by andries brouwer +.\" 2001-12-13 added remark by zack weinberg +.\" 2007-06-18 mtk: +.\" added details about seekable files and file offset. +.\" noted that write() may write less than 'count' bytes, and +.\" gave some examples of why this might occur. +.\" noted what happens if write() is interrupted by a signal. +.\" +.th write 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +write \- write to a file descriptor +.sh synopsis +.nf +.b #include +.pp +.bi "ssize_t write(int " fd ", const void *" buf ", size_t " count ); +.fi +.sh description +.br write () +writes up to +.i count +bytes from the buffer starting at +.i buf +to the file referred to by the file descriptor +.ir fd . +.pp +the number of bytes written may be less than +.i count +if, for example, +there is insufficient space on the underlying physical medium, or the +.b rlimit_fsize +resource limit is encountered (see +.br setrlimit (2)), +or the call was interrupted by a signal +handler after having written less than +.i count +bytes. +(see also +.br pipe (7).) +.pp +for a seekable file (i.e., one to which +.br lseek (2) +may be applied, for example, a regular file) +writing takes place at the file offset, +and the file offset is incremented by +the number of bytes actually written. +if the file was +.br open (2)ed +with +.br o_append , +the file offset is first set to the end of the file before writing. +the adjustment of the file offset and the write operation +are performed as an atomic step. +.pp +posix requires that a +.br read (2) +that can be proved to occur after a +.br write () +has returned will return the new data. +note that not all filesystems are posix conforming. +.pp +according to posix.1, if +.i count +is greater than +.br ssize_max , +the result is implementation-defined; +see notes for the upper limit on linux. +.sh return value +on success, the number of bytes written is returned. +on error, \-1 is returned, and \fierrno\fp is set +to indicate the error. +.pp +note that a successful +.br write () +may transfer fewer than +.i count +bytes. +such partial writes can occur for various reasons; +for example, because there was insufficient space on the disk device +to write all of the requested bytes, or because a blocked +.br write () +to a socket, pipe, or similar was interrupted by a signal handler +after it had transferred some, but before it had transferred all +of the requested bytes. +in the event of a partial write, the caller can make another +.br write () +call to transfer the remaining bytes. +the subsequent call will either transfer further bytes or +may result in an error (e.g., if the disk is now full). +.pp +if \ficount\fp is zero and +.i fd +refers to a regular file, then +.br write () +may return a failure status if one of the errors below is detected. +if no errors are detected, or error detection is not performed, +0 is returned without causing any other effect. +if +\ficount\fp is zero and +.i fd +refers to a file other than a regular file, +the results are not specified. +.sh errors +.tp +.b eagain +the file descriptor +.i fd +refers to a file other than a socket and has been marked nonblocking +.rb ( o_nonblock ), +and the write would block. +see +.br open (2) +for further details on the +.br o_nonblock +flag. +.tp +.br eagain " or " ewouldblock +.\" actually eagain on linux +the file descriptor +.i fd +refers to a socket and has been marked nonblocking +.rb ( o_nonblock ), +and the write would block. +posix.1-2001 allows either error to be returned for this case, +and does not require these constants to have the same value, +so a portable application should check for both possibilities. +.tp +.b ebadf +.i fd +is not a valid file descriptor or is not open for writing. +.tp +.b edestaddrreq +.i fd +refers to a datagram socket for which a peer address has not been set using +.br connect (2). +.tp +.b edquot +the user's quota of disk blocks on the filesystem containing the file +referred to by +.i fd +has been exhausted. +.tp +.b efault +.i buf +is outside your accessible address space. +.tp +.b efbig +an attempt was made to write a file that exceeds the implementation-defined +maximum file size or the process's file size limit, +or to write at a position past the maximum allowed offset. +.tp +.b eintr +the call was interrupted by a signal before any data was written; see +.br signal (7). +.tp +.b einval +.i fd +is attached to an object which is unsuitable for writing; +or the file was opened with the +.b o_direct +flag, and either the address specified in +.ir buf , +the value specified in +.ir count , +or the file offset is not suitably aligned. +.tp +.b eio +a low-level i/o error occurred while modifying the inode. +this error may relate to the write-back of data written by an earlier +.br write (), +which may have been issued to a different file descriptor on +the same file. +since linux 4.13, errors from write-back come +with a promise that they +.i may +be reported by subsequent. +.br write () +requests, and +.i will +be reported by a subsequent +.br fsync (2) +(whether or not they were also reported by +.br write ()). +.\" commit 088737f44bbf6378745f5b57b035e57ee3dc4750 +an alternate cause of +.b eio +on networked filesystems is when an advisory lock had been taken out +on the file descriptor and this lock has been lost. +see the +.i "lost locks" +section of +.br fcntl (2) +for further details. +.tp +.b enospc +the device containing the file referred to by +.i fd +has no room for the data. +.tp +.b eperm +the operation was prevented by a file seal; see +.br fcntl (2). +.tp +.b epipe +.i fd +is connected to a pipe or socket whose reading end is closed. +when this happens the writing process will also receive a +.b sigpipe +signal. +(thus, the write return value is seen only if the program +catches, blocks or ignores this signal.) +.pp +other errors may occur, depending on the object connected to +.ir fd . +.sh conforming to +svr4, 4.3bsd, posix.1-2001. +.\" svr4 documents additional error +.\" conditions edeadlk, enolck, enolnk, enosr, enxio, or erange. +.pp +under svr4 a write may be interrupted and return +.b eintr +at any point, +not just before any data is written. +.sh notes +the types +.i size_t +and +.i ssize_t +are, respectively, +unsigned and signed integer data types specified by posix.1. +.pp +a successful return from +.br write () +does not make any guarantee that data has been committed to disk. +on some filesystems, including nfs, it does not even guarantee +that space has successfully been reserved for the data. +in this case, +some errors might be delayed until a future +.br write (), +.br fsync (2), +or even +.br close (2). +the only way to be sure is to call +.br fsync (2) +after you are done writing all your data. +.pp +if a +.br write () +is interrupted by a signal handler before any bytes are written, +then the call fails with the error +.br eintr ; +if it is interrupted after at least one byte has been written, +the call succeeds, and returns the number of bytes written. +.pp +on linux, +.br write () +(and similar system calls) will transfer at most +0x7ffff000 (2,147,479,552) bytes, +returning the number of bytes actually transferred. +.\" commit e28cc71572da38a5a12c1cfe4d7032017adccf69 +(this is true on both 32-bit and 64-bit systems.) +.pp +an error return value while performing +.br write () +using direct i/o does not mean the +entire write has failed. +partial data may be written +and the data at the file offset on which the +.br write () +was attempted should be considered inconsistent. +.sh bugs +according to posix.1-2008/susv4 section xsi 2.9.7 +("thread interactions with regular file operations"): +.pp +.rs 4 +all of the following functions shall be atomic with respect to +each other in the effects specified in posix.1-2008 when they +operate on regular files or symbolic links: ... +.re +.pp +among the apis subsequently listed are +.br write () +and +.br writev (2). +and among the effects that should be atomic across threads (and processes) +are updates of the file offset. +however, on linux before version 3.14, +this was not the case: if two processes that share +an open file description (see +.br open (2)) +perform a +.br write () +(or +.br writev (2)) +at the same time, then the i/o operations were not atomic +with respect to updating the file offset, +with the result that the blocks of data output by the two processes +might (incorrectly) overlap. +this problem was fixed in linux 3.14. +.\" http://thread.gmane.org/gmane.linux.kernel/1649458 +.\" from: michael kerrisk (man-pages gmail.com> +.\" subject: update of file offset on write() etc. is non-atomic with i/o +.\" date: 2014-02-17 15:41:37 gmt +.\" newsgroups: gmane.linux.kernel, gmane.linux.file-systems +.\" commit 9c225f2655e36a470c4f58dbbc99244c5fc7f2d4 +.\" author: linus torvalds +.\" date: mon mar 3 09:36:58 2014 -0800 +.\" +.\" vfs: atomic f_pos accesses as per posix +.sh see also +.br close (2), +.br fcntl (2), +.br fsync (2), +.br ioctl (2), +.br lseek (2), +.br open (2), +.br pwrite (2), +.br read (2), +.br select (2), +.br writev (2), +.br fwrite (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/ctime.3 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sun jul 25 10:40:51 1993 by rik faith (faith@cs.unc.edu) +.\" modified sun apr 14 16:20:34 1996 by andries brouwer (aeb@cwi.nl) +.th siginterrupt 3 2021-03-22 "" "linux programmer's manual" +.sh name +siginterrupt \- allow signals to interrupt system calls +.sh synopsis +.nf +.b #include +.pp +.bi "int siginterrupt(int " sig ", int " flag ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br siginterrupt (): +.nf + _xopen_source >= 500 +.\" || _xopen_source && _xopen_source_extended + || /* since glibc 2.12: */ _posix_c_source >= 200809l + || /* glibc <= 2.19: */ _bsd_source +.fi +.sh description +the +.br siginterrupt () +function changes the restart behavior when +a system call is interrupted by the signal \fisig\fp. +if the \fiflag\fp +argument is false (0), then system calls will be restarted if interrupted +by the specified signal \fisig\fp. +this is the default behavior in linux. +.pp +if the \fiflag\fp argument is true (1) and no data has been transferred, +then a system call interrupted by the signal \fisig\fp will return \-1 +and \fierrno\fp will be set to +.br eintr . +.pp +if the \fiflag\fp argument is true (1) and data transfer has started, +then the system call will be interrupted and will return the actual +amount of data transferred. +.sh return value +the +.br siginterrupt () +function returns 0 on success. +it returns \-1 if the +signal number +.i sig +is invalid, with +.i errno +set to indicate the error. +.sh errors +.tp +.b einval +the specified signal number is invalid. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lb lb lbx +l l l. +interface attribute value +t{ +.br siginterrupt () +t} thread safety t{ +mt-unsafe const:sigintr +t} +.te +.hy +.ad +.sp 1 +.sh conforming to +4.3bsd, posix.1-2001. +posix.1-2008 marks +.br siginterrupt () +as obsolete, recommending the use of +.br sigaction (2) +with the +.b sa_restart +flag instead. +.sh see also +.br signal (2) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2017, michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of +.\" this manual under the conditions for verbatim copying, provided that +.\" the entire resulting derived work is distributed under the terms of +.\" a permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume. +.\" no responsibility for errors or omissions, or for damages resulting. +.\" from the use of the information contained herein. the author(s) may. +.\" not have taken the same level of care in the production of this. +.\" manual, which is licensed free of charge, as they might when working. +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th getentropy 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +getentropy \- fill a buffer with random bytes +.sh synopsis +.nf +.b #include +.pp +.bi "int getentropy(void *" buffer ", size_t " length ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br getentropy (): +.nf + _default_source +.fi +.sh description +the +.br getentropy () +function writes +.i length +bytes of high-quality random data to the buffer starting +at the location pointed to by +.ir buffer . +the maximum permitted value for the +.i length +argument is 256. +.pp +a successful call to +.br getentropy () +always provides the requested number of bytes of entropy. +.sh return value +on success, this function returns zero. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b efault +part or all of the buffer specified by +.i buffer +and +.i length +is not in valid addressable memory. +.tp +.b eio +.i length +is greater than 256. +.tp +.b eio +an unspecified error occurred while trying to overwrite +.i buffer +with random data. +.tp +.b enosys +this kernel version does not implement the +.br getrandom (2) +system call required to implement this function. +.sh versions +the +.br getentropy () +function first appeared in glibc 2.25. +.sh conforming to +this function is nonstandard. +it is also present on openbsd. +.sh notes +the +.br getentropy () +function is implemented using +.br getrandom (2). +.pp +whereas the glibc wrapper makes +.br getrandom (2) +a cancellation point, +.br getentropy () +is not a cancellation point. +.pp +.br getentropy () +is also declared in +.br . +(no feature test macro need be defined to obtain the declaration from +that header file.) +.pp +a call to +.br getentropy () +may block if the system has just booted and the kernel has +not yet collected enough randomness to initialize the entropy pool. +in this case, +.br getentropy () +will keep blocking even if a signal is handled, +and will return only once the entropy pool has been initialized. +.sh see also +.br getrandom (2), +.br urandom (4), +.br random (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/strtoimax.3 + +.\" copyright (c) 1990, 1991 the regents of the university of california. +.\" all rights reserved. +.\" +.\" this code is derived from software contributed to berkeley by +.\" chris torek and the american national standards committee x3, +.\" on information processing systems. +.\" +.\" %%%license_start(bsd_4_clause_ucb) +.\" redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. all advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" this product includes software developed by the university of +.\" california, berkeley and its contributors. +.\" 4. neither the name of the university nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" this software is provided by the regents and contributors ``as is'' and +.\" any express or implied warranties, including, but not limited to, the +.\" implied warranties of merchantability and fitness for a particular purpose +.\" are disclaimed. in no event shall the regents or contributors be liable +.\" for any direct, indirect, incidental, special, exemplary, or consequential +.\" damages (including, but not limited to, procurement of substitute goods +.\" or services; loss of use, data, or profits; or business interruption) +.\" however caused and on any theory of liability, whether in contract, strict +.\" liability, or tort (including negligence or otherwise) arising in any way +.\" out of the use of this software, even if advised of the possibility of +.\" such damage. +.\" %%%license_end +.\" +.\" @(#)fopen.3 6.8 (berkeley) 6/29/91 +.\" +.\" converted for linux, mon nov 29 15:22:01 1993, faith@cs.unc.edu +.\" modified, aeb, 960421, 970806 +.\" modified, joey, aeb, 2002-01-03 +.\" +.th fopen 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +fopen, fdopen, freopen \- stream open functions +.sh synopsis +.nf +.b #include +.pp +.bi "file *fopen(const char *restrict " pathname \ +", const char *restrict " mode ); +.bi "file *fdopen(int " fd ", const char *" mode ); +.bi "file *freopen(const char *restrict " pathname \ +", const char *restrict " mode , +.bi " file *restrict " stream ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br fdopen (): +.nf + _posix_c_source +.fi +.sh description +the +.br fopen () +function opens the file whose name is the string pointed to by +.i pathname +and associates a stream with it. +.pp +the argument +.i mode +points to a string beginning with one of the following sequences +(possibly followed by additional characters, as described below): +.tp +.b r +open text file for reading. +the stream is positioned at the beginning of the file. +.tp +.b r+ +open for reading and writing. +the stream is positioned at the beginning of the file. +.tp +.b w +truncate file to zero length or create text file for writing. +the stream is positioned at the beginning of the file. +.tp +.b w+ +open for reading and writing. +the file is created if it does not exist, otherwise it is truncated. +the stream is positioned at the beginning of +the file. +.tp +.b a +open for appending (writing at end of file). +the file is created if it does not exist. +the stream is positioned at the end of the file. +.tp +.b a+ +open for reading and appending (writing at end of file). +the file is created if it does not exist. +output is always appended to the end of the file. +posix is silent on what the initial read position is when using this mode. +for glibc, the initial file position for reading is at +the beginning of the file, but for android/bsd/macos, the +initial file position for reading is at the end of the file. +.pp +the +.i mode +string can also include the letter \(aqb\(aq either as a last character or as +a character between the characters in any of the two-character strings +described above. +this is strictly for compatibility with c89 +and has no effect; the \(aqb\(aq is ignored on all posix +conforming systems, including linux. +(other systems may treat text files and binary files differently, +and adding the \(aqb\(aq may be a good idea if you do i/o to a binary +file and expect that your program may be ported to non-unix +environments.) +.pp +see notes below for details of glibc extensions for +.ir mode . +.pp +any created file will have the mode +.br s_irusr " | " s_iwusr " | " s_irgrp " | " s_iwgrp " | " s_iroth " | " s_iwoth +(0666), as modified by the process's umask value (see +.br umask (2)). +.pp +reads and writes may be intermixed on read/write streams in any order. +note that ansi c requires that a file positioning function intervene +between output and input, unless an input operation encounters end-of-file. +(if this condition is not met, then a read is allowed to return the +result of writes other than the most recent.) +therefore it is good practice (and indeed sometimes necessary +under linux) to put an +.br fseek (3) +or +.br fgetpos (3) +operation between write and read operations on such a stream. +this operation may be an apparent no-op +(as in \fifseek(..., 0l, seek_cur)\fp +called for its synchronizing side effect). +.pp +opening a file in append mode (\fba\fp as the first character of +.ir mode ) +causes all subsequent write operations to this stream to occur +at end-of-file, as if preceded the call: +.pp +.in +4n +.ex +fseek(stream, 0, seek_end); +.ee +.in +.pp +the file descriptor associated with the stream is opened as if by a call to +.br open (2) +with the following flags: +.rs +.ts +allbox; +lb lb +c l. +fopen() mode open() flags +\fir\fp o_rdonly +\fiw\fp o_wronly | o_creat | o_trunc +\fia\fp o_wronly | o_creat | o_append +\fir+\fp o_rdwr +\fiw+\fp o_rdwr | o_creat | o_trunc +\fia+\fp o_rdwr | o_creat | o_append +.te +.re +.\" +.ss fdopen() +the +.br fdopen () +function associates a stream with the existing file descriptor, +.ir fd . +the +.i mode +of the stream (one of the values "r", "r+", "w", "w+", "a", "a+") +must be compatible with the mode of the file descriptor. +the file position indicator of the new stream is set to that +belonging to +.ir fd , +and the error and end-of-file indicators are cleared. +modes "w" or "w+" do not cause truncation of the file. +the file descriptor is not dup'ed, and will be closed when +the stream created by +.br fdopen () +is closed. +the result of applying +.br fdopen () +to a shared memory object is undefined. +.\" +.ss freopen() +the +.br freopen () +function opens the file whose name is the string pointed to by +.i pathname +and associates the stream pointed to by +.i stream +with it. +the original stream (if it exists) is closed. +the +.i mode +argument is used just as in the +.br fopen () +function. +.pp +if the +.i pathname +argument is a null pointer, +.br freopen () +changes the mode of the stream to that specified in +.ir mode ; +that is, +.br freopen () +reopens the pathname that is associated with the stream. +the specification for this behavior was added in the c99 standard, which says: +.pp +.rs +in this case, +the file descriptor associated with the stream need not be closed +if the call to +.br freopen () +succeeds. +it is implementation-defined which changes of mode are permitted (if any), +and under what circumstances. +.re +.pp +the primary use of the +.br freopen () +function is to change the file associated with a standard text stream +.ri ( stderr ", " stdin ", or " stdout ). +.sh return value +upon successful completion +.br fopen (), +.br fdopen (), +and +.br freopen () +return a +.i file +pointer. +otherwise, null is returned and +.i errno +is set to indicate the error. +.sh errors +.tp +.b einval +the +.i mode +provided to +.br fopen (), +.br fdopen (), +or +.br freopen () +was invalid. +.pp +the +.br fopen (), +.br fdopen (), +and +.br freopen () +functions may also fail and set +.i errno +for any of the errors specified for the routine +.br malloc (3). +.pp +the +.br fopen () +function may also fail and set +.i errno +for any of the errors specified for the routine +.br open (2). +.pp +the +.br fdopen () +function may also fail and set +.i errno +for any of the errors specified for the routine +.br fcntl (2). +.pp +the +.br freopen () +function may also fail and set +.i errno +for any of the errors specified for the routines +.br open (2), +.br fclose (3), +and +.br fflush (3). +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br fopen (), +.br fdopen (), +.br freopen () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +.br fopen (), +.br freopen (): +posix.1-2001, posix.1-2008, c89, c99. +.pp +.br fdopen (): +posix.1-2001, posix.1-2008. +.sh notes +.ss glibc notes +the gnu c library allows the following extensions for the string specified in +.ir mode : +.tp +.br c " (since glibc 2.3.3)" +do not make the open operation, +or subsequent read and write operations, +thread cancellation points. +this flag is ignored for +.br fdopen (). +.tp +.br e " (since glibc 2.7)" +open the file with the +.b o_cloexec +flag. +see +.br open (2) +for more information. +this flag is ignored for +.br fdopen (). +.tp +.br m " (since glibc 2.3)" +attempt to access the file using +.br mmap (2), +rather than i/o system calls +.rb ( read (2), +.br write (2)). +currently, +.\" as at glibc 2.4: +use of +.br mmap (2) +is attempted only for a file opened for reading. +.tp +.b x +.\" since glibc 2.0? +.\" fixme . c11 specifies this flag +open the file exclusively +(like the +.b o_excl +flag of +.br open (2)). +if the file already exists, +.br fopen () +fails, and sets +.i errno +to +.br eexist . +this flag is ignored for +.br fdopen (). +.pp +in addition to the above characters, +.br fopen () +and +.br freopen () +support the following syntax +in +.ir mode : +.pp +.bi " ,ccs=" string +.pp +the given +.i string +is taken as the name of a coded character set and +the stream is marked as wide-oriented. +thereafter, internal conversion functions convert i/o +to and from the character set +.ir string . +if the +.bi ,ccs= string +syntax is not specified, +then the wide-orientation of the stream is +determined by the first file operation. +if that operation is a wide-character operation, +the stream is marked wide-oriented, +and functions to convert to the coded character set are loaded. +.sh bugs +when parsing for individual flag characters in +.ir mode +(i.e., the characters preceding the "ccs" specification), +the glibc implementation of +.\" fixme . http://sourceware.org/bugzilla/show_bug.cgi?id=12685 +.br fopen () +and +.br freopen () +limits the number of characters examined in +.i mode +to 7 (or, in glibc versions before 2.14, to 6, +which was not enough to include possible specifications such as "rb+cmxe"). +the current implementation of +.br fdopen () +parses at most 5 characters in +.ir mode . +.sh see also +.br open (2), +.br fclose (3), +.br fileno (3), +.br fmemopen (3), +.br fopencookie (3), +.br open_memstream (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1995-2000 david engel (david@ods.com) +.\" copyright 1995 rickard e. faith (faith@cs.unc.edu) +.\" copyright 2000 ben collins (bcollins@debian.org) +.\" redone for glibc 2.2 +.\" copyright 2000 jakub jelinek (jakub@redhat.com) +.\" corrected. +.\" and copyright (c) 2012, 2016, michael kerrisk +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" do not restrict distribution. +.\" may be distributed under the gnu general public license +.\" %%%license_end +.\" +.th ldd 1 2021-08-27 "" "linux programmer's manual" +.sh name +ldd \- print shared object dependencies +.sh synopsis +.nf +.br ldd " [\fioption\fp]... \fifile\fp..." +.fi +.sh description +.b ldd +prints the shared objects (shared libraries) required by each program or +shared object specified on the command line. +an example of its use and output +is the following: +.pp +.in +4n +.ex +$ \fbldd /bin/ls\fp + linux\-vdso.so.1 (0x00007ffcc3563000) + libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f87e5459000) + libcap.so.2 => /lib64/libcap.so.2 (0x00007f87e5254000) + libc.so.6 => /lib64/libc.so.6 (0x00007f87e4e92000) + libpcre.so.1 => /lib64/libpcre.so.1 (0x00007f87e4c22000) + libdl.so.2 => /lib64/libdl.so.2 (0x00007f87e4a1e000) + /lib64/ld\-linux\-x86\-64.so.2 (0x00005574bf12e000) + libattr.so.1 => /lib64/libattr.so.1 (0x00007f87e4817000) + libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f87e45fa000) +.ee +.in +.pp +in the usual case, +.b ldd +invokes the standard dynamic linker (see +.br ld.so (8)) +with the +.b ld_trace_loaded_objects +environment variable set to 1. +this causes the dynamic linker to inspect the program's dynamic dependencies, +and find (according to the rules described in +.br ld.so (8)) +and load the objects that satisfy those dependencies. +for each dependency, +.b ldd +displays the location of the matching object +and the (hexadecimal) address at which it is loaded. +(the +.i linux\-vdso +and +.i ld\-linux +shared dependencies are special; see +.br vdso (7) +and +.br ld.so (8).) +.\" +.ss security +be aware that in some circumstances +(e.g., where the program specifies an elf interpreter other than +.ir ld\-linux.so ), +.\" the circumstances are where the program has an interpreter +.\" other than ld-linux.so. in this case, ldd tries to execute the +.\" program directly with ld_trace_loaded_objects=1, with the +.\" result that the program interpreter gets control, and can do +.\" what it likes, or pass control to the program itself. +.\" much more detail at +.\" http://www.catonmat.net/blog/ldd-arbitrary-code-execution/ +some versions of +.b ldd +may attempt to obtain the dependency information +by attempting to directly execute the program, +which may lead to the execution of whatever code is defined +in the program's elf interpreter, +and perhaps to execution of the program itself. +.\" mainline glibc's ldd allows this possibility (the line +.\" try_trace "$file" +.\" in glibc 2.15, for example), but many distro versions of +.\" ldd seem to remove that code path from the script. +(in glibc versions before 2.27, +.\" glibc commit eedca9772e99c72ab4c3c34e43cc764250aa3e3c +the upstream +.b ldd +implementation did this for example, +although most distributions provided a modified version that did not.) +.pp +thus, you should +.i never +employ +.b ldd +on an untrusted executable, +since this may result in the execution of arbitrary code. +a safer alternative when dealing with untrusted executables is: +.pp +.in +4n +.ex +$ \fbobjdump \-p /path/to/program | grep needed\fp +.ee +.in +.pp +note, however, that this alternative shows only the direct dependencies +of the executable, while +.b ldd +shows the entire dependency tree of the executable. +.sh options +.tp +.b \-\-version +print the version number of +.br ldd . +.tp +.br \-v ", " \-\-verbose +print all information, including, for example, +symbol versioning information. +.tp +.br \-u ", " \-\-unused +print unused direct dependencies. +(since glibc 2.3.4.) +.tp +.br \-d ", " \-\-data\-relocs +perform relocations and report any missing objects (elf only). +.tp +.br \-r ", " \-\-function\-relocs +perform relocations for both data objects and functions, and +report any missing objects or functions (elf only). +.tp +.b \-\-help +usage information. +.\" .sh notes +.\" the standard version of +.\" .b ldd +.\" comes with glibc2. +.\" libc5 came with an older version, still present +.\" on some systems. +.\" the long options are not supported by the libc5 version. +.\" on the other hand, the glibc2 version does not support +.\" .b \-v +.\" and only has the equivalent +.\" .br \-\-version . +.\" .lp +.\" the libc5 version of this program will use the name of a library given +.\" on the command line as-is when it contains a \(aq/\(aq; otherwise it +.\" searches for the library in the standard locations. +.\" to run it +.\" on a shared library in the current directory, prefix the name with "./". +.sh bugs +.b ldd +does not work on a.out shared libraries. +.pp +.b ldd +does not work with some extremely old a.out programs which were +built before +.b ldd +support was added to the compiler releases. +if you use +.b ldd +on one of these programs, the program will attempt to run with +.i argc += 0 and the results will be unpredictable. +.\" .sh author +.\" david engel. +.\" roland mcgrath and ulrich drepper. +.sh see also +.br pldd (1), +.br sprof (1), +.br ld.so (8), +.br ldconfig (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2008 linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th pthread_attr_setstack 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +pthread_attr_setstack, pthread_attr_getstack \- set/get stack +attributes in thread attributes object +.sh synopsis +.nf +.b #include +.pp +.bi "int pthread_attr_setstack(pthread_attr_t *" attr , +.bi " void *" stackaddr ", size_t " stacksize ); +.bi "int pthread_attr_getstack(const pthread_attr_t *restrict " attr , +.bi " void **restrict " stackaddr , +.bi " size_t *restrict " stacksize ); +.pp +compile and link with \fi\-pthread\fp. +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br pthread_attr_getstack (), +.br pthread_attr_setstack (): +.nf + _posix_c_source >= 200112l +.fi +.sh description +the +.br pthread_attr_setstack () +function sets the stack address and stack size attributes of the +thread attributes object referred to by +.i attr +to the values specified in +.ir stackaddr +and +.ir stacksize , +respectively. +these attributes specify the location and size of the stack that should +be used by a thread that is created using the thread attributes object +.ir attr . +.pp +.i stackaddr +should point to the lowest addressable byte of a buffer of +.i stacksize +bytes that was allocated by the caller. +the pages of the allocated buffer should be both readable and writable. +.pp +the +.br pthread_attr_getstack () +function returns the stack address and stack size attributes of the +thread attributes object referred to by +.i attr +in the buffers pointed to by +.ir stackaddr +and +.ir stacksize , +respectively. +.sh return value +on success, these functions return 0; +on error, they return a nonzero error number. +.sh errors +.br pthread_attr_setstack () +can fail with the following error: +.tp +.b einval +.i stacksize +is less than +.br pthread_stack_min +(16384) bytes. +on some systems, this error may also occur if +.ir stackaddr +or +.ir "stackaddr\ +\ stacksize" +is not suitably aligned. +.pp +posix.1 also documents an +.br eacces +error if the stack area described by +.i stackaddr +and +.i stacksize +is not both readable and writable by the caller. +.sh versions +these functions are provided by glibc since version 2.2. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br pthread_attr_setstack (), +.br pthread_attr_getstack () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +these functions are provided for applications that must ensure that +a thread's stack is placed in a particular location. +for most applications, this is not necessary, +and the use of these functions should be avoided. +(use +.br pthread_attr_setstacksize (3) +if an application simply requires a stack size other than the default.) +.pp +when an application employs +.br pthread_attr_setstack (), +it takes over the responsibility of allocating the stack. +any guard size value that was set using +.br pthread_attr_setguardsize (3) +is ignored. +if deemed necessary, +it is the application's responsibility to allocate a guard area +(one or more pages protected against reading and writing) +to handle the possibility of stack overflow. +.pp +the address specified in +.i stackaddr +should be suitably aligned: +for full portability, align it on a page boundary +.ri ( sysconf(_sc_pagesize) ). +.br posix_memalign (3) +may be useful for allocation. +probably, +.ir stacksize +should also be a multiple of the system page size. +.pp +if +.i attr +is used to create multiple threads, then the caller must change the +stack address attribute between calls to +.br pthread_create (3); +otherwise, the threads will attempt to use the same memory area +for their stacks, and chaos will ensue. +.sh examples +see +.br pthread_attr_init (3). +.sh see also +.ad l +.nh +.br mmap (2), +.br mprotect (2), +.br posix_memalign (3), +.br pthread_attr_init (3), +.br pthread_attr_setguardsize (3), +.br pthread_attr_setstackaddr (3), +.br pthread_attr_setstacksize (3), +.br pthread_create (3), +.br pthreads (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/nextafter.3 + +.so man3/ilogb.3 + +.\" copyright (c) 2008 linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th pthread_attr_setguardsize 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +pthread_attr_setguardsize, pthread_attr_getguardsize \- set/get guard size +attribute in thread attributes object +.sh synopsis +.nf +.b #include +.pp +.bi "int pthread_attr_setguardsize(pthread_attr_t *" attr \ +", size_t " guardsize ); +.bi "int pthread_attr_getguardsize(const pthread_attr_t *restrict " attr , +.bi " size_t *restrict " guardsize ); +.pp +compile and link with \fi\-pthread\fp. +.fi +.sh description +the +.br pthread_attr_setguardsize () +function sets the guard size attribute of the +thread attributes object referred to by +.i attr +to the value specified in +.ir guardsize . +.pp +if +.i guardsize +is greater than 0, +then for each new thread created using +.i attr +the system allocates an additional region of at least +.i guardsize +bytes at the end of the thread's stack to act as the guard area +for the stack (but see bugs). +.pp +if +.i guardsize +is 0, then new threads created with +.i attr +will not have a guard area. +.pp +the default guard size is the same as the system page size. +.pp +if the stack address attribute has been set in +.i attr +(using +.br pthread_attr_setstack (3) +or +.br pthread_attr_setstackaddr (3)), +meaning that the caller is allocating the thread's stack, +then the guard size attribute is ignored +(i.e., no guard area is created by the system): +it is the application's responsibility to handle stack overflow +(perhaps by using +.br mprotect (2) +to manually define a guard area at the end of the stack +that it has allocated). +.pp +the +.br pthread_attr_getguardsize () +function returns the guard size attribute of the +thread attributes object referred to by +.i attr +in the buffer pointed to by +.ir guardsize . +.sh return value +on success, these functions return 0; +on error, they return a nonzero error number. +.sh errors +posix.1 documents an +.b einval +error if +.i attr +or +.i guardsize +is invalid. +on linux these functions always succeed +(but portable and future-proof applications should nevertheless +handle a possible error return). +.sh versions +these functions are provided by glibc since version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br pthread_attr_setguardsize (), +.br pthread_attr_getguardsize () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +a guard area consists of virtual memory pages that are protected +to prevent read and write access. +if a thread overflows its stack into the guard area, +then, on most hard architectures, it receives a +.b sigsegv +signal, thus notifying it of the overflow. +guard areas start on page boundaries, +and the guard size is internally rounded up to +the system page size when creating a thread. +(nevertheless, +.br pthread_attr_getguardsize () +returns the guard size that was set by +.br pthread_attr_setguardsize ().) +.pp +setting a guard size of 0 may be useful to save memory +in an application that creates many threads +and knows that stack overflow can never occur. +.pp +choosing a guard size larger than the default size +may be necessary for detecting stack overflows +if a thread allocates large data structures on the stack. +.sh bugs +as at glibc 2.8, the nptl threading implementation includes +the guard area within the stack size allocation, +rather than allocating extra space at the end of the stack, +as posix.1 requires. +(this can result in an +.b einval +error from +.br pthread_create (3) +if the guard size value is too large, +leaving no space for the actual stack.) +.pp +the obsolete linuxthreads implementation did the right thing, +allocating extra space at the end of the stack for the guard area. +.\" glibc includes the guardsize within the allocated stack size, +.\" which looks pretty clearly to be in violation of posix. +.\" +.\" filed bug, 22 oct 2008: +.\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=6973 +.\" +.\" older reports: +.\" https//bugzilla.redhat.com/show_bug.cgi?id=435337 +.\" reportedly, linuxthreads did the right thing, allocating +.\" extra space at the end of the stack: +.\" http://sourceware.org/ml/libc-alpha/2008-05/msg00086.html +.sh examples +see +.br pthread_getattr_np (3). +.sh see also +.br mmap (2), +.br mprotect (2), +.br pthread_attr_init (3), +.br pthread_attr_setstack (3), +.br pthread_attr_setstacksize (3), +.br pthread_create (3), +.br pthreads (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/fgetc.3 + +.so man3/termios.3 + +.\" copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de) +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under gpl +.\" %%%license_end +.\" +.th getttyent 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +getttyent, getttynam, setttyent, endttyent \- get ttys file entry +.sh synopsis +.nf +.b "#include " +.pp +.b "struct ttyent *getttyent(void);" +.bi "struct ttyent *getttynam(const char *" name ); +.pp +.b "int setttyent(void);" +.b "int endttyent(void);" +.fi +.sh description +these functions provide an interface to the file +.b _path_ttys +(e.g., +.ir /etc/ttys ). +.pp +the function +.br setttyent () +opens the file or rewinds it if already open. +.pp +the function +.br endttyent () +closes the file. +.pp +the function +.br getttynam () +searches for a given terminal name in the file. +it returns a pointer to a +.i ttyent +structure (description below). +.pp +the function +.br getttyent () +opens the file +.b _path_ttys +(if necessary) and returns the first entry. +if the file is already open, the next entry. +the +.i ttyent +structure has the form: +.pp +.in +4n +.ex +struct ttyent { + char *ty_name; /* terminal device name */ + char *ty_getty; /* command to execute, usually getty */ + char *ty_type; /* terminal type for termcap */ + int ty_status; /* status flags */ + char *ty_window; /* command to start up window manager */ + char *ty_comment; /* comment field */ +}; +.ee +.in +.pp +.i ty_status +can be: +.pp +.in +4n +.ex +#define tty_on 0x01 /* enable logins (start ty_getty program) */ +#define tty_secure 0x02 /* allow uid 0 to login */ +.ee +.in +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br getttyent (), +.br setttyent (), +.br endttyent (), +.br getttynam () +t} thread safety mt-unsafe race:ttyent +.te +.hy +.ad +.sp 1 +.sh conforming to +not in posix.1. +present on the bsds, and perhaps other systems. +.sh notes +under linux, the file +.ir /etc/ttys , +and the functions described above, are not used. +.sh see also +.br ttyname (3), +.br ttyslot (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sat jul 24 17:56:43 1993 by rik faith (faith@cs.unc.edu) +.\" added history, aeb, 980113. +.\" 2005-05-05 mtk: added strcasestr() +.\" +.th strstr 3 2021-08-27 "gnu" "linux programmer's manual" +.sh name +strstr, strcasestr \- locate a substring +.sh synopsis +.nf +.b #include +.pp +.bi "char *strstr(const char *" haystack ", const char *" needle ); +.pp +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "char *strcasestr(const char *" haystack ", const char *" needle ); +.fi +.sh description +the +.br strstr () +function finds the first occurrence of the substring +.i needle +in the string +.ir haystack . +the terminating null bytes (\(aq\e0\(aq) are not compared. +.pp +the +.br strcasestr () +function is like +.br strstr (), +but ignores the case of both arguments. +.sh return value +these functions return a pointer to the beginning of the +located substring, or null if the substring is not found. +.pp +if +.i needle +is the empty string, +the return value is always +.i haystack +itself. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br strstr () +t} thread safety mt-safe +t{ +.br strcasestr () +t} thread safety mt-safe locale +.te +.hy +.ad +.sp 1 +.sh conforming to +.br strstr (): +posix.1-2001, posix.1-2008, c89, c99. +.pp +the +.br strcasestr () +function is a nonstandard extension. +.sh see also +.br index (3), +.br memchr (3), +.br memmem (3), +.br rindex (3), +.br strcasecmp (3), +.br strchr (3), +.br string (3), +.br strpbrk (3), +.br strsep (3), +.br strspn (3), +.br strtok (3), +.br wcsstr (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sat jul 24 18:57:24 1993 by rik faith (faith@cs.unc.edu) +.th memccpy 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +memccpy \- copy memory area +.sh synopsis +.nf +.b #include +.pp +.bi "void *memccpy(void *restrict " dest ", const void *restrict " src , +.bi " int " c ", size_t " n ); +.fi +.sh description +the +.br memccpy () +function copies no more than +.i n +bytes from +memory area +.i src +to memory area +.ir dest , +stopping when the +character +.i c +is found. +.pp +if the memory areas overlap, the results are undefined. +.sh return value +the +.br memccpy () +function returns a pointer to the next character +in +.ir dest +after +.ir c , +or null if +.i c +was not found in the +first +.i n +characters of +.ir src . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br memccpy () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, svr4, 4.3bsd. +.sh see also +.br bcopy (3), +.br bstring (3), +.br memcpy (3), +.br memmove (3), +.br strcpy (3), +.br strncpy (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/getspnam.3 + +.so man3/div.3 + +.so man3/logb.3 + +.\" copyright (c) 2012, cyrill gorcunov +.\" and copyright (c) 2012, 2016, michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of +.\" this manual under the conditions for verbatim copying, provided that +.\" the entire resulting derived work is distributed under the terms of +.\" a permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume +.\" no responsibility for errors or omissions, or for damages resulting +.\" from the use of the information contained herein. the author(s) may +.\" not have taken the same level of care in the production of this +.\" manual, which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" kernel commit d97b46a64674a267bc41c9e16132ee2a98c3347d +.\" +.th kcmp 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +kcmp \- compare two processes to determine if they share a kernel resource +.sh synopsis +.nf +.br "#include " " /* definition of " kcmp_* " constants */" +.br "#include " " /* definition of " sys_* " constants */" +.b #include +.pp +.bi "int syscall(sys_kcmp, pid_t " pid1 ", pid_t " pid2 ", int " type , +.bi " unsigned long " idx1 ", unsigned long " idx2 ); +.fi +.pp +.ir note : +glibc provides no wrapper for +.br kcmp (), +necessitating the use of +.br syscall (2). +.sh description +the +.br kcmp () +system call can be used to check whether the two processes identified by +.i pid1 +and +.i pid2 +share a kernel resource such as virtual memory, file descriptors, +and so on. +.pp +permission to employ +.br kcmp () +is governed by ptrace access mode +.b ptrace_mode_read_realcreds +checks against both +.i pid1 +and +.ir pid2 ; +see +.br ptrace (2). +.pp +the +.i type +argument specifies which resource is to be compared in the two processes. +it has one of the following values: +.tp +.br kcmp_file +check whether a file descriptor +.i idx1 +in the process +.i pid1 +refers to the same open file description (see +.br open (2)) +as file descriptor +.i idx2 +in the process +.ir pid2 . +the existence of two file descriptors that refer to the same +open file description can occur as a result of +.br dup (2) +(and similar) +.br fork (2), +or passing file descriptors via a domain socket (see +.br unix (7)). +.tp +.br kcmp_files +check whether the processes share the same set of open file descriptors. +the arguments +.i idx1 +and +.i idx2 +are ignored. +see the discussion of the +.br clone_files +flag in +.br clone (2). +.tp +.br kcmp_fs +check whether the processes share the same filesystem information +(i.e., file mode creation mask, working directory, and filesystem root). +the arguments +.i idx1 +and +.i idx2 +are ignored. +see the discussion of the +.br clone_fs +flag in +.br clone (2). +.tp +.br kcmp_io +check whether the processes share i/o context. +the arguments +.i idx1 +and +.i idx2 +are ignored. +see the discussion of the +.br clone_io +flag in +.br clone (2). +.tp +.br kcmp_sighand +check whether the processes share the same table of signal dispositions. +the arguments +.i idx1 +and +.i idx2 +are ignored. +see the discussion of the +.br clone_sighand +flag in +.br clone (2). +.tp +.br kcmp_sysvsem +check whether the processes share the same +list of system\ v semaphore undo operations. +the arguments +.i idx1 +and +.i idx2 +are ignored. +see the discussion of the +.br clone_sysvsem +flag in +.br clone (2). +.tp +.br kcmp_vm +check whether the processes share the same address space. +the arguments +.i idx1 +and +.i idx2 +are ignored. +see the discussion of the +.br clone_vm +flag in +.br clone (2). +.tp +.br kcmp_epoll_tfd " (since linux 4.13)" +.\" commit 0791e3644e5ef21646fe565b9061788d05ec71d4 +check whether the file descriptor +.i idx1 +of the process +.i pid1 +is present in the +.br epoll (7) +instance described by +.i idx2 +of the process +.ir pid2 . +the argument +.i idx2 +is a pointer to a structure where the target file is described. +this structure has the form: +.pp +.in +4n +.ex +struct kcmp_epoll_slot { + __u32 efd; + __u32 tfd; + __u64 toff; +}; +.ee +.in +.pp +within this structure, +.i efd +is an epoll file descriptor returned from +.br epoll_create (2), +.i tfd +is a target file descriptor number, and +.i toff +is a target file offset counted from zero. +several different targets may be registered with +the same file descriptor number and setting a specific +offset helps to investigate each of them. +.pp +note the +.br kcmp () +is not protected against false positives which may occur if +the processes are currently running. +one should stop the processes by sending +.br sigstop +(see +.br signal (7)) +prior to inspection with this system call to obtain meaningful results. +.sh return value +the return value of a successful call to +.br kcmp () +is simply the result of arithmetic comparison +of kernel pointers (when the kernel compares resources, it uses their +memory addresses). +.pp +the easiest way to explain is to consider an example. +suppose that +.i v1 +and +.i v2 +are the addresses of appropriate resources, then the return value +is one of the following: +.rs 4 +.ip 0 4 +.i v1 +is equal to +.ir v2 ; +in other words, the two processes share the resource. +.ip 1 +.i v1 +is less than +.ir v2 . +.ip 2 +.i v1 +is greater than +.ir v2 . +.ip 3 +.i v1 +is not equal to +.ir v2 , +but ordering information is unavailable. +.re +.pp +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.pp +.br kcmp () +was designed to return values suitable for sorting. +this is particularly handy if one needs to compare +a large number of file descriptors. +.sh errors +.tp +.b ebadf +.i type +is +.b kcmp_file +and +.i fd1 +or +.i fd2 +is not an open file descriptor. +.tp +.b efault +the epoll slot addressed by +.i idx2 +is outside of the user's address space. +.tp +.b einval +.i type +is invalid. +.tp +.b enoent +the target file is not present in +.br epoll (7) +instance. +.tp +.b eperm +insufficient permission to inspect process resources. +the +.b cap_sys_ptrace +capability is required to inspect processes that you do not own. +other ptrace limitations may also apply, such as +.br config_security_yama , +which, when +.i /proc/sys/kernel/yama/ptrace_scope +is 2, limits +.br kcmp () +to child processes; +see +.br ptrace (2). +.tp +.b esrch +process +.i pid1 +or +.i pid2 +does not exist. +.sh versions +the +.br kcmp () +system call first appeared in linux 3.5. +.sh conforming to +.br kcmp () +is linux-specific and should not be used in programs intended to be portable. +.sh notes +before linux 5.12, +this system call is available only if the kernel is configured with +.br config_checkpoint_restore , +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 +.br proc (5) +filesystem; this was deemed to be unsuitable for security reasons.) +since linux 5.12, this system call is made available unconditionally. +.pp +see +.br clone (2) +for some background information on the shared resources +referred to on this page. +.sh examples +the program below uses +.br kcmp () +to test whether pairs of file descriptors refer to +the same open file description. +the program tests different cases for the file descriptor pairs, +as described in the program output. +an example run of the program is as follows: +.pp +.in +4n +.ex +$ \fb./a.out\fp +parent pid is 1144 +parent opened file on fd 3 + +pid of child of fork() is 1145 + compare duplicate fds from different processes: + kcmp(1145, 1144, kcmp_file, 3, 3) ==> same +child opened file on fd 4 + compare fds from distinct open()s in same process: + kcmp(1145, 1145, kcmp_file, 3, 4) ==> different +child duplicated fd 3 to create fd 5 + compare duplicated fds in same process: + kcmp(1145, 1145, kcmp_file, 3, 5) ==> same +.ee +.in +.ss program source +\& +.ex +#define _gnu_source +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define errexit(msg) do { perror(msg); exit(exit_failure); \e + } while (0) + +static int +kcmp(pid_t pid1, pid_t pid2, int type, + unsigned long idx1, unsigned long idx2) +{ + return syscall(sys_kcmp, pid1, pid2, type, idx1, idx2); +} + +static void +test_kcmp(char *msg, pid_t pid1, pid_t pid2, int fd_a, int fd_b) +{ + printf("\et%s\en", msg); + printf("\et\etkcmp(%jd, %jd, kcmp_file, %d, %d) ==> %s\en", + (intmax_t) pid1, (intmax_t) pid2, fd_a, fd_b, + (kcmp(pid1, pid2, kcmp_file, fd_a, fd_b) == 0) ? + "same" : "different"); +} + +int +main(int argc, char *argv[]) +{ + int fd1, fd2, fd3; + char pathname[] = "/tmp/kcmp.test"; + + fd1 = open(pathname, o_creat | o_rdwr, s_irusr | s_iwusr); + if (fd1 == \-1) + errexit("open"); + + printf("parent pid is %jd\en", (intmax_t) getpid()); + printf("parent opened file on fd %d\en\en", fd1); + + switch (fork()) { + case \-1: + errexit("fork"); + + case 0: + printf("pid of child of fork() is %jd\en", (intmax_t) getpid()); + + test_kcmp("compare duplicate fds from different processes:", + getpid(), getppid(), fd1, fd1); + + fd2 = open(pathname, o_creat | o_rdwr, s_irusr | s_iwusr); + if (fd2 == \-1) + errexit("open"); + printf("child opened file on fd %d\en", fd2); + + test_kcmp("compare fds from distinct open()s in same process:", + getpid(), getpid(), fd1, fd2); + + fd3 = dup(fd1); + if (fd3 == \-1) + errexit("dup"); + printf("child duplicated fd %d to create fd %d\en", fd1, fd3); + + test_kcmp("compare duplicated fds in same process:", + getpid(), getpid(), fd1, fd3); + break; + + default: + wait(null); + } + + exit(exit_success); +} +.ee +.sh see also +.br clone (2), +.br unshare (2) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/getw.3 + +.so man7/operator.7 + +.so man3/rpc.3 + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" iso/iec 9899:1999 +.\" +.th wctob 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +wctob \- try to represent a wide character as a single byte +.sh synopsis +.nf +.b #include +.pp +.bi "int wctob(wint_t " c ); +.fi +.sh description +the +.br wctob () +function tests whether +the multibyte representation of the +wide character +.ir c , +starting in the initial state, consists of a single +byte. +if so, it is returned as an +.ir "unsigned char" . +.pp +never use this function. +it cannot help you in writing internationalized +programs. +internationalized programs must never distinguish single-byte and +multibyte characters. +.sh return value +the +.br wctob () +function returns the single-byte representation of +.ir c , +if it exists, or +.b eof +otherwise. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br wctob () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh notes +the behavior of +.br wctob () +depends on the +.b lc_ctype +category of the +current locale. +.pp +this function should never be used. +internationalized programs must never +distinguish single-byte and multibyte characters. +use either +.br wctomb (3) +or the thread-safe +.br wcrtomb (3) +instead. +.sh see also +.br btowc (3), +.br wcrtomb (3), +.br wctomb (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sun jul 25 10:39:43 1993 by rik faith (faith@cs.unc.edu) +.th strfry 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +strfry \- randomize a string +.sh synopsis +.nf +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "char *strfry(char *" string ); +.fi +.sh description +the +.br strfry () +function randomizes the contents of +.i string +by randomly swapping characters in the string. +the result is an anagram of +.ir string . +.sh return value +the +.br strfry () +functions returns a pointer to the randomized +string. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br strfry () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +the +.br strfry () +function is unique to the +gnu c library. +.sh see also +.br memfrob (3), +.br string (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/chmod.2 + +.so man2/chown.2 + +.so man3/des_crypt.3 + +.so man3/sigsetops.3 + +.so man3/random_r.3 + +.\" copyright (c) 2018 by eugene syromyatnikov , +.\" and copyright (c) 2018 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th address_families 7 2021-03-22 "linux" "linux programmer's manual" +.sh name +address_families \- socket address families (domains) +.sh synopsis +.nf +.br "#include " " /* see notes */" +.b #include +.pp +.bi "int socket(int " domain ", int " type ", int " protocol ); +.fi +.sh description +the +.i domain +argument of the +.br socket (2) +specifies a communication domain; this selects the protocol +family which will be used for communication. +these families are defined in +.ir . +the formats currently understood by the linux kernel include: +.tp +.br af_unix ", " af_local +local communication +for further information, see +.br unix (7). +.tp +.b af_inet +ipv4 internet protocols. +for further information, see +.br ip (7). +.tp +.b af_ax25 +amateur radio ax.25 protocol. +for further information, see +.br ax25 (4). +.\" part of ax25-tools +.tp +.b af_ipx +ipx \- novell protocols. +.tp +.b af_appletalk +appletalk +for further information, see +.br ddp (7). +.tp +.b af_netrom +ax.25 packet layer protocol. +for further information, see +.br netrom (4), +.\" part of ax25-tools package +.ur https://www.tldp.org/howto/ax25-howto/x61.html +.i the packet radio protocols and linux +.ue +and the +.ir ax.25 ", " net/rom ", and " "rose network programming" +chapters of the +.ur https://www.tldp.org/howto/ax25-howto/x2107.html +.i linux amateur radio ax.25 howto +.ue . +.tp +.b af_bridge +can't be used for creating sockets; +mostly used for bridge links in +.br rtnetlink (7) +protocol commands. +.tp +.b af_atmpvc +access to raw atm permanent virtual circuits (pvcs). +for further information, see the +.ur https://www.tldp.org/howto/text/atm-linux-howto +.i atm on linux howto +.ue . +.tp +.b af_x25 +itu-t x.25 / iso-8208 protocol. +for further information, see +.br x25 (7). +.tp +.b af_inet6 +ipv6 internet protocols. +for further information, see +.br ipv6 (7). +.tp +.b af_rose +rats (radio amateur telecommunications society) +open systems environment (rose) ax.25 packet layer protocol. +for further information, see the resources listed for +.br af_netrom . +.tp +.b af_decnet +decet protocol sockets. +see +.i documentation/networking/decnet.txt +in the linux kernel source tree for details. +.tp +.b af_netbeui +reserved for "802.2llc project"; never used. +.tp +.b af_security +this was a short-lived (between linux 2.1.30 and 2.1.99pre2) protocol family +for firewall upcalls. +.tp +.b af_key +key management protocol, originally developed for usage with ipsec +(since linux 2.1.38). +this has no relation to +.br keyctl (2) +and the in-kernel key storage facility. +see +.ur https://tools.ietf.org/html/rfc2367 +rfc 2367 +.i pf_key key management api, version 2 +.ue +for details. +.tp +.b af_netlink +kernel user interface device +for further information, see +.br netlink (7). +.tp +.b af_packet +low-level packet interface. +for further information, see +.br packet (7). +.\" .tp +.\" .b af_ash +.\" asynchronous serial host protocol (?) +.\" notes from eugene syromyatnikov: +.\" i haven't found any concrete information about this one; +.\" it never was implemented in linux, at least, judging by historical +.\" repos. there is also this file (and its variations): +.\" https://github.com/ecki/net-tools/blob/master/lib/ash.c +.\" ( https://github.com/ecki/net-tools/commits/master/lib/ash.c ) +.\" it mentions "net-2 distribution" (bsd net/2?), but, again, i failed +.\" to find any mentions of "ash" protocol there. +.\" (for the reference: +.\" ftp://pdp11.org.ru/pub/unix-archive/distributions/ucb/net2/net2.tar.gz ) +.\" another source that mentions it is +.\" https://www.silabs.com/documents/public/user-guides/ug101-uart-gateway-protocol-reference.pdf +.\" https://www.silabs.com/documents/public/user-guides/ug115-ashv3-protocol-reference.pdf +.\" but i doubt that it's related, as former files use 64-byte addresses and +.\" "hamming-encode of hops", and that's barely combines with a protocol +.\" that is mainly used over serial connection. +.tp +.b af_econet +.\" commit: 349f29d841dbae854bd7367be7c250401f974f47 +acorn econet protocol (removed in linux 3.5). +see the +.ur http://www.8bs.com/othrdnld/manuals/econet.shtml +econet documentation +.ue +for details. +.tp +.b af_atmsvc +access to atm switched virtual circuits (svcs) +see the +.ur https://www.tldp.org/howto/text/atm-linux-howto +.i atm on linux howto +.ue +for details. +.tp +.b af_rds +.\" commit: 639b321b4d8f4e412bfbb2a4a19bfebc1e68ace4 +reliable datagram sockets (rds) protocol (since linux 2.6.30). +rds over rdma has no relation to +.b af_smc +or +.br af_xdp . +for further information see +.\" rds-tools: https://github.com/oracle/rds-tools/blob/master/rds.7 +.\" rds-tools: https://github.com/oracle/rds-tools/blob/master/rds-rdma.7 +.br rds (7), +.br rds\-rdma (7), +and +.i documentation/networking/rds.txt +in the linux kernel source tree. +.tp +.b af_irda +.\" commits: 1ca163afb6fd569b, d64c2a76123f0300 +socket interface over irda +(moved to staging in linux 4.14, removed in linux 4.17). +.\" irda-utils: https://sourceforge.net/p/irda/code/head/tree/tags/irdautils_0_9_18/irda-utils/man/irda.7.gz?format=raw +for further information see +.br irda (7). +.tp +.b af_pppox +generic ppp transport layer, for setting up l2 tunnels +(l2tp and pppoe). +see +.i documentation/networking/l2tp.txt +in the linux kernel source tree for details. +.tp +.b af_wanpipe +.\" commits: ce0ecd594d78710422599918a608e96dd1ee6024 +legacy protocol for wide area network (wan) connectivity +that was used by sangoma wan cards (called "wanpipe"); +removed in linux 2.6.21. +.tp +.b af_llc +.\" linux-history commit: 34beb106cde7da233d4df35dd3d6cf4fee937caa +logical link control (ieee 802.2 llc) protocol, upper part +of data link layer of iso/osi networking protocol stack +(since linux 2.4); +has no relation to +.br af_packet . +see chapter +.i 13.5.3. logical link control +in +.i understanding linux kernel internals +(o'reilly media, 2006) +and +.i ieee standards for local area networks: logical link control +(the institute of electronics and electronics engineers, inc., +new york, new york, 1985) +for details. +see also +.ur https://wiki.linuxfoundation.org/networking/llc +some historical notes +.ue +regarding its development. +.tp +.b af_ib +.\" commits: 8d36eb01da5d371f..ce117ffac2e93334 +infiniband native addressing (since linux 3.11). +.tp +.b af_mpls +.\" commits: 0189197f441602acdca3f97750d392a895b778fd +multiprotocol label switching (since linux 4.1); +mostly used for configuring mpls routing via +.br netlink (7), +as it doesn't expose ability to create sockets to user space. +.tp +.b af_can +.\" commits: 8dbde28d9711475a..5423dd67bd0108a1 +controller area network automotive bus protocol (since linux 2.6.25). +see +.i documentation/networking/can.rst +in the linux kernel source tree for details. +.tp +.b af_tipc +.\" commits: b97bf3fd8f6a16966d4f18983b2c40993ff937d4 +tipc, "cluster domain sockets" protocol (since linux 2.6.16). +see +.ur http://tipc.io/programming.html +.i tipc programmer's guide +.ue +and the +.ur http://tipc.io/protocol.html +protocol description +.ue +for details. +.tp +.b af_bluetooth +.\" commits: 8d36eb01da5d371f..ce117ffac2e93334 +bluetooth low-level socket protocol (since linux 3.11). +see +.ur https://git.kernel.org\:/pub/scm\:/bluetooth/bluez.git\:/tree/doc/mgmt-api.txt +.i bluetooth management api overview +.ue +and +.ur https://people.csail.mit.edu/albert/bluez-intro/ +.i an introduction to bluetooth programming +by albert huang +.ue +for details. +.tp +.b af_iucv +.\" commit: eac3731bd04c7131478722a3c148b78774553116 +iucv (inter-user communication vehicle) z/vm protocol +for hypervisor-guest interaction (since linux 2.6.21); +has no relation to +.b af_vsock +and/or +.br af_smc +see +.ur https://www.ibm.com\:/support\:/knowledgecenter\:/en/ssb27u_6.4.0\:/com.ibm.zvm.v640.hcpb4\:/iucv.htm +.i iucv protocol overview +.ue +for details. +.tp +.b af_rxrpc +.\" commit: 17926a79320afa9b95df6b977b40cca6d8713cea +.\" http://people.redhat.com/~dhowells/rxrpc/ +.\" https://www.infradead.org/~dhowells/kafs/af_rxrpc_client.html +.\" http://workshop.openafs.org/afsbpw09/talks/thu_2/kafs.pdf +.\" http://pages.cs.wisc.edu/~remzi/ostep/dist-afs.pdf +.\" http://web.mit.edu/kolya/afs/rx/rx-spec +rx, andrew file system remote procedure call protocol +(since linux 2.6.22). +see +.i documentation/networking/rxrpc.txt +in the linux kernel source tree for details. +.tp +.b af_isdn +.\" commit: 1b2b03f8e514e4f68e293846ba511a948b80243c +new "modular isdn" driver interface protocol (since linux 2.6.27). +see the +.ur http://www.misdn.eu/wiki/main_page/ +misdn wiki +.ue +for details. +.tp +.b af_phonet +.\" commit: 4b07b3f69a8471cdc142c51461a331226fef248a +nokia cellular modem ipc/rpc interface (since linux 2.6.31). +see +.i documentation/networking/phonet.txt +in the linux kernel source tree for details. +.tp +.b af_ieee802154 +.\" commit: 9ec7671603573ede31207eb5b0b3e1aa211b2854 +ieee 802.15.4 wpan (wireless personal area network) raw packet protocol +(since linux 2.6.31). +see +.i documentation/networking/ieee802154.txt +in the linux kernel source tree for details. +.tp +.b af_caif +.\" commit: 529d6dad5bc69de14cdd24831e2a14264e93daa4 +.\" https://lwn.net/articles/371017/ +.\" http://read.pudn.com/downloads157/doc/comm/698729/misc/caif/com%20cpu%20to%20appl%20cpu%20interface%20description_lzn901%202002_revr1c.pdf +.\" http://read.pudn.com/downloads157/doc/comm/698729/misc/caif/com%20cpu%20to%20appl%20cpu%20interface%20protocol%20specification_lzn901%201708_revr1a.pdf +ericsson's communication cpu to application cpu interface (caif) protocol +(since linux 2.6.36). +see +.i documentation/networking/caif/linux\-caif.txt +in the linux kernel source tree for details. +.tp +.b af_alg +interface to kernel crypto api (since linux 2.6.38). +see +.i documentation/crypto/userspace\-if.rst +in the linux kernel source tree for details. +.tp +.b af_vsock +.\" commit: d021c344051af91f42c5ba9fdedc176740cbd238 +vmware vsockets protocol for hypervisor-guest interaction (since linux 3.9); +has no relation to +.b af_iucv +and +.br af_smc . +for further information, see +.br vsock (7). +.tp +.b af_kcm +.\" commit: 03c8efc1ffeb6b82a22c1af8dd908af349563314 +kcm (kernel connection multiplexer) interface (since linux 4.6). +see +.i documentation/networking/kcm.txt +in the linux kernel source tree for details. +.tp +.b af_qipcrtr +.\" commit: bdabad3e363d825ddf9679dd431cca0b2c30f881 +qualcomm ipc router interface protocol (since linux 4.7). +.tp +.b af_smc +.\" commit: f3a3e248f3f7cd9a4bed334022704d7e7fc781bf +smc-r (shared memory communications over rdma) protocol (since linux 4.11), +and smc-d (shared memory communications, direct memory access) protocol +for intra-node z/vm quest interaction (since linux 4.19); +has no relation to +.br af_rds ", " af_iucv +or +.br af_vsock . +see +.ur https://tools.ietf.org/html/rfc7609 +rfc 7609 +.i ibm's shared memory communications over rdma (smc-r) protocol +.ue +for details regarding smc-r. +see +.ur https://www-01.ibm.com\:/software/network\:/commserver\:/smc-d/index.html +.i smc-d reference information +.ue +for details regarding smc-d. +.tp +.b af_xdp +.\" commit: c0c77d8fb787cfe0c3fca689c2a30d1dad4eaba7 +xdp (express data path) interface (since linux 4.18). +see +.i documentation/networking/af_xdp.rst +in the linux kernel source tree for details. +.sh see also +.br socket (2), +.br socket (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/ecvt_r.3 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified 1993-07-24 by rik faith (faith@cs.unc.edu) +.\" modified 2002-07-27 by walter harms +.\" (walter.harms@informatik.uni-oldenburg.de) +.\" +.th modf 3 2021-03-22 "" "linux programmer's manual" +.sh name +modf, modff, modfl \- extract signed integral and fractional values from +floating-point number +.sh synopsis +.nf +.b #include +.pp +.bi "double modf(double " x ", double *" iptr ); +.bi "float modff(float " x ", float *" iptr ); +.bi "long double modfl(long double " x ", long double *" iptr ); +.fi +.pp +link with \fi\-lm\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br modff (), +.br modfl (): +.nf + _isoc99_source || _posix_c_source >= 200112l + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.sh description +these functions break the argument +.i x +into an integral +part and a fractional part, each of which has the same sign as +.ir x . +the integral part is stored in the location pointed to by +.ir iptr . +.sh return value +these functions return the fractional part of +.ir x . +.pp +if +.i x +is a nan, a nan is returned, and +.ir *iptr +is set to a nan. +.pp +if +.i x +is positive infinity (negative infinity), +0 (\-0) is returned, and +.ir *iptr +is set to positive infinity (negative infinity). +.sh errors +no errors occur. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br modf (), +.br modff (), +.br modfl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.pp +the variant returning +.i double +also conforms to +svr4, 4.3bsd, c89. +.sh see also +.br frexp (3), +.br ldexp (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/getegid.2 + +.so man3/unlocked_stdio.3 + +.so man3/nl_langinfo.3 + +.so man2/setgroups.2 + +.so man3/getipnodebyname.3 + +.so man7/system_data_types.7 + +.\" copyright 2001 walter harms (walter.harms@informatik.uni-oldenburg.de) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" aeb: some corrections +.th dysize 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +dysize \- get number of days for a given year +.sh synopsis +.nf +.b "#include " +.pp +.bi "int dysize(int " year ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br dysize (): +.nf + since glibc 2.19: + _default_source + glibc 2.19 and earlier: + _bsd_source || _svid_source +.fi +.sh description +the function returns 365 for a normal year and 366 for a leap year. +the calculation for leap year is based on: +.pp +.in +4n +.ex +(year) %4 == 0 && ((year) %100 != 0 || (year) %400 == 0) +.ee +.in +.pp +the formula is defined in the macro +.i __isleap(year) +also found in +.ir . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br dysize () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +this function occurs in sunos 4.x. +.sh notes +this is a compatibility function only. +don't use it in new programs. +.\" the sco version of this function had a year-2000 problem. +.sh see also +.br strftime (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/rpc.3 + +.so man3/timegm.3 + +.so man3/pthread_setconcurrency.3 + +.so man2/timer_settime.2 + +.\" this manpage is copyright (c) 1992 drew eckhardt; +.\" and copyright (c) 1993 michael haardt, ian jackson. +.\" and copyright (c) 2005, 2008 michael kerrisk +.\" and copyright (c) 2014 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified 1993-07-21, rik faith +.\" modified 1994-08-21, michael chastain : +.\" fixed typos. +.\" modified 1997-01-31, eric s. raymond +.\" modified 2002-09-28, aeb +.\" 2009-01-12, mtk, reordered text in description and added some +.\" details for dup2(). +.\" 2008-10-09, mtk: add description of dup3() +.\" +.th dup 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +dup, dup2, dup3 \- duplicate a file descriptor +.sh synopsis +.nf +.b #include +.pp +.bi "int dup(int " oldfd ); +.bi "int dup2(int " oldfd ", int " newfd ); +.pp +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.br "#include " " /* definition of " o_* " constants */" +.b #include +.pp +.bi "int dup3(int " oldfd ", int " newfd ", int " flags ); +.fi +.sh description +the +.br dup () +system call allocates a new file descriptor that refers to the same +open file description as the descriptor +.ir oldfd . +(for an explanation of open file descriptions, see +.br open (2).) +the new file descriptor number is guaranteed to be the lowest-numbered +file descriptor that was unused in the calling process. +.pp +after a successful return, +the old and new file descriptors may be used interchangeably. +since the two file descriptors refer to the same open file description, +they share file offset and file status flags; +for example, if the file offset is modified by using +.br lseek (2) +on one of the file descriptors, +the offset is also changed for the other file descriptor. +.pp +the two file descriptors do not share file descriptor flags +(the close-on-exec flag). +the close-on-exec flag +.rb ( fd_cloexec ; +see +.br fcntl (2)) +for the duplicate descriptor is off. +.\" +.ss dup2() +the +.br dup2 () +system call performs the same task as +.br dup (), +but instead of using the lowest-numbered unused file descriptor, +it uses the file descriptor number specified in +.ir newfd . +in other words, +the file descriptor +.i newfd +is adjusted so that it now refers to the same open file description as +.ir oldfd . +.pp +if the file descriptor +.ir newfd +was previously open, it is closed before being reused; +the close is performed silently +(i.e., any errors during the close are not reported by +.br dup2 ()). +.pp +the steps of closing and reusing the file descriptor +.ir newfd +are performed +.ir atomically . +this is important, because trying to implement equivalent functionality using +.br close (2) +and +.br dup () +would be +subject to race conditions, whereby +.i newfd +might be reused between the two steps. +such reuse could happen because the main program is interrupted +by a signal handler that allocates a file descriptor, +or because a parallel thread allocates a file descriptor. +.pp +note the following points: +.ip * 3 +if +.i oldfd +is not a valid file descriptor, then the call fails, and +.i newfd +is not closed. +.ip * +if +.i oldfd +is a valid file descriptor, and +.i newfd +has the same value as +.ir oldfd , +then +.br dup2 () +does nothing, and returns +.ir newfd . +.\" +.ss dup3() +.br dup3 () +is the same as +.br dup2 (), +except that: +.ip * 3 +the caller can force the close-on-exec flag to be set +for the new file descriptor by specifying +.br o_cloexec +in +.ir flags . +see the description of the same flag in +.br open (2) +for reasons why this may be useful. +.ip * +.\" ulrich drepper, lkml, 2008-10-09: +.\" we deliberately decided on this change. otherwise, what is the +.\" result of dup3(fd, fd, o_cloexec)? +if +.ir oldfd +equals +.ir newfd , +then +.br dup3 () +fails with the error +.br einval . +.sh return value +on success, these system calls +return the new file descriptor. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b ebadf +.i oldfd +isn't an open file descriptor. +.tp +.b ebadf +.i newfd +is out of the allowed range for file descriptors (see the discussion of +.br rlimit_nofile +in +.br getrlimit (2)). +.tp +.b ebusy +(linux only) this may be returned by +.br dup2 () +or +.br dup3 () +during a race condition with +.br open (2) +and +.br dup (). +.tp +.b eintr +the +.br dup2 () +or +.br dup3 () +call was interrupted by a signal; see +.br signal (7). +.tp +.b einval +.rb ( dup3 ()) +.i flags +contain an invalid value. +.tp +.b einval +.rb ( dup3 ()) +.i oldfd +was equal to +.ir newfd . +.tp +.b emfile +the per-process limit on the number of open file descriptors has been reached +(see the discussion of +.br rlimit_nofile +in +.br getrlimit (2)). +.sh versions +.br dup3 () +was added to linux in version 2.6.27; +glibc support is available starting with +version 2.9. +.sh conforming to +.br dup (), +.br dup2 (): +posix.1-2001, posix.1-2008, svr4, 4.3bsd. +.pp +.br dup3 () +is linux-specific. +.\" svr4 documents additional +.\" eintr and enolink error conditions. posix.1 adds eintr. +.\" the ebusy return is linux-specific. +.sh notes +the error returned by +.br dup2 () +is different from that returned by +.br fcntl( "..., " f_dupfd ", ..." ) +when +.i newfd +is out of range. +on some systems, +.br dup2 () +also sometimes returns +.b einval +like +.br f_dupfd . +.pp +if +.i newfd +was open, any errors that would have been reported at +.br close (2) +time are lost. +if this is of concern, +then\(emunless the program is single-threaded and does not allocate +file descriptors in signal handlers\(emthe correct approach is +.i not +to close +.i newfd +before calling +.br dup2 (), +because of the race condition described above. +instead, code something like the following could be used: +.pp +.in +4n +.ex +/* obtain a duplicate of \(aqnewfd\(aq that can subsequently + be used to check for close() errors; an ebadf error + means that \(aqnewfd\(aq was not open. */ + +tmpfd = dup(newfd); +if (tmpfd == \-1 && errno != ebadf) { + /* handle unexpected dup() error. */ +} + +/* atomically duplicate \(aqoldfd\(aq on \(aqnewfd\(aq. */ + +if (dup2(oldfd, newfd) == \-1) { + /* handle dup2() error. */ +} + +/* now check for close() errors on the file originally + referred to by \(aqnewfd\(aq. */ + +if (tmpfd != \-1) { + if (close(tmpfd) == \-1) { + /* handle errors from close. */ + } +} +.ee +.in +.sh see also +.br close (2), +.br fcntl (2), +.br open (2), +.br pidfd_getfd (2) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1993 mitchum dsouza +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" updated, aeb, 980809 +.th catgets 3 2021-03-22 "" "linux programmer's manual" +.sh name +catgets \- get message from a message catalog +.sh synopsis +.nf +.b #include +.pp +.bi "char *catgets(nl_catd " catalog ", int " set_number \ +", int " message_number , +.bi " const char *" message ); +.fi +.sh description +.br catgets () +reads the message +.ir message_number , +in set +.ir set_number , +from the message catalog identified by +.ir catalog , +where +.i catalog +is a catalog descriptor returned from an earlier call to +.br catopen (3). +the fourth argument, +.ir message , +points to a default message string which will be returned by +.br catgets () +if the identified message catalog is not currently available. +the +message-text is contained in an internal buffer area and should be copied by +the application if it is to be saved or modified. +the return string is +always terminated with a null byte (\(aq\e0\(aq). +.sh return value +on success, +.br catgets () +returns a pointer to an internal buffer area +containing the null-terminated message string. +on failure, +.br catgets () +returns the value +.ir message . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br catgets () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +the +.br catgets () +function is available only in libc.so.4.4.4c and above. +the jan 1987 x/open portability guide specifies a more subtle +error return: +.i message +is returned if the message catalog specified by +.i catalog +is not available, while an empty string is returned +when the message catalog is available but does not contain +the specified message. +these two possible error returns seem to be discarded in susv2 +in favor of always returning +.ir message . +.sh see also +.br catopen (3), +.br setlocale (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/clone.2 + +.so man3/lrint.3 + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" +.\" modified, aeb, 990824 +.\" +.th mb_len_max 3 2015-07-23 "linux" "linux programmer's manual" +.sh name +mb_len_max \- maximum multibyte length of a character across all locales +.sh synopsis +.nf +.b #include +.fi +.sh description +the +.b mb_len_max +macro is the maximum number of bytes needed to represent a single +wide character, in any of the supported locales. +.sh return value +a constant integer greater than zero. +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh notes +the entities +.b mb_len_max +and +.i sizeof(wchar_t) +are totally unrelated. +in glibc, +.b mb_len_max +is typically 16 +.\" for an explanation of why the limit was raised to 16, see +.\" http://lists.gnu.org/archive/html/bug-gnulib/2015-05/msg00001.html +.\" from: bruno haible +.\" subject: re: why is mb_len_max so large (16) on glibc +.\" date: thu, 14 may 2015 02:30:14 +0200 +(6 in glibc versions earlier than 2.2), while +.i sizeof(wchar_t) +is 4. +.sh see also +.br mb_cur_max (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/setbuf.3 + +.\" copyright 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th erfc 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +erfc, erfcf, erfcl \- complementary error function +.sh synopsis +.nf +.b #include +.pp +.bi "double erfc(double " x ); +.bi "float erfcf(float " x ); +.bi "long double erfcl(long double " x ); +.fi +.pp +link with \fi\-lm\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br erfc (): +.nf + _isoc99_source || _posix_c_source >= 200112l || _xopen_source + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.pp +.br erfcf (), +.br erfcl (): +.nf + _isoc99_source || _posix_c_source >= 200112l + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.sh description +these functions return the complementary error function of +.ir x , +that is, 1.0 \- erf(x). +.sh return value +on success, these functions return the complementary error function of +.ir x , +a value in the range [0,2]. +.pp +if +.i x +is a nan, a nan is returned. +.pp +if +.i x +is +0 or \-0, 1 is returned. +.pp +if +.i x +is positive infinity, ++0 is returned. +.pp +if +.i x +is negative infinity, ++2 is returned. +.pp +if the function result underflows and produces an unrepresentable value, +the return value is 0.0. +.pp +if the function result underflows but produces a representable +(i.e., subnormal) value, +.\" e.g., erfc(27) on x86-32 +that value is returned, and +a range error occurs. +.sh errors +see +.br math_error (7) +for information on how to determine whether an error has occurred +when calling these functions. +.pp +the following errors can occur: +.tp +range error: result underflow (result is subnormal) +.\" .i errno +.\" is set to +.\" .br erange . +an underflow floating-point exception +.rb ( fe_underflow ) +is raised. +.pp +these functions do not set +.ir errno . +.\" it is intentional that these functions do not set errno for this case +.\" see http://sources.redhat.com/bugzilla/show_bug.cgi?id=6785 +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br erfc (), +.br erfcf (), +.br erfcl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.pp +the variant returning +.i double +also conforms to +svr4, 4.3bsd. +.sh notes +the +.br erfc (), +.br erfcf (), +and +.br erfcl () +functions are provided to avoid the loss accuracy that +would occur for the calculation 1-erf(x) for large values of +.ir x +(for which the value of erf(x) approaches 1). +.sh see also +.br cerf (3), +.br erf (3), +.br exp (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/isalpha.3 + +.so man3/remquo.3 + +.so man3/scanf.3 + +.\" copyright (c) 1983, 1991 the regents of the university of california. +.\" all rights reserved. +.\" +.\" %%%license_start(bsd_4_clause_ucb) +.\" redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. all advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" this product includes software developed by the university of +.\" california, berkeley and its contributors. +.\" 4. neither the name of the university nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" this software is provided by the regents and contributors ``as is'' and +.\" any express or implied warranties, including, but not limited to, the +.\" implied warranties of merchantability and fitness for a particular purpose +.\" are disclaimed. in no event shall the regents or contributors be liable +.\" for any direct, indirect, incidental, special, exemplary, or consequential +.\" damages (including, but not limited to, procurement of substitute goods +.\" or services; loss of use, data, or profits; or business interruption) +.\" however caused and on any theory of liability, whether in contract, strict +.\" liability, or tort (including negligence or otherwise) arising in any way +.\" out of the use of this software, even if advised of the possibility of +.\" such damage. +.\" %%%license_end +.\" +.\" $id: shutdown.2,v 1.1.1.1 1999/03/21 22:52:23 freitag exp $ +.\" +.\" modified sat jul 24 09:57:55 1993 by rik faith +.\" modified tue oct 22 22:04:51 1996 by eric s. raymond +.\" modified 1998 by andi kleen +.\" +.th shutdown 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +shutdown \- shut down part of a full-duplex connection +.sh synopsis +.nf +.b #include +.pp +.bi "int shutdown(int " sockfd ", int " how ); +.fi +.sh description +the +.br shutdown () +call causes all or part of a full-duplex connection on the socket +associated with +.i sockfd +to be shut down. +if +.i how +is +.br shut_rd , +further receptions will be disallowed. +if +.i how +is +.br shut_wr , +further transmissions will be disallowed. +if +.i how +is +.br shut_rdwr , +further receptions and transmissions will be disallowed. +.sh return value +on success, zero is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b ebadf +.i sockfd +is not a valid file descriptor. +.tp +.b einval +an invalid value was specified in +.ir how +(but see bugs). +.tp +.b enotconn +the specified socket is not connected. +.tp +.b enotsock +the file descriptor +.i sockfd +does not refer to a socket. +.sh conforming to +posix.1-2001, posix.1-2008, 4.4bsd +.rb ( shutdown () +first appeared in 4.2bsd). +.sh notes +the constants +.br shut_rd , +.br shut_wr , +.b shut_rdwr +have the value 0, 1, 2, +respectively, and are defined in +.i +since glibc-2.1.91. +.sh bugs +checks for the validity of +.i how +are done in domain-specific code, +and before linux 3.7 not all domains performed these checks. +.\" https://bugzilla.kernel.org/show_bug.cgi?id=47111 +most notably, unix domain sockets simply ignored invalid values. +this problem was fixed for unix domain sockets +.\" commit fc61b928dc4d72176cf4bd4d30bf1d22e599aefc +.\" and for decnet sockets in commit 46b66d7077b89fb4917ceef19b3f7dd86055c94a +in linux 3.7. +.sh see also +.br close (2), +.br connect (2), +.br socket (2), +.br socket (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/slist.3 + +.\" copyright (c) 1994 jochen hein (hein@student.tu-clausthal.de) +.\" copyright (c) 2008 petr baudis (pasky@suse.cz) +.\" copyright (c) 2014 michael kerrisk +.\" +.\" %%%license_start(gplv2+_sw_3_para) +.\" this program is free software; you can redistribute it and/or modify +.\" it under the terms of the gnu general public license as published by +.\" the free software foundation; either version 2 of the license, or +.\" (at your option) any later version. +.\" +.\" this program 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" 2008-06-17 petr baudis +.\" lc_time: describe first_weekday and first_workday +.\" +.th locale 5 2021-03-22 "linux" "linux user manual" +.sh name +locale \- describes a locale definition file +.sh description +the +.b locale +definition file contains all the information that the +.br localedef (1) +command needs to convert it into the binary locale database. +.pp +the definition files consist of sections which each describe a +locale category in detail. +see +.br locale (7) +for additional details for these categories. +.ss syntax +the locale definition file starts with a header that may consist +of the following keywords: +.tp +.i escape_char +is followed by a character that should be used as the +escape-character for the rest of the file to mark characters that +should be interpreted in a special way. +it defaults to the backslash (\e). +.tp +.i comment_char +is followed by a character that will be used as the +comment-character for the rest of the file. +it defaults to the number sign (#). +.pp +the locale definition has one part for each locale category. +each part can be copied from another existing locale or +can be defined from scratch. +if the category should be copied, +the only valid keyword in the definition is +.i copy +followed by the name of the locale in double quotes which should be +copied. +the exceptions for this rule are +.b lc_collate +and +.b lc_ctype +where a +.i copy +statement can be followed by locale-specific rules and selected overrides. +.pp +when defining a locale or a category from scratch, an existing system- +provided locale definition file should be used as a reference to follow +common glibc conventions. +.ss locale category sections +the following category sections are defined by posix: +.ip * 3 +.b lc_ctype +.ip * +.b lc_collate +.ip * +.b lc_messages +.ip * +.b lc_monetary +.ip * +.b lc_numeric +.ip * +.b lc_time +.pp +in addition, since version 2.2, +the gnu c library supports the following nonstandard categories: +.ip * 3 +.b lc_address +.ip * +.b lc_identification +.ip * +.b lc_measurement +.ip * +.b lc_name +.ip * +.b lc_paper +.ip * +.b lc_telephone +.pp +see +.br locale (7) +for a more detailed description of each category. +.ss lc_address +the definition starts with the string +.i lc_address +in the first column. +.pp +the following keywords are allowed: +.tp +.i postal_fmt +followed by a string containing field descriptors that define +the format used for postal addresses in the locale. +the following field descriptors are recognized: +.rs +.tp +%n +person's name, possibly constructed with the +.b lc_name +.i name_fmt +keyword (since glibc 2.24). +.tp 4 +%a +care of person, or organization. +.tp +%f +firm name. +.tp +%d +department name. +.tp +%b +building name. +.tp +%s +street or block (e.g., japanese) name. +.tp +%h +house number or designation. +.tp +%n +insert an end-of-line if the previous descriptor's value was not an empty +string; otherwise ignore. +.tp +%t +insert a space if the previous descriptor's value was not an empty string; +otherwise ignore. +.tp +%r +room number, door designation. +.tp +%e +floor number. +.tp +%c +country designation, from the +.i country_post +keyword. +.tp +%l +local township within town or city (since glibc 2.24). +.tp +%z +zip number, postal code. +.tp +%t +town, city. +.tp +%s +state, province, or prefecture. +.tp +%c +country, as taken from data record. +.pp +each field descriptor may have an \(aqr\(aq after +the \(aq%\(aq to specify that the +information is taken from a romanized version string of the +entity. +.re +.tp +.i country_name +followed by the country name in the language of the current document +(e.g., "deutschland" for the +.b de_de +locale). +.tp +.i country_post +followed by the abbreviation of the country (see cert_mailcodes). +.tp +.i country_ab2 +followed by the two-letter abbreviation of the country (iso 3166). +.tp +.i country_ab3 +followed by the three-letter abbreviation of the country (iso 3166). +.tp +.i country_num +followed by the numeric country code (iso 3166). +.tp +.i country_car +followed by the international license plate country code. +.tp +.i country_isbn +followed by the isbn code (for books). +.tp +.i lang_name +followed by the language name in the language of the current document. +.tp +.i lang_ab +followed by the two-letter abbreviation of the language (iso 639). +.tp +.i lang_term +followed by the three-letter abbreviation of the language (iso 639-2/t). +.tp +.i lang_lib +followed by the three-letter abbreviation of the language for library +use (iso 639-2/b). +applications should in general prefer +.i lang_term +over +.ir lang_lib . +.pp +the +.b lc_address +definition ends with the string +.ir "end lc_address" . +.ss lc_ctype +the definition starts with the string +.i lc_ctype +in the first column. +.pp +the following keywords are allowed: +.tp +.i upper +followed by a list of uppercase letters. +the letters +.b a +through +.b z +are included automatically. +characters also specified as +.br cntrl , +.br digit , +.br punct , +or +.b space +are not allowed. +.tp +.i lower +followed by a list of lowercase letters. +the letters +.b a +through +.b z +are included automatically. +characters also specified as +.br cntrl , +.br digit , +.br punct , +or +.b space +are not allowed. +.tp +.i alpha +followed by a list of letters. +all character specified as either +.b upper +or +.b lower +are automatically included. +characters also specified as +.br cntrl , +.br digit , +.br punct , +or +.b space +are not allowed. +.tp +.i digit +followed by the characters classified as numeric digits. +only the +digits +.b 0 +through +.b 9 +are allowed. +they are included by default in this class. +.tp +.i space +followed by a list of characters defined as white-space +characters. +characters also specified as +.br upper , +.br lower , +.br alpha , +.br digit , +.br graph , +or +.b xdigit +are not allowed. +the characters +.br , +.br , +.br , +.br , +.br , +and +.b +are automatically included. +.tp +.i cntrl +followed by a list of control characters. +characters also specified as +.br upper , +.br lower , +.br alpha , +.br digit , +.br punct , +.br graph , +.br print , +or +.b xdigit +are not allowed. +.tp +.i punct +followed by a list of punctuation characters. +characters also +specified as +.br upper , +.br lower , +.br alpha , +.br digit , +.br cntrl , +.br xdigit , +or the +.b +character are not allowed. +.tp +.i graph +followed by a list of printable characters, not including the +.b +character. +the characters defined as +.br upper , +.br lower , +.br alpha , +.br digit , +.br xdigit , +and +.b punct +are automatically included. +characters also specified as +.b cntrl +are not allowed. +.tp +.i print +followed by a list of printable characters, including the +.b +character. +the characters defined as +.br upper , +.br lower , +.br alpha , +.br digit , +.br xdigit , +.br punct , +and the +.b +character are automatically included. +characters also specified as +.b cntrl +are not allowed. +.tp +.i xdigit +followed by a list of characters classified as hexadecimal +digits. +the decimal digits must be included followed by one or +more set of six characters in ascending order. +the following +characters are included by default: +.b 0 +through +.br 9 , +.b a +through +.br f , +.b a +through +.br f . +.tp +.i blank +followed by a list of characters classified as +.br blank . +the characters +.b +and +.b +are automatically included. +.tp +.i charclass +followed by a list of locale-specific character class names +which are then to be defined in the locale. +.tp +.i toupper +followed by a list of mappings from lowercase to uppercase +letters. +each mapping is a pair of a lowercase and an uppercase letter +separated with a +.b , +and enclosed in parentheses. +.tp +.i tolower +followed by a list of mappings from uppercase to lowercase +letters. +if the keyword tolower is not present, the reverse of the +toupper list is used. +.tp +.i map totitle +followed by a list of mapping pairs of +characters and letters +to be used in titles (headings). +.tp +.i class +followed by a locale-specific character class definition, +starting with the class name followed by the characters +belonging to the class. +.tp +.i charconv +followed by a list of locale-specific character mapping names +which are then to be defined in the locale. +.tp +.i outdigit +followed by a list of alternate output digits for the locale. +.tp +.i map to_inpunct +followed by a list of mapping pairs of +alternate digits and separators +for input digits for the locale. +.tp +.i map to_outpunct +followed by a list of mapping pairs of +alternate separators +for output for the locale. +.tp +.i translit_start +marks the start of the transliteration rules section. +the section can contain the +.i include +keyword in the beginning followed by +locale-specific rules and overrides. +any rule specified in the locale file +will override any rule +copied or included from other files. +in case of duplicate rule definitions in the locale file, +only the first rule is used. +.ip +a transliteration rule consist of a character to be transliterated +followed by a list of transliteration targets separated by semicolons. +the first target which can be presented in the target character set +is used, if none of them can be used the +.i default_missing +character will be used instead. +.tp +.i include +in the transliteration rules section includes +a transliteration rule file +(and optionally a repertoire map file). +.tp +.i default_missing +in the transliteration rules section +defines the default character to be used for +transliteration where none of the targets cannot be presented +in the target character set. +.tp +.i translit_end +marks the end of the transliteration rules. +.pp +the +.b lc_ctype +definition ends with the string +.ir "end lc_ctype" . +.ss lc_collate +note that glibc does not support all posix-defined options, +only the options described below are supported (as of glibc 2.23). +.pp +the definition starts with the string +.i lc_collate +in the first column. +.pp +the following keywords are allowed: +.tp +.i coll_weight_max +followed by the number representing used collation levels. +this keyword is recognized but ignored by glibc. +.tp +.i collating\-element +followed by the definition of a collating-element symbol +representing a multicharacter collating element. +.tp +.i collating\-symbol +followed by the definition of a collating symbol +that can be used in collation order statements. +.tp +.i define +followed by +.b string +to be evaluated in an +.i ifdef +.b string +/ +.i else +/ +.i endif +construct. +.tp +.i reorder\-after +followed by a redefinition of a collation rule. +.tp +.i reorder\-end +marks the end of the redefinition of a collation rule. +.tp +.i reorde\r-sections\-after +followed by a script name to reorder listed scripts after. +.tp +.i reorder\-sections\-end +marks the end of the reordering of sections. +.tp +.i script +followed by a declaration of a script. +.tp +.i symbol\-equivalence +followed by a collating-symbol to be equivalent to another defined +collating-symbol. +.pp +the collation rule definition starts with a line: +.tp +.i order_start +followed by a list of keywords chosen from +.br forward , +.br backward , +or +.br position . +the order definition consists of lines that describe the collation +order and is terminated with the keyword +.ir order_end . +.pp +the +.b lc_collate +definition ends with the string +.ir "end lc_collate" . +.ss lc_identification +the definition starts with the string +.i lc_identification +in the first column. +.pp +the following keywords are allowed: +.tp +.i title +followed by the title of the locale document +(e.g., "maori language locale for new zealand"). +.tp +.i source +followed by the name of the organization that maintains this document. +.tp +.i address +followed by the address of the organization that maintains this document. +.tp +.i contact +followed by the name of the contact person at +the organization that maintains this document. +.tp +.i email +followed by the email address of the person or +organization that maintains this document. +.tp +.i tel +followed by the telephone number (in international format) +of the organization that maintains this document. +as of glibc 2.24, this keyword is deprecated in favor of +other contact methods. +.tp +.i fax +followed by the fax number (in international format) +of the organization that maintains this document. +as of glibc 2.24, this keyword is deprecated in favor of +other contact methods. +.tp +.i language +followed by the name of the language to which this document applies. +.tp +.i territory +followed by the name of the country/geographic extent +to which this document applies. +.tp +.i audience +followed by a description of the audience for which this document is +intended. +.tp +.i application +followed by a description of any special application +for which this document is intended. +.tp +.i abbreviation +followed by the short name for provider of the source of this document. +.tp +.i revision +followed by the revision number of this document. +.tp +.i date +followed by the revision date of this document. +.pp +in addition, for each of the categories defined by the document, +there should be a line starting with the keyword +.ir category , +followed by: +.ip * 3 +a string that identifies this locale category definition, +.ip * +a semicolon, and +.ip * +one of the +.b lc_* +identifiers. +.pp +the +.b lc_identification +definition ends with the string +.ir "end lc_identification" . +.ss lc_messages +the definition starts with the string +.i lc_messages +in the first column. +.pp +the following keywords are allowed: +.tp +.i yesexpr +followed by a regular expression that describes possible +yes-responses. +.tp +.i noexpr +followed by a regular expression that describes possible +no-responses. +.tp +.i yesstr +followed by the output string corresponding to "yes". +.tp +.i nostr +followed by the output string corresponding to "no". +.pp +the +.b lc_messages +definition ends with the string +.ir "end lc_messages" . +.ss lc_measurement +the definition starts with the string +.i lc_measurement +in the first column. +.pp +the following keywords are allowed: +.tp +.i measurement +followed by number identifying the standard used for measurement. +the following values are recognized: +.rs +.tp 4 +.b 1 +metric. +.tp +.b 2 +us customary measurements. +.re +.pp +the +.b lc_measurement +definition ends with the string +.ir "end lc_measurement" . +.ss lc_monetary +the definition starts with the string +.i lc_monetary +in the first column. +.pp +the following keywords are allowed: +.tp +.i int_curr_symbol +followed by the international currency symbol. +this must be a +4-character string containing the international currency symbol as +defined by the iso 4217 standard (three characters) followed by a +separator. +.tp +.i currency_symbol +followed by the local currency symbol. +.tp +.i mon_decimal_point +followed by the single-character string that will be used as the +decimal delimiter when formatting monetary quantities. +.tp +.i mon_thousands_sep +followed by the single-character string that will be used as a group +separator when formatting monetary quantities. +.tp +.i mon_grouping +followed by a sequence of integers separated by semicolons that +describe the formatting of monetary quantities. +see +.i grouping +below for details. +.tp +.i positive_sign +followed by a string that is used to indicate a positive sign for +monetary quantities. +.tp +.i negative_sign +followed by a string that is used to indicate a negative sign for +monetary quantities. +.tp +.i int_frac_digits +followed by the number of fractional digits that should be used when +formatting with the +.ir int_curr_symbol . +.tp +.i frac_digits +followed by the number of fractional digits that should be used when +formatting with the +.ir currency_symbol . +.tp +.i p_cs_precedes +followed by an integer that indicates the placement of +.i currency_symbol +for a nonnegative formatted monetary quantity: +.rs +.tp 4 +.b 0 +the symbol succeeds the value. +.tp +.b 1 +the symbol precedes the value. +.re +.tp +.i p_sep_by_space +followed by an integer that indicates the separation of +.ir currency_symbol , +the sign string, and the value for a nonnegative formatted monetary quantity. +the following values are recognized: +.rs +.tp 4 +.b 0 +no space separates the currency symbol and the value. +.tp +.b 1 +if the currency symbol and the sign string are adjacent, +a space separates them from the value; +otherwise a space separates the currency symbol and the value. +.tp +.b 2 +if the currency symbol and the sign string are adjacent, +a space separates them from the value; +otherwise a space separates the sign string and the value. +.re +.tp +.i n_cs_precedes +followed by an integer that indicates the placement of +.i currency_symbol +for a negative formatted monetary quantity. +the same values are recognized as for +.ir p_cs_precedes . +.tp +.i n_sep_by_space +followed by an integer that indicates the separation of +.ir currency_symbol , +the sign string, and the value for a negative formatted monetary quantity. +the same values are recognized as for +.ir p_sep_by_space . +.tp +.i p_sign_posn +followed by an integer that indicates where the +.i positive_sign +should be placed for a nonnegative monetary quantity: +.rs +.tp 4 +.b 0 +parentheses enclose the quantity and the +.i currency_symbol +or +.ir int_curr_symbol . +.tp +.b 1 +the sign string precedes the quantity and the +.i currency_symbol +or the +.ir int_curr_symbol . +.tp +.b 2 +the sign string succeeds the quantity and the +.i currency_symbol +or the +.ir int_curr_symbol . +.tp +.b 3 +the sign string precedes the +.i currency_symbol +or the +.ir int_curr_symbol . +.tp +.b 4 +the sign string succeeds the +.i currency_symbol +or the +.ir int_curr_symbol . +.re +.tp +.i n_sign_posn +followed by an integer that indicates where the +.i negative_sign +should be placed for a negative monetary quantity. +the same values are recognized as for +.ir p_sign_posn . +.tp +.i int_p_cs_precedes +followed by an integer that indicates the placement of +.i int_curr_symbol +for a nonnegative internationally formatted monetary quantity. +the same values are recognized as for +.ir p_cs_precedes . +.tp +.i int_n_cs_precedes +followed by an integer that indicates the placement of +.i int_curr_symbol +for a negative internationally formatted monetary quantity. +the same values are recognized as for +.ir p_cs_precedes . +.tp +.i int_p_sep_by_space +followed by an integer that indicates the separation of +.ir int_curr_symbol , +the sign string, +and the value for a nonnegative internationally formatted monetary quantity. +the same values are recognized as for +.ir p_sep_by_space . +.tp +.i int_n_sep_by_space +followed by an integer that indicates the separation of +.ir int_curr_symbol , +the sign string, +and the value for a negative internationally formatted monetary quantity. +the same values are recognized as for +.ir p_sep_by_space . +.tp +.i int_p_sign_posn +followed by an integer that indicates where the +.i positive_sign +should be placed for a nonnegative +internationally formatted monetary quantity. +the same values are recognized as for +.ir p_sign_posn . +.tp +.i int_n_sign_posn +followed by an integer that indicates where the +.i negative_sign +should be placed for a negative +internationally formatted monetary quantity. +the same values are recognized as for +.ir p_sign_posn . +.pp +the +.b lc_monetary +definition ends with the string +.ir "end lc_monetary" . +.ss lc_name +the definition starts with the string +.i lc_name +in the first column. +.pp +various keywords are allowed, but only +.i name_fmt +is mandatory. +other keywords are needed only if there is common convention to +use the corresponding salutation in this locale. +the allowed keywords are as follows: +.tp +.i name_fmt +followed by a string containing field descriptors that define +the format used for names in the locale. +the following field descriptors are recognized: +.rs +.tp 4 +%f +family name(s). +.tp +%f +family names in uppercase. +.tp +%g +first given name. +.tp +%g +first given initial. +.tp +%l +first given name with latin letters. +.tp +%o +other shorter name. +.tp +%m +additional given name(s). +.tp +%m +initials for additional given name(s). +.tp +%p +profession. +.tp +%s +salutation, such as "doctor". +.tp +%s +abbreviated salutation, such as "mr." or "dr.". +.tp +%d +salutation, using the fdcc-sets conventions. +.\" 1 for the name_gen +.\" in glibc 2.19, %d1 is used in only: +.\" /home/mtk/archive/glibc/glibc-2.19/localedata/locales/bem_zm +.\" /home/mtk/archive/glibc/glibc-2.19/localedata/locales/zh_hk +.\" in glibc 2.19, %d[2-5] appear to be not used at all +.\" 2 for name_mr +.\" 3 for name_mrs +.\" 4 for name_miss +.\" 5 for name_ms +.tp +%t +if the preceding field descriptor resulted in an empty string, +then the empty string, otherwise a space character. +.re +.tp +.i name_gen +followed by the general salutation for any gender. +.tp +.i name_mr +followed by the salutation for men. +.tp +.i name_mrs +followed by the salutation for married women. +.tp +.i name_miss +followed by the salutation for unmarried women. +.tp +.i name_ms +followed by the salutation valid for all women. +.pp +the +.b lc_name +definition ends with the string +.ir "end lc_name" . +.ss lc_numeric +the definition starts with the string +.i lc_numeric +in the first column. +.pp +the following keywords are allowed: +.tp +.i decimal_point +followed by the single-character string that will be used as the +decimal delimiter when formatting numeric quantities. +.tp +.i thousands_sep +followed by the single-character string that will be used as a group +separator when formatting numeric quantities. +.tp +.i grouping +followed by a sequence of integers separated by semicolons +that describe the formatting of numeric quantities. +.ip +each integer specifies the number of digits in a group. +the first integer defines the size of the group immediately +to the left of the decimal delimiter. +subsequent integers define succeeding groups to the +left of the previous group. +if the last integer is not \-1, then the size of the previous group +(if any) is repeatedly used for the remainder of the digits. +if the last integer is \-1, then no further grouping is performed. +.pp +the +.b lc_numeric +definition ends with the string +.ir "end lc_numeric" . +.ss lc_paper +the definition starts with the string +.i lc_paper +in the first column. +.pp +the following keywords are allowed: +.tp +.i height +followed by the height, in millimeters, of the standard paper format. +.tp +.i width +followed by the width, in millimeters, of the standard paper format. +.pp +the +.b lc_paper +definition ends with the string +.ir "end lc_paper" . +.ss lc_telephone +the definition starts with the string +.i lc_telephone +in the first column. +.pp +the following keywords are allowed: +.tp +.i tel_int_fmt +followed by a string that contains field descriptors that identify +the format used to dial international numbers. +the following field descriptors are recognized: +.rs +.tp 4 +%a +area code without nationwide prefix (the prefix is often "00"). +.tp +%a +area code including nationwide prefix. +.tp +%l +local number (within area code). +.tp +%e +extension (to local number). +.tp +%c +country code. +.tp +%c +alternate carrier service code used for dialing abroad. +.tp +%t +if the preceding field descriptor resulted in an empty string, +then the empty string, otherwise a space character. +.re +.tp +.i tel_dom_fmt +followed by a string that contains field descriptors that identify +the format used to dial domestic numbers. +the recognized field descriptors are the same as for +.ir tel_int_fmt . +.tp +.i int_select +followed by the prefix used to call international phone numbers. +.tp +.i int_prefix +followed by the prefix used from other countries to dial this country. +.pp +the +.b lc_telephone +definition ends with the string +.ir "end lc_telephone" . +.ss lc_time +the definition starts with the string +.i lc_time +in the first column. +.pp +the following keywords are allowed: +.tp +.i abday +followed by a list of abbreviated names of the days of the week. +the list starts with the first day of the week +as specified by +.i week +(sunday by default). +see notes. +.tp +.i day +followed by a list of names of the days of the week. +the list starts with the first day of the week +as specified by +.i week +(sunday by default). +see notes. +.tp +.i abmon +followed by a list of abbreviated month names. +.tp +.i mon +followed by a list of month names. +.tp +.i d_t_fmt +followed by the appropriate date and time format +(for syntax, see +.br strftime (3)). +.tp +.i d_fmt +followed by the appropriate date format +(for syntax, see +.br strftime (3)). +.tp +.i t_fmt +followed by the appropriate time format +(for syntax, see +.br strftime (3)). +.tp +.i am_pm +followed by the appropriate representation of the +.b am +and +.b pm +strings. +this should be left empty for locales not using am/pm convention. +.tp +.i t_fmt_ampm +followed by the appropriate time format +(for syntax, see +.br strftime (3)) +when using 12h clock format. +this should be left empty for locales not using am/pm convention. +.tp +.i era +followed by semicolon-separated strings that define how years are +counted and displayed for each era in the locale. +each string has the following format: +.rs +.pp +.ir direction ":" offset ":" start_date ":" end_date ":" era_name ":" era_format +.pp +the fields are to be defined as follows: +.tp 4 +.i direction +either +.b + +or +.br \- . +.b + +means the years closer to +.i start_date +have lower numbers than years closer to +.ir end_date . +.b \- +means the opposite. +.tp +.i offset +the number of the year closest to +.i start_date +in the era, corresponding to the +.i %ey +descriptor (see +.br strptime (3)). +.tp +.i start_date +the start of the era in the form of +.ir yyyy/mm/dd . +years prior ad 1 are represented as negative numbers. +.tp +.i end_date +the end of the era in the form of +.ir yyyy/mm/dd , +or one of the two special values of +.b \-* +or +.br +* . +.b \-* +means the ending date is the beginning of time. +.b +* +means the ending date is the end of time. +.tp +.i era_name +the name of the era corresponding to the +.i %ec +descriptor (see +.br strptime (3)). +.tp +.i era_format +the format of the year in the era corresponding to the +.i %ey +descriptor (see +.br strptime (3)). +.re +.tp +.i era_d_fmt +followed by the format of the date in alternative era notation, +corresponding to the +.i %ex +descriptor (see +.br strptime (3)). +.tp +.i era_t_fmt +followed by the format of the time in alternative era notation, +corresponding to the +.i %ex +descriptor (see +.br strptime (3)). +.tp +.i era_d_t_fmt +followed by the format of the date and time in alternative era notation, +corresponding to the +.i %ec +descriptor (see +.br strptime (3)). +.tp +.i alt_digits +followed by the alternative digits used for date and time in the locale. +.tp +.i week +followed by a list of three values separated by semicolons: +the number of days in a week (by default 7), +a date of beginning of the week (by default corresponds to sunday), +and the minimal length of the first week in year (by default 4). +regarding the start of the week, +.b 19971130 +shall be used for sunday and +.b 19971201 +shall be used for monday. +see notes. +.tp +.ir first_weekday " (since glibc 2.2)" +followed by the number of the day from the +.i day +list to be shown as the first day of the week in calendar applications. +the default value of +.b 1 +corresponds to either sunday or monday depending +on the value of the second +.i week +list item. +see notes. +.tp +.ir first_workday " (since glibc 2.2)" +followed by the number of the first working day from the +.i day +list. +the default value is +.br 2 . +see notes. +.tp +.i cal_direction +followed by a number value that indicates the direction for the +display of calendar dates, as follows: +.rs +.tp 4 +.b 1 +left-right from top. +.tp +.b 2 +top-down from left. +.tp +.b 3 +right-left from top. +.re +.tp +.i date_fmt +followed by the appropriate date representation for +.br date (1) +(for syntax, see +.br strftime (3)). +.pp +the +.b lc_time +definition ends with the string +.ir "end lc_time" . +.sh files +.tp +.i /usr/lib/locale/locale\-archive +usual default locale archive location. +.tp +.i /usr/share/i18n/locales +usual default path for locale definition files. +.sh conforming to +posix.2. +.sh notes +the collective gnu c library community wisdom regarding +.ir abday , +.ir day , +.ir week , +.ir first_weekday , +and +.i first_workday +states at +https://sourceware.org/glibc/wiki/locales +the following: +.ip * 3 +the value of the second +.i week +list item specifies the base of the +.i abday +and +.i day +lists. +.ip * +.i first_weekday +specifies the offset of the first day-of-week in the +.i abday +and +.i day +lists. +.ip * +for compatibility reasons, all glibc locales should set the value of the +second +.i week +list item to +.b 19971130 +(sunday) and base the +.i abday +and +.i day +lists appropriately, and set +.i first_weekday +and +.i first_workday +to +.b 1 +or +.br 2 , +depending on whether the week and work week actually starts on sunday or +monday for the locale. +.\" .sh author +.\" jochen hein (hein@student.tu-clausthal.de) +.sh see also +.br iconv (1), +.br locale (1), +.br localedef (1), +.br localeconv (3), +.br newlocale (3), +.br setlocale (3), +.br strftime (3), +.br strptime (3), +.br uselocale (3), +.br charmap (5), +.br charsets (7), +.br locale (7), +.br unicode (7), +.br utf\-8 (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de) +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under gpl +.\" %%%license_end +.\" +.th casin 3 2021-03-22 "" "linux programmer's manual" +.sh name +casin, casinf, casinl \- complex arc sine +.sh synopsis +.nf +.b #include +.pp +.bi "double complex casin(double complex " z ); +.bi "float complex casinf(float complex " z ); +.bi "long double complex casinl(long double complex " z ); +.pp +link with \fi\-lm\fp. +.fi +.sh description +these functions calculate the complex arc sine of +.ir z . +if \fiy\ =\ casin(z)\fp, then \fiz\ =\ csin(y)\fp. +the real part of +.i y +is chosen in the interval [\-pi/2,pi/2]. +.pp +one has: +.pp +.nf + casin(z) = \-i clog(iz + csqrt(1 \- z * z)) +.fi +.sh versions +these functions first appeared in glibc in version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br casin (), +.br casinf (), +.br casinl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.sh see also +.br clog (3), +.br csin (3), +.br complex (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/strcpy.3 + +.\" copyright (c) 2006 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th sem_unlink 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +sem_unlink \- remove a named semaphore +.sh synopsis +.nf +.b #include +.pp +.bi "int sem_unlink(const char *" name ); +.fi +.pp +link with \fi\-pthread\fp. +.sh description +.br sem_unlink () +removes the named semaphore referred to by +.ir name . +the semaphore name is removed immediately. +the semaphore is destroyed once all other processes that have +the semaphore open close it. +.sh return value +on success +.br sem_unlink () +returns 0; on error, \-1 is returned, with +.i errno +set to indicate the error. +.sh errors +.tp +.b eacces +the caller does not have permission to unlink this semaphore. +.tp +.b enametoolong +.i name +was too long. +.tp +.b enoent +there is no semaphore with the given +.ir name . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br sem_unlink () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh see also +.br sem_getvalue (3), +.br sem_open (3), +.br sem_post (3), +.br sem_wait (3), +.br sem_overview (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/sigwaitinfo.2 + +.so man3/getservent.3 + +.so man3/csqrt.3 + +.\" copyright (c) 2004 andries brouwer (aeb@cwi.nl) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th sigpause 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +sigpause \- atomically release blocked signals and wait for interrupt +.sh synopsis +.nf +.b #include +.pp +.bi "int sigpause(int " sigmask "); /* bsd (but see notes) */" +.pp +.bi "int sigpause(int " sig "); /* system v / unix 95 */" +.fi +.sh description +don't use this function. +use +.br sigsuspend (2) +instead. +.pp +the function +.br sigpause () +is designed to wait for some signal. +it changes the process's signal mask (set of blocked signals), +and then waits for a signal to arrive. +upon arrival of a signal, the original signal mask is restored. +.sh return value +if +.br sigpause () +returns, it was interrupted by a signal and the return value is \-1 +with +.i errno +set to +.br eintr . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br sigpause () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.\" fixme: the marking is different from that in the glibc manual, +.\" marking in glibc manual is more detailed: +.\" +.\" sigpause: mt-unsafe race:sigprocmask/!bsd!linux +.\" +.\" glibc manual says /!linux!bsd indicate the preceding marker only applies +.\" when the underlying kernel is neither linux nor a bsd kernel. +.\" so, it is safe in linux kernel. +.sh conforming to +the system v version of +.br sigpause () +is standardized in posix.1-2001. +it is also specified in posix.1-2008, where it is marked obsolete. +.sh notes +.ss history +the classical bsd version of this function appeared in 4.2bsd. +it sets the process's signal mask to +.ir sigmask . +unix 95 standardized the incompatible system v version of +this function, which removes only the specified signal +.i sig +from the process's signal mask. +.\" __xpg_sigpause: unix 95, spec 1170, svid, svr4, xpg +the unfortunate situation with two incompatible functions with the +same name was solved by the +.br \%sigsuspend (2) +function, that takes a +.i "sigset_t\ *" +argument (instead of an +.ir int ). +.ss linux notes +on linux, this routine is a system call only on the sparc (sparc64) +architecture. +.pp +.\" libc4 and libc5 know only about the bsd version. +.\" +glibc uses the bsd version if the +.b _bsd_source +feature test macro is defined and none of +.br _posix_source , +.br _posix_c_source , +.br _xopen_source , +.br _gnu_source , +or +.b _svid_source +is defined. +otherwise, the system v version is used, +and feature test macros must be defined as follows to obtain the declaration: +.ip * 3 +since glibc 2.26: +_xopen_source >= 500 +.\" || (_xopen_source && _xopen_source_extended) +.ip * +glibc 2.25 and earlier: _xopen_source +.pp +since glibc 2.19, only the system v version is exposed by +.ir ; +applications that formerly used the bsd +.br sigpause () +should be amended to use +.br sigsuspend (2). +.\" +.\" for the bsd version, one usually uses a zero +.\" .i sigmask +.\" to indicate that no signals are to be blocked. +.sh see also +.br kill (2), +.br sigaction (2), +.br sigprocmask (2), +.br sigsuspend (2), +.br sigblock (3), +.br sigvec (3), +.br feature_test_macros (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/mempcpy.3 + +.so man3/rpc.3 + +.so man3/infinity.3 + +.so man2/unimplemented.2 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" and copyright 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified 1993-07-24 by rik faith (faith@cs.unc.edu) +.\" modified 2002-07-27 by walter harms +.\" (walter.harms@informatik.uni-oldenburg.de) +.\" +.th sin 3 2021-03-22 "" "linux programmer's manual" +.sh name +sin, sinf, sinl \- sine function +.sh synopsis +.nf +.b #include +.pp +.bi "double sin(double " x ); +.bi "float sinf(float " x ); +.bi "long double sinl(long double " x ); +.fi +.pp +link with \fi\-lm\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br sinf (), +.br sinl (): +.nf + _isoc99_source || _posix_c_source >= 200112l + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.sh description +these functions return the sine of +.ir x , +where +.i x +is +given in radians. +.sh return value +on success, these functions return the sine of +.ir x . +.pp +if +.i x +is a nan, a nan is returned. +.pp +if +.i x +is positive infinity or negative infinity, +a domain error occurs, +and a nan is returned. +.\" +.\" posix.1 allows an optional range error for subnormal x +.\" glibc 2.8 doesn't do this +.sh errors +see +.br math_error (7) +for information on how to determine whether an error has occurred +when calling these functions. +.pp +the following errors can occur: +.tp +domain error: \fix\fp is an infinity +.i errno +is set to +.br edom +(but see bugs). +an invalid floating-point exception +.rb ( fe_invalid ) +is raised. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br sin (), +.br sinf (), +.br sinl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.pp +the variant returning +.i double +also conforms to +svr4, 4.3bsd, c89. +.sh bugs +before version 2.10, the glibc implementation did not set +.\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=6781 +.i errno +to +.b edom +when a domain error occurred. +.sh see also +.br acos (3), +.br asin (3), +.br atan (3), +.br atan2 (3), +.br cos (3), +.br csin (3), +.br sincos (3), +.br tan (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1991 the regents of the university of california. +.\" all rights reserved. +.\" +.\" %%%license_start(bsd_4_clause_ucb) +.\" redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. all advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" this product includes software developed by the university of +.\" california, berkeley and its contributors. +.\" 4. neither the name of the university nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" this software is provided by the regents and contributors ``as is'' and +.\" any express or implied warranties, including, but not limited to, the +.\" implied warranties of merchantability and fitness for a particular purpose +.\" are disclaimed. in no event shall the regents or contributors be liable +.\" for any direct, indirect, incidental, special, exemplary, or consequential +.\" damages (including, but not limited to, procurement of substitute goods +.\" or services; loss of use, data, or profits; or business interruption) +.\" however caused and on any theory of liability, whether in contract, strict +.\" liability, or tort (including negligence or otherwise) arising in any way +.\" out of the use of this software, even if advised of the possibility of +.\" such damage. +.\" %%%license_end +.\" +.\" @(#)exec.3 6.4 (berkeley) 4/19/91 +.\" +.\" converted for linux, mon nov 29 11:12:48 1993, faith@cs.unc.edu +.\" updated more for linux, tue jul 15 11:54:18 1997, pacman@cqc.com +.\" modified, 24 jun 2004, michael kerrisk +.\" added note on casting null +.\" +.th exec 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +execl, execlp, execle, execv, execvp, execvpe \- execute a file +.sh synopsis +.nf +.b #include +.pp +.b extern char **environ; +.pp +.bi "int execl(const char *" pathname ", const char *" arg ", ..." +.b " /*, (char *) null */);" +.bi "int execlp(const char *" file ", const char *" arg ", ..." +.b " /*, (char *) null */);" +.bi "int execle(const char *" pathname ", const char *" arg ", ..." +.bi " /*, (char *) null, char *const " envp "[] */);" +.bi "int execv(const char *" pathname ", char *const " argv "[]);" +.bi "int execvp(const char *" file ", char *const " argv "[]);" +.bi "int execvpe(const char *" file ", char *const " argv \ +"[], char *const " envp "[]);" +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br execvpe (): +.nf + _gnu_source +.fi +.sh description +the +.br exec () +family of functions replaces the current process image with a new process +image. +the functions described in this manual page are layered on top of +.br execve (2). +(see the manual page for +.br execve (2) +for further details about the replacement of the current process image.) +.pp +the initial argument for these functions is the name of a file that is +to be executed. +.pp +the functions can be grouped based on the letters following the "exec" prefix. +.\" +.ss l - execl(), execlp(), execle() +the +.i "const char\ *arg" +and subsequent ellipses can be thought of as +.ir arg0 , +.ir arg1 , +\&..., +.ir argn . +together they describe a list of one or more pointers to null-terminated +strings that represent the argument list available to the executed program. +the first argument, by convention, should point to the filename associated +with the file being executed. +the list of arguments +.i must +be terminated by a null pointer, +and, since these are variadic functions, this pointer must be cast +.ir "(char\ *) null" . +.pp +by contrast with the 'l' functions, the 'v' functions (below) specify the +command-line arguments of the executed program as a vector. +.\" +.ss v - execv(), execvp(), execvpe() +the +.i "char\ *const argv[]" +argument is an array of pointers to null-terminated strings that +represent the argument list available to the new program. +the first argument, by convention, should point to the filename +associated with the file being executed. +the array of pointers +.i must +be terminated by a null pointer. +.ss e - execle(), execvpe() +the environment of the new process image is specified via the argument +.ir envp . +the +.i envp +argument is an array of pointers to null-terminated strings and +.i must +be terminated by a null pointer. +.pp +all other +.br exec () +functions (which do not include 'e' in the suffix) +take the environment for the new process +image from the external variable +.i environ +in the calling process. +.ss p - execlp(), execvp(), execvpe() +these functions duplicate the actions of the shell in +searching for an executable file +if the specified filename does not contain a slash (/) character. +the file is sought in the colon-separated list of directory pathnames +specified in the +.b path +environment variable. +if this variable isn't defined, the path list defaults to +a list that includes the directories returned by +.ir confstr(_cs_path) +(which typically returns the value "/bin:/usr/bin") +and possibly also the current working directory; +see notes for further details. +.pp +.br execvpe () +searches for the program using the value of +.b path +from the caller's environment, not from the +.i envp +argument. +.pp +if the specified filename includes a slash character, then +.b path +is ignored, and the file at the specified pathname is executed. +.pp +in addition, certain errors are treated specially. +.pp +if permission is denied for a file (the attempted +.br execve (2) +failed with the error +.br eacces ), +these functions will continue searching the rest of the search path. +if no other file is found, however, +they will return with +.i errno +set to +.br eacces . +.pp +if the header of a file isn't recognized (the attempted +.br execve (2) +failed with the error +.br enoexec ), +these functions will execute the shell +.ri ( /bin/sh ) +with the path of the file as its first argument. +(if this attempt fails, no further searching is done.) +.pp +all other +.br exec () +functions (which do not include 'p' in the suffix) +take as their first argument a (relative or absolute) pathname +that identifies the program to be executed. +.sh return value +the +.br exec () +functions return only if an error has occurred. +the return value is \-1, and +.i errno +is set to indicate the error. +.sh errors +all of these functions may fail and set +.i errno +for any of the errors specified for +.br execve (2). +.sh versions +the +.br execvpe () +function first appeared in glibc 2.11. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br execl (), +.br execle (), +.br execv () +t} thread safety mt-safe +t{ +.br execlp (), +.br execvp (), +.br execvpe () +t} thread safety mt-safe env +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.pp +the +.br execvpe () +function is a gnu extension. +.sh notes +the default search path (used when the environment +does not contain the variable \fbpath\fr) +shows some variation across systems. +it generally includes +.i /bin +and +.ir /usr/bin +(in that order) and may also include the current working directory. +on some other systems, the current working is included after +.i /bin +and +.ir /usr/bin , +as an anti-trojan-horse measure. +the glibc implementation long followed the traditional default where +the current working directory is included at the start of the search path. +however, some code refactoring during the development of glibc 2.24 +.\" glibc commit 1eb8930608705702d5746e5491bab4e4429fcb83 +caused the current working directory to be dropped altogether +from the default search path. +this accidental behavior change is considered mildly beneficial, +and won't be reverted. +.pp +the behavior of +.br execlp () +and +.br execvp () +when errors occur while attempting to execute the file is historic +practice, but has not traditionally been documented and is not specified by +the posix standard. +bsd (and possibly other systems) do an automatic +sleep and retry if +.b etxtbsy +is encountered. +linux treats it as a hard +error and returns immediately. +.pp +traditionally, the functions +.br execlp () +and +.br execvp () +ignored all errors except for the ones described above and +.b enomem +and +.br e2big , +upon which they returned. +they now return if any error other than the ones +described above occurs. +.sh bugs +before glibc 2.24, +.br execl () +and +.br execle () +employed +.br realloc (3) +internally and were consequently not async-signal-safe, +in violation of the requirements of posix.1. +.\" https://sourceware.org/bugzilla/show_bug.cgi?id=19534 +this was fixed in glibc 2.24. +.\" +.ss architecture-specific details +on sparc and sparc64, +.br execv () +is provided as a system call by the kernel +(with the prototype shown above) +for compatibility with sunos. +this function is +.i not +employed by the +.br execv () +wrapper function on those architectures. +.sh see also +.br sh (1), +.br execve (2), +.br execveat (2), +.br fork (2), +.br ptrace (2), +.br fexecve (3), +.br system (3), +.br environ (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/clog10.3 + +.so man3/rcmd.3 + +.so man3/atoi.3 + +.\" copyright (c) 2003 andries brouwer (aeb@cwi.nl) +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th cfree 3 2021-03-22 "" "linux programmer's manual" +.sh name +cfree \- free allocated memory +.sh synopsis +.nf +.pp +.b "#include " +.pp +/* in sunos 4 */ +.bi "int cfree(void *" ptr ); +.pp +/* in glibc or freebsd libcompat */ +.bi "void cfree(void *" ptr ); +.pp +/* in sco openserver */ +.bi "void cfree(char *" ptr ", unsigned int " num ", unsigned int " size ); +.pp +/* in solaris watchmalloc.so.1 */ +.bi "void cfree(void *" ptr ", size_t " nelem ", size_t " elsize ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br cfree (): +.nf + since glibc 2.19: + _default_source + glibc 2.19 and earlier: + _bsd_source || _svid_source +.fi +.sh description +this function should never be used. +use +.br free (3) +instead. +starting with version 2.26, it has been removed from glibc. +.ss 1-arg cfree +in glibc, the function +.br cfree () +is a synonym for +.br free (3), +"added for compatibility with sunos". +.pp +other systems have other functions with this name. +the declaration is sometimes in +.i +and sometimes in +.ir . +.ss 3-arg cfree +some sco and solaris versions have malloc libraries with a 3-argument +.br cfree (), +apparently as an analog to +.br calloc (3). +.pp +if you need it while porting something, add +.pp +.in +4n +.ex +#define cfree(p, n, s) free((p)) +.ee +.in +.pp +to your file. +.pp +a frequently asked question is "can i use +.br free (3) +to free memory allocated with +.br calloc (3), +or do i need +.br cfree ()?" +answer: use +.br free (3). +.pp +an sco manual writes: "the cfree routine is provided for compliance +to the ibcse2 standard and simply calls free. +the num and size +arguments to cfree are not used." +.sh return value +the sunos version of +.br cfree () +(which is a synonym for +.br free (3)) +returns 1 on success and 0 on failure. +in case of error, +.i errno +is set to +.br einval : +the value of +.i ptr +was not a pointer to a block previously allocated by +one of the routines in the +.br malloc (3) +family. +.sh versions +the +.br cfree () +function was removed +.\" commit 025b33ae84bb8f15b2748a1d8605dca453fce112 +from glibc in version 2.26. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br cfree () +t} thread safety mt-safe /* in glibc */ +.te +.hy +.ad +.sp 1 +.sh conforming to +the 3-argument version of +.br cfree () +as used by sco conforms to the ibcse2 standard: +intel386 binary compatibility specification, edition 2. +.sh see also +.br malloc (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th getnetent_r 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +getnetent_r, getnetbyname_r, getnetbyaddr_r \- get +network entry (reentrant) +.sh synopsis +.nf +.b #include +.pp +.bi "int getnetent_r(struct netent *restrict " result_buf , +.bi " char *restrict " buf ", size_t " buflen , +.bi " struct netent **restrict " result , +.bi " int *restrict " h_errnop ); +.bi "int getnetbyname_r(const char *restrict " name , +.bi " struct netent *restrict " result_buf , +.bi " char *restrict " buf ", size_t " buflen , +.bi " struct netent **restrict " result , +.bi " int *restrict " h_errnop ); +.bi "int getnetbyaddr_r(uint32_t " net ", int " type , +.bi " struct netent *restrict " result_buf , +.bi " char *restrict " buf ", size_t " buflen , +.bi " struct netent **restrict " result , +.bi " int *restrict " h_errnop ); +.pp +.fi +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br getnetent_r (), +.br getnetbyname_r (), +.br getnetbyaddr_r (): +.nf + since glibc 2.19: + _default_source + glibc 2.19 and earlier: + _bsd_source || _svid_source +.fi +.sh description +the +.br getnetent_r (), +.br getnetbyname_r (), +and +.br getnetbyaddr_r () +functions are the reentrant equivalents of, respectively, +.br getnetent (3), +.br getnetbyname (3), +and +.br getnetbynumber (3). +they differ in the way that the +.i netent +structure is returned, +and in the function calling signature and return value. +this manual page describes just the differences from +the nonreentrant functions. +.pp +instead of returning a pointer to a statically allocated +.i netent +structure as the function result, +these functions copy the structure into the location pointed to by +.ir result_buf . +.pp +the +.i buf +array is used to store the string fields pointed to by the returned +.i netent +structure. +(the nonreentrant functions allocate these strings in static storage.) +the size of this array is specified in +.ir buflen . +if +.i buf +is too small, the call fails with the error +.br erange , +and the caller must try again with a larger buffer. +(a buffer of length 1024 bytes should be sufficient for most applications.) +.\" i can find no information on the required/recommended buffer size; +.\" the nonreentrant functions use a 1024 byte buffer -- mtk. +.pp +if the function call successfully obtains a network record, then +.i *result +is set pointing to +.ir result_buf ; +otherwise, +.i *result +is set to null. +.pp +the buffer pointed to by +.i h_errnop +is used to return the value that would be stored in the global variable +.i h_errno +by the nonreentrant versions of these functions. +.\" getnetent.3 doesn't document any use of h_errno, but nevertheless +.\" the nonreentrant functions no seem to set h_errno. +.sh return value +on success, these functions return 0. +on error, they return one of the positive error numbers listed in errors. +.pp +on error, record not found +.rb ( getnetbyname_r (), +.br getnetbyaddr_r ()), +or end of input +.rb ( getnetent_r ()) +.i result +is set to null. +.sh errors +.tp +.b enoent +.rb ( getnetent_r ()) +no more records in database. +.tp +.b erange +.i buf +is too small. +try again with a larger buffer +(and increased +.ir buflen ). +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br getnetent_r (), +.br getnetbyname_r (), +.br getnetbyaddr_r () +t} thread safety mt-safe locale +.te +.hy +.ad +.sp 1 +.sh conforming to +these functions are gnu extensions. +functions with similar names exist on some other systems, +though typically with different calling signatures. +.sh see also +.br getnetent (3), +.br networks (5) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 2009 lefteris dimitroulakis (edimitro@tee.gr) +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th iso_8859-10 7 2020-08-13 "linux" "linux programmer's manual" +.sh name +iso_8859-10 \- iso 8859-10 character set encoded in octal, decimal, +and hexadecimal +.sh description +the iso 8859 standard includes several 8-bit extensions to the ascii +character set (also known as iso 646-irv). +iso 8859-10 encodes the +characters used in nordic languages. +.ss iso 8859 alphabets +the full set of iso 8859 alphabets includes: +.ts +l l. +iso 8859-1 west european languages (latin-1) +iso 8859-2 central and east european languages (latin-2) +iso 8859-3 southeast european and miscellaneous languages (latin-3) +iso 8859-4 scandinavian/baltic languages (latin-4) +iso 8859-5 latin/cyrillic +iso 8859-6 latin/arabic +iso 8859-7 latin/greek +iso 8859-8 latin/hebrew +iso 8859-9 latin-1 modification for turkish (latin-5) +iso 8859-10 lappish/nordic/eskimo languages (latin-6) +iso 8859-11 latin/thai +iso 8859-13 baltic rim languages (latin-7) +iso 8859-14 celtic (latin-8) +iso 8859-15 west european languages (latin-9) +iso 8859-16 romanian (latin-10) +.te +.ss iso 8859-10 characters +the following table displays the characters in iso 8859-10 that +are printable and unlisted in the +.br ascii (7) +manual page. +.ts +l l l c lp-1. +oct dec hex char description +_ +240 160 a0   no-break space +241 161 a1 ą latin capital letter a with ogonek +242 162 a2 ē latin capital letter e with macron +243 163 a3 ģ latin capital letter g with cedilla +244 164 a4 ī latin capital letter i with macron +245 165 a5 ĩ latin capital letter i with tilde +246 166 a6 ķ latin capital letter k with cedilla +247 167 a7 § section sign +250 168 a8 ļ latin capital letter l with cedilla +251 169 a9 đ latin capital letter d with stroke +252 170 aa š latin capital letter s with caron +253 171 ab ŧ latin capital letter t with stroke +254 172 ac ž latin capital letter z with caron +255 173 ad ­ soft hyphen +256 174 ae ū latin capital letter u with macron +257 175 af ŋ latin capital letter eng +260 176 b0 ° degree sign +261 177 b1 ą latin small letter a with ogonek +262 178 b2 ē latin small letter e with macron +263 179 b3 ģ latin small letter g with cedilla +264 180 b4 ī latin small letter i with macron +265 181 b5 ĩ latin small letter i with tilde +266 182 b6 ķ latin small letter k with cedilla +267 183 b7 · middle dot +270 184 b8 ļ latin small letter l with cedilla +271 185 b9 đ latin small letter d with stroke +272 186 ba š latin small letter s with caron +273 187 bb ŧ latin small letter t with stroke +274 188 bc ž latin small letter z with caron +275 189 bd ― horizontal bar +276 190 be ū latin small letter u with macron +277 191 bf ŋ latin small letter eng +300 192 c0 ā latin capital letter a with macron +301 193 c1 á latin capital letter a with acute +302 194 c2 â latin capital letter a with circumflex +303 195 c3 ã latin capital letter a with tilde +304 196 c4 ä latin capital letter a with diaeresis +305 197 c5 å latin capital letter a with ring above +306 198 c6 æ latin capital letter ae +307 199 c7 į latin capital letter i with ogonek +310 200 c8 č latin capital letter c with caron +311 201 c9 é latin capital letter e with acute +312 202 ca ę latin capital letter e with ogonek +312 202 cb ë latin capital letter e with diaeresis +314 204 cc ė latin capital letter e with dot above +315 205 cd í latin capital letter i with acute +316 206 ce î latin capital letter i with circumflex +317 207 cf ï latin capital letter i with diaeresis +320 208 d0 ð latin capital letter eth +321 209 d1 ņ latin capital letter n with cedilla +322 210 d2 ō latin capital letter o with macron +323 211 d3 ó latin capital letter o with acute +324 212 d4 ô latin capital letter o with circumflex +325 213 d5 õ latin capital letter o with tilde +326 214 d6 ö latin capital letter o with diaeresis +327 215 d7 ũ latin capital letter u with tilde +330 216 d8 ø latin capital letter o with stroke +331 217 d9 ų latin capital letter u with ogonek +332 218 da ú latin capital letter u with acute +333 219 db û latin capital letter u with circumflex +334 220 dc ü latin capital letter u with diaeresis +335 221 dd ý latin capital letter y with acute +336 222 de þ latin capital letter thorn +337 223 df ß latin small letter sharp s +340 224 e0 ā latin small letter a with macron +341 225 e1 á latin small letter a with acute +342 226 e2 â latin small letter a with circumflex +343 227 e3 ã latin small letter a with tilde +344 228 e4 ä latin small letter a with diaeresis +345 229 e5 å latin small letter a with ring above +346 230 e6 æ latin small letter ae +347 231 e7 į latin small letter i with ogonek +350 232 e8 č latin small letter c with caron +351 233 e9 é latin small letter e with acute +352 234 ea ę latin small letter e with ogonek +353 235 eb ë latin small letter e with diaeresis +354 236 ec ė latin small letter e with dot above +355 237 ed í latin small letter i with acute +356 238 ee î latin small letter i with circumflex +357 239 ef ï latin small letter i with diaeresis +360 240 f0 ð latin small letter eth +361 241 f1 ņ latin small letter n with cedilla +362 242 f2 ō latin small letter o with macron +363 243 f3 ó latin small letter o with acute +364 244 f4 ô latin small letter o with circumflex +365 245 f5 õ latin small letter o with tilde +366 246 f6 ö latin small letter o with diaeresis +367 247 f7 ũ latin small letter u with tilde +370 248 f8 ø latin small letter o with stroke +371 249 f9 ų latin small letter u with ogonek +372 250 fa ú latin small letter u with acute +373 251 fb û latin small letter u with circumflex +374 252 fc ü latin small letter u with diaeresis +375 253 fd ý latin small letter y with acute +376 254 fe þ latin small letter thorn +377 255 ff ĸ latin small letter kra +.te +.sh notes +iso 8859-10 is also known as latin-6. +.sh see also +.br ascii (7), +.br charsets (7), +.br utf\-8 (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1990, 1991 the regents of the university of california. +.\" all rights reserved. +.\" +.\" this code is derived from software contributed to berkeley by +.\" chris torek and the american national standards committee x3, +.\" on information processing systems. +.\" +.\" %%%license_start(bsd_4_clause_ucb) +.\" redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. all advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" this product includes software developed by the university of +.\" california, berkeley and its contributors. +.\" 4. neither the name of the university nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" this software is provided by the regents and contributors ``as is'' and +.\" any express or implied warranties, including, but not limited to, the +.\" implied warranties of merchantability and fitness for a particular purpose +.\" are disclaimed. in no event shall the regents or contributors be liable +.\" for any direct, indirect, incidental, special, exemplary, or consequential +.\" damages (including, but not limited to, procurement of substitute goods +.\" or services; loss of use, data, or profits; or business interruption) +.\" however caused and on any theory of liability, whether in contract, strict +.\" liability, or tort (including negligence or otherwise) arising in any way +.\" out of the use of this software, even if advised of the possibility of +.\" such damage. +.\" %%%license_end +.\" +.\" @(#)fseek.3 6.11 (berkeley) 6/29/91 +.\" +.\" converted for linux, mon nov 29 15:22:01 1993, faith@cs.unc.edu +.\" +.th fseek 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +fgetpos, fseek, fsetpos, ftell, rewind \- reposition a stream +.sh synopsis +.nf +.b #include +.pp +.bi "int fseek(file *" stream ", long " offset ", int " whence ); +.bi "long ftell(file *" stream ); +.pp +.bi "void rewind(file *" stream ); +.pp +.bi "int fgetpos(file *restrict " stream ", fpos_t *restrict " pos ); +.bi "int fsetpos(file *" stream ", const fpos_t *" pos ); +.fi +.sh description +the +.br fseek () +function sets the file position indicator for the stream pointed to by +.ir stream . +the new position, measured in bytes, is obtained by adding +.i offset +bytes to the position specified by +.ir whence . +if +.i whence +is set to +.br seek_set , +.br seek_cur , +or +.br seek_end , +the offset is relative to the start of the file, the current position +indicator, or end-of-file, respectively. +a successful call to the +.br fseek () +function clears the end-of-file indicator for the stream and undoes +any effects of the +.br ungetc (3) +function on the same stream. +.pp +the +.br ftell () +function obtains the current value of the file position indicator for the +stream pointed to by +.ir stream . +.pp +the +.br rewind () +function sets the file position indicator for the stream pointed to by +.i stream +to the beginning of the file. +it is equivalent to: +.pp +.rs +(void) fseek(stream, 0l, seek_set) +.re +.pp +except that the error indicator for the stream is also cleared (see +.br clearerr (3)). +.pp +the +.br fgetpos () +and +.br fsetpos () +functions are alternate interfaces equivalent to +.br ftell () +and +.br fseek () +(with +.i whence +set to +.br seek_set ), +setting and storing the current value of the file offset into or from the +object referenced by +.ir pos . +on some non-unix systems, an +.i fpos_t +object may be a complex object and these routines may be the only way to +portably reposition a text stream. +.sh return value +the +.br rewind () +function returns no value. +upon successful completion, +.br fgetpos (), +.br fseek (), +.br fsetpos () +return 0, +and +.br ftell () +returns the current offset. +otherwise, \-1 is returned and +.i errno +is set to indicate the error. +.sh errors +.tp +.b einval +the +.i whence +argument to +.br fseek () +was not +.br seek_set , +.br seek_end , +or +.br seek_cur . +or: the resulting file offset would be negative. +.tp +.b espipe +the file descriptor underlying +.i stream +is not seekable (e.g., it refers to a pipe, fifo, or socket). +.pp +the functions +.br fgetpos (), +.br fseek (), +.br fsetpos (), +and +.br ftell () +may also fail and set +.i errno +for any of the errors specified for the routines +.br fflush (3), +.br fstat (2), +.br lseek (2), +and +.br malloc (3). +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br fseek (), +.br ftell (), +.br rewind (), +.br fgetpos (), +.br fsetpos () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c89, c99. +.sh see also +.br lseek (2), +.br fseeko (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/rpc.3 + +.so man3/gethostbyname.3 + +.so man3/fts.3 + +.so man2/brk.2 + +.so man7/system_data_types.7 + +.so man7/system_data_types.7 + +.so man3/getgrent_r.3 + +.\" copyright (c) 2006 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th mq_send 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +mq_send, mq_timedsend \- send a message to a message queue +.sh synopsis +.nf +.b #include +.pp +.bi "int mq_send(mqd_t " mqdes ", const char *" msg_ptr , +.bi " size_t " msg_len ", unsigned int " msg_prio ); +.pp +.b #include +.b #include +.pp +.bi "int mq_timedsend(mqd_t " mqdes ", const char *" msg_ptr , +.bi " size_t " msg_len ", unsigned int " msg_prio , +.bi " const struct timespec *" abs_timeout ); +.fi +.pp +link with \fi\-lrt\fp. +.pp +.ad l +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br mq_timedsend (): +.nf + _posix_c_source >= 200112l +.fi +.sh description +.br mq_send () +adds the message pointed to by +.i msg_ptr +to the message queue referred to by the message queue descriptor +.ir mqdes . +the +.i msg_len +argument specifies the length of the message pointed to by +.ir msg_ptr ; +this length must be less than or equal to the queue's +.i mq_msgsize +attribute. +zero-length messages are allowed. +.pp +the +.i msg_prio +argument is a nonnegative integer that specifies the priority +of this message. +messages are placed on the queue in decreasing order of priority, +with newer messages of the same priority being placed after +older messages with the same priority. +see +.br mq_overview (7) +for details on the range for the message priority. +.pp +if the message queue is already full +(i.e., the number of messages on the queue equals the queue's +.i mq_maxmsg +attribute), then, by default, +.br mq_send () +blocks until sufficient space becomes available to allow the message +to be queued, or until the call is interrupted by a signal handler. +if the +.b o_nonblock +flag is enabled for the message queue description, +then the call instead fails immediately with the error +.br eagain . +.pp +.br mq_timedsend () +behaves just like +.br mq_send (), +except that if the queue is full and the +.b o_nonblock +flag is not enabled for the message queue description, then +.i abs_timeout +points to a structure which specifies how long the call will block. +this value is an absolute timeout in seconds and nanoseconds +since the epoch, 1970-01-01 00:00:00 +0000 (utc), +specified in the following structure: +.pp +.in +4n +.ex +struct timespec { + time_t tv_sec; /* seconds */ + long tv_nsec; /* nanoseconds */ +}; +.ee +.in +.pp +if the message queue is full, +and the timeout has already expired by the time of the call, +.br mq_timedsend () +returns immediately. +.sh return value +on success, +.br mq_send () +and +.br mq_timedsend () +return zero; on error, \-1 is returned, with +.i errno +set to indicate the error. +.sh errors +.tp +.b eagain +the queue was full, and the +.b o_nonblock +flag was set for the message queue description referred to by +.ir mqdes . +.tp +.b ebadf +the descriptor specified in +.i mqdes +was invalid or not opened for writing. +.tp +.b eintr +the call was interrupted by a signal handler; see +.br signal (7). +.tp +.b einval +the call would have blocked, and +.i abs_timeout +was invalid, either because +.i tv_sec +was less than zero, or because +.i tv_nsec +was less than zero or greater than 1000 million. +.tp +.b emsgsize +.i msg_len +was greater than the +.i mq_msgsize +attribute of the message queue. +.tp +.b etimedout +the call timed out before a message could be transferred. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br mq_send (), +.br mq_timedsend () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +on linux, +.br mq_timedsend () +is a system call, and +.br mq_send () +is a library function layered on top of that system call. +.sh see also +.br mq_close (3), +.br mq_getattr (3), +.br mq_notify (3), +.br mq_open (3), +.br mq_receive (3), +.br mq_unlink (3), +.br mq_overview (7), +.br time (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" 386bsd man pages +.\" modified sat jul 24 18:50:48 1993 by rik faith (faith@cs.unc.edu) +.\" interchanged 'needle' and 'haystack'; added history, aeb, 980113. +.th memmem 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +memmem \- locate a substring +.sh synopsis +.nf +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "void *memmem(const void *" haystack ", size_t " haystacklen , +.bi " const void *" needle ", size_t " needlelen ); +.fi +.sh description +the +.br memmem () +function finds the start of the first occurrence +of the substring +.ir needle +of length +.i needlelen +in the memory +area +.i haystack +of length +.ir haystacklen . +.sh return value +the +.br memmem () +function returns a pointer to the beginning of the +substring, or null if the substring is not found. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br memmem () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +this function is not specified in posix.1, +but is present on a number of other systems. +.sh bugs +.\" this function was broken in linux libraries up to and including libc 5.0.9; +.\" there the +.\" .ir needle +.\" and +.\" .i haystack +.\" arguments were interchanged, +.\" and a pointer to the end of the first occurrence of +.\" .i needle +.\" was returned. +.\" +.\" both old and new libc's have the bug that if +.\" .i needle +.\" is empty, +.\" .i haystack\-1 +.\" (instead of +.\" .ir haystack ) +.\" is returned. +in glibc 2.0, if +.i needle +is empty, +.br memmem () +returns a pointer to the last byte of +.ir haystack . +this is fixed in glibc 2.1. +.sh see also +.br bstring (3), +.br strstr (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/exp.3 + +.so man7/iso_8859-8.7 + +.\" copyright (c) 2016 julia computing inc, keno fischer +.\" description based on include/uapi/fuse.h and code in fs/fuse +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th fuse 4 2018-02-02 "linux" "linux programmer's manual" +.sh name +fuse \- filesystem in userspace (fuse) device +.sh synopsis +.nf +.b #include +.fi +.sh description +this device is the primary interface between the fuse filesystem driver +and a user-space process wishing to provide the filesystem (referred to +in the rest of this manual page as the +.ir "filesystem daemon" ). +this manual page is intended for those +interested in understanding the kernel interface itself. +those implementing a fuse filesystem may wish to make use of +a user-space library such as +.i libfuse +that abstracts away the low-level interface. +.pp +at its core, fuse is a simple client-server protocol, in which the linux +kernel is the client and the daemon is the server. +after obtaining a file descriptor for this device, the daemon may +.br read (2) +requests from that file descriptor and is expected to +.br write (2) +back its replies. +it is important to note that a file descriptor is +associated with a unique fuse filesystem. +in particular, opening a second copy of this device, +will not allow access to resources created +through the first file descriptor (and vice versa). +.\" +.ss the basic protocol +every message that is read by the daemon begins with a header described by +the following structure: +.pp +.in +4n +.ex +struct fuse_in_header { + uint32_t len; /* total length of the data, + including this header */ + uint32_t opcode; /* the kind of operation (see below) */ + uint64_t unique; /* a unique identifier for this request */ + uint64_t nodeid; /* id of the filesystem object + being operated on */ + uint32_t uid; /* uid of the requesting process */ + uint32_t gid; /* gid of the requesting process */ + uint32_t pid; /* pid of the requesting process */ + uint32_t padding; +}; +.ee +.in +.pp +the header is followed by a variable-length data portion +(which may be empty) specific to the requested operation +(the requested operation is indicated by +.ir opcode ). +.pp +the daemon should then process the request and if applicable send +a reply (almost all operations require a reply; if they do not, +this is documented below), by performing a +.br write (2) +to the file descriptor. +all replies must start with the following header: +.pp +.in +4n +.ex +struct fuse_out_header { + uint32_t len; /* total length of data written to + the file descriptor */ + int32_t error; /* any error that occurred (0 if none) */ + uint64_t unique; /* the value from the + corresponding request */ +}; +.ee +.in +.pp +this header is also followed by (potentially empty) variable-sized +data depending on the executed request. +however, if the reply is an error reply (i.e., +.i error +is set), +then no further payload data should be sent, independent of the request. +.\" +.ss exchanged messages +this section should contain documentation for each of the messages +in the protocol. +this manual page is currently incomplete, +so not all messages are documented. +for each message, first the struct sent by the kernel is given, +followed by a description of the semantics of the message. +.tp +.br fuse_init +.ip +.in +4n +.ex +struct fuse_init_in { + uint32_t major; + uint32_t minor; + uint32_t max_readahead; /* since protocol v7.6 */ + uint32_t flags; /* since protocol v7.6 */ +}; +.ee +.in +.ip +this is the first request sent by the kernel to the daemon. +it is used to negotiate the protocol version and other filesystem parameters. +note that the protocol version may affect the layout of any structure +in the protocol (including this structure). +the daemon must thus remember the negotiated version +and flags for each session. +as of the writing of this man page, +the highest supported kernel protocol version is +.ir 7.26 . +.ip +users should be aware that the descriptions in this manual page +may be incomplete or incorrect for older or more recent protocol versions. +.ip +the reply for this request has the following format: +.ip +.in +4n +.ex +struct fuse_init_out { + uint32_t major; + uint32_t minor; + uint32_t max_readahead; /* since v7.6 */ + uint32_t flags; /* since v7.6; some flags bits + were introduced later */ + uint16_t max_background; /* since v7.13 */ + uint16_t congestion_threshold; /* since v7.13 */ + uint32_t max_write; /* since v7.5 */ + uint32_t time_gran; /* since v7.6 */ + uint32_t unused[9]; +}; +.ee +.in +.ip +if the major version supported by the kernel is larger than that supported +by the daemon, the reply shall consist of only +.i uint32_t major +(following the usual header), +indicating the largest major version supported by the daemon. +the kernel will then issue a new +.b fuse_init +request conforming to the older version. +in the reverse case, the daemon should +quietly fall back to the kernel's major version. +.ip +the negotiated minor version is considered to be the minimum +of the minor versions provided by the daemon and the kernel and +both parties should use the protocol corresponding to said minor version. +.tp +.br fuse_getattr +.ip +.in +4n +.ex +struct fuse_getattr_in { + uint32_t getattr_flags; + uint32_t dummy; + uint64_t fh; /* set only if + (getattr_flags & fuse_getattr_fh) +}; +.ee +.in +.ip +the requested operation is to compute the attributes to be returned +by +.br stat (2) +and similar operations for the given filesystem object. +the object for which the attributes should be computed is indicated +either by +.ir header\->nodeid +or, if the +.br fuse_getattr_fh +flag is set, by the file handle +.ir fh . +the latter case of operation is analogous to +.br fstat (2). +.ip +for performance reasons, these attributes may be cached in the kernel for +a specified duration of time. +while the cache timeout has not been exceeded, +the attributes will be served from the cache and will not cause additional +.b fuse_getattr +requests. +.ip +the computed attributes and the requested +cache timeout should then be returned in the following structure: +.ip +.in +4n +.ex +struct fuse_attr_out { + /* attribute cache duration (seconds + nanoseconds) */ + uint64_t attr_valid; + uint32_t attr_valid_nsec; + uint32_t dummy; + struct fuse_attr { + uint64_t ino; + uint64_t size; + uint64_t blocks; + uint64_t atime; + uint64_t mtime; + uint64_t ctime; + uint32_t atimensec; + uint32_t mtimensec; + uint32_t ctimensec; + uint32_t mode; + uint32_t nlink; + uint32_t uid; + uint32_t gid; + uint32_t rdev; + uint32_t blksize; + uint32_t padding; + } attr; +}; +.ee +.in +.tp +.br fuse_access +.ip +.in +4n +.ex +struct fuse_access_in { + uint32_t mask; + uint32_t padding; +}; +.ee +.in +.ip +if the +.i default_permissions +mount options is not used, this request may be used for permissions checking. +no reply data is expected, but errors may be indicated +as usual by setting the +.i error +field in the reply header (in particular, access denied errors +may be indicated by returning +.br \-eacces ). +.tp +.br fuse_open " and " fuse_opendir +.in +4n +.ex +struct fuse_open_in { + uint32_t flags; /* the flags that were passed + to the open(2) */ + uint32_t unused; +}; +.ee +.in +.ip +the requested operation is to open the node indicated by +.ir header\->nodeid . +the exact semantics of what this means will depend on the +filesystem being implemented. +however, at the very least the +filesystem should validate that the requested +.i flags +are valid for the indicated resource and then send a reply with the +following format: +.ip +.in +4n +.ex +struct fuse_open_out { + uint64_t fh; + uint32_t open_flags; + uint32_t padding; +}; +.ee +.in +.ip +the +.i fh +field is an opaque identifier that the kernel will use to refer +to this resource +the +.i open_flags +field is a bit mask of any number of the flags +that indicate properties of this file handle to the kernel: +.rs 7 +.tp 18 +.br fopen_direct_io +bypass page cache for this open file. +.tp +.br fopen_keep_cache +don't invalidate the data cache on open. +.tp +.br fopen_nonseekable +the file is not seekable. +.re +.tp +.br fuse_read " and " fuse_readdir +.ip +.in +4n +.ex +struct fuse_read_in { + uint64_t fh; + uint64_t offset; + uint32_t size; + uint32_t read_flags; + uint64_t lock_owner; + uint32_t flags; + uint32_t padding; +}; +.ee +.in +.ip +the requested action is to read up to +.i size +bytes of the file or directory, starting at +.ir offset . +the bytes should be returned directly following the usual reply header. +.tp +.br fuse_interrupt +.in +4n +.ex +struct fuse_interrupt_in { + uint64_t unique; +}; +.ee +.in +.ip +the requested action is to cancel the pending operation indicated by +.ir unique . +this request requires no response. +however, receipt of this message does +not by itself cancel the indicated operation. +the kernel will still expect a reply to said operation (e.g., an +.i eintr +error or a short read). +at most one +.b fuse_interrupt +request will be issued for a given operation. +after issuing said operation, +the kernel will wait uninterruptibly for completion of the indicated request. +.tp +.br fuse_lookup +directly following the header is a filename to be looked up in the directory +indicated by +.ir header\->nodeid . +the expected reply is of the form: +.ip +.in +4n +.ex +struct fuse_entry_out { + uint64_t nodeid; /* inode id */ + uint64_t generation; /* inode generation */ + uint64_t entry_valid; + uint64_t attr_valid; + uint32_t entry_valid_nsec; + uint32_t attr_valid_nsec; + struct fuse_attr attr; +}; +.ee +.in +.ip +the combination of +.i nodeid +and +.i generation +must be unique for the filesystem's lifetime. +.ip +the interpretation of timeouts and +.i attr +is as for +.br fuse_getattr . +.tp +.br fuse_flush +.in +4n +.ex +struct fuse_flush_in { + uint64_t fh; + uint32_t unused; + uint32_t padding; + uint64_t lock_owner; +}; +.ee +.in +.ip +the requested action is to flush any pending changes to the indicated +file handle. +no reply data is expected. +however, an empty reply message +still needs to be issued once the flush operation is complete. +.tp +.br fuse_release " and " fuse_releasedir +.in +4n +.ex +struct fuse_release_in { + uint64_t fh; + uint32_t flags; + uint32_t release_flags; + uint64_t lock_owner; +}; +.ee +.in +.ip +these are the converse of +.br fuse_open +and +.br fuse_opendir +respectively. +the daemon may now free any resources associated with the +file handle +.i fh +as the kernel will no longer refer to it. +there is no reply data associated with this request, +but a reply still needs to be issued once the request has +been completely processed. +.tp +.br fuse_statfs +this operation implements +.br statfs (2) +for this filesystem. +there is no input data associated with this request. +the expected reply data has the following structure: +.ip +.in +4n +.ex +struct fuse_kstatfs { + uint64_t blocks; + uint64_t bfree; + uint64_t bavail; + uint64_t files; + uint64_t ffree; + uint32_t bsize; + uint32_t namelen; + uint32_t frsize; + uint32_t padding; + uint32_t spare[6]; +}; + +struct fuse_statfs_out { + struct fuse_kstatfs st; +}; +.ee +.in +.ip +for the interpretation of these fields, see +.br statfs (2). +.sh errors +.tp +.b e2big +returned from +.br read (2) +operations when the kernel's request is too large for the provided buffer +and the request was +.br fuse_setxattr . +.tp +.b einval +returned from +.br write (2) +if validation of the reply failed. +not all mistakes in replies will be caught by this validation. +however, basic mistakes, such as short replies or an incorrect +.i unique +value, are detected. +.tp +.b eio +returned from +.br read (2) +operations when the kernel's request is too large for the provided buffer. +.ip +.ir note : +there are various ways in which incorrect use of these interfaces can cause +operations on the provided filesystem's files and directories to fail with +.br eio . +among the possible incorrect uses are: +.rs +.ip * 3 +changing +.i mode & s_ifmt +for an inode that has previously been reported to the kernel; or +.ip * +giving replies to the kernel that are shorter than what the kernel expected. +.re +.tp +.b enodev +returned from +.br read (2) +and +.br write (2) +if the fuse filesystem was unmounted. +.tp +.b eperm +returned from operations on a +.i /dev/fuse +file descriptor that has not been mounted. +.sh conforming to +the fuse filesystem is linux-specific. +.sh notes +the following messages are not yet documented in this manual page: +.pp +.\" fixme: document the following. +.in +4n +.ex +.br fuse_batch_forget +.br fuse_bmap +.br fuse_create +.br fuse_destroy +.br fuse_fallocate +.br fuse_forget +.br fuse_fsync +.br fuse_fsyncdir +.br fuse_getlk +.br fuse_getxattr +.br fuse_ioctl +.br fuse_link +.br fuse_listxattr +.br fuse_lseek +.br fuse_mkdir +.br fuse_mknod +.br fuse_notify_reply +.br fuse_poll +.br fuse_readdirplus +.br fuse_readlink +.br fuse_removexattr +.br fuse_rename +.br fuse_rename2 +.br fuse_rmdir +.br fuse_setattr +.br fuse_setlk +.br fuse_setlkw +.br fuse_symlink +.br fuse_unlink +.br fuse_write +.ee +.in +.sh see also +.br fusermount (1), +.br mount.fuse (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/fputwc.3 + +.so man3/lgamma.3 + +.so man3/xcrypt.3 + +.so man2/mmap.2 + +.so man3/remainder.3 + +.so man3/pthread_tryjoin_np.3 + +.\" copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de) +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under gpl +.\" %%%license_end +.\" +.\" based on glibc infopages +.\" polished - aeb +.\" +.th setnetgrent 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +setnetgrent, endnetgrent, getnetgrent, getnetgrent_r, innetgr \- +handle network group entries +.sh synopsis +.nf +.b #include +.pp +.bi "int setnetgrent(const char *" netgroup ); +.b "void endnetgrent(void);" +.pp +.bi "int getnetgrent(char **restrict " host , +.bi " char **restrict " user ", char **restrict " domain ); +.bi "int getnetgrent_r(char **restrict " host , +.bi " char **restrict " user ", char **restrict " domain , +.bi " char *restrict " buf ", size_t " buflen ); +.pp +.bi "int innetgr(const char *" netgroup ", const char *" host , +.bi " const char *" user ", const char *" domain ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.ad l +.pp +.nh +.br setnetgrent (), +.br endnetgrent (), +.br getnetgrent (), +.br getnetgrent_r (), +.br innetgr (): +.hy +.nf + since glibc 2.19: + _default_source + glibc 2.19 and earlier: + _bsd_source || _svid_source +.fi +.ad +.sh description +the +.i netgroup +is a sunos invention. +a netgroup database is a list of string triples +.ri ( hostname ", " username ", " domainname ) +or other netgroup names. +any of the elements in a triple can be empty, +which means that anything matches. +the functions described here allow access to the netgroup databases. +the file +.i /etc/nsswitch.conf +defines what database is searched. +.pp +the +.br setnetgrent () +call defines the netgroup that will be searched by subsequent +.br getnetgrent () +calls. +the +.br getnetgrent () +function retrieves the next netgroup entry, and returns pointers in +.ir host , +.ir user , +.ir domain . +a null pointer means that the corresponding entry matches any string. +the pointers are valid only as long as there is no call to other +netgroup-related functions. +to avoid this problem you can use the gnu function +.br getnetgrent_r () +that stores the strings in the supplied buffer. +to free all allocated buffers use +.br endnetgrent (). +.pp +in most cases you want to check only if the triplet +.ri ( hostname ", " username ", " domainname ) +is a member of a netgroup. +the function +.br innetgr () +can be used for this without calling the above three functions. +again, a null pointer is a wildcard and matches any string. +the function is thread-safe. +.sh return value +these functions return 1 on success and 0 for failure. +.sh files +.i /etc/netgroup +.br +.i /etc/nsswitch.conf +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lb lb lbx +l l l. +interface attribute value +t{ +.br setnetgrent (), +.br getnetgrent_r (), +.br innetgr () +t} thread safety t{ +mt-unsafe race:netgrent +locale +t} +t{ +.br endnetgrent () +t} thread safety t{ +mt-unsafe race:netgrent +t} +t{ +.br getnetgrent () +t} thread safety t{ +mt-unsafe race:netgrent +race:netgrentbuf locale +t} +.te +.hy +.ad +.sp 1 +in the above table, +.i netgrent +in +.i race:netgrent +signifies that if any of the functions +.br setnetgrent (), +.br getnetgrent_r (), +.br innetgr (), +.br getnetgrent (), +or +.br endnetgrent () +are used in parallel in different threads of a program, +then data races could occur. +.sh conforming to +these functions are not in posix.1, but +.br setnetgrent (), +.br endnetgrent (), +.br getnetgrent (), +and +.br innetgr () +are available on most unix systems. +.br getnetgrent_r () +is not widely available on other systems. +.\" getnetgrent_r() is on solaris 8 and aix 5.1, but not the bsds. +.sh notes +in the bsd implementation, +.br setnetgrent () +returns void. +.sh see also +.br sethostent (3), +.br setprotoent (3), +.br setservent (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2006 andrew morton +.\" and copyright 2006 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" 2006-07-05 initial creation, michael kerrisk based on +.\" andrew morton's comments in fs/sync.c +.\" 2010-10-09, mtk, document sync_file_range2() +.\" +.th sync_file_range 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +sync_file_range \- sync a file segment with disk +.sh synopsis +.nf +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "int sync_file_range(int " fd ", off64_t " offset ", off64_t " nbytes , +.bi " unsigned int " flags ); +.fi +.sh description +.br sync_file_range () +permits fine control when synchronizing the open file referred to by the +file descriptor +.i fd +with disk. +.pp +.i offset +is the starting byte of the file range to be synchronized. +.i nbytes +specifies the length of the range to be synchronized, in bytes; if +.i nbytes +is zero, then all bytes from +.i offset +through to the end of file are synchronized. +synchronization is in units of the system page size: +.i offset +is rounded down to a page boundary; +.i (offset+nbytes\-1) +is rounded up to a page boundary. +.pp +the +.i flags +bit-mask argument can include any of the following values: +.tp +.b sync_file_range_wait_before +wait upon write-out of all pages in the specified range +that have already been submitted to the device driver for write-out +before performing any write. +.tp +.b sync_file_range_write +initiate write-out of all dirty pages in the specified +range which are not presently submitted write-out. +note that even this may block if you attempt to +write more than request queue size. +.tp +.b sync_file_range_wait_after +wait upon write-out of all pages in the range +after performing any write. +.pp +specifying +.i flags +as 0 is permitted, as a no-op. +.ss warning +this system call is extremely dangerous and should not be used in portable +programs. +none of these operations writes out the file's metadata. +therefore, unless the application is strictly performing overwrites of +already-instantiated disk blocks, there are no guarantees that the data will +be available after a crash. +there is no user interface to know if a write is purely an overwrite. +on filesystems using copy-on-write semantics (e.g., +.ir btrfs ) +an overwrite of existing allocated blocks is impossible. +when writing into preallocated space, +many filesystems also require calls into the block +allocator, which this system call does not sync out to disk. +this system call does not flush disk write caches and thus does not provide +any data integrity on systems with volatile disk write caches. +.ss some details +.b sync_file_range_wait_before +and +.b sync_file_range_wait_after +will detect any +i/o errors or +.b enospc +conditions and will return these to the caller. +.pp +useful combinations of the +.i flags +bits are: +.tp +.b sync_file_range_wait_before | sync_file_range_write +ensures that all pages +in the specified range which were dirty when +.br sync_file_range () +was called are placed +under write-out. +this is a start-write-for-data-integrity operation. +.tp +.b sync_file_range_write +start write-out of all dirty pages in the specified range which +are not presently under write-out. +this is an asynchronous flush-to-disk +operation. +this is not suitable for data integrity operations. +.tp +.br sync_file_range_wait_before " (or " sync_file_range_wait_after ) +wait for +completion of write-out of all pages in the specified range. +this can be used after an earlier +.b sync_file_range_wait_before | sync_file_range_write +operation to wait for completion of that operation, and obtain its result. +.tp +.b sync_file_range_wait_before | sync_file_range_write | \ +sync_file_range_wait_after +this is a write-for-data-integrity operation +that will ensure that all pages in the specified range which were dirty when +.br sync_file_range () +was called are committed to disk. +.sh return value +on success, +.br sync_file_range () +returns 0; on failure \-1 is returned and +.i errno +is set to indicate the error. +.sh errors +.tp +.b ebadf +.i fd +is not a valid file descriptor. +.tp +.b einval +.i flags +specifies an invalid bit; or +.i offset +or +.i nbytes +is invalid. +.tp +.b eio +i/o error. +.tp +.b enomem +out of memory. +.tp +.b enospc +out of disk space. +.tp +.b espipe +.i fd +refers to something other than a regular file, a block device, or +a directory. +.sh versions +.br sync_file_range () +appeared on linux in kernel 2.6.17. +.sh conforming to +this system call is linux-specific, and should be avoided +in portable programs. +.sh notes +.ss sync_file_range2() +some architectures (e.g., powerpc, arm) +need 64-bit arguments to be aligned in a suitable pair of registers. +.\" see kernel commit edd5cd4a9424f22b0fa08bef5e299d41befd5622 +on such architectures, the call signature of +.br sync_file_range () +shown in the synopsis would force +a register to be wasted as padding between the +.i fd +and +.i offset +arguments. +(see +.br syscall (2) +for details.) +therefore, these architectures define a different +system call that orders the arguments suitably: +.pp +.in +4n +.ex +.bi "int sync_file_range2(int " fd ", unsigned int " flags , +.bi " off64_t " offset ", off64_t " nbytes ); +.ee +.in +.pp +the behavior of this system call is otherwise exactly the same as +.br sync_file_range (). +.pp +a system call with this signature first appeared on the arm architecture +in linux 2.6.20, with the name +.br arm_sync_file_range (). +it was renamed in linux 2.6.22, +when the analogous system call was added for powerpc. +on architectures where glibc support is provided, +glibc transparently wraps +.br sync_file_range2 () +under the name +.br sync_file_range (). +.sh see also +.br fdatasync (2), +.br fsync (2), +.br msync (2), +.br sync (2) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/fgetwc.3 + +.so man2/lchown.2 + +.\" copyright (c) 2010 intel corporation, author: andi kleen +.\" and copyright 2014, vivek goyal +.\" and copyright (c) 2015, michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th kexec_load 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +kexec_load, kexec_file_load \- load a new kernel for later execution +.sh synopsis +.nf +.br "#include " " /* definition of " kexec_* " constants */" +.br "#include " " /* definition of " sys_* " constants */" +.b #include +.pp +.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 : +glibc provides no wrappers for these system calls, +necessitating the use of +.br syscall (2). +.sh description +the +.br kexec_load () +system call loads a new kernel that can be executed later by +.br reboot (2). +.pp +the +.i flags +argument is a bit mask that controls the operation of the call. +the following values can be specified in +.ir flags : +.tp +.br kexec_on_crash " (since linux 2.6.13)" +execute the new kernel automatically on a system crash. +this "crash kernel" is loaded into an area of reserved memory that +is determined at boot time using the +.i crashkernel +kernel command-line parameter. +the location of this reserved memory is exported to user space via the +.i /proc/iomem +file, in an entry labeled "crash kernel". +a user-space application can parse this file and prepare a list of +segments (see below) that specify this reserved memory as destination. +if this flag is specified, the kernel checks that the +target segments specified in +.i segments +fall within the reserved region. +.tp +.br kexec_preserve_context " (since linux 2.6.27)" +preserve the system hardware and +software states before executing the new kernel. +this could be used for system suspend. +this flag is available only if the kernel was configured with +.br config_kexec_jump , +and is effective only if +.i nr_segments +is greater than 0. +.pp +the high-order bits (corresponding to the mask 0xffff0000) of +.i flags +contain the architecture of the to-be-executed kernel. +specify (or) the constant +.b kexec_arch_default +to use the current architecture, +or one of the following architecture constants +.br kexec_arch_386 , +.br kexec_arch_68k , +.br kexec_arch_x86_64 , +.br kexec_arch_ppc , +.br kexec_arch_ppc64 , +.br kexec_arch_ia_64 , +.br kexec_arch_arm , +.br kexec_arch_s390 , +.br kexec_arch_sh , +.br kexec_arch_mips , +and +.br kexec_arch_mips_le . +the architecture must be executable on the cpu of the system. +.pp +the +.i entry +argument is the physical entry address in the kernel image. +the +.i nr_segments +argument is the number of segments pointed to by the +.i segments +pointer; +the kernel imposes an (arbitrary) limit of 16 on the number of segments. +the +.i segments +argument is an array of +.i kexec_segment +structures which define the kernel layout: +.pp +.in +4n +.ex +struct kexec_segment { + void *buf; /* buffer in user space */ + size_t bufsz; /* buffer length in user space */ + void *mem; /* physical address of kernel */ + size_t memsz; /* physical address length */ +}; +.ee +.in +.pp +the kernel image defined by +.i segments +is copied from the calling process into +the kernel either in regular +memory or in reserved memory (if +.br kexec_on_crash +is set). +the kernel first performs various sanity checks on the +information passed in +.ir segments . +if these checks pass, the kernel copies the segment data to kernel memory. +each segment specified in +.i segments +is copied as follows: +.ip * 3 +.i buf +and +.i bufsz +identify a memory region in the caller's virtual address space +that is the source of the copy. +the value in +.i bufsz +may not exceed the value in the +.i memsz +field. +.ip * +.i mem +and +.i memsz +specify a physical address range that is the target of the copy. +the values specified in both fields must be multiples of +the system page size. +.ip * +.i bufsz +bytes are copied from the source buffer to the target kernel buffer. +if +.i bufsz +is less than +.ir memsz , +then the excess bytes in the kernel buffer are zeroed out. +.pp +in case of a normal kexec (i.e., the +.br kexec_on_crash +flag is not set), the segment data is loaded in any available memory +and is moved to the final destination at kexec reboot time (e.g., when the +.br kexec (8) +command is executed with the +.i \-e +option). +.pp +in case of kexec on panic (i.e., the +.br kexec_on_crash +flag is set), the segment data is +loaded to reserved memory at the time of the call, and, after a crash, +the kexec mechanism simply passes control to that kernel. +.pp +the +.br kexec_load () +system call is available only if the kernel was configured with +.br config_kexec . +.ss kexec_file_load() +the +.br kexec_file_load () +system call is similar to +.br kexec_load (), +but it takes a different set of arguments. +it reads the kernel to be loaded from the file referred to by +the file descriptor +.ir kernel_fd , +and the initrd (initial ram disk) +to be loaded from file referred to by the file descriptor +.ir initrd_fd . +the +.ir cmdline +argument is a pointer to a buffer containing the command line +for the new kernel. +the +.ir cmdline_len +argument specifies size of the buffer. +the last byte in the buffer must be a null byte (\(aq\e0\(aq). +.pp +the +.ir flags +argument is a bit mask which modifies the behavior of the call. +the following values can be specified in +.ir flags : +.tp +.br kexec_file_unload +unload the currently loaded kernel. +.tp +.br kexec_file_on_crash +load the new kernel in the memory region reserved for the crash kernel +(as for +.br kexec_on_crash ). +this kernel is booted if the currently running kernel crashes. +.tp +.br kexec_file_no_initramfs +loading initrd/initramfs is optional. +specify this flag if no initramfs is being loaded. +if this flag is set, the value passed in +.ir initrd_fd +is ignored. +.pp +the +.br kexec_file_load () +.\" see also http://lwn.net/articles/603116/ +system call was added to provide support for systems +where "kexec" loading should be restricted to +only kernels that are signed. +this system call is available only if the kernel was configured with +.br config_kexec_file . +.sh return value +on success, these system calls returns 0. +on error, \-1 is returned and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eaddrnotavail +.\" see kernel/kexec.::sanity_check_segment_list in the 3.19 kernel source +the +.b kexec_on_crash +flags was specified, but the region specified by the +.i mem +and +.i memsz +fields of one of the +.i segments +entries lies outside the range of memory reserved for the crash kernel. +.tp +.b eaddrnotavail +the value in a +.i mem +or +.i memsz +field in one of the +.i segments +entries is not a multiple of the system page size. +.tp +.b ebadf +.i kernel_fd +or +.i initrd_fd +is not a valid file descriptor. +.tp +.b ebusy +another crash kernel is already being loaded +or a crash kernel is already in use. +.tp +.b einval +.i flags +is invalid. +.tp +.b einval +the value of a +.i bufsz +field in one of the +.i segments +entries exceeds the value in the corresponding +.i memsz +field. +.tp +.b einval +.ir nr_segments +exceeds +.br kexec_segment_max +(16). +.tp +.b einval +two or more of the kernel target buffers overlap. +.tp +.b einval +the value in +.i cmdline[cmdline_len\-1] +is not \(aq\e0\(aq. +.tp +.b einval +the file referred to by +.i kernel_fd +or +.i initrd_fd +is empty (length zero). +.tp +.b enoexec +.i kernel_fd +does not refer to an open file, or the kernel can't load this file. +currently, the file must be a bzimage and contain an x86 kernel that +is loadable above 4\ gib in memory (see the kernel source file +.ir documentation/x86/boot.txt ). +.tp +.b enomem +could not allocate memory. +.tp +.b eperm +the caller does not have the +.br cap_sys_boot +capability. +.sh versions +the +.br kexec_load () +system call first appeared in linux 2.6.13. +the +.br kexec_file_load () +system call first appeared in linux 3.17. +.sh conforming to +these system calls are linux-specific. +.sh see also +.br reboot (2), +.br syscall (2), +.br kexec (8) +.pp +the kernel source files +.ir documentation/kdump/kdump.txt +and +.ir documentation/admin\-guide/kernel\-parameters.txt +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1993 rickard e. faith (faith@cs.unc.edu) +.\" portions extracted from /usr/include/dirent.h are: +.\" copyright 1991, 1992 free software foundation +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th getdirentries 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +getdirentries \- get directory entries in a filesystem-independent format +.sh synopsis +.nf +.b #include +.pp +.bi "ssize_t getdirentries(int " fd ", char *restrict " buf ", size_t " nbytes , +.bi " off_t *restrict " basep ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br getdirentries (): +.nf + since glibc 2.19: + _default_source + glibc 2.19 and earlier: + _bsd_source || _svid_source +.fi +.sh description +read directory entries from the directory specified by +.i fd +into +.ir buf . +at most +.i nbytes +are read. +reading starts at offset +.ir *basep , +and +.i *basep +is updated with the new position after reading. +.sh return value +.br getdirentries () +returns the number of bytes read or zero when at the end of the directory. +if an error occurs, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +see the linux library source code for details. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br getdirentries () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +not in posix.1. +present on the bsds, and a few other systems. +use +.br opendir (3) +and +.br readdir (3) +instead. +.sh see also +.br lseek (2), +.br open (2) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/csinh.3 + +.so man3/rpc.3 + +.so man3/stailq.3 + +.so man3/tsearch.3 + +.so man3/casinh.3 + +.so man3/drand48_r.3 + +.so man3/gsignal.3 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" +.\" modified 1993-07-24 by rik faith (faith@cs.unc.edu) +.\" modified 2003-11-15 by aeb +.\" +.th getgrnam 3 2021-03-22 "" "linux programmer's manual" +.sh name +getgrnam, getgrnam_r, getgrgid, getgrgid_r \- get group file entry +.sh synopsis +.nf +.b #include +.b #include +.pp +.bi "struct group *getgrnam(const char *" name ); +.bi "struct group *getgrgid(gid_t " gid ); +.pp +.bi "int getgrnam_r(const char *restrict " name \ +", struct group *restrict " grp , +.bi " char *restrict " buf ", size_t " buflen , +.bi " struct group **restrict " result ); +.bi "int getgrgid_r(gid_t " gid ", struct group *restrict " grp , +.bi " char *restrict " buf ", size_t " buflen , +.bi " struct group **restrict " result ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br getgrnam_r (), +.br getgrgid_r (): +.nf + _posix_c_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.sh description +the +.br getgrnam () +function returns a pointer to a structure containing +the broken-out fields of the record in the group database +(e.g., the local group file +.ir /etc/group , +nis, and ldap) +that matches the group name +.ir name . +.pp +the +.br getgrgid () +function returns a pointer to a structure containing +the broken-out fields of the record in the group database +that matches the group id +.ir gid . +.pp +the \figroup\fp structure is defined in \fi\fp as follows: +.pp +.in +4n +.ex +struct group { + char *gr_name; /* group name */ + char *gr_passwd; /* group password */ + gid_t gr_gid; /* group id */ + char **gr_mem; /* null\-terminated array of pointers + to names of group members */ +}; +.ee +.in +.pp +for more information about the fields of this structure, see +.br group (5). +.pp +the +.br getgrnam_r () +and +.br getgrgid_r () +functions obtain the same information as +.br getgrnam () +and +.br getgrgid (), +but store the retrieved +.i group +structure +in the space pointed to by +.ir grp . +the string fields pointed to by the members of the +.i group +structure are stored in the buffer +.i buf +of size +.ir buflen . +a pointer to the result (in case of success) or null (in case no entry +was found or an error occurred) is stored in +.ir *result . +.pp +the call +.pp + sysconf(_sc_getgr_r_size_max) +.pp +returns either \-1, without changing +.ir errno , +or an initial suggested size for +.ir buf . +(if this size is too small, +the call fails with +.br erange , +in which case the caller can retry with a larger buffer.) +.sh return value +the +.br getgrnam () +and +.br getgrgid () +functions return a pointer to a +.i group +structure, or null if the matching entry +is not found or an error occurs. +if an error occurs, +.i errno +is set to indicate the error. +if one wants to check +.i errno +after the call, it should be set to zero before the call. +.pp +the return value may point to a static area, and may be overwritten +by subsequent calls to +.br getgrent (3), +.br getgrgid (), +or +.br getgrnam (). +(do not pass the returned pointer to +.br free (3).) +.pp +on success, +.br getgrnam_r () +and +.br getgrgid_r () +return zero, and set +.ir *result +to +.ir grp . +if no matching group record was found, +these functions return 0 and store null in +.ir *result . +in case of error, an error number is returned, and null is stored in +.ir *result . +.sh errors +.tp +.br 0 " or " enoent " or " esrch " or " ebadf " or " eperm " or ..." +the given +.i name +or +.i gid +was not found. +.tp +.b eintr +a signal was caught; see +.br signal (7). +.tp +.b eio +i/o error. +.tp +.b emfile +the per-process limit on the number of open file descriptors has been reached. +.tp +.b enfile +the system-wide limit on the total number of open files has been reached. +.tp +.b enomem +.\" not in posix +insufficient memory to allocate +.i group +structure. +.\" to allocate the group structure, or to allocate buffers +.tp +.b erange +insufficient buffer space supplied. +.sh files +.tp +.i /etc/group +local group database file +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lb lb lbx +l l l. +interface attribute value +t{ +.br getgrnam () +t} thread safety t{ +mt-unsafe race:grnam locale +t} +t{ +.br getgrgid () +t} thread safety t{ +mt-unsafe race:grgid locale +t} +t{ +.br getgrnam_r (), +.br getgrgid_r () +t} thread safety mt-safe locale +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, svr4, 4.3bsd. +.sh notes +the formulation given above under "return value" is from posix.1. +.\" posix.1-2001, posix.1-2008 +it does not call "not found" an error, hence does not specify what value +.i errno +might have in this situation. +but that makes it impossible to recognize +errors. +one might argue that according to posix +.i errno +should be left unchanged if an entry is not found. +experiments on various +unix-like systems show that lots of different values occur in this +situation: 0, enoent, ebadf, esrch, ewouldblock, eperm, and probably others. +.\" more precisely: +.\" aix 5.1 - gives esrch +.\" osf1 4.0g - gives ewouldblock +.\" libc, glibc up to version 2.6, irix 6.5 - give enoent +.\" glibc since version 2.7 - give 0 +.\" freebsd 4.8, openbsd 3.2, netbsd 1.6 - give eperm +.\" sunos 5.8 - gives ebadf +.\" tru64 5.1b, hp-ux-11i, sunos 5.7 - give 0 +.sh see also +.br endgrent (3), +.br fgetgrent (3), +.br getgrent (3), +.br getpwnam (3), +.br setgrent (3), +.br group (5) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/sem_wait.3 + +.so man3/getutent.3 + +.so man3/remainder.3 + +.\" copyright (c) 2014 red hat, inc. all rights reserved. +.\" written by david howells (dhowells@redhat.com) +.\" +.\" %%%license_start(gplv2+_sw_onepara) +.\" this program is free software; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license +.\" as published by the free software foundation; either version +.\" 2 of the license, or (at your option) any later version. +.\" %%%license_end +.\" +.th thread-keyring 7 2020-08-13 linux "linux programmer's manual" +.sh name +thread-keyring \- per-thread keyring +.sh description +the thread keyring is a keyring used to anchor keys on behalf of a process. +it is created only when a thread requests it. +the thread keyring has the name (description) +.ir _tid . +.pp +a special serial number value, +.br key_spec_thread_keyring , +is defined that can be used in lieu of the actual serial number of +the calling thread's thread keyring. +.pp +from the +.br keyctl (1) +utility, '\fb@t\fp' can be used instead of a numeric key id in +much the same way, but as +.br keyctl (1) +is a program run after forking, this is of no utility. +.pp +thread keyrings are not inherited across +.br clone (2) +and +.br fork (2) +and are cleared by +.br execve (2). +a thread keyring is destroyed when the thread that refers to it terminates. +.pp +initially, a thread does not have a thread keyring. +if a thread doesn't have a thread keyring when it is accessed, +then it will be created if it is to be modified; +otherwise the operation fails with the error +.br enokey . +.sh see also +.ad l +.nh +.br keyctl (1), +.br keyctl (3), +.br keyrings (7), +.br persistent\-keyring (7), +.br process\-keyring (7), +.br session\-keyring (7), +.br user\-keyring (7), +.br user\-session\-keyring (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/getrlimit.2 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sat jul 24 21:46:57 1993 by rik faith (faith@cs.unc.edu) +.\" modified 961109, 031115, aeb +.\" +.th getmntent 3 2021-03-22 "" "linux programmer's manual" +.sh name +getmntent, setmntent, addmntent, endmntent, hasmntopt, +getmntent_r \- get filesystem descriptor file entry +.sh synopsis +.nf +.b #include +.b #include +.pp +.bi "file *setmntent(const char *" filename ", const char *" type ); +.pp +.bi "struct mntent *getmntent(file *" stream ); +.pp +.bi "int addmntent(file *restrict " stream , +.bi " const struct mntent *restrict " mnt ); +.pp +.bi "int endmntent(file *" streamp ); +.pp +.bi "char *hasmntopt(const struct mntent *" mnt ", const char *" opt ); +.pp +/* gnu extension */ +.b #include +.pp +.bi "struct mntent *getmntent_r(file *restrict " streamp , +.bi " struct mntent *restrict " mntbuf , +.bi " char *restrict " buf ", int " buflen ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br getmntent_r (): +.nf + since glibc 2.19: + _default_source + glibc 2.19 and earlier: + _bsd_source || _svid_source +.fi +.sh description +these routines are used to access the filesystem description file +.i /etc/fstab +and the mounted filesystem description file +.ir /etc/mtab . +.pp +the +.br setmntent () +function opens the filesystem description file +.i filename +and returns a file pointer which can be used by +.br getmntent (). +the argument +.i type +is the type of access +required and can take the same values as the +.i mode +argument of +.br fopen (3). +the returned stream should be closed using +.br endmntent () +rather than +.br fclose (3). +.pp +the +.br getmntent () +function reads the next line of the filesystem +description file from +.i stream +and returns a pointer to a structure +containing the broken out fields from a line in the file. +the pointer +points to a static area of memory which is overwritten by subsequent +calls to +.br getmntent (). +.pp +the +.br addmntent () +function adds the +.i mntent +structure +.i mnt +to +the end of the open +.ir stream . +.pp +the +.br endmntent () +function closes the +.ir stream +associated with the filesystem description file. +.pp +the +.br hasmntopt () +function scans the +.i mnt_opts +field (see below) +of the +.i mntent +structure +.i mnt +for a substring that matches +.ir opt . +see +.i +and +.br mount (8) +for valid mount options. +.pp +the reentrant +.br getmntent_r () +function is similar to +.br getmntent (), +but stores the +.ir "struct mount" +in the provided +.i *mntbuf +and stores the strings pointed to by the entries in that struct +in the provided array +.i buf +of size +.ir buflen . +.pp +the +.i mntent +structure is defined in +.i +as follows: +.pp +.in +4n +.ex +struct mntent { + char *mnt_fsname; /* name of mounted filesystem */ + char *mnt_dir; /* filesystem path prefix */ + char *mnt_type; /* mount type (see mntent.h) */ + char *mnt_opts; /* mount options (see mntent.h) */ + int mnt_freq; /* dump frequency in days */ + int mnt_passno; /* pass number on parallel fsck */ +}; +.ee +.in +.pp +since fields in the mtab and fstab files are separated by whitespace, +octal escapes are used to represent the characters space (\e040), +tab (\e011), newline (\e012), and backslash (\e\e) in those files +when they occur in one of the four strings in a +.i mntent +structure. +the routines +.br addmntent () +and +.br getmntent () +will convert +from string representation to escaped representation and back. +when converting from escaped representation, the sequence \e134 is +also converted to a backslash. +.sh return value +the +.br getmntent () +and +.br getmntent_r () +functions return +a pointer to the +.i mntent +structure or null on failure. +.pp +the +.br addmntent () +function returns 0 on success and 1 on failure. +.pp +the +.br endmntent () +function always returns 1. +.pp +the +.br hasmntopt () +function returns the address of the substring if +a match is found and null otherwise. +.sh files +.tp +.i /etc/fstab +filesystem description file +.tp +.i /etc/mtab +mounted filesystem description file +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lb lb lbx +l l l. +interface attribute value +t{ +.br setmntent (), +.br endmntent (), +.br hasmntopt () +t} thread safety mt-safe +t{ +.br getmntent () +t} thread safety t{ +mt-unsafe race:mntentbuf locale +t} +t{ +.br addmntent () +t} thread safety t{ +mt-safe race:stream locale +t} +t{ +.br getmntent_r () +t} thread safety mt-safe locale +.te +.hy +.ad +.sp 1 +.sh conforming to +the nonreentrant functions are from sunos 4.1.3. +a routine +.br getmntent_r () +was introduced in hp-ux 10, but it returns an +.ir int . +the prototype shown above is glibc-only. +.sh notes +system v also has a +.br getmntent () +function but the calling sequence +differs, and the returned structure is different. +under system v +.i /etc/mnttab +is used. +4.4bsd and digital unix have a routine +.br getmntinfo (), +a wrapper around the system call +.br getfsstat (). +.sh see also +.br fopen (3), +.br fstab (5), +.br mount (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/drand48_r.3 + +.so man3/rpc.3 + +.so man2/sigaction.2 + +.so man3/tailq.3 + +.\" this man page is copyright (c) 1999 andi kleen . +.\" +.\" %%%license_start(verbatim_one_para) +.\" permission is granted to distribute possibly modified copies +.\" of this page provided the header is included verbatim, +.\" and in case of nontrivial modification author and date +.\" of the modification is added to the header. +.\" %%%license_end +.\" +.\" based on the original comments from alexey kuznetsov, written with +.\" help from matthew wilcox. +.\" $id: rtnetlink.7,v 1.8 2000/01/22 01:55:04 freitag exp $ +.\" +.th rtnetlink 7 2021-03-22 "linux" "linux programmer's manual" +.sh name +rtnetlink \- linux routing socket +.sh synopsis +.nf +.b #include +.b #include +.b #include +.b #include +.pp +.bi "rtnetlink_socket = socket(af_netlink, int " socket_type ", netlink_route);" +.fi +.sh description +rtnetlink allows the kernel's routing tables to be read and altered. +it is used within the kernel to communicate between +various subsystems, though this usage is not documented here, and for +communication with user-space programs. +network routes, ip addresses, link parameters, neighbor setups, queueing +disciplines, traffic classes and packet classifiers may all be controlled +through +.b netlink_route +sockets. +it is based on netlink messages; see +.br netlink (7) +for more information. +.\" fixme . ? all these macros could be moved to rtnetlink(3) +.ss routing attributes +some rtnetlink messages have optional attributes after the initial header: +.pp +.in +4n +.ex +struct rtattr { + unsigned short rta_len; /* length of option */ + unsigned short rta_type; /* type of option */ + /* data follows */ +}; +.ee +.in +.pp +these attributes should be manipulated using only the rta_* macros +or libnetlink, see +.br rtnetlink (3). +.ss messages +rtnetlink consists of these message types +(in addition to standard netlink messages): +.tp +.br rtm_newlink ", " rtm_dellink ", " rtm_getlink +create, remove, or get information about a specific network interface. +these messages contain an +.i ifinfomsg +structure followed by a series of +.i rtattr +structures. +.ip +.ex +struct ifinfomsg { + unsigned char ifi_family; /* af_unspec */ + unsigned short ifi_type; /* device type */ + int ifi_index; /* interface index */ + unsigned int ifi_flags; /* device flags */ + unsigned int ifi_change; /* change mask */ +}; +.ee +.ip +.\" fixme document ifinfomsg.ifi_type +.i ifi_flags +contains the device flags, see +.br netdevice (7); +.i ifi_index +is the unique interface index +(since linux 3.7, it is possible to feed a nonzero value with the +.b rtm_newlink +message, thus creating a link with the given +.ir ifindex ); +.i ifi_change +is reserved for future use and should be always set to 0xffffffff. +.ts +tab(:); +c s s +lb l l. +routing attributes +rta_type:value type:description +_ +ifla_unspec:-:unspecified +ifla_address:hardware address:interface l2 address +ifla_broadcast:hardware address:l2 broadcast address +ifla_ifname:asciiz string:device name +ifla_mtu:unsigned int:mtu of the device +ifla_link:int:link type +ifla_qdisc:asciiz string:queueing discipline +ifla_stats:t{ +see below +t}:interface statistics +.te +.ip +the value type for +.b ifla_stats +is +.ir "struct rtnl_link_stats" +.ri ( "struct net_device_stats" +in linux 2.4 and earlier). +.tp +.br rtm_newaddr ", " rtm_deladdr ", " rtm_getaddr +add, remove, or receive information about an ip address associated with +an interface. +in linux 2.2, an interface can carry multiple ip addresses, +this replaces the alias device concept in 2.0. +in linux 2.2, these messages +support ipv4 and ipv6 addresses. +they contain an +.i ifaddrmsg +structure, optionally followed by +.i rtattr +routing attributes. +.ip +.ex +struct ifaddrmsg { + unsigned char ifa_family; /* address type */ + unsigned char ifa_prefixlen; /* prefixlength of address */ + unsigned char ifa_flags; /* address flags */ + unsigned char ifa_scope; /* address scope */ + unsigned int ifa_index; /* interface index */ +}; +.ee +.ip +.i ifa_family +is the address family type (currently +.b af_inet +or +.br af_inet6 ), +.i ifa_prefixlen +is the length of the address mask of the address if defined for the +family (like for ipv4), +.i ifa_scope +is the address scope, +.i ifa_index +is the interface index of the interface the address is associated with. +.i ifa_flags +is a flag word of +.b ifa_f_secondary +for secondary address (old alias interface), +.b ifa_f_permanent +for a permanent address set by the user and other undocumented flags. +.ts +tab(:); +c s s +lb l l. +attributes +rta_type:value type:description +_ +ifa_unspec:-:unspecified +ifa_address:raw protocol address:interface address +ifa_local:raw protocol address:local address +ifa_label:asciiz string:name of the interface +ifa_broadcast:raw protocol address:broadcast address +ifa_anycast:raw protocol address:anycast address +ifa_cacheinfo:struct ifa_cacheinfo:address information +.te +.\" fixme document struct ifa_cacheinfo +.tp +.br rtm_newroute ", " rtm_delroute ", " rtm_getroute +create, remove, or receive information about a network route. +these messages contain an +.i rtmsg +structure with an optional sequence of +.i rtattr +structures following. +for +.br rtm_getroute , +setting +.i rtm_dst_len +and +.i rtm_src_len +to 0 means you get all entries for the specified routing table. +for the other fields, except +.i rtm_table +and +.ir rtm_protocol , +0 is the wildcard. +.ip +.ex +struct rtmsg { + unsigned char rtm_family; /* address family of route */ + unsigned char rtm_dst_len; /* length of destination */ + unsigned char rtm_src_len; /* length of source */ + unsigned char rtm_tos; /* tos filter */ + unsigned char rtm_table; /* routing table id; + see rta_table below */ + unsigned char rtm_protocol; /* routing protocol; see below */ + unsigned char rtm_scope; /* see below */ + unsigned char rtm_type; /* see below */ + + unsigned int rtm_flags; +}; +.ee +.ts +tab(:); +lb l. +rtm_type:route type +_ +rtn_unspec:unknown route +rtn_unicast:a gateway or direct route +rtn_local:a local interface route +rtn_broadcast:t{ +a local broadcast route (sent as a broadcast) +t} +rtn_anycast:t{ +a local broadcast route (sent as a unicast) +t} +rtn_multicast:a multicast route +rtn_blackhole:a packet dropping route +rtn_unreachable:an unreachable destination +rtn_prohibit:a packet rejection route +rtn_throw:continue routing lookup in another table +rtn_nat:a network address translation rule +rtn_xresolve:t{ +refer to an external resolver (not implemented) +t} +.te +.ts +tab(:); +lb l. +rtm_protocol:route origin +_ +rtprot_unspec:unknown +rtprot_redirect:t{ +by an icmp redirect (currently unused) +t} +rtprot_kernel:by the kernel +rtprot_boot:during boot +rtprot_static:by the administrator +.te +.sp 1 +values larger than +.b rtprot_static +are not interpreted by the kernel, they are just for user information. +they may be used to tag the source of a routing information or to +distinguish between multiple routing daemons. +see +.i +for the routing daemon identifiers which are already assigned. +.ip +.i rtm_scope +is the distance to the destination: +.ts +tab(:); +lb l. +rt_scope_universe:global route +rt_scope_site:t{ +interior route in the local autonomous system +t} +rt_scope_link:route on this link +rt_scope_host:route on the local host +rt_scope_nowhere:destination doesn't exist +.te +.sp 1 +the values between +.b rt_scope_universe +and +.b rt_scope_site +are available to the user. +.ip +the +.i rtm_flags +have the following meanings: +.ts +tab(:); +lb l. +rtm_f_notify:t{ +if the route changes, notify the user via rtnetlink +t} +rtm_f_cloned:route is cloned from another route +rtm_f_equalize:a multipath equalizer (not yet implemented) +.te +.sp 1 +.i rtm_table +specifies the routing table +.ts +tab(:); +lb l. +rt_table_unspec:an unspecified routing table +rt_table_default:the default table +rt_table_main:the main table +rt_table_local:the local table +.te +.sp 1 +the user may assign arbitrary values between +.b rt_table_unspec +and +.br rt_table_default . +.\" keep table on same page +.bp +1 +.ts +tab(:); +c s s +lb2 l2 l. +attributes +rta_type:value type:description +_ +rta_unspec:-:ignored +rta_dst:protocol address:route destination address +rta_src:protocol address:route source address +rta_iif:int:input interface index +rta_oif:int:output interface index +rta_gateway:protocol address:the gateway of the route +rta_priority:int:priority of route +rta_prefsrc:protocol address:preferred source address +rta_metrics:int:route metric +rta_multipath::t{ +multipath nexthop data +br +(see below). +t} +rta_protoinfo::no longer used +rta_flow:int:route realm +rta_cacheinfo:struct rta_cacheinfo:(see linux/rtnetlink.h) +rta_session::no longer used +rta_mp_algo::no longer used +rta_table:int:t{ +routing table id; if set, +.br +rtm_table is ignored +t} +rta_mark:int: +rta_mfc_stats:struct rta_mfc_stats:(see linux/rtnetlink.h) +rta_via:struct rtvia:t{ +gateway in different af +(see below) +t} +rta_newdst:protocol address:t{ +change packet +destination address +t} +rta_pref:char:t{ +rfc4191 ipv6 router +preference (see below) +t} +rta_encap_type:short:t{ +encapsulation type for +.br +lwtunnels (see below) +t} +rta_encap::defined by rta_encap_type +rta_expires:int:t{ +expire time for ipv6 +routes (in seconds) +t} +.te +.ip +.b rta_multipath +contains several packed instances of +.i struct rtnexthop +together with nested rtas +.rb ( rta_gateway ): +.ip +.in +4n +.ex +struct rtnexthop { + unsigned short rtnh_len; /* length of struct + length + of rtas */ + unsigned char rtnh_flags; /* flags (see + linux/rtnetlink.h) */ + unsigned char rtnh_hops; /* nexthop priority */ + int rtnh_ifindex; /* interface index for this + nexthop */ +} +.ee +.in +.ip +there exist a bunch of +.b rtnh_* +macros similar to +.b rta_* +and +.b nlhdr_* +macros +useful to handle these structures. +.ip +.in +4n +.ex +struct rtvia { + unsigned short rtvia_family; + unsigned char rtvia_addr[0]; +}; +.ee +.in +.ip +.i rtvia_addr +is the address, +.i rtvia_family +is its family type. +.ip +.b rta_pref +may contain values +.br icmpv6_router_pref_low , +.br icmpv6_router_pref_medium , +and +.br icmpv6_router_pref_high +defined incw +.ir . +.ip +.b rta_encap_type +may contain values +.br lwtunnel_encap_mpls , +.br lwtunnel_encap_ip , +.br lwtunnel_encap_ila , +or +.br lwtunnel_encap_ip6 +defined in +.ir . +.ip +.b fill these values in! +.tp +.br rtm_newneigh ", " rtm_delneigh ", " rtm_getneigh +add, remove, or receive information about a neighbor table +entry (e.g., an arp entry). +the message contains an +.i ndmsg +structure. +.ip +.ex +struct ndmsg { + unsigned char ndm_family; + int ndm_ifindex; /* interface index */ + __u16 ndm_state; /* state */ + __u8 ndm_flags; /* flags */ + __u8 ndm_type; +}; + +struct nda_cacheinfo { + __u32 ndm_confirmed; + __u32 ndm_used; + __u32 ndm_updated; + __u32 ndm_refcnt; +}; +.ee +.ip +.i ndm_state +is a bit mask of the following states: +.ts +tab(:); +lb l. +nud_incomplete:a currently resolving cache entry +nud_reachable:a confirmed working cache entry +nud_stale:an expired cache entry +nud_delay:an entry waiting for a timer +nud_probe:a cache entry that is currently reprobed +nud_failed:an invalid cache entry +nud_noarp:a device with no destination cache +nud_permanent:a static entry +.te +.sp 1 +valid +.i ndm_flags +are: +.ts +tab(:); +lb l. +ntf_proxy:a proxy arp entry +ntf_router:an ipv6 router +.te +.sp 1 +.\" fixme . +.\" document the members of the struct better +the +.i rtattr +struct has the following meanings for the +.i rta_type +field: +.ts +tab(:); +lb l. +nda_unspec:unknown type +nda_dst:a neighbor cache n/w layer destination address +nda_lladdr:a neighbor cache link layer address +nda_cacheinfo:cache statistics +.te +.sp 1 +if the +.i rta_type +field is +.br nda_cacheinfo , +then a +.i struct nda_cacheinfo +header follows. +.tp +.br rtm_newrule ", " rtm_delrule ", " rtm_getrule +add, delete, or retrieve a routing rule. +carries a +.i struct rtmsg +.tp +.br rtm_newqdisc ", " rtm_delqdisc ", " rtm_getqdisc +add, remove, or get a queueing discipline. +the message contains a +.i struct tcmsg +and may be followed by a series of +attributes. +.ip +.ex +struct tcmsg { + unsigned char tcm_family; + int tcm_ifindex; /* interface index */ + __u32 tcm_handle; /* qdisc handle */ + __u32 tcm_parent; /* parent qdisc */ + __u32 tcm_info; +}; +.ee +.ts +tab(:); +c s s +lb2 l2 l. +attributes +rta_type:value type:description +_ +tca_unspec:-:unspecified +tca_kind:asciiz string:name of queueing discipline +tca_options:byte sequence:qdisc-specific options follow +tca_stats:struct tc_stats:qdisc statistics +tca_xstats:qdisc-specific:module-specific statistics +tca_rate:struct tc_estimator:rate limit +.te +.sp 1 +in addition, various other qdisc-module-specific attributes are allowed. +for more information see the appropriate include files. +.tp +.br rtm_newtclass ", " rtm_deltclass ", " rtm_gettclass +add, remove, or get a traffic class. +these messages contain a +.i struct tcmsg +as described above. +.tp +.br rtm_newtfilter ", " rtm_deltfilter ", " rtm_gettfilter +add, remove, or receive information about a traffic filter. +these messages contain a +.i struct tcmsg +as described above. +.sh versions +.b rtnetlink +is a new feature of linux 2.2. +.sh bugs +this manual page is incomplete. +.sh see also +.br cmsg (3), +.br rtnetlink (3), +.br ip (7), +.br netlink (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" iso/iec 9899:1999 +.\" +.th wcscat 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +wcscat \- concatenate two wide-character strings +.sh synopsis +.nf +.b #include +.pp +.bi "wchar_t *wcscat(wchar_t *restrict " dest \ +", const wchar_t *restrict " src ); +.fi +.sh description +the +.br wcscat () +function is the wide-character equivalent +of the +.br strcat (3) +function. +it copies the wide-character string pointed to by +.ir src , +including the terminating null wide character (l\(aq\e0\(aq), +to the end of the wide-character string pointed to by +.ir dest . +.pp +the strings may not overlap. +.pp +the programmer must ensure that there is room for at least +.ir wcslen(dest) + wcslen(src) +1 +wide characters at +.ir dest . +.sh return value +.br wcscat () +returns +.ir dest . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br wcscat () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh see also +.br strcat (3), +.br wcpcpy (3), +.br wcscpy (3), +.br wcsncat (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man4/mem.4 + +.so man3/bswap.3 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sat jul 24 18:54:45 1993 by rik faith (faith@cs.unc.edu) +.th memfrob 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +memfrob \- frobnicate (encrypt) a memory area +.sh synopsis +.nf +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "void *memfrob(void *" s ", size_t " n ); +.fi +.sh description +the +.br memfrob () +function encrypts the first \fin\fp bytes of the +memory area \fis\fp by exclusive-oring each character with the number +42. +the effect can be reversed by using +.br memfrob () +on the +encrypted memory area. +.pp +note that this function is not a proper encryption routine as the xor +constant is fixed, and is suitable only for hiding strings. +.sh return value +the +.br memfrob () +function returns a pointer to the encrypted memory +area. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br memfrob () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +the +.br memfrob () +function is unique to the +gnu c library. +.sh see also +.br bstring (3), +.br strfry (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/pthread_attr_setsigmask_np.3 + +.\" copyright (c) 2014 red hat, inc. all rights reserved. +.\" written by david howells (dhowells@redhat.com) +.\" +.\" %%%license_start(gplv2+_sw_onepara) +.\" this program is free software; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license +.\" as published by the free software foundation; either version +.\" 2 of the license, or (at your option) any later version. +.\" %%%license_end +.\" +.th user-keyring 7 2020-08-13 linux "linux programmer's manual" +.sh name +user-keyring \- per-user keyring +.sh description +the user keyring is a keyring used to anchor keys on behalf of a user. +each uid the kernel deals with has its own user keyring that +is shared by all processes with that uid. +the user keyring has a name (description) of the form +.i _uid. +where +.i +is the user id of the corresponding user. +.pp +the user keyring is associated with the record that the kernel maintains +for the uid. +it comes into existence upon the first attempt to access either the +user keyring, the +.br user\-session\-keyring (7), +or the +.br session\-keyring (7). +the keyring remains pinned in existence so long as there are processes +running with that real uid or files opened by those processes remain open. +(the keyring can also be pinned indefinitely by linking it +into another keyring.) +.pp +typically, the user keyring is created by +.br pam_keyinit (8) +when a user logs in. +.pp +the user keyring is not searched by default by +.br request_key (2). +when +.br pam_keyinit (8) +creates a session keyring, it adds to it a link to the user +keyring so that the user keyring will be searched when the session keyring is. +.pp +a special serial number value, +.br key_spec_user_keyring , +is defined that can be used in lieu of the actual serial number of +the calling process's user keyring. +.pp +from the +.br keyctl (1) +utility, '\fb@u\fp' can be used instead of a numeric key id in +much the same way. +.pp +user keyrings are independent of +.br clone (2), +.br fork (2), +.br vfork (2), +.br execve (2), +and +.br _exit (2) +excepting that the keyring is destroyed when the uid record is destroyed when +the last process pinning it exits. +.pp +if it is necessary for a key associated with a user to exist beyond the uid +record being garbage collected\(emfor example, for use by a +.br cron (8) +script\(emthen the +.br persistent\-keyring (7) +should be used instead. +.pp +if a user keyring does not exist when it is accessed, it will be created. +.sh see also +.ad l +.nh +.br keyctl (1), +.br keyctl (3), +.br keyrings (7), +.br persistent\-keyring (7), +.br process\-keyring (7), +.br session\-keyring (7), +.br thread\-keyring (7), +.br user\-session\-keyring (7), +.br pam_keyinit (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/printf.3 + +.\" copyright (c) 1993 by thomas koenig (ig25@rz.uni-karlsruhe.de) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified sat jul 24 19:10:00 1993 by rik faith (faith@cs.unc.edu) +.\" modified sun aug 21 17:51:50 1994 by rik faith (faith@cs.unc.edu) +.\" modified sat sep 2 21:52:01 1995 by jim van zandt +.\" modified mon may 27 22:55:26 1996 by martin schulze (joey@linux.de) +.\" +.th isalpha 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +isalnum, isalpha, isascii, isblank, iscntrl, isdigit, isgraph, islower, +isprint, ispunct, isspace, isupper, isxdigit, +isalnum_l, isalpha_l, isascii_l, isblank_l, iscntrl_l, +isdigit_l, isgraph_l, islower_l, +isprint_l, ispunct_l, isspace_l, isupper_l, isxdigit_l +\- character classification functions +.sh synopsis +.nf +.b #include +.pp +.bi "int isalnum(int " c ); +.bi "int isalpha(int " c ); +.bi "int iscntrl(int " c ); +.bi "int isdigit(int " c ); +.bi "int isgraph(int " c ); +.bi "int islower(int " c ); +.bi "int isprint(int " c ); +.bi "int ispunct(int " c ); +.bi "int isspace(int " c ); +.bi "int isupper(int " c ); +.bi "int isxdigit(int " c ); +.pp +.bi "int isascii(int " c ); +.bi "int isblank(int " c ); +.pp +.bi "int isalnum_l(int " c ", locale_t " locale ); +.bi "int isalpha_l(int " c ", locale_t " locale ); +.bi "int isblank_l(int " c ", locale_t " locale ); +.bi "int iscntrl_l(int " c ", locale_t " locale ); +.bi "int isdigit_l(int " c ", locale_t " locale ); +.bi "int isgraph_l(int " c ", locale_t " locale ); +.bi "int islower_l(int " c ", locale_t " locale ); +.bi "int isprint_l(int " c ", locale_t " locale ); +.bi "int ispunct_l(int " c ", locale_t " locale ); +.bi "int isspace_l(int " c ", locale_t " locale ); +.bi "int isupper_l(int " c ", locale_t " locale ); +.bi "int isxdigit_l(int " c ", locale_t " locale ); +.pp +.bi "int isascii_l(int " c ", locale_t " locale ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.ad l +.pp +.br isascii (): +.nf + _xopen_source + || /* glibc since 2.19: */ _default_source + || /* glibc <= 2.19: */ _svid_source +.fi +.pp +.br isblank (): +.nf + _isoc99_source || _posix_c_source >= 200112l +.fi +.nh +.pp +.br isalnum_l (), +.br isalpha_l (), +.br isblank_l (), +.br iscntrl_l (), +.br isdigit_l (), +.br isgraph_l (), +.br islower_l (), +.br isprint_l (), +.br ispunct_l (), +.br isspace_l (), +.br isupper_l (), +.br isxdigit_l (): +.hy +.nf + since glibc 2.10: + _xopen_source >= 700 + before glibc 2.10: + _gnu_source +.fi +.pp +.br isascii_l (): +.nf + since glibc 2.10: + _xopen_source >= 700 && (_svid_source || _bsd_source) + before glibc 2.10: + _gnu_source +.fi +.ad +.sh description +these functions check whether +.ir c , +which must have the value of an +.i unsigned char +or +.br eof , +falls into a certain character class according to the specified locale. +the functions without the +"_l" suffix perform the check based on the current locale. +.pp +the functions with the "_l" suffix perform the check +based on the locale specified by the locale object +.ir locale . +the behavior of these functions is undefined if +.i locale +is the special locale object +.b lc_global_locale +(see +.br duplocale (3)) +or is not a valid locale object handle. +.pp +the list below explains the operation of the functions without +the "_l" suffix; +the functions with the "_l" suffix differ only in using the locale object +.i locale +instead of the current locale. +.tp +.br isalnum () +checks for an alphanumeric character; it is equivalent to +.bi "(isalpha(" c ") || isdigit(" c "))" \fr. +.tp +.br isalpha () +checks for an alphabetic character; in the standard \fb"c"\fp +locale, it is equivalent to +.bi "(isupper(" c ") || islower(" c "))" \fr. +in some locales, there may be additional characters for which +.br isalpha () +is true\(emletters which are neither uppercase nor lowercase. +.tp +.br isascii () +checks whether \fic\fp is a 7-bit +.i unsigned char +value that fits into +the ascii character set. +.tp +.br isblank () +checks for a blank character; that is, a space or a tab. +.tp +.br iscntrl () +checks for a control character. +.tp +.br isdigit () +checks for a digit (0 through 9). +.tp +.br isgraph () +checks for any printable character except space. +.tp +.br islower () +checks for a lowercase character. +.tp +.br isprint () +checks for any printable character including space. +.tp +.br ispunct () +checks for any printable character which is not a space or an +alphanumeric character. +.tp +.br isspace () +checks for white-space characters. +in the +.b """c""" +and +.b """posix""" +locales, these are: space, form-feed +.rb ( \(aq\ef\(aq ), +newline +.rb ( \(aq\en\(aq ), +carriage return +.rb ( \(aq\er\(aq ), +horizontal tab +.rb ( \(aq\et\(aq ), +and vertical tab +.rb ( \(aq\ev\(aq ). +.tp +.br isupper () +checks for an uppercase letter. +.tp +.br isxdigit () +checks for hexadecimal digits, that is, one of +.br +.br "0 1 2 3 4 5 6 7 8 9 a b c d e f a b c d e f" . +.sh return value +the values returned are nonzero if the character +.i c +falls into the tested class, and zero if not. +.sh versions +.br isalnum_l (), +.br isalpha_l (), +.br isblank_l (), +.br iscntrl_l (), +.br isdigit_l (), +.br isgraph_l (), +.br islower_l (), +.br isprint_l (), +.br ispunct_l (), +.br isspace_l (), +.br isupper_l (), +.br isxdigit_l (), +and +.br isascii_l () +are available since glibc 2.3. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br isalnum (), +.br isalpha (), +.br isascii (), +.br isblank (), +.br iscntrl (), +.br isdigit (), +.br isgraph (), +.br islower (), +.br isprint (), +.br ispunct (), +.br isspace (), +.br isupper (), +.br isxdigit () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.\" fixme: need a thread-safety statement about the *_l functions +.sh conforming to +c89 specifies +.br isalnum (), +.br isalpha (), +.br iscntrl (), +.br isdigit (), +.br isgraph (), +.br islower (), +.br isprint (), +.br ispunct (), +.br isspace (), +.br isupper (), +and +.br isxdigit (), +but not +.br isascii () +and +.br isblank (). +posix.1-2001 +also specifies those functions, and also +.br isascii () +(as an xsi extension) +and +.br isblank (). +c99 specifies all of the preceding functions, except +.br isascii (). +.pp +posix.1-2008 marks +.br isascii () +as obsolete, +noting that it cannot be used portably in a localized application. +.pp +posix.1-2008 specifies +.br isalnum_l (), +.br isalpha_l (), +.br isblank_l (), +.br iscntrl_l (), +.br isdigit_l (), +.br isgraph_l (), +.br islower_l (), +.br isprint_l (), +.br ispunct_l (), +.br isspace_l (), +.br isupper_l (), +and +.br isxdigit_l (). +.pp +.br isascii_l () +is a gnu extension. +.sh notes +the standards require that the argument +.i c +for these functions is either +.b eof +or a value that is representable in the type +.ir "unsigned char" . +if the argument +.i c +is of type +.ir char , +it must be cast to +.ir "unsigned char" , +as in the following example: +.pp +.in +4n +.ex +char c; +\&... +res = toupper((unsigned char) c); +.ee +.in +.pp +this is necessary because +.i char +may be the equivalent of +.ir "signed char" , +in which case a byte where the top bit is set would be sign extended when +converting to +.ir int , +yielding a value that is outside the range of +.ir "unsigned char" . +.pp +the details of what characters belong to which class depend on the +locale. +for example, +.br isupper () +will not recognize an a-umlaut (\(:a) as an uppercase letter in the default +.b "c" +locale. +.sh see also +.br iswalnum (3), +.br iswalpha (3), +.br iswblank (3), +.br iswcntrl (3), +.br iswdigit (3), +.br iswgraph (3), +.br iswlower (3), +.br iswprint (3), +.br iswpunct (3), +.br iswspace (3), +.br iswupper (3), +.br iswxdigit (3), +.br newlocale (3), +.br setlocale (3), +.br toascii (3), +.br tolower (3), +.br toupper (3), +.br uselocale (3), +.br ascii (7), +.br locale (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +import os +import glob +import random + +# navigate to the directory +data_dir = '/media/external/man-pages-dataset/man-pages-5.13' +os.chdir(data_dir) + +# function to preprocess the text +def preprocess_text(file_path): + try: + with open(file_path, 'r', encoding='utf-8') as file: + text = file.read() + # simple preprocessing (e.g., lowercase conversion) + text = text.lower() + return text + except exception as e: + print(f'failed to process {file_path}: {e}') + return none + +# collect and preprocess the data +all_data = [] +file_paths = glob.glob('**/*', recursive=true) # adjusted this line to match all files +print(f'found {len(file_paths)} files.') + +for file_path in file_paths: + preprocessed_text = preprocess_text(file_path) + if preprocessed_text is not none: + all_data.append(preprocessed_text) + +print(f'processed {len(all_data)} files.') + +# shuffle and split the data +random.shuffle(all_data) +train_size = int(0.8 * len(all_data)) +train_data, val_test_data = all_data[:train_size], all_data[train_size:] +val_size = int(0.5 * len(val_test_data)) +val_data, test_data = val_test_data[:val_size], val_test_data[val_size:] + +# save the preprocessed data +output_dir = os.path.join(data_dir, 'preprocessed_data') +os.makedirs(output_dir, exist_ok=true) + +with open(os.path.join(output_dir, 'train.txt'), 'w', encoding='utf-8') as file: + file.write('\n'.join(train_data)) +with open(os.path.join(output_dir, 'val.txt'), 'w', encoding='utf-8') as file: + file.write('\n'.join(val_data)) +with open(os.path.join(output_dir, 'test.txt'), 'w', encoding='utf-8') as file: + file.write('\n'.join(test_data)) + +print(f'data preprocessing and splitting completed. preprocessed data saved to {output_dir}') + +.so man2/uname.2 + +.\" copyright (c) 1993 by thomas koenig (ig25@rz.uni-karlsruhe.de) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified sat jul 24 19:53:02 1993 by rik faith (faith@cs.unc.edu) +.\" +.\" fixme many more values for 'name' are supported, some of which +.\" are documented under 'info confstr'. +.\" see for the rest. +.\" these should all be added to this page. +.\" see also the posix.1-2001 specification of confstr() +.\" +.th confstr 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +confstr \- get configuration dependent string variables +.sh synopsis +.nf +.b #include +.pp +.bi "size_t confstr(int " "name" ", char *" buf ", size_t " len ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br confstr (): +.nf + _posix_c_source >= 2 || _xopen_source +.fi +.sh description +.br confstr () +gets the value of configuration-dependent string variables. +.pp +the +.i name +argument is the system variable to be queried. +the following variables are supported: +.tp +.br _cs_gnu_libc_version " (gnu c library only; since glibc 2.3.2)" +a string which identifies the gnu c library version on this system +(e.g., "glibc 2.3.4"). +.tp +.br _cs_gnu_libpthread_version " (gnu c library only; since glibc 2.3.2)" +a string which identifies the posix implementation supplied by this +c library (e.g., "nptl 2.3.4" or "linuxthreads\-0.10"). +.tp +.b _cs_path +a value for the +.b path +variable which indicates where all the posix.2 standard utilities can +be found. +.pp +if +.i buf +is not null and +.i len +is not zero, +.br confstr () +copies the value of the string to +.i buf +truncated to +.i len \- 1 +bytes if necessary, with a null byte (\(aq\e0\(aq) as terminator. +this can be detected by comparing the return value of +.br confstr () +against +.ir len . +.pp +if +.i len +is zero and +.i buf +is null, +.br confstr () +just returns the value as defined below. +.sh return value +if +.i name +is a valid configuration variable, +.br confstr () +returns the number of bytes (including the terminating null byte) +that would be required to hold the entire value of that variable. +this value may be greater than +.ir len , +which means that the value in +.i buf +is truncated. +.pp +if +.i name +is a valid configuration variable, +but that variable does not have a value, then +.br confstr () +returns 0. +if +.i name +does not correspond to a valid configuration variable, +.br confstr () +returns 0, and +.i errno +is set to +.br einval . +.sh errors +.tp +.b einval +the value of +.i name +is invalid. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br confstr () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh examples +the following code fragment determines the path where to find +the posix.2 system utilities: +.pp +.in +4n +.ex +char *pathbuf; +size_t n; + +n = confstr(_cs_path, null, (size_t) 0); +pathbuf = malloc(n); +if (pathbuf == null) + abort(); +confstr(_cs_path, pathbuf, n); +.ee +.in +.sh see also +.br getconf (1), +.br sh (1), +.br exec (3), +.br fpathconf (3), +.br pathconf (3), +.br sysconf (3), +.br system (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/circleq.3 + +.so man3/j0.3 + +.so man3/encrypt.3 + +.so man3/argz_add.3 + +.\" copyright (c) 2013 by michael kerrisk +.\" and copyright (c) 2012 by eric w. biederman +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" +.th pid_namespaces 7 2020-11-01 "linux" "linux programmer's manual" +.sh name +pid_namespaces \- overview of linux pid namespaces +.sh description +for an overview of namespaces, see +.br namespaces (7). +.pp +pid namespaces isolate the process id number space, +meaning that processes in different pid namespaces can have the same pid. +pid namespaces allow containers to provide functionality +such as suspending/resuming the set of processes in the container and +migrating the container to a new host +while the processes inside the container maintain the same pids. +.pp +pids in a new pid namespace start at 1, +somewhat like a standalone system, and calls to +.br fork (2), +.br vfork (2), +or +.br clone (2) +will produce processes with pids that are unique within the namespace. +.pp +use of pid namespaces requires a kernel that is configured with the +.b config_pid_ns +option. +.\" +.\" ============================================================ +.\" +.ss the namespace "init" process +the first process created in a new namespace +(i.e., the process created using +.br clone (2) +with the +.br clone_newpid +flag, or the first child created by a process after a call to +.br unshare (2) +using the +.br clone_newpid +flag) has the pid 1, and is the "init" process for the namespace (see +.br init (1)). +this process becomes the parent of any child processes that are orphaned +because a process that resides in this pid namespace terminated +(see below for further details). +.pp +if the "init" process of a pid namespace terminates, +the kernel terminates all of the processes in the namespace via a +.br sigkill +signal. +this behavior reflects the fact that the "init" process +is essential for the correct operation of a pid namespace. +in this case, a subsequent +.br fork (2) +into this pid namespace fail with the error +.br enomem ; +it is not possible to create a new process in a pid namespace whose "init" +process has terminated. +such scenarios can occur when, for example, +a process uses an open file descriptor for a +.i /proc/[pid]/ns/pid +file corresponding to a process that was in a namespace to +.br setns (2) +into that namespace after the "init" process has terminated. +another possible scenario can occur after a call to +.br unshare (2): +if the first child subsequently created by a +.br fork (2) +terminates, then subsequent calls to +.br fork (2) +fail with +.br enomem . +.pp +only signals for which the "init" process has established a signal handler +can be sent to the "init" process by other members of the pid namespace. +this restriction applies even to privileged processes, +and prevents other members of the pid namespace from +accidentally killing the "init" process. +.pp +likewise, a process in an ancestor namespace +can\(emsubject to the usual permission checks described in +.br kill (2)\(emsend +signals to the "init" process of a child pid namespace only +if the "init" process has established a handler for that signal. +(within the handler, the +.i siginfo_t +.i si_pid +field described in +.br sigaction (2) +will be zero.) +.b sigkill +or +.b sigstop +are treated exceptionally: +these signals are forcibly delivered when sent from an ancestor pid namespace. +neither of these signals can be caught by the "init" process, +and so will result in the usual actions associated with those signals +(respectively, terminating and stopping the process). +.pp +starting with linux 3.4, the +.br reboot (2) +system call causes a signal to be sent to the namespace "init" process. +see +.br reboot (2) +for more details. +.\" +.\" ============================================================ +.\" +.ss nesting pid namespaces +pid namespaces can be nested: +each pid namespace has a parent, +except for the initial ("root") pid namespace. +the parent of a pid namespace is the pid namespace of the process that +created the namespace using +.br clone (2) +or +.br unshare (2). +pid namespaces thus form a tree, +with all namespaces ultimately tracing their ancestry to the root namespace. +since linux 3.7, +.\" commit f2302505775fd13ba93f034206f1e2a587017929 +.\" the kernel constant max_pid_ns_level +the kernel limits the maximum nesting depth for pid namespaces to 32. +.pp +a process is visible to other processes in its pid namespace, +and to the processes in each direct ancestor pid namespace +going back to the root pid namespace. +in this context, "visible" means that one process +can be the target of operations by another process using +system calls that specify a process id. +conversely, the processes in a child pid namespace can't see +processes in the parent and further removed ancestor namespaces. +more succinctly: a process can see (e.g., send signals with +.br kill (2), +set nice values with +.br setpriority (2), +etc.) only processes contained in its own pid namespace +and in descendants of that namespace. +.pp +a process has one process id in each of the layers of the pid +namespace hierarchy in which is visible, +and walking back though each direct ancestor namespace +through to the root pid namespace. +system calls that operate on process ids always +operate using the process id that is visible in the +pid namespace of the caller. +a call to +.br getpid (2) +always returns the pid associated with the namespace in which +the process was created. +.pp +some processes in a pid namespace may have parents +that are outside of the namespace. +for example, the parent of the initial process in the namespace +(i.e., the +.br init (1) +process with pid 1) is necessarily in another namespace. +likewise, the direct children of a process that uses +.br setns (2) +to cause its children to join a pid namespace are in a different +pid namespace from the caller of +.br setns (2). +calls to +.br getppid (2) +for such processes return 0. +.pp +while processes may freely descend into child pid namespaces +(e.g., using +.br setns (2) +with a pid namespace file descriptor), +they may not move in the other direction. +that is to say, processes may not enter any ancestor namespaces +(parent, grandparent, etc.). +changing pid namespaces is a one-way operation. +.pp +the +.br ns_get_parent +.br ioctl (2) +operation can be used to discover the parental relationship +between pid namespaces; see +.br ioctl_ns (2). +.\" +.\" ============================================================ +.\" +.ss setns(2) and unshare(2) semantics +calls to +.br setns (2) +that specify a pid namespace file descriptor +and calls to +.br unshare (2) +with the +.br clone_newpid +flag cause children subsequently created +by the caller to be placed in a different pid namespace from the caller. +(since linux 4.12, that pid namespace is shown via the +.ir /proc/[pid]/ns/pid_for_children +file, as described in +.br namespaces (7).) +these calls do not, however, +change the pid namespace of the calling process, +because doing so would change the caller's idea of its own pid +(as reported by +.br getpid ()), +which would break many applications and libraries. +.pp +to put things another way: +a process's pid namespace membership is determined when the process is created +and cannot be changed thereafter. +among other things, this means that the parental relationship +between processes mirrors the parental relationship between pid namespaces: +the parent of a process is either in the same namespace +or resides in the immediate parent pid namespace. +.pp +a process may call +.br unshare (2) +with the +.b clone_newpid +flag only once. +after it has performed this operation, its +.ir /proc/pid/ns/pid_for_children +symbolic link will be empty until the first child is created in the namespace. +.\" +.\" ============================================================ +.\" +.ss adoption of orphaned children +when a child process becomes orphaned, it is reparented to the "init" +process in the pid namespace of its parent +(unless one of the nearer ancestors of the parent employed the +.br prctl (2) +.b pr_set_child_subreaper +command to mark itself as the reaper of orphaned descendant processes). +note that because of the +.br setns (2) +and +.br unshare (2) +semantics described above, this may be the "init" process in the pid +namespace that is the +.i parent +of the child's pid namespace, +rather than the "init" process in the child's own pid namespace. +.\" furthermore, by definition, the parent of the "init" process +.\" of a pid namespace resides in the parent pid namespace. +.\" +.\" ============================================================ +.\" +.ss compatibility of clone_newpid with other clone_* flags +in current versions of linux, +.br clone_newpid +can't be combined with +.br clone_thread . +threads are required to be in the same pid namespace such that +the threads in a process can send signals to each other. +similarly, it must be possible to see all of the threads +of a process in the +.br proc (5) +filesystem. +additionally, if two threads were in different pid +namespaces, the process id of the process sending a signal +could not be meaningfully encoded when a signal is sent +(see the description of the +.i siginfo_t +type in +.br sigaction (2)). +since this is computed when a signal is enqueued, +a signal queue shared by processes in multiple pid namespaces +would defeat that. +.pp +.\" note these restrictions were all introduced in +.\" 8382fcac1b813ad0a4e68a838fc7ae93fa39eda0 +.\" when clone_newpid|clone_vm was disallowed +in earlier versions of linux, +.br clone_newpid +was additionally disallowed (failing with the error +.br einval ) +in combination with +.br clone_sighand +.\" (restriction lifted in faf00da544045fdc1454f3b9e6d7f65c841de302) +(before linux 4.3) as well as +.\" (restriction lifted in e79f525e99b04390ca4d2366309545a836c03bf1) +.br clone_vm +(before linux 3.12). +the changes that lifted these restrictions have also been ported to +earlier stable kernels. +.\" +.\" ============================================================ +.\" +.ss /proc and pid namespaces +a +.i /proc +filesystem shows (in the +.i /proc/[pid] +directories) only processes visible in the pid namespace +of the process that performed the mount, even if the +.i /proc +filesystem is viewed from processes in other namespaces. +.pp +after creating a new pid namespace, +it is useful for the child to change its root directory +and mount a new procfs instance at +.i /proc +so that tools such as +.br ps (1) +work correctly. +if a new mount namespace is simultaneously created by including +.br clone_newns +in the +.ir flags +argument of +.br clone (2) +or +.br unshare (2), +then it isn't necessary to change the root directory: +a new procfs instance can be mounted directly over +.ir /proc . +.pp +from a shell, the command to mount +.i /proc +is: +.pp +.in +4n +.ex +$ mount \-t proc proc /proc +.ee +.in +.pp +calling +.br readlink (2) +on the path +.i /proc/self +yields the process id of the caller in the pid namespace of the procfs mount +(i.e., the pid namespace of the process that mounted the procfs). +this can be useful for introspection purposes, +when a process wants to discover its pid in other namespaces. +.\" +.\" ============================================================ +.\" +.ss /proc files +.tp +.br /proc/sys/kernel/ns_last_pid " (since linux 3.3)" +.\" commit b8f566b04d3cddd192cfd2418ae6d54ac6353792 +this file +(which is virtualized per pid namespace) +displays the last pid that was allocated in this pid namespace. +when the next pid is allocated, +the kernel will search for the lowest unallocated pid +that is greater than this value, +and when this file is subsequently read it will show that pid. +.ip +this file is writable by a process that has the +.b cap_sys_admin +or (since linux 5.9) +.b cap_checkpoint_restore +capability inside the user namespace that owns the pid namespace. +.\" this ability is necessary to support checkpoint restore in user-space +this makes it possible to determine the pid that is allocated +to the next process that is created inside this pid namespace. +.\" +.\" ============================================================ +.\" +.ss miscellaneous +when a process id is passed over a unix domain socket to a +process in a different pid namespace (see the description of +.b scm_credentials +in +.br unix (7)), +it is translated into the corresponding pid value in +the receiving process's pid namespace. +.sh conforming to +namespaces are a linux-specific feature. +.sh examples +see +.br user_namespaces (7). +.sh see also +.br clone (2), +.br reboot (2), +.br setns (2), +.br unshare (2), +.br proc (5), +.br capabilities (7), +.br credentials (7), +.br mount_namespaces (7), +.br namespaces (7), +.br user_namespaces (7), +.br switch_root (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" +.\" modified 1993-03-29, david metcalfe +.\" modified 1993-07-24, rik faith (faith@cs.unc.edu) +.\" 2006-01-15, mtk, added example program. +.\" modified 2012-03-08, mark r. bannister +.\" and ben bacarisse +.\" document qsort_r() +.\" +.th qsort 3 2021-03-22 "" "linux programmer's manual" +.sh name +qsort, qsort_r \- sort an array +.sh synopsis +.nf +.b #include +.pp +.bi "void qsort(void *" base ", size_t " nmemb ", size_t " size , +.bi " int (*" compar ")(const void *, const void *));" +.bi "void qsort_r(void *" base ", size_t " nmemb ", size_t " size , +.bi " int (*" compar ")(const void *, const void *, void *)," +.bi " void *" arg ");" +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br qsort_r (): +.nf + _gnu_source +.fi +.sh description +the +.br qsort () +function sorts an array with \finmemb\fp elements of +size \fisize\fp. +the \fibase\fp argument points to the start of the +array. +.pp +the contents of the array are sorted in ascending order according to a +comparison function pointed to by \ficompar\fp, which is called with two +arguments that point to the objects being compared. +.pp +the comparison function must return an integer less than, equal to, or +greater than zero if the first argument is considered to be respectively +less than, equal to, or greater than the second. +if two members compare as equal, +their order in the sorted array is undefined. +.pp +the +.br qsort_r () +function is identical to +.br qsort () +except that the comparison function +.i compar +takes a third argument. +a pointer is passed to the comparison function via +.ir arg . +in this way, the comparison function does not need to use global variables to +pass through arbitrary arguments, and is therefore reentrant and safe to +use in threads. +.sh return value +the +.br qsort () +and +.br qsort_r () +functions return no value. +.sh versions +.br qsort_r () +was added to glibc in version 2.8. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br qsort (), +.br qsort_r () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +.br qsort (): +posix.1-2001, posix.1-2008, c89, c99, svr4, 4.3bsd. +.sh notes +to compare c strings, the comparison function can call +.br strcmp (3), +as shown in the example below. +.sh examples +for one example of use, see the example under +.br bsearch (3). +.pp +another example is the following program, +which sorts the strings given in its command-line arguments: +.pp +.ex +#include +#include +#include + +static int +cmpstringp(const void *p1, const void *p2) +{ + /* the actual arguments to this function are "pointers to + pointers to char", but strcmp(3) arguments are "pointers + to char", hence the following cast plus dereference. */ + + return strcmp(*(const char **) p1, *(const char **) p2); +} + +int +main(int argc, char *argv[]) +{ + if (argc < 2) { + fprintf(stderr, "usage: %s ...\en", argv[0]); + exit(exit_failure); + } + + qsort(&argv[1], argc \- 1, sizeof(char *), cmpstringp); + + for (int j = 1; j < argc; j++) + puts(argv[j]); + exit(exit_success); +} +.ee +.sh see also +.br sort (1), +.br alphasort (3), +.br strcmp (3), +.br versionsort (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/stdio_ext.3 + +#!/bin/sh +# +# remove_colophon.sh +# +# remove the colophon section from the man pages provided as +# command-line arguments. (this is useful to remove the colophon +# sections from all of the man pages in two different release trees +# in order to do a "diff -run" to see the "real" differences between +# the trees.) +# +###################################################################### +# +# (c) copyright 2008 & 2013, michael kerrisk +# this program is free software; you can redistribute it and/or +# modify it under the terms of the gnu general public license +# as published by the free software foundation; either version 2 +# of the license, or (at your option) any later version. +# +# this program 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 general public license for more details +# (http://www.gnu.org/licenses/gpl-2.0.html). +# +# +for f in "$@"; do + sed -i '/^\.sh colophon/,$d' "$f" +done + +.\" copyright (c) 2018, stefan hajnoczi +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th vsock 7 2021-03-22 "linux" "linux programmer's manual" +.sh name +vsock \- linux vsock address family +.sh synopsis +.nf +.b #include +.b #include +.pp +.ib stream_socket " = socket(af_vsock, sock_stream, 0);" +.ib datagram_socket " = socket(af_vsock, sock_dgram, 0);" +.fi +.sh description +the vsock address family facilitates communication between virtual machines and +the host they are running on. +this address family is used by guest agents and +hypervisor services that need a communications channel that is independent of +virtual machine network configuration. +.pp +valid socket types are +.b sock_stream +and +.br sock_dgram . +.b sock_stream +provides connection-oriented byte streams with guaranteed, in-order delivery. +.b sock_dgram +provides a connectionless datagram packet service with best-effort delivery and +best-effort ordering. +availability of these socket types is dependent on the +underlying hypervisor. +.pp +a new socket is created with +.pp +.in +4n +.ex +socket(af_vsock, socket_type, 0); +.ee +.in +.pp +when a process wants to establish a connection, it calls +.br connect (2) +with a given destination socket address. +the socket is automatically bound to a free port if unbound. +.pp +a process can listen for incoming connections by first binding to a socket +address using +.br bind (2) +and then calling +.br listen (2). +.pp +data is transmitted using the +.br send (2) +or +.br write (2) +families of system calls and data is received using the +.br recv (2) +or +.br read (2) +families of system calls. +.ss address format +a socket address is defined as a combination of a 32-bit context identifier +(cid) and a 32-bit port number. +the cid identifies the source or destination, +which is either a virtual machine or the host. +the port number differentiates between multiple services running on +a single machine. +.pp +.in +4n +.ex +struct sockaddr_vm { + sa_family_t svm_family; /* address family: af_vsock */ + unsigned short svm_reserved1; + unsigned int svm_port; /* port # in host byte order */ + unsigned int svm_cid; /* address in host byte order */ + unsigned char svm_zero[sizeof(struct sockaddr) \- + sizeof(sa_family_t) \- + sizeof(unsigned short) \- + sizeof(unsigned int) \- + sizeof(unsigned int)]; +}; +.ee +.in +.pp +.i svm_family +is always set to +.br af_vsock . +.i svm_reserved1 +is always set to 0. +.i svm_port +contains the port number in host byte order. +the port numbers below 1024 are called +.ir "privileged ports" . +only a process with the +.b cap_net_bind_service +capability may +.br bind (2) +to these port numbers. +.i svm_zero +must be zero-filled. +.pp +there are several special addresses: +.b vmaddr_cid_any +(\-1u) +means any address for binding; +.b vmaddr_cid_hypervisor +(0) is reserved for services built into the hypervisor; +.b vmaddr_cid_local +(1) is the well-known address for local communication (loopback); +.b vmaddr_cid_host +(2) +is the well-known address of the host. +.pp +the special constant +.b vmaddr_port_any +(\-1u) +means any port number for binding. +.ss live migration +sockets are affected by live migration of virtual machines. +connected +.b sock_stream +sockets become disconnected when the virtual machine migrates to a new host. +applications must reconnect when this happens. +.pp +the local cid may change across live migration if the old cid is +not available on the new host. +bound sockets are automatically updated to the new cid. +.ss ioctls +the following ioctls are available on the +.ir /dev/vsock +device. +.tp +.b ioctl_vm_sockets_get_local_cid +get the cid of the local machine. +the argument is a pointer to an +.ir "unsigned int" . +.ip +.in +4n +.ex +ioctl(fd, ioctl_vm_sockets_get_local_cid, &cid); +.ee +.in +.ip +consider using +.b vmaddr_cid_any +when binding instead of getting the local cid with +.br ioctl_vm_sockets_get_local_cid . +.ss local communication +.b vmaddr_cid_local +(1) directs packets to the same host that generated them. +this is useful +for testing applications on a single host and for debugging. +.pp +the local cid obtained with +.br ioctl_vm_sockets_get_local_cid +can be used for the same purpose, but it is preferable to use +.b vmaddr_cid_local . +.sh errors +.tp +.b eacces +unable to bind to a privileged port without the +.b cap_net_bind_service +capability. +.tp +.b eaddrinuse +unable to bind to a port that is already in use. +.tp +.b eaddrnotavail +unable to find a free port for binding or unable to bind to a nonlocal cid. +.tp +.b einval +invalid parameters. +this includes: +attempting to bind a socket that is already bound, providing an invalid struct +.ir sockaddr_vm , +and other input validation errors. +.tp +.b enoprotoopt +invalid socket option in +.br setsockopt (2) +or +.br getsockopt (2). +.tp +.b enotconn +unable to perform operation on an unconnected socket. +.tp +.b eopnotsupp +operation not supported. +this includes: +the +.b msg_oob +flag that is not implemented for the +.br send (2) +family of syscalls and +.b msg_peek +for the +.br recv (2) +family of syscalls. +.tp +.b eprotonosupport +invalid socket protocol number. +the protocol should always be 0. +.tp +.b esocktnosupport +unsupported socket type in +.br socket (2). +only +.b sock_stream +and +.b sock_dgram +are valid. +.sh versions +support for vmware (vmci) has been available since linux 3.9. +kvm (virtio) is supported since linux 4.8. +hyper-v is supported since linux 4.14. +.pp +.b vmaddr_cid_local +is supported since linux 5.6. +.\" commit ef343b35d46667668a099655fca4a5b2e43a5dfe +local communication in the guest and on the host is available since linux 5.6. +previous versions supported only local communication within a guest +(not on the host), and with only some transports (vmci and virtio). +.sh see also +.br bind (2), +.br connect (2), +.br listen (2), +.br recv (2), +.br send (2), +.br socket (2), +.br capabilities (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/fma.3 + +.\" copyright (c) 1996 andries brouwer , mon oct 31 22:13:04 1996 +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" this is combined from many sources. +.\" for linux, the definitive source is of course console.c. +.\" about vt100-like escape sequences in general there are +.\" the iso 6429 and iso 2022 norms, the descriptions of +.\" an actual vt100, and the xterm docs (ctlseqs.ms). +.\" substantial portions of this text are derived from a write-up +.\" by eric s. raymond . +.\" +.\" tiny correction, aeb, 961107. +.\" +.\" 2006-05-27, several corrections - thomas e. dickey +.\" +.th console_codes 4 2021-03-22 "linux" "linux programmer's manual" +.sh name +console_codes \- linux console escape and control sequences +.sh description +the linux console implements a large subset of the vt102 and ecma-48/iso +6429/ansi x3.64 terminal controls, plus certain private-mode sequences +for changing the color palette, character-set mapping, and so on. +in the tabular descriptions below, the second column gives ecma-48 or dec +mnemonics (the latter if prefixed with dec) for the given function. +sequences without a mnemonic are neither ecma-48 nor vt102. +.pp +after all the normal output processing has been done, and a +stream of characters arrives at the console driver for actual +printing, the first thing that happens is a translation from +the code used for processing to the code used for printing. +.pp +if the console is in utf-8 mode, then the incoming bytes are +first assembled into 16-bit unicode codes. +otherwise, each byte is transformed according to the current mapping table +(which translates it to a unicode value). +see the \fbcharacter sets\fp section below for discussion. +.pp +in the normal case, the unicode value is converted to a font index, +and this is stored in video memory, so that the corresponding glyph +(as found in video rom) appears on the screen. +note that the use of unicode (and the design of the pc hardware) +allows us to use 512 different glyphs simultaneously. +.pp +if the current unicode value is a control character, or we are +currently processing an escape sequence, the value will treated +specially. +instead of being turned into a font index and rendered as +a glyph, it may trigger cursor movement or other control functions. +see the \fblinux console controls\fp section below for discussion. +.pp +it is generally not good practice to hard-wire terminal controls into +programs. +linux supports a +.br terminfo (5) +database of terminal capabilities. +rather than emitting console escape sequences by hand, you will almost +always want to use a terminfo-aware screen library or utility such as +.br ncurses (3), +.br tput (1), +or +.br reset (1). +.ss linux console controls +this section describes all the control characters and escape sequences +that invoke special functions (i.e., anything other than writing a +glyph at the current cursor location) on the linux console. +.pp +.b "control characters" +.pp +a character is a control character if (before transformation +according to the mapping table) it has one of the 14 codes +00 (nul), 07 (bel), 08 (bs), 09 (ht), 0a (lf), 0b (vt), +0c (ff), 0d (cr), 0e (so), 0f (si), 18 (can), 1a (sub), +1b (esc), 7f (del). +one can set a "display control characters" mode (see below), +and allow 07, 09, 0b, 18, 1a, 7f to be displayed as glyphs. +on the other hand, in utf-8 mode all codes 00\(en1f are regarded +as control characters, regardless of any "display control characters" +mode. +.pp +if we have a control character, it is acted upon immediately +and then discarded (even in the middle of an escape sequence) +and the escape sequence continues with the next character. +(however, esc starts a new escape sequence, possibly aborting a previous +unfinished one, and can and sub abort any escape sequence.) +the recognized control characters are bel, bs, ht, lf, vt, ff, +cr, so, si, can, sub, esc, del, csi. +they do what one would expect: +.hp +bel (0x07, \fb\(hag\fp) beeps; +.hp +bs (0x08, \fb\(hah\fp) backspaces one column +(but not past the beginning of the line); +.hp +ht (0x09, \fb\(hai\fp) goes to the next tab stop or to the end of the line +if there is no earlier tab stop; +.hp +lf (0x0a, \fb\(haj\fp), vt (0x0b, \fb\(hak\fp), and +ff (0x0c, \fb\(hal\fp) all give a linefeed, +and if lf/nl (new-line mode) is set also a carriage return; +.hp +cr (0x0d, \fb\(ham\fp) gives a carriage return; +.hp +so (0x0e, \fb\(han\fp) activates the g1 character set; +.hp +si (0x0f, \fb\(hao\fp) activates the g0 character set; +.hp +can (0x18, \fb\(hax\fp) and sub (0x1a, \fb\(haz\fp) abort escape sequences; +.hp +esc (0x1b, \fb\(ha[\fp) starts an escape sequence; +.hp +del (0x7f) is ignored; +.hp +csi (0x9b) is equivalent to esc [. +.pp +.b "esc- but not csi-sequences" +.ad l +.ts +l l lx. +esc c ris reset. +esc d ind linefeed. +esc e nel newline. +esc h hts set tab stop at current column. +esc m ri reverse linefeed. +esc z decid t{ +dec private identification. the kernel +returns the string esc [ ? 6 c, claiming +that it is a vt102. +t} +esc 7 decsc t{ +save current state (cursor coordinates, +attributes, character sets pointed at by g0, g1). +t} +esc 8 decrc t{ +restore state most recently saved by esc 7. +t} +esc [ csi control sequence introducer +esc % start sequence selecting character set +esc % @ \0\0\0select default (iso 646 / iso 8859-1) +esc % g \0\0\0select utf-8 +esc % 8 \0\0\0select utf-8 (obsolete) +esc # 8 decaln t{ +dec screen alignment test \- fill screen with e's +t} +esc ( t{ +start sequence defining g0 character set +(followed by one of b, 0, u, k, as below) +t} +esc ( b t{ +select default (iso 8859-1 mapping) +t} +esc ( 0 t{ +select vt100 graphics mapping +t} +esc ( u t{ +select null mapping \- straight to character rom +t} +esc ( k t{ +select user mapping \- the map that is loaded by the utility \fbmapscrn\fp(8) +t} +esc ) t{ +start sequence defining g1 (followed by one of b, 0, u, k, as above). +t} +esc > decpnm set numeric keypad mode +esc = decpam set application keypad mode +esc ] osc t{ +(should be: operating system command) +esc ] p \finrrggbb\fp: set palette, with parameter +given in 7 hexadecimal digits after the final p :-(. +here \fin\fp is the color (0\(en15), and \firrggbb\fp indicates +the red/green/blue values (0\(en255). +esc ] r: reset palette +t} +.te +.ad +.pp +.b "ecma-48 csi sequences" +.pp +csi (or esc [) is followed by a sequence of parameters, +at most npar (16), that are decimal numbers separated by +semicolons. +an empty or absent parameter is taken to be 0. +the sequence of parameters may be preceded by a single question mark. +.pp +however, after csi [ (or esc [ [) a single character is read +and this entire sequence is ignored. +(the idea is to ignore an echoed function key.) +.pp +the action of a csi sequence is determined by its final character. +.ad l +.ts +l l lx. +@ ich t{ +insert the indicated # of blank characters. +t} +a cuu t{ +move cursor up the indicated # of rows. +t} +b cud t{ +move cursor down the indicated # of rows. +t} +c cuf t{ +move cursor right the indicated # of columns. +t} +d cub t{ +move cursor left the indicated # of columns. +t} +e cnl t{ +move cursor down the indicated # of rows, to column 1. +t} +f cpl t{ +move cursor up the indicated # of rows, to column 1. +t} +g cha t{ +move cursor to indicated column in current row. +t} +h cup t{ +move cursor to the indicated row, column (origin at 1,1). +t} +j ed t{ +erase display (default: from cursor to end of display). +t} + t{ +esc [ 1 j: erase from start to cursor. +t} + t{ +esc [ 2 j: erase whole display. +t} + t{ +esc [ 3 j: erase whole display including scroll-back +buffer (since linux 3.0). +t} +.\" esc [ 3 j: commit f8df13e0a901fe55631fed66562369b4dba40f8b +k el t{ +erase line (default: from cursor to end of line). +t} + t{ +esc [ 1 k: erase from start of line to cursor. +t} + t{ +esc [ 2 k: erase whole line. +t} +l il t{ +insert the indicated # of blank lines. +t} +m dl t{ +delete the indicated # of lines. +t} +p dch t{ +delete the indicated # of characters on current line. +t} +x ech t{ +erase the indicated # of characters on current line. +t} +a hpr t{ +move cursor right the indicated # of columns. +t} +c da t{ +answer esc [ ? 6 c: "i am a vt102". +t} +d vpa t{ +move cursor to the indicated row, current column. +t} +e vpr t{ +move cursor down the indicated # of rows. +t} +f hvp t{ +move cursor to the indicated row, column. +t} +g tbc t{ +without parameter: clear tab stop at current position. +t} + t{ +esc [ 3 g: delete all tab stops. +t} +h sm set mode (see below). +l rm reset mode (see below). +m sgr set attributes (see below). +n dsr status report (see below). +q decll set keyboard leds. + esc [ 0 q: clear all leds + esc [ 1 q: set scroll lock led + esc [ 2 q: set num lock led + esc [ 3 q: set caps lock led +r decstbm t{ +set scrolling region; parameters are top and bottom row. +t} +s ? save cursor location. +u ? restore cursor location. +\` hpa t{ +move cursor to indicated column in current row. +t} +.te +.ad +.pp +.b ecma-48 select graphic rendition +.pp +the ecma-48 sgr sequence esc [ \fiparameters\fp m sets display +attributes. +several attributes can be set in the same sequence, separated by +semicolons. +an empty parameter (between semicolons or string initiator or +terminator) is interpreted as a zero. +.ad l +.ts +l lx. +param result +0 t{ +reset all attributes to their defaults +t} +1 set bold +2 t{ +set half-bright (simulated with color on a color display) +t} +4 t{ +set underscore (simulated with color on a color display) +(the colors used to simulate dim or underline are set +using esc ] ...) +t} +5 set blink +7 set reverse video +10 t{ +reset selected mapping, display control flag, +and toggle meta flag (ecma-48 says "primary font"). +t} +11 t{ +select null mapping, set display control flag, +reset toggle meta flag (ecma-48 says "first alternate font"). +t} +12 t{ +select null mapping, set display control flag, +set toggle meta flag (ecma-48 says "second alternate font"). +the toggle meta flag +causes the high bit of a byte to be toggled +before the mapping table translation is done. +t} +21 t{ +set underline; before linux 4.17, this value +set normal intensity (as is done in many other terminals) +t} +22 set normal intensity +24 underline off +25 blink off +27 reverse video off +30 set black foreground +31 set red foreground +32 set green foreground +33 set brown foreground +34 set blue foreground +35 set magenta foreground +36 set cyan foreground +37 set white foreground +38 t{ +256/24-bit foreground color follows, shoehorned into 16 basic colors +(before linux 3.16: set underscore on, set default foreground color) +t} +39 t{ +set default foreground color +(before linux 3.16: set underscore off, set default foreground color) +t} +40 set black background +41 set red background +42 set green background +43 set brown background +44 set blue background +45 set magenta background +46 set cyan background +47 set white background +48 t{ +256/24-bit background color follows, shoehorned into 8 basic colors +t} +49 set default background color +90..97 t{ +set foreground to bright versions of 30..37 +t} +100.107 t{ +set background, same as 40..47 (bright not supported) +t} +.te +.ad +.pp +commands 38 and 48 require further arguments: +.ts +l lx. +;5;x t{ +256 color: values 0..15 are ibgr (black, red, green, ... white), +16..231 a 6x6x6 color cube, 232..255 a grayscale ramp +t} +;2;r;g;b t{ +24-bit color, r/g/b components are in the range 0..255 +t} +.te +.pp +.b ecma-48 mode switches +.tp +esc [ 3 h +deccrm (default off): display control chars. +.tp +esc [ 4 h +decim (default off): set insert mode. +.tp +esc [ 20 h +lf/nl (default off): automatically follow echo of lf, vt, or ff with cr. +.\" +.pp +.b ecma-48 status report commands +.\" +.tp +esc [ 5 n +device status report (dsr): answer is esc [ 0 n (terminal ok). +.tp +esc [ 6 n +cursor position report (cpr): answer is esc [ \fiy\fp ; \fix\fp r, +where \fix,y\fp is the cursor location. +.\" +.pp +.b dec private mode (decset/decrst) sequences +.pp +.\" +these are not described in ecma-48. +we list the set mode sequences; +the reset mode sequences are obtained by replacing the final \(aqh\(aq +by \(aql\(aq. +.tp +esc [ ? 1 h +decckm (default off): when set, the cursor keys send an esc o prefix, +rather than esc [. +.tp +esc [ ? 3 h +deccolm (default off = 80 columns): 80/132 col mode switch. +the driver sources note that this alone does not suffice; some user-mode +utility such as +.br resizecons (8) +has to change the hardware registers on the console video card. +.tp +esc [ ? 5 h +decscnm (default off): set reverse-video mode. +.tp +esc [ ? 6 h +decom (default off): when set, cursor addressing is relative to +the upper left corner of the scrolling region. +.tp +esc [ ? 7 h +decawm (default on): set autowrap on. +in this mode, a graphic +character emitted after column 80 (or column 132 of deccolm is on) +forces a wrap to the beginning of the following line first. +.tp +esc [ ? 8 h +decarm (default on): set keyboard autorepeat on. +.tp +esc [ ? 9 h +x10 mouse reporting (default off): set reporting mode to 1 (or reset to +0)\(emsee below. +.tp +esc [ ? 25 h +dectecm (default on): make cursor visible. +.tp +esc [ ? 1000 h +x11 mouse reporting (default off): set reporting mode to 2 (or reset +to 0)\(emsee below. +.\" +.pp +.b linux console private csi sequences +.pp +.\" +the following sequences are neither ecma-48 nor native vt102. +they are native to the linux console driver. +colors are in sgr parameters: +0 = black, 1 = red, 2 = green, 3 = brown, 4 = blue, 5 = magenta, 6 = +cyan, 7 = white; 8\(en15 = bright versions of 0\(en7. +.ts +l lx. +esc [ 1 ; \fin\fp ] t{ +set color \fin\fp as the underline color. +t} +esc [ 2 ; \fin\fp ] t{ +set color \fin\fp as the dim color. +t} +esc [ 8 ] t{ +make the current color pair the default attributes. +t} +esc [ 9 ; \fin\fp ] t{ +set screen blank timeout to \fin\fp minutes. +t} +esc [ 10 ; \fin\fp ] t{ +set bell frequency in hz. +t} +esc [ 11 ; \fin\fp ] t{ +set bell duration in msec. +t} +esc [ 12 ; \fin\fp ] t{ +bring specified console to the front. +t} +esc [ 13 ] t{ +unblank the screen. +t} +esc [ 14 ; \fin\fp ] t{ +set the vesa powerdown interval in minutes. +t} +esc [ 15 ] t{ +bring the previous console to the front +(since linux 2.6.0). +t} +esc [ 16 ; \fin\fp ] t{ +set the cursor blink interval in milliseconds +(since linux 4.2). +t} +.\" commit bd63364caa8df38bad2b25b11b2a1b849475cce5 +.te +.ss character sets +the kernel knows about 4 translations of bytes into console-screen +symbols. +the four tables are: a) latin1 \-> pc, +b) vt100 graphics \-> pc, c) pc \-> pc, d) user-defined. +.pp +there are two character sets, called g0 and g1, and one of them +is the current character set. +(initially g0.) +typing \fb\(han\fp causes g1 to become current, +\fb\(hao\fp causes g0 to become current. +.pp +these variables g0 and g1 point at a translation table, and can be +changed by the user. +initially they point at tables a) and b), respectively. +the sequences esc ( b and esc ( 0 and esc ( u and esc ( k cause g0 to +point at translation table a), b), c), and d), respectively. +the sequences esc ) b and esc ) 0 and esc ) u and esc ) k cause g1 to +point at translation table a), b), c), and d), respectively. +.pp +the sequence esc c causes a terminal reset, which is what you want if the +screen is all garbled. +the oft-advised "echo \(hav\(hao" will make only g0 current, +but there is no guarantee that g0 points at table a). +in some distributions there is a program +.br reset (1) +that just does "echo \(ha[c". +if your terminfo entry for the console is correct +(and has an entry rs1=\eec), then "tput reset" will also work. +.pp +the user-defined mapping table can be set using +.br mapscrn (8). +the result of the mapping is that if a symbol c is printed, the symbol +s = map[c] is sent to the video memory. +the bitmap that corresponds to +s is found in the character rom, and can be changed using +.br setfont (8). +.ss mouse tracking +the mouse tracking facility is intended to return +.br xterm (1)-compatible +mouse status reports. +because the console driver has no way to know +the device or type of the mouse, these reports are returned in the +console input stream only when the virtual terminal driver receives +a mouse update ioctl. +these ioctls must be generated by a mouse-aware +user-mode application such as the +.br gpm (8) +daemon. +.pp +the mouse tracking escape sequences generated by +\fbxterm\fp(1) encode numeric parameters in a single character as +\fivalue\fp+040. +for example, \(aq!\(aq is 1. +the screen coordinate system is 1-based. +.pp +the x10 compatibility mode sends an escape sequence on button press +encoding the location and the mouse button pressed. +it is enabled by sending esc [ ? 9 h and disabled with esc [ ? 9 l. +on button press, \fbxterm\fp(1) sends +esc [ m \fibxy\fp (6 characters). +here \fib\fp is button\-1, +and \fix\fp and \fiy\fp are the x and y coordinates of the mouse +when the button was pressed. +this is the same code the kernel also produces. +.pp +normal tracking mode (not implemented in linux 2.0.24) sends an escape +sequence on both button press and release. +modifier information is also sent. +it is enabled by sending esc [ ? 1000 h and disabled with +esc [ ? 1000 l. +on button press or release, \fbxterm\fp(1) sends esc [ m +\fibxy\fp. +the low two bits of \fib\fp encode button information: +0=mb1 pressed, 1=mb2 pressed, 2=mb3 pressed, 3=release. +the upper bits encode what modifiers were down when the button was +pressed and are added together: 4=shift, 8=meta, 16=control. +again \fix\fp and +\fiy\fp are the x and y coordinates of the mouse event. +the upper left corner is (1,1). +.ss comparisons with other terminals +many different terminal types are described, like the linux console, +as being "vt100-compatible". +here we discuss differences between the +linux console and the two most important others, the dec vt102 and +.br xterm (1). +.\" +.pp +.b control-character handling +.pp +the vt102 also recognized the following control characters: +.hp +nul (0x00) was ignored; +.hp +enq (0x05) triggered an answerback message; +.hp +dc1 (0x11, \fb\(haq\fp, xon) resumed transmission; +.hp +dc3 (0x13, \fb\(has\fp, xoff) caused vt100 to ignore (and stop transmitting) +all codes except xoff and xon. +.pp +vt100-like dc1/dc3 processing may be enabled by the terminal driver. +.pp +the +.br xterm (1) +program (in vt100 mode) recognizes the control characters +bel, bs, ht, lf, vt, ff, cr, so, si, esc. +.\" +.pp +.b escape sequences +.pp +vt100 console sequences not implemented on the linux console: +.ts +l l l. +esc n ss2 t{ +single shift 2. (select g2 character set for the next character only.) +t} +esc o ss3 t{ +single shift 3. (select g3 character set for the next character only.) +t} +esc p dcs t{ +device control string (ended by esc \e) +t} +esc x sos start of string. +esc \(ha pm privacy message (ended by esc \e) +esc \e st string terminator +esc * ... designate g2 character set +esc + ... designate g3 character set +.te +.pp +the program +.br xterm (1) +(in vt100 mode) recognizes esc c, esc # 8, esc >, esc =, +esc d, esc e, esc h, esc m, esc n, esc o, esc p ... esc \e, +esc z (it answers esc [ ? 1 ; 2 c, "i am a vt100 with +advanced video option") +and esc \(ha ... esc \e with the same meanings as indicated above. +it accepts esc (, esc ), esc *, esc + followed by 0, a, b for +the dec special character and line drawing set, uk, and us-ascii, +respectively. +.pp +the user can configure \fbxterm\fp(1) to respond to vt220-specific +control sequences, and it will identify itself as a vt52, vt100, and +up depending on the way it is configured and initialized. +.pp +it accepts esc ] (osc) for the setting of certain resources. +in addition to the ecma-48 string terminator (st), +\fbxterm\fp(1) accepts a bel to terminate an osc string. +these are a few of the osc control sequences recognized by \fbxterm\fp(1): +.ts +l l. +esc ] 0 ; \fitxt\fp st t{ +set icon name and window title to \fitxt\fp. +t} +esc ] 1 ; \fitxt\fp st set icon name to \fitxt\fp. +esc ] 2 ; \fitxt\fp st set window title to \fitxt\fp. +esc ] 4 ; \finum\fp; \fitxt\fp st set ansi color \finum\fp to \fitxt\fp. +esc ] 10 ; \fitxt\fp st set dynamic text color to \fitxt\fp. +esc ] 4 6 ; \finame\fp st t{ +change log file to \finame\fp (normally disabled by a compile-time option). +t} +esc ] 5 0 ; \fifn\fp st set font to \fifn\fp. +.te +.pp +it recognizes the following with slightly modified meaning +(saving more state, behaving closer to vt100/vt220): +.ts +l l l. +esc 7 decsc save cursor +esc 8 decrc restore cursor +.te +.pp +it also recognizes +.ts +l l lx. +esc f t{ +cursor to lower left corner of screen (if enabled +by \fbxterm\fp(1)'s \fbhplowerleftbugcompat\fp resource) +t} +esc l memory lock (per hp terminals). + locks memory above the cursor. +esc m memory unlock (per hp terminals). +esc n ls2 invoke the g2 character set. +esc o ls3 invoke the g3 character set. +esc | ls3r invoke the g3 character set as gr. +esc } ls2r invoke the g2 character set as gr. +esc \(ti ls1r invoke the g1 character set as gr. +.te +.pp +it also recognizes esc % and provides a more complete utf-8 +implementation than linux console. +.\" +.pp +.b csi sequences +.pp +old versions of \fbxterm\fp(1), for example, from x11r5, +interpret the blink sgr as a bold sgr. +later versions which implemented ansi colors, for example, +xfree86 3.1.2a in 1995, improved this by allowing +the blink attribute to be displayed as a color. +modern versions of xterm implement blink sgr as blinking text +and still allow colored text as an alternate rendering of sgrs. +stock x11r6 versions did not recognize the color-setting sgrs until +the x11r6.8 release, which incorporated xfree86 xterm. +all ecma-48 csi sequences recognized by linux are also recognized by +.ir xterm , +however \fbxterm\fp(1) implements several ecma-48 and dec control sequences +not recognized by linux. +.pp +the \fbxterm\fp(1) +program recognizes all of the dec private mode sequences listed +above, but none of the linux private-mode sequences. +for discussion of \fbxterm\fp(1)'s +own private-mode sequences, refer to the +\fixterm control sequences\fp +document by +edward moy, +stephen gildea, +and thomas e.\& dickey +available with the x distribution. +that document, though terse, is much longer than this manual page. +for a chronological overview, +.pp +.rs +.ur http://invisible\-island.net\:/xterm\:/xterm.log.html +.ue +.re +.pp +details changes to xterm. +.pp +the \fivttest\fp program +.pp +.rs +.ur http://invisible\-island.net\:/vttest/ +.ue +.re +.pp +demonstrates many of these control sequences. +the \fbxterm\fp(1) source distribution also contains sample +scripts which exercise other features. +.sh notes +esc 8 (decrc) is not able to restore the character set changed with +esc %. +.sh bugs +in 2.0.23, csi is broken, and nul is not ignored inside +escape sequences. +.pp +some older kernel versions (after 2.0) interpret 8-bit control +sequences. +these "c1 controls" use codes between 128 and 159 to replace +esc [, esc ] and similar two-byte control sequence initiators. +there are fragments of that in modern kernels (either overlooked or +broken by changes to support utf-8), +but the implementation is incomplete and should be regarded +as unreliable. +.pp +linux "private mode" sequences do not follow the rules in ecma-48 +for private mode control sequences. +in particular, those ending with ] do not use a standard terminating +character. +the osc (set palette) sequence is a greater problem, +since \fbxterm\fp(1) may interpret this as a control sequence +which requires a string terminator (st). +unlike the \fbsetterm\fp(1) sequences which will be ignored (since +they are invalid control sequences), the palette sequence will make +\fbxterm\fp(1) appear to hang (though pressing the return-key +will fix that). +to accommodate applications which have been hardcoded to use linux +control sequences, +set the \fbxterm\fp(1) resource \fbbrokenlinuxosc\fp to true. +.pp +an older version of this document implied that linux recognizes the +ecma-48 control sequence for invisible text. +it is ignored. +.sh see also +.br ioctl_console (2), +.br charsets (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2016, michael kerrisk +.\" based on an earlier version of the page where a few pieces were +.\" copyright (c) 1993 by dan miner (dminer@nyx.cs.du.edu) and subsequently +.\" others (see old changelog below). +.\" the structure definitions are taken more or less straight from the kernel +.\" source files. +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" +.\" modified sat jul 24 12:35:12 1993 by rik faith +.\" modified tue oct 22 22:29:51 1996 by eric s. raymond +.\" modified mon aug 25 16:06:11 1997 by nicolás lichtmaier +.\" +.th sysinfo 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +sysinfo \- return system information +.sh synopsis +.nf +.b #include +.pp +.bi "int sysinfo(struct sysinfo *" info ); +.fi +.sh description +.br sysinfo () +returns certain statistics on memory and swap usage, +as well as the load average. +.pp +until linux 2.3.16, +.br sysinfo () +returned information in the following structure: +.pp +.in +4n +.ex +struct sysinfo { + long uptime; /* seconds since boot */ + unsigned long loads[3]; /* 1, 5, and 15 minute load averages */ + unsigned long totalram; /* total usable main memory size */ + unsigned long freeram; /* available memory size */ + unsigned long sharedram; /* amount of shared memory */ + unsigned long bufferram; /* memory used by buffers */ + unsigned long totalswap; /* total swap space size */ + unsigned long freeswap; /* swap space still available */ + unsigned short procs; /* number of current processes */ + char _f[22]; /* pads structure to 64 bytes */ +}; +.ee +.in +.pp +in the above structure, the sizes of the memory and swap fields +are given in bytes. +.pp +since linux 2.3.23 (i386) and linux 2.3.48 +(all architectures) the structure is: +.pp +.in +4n +.ex +struct sysinfo { + long uptime; /* seconds since boot */ + unsigned long loads[3]; /* 1, 5, and 15 minute load averages */ + unsigned long totalram; /* total usable main memory size */ + unsigned long freeram; /* available memory size */ + unsigned long sharedram; /* amount of shared memory */ + unsigned long bufferram; /* memory used by buffers */ + unsigned long totalswap; /* total swap space size */ + unsigned long freeswap; /* swap space still available */ + unsigned short procs; /* number of current processes */ + unsigned long totalhigh; /* total high memory size */ + unsigned long freehigh; /* available high memory size */ + unsigned int mem_unit; /* memory unit size in bytes */ + char _f[20\-2*sizeof(long)\-sizeof(int)]; + /* padding to 64 bytes */ +}; +.ee +.in +.pp +in the above structure, +sizes of the memory and swap fields are given as multiples of +.i mem_unit +bytes. +.sh return value +on success, +.br sysinfo () +returns zero. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b efault +.ir info +is not a valid address. +.sh versions +.br sysinfo () +first appeared in linux 0.98.pl6. +.sh conforming to +this function is linux-specific, and should not be used in programs +intended to be portable. +.sh notes +all of the information provided by this system call is also available via +.ir /proc/meminfo +and +.ir /proc/loadavg . +.sh see also +.br proc (5) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 2002 walter harms(walter.harms@informatik.uni-oldenburg.de) +.\" and copyright (c) 2011 michael kerrisk +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under gpl +.\" %%%license_end +.\" +.th cacosh 3 2021-03-22 "" "linux programmer's manual" +.sh name +cacosh, cacoshf, cacoshl \- complex arc hyperbolic cosine +.sh synopsis +.nf +.b #include +.pp +.bi "double complex cacosh(double complex " z ); +.bi "float complex cacoshf(float complex " z ); +.bi "long double complex cacoshl(long double complex " z ); +.pp +link with \fi\-lm\fp. +.fi +.sh description +these functions calculate the complex arc hyperbolic cosine of +.ir z . +if \fiy\ =\ cacosh(z)\fp, then \fiz\ =\ ccosh(y)\fp. +the imaginary part of +.i y +is chosen in the interval [\-pi,pi]. +the real part of +.i y +is chosen nonnegative. +.pp +one has: +.pp +.nf + cacosh(z) = 2 * clog(csqrt((z + 1) / 2) + csqrt((z \- 1) / 2)) +.fi +.sh versions +these functions first appeared in glibc in version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br cacosh (), +.br cacoshf (), +.br cacoshl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.sh examples +.ex +/* link with "\-lm" */ + +#include +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + double complex z, c, f; + + if (argc != 3) { + fprintf(stderr, "usage: %s \en", argv[0]); + exit(exit_failure); + } + + z = atof(argv[1]) + atof(argv[2]) * i; + + c = cacosh(z); + printf("cacosh() = %6.3f %6.3f*i\en", creal(c), cimag(c)); + + f = 2 * clog(csqrt((z + 1)/2) + csqrt((z \- 1)/2)); + printf("formula = %6.3f %6.3f*i\en", creal(f2), cimag(f2)); + + exit(exit_success); +} +.ee +.sh see also +.br acosh (3), +.br cabs (3), +.br ccosh (3), +.br cimag (3), +.br complex (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/cimag.3 + +.so man3/fgetc.3 + +.\" copyright (c) 2017 by michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" +.th ioctl_iflags 2 2019-11-19 "linux" "linux programmer's manual" +.sh name +ioctl_iflags \- ioctl() operations for inode flags +.sh description +various linux filesystems support the notion of +.ir "inode flags" \(emattributes +that modify the semantics of files and directories. +these flags can be retrieved and modified using two +.br ioctl (2) +operations: +.pp +.in +4n +.ex +int attr; +fd = open("pathname", ...); + +ioctl(fd, fs_ioc_getflags, &attr); /* place current flags + in \(aqattr\(aq */ +attr |= fs_noatime_fl; /* tweak returned bit mask */ +ioctl(fd, fs_ioc_setflags, &attr); /* update flags for inode + referred to by \(aqfd\(aq */ +.ee +.in +.pp +the +.br lsattr (1) +and +.br chattr (1) +shell commands provide interfaces to these two operations, +allowing a user to view and modify the inode flags associated with a file. +.pp +the following flags are supported +(shown along with the corresponding letter used to indicate the flag by +.br lsattr (1) +and +.br chattr (1)): +.tp +.br fs_append_fl " \(aqa\(aq" +the file can be opened only with the +.b o_append +flag. +(this restriction applies even to the superuser.) +only a privileged process +.rb ( cap_linux_immutable ) +can set or clear this attribute. +.tp +.br fs_compr_fl " \(aqc\(aq" +store the file in a compressed format on disk. +this flag is +.i not +supported by most of the mainstream filesystem implementations; +one exception is +.br btrfs (5). +.tp +.br fs_dirsync_fl " \(aqd\(aq (since linux 2.6.0)" +write directory changes synchronously to disk. +this flag provides semantics equivalent to the +.br mount (2) +.b ms_dirsync +option, but on a per-directory basis. +this flag can be applied only to directories. +.\" .tp +.\" .br fs_extent_fl " \(aqe\(aq" +.\" fixme some support on ext4? (ext4_extents_fl) +.tp +.br fs_immutable_fl " \(aqi\(aq" +the file is immutable: +no changes are permitted to the file contents or metadata +(permissions, timestamps, ownership, link count, and so on). +(this restriction applies even to the superuser.) +only a privileged process +.rb ( cap_linux_immutable ) +can set or clear this attribute. +.tp +.br fs_journal_data_fl " \(aqj\(aq" +enable journaling of file data on +.br ext3 (5) +and +.br ext4 (5) +filesystems. +on a filesystem that is journaling in +.i ordered +or +.i writeback +mode, a privileged +.rb ( cap_sys_resource ) +process can set this flag to enable journaling of data updates on +a per-file basis. +.tp +.br fs_noatime_fl " \(aqa\(aq" +don't update the file last access time when the file is accessed. +this can provide i/o performance benefits for applications that do not care +about the accuracy of this timestamp. +this flag provides functionality similar to the +.br mount (2) +.br ms_noatime +flag, but on a per-file basis. +.\" .tp +.\" .br fs_nocomp_fl " \(aq\(aq" +.\" fixme support for fs_nocomp_fl on btrfs? +.tp +.br fs_nocow_fl " \(aqc\(aq (since linux 2.6.39)" +the file will not be subject to copy-on-write updates. +this flag has an effect only on filesystems that support copy-on-write +semantics, such as btrfs. +see +.br chattr (1) +and +.br btrfs (5). +.tp +.br fs_nodump_fl " \(aqd\(aq" +don't include this file in backups made using +.br dump (8). +.tp +.br fs_notail_fl " \(aqt\(aq" +this flag is supported only on reiserfs. +it disables the reiserfs tail-packing feature, +which tries to pack small files (and the final fragment of larger files) +into the same disk block as the file metadata. +.tp +.br fs_projinherit_fl " \(aqp\(aq (since linux 4.5)" +.\" commit 040cb3786d9b25293b8b0b05b90da0f871e1eb9b +.\" flag name was added in linux 4.4 +.\" fixme not currently supported because not in fs_fl_user_modifiable? +inherit the quota project id. +files and subdirectories will inherit the project id of the directory. +this flag can be applied only to directories. +.tp +.br fs_secrm_fl " \(aqs\(aq" +mark the file for secure deletion. +this feature is not implemented by any filesystem, +since the task of securely erasing a file from a recording medium +is surprisingly difficult. +.tp +.br fs_sync_fl " \(aqs\(aq" +make file updates synchronous. +for files, this makes all writes synchronous +(as though all opens of the file were with the +.br o_sync +flag). +for directories, this has the same effect as the +.br fs_dirsync_fl +flag. +.tp +.br fs_topdir_fl " \(aqt\(aq" +mark a directory for special treatment under the orlov block-allocation +strategy. +see +.br chattr (1) +for details. +this flag can be applied only to directories and +has an effect only for ext2, ext3, and ext4. +.tp +.br fs_unrm_fl " \(aqu\(aq" +allow the file to be undeleted if it is deleted. +this feature is not implemented by any filesystem, +since it is possible to implement file-recovery mechanisms outside the kernel. +.pp +in most cases, +when any of the above flags is set on a directory, +the flag is inherited by files and subdirectories +created inside that directory. +exceptions include +.br fs_topdir_fl , +which is not inheritable, and +.br fs_dirsync_fl , +which is inherited only by subdirectories. +.sh conforming to +inode flags are a nonstandard linux extension. +.sh notes +in order to change the inode flags of a file using the +.br fs_ioc_setflags +operation, +the effective user id of the caller must match the owner of the file, +or the caller must have the +.br cap_fowner +capability. +.pp +the type of the argument given to the +.br fs_ioc_getflags +and +.br fs_ioc_setflags +operations is +.ir "int\ *" , +notwithstanding the implication in the kernel source file +.i include/uapi/linux/fs.h +that the argument is +.ir "long\ *" . +.sh see also +.br chattr (1), +.br lsattr (1), +.br mount (2), +.br btrfs (5), +.br ext4 (5), +.br xfs (5), +.br xattr (7), +.br mount (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/rpc.3 + +.so man3/xdr.3 + +.\" this page was taken from the 4.4bsd-lite cdrom (bsd license) +.\" +.\" %%%license_start(bsd_oneline_cdrom) +.\" this page was taken from the 4.4bsd-lite cdrom (bsd license) +.\" %%%license_end +.\" +.\" @(#)rpc.3n 2.4 88/08/08 4.0 rpcsrc; from 1.19 88/06/24 smi +.\" +.\" 2007-12-30, mtk, convert function prototypes to modern c syntax +.\" +.th rpc 3 2021-03-22 "" "linux programmer's manual" +.sh name +rpc \- library routines for remote procedure calls +.sh synopsis and description +these routines allow c programs to make procedure +calls on other machines across the network. +first, the client calls a procedure to send a data packet to the server. +upon receipt of the packet, the server calls a dispatch routine +to perform the requested service, and then sends back a reply. +finally, the procedure call returns to the client. +.\" .lp +.\" we don't have an rpc_secure.3 page at the moment -- mtk, 19 sep 05 +.\" routines that are used for secure rpc (des authentication) are described in +.\" .br rpc_secure (3). +.\" secure rpc can be used only if des encryption is available. +.pp +to take use of these routines, include the header file +.ir "" . +.pp +the prototypes below make use of the following types: +.pp +.rs 4 +.ex +.bi "typedef int " bool_t ; +.pp +.bi "typedef bool_t (*" xdrproc_t ")(xdr *, void *, ...);" +.pp +.bi "typedef bool_t (*" resultproc_t ")(caddr_t " resp , +.bi " struct sockaddr_in *" raddr ); +.ee +.re +.pp +see the header files for the declarations of the +.ir auth , +.ir client , +.ir svcxprt , +and +.ir xdr +types. +.pp +.nf +.bi "void auth_destroy(auth *" auth ); +.fi +.ip +a macro that destroys the authentication information associated with +.ir auth . +destruction usually involves deallocation of private data structures. +the use of +.i auth +is undefined after calling +.br auth_destroy (). +.pp +.nf +.bi "auth *authnone_create(void);" +.fi +.ip +create and return an rpc +authentication handle that passes nonusable authentication +information with each remote procedure call. +this is the default authentication used by rpc. +.pp +.nf +.bi "auth *authunix_create(char *" host ", uid_t " uid ", gid_t " gid , +.bi " int " len ", gid_t *" aup_gids ); +.fi +.ip +create and return an rpc authentication handle that contains +authentication information. +the parameter +.i host +is the name of the machine on which the information was created; +.i uid +is the user's user id; +.i gid +is the user's current group id; +.i len +and +.i aup_gids +refer to a counted array of groups to which the user belongs. +it is easy to impersonate a user. +.pp +.nf +.bi "auth *authunix_create_default(void);" +.fi +.ip +calls +.br authunix_create () +with the appropriate parameters. +.pp +.nf +.bi "int callrpc(char *" host ", unsigned long " prognum , +.bi " unsigned long " versnum ", unsigned long " procnum , +.bi " xdrproc_t " inproc ", const char *" in , +.bi " xdrproc_t " outproc ", char *" out ); +.fi +.ip +call the remote procedure associated with +.ir prognum , +.ir versnum , +and +.i procnum +on the machine, +.ir host . +the parameter +.i in +is the address of the procedure's argument(s), and +.i out +is the address of where to place the result(s); +.i inproc +is used to encode the procedure's parameters, and +.i outproc +is used to decode the procedure's results. +this routine returns zero if it succeeds, or the value of +.b "enum clnt_stat" +cast to an integer if it fails. +the routine +.br clnt_perrno () +is handy for translating failure statuses into messages. +.ip +warning: calling remote procedures with this routine +uses udp/ip as a transport; see +.br clntudp_create () +for restrictions. +you do not have control of timeouts or authentication using this routine. +.pp +.nf +.bi "enum clnt_stat clnt_broadcast(unsigned long " prognum , +.bi " unsigned long " versnum ", unsigned long " procnum , +.bi " xdrproc_t " inproc ", char *" in , +.bi " xdrproc_t " outproc ", char *" out , +.bi " resultproc_t " eachresult ); +.fi +.ip +like +.br callrpc (), +except the call message is broadcast to all locally +connected broadcast nets. +each time it receives a response, this routine calls +.br eachresult (), +whose form is: +.ip +.in +4n +.ex +.bi "eachresult(char *" out ", struct sockaddr_in *" addr ); +.ee +.in +.ip +where +.i out +is the same as +.i out +passed to +.br clnt_broadcast (), +except that the remote procedure's output is decoded there; +.i addr +points to the address of the machine that sent the results. +if +.br eachresult () +returns zero, +.br clnt_broadcast () +waits for more replies; otherwise it returns with appropriate status. +.ip +warning: broadcast sockets are limited in size to the +maximum transfer unit of the data link. +for ethernet, this value is 1500 bytes. +.pp +.nf +.bi "enum clnt_stat clnt_call(client *" clnt ", unsigned long " procnum , +.bi " xdrproc_t " inproc ", char *" in , +.bi " xdrproc_t " outproc ", char *" out , +.bi " struct timeval " tout ); +.fi +.ip +a macro that calls the remote procedure +.i procnum +associated with the client handle, +.ir clnt , +which is obtained with an rpc client creation routine such as +.br clnt_create (). +the parameter +.i in +is the address of the procedure's argument(s), and +.i out +is the address of where to place the result(s); +.i inproc +is used to encode the procedure's parameters, and +.i outproc +is used to decode the procedure's results; +.i tout +is the time allowed for results to come back. +.pp +.nf +.bi "clnt_destroy(client *" clnt ); +.fi +.ip +a macro that destroys the client's rpc handle. +destruction usually involves deallocation +of private data structures, including +.i clnt +itself. +use of +.i clnt +is undefined after calling +.br clnt_destroy (). +if the rpc library opened the associated socket, it will close it also. +otherwise, the socket remains open. +.pp +.nf +.bi "client *clnt_create(const char *" host ", unsigned long " prog , +.bi " unsigned long " vers ", const char *" proto ); +.fi +.ip +generic client creation routine. +.i host +identifies the name of the remote host where the server is located. +.i proto +indicates which kind of transport protocol to use. +the currently supported values for this field are \(lqudp\(rq +and \(lqtcp\(rq. +default timeouts are set, but can be modified using +.br clnt_control (). +.ip +warning: using udp has its shortcomings. +since udp-based rpc messages can hold only up to 8 kbytes of encoded data, +this transport cannot be used for procedures that take +large arguments or return huge results. +.pp +.nf +.bi "bool_t clnt_control(client *" cl ", int " req ", char *" info ); +.fi +.ip +a macro used to change or retrieve various information +about a client object. +.i req +indicates the type of operation, and +.i info +is a pointer to the information. +for both udp and tcp, the supported values of +.i req +and their argument types and what they do are: +.ip +.in +4n +.ex +\fbclset_timeout\fp \fistruct timeval\fp // set total timeout +\fbclget_timeout\fp \fistruct timeval\fp // get total timeout +.ee +.in +.ip +note: if you set the timeout using +.br clnt_control (), +the timeout parameter passed to +.br clnt_call () +will be ignored in all future calls. +.ip +.in +4n +.ex +\fbclget_server_addr\fp \fistruct sockaddr_in\fp + // get server\(aqs address +.ee +.in +.ip +the following operations are valid for udp only: +.ip +.in +4n +.ex +\fbclset_retry_timeout\fp \fistruct timeval\fp // set the retry timeout +\fbclget_retry_timeout\fp \fistruct timeval\fp // get the retry timeout +.ee +.in +.ip +the retry timeout is the time that "udp rpc" +waits for the server to reply before +retransmitting the request. +.pp +.nf +.bi "clnt_freeres(client * " clnt ", xdrproc_t " outproc ", char *" out ); +.fi +.ip +a macro that frees any data allocated by the rpc/xdr +system when it decoded the results of an rpc call. +the parameter +.i out +is the address of the results, and +.i outproc +is the xdr routine describing the results. +this routine returns one if the results were successfully freed, +and zero otherwise. +.pp +.nf +.bi "void clnt_geterr(client *" clnt ", struct rpc_err *" errp ); +.fi +.ip +a macro that copies the error structure out of the client +handle to the structure at address +.ir errp . +.pp +.nf +.bi "void clnt_pcreateerror(const char *" s ); +.fi +.ip +print a message to standard error indicating why a client rpc +handle could not be created. +the message is prepended with string +.i s +and a colon. +used when a +.br clnt_create (), +.br clntraw_create (), +.br clnttcp_create (), +or +.br clntudp_create () +call fails. +.pp +.nf +.bi "void clnt_perrno(enum clnt_stat " stat ); +.fi +.ip +print a message to standard error corresponding +to the condition indicated by +.ir stat . +used after +.br callrpc (). +.pp +.nf +.bi "clnt_perror(client *" clnt ", const char *" s ); +.fi +.ip +print a message to standard error indicating why an rpc call failed; +.i clnt +is the handle used to do the call. +the message is prepended with string +.i s +and a colon. +used after +.br clnt_call (). +.pp +.nf +.bi "char *clnt_spcreateerror(const char *" s ); +.fi +.ip +like +.br clnt_pcreateerror (), +except that it returns a string instead of printing to the standard error. +.ip +bugs: returns pointer to static data that is overwritten on each call. +.pp +.nf +.bi "char *clnt_sperrno(enum clnt_stat " stat ); +.fi +.ip +take the same arguments as +.br clnt_perrno (), +but instead of sending a message to the standard error indicating why an rpc +call failed, return a pointer to a string which contains the message. +the string ends with a newline. +.ip +.br clnt_sperrno () +is used instead of +.br clnt_perrno () +if the program does not have a standard error (as a program +running as a server quite likely does not), or if the programmer +does not want the message to be output with +.br printf (3), +or if a message format different than that supported by +.br clnt_perrno () +is to be used. +note: unlike +.br clnt_sperror () +and +.br clnt_spcreateerror (), +.br clnt_sperrno () +returns pointer to static data, but the +result will not get overwritten on each call. +.pp +.nf +.bi "char *clnt_sperror(client *" rpch ", const char *" s ); +.fi +.ip +like +.br clnt_perror (), +except that (like +.br clnt_sperrno ()) +it returns a string instead of printing to standard error. +.ip +bugs: returns pointer to static data that is overwritten on each call. +.pp +.nf +.bi "client *clntraw_create(unsigned long " prognum \ +", unsigned long " versnum ); +.fi +.ip +this routine creates a toy rpc client for the remote program +.ir prognum , +version +.ir versnum . +the transport used to pass messages to the service is +actually a buffer within the process's address space, so the +corresponding rpc server should live in the same address space; see +.br svcraw_create (). +this allows simulation of rpc and acquisition of rpc +overheads, such as round trip times, without any kernel interference. +this routine returns null if it fails. +.pp +.nf +.bi "client *clnttcp_create(struct sockaddr_in *" addr , +.bi " unsigned long " prognum ", unsigned long " versnum , +.bi " int *" sockp ", unsigned int " sendsz \ +", unsigned int " recvsz ); +.fi +.ip +this routine creates an rpc client for the remote program +.ir prognum , +version +.ir versnum ; +the client uses tcp/ip as a transport. +the remote program is located at internet address +.ir *addr . +if +.\"the following inline font conversion is necessary for the hyphen indicator +.i addr\->sin_port +is zero, then it is set to the actual port that the remote +program is listening on (the remote +.b portmap +service is consulted for this information). +the parameter +.i sockp +is a socket; if it is +.br rpc_anysock , +then this routine opens a new one and sets +.ir sockp . +since tcp-based rpc uses buffered i/o, +the user may specify the size of the send and receive buffers +with the parameters +.i sendsz +and +.ir recvsz ; +values of zero choose suitable defaults. +this routine returns null if it fails. +.pp +.nf +.bi "client *clntudp_create(struct sockaddr_in *" addr , +.bi " unsigned long " prognum ", unsigned long " versnum , +.bi " struct timeval " wait ", int *" sockp ); +.fi +.ip +this routine creates an rpc client for the remote program +.ir prognum , +version +.ir versnum ; +the client uses use udp/ip as a transport. +the remote program is located at internet address +.ir addr . +if +.i addr\->sin_port +is zero, then it is set to actual port that the remote +program is listening on (the remote +.b portmap +service is consulted for this information). +the parameter +.i sockp +is a socket; if it is +.br rpc_anysock , +then this routine opens a new one and sets +.ir sockp . +the udp transport resends the call message in intervals of +.i wait +time until a response is received or until the call times out. +the total time for the call to time out is specified by +.br clnt_call (). +.ip +warning: since udp-based rpc messages can hold only up to 8 kbytes +of encoded data, this transport cannot be used for procedures +that take large arguments or return huge results. +.pp +.nf +.bi "client *clntudp_bufcreate(struct sockaddr_in *" addr , +.bi " unsigned long " prognum ", unsigned long " versnum , +.bi " struct timeval " wait ", int *" sockp , +.bi " unsigned int " sendsize ", unsigned int "recosize ); +.fi +.ip +this routine creates an rpc client for the remote program +.ir prognum , +on +.ir versnum ; +the client uses use udp/ip as a transport. +the remote program is located at internet address +.ir addr . +if +.i addr\->sin_port +is zero, then it is set to actual port that the remote +program is listening on (the remote +.b portmap +service is consulted for this information). +the parameter +.i sockp +is a socket; if it is +.br rpc_anysock , +then this routine opens a new one and sets +.ir sockp . +the udp transport resends the call message in intervals of +.i wait +time until a response is received or until the call times out. +the total time for the call to time out is specified by +.br clnt_call (). +.ip +this allows the user to specify the maximum packet +size for sending and receiving udp-based rpc messages. +.pp +.nf +.bi "void get_myaddress(struct sockaddr_in *" addr ); +.fi +.ip +stuff the machine's ip address into +.ir *addr , +without consulting the library routines that deal with +.ir /etc/hosts . +the port number is always set to +.br htons(pmapport) . +.pp +.nf +.bi "struct pmaplist *pmap_getmaps(struct sockaddr_in *" addr ); +.fi +.ip +a user interface to the +.b portmap +service, which returns a list of the current rpc +program-to-port mappings on the host located at ip address +.ir *addr . +this routine can return null. +the command +.ir "rpcinfo\ \-p" +uses this routine. +.pp +.nf +.bi "unsigned short pmap_getport(struct sockaddr_in *" addr , +.bi " unsigned long " prognum ", unsigned long " versnum , +.bi " unsigned int " protocol ); +.fi +.ip +a user interface to the +.b portmap +service, which returns the port number +on which waits a service that supports program number +.ir prognum , +version +.ir versnum , +and speaks the transport protocol associated with +.ir protocol . +the value of +.i protocol +is most likely +.b ipproto_udp +or +.br ipproto_tcp . +a return value of zero means that the mapping does not exist +or that the rpc system failed to contact the remote +.b portmap +service. +in the latter case, the global variable +.i rpc_createerr +contains the rpc status. +.pp +.nf +.bi "enum clnt_stat pmap_rmtcall(struct sockaddr_in *" addr , +.bi " unsigned long " prognum ", unsigned long " versnum , +.bi " unsigned long " procnum , +.bi " xdrproc_t " inproc ", char *" in , +.bi " xdrproc_t " outproc ", char *" out , +.bi " struct timeval " tout ", unsigned long *" portp ); +.fi +.ip +a user interface to the +.b portmap +service, which instructs +.b portmap +on the host at ip address +.i *addr +to make an rpc call on your behalf to a procedure on that host. +the parameter +.i *portp +will be modified to the program's port number if the procedure succeeds. +the definitions of other parameters are discussed +in +.br callrpc () +and +.br clnt_call (). +this procedure should be used for a \(lqping\(rq and nothing else. +see also +.br clnt_broadcast (). +.pp +.nf +.bi "bool_t pmap_set(unsigned long " prognum ", unsigned long " versnum , +.bi " int " protocol ", unsigned short " port ); +.fi +.ip +a user interface to the +.b portmap +service, which establishes a mapping between the triple +.ri [ prognum , versnum , protocol ] +and +.i port +on the machine's +.b portmap +service. +the value of +.i protocol +is most likely +.b ipproto_udp +or +.br ipproto_tcp . +this routine returns one if it succeeds, zero otherwise. +automatically done by +.br svc_register (). +.pp +.nf +.bi "bool_t pmap_unset(unsigned long " prognum ", unsigned long " versnum ); +.fi +.ip +a user interface to the +.b portmap +service, which destroys all mapping between the triple +.ri [ prognum , versnum , * ] +and +.b ports +on the machine's +.b portmap +service. +this routine returns one if it succeeds, zero otherwise. +.pp +.nf +.bi "int registerrpc(unsigned long " prognum ", unsigned long " versnum , +.bi " unsigned long " procnum ", char *(*" procname ")(char *)," +.bi " xdrproc_t " inproc ", xdrproc_t " outproc ); +.fi +.ip +register procedure +.i procname +with the rpc service package. +if a request arrives for program +.ir prognum , +version +.ir versnum , +and procedure +.ir procnum , +.i procname +is called with a pointer to its parameter(s); +.i procname +should return a pointer to its static result(s); +.i inproc +is used to decode the parameters while +.i outproc +is used to encode the results. +this routine returns zero if the registration succeeded, \-1 otherwise. +.ip +warning: remote procedures registered in this form +are accessed using the udp/ip transport; see +.br svcudp_create () +for restrictions. +.pp +.nf +.bi "struct rpc_createerr " rpc_createerr ; +.fi +.ip +a global variable whose value is set by any rpc client creation routine +that does not succeed. +use the routine +.br clnt_pcreateerror () +to print the reason why. +.pp +.nf +.bi "void svc_destroy(svcxprt *" xprt ); +.fi +.ip +a macro that destroys the rpc service transport handle, +.ir xprt . +destruction usually involves deallocation +of private data structures, including +.i xprt +itself. +use of +.i xprt +is undefined after calling this routine. +.pp +.nf +.bi "fd_set " svc_fdset ; +.fi +.ip +a global variable reflecting the rpc service side's +read file descriptor bit mask; it is suitable as a parameter to the +.br select (2) +system call. +this is of interest only if a service implementor does their own +asynchronous event processing, instead of calling +.br svc_run (). +this variable is read-only (do not pass its address to +.br select (2)!), +yet it may change after calls to +.br svc_getreqset () +or any creation routines. +.pp +.nf +.bi "int " svc_fds ; +.fi +.ip +similar to +.br svc_fdset , +but limited to 32 file descriptors. +this interface is obsoleted by +.br svc_fdset . +.pp +.nf +.bi "svc_freeargs(svcxprt *" xprt ", xdrproc_t " inproc ", char *" in ); +.fi +.ip +a macro that frees any data allocated by the rpc/xdr +system when it decoded the arguments to a service procedure using +.br svc_getargs (). +this routine returns 1 if the results were successfully freed, +and zero otherwise. +.pp +.nf +.bi "svc_getargs(svcxprt *" xprt ", xdrproc_t " inproc ", char *" in ); +.fi +.ip +a macro that decodes the arguments of an rpc request +associated with the rpc service transport handle, +.ir xprt . +the parameter +.i in +is the address where the arguments will be placed; +.i inproc +is the xdr routine used to decode the arguments. +this routine returns one if decoding succeeds, and zero otherwise. +.pp +.nf +.bi "struct sockaddr_in *svc_getcaller(svcxprt *" xprt ); +.fi +.ip +the approved way of getting the network address of the caller +of a procedure associated with the rpc service transport handle, +.ir xprt . +.pp +.nf +.bi "void svc_getreqset(fd_set *" rdfds ); +.fi +.ip +this routine is of interest only if a service implementor does not call +.br svc_run (), +but instead implements custom asynchronous event processing. +it is called when the +.br select (2) +system call has determined that an rpc request has arrived on some +rpc socket(s); +.i rdfds +is the resultant read file descriptor bit mask. +the routine returns when all sockets associated with the value of +.i rdfds +have been serviced. +.pp +.nf +.bi "void svc_getreq(int " rdfds ); +.fi +.ip +similar to +.br svc_getreqset (), +but limited to 32 file descriptors. +this interface is obsoleted by +.br svc_getreqset (). +.pp +.nf +.bi "bool_t svc_register(svcxprt *" xprt ", unsigned long " prognum , +.bi " unsigned long " versnum , +.bi " void (*" dispatch ")(struct svc_req *, svcxprt *)," +.bi " unsigned long " protocol ); +.fi +.ip +associates +.i prognum +and +.i versnum +with the service dispatch procedure, +.ir dispatch . +if +.i protocol +is zero, the service is not registered with the +.b portmap +service. +if +.i protocol +is nonzero, then a mapping of the triple +.ri [ prognum , versnum , protocol ] +to +.i xprt\->xp_port +is established with the local +.b portmap +service (generally +.i protocol +is zero, +.b ipproto_udp +or +.br ipproto_tcp ). +the procedure +.i dispatch +has the following form: +.ip +.in +4n +.ex +dispatch(struct svc_req *request, svcxprt *xprt); +.ee +.in +.ip +the +.br svc_register () +routine returns one if it succeeds, and zero otherwise. +.pp +.nf +.b "void svc_run(void);" +.fi +.ip +this routine never returns. +it waits for rpc requests to arrive, and calls the appropriate service +procedure using +.br svc_getreq () +when one arrives. +this procedure is usually waiting for a +.br select (2) +system call to return. +.pp +.nf +.bi "bool_t svc_sendreply(svcxprt *" xprt ", xdrproc_t " outproc \ +", char *" out ); +.fi +.ip +called by an rpc service's dispatch routine to send the results of a +remote procedure call. +the parameter +.i xprt +is the request's associated transport handle; +.i outproc +is the xdr routine which is used to encode the results; and +.i out +is the address of the results. +this routine returns one if it succeeds, zero otherwise. +.pp +.nf +.bi "void svc_unregister(unsigned long " prognum ", unsigned long " versnum ); +.fi +.ip +remove all mapping of the double +.ri [ prognum , versnum ] +to dispatch routines, and of the triple +.ri [ prognum , versnum , * ] +to port number. +.pp +.nf +.bi "void svcerr_auth(svcxprt *" xprt ", enum auth_stat " why ); +.fi +.ip +called by a service dispatch routine that refuses to perform +a remote procedure call due to an authentication error. +.pp +.nf +.bi "void svcerr_decode(svcxprt *" xprt ); +.fi +.ip +called by a service dispatch routine that cannot successfully +decode its parameters. +see also +.br svc_getargs (). +.pp +.nf +.bi "void svcerr_noproc(svcxprt *" xprt ); +.fi +.ip +called by a service dispatch routine that does not implement +the procedure number that the caller requests. +.pp +.nf +.bi "void svcerr_noprog(svcxprt *" xprt ); +.fi +.ip +called when the desired program is not registered with the rpc package. +service implementors usually do not need this routine. +.pp +.nf +.bi "void svcerr_progvers(svcxprt *" xprt ", unsigned long " low_vers , +.bi " unsigned long " high_vers ); +.fi +.ip +called when the desired version of a program is not registered +with the rpc package. +service implementors usually do not need this routine. +.pp +.nf +.bi "void svcerr_systemerr(svcxprt *" xprt ); +.fi +.ip +called by a service dispatch routine when it detects a system +error not covered by any particular protocol. +for example, if a service can no longer allocate storage, +it may call this routine. +.pp +.nf +.bi "void svcerr_weakauth(svcxprt *" xprt ); +.fi +.ip +called by a service dispatch routine that refuses to perform +a remote procedure call due to insufficient authentication parameters. +the routine calls +.br "svcerr_auth(xprt, auth_tooweak)" . +.pp +.nf +.bi "svcxprt *svcfd_create(int " fd ", unsigned int " sendsize , +.bi " unsigned int " recvsize ); +.fi +.ip +create a service on top of any open file descriptor. +typically, this file descriptor is a connected socket for a stream protocol such +as tcp. +.i sendsize +and +.i recvsize +indicate sizes for the send and receive buffers. +if they are zero, a reasonable default is chosen. +.pp +.nf +.bi "svcxprt *svcraw_create(void);" +.fi +.ip +this routine creates a toy rpc +service transport, to which it returns a pointer. +the transport is really a buffer within the process's address space, +so the corresponding rpc client should live in the same address space; see +.br clntraw_create (). +this routine allows simulation of rpc and acquisition of rpc +overheads (such as round trip times), without any kernel interference. +this routine returns null if it fails. +.pp +.nf +.bi "svcxprt *svctcp_create(int " sock ", unsigned int " send_buf_size , +.bi " unsigned int " recv_buf_size ); +.fi +.ip +this routine creates a tcp/ip-based rpc +service transport, to which it returns a pointer. +the transport is associated with the socket +.ir sock , +which may be +.br rpc_anysock , +in which case a new socket is created. +if the socket is not bound to a local tcp +port, then this routine binds it to an arbitrary port. +upon completion, +.i xprt\->xp_sock +is the transport's socket descriptor, and +.i xprt\->xp_port +is the transport's port number. +this routine returns null if it fails. +since tcp-based rpc uses buffered i/o, +users may specify the size of buffers; values of zero +choose suitable defaults. +.pp +.nf +.bi "svcxprt *svcudp_bufcreate(int " sock ", unsigned int " sendsize , +.bi " unsigned int " recosize ); +.fi +.ip +this routine creates a udp/ip-based rpc +service transport, to which it returns a pointer. +the transport is associated with the socket +.ir sock , +which may be +.br rpc_anysock , +in which case a new socket is created. +if the socket is not bound to a local udp +port, then this routine binds it to an arbitrary port. +upon completion, +.i xprt\->xp_sock +is the transport's socket descriptor, and +.i xprt\->xp_port +is the transport's port number. +this routine returns null if it fails. +.ip +this allows the user to specify the maximum packet size for sending and +receiving udp-based rpc messages. +.pp +.nf +.bi "svcxprt *svcudp_create(int " sock ); +.fi +.ip +this call is equivalent to +.i svcudp_bufcreate(sock,sz,sz) +for some default size +.ir sz . +.pp +.nf +.bi "bool_t xdr_accepted_reply(xdr *" xdrs ", struct accepted_reply *" ar ); +.fi +.ip +used for encoding rpc reply messages. +this routine is useful for users who wish to generate +rpc-style messages without using the rpc package. +.pp +.nf +.bi "bool_t xdr_authunix_parms(xdr *" xdrs ", struct authunix_parms *" aupp ); +.fi +.ip +used for describing unix credentials. +this routine is useful for users +who wish to generate these credentials without using the rpc +authentication package. +.pp +.nf +.bi "void xdr_callhdr(xdr *" xdrs ", struct rpc_msg *" chdr ); +.fi +.ip +used for describing rpc call header messages. +this routine is useful for users who wish to generate +rpc-style messages without using the rpc package. +.pp +.nf +.bi "bool_t xdr_callmsg(xdr *" xdrs ", struct rpc_msg *" cmsg ); +.fi +.ip +used for describing rpc call messages. +this routine is useful for users who wish to generate rpc-style +messages without using the rpc package. +.pp +.nf +.bi "bool_t xdr_opaque_auth(xdr *" xdrs ", struct opaque_auth *" ap ); +.fi +.ip +used for describing rpc authentication information messages. +this routine is useful for users who wish to generate +rpc-style messages without using the rpc package. +.pp +.nf +.bi "bool_t xdr_pmap(xdr *" xdrs ", struct pmap *" regs ); +.fi +.ip +used for describing parameters to various +.b portmap +procedures, externally. +this routine is useful for users who wish to generate +these parameters without using the +.b pmap +interface. +.pp +.nf +.bi "bool_t xdr_pmaplist(xdr *" xdrs ", struct pmaplist **" rp ); +.fi +.ip +used for describing a list of port mappings, externally. +this routine is useful for users who wish to generate +these parameters without using the +.b pmap +interface. +.pp +.nf +.bi "bool_t xdr_rejected_reply(xdr *" xdrs ", struct rejected_reply *" rr ); +.fi +.ip +used for describing rpc reply messages. +this routine is useful for users who wish to generate +rpc-style messages without using the rpc package. +.pp +.nf +.bi "bool_t xdr_replymsg(xdr *" xdrs ", struct rpc_msg *" rmsg ); +.fi +.ip +used for describing rpc reply messages. +this routine is useful for users who wish to generate +rpc style messages without using the rpc package. +.pp +.nf +.bi "void xprt_register(svcxprt *" xprt ); +.fi +.ip +after rpc service transport handles are created, +they should register themselves with the rpc service package. +this routine modifies the global variable +.ir svc_fds . +service implementors usually do not need this routine. +.pp +.nf +.bi "void xprt_unregister(svcxprt *" xprt ); +.fi +.ip +before an rpc service transport handle is destroyed, +it should unregister itself with the rpc service package. +this routine modifies the global variable +.ir svc_fds . +service implementors usually do not need this routine. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br auth_destroy (), +.br authnone_create (), +.br authunix_create (), +.br authunix_create_default (), +.br callrpc (), +.br clnt_broadcast (), +.br clnt_call (), +.br clnt_destroy (), +.br clnt_create (), +.br clnt_control (), +.br clnt_freeres (), +.br clnt_geterr (), +.br clnt_pcreateerror (), +.br clnt_perrno (), +.br clnt_perror (), +.br clnt_spcreateerror (), +.br clnt_sperrno (), +.br clnt_sperror (), +.br clntraw_create (), +.br clnttcp_create (), +.br clntudp_create (), +.br clntudp_bufcreate (), +.br get_myaddress (), +.br pmap_getmaps (), +.br pmap_getport (), +.br pmap_rmtcall (), +.br pmap_set (), +.br pmap_unset (), +.br registerrpc (), +.br svc_destroy (), +.br svc_freeargs (), +.br svc_getargs (), +.br svc_getcaller (), +.br svc_getreqset (), +.br svc_getreq (), +.br svc_register (), +.br svc_run (), +.br svc_sendreply (), +.br svc_unregister (), +.br svcerr_auth (), +.br svcerr_decode (), +.br svcerr_noproc (), +.br svcerr_noprog (), +.br svcerr_progvers (), +.br svcerr_systemerr (), +.br svcerr_weakauth (), +.br svcfd_create (), +.br svcraw_create (), +.br svctcp_create (), +.br svcudp_bufcreate (), +.br svcudp_create (), +.br xdr_accepted_reply (), +.br xdr_authunix_parms (), +.br xdr_callhdr (), +.br xdr_callmsg (), +.br xdr_opaque_auth (), +.br xdr_pmap (), +.br xdr_pmaplist (), +.br xdr_rejected_reply (), +.br xdr_replymsg (), +.br xprt_register (), +.br xprt_unregister () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh see also +.\" we don't have an rpc_secure.3 page in the set at the moment -- mtk, 19 sep 05 +.\" .br rpc_secure (3), +.br xdr (3) +.pp +the following manuals: +.rs +remote procedure calls: protocol specification +.br +remote procedure call programming guide +.br +rpcgen programming guide +.br +.re +.pp +.ir "rpc: remote procedure call protocol specification" , +rfc\ 1050, sun microsystems, inc., +usc-isi. +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" iso/iec 9899:1999 +.\" +.th wcscmp 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +wcscmp \- compare two wide-character strings +.sh synopsis +.nf +.b #include +.pp +.bi "int wcscmp(const wchar_t *" s1 ", const wchar_t *" s2 ); +.fi +.sh description +the +.br wcscmp () +function is the wide-character equivalent +of the +.br strcmp (3) +function. +it compares the wide-character string pointed to by +.i s1 +and the +wide-character string pointed to by +.ir s2 . +.sh return value +the +.br wcscmp () +function returns zero if the wide-character strings at +.i s1 +and +.i s2 +are equal. +it returns an integer greater than zero if +at the first differing position +.ir i , +the corresponding wide-character +.i s1[i] +is greater than +.ir s2[i] . +it returns an integer less than zero if +at the first differing position +.ir i , +the corresponding wide-character +.i s1[i] +is less than +.ir s2[i] . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br wcscmp () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh see also +.br strcmp (3), +.br wcscasecmp (3), +.br wmemcmp (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1993 by thomas koenig (ig25@rz.uni-karlsruhe.de) +.\" and copyright 1999 by bruno haible (haible@clisp.cons.org) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified sat jul 24 18:20:12 1993 by rik faith (faith@cs.unc.edu) +.\" modified tue jul 15 16:49:10 1997 by andries brouwer (aeb@cwi.nl) +.\" modified sun jul 4 14:52:16 1999 by bruno haible (haible@clisp.cons.org) +.\" modified tue aug 24 17:11:01 1999 by andries brouwer (aeb@cwi.nl) +.\" modified tue feb 6 03:31:55 2001 by andries brouwer (aeb@cwi.nl) +.\" +.th setlocale 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +setlocale \- set the current locale +.sh synopsis +.nf +.b #include +.pp +.bi "char *setlocale(int " category ", const char *" locale ); +.fi +.sh description +the +.br setlocale () +function is used to set or query the program's current locale. +.pp +if +.i locale +is not null, +the program's current locale is modified according to the arguments. +the argument +.i category +determines which parts of the program's current locale should be modified. +.ad l +.nh +.ts +lb lb +lb lx. +category governs +lc_all all of the locale +lc_address t{ +formatting of addresses and +geography-related items (*) +t} +lc_collate string collation +lc_ctype character classification +lc_identification t{ +metadata describing the locale (*) +t} +lc_measurement t{ +settings related to measurements +(metric versus us customary) (*) +t} +lc_messages t{ +localizable natural-language messages +t} +lc_monetary t{ +formatting of monetary values +t} +lc_name t{ +formatting of salutations for persons (*) +t} +lc_numeric t{ +formatting of nonmonetary numeric values +t} +lc_paper t{ +settings related to the standard paper size (*) +t} +lc_telephone t{ +formats to be used with telephone services (*) +t} +lc_time t{ +formatting of date and time values +t} +.te +.hy +.ad +.pp +the categories marked with an asterisk in the above table +are gnu extensions. +for further information on these locale categories, see +.br locale (7). +.pp +the argument +.i locale +is a pointer to a character string containing the +required setting of +.ir category . +such a string is either a well-known constant like "c" or "da_dk" +(see below), or an opaque string that was returned by another call of +.br setlocale (). +.pp +if +.i locale +is an empty string, +.br """""" , +each part of the locale that should be modified is set according to the +environment variables. +the details are implementation-dependent. +for glibc, first (regardless of +.ir category ), +the environment variable +.b lc_all +is inspected, +next the environment variable with the same name as the category +(see the table above), +and finally the environment variable +.br lang . +the first existing environment variable is used. +if its value is not a valid locale specification, the locale +is unchanged, and +.br setlocale () +returns null. +.pp +the locale +.b """c""" +or +.b """posix""" +is a portable locale; +it exists on all conforming systems. +.pp +a locale name is typically of the form +.ir language "[_" territory "][." codeset "][@" modifier "]," +where +.i language +is an iso 639 language code, +.i territory +is an iso 3166 country code, and +.i codeset +is a character set or encoding identifier like +.b "iso\-8859\-1" +or +.br "utf\-8" . +for a list of all supported locales, try "locale \-a" (see +.br locale (1)). +.pp +if +.i locale +is null, the current locale is only queried, not modified. +.pp +on startup of the main program, the portable +.b """c""" +locale is selected as default. +a program may be made portable to all locales by calling: +.pp +.in +4n +.ex +setlocale(lc_all, ""); +.ee +.in +.pp +after program initialization, and then: +.ip \(bu 2 +using the values returned from a +.br localeconv (3) +call for locale-dependent information; +.ip \(bu +using the multibyte and wide character functions for text processing if +.br "mb_cur_max > 1" ; +.ip \(bu +using +.br strcoll (3) +and +.br strxfrm (3) +to compare strings; and +.ip \(bu +using +.br wcscoll (3) +and +.br wcsxfrm (3) +to compare wide-character strings. +.sh return value +a successful call to +.br setlocale () +returns an opaque string that corresponds to the locale set. +this string may be allocated in static storage. +the string returned is such that a subsequent call with that string +and its associated category will restore that part of the process's +locale. +the return value is null if the request cannot be honored. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br setlocale () +t} thread safety mt-unsafe const:locale env +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c89, c99. +.pp +the c standards specify only the categories +.br lc_all , +.br lc_collate , +.br lc_ctype , +.br lc_monetary , +.br lc_numeric , +and +.br lc_time . +posix.1 adds +.br lc_messages . +the remaining categories are gnu extensions. +.sh see also +.br locale (1), +.br localedef (1), +.br isalpha (3), +.br localeconv (3), +.br nl_langinfo (3), +.br rpmatch (3), +.br strcoll (3), +.br strftime (3), +.br charsets (7), +.br locale (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/termios.3 + +.so man3/pow.3 + +.\" copyright (c) 1990, 1991 the regents of the university of california. +.\" and copyright (c) 2020 arkadiusz drabczyk +.\" all rights reserved. +.\" +.\" this code is derived from software contributed to berkeley by +.\" chris torek and the american national standards committee x3, +.\" on information processing systems. +.\" +.\" %%%license_start(bsd_4_clause_ucb) +.\" redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. all advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" this product includes software developed by the university of +.\" california, berkeley and its contributors. +.\" 4. neither the name of the university nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" this software is provided by the regents and contributors ``as is'' and +.\" any express or implied warranties, including, but not limited to, the +.\" implied warranties of merchantability and fitness for a particular purpose +.\" are disclaimed. in no event shall the regents or contributors be liable +.\" for any direct, indirect, incidental, special, exemplary, or consequential +.\" damages (including, but not limited to, procurement of substitute goods +.\" or services; loss of use, data, or profits; or business interruption) +.\" however caused and on any theory of liability, whether in contract, strict +.\" liability, or tort (including negligence or otherwise) arising in any way +.\" out of the use of this software, even if advised of the possibility of +.\" such damage. +.\" %%%license_end +.\" +.\" @(#)fread.3 6.6 (berkeley) 6/29/91 +.\" +.\" converted for linux, mon nov 29 15:37:33 1993, faith@cs.unc.edu +.\" sun feb 19 21:26:54 1995 by faith, return values +.\" modified thu apr 20 20:43:53 1995 by jim van zandt +.\" modified fri may 17 10:21:51 1996 by martin schulze +.\" +.th fread 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +fread, fwrite \- binary stream input/output +.sh synopsis +.nf +.b #include +.pp +.bi "size_t fread(void *restrict " ptr ", size_t " size ", size_t " nmemb , +.bi " file *restrict " stream ); +.bi "size_t fwrite(const void *restrict " ptr ", size_t " size \ +", size_t " nmemb , +.bi " file *restrict " stream ); +.fi +.sh description +the function +.br fread () +reads +.i nmemb +items of data, each +.i size +bytes long, from the stream pointed to by +.ir stream , +storing them at the location given by +.ir ptr . +.pp +the function +.br fwrite () +writes +.i nmemb +items of data, each +.i size +bytes long, to the stream pointed to by +.ir stream , +obtaining them from the location given by +.ir ptr . +.pp +for nonlocking counterparts, see +.br unlocked_stdio (3). +.sh return value +on success, +.br fread () +and +.br fwrite () +return the number of items read or written. +this number equals the number of bytes transferred only when +.i size +is 1. +if an error occurs, or the end of the file is reached, +the return value is a short item count (or zero). +.pp +the file position indicator for the stream is advanced by the number +of bytes successfully read or written. +.pp +.br fread () +does not distinguish between end-of-file and error, and callers must use +.br feof (3) +and +.br ferror (3) +to determine which occurred. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br fread (), +.br fwrite () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c89. +.sh examples +the program below demonstrates the use of +.br fread () +by parsing /bin/sh elf executable in binary mode and printing its +magic and class: +.pp +.in +4n +.ex +$ \fb./a.out\fp +elf magic: 0x7f454c46 +class: 0x02 +.ee +.in +.ss program source +\& +.ex +#include +#include + +#define array_size(arr) (sizeof(arr) / sizeof((arr)[0])) + +int +main(void) +{ + file *fp = fopen("/bin/sh", "rb"); + if (!fp) { + perror("fopen"); + return exit_failure; + } + + unsigned char buffer[4]; + + size_t ret = fread(buffer, sizeof(*buffer), array_size(buffer), fp); + if (ret != array_size(buffer)) { + fprintf(stderr, "fread() failed: %zu\en", ret); + exit(exit_failure); + } + + printf("elf magic: %#04x%02x%02x%02x\en", buffer[0], buffer[1], + buffer[2], buffer[3]); + + ret = fread(buffer, 1, 1, fp); + if (ret != 1) { + fprintf(stderr, "fread() failed: %zu\en", ret); + exit(exit_failure); + } + + printf("class: %#04x\en", buffer[0]); + + fclose(fp); + + exit(exit_success); +} +.ee +.sh see also +.br read (2), +.br write (2), +.br feof (3), +.br ferror (3), +.br unlocked_stdio (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2016, michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th nextup 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +nextup, nextupf, nextupl, nextdown, nextdownf, nextdownl \- +return next floating-point number toward positive/negative infinity +.sh synopsis +.nf +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "double nextup(double " x ); +.bi "float nextupf(float " x ); +.bi "long double nextupl(long double " x ); +.pp +.bi "double nextdown(double " x ); +.bi "float nextdownf(float " x ); +.bi "long double nextdownl(long double " x ); +.fi +.pp +link with \fi\-lm\fp. +.sh description +the +.br nextup (), +.br nextupf (), +and +.br nextupl () +functions return the next representable floating-point number greater than +.ir x . +.pp +if +.i x +is the smallest representable negative number in the corresponding type, +these functions return \-0. +if +.i x +is 0, the returned value is the smallest representable positive number +of the corresponding type. +.pp +if +.i x +is positive infinity, the returned value is positive infinity. +if +.i x +is negative infinity, +the returned value is the largest representable finite negative number +of the corresponding type. +.pp +if +.i x +is nan, +the returned value is nan. +.pp +the value returned by +.ir nextdown(x) +is +.ir \-nextup(\-x) , +and similarly for the other types. +.sh return value +see description. +.\" .sh errors +.sh versions +these functions first appeared in glibc in version 2.24. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br nextup (), +.br nextupf (), +.br nextupl (), +.br nextdown (), +.br nextdownf (), +.br nextdownl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +these functions are described in +.ir "ieee std 754-2008 - standard for floating-point arithmetic" +and +.ir "iso/iec ts 18661". +.sh see also +.br nearbyint (3), +.br nextafter (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1993 rickard e. faith (faith@cs.unc.edu) and +.\" and copyright 2006 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified 21 aug 1994 by michael chastain : +.\" removed note about old libc (pre-4.5.26) translating to 'sync'. +.\" modified 15 apr 1995 by michael chastain : +.\" added `see also' section. +.\" modified 13 apr 1996 by markus kuhn +.\" added remarks about fdatasync. +.\" modified 31 jan 1997 by eric s. raymond +.\" modified 18 apr 2001 by andi kleen +.\" fix description to describe what it really does; add a few caveats. +.\" 2006-04-28, mtk, substantial rewrite of various parts. +.\" 2012-02-27 various changes by christoph hellwig +.\" +.th fsync 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +fsync, fdatasync \- synchronize a file's in-core state with storage device +.sh synopsis +.nf +.b #include +.pp +.bi "int fsync(int " fd ); +.pp +.bi "int fdatasync(int " fd ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.nf +.br fsync (): + glibc 2.16 and later: + no feature test macros need be defined + glibc up to and including 2.15: + _bsd_source || _xopen_source + || /* since glibc 2.8: */ _posix_c_source >= 200112l +.fi +.pp +.br fdatasync (): +.nf + _posix_c_source >= 199309l || _xopen_source >= 500 +.fi +.sh description +.br fsync () +transfers ("flushes") all modified in-core data of +(i.e., modified buffer cache pages for) the +file referred to by the file descriptor +.i fd +to the disk device (or other permanent storage device) so that all +changed information can be retrieved even if the system crashes or +is rebooted. +this includes writing through or flushing a disk cache if present. +the call blocks until the device reports that the transfer has completed. +.pp +as well as flushing the file data, +.br fsync () +also flushes the metadata information associated with the file (see +.br inode (7)). +.pp +calling +.br fsync () +does not necessarily ensure +that the entry in the directory containing the file has also reached disk. +for that an explicit +.br fsync () +on a file descriptor for the directory is also needed. +.pp +.br fdatasync () +is similar to +.br fsync (), +but does not flush modified metadata unless that metadata +is needed in order to allow a subsequent data retrieval to be +correctly handled. +for example, changes to +.i st_atime +or +.i st_mtime +(respectively, time of last access and +time of last modification; see +.br inode (7)) +do not require flushing because they are not necessary for +a subsequent data read to be handled correctly. +on the other hand, a change to the file size +.ri ( st_size , +as made by say +.br ftruncate (2)), +would require a metadata flush. +.pp +the aim of +.br fdatasync () +is to reduce disk activity for applications that do not +require all metadata to be synchronized with the disk. +.sh return value +on success, these system calls return zero. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b ebadf +.i fd +is not a valid open file descriptor. +.tp +.b eio +an error occurred during synchronization. +this error may relate to data written to some other file descriptor +on the same file. +since linux 4.13, +.\" commit 088737f44bbf6378745f5b57b035e57ee3dc4750 +errors from write-back will be reported to +all file descriptors that might have written the data which triggered +the error. +some filesystems (e.g., nfs) keep close track of which data +came through which file descriptor, and give more precise reporting. +other filesystems (e.g., most local filesystems) will report errors to +all file descriptors that were open on the file when the error was recorded. +.tp +.b enospc +disk space was exhausted while synchronizing. +.tp +.br erofs ", " einval +.i fd +is bound to a special file (e.g., a pipe, fifo, or socket) +which does not support synchronization. +.tp +.br enospc ", " edquot +.i fd +is bound to a file on nfs or another filesystem which does not allocate +space at the time of a +.br write (2) +system call, and some previous write failed due to insufficient +storage space. +.sh conforming to +posix.1-2001, posix.1-2008, 4.3bsd. +.pp +on posix systems on which +.br fdatasync () +is available, +.b _posix_synchronized_io +is defined in +.i +to a value greater than 0. +(see also +.br sysconf (3).) +.\" posix.1-2001: it shall be defined to -1 or 0 or 200112l. +.\" -1: unavailable, 0: ask using sysconf(). +.\" glibc defines them to 1. +.sh notes +on some unix systems (but not linux), +.i fd +must be a +.i writable +file descriptor. +.pp +in linux 2.2 and earlier, +.br fdatasync () +is equivalent to +.br fsync (), +and so has no performance advantage. +.pp +the +.br fsync () +implementations in older kernels and lesser used filesystems +do not know how to flush disk caches. +in these cases disk caches need to be disabled using +.br hdparm (8) +or +.br sdparm (8) +to guarantee safe operation. +.sh see also +.br sync (1), +.br bdflush (2), +.br open (2), +.br posix_fadvise (2), +.br pwritev (2), +.br sync (2), +.br sync_file_range (2), +.br fflush (3), +.br fileno (3), +.br hdparm (8), +.br mount (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/scalbln.3 + +.so man4/mem.4 + +.so man3/rpc.3 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" and copyright (c) 2008 linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" libc.info (from glibc distribution) +.\" modified sat jul 24 19:12:00 1993 by rik faith +.\" modified sun sep 3 20:29:36 1995 by jim van zandt +.\" changed network into host byte order (for inet_network), +.\" andreas jaeger , 980130. +.\" 2008-06-19, mtk +.\" describe the various address forms supported by inet_aton(). +.\" clarify discussion of inet_lnaof(), inet_netof(), and inet_makeaddr(). +.\" add discussion of classful addressing, noting that it is obsolete. +.\" added an example program. +.\" +.th inet 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +inet_aton, inet_addr, inet_network, inet_ntoa, inet_makeaddr, inet_lnaof, +inet_netof \- internet address manipulation routines +.sh synopsis +.nf +.b #include +.b #include +.b #include +.pp +.bi "int inet_aton(const char *" cp ", struct in_addr *" inp ); +.pp +.bi "in_addr_t inet_addr(const char *" cp ); +.bi "in_addr_t inet_network(const char *" cp ); +.pp +.bi "char *inet_ntoa(struct in_addr " in ); +.pp +.bi "struct in_addr inet_makeaddr(in_addr_t " net ", in_addr_t " host ); +.pp +.bi "in_addr_t inet_lnaof(struct in_addr " in ); +.bi "in_addr_t inet_netof(struct in_addr " in ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br inet_aton (), +.br inet_ntoa (): +.nf + since glibc 2.19: + _default_source + in glibc up to and including 2.19: + _bsd_source || _bsd_source +.fi +.sh description +.br inet_aton () +converts the internet host address \ficp\fp from the +ipv4 numbers-and-dots notation into binary form (in network byte order) +and stores it in the structure that \fiinp\fp points to. +.br inet_aton () +returns nonzero if the address is valid, zero if not. +the address supplied in +.i cp +can have one of the following forms: +.tp 10 +.i a.b.c.d +each of the four numeric parts specifies a byte of the address; +the bytes are assigned in left-to-right order to produce the binary address. +.tp +.i a.b.c +parts +.i a +and +.i b +specify the first two bytes of the binary address. +part +.i c +is interpreted as a 16-bit value that defines the rightmost two bytes +of the binary address. +this notation is suitable for specifying (outmoded) class b +network addresses. +.tp +.i a.b +part +.i a +specifies the first byte of the binary address. +part +.i b +is interpreted as a 24-bit value that defines the rightmost three bytes +of the binary address. +this notation is suitable for specifying (outmoded) class a +network addresses. +.tp +.i a +the value +.i a +is interpreted as a 32-bit value that is stored directly +into the binary address without any byte rearrangement. +.pp +in all of the above forms, +components of the dotted address can be specified in decimal, +octal (with a leading +.ir 0 ), +or hexadecimal, with a leading +.ir 0x ). +addresses in any of these forms are collectively termed +.ir "ipv4 numbers-and-dots notation" . +the form that uses exactly four decimal numbers is referred to as +.ir "ipv4 dotted-decimal notation" +(or sometimes: +.ir "ipv4 dotted-quad notation" ). +.pp +.br inet_aton () +returns 1 if the supplied string was successfully interpreted, +or 0 if the string is invalid +.rb ( errno +is +.i not +set on error). +.pp +the +.br inet_addr () +function converts the internet host address +\ficp\fp from ipv4 numbers-and-dots notation into binary data in network +byte order. +if the input is invalid, +.b inaddr_none +(usually \-1) is returned. +use of this function is problematic because \-1 is a valid address +(255.255.255.255). +avoid its use in favor of +.br inet_aton (), +.br inet_pton (3), +or +.br getaddrinfo (3), +which provide a cleaner way to indicate error return. +.pp +the +.br inet_network () +function converts +.ir cp , +a string in ipv4 numbers-and-dots notation, +into a number in host byte order suitable for use as an +internet network address. +on success, the converted address is returned. +if the input is invalid, \-1 is returned. +.pp +the +.br inet_ntoa () +function converts the internet host address +\fiin\fp, given in network byte order, to a string in ipv4 +dotted-decimal notation. +the string is returned in a statically +allocated buffer, which subsequent calls will overwrite. +.pp +the +.br inet_lnaof () +function returns the local network address part +of the internet address \fiin\fp. +the returned value is in host byte order. +.pp +the +.br inet_netof () +function returns the network number part of +the internet address \fiin\fp. +the returned value is in host byte order. +.pp +the +.br inet_makeaddr () +function is the converse of +.br inet_netof () +and +.br inet_lnaof (). +it returns an internet host address in network byte order, +created by combining the network number \finet\fp +with the local address \fihost\fp, both in +host byte order. +.pp +the structure \fiin_addr\fp as used in +.br inet_ntoa (), +.br inet_makeaddr (), +.br inet_lnaof (), +and +.br inet_netof () +is defined in +.i +as: +.pp +.in +4n +.ex +typedef uint32_t in_addr_t; + +struct in_addr { + in_addr_t s_addr; +}; +.ee +.in +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br inet_aton (), +.br inet_addr (), +.br inet_network (), +.br inet_ntoa () +t} thread safety mt-safe locale +t{ +.br inet_makeaddr (), +.br inet_lnaof (), +.br inet_netof () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +.br inet_addr (), +.br inet_ntoa (): +posix.1-2001, posix.1-2008, 4.3bsd. +.pp +.br inet_aton () +is not specified in posix.1, but is available on most systems. +.sh notes +on x86 architectures, the host byte order is least significant byte +first (little endian), whereas the network byte order, as used on the +internet, is most significant byte first (big endian). +.pp +.br inet_lnaof (), +.br inet_netof (), +and +.br inet_makeaddr () +are legacy functions that assume they are dealing with +.ir "classful network addresses" . +classful networking divides ipv4 network addresses into host and network +components at byte boundaries, as follows: +.tp 10 +class a +this address type is indicated by the value 0 in the +most significant bit of the (network byte ordered) address. +the network address is contained in the most significant byte, +and the host address occupies the remaining three bytes. +.tp +class b +this address type is indicated by the binary value 10 in the +most significant two bits of the address. +the network address is contained in the two most significant bytes, +and the host address occupies the remaining two bytes. +.tp +class c +this address type is indicated by the binary value 110 in the +most significant three bits of the address. +the network address is contained in the three most significant bytes, +and the host address occupies the remaining byte. +.pp +classful network addresses are now obsolete, +having been superseded by classless inter-domain routing (cidr), +which divides addresses into network and host components at +arbitrary bit (rather than byte) boundaries. +.sh examples +an example of the use of +.br inet_aton () +and +.br inet_ntoa () +is shown below. +here are some example runs: +.pp +.in +4n +.ex +.rb "$" " ./a.out 226.000.000.037" " # last byte is in octal" +226.0.0.31 +.rb "$" " ./a.out 0x7f.1 " " # first byte is in hex" +127.0.0.1 +.ee +.in +.ss program source +\& +.ex +#define _bsd_source +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + struct in_addr addr; + + if (argc != 2) { + fprintf(stderr, "%s \en", argv[0]); + exit(exit_failure); + } + + if (inet_aton(argv[1], &addr) == 0) { + fprintf(stderr, "invalid address\en"); + exit(exit_failure); + } + + printf("%s\en", inet_ntoa(addr)); + exit(exit_success); +} +.ee +.sh see also +.br byteorder (3), +.br getaddrinfo (3), +.br gethostbyname (3), +.br getnameinfo (3), +.br getnetent (3), +.br inet_net_pton (3), +.br inet_ntop (3), +.br inet_pton (3), +.br hosts (5), +.br networks (5) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/wprintf.3 + +.so man3/getaddrinfo.3 + +.\" copyright 2003 walter harms, 2004 andries brouwer . +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" created 2004-10-31. text taken from a page by walter harms, 2003-09-08 +.\" +.th drand48_r 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +drand48_r, erand48_r, lrand48_r, nrand48_r, mrand48_r, jrand48_r, +srand48_r, seed48_r, lcong48_r +\- generate uniformly distributed pseudo-random numbers reentrantly +.sh synopsis +.nf +.b #include +.pp +.bi "int drand48_r(struct drand48_data *restrict " buffer , +.bi " double *restrict " result ); +.bi "int erand48_r(unsigned short " xsubi [3] "," +.bi " struct drand48_data *restrict "buffer , +.bi " double *restrict " result ");" +.pp +.bi "int lrand48_r(struct drand48_data *restrict " buffer , +.bi " long *restrict " result ); +.bi "int nrand48_r(unsigned short " xsubi[3] "," +.bi " struct drand48_data *restrict "buffer , +.bi " long *restrict " result ");" +.pp +.bi "int mrand48_r(struct drand48_data *restrict " buffer , +.bi " long *restrict " result ");" +.bi "int jrand48_r(unsigned short " xsubi[3] "," +.bi " struct drand48_data *restrict " buffer , +.bi " long *restrict " result ");" +.pp +.bi "int srand48_r(long int " seedval ", struct drand48_data *" buffer ");" +.bi "int seed48_r(unsigned short " seed16v[3] ", struct drand48_data *" buffer ); +.bi "int lcong48_r(unsigned short " param[7] ", struct drand48_data *" buffer ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +all functions shown above: +.\" .br drand48_r (), +.\" .br erand48_r (), +.\" .br lrand48_r (), +.\" .br nrand48_r (), +.\" .br mrand48_r (), +.\" .br jrand48_r (), +.\" .br srand48_r (), +.\" .br seed48_r (), +.\" .br lcong48_r (): +.nf + /* glibc since 2.19: */ _default_source + || /* glibc <= 2.19: */ _svid_source || _bsd_source +.fi +.sh description +these functions are the reentrant analogs of the functions described in +.br drand48 (3). +instead of modifying the global random generator state, they use +the supplied data +.ir buffer . +.pp +before the first use, this struct must be initialized, for example, +by filling it with zeros, or by calling one of the functions +.br srand48_r (), +.br seed48_r (), +or +.br lcong48_r (). +.sh return value +the return value is 0. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br drand48_r (), +.br erand48_r (), +.br lrand48_r (), +.br nrand48_r (), +.br mrand48_r (), +.br jrand48_r (), +.br srand48_r (), +.br seed48_r (), +.br lcong48_r () +t} thread safety mt-safe race:buffer +.te +.hy +.ad +.sp 1 +.sh conforming to +these functions are gnu extensions and are not portable. +.sh see also +.br drand48 (3), +.br rand (3), +.br random (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) international business machines orp., 2006 +.\" +.\" %%%license_start(gplv2+_sw_3_para) +.\" this program is free software; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" this program 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" history: +.\" 2006-04-27, created by eduardo m. fleury +.\" with various additions by michael kerrisk +.\" +.\" +.th ioprio_set 2 2021-06-20 "linux" "linux programmer's manual" +.sh name +ioprio_get, ioprio_set \- get/set i/o scheduling class and priority +.sh synopsis +.nf +.br "#include " "/* definition of " ioprio_* " constants */" +.br "#include " "/* definition of " sys_* " constants */" +.b #include +.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 : +glibc provides no wrappers for these system calls, +necessitating the use of +.br syscall (2). +.sh description +the +.br ioprio_get () +and +.br ioprio_set () +system calls get and set the i/o scheduling class and +priority of one or more threads. +.pp +the +.i which +and +.i who +arguments identify the thread(s) on which the system +calls operate. +the +.i which +argument determines how +.i who +is interpreted, and has one of the following values: +.tp +.b ioprio_who_process +.i who +is a process id or thread id identifying a single process or thread. +if +.i who +is 0, then operate on the calling thread. +.tp +.b ioprio_who_pgrp +.i who +is a process group id identifying all the members of a process group. +if +.i who +is 0, then operate on the process group of which the caller is a member. +.tp +.b ioprio_who_user +.i who +is a user id identifying all of the processes that +have a matching real uid. +.\" fixme . need to document the behavior when 'who" is specified as 0 +.\" see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=652443 +.pp +if +.i which +is specified as +.b ioprio_who_pgrp +or +.b ioprio_who_user +when calling +.br ioprio_get (), +and more than one process matches +.ir who , +then the returned priority will be the highest one found among +all of the matching processes. +one priority is said to be +higher than another one if it belongs to a higher priority +class +.rb ( ioprio_class_rt +is the highest priority class; +.b ioprio_class_idle +is the lowest) +or if it belongs to the same priority class as the other process but +has a higher priority level (a lower priority number means a +higher priority level). +.pp +the +.i ioprio +argument given to +.br ioprio_set () +is a bit mask that specifies both the scheduling class and the +priority to be assigned to the target process(es). +the following macros are used for assembling and dissecting +.i ioprio +values: +.tp +.bi ioprio_prio_value( class ", " data ) +given a scheduling +.i class +and priority +.ri ( data ), +this macro combines the two values to produce an +.i ioprio +value, which is returned as the result of the macro. +.tp +.bi ioprio_prio_class( mask ) +given +.i mask +(an +.i ioprio +value), this macro returns its i/o class component, that is, +one of the values +.br ioprio_class_rt , +.br ioprio_class_be , +or +.br ioprio_class_idle . +.tp +.bi ioprio_prio_data( mask ) +given +.i mask +(an +.i ioprio +value), this macro returns its priority +.ri ( data ) +component. +.pp +see the notes section for more +information on scheduling classes and priorities, +as well as the meaning of specifying +.i ioprio +as 0. +.pp +i/o priorities are supported for reads and for synchronous +.rb ( o_direct , +.br o_sync ) +writes. +i/o priorities are not supported for asynchronous +writes because they are issued outside the context of the program +dirtying the memory, and thus program-specific priorities do not apply. +.sh return value +on success, +.br ioprio_get () +returns the +.i ioprio +value of the process with highest i/o priority of any of the processes +that match the criteria specified in +.i which +and +.ir who . +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.pp +on success, +.br ioprio_set () +returns 0. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b einval +invalid value for +.i which +or +.ir ioprio . +refer to the notes section for available scheduler +classes and priority levels for +.ir ioprio . +.tp +.b eperm +the calling process does not have the privilege needed to assign this +.i ioprio +to the specified process(es). +see the notes section for more information on required +privileges for +.br ioprio_set (). +.tp +.b esrch +no process(es) could be found that matched the specification in +.i which +and +.ir who . +.sh versions +these system calls have been available on linux since +kernel 2.6.13. +.sh conforming to +these system calls are linux-specific. +.sh notes +two or more processes or threads can share an i/o context. +this will be the case when +.br clone (2) +was called with the +.b clone_io +flag. +however, by default, the distinct threads of a process will +.b not +share the same i/o context. +this means that if you want to change the i/o +priority of all threads in a process, you may need to call +.br ioprio_set () +on each of the threads. +the thread id that you would need for this operation +is the one that is returned by +.br gettid (2) +or +.br clone (2). +.pp +these system calls have an effect only when used +in conjunction with an i/o scheduler that supports i/o priorities. +as at kernel 2.6.17 the only such scheduler is the completely fair queuing +(cfq) i/o scheduler. +.pp +if no i/o scheduler has been set for a thread, +then by default the i/o priority will follow the cpu nice value +.rb ( setpriority (2)). +in linux kernels before version 2.6.24, +once an i/o priority had been set using +.br ioprio_set (), +there was no way to reset the i/o scheduling behavior to the default. +since linux 2.6.24, +.\" commit 8ec680e4c3ec818efd1652f15199ed1c216ab550 +specifying +.i ioprio +as 0 can be used to reset to the default i/o scheduling behavior. +.ss selecting an i/o scheduler +i/o schedulers are selected on a per-device basis via the special +file +.ir /sys/block//queue/scheduler . +.pp +one can view the current i/o scheduler via the +.i /sys +filesystem. +for example, the following command +displays a list of all schedulers currently loaded in the kernel: +.pp +.in +4n +.ex +.rb "$" " cat /sys/block/sda/queue/scheduler" +noop anticipatory deadline [cfq] +.ee +.in +.pp +the scheduler surrounded by brackets is the one actually +in use for the device +.ri ( sda +in the example). +setting another scheduler is done by writing the name of the +new scheduler to this file. +for example, the following command will set the +scheduler for the +.i sda +device to +.ir cfq : +.pp +.in +4n +.ex +.rb "$" " su" +password: +.rb "#" " echo cfq > /sys/block/sda/queue/scheduler" +.ee +.in +.\" +.ss the completely fair queuing (cfq) i/o scheduler +since version 3 (also known as cfq time sliced), cfq implements +i/o nice levels similar to those +of cpu scheduling. +these nice levels are grouped into three scheduling classes, +each one containing one or more priority levels: +.tp +.br ioprio_class_rt " (1)" +this is the real-time i/o class. +this scheduling class is given +higher priority than any other class: +processes from this class are +given first access to the disk every time. +thus, this i/o class needs to be used with some +care: one i/o real-time process can starve the entire system. +within the real-time class, +there are 8 levels of class data (priority) that determine exactly +how much time this process needs the disk for on each service. +the highest real-time priority level is 0; the lowest is 7. +in the future, this might change to be more directly mappable to +performance, by passing in a desired data rate instead. +.tp +.br ioprio_class_be " (2)" +this is the best-effort scheduling class, +which is the default for any process +that hasn't set a specific i/o priority. +the class data (priority) determines how much +i/o bandwidth the process will get. +best-effort priority levels are analogous to cpu nice values +(see +.br getpriority (2)). +the priority level determines a priority relative +to other processes in the best-effort scheduling class. +priority levels range from 0 (highest) to 7 (lowest). +.tp +.br ioprio_class_idle " (3)" +this is the idle scheduling class. +processes running at this level get i/o +time only when no one else needs the disk. +the idle class has no class data. +attention is required when assigning this priority class to a process, +since it may become starved if higher priority processes are +constantly accessing the disk. +.pp +refer to the kernel source file +.i documentation/block/ioprio.txt +for more information on the cfq i/o scheduler and an example program. +.ss required permissions to set i/o priorities +permission to change a process's priority is granted or denied based +on two criteria: +.tp +.b "process ownership" +an unprivileged process may set the i/o priority only for a process +whose real uid +matches the real or effective uid of the calling process. +a process which has the +.b cap_sys_nice +capability can change the priority of any process. +.tp +.b "what is the desired priority" +attempts to set very high priorities +.rb ( ioprio_class_rt ) +require the +.b cap_sys_admin +capability. +kernel versions up to 2.6.24 also required +.b cap_sys_admin +to set a very low priority +.rb ( ioprio_class_idle ), +but since linux 2.6.25, this is no longer required. +.pp +a call to +.br ioprio_set () +must follow both rules, or the call will fail with the error +.br eperm . +.sh bugs +.\" 6 may 07: bug report raised: +.\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=4464 +.\" ulrich drepper replied that he wasn't going to add these +.\" to glibc. +glibc does not yet provide a suitable header file defining +the function prototypes and macros described on this page. +suitable definitions can be found in +.ir linux/ioprio.h . +.sh see also +.br ionice (1), +.br getpriority (2), +.br open (2), +.br capabilities (7), +.br cgroups (7) +.pp +.i documentation/block/ioprio.txt +in the linux kernel source tree +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th utimensat 2 2021-08-27 "linux" "linux programmer's manual" +.sh name +utimensat, futimens \- change file timestamps with nanosecond precision +.sh synopsis +.nf +.br "#include " " /* definition of " at_* " constants */" +.b #include +.pp +.bi "int utimensat(int " dirfd ", const char *" pathname , +.bi " const struct timespec " times "[2], int " flags ); +.bi "int futimens(int " fd ", const struct timespec " times [2]); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br utimensat (): +.nf + since glibc 2.10: + _posix_c_source >= 200809l + before glibc 2.10: + _atfile_source +.fi +.pp +.br futimens (): +.nf + since glibc 2.10: + _posix_c_source >= 200809l + before glibc 2.10: + _gnu_source +.fi +.sh description +.br utimensat () +and +.br futimens () +update the timestamps of a file with nanosecond precision. +this contrasts with the historical +.br utime (2) +and +.br utimes (2), +which permit only second and microsecond precision, respectively, +when setting file timestamps. +.pp +with +.br utimensat () +the file is specified via the pathname given in +.ir pathname . +with +.br futimens () +the file whose timestamps are to be updated is specified via +an open file descriptor, +.ir fd . +.pp +for both calls, the new file timestamps are specified in the array +.ir times : +.i times[0] +specifies the new "last access time" (\fiatime\fp); +.i times[1] +specifies the new "last modification time" (\fimtime\fp). +each of the elements of +.i times +specifies a time as the number of seconds and nanoseconds +since the epoch, 1970-01-01 00:00:00 +0000 (utc). +this information is conveyed in a structure of the following form: +.pp +.in +4n +.ex +struct timespec { + time_t tv_sec; /* seconds */ + long tv_nsec; /* nanoseconds */ +}; +.ee +.in +.pp +updated file timestamps are set to the greatest value +supported by the filesystem that is not greater than the specified time. +.pp +if the +.i tv_nsec +field of one of the +.i timespec +structures has the special value +.br utime_now , +then the corresponding file timestamp is set to the current time. +if the +.i tv_nsec +field of one of the +.i timespec +structures has the special value +.br utime_omit , +then the corresponding file timestamp is left unchanged. +in both of these cases, the value of the corresponding +.i tv_sec +.\" 2.6.22 was broken: it is not ignored +field is ignored. +.pp +if +.i times +is null, then both timestamps are set to the current time. +.\" +.ss permissions requirements +to set both file timestamps to the current time (i.e., +.i times +is null, or both +.i tv_nsec +fields specify +.br utime_now ), +either: +.ip 1. 3 +the caller must have write access to the file; +.\" 2.6.22 was broken here -- for futimens() the check is +.\" based on whether or not the file descriptor is writable, +.\" not on whether the caller's effective uid has write +.\" permission for the file referred to by the descriptor. +.ip 2. +the caller's effective user id must match the owner of the file; or +.ip 3. +the caller must have appropriate privileges. +.pp +to make any change other than setting both timestamps to the +current time (i.e., +.i times +is not null, and neither +.i tv_nsec +field is +.b utime_now +.\" 2.6.22 was broken here: +.\" both must be something other than *either* utime_omit *or* utime_now. +and neither +.i tv_nsec +field is +.br utime_omit ), +either condition 2 or 3 above must apply. +.pp +if both +.i tv_nsec +fields are specified as +.br utime_omit , +then no file ownership or permission checks are performed, +and the file timestamps are not modified, +but other error conditions may still be detected. +.\" +.\" +.ss utimensat() specifics +if +.i pathname +is relative, then by default it is interpreted relative to the +directory referred to by the open file descriptor, +.ir dirfd +(rather than relative to the current working directory of +the calling process, as is done by +.br utimes (2) +for a relative pathname). +see +.br openat (2) +for an explanation of why this can be useful. +.pp +if +.i pathname +is relative and +.i dirfd +is the special value +.br at_fdcwd , +then +.i pathname +is interpreted relative to the current working +directory of the calling process (like +.br utimes (2)). +.pp +if +.i pathname +is absolute, then +.i dirfd +is ignored. +.pp +the +.i flags +field is a bit mask that may be 0, or include the following constant, +defined in +.ir : +.tp +.b at_symlink_nofollow +if +.i pathname +specifies a symbolic link, then update the timestamps of the link, +rather than the file to which it refers. +.sh return value +on success, +.br utimensat () +and +.br futimens () +return 0. +on error, \-1 is returned and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eacces +.i times +is null, +or both +.i tv_nsec +values are +.br utime_now , +and the effective user id of the caller does not match +the owner of the file, +the caller does not have write access to the file, +and the caller is not privileged +(linux: does not have either the +.b cap_fowner +or the +.b cap_dac_override +capability). +.\" but linux 2.6.22 was broken here. +.\" traditionally, utime()/utimes() gives the error eacces for the case +.\" where the timestamp pointer argument is null (i.e., set both timestamps +.\" to the current time), and the file is owned by a user other than the +.\" effective uid of the caller, and the file is not writable by the +.\" effective uid of the program. utimensat() also gives this error in the +.\" same case. however, in the same circumstances, when utimensat() is +.\" given a 'times' array in which both tv_nsec fields are utime_now, which +.\" provides equivalent functionality to specifying 'times' as null, the +.\" call succeeds. it should fail with the error eacces in this case. +.\" +.\" posix.1-2008 has the following: +.\" .tp +.\" .b eacces +.\" .rb ( utimensat ()) +.\" .i fd +.\" was not opened with +.\" .b o_search +.\" and the permissions of the directory to which +.\" .i fd +.\" refers do not allow searches. +.\" ext2_immutable_fl and similar flags for other filesystems. +.tp +.b ebadf +.rb ( futimens ()) +.i fd +is not a valid file descriptor. +.tp +.b ebadf +.rb ( utimensat ()) +.i pathname +is relative but +.i dirfd +is neither +.br at_fdcwd +nor a valid file descriptor. +.tp +.b efault +.i times +pointed to an invalid address; or, +.i dirfd +was +.br at_fdcwd , +and +.i pathname +is null or an invalid address. +.tp +.b einval +invalid value in +.ir flags . +.tp +.b einval +invalid value in one of the +.i tv_nsec +fields (value outside range 0 to 999,999,999, and not +.b utime_now +or +.br utime_omit ); +or an invalid value in one of the +.i tv_sec +fields. +.tp +.b einval +.\" susv4 does not specify this error. +.i pathname +is null, +.i dirfd +is not +.br at_fdcwd , +and +.i flags +contains +.br at_symlink_nofollow . +.tp +.b eloop +.rb ( utimensat ()) +too many symbolic links were encountered in resolving +.ir pathname . +.tp +.b enametoolong +.rb ( utimensat ()) +.i pathname +is too long. +.tp +.b enoent +.rb ( utimensat ()) +a component of +.i pathname +does not refer to an existing directory or file, +or +.i pathname +is an empty string. +.tp +.b enotdir +.rb ( utimensat ()) +.i pathname +is a relative pathname, but +.i dirfd +is neither +.b at_fdcwd +nor a file descriptor referring to a directory; +or, one of the prefix components of +.i pathname +is not a directory. +.tp +.b eperm +the caller attempted to change one or both timestamps to a value +other than the current time, +or to change one of the timestamps to the current time while +leaving the other timestamp unchanged, +(i.e., +.i times +is not null, neither +.i tv_nsec +field is +.br utime_now , +and neither +.i tv_nsec +field is +.br utime_omit ) +and either: +.rs +.ip * 3 +the caller's effective user id does not match the owner of file, +and the caller is not privileged +(linux: does not have the +.br cap_fowner +capability); or, +.ip * +.\" linux 2.6.22 was broken here: +.\" it was not consistent with the old utimes() implementation, +.\" since the case when both tv_nsec fields are utime_now, was not +.\" treated like the (times == null) case. +the file is marked append-only or immutable (see +.br chattr (1)). +.\" ext2_immutable_fl ext_apppend_fl and similar flags for +.\" other filesystems. +.\" +.\" why the inconsistency (which is described under notes) between +.\" eacces and eperm, where only eperm tests for append-only. +.\" (this was also so for the older utimes() implementation.) +.re +.tp +.b erofs +the file is on a read-only filesystem. +.tp +.b esrch +.rb ( utimensat ()) +search permission is denied for one of the prefix components of +.ir pathname . +.sh versions +.br utimensat () +was added to linux in kernel 2.6.22; +glibc support was added with version 2.6. +.pp +support for +.br futimens () +first appeared in glibc 2.6. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br utimensat (), +.br futimens () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +.br futimens () +and +.br utimensat () +are specified in posix.1-2008. +.sh notes +.br utimensat () +obsoletes +.br futimesat (2). +.pp +on linux, timestamps cannot be changed for a file marked immutable, +and the only change permitted for files marked append-only is to +set the timestamps to the current time. +(this is consistent with the historical behavior of +.br utime (2) +and +.br utimes (2) +on linux.) +.pp +if both +.i tv_nsec +fields are specified as +.br utime_omit , +then the linux implementation of +.br utimensat () +succeeds even if the file referred to by +.ir dirfd +and +.i pathname +does not exist. +.ss c library/kernel abi differences +on linux, +.br futimens () +is a library function implemented on top of the +.br utimensat () +system call. +to support this, the linux +.br utimensat () +system call implements a nonstandard feature: if +.i pathname +is null, then the call modifies the timestamps of +the file referred to by the file descriptor +.i dirfd +(which may refer to any type of file). +using this feature, the call +.i "futimens(fd,\ times)" +is implemented as: +.pp +.in +4n +.ex +utimensat(fd, null, times, 0); +.ee +.in +.pp +note, however, that the glibc wrapper for +.br utimensat () +disallows passing null as the value for +.ir pathname : +the wrapper function returns the error +.br einval +in this case. +.sh bugs +several bugs afflict +.br utimensat () +and +.br futimens () +on kernels before 2.6.26. +these bugs are either nonconformances with the posix.1 draft specification +or inconsistencies with historical linux behavior. +.ip * 3 +posix.1 specifies that if one of the +.i tv_nsec +fields has the value +.b utime_now +or +.br utime_omit , +then the value of the corresponding +.i tv_sec +field should be ignored. +instead, the value of the +.i tv_sec +field is required to be 0 (or the error +.b einval +results). +.ip * +various bugs mean that for the purposes of permission checking, +the case where both +.i tv_nsec +fields are set to +.br utime_now +isn't always treated the same as specifying +.i times +as null, +and the case where one +.i tv_nsec +value is +.b utime_now +and the other is +.b utime_omit +isn't treated the same as specifying +.i times +as a pointer to an array of structures containing arbitrary time values. +as a result, in some cases: +a) file timestamps can be updated by a process that shouldn't have +permission to perform updates; +b) file timestamps can't be updated by a process that should have +permission to perform updates; and +c) the wrong +.i errno +value is returned in case of an error. +.\" below, the long description of the errors from the previous bullet +.\" point (abridged because it's too much detail for a man page). +.\" .ip * +.\" if one of the +.\" .i tv_nsec +.\" fields is +.\" .br utime_omit +.\" and the other is +.\" .br utime_now , +.\" then the error +.\" .b eperm +.\" should occur if the process's effective user id does not match +.\" the file owner and the process is not privileged. +.\" instead, the call successfully changes one of the timestamps. +.\" .ip * +.\" if file is not writable by the effective user id of the process and +.\" the process's effective user id does not match the file owner and +.\" the process is not privileged, +.\" and +.\" .i times +.\" is null, then the error +.\" .b eacces +.\" results. +.\" this error should also occur if +.\" .i times +.\" points to an array of structures in which both +.\" .i tv_nsec +.\" fields are +.\" .br utime_now . +.\" instead the call succeeds. +.\" .ip * +.\" if a file is marked as append-only (see +.\" .br chattr (1)), +.\" then linux traditionally +.\" (i.e., +.\" .br utime (2), +.\" .br utimes (2)), +.\" permits a null +.\" .i times +.\" argument to be used in order to update both timestamps to the current time. +.\" for consistency, +.\" .br utimensat () +.\" and +.\" .br futimens () +.\" should also produce the same result when given a +.\" .i times +.\" argument that points to an array of structures in which both +.\" .i tv_nsec +.\" fields are +.\" .br utime_now . +.\" instead, the call fails with the error +.\" .br eperm . +.\" .ip * +.\" if a file is marked as immutable (see +.\" .br chattr (1)), +.\" then linux traditionally +.\" (i.e., +.\" .br utime (2), +.\" .br utimes (2)), +.\" gives an +.\" .b eacces +.\" error if +.\" .i times +.\" is null. +.\" for consistency, +.\" .br utimensat () +.\" and +.\" .br futimens () +.\" should also produce the same result when given a +.\" .i times +.\" that points to an array of structures in which both +.\" .i tv_nsec +.\" fields are +.\" .br utime_now . +.\" instead, the call fails with the error +.\" .br eperm . +.ip * +posix.1 says that a process that has \fiwrite access to the file\fp +can make a call with +.i times +as null, or with +.i times +pointing to an array of structures in which both +.i tv_nsec +fields are +.br utime_now , +in order to update both timestamps to the current time. +however, +.br futimens () +instead checks whether the +.ir "access mode of the file descriptor allows writing" . +.\" this means that a process with a file descriptor that allows +.\" writing could change the timestamps of a file for which it +.\" does not have write permission; +.\" conversely, a process with a read-only file descriptor won't +.\" be able to update the timestamps of a file, +.\" even if it has write permission on the file. +.sh see also +.br chattr (1), +.br touch (1), +.br futimesat (2), +.br openat (2), +.br stat (2), +.br utimes (2), +.br futimes (3), +.br inode (7), +.br path_resolution (7), +.br symlink (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2003 andries brouwer (aeb@cwi.nl) +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th wcstoimax 3 2021-03-22 "" "linux programmer's manual" +.sh name +wcstoimax, wcstoumax \- convert wide-character string to integer +.sh synopsis +.nf +.b #include +.b #include +.pp +.bi "intmax_t wcstoimax(const wchar_t *restrict " nptr , +.bi " wchar_t **restrict " endptr ", int " base ); +.bi "uintmax_t wcstoumax(const wchar_t *restrict " nptr , +.bi " wchar_t **restrict " endptr ", int " base ); +.fi +.sh description +these functions are just like +.br wcstol (3) +and +.br wcstoul (3), +except that they return a value of type +.i intmax_t +and +.ir uintmax_t , +respectively. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br wcstoimax (), +.br wcstoumax () +t} thread safety mt-safe locale +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh see also +.br imaxabs (3), +.br imaxdiv (3), +.br strtoimax (3), +.br strtoumax (3), +.\" fixme . the pages referred to by the following xrefs are not yet written +.br wcstol (3), +.br wcstoul (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/key_setsecret.3 + +.so man3/cbrt.3 + +.\" copyright (c) 2014 red hat, inc. all rights reserved. +.\" written by david howells (dhowells@redhat.com) +.\" +.\" %%%license_start(gplv2+_sw_onepara) +.\" this program is free software; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license +.\" as published by the free software foundation; either version +.\" 2 of the license, or (at your option) any later version. +.\" %%%license_end +.\" +.th session-keyring 7 2021-03-22 linux "linux programmer's manual" +.sh name +session-keyring \- session shared process keyring +.sh description +the session keyring is a keyring used to anchor keys on behalf of a process. +it is typically created by +.br pam_keyinit (8) +when a user logs in and a link will be added that refers to the +.br user\-keyring (7). +optionally, pam may revoke the session keyring on logout. +(in typical configurations, pam does do this revocation.) +the session keyring has the name (description) +.ir _ses . +.pp +a special serial number value, +.br key_spec_session_keyring , +is defined that can be used in lieu of the actual serial number of +the calling process's session keyring. +.pp +from the +.br keyctl (1) +utility, '\fb@s\fp' can be used instead of a numeric key id in +much the same way. +.pp +a process's session keyring is inherited across +.br clone (2), +.br fork (2), +and +.br vfork (2). +the session keyring +is preserved across +.br execve (2), +even when the executable is set-user-id or set-group-id or has capabilities. +the session keyring is destroyed when the last process that +refers to it exits. +.pp +if a process doesn't have a session keyring when it is accessed, then, +under certain circumstances, the +.br user\-session\-keyring (7) +will be attached as the session keyring +and under others a new session keyring will be created. +(see +.br user\-session\-keyring (7) +for further details.) +.ss special operations +the +.i keyutils +library provides the following special operations for manipulating +session keyrings: +.tp +.br keyctl_join_session_keyring (3) +this operation allows the caller to change the session keyring +that it subscribes to. +the caller can join an existing keyring with a specified name (description), +create a new keyring with a given name, +or ask the kernel to create a new "anonymous" +session keyring with the name "_ses". +(this function is an interface to the +.br keyctl (2) +.b keyctl_join_session_keyring +operation.) +.tp +.br keyctl_session_to_parent (3) +this operation allows the caller to make the parent process's +session keyring to the same as its own. +for this to succeed, the parent process must have +identical security attributes and must be single threaded. +(this function is an interface to the +.br keyctl (2) +.b keyctl_session_to_parent +operation.) +.pp +these operations are also exposed through the +.br keyctl (1) +utility as: +.pp +.in +4n +.ex +keyctl session +keyctl session \- [ ...] +keyctl session [ ...] +.ee +.in +.pp +and: +.pp +.in +4n +.ex +keyctl new_session +.ee +.in +.sh see also +.ad l +.nh +.br keyctl (1), +.br keyctl (3), +.br keyctl_join_session_keyring (3), +.br keyctl_session_to_parent (3), +.br keyrings (7), +.br persistent\-keyring (7), +.br process\-keyring (7), +.br thread\-keyring (7), +.br user\-keyring (7), +.br user\-session\-keyring (7), +.br pam_keyinit (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/getgroups.2 + +.so man3/unlocked_stdio.3 + +.so man3/exec.3 + +.\" copyright (c) 1992 drew eckhardt (drew@cs.colorado.edu), march 28, 1992 +.\" parts copyright (c) 1995 nicolai langfeldt (janl@ifi.uio.no), 1/1/95 +.\" and copyright (c) 2006, 2007, 2014 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified by michael haardt +.\" modified 1993-07-24 by rik faith +.\" modified 1995-05-18 by todd larason +.\" modified 1997-01-31 by eric s. raymond +.\" modified 1995-01-09 by richard kettlewell +.\" modified 1998-05-13 by michael haardt +.\" modified 1999-07-06 by aeb & albert cahalan +.\" modified 2000-01-07 by aeb +.\" modified 2004-06-23 by michael kerrisk +.\" 2007-06-08 mtk: added example program +.\" 2007-07-05 mtk: added details on underlying system call interfaces +.\" +.th stat 2 2021-08-27 "linux" "linux programmer's manual" +.sh name +stat, fstat, lstat, fstatat \- get file status +.sh synopsis +.nf +.b #include +.pp +.bi "int stat(const char *restrict " pathname , +.bi " struct stat *restrict " statbuf ); +.bi "int fstat(int " fd ", struct stat *" statbuf ); +.bi "int lstat(const char *restrict " pathname , +.bi " struct stat *restrict " statbuf ); +.pp +.br "#include " "/* definition of " at_* " constants */" +.b #include +.pp +.bi "int fstatat(int " dirfd ", const char *restrict " pathname , +.bi " struct stat *restrict " statbuf ", int " flags ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br lstat (): +.nf + /* since glibc 2.20 */ _default_source + || _xopen_source >= 500 +.\" _xopen_source && _xopen_source_extended + || /* since glibc 2.10: */ _posix_c_source >= 200112l + || /* glibc 2.19 and earlier */ _bsd_source +.fi +.pp +.br fstatat (): +.nf + since glibc 2.10: + _posix_c_source >= 200809l + before glibc 2.10: + _atfile_source +.fi +.sh description +these functions return information about a file, in the buffer pointed to by +.ir statbuf . +no permissions are required on the file itself, but\(emin the case of +.br stat (), +.br fstatat (), +and +.br lstat ()\(emexecute +(search) permission is required on all of the directories in +.i pathname +that lead to the file. +.pp +.br stat () +and +.br fstatat () +retrieve information about the file pointed to by +.ir pathname ; +the differences for +.br fstatat () +are described below. +.pp +.br lstat () +is identical to +.br stat (), +except that if +.i pathname +is a symbolic link, then it returns information about the link itself, +not the file that the link refers to. +.pp +.br fstat () +is identical to +.br stat (), +except that the file about which information is to be retrieved +is specified by the file descriptor +.ir fd . +.\" +.ss the stat structure +all of these system calls return a +.i stat +structure, which contains the following fields: +.pp +.in +4n +.ex +struct stat { + dev_t st_dev; /* id of device containing file */ + ino_t st_ino; /* inode number */ + mode_t st_mode; /* file type and mode */ + nlink_t st_nlink; /* number of hard links */ + uid_t st_uid; /* user id of owner */ + gid_t st_gid; /* group id of owner */ + dev_t st_rdev; /* device id (if special file) */ + off_t st_size; /* total size, in bytes */ + blksize_t st_blksize; /* block size for filesystem i/o */ + blkcnt_t st_blocks; /* number of 512b blocks allocated */ + + /* since linux 2.6, the kernel supports nanosecond + precision for the following timestamp fields. + for the details before linux 2.6, see notes. */ + + struct timespec st_atim; /* time of last access */ + struct timespec st_mtim; /* time of last modification */ + struct timespec st_ctim; /* time of last status change */ + +#define st_atime st_atim.tv_sec /* backward compatibility */ +#define st_mtime st_mtim.tv_sec +#define st_ctime st_ctim.tv_sec +}; +.ee +.in +.pp +.ir note : +the order of fields in the +.i stat +structure varies somewhat +across architectures. +in addition, +the definition above does not show the padding bytes +that may be present between some fields on various architectures. +consult the glibc and kernel source code +if you need to know the details. +.pp +.\" background: inode attributes are modified with i_mutex held, but +.\" read by stat() without taking the mutex. +.ir note : +for performance and simplicity reasons, different fields in the +.i stat +structure may contain state information from different moments +during the execution of the system call. +for example, if +.ir st_mode +or +.ir st_uid +is changed by another process by calling +.br chmod (2) +or +.br chown (2), +.br stat () +might return the old +.i st_mode +together with the new +.ir st_uid , +or the old +.i st_uid +together with the new +.ir st_mode . +.pp +the fields in the +.i stat +structure are as follows: +.tp +.i st_dev +this field describes the device on which this file resides. +(the +.br major (3) +and +.br minor (3) +macros may be useful to decompose the device id in this field.) +.tp +.i st_ino +this field contains the file's inode number. +.tp +.i st_mode +this field contains the file type and mode. +see +.br inode (7) +for further information. +.tp +.i st_nlink +this field contains the number of hard links to the file. +.tp +.i st_uid +this field contains the user id of the owner of the file. +.tp +.i st_gid +this field contains the id of the group owner of the file. +.tp +.i st_rdev +this field describes the device that this file (inode) represents. +.tp +.i st_size +this field gives the size of the file (if it is a regular +file or a symbolic link) in bytes. +the size of a symbolic link is the length of the pathname +it contains, without a terminating null byte. +.tp +.i st_blksize +this field gives the "preferred" block size for efficient filesystem i/o. +.tp +.i st_blocks +this field indicates the number of blocks allocated to the file, +in 512-byte units. +(this may be smaller than +.ir st_size /512 +when the file has holes.) +.tp +.i st_atime +this is the time of the last access of file data. +.tp +.i st_mtime +this is the time of last modification of file data. +.tp +.i st_ctime +this is the file's last status change timestamp +(time of last change to the inode). +.pp +for further information on the above fields, see +.br inode (7). +.\" +.ss fstatat() +the +.br fstatat () +system call is a more general interface for accessing file information +which can still provide exactly the behavior of each of +.br stat (), +.br lstat (), +and +.br fstat (). +.pp +if the pathname given in +.i pathname +is relative, then it is interpreted relative to the directory +referred to by the file descriptor +.i dirfd +(rather than relative to the current working directory of +the calling process, as is done by +.br stat () +and +.br lstat () +for a relative pathname). +.pp +if +.i pathname +is relative and +.i dirfd +is the special value +.br at_fdcwd , +then +.i pathname +is interpreted relative to the current working +directory of the calling process (like +.br stat () +and +.br lstat ()). +.pp +if +.i pathname +is absolute, then +.i dirfd +is ignored. +.pp +.i flags +can either be 0, or include one or more of the following flags ored: +.tp +.br at_empty_path " (since linux 2.6.39)" +.\" commit 65cfc6722361570bfe255698d9cd4dccaf47570d +if +.i pathname +is an empty string, operate on the file referred to by +.ir dirfd +(which may have been obtained using the +.br open (2) +.b o_path +flag). +in this case, +.i dirfd +can refer to any type of file, not just a directory, and +the behavior of +.br fstatat () +is similar to that of +.br fstat (). +if +.i dirfd +is +.br at_fdcwd , +the call operates on the current working directory. +this flag is linux-specific; define +.b _gnu_source +.\" before glibc 2.16, defining _atfile_source sufficed +to obtain its definition. +.tp +.br at_no_automount " (since linux 2.6.38)" +don't automount the terminal ("basename") component of +.i pathname +if it is a directory that is an automount point. +this allows the caller to gather attributes of an automount point +(rather than the location it would mount). +since linux 4.14, +.\" commit 42f46148217865a545e129612075f3d828a2c4e4 +also don't instantiate a nonexistent name in an +on-demand directory such as used for automounter indirect maps. +this +flag has no effect if the mount point has already been mounted over. +.ip +both +.br stat () +and +.br lstat () +act as though +.b at_no_automount +was set. +.ip +the +.b at_no_automount +can be used in tools that scan directories +to prevent mass-automounting of a directory of automount points. +.ip +this flag is linux-specific; define +.b _gnu_source +.\" before glibc 2.16, defining _atfile_source sufficed +to obtain its definition. +.tp +.b at_symlink_nofollow +if +.i pathname +is a symbolic link, do not dereference it: +instead return information about the link itself, like +.br lstat (). +(by default, +.br fstatat () +dereferences symbolic links, like +.br stat ().) +.pp +see +.br openat (2) +for an explanation of the need for +.br fstatat (). +.sh return value +on success, zero is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eacces +search permission is denied for one of the directories +in the path prefix of +.ir pathname . +(see also +.br path_resolution (7).) +.tp +.b ebadf +.i fd +is not a valid open file descriptor. +.tp +.b ebadf +.rb ( fstatat ()) +.i pathname +is relative but +.i dirfd +is neither +.b at_fdcwd +nor a valid file descriptor. +.tp +.b efault +bad address. +.tp +.b einval +.rb ( fstatat ()) +invalid flag specified in +.ir flags . +.tp +.b eloop +too many symbolic links encountered while traversing the path. +.tp +.b enametoolong +.i pathname +is too long. +.tp +.b enoent +a component of +.i pathname +does not exist or is a dangling symbolic link. +.tp +.b enoent +.i pathname +is an empty string and +.b at_empty_path +was not specified in +.ir flags . +.tp +.b enomem +out of memory (i.e., kernel memory). +.tp +.b enotdir +a component of the path prefix of +.i pathname +is not a directory. +.tp +.b enotdir +.rb ( fstatat ()) +.i pathname +is relative and +.i dirfd +is a file descriptor referring to a file other than a directory. +.tp +.b eoverflow +.i pathname +or +.i fd +refers to a file whose size, inode number, +or number of blocks cannot be represented in, respectively, the types +.ir off_t , +.ir ino_t , +or +.ir blkcnt_t . +this error can occur when, for example, +an application compiled on a 32-bit platform without +.i \-d_file_offset_bits=64 +calls +.br stat () +on a file whose size exceeds +.i (1<<31)\-1 +bytes. +.sh versions +.br fstatat () +was added to linux in kernel 2.6.16; +library support was added to glibc in version 2.4. +.sh conforming to +.br stat (), +.br fstat (), +.br lstat (): +svr4, 4.3bsd, posix.1-2001, posix.1.2008. +.\" svr4 documents additional +.\" .br fstat () +.\" error conditions eintr, enolink, and eoverflow. svr4 +.\" documents additional +.\" .br stat () +.\" and +.\" .br lstat () +.\" error conditions eintr, emultihop, enolink, and eoverflow. +.pp +.br fstatat (): +posix.1-2008. +.pp +according to posix.1-2001, +.br lstat () +on a symbolic link need return valid information only in the +.i st_size +field and the file type of the +.ir st_mode +field of the +.ir stat +structure. +posix.1-2008 tightens the specification, requiring +.br lstat () +to return valid information in all fields except the mode bits in +.ir st_mode . +.pp +use of the +.i st_blocks +and +.i st_blksize +fields may be less portable. +(they were introduced in bsd. +the interpretation differs between systems, +and possibly on a single system when nfs mounts are involved.) +.sh notes +.ss timestamp fields +older kernels and older standards did not support nanosecond timestamp +fields. +instead, there were three timestamp +.ri fields\(em st_atime , +.ir st_mtime , +and +.ir st_ctime \(emtyped +as +.ir time_t +that recorded timestamps with one-second precision. +.pp +since kernel 2.5.48, the +.i stat +structure supports nanosecond resolution for the three file timestamp fields. +the nanosecond components of each timestamp are available +via names of the form +.ir st_atim.tv_nsec , +if suitable feature test macros are defined. +nanosecond timestamps were standardized in posix.1-2008, +and, starting with version 2.12, +glibc exposes the nanosecond component names if +.br _posix_c_source +is defined with the value 200809l or greater, or +.br _xopen_source +is defined with the value 700 or greater. +up to and including glibc 2.19, +the definitions of the nanoseconds components are also defined if +.b _bsd_source +or +.b _svid_source +is defined. +if none of the aforementioned macros are defined, +then the nanosecond values are exposed with names of the form +.ir st_atimensec . +.\" +.ss c library/kernel differences +over time, increases in the size of the +.i stat +structure have led to three successive versions of +.br stat (): +.ir sys_stat () +(slot +.ir __nr_oldstat ), +.ir sys_newstat () +(slot +.ir __nr_stat ), +and +.i sys_stat64() +(slot +.ir __nr_stat64 ) +on 32-bit platforms such as i386. +the first two versions were already present in linux 1.0 +(albeit with different names); +.\" see include/asm-i386/stat.h in the linux 2.4 source code for the +.\" various versions of the structure definitions +the last was added in linux 2.4. +similar remarks apply for +.br fstat () +and +.br lstat (). +.pp +the kernel-internal versions of the +.i stat +structure dealt with by the different versions are, respectively: +.tp +.ir __old_kernel_stat +the original structure, with rather narrow fields, and no padding. +.tp +.ir stat +larger +.i st_ino +field and padding added to various parts of the structure to +allow for future expansion. +.tp +.ir stat64 +even larger +.i st_ino +field, +larger +.i st_uid +and +.i st_gid +fields to accommodate the linux-2.4 expansion of uids and gids to 32 bits, +and various other enlarged fields and further padding in the structure. +(various padding bytes were eventually consumed in linux 2.6, +with the advent of 32-bit device ids and nanosecond components +for the timestamp fields.) +.pp +the glibc +.br stat () +wrapper function hides these details from applications, +invoking the most recent version of the system call provided by the kernel, +and repacking the returned information if required for old binaries. +.\" +.\" a note from andries brouwer, july 2007 +.\" +.\" > is the story not rather more complicated for some calls like +.\" > stat(2)? +.\" +.\" yes and no, mostly no. see /usr/include/sys/stat.h . +.\" +.\" the idea is here not so much that syscalls change, but that +.\" the definitions of struct stat and of the types dev_t and mode_t change. +.\" this means that libc (even if it does not call the kernel +.\" but only calls some internal function) must know what the +.\" format of dev_t or of struct stat is. +.\" the communication between the application and libc goes via +.\" the include file that defines a _stat_ver and +.\" _mknod_ver describing the layout of the data that user space +.\" uses. each (almost each) occurrence of stat() is replaced by +.\" an occurrence of xstat() where the first parameter of xstat() +.\" is this version number _stat_ver. +.\" +.\" now, also the definitions used by the kernel change. +.\" but glibc copes with this in the standard way, and the +.\" struct stat as returned by the kernel is repacked into +.\" the struct stat as expected by the application. +.\" thus, _stat_ver and this setup cater for the application-libc +.\" interface, rather than the libc-kernel interface. +.\" +.\" (note that the details depend on gcc being used as c compiler.) +.pp +on modern 64-bit systems, life is simpler: there is a single +.br stat () +system call and the kernel deals with a +.i stat +structure that contains fields of a sufficient size. +.pp +the underlying system call employed by the glibc +.br fstatat () +wrapper function is actually called +.br fstatat64 () +or, on some architectures, +.\" strace(1) shows the name "newfstatat" on x86-64 +.br newfstatat (). +.sh examples +the following program calls +.br lstat () +and displays selected fields in the returned +.i stat +structure. +.pp +.ex +#include +#include +#include +#include +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + struct stat sb; + + if (argc != 2) { + fprintf(stderr, "usage: %s \en", argv[0]); + exit(exit_failure); + } + + if (lstat(argv[1], &sb) == \-1) { + perror("lstat"); + exit(exit_failure); + } + + printf("id of containing device: [%jx,%jx]\en", + (uintmax_t) major(sb.st_dev), + (uintmax_t) minor(sb.st_dev)); + + printf("file type: "); + + switch (sb.st_mode & s_ifmt) { + case s_ifblk: printf("block device\en"); break; + case s_ifchr: printf("character device\en"); break; + case s_ifdir: printf("directory\en"); break; + case s_ififo: printf("fifo/pipe\en"); break; + case s_iflnk: printf("symlink\en"); break; + case s_ifreg: printf("regular file\en"); break; + case s_ifsock: printf("socket\en"); break; + default: printf("unknown?\en"); break; + } + + printf("i\-node number: %ju\en", (uintmax_t) sb.st_ino); + + printf("mode: %jo (octal)\en", + (uintmax_t) sb.st_mode); + + printf("link count: %ju\en", (uintmax_t) sb.st_nlink); + printf("ownership: uid=%ju gid=%ju\en", + (uintmax_t) sb.st_uid, (uintmax_t) sb.st_gid); + + printf("preferred i/o block size: %jd bytes\en", + (intmax_t) sb.st_blksize); + printf("file size: %jd bytes\en", + (intmax_t) sb.st_size); + printf("blocks allocated: %jd\en", + (intmax_t) sb.st_blocks); + + printf("last status change: %s", ctime(&sb.st_ctime)); + printf("last file access: %s", ctime(&sb.st_atime)); + printf("last file modification: %s", ctime(&sb.st_mtime)); + + exit(exit_success); +} +.ee +.sh see also +.br ls (1), +.br stat (1), +.br access (2), +.br chmod (2), +.br chown (2), +.br readlink (2), +.br statx (2), +.br utime (2), +.br capabilities (7), +.br inode (7), +.br symlink (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/random.3 + +.so man3/ecvt.3 + +.\" copyright (c) 2004 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th posix_openpt 3 2021-03-22 "" "linux programmer's manual" +.sh name +posix_openpt \- open a pseudoterminal device +.sh synopsis +.nf +.b #include +.b #include +.pp +.bi "int posix_openpt(int " flags ");" +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br posix_openpt (): +.nf + _xopen_source >= 600 +.fi +.sh description +the +.br posix_openpt () +function opens an unused pseudoterminal master device, returning a +file descriptor that can be used to refer to that device. +.pp +the +.i flags +argument is a bit mask that ors together zero or more of +the following flags: +.tp +.b o_rdwr +open the device for both reading and writing. +it is usual to specify this flag. +.tp +.b o_noctty +do not make this device the controlling terminal for the process. +.sh return value +on success, +.br posix_openpt () +returns a file descriptor (a nonnegative integer) which is the lowest +numbered unused file descriptor. +on failure, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +see +.br open (2). +.sh versions +glibc support for +.br posix_openpt () +has been provided since version 2.2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br posix_openpt () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.pp +.br posix_openpt () +is part of the unix 98 pseudoterminal support (see +.br pts (4)). +.sh notes +some older unix implementations that support system v +(aka unix 98) pseudoterminals don't have this function, but it +can be easily implemented by opening the pseudoterminal multiplexor device: +.pp +.in +4n +.ex +int +posix_openpt(int flags) +{ + return open("/dev/ptmx", flags); +} +.ee +.in +.pp +calling +.br posix_openpt () +creates a pathname for the corresponding pseudoterminal slave device. +the pathname of the slave device can be obtained using +.br ptsname (3). +the slave device pathname exists only as long as the master device is open. +.sh see also +.br open (2), +.br getpt (3), +.br grantpt (3), +.br ptsname (3), +.br unlockpt (3), +.br pts (4), +.br pty (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" $netbsd: fts.3,v 1.13.2.1 1997/11/14 02:09:32 mrg exp $ +.\" +.\" copyright (c) 1989, 1991, 1993, 1994 +.\" the regents of the university of california. all rights reserved. +.\" +.\" %%%license_start(bsd_4_clause_ucb) +.\" redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. all advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" this product includes software developed by the university of +.\" california, berkeley and its contributors. +.\" 4. neither the name of the university nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" this software is provided by the regents and contributors ``as is'' and +.\" any express or implied warranties, including, but not limited to, the +.\" implied warranties of merchantability and fitness for a particular purpose +.\" are disclaimed. in no event shall the regents or contributors be liable +.\" for any direct, indirect, incidental, special, exemplary, or consequential +.\" damages (including, but not limited to, procurement of substitute goods +.\" or services; loss of use, data, or profits; or business interruption) +.\" however caused and on any theory of liability, whether in contract, strict +.\" liability, or tort (including negligence or otherwise) arising in any way +.\" out of the use of this software, even if advised of the possibility of +.\" such damage. +.\" %%%license_end +.\" +.\" @(#)fts.3 8.5 (berkeley) 4/16/94 +.\" +.\" 2007-12-08, mtk, converted from mdoc to man macros +.\" +.th fts 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +fts, fts_open, fts_read, fts_children, fts_set, fts_close \- \ +traverse a file hierarchy +.sh synopsis +.nf +.b #include +.b #include +.b #include +.pp +.bi "fts *fts_open(char * const *" path_argv ", int " options , +.bi " int (*" compar ")(const ftsent **, const ftsent **));" +.pp +.bi "ftsent *fts_read(fts *" ftsp ); +.pp +.bi "ftsent *fts_children(fts *" ftsp ", int " instr ); +.pp +.bi "int fts_set(fts *" ftsp ", ftsent *" f ", int " instr ); +.pp +.bi "int fts_close(fts *" ftsp ); +.fi +.sh description +the +fts functions are provided for traversing +file hierarchies. +a simple overview is that the +.br fts_open () +function returns a "handle" (of type +.ir "fts\ *" ) +that refers to a file hierarchy "stream". +this handle is then supplied to the other +fts functions. +the function +.br fts_read () +returns a pointer to a structure describing one of the files in the file +hierarchy. +the function +.br fts_children () +returns a pointer to a linked list of structures, each of which describes +one of the files contained in a directory in the hierarchy. +.pp +in general, directories are visited two distinguishable times; in preorder +(before any of their descendants are visited) and in postorder (after all +of their descendants have been visited). +files are visited once. +it is possible to walk the hierarchy "logically" (visiting the files that +symbolic links point to) +or physically (visiting the symbolic links themselves), +order the walk of the hierarchy or +prune and/or revisit portions of the hierarchy. +.pp +two structures (and associated types) are defined in the include file +.ir . +the first type is +.ir fts , +the structure that represents the file hierarchy itself. +the second type is +.ir ftsent , +the structure that represents a file in the file +hierarchy. +normally, an +.i ftsent +structure is returned for every file in the file +hierarchy. +in this manual page, "file" and +"ftsent structure" +are generally interchangeable. +.pp +the +.i ftsent +structure contains fields describing a file. +the structure contains at least the following fields +(there are additional fields that +should be considered private to the implementation): +.pp +.in +4n +.ex +typedef struct _ftsent { + unsigned short fts_info; /* flags for ftsent structure */ + char *fts_accpath; /* access path */ + char *fts_path; /* root path */ + short fts_pathlen; /* strlen(fts_path) + + strlen(fts_name) */ + char *fts_name; /* filename */ + short fts_namelen; /* strlen(fts_name) */ + short fts_level; /* depth (\-1 to n) */ + int fts_errno; /* file errno */ + long fts_number; /* local numeric value */ + void *fts_pointer; /* local address value */ + struct _ftsent *fts_parent; /* parent directory */ + struct _ftsent *fts_link; /* next file structure */ + struct _ftsent *fts_cycle; /* cycle structure */ + struct stat *fts_statp; /* stat(2) information */ +.\" also: +.\" ino_t fts_ino; /* inode (only for directories)*/ +.\" dev_t fts_dev; /* device (only for directories)*/ +.\" nlink_t fts_nlink; /* link count (only for directories)*/ +.\" u_short fts_flags; /* private flags for ftsent structure */ +.\" u_short fts_instr; /* fts_set() instructions */ +} ftsent; +.ee +.in +.pp +these fields are defined as follows: +.\" .bl -tag -width "fts_namelen" +.tp +.ir fts_info +one of the following values describing the returned +.i ftsent +structure and +the file it represents. +with the exception of directories without errors +.rb ( fts_d ), +all of these +entries are terminal, that is, they will not be revisited, nor will any +of their descendants be visited. +.\" .bl -tag -width fts_default +.rs +.tp +.br fts_d +a directory being visited in preorder. +.tp +.br fts_dc +a directory that causes a cycle in the tree. +(the +.i fts_cycle +field of the +.i ftsent +structure will be filled in as well.) +.tp +.br fts_default +any +.i ftsent +structure that represents a file type not explicitly described +by one of the other +.i fts_info +values. +.tp +.br fts_dnr +a directory which cannot be read. +this is an error return, and the +.i fts_errno +field will be set to indicate what caused the error. +.tp +.br fts_dot +a file named +"." +or +".." +which was not specified as a filename to +.br fts_open () +(see +.br fts_seedot ). +.tp +.br fts_dp +a directory being visited in postorder. +the contents of the +.i ftsent +structure will be unchanged from when +it was returned in preorder, that is, with the +.i fts_info +field set to +.br fts_d . +.tp +.br fts_err +this is an error return, and the +.i fts_errno +field will be set to indicate what caused the error. +.tp +.br fts_f +a regular file. +.tp +.br fts_ns +a file for which no +.br stat (2) +information was available. +the contents of the +.i fts_statp +field are undefined. +this is an error return, and the +.i fts_errno +field will be set to indicate what caused the error. +.tp +.br fts_nsok +a file for which no +.br stat (2) +information was requested. +the contents of the +.i fts_statp +field are undefined. +.tp +.br fts_sl +a symbolic link. +.tp +.br fts_slnone +a symbolic link with a nonexistent target. +the contents of the +.i fts_statp +field reference the file characteristic information for the symbolic link +itself. +.\" .el +.re +.tp +.ir fts_accpath +a path for accessing the file from the current directory. +.tp +.ir fts_path +the path for the file relative to the root of the traversal. +this path contains the path specified to +.br fts_open () +as a prefix. +.tp +.ir fts_pathlen +the sum of the lengths of the strings referenced by +.ir fts_path +and +.ir fts_name . +.tp +.ir fts_name +the name of the file. +.tp +.ir fts_namelen +the length of the string referenced by +.ir fts_name . +.tp +.ir fts_level +the depth of the traversal, numbered from \-1 to n, where this file +was found. +the +.i ftsent +structure representing the parent of the starting point (or root) +of the traversal is numbered \-1, and the +.i ftsent +structure for the root +itself is numbered 0. +.tp +.ir fts_errno +if +.br fts_children () +or +.br fts_read () +returns an +.i ftsent +structure whose +.i fts_info +field is set to +.br fts_dnr , +.br fts_err , +or +.br fts_ns , +the +.i fts_errno +field contains the error number (i.e., the +.ir errno +value) +specifying the cause of the error. +otherwise, the contents of the +.i fts_errno +field are undefined. +.tp +.ir fts_number +this field is provided for the use of the application program and is +not modified by the +fts functions. +it is initialized to 0. +.tp +.ir fts_pointer +this field is provided for the use of the application program and is +not modified by the +fts functions. +it is initialized to +null. +.tp +.ir fts_parent +a pointer to the +.i ftsent +structure referencing the file in the hierarchy +immediately above the current file, that is, the directory of which this +file is a member. +a parent structure for the initial entry point is provided as well, +however, only the +.ir fts_level , +.ir fts_number , +and +.i fts_pointer +fields are guaranteed to be initialized. +.tp +.ir fts_link +upon return from the +.br fts_children () +function, the +.i fts_link +field points to the next structure in the null-terminated linked list of +directory members. +otherwise, the contents of the +.i fts_link +field are undefined. +.tp +.ir fts_cycle +if a directory causes a cycle in the hierarchy (see +.br fts_dc ), +either because +of a hard link between two directories, or a symbolic link pointing to a +directory, the +.i fts_cycle +field of the structure will point to the +.i ftsent +structure in the hierarchy that references the same file as the current +.i ftsent +structure. +otherwise, the contents of the +.i fts_cycle +field are undefined. +.tp +.ir fts_statp +a pointer to +.br stat (2) +information for the file. +.\" .el +.pp +a single buffer is used for all of the paths of all of the files in the +file hierarchy. +therefore, the +.i fts_path +and +.i fts_accpath +fields are guaranteed to be +null-terminated +.i only +for the file most recently returned by +.br fts_read (). +to use these fields to reference any files represented by other +.i ftsent +structures will require that the path buffer be modified using the +information contained in that +.i ftsent +structure's +.i fts_pathlen +field. +any such modifications should be undone before further calls to +.br fts_read () +are attempted. +the +.i fts_name +field is always +null-terminated. +.ss fts_open() +the +.br fts_open () +function takes a pointer to an array of character pointers naming one +or more paths which make up a logical file hierarchy to be traversed. +the array must be terminated by a +null pointer. +.pp +there are +a number of options, at least one of which (either +.br fts_logical +or +.br fts_physical ) +must be specified. +the options are selected by oring +the following values: +.\" .bl -tag -width "fts_physical" +.tp +.br fts_comfollow +this option causes any symbolic link specified as a root path to be +followed immediately whether or not +.br fts_logical +is also specified. +.tp +.br fts_logical +this option causes the +fts routines to return +.i ftsent +structures for the targets of symbolic links +instead of the symbolic links themselves. +if this option is set, the only symbolic links for which +.i ftsent +structures +are returned to the application are those referencing nonexistent files. +either +.br fts_logical +or +.br fts_physical +.i must +be provided to the +.br fts_open () +function. +.tp +.br fts_nochdir +as a performance optimization, the +fts functions change directories as they walk the file hierarchy. +this has the side-effect that an application cannot rely on being +in any particular directory during the traversal. +the +.br fts_nochdir +option turns off this optimization, and the +fts functions will not change the current directory. +note that applications should not themselves change their current directory +and try to access files unless +.br fts_nochdir +is specified and absolute +pathnames were provided as arguments to +.br fts_open (). +.tp +.br fts_nostat +by default, returned +.i ftsent +structures reference file characteristic information (the +.i statp +field) for each file visited. +this option relaxes that requirement as a performance optimization, +allowing the +fts functions to set the +.i fts_info +field to +.br fts_nsok +and leave the contents of the +.i statp +field undefined. +.tp +.br fts_physical +this option causes the +fts routines to return +.i ftsent +structures for symbolic links themselves instead +of the target files they point to. +if this option is set, +.i ftsent +structures for all symbolic links in the +hierarchy are returned to the application. +either +.br fts_logical +or +.br fts_physical +.i must +be provided to the +.br fts_open () +function. +.tp +.br fts_seedot +by default, unless they are specified as path arguments to +.br fts_open (), +any files named +"." +or +".." +encountered in the file hierarchy are ignored. +this option causes the +fts routines to return +.i ftsent +structures for them. +.tp +.br fts_xdev +this option prevents +fts from descending into directories that have a different device number +than the file from which the descent began. +.\" .el +.pp +the argument +.br compar () +specifies a user-defined function which may be used to order the traversal +of the hierarchy. +it +takes two pointers to pointers to +.i ftsent +structures as arguments and +should return a negative value, zero, or a positive value to indicate +if the file referenced by its first argument comes before, in any order +with respect to, or after, the file referenced by its second argument. +the +.ir fts_accpath , +.ir fts_path , +and +.i fts_pathlen +fields of the +.i ftsent +structures may +.i never +be used in this comparison. +if the +.i fts_info +field is set to +.br fts_ns +or +.br fts_nsok , +the +.i fts_statp +field may not either. +if the +.br compar () +argument is +null, +the directory traversal order is in the order listed in +.i path_argv +for the root paths, and in the order listed in the directory for +everything else. +.ss fts_read() +the +.br fts_read () +function returns a pointer to an +.i ftsent +structure describing a file in +the hierarchy. +directories (that are readable and do not cause cycles) are visited at +least twice, once in preorder and once in postorder. +all other files are visited at least once. +(hard links between directories that do not cause cycles or symbolic +links to symbolic links may cause files to be visited more than once, +or directories more than twice.) +.pp +if all the members of the hierarchy have been returned, +.br fts_read () +returns null and sets +.i errno +to 0. +if an error unrelated to a file in the hierarchy occurs, +.br fts_read () +returns +null +and sets +.i errno +to indicate the error. +if an error related to a returned file occurs, a pointer to an +.i ftsent +structure is returned, and +.i errno +may or may not have been set (see +.ir fts_info ). +.pp +the +.i ftsent +structures returned by +.br fts_read () +may be overwritten after a call to +.br fts_close () +on the same file hierarchy stream, or, after a call to +.br fts_read () +on the same file hierarchy stream unless they represent a file of type +directory, in which case they will not be overwritten until after a call to +.br fts_read () +after the +.i ftsent +structure has been returned by the function +.br fts_read () +in postorder. +.ss fts_children() +the +.br fts_children () +function returns a pointer to an +.i ftsent +structure describing the first entry in a null-terminated linked list of +the files in the directory represented by the +.i ftsent +structure most recently returned by +.br fts_read (). +the list is linked through the +.i fts_link +field of the +.i ftsent +structure, and is ordered by the user-specified comparison function, if any. +repeated calls to +.br fts_children () +will re-create this linked list. +.pp +as a special case, if +.br fts_read () +has not yet been called for a hierarchy, +.br fts_children () +will return a pointer to the files in the logical directory specified to +.br fts_open (), +that is, the arguments specified to +.br fts_open (). +otherwise, if the +.i ftsent +structure most recently returned by +.br fts_read () +is not a directory being visited in preorder, +or the directory does not contain any files, +.br fts_children () +returns +null +and sets +.i errno +to zero. +if an error occurs, +.br fts_children () +returns +null +and sets +.i errno +to indicate the error. +.pp +the +.i ftsent +structures returned by +.br fts_children () +may be overwritten after a call to +.br fts_children (), +.br fts_close (), +or +.br fts_read () +on the same file hierarchy stream. +.pp +the +.i instr +argument is either zero or the following value: +.\" .bl -tag -width fts_nameonly +.tp +.br fts_nameonly +only the names of the files are needed. +the contents of all the fields in the returned linked list of structures +are undefined with the exception of the +.i fts_name +and +.i fts_namelen +fields. +.\" .el +.ss fts_set() +the function +.br fts_set () +allows the user application to determine further processing for the +file +.i f +of the stream +.ir ftsp . +the +.br fts_set () +function +returns 0 on success, and \-1 if an error occurs. +.pp +the +.i instr +argument is either 0 (meaning "do nothing") or one of the following values: +.\" .bl -tag -width fts_physical +.tp +.br fts_again +revisit the file; any file type may be revisited. +the next call to +.br fts_read () +will return the referenced file. +the +.i fts_stat +and +.i fts_info +fields of the structure will be reinitialized at that time, +but no other fields will have been changed. +this option is meaningful only for the most recently returned +file from +.br fts_read (). +normal use is for postorder directory visits, where it causes the +directory to be revisited (in both preorder and postorder) as well as all +of its descendants. +.tp +.br fts_follow +the referenced file must be a symbolic link. +if the referenced file is the one most recently returned by +.br fts_read (), +the next call to +.br fts_read () +returns the file with the +.i fts_info +and +.i fts_statp +fields reinitialized to reflect the target of the symbolic link instead +of the symbolic link itself. +if the file is one of those most recently returned by +.br fts_children (), +the +.i fts_info +and +.i fts_statp +fields of the structure, when returned by +.br fts_read (), +will reflect the target of the symbolic link instead of the symbolic link +itself. +in either case, if the target of the symbolic link does not exist, the +fields of the returned structure will be unchanged and the +.i fts_info +field will be set to +.br fts_slnone . +.ip +if the target of the link is a directory, the preorder return, followed +by the return of all of its descendants, followed by a postorder return, +is done. +.tp +.br fts_skip +no descendants of this file are visited. +the file may be one of those most recently returned by either +.br fts_children () +or +.br fts_read (). +.\" .el +.ss fts_close() +the +.br fts_close () +function closes the file hierarchy stream referred to by +.i ftsp +and restores the current directory to the directory from which +.br fts_open () +was called to open +.ir ftsp . +the +.br fts_close () +function +returns 0 on success, and \-1 if an error occurs. +.sh errors +the function +.br fts_open () +may fail and set +.i errno +for any of the errors specified for +.br open (2) +and +.br malloc (3). +.pp +the function +.br fts_close () +may fail and set +.i errno +for any of the errors specified for +.br chdir (2) +and +.br close (2). +.pp +the functions +.br fts_read () +and +.br fts_children () +may fail and set +.i errno +for any of the errors specified for +.br chdir (2), +.br malloc (3), +.br opendir (3), +.br readdir (3), +and +.br stat (2). +.pp +in addition, +.br fts_children (), +.br fts_open (), +and +.br fts_set () +may fail and set +.i errno +as follows: +.tp +.b einval +.i options +or +.i instr +was invalid. +.sh versions +these functions are available in linux since glibc2. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br fts_open (), +.br fts_set (), +.br fts_close () +t} thread safety mt-safe +t{ +.br fts_read (), +.br fts_children () +t} thread safety mt-unsafe +.te +.hy +.ad +.sp 1 +.sh conforming to +4.4bsd. +.sh bugs +in versions of glibc before 2.23, +.\" fixed by commit 8b7b7f75d91f7bac323dd6a370aeb3e9c5c4a7d5 +.\" https://sourceware.org/bugzilla/show_bug.cgi?id=15838 +.\" https://sourceware.org/bugzilla/show_bug.cgi?id=11460 +all of the apis described in this man page are not safe when compiling +a program using the lfs apis (e.g., when compiling with +.ir \-d_file_offset_bits=64 ). +.\" +.\" the following statement is years old, and seems no closer to +.\" being true -- mtk +.\" the +.\" .i fts +.\" utility is expected to be included in a future +.\" posix.1 +.\" revision. +.sh see also +.br find (1), +.br chdir (2), +.br stat (2), +.br ftw (3), +.br qsort (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1994 mike battersby +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified by aeb, 960721 +.\" 2005-11-21, mtk, added descriptions of sigisemptyset(), sigandset(), +.\" and sigorset() +.\" 2007-10-26 mdw added wording that a sigset_t must be initialized +.\" prior to use +.\" +.th sigsetops 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +sigemptyset, sigfillset, sigaddset, sigdelset, sigismember \- posix +signal set operations +.sh synopsis +.nf +.b #include +.pp +.bi "int sigemptyset(sigset_t *" set ); +.bi "int sigfillset(sigset_t *" set ); +.pp +.bi "int sigaddset(sigset_t *" set ", int " signum ); +.bi "int sigdelset(sigset_t *" set ", int " signum ); +.pp +.bi "int sigismember(const sigset_t *" set ", int " signum ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br sigemptyset (), +.br sigfillset (), +.br sigaddset (), +.br sigdelset (), +.br sigismember (): +.nf + _posix_c_source +.fi +.sh description +these functions allow the manipulation of posix signal sets. +.pp +.br sigemptyset () +initializes the signal set given by +.i set +to empty, with all signals excluded from the set. +.pp +.br sigfillset () +initializes +.i set +to full, including all signals. +.pp +.br sigaddset () +and +.br sigdelset () +add and delete respectively signal +.i signum +from +.ir set . +.pp +.br sigismember () +tests whether +.i signum +is a member of +.ir set . +.pp +objects of type +.i sigset_t +must be initialized by a call to either +.br sigemptyset () +or +.br sigfillset () +before being passed to the functions +.br sigaddset (), +.br sigdelset (), +and +.br sigismember () +or the additional glibc functions described below +.rb ( sigisemptyset (), +.br sigandset (), +and +.br sigorset ()). +the results are undefined if this is not done. +.sh return value +.br sigemptyset (), +.br sigfillset (), +.br sigaddset (), +and +.br sigdelset () +return 0 on success and \-1 on error. +.pp +.br sigismember () +returns 1 if +.i signum +is a member of +.ir set , +0 if +.i signum +is not a member, and \-1 on error. +.pp +on error, these functions set +.i errno +to indicate the error. +.sh errors +.tp +.b einval +.i signum +is not a valid signal. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br sigemptyset (), +.br sigfillset (), +.br sigaddset (), +.br sigdelset (), +.br sigismember (), +.br sigisemptyset (), +.br sigorset (), +.br sigandset () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +when creating a filled signal set, the glibc +.br sigfillset () +function does not include the two real-time signals used internally +by the nptl threading implementation. +see +.br nptl (7) +for details. +.\" +.ss glibc extensions +if the +.b _gnu_source +feature test macro is defined, then \fi\fp +exposes three other functions for manipulating signal +sets: +.pp +.nf +.bi "int sigisemptyset(const sigset_t *" set ); +.bi "int sigorset(sigset_t *" dest ", const sigset_t *" left , +.bi " const sigset_t *" right ); +.bi "int sigandset(sigset_t *" dest ", const sigset_t *" left , +.bi " const sigset_t *" right ); +.fi +.pp +.br sigisemptyset () +returns 1 if +.i set +contains no signals, and 0 otherwise. +.pp +.br sigorset () +places the union of the sets +.i left +and +.i right +in +.ir dest . +.br sigandset () +places the intersection of the sets +.i left +and +.i right +in +.ir dest . +both functions return 0 on success, and \-1 on failure. +.pp +these functions are nonstandard (a few other systems provide similar +functions) and their use should be avoided in portable applications. +.sh see also +.br sigaction (2), +.br sigpending (2), +.br sigprocmask (2), +.br sigsuspend (2) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +==================== changes in man-pages-5.13 ==================== + +released: 2021-08-27, christchurch + +ahelenia ziemiańska (наб) +alan peakall +alejandro colomar +alexis wilke +askar safin +christian brauner +christophe leroy +christopher yeleighton +cristian morales vega +dan robertson +darrick j. wong +dominique brazziel +emanueletorre +eric w. biederman +g. branden robinson +helge kreutzmann +jakub wilk +james o. d. hunt +jonny grant +kees cook +kir kolyshkin +kurt kanzenbach +kxuan +michael kerrisk +michael weiß +neilbrown +nora platiel +pali rohár +peter collingbourne +richard palethorpe +rodrigo campos +sagar patel +serge e. hallyn +sergey petrakov +stefan kanthak +štěpán němec +thomas gleixner +thomas voss +viet than +will manley + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +mount_setattr.2 + christian brauner [alejandro colomar, michael kerrisk] + new manual page documenting the mount_setattr() system call + + +newly documented interfaces in existing pages +--------------------------------------------- + +futex.2 + kurt kanzenbach [alejandro colomar, thomas gleixner, michael kerrisk] + document futex_lock_pi2 + +ioctl_tty.2 + pali rohár [alejandro colomar, michael kerrisk] + document ioctls: tcgets2, tcsets2, tcsetsw2, tcsetsf2 + +pidfd_open.2 + michael kerrisk + document pidfd_nonblock + +seccomp_unotify.2 + rodrigo campos [alejandro colomar] + document seccomp_addfd_flag_send + +sigaction.2 + peter collingbourne [alejandro colomar, michael kerrisk] + document sa_expose_tagbits and the flag support detection protocol + +statx.2 + neilbrown + document statx_mnt_id +capabilities.7 +user_namespaces.7 + michael kerrisk, kir kolyshkin [alejandro colomar] + describe cap_setfcap for mapping uid 0 + +mount_namespaces.7 + michael kerrisk [christian brauner, eric w. biederman] + more clearly explain the notion of locked mounts + for a long time, this manual page has had a brief discussion of + "locked" mounts, without clearly saying what this concept is, or + why it exists. expand the discussion with an explanation of what + locked mounts are, why mounts are locked, and some examples of the + effect of locking. +user_namespaces.7 + michael kerrisk + document /proc/pid/projid_map + +ld.so.8 + michael kerrisk + document --list-tunables option added in glibc 2.33 + + +global changes +-------------- + +a few pages + michael kerrisk + errors: correct alphabetic order + +a few pages + michael kerrisk + place see also entries in correct order + +a few pages + michael kerrisk + arrange .sh sections in correct order + +various pages + michael kerrisk + fix ebadf error description + make the description of the ebadf error for invalid 'dirfd' more + uniform. in particular, note that the error only occurs when the + pathname is relative, and that it occurs when the 'dirfd' is + neither valid *nor* has the value at_fdcwd. + +various pages + michael kerrisk + errors: combine errors into a single alphabetic list + these pages split out extra errors for some apis into a separate + list. probably, the pages are easier to ready if all errors are + combined into a single list. + + note that there still remain a few pages where the errors are + listed separately for different apis. for the moment, it seems + best to leave those pages as is, since the error lists are + largely distinct in those pages. + +various pages + michael kerrisk + terminology clean-up: "mount point" ==> "mount" + many times, these pages use the terminology "mount point", where + "mount" would be better. a "mount point" is the location at which + a mount is attached. a "mount" is an association between a + filesystem and a mount point. + +accept.2 +access.2 +getpriority.2 +mlock.2 + michael kerrisk + errors: combine errors into a single list + these pages split out errors into separate lists (perhaps per api, + perhaps "may" vs "shall", perhaps "linux-specific" vs + standard(??)), but there's no good reason to do this. it makes + the error list harder to read, and is inconsistent with other + pages. so, combine the errors into a single list. + +fanotify_mark.2 +futimesat.2 +mount_setattr.2 +statx.2 +symlink.2 +mkfifo.3 + michael kerrisk + refer the reader to openat(2) for explanation of why 'dirfd' is useful + +various pages + thomas voss [alejandro colomar] + consistently use '*argv[]' + + +changes to individual pages +--------------------------- + +iconv.1 +iconvconfig.8 + michael kerrisk [christopher yeleighton] + files: note that files may be under /usr/lib64 rather than /lib/64 + see https://bugzilla.kernel.org/show_bug.cgi?id=214163 + +ldd.1 + alejandro colomar [emanueletorre] + fix example command + +add_key.2 +keyctl.2 +request_key.2 + michael kerrisk [dominique brazziel] + note that the "libkeyutils" package provides + see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=992377 + +close_range.2 + michael kerrisk, alejandro colomar + glibc 2.34 has added a close_range() wrapper + +execve.2 + michael kerrisk [nora platiel] + the pathname given to interpreter is not necessarily absolute + michael kerrisk + see also: getauxval(3) + getauxval(3) is useful background regarding execve(2). + +fanotify_mark.2 + michael kerrisk + errors: add missing ebadf error for invalid 'dirfd' + +ioctl_tty.2 + pali rohár [alejandro colomar] + update dtr example + do not include unused (and incompatible) header file termios.h and + include required header files for puts() and close() functions. + +mount.2 + michael kerrisk + errors: add eperm error for case where a mount is locked + refer the reader to mount_namespaces(7) for details. + michael kerrisk + see also: add mount_setattr(2) + +open.2 + michael kerrisk + explicitly describe the ebadf error that can occur with openat() + in particular, specifying an invalid file descriptor number + in 'dirfd' can be used as a check that 'pathname' is absolute. + michael kerrisk + clarify that openat()'s dirfd must be opened with o_rdonly or o_path + michael kerrisk + add mount_setattr(2) to list of 'dirfd' apis + +open_by_handle_at.2 + michael kerrisk + errors: add missing ebadf error for invalid 'dirfd' + +readv2.2 + will manley [alejandro colomar] + note preadv2(..., rwf_nowait) bug in bugs section + +readv.2 +pipe.7 + michael kerrisk [наб] + make text on pipe writes more general to avoid a confusion in writev(2) + +seccomp.2 + eric w. biederman [kees cook] + clarify that bad system calls kill the thread (not the process) + +syscalls.2 + michael kerrisk + add quotactl_fd(); remove quotactl_path() + quotactl_path() was never wired up in linux 5.13. + it was replaced instead by quotactl_fd(), + michael kerrisk + add system calls that are new in 5.13 + +umount.2 + michael kerrisk + errors: add einval for case where mount is locked + +wait.2 + richard palethorpe [alejandro colomar] + add esrch for when pid == int_min + michael kerrisk + errors: document eagain for waitid() on a pid file descriptor + +getaddrinfo.3 + alejandro colomar [cristian morales vega] + note that 'errno' is set in parallel with eai_system + +getauxval.3 + michael kerrisk + see also: add execve(2) + +getopt.3 + james o. d. hunt [alejandro colomar] + further clarification of 'optstring' + +pthread_setname_np.3 + michael kerrisk [alexis wilke] + examples: remove a bug by simplifying the code + +strlen.3 +wcslen.3 + michael kerrisk [alejandro colomar, jonny grant] + recommend alternatives where input buffer might not be null-terminated + +strstr.3 + alejandro colomar [stefan kanthak] + document special case for empty needle + +termios.3 + pali rohár [alejandro colomar] + sparc architecture has 4 different bnnn constants + pali rohár [alejandro colomar] + add information how to set baud rate to any other value + pali rohár [alejandro colomar] + use bold style for bnn and extn macro constants + pali rohár [alejandro colomar] + document missing baud-rate constants + +tsearch.3 + michael kerrisk + name: add twalk_r + +wcstok.3 + jakub wilk + fix type mismatch in the example + +proc.5 + michael kerrisk + add /proc/pid/projid_map, referring reader to user_namespaces(7) + michael kerrisk + remove duplicated /proc/[pid]/gid_map entry + +mount_namespaces.7 + michael kerrisk + terminology clean-up: "mount point" ==> "mount" + many times, this page uses the terminology "mount point", where + "mount" would be better. a "mount point" is the location at which + a mount is attached. a "mount" is an association between a + filesystem and a mount point. + michael kerrisk + see also: add mount_setattr(2) + +namespaces.7 + štěpán němec [alejandro colomar] + fix confusion caused by text reorganization + +path_resolution.7 + michael kerrisk [askar safin] + improve description of trailing slashes + see https://bugzilla.kernel.org/show_bug.cgi?id=212385 + +posixoptions.7 + alejandro colomar [alan peakall] + fix legacy functions list (s/getcwd/getwd/) + +user_namespaces.7 + kir kolyshkin [alejandro colomar] + fix a reference to a kernel document + michael kerrisk [eric w. biederman] + add a definition of "global root" + +vdso.7 + michael kerrisk [christophe leroy] + update clock_realtime_coarse + clock_monotonic_coarse info for powerpc + alejandro colomar [christophe leroy] + add y2038 compliant gettime for ppc/32 + +.so man3/stdarg.3 + +.so man3/modf.3 + +.so man7/system_data_types.7 + +.so man3/log.3 + +.so man2/outb.2 + +.so man2/outb.2 + +.so man4/null.4 + +.\" this man page is copyright (c) 1998 pawel krawczyk. +.\" +.\" %%%license_start(verbatim_one_para) +.\" permission is granted to distribute possibly modified copies +.\" of this page provided the header is included verbatim, +.\" and in case of nontrivial modification author and date +.\" of the modification is added to the header. +.\" %%%license_end +.\" +.\" $id: sendfile.2,v 1.5 1999/05/18 11:54:11 freitag exp $ +.\" 2000-11-19 bert hubert : in_fd cannot be socket +.\" +.\" 2004-12-17, mtk +.\" updated description of in_fd and out_fd for 2.6 +.\" various wording and formatting changes +.\" +.\" 2005-03-31 martin pool mmap() improvements +.\" +.th sendfile 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +sendfile \- transfer data between file descriptors +.sh synopsis +.nf +.b #include +.pp +.bi "ssize_t sendfile(int" " out_fd" ", int" " in_fd" ", off_t *" \ + offset ", size_t" " count" ); +.\" the below is too ugly. comments about glibc versions belong +.\" in the notes, not in the header. +.\" +.\" .b #include +.\" .b #if (__glibc__==2 && __glibc_minor__>=1) || __glibc__>2 +.\" .b #include +.\" #else +.\" .b #include +.\" .b /* no system prototype before glibc 2.1. */ +.\" .bi "ssize_t sendfile(int" " out_fd" ", int" " in_fd" ", off_t *" \ +.\" offset ", size_t" " count" ) +.\" .b #endif +.\" +.fi +.sh description +.br sendfile () +copies data between one file descriptor and another. +because this copying is done within the kernel, +.br sendfile () +is more efficient than the combination of +.br read (2) +and +.br write (2), +which would require transferring data to and from user space. +.pp +.i in_fd +should be a file descriptor opened for reading and +.i out_fd +should be a descriptor opened for writing. +.pp +if +.i offset +is not null, then it points +to a variable holding the file offset from which +.br sendfile () +will start reading data from +.ir in_fd . +when +.br sendfile () +returns, this variable +will be set to the offset of the byte following the last byte that was read. +if +.i offset +is not null, then +.br sendfile () +does not modify the file offset of +.ir in_fd ; +otherwise the file offset is adjusted to reflect +the number of bytes read from +.ir in_fd . +.pp +if +.i offset +is null, then data will be read from +.ir in_fd +starting at the file offset, +and the file offset will be updated by the call. +.pp +.i count +is the number of bytes to copy between the file descriptors. +.pp +the +.ir in_fd +argument must correspond to a file which supports +.br mmap (2)-like +operations +(i.e., it cannot be a socket). +.pp +in linux kernels before 2.6.33, +.i out_fd +must refer to a socket. +since linux 2.6.33 it can be any file. +if it is a regular file, then +.br sendfile () +changes the file offset appropriately. +.sh return value +if the transfer was successful, the number of bytes written to +.i out_fd +is returned. +note that a successful call to +.br sendfile () +may write fewer bytes than requested; +the caller should be prepared to retry the call if there were unsent bytes. +see also notes. +.pp +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eagain +nonblocking i/o has been selected using +.b o_nonblock +and the write would block. +.tp +.b ebadf +the input file was not opened for reading or the output file +was not opened for writing. +.tp +.b efault +bad address. +.tp +.b einval +descriptor is not valid or locked, or an +.br mmap (2)-like +operation is not available for +.ir in_fd , +or +.i count +is negative. +.tp +.b einval +.i out_fd +has the +.b o_append +flag set. +this is not currently supported by +.br sendfile (). +.tp +.b eio +unspecified error while reading from +.ir in_fd . +.tp +.b enomem +insufficient memory to read from +.ir in_fd . +.tp +.b eoverflow +.i count +is too large, the operation would result in exceeding the maximum size of either +the input file or the output file. +.tp +.b espipe +.i offset +is not null but the input file is not seekable. +.sh versions +.br sendfile () +first appeared in linux 2.2. +the include file +.i +is present since glibc 2.1. +.sh conforming to +not specified in posix.1-2001, nor in other standards. +.pp +other unix systems implement +.br sendfile () +with different semantics and prototypes. +it should not be used in portable programs. +.sh notes +.br sendfile () +will transfer at most 0x7ffff000 (2,147,479,552) bytes, +returning the number of bytes actually transferred. +.\" commit e28cc71572da38a5a12c1cfe4d7032017adccf69 +(this is true on both 32-bit and 64-bit systems.) +.pp +if you plan to use +.br sendfile () +for sending files to a tcp socket, but need +to send some header data in front of the file contents, you will find +it useful to employ the +.b tcp_cork +option, described in +.br tcp (7), +to minimize the number of packets and to tune performance. +.pp +in linux 2.4 and earlier, +.i out_fd +could also refer to a regular file; +this possibility went away in the linux 2.6.x kernel series, +but was restored in linux 2.6.33. +.pp +the original linux +.br sendfile () +system call was not designed to handle large file offsets. +consequently, linux 2.4 added +.br sendfile64 (), +with a wider type for the +.i offset +argument. +the glibc +.br sendfile () +wrapper function transparently deals with the kernel differences. +.pp +applications may wish to fall back to +.br read (2)/ write (2) +in the case where +.br sendfile () +fails with +.b einval +or +.br enosys . +.pp +if +.i out_fd +refers to a socket or pipe with zero-copy support, callers must ensure the +transferred portions of the file referred to by +.i in_fd +remain unmodified until the reader on the other end of +.i out_fd +has consumed the transferred data. +.pp +the linux-specific +.br splice (2) +call supports transferring data between arbitrary file descriptors +provided one (or both) of them is a pipe. +.sh see also +.br copy_file_range (2), +.br mmap (2), +.br open (2), +.br socket (2), +.br splice (2) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/ftw.3 + +.so man3/ctanh.3 + +.\" this manpage is copyright (c) 1992 drew eckhardt; +.\" and copyright (c) 1993 michael haardt, ian jackson. +.\" and copyright (c) 2016 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified wed jul 21 22:40:25 1993 by rik faith +.\" modified sat feb 18 15:27:48 1995 by michael haardt +.\" modified sun apr 14 11:40:50 1996 by andries brouwer : +.\" corrected description of effect on locks (thanks to +.\" tigran aivazian ). +.\" modified fri jan 31 16:21:46 1997 by eric s. raymond +.\" modified 2000-07-22 by nicolás lichtmaier +.\" added note about close(2) not guaranteeing that data is safe on close. +.\" +.th close 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +close \- close a file descriptor +.sh synopsis +.nf +.b #include +.pp +.bi "int close(int " fd ); +.fi +.sh description +.br close () +closes a file descriptor, so that it no longer refers to any file and +may be reused. +any record locks (see +.br fcntl (2)) +held on the file it was associated with, +and owned by the process, are removed (regardless of the file +descriptor that was used to obtain the lock). +.pp +if +.i fd +is the last file descriptor referring to the underlying +open file description (see +.br open (2)), +the resources associated with the open file description are freed; +if the file descriptor was the last reference to a file which has been +removed using +.br unlink (2), +the file is deleted. +.sh return value +.br close () +returns zero on success. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b ebadf +.i fd +isn't a valid open file descriptor. +.tp +.b eintr +.\" though, it's in doubt whether this error can ever occur; see +.\" https://lwn.net/articles/576478/ "returning eintr from close()" +the +.br close () +call was interrupted by a signal; see +.br signal (7). +.tp +.b eio +an i/o error occurred. +.tp +.br enospc ", " edquot +on nfs, these errors are not normally reported against the first write +which exceeds the available storage space, but instead against a +subsequent +.br write (2), +.br fsync (2), +or +.br close (). +.pp +see notes for a discussion of why +.br close () +should not be retried after an error. +.sh conforming to +posix.1-2001, posix.1-2008, svr4, 4.3bsd. +.\" svr4 documents an additional enolink error condition. +.sh notes +a successful close does not guarantee that the data has been successfully +saved to disk, as the kernel uses the buffer cache to defer writes. +typically, filesystems do not flush buffers when a file is closed. +if you need to be sure that +the data is physically stored on the underlying disk, use +.br fsync (2). +(it will depend on the disk hardware at this point.) +.pp +the close-on-exec file descriptor flag can be used to ensure +that a file descriptor is automatically closed upon a successful +.br execve (2); +see +.br fcntl (2) +for details. +.\" +.ss multithreaded processes and close() +it is probably unwise to close file descriptors while +they may be in use by system calls in +other threads in the same process. +since a file descriptor may be reused, +there are some obscure race conditions +that may cause unintended side effects. +.\" date: tue, 4 sep 2007 13:57:35 +0200 +.\" from: fredrik noring +.\" one such race involves signals and erestartsys. if a file descriptor +.\" in use by a system call is closed and then reused by e.g. an +.\" independent open() in some unrelated thread, before the original system +.\" call has restarted after erestartsys, the original system call will +.\" later restart with the reused file descriptor. this is most likely a +.\" serious programming error. +.pp +furthermore, consider the following scenario where two threads are +performing operations on the same file descriptor: +.ip 1. 3 +one thread is blocked in an i/o system call on the file descriptor. +for example, it is trying to +.br write (2) +to a pipe that is already full, or trying to +.br read (2) +from a stream socket which currently has no available data. +.ip 2. +another thread closes the file descriptor. +.pp +the behavior in this situation varies across systems. +on some systems, when the file descriptor is closed, +the blocking system call returns immediately with an error. +.pp +on linux (and possibly some other systems), the behavior is different: +the blocking i/o system call holds a reference to the underlying +open file description, and this reference keeps the description open +until the i/o system call completes. +.\" 'struct file' in kernel-speak +(see +.br open (2) +for a discussion of open file descriptions.) +thus, the blocking system call in the first thread may successfully +complete after the +.br close () +in the second thread. +.\" +.ss dealing with error returns from close() +a careful programmer will check the return value of +.br close (), +since it is quite possible that errors on a previous +.br write (2) +operation are reported only on the final +.br close () +that releases the open file description. +failing to check the return value when closing a file may lead to +.i silent +loss of data. +this can especially be observed with nfs and with disk quota. +.pp +note, however, that a failure return should be used only for +diagnostic purposes (i.e., a warning to the application that there +may still be i/o pending or there may have been failed i/o) +or remedial purposes +(e.g., writing the file once more or creating a backup). +.pp +retrying the +.br close () +after a failure return is the wrong thing to do, +.\" the file descriptor is released early in close(); +.\" close() ==> __close_fd(): +.\" __put_unused_fd() ==> __clear_open_fd() +.\" return filp_close(file, files); +.\" +.\" the errors are returned by filp_close() after the fd has been +.\" cleared for re-use. +since this may cause a reused file descriptor +from another thread to be closed. +this can occur because the linux kernel +.i always +releases the file descriptor early in the close +operation, freeing it for reuse; +the steps that may return an error, +.\" filp_close() +such as flushing data to the filesystem or device, +occur only later in the close operation. +.pp +many other implementations similarly always close the file descriptor +.\" freebsd documents this explicitly. from the look of the source code +.\" svr4, ancient sunos, later solaris, and aix all do this. +(except in the case of +.br ebadf , +meaning that the file descriptor was invalid) +even if they subsequently report an error on return from +.br close (). +posix.1 is currently silent on this point, +but there are plans to mandate this behavior in the next major release +.\" issue 8 +of the standard. +.pp +a careful programmer who wants to know about i/o errors may precede +.br close () +with a call to +.br fsync (2). +.pp +the +.b eintr +error is a somewhat special case. +regarding the +.b eintr +error, posix.1-2008 says: +.pp +.rs +if +.br close () +is interrupted by a signal that is to be caught, it shall return \-1 with +.i errno +set to +.b eintr +and the state of +.i fildes +is unspecified. +.re +.pp +this permits the behavior that occurs on linux and +many other implementations, where, +as with other errors that may be reported by +.br close (), +the file descriptor is guaranteed to be closed. +however, it also permits another possibility: +that the implementation returns an +.b eintr +error and keeps the file descriptor open. +(according to its documentation, hp-ux's +.br close () +does this.) +the caller must then once more use +.br close () +to close the file descriptor, to avoid file descriptor leaks. +this divergence in implementation behaviors provides +a difficult hurdle for portable applications, since on many implementations, +.br close () +must not be called again after an +.b eintr +error, and on at least one, +.br close () +must be called again. +there are plans to address this conundrum for +the next major release of the posix.1 standard. +.\" fixme . for later review when issue 8 is one day released... +.\" posix proposes further changes for eintr +.\" http://austingroupbugs.net/tag_view_page.php?tag_id=8 +.\" http://austingroupbugs.net/view.php?id=529 +.\" +.\" fixme . +.\" review the following glibc bug later +.\" https://sourceware.org/bugzilla/show_bug.cgi?id=14627 +.sh see also +.br close_range (2), +.br fcntl (2), +.br fsync (2), +.br open (2), +.br shutdown (2), +.br unlink (2), +.br fclose (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" iso/iec 9899:1999 +.\" +.th wcsncat 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +wcsncat \- concatenate two wide-character strings +.sh synopsis +.nf +.b #include +.pp +.bi "wchar_t *wcsncat(wchar_t *restrict " dest \ +", const wchar_t *restrict " src , +.bi " size_t " n ); +.fi +.sh description +the +.br wcsncat () +function is the wide-character equivalent of the +.br strncat (3) +function. +it copies at most +.i n +wide characters from the wide-character +string pointed to by +.i src +to the end of the wide-character string pointed +to by +.ir dest , +and adds a terminating null wide character (l\(aq\e0\(aq). +.pp +the strings may not overlap. +.pp +the programmer must ensure that there is room for at least +.ir wcslen(dest) + n +1 +wide characters at +.ir dest . +.sh return value +.br wcsncat () +returns +.ir dest . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br wcsncat () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh see also +.br strncat (3), +.br wcscat (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/err.3 + +.\" copyright 2008 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" +.th random_r 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +random_r, srandom_r, initstate_r, setstate_r \- reentrant +random number generator +.sh synopsis +.nf +.b #include +.pp +.bi "int random_r(struct random_data *restrict " buf , +.bi " int32_t *restrict " result ); +.bi "int srandom_r(unsigned int " seed ", struct random_data *" buf ); +.pp +.bi "int initstate_r(unsigned int " seed ", char *restrict " statebuf , +.bi " size_t " statelen ", struct random_data *restrict " buf ); +.bi "int setstate_r(char *restrict " statebuf , +.bi " struct random_data *restrict " buf ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br random_r (), +.br srandom_r (), +.br initstate_r (), +.br setstate_r (): +.nf + /* glibc since 2.19: */ _default_source + || /* glibc <= 2.19: */ _svid_source || _bsd_source +.fi +.sh description +these functions are the reentrant equivalents +of the functions described in +.br random (3). +they are suitable for use in multithreaded programs where each thread +needs to obtain an independent, reproducible sequence of random numbers. +.pp +the +.br random_r () +function is like +.br random (3), +except that instead of using state information maintained +in a global variable, +it uses the state information in the argument pointed to by +.ir buf , +which must have been previously initialized by +.br initstate_r (). +the generated random number is returned in the argument +.ir result . +.pp +the +.br srandom_r () +function is like +.br srandom (3), +except that it initializes the seed for the random number generator +whose state is maintained in the object pointed to by +.ir buf , +which must have been previously initialized by +.br initstate_r (), +instead of the seed associated with the global state variable. +.pp +the +.br initstate_r () +function is like +.br initstate (3) +except that it initializes the state in the object pointed to by +.ir buf , +rather than initializing the global state variable. +before calling this function, the +.ir buf.state +field must be initialized to null. +the +.br initstate_r () +function records a pointer to the +.i statebuf +argument inside the structure pointed to by +.ir buf . +thus, +.ir statebuf +should not be deallocated so long as +.ir buf +is still in use. +(so, +.i statebuf +should typically be allocated as a static variable, +or allocated on the heap using +.br malloc (3) +or similar.) +.pp +the +.br setstate_r () +function is like +.br setstate (3) +except that it modifies the state in the object pointed to by +.ir buf , +rather than modifying the global state variable. +\fistate\fp must first have been initialized +using +.br initstate_r () +or be the result of a previous call of +.br setstate_r (). +.sh return value +all of these functions return 0 on success. +on error, \-1 is returned, with +.i errno +set to indicate the error. +.sh errors +.tp +.b einval +a state array of less than 8 bytes was specified to +.br initstate_r (). +.tp +.b einval +the +.i statebuf +or +.i buf +argument to +.br setstate_r () +was null. +.tp +.b einval +the +.i buf +or +.i result +argument to +.br random_r () +was null. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br random_r (), +.br srandom_r (), +.br initstate_r (), +.br setstate_r () +t} thread safety mt-safe race:buf +.te +.hy +.ad +.sp 1 +.sh conforming to +these functions are nonstandard glibc extensions. +.\" these functions appear to be on tru64, but don't seem to be on +.\" solaris, hp-ux, or freebsd. +.sh bugs +the +.br initstate_r () +interface is confusing. +.\" fixme . https://sourceware.org/bugzilla/show_bug.cgi?id=3662 +it appears that the +.ir random_data +type is intended to be opaque, +but the implementation requires the user to either initialize the +.i buf.state +field to null or zero out the entire structure before the call. +.sh see also +.br drand48 (3), +.br rand (3), +.br random (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/sgetmask.2 + +.\" copyright 1993 rickard e. faith (faith@cs.unc.edu) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified, 27 may 2004, michael kerrisk +.\" added notes on capability requirements +.\" +.th vhangup 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +vhangup \- virtually hangup the current terminal +.sh synopsis +.nf +.b #include +.pp +.b int vhangup(void); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br vhangup (): +.nf + since glibc 2.21: +.\" commit 266865c0e7b79d4196e2cc393693463f03c90bd8 + _default_source + in glibc 2.19 and 2.20: + _default_source || (_xopen_source && _xopen_source < 500) + up to and including glibc 2.19: + _bsd_source || (_xopen_source && _xopen_source < 500) +.fi +.sh description +.br vhangup () +simulates a hangup on the current terminal. +this call arranges for other +users to have a \*(lqclean\*(rq terminal at login time. +.sh return value +on success, zero is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eperm +the calling process has insufficient privilege to call +.br vhangup (); +the +.b cap_sys_tty_config +capability is required. +.sh conforming to +this call is linux-specific, and should not be used in programs +intended to be portable. +.sh see also +.br init (1), +.br capabilities (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/sinh.3 + +.\" copyright (c) 1993 michael haardt (michael@moria.de), +.\" fri apr 2 11:32:09 met dst 1993 +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" modified sat jul 24 17:03:24 1993 by rik faith (faith@cs.unc.edu) +.th ttys 4 1992-12-19 "linux" "linux programmer's manual" +.sh name +ttys \- serial terminal lines +.sh description +.b ttys[0\-3] +are character devices for the serial terminal lines. +.pp +they are typically created by: +.pp +.in +4n +.ex +mknod \-m 660 /dev/ttys0 c 4 64 # base address 0x3f8 +mknod \-m 660 /dev/ttys1 c 4 65 # base address 0x2f8 +mknod \-m 660 /dev/ttys2 c 4 66 # base address 0x3e8 +mknod \-m 660 /dev/ttys3 c 4 67 # base address 0x2e8 +chown root:tty /dev/ttys[0\-3] +.ee +.in +.sh files +.i /dev/ttys[0\-3] +.sh see also +.br chown (1), +.br mknod (1), +.br tty (4), +.br agetty (8), +.br mingetty (8), +.br setserial (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1994 jochen hein (hein@student.tu-clausthal.de) +.\" +.\" %%%license_start(gplv2+_sw_3_para) +.\" this program is free software; you can redistribute it and/or modify +.\" it under the terms of the gnu general public license as published by +.\" the free software foundation; either version 2 of the license, or +.\" (at your option) any later version. +.\" +.\" this program 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th charmap 5 2020-06-09 "gnu" "linux programmer's manual" +.sh name +charmap \- character set description file +.sh description +a character set description (charmap) defines all available characters +and their encodings in a character set. +.br localedef (1) +can use charmaps to create locale variants for different character sets. +.ss syntax +the charmap file starts with a header that may consist of the +following keywords: +.tp +.ri < code_set_name > +is followed by the name of the character map. +.tp +.ri < comment_char > +is followed by a character that will be used as the comment character +for the rest of the file. +it defaults to the number sign (#). +.tp +.ri < escape_char > +is followed by a character that should be used as the escape character +for the rest of the file to mark characters that should be interpreted +in a special way. +it defaults to the backslash (\e). +.tp +.ri < mb_cur_max > +is followed by the maximum number of bytes for a character. +the default value is 1. +.tp +.ri < mb_cur_min > +is followed by the minimum number of bytes for a character. +this value must be less than or equal than +.ri < mb_cur_max >. +if not specified, it defaults to +.ri < mb_cur_max >. +.pp +the character set definition section starts with the keyword +.i charmap +in the first column. +.pp +the following lines may have one of the two following forms to +define the character set: +.tp +.ri < character >\ byte-sequence\ comment +this form defines exactly one character and its byte sequence, +.i comment +being optional. +.tp +.ri < character >..< character >\ byte-sequence\ comment +this form defines a character range and its byte sequence, +.i comment +being optional. +.pp +the character set definition section ends with the string +.ir "end charmap" . +.pp +the character set definition section may optionally be followed by a +section to define widths of characters. +.pp +the +.i width_default +keyword can be used to define the default width for all characters +not explicitly listed. +the default character width is 1. +.pp +the width section for individual characters starts with the keyword +.i width +in the first column. +.pp +the following lines may have one of the two following forms to +define the widths of the characters: +.tp +.ri < character >\ width +this form defines the width of exactly one character. +.tp +.ri < character >...< character >\ width +this form defines the width for all the characters in the range. +.pp +the width definition section ends with the string +.ir "end width" . +.sh files +.tp +.i /usr/share/i18n/charmaps +usual default character map path. +.sh conforming to +posix.2. +.sh examples +the euro sign is defined as follows in the +.i utf\-8 +charmap: +.pp +.nf + /xe2/x82/xac euro sign +.fi +.sh see also +.br iconv (1), +.br locale (1), +.br localedef (1), +.br locale (5), +.br charsets (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2006 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th sem_open 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +sem_open \- initialize and open a named semaphore +.sh synopsis +.nf +.br "#include " " /* for o_* constants */" +.br "#include " " /* for mode constants */" +.b #include +.pp +.bi "sem_t *sem_open(const char *" name ", int " oflag ); +.bi "sem_t *sem_open(const char *" name ", int " oflag , +.bi " mode_t " mode ", unsigned int " value ); +.fi +.pp +link with \fi\-pthread\fp. +.sh description +.br sem_open () +creates a new posix semaphore or opens an existing semaphore. +the semaphore is identified by +.ir name . +for details of the construction of +.ir name , +see +.br sem_overview (7). +.pp +the +.i oflag +argument specifies flags that control the operation of the call. +(definitions of the flags values can be obtained by including +.ir .) +if +.b o_creat +is specified in +.ir oflag , +then the semaphore is created if +it does not already exist. +the owner (user id) of the semaphore is set to the effective +user id of the calling process. +the group ownership (group id) is set to the effective group id +of the calling process. +.\" in reality the filesystem ids are used on linux. +if both +.b o_creat +and +.b o_excl +are specified in +.ir oflag , +then an error is returned if a semaphore with the given +.i name +already exists. +.pp +if +.b o_creat +is specified in +.ir oflag , +then two additional arguments must be supplied. +the +.i mode +argument specifies the permissions to be placed on the new semaphore, +as for +.br open (2). +(symbolic definitions for the permissions bits can be obtained by including +.ir .) +the permissions settings are masked against the process umask. +both read and write permission should be granted to each class of +user that will access the semaphore. +the +.i value +argument specifies the initial value for the new semaphore. +if +.b o_creat +is specified, and a semaphore with the given +.i name +already exists, then +.i mode +and +.i value +are ignored. +.sh return value +on success, +.br sem_open () +returns the address of the new semaphore; +this address is used when calling other semaphore-related functions. +on error, +.br sem_open () +returns +.br sem_failed , +with +.i errno +set to indicate the error. +.sh errors +.tp +.b eacces +the semaphore exists, but the caller does not have permission to +open it. +.tp +.b eexist +both +.b o_creat +and +.b o_excl +were specified in +.ir oflag , +but a semaphore with this +.i name +already exists. +.tp +.b einval +.i value +was greater than +.br sem_value_max . +.tp +.b einval +.i name +consists of just "/", followed by no other characters. +.tp +.b emfile +the per-process limit on the number of open file descriptors has been reached. +.tp +.b enametoolong +.i name +was too long. +.tp +.b enfile +the system-wide limit on the total number of open files has been reached. +.tp +.b enoent +the +.b o_creat +flag was not specified in +.ir oflag +and no semaphore with this +.i name +exists; +or, +.\" this error can occur if we have a name of the (nonportable) form +.\" /dir/name, and the directory /dev/shm/dir does not exist. +.b o_creat +was specified, but +.i name +wasn't well formed. +.tp +.b enomem +insufficient memory. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br sem_open () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh see also +.br sem_close (3), +.br sem_getvalue (3), +.br sem_post (3), +.br sem_unlink (3), +.br sem_wait (3), +.br sem_overview (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/finite.3 + +.so man3/circleq.3 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" and copyright 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified 1993-07-24 by rik faith (faith@cs.unc.edu) +.\" modified 2002-07-27 by walter harms +.\" (walter.harms@informatik.uni-oldenburg.de) +.\" +.th atan 3 2021-03-22 "" "linux programmer's manual" +.sh name +atan, atanf, atanl \- arc tangent function +.sh synopsis +.nf +.b #include +.pp +.bi "double atan(double " x ); +.bi "float atanf(float " x ); +.bi "long double atanl(long double " x ); +.pp +.fi +link with \fi\-lm\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br atanf (), +.br atanl (): +.nf + _isoc99_source || _posix_c_source >= 200112l + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.sh description +these functions calculate the principal value of the arc tangent of +.ir x ; +that is the value whose tangent is +.ir x . +.sh return value +on success, these functions return the principal value of the arc tangent of +.ir x +in radians; the return value is in the range [\-pi/2,\ pi/2]. +.pp +if +.i x +is a nan, a nan is returned. +.pp +if +.i x +is +0 (\-0), ++0 (\-0) is returned. +.pp +if +.i x +is positive infinity (negative infinity), +pi/2 (\-pi/2) is returned. +.\" +.\" posix.1-2001 documents an optional range error for subnormal x; +.\" glibc 2.8 does not do this. +.sh errors +no errors occur. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br atan (), +.br atanf (), +.br atanl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.pp +the variant returning +.i double +also conforms to +svr4, 4.3bsd, c89. +.sh see also +.br acos (3), +.br asin (3), +.br atan2 (3), +.br carg (3), +.br catan (3), +.br cos (3), +.br sin (3), +.br tan (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/atan2.3 + +.so man2/fstatfs.2 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified 1993-07-24 by rik faith (faith@cs.unc.edu) +.\" modified 2002-08-10 by walter harms (walter.harms@informatik.uni-oldenburg.de) +.th copysign 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +copysign, copysignf, copysignl \- copy sign of a number +.sh synopsis +.nf +.b #include +.pp +.bi "double copysign(double " x ", double " y ); +.bi "float copysignf(float " x ", float " y ); +.bi "long double copysignl(long double " x ", long double " y ); +.fi +.pp +link with \fi\-lm\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br copysign (), +.br copysignf (), +.br copysignl (): +.nf + _isoc99_source || _posix_c_source >= 200112l + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.sh description +these functions return a value whose absolute value matches that of +.ir x , +but whose sign bit matches that of +.ir y . +.pp +for example, +.i "copysign(42.0,\ \-1.0)" +and +.i "copysign(\-42.0, \-1.0)" +both return \-42.0. +.sh return value +on success, these functions return a value whose magnitude is taken from +.i x +and whose sign is taken from +.ir y . +.pp +if +.i x +is a nan, +a nan with the sign bit of +.i y +is returned. +.sh errors +no errors occur. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br copysign (), +.br copysignf (), +.br copysignl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.\" 4.3bsd. +this function is defined in iec 559 (and the appendix with +recommended functions in ieee 754/ieee 854). +.sh notes +on architectures where the floating-point formats are not ieee 754 compliant, +these +functions may treat a negative zero as positive. +.sh see also +.br signbit (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/lgamma.3 + +.so man3/makedev.3 + +.so man3/unlocked_stdio.3 + +.so man3/log1p.3 + +.so man3/gethostbyname.3 + +.so man3/stdio_ext.3 + +.\" this man page is copyright (c) 1999 andi kleen . +.\" +.\" %%%license_start(verbatim_one_para) +.\" permission is granted to distribute possibly modified copies +.\" of this page provided the header is included verbatim, +.\" and in case of nontrivial modification author and date +.\" of the modification is added to the header. +.\" %%%license_end +.\" +.\" $id: rtnetlink.3,v 1.2 1999/05/18 10:35:10 freitag exp $ +.\" +.th rtnetlink 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +rtnetlink \- macros to manipulate rtnetlink messages +.sh synopsis +.nf +.b #include +.b #include +.b #include +.b #include +.pp +.bi "rtnetlink_socket = socket(af_netlink, int " socket_type \ +", netlink_route);" +.pp +.bi "int rta_ok(struct rtattr *" rta ", int " rtabuflen ); +.pp +.bi "void *rta_data(struct rtattr *" rta ); +.bi "unsigned int rta_payload(struct rtattr *" rta ); +.pp +.bi "struct rtattr *rta_next(struct rtattr *" rta \ +", unsigned int " rtabuflen ); +.pp +.bi "unsigned int rta_length(unsigned int " length ); +.bi "unsigned int rta_space(unsigned int "length ); +.fi +.sh description +all +.br rtnetlink (7) +messages consist of a +.br netlink (7) +message header and appended attributes. +the attributes should be manipulated only using the macros provided here. +.pp +.bi rta_ok( rta ", " attrlen ) +returns true if +.i rta +points to a valid routing attribute; +.i attrlen +is the running length of the attribute buffer. +when not true then you must assume there are no more attributes in the +message, even if +.i attrlen +is nonzero. +.pp +.bi rta_data( rta ) +returns a pointer to the start of this attribute's data. +.pp +.bi rta_payload( rta ) +returns the length of this attribute's data. +.pp +.bi rta_next( rta ", " attrlen ) +gets the next attribute after +.ir rta . +calling this macro will update +.ir attrlen . +you should use +.b rta_ok +to check the validity of the returned pointer. +.pp +.bi rta_length( len ) +returns the length which is required for +.i len +bytes of data plus the header. +.pp +.bi rta_space( len ) +returns the amount of space which will be needed in a message with +.i len +bytes of data. +.sh conforming to +these macros are nonstandard linux extensions. +.sh bugs +this manual page is incomplete. +.sh examples +.\" fixme . ? would be better to use libnetlink in the example code here +creating a rtnetlink message to set the mtu of a device: +.pp +.in +4n +.ex +#include + +\&... + +struct { + struct nlmsghdr nh; + struct ifinfomsg if; + char attrbuf[512]; +} req; + +struct rtattr *rta; +unsigned int mtu = 1000; + +int rtnetlink_sk = socket(af_netlink, sock_dgram, netlink_route); + +memset(&req, 0, sizeof(req)); +req.nh.nlmsg_len = nlmsg_length(sizeof(req.if)); +req.nh.nlmsg_flags = nlm_f_request; +req.nh.nlmsg_type = rtm_newlink; +req.if.ifi_family = af_unspec; +req.if.ifi_index = interface_index; +req.if.ifi_change = 0xffffffff; /* ??? */ +rta = (struct rtattr *)(((char *) &req) + + nlmsg_align(req.nh.nlmsg_len)); +rta\->rta_type = ifla_mtu; +rta\->rta_len = rta_length(sizeof(mtu)); +req.nh.nlmsg_len = nlmsg_align(req.nh.nlmsg_len) + + rta_length(sizeof(mtu)); +memcpy(rta_data(rta), &mtu, sizeof(mtu)); +send(rtnetlink_sk, &req, req.nh.nlmsg_len, 0); +.ee +.in +.sh see also +.br netlink (3), +.br netlink (7), +.br rtnetlink (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/ccos.3 + +.\" copyright (c) 2017 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th bzero 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +bzero, explicit_bzero \- zero a byte string +.sh synopsis +.nf +.b #include +.pp +.bi "void bzero(void *" s ", size_t " n ); +.pp +.b #include +.pp +.bi "void explicit_bzero(void *" s ", size_t " n ); +.fi +.sh description +the +.br bzero () +function erases the data in the +.i n +bytes of the memory starting at the location pointed to by +.ir s , +by writing zeros (bytes containing \(aq\e0\(aq) to that area. +.pp +the +.br explicit_bzero () +function performs the same task as +.br bzero (). +it differs from +.br bzero () +in that it guarantees that compiler optimizations will not remove the +erase operation if the compiler deduces that the operation is "unnecessary". +.sh return value +none. +.sh versions +.br explicit_bzero () +first appeared in glibc 2.25. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br bzero (), +.br explicit_bzero () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +the +.br bzero () +function is deprecated (marked as legacy in posix.1-2001); use +.br memset (3) +in new programs. +posix.1-2008 removes the specification of +.br bzero (). +the +.br bzero () +function first appeared in 4.3bsd. +.pp +the +.br explicit_bzero () +function is a nonstandard extension that is also present on some of the bsds. +some other implementations have a similar function, such as +.br memset_explicit () +or +.br memset_s (). +.sh notes +the +.br explicit_bzero () +function addresses a problem that security-conscious applications +may run into when using +.br bzero (): +if the compiler can deduce that the location to be zeroed will +never again be touched by a +.i correct +program, then it may remove the +.br bzero () +call altogether. +this is a problem if the intent of the +.br bzero () +call was to erase sensitive data (e.g., passwords) +to prevent the possibility that the data was leaked +by an incorrect or compromised program. +calls to +.br explicit_bzero () +are never optimized away by the compiler. +.pp +the +.br explicit_bzero () +function does not solve all problems associated with erasing sensitive data: +.ip 1. 3 +the +.br explicit_bzero () +function does +.i not +guarantee that sensitive data is completely erased from memory. +(the same is true of +.br bzero ().) +for example, there may be copies of the sensitive data in +a register and in "scratch" stack areas. +the +.br explicit_bzero () +function is not aware of these copies, and can't erase them. +.ip 2. +in some circumstances, +.br explicit_bzero () +can +.i decrease +security. +if the compiler determined that the variable containing the +sensitive data could be optimized to be stored in a register +(because it is small enough to fit in a register, +and no operation other than the +.br explicit_bzero () +call would need to take the address of the variable), then the +.br explicit_bzero () +call will force the data to be copied from the register +to a location in ram that is then immediately erased +(while the copy in the register remains unaffected). +the problem here is that data in ram is more likely to be exposed +by a bug than data in a register, and thus the +.br explicit_bzero () +call creates a brief time window where the sensitive data is more +vulnerable than it would otherwise have been +if no attempt had been made to erase the data. +.pp +note that declaring the sensitive variable with the +.b volatile +qualifier does +.i not +eliminate the above problems. +indeed, it will make them worse, since, for example, +it may force a variable that would otherwise have been optimized +into a register to instead be maintained in (more vulnerable) +ram for its entire lifetime. +.pp +notwithstanding the above details, for security-conscious applications, using +.br explicit_bzero () +is generally preferable to not using it. +the developers of +.br explicit_bzero () +anticipate that future compilers will recognize calls to +.br explicit_bzero () +and take steps to ensure that all copies of the sensitive data are erased, +including copies in registers or in "scratch" stack areas. +.sh see also +.br bstring (3), +.br memset (3), +.br swab (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" this manpage is copyright (c) 1995 james r. van zandt +.\" and copyright (c) 2006, 2014 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" changed section from 2 to 3, aeb, 950919 +.\" +.th mkfifo 3 2021-08-27 "gnu" "linux programmer's manual" +.sh name +mkfifo, mkfifoat \- make a fifo special file (a named pipe) +.sh synopsis +.nf +.b #include +.b #include +.pp +.bi "int mkfifo(const char *" pathname ", mode_t " mode ); +.pp +.br "#include " "/* definition of at_* constants */" +.b #include +.pp +.bi "int mkfifoat(int " dirfd ", const char *" pathname ", mode_t " mode ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br mkfifoat (): +.nf + since glibc 2.10: + _posix_c_source >= 200809l + before glibc 2.10: + _atfile_source +.fi +.sh description +.br mkfifo () +makes a fifo special file with name \fipathname\fp. +\fimode\fp specifies the fifo's permissions. +it is modified by the +process's \fbumask\fp in the usual way: the permissions of the created +file are \fb(\fp\fimode\fp\fb & \(tiumask)\fp. +.pp +a fifo special file is similar to a pipe, except that it is created +in a different way. +instead of being an anonymous communications +channel, a fifo special file is entered into the filesystem by +calling +.br mkfifo (). +.pp +once you have created a fifo special file in this way, any process can +open it for reading or writing, in the same way as an ordinary file. +however, it has to be open at both ends simultaneously before you can +proceed to do any input or output operations on it. +opening a fifo for reading normally blocks until some +other process opens the same fifo for writing, and vice versa. +see +.br fifo (7) +for nonblocking handling of fifo special files. +.ss mkfifoat() +the +.br mkfifoat () +function operates in exactly the same way as +.br mkfifo (), +except for the differences described here. +.pp +if the pathname given in +.i pathname +is relative, then it is interpreted relative to the directory +referred to by the file descriptor +.i dirfd +(rather than relative to the current working directory of +the calling process, as is done by +.br mkfifo () +for a relative pathname). +.pp +if +.i pathname +is relative and +.i dirfd +is the special value +.br at_fdcwd , +then +.i pathname +is interpreted relative to the current working +directory of the calling process (like +.br mkfifo ()). +.pp +if +.i pathname +is absolute, then +.i dirfd +is ignored. +.pp +see +.br openat (2) +for an explanation of the need for +.br mkfifoat (). +.sh return value +on success +.br mkfifo () +and +.br mkfifoat () +return 0. +on error, \-1 is returned and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eacces +one of the directories in \fipathname\fp did not allow search +(execute) permission. +.tp +.b ebadf +.rb ( mkfifoat ()) +.i pathname +is relative but +.i dirfd +is neither +.b at_fdcwd +nor a valid file descriptor. +.tp +.b edquot +the user's quota of disk blocks or inodes on the filesystem has been +exhausted. +.tp +.b eexist +\fipathname\fp already exists. +this includes the case where +.i pathname +is a symbolic link, dangling or not. +.tp +.b enametoolong +either the total length of \fipathname\fp is greater than +\fbpath_max\fp, or an individual filename component has a length +greater than \fbname_max\fp. +in the gnu system, there is no imposed +limit on overall filename length, but some filesystems may place +limits on the length of a component. +.tp +.b enoent +a directory component in \fipathname\fp does not exist or is a +dangling symbolic link. +.tp +.b enospc +the directory or filesystem has no room for the new file. +.tp +.b enotdir +a component used as a directory in \fipathname\fp is not, in fact, a +directory. +.tp +.b enotdir +.rb ( mkfifoat ()) +.i pathname +is a relative pathname and +.i dirfd +is a file descriptor referring to a file other than a directory. +.tp +.b erofs +\fipathname\fp refers to a read-only filesystem. +.sh versions +.br mkfifoat () +was added to glibc in version 2.4. +it is implemented using +.br mknodat (2), +available on linux since kernel 2.6.16. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br mkfifo (), +.br mkfifoat () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +.br mkfifo (): +posix.1-2001, posix.1-2008. +.pp +.br mkfifoat (): +posix.1-2008. +.sh see also +.br mkfifo (1), +.br close (2), +.br open (2), +.br read (2), +.br stat (2), +.br umask (2), +.br write (2), +.br fifo (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1993 michael haardt (michael@moria.de), +.\" fri apr 2 11:32:09 met dst 1993 +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" modified 1993-07-24 by rik faith (faith@cs.unc.edu) +.\" modified 2003-04-07 by michael kerrisk +.\" +.th tty 4 2019-03-06 "linux" "linux programmer's manual" +.sh name +tty \- controlling terminal +.sh description +the file +.i /dev/tty +is a character file with major number 5 and +minor number 0, usually with mode 0666 and ownership root:tty. +it is a synonym for the controlling terminal of a process, if any. +.pp +in addition to the +.br ioctl (2) +requests supported by the device that +.b tty +refers to, the +.br ioctl (2) +request +.b tiocnotty +is supported. +.ss tiocnotty +detach the calling process from its controlling terminal. +.pp +if the process is the session leader, +then +.b sighup +and +.b sigcont +signals are sent to the foreground process group +and all processes in the current session lose their controlling tty. +.pp +this +.br ioctl (2) +call works only on file descriptors connected +to +.ir /dev/tty . +it is used by daemon processes when they are invoked +by a user at a terminal. +the process attempts to open +.ir /dev/tty . +if the open succeeds, it +detaches itself from the terminal by using +.br tiocnotty , +while if the +open fails, it is obviously not attached to a terminal and does not need +to detach itself. +.sh files +.i /dev/tty +.sh see also +.br chown (1), +.br mknod (1), +.br ioctl (2), +.br ioctl_console (2), +.br ioctl_tty (2), +.br termios (3), +.br ttys (4), +.br vcs (4), +.br pty (7), +.br agetty (8), +.br mingetty (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) michael kerrisk, 2004 +.\" using some material drawn from earlier man pages +.\" written by thomas kuhn, copyright 1996 +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th mlock 2 2021-08-27 "linux" "linux programmer's manual" +.sh name +mlock, mlock2, munlock, mlockall, munlockall \- lock and unlock memory +.sh synopsis +.nf +.b #include +.pp +.bi "int mlock(const void *" addr ", size_t " len ); +.bi "int mlock2(const void *" addr ", size_t " len ", unsigned int " flags ); +.bi "int munlock(const void *" addr ", size_t " len ); +.pp +.bi "int mlockall(int " flags ); +.b int munlockall(void); +.fi +.sh description +.br mlock (), +.br mlock2 (), +and +.br mlockall () +lock part or all of the calling process's virtual address +space into ram, preventing that memory from being paged to the +swap area. +.pp +.br munlock () +and +.br munlockall () +perform the converse operation, +unlocking part or all of the calling process's virtual +address space, so that pages in the specified virtual address range may +once more to be swapped out if required by the kernel memory manager. +.pp +memory locking and unlocking are performed in units of whole pages. +.ss mlock(), mlock2(), and munlock() +.br mlock () +locks pages in the address range starting at +.i addr +and continuing for +.i len +bytes. +all pages that contain a part of the specified address range are +guaranteed to be resident in ram when the call returns successfully; +the pages are guaranteed to stay in ram until later unlocked. +.pp +.br mlock2 () +.\" commit a8ca5d0ecbdde5cc3d7accacbd69968b0c98764e +.\" commit de60f5f10c58d4f34b68622442c0e04180367f3f +.\" commit b0f205c2a3082dd9081f9a94e50658c5fa906ff1 +also locks pages in the specified range starting at +.i addr +and continuing for +.i len +bytes. +however, the state of the pages contained in that range after the call +returns successfully will depend on the value in the +.i flags +argument. +.pp +the +.i flags +argument can be either 0 or the following constant: +.tp +.b mlock_onfault +lock pages that are currently resident and mark the entire range so +that the remaining nonresident pages are locked when they are populated +by a page fault. +.pp +if +.i flags +is 0, +.br mlock2 () +behaves exactly the same as +.br mlock (). +.pp +.br munlock () +unlocks pages in the address range starting at +.i addr +and continuing for +.i len +bytes. +after this call, all pages that contain a part of the specified +memory range can be moved to external swap space again by the kernel. +.ss mlockall() and munlockall() +.br mlockall () +locks all pages mapped into the address space of the +calling process. +this includes the pages of the code, data, and stack +segment, as well as shared libraries, user space kernel data, shared +memory, and memory-mapped files. +all mapped pages are guaranteed +to be resident in ram when the call returns successfully; +the pages are guaranteed to stay in ram until later unlocked. +.pp +the +.i flags +argument is constructed as the bitwise or of one or more of the +following constants: +.tp +.b mcl_current +lock all pages which are currently mapped into the address space of +the process. +.tp +.b mcl_future +lock all pages which will become mapped into the address space of the +process in the future. +these could be, for instance, new pages required +by a growing heap and stack as well as new memory-mapped files or +shared memory regions. +.tp +.br mcl_onfault " (since linux 4.4)" +used together with +.br mcl_current , +.br mcl_future , +or both. +mark all current (with +.br mcl_current ) +or future (with +.br mcl_future ) +mappings to lock pages when they are faulted in. +when used with +.br mcl_current , +all present pages are locked, but +.br mlockall () +will not fault in non-present pages. +when used with +.br mcl_future , +all future mappings will be marked to lock pages when they are faulted +in, but they will not be populated by the lock when the mapping is +created. +.b mcl_onfault +must be used with either +.b mcl_current +or +.b mcl_future +or both. +.pp +if +.b mcl_future +has been specified, then a later system call (e.g., +.br mmap (2), +.br sbrk (2), +.br malloc (3)), +may fail if it would cause the number of locked bytes to exceed +the permitted maximum (see below). +in the same circumstances, stack growth may likewise fail: +the kernel will deny stack expansion and deliver a +.b sigsegv +signal to the process. +.pp +.br munlockall () +unlocks all pages mapped into the address space of the +calling process. +.sh return value +on success, these system calls return 0. +on error, \-1 is returned, +.i errno +is set to indicate the error, +and no changes are made to any locks in the +address space of the process. +.sh errors +.\"svr4 documents an additional eagain error code. +.tp +.b eagain +.rb ( mlock (), +.br mlock2 (), +and +.br munlock ()) +some or all of the specified address range could not be locked. +.tp +.b einval +.rb ( mlock (), +.br mlock2 (), +and +.br munlock ()) +the result of the addition +.ir addr + len +was less than +.ir addr +(e.g., the addition may have resulted in an overflow). +.tp +.b einval +.rb ( mlock2 ()) +unknown \fiflags\fp were specified. +.tp +.b einval +.rb ( mlockall ()) +unknown \fiflags\fp were specified or +.b mcl_onfault +was specified without either +.b mcl_future +or +.br mcl_current . +.tp +.b einval +(not on linux) +.i addr +was not a multiple of the page size. +.tp +.b enomem +.rb ( mlock (), +.br mlock2 (), +and +.br munlock ()) +some of the specified address range does not correspond to mapped +pages in the address space of the process. +.tp +.b enomem +.rb ( mlock (), +.br mlock2 (), +and +.br munlock ()) +locking or unlocking a region would result in the total number of +mappings with distinct attributes (e.g., locked versus unlocked) +exceeding the allowed maximum. +.\" i.e., the number of vmas would exceed the 64kb maximum +(for example, unlocking a range in the middle of a currently locked +mapping would result in three mappings: +two locked mappings at each end and an unlocked mapping in the middle.) +.tp +.b enomem +(linux 2.6.9 and later) the caller had a nonzero +.b rlimit_memlock +soft resource limit, but tried to lock more memory than the limit +permitted. +this limit is not enforced if the process is privileged +.rb ( cap_ipc_lock ). +.tp +.b enomem +(linux 2.4 and earlier) the calling process tried to lock more than +half of ram. +.\" in the case of mlock(), this check is somewhat buggy: it doesn't +.\" take into account whether the to-be-locked range overlaps with +.\" already locked pages. thus, suppose we allocate +.\" (num_physpages / 4 + 1) of memory, and lock those pages once using +.\" mlock(), and then lock the *same* page range a second time. +.\" in the case, the second mlock() call will fail, since the check +.\" calculates that the process is trying to lock (num_physpages / 2 + 2) +.\" pages, which of course is not true. (mtk, nov 04, kernel 2.4.28) +.tp +.b eperm +the caller is not privileged, but needs privilege +.rb ( cap_ipc_lock ) +to perform the requested operation. +.tp +.b eperm +.rb ( munlockall ()) +(linux 2.6.8 and earlier) the caller was not privileged +.rb ( cap_ipc_lock ). +.sh versions +.br mlock2 () +is available since linux 4.4; +glibc support was added in version 2.27. +.sh conforming to +.br mlock (), +.br munlock (), +.br mlockall (), +and +.br munlockall (): +posix.1-2001, posix.1-2008, svr4. +.pp +.br mlock2 () +is linux specific. +.pp +on posix systems on which +.br mlock () +and +.br munlock () +are available, +.b _posix_memlock_range +is defined in \fi\fp and the number of bytes in a page +can be determined from the constant +.b pagesize +(if defined) in \fi\fp or by calling +.ir sysconf(_sc_pagesize) . +.pp +on posix systems on which +.br mlockall () +and +.br munlockall () +are available, +.b _posix_memlock +is defined in \fi\fp to a value greater than 0. +(see also +.br sysconf (3).) +.\" posix.1-2001: it shall be defined to -1 or 0 or 200112l. +.\" -1: unavailable, 0: ask using sysconf(). +.\" glibc defines it to 1. +.sh notes +memory locking has two main applications: real-time algorithms and +high-security data processing. +real-time applications require +deterministic timing, and, like scheduling, paging is one major cause +of unexpected program execution delays. +real-time applications will +usually also switch to a real-time scheduler with +.br sched_setscheduler (2). +cryptographic security software often handles critical bytes like +passwords or secret keys as data structures. +as a result of paging, +these secrets could be transferred onto a persistent swap store medium, +where they might be accessible to the enemy long after the security +software has erased the secrets in ram and terminated. +(but be aware that the suspend mode on laptops and some desktop +computers will save a copy of the system's ram to disk, regardless +of memory locks.) +.pp +real-time processes that are using +.br mlockall () +to prevent delays on page faults should reserve enough +locked stack pages before entering the time-critical section, +so that no page fault can be caused by function calls. +this can be achieved by calling a function that allocates a +sufficiently large automatic variable (an array) and writes to the +memory occupied by this array in order to touch these stack pages. +this way, enough pages will be mapped for the stack and can be +locked into ram. +the dummy writes ensure that not even copy-on-write +page faults can occur in the critical section. +.pp +memory locks are not inherited by a child created via +.br fork (2) +and are automatically removed (unlocked) during an +.br execve (2) +or when the process terminates. +the +.br mlockall () +.b mcl_future +and +.b mcl_future | mcl_onfault +settings are not inherited by a child created via +.br fork (2) +and are cleared during an +.br execve (2). +.pp +note that +.br fork (2) +will prepare the address space for a copy-on-write operation. +the consequence is that any write access that follows will cause +a page fault that in turn may cause high latencies for a real-time process. +therefore, it is crucial not to invoke +.br fork (2) +after an +.br mlockall () +or +.br mlock () +operation\(emnot even from a thread which runs at a low priority within +a process which also has a thread running at elevated priority. +.pp +the memory lock on an address range is automatically removed +if the address range is unmapped via +.br munmap (2). +.pp +memory locks do not stack, that is, pages which have been locked several times +by calls to +.br mlock (), +.br mlock2 (), +or +.br mlockall () +will be unlocked by a single call to +.br munlock () +for the corresponding range or by +.br munlockall (). +pages which are mapped to several locations or by several processes stay +locked into ram as long as they are locked at least at one location or by +at least one process. +.pp +if a call to +.br mlockall () +which uses the +.b mcl_future +flag is followed by another call that does not specify this flag, the +changes made by the +.b mcl_future +call will be lost. +.pp +the +.br mlock2 () +.b mlock_onfault +flag and the +.br mlockall () +.b mcl_onfault +flag allow efficient memory locking for applications that deal with +large mappings where only a (small) portion of pages in the mapping are touched. +in such cases, locking all of the pages in a mapping would incur +a significant penalty for memory locking. +.ss linux notes +under linux, +.br mlock (), +.br mlock2 (), +and +.br munlock () +automatically round +.i addr +down to the nearest page boundary. +however, the posix.1 specification of +.br mlock () +and +.br munlock () +allows an implementation to require that +.i addr +is page aligned, so portable applications should ensure this. +.pp +the +.i vmlck +field of the linux-specific +.i /proc/[pid]/status +file shows how many kilobytes of memory the process with id +.i pid +has locked using +.br mlock (), +.br mlock2 (), +.br mlockall (), +and +.br mmap (2) +.br map_locked . +.ss limits and permissions +in linux 2.6.8 and earlier, +a process must be privileged +.rb ( cap_ipc_lock ) +in order to lock memory and the +.b rlimit_memlock +soft resource limit defines a limit on how much memory the process may lock. +.pp +since linux 2.6.9, no limits are placed on the amount of memory +that a privileged process can lock and the +.b rlimit_memlock +soft resource limit instead defines a limit on how much memory an +unprivileged process may lock. +.sh bugs +in linux 4.8 and earlier, +a bug in the kernel's accounting of locked memory for unprivileged processes +(i.e., without +.br cap_ipc_lock ) +meant that if the region specified by +.i addr +and +.i len +overlapped an existing lock, +then the already locked bytes in the overlapping region were counted twice +when checking against the limit. +such double accounting could incorrectly calculate a "total locked memory" +value for the process that exceeded the +.br rlimit_memlock +limit, with the result that +.br mlock () +and +.br mlock2 () +would fail on requests that should have succeeded. +this bug was fixed +.\" commit 0cf2f6f6dc605e587d2c1120f295934c77e810e8 +in linux 4.9. +.pp +in the 2.4 series linux kernels up to and including 2.4.17, +a bug caused the +.br mlockall () +.b mcl_future +flag to be inherited across a +.br fork (2). +this was rectified in kernel 2.4.18. +.pp +since kernel 2.6.9, if a privileged process calls +.i mlockall(mcl_future) +and later drops privileges (loses the +.b cap_ipc_lock +capability by, for example, +setting its effective uid to a nonzero value), +then subsequent memory allocations (e.g., +.br mmap (2), +.br brk (2)) +will fail if the +.b rlimit_memlock +resource limit is encountered. +.\" see the following lkml thread: +.\" http://marc.theaimsgroup.com/?l=linux-kernel&m=113801392825023&w=2 +.\" "rationale for rlimit_memlock" +.\" 23 jan 2006 +.sh see also +.br mincore (2), +.br mmap (2), +.br setrlimit (2), +.br shmctl (2), +.br sysconf (3), +.br proc (5), +.br capabilities (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/nan.3 + +.so man3/pthread_mutex_consistent.3 + +.so man2/sendfile.2 + +.so man3/fts.3 + +.so man3/xdr.3 + +.\" copyright (c) 2003 andries brouwer (aeb@cwi.nl) and +.\" walter harms (walter.harms@informatik.uni-oldenburg.de) +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under gpl +.\" %%%license_end +.\" +.th getspnam 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +getspnam, getspnam_r, getspent, getspent_r, setspent, endspent, +fgetspent, fgetspent_r, sgetspent, sgetspent_r, putspent, +lckpwdf, ulckpwdf \- get shadow password file entry +.sh synopsis +.nf +/* general shadow password file api */ +.b #include +.pp +.bi "struct spwd *getspnam(const char *" name ); +.b struct spwd *getspent(void); +.pp +.b void setspent(void); +.b void endspent(void); +.pp +.bi "struct spwd *fgetspent(file *" stream ); +.bi "struct spwd *sgetspent(const char *" s ); +.pp +.bi "int putspent(const struct spwd *" p ", file *" stream ); +.pp +.b int lckpwdf(void); +.b int ulckpwdf(void); +.pp +/* gnu extension */ +.b #include +.pp +.bi "int getspent_r(struct spwd *" spbuf , +.bi " char *" buf ", size_t " buflen ", struct spwd **" spbufp ); +.bi "int getspnam_r(const char *" name ", struct spwd *" spbuf , +.bi " char *" buf ", size_t " buflen ", struct spwd **" spbufp ); +.pp +.bi "int fgetspent_r(file *" stream ", struct spwd *" spbuf , +.bi " char *" buf ", size_t " buflen ", struct spwd **" spbufp ); +.bi "int sgetspent_r(const char *" s ", struct spwd *" spbuf , +.bi " char *" buf ", size_t " buflen ", struct spwd **" spbufp ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br getspent_r (), +.br getspnam_r (), +.br fgetspent_r (), +.br sgetspent_r (): +.nf + since glibc 2.19: + _default_source + glibc 2.19 and earlier: + _bsd_source || _svid_source +.fi +.sh description +long ago it was considered safe to have encrypted passwords openly +visible in the password file. +when computers got faster and people +got more security-conscious, this was no longer acceptable. +julianne frances haugh implemented the shadow password suite +that keeps the encrypted passwords in +the shadow password database +(e.g., the local shadow password file +.ir /etc/shadow , +nis, and ldap), +readable only by root. +.pp +the functions described below resemble those for +the traditional password database +(e.g., see +.br getpwnam (3) +and +.br getpwent (3)). +.\" fixme . i've commented out the following for the +.\" moment. the relationship between pam and nsswitch.conf needs +.\" to be clearly documented in one place, which is pointed to by +.\" the pages for the user, group, and shadow password functions. +.\" (jul 2005, mtk) +.\" +.\" this shadow password setup has been superseded by pam +.\" (pluggable authentication modules), and the file +.\" .i /etc/nsswitch.conf +.\" now describes the sources to be used. +.pp +the +.br getspnam () +function returns a pointer to a structure containing +the broken-out fields of the record in the shadow password database +that matches the username +.ir name . +.pp +the +.br getspent () +function returns a pointer to the next entry in the shadow password +database. +the position in the input stream is initialized by +.br setspent (). +when done reading, the program may call +.br endspent () +so that resources can be deallocated. +.\" some systems require a call of setspent() before the first getspent() +.\" glibc does not +.pp +the +.br fgetspent () +function is similar to +.br getspent () +but uses the supplied stream instead of the one implicitly opened by +.br setspent (). +.pp +the +.br sgetspent () +function parses the supplied string +.i s +into a struct +.ir spwd . +.pp +the +.br putspent () +function writes the contents of the supplied struct +.i spwd +.i *p +as a text line in the shadow password file format to +.ir stream . +string entries with value null and numerical entries with value \-1 +are written as an empty string. +.pp +the +.br lckpwdf () +function is intended to protect against multiple simultaneous accesses +of the shadow password database. +it tries to acquire a lock, and returns 0 on success, +or \-1 on failure (lock not obtained within 15 seconds). +the +.br ulckpwdf () +function releases the lock again. +note that there is no protection against direct access of the shadow +password file. +only programs that use +.br lckpwdf () +will notice the lock. +.pp +these were the functions that formed the original shadow api. +they are widely available. +.\" also in libc5 +.\" sun doesn't have sgetspent() +.ss reentrant versions +analogous to the reentrant functions for the password database, glibc +also has reentrant functions for the shadow password database. +the +.br getspnam_r () +function is like +.br getspnam () +but stores the retrieved shadow password structure in the space pointed to by +.ir spbuf . +this shadow password structure contains pointers to strings, and these strings +are stored in the buffer +.i buf +of size +.ir buflen . +a pointer to the result (in case of success) or null (in case no entry +was found or an error occurred) is stored in +.ir *spbufp . +.pp +the functions +.br getspent_r (), +.br fgetspent_r (), +and +.br sgetspent_r () +are similarly analogous to their nonreentrant counterparts. +.pp +some non-glibc systems also have functions with these names, +often with different prototypes. +.\" sun doesn't have sgetspent_r() +.ss structure +the shadow password structure is defined in \fi\fp as follows: +.pp +.in +4n +.ex +struct spwd { + char *sp_namp; /* login name */ + char *sp_pwdp; /* encrypted password */ + long sp_lstchg; /* date of last change + (measured in days since + 1970\-01\-01 00:00:00 +0000 (utc)) */ + long sp_min; /* min # of days between changes */ + long sp_max; /* max # of days between changes */ + long sp_warn; /* # of days before password expires + to warn user to change it */ + long sp_inact; /* # of days after password expires + until account is disabled */ + long sp_expire; /* date when account expires + (measured in days since + 1970\-01\-01 00:00:00 +0000 (utc)) */ + unsigned long sp_flag; /* reserved */ +}; +.ee +.in +.sh return value +the functions that return a pointer return null if no more entries +are available or if an error occurs during processing. +the functions which have \fiint\fp as the return value return 0 for +success and \-1 for failure, with +.i errno +set to indicate the error. +.pp +for the nonreentrant functions, the return value may point to static area, +and may be overwritten by subsequent calls to these functions. +.pp +the reentrant functions return zero on success. +in case of error, an error number is returned. +.sh errors +.tp +.b eacces +the caller does not have permission to access the shadow password file. +.tp +.b erange +supplied buffer is too small. +.sh files +.tp +.i /etc/shadow +local shadow password database file +.tp +.i /etc/.pwd.lock +lock file +.pp +the include file +.i +defines the constant +.b _path_shadow +to the pathname of the shadow password file. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lb lb lbx +l l l. +interface attribute value +t{ +.br getspnam () +t} thread safety t{ +mt-unsafe race:getspnam locale +t} +t{ +.br getspent () +t} thread safety t{ +mt-unsafe race:getspent +race:spentbuf locale +t} +t{ +.br setspent (), +.br endspent (), +.br getspent_r () +t} thread safety t{ +mt-unsafe race:getspent locale +t} +t{ +.br fgetspent () +t} thread safety t{ +mt-unsafe race:fgetspent +t} +t{ +.br sgetspent () +t} thread safety t{ +mt-unsafe race:sgetspent +t} +t{ +.br putspent (), +.br getspnam_r (), +.br sgetspent_r () +t} thread safety t{ +mt-safe locale +t} +t{ +.br lckpwdf (), +.br ulckpwdf (), +.br fgetspent_r () +t} thread safety t{ +mt-safe +t} +.te +.hy +.ad +.sp 1 +in the above table, +.i getspent +in +.i race:getspent +signifies that if any of the functions +.br setspent (), +.br getspent (), +.br getspent_r (), +or +.br endspent () +are used in parallel in different threads of a program, +then data races could occur. +.sh conforming to +the shadow password database and its associated api are +not specified in posix.1. +however, many other systems provide a similar api. +.sh see also +.br getgrnam (3), +.br getpwnam (3), +.br getpwnam_r (3), +.br shadow (5) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/list.3 + +.so man3/hypot.3 + +.so man3/cosh.3 + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" iso/iec 9899:1999 +.\" +.th iswspace 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +iswspace \- test for whitespace wide character +.sh synopsis +.nf +.b #include +.pp +.bi "int iswspace(wint_t " wc ); +.fi +.sh description +the +.br iswspace () +function is the wide-character equivalent of the +.br isspace (3) +function. +it tests whether +.i wc +is a wide character +belonging to the wide-character class "space". +.pp +the wide-character class "space" is disjoint from the wide-character class +"graph" and therefore also disjoint from its subclasses "alnum", "alpha", +"upper", "lower", "digit", "xdigit", "punct". +.\" note: unix98 (susv2/xbd/locale.html) says that "space" and "graph" may +.\" have characters in common, except u+0020. but c99 (iso/iec 9899:1999 +.\" section 7.25.2.1.10) says that "space" and "graph" are disjoint. +.pp +the wide-character class "space" contains the wide-character class "blank". +.pp +the wide-character class "space" always contains at least the space character +and the control +characters \(aq\ef\(aq, \(aq\en\(aq, \(aq\er\(aq, \(aq\et\(aq, \(aq\ev\(aq. +.sh return value +the +.br iswspace () +function returns nonzero if +.i wc +is a wide character +belonging to the wide-character class "space". +otherwise, it returns zero. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br iswspace () +t} thread safety mt-safe locale +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh notes +the behavior of +.br iswspace () +depends on the +.b lc_ctype +category of the +current locale. +.sh see also +.br isspace (3), +.br iswctype (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/sigpending.2 + +.so man3/circleq.3 + +.so man3/updwtmp.3 + +.so man3/fts.3 + +.so man3/setbuf.3 + +.so man3/open_memstream.3 + +.\" copyright (c) 2007 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th bsd_signal 3 2021-03-22 "" "linux programmer's manual" +.sh name +bsd_signal \- signal handling with bsd semantics +.sh synopsis +.nf +.b #include +.pp +.b typedef void (*sighandler_t)(int); +.pp +.bi "sighandler_t bsd_signal(int " signum ", sighandler_t " handler ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br bsd_signal (): +.nf + since glibc 2.26: + _xopen_source >= 500 +.\" || _xopen_source && _xopen_source_extended + && ! (_posix_c_source >= 200809l) + glibc 2.25 and earlier: + _xopen_source +.fi +.sh description +the +.br bsd_signal () +function takes the same arguments, and performs the same task, as +.br signal (2). +.pp +the difference between the two is that +.br bsd_signal () +is guaranteed to provide reliable signal semantics, that is: +a) the disposition of the signal is not reset to the default +when the handler is invoked; +b) delivery of further instances of the signal is blocked while +the signal handler is executing; and +c) if the handler interrupts a blocking system call, +then the system call is automatically restarted. +a portable application cannot rely on +.br signal (2) +to provide these guarantees. +.sh return value +the +.br bsd_signal () +function returns the previous value of the signal handler, or +.b sig_err +on error. +.sh errors +as for +.br signal (2). +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br bsd_signal () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +4.2bsd, posix.1-2001. +posix.1-2008 removes the specification of +.br bsd_signal (), +recommending the use of +.br sigaction (2) +instead. +.sh notes +use of +.br bsd_signal () +should be avoided; use +.br sigaction (2) +instead. +.pp +on modern linux systems, +.br bsd_signal () +and +.br signal (2) +are equivalent. +but on older systems, +.br signal (2) +provided unreliable signal semantics; see +.br signal (2) +for details. +.pp +the use of +.i sighandler_t +is a gnu extension; +this type is defined only if the +.b _gnu_source +feature test macro is defined. +.sh see also +.br sigaction (2), +.br signal (2), +.br sysv_signal (3), +.br signal (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/pow10.3 + +.\" copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de) +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under gpl +.\" %%%license_end +.\" +.th csqrt 3 2021-03-22 "" "linux programmer's manual" +.sh name +csqrt, csqrtf, csqrtl \- complex square root +.sh synopsis +.nf +.b #include +.pp +.bi "double complex csqrt(double complex " z ");" +.bi "float complex csqrtf(float complex " z ");" +.bi "long double complex csqrtl(long double complex " z ");" +.pp +link with \fi\-lm\fp. +.fi +.sh description +these functions calculate the complex square root of +.ir z , +with a branch cut along the negative real axis. +(that means that \ficsqrt(\-1+eps*i)\fp will be close to i while +\ficsqrt(\-1\-eps*i)\fp will be close to \-i, \fiif eps\fp is a small positive +real number.) +.sh versions +these functions first appeared in glibc in version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br csqrt (), +.br csqrtf (), +.br csqrtl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.sh see also +.br cabs (3), +.br cexp (3), +.br complex (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) tom bjorkholm & markus kuhn, 1996 +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" 1996-04-01 tom bjorkholm +.\" first version written +.\" 1996-04-10 markus kuhn +.\" revision +.\" +.th sched_rr_get_interval 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +sched_rr_get_interval \- get the sched_rr interval for the named process +.sh synopsis +.nf +.b #include +.pp +.bi "int sched_rr_get_interval(pid_t " pid ", struct timespec *" tp ); +.fi +.sh description +.br sched_rr_get_interval () +writes into the +.i timespec +structure pointed to by +.i tp +the round-robin time quantum for the process identified by +.ir pid . +the specified process should be running under the +.b sched_rr +scheduling policy. +.pp +the +.i timespec +structure has the following form: +.pp +.in +4n +.ex +struct timespec { + time_t tv_sec; /* seconds */ + long tv_nsec; /* nanoseconds */ +}; +.ee +.in +.pp +if +.i pid +is zero, the time quantum for the calling process is written into +.ir *tp . +.\" fixme . on linux, sched_rr_get_interval() +.\" returns the timeslice for sched_other processes -- this timeslice +.\" is influenced by the nice value. +.\" for sched_fifo processes, this always returns 0. +.\" +.\" the round-robin time quantum value is not alterable under linux +.\" 1.3.81. +.\" +.sh return value +on success, +.br sched_rr_get_interval () +returns 0. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b efault +problem with copying information to user space. +.tp +.b einval +invalid pid. +.tp +.b enosys +the system call is not yet implemented (only on rather old kernels). +.tp +.b esrch +could not find a process with the id +.ir pid . +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +posix systems on which +.br sched_rr_get_interval () +is available define +.b _posix_priority_scheduling +in +.ir . +.ss linux notes +posix does not specify any mechanism for controlling the size of the +round-robin time quantum. +older linux kernels provide a (nonportable) method of doing this. +the quantum can be controlled by adjusting the process's nice value (see +.br setpriority (2)). +assigning a negative (i.e., high) nice value results in a longer quantum; +assigning a positive (i.e., low) nice value results in a shorter quantum. +the default quantum is 0.1 seconds; +the degree to which changing the nice value affects the +quantum has varied somewhat across kernel versions. +this method of adjusting the quantum was removed +.\" commit a4ec24b48ddef1e93f7578be53270f0b95ad666c +starting with linux 2.6.24. +.pp +linux 3.9 added +.\" commit ce0dbbbb30aee6a835511d5be446462388ba9eee +a new mechanism for adjusting (and viewing) the +.br sched_rr +quantum: the +.i /proc/sys/kernel/sched_rr_timeslice_ms +file exposes the quantum as a millisecond value, whose default is 100. +writing 0 to this file resets the quantum to the default value. +.\" .sh bugs +.\" as of linux 1.3.81 +.\" .br sched_rr_get_interval () +.\" returns with error +.\" enosys, because sched_rr has not yet been fully implemented and tested +.\" properly. +.sh see also +.br sched (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2005 robert love +.\" and copyright (c) 2008, michael kerrisk +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" 2005-07-19 robert love - initial version +.\" 2006-02-07 mtk, minor changes +.\" 2008-10-10 mtk: add description of inotify_init1() +.\" +.th inotify_init 2 2020-04-11 "linux" "linux programmer's manual" +.sh name +inotify_init, inotify_init1 \- initialize an inotify instance +.sh synopsis +.nf +.b #include +.pp +.b "int inotify_init(void);" +.bi "int inotify_init1(int " flags ); +.fi +.sh description +for an overview of the inotify api, see +.br inotify (7). +.pp +.br inotify_init () +initializes a new inotify instance and returns a file descriptor associated +with a new inotify event queue. +.pp +if +.i flags +is 0, then +.br inotify_init1 () +is the same as +.br inotify_init (). +the following values can be bitwise ored in +.ir flags +to obtain different behavior: +.tp +.b in_nonblock +set the +.br o_nonblock +file status flag on the open file description (see +.br open (2)) +referred to by the new file descriptor. +using this flag saves extra calls to +.br fcntl (2) +to achieve the same result. +.tp +.b in_cloexec +set the close-on-exec +.rb ( fd_cloexec ) +flag on the new file descriptor. +see the description of the +.b o_cloexec +flag in +.br open (2) +for reasons why this may be useful. +.sh return value +on success, these system calls return a new file descriptor. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b einval +.rb ( inotify_init1 ()) +an invalid value was specified in +.ir flags . +.tp +.b emfile +the user limit on the total number of inotify instances has been reached. +.tp +.b emfile +the per-process limit on the number of open file descriptors has been reached. +.tp +.b enfile +the system-wide limit on the total number of open files has been reached. +.tp +.b enomem +insufficient kernel memory is available. +.sh versions +.br inotify_init () +first appeared in linux 2.6.13; +library support was added to glibc in version 2.4. +.br inotify_init1 () +was added in linux 2.6.27; +library support was added to glibc in version 2.9. +.sh conforming to +these system calls are linux-specific. +.sh see also +.br inotify_add_watch (2), +.br inotify_rm_watch (2), +.br inotify (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man7/system_data_types.7 + +.\" copyright 1993 mitchum dsouza +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified, jmv@lucifer.dorms.spbu.ru, 1999-11-08 +.\" modified, aeb, 2000-04-07 +.\" updated from glibc docs, c. scott ananian, 2001-08-25 +.\" modified, aeb, 2001-08-31 +.\" modified, wharms 2001-11-12, remark on white space and example +.\" +.th strptime 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +strptime \- convert a string representation of time to a time tm structure +.sh synopsis +.nf +.br "#define _xopen_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "char *strptime(const char *restrict " s ", const char *restrict " format , +.bi " struct tm *restrict " tm ); +.fi +.sh description +the +.br strptime () +function is the converse of +.br strftime (3); +it converts the character string pointed to by +.i s +to values which are stored in the +"broken-down time" +structure pointed to by +.ir tm , +using the format specified by +.ir format . +.pp +the broken-down time structure +.i tm +is defined in +.ir +as follows: +.pp +.in +4n +.ex +struct tm { + int tm_sec; /* seconds (0\-60) */ + int tm_min; /* minutes (0\-59) */ + int tm_hour; /* hours (0\-23) */ + int tm_mday; /* day of the month (1\-31) */ + int tm_mon; /* month (0\-11) */ + int tm_year; /* year \- 1900 */ + int tm_wday; /* day of the week (0\-6, sunday = 0) */ + int tm_yday; /* day in the year (0\-365, 1 jan = 0) */ + int tm_isdst; /* daylight saving time */ +}; +.ee +.in +.pp +for more details on the +.i tm +structure, see +.br ctime (3). +.pp +the +.i format +argument +is a character string that consists of field descriptors and text characters, +reminiscent of +.br scanf (3). +each field descriptor consists of a +.b % +character followed by another character that specifies the replacement +for the field descriptor. +all other characters in the +.i format +string must have a matching character in the input string, +except for whitespace, which matches zero or more +whitespace characters in the input string. +there should be white\%space or other alphanumeric characters +between any two field descriptors. +.pp +the +.br strptime () +function processes the input string from left +to right. +each of the three possible input elements (whitespace, +literal, or format) are handled one after the other. +if the input cannot be matched to the format string, the function stops. +the remainder of the format and input strings are not processed. +.pp +the supported input field descriptors are listed below. +in case a text string (such as the name of a day of the week or a month name) +is to be matched, the comparison is case insensitive. +in case a number is to be matched, leading zeros are +permitted but not required. +.tp +.b %% +the +.b % +character. +.tp +.br %a " or " %a +the name of the day of the week according to the current locale, +in abbreviated form or the full name. +.tp +.br %b " or " %b " or " %h +the month name according to the current locale, +in abbreviated form or the full name. +.tp +.b %c +the date and time representation for the current locale. +.tp +.b %c +the century number (0\(en99). +.tp +.br %d " or " %e +the day of month (1\(en31). +.tp +.b %d +equivalent to +.br %m/%d/%y . +(this is the american style date, very confusing +to non-americans, especially since +.b %d/%m/%y +is widely used in europe. +the iso 8601 standard format is +.br %y\-%m\-%d .) +.tp +.b %h +the hour (0\(en23). +.tp +.b %i +the hour on a 12-hour clock (1\(en12). +.tp +.b %j +the day number in the year (1\(en366). +.tp +.b %m +the month number (1\(en12). +.tp +.b %m +the minute (0\(en59). +.tp +.b %n +arbitrary whitespace. +.tp +.b %p +the locale's equivalent of am or pm. +(note: there may be none.) +.tp +.b %r +the 12-hour clock time (using the locale's am or pm). +in the posix locale equivalent to +.br "%i:%m:%s %p" . +if +.i t_fmt_ampm +is empty in the +.b lc_time +part of the current locale, +then the behavior is undefined. +.tp +.b %r +equivalent to +.br %h:%m . +.tp +.b %s +the second (0\(en60; 60 may occur for leap seconds; +earlier also 61 was allowed). +.tp +.b %t +arbitrary whitespace. +.tp +.b %t +equivalent to +.br %h:%m:%s . +.tp +.b %u +the week number with sunday the first day of the week (0\(en53). +the first sunday of january is the first day of week 1. +.tp +.b %w +the ordinal number of the day of the week (0\(en6), with sunday = 0. +.tp +.b %w +the week number with monday the first day of the week (0\(en53). +the first monday of january is the first day of week 1. +.tp +.b %x +the date, using the locale's date format. +.tp +.b %x +the time, using the locale's time format. +.tp +.b %y +the year within century (0\(en99). +when a century is not otherwise specified, values in the range 69\(en99 refer +to years in the twentieth century (1969\(en1999); values in the +range 00\(en68 refer to years in the twenty-first century (2000\(en2068). +.tp +.b %y +the year, including century (for example, 1991). +.pp +some field descriptors can be modified by the e or o modifier characters +to indicate that an alternative format or specification should be used. +if the +alternative format or specification does not exist in the current locale, the +unmodified field descriptor is used. +.pp +the e modifier specifies that the input string may contain +alternative locale-dependent versions of the date and time representation: +.tp +.b %ec +the locale's alternative date and time representation. +.tp +.b %ec +the name of the base year (period) in the locale's alternative representation. +.tp +.b %ex +the locale's alternative date representation. +.tp +.b %ex +the locale's alternative time representation. +.tp +.b %ey +the offset from +.b %ec +(year only) in the locale's alternative representation. +.tp +.b %ey +the full alternative year representation. +.pp +the o modifier specifies that the numerical input may be in an +alternative locale-dependent format: +.tp +.br %od " or " %oe +the day of the month using the locale's alternative numeric symbols; +leading zeros are permitted but not required. +.tp +.b %oh +the hour (24-hour clock) using the locale's alternative numeric symbols. +.tp +.b %oi +the hour (12-hour clock) using the locale's alternative numeric symbols. +.tp +.b %om +the month using the locale's alternative numeric symbols. +.tp +.b %om +the minutes using the locale's alternative numeric symbols. +.tp +.b %os +the seconds using the locale's alternative numeric symbols. +.tp +.b %ou +the week number of the year (sunday as the first day of the week) +using the locale's alternative numeric symbols. +.tp +.b %ow +the ordinal number of the day of the week (sunday=0), + using the locale's alternative numeric symbols. +.tp +.b %ow +the week number of the year (monday as the first day of the week) +using the locale's alternative numeric symbols. +.tp +.b %oy +the year (offset from +.br %c ) +using the locale's alternative numeric symbols. +.sh return value +the return value of the function is a pointer to the first character +not processed in this function call. +in case the input string +contains more characters than required by the format string, the return +value points right after the last consumed input character. +in case the whole input string is consumed, +the return value points to the null byte at the end of the string. +if +.br strptime () +fails to match all +of the format string and therefore an error occurred, the function +returns null. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br strptime () +t} thread safety mt-safe env locale +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, susv2. +.sh notes +in principle, this function does not initialize +.i tm +but +stores only the values specified. +this means that +.i tm +should be initialized before the call. +details differ a bit between different unix systems. +the glibc implementation does not touch those fields which are not +explicitly specified, except that it recomputes the +.i tm_wday +and +.i tm_yday +field if any of the year, month, or day elements changed. +.\" .pp +.\" this function is available since libc 4.6.8. +.\" linux libc4 and libc5 includes define the prototype unconditionally; +.\" glibc2 includes provide a prototype only when +.\" .b _xopen_source +.\" or +.\" .b _gnu_source +.\" are defined. +.\" .pp +.\" before libc 5.4.13 whitespace +.\" (and the \(aqn\(aq and \(aqt\(aq specifications) was not handled, +.\" no \(aqe\(aq and \(aqo\(aq locale modifier characters were accepted, +.\" and the \(aqc\(aq specification was a synonym for the \(aqc\(aq specification. +.pp +the \(aqy\(aq (year in century) specification is taken to specify a year +.\" in the 20th century by libc4 and libc5. +.\" it is taken to be a year +in the range 1950\(en2049 by glibc 2.0. +it is taken to be a year in +1969\(en2068 since glibc 2.1. +.\" in libc4 and libc5 the code for %i is broken (fixed in glibc; +.\" %oi was fixed in glibc 2.2.4). +.ss glibc notes +for reasons of symmetry, glibc tries to support for +.br strptime () +the same format characters as for +.br strftime (3). +(in most cases, the corresponding fields are parsed, but no field in +.i tm +is changed.) +this leads to +.tp +.b %f +equivalent to +.br %y\-%m\-%d , +the iso 8601 date format. +.tp +.b %g +the year corresponding to the iso week number, but without the century +(0\(en99). +.tp +.b %g +the year corresponding to the iso week number. +(for example, 1991.) +.tp +.b %u +the day of the week as a decimal number (1\(en7, where monday = 1). +.tp +.b %v +the iso 8601:1988 week number as a decimal number (1\(en53). +if the week (starting on monday) containing 1 january has four or more days +in the new year, then it is considered week 1. +otherwise, it is the last week +of the previous year, and the next week is week 1. +.tp +.b %z +an rfc-822/iso 8601 standard timezone specification. +.tp +.b %z +the timezone name. +.pp +similarly, because of gnu extensions to +.br strftime (3), +.b %k +is accepted as a synonym for +.br %h , +and +.b %l +should be accepted +as a synonym for +.br %i , +and +.b %p +is accepted as a synonym for +.br %p . +finally +.tp +.b %s +the number of seconds since the epoch, 1970-01-01 00:00:00 +0000 (utc). +leap seconds are not counted unless leap second support is available. +.pp +the glibc implementation does not require whitespace between +two field descriptors. +.sh examples +the following example demonstrates the use of +.br strptime () +and +.br strftime (3). +.pp +.ex +#define _xopen_source +#include +#include +#include +#include + +int +main(void) +{ + struct tm tm; + char buf[255]; + + memset(&tm, 0, sizeof(tm)); + strptime("2001\-11\-12 18:31:01", "%y\-%m\-%d %h:%m:%s", &tm); + strftime(buf, sizeof(buf), "%d %b %y %h:%m", &tm); + puts(buf); + exit(exit_success); +} +.ee +.sh see also +.br time (2), +.br getdate (3), +.br scanf (3), +.br setlocale (3), +.br strftime (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +#!/bin/sh + +log=/tmp/markup_check.$$ +rm -f $log $log.full + +if test $# -eq 0; then + echo 1>&2 "usage: $0 filename-or-dirname ... $#" + exit 1 +fi + +file_list=$(find $* -type f | grep '\.[1-9][a-za-z]*$') + +pagename_pattern='[a-z_a-z][^ ]*' + +( + echo "" + echo "checking for page xref without space before left parenthesis:" + pattern='^\.br *'"$pagename_pattern"'([1-8][^1-9]' + echo " pattern: '$pattern'" + grep "$pattern" $file_list | sed 's/^/ /' | tee -a $log + + echo "" + echo "checking for .ir xrefs that should be .br" + pattern='^\.ir *'"$pagename_pattern"' *([1-8][^1-9]' + echo " pattern: '$pattern'" + grep "$pattern" $file_list | sed 's/^/ /' | tee -a $log + + echo "" + echo "checking for misformatted punctuation in .br xrefs" + pattern='^\.br *'"$pagename_pattern"' *([1-8a-za-z]*) [^ ]' + echo " pattern: '$pattern'" + grep "$pattern" $file_list | sed 's/^/ /' | tee -a $log + + echo "" + echo "checking for .b xrefs that should be .br" + pattern='^\.b '"$pagename_pattern"' *([1-8a-za-z]*)' + echo " pattern: '$pattern'" + grep "$pattern" $file_list | sed 's/^/ /' | tee -a $log +) > $log.full + +if test $(cat $log | wc -l) -gt 0; then + echo "" + echo "markup errors!!!!!" + cat $log.full + exit 1 +fi + +exit 0 + +.\" copyright 1995 jim van zandt +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" corrected prototype and include, aeb, 990927 +.th lsearch 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +lfind, lsearch \- linear search of an array +.sh synopsis +.nf +.b #include +.pp +.bi "void *lfind(const void *" key ", const void *" base ", size_t *" nmemb , +.bi " size_t " size ", int(*" compar ")(const void *, const void *));" +.bi "void *lsearch(const void *" key ", void *" base ", size_t *" nmemb , +.bi " size_t " size ", int(*" compar ")(const void *, const void *));" +.fi +.sh description +.br lfind () +and +.br lsearch () +perform a linear search for +.i key +in the array +.ir base +which has +.i *nmemb +elements of +.i size +bytes each. +the comparison function referenced by +.i compar +is expected to have two arguments which point to the +.i key +object and to an array member, in that order, and which +returns zero if the +.i key +object matches the array member, and +nonzero otherwise. +.pp +if +.br lsearch () +does not find a matching element, then the +.i key +object is inserted at the end of the table, and +.i *nmemb +is +incremented. +in particular, one should know that a matching element +exists, or that more room is available. +.sh return value +.br lfind () +returns a pointer to a matching member of the array, or +null if no match is found. +.br lsearch () +returns a pointer to +a matching member of the array, or to the newly added member if no +match is found. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br lfind (), +.br lsearch () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, svr4, 4.3bsd. +present in libc since libc-4.6.27. +.sh bugs +the naming is unfortunate. +.sh see also +.br bsearch (3), +.br hsearch (3), +.br tsearch (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/log.3 + +.\" copyright (c) 2003 davide libenzi +.\" +.\" %%%license_start(gplv2+_sw_3_para) +.\" this program is free software; you can redistribute it and/or modify +.\" it under the terms of the gnu general public license as published by +.\" the free software foundation; either version 2 of the license, or +.\" (at your option) any later version. +.\" +.\" this program 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" davide libenzi +.\" +.th epoll 7 2021-03-22 "linux" "linux programmer's manual" +.sh name +epoll \- i/o event notification facility +.sh synopsis +.nf +.b #include +.fi +.sh description +the +.b epoll +api performs a similar task to +.br poll (2): +monitoring multiple file descriptors to see if i/o is possible on any of them. +the +.b epoll +api can be used either as an edge-triggered or a level-triggered +interface and scales well to large numbers of watched file descriptors. +.pp +the central concept of the +.b epoll +api is the +.b epoll +.ir instance , +an in-kernel data structure which, from a user-space perspective, +can be considered as a container for two lists: +.ip \(bu 2 +the +.i interest +list (sometimes also called the +.b epoll +set): the set of file descriptors that the process has registered +an interest in monitoring. +.ip \(bu +the +.i ready +list: the set of file descriptors that are "ready" for i/o. +the ready list is a subset of +(or, more precisely, a set of references to) +the file descriptors in the interest list. +the ready list is dynamically populated +by the kernel as a result of i/o activity on those file descriptors. +.pp +the following system calls are provided to +create and manage an +.b epoll +instance: +.ip \(bu 2 +.br epoll_create (2) +creates a new +.b epoll +instance and returns a file descriptor referring to that instance. +(the more recent +.br epoll_create1 (2) +extends the functionality of +.br epoll_create (2).) +.ip \(bu +interest in particular file descriptors is then registered via +.br epoll_ctl (2), +which adds items to the interest list of the +.b epoll +instance. +.ip \(bu +.br epoll_wait (2) +waits for i/o events, +blocking the calling thread if no events are currently available. +(this system call can be thought of as fetching items from +the ready list of the +.b epoll +instance.) +.\" +.ss level-triggered and edge-triggered +the +.b epoll +event distribution interface is able to behave both as edge-triggered +(et) and as level-triggered (lt). +the difference between the two mechanisms +can be described as follows. +suppose that +this scenario happens: +.ip 1. 3 +the file descriptor that represents the read side of a pipe +.ri ( rfd ) +is registered on the +.b epoll +instance. +.ip 2. +a pipe writer writes 2\ kb of data on the write side of the pipe. +.ip 3. +a call to +.br epoll_wait (2) +is done that will return +.i rfd +as a ready file descriptor. +.ip 4. +the pipe reader reads 1\ kb of data from +.ir rfd . +.ip 5. +a call to +.br epoll_wait (2) +is done. +.pp +if the +.i rfd +file descriptor has been added to the +.b epoll +interface using the +.b epollet +(edge-triggered) +flag, the call to +.br epoll_wait (2) +done in step +.b 5 +will probably hang despite the available data still present in the file +input buffer; +meanwhile the remote peer might be expecting a response based on the +data it already sent. +the reason for this is that edge-triggered mode +delivers events only when changes occur on the monitored file descriptor. +so, in step +.b 5 +the caller might end up waiting for some data that is already present inside +the input buffer. +in the above example, an event on +.i rfd +will be generated because of the write done in +.b 2 +and the event is consumed in +.br 3 . +since the read operation done in +.b 4 +does not consume the whole buffer data, the call to +.br epoll_wait (2) +done in step +.b 5 +might block indefinitely. +.pp +an application that employs the +.b epollet +flag should use nonblocking file descriptors to avoid having a blocking +read or write starve a task that is handling multiple file descriptors. +the suggested way to use +.b epoll +as an edge-triggered +.rb ( epollet ) +interface is as follows: +.ip a) 3 +with nonblocking file descriptors; and +.ip b) +by waiting for an event only after +.br read (2) +or +.br write (2) +return +.br eagain . +.pp +by contrast, when used as a level-triggered interface +(the default, when +.b epollet +is not specified), +.b epoll +is simply a faster +.br poll (2), +and can be used wherever the latter is used since it shares the +same semantics. +.pp +since even with edge-triggered +.br epoll , +multiple events can be generated upon receipt of multiple chunks of data, +the caller has the option to specify the +.b epolloneshot +flag, to tell +.b epoll +to disable the associated file descriptor after the receipt of an event with +.br epoll_wait (2). +when the +.b epolloneshot +flag is specified, +it is the caller's responsibility to rearm the file descriptor using +.br epoll_ctl (2) +with +.br epoll_ctl_mod . +.pp +if multiple threads +(or processes, if child processes have inherited the +.b epoll +file descriptor across +.br fork (2)) +are blocked in +.br epoll_wait (2) +waiting on the same epoll file descriptor and a file descriptor +in the interest list that is marked for edge-triggered +.rb ( epollet ) +notification becomes ready, +just one of the threads (or processes) is awoken from +.br epoll_wait (2). +this provides a useful optimization for avoiding "thundering herd" wake-ups +in some scenarios. +.\" +.ss interaction with autosleep +if the system is in +.b autosleep +mode via +.i /sys/power/autosleep +and an event happens which wakes the device from sleep, the device +driver will keep the device awake only until that event is queued. +to keep the device awake until the event has been processed, +it is necessary to use the +.br epoll_ctl (2) +.b epollwakeup +flag. +.pp +when the +.b epollwakeup +flag is set in the +.b events +field for a +.ir "struct epoll_event" , +the system will be kept awake from the moment the event is queued, +through the +.br epoll_wait (2) +call which returns the event until the subsequent +.br epoll_wait (2) +call. +if the event should keep the system awake beyond that time, +then a separate +.i wake_lock +should be taken before the second +.br epoll_wait (2) +call. +.ss /proc interfaces +the following interfaces can be used to limit the amount of +kernel memory consumed by epoll: +.\" following was added in 2.6.28, but them removed in 2.6.29 +.\" .tp +.\" .ir /proc/sys/fs/epoll/max_user_instances " (since linux 2.6.28)" +.\" this specifies an upper limit on the number of epoll instances +.\" that can be created per real user id. +.tp +.ir /proc/sys/fs/epoll/max_user_watches " (since linux 2.6.28)" +this specifies a limit on the total number of +file descriptors that a user can register across +all epoll instances on the system. +the limit is per real user id. +each registered file descriptor costs roughly 90 bytes on a 32-bit kernel, +and roughly 160 bytes on a 64-bit kernel. +currently, +.\" 2.6.29 (in 2.6.28, the default was 1/32 of lowmem) +the default value for +.i max_user_watches +is 1/25 (4%) of the available low memory, +divided by the registration cost in bytes. +.ss example for suggested usage +while the usage of +.b epoll +when employed as a level-triggered interface does have the same +semantics as +.br poll (2), +the edge-triggered usage requires more clarification to avoid stalls +in the application event loop. +in this example, listener is a +nonblocking socket on which +.br listen (2) +has been called. +the function +.i do_use_fd() +uses the new ready file descriptor until +.b eagain +is returned by either +.br read (2) +or +.br write (2). +an event-driven state machine application should, after having received +.br eagain , +record its current state so that at the next call to +.i do_use_fd() +it will continue to +.br read (2) +or +.br write (2) +from where it stopped before. +.pp +.in +4n +.ex +#define max_events 10 +struct epoll_event ev, events[max_events]; +int listen_sock, conn_sock, nfds, epollfd; + +/* code to set up listening socket, \(aqlisten_sock\(aq, + (socket(), bind(), listen()) omitted. */ + +epollfd = epoll_create1(0); +if (epollfd == \-1) { + perror("epoll_create1"); + exit(exit_failure); +} + +ev.events = epollin; +ev.data.fd = listen_sock; +if (epoll_ctl(epollfd, epoll_ctl_add, listen_sock, &ev) == \-1) { + perror("epoll_ctl: listen_sock"); + exit(exit_failure); +} + +for (;;) { + nfds = epoll_wait(epollfd, events, max_events, \-1); + if (nfds == \-1) { + perror("epoll_wait"); + exit(exit_failure); + } + + for (n = 0; n < nfds; ++n) { + if (events[n].data.fd == listen_sock) { + conn_sock = accept(listen_sock, + (struct sockaddr *) &addr, &addrlen); + if (conn_sock == \-1) { + perror("accept"); + exit(exit_failure); + } + setnonblocking(conn_sock); + ev.events = epollin | epollet; + ev.data.fd = conn_sock; + if (epoll_ctl(epollfd, epoll_ctl_add, conn_sock, + &ev) == \-1) { + perror("epoll_ctl: conn_sock"); + exit(exit_failure); + } + } else { + do_use_fd(events[n].data.fd); + } + } +} +.ee +.in +.pp +when used as an edge-triggered interface, for performance reasons, it is +possible to add the file descriptor inside the +.b epoll +interface +.rb ( epoll_ctl_add ) +once by specifying +.rb ( epollin | epollout ). +this allows you to avoid +continuously switching between +.b epollin +and +.b epollout +calling +.br epoll_ctl (2) +with +.br epoll_ctl_mod . +.ss questions and answers +.ip 0. 4 +what is the key used to distinguish the file descriptors registered in an +interest list? +.ip +the key is the combination of the file descriptor number and +the open file description +(also known as an "open file handle", +the kernel's internal representation of an open file). +.ip 1. +what happens if you register the same file descriptor on an +.b epoll +instance twice? +.ip +you will probably get +.br eexist . +however, it is possible to add a duplicate +.rb ( dup (2), +.br dup2 (2), +.br fcntl (2) +.br f_dupfd ) +file descriptor to the same +.b epoll +instance. +.\" but a file descriptor duplicated by fork(2) can't be added to the +.\" set, because the [file *, fd] pair is already in the epoll set. +.\" that is a somewhat ugly inconsistency. on the one hand, a child process +.\" cannot add the duplicate file descriptor to the epoll set. (in every +.\" other case that i can think of, file descriptors duplicated by fork have +.\" similar semantics to file descriptors duplicated by dup() and friends.) on +.\" the other hand, the very fact that the child has a duplicate of the +.\" file descriptor means that even if the parent closes its file descriptor, +.\" then epoll_wait() in the parent will continue to receive notifications for +.\" that file descriptor because of the duplicated file descriptor in the child. +.\" +.\" see http://thread.gmane.org/gmane.linux.kernel/596462/ +.\" "epoll design problems with common fork/exec patterns" +.\" +.\" mtk, feb 2008 +this can be a useful technique for filtering events, +if the duplicate file descriptors are registered with different +.i events +masks. +.ip 2. +can two +.b epoll +instances wait for the same file descriptor? +if so, are events reported to both +.b epoll +file descriptors? +.ip +yes, and events would be reported to both. +however, careful programming may be needed to do this correctly. +.ip 3. +is the +.b epoll +file descriptor itself poll/epoll/selectable? +.ip +yes. +if an +.b epoll +file descriptor has events waiting, then it will +indicate as being readable. +.ip 4. +what happens if one attempts to put an +.b epoll +file descriptor into its own file descriptor set? +.ip +the +.br epoll_ctl (2) +call fails +.rb ( einval ). +however, you can add an +.b epoll +file descriptor inside another +.b epoll +file descriptor set. +.ip 5. +can i send an +.b epoll +file descriptor over a unix domain socket to another process? +.ip +yes, but it does not make sense to do this, since the receiving process +would not have copies of the file descriptors in the interest list. +.ip 6. +will closing a file descriptor cause it to be removed from all +.b epoll +interest lists? +.ip +yes, but be aware of the following point. +a file descriptor is a reference to an open file description (see +.br open (2)). +whenever a file descriptor is duplicated via +.br dup (2), +.br dup2 (2), +.br fcntl (2) +.br f_dupfd , +or +.br fork (2), +a new file descriptor referring to the same open file description is +created. +an open file description continues to exist until all +file descriptors referring to it have been closed. +.ip +a file descriptor is removed from an +interest list only after all the file descriptors referring to the underlying +open file description have been closed. +this means that even after a file descriptor that is part of an +interest list has been closed, +events may be reported for that file descriptor if other file +descriptors referring to the same underlying file description remain open. +to prevent this happening, +the file descriptor must be explicitly removed from the interest list (using +.br epoll_ctl (2) +.br epoll_ctl_del ) +before it is duplicated. +alternatively, +the application must ensure that all file descriptors are closed +(which may be difficult if file descriptors were duplicated +behind the scenes by library functions that used +.br dup (2) +or +.br fork (2)). +.ip 7. +if more than one event occurs between +.br epoll_wait (2) +calls, are they combined or reported separately? +.ip +they will be combined. +.ip 8. +does an operation on a file descriptor affect the +already collected but not yet reported events? +.ip +you can do two operations on an existing file descriptor. +remove would be meaningless for +this case. +modify will reread available i/o. +.ip 9. +do i need to continuously read/write a file descriptor +until +.b eagain +when using the +.b epollet +flag (edge-triggered behavior)? +.ip +receiving an event from +.br epoll_wait (2) +should suggest to you that such +file descriptor is ready for the requested i/o operation. +you must consider it ready until the next (nonblocking) +read/write yields +.br eagain . +when and how you will use the file descriptor is entirely up to you. +.ip +for packet/token-oriented files (e.g., datagram socket, +terminal in canonical mode), +the only way to detect the end of the read/write i/o space +is to continue to read/write until +.br eagain . +.ip +for stream-oriented files (e.g., pipe, fifo, stream socket), the +condition that the read/write i/o space is exhausted can also be detected by +checking the amount of data read from / written to the target file +descriptor. +for example, if you call +.br read (2) +by asking to read a certain amount of data and +.br read (2) +returns a lower number of bytes, you +can be sure of having exhausted the read i/o space for the file +descriptor. +the same is true when writing using +.br write (2). +(avoid this latter technique if you cannot guarantee that +the monitored file descriptor always refers to a stream-oriented file.) +.ss possible pitfalls and ways to avoid them +.tp +.b o starvation (edge-triggered) +.pp +if there is a large amount of i/o space, +it is possible that by trying to drain +it the other files will not get processed causing starvation. +(this problem is not specific to +.br epoll .) +.pp +the solution is to maintain a ready list +and mark the file descriptor as ready +in its associated data structure, thereby allowing the application to +remember which files need to be processed but still round robin amongst +all the ready files. +this also supports ignoring subsequent events you +receive for file descriptors that are already ready. +.tp +.b o if using an event cache... +.pp +if you use an event cache or store all the file descriptors returned from +.br epoll_wait (2), +then make sure to provide a way to mark +its closure dynamically (i.e., caused by +a previous event's processing). +suppose you receive 100 events from +.br epoll_wait (2), +and in event #47 a condition causes event #13 to be closed. +if you remove the structure and +.br close (2) +the file descriptor for event #13, then your +event cache might still say there are events waiting for that +file descriptor causing confusion. +.pp +one solution for this is to call, during the processing of event 47, +.br epoll_ctl ( epoll_ctl_del ) +to delete file descriptor 13 and +.br close (2), +then mark its associated +data structure as removed and link it to a cleanup list. +if you find another +event for file descriptor 13 in your batch processing, +you will discover the file descriptor had been +previously removed and there will be no confusion. +.sh versions +the +.b epoll +api was introduced in linux kernel 2.5.44. +.\" its interface should be finalized in linux kernel 2.5.66. +support was added to glibc in version 2.3.2. +.sh conforming to +the +.b epoll +api is linux-specific. +some other systems provide similar +mechanisms, for example, freebsd has +.ir kqueue , +and solaris has +.ir /dev/poll . +.sh notes +the set of file descriptors that is being monitored via +an epoll file descriptor can be viewed via the entry for +the epoll file descriptor in the process's +.ir /proc/[pid]/fdinfo +directory. +see +.br proc (5) +for further details. +.pp +the +.br kcmp (2) +.b kcmp_epoll_tfd +operation can be used to test whether a file descriptor +is present in an epoll instance. +.sh see also +.br epoll_create (2), +.br epoll_create1 (2), +.br epoll_ctl (2), +.br epoll_wait (2), +.br poll (2), +.br select (2) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/csin.3 + +.so man3/fenv.3 + +.so man3/xdr.3 + +.so man3/ffs.3 + +.\" this manpage is copyright (c) 1992 drew eckhardt; +.\" and copyright (c) 1993 ian jackson +.\" and copyright (c) 2006, 2014 michael kerrisk. +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified 1993-07-24 by rik faith +.\" modified 1996-09-08 by arnt gulbrandsen +.\" modified 1997-01-31 by eric s. raymond +.\" modified 2001-05-17 by aeb +.\" modified 2004-06-23 by michael kerrisk +.\" +.th unlink 2 2021-08-27 "linux" "linux programmer's manual" +.sh name +unlink, unlinkat \- delete a name and possibly the file it refers to +.sh synopsis +.nf +.b #include +.pp +.bi "int unlink(const char *" pathname ); +.pp +.br "#include " "/* definition of " at_* " constants */" +.b #include +.pp +.bi "int unlinkat(int " dirfd ", const char *" pathname ", int " flags ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br unlinkat (): +.nf + since glibc 2.10: + _posix_c_source >= 200809l + before glibc 2.10: + _atfile_source +.fi +.sh description +.br unlink () +deletes a name from the filesystem. +if that name was the +last link to a file and no processes have the file open, the file is +deleted and the space it was using is made available for reuse. +.pp +if the name was the last link to a file but any processes still have +the file open, the file will remain in existence until the last file +descriptor referring to it is closed. +.pp +if the name referred to a symbolic link, the link is removed. +.pp +if the name referred to a socket, fifo, or device, the name for it is +removed but processes which have the object open may continue to use +it. +.ss unlinkat() +the +.br unlinkat () +system call operates in exactly the same way as either +.br unlink () +or +.br rmdir (2) +(depending on whether or not +.i flags +includes the +.b at_removedir +flag) +except for the differences described here. +.pp +if the pathname given in +.i pathname +is relative, then it is interpreted relative to the directory +referred to by the file descriptor +.i dirfd +(rather than relative to the current working directory of +the calling process, as is done by +.br unlink () +and +.br rmdir (2) +for a relative pathname). +.pp +if the pathname given in +.i pathname +is relative and +.i dirfd +is the special value +.br at_fdcwd , +then +.i pathname +is interpreted relative to the current working +directory of the calling process (like +.br unlink () +and +.br rmdir (2)). +.pp +if the pathname given in +.i pathname +is absolute, then +.i dirfd +is ignored. +.pp +.i flags +is a bit mask that can either be specified as 0, or by oring +together flag values that control the operation of +.br unlinkat (). +currently, only one such flag is defined: +.tp +.b at_removedir +by default, +.br unlinkat () +performs the equivalent of +.br unlink () +on +.ir pathname . +if the +.b at_removedir +flag is specified, then +performs the equivalent of +.br rmdir (2) +on +.ir pathname . +.pp +see +.br openat (2) +for an explanation of the need for +.br unlinkat (). +.sh return value +on success, zero is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eacces +write access to the directory containing +.i pathname +is not allowed for the process's effective uid, or one of the +directories in +.i pathname +did not allow search permission. +(see also +.br path_resolution (7).) +.tp +.br ebusy +the file +.i pathname +cannot be unlinked because it is being used by the system +or another process; +for example, it is a mount point +or the nfs client software created it to represent an +active but otherwise nameless inode ("nfs silly renamed"). +.tp +.b efault +.i pathname +points outside your accessible address space. +.tp +.b eio +an i/o error occurred. +.tp +.b eisdir +.i pathname +refers to a directory. +(this is the non-posix value returned by linux since 2.1.132.) +.tp +.b eloop +too many symbolic links were encountered in translating +.ir pathname . +.tp +.b enametoolong +.ir pathname " was too long." +.tp +.b enoent +a component in +.i pathname +does not exist or is a dangling symbolic link, or +.i pathname +is empty. +.tp +.b enomem +insufficient kernel memory was available. +.tp +.b enotdir +a component used as a directory in +.i pathname +is not, in fact, a directory. +.tp +.b eperm +the system does not allow unlinking of directories, +or unlinking of directories requires privileges that the +calling process doesn't have. +(this is the posix prescribed error return; +as noted above, linux returns +.b eisdir +for this case.) +.tp +.br eperm " (linux only)" +the filesystem does not allow unlinking of files. +.tp +.br eperm " or " eacces +the directory containing +.i pathname +has the sticky bit +.rb ( s_isvtx ) +set and the process's effective uid is neither the uid of the file to +be deleted nor that of the directory containing it, and +the process is not privileged (linux: does not have the +.b cap_fowner +capability). +.tp +.b eperm +the file to be unlinked is marked immutable or append-only. +(see +.br ioctl_iflags (2).) +.tp +.b erofs +.i pathname +refers to a file on a read-only filesystem. +.pp +the same errors that occur for +.br unlink () +and +.br rmdir (2) +can also occur for +.br unlinkat (). +the following additional errors can occur for +.br unlinkat (): +.tp +.b ebadf +.i pathname +is relative but +.i dirfd +is neither +.b at_fdcwd +nor a valid file descriptor. +.tp +.b einval +an invalid flag value was specified in +.ir flags . +.tp +.b eisdir +.i pathname +refers to a directory, and +.b at_removedir +was not specified in +.ir flags . +.tp +.b enotdir +.i pathname +is relative and +.i dirfd +is a file descriptor referring to a file other than a directory. +.sh versions +.br unlinkat () +was added to linux in kernel 2.6.16; +library support was added to glibc in version 2.4. +.sh conforming to +.br unlink (): +svr4, 4.3bsd, posix.1-2001, posix.1-2008. +.\" svr4 documents additional error +.\" conditions eintr, emultihop, etxtbsy, enolink. +.pp +.br unlinkat (): +posix.1-2008. +.sh notes +.ss glibc notes +on older kernels where +.br unlinkat () +is unavailable, the glibc wrapper function falls back to the use of +.br unlink () +or +.br rmdir (2). +when +.i pathname +is a relative pathname, +glibc constructs a pathname based on the symbolic link in +.ir /proc/self/fd +that corresponds to the +.ir dirfd +argument. +.sh bugs +infelicities in the protocol underlying nfs can cause the unexpected +disappearance of files which are still being used. +.sh see also +.br rm (1), +.br unlink (1), +.br chmod (2), +.br link (2), +.br mknod (2), +.br open (2), +.br rename (2), +.br rmdir (2), +.br mkfifo (3), +.br remove (3), +.br path_resolution (7), +.br symlink (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" sd.4 +.\" copyright 1992 rickard e. faith (faith@cs.unc.edu) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th sd 4 2017-09-15 "linux" "linux programmer's manual" +.sh name +sd \- driver for scsi disk drives +.sh synopsis +.nf +.br "#include " "/* for hdio_getgeo */" +.br "#include " "/* for blkgetsize and blkrrpart */" +.fi +.sh configuration +the block device name has the following form: +.bi sd lp, +where +.i l +is a letter denoting the physical drive, and +.i p +is a number denoting the partition on that physical drive. +often, the partition number, +.ir p , +will be left off when the device corresponds to the whole drive. +.pp +scsi disks have a major device number of 8, and a minor device number of +the form (16 * +.ir drive_number ") + " partition_number , +where +.i drive_number +is the number of the physical drive in order of detection, and +.i partition_number +is as follows: +.ip +3 +partition 0 is the whole drive +.ip +partitions 1\(en4 are the dos "primary" partitions +.ip +partitions 5\(en8 are the dos "extended" (or "logical") partitions +.pp +for example, +.i /dev/sda +will have major 8, minor 0, and will refer to all of the first scsi drive +in the system; and +.i /dev/sdb3 +will have major 8, minor 19, and will refer to the third dos "primary" +partition on the second scsi drive in the system. +.pp +at this time, only block devices are provided. +raw devices have not yet been implemented. +.sh description +the following +.ir ioctl s +are provided: +.tp +.b hdio_getgeo +returns the bios disk parameters in the following structure: +.pp +.in +4n +.ex +struct hd_geometry { + unsigned char heads; + unsigned char sectors; + unsigned short cylinders; + unsigned long start; +}; +.ee +.in +.ip +a pointer to this structure is passed as the +.br ioctl (2) +parameter. +.ip +the information returned in the parameter is the disk geometry of the drive +.i "as understood by dos!" +this geometry is +.i not +the physical geometry of the drive. +it is used when constructing the +drive's partition table, however, and is needed for convenient operation +of +.br fdisk (1), +.br efdisk (1), +and +.br lilo (1). +if the geometry information is not available, zero will be returned for all +of the parameters. +.tp +.b blkgetsize +returns the device size in sectors. +the +.br ioctl (2) +parameter should be a pointer to a +.ir long . +.tp +.b blkrrpart +forces a reread of the scsi disk partition tables. +no parameter is needed. +.ip +the scsi +.br ioctl (2) +operations are also supported. +if the +.br ioctl (2) +parameter is required, and it is null, then +.br ioctl (2) +fails with the error +.br einval . +.sh files +.tp +.i /dev/sd[a\-h] +the whole device +.tp +.i /dev/sd[a\-h][0\-8] +individual block partitions +.\".sh see also +.\".br scsi (4) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/list.3 + +.so man3/rpc.3 + +.so man3/sin.3 + +.\" copyright (c) 1999 joseph samuel myers. +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th pread 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +pread, pwrite \- read from or write to a file descriptor at a given offset +.sh synopsis +.nf +.b #include +.pp +.bi "ssize_t pread(int " fd ", void *" buf ", size_t " count \ +", off_t " offset ); +.bi "ssize_t pwrite(int " fd ", const void *" buf ", size_t " count \ +", off_t " offset ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br pread (), +.br pwrite (): +.nf + _xopen_source >= 500 + || /* since glibc 2.12: */ _posix_c_source >= 200809l +.fi +.sh description +.br pread () +reads up to +.i count +bytes from file descriptor +.i fd +at offset +.i offset +(from the start of the file) into the buffer starting at +.ir buf . +the file offset is not changed. +.pp +.br pwrite () +writes up to +.i count +bytes from the buffer starting at +.i buf +to the file descriptor +.i fd +at offset +.ir offset . +the file offset is not changed. +.pp +the file referenced by +.i fd +must be capable of seeking. +.sh return value +on success, +.br pread () +returns the number of bytes read +(a return of zero indicates end of file) +and +.br pwrite () +returns the number of bytes written. +.pp +note that it is not an error for a successful call to transfer fewer bytes +than requested (see +.br read (2) +and +.br write (2)). +.pp +on error, \-1 is returned and +.i errno +is set to indicate the error. +.sh errors +.br pread () +can fail and set +.i errno +to any error specified for +.br read (2) +or +.br lseek (2). +.br pwrite () +can fail and set +.i errno +to any error specified for +.br write (2) +or +.br lseek (2). +.sh versions +the +.br pread () +and +.br pwrite () +system calls were added to linux in +version 2.1.60; the entries in the i386 system call table were added +in 2.1.69. +c library support (including emulation using +.br lseek (2) +on older kernels without the system calls) was added in glibc 2.1. +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +the +.br pread () +and +.br pwrite () +system calls are especially useful in multithreaded applications. +they allow multiple threads to perform i/o on the same file descriptor +without being affected by changes to the file offset by other threads. +.\" +.ss c library/kernel differences +on linux, the underlying system calls were renamed +in kernel 2.6: +.br pread () +became +.br pread64 (), +and +.br pwrite () +became +.br pwrite64 (). +the system call numbers remained the same. +the glibc +.br pread () +and +.br pwrite () +wrapper functions transparently deal with the change. +.pp +on some 32-bit architectures, +the calling signature for these system calls differ, +for the reasons described in +.br syscall (2). +.sh bugs +posix requires that opening a file with the +.br o_append +flag should have no effect on the location at which +.br pwrite () +writes data. +however, on linux, if a file is opened with +.\" fixme . https://bugzilla.kernel.org/show_bug.cgi?id=43178 +.br o_append , +.br pwrite () +appends data to the end of the file, regardless of the value of +.ir offset . +.sh see also +.br lseek (2), +.br read (2), +.br readv (2), +.br write (2) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2008 linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th pthread_attr_setinheritsched 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +pthread_attr_setinheritsched, pthread_attr_getinheritsched \- set/get +inherit-scheduler attribute in thread attributes object +.sh synopsis +.nf +.b #include +.pp +.bi "int pthread_attr_setinheritsched(pthread_attr_t *" attr , +.bi " int " inheritsched ); +.bi "int pthread_attr_getinheritsched(const pthread_attr_t *restrict " attr , +.bi " int *restrict " inheritsched ); +.pp +compile and link with \fi\-pthread\fp. +.fi +.sh description +the +.br pthread_attr_setinheritsched () +function sets the inherit-scheduler attribute of the +thread attributes object referred to by +.ir attr +to the value specified in +.ir inheritsched . +the inherit-scheduler attribute determines whether a thread created using +the thread attributes object +.i attr +will inherit its scheduling attributes from the calling thread +or whether it will take them from +.ir attr . +.pp +the following scheduling attributes are affected by the +inherit-scheduler attribute: +scheduling policy +.rb ( pthread_attr_setschedpolicy (3)), +scheduling priority +.rb ( pthread_attr_setschedparam (3)), +and contention scope +.rb ( pthread_attr_setscope (3)). +.pp +the following values may be specified in +.ir inheritsched : +.tp +.b pthread_inherit_sched +threads that are created using +.i attr +inherit scheduling attributes from the creating thread; +the scheduling attributes in +.i attr +are ignored. +.tp +.b pthread_explicit_sched +threads that are created using +.i attr +take their scheduling attributes from the values specified +by the attributes object. +.\" fixme document the defaults for scheduler settings +.pp +the default setting of the inherit-scheduler attribute in +a newly initialized thread attributes object is +.br pthread_inherit_sched . +.pp +the +.br pthread_attr_getinheritsched () +returns the inherit-scheduler attribute of the thread attributes object +.ir attr +in the buffer pointed to by +.ir inheritsched . +.sh return value +on success, these functions return 0; +on error, they return a nonzero error number. +.sh errors +.br pthread_attr_setinheritsched () +can fail with the following error: +.tp +.b einval +invalid value in +.ir inheritsched . +.pp +posix.1 also documents an optional +.b enotsup +error ("attempt was made to set the attribute to an unsupported value") for +.br pthread_attr_setinheritsched (). +.\" .sh versions +.\" available since glibc 2.0. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br pthread_attr_setinheritsched (), +.br pthread_attr_getinheritsched () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh bugs +as at glibc 2.8, if a thread attributes object is initialized using +.br pthread_attr_init (3), +then the scheduling policy of the attributes object is set to +.br sched_other +and the scheduling priority is set to 0. +however, if the inherit-scheduler attribute is then set to +.br pthread_explicit_sched , +then a thread created using the attribute object +wrongly inherits its scheduling attributes from the creating thread. +this bug does not occur if either the scheduling policy or +scheduling priority attribute is explicitly set +in the thread attributes object before calling +.br pthread_create (3). +.\" fixme . track status of the following bug: +.\" http://sourceware.org/bugzilla/show_bug.cgi?id=7007 +.sh examples +see +.br pthread_setschedparam (3). +.sh see also +.ad l +.nh +.br pthread_attr_init (3), +.br pthread_attr_setschedparam (3), +.br pthread_attr_setschedpolicy (3), +.br pthread_attr_setscope (3), +.br pthread_create (3), +.br pthread_setschedparam (3), +.br pthread_setschedprio (3), +.br pthreads (7), +.br sched (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2008 linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th pthread_cleanup_push 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +pthread_cleanup_push, pthread_cleanup_pop \- push and pop +thread cancellation clean-up handlers +.sh synopsis +.nf +.b #include +.pp +.bi "void pthread_cleanup_push(void (*" routine ")(void *), void *" arg ); +.bi "void pthread_cleanup_pop(int " execute ); +.pp +compile and link with \fi\-pthread\fp. +.fi +.sh description +these functions manipulate the calling thread's stack of +thread-cancellation clean-up handlers. +a clean-up handler is a function that is automatically executed +when a thread is canceled (or in various other circumstances +described below); +it might, for example, unlock a mutex so that +it becomes available to other threads in the process. +.pp +the +.br pthread_cleanup_push () +function pushes +.i routine +onto the top of the stack of clean-up handlers. +when +.i routine +is later invoked, it will be given +.i arg +as its argument. +.pp +the +.br pthread_cleanup_pop () +function removes the routine at the top of the stack of clean-up handlers, +and optionally executes it if +.i execute +is nonzero. +.pp +a cancellation clean-up handler is popped from the stack +and executed in the following circumstances: +.ip 1. 3 +when a thread is canceled, +all of the stacked clean-up handlers are popped and executed in +the reverse of the order in which they were pushed onto the stack. +.ip 2. +when a thread terminates by calling +.br pthread_exit (3), +all clean-up handlers are executed as described in the preceding point. +(clean-up handlers are +.i not +called if the thread terminates by +performing a +.i return +from the thread start function.) +.ip 3. +when a thread calls +.br pthread_cleanup_pop () +with a nonzero +.i execute +argument, the top-most clean-up handler is popped and executed. +.pp +posix.1 permits +.br pthread_cleanup_push () +and +.br pthread_cleanup_pop () +to be implemented as macros that expand to text +containing \(aq\fb{\fp\(aq and \(aq\fb}\fp\(aq, respectively. +for this reason, the caller must ensure that calls to these +functions are paired within the same function, +and at the same lexical nesting level. +(in other words, a clean-up handler is established only +during the execution of a specified section of code.) +.pp +calling +.br longjmp (3) +.rb ( siglongjmp (3)) +produces undefined results if any call has been made to +.br pthread_cleanup_push () +or +.br pthread_cleanup_pop () +without the matching call of the pair since the jump buffer +was filled by +.br setjmp (3) +.rb ( sigsetjmp (3)). +likewise, calling +.br longjmp (3) +.rb ( siglongjmp (3)) +from inside a clean-up handler produces undefined results +unless the jump buffer was also filled by +.br setjmp (3) +.rb ( sigsetjmp (3)) +inside the handler. +.sh return value +these functions do not return a value. +.sh errors +there are no errors. +.\" sh versions +.\" available since glibc 2.0 +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br pthread_cleanup_push (), +.br pthread_cleanup_pop () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +on linux, the +.br pthread_cleanup_push () +and +.br pthread_cleanup_pop () +functions +.i are +implemented as macros that expand to text +containing \(aq\fb{\fp\(aq and \(aq\fb}\fp\(aq, respectively. +this means that variables declared within the scope of +paired calls to these functions will be visible within only that scope. +.pp +posix.1 +.\" the text was actually added in the 2004 tc2 +says that the effect of using +.ir return , +.ir break , +.ir continue , +or +.ir goto +to prematurely leave a block bracketed +.br pthread_cleanup_push () +and +.br pthread_cleanup_pop () +is undefined. +portable applications should avoid doing this. +.sh examples +the program below provides a simple example of the use of the functions +described in this page. +the program creates a thread that executes a loop bracketed by +.br pthread_cleanup_push () +and +.br pthread_cleanup_pop (). +this loop increments a global variable, +.ir cnt , +once each second. +depending on what command-line arguments are supplied, +the main thread sends the other thread a cancellation request, +or sets a global variable that causes the other thread +to exit its loop and terminate normally (by doing a +.ir return ). +.pp +in the following shell session, +the main thread sends a cancellation request to the other thread: +.pp +.in +4n +.ex +$ \fb./a.out\fp +new thread started +cnt = 0 +cnt = 1 +canceling thread +called clean\-up handler +thread was canceled; cnt = 0 +.ee +.in +.pp +from the above, we see that the thread was canceled, +and that the cancellation clean-up handler was called +and it reset the value of the global variable +.i cnt +to 0. +.pp +in the next run, the main program sets a +global variable that causes other thread to terminate normally: +.pp +.in +4n +.ex +$ \fb./a.out x\fp +new thread started +cnt = 0 +cnt = 1 +thread terminated normally; cnt = 2 +.ee +.in +.pp +from the above, we see that the clean-up handler was not executed (because +.i cleanup_pop_arg +was 0), and therefore the value of +.i cnt +was not reset. +.pp +in the next run, the main program sets a global variable that +causes the other thread to terminate normally, +and supplies a nonzero value for +.ir cleanup_pop_arg : +.pp +.in +4n +.ex +$ \fb./a.out x 1\fp +new thread started +cnt = 0 +cnt = 1 +called clean\-up handler +thread terminated normally; cnt = 0 +.ee +.in +.pp +in the above, we see that although the thread was not canceled, +the clean-up handler was executed, because the argument given to +.br pthread_cleanup_pop () +was nonzero. +.ss program source +\& +.ex +#include +#include +#include +#include +#include +#include + +#define handle_error_en(en, msg) \e + do { errno = en; perror(msg); exit(exit_failure); } while (0) + +static int done = 0; +static int cleanup_pop_arg = 0; +static int cnt = 0; + +static void +cleanup_handler(void *arg) +{ + printf("called clean\-up handler\en"); + cnt = 0; +} + +static void * +thread_start(void *arg) +{ + time_t start, curr; + + printf("new thread started\en"); + + pthread_cleanup_push(cleanup_handler, null); + + curr = start = time(null); + + while (!done) { + pthread_testcancel(); /* a cancellation point */ + if (curr < time(null)) { + curr = time(null); + printf("cnt = %d\en", cnt); /* a cancellation point */ + cnt++; + } + } + + pthread_cleanup_pop(cleanup_pop_arg); + return null; +} + +int +main(int argc, char *argv[]) +{ + pthread_t thr; + int s; + void *res; + + s = pthread_create(&thr, null, thread_start, null); + if (s != 0) + handle_error_en(s, "pthread_create"); + + sleep(2); /* allow new thread to run a while */ + + if (argc > 1) { + if (argc > 2) + cleanup_pop_arg = atoi(argv[2]); + done = 1; + + } else { + printf("canceling thread\en"); + s = pthread_cancel(thr); + if (s != 0) + handle_error_en(s, "pthread_cancel"); + } + + s = pthread_join(thr, &res); + if (s != 0) + handle_error_en(s, "pthread_join"); + + if (res == pthread_canceled) + printf("thread was canceled; cnt = %d\en", cnt); + else + printf("thread terminated normally; cnt = %d\en", cnt); + exit(exit_success); +} +.ee +.sh see also +.br pthread_cancel (3), +.br pthread_cleanup_push_defer_np (3), +.br pthread_setcancelstate (3), +.br pthread_testcancel (3), +.br pthreads (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/strfromd.3 + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" +.th wcsdup 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +wcsdup \- duplicate a wide-character string +.sh synopsis +.nf +.b #include +.pp +.bi "wchar_t *wcsdup(const wchar_t *" s ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br wcsdup (): +.nf + since glibc 2.10: + _posix_c_source >= 200809l + before glibc 2.10: + _gnu_source +.fi +.sh description +the +.br wcsdup () +function is the wide-character equivalent +of the +.br strdup (3) +function. +it allocates and returns a new wide-character string whose initial +contents is a duplicate of the wide-character string pointed to by +.ir s . +.pp +memory for the new wide-character string is +obtained with +.br malloc (3), +and should be freed with +.br free (3). +.sh return value +on success, +.br wcsdup () +returns a pointer to the new wide-character string. +on error, it returns null, with +.i errno +set to indicate the error. +.sh errors +.tp +.b enomem +insufficient memory available to allocate duplicate string. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br wcsdup () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2008. +this function is not specified in posix.1-2001, +and is not widely available on other systems. +.\" present in libc5 and glibc 2.0 and later +.sh see also +.br strdup (3), +.br wcscpy (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man7/system_data_types.7 + +.so man3/malloc.3 + +.so man3/xdr.3 + +.\" from jt@hplb.hpl.hp.com thu dec 19 18:31:49 1996 +.\" from: jean tourrilhes +.\" address: hp labs, filton road, stoke gifford, bristol bs12 6qz, u.k. +.\" jean ii - hplb - '96 +.\" wavelan.c.4 +.\" +.\" provenance of this page is unclear. +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" licensed under the gpl, +.\" after inquiries with jean tourrilhes and bruce janson +.\" (mtk, july 2006) +.\" %%%license_end +.\" +.th wavelan 4 2021-03-22 "linux" "linux programmer's manual" +.sh name +wavelan \- at&t gis wavelan isa device driver +.sh synopsis +.nf +.bi "insmod wavelan_cs.o [io=" b,b.. "] [ irq=" i,i.. "] [name=" n,n.. ] +.fi +.sh description +.i this driver is obsolete: +it was removed from the kernel in version 2.6.35. +.pp +.b wavelan +is the low-level device driver for the ncr / at&t / lucent +.b wavelan isa +and digital (dec) +.b roamabout ds +wireless ethernet adapter. +this driver is available as a module or +might be compiled in the kernel. +this driver supports multiple cards +in both forms (up to 4) and allocates the next available ethernet +device (eth0..eth#) for each card found, unless a device name is +explicitly specified (see below). +this device name will be reported +in the kernel log file with the mac address, nwid, and frequency used +by the card. +.ss parameters +this section applies to the module form (parameters passed on the +.br insmod (8) +command line). +if the driver is included in the kernel, use the +.i ether=irq,io,name +syntax on the kernel command line. +.tp +.b io +specify the list of base addresses where to search for wavelan cards +(setting by dip switch on the card). +if you don't specify any io +address, the driver will scan 0x390 and 0x3e0 addresses, which might +conflict with other hardware... +.tp +.b irq +set the list of irqs that each wavelan card should use (the value is +saved in permanent storage for future use). +.tp +.b name +set the list of names to be used for each wavelan card device (name +used by +.br ifconfig (8)). +.ss wireless extensions +use +.br iwconfig (8) +to manipulate wireless extensions. +.ss nwid (or domain) +set the network id +.ri [ 0 +to +.ir ffff ] +or disable it +.ri [ off ]. +as the nwid is stored in the card permanent storage area, it will be +reused at any further invocation of the driver. +.ss frequency & channels +for the 2.4\ ghz 2.00 hardware, you are able to set the frequency by +specifying one of the 10 defined channels +.ri ( 2.412, +.i 2.422, 2.425, 2.4305, 2.432, 2.442, 2.452, 2.460, 2.462 +or +.ir 2.484 ) +or directly as a numeric value. +the frequency is changed immediately and +permanently. +frequency availability depends on the regulations... +.ss statistics spy +set a list of mac addresses in the driver (up to 8) and get the last +quality of link for each of those (see +.br iwspy (8)). +.ss /proc/net/wireless +.i status +is the status reported by the modem. +.i link quality +reports the quality of the modulation on the air (direct sequence +spread spectrum) [max = 16]. +.i level +and +.i noise +refer to the signal level and noise level [max = 64]. +the +.i crypt discarded packet +and +.i misc discarded packet +counters are not implemented. +.ss private ioctl +you may use +.br iwpriv (8) +to manipulate private ioctls. +.ss quality and level threshold +enables you to define the quality and level threshold used by the +modem (packet below that level are discarded). +.ss histogram +this functionality makes it possible to set a number of +signal level intervals and +to count the number of packets received in each of those defined +intervals. +this distribution might be used to calculate the mean value +and standard deviation of the signal level. +.ss specific notes +this driver fails to detect some +.b non-ncr/at&t/lucent +wavelan cards. +if this happens for you, you must look in the source code on +how to add your card to the detection routine. +.pp +some of the mentioned features are optional. +you may enable to disable +them by changing flags in the driver header and recompile. +.\" .sh author +.\" bruce janson \(em bruce@cs.usyd.edu.au +.\" .br +.\" jean tourrilhes \(em jt@hplb.hpl.hp.com +.\" .br +.\" (and others; see source code for details) +.\" +.\" see also part +.\" +.sh see also +.br wavelan_cs (4), +.br ifconfig (8), +.br insmod (8), +.br iwconfig (8), +.br iwpriv (8), +.br iwspy (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th getrpcent_r 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +getrpcent_r, getrpcbyname_r, getrpcbynumber_r \- get +rpc entry (reentrant) +.sh synopsis +.nf +.b #include +.pp +.bi "int getrpcent_r(struct rpcent *" result_buf ", char *" buf , +.bi " size_t " buflen ", struct rpcent **" result ); +.bi "int getrpcbyname_r(const char *" name , +.bi " struct rpcent *" result_buf ", char *" buf , +.bi " size_t " buflen ", struct rpcent **" result ); +.bi "int getrpcbynumber_r(int " number , +.bi " struct rpcent *" result_buf ", char *" buf , +.bi " size_t " buflen ", struct rpcent **" result ); +.pp +.fi +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br getrpcent_r (), +.br getrpcbyname_r (), +.br getrpcbynumber_r (): +.nf + since glibc 2.19: + _default_source + glibc 2.19 and earlier: + _bsd_source || _svid_source +.fi +.sh description +the +.br getrpcent_r (), +.br getrpcbyname_r (), +and +.br getrpcbynumber_r () +functions are the reentrant equivalents of, respectively, +.br getrpcent (3), +.br getrpcbyname (3), +and +.br getrpcbynumber (3). +they differ in the way that the +.i rpcent +structure is returned, +and in the function calling signature and return value. +this manual page describes just the differences from +the nonreentrant functions. +.pp +instead of returning a pointer to a statically allocated +.i rpcent +structure as the function result, +these functions copy the structure into the location pointed to by +.ir result_buf . +.pp +the +.i buf +array is used to store the string fields pointed to by the returned +.i rpcent +structure. +(the nonreentrant functions allocate these strings in static storage.) +the size of this array is specified in +.ir buflen . +if +.i buf +is too small, the call fails with the error +.br erange , +and the caller must try again with a larger buffer. +(a buffer of length 1024 bytes should be sufficient for most applications.) +.\" i can find no information on the required/recommended buffer size; +.\" the nonreentrant functions use a 1024 byte buffer -- mtk. +.pp +if the function call successfully obtains an rpc record, then +.i *result +is set pointing to +.ir result_buf ; +otherwise, +.i *result +is set to null. +.sh return value +on success, these functions return 0. +on error, they return one of the positive error numbers listed in errors. +.pp +on error, record not found +.rb ( getrpcbyname_r (), +.br getrpcbynumber_r ()), +or end of input +.rb ( getrpcent_r ()) +.i result +is set to null. +.sh errors +.tp +.b enoent +.rb ( getrpcent_r ()) +no more records in database. +.tp +.b erange +.i buf +is too small. +try again with a larger buffer +(and increased +.ir buflen ). +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br getrpcent_r (), +.br getrpcbyname_r (), +.br getrpcbynumber_r () +t} thread safety mt-safe locale +.te +.hy +.ad +.sp 1 +.sh conforming to +these functions are gnu extensions. +functions with similar names exist on some other systems, +though typically with different calling signatures. +.sh see also +.br getrpcent (3), +.br rpc (5) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/shm_open.3 + +.so man3/end.3 + +.\" copyright (c) 1986 the regents of the university of california. +.\" all rights reserved. +.\" +.\" %%%license_start(permissive_misc) +.\" redistribution and use in source and binary forms are permitted +.\" provided that the above copyright notice and this paragraph are +.\" duplicated in all such forms and that any documentation, +.\" advertising materials, and other materials related to such +.\" distribution and use acknowledge that the software was developed +.\" by the university of california, berkeley. the name of the +.\" university may not be used to endorse or promote products derived +.\" from this software without specific prior written permission. +.\" this software is provided ``as is'' and without any express or +.\" implied warranties, including, without limitation, the implied +.\" warranties of merchantability and fitness for a particular purpose. +.\" %%%license_end +.\" +.\" @(#)resolver.5 5.9 (berkeley) 12/14/89 +.\" $id: resolver.5,v 8.6 1999/05/21 00:01:02 vixie exp $ +.\" +.\" added ndots remark by bernhard r. link - debian bug #182886 +.\" +.th resolv.conf 5 2021-03-22 "" "linux programmer's manual" +.uc 4 +.sh name +resolv.conf \- resolver configuration file +.sh synopsis +.nf +.b /etc/resolv.conf +.fi +.sh description +the +.i resolver +is a set of routines in the c library +that provide access to the internet domain name system (dns). +the resolver configuration file contains information that is read +by the resolver routines the first time they are invoked by a process. +the file is designed to be human readable and contains a list of +keywords with values that provide various types of resolver information. +the configuration file is considered a trusted source of dns information; +see the +.b trust-ad +option below for details. +.pp +if this file does not exist, only the name server on the local machine +will be queried, and the search list contains the local domain name +determined from the hostname. +.pp +the different configuration options are: +.tp +\fbnameserver\fp name server ip address +internet address of a name server that the resolver should query, +either an ipv4 address (in dot notation), +or an ipv6 address in colon (and possibly dot) notation as per rfc 2373. +up to +.b maxns +(currently 3, see \fi\fp) name servers may be listed, +one per keyword. +if there are multiple servers, +the resolver library queries them in the order listed. +if no \fbnameserver\fp entries are present, +the default is to use the name server on the local machine. +(the algorithm used is to try a name server, and if the query times out, +try the next, until out of name servers, +then repeat trying all the name servers +until a maximum number of retries are made.) +.tp +\fbsearch\fp search list for host-name lookup. +by default, the search list contains one entry, the local domain name. +it is determined from the local hostname returned by +.br gethostname (2); +the local domain name is taken to be everything after the first +\(aq.\(aq. +finally, if the hostname does not contain a \(aq.\(aq, the +root domain is assumed as the local domain name. +.ip +this may be changed by listing the desired domain search path +following the \fisearch\fp keyword with spaces or tabs separating +the names. +resolver queries having fewer than +.i ndots +dots (default is 1) in them will be attempted using each component +of the search path in turn until a match is found. +for environments with multiple subdomains please read +.bi "options ndots:" n +below to avoid man-in-the-middle attacks and unnecessary +traffic for the root-dns-servers. +.\" when having a resolv.conv with a line +.\" search subdomain.domain.tld domain.tld +.\" and doing a hostlookup, for example by +.\" ping host.anothersubdomain +.\" it sends dns-requests for +.\" host.anothersubdomain. +.\" host.anothersubdomain.subdomain.domain.tld. +.\" host.anothersubdomain.domain.tld. +.\" thus not only causing unnecessary traffic for the root-dns-servers +.\" but broadcasting information to the outside and making man-in-the-middle +.\" attacks possible. +note that this process may be slow and will generate a lot of network +traffic if the servers for the listed domains are not local, +and that queries will time out if no server is available +for one of the domains. +.ip +if there are multiple +.b search +directives, only the search list from the last instance is used. +.ip +in glibc 2.25 and earlier, the search list is limited to six domains +with a total of 256 characters. +since glibc 2.26, +.\" glibc commit 3f853f22c87f0b671c0366eb290919719fa56c0e +the search list is unlimited. +.ip +the +.b domain +directive is an obsolete name for the +.b search +directive that handles one search list entry only. +.tp +\fbsortlist\fp +this option allows addresses returned by +.br gethostbyname (3) +to be sorted. +a sortlist is specified by ip-address-netmask pairs. +the netmask is +optional and defaults to the natural netmask of the net. +the ip address +and optional network pairs are separated by slashes. +up to 10 pairs may +be specified. +here is an example: +.ip +.in +4n +sortlist 130.155.160.0/255.255.240.0 130.155.0.0 +.in +.tp +\fboptions\fp +options allows certain internal resolver variables to be modified. +the syntax is +.rs +.ip +\fboptions\fp \fioption\fp \fi...\fp +.pp +where \fioption\fp is one of the following: +.tp +\fbdebug\fp +.\" since glibc 2.2? +sets +.br res_debug +in +.ir _res.options +(effective only if glibc was built with debug support; see +.br resolver (3)). +.tp +.bi ndots: n +.\" since glibc 2.2 +sets a threshold for the number of dots which +must appear in a name given to +.br res_query (3) +(see +.br resolver (3)) +before an \fiinitial absolute query\fp will be made. +the default for +\fin\fp is 1, meaning that if there are any dots in a name, the name +will be tried first as an absolute name before any \fisearch list\fp +elements are appended to it. +the value for this option is silently capped to 15. +.tp +.bi timeout: n +.\" since glibc 2.2 +sets the amount of time the resolver will wait for a +response from a remote name server before retrying the +query via a different name server. +this may +.br not +be the total time taken by any resolver api call and there is no +guarantee that a single resolver api call maps to a single timeout. +measured in seconds, +the default is +.br res_timeout +(currently 5, see \fi\fp). +the value for this option is silently capped to 30. +.tp +.bi attempts: n +sets the number of times the resolver will send a +query to its name servers before giving up and returning +an error to the calling application. +the default is +.br res_dflretry +(currently 2, see \fi\fp). +the value for this option is silently capped to 5. +.tp +.b rotate +.\" since glibc 2.2 +sets +.br res_rotate +in +.ir _res.options , +which causes round-robin selection of name servers from among those listed. +this has the effect of spreading the query load among all listed servers, +rather than having all clients try the first listed server first every time. +.tp +.b no\-check\-names +.\" since glibc 2.2 +sets +.br res_nocheckname +in +.ir _res.options , +which disables the modern bind checking of incoming hostnames and +mail names for invalid characters such as underscore (_), non-ascii, +or control characters. +.tp +.b inet6 +.\" since glibc 2.2 +sets +.br res_use_inet6 +in +.ir _res.options . +this has the effect of trying an aaaa query before an a query inside the +.br gethostbyname (3) +function, and of mapping ipv4 responses in ipv6 "tunneled form" +if no aaaa records are found but an a record set exists. +since glibc 2.25, +.\" b76e065991ec01299225d9da90a627ebe6c1ac97 +this option is deprecated; applications should use +.br getaddrinfo (3), +rather than +.br gethostbyname (3). +.tp +.br ip6\-bytestring " (since glibc 2.3.4 to 2.24)" +sets +.br res_usebstring +in +.ir _res.options . +this causes reverse ipv6 lookups to be made using the bit-label format +described in rfc\ 2673; +if this option is not set (which is the default), then nibble format is used. +this option was removed in glibc 2.25, +since it relied on a backward-incompatible +dns extension that was never deployed on the internet. +.tp +.br ip6\-dotint / no\-ip6\-dotint " (glibc 2.3.4 to 2.24)" +clear/set +.br res_noip6dotint +in +.ir _res.options . +when this option is clear +.rb ( ip6\-dotint ), +reverse ipv6 lookups are made in the (deprecated) +.i ip6.int +zone; +when this option is set +.rb ( no\-ip6\-dotint ), +reverse ipv6 lookups are made in the +.i ip6.arpa +zone by default. +these options are available in glibc versions up to 2.24, where +.br no\-ip6\-dotint +is the default. +since +.br ip6\-dotint +support long ago ceased to be available on the internet, +these options were removed in glibc 2.25. +.tp +.br edns0 " (since glibc 2.6)" +sets +.br res_use_edns0 +in +.ir _res.options . +this enables support for the dns extensions described in rfc\ 2671. +.tp +.br single\-request " (since glibc 2.10)" +sets +.br res_snglkup +in +.ir _res.options . +by default, glibc performs ipv4 and ipv6 lookups in parallel since +version 2.9. +some appliance dns servers +cannot handle these queries properly and make the requests time out. +this option disables the behavior and makes glibc perform the ipv6 +and ipv4 requests sequentially (at the cost of some slowdown of the +resolving process). +.tp +.br single\-request\-reopen " (since glibc 2.9)" +sets +.br res_snglkupreop +in +.ir _res.options . +the resolver uses the same socket for the a and aaaa requests. +some hardware mistakenly sends back only one reply. +when that happens the client system will sit and wait for the second reply. +turning this option on changes this behavior +so that if two requests from the same port are not handled correctly it will +close the socket and open a new one before sending the second request. +.tp +.br no\-tld\-query " (since glibc 2.14)" +sets +.br res_notldquery +in +.ir _res.options . +this option causes +.br res_nsearch () +to not attempt to resolve an unqualified name +as if it were a top level domain (tld). +this option can cause problems if the site has ``localhost'' as a tld +rather than having localhost on one or more elements of the search list. +this option has no effect if neither res_defnames or res_dnsrch is set. +.tp +.br use\-vc " (since glibc 2.14)" +sets +.br res_usevc +in +.ir _res.options . +this option forces the use of tcp for dns resolutions. +.\" aef16cc8a4c670036d45590877d411a97f01e0cd +.tp +.br no\-reload " (since glibc 2.26)" +sets +.br res_noreload +in +.ir _res.options . +this option disables automatic reloading of a changed configuration file. +.tp +.br trust\-ad " (since glibc 2.31)" +.\" 446997ff1433d33452b81dfa9e626b8dccf101a4 +sets +.br res_trustad +in +.ir _res.options . +this option controls the ad bit behavior of the stub resolver. +if a validating resolver sets the ad bit in a response, +it indicates that the data in the response was verified according +to the dnssec protocol. +in order to rely on the ad bit, the local system has to +trust both the dnssec-validating resolver and the network path to it, +which is why an explicit opt-in is required. +if the +.b trust\-ad +option is active, the stub resolver sets the ad bit in outgoing dns +queries (to enable ad bit support), and preserves the ad bit in responses. +without this option, the ad bit is not set in queries, +and it is always removed from responses before they are returned to the +application. +this means that applications can trust the ad bit in responses if the +.b trust\-ad +option has been set correctly. +.ip +in glibc version 2.30 and earlier, +the ad is not set automatically in queries, +and is passed through unchanged to applications in responses. +.re +.pp +the \fisearch\fp keyword of a system's \firesolv.conf\fp file can be +overridden on a per-process basis by setting the environment variable +.b localdomain +to a space-separated list of search domains. +.pp +the \fioptions\fp keyword of a system's \firesolv.conf\fp file can be +amended on a per-process basis by setting the environment variable +.b res_options +to a space-separated list of resolver options +as explained above under \fboptions\fp. +.pp +the keyword and value must appear on a single line, and the keyword +(e.g., \fbnameserver\fp) must start the line. +the value follows the keyword, separated by white space. +.pp +lines that contain a semicolon (;) or hash character (#) +in the first column are treated as comments. +.sh files +.ir /etc/resolv.conf , +.i +.sh see also +.br gethostbyname (3), +.br resolver (3), +.br host.conf (5), +.br hosts (5), +.br nsswitch.conf (5), +.br hostname (7), +.br named (8) +.pp +name server operations guide for bind +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/logb.3 + +.\" copyright (c) 1993 +.\" the regents of the university of california. all rights reserved. +.\" +.\" %%%license_start(bsd_4_clause_ucb) +.\" redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. all advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" this product includes software developed by the university of +.\" california, berkeley and its contributors. +.\" 4. neither the name of the university nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" this software is provided by the regents and contributors ``as is'' and +.\" any express or implied warranties, including, but not limited to, the +.\" implied warranties of merchantability and fitness for a particular purpose +.\" are disclaimed. in no event shall the regents or contributors be liable +.\" for any direct, indirect, incidental, special, exemplary, or consequential +.\" damages (including, but not limited to, procurement of substitute goods +.\" or services; loss of use, data, or profits; or business interruption) +.\" however caused and on any theory of liability, whether in contract, strict +.\" liability, or tort (including negligence or otherwise) arising in any way +.\" out of the use of this software, even if advised of the possibility of +.\" such damage. +.\" %%%license_end +.\" +.\" from: @(#)err.3 8.1 (berkeley) 6/9/93 +.\" $freebsd: src/lib/libc/gen/err.3,v 1.11.2.5 2001/08/17 15:42:32 ru exp $ +.\" +.\" 2011-09-10, mtk, converted from mdoc to man macros +.\" +.th err 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +err, verr, errx, verrx, warn, vwarn, warnx, vwarnx \- formatted error messages +.sh synopsis +.nf +.b #include +.pp +.bi "noreturn void err(int " eval ", const char *" fmt ", ...);" +.bi "noreturn void errx(int " eval ", const char *" fmt ", ...);" +.pp +.bi "void warn(const char *" fmt ", ...);" +.bi "void warnx(const char *" fmt ", ...);" +.pp +.b #include +.pp +.bi "noreturn void verr(int " eval ", const char *" fmt ", va_list " args ); +.bi "noreturn void verrx(int " eval ", const char *" fmt ", va_list " args ); +.pp +.bi "void vwarn(const char *" fmt ", va_list " args ); +.bi "void vwarnx(const char *" fmt ", va_list " args ); +.fi +.sh description +the +.br err () +and +.br warn () +family of functions display a formatted error message on the standard +error output. +in all cases, the last component of the program name, a colon character, +and a space are output. +if the +.i fmt +argument is not null, the +.br printf (3)-like +formatted error message is output. +the output is terminated by a newline character. +.pp +the +.br err (), +.br verr (), +.br warn (), +and +.br vwarn () +functions append an error message obtained from +.br strerror (3) +based on the global variable +.ir errno , +preceded by another colon and space unless the +.i fmt +argument is +null. +.pp +the +.br errx () +and +.br warnx () +functions do not append an error message. +.pp +the +.br err (), +.br verr (), +.br errx (), +and +.br verrx () +functions do not return, but exit with the value of the argument +.ir eval . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br err (), +.br errx (), +.br warn (), +.br warnx (), +.br verr (), +.br verrx (), +.br vwarn (), +.br vwarnx () +t} thread safety mt-safe locale +.te +.hy +.ad +.sp 1 +.sh conforming to +these functions are nonstandard bsd extensions. +.\" .sh history +.\" the +.\" .br err () +.\" and +.\" .br warn () +.\" functions first appeared in +.\" 4.4bsd. +.sh examples +display the current +.i errno +information string and exit: +.pp +.in +4n +.ex +p = malloc(size); +if (p == null) + err(exit_failure, null); +fd = open(file_name, o_rdonly, 0); +if (fd == \-1) + err(exit_failure, "%s", file_name); +.ee +.in +.pp +display an error message and exit: +.pp +.in +4n +.ex +if (tm.tm_hour < start_time) + errx(exit_failure, "too early, wait until %s", + start_time_string); +.ee +.in +.pp +warn of an error: +.pp +.in +4n +.ex +fd = open(raw_device, o_rdonly, 0); +if (fd == \-1) + warnx("%s: %s: trying the block device", + raw_device, strerror(errno)); +fd = open(block_device, o_rdonly, 0); +if (fd == \-1) + err(exit_failure, "%s", block_device); +.ee +.in +.sh see also +.br error (3), +.br exit (3), +.br perror (3), +.br printf (3), +.br strerror (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man7/iso_8859-11.7 + +.\" copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de) +.\" and copyright 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under gpl +.\" %%%license_end +.\" +.th fmax 3 2021-03-22 "" "linux programmer's manual" +.sh name +fmax, fmaxf, fmaxl \- determine maximum of two floating-point numbers +.sh synopsis +.nf +.b #include +.pp +.bi "double fmax(double " x ", double " y ); +.bi "float fmaxf(float " x ", float " y ); +.bi "long double fmaxl(long double " x ", long double " y ); +.fi +.pp +link with \fi\-lm\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br fmax (), +.br fmaxf (), +.br fmaxl (): +.nf + _isoc99_source || _posix_c_source >= 200112l +.fi +.sh description +these functions return the larger value of +.i x +and +.ir y . +.sh return value +these functions return the maximum of +.i x +and +.ir y . +.pp +if one argument is a nan, the other argument is returned. +.pp +if both arguments are nan, a nan is returned. +.sh errors +no errors occur. +.sh versions +these functions first appeared in glibc in version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br fmax (), +.br fmaxf (), +.br fmaxl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.sh see also +.br fdim (3), +.br fmin (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" iso/iec 9899:1999 +.\" +.th wcstombs 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +wcstombs \- convert a wide-character string to a multibyte string +.sh synopsis +.nf +.b #include +.pp +.bi "size_t wcstombs(char *restrict " dest ", const wchar_t *restrict " src , +.bi " size_t " n ); +.fi +.sh description +if +.i dest +is not null, the +.br wcstombs () +function converts +the wide-character string +.i src +to a multibyte string starting at +.ir dest . +at most +.i n +bytes are written to +.ir dest . +the sequence of characters placed in +.ir dest +begins in the initial shift state. +the conversion can stop for three reasons: +.ip 1. 3 +a wide character has been encountered that can not be represented as a +multibyte sequence (according to the current locale). +in this case, +.i (size_t)\ \-1 +is returned. +.ip 2. +the length limit forces a stop. +in this case, the number of bytes written to +.i dest +is returned, but the shift state at this point is lost. +.ip 3. +the wide-character string has been completely converted, including the +terminating null wide character (l\(aq\e0\(aq). +in this case, the conversion ends in the initial shift state. +the number of bytes written to +.ir dest , +excluding the terminating null byte (\(aq\e0\(aq), is returned. +.pp +the programmer must ensure that there is room for at least +.i n +bytes +at +.ir dest . +.pp +if +.ir dest +is null, +.i n +is ignored, and the conversion proceeds as +above, except that the converted bytes are not written out to memory, +and no length limit exists. +.pp +in order to avoid the case 2 above, the programmer should make sure +.i n +is greater than or equal to +.ir "wcstombs(null,src,0)+1" . +.sh return value +the +.br wcstombs () +function returns the number of bytes that make up the +converted part of a multibyte sequence, +not including the terminating null byte. +if a wide character was encountered which could not be +converted, +.i (size_t)\ \-1 +is returned. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br wcstombs () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh notes +the behavior of +.br wcstombs () +depends on the +.b lc_ctype +category of the +current locale. +.pp +the function +.br wcsrtombs (3) +provides a better interface to the same functionality. +.sh see also +.br mblen (3), +.br mbstowcs (3), +.br mbtowc (3), +.br wcsrtombs (3), +.br wctomb (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" iso/iec 9899:1999 +.\" +.th wcsspn 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +wcsspn \- advance in a wide-character string, skipping +any of a set of wide characters +.sh synopsis +.nf +.b #include +.pp +.bi "size_t wcsspn(const wchar_t *" wcs ", const wchar_t *" accept ); +.fi +.sh description +the +.br wcsspn () +function is the wide-character equivalent of the +.br strspn (3) +function. +it determines the length of the longest initial segment of +.i wcs +which consists entirely of wide-characters listed in +.ir accept . +in other +words, it searches for the first occurrence in the wide-character string +.i wcs +of a wide-character not contained in the wide-character string +.ir accept . +.sh return value +the +.br wcsspn () +function returns the number of +wide characters in the longest +initial segment of +.i wcs +which consists entirely of wide-characters listed +in +.ir accept . +in other words, it returns the position of the first +occurrence in the wide-character string +.i wcs +of a wide-character not +contained in the wide-character string +.ir accept , +or +.i wcslen(wcs) +if there is none. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br wcsspn () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh see also +.br strspn (3), +.br wcscspn (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" page by b.hubert +.\" and copyright (c) 2015, thomas gleixner +.\" and copyright (c) 2015, michael kerrisk +.\" +.\" %%%license_start(freely_redistributable) +.\" may be freely modified and distributed +.\" %%%license_end +.\" +.\" niki a. rahimi (ltc security development, narahimi@us.ibm.com) +.\" added errors section. +.\" +.\" modified 2004-06-17 mtk +.\" modified 2004-10-07 aeb, added futex_requeue, futex_cmp_requeue +.\" +.\" fixme still to integrate are some points from torvald riegel's mail of +.\" 2015-01-23: +.\" http://thread.gmane.org/gmane.linux.kernel/1703405/focus=7977 +.\" +.\" fixme do we need to add some text regarding torvald riegel's 2015-01-24 mail +.\" http://thread.gmane.org/gmane.linux.kernel/1703405/focus=1873242 +.\" +.th futex 2 2021-08-27 "linux" "linux programmer's manual" +.sh name +futex \- fast user-space locking +.sh synopsis +.nf +.pp +.br "#include " " /* definition of " futex_* " constants */" +.br "#include " " /* definition of " sys_* " constants */" +.b #include +.pp +.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 ); +.fi +.pp +.ir note : +glibc provides no wrapper for +.br futex (), +necessitating the use of +.br syscall (2). +.sh description +the +.br futex () +system call provides a method for waiting until a certain condition becomes +true. +it is typically used as a blocking construct in the context of +shared-memory synchronization. +when using futexes, the majority of +the synchronization operations are performed in user space. +a user-space program employs the +.br futex () +system call only when it is likely that the program has to block for +a longer time until the condition becomes true. +other +.br futex () +operations can be used to wake any processes or threads waiting +for a particular condition. +.pp +a futex is a 32-bit value\(emreferred to below as a +.ir "futex word" \(emwhose +address is supplied to the +.br futex () +system call. +(futexes are 32 bits in size on all platforms, including 64-bit systems.) +all futex operations are governed by this value. +in order to share a futex between processes, +the futex is placed in a region of shared memory, +created using (for example) +.br mmap (2) +or +.br shmat (2). +(thus, the futex word may have different +virtual addresses in different processes, +but these addresses all refer to the same location in physical memory.) +in a multithreaded program, it is sufficient to place the futex word +in a global variable shared by all threads. +.pp +when executing a futex operation that requests to block a thread, +the kernel will block only if the futex word has the value that the +calling thread supplied (as one of the arguments of the +.br futex () +call) as the expected value of the futex word. +the loading of the futex word's value, +the comparison of that value with the expected value, +and the actual blocking will happen atomically and will be totally ordered +with respect to concurrent operations performed by other threads +on the same futex word. +.\" notes from darren hart (dec 2015): +.\" totally ordered with respect futex operations refers to semantics +.\" of the acquire/release operations and how they impact ordering of +.\" memory reads and writes. the kernel futex operations are protected +.\" by spinlocks, which ensure that all operations are serialized +.\" with respect to one another. +.\" +.\" this is a lot to attempt to define in this document. perhaps a +.\" reference to linux/documentation/memory-barriers.txt as a footnote +.\" would be sufficient? or perhaps for this manual, "serialized" would +.\" be sufficient, with a footnote regarding "totally ordered" and a +.\" pointer to the memory-barrier documentation? +thus, the futex word is used to connect the synchronization in user space +with the implementation of blocking by the kernel. +analogously to an atomic +compare-and-exchange operation that potentially changes shared memory, +blocking via a futex is an atomic compare-and-block operation. +.\" fixme(torvald riegel): +.\" eventually we want to have some text in notes to satisfy +.\" the reference in the following sentence +.\" see notes for a detailed specification of +.\" the synchronization semantics. +.pp +one use of futexes is for implementing locks. +the state of the lock (i.e., acquired or not acquired) +can be represented as an atomically accessed flag in shared memory. +in the uncontended case, +a thread can access or modify the lock state with atomic instructions, +for example atomically changing it from not acquired to acquired +using an atomic compare-and-exchange instruction. +(such instructions are performed entirely in user mode, +and the kernel maintains no information about the lock state.) +on the other hand, a thread may be unable to acquire a lock because +it is already acquired by another thread. +it then may pass the lock's flag as a futex word and the value +representing the acquired state as the expected value to a +.br futex () +wait operation. +this +.br futex () +operation will block if and only if the lock is still acquired +(i.e., the value in the futex word still matches the "acquired state"). +when releasing the lock, a thread has to first reset the +lock state to not acquired and then execute a futex +operation that wakes threads blocked on the lock flag used as a futex word +(this can be further optimized to avoid unnecessary wake-ups). +see +.br futex (7) +for more detail on how to use futexes. +.pp +besides the basic wait and wake-up futex functionality, there are further +futex operations aimed at supporting more complex use cases. +.pp +note that +no explicit initialization or destruction is necessary to use futexes; +the kernel maintains a futex +(i.e., the kernel-internal implementation artifact) +only while operations such as +.br futex_wait , +described below, are being performed on a particular futex word. +.\" +.ss arguments +the +.i uaddr +argument points to the futex word. +on all platforms, futexes are four-byte +integers that must be aligned on a four-byte boundary. +the operation to perform on the futex is specified in the +.i futex_op +argument; +.ir val +is a value whose meaning and purpose depends on +.ir futex_op . +.pp +the remaining arguments +.ri ( timeout , +.ir uaddr2 , +and +.ir val3 ) +are required only for certain of the futex operations described below. +where one of these arguments is not required, it is ignored. +.pp +for several blocking operations, the +.i timeout +argument is a pointer to a +.ir timespec +structure that specifies a timeout for the operation. +however, notwithstanding the prototype shown above, for some operations, +the least significant four bytes of this argument are instead +used as an integer whose meaning is determined by the operation. +for these operations, the kernel casts the +.i timeout +value first to +.ir "unsigned long", +then to +.ir uint32_t , +and in the remainder of this page, this argument is referred to as +.i val2 +when interpreted in this fashion. +.pp +where it is required, the +.ir uaddr2 +argument is a pointer to a second futex word that is employed +by the operation. +.pp +the interpretation of the final integer argument, +.ir val3 , +depends on the operation. +.\" +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.\" +.ss futex operations +the +.i futex_op +argument consists of two parts: +a command that specifies the operation to be performed, +bitwise ored with zero or more options that +modify the behaviour of the operation. +the options that may be included in +.i futex_op +are as follows: +.tp +.br futex_private_flag " (since linux 2.6.22)" +.\" commit 34f01cc1f512fa783302982776895c73714ebbc2 +this option bit can be employed with all futex operations. +it tells the kernel that the futex is process-private and not shared +with another process (i.e., it is being used for synchronization +only between threads of the same process). +this allows the kernel to make some additional performance optimizations. +.\" i.e., it allows the kernel choose the fast path for validating +.\" the user-space address and avoids expensive vma lookups, +.\" taking reference counts on file backing store, and so on. +.ip +as a convenience, +.i +defines a set of constants with the suffix +.b _private +that are equivalents of all of the operations listed below, +.\" except the obsolete futex_fd, for which the "private" flag was +.\" meaningless +but with the +.br futex_private_flag +ored into the constant value. +thus, there are +.br futex_wait_private , +.br futex_wake_private , +and so on. +.tp +.br futex_clock_realtime " (since linux 2.6.28)" +.\" commit 1acdac104668a0834cfa267de9946fac7764d486 +this option bit can be employed only with the +.br futex_wait_bitset , +.br futex_wait_requeue_pi , +(since linux 4.5) +.\" commit 337f13046ff03717a9e99675284a817527440a49 +.br futex_wait , +and +(since linux 5.14) +.\" commit bf22a6976897977b0a3f1aeba6823c959fc4fdae +.b futex_lock_pi2 +operations. +.ip +if this option is set, the kernel measures the +.i timeout +against the +.b clock_realtime +clock. +.ip +if this option is not set, the kernel measures the +.i timeout +against the +.b clock_monotonic +clock. +.pp +the operation specified in +.i futex_op +is one of the following: +.\" +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.\" +.tp +.br futex_wait " (since linux 2.6.0)" +.\" strictly speaking, since some time in 2.5.x +this operation tests that the value at the +futex word pointed to by the address +.i uaddr +still contains the expected value +.ir val , +and if so, then sleeps waiting for a +.b futex_wake +operation on the futex word. +the load of the value of the futex word is an atomic memory +access (i.e., using atomic machine instructions of the respective +architecture). +this load, the comparison with the expected value, and +starting to sleep are performed atomically +.\" fixme: torvald, i think we may need to add some explanation of +.\" "totally ordered" here. +and totally ordered +with respect to other futex operations on the same futex word. +if the thread starts to sleep, +it is considered a waiter on this futex word. +if the futex value does not match +.ir val , +then the call fails immediately with the error +.br eagain . +.ip +the purpose of the comparison with the expected value is to prevent lost +wake-ups. +if another thread changed the value of the futex word after the +calling thread decided to block based on the prior value, +and if the other thread executed a +.br futex_wake +operation (or similar wake-up) after the value change and before this +.br futex_wait +operation, then the calling thread will observe the +value change and will not start to sleep. +.ip +if the +.i timeout +is not null, the structure it points to specifies a +timeout for the wait. +(this interval will be rounded up to the system clock granularity, +and is guaranteed not to expire early.) +the timeout is by default measured according to the +.br clock_monotonic +clock, but, since linux 4.5, the +.br clock_realtime +clock can be selected by specifying +.br futex_clock_realtime +in +.ir futex_op . +if +.i timeout +is null, the call blocks indefinitely. +.ip +.ir note : +for +.br futex_wait , +.ir timeout +is interpreted as a +.ir relative +value. +this differs from other futex operations, where +.i timeout +is interpreted as an absolute value. +to obtain the equivalent of +.br futex_wait +with an absolute timeout, employ +.br futex_wait_bitset +with +.ir val3 +specified as +.br futex_bitset_match_any . +.ip +the arguments +.i uaddr2 +and +.i val3 +are ignored. +.\" fixme . (torvald) i think we should remove this. or maybe adapt to a +.\" different example. +.\" +.\" for +.\" .br futex (7), +.\" this call is executed if decrementing the count gave a negative value +.\" (indicating contention), +.\" and will sleep until another process or thread releases +.\" the futex and executes the +.\" .b futex_wake +.\" operation. +.\" +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.\" +.tp +.br futex_wake " (since linux 2.6.0)" +.\" strictly speaking, since linux 2.5.x +this operation wakes at most +.i val +of the waiters that are waiting (e.g., inside +.br futex_wait ) +on the futex word at the address +.ir uaddr . +most commonly, +.i val +is specified as either 1 (wake up a single waiter) or +.br int_max +(wake up all waiters). +no guarantee is provided about which waiters are awoken +(e.g., a waiter with a higher scheduling priority is not guaranteed +to be awoken in preference to a waiter with a lower priority). +.ip +the arguments +.ir timeout , +.ir uaddr2 , +and +.i val3 +are ignored. +.\" fixme . (torvald) i think we should remove this. or maybe adapt to +.\" a different example. +.\" +.\" for +.\" .br futex (7), +.\" this is executed if incrementing the count showed that +.\" there were waiters, +.\" once the futex value has been set to 1 +.\" (indicating that it is available). +.\" +.\" how does "incrementing the count show that there were waiters"? +.\" +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.\" +.tp +.br futex_fd " (from linux 2.6.0 up to and including linux 2.6.25)" +.\" strictly speaking, from linux 2.5.x to 2.6.25 +this operation creates a file descriptor that is associated with +the futex at +.ir uaddr . +the caller must close the returned file descriptor after use. +when another process or thread performs a +.br futex_wake +on the futex word, the file descriptor indicates as being readable with +.br select (2), +.br poll (2), +and +.br epoll (7) +.ip +the file descriptor can be used to obtain asynchronous notifications: if +.i val +is nonzero, then, when another process or thread executes a +.br futex_wake , +the caller will receive the signal number that was passed in +.ir val . +.ip +the arguments +.ir timeout , +.ir uaddr2 , +and +.i val3 +are ignored. +.ip +because it was inherently racy, +.b futex_fd +has been removed +.\" commit 82af7aca56c67061420d618cc5a30f0fd4106b80 +from linux 2.6.26 onward. +.\" +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.\" +.tp +.br futex_requeue " (since linux 2.6.0)" +this operation performs the same task as +.br futex_cmp_requeue +(see below), except that no check is made using the value in +.ir val3 . +(the argument +.i val3 +is ignored.) +.\" +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.\" +.tp +.br futex_cmp_requeue " (since linux 2.6.7)" +this operation first checks whether the location +.i uaddr +still contains the value +.ir val3 . +if not, the operation fails with the error +.br eagain . +otherwise, the operation wakes up a maximum of +.i val +waiters that are waiting on the futex at +.ir uaddr . +if there are more than +.i val +waiters, then the remaining waiters are removed +from the wait queue of the source futex at +.i uaddr +and added to the wait queue of the target futex at +.ir uaddr2 . +the +.i val2 +argument specifies an upper limit on the number of waiters +that are requeued to the futex at +.ir uaddr2 . +.ip +.\" fixme(torvald) is the following correct? or is just the decision +.\" which threads to wake or requeue part of the atomic operation? +the load from +.i uaddr +is an atomic memory access (i.e., using atomic machine instructions of +the respective architecture). +this load, the comparison with +.ir val3 , +and the requeueing of any waiters are performed atomically and totally +ordered with respect to other operations on the same futex word. +.\" notes from a f2f conversation with thomas gleixner (aug 2015): ### +.\" the operation is serialized with respect to operations on both +.\" source and target futex. no other waiter can enqueue itself +.\" for waiting and no other waiter can dequeue itself because of +.\" a timeout or signal. +.ip +typical values to specify for +.i val +are 0 or 1. +(specifying +.br int_max +is not useful, because it would make the +.br futex_cmp_requeue +operation equivalent to +.br futex_wake .) +the limit value specified via +.i val2 +is typically either 1 or +.br int_max . +(specifying the argument as 0 is not useful, because it would make the +.br futex_cmp_requeue +operation equivalent to +.br futex_wait .) +.ip +the +.b futex_cmp_requeue +operation was added as a replacement for the earlier +.br futex_requeue . +the difference is that the check of the value at +.i uaddr +can be used to ensure that requeueing happens only under certain +conditions, which allows race conditions to be avoided in certain use cases. +.\" but, as rich felker points out, there remain valid use cases for +.\" futex_requeue, for example, when the calling thread is requeuing +.\" the target(s) to a lock that the calling thread owns +.\" from: rich felker +.\" date: wed, 29 oct 2014 22:43:17 -0400 +.\" to: darren hart +.\" cc: libc-alpha@sourceware.org, ... +.\" subject: re: add futex wrapper to glibc? +.ip +both +.br futex_requeue +and +.br futex_cmp_requeue +can be used to avoid "thundering herd" wake-ups that could occur when using +.b futex_wake +in cases where all of the waiters that are woken need to acquire +another futex. +consider the following scenario, +where multiple waiter threads are waiting on b, +a wait queue implemented using a futex: +.ip +.in +4n +.ex +lock(a) +while (!check_value(v)) { + unlock(a); + block_on(b); + lock(a); +}; +unlock(a); +.ee +.in +.ip +if a waker thread used +.br futex_wake , +then all waiters waiting on b would be woken up, +and they would all try to acquire lock a. +however, waking all of the threads in this manner would be pointless because +all except one of the threads would immediately block on lock a again. +by contrast, a requeue operation wakes just one waiter and moves +the other waiters to lock a, +and when the woken waiter unlocks a then the next waiter can proceed. +.\" +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.\" +.tp +.br futex_wake_op " (since linux 2.6.14)" +.\" commit 4732efbeb997189d9f9b04708dc26bf8613ed721 +.\" author: jakub jelinek +.\" date: tue sep 6 15:16:25 2005 -0700 +.\" fixme. (torvald) the glibc condvar implementation is currently being +.\" revised (e.g., to not use an internal lock anymore). +.\" it is probably more future-proof to remove this paragraph. +.\" [torvald, do you have an update here?] +this operation was added to support some user-space use cases +where more than one futex must be handled at the same time. +the most notable example is the implementation of +.br pthread_cond_signal (3), +which requires operations on two futexes, +the one used to implement the mutex and the one used in the implementation +of the wait queue associated with the condition variable. +.br futex_wake_op +allows such cases to be implemented without leading to +high rates of contention and context switching. +.ip +the +.br futex_wake_op +operation is equivalent to executing the following code atomically +and totally ordered with respect to other futex operations on +any of the two supplied futex words: +.ip +.in +4n +.ex +uint32_t oldval = *(uint32_t *) uaddr2; +*(uint32_t *) uaddr2 = oldval \fiop\fp \fioparg\fp; +futex(uaddr, futex_wake, val, 0, 0, 0); +if (oldval \ficmp\fp \ficmparg\fp) + futex(uaddr2, futex_wake, val2, 0, 0, 0); +.ee +.in +.ip +in other words, +.br futex_wake_op +does the following: +.rs +.ip * 3 +saves the original value of the futex word at +.ir uaddr2 +and performs an operation to modify the value of the futex at +.ir uaddr2 ; +this is an atomic read-modify-write memory access (i.e., using atomic +machine instructions of the respective architecture) +.ip * +wakes up a maximum of +.i val +waiters on the futex for the futex word at +.ir uaddr ; +and +.ip * +dependent on the results of a test of the original value of the +futex word at +.ir uaddr2 , +wakes up a maximum of +.i val2 +waiters on the futex for the futex word at +.ir uaddr2 . +.re +.ip +the operation and comparison that are to be performed are encoded +in the bits of the argument +.ir val3 . +pictorially, the encoding is: +.ip +.in +4n +.ex ++---+---+-----------+-----------+ +|op |cmp| oparg | cmparg | ++---+---+-----------+-----------+ + 4 4 12 12 <== # of bits +.ee +.in +.ip +expressed in code, the encoding is: +.ip +.in +4n +.ex +#define futex_op(op, oparg, cmp, cmparg) \e + (((op & 0xf) << 28) | \e + ((cmp & 0xf) << 24) | \e + ((oparg & 0xfff) << 12) | \e + (cmparg & 0xfff)) +.ee +.in +.ip +in the above, +.i op +and +.i cmp +are each one of the codes listed below. +the +.i oparg +and +.i cmparg +components are literal numeric values, except as noted below. +.ip +the +.i op +component has one of the following values: +.ip +.in +4n +.ex +futex_op_set 0 /* uaddr2 = oparg; */ +futex_op_add 1 /* uaddr2 += oparg; */ +futex_op_or 2 /* uaddr2 |= oparg; */ +futex_op_andn 3 /* uaddr2 &= \(tioparg; */ +futex_op_xor 4 /* uaddr2 \(ha= oparg; */ +.ee +.in +.ip +in addition, bitwise oring the following value into +.i op +causes +.ir "(1\ <<\ oparg)" +to be used as the operand: +.ip +.in +4n +.ex +futex_op_arg_shift 8 /* use (1 << oparg) as operand */ +.ee +.in +.ip +the +.i cmp +field is one of the following: +.ip +.in +4n +.ex +futex_op_cmp_eq 0 /* if (oldval == cmparg) wake */ +futex_op_cmp_ne 1 /* if (oldval != cmparg) wake */ +futex_op_cmp_lt 2 /* if (oldval < cmparg) wake */ +futex_op_cmp_le 3 /* if (oldval <= cmparg) wake */ +futex_op_cmp_gt 4 /* if (oldval > cmparg) wake */ +futex_op_cmp_ge 5 /* if (oldval >= cmparg) wake */ +.ee +.in +.ip +the return value of +.br futex_wake_op +is the sum of the number of waiters woken on the futex +.ir uaddr +plus the number of waiters woken on the futex +.ir uaddr2 . +.\" +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.\" +.tp +.br futex_wait_bitset " (since linux 2.6.25)" +.\" commit cd689985cf49f6ff5c8eddc48d98b9d581d9475d +this operation is like +.br futex_wait +except that +.i val3 +is used to provide a 32-bit bit mask to the kernel. +this bit mask, in which at least one bit must be set, +is stored in the kernel-internal state of the waiter. +see the description of +.br futex_wake_bitset +for further details. +.ip +if +.i timeout +is not null, the structure it points to specifies +an absolute timeout for the wait operation. +if +.i timeout +is null, the operation can block indefinitely. +.ip +the +.i uaddr2 +argument is ignored. +.\" +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.\" +.tp +.br futex_wake_bitset " (since linux 2.6.25)" +.\" commit cd689985cf49f6ff5c8eddc48d98b9d581d9475d +this operation is the same as +.br futex_wake +except that the +.i val3 +argument is used to provide a 32-bit bit mask to the kernel. +this bit mask, in which at least one bit must be set, +is used to select which waiters should be woken up. +the selection is done by a bitwise and of the "wake" bit mask +(i.e., the value in +.ir val3 ) +and the bit mask which is stored in the kernel-internal +state of the waiter (the "wait" bit mask that is set using +.br futex_wait_bitset ). +all of the waiters for which the result of the and is nonzero are woken up; +the remaining waiters are left sleeping. +.ip +the effect of +.br futex_wait_bitset +and +.br futex_wake_bitset +is to allow selective wake-ups among multiple waiters that are blocked +on the same futex. +however, note that, depending on the use case, +employing this bit-mask multiplexing feature on a +futex can be less efficient than simply using multiple futexes, +because employing bit-mask multiplexing requires the kernel +to check all waiters on a futex, +including those that are not interested in being woken up +(i.e., they do not have the relevant bit set in their "wait" bit mask). +.\" according to http://locklessinc.com/articles/futex_cheat_sheet/: +.\" +.\" "the original reason for the addition of these extensions +.\" was to improve the performance of pthread read-write locks +.\" in glibc. however, the pthreads library no longer uses the +.\" same locking algorithm, and these extensions are not used +.\" without the bitset parameter being all ones. +.\" +.\" the page goes on to note that the futex_wait_bitset operation +.\" is nevertheless used (with a bit mask of all ones) in order to +.\" obtain the absolute timeout functionality that is useful +.\" for efficiently implementing pthreads apis (which use absolute +.\" timeouts); futex_wait provides only relative timeouts. +.ip +the constant +.br futex_bitset_match_any , +which corresponds to all 32 bits set in the bit mask, can be used as the +.i val3 +argument for +.br futex_wait_bitset +and +.br futex_wake_bitset . +other than differences in the handling of the +.i timeout +argument, the +.br futex_wait +operation is equivalent to +.br futex_wait_bitset +with +.ir val3 +specified as +.br futex_bitset_match_any ; +that is, allow a wake-up by any waker. +the +.br futex_wake +operation is equivalent to +.br futex_wake_bitset +with +.ir val3 +specified as +.br futex_bitset_match_any ; +that is, wake up any waiter(s). +.ip +the +.i uaddr2 +and +.i timeout +arguments are ignored. +.\" +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.\" +.ss priority-inheritance futexes +linux supports priority-inheritance (pi) futexes in order to handle +priority-inversion problems that can be encountered with +normal futex locks. +priority inversion is the problem that occurs when a high-priority +task is blocked waiting to acquire a lock held by a low-priority task, +while tasks at an intermediate priority continuously preempt +the low-priority task from the cpu. +consequently, the low-priority task makes no progress toward +releasing the lock, and the high-priority task remains blocked. +.pp +priority inheritance is a mechanism for dealing with +the priority-inversion problem. +with this mechanism, when a high-priority task becomes blocked +by a lock held by a low-priority task, +the priority of the low-priority task is temporarily raised +to that of the high-priority task, +so that it is not preempted by any intermediate level tasks, +and can thus make progress toward releasing the lock. +to be effective, priority inheritance must be transitive, +meaning that if a high-priority task blocks on a lock +held by a lower-priority task that is itself blocked by a lock +held by another intermediate-priority task +(and so on, for chains of arbitrary length), +then both of those tasks +(or more generally, all of the tasks in a lock chain) +have their priorities raised to be the same as the high-priority task. +.pp +from a user-space perspective, +what makes a futex pi-aware is a policy agreement (described below) +between user space and the kernel about the value of the futex word, +coupled with the use of the pi-futex operations described below. +(unlike the other futex operations described above, +the pi-futex operations are designed +for the implementation of very specific ipc mechanisms.) +.\" +.\" quoting darren hart: +.\" these opcodes paired with the pi futex value policy (described below) +.\" defines a "futex" as pi aware. these were created very specifically +.\" in support of pi pthread_mutexes, so it makes a lot more sense to +.\" talk about a pi aware pthread_mutex, than a pi aware futex, since +.\" there is a lot of policy and scaffolding that has to be built up +.\" around it to use it properly (this is what a pi pthread_mutex is). +.pp +.\" mtk: the following text is drawn from the hart/guniguntala paper +.\" (listed in see also), but i have reworded some pieces +.\" significantly. +.\" +the pi-futex operations described below differ from the other +futex operations in that they impose policy on the use of the value of the +futex word: +.ip * 3 +if the lock is not acquired, the futex word's value shall be 0. +.ip * +if the lock is acquired, the futex word's value shall +be the thread id (tid; +see +.br gettid (2)) +of the owning thread. +.ip * +if the lock is owned and there are threads contending for the lock, +then the +.b futex_waiters +bit shall be set in the futex word's value; in other words, this value is: +.ip + futex_waiters | tid +.ip +(note that is invalid for a pi futex word to have no owner and +.br futex_waiters +set.) +.pp +with this policy in place, +a user-space application can acquire an unacquired +lock or release a lock using atomic instructions executed in user mode +(e.g., a compare-and-swap operation such as +.i cmpxchg +on the x86 architecture). +acquiring a lock simply consists of using compare-and-swap to atomically +set the futex word's value to the caller's tid if its previous value was 0. +releasing a lock requires using compare-and-swap to set the futex word's +value to 0 if the previous value was the expected tid. +.pp +if a futex is already acquired (i.e., has a nonzero value), +waiters must employ the +.b futex_lock_pi +or +.b futex_lock_pi2 +operations to acquire the lock. +if other threads are waiting for the lock, then the +.b futex_waiters +bit is set in the futex value; +in this case, the lock owner must employ the +.b futex_unlock_pi +operation to release the lock. +.pp +in the cases where callers are forced into the kernel +(i.e., required to perform a +.br futex () +call), +they then deal directly with a so-called rt-mutex, +a kernel locking mechanism which implements the required +priority-inheritance semantics. +after the rt-mutex is acquired, the futex value is updated accordingly, +before the calling thread returns to user space. +.pp +it is important to note +.\" tglx (july 2015): +.\" if there are multiple waiters on a pi futex then a wake pi operation +.\" will wake the first waiter and hand over the lock to this waiter. this +.\" includes handing over the rtmutex which represents the futex in the +.\" kernel. the strict requirement is that the futex owner and the rtmutex +.\" owner must be the same, except for the update period which is +.\" serialized by the futex internal locking. that means the kernel must +.\" update the user-space value prior to returning to user space +that the kernel will update the futex word's value prior +to returning to user space. +(this prevents the possibility of the futex word's value ending +up in an invalid state, such as having an owner but the value being 0, +or having waiters but not having the +.b futex_waiters +bit set.) +.pp +if a futex has an associated rt-mutex in the kernel +(i.e., there are blocked waiters) +and the owner of the futex/rt-mutex dies unexpectedly, +then the kernel cleans up the rt-mutex and hands it over to the next waiter. +this in turn requires that the user-space value is updated accordingly. +to indicate that this is required, the kernel sets the +.b futex_owner_died +bit in the futex word along with the thread id of the new owner. +user space can detect this situation via the presence of the +.b futex_owner_died +bit and is then responsible for cleaning up the stale state left over by +the dead owner. +.\" tglx (july 2015): +.\" the futex_owner_died bit can also be set on uncontended futexes, where +.\" the kernel has no state associated. this happens via the robust futex +.\" mechanism. in that case the futex value will be set to +.\" futex_owner_died. the robust futex mechanism is also available for non +.\" pi futexes. +.pp +pi futexes are operated on by specifying one of the values listed below in +.ir futex_op . +note that the pi futex operations must be used as paired operations +and are subject to some additional requirements: +.ip * 3 +.br futex_lock_pi , +.br futex_lock_pi2 , +and +.b futex_trylock_pi +pair with +.br futex_unlock_pi . +.b futex_unlock_pi +must be called only on a futex owned by the calling thread, +as defined by the value policy, otherwise the error +.b eperm +results. +.ip * +.b futex_wait_requeue_pi +pairs with +.br futex_cmp_requeue_pi . +this must be performed from a non-pi futex to a distinct pi futex +(or the error +.b einval +results). +additionally, +.i val +(the number of waiters to be woken) must be 1 +(or the error +.b einval +results). +.pp +the pi futex operations are as follows: +.\" +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.\" +.tp +.br futex_lock_pi " (since linux 2.6.18)" +.\" commit c87e2837be82df479a6bae9f155c43516d2feebc +this operation is used after an attempt to acquire +the lock via an atomic user-mode instruction failed +because the futex word has a nonzero value\(emspecifically, +because it contained the (pid-namespace-specific) tid of the lock owner. +.ip +the operation checks the value of the futex word at the address +.ir uaddr . +if the value is 0, then the kernel tries to atomically set +the futex value to the caller's tid. +if the futex word's value is nonzero, +the kernel atomically sets the +.b futex_waiters +bit, which signals the futex owner that it cannot unlock the futex in +user space atomically by setting the futex value to 0. +.\" tglx (july 2015): +.\" the operation here is similar to the futex_wait logic. when the user +.\" space atomic acquire does not succeed because the futex value was non +.\" zero, then the waiter goes into the kernel, takes the kernel internal +.\" lock and retries the acquisition under the lock. if the acquisition +.\" does not succeed either, then it sets the futex_waiters bit, to signal +.\" the lock owner that it needs to go into the kernel. here is the pseudo +.\" code: +.\" +.\" lock(kernel_lock); +.\" retry: +.\" +.\" /* +.\" * owner might have unlocked in user space before we +.\" * were able to set the waiter bit. +.\" */ +.\" if (atomic_acquire(futex) == success) { +.\" unlock(kernel_lock()); +.\" return 0; +.\" } +.\" +.\" /* +.\" * owner might have unlocked after the above atomic_acquire() +.\" * attempt. +.\" */ +.\" if (atomic_set_waiters_bit(futex) != success) +.\" goto retry; +.\" +.\" queue_waiter(); +.\" unlock(kernel_lock); +.\" block(); +.\" +after that, the kernel: +.rs +.ip 1. 3 +tries to find the thread which is associated with the owner tid. +.ip 2. +creates or reuses kernel state on behalf of the owner. +(if this is the first waiter, there is no kernel state for this +futex, so kernel state is created by locking the rt-mutex +and the futex owner is made the owner of the rt-mutex. +if there are existing waiters, then the existing state is reused.) +.ip 3. +attaches the waiter to the futex +(i.e., the waiter is enqueued on the rt-mutex waiter list). +.re +.ip +if more than one waiter exists, +the enqueueing of the waiter is in descending priority order. +(for information on priority ordering, see the discussion of the +.br sched_deadline , +.br sched_fifo , +and +.br sched_rr +scheduling policies in +.br sched (7).) +the owner inherits either the waiter's cpu bandwidth +(if the waiter is scheduled under the +.br sched_deadline +policy) or the waiter's priority (if the waiter is scheduled under the +.br sched_rr +or +.br sched_fifo +policy). +.\" august 2015: +.\" mtk: if the realm is restricted purely to sched_other (sched_normal) +.\" processes, does the nice value come into play also? +.\" +.\" tglx: no. sched_other/normal tasks are handled in fifo order +this inheritance follows the lock chain in the case of nested locking +.\" (i.e., task 1 blocks on lock a, held by task 2, +.\" while task 2 blocks on lock b, held by task 3) +and performs deadlock detection. +.ip +the +.i timeout +argument provides a timeout for the lock attempt. +if +.i timeout +is not null, the structure it points to specifies +an absolute timeout, measured against the +.br clock_realtime +clock. +.\" 2016-07-07 response from thomas gleixner on lkml: +.\" from: thomas gleixner +.\" date: 6 july 2016 at 20:57 +.\" subject: re: futex: allow futex_clock_realtime with futex_wait op +.\" +.\" on thu, 23 jun 2016, michael kerrisk (man-pages) wrote: +.\" > on 06/23/2016 08:28 pm, darren hart wrote: +.\" > > and as a follow-on, what is the reason for futex_lock_pi only using +.\" > > clock_realtime? it seems reasonable to me that a user may want to wait a +.\" > > specific amount of time, regardless of wall time. +.\" > +.\" > yes, that's another weird inconsistency. +.\" +.\" the reason is that phtread_mutex_timedlock() uses absolute timeouts based on +.\" clock_realtime. glibc folks asked to make that the default behaviour back +.\" then when we added lock_pi. +if +.i timeout +is null, the operation will block indefinitely. +.ip +the +.ir uaddr2 , +.ir val , +and +.i val3 +arguments are ignored. +.\" +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.\" +.tp +.br futex_lock_pi2 " (since linux 5.14)" +.\" commit bf22a6976897977b0a3f1aeba6823c959fc4fdae +this operation is the same as +.br futex_lock_pi , +except that the clock against which +.i timeout +is measured is selectable. +by default, the (absolute) timeout specified in +.i timeout +is measured againt the +.b clock_monotonic +clock, but if the +.b futex_clock_realtime +flag is specified in +.ir futex_op , +then the timeout is measured against the +.b clock_realtime +clock. +.\" +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.\" +.tp +.br futex_trylock_pi " (since linux 2.6.18)" +.\" commit c87e2837be82df479a6bae9f155c43516d2feebc +this operation tries to acquire the lock at +.ir uaddr . +it is invoked when a user-space atomic acquire did not +succeed because the futex word was not 0. +.ip +because the kernel has access to more state information than user space, +acquisition of the lock might succeed if performed by the +kernel in cases where the futex word +(i.e., the state information accessible to use-space) contains stale state +.rb ( futex_waiters +and/or +.br futex_owner_died ). +this can happen when the owner of the futex died. +user space cannot handle this condition in a race-free manner, +but the kernel can fix this up and acquire the futex. +.\" paraphrasing a f2f conversation with thomas gleixner about the +.\" above point (aug 2015): ### +.\" there is a rare possibility of a race condition involving an +.\" uncontended futex with no owner, but with waiters. the +.\" kernel-user-space contract is that if a futex is nonzero, you must +.\" go into kernel. the futex was owned by a task, and that task dies +.\" but there are no waiters, so the futex value is non zero. +.\" therefore, the next locker has to go into the kernel, +.\" so that the kernel has a chance to clean up. (cmxch on zero +.\" in user space would fail, so kernel has to clean up.) +.\" darren hart (oct 2015): +.\" the trylock in the kernel has more state, so it can independently +.\" verify the flags that user space must trust implicitly. +.ip +the +.ir uaddr2 , +.ir val , +.ir timeout , +and +.ir val3 +arguments are ignored. +.\" +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.\" +.tp +.br futex_unlock_pi " (since linux 2.6.18)" +.\" commit c87e2837be82df479a6bae9f155c43516d2feebc +this operation wakes the top priority waiter that is waiting in +.b futex_lock_pi +or +.b futex_lock_pi2 +on the futex address provided by the +.i uaddr +argument. +.ip +this is called when the user-space value at +.i uaddr +cannot be changed atomically from a tid (of the owner) to 0. +.ip +the +.ir uaddr2 , +.ir val , +.ir timeout , +and +.ir val3 +arguments are ignored. +.\" +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.\" +.tp +.br futex_cmp_requeue_pi " (since linux 2.6.31)" +.\" commit 52400ba946759af28442dee6265c5c0180ac7122 +this operation is a pi-aware variant of +.br futex_cmp_requeue . +it requeues waiters that are blocked via +.b futex_wait_requeue_pi +on +.i uaddr +from a non-pi source futex +.ri ( uaddr ) +to a pi target futex +.ri ( uaddr2 ). +.ip +as with +.br futex_cmp_requeue , +this operation wakes up a maximum of +.i val +waiters that are waiting on the futex at +.ir uaddr . +however, for +.br futex_cmp_requeue_pi , +.i val +is required to be 1 +(since the main point is to avoid a thundering herd). +the remaining waiters are removed from the wait queue of the source futex at +.i uaddr +and added to the wait queue of the target futex at +.ir uaddr2 . +.ip +the +.i val2 +.\" val2 is the cap on the number of requeued waiters. +.\" in the glibc pthread_cond_broadcast() implementation, this argument +.\" is specified as int_max, and for pthread_cond_signal() it is 0. +and +.i val3 +arguments serve the same purposes as for +.br futex_cmp_requeue . +.\" +.\" the page at http://locklessinc.com/articles/futex_cheat_sheet/ +.\" notes that "priority-inheritance futex to priority-inheritance +.\" futex requeues are currently unsupported". however, probably +.\" the page does not need to say nothing about this, since +.\" thomas gleixner commented (july 2015): "they never will be +.\" supported because they make no sense at all" +.\" +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.\" +.tp +.br futex_wait_requeue_pi " (since linux 2.6.31)" +.\" commit 52400ba946759af28442dee6265c5c0180ac7122 +.\" +wait on a non-pi futex at +.i uaddr +and potentially be requeued (via a +.br futex_cmp_requeue_pi +operation in another task) onto a pi futex at +.ir uaddr2 . +the wait operation on +.i uaddr +is the same as for +.br futex_wait . +.ip +the waiter can be removed from the wait on +.i uaddr +without requeueing on +.ir uaddr2 +via a +.br futex_wake +operation in another task. +in this case, the +.br futex_wait_requeue_pi +operation fails with the error +.br eagain . +.ip +if +.i timeout +is not null, the structure it points to specifies +an absolute timeout for the wait operation. +if +.i timeout +is null, the operation can block indefinitely. +.ip +the +.i val3 +argument is ignored. +.ip +the +.br futex_wait_requeue_pi +and +.br futex_cmp_requeue_pi +were added to support a fairly specific use case: +support for priority-inheritance-aware posix threads condition variables. +the idea is that these operations should always be paired, +in order to ensure that user space and the kernel remain in sync. +thus, in the +.br futex_wait_requeue_pi +operation, the user-space application pre-specifies the target +of the requeue that takes place in the +.br futex_cmp_requeue_pi +operation. +.\" +.\" darren hart notes that a patch to allow glibc to fully support +.\" pi-aware pthreads condition variables has not yet been accepted into +.\" glibc. the story is complex, and can be found at +.\" https://sourceware.org/bugzilla/show_bug.cgi?id=11588 +.\" darren notes that in the meantime, the patch is shipped with various +.\" preempt_rt-enabled linux systems. +.\" +.\" related to the preceding, darren proposed that somewhere, man-pages +.\" should document the following point: +.\" +.\" while the linux kernel, since 2.6.31, supports requeueing of +.\" priority-inheritance (pi) aware mutexes via the +.\" futex_wait_requeue_pi and futex_cmp_requeue_pi futex operations, +.\" the glibc implementation does not yet take full advantage of this. +.\" specifically, the condvar internal data lock remains a non-pi aware +.\" mutex, regardless of the type of the pthread_mutex associated with +.\" the condvar. this can lead to an unbounded priority inversion on +.\" the internal data lock even when associating a pi aware +.\" pthread_mutex with a condvar during a pthread_cond*_wait +.\" operation. for this reason, it is not recommended to rely on +.\" priority inheritance when using pthread condition variables. +.\" +.\" the problem is that the obvious location for this text is +.\" the pthread_cond*wait(3) man page. however, such a man page +.\" does not currently exist. +.\" +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.\" +.sh return value +in the event of an error (and assuming that +.br futex () +was invoked via +.br syscall (2)), +all operations return \-1 and set +.i errno +to indicate the error. +.pp +the return value on success depends on the operation, +as described in the following list: +.tp +.b futex_wait +returns 0 if the caller was woken up. +note that a wake-up can also be caused by common futex usage patterns +in unrelated code that happened to have previously used the futex word's +memory location (e.g., typical futex-based implementations of +pthreads mutexes can cause this under some conditions). +therefore, callers should always conservatively assume that a return +value of 0 can mean a spurious wake-up, and use the futex word's value +(i.e., the user-space synchronization scheme) +to decide whether to continue to block or not. +.tp +.b futex_wake +returns the number of waiters that were woken up. +.tp +.b futex_fd +returns the new file descriptor associated with the futex. +.tp +.b futex_requeue +returns the number of waiters that were woken up. +.tp +.b futex_cmp_requeue +returns the total number of waiters that were woken up or +requeued to the futex for the futex word at +.ir uaddr2 . +if this value is greater than +.ir val , +then the difference is the number of waiters requeued to the futex for the +futex word at +.ir uaddr2 . +.tp +.b futex_wake_op +returns the total number of waiters that were woken up. +this is the sum of the woken waiters on the two futexes for +the futex words at +.i uaddr +and +.ir uaddr2 . +.tp +.b futex_wait_bitset +returns 0 if the caller was woken up. +see +.b futex_wait +for how to interpret this correctly in practice. +.tp +.b futex_wake_bitset +returns the number of waiters that were woken up. +.tp +.b futex_lock_pi +returns 0 if the futex was successfully locked. +.tp +.b futex_lock_pi2 +returns 0 if the futex was successfully locked. +.tp +.b futex_trylock_pi +returns 0 if the futex was successfully locked. +.tp +.b futex_unlock_pi +returns 0 if the futex was successfully unlocked. +.tp +.b futex_cmp_requeue_pi +returns the total number of waiters that were woken up or +requeued to the futex for the futex word at +.ir uaddr2 . +if this value is greater than +.ir val , +then difference is the number of waiters requeued to the futex for +the futex word at +.ir uaddr2 . +.tp +.b futex_wait_requeue_pi +returns 0 if the caller was successfully requeued to the futex for +the futex word at +.ir uaddr2 . +.\" +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.\" +.sh errors +.tp +.b eacces +no read access to the memory of a futex word. +.tp +.b eagain +.rb ( futex_wait , +.br futex_wait_bitset , +.br futex_wait_requeue_pi ) +the value pointed to by +.i uaddr +was not equal to the expected value +.i val +at the time of the call. +.ip +.br note : +on linux, the symbolic names +.b eagain +and +.b ewouldblock +(both of which appear in different parts of the kernel futex code) +have the same value. +.tp +.b eagain +.rb ( futex_cmp_requeue , +.br futex_cmp_requeue_pi ) +the value pointed to by +.i uaddr +is not equal to the expected value +.ir val3 . +.tp +.b eagain +.rb ( futex_lock_pi , +.br futex_lock_pi2 , +.br futex_trylock_pi , +.br futex_cmp_requeue_pi ) +the futex owner thread id of +.i uaddr +(for +.br futex_cmp_requeue_pi : +.ir uaddr2 ) +is about to exit, +but has not yet handled the internal state cleanup. +try again. +.tp +.b edeadlk +.rb ( futex_lock_pi , +.br futex_lock_pi2 , +.br futex_trylock_pi , +.br futex_cmp_requeue_pi ) +the futex word at +.i uaddr +is already locked by the caller. +.tp +.br edeadlk +.\" fixme . i see that kernel/locking/rtmutex.c uses edeadlk in some +.\" places, and edeadlock in others. on almost all architectures +.\" these constants are synonymous. is there a reason that both +.\" names are used? +.\" +.\" tglx (july 2015): "no. we should probably fix that." +.\" +.rb ( futex_cmp_requeue_pi ) +while requeueing a waiter to the pi futex for the futex word at +.ir uaddr2 , +the kernel detected a deadlock. +.tp +.b efault +a required pointer argument (i.e., +.ir uaddr , +.ir uaddr2 , +or +.ir timeout ) +did not point to a valid user-space address. +.tp +.b eintr +a +.b futex_wait +or +.b futex_wait_bitset +operation was interrupted by a signal (see +.br signal (7)). +in kernels before linux 2.6.22, this error could also be returned for +a spurious wakeup; since linux 2.6.22, this no longer happens. +.tp +.b einval +the operation in +.i futex_op +is one of those that employs a timeout, but the supplied +.i timeout +argument was invalid +.ri ( tv_sec +was less than zero, or +.i tv_nsec +was not less than 1,000,000,000). +.tp +.b einval +the operation specified in +.i futex_op +employs one or both of the pointers +.i uaddr +and +.ir uaddr2 , +but one of these does not point to a valid object\(emthat is, +the address is not four-byte-aligned. +.tp +.b einval +.rb ( futex_wait_bitset , +.br futex_wake_bitset ) +the bit mask supplied in +.i val3 +is zero. +.tp +.b einval +.rb ( futex_cmp_requeue_pi ) +.i uaddr +equals +.i uaddr2 +(i.e., an attempt was made to requeue to the same futex). +.tp +.b einval +.rb ( futex_fd ) +the signal number supplied in +.i val +is invalid. +.tp +.b einval +.rb ( futex_wake , +.br futex_wake_op , +.br futex_wake_bitset , +.br futex_requeue , +.br futex_cmp_requeue ) +the kernel detected an inconsistency between the user-space state at +.i uaddr +and the kernel state\(emthat is, it detected a waiter which waits in +.b futex_lock_pi +or +.b futex_lock_pi2 +on +.ir uaddr . +.tp +.b einval +.rb ( futex_lock_pi , +.br futex_lock_pi2 , +.br futex_trylock_pi , +.br futex_unlock_pi ) +the kernel detected an inconsistency between the user-space state at +.i uaddr +and the kernel state. +this indicates either state corruption +or that the kernel found a waiter on +.i uaddr +which is waiting via +.b futex_wait +or +.br futex_wait_bitset . +.tp +.b einval +.rb ( futex_cmp_requeue_pi ) +the kernel detected an inconsistency between the user-space state at +.i uaddr2 +and the kernel state; +.\" from a conversation with thomas gleixner (aug 2015): ### +.\" the kernel sees: i have non pi state for a futex you tried to +.\" tell me was pi +that is, the kernel detected a waiter which waits via +.b futex_wait +or +.b futex_wait_bitset +on +.ir uaddr2 . +.tp +.b einval +.rb ( futex_cmp_requeue_pi ) +the kernel detected an inconsistency between the user-space state at +.i uaddr +and the kernel state; +that is, the kernel detected a waiter which waits via +.b futex_wait +or +.b futex_wait_bitset +on +.ir uaddr . +.tp +.b einval +.rb ( futex_cmp_requeue_pi ) +the kernel detected an inconsistency between the user-space state at +.i uaddr +and the kernel state; +that is, the kernel detected a waiter which waits on +.i uaddr +via +.b futex_lock_pi +or +.b futex_lock_pi2 +(instead of +.br futex_wait_requeue_pi ). +.tp +.b einval +.rb ( futex_cmp_requeue_pi ) +.\" this deals with the case: +.\" wait_requeue_pi(a, b); +.\" requeue_pi(a, c); +an attempt was made to requeue a waiter to a futex other than that +specified by the matching +.b futex_wait_requeue_pi +call for that waiter. +.tp +.b einval +.rb ( futex_cmp_requeue_pi ) +the +.i val +argument is not 1. +.tp +.b einval +invalid argument. +.tp +.b enfile +.rb ( futex_fd ) +the system-wide limit on the total number of open files has been reached. +.tp +.b enomem +.rb ( futex_lock_pi , +.br futex_lock_pi2 , +.br futex_trylock_pi , +.br futex_cmp_requeue_pi ) +the kernel could not allocate memory to hold state information. +.tp +.b enosys +invalid operation specified in +.ir futex_op . +.tp +.b enosys +the +.b futex_clock_realtime +option was specified in +.ir futex_op , +but the accompanying operation was neither +.br futex_wait , +.br futex_wait_bitset , +.br futex_wait_requeue_pi , +nor +.br futex_lock_pi2 . +.tp +.b enosys +.rb ( futex_lock_pi , +.br futex_lock_pi2 , +.br futex_trylock_pi , +.br futex_unlock_pi , +.br futex_cmp_requeue_pi , +.br futex_wait_requeue_pi ) +a run-time check determined that the operation is not available. +the pi-futex operations are not implemented on all architectures and +are not supported on some cpu variants. +.tp +.b eperm +.rb ( futex_lock_pi , +.br futex_lock_pi2 , +.br futex_trylock_pi , +.br futex_cmp_requeue_pi ) +the caller is not allowed to attach itself to the futex at +.i uaddr +(for +.br futex_cmp_requeue_pi : +the futex at +.ir uaddr2 ). +(this may be caused by a state corruption in user space.) +.tp +.b eperm +.rb ( futex_unlock_pi ) +the caller does not own the lock represented by the futex word. +.tp +.b esrch +.rb ( futex_lock_pi , +.br futex_lock_pi2 , +.br futex_trylock_pi , +.br futex_cmp_requeue_pi ) +the thread id in the futex word at +.i uaddr +does not exist. +.tp +.b esrch +.rb ( futex_cmp_requeue_pi ) +the thread id in the futex word at +.i uaddr2 +does not exist. +.tp +.b etimedout +the operation in +.i futex_op +employed the timeout specified in +.ir timeout , +and the timeout expired before the operation completed. +.\" +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.\" +.sh versions +futexes were first made available in a stable kernel release +with linux 2.6.0. +.pp +initial futex support was merged in linux 2.5.7 but with different +semantics from what was described above. +a four-argument system call with the semantics +described in this page was introduced in linux 2.5.40. +a fifth argument was added in linux 2.5.70, +and a sixth argument was added in linux 2.6.7. +.sh conforming to +this system call is linux-specific. +.sh notes +several higher-level programming abstractions are implemented via futexes, +including posix semaphores and +various posix threads synchronization mechanisms +(mutexes, condition variables, read-write locks, and barriers). +.\" todo fixme(torvald) above, we cite this section and claim it contains +.\" details on the synchronization semantics; add the c11 equivalents +.\" here (or whatever we find consensus for). +.\" +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.\" +.sh examples +the program below demonstrates use of futexes in a program where a parent +process and a child process use a pair of futexes located inside a +shared anonymous mapping to synchronize access to a shared resource: +the terminal. +the two processes each write +.ir nloops +(a command-line argument that defaults to 5 if omitted) +messages to the terminal and employ a synchronization protocol +that ensures that they alternate in writing messages. +upon running this program we see output such as the following: +.pp +.in +4n +.ex +$ \fb./futex_demo\fp +parent (18534) 0 +child (18535) 0 +parent (18534) 1 +child (18535) 1 +parent (18534) 2 +child (18535) 2 +parent (18534) 3 +child (18535) 3 +parent (18534) 4 +child (18535) 4 +.ee +.in +.ss program source +\& +.ex +/* futex_demo.c + + usage: futex_demo [nloops] + (default: 5) + + demonstrate the use of futexes in a program where parent and child + use a pair of futexes located inside a shared anonymous mapping to + synchronize access to a shared resource: the terminal. the two + processes each write \(aqnum\-loops\(aq messages to the terminal and employ + a synchronization protocol that ensures that they alternate in + writing messages. +*/ +#define _gnu_source +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define errexit(msg) do { perror(msg); exit(exit_failure); \e + } while (0) + +static uint32_t *futex1, *futex2, *iaddr; + +static int +futex(uint32_t *uaddr, int futex_op, uint32_t val, + const struct timespec *timeout, uint32_t *uaddr2, uint32_t val3) +{ + return syscall(sys_futex, uaddr, futex_op, val, + timeout, uaddr2, val3); +} + +/* acquire the futex pointed to by \(aqfutexp\(aq: wait for its value to + become 1, and then set the value to 0. */ + +static void +fwait(uint32_t *futexp) +{ + long s; + + /* atomic_compare_exchange_strong(ptr, oldval, newval) + atomically performs the equivalent of: + + if (*ptr == *oldval) + *ptr = newval; + + it returns true if the test yielded true and *ptr was updated. */ + + while (1) { + + /* is the futex available? */ + const uint32_t one = 1; + if (atomic_compare_exchange_strong(futexp, &one, 0)) + break; /* yes */ + + /* futex is not available; wait. */ + + s = futex(futexp, futex_wait, 0, null, null, 0); + if (s == \-1 && errno != eagain) + errexit("futex\-futex_wait"); + } +} + +/* release the futex pointed to by \(aqfutexp\(aq: if the futex currently + has the value 0, set its value to 1 and the wake any futex waiters, + so that if the peer is blocked in fwait(), it can proceed. */ + +static void +fpost(uint32_t *futexp) +{ + long s; + + /* atomic_compare_exchange_strong() was described + in comments above. */ + + const uint32_t zero = 0; + if (atomic_compare_exchange_strong(futexp, &zero, 1)) { + s = futex(futexp, futex_wake, 1, null, null, 0); + if (s == \-1) + errexit("futex\-futex_wake"); + } +} + +int +main(int argc, char *argv[]) +{ + pid_t childpid; + int nloops; + + setbuf(stdout, null); + + nloops = (argc > 1) ? atoi(argv[1]) : 5; + + /* create a shared anonymous mapping that will hold the futexes. + since the futexes are being shared between processes, we + subsequently use the "shared" futex operations (i.e., not the + ones suffixed "_private"). */ + + iaddr = mmap(null, sizeof(*iaddr) * 2, prot_read | prot_write, + map_anonymous | map_shared, \-1, 0); + if (iaddr == map_failed) + errexit("mmap"); + + futex1 = &iaddr[0]; + futex2 = &iaddr[1]; + + *futex1 = 0; /* state: unavailable */ + *futex2 = 1; /* state: available */ + + /* create a child process that inherits the shared anonymous + mapping. */ + + childpid = fork(); + if (childpid == \-1) + errexit("fork"); + + if (childpid == 0) { /* child */ + for (int j = 0; j < nloops; j++) { + fwait(futex1); + printf("child (%jd) %d\en", (intmax_t) getpid(), j); + fpost(futex2); + } + + exit(exit_success); + } + + /* parent falls through to here. */ + + for (int j = 0; j < nloops; j++) { + fwait(futex2); + printf("parent (%jd) %d\en", (intmax_t) getpid(), j); + fpost(futex1); + } + + wait(null); + + exit(exit_success); +} +.ee +.sh see also +.ad l +.br get_robust_list (2), +.br restart_syscall (2), +.br pthread_mutexattr_getprotocol (3), +.br futex (7), +.br sched (7) +.pp +the following kernel source files: +.ip * 2 +.i documentation/pi\-futex.txt +.ip * +.i documentation/futex\-requeue\-pi.txt +.ip * +.i documentation/locking/rt\-mutex.txt +.ip * +.i documentation/locking/rt\-mutex\-design.txt +.ip * +.i documentation/robust\-futex\-abi.txt +.pp +franke, h., russell, r., and kirwood, m., 2002. +\fifuss, futexes and furwocks: fast userlevel locking in linux\fp +(from proceedings of the ottawa linux symposium 2002), +.br +.ur http://kernel.org\:/doc\:/ols\:/2002\:/ols2002\-pages\-479\-495.pdf +.ue +.pp +hart, d., 2009. \fia futex overview and update\fp, +.ur http://lwn.net/articles/360699/ +.ue +.pp +hart, d.\& and guniguntala, d., 2009. +\firequeue-pi: making glibc condvars pi-aware\fp +(from proceedings of the 2009 real-time linux workshop), +.ur http://lwn.net/images/conf/rtlws11/papers/proc/p10.pdf +.ue +.pp +drepper, u., 2011. \fifutexes are tricky\fp, +.ur http://www.akkadia.org/drepper/futex.pdf +.ue +.pp +futex example library, futex-*.tar.bz2 at +.br +.ur ftp://ftp.kernel.org\:/pub\:/linux\:/kernel\:/people\:/rusty/ +.ue +.\" +.\" fixme(torvald) we should probably refer to the glibc code here, in +.\" particular the glibc-internal futex wrapper functions that are +.\" wip, and the generic pthread_mutex_t and perhaps condvar +.\" implementations. +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1993 michael haardt (michael@moria.de), +.\" fri apr 2 11:32:09 met dst 1993 +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" modified sat jul 24 16:57:14 1993 by rik faith (faith@cs.unc.edu) +.th intro 4 2017-09-15 "linux" "linux programmer's manual" +.sh name +intro \- introduction to special files +.sh description +section 4 of the manual describes special files (devices). +.sh files +/dev/* \(em device files +.sh notes +.ss authors and copyright conditions +look at the header of the manual page source for the author(s) and copyright +conditions. +note that these can be different from page to page! +.sh see also +.br mknod (1), +.br mknod (2), +.br standards (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/finite.3 + +.\" copyright (c) 2014 red hat, inc. all rights reserved. +.\" written by david howells (dhowells@redhat.com) +.\" +.\" %%%license_start(gplv2+_sw_onepara) +.\" this program is free software; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license +.\" as published by the free software foundation; either version +.\" 2 of the license, or (at your option) any later version. +.\" %%%license_end +.\" +.th user-session-keyring 7 2020-08-13 linux "linux programmer's manual" +.sh name +user-session-keyring \- per-user default session keyring +.sh description +the user session keyring is a keyring used to anchor keys on behalf of a user. +each uid the kernel deals with has its own user session keyring that +is shared by all processes with that uid. +the user session keyring has a name (description) of the form +.i _uid_ses. +where +.i +is the user id of the corresponding user. +.pp +the user session keyring is associated with the record that +the kernel maintains for the uid. +it comes into existence upon the first attempt to access either the +user session keyring, the +.br user\-keyring (7), +or the +.br session\-keyring (7). +.\" davis howells: the user and user-session keyrings are managed as a pair. +the keyring remains pinned in existence so long as there are processes +running with that real uid or files opened by those processes remain open. +(the keyring can also be pinned indefinitely by linking it +into another keyring.) +.pp +the user session keyring is created on demand when a thread requests it +or when a thread asks for its +.br session\-keyring (7) +and that keyring doesn't exist. +in the latter case, a user session keyring will be created and, +if the session keyring wasn't to be created, +the user session keyring will be set as the process's actual session keyring. +.pp +the user session keyring is searched by +.br request_key (2) +if the actual session keyring does not exist and is ignored otherwise. +.pp +a special serial number value, +.br key_spec_user_session_keyring , +is defined +that can be used in lieu of the actual serial number of +the calling process's user session keyring. +.pp +from the +.br keyctl (1) +utility, '\fb@us\fp' can be used instead of a numeric key id in +much the same way. +.pp +user session keyrings are independent of +.br clone (2), +.br fork (2), +.br vfork (2), +.br execve (2), +and +.br _exit (2) +excepting that the keyring is destroyed when the uid record is destroyed +when the last process pinning it exits. +.pp +if a user session keyring does not exist when it is accessed, +it will be created. +.pp +rather than relying on the user session keyring, +it is strongly recommended\(emespecially if the process +is running as root\(emthat a +.br session\-keyring (7) +be set explicitly, for example by +.br pam_keyinit (8). +.sh notes +the user session keyring was added to support situations where +a process doesn't have a session keyring, +perhaps because it was created via a pathway that didn't involve pam +(e.g., perhaps it was a daemon started by +.br inetd (8)). +in such a scenario, the user session keyring acts as a substitute for the +.br session\-keyring (7). +.sh see also +.ad l +.nh +.br keyctl (1), +.br keyctl (3), +.br keyrings (7), +.br persistent\-keyring (7), +.br process\-keyring (7), +.br session\-keyring (7), +.br thread\-keyring (7), +.br user\-keyring (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/gethostbyname.3 + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification +.\" http://www.unix-systems.org/online.html +.\" iso/iec 9899:1999 +.\" +.th mbrtowc 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +mbrtowc \- convert a multibyte sequence to a wide character +.sh synopsis +.nf +.b #include +.pp +.bi "size_t mbrtowc(wchar_t *restrict " pwc ", const char *restrict " s \ +", size_t " n , +.bi " mbstate_t *restrict " ps ); +.fi +.sh description +the main case for this function is when +.ir s +is not null and +.i pwc +is +not null. +in this case, the +.br mbrtowc () +function inspects at most +.i n +bytes of the multibyte string starting at +.ir s , +extracts the next complete +multibyte character, converts it to a wide character and stores it at +.ir *pwc . +it updates the shift state +.ir *ps . +if the converted wide +character is not l\(aq\e0\(aq (the null wide character), +it returns the number of bytes that were consumed +from +.ir s . +if the converted wide character is l\(aq\e0\(aq, it resets the shift +state +.i *ps +to the initial state and returns 0. +.pp +if the +.ir n +bytes starting at +.i s +do not contain a complete multibyte +character, +.br mbrtowc () +returns +.ir "(size_t)\ \-2" . +this can happen even if +.i n +>= +.ir mb_cur_max , +if the multibyte string contains redundant shift +sequences. +.pp +if the multibyte string starting at +.i s +contains an invalid multibyte +sequence before the next complete character, +.br mbrtowc () +returns +.ir "(size_t)\ \-1" +and sets +.i errno +to +.br eilseq . +in this case, +the effects on +.i *ps +are undefined. +.pp +a different case is when +.ir s +is not null but +.i pwc +is null. +in this case, the +.br mbrtowc () +function behaves as above, except that it does not +store the converted wide character in memory. +.pp +a third case is when +.i s +is null. +in this case, +.ir pwc +and +.i n +are +ignored. +if the conversion state represented by +.i *ps +denotes an +incomplete multibyte character conversion, the +.br mbrtowc () +function +returns +.ir "(size_t)\ \-1" , +sets +.i errno +to +.br eilseq , +and +leaves +.i *ps +in an undefined state. +otherwise, the +.br mbrtowc () +function +puts +.i *ps +in the initial state and returns 0. +.pp +in all of the above cases, if +.i ps +is null, a static anonymous +state known only to the +.br mbrtowc () +function is used instead. +otherwise, +.ir *ps +must be a valid +.i mbstate_t +object. +an +.ir mbstate_t +object +.i a +can be initialized to the initial state +by zeroing it, for example using +.pp +.in +4n +.ex +memset(&a, 0, sizeof(a)); +.ee +.in +.sh return value +the +.br mbrtowc () +function returns the number of bytes parsed from the +multibyte sequence starting at +.ir s , +if a non-l\(aq\e0\(aq wide character +was recognized. +it returns 0, if a l\(aq\e0\(aq wide character was recognized. +it returns +.i (size_t)\ \-1 +and sets +.i errno +to +.br eilseq , +if an invalid multibyte sequence was +encountered. +it returns +.i "(size_t)\ \-2" +if it couldn't parse a complete multibyte +character, meaning that +.i n +should be increased. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br mbrtowc () +t} thread safety mt-unsafe race:mbrtowc/!ps +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh notes +the behavior of +.br mbrtowc () +depends on the +.b lc_ctype +category of the +current locale. +.sh see also +.br mbsinit (3), +.br mbsrtowcs (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/err.3 + +.so man3/slist.3 + +.\" copyright (c) 1992 drew eckhardt (drew@cs.colorado.edu), march 28, 1992 +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified by michael haardt (michael@moria.de) +.\" modified 1993-07-23 by rik faith (faith@cs.unc.edu) +.\" modified 1994-08-21 by michael chastain (mec@shell.portal.com): +.\" fixed necessary '#include' lines. +.\" modified 1995-04-15 by michael chastain (mec@shell.portal.com): +.\" added reference to adjtimex. +.\" removed some nonsense lines pointed out by urs thuermann, +.\" (urs@isnogud.escape.de), aeb, 950722. +.\" modified 1997-01-14 by austin donnelly (and1000@debian.org): +.\" added return values section, and bit on efault +.\" added clarification on timezone, aeb, 971210. +.\" removed "#include ", aeb, 010316. +.\" modified, 2004-05-27 by michael kerrisk +.\" added notes on capability requirement. +.\" +.th gettimeofday 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +gettimeofday, settimeofday \- get / set time +.sh synopsis +.nf +.b #include +.pp +.bi "int gettimeofday(struct timeval *restrict " tv , +.bi " struct timezone *restrict " tz ); +.bi "int settimeofday(const struct timeval *" tv , +.bi " const struct timezone *" tz ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br settimeofday (): +.nf + since glibc 2.19: + _default_source + glibc 2.19 and earlier: + _bsd_source +.fi +.sh description +the functions +.br gettimeofday () +and +.br settimeofday () +can get and set the time as well as a timezone. +.pp +the +.i tv +argument is a +.i struct timeval +(as specified in +.ir ): +.pp +.in +4n +.ex +struct timeval { + time_t tv_sec; /* seconds */ + suseconds_t tv_usec; /* microseconds */ +}; +.ee +.in +.pp +and gives the number of seconds and microseconds since the epoch (see +.br time (2)). +.pp +the +.i tz +argument is a +.ir "struct timezone" : +.pp +.in +4n +.ex +struct timezone { + int tz_minuteswest; /* minutes west of greenwich */ + int tz_dsttime; /* type of dst correction */ +}; +.ee +.in +.pp +if either +.i tv +or +.i tz +is null, the corresponding structure is not set or returned. +.\" fixme . the compilation warning looks to be going away in 2.17 +.\" see glibc commit 4b7634a5e03b0da6f8875de9d3f74c1cf6f2a6e8 +(however, compilation warnings will result if +.i tv +is null.) +.\" the following is covered under eperm below: +.\" .pp +.\" only the superuser may use +.\" .br settimeofday (). +.pp +the use of the +.i timezone +structure is obsolete; the +.i tz +argument should normally be specified as null. +(see notes below.) +.pp +under linux, there are some peculiar "warp clock" semantics associated +with the +.br settimeofday () +system call if on the very first call (after booting) +that has a non-null +.i tz +argument, the +.i tv +argument is null and the +.i tz_minuteswest +field is nonzero. +(the +.i tz_dsttime +field should be zero for this case.) +in such a case it is assumed that the cmos clock +is on local time, and that it has to be incremented by this amount +to get utc system time. +no doubt it is a bad idea to use this feature. +.sh return value +.br gettimeofday () +and +.br settimeofday () +return 0 for success. +on error, \-1 is returned and +.i errno +is set to indicate the error. +.sh errors +.tp +.b efault +one of +.i tv +or +.i tz +pointed outside the accessible address space. +.tp +.b einval +.rb ( settimeofday ()): +.i timezone +is invalid. +.tp +.b einval +.rb ( settimeofday ()): +.i tv.tv_sec +is negative or +.i tv.tv_usec +is outside the range [0..999,999]. +.tp +.br einval " (since linux 4.3)" +.\" commit e1d7ba8735551ed79c7a0463a042353574b96da3 +.rb ( settimeofday ()): +an attempt was made to set the time to a value less than +the current value of the +.b clock_monotonic +clock (see +.br clock_gettime (2)). +.tp +.b eperm +the calling process has insufficient privilege to call +.br settimeofday (); +under linux the +.b cap_sys_time +capability is required. +.sh conforming to +svr4, 4.3bsd. +posix.1-2001 describes +.br gettimeofday () +but not +.br settimeofday (). +posix.1-2008 marks +.br gettimeofday () +as obsolete, recommending the use of +.br clock_gettime (2) +instead. +.sh notes +the time returned by +.br gettimeofday () +.i is +affected by discontinuous jumps in the system time +(e.g., if the system administrator manually changes the system time). +if you need a monotonically increasing clock, see +.br clock_gettime (2). +.pp +macros for operating on +.i timeval +structures are described in +.br timeradd (3). +.pp +traditionally, the fields of +.i struct timeval +were of type +.ir long . +.\" +.ss c library/kernel differences +on some architectures, an implementation of +.br gettimeofday () +is provided in the +.br vdso (7). +.\" +.ss the tz_dsttime field +on a non-linux kernel, with glibc, the +.i tz_dsttime +field of +.i struct timezone +will be set to a nonzero value by +.br gettimeofday () +if the current timezone has ever had or will have a daylight saving +rule applied. +in this sense it exactly mirrors the meaning of +.br daylight (3) +for the current zone. +on linux, with glibc, the setting of the +.i tz_dsttime +field of +.i struct timezone +has never been used by +.br settimeofday () +or +.br gettimeofday (). +.\" it has not +.\" been and will not be supported by libc or glibc. +.\" each and every occurrence of this field in the kernel source +.\" (other than the declaration) is a bug. +thus, the following is purely of historical interest. +.pp +on old systems, the field +.i tz_dsttime +contains a symbolic constant (values are given below) +that indicates in which part of the year daylight saving time +is in force. +(note: this value is constant throughout the year: +it does not indicate that dst is in force, it just selects an +algorithm.) +the daylight saving time algorithms defined are as follows: +.pp +.in +4n +.ex +\fbdst_none\fp /* not on dst */ +\fbdst_usa\fp /* usa style dst */ +\fbdst_aust\fp /* australian style dst */ +\fbdst_wet\fp /* western european dst */ +\fbdst_met\fp /* middle european dst */ +\fbdst_eet\fp /* eastern european dst */ +\fbdst_can\fp /* canada */ +\fbdst_gb\fp /* great britain and eire */ +\fbdst_rum\fp /* romania */ +\fbdst_tur\fp /* turkey */ +\fbdst_austalt\fp /* australian style with shift in 1986 */ +.ee +.in +.pp +of course it turned out that the period in which +daylight saving time is in force cannot be given +by a simple algorithm, one per country; indeed, +this period is determined by unpredictable political +decisions. +so this method of representing timezones +has been abandoned. +.sh see also +.br date (1), +.br adjtimex (2), +.br clock_gettime (2), +.br time (2), +.br ctime (3), +.br ftime (3), +.br timeradd (3), +.br capabilities (7), +.br time (7), +.br vdso (7), +.br hwclock (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1993 rickard e. faith (faith@cs.unc.edu) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th getgid 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +getgid, getegid \- get group identity +.sh synopsis +.nf +.b #include +.pp +.b gid_t getgid(void); +.b gid_t getegid(void); +.fi +.sh description +.br getgid () +returns the real group id of the calling process. +.pp +.br getegid () +returns the effective group id of the calling process. +.sh errors +these functions are always successful +and never modify +.\" https://www.austingroupbugs.net/view.php?id=511 +.\" 0000511: getuid and friends should not modify errno +.ir errno . +.sh conforming to +posix.1-2001, posix.1-2008, 4.3bsd. +.sh notes +the original linux +.br getgid () +and +.br getegid () +system calls supported only 16-bit group ids. +subsequently, linux 2.4 added +.br getgid32 () +and +.br getegid32 (), +supporting 32-bit ids. +the glibc +.br getgid () +and +.br getegid () +wrapper functions transparently deal with the variations across kernel versions. +.pp +on alpha, instead of a pair of +.br getgid () +and +.br getegid () +system calls, a single +.br getxgid () +system call is provided, which returns a pair of real and effective gids. +the glibc +.br getgid () +and +.br getegid () +wrapper functions transparently deal with this. +see +.br syscall (2) +for details regarding register mapping. +.sh see also +.br getresgid (2), +.br setgid (2), +.br setregid (2), +.br credentials (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/argz_add.3 + +.so man2/rename.2 + +.so man3/isalpha.3 + +.so man3/getprotoent_r.3 + +.so man2/uname.2 + +.\" copyright (c) 2008 linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th pthread_getattr_np 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +pthread_getattr_np \- get attributes of created thread +.sh synopsis +.nf +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "int pthread_getattr_np(pthread_t " thread ", pthread_attr_t *" attr ); +.pp +compile and link with \fi\-pthread\fp. +.fi +.sh description +the +.br pthread_getattr_np () +function initializes the thread attributes object referred to by +.i attr +so that it contains actual attribute values describing the running thread +.ir thread . +.pp +the returned attribute values may differ from +the corresponding attribute values passed in the +.i attr +object that was used to create the thread using +.br pthread_create (3). +in particular, the following attributes may differ: +.ip * 2 +the detach state, since a joinable thread may have detached itself +after creation; +.ip * +the stack size, +which the implementation may align to a suitable boundary. +.ip * +and the guard size, +which the implementation may round upward to a multiple of the page size, +or ignore (i.e., treat as 0), +if the application is allocating its own stack. +.pp +furthermore, if the stack address attribute was not set +in the thread attributes object used to create the thread, +then the returned thread attributes object will report the actual +stack address that the implementation selected for the thread. +.pp +when the thread attributes object returned by +.br pthread_getattr_np () +is no longer required, it should be destroyed using +.br pthread_attr_destroy (3). +.sh return value +on success, this function returns 0; +on error, it returns a nonzero error number. +.sh errors +.tp +.b enomem +.\" can happen (but unlikely) while trying to allocate memory for cpuset +insufficient memory. +.pp +in addition, if +.i thread +refers to the main thread, then +.br pthread_getattr_np () +can fail because of errors from various underlying calls: +.br fopen (3), +if +.ir /proc/self/maps +can't be opened; +and +.br getrlimit (2), +if the +.br rlimit_stack +resource limit is not supported. +.sh versions +this function is available in glibc since version 2.2.3. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br pthread_getattr_np () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +this function is a nonstandard gnu extension; +hence the suffix "_np" (nonportable) in the name. +.sh examples +the program below demonstrates the use of +.br pthread_getattr_np (). +the program creates a thread that then uses +.br pthread_getattr_np () +to retrieve and display its guard size, stack address, +and stack size attributes. +command-line arguments can be used to set these attributes +to values other than the default when creating the thread. +the shell sessions below demonstrate the use of the program. +.pp +in the first run, on an x86-32 system, +a thread is created using default attributes: +.pp +.in +4n +.ex +.rb "$" " ulimit \-s" " # no stack limit ==> default stack size is 2 mb" +unlimited +.rb "$" " ./a.out" +attributes of created thread: + guard size = 4096 bytes + stack address = 0x40196000 (eos = 0x40397000) + stack size = 0x201000 (2101248) bytes +.ee +.in +.pp +in the following run, we see that if a guard size is specified, +it is rounded up to the next multiple of the system page size +(4096 bytes on x86-32): +.pp +.in +4n +.ex +.rb "$" " ./a.out \-g 4097" +thread attributes object after initializations: + guard size = 4097 bytes + stack address = (nil) + stack size = 0x0 (0) bytes + +attributes of created thread: + guard size = 8192 bytes + stack address = 0x40196000 (eos = 0x40397000) + stack size = 0x201000 (2101248) bytes +.ee +.in +.\".in +4n +.\".nf +.\"$ ./a.out \-s 0x8000 +.\"thread attributes object after initializations: +.\" guard size = 4096 bytes +.\" stack address = 0xffff8000 (eos = (nil)) +.\" stack size = 0x8000 (32768) bytes +.\" +.\"attributes of created thread: +.\" guard size = 4096 bytes +.\" stack address = 0x4001e000 (eos = 0x40026000) +.\" stack size = 0x8000 (32768) bytes +.\".fi +.\".in +.pp +in the last run, the program manually allocates a stack for the thread. +in this case, the guard size attribute is ignored. +.pp +.in +4n +.ex +.rb "$" " ./a.out \-g 4096 \-s 0x8000 \-a" +allocated thread stack at 0x804d000 + +thread attributes object after initializations: + guard size = 4096 bytes + stack address = 0x804d000 (eos = 0x8055000) + stack size = 0x8000 (32768) bytes + +attributes of created thread: + guard size = 0 bytes + stack address = 0x804d000 (eos = 0x8055000) + stack size = 0x8000 (32768) bytes +.ee +.in +.ss program source +\& +.ex +#define _gnu_source /* to get pthread_getattr_np() declaration */ +#include +#include +#include +#include +#include + +#define handle_error_en(en, msg) \e + do { errno = en; perror(msg); exit(exit_failure); } while (0) + +static void +display_stack_related_attributes(pthread_attr_t *attr, char *prefix) +{ + int s; + size_t stack_size, guard_size; + void *stack_addr; + + s = pthread_attr_getguardsize(attr, &guard_size); + if (s != 0) + handle_error_en(s, "pthread_attr_getguardsize"); + printf("%sguard size = %zu bytes\en", prefix, guard_size); + + s = pthread_attr_getstack(attr, &stack_addr, &stack_size); + if (s != 0) + handle_error_en(s, "pthread_attr_getstack"); + printf("%sstack address = %p", prefix, stack_addr); + if (stack_size > 0) + printf(" (eos = %p)", (char *) stack_addr + stack_size); + printf("\en"); + printf("%sstack size = %#zx (%zu) bytes\en", + prefix, stack_size, stack_size); +} + +static void +display_thread_attributes(pthread_t thread, char *prefix) +{ + int s; + pthread_attr_t attr; + + s = pthread_getattr_np(thread, &attr); + if (s != 0) + handle_error_en(s, "pthread_getattr_np"); + + display_stack_related_attributes(&attr, prefix); + + s = pthread_attr_destroy(&attr); + if (s != 0) + handle_error_en(s, "pthread_attr_destroy"); +} + +static void * /* start function for thread we create */ +thread_start(void *arg) +{ + printf("attributes of created thread:\en"); + display_thread_attributes(pthread_self(), "\et"); + + exit(exit_success); /* terminate all threads */ +} + +static void +usage(char *pname, char *msg) +{ + if (msg != null) + fputs(msg, stderr); + fprintf(stderr, "usage: %s [\-s stack\-size [\-a]]" + " [\-g guard\-size]\en", pname); + fprintf(stderr, "\et\et\-a means program should allocate stack\en"); + exit(exit_failure); +} + +static pthread_attr_t * /* get thread attributes from command line */ +get_thread_attributes_from_cl(int argc, char *argv[], + pthread_attr_t *attrp) +{ + int s, opt, allocate_stack; + size_t stack_size, guard_size; + void *stack_addr; + pthread_attr_t *ret_attrp = null; /* set to attrp if we initialize + a thread attributes object */ + allocate_stack = 0; + stack_size = \-1; + guard_size = \-1; + + while ((opt = getopt(argc, argv, "ag:s:")) != \-1) { + switch (opt) { + case \(aqa\(aq: allocate_stack = 1; break; + case \(aqg\(aq: guard_size = strtoul(optarg, null, 0); break; + case \(aqs\(aq: stack_size = strtoul(optarg, null, 0); break; + default: usage(argv[0], null); + } + } + + if (allocate_stack && stack_size == \-1) + usage(argv[0], "specifying \-a without \-s makes no sense\en"); + + if (argc > optind) + usage(argv[0], "extraneous command\-line arguments\en"); + + if (stack_size >= 0 || guard_size > 0) { + ret_attrp = attrp; + + s = pthread_attr_init(attrp); + if (s != 0) + handle_error_en(s, "pthread_attr_init"); + } + + if (stack_size >= 0) { + if (!allocate_stack) { + s = pthread_attr_setstacksize(attrp, stack_size); + if (s != 0) + handle_error_en(s, "pthread_attr_setstacksize"); + } else { + s = posix_memalign(&stack_addr, sysconf(_sc_pagesize), + stack_size); + if (s != 0) + handle_error_en(s, "posix_memalign"); + printf("allocated thread stack at %p\en\en", stack_addr); + + s = pthread_attr_setstack(attrp, stack_addr, stack_size); + if (s != 0) + handle_error_en(s, "pthread_attr_setstacksize"); + } + } + + if (guard_size >= 0) { + s = pthread_attr_setguardsize(attrp, guard_size); + if (s != 0) + handle_error_en(s, "pthread_attr_setstacksize"); + } + + return ret_attrp; +} + +int +main(int argc, char *argv[]) +{ + int s; + pthread_t thr; + pthread_attr_t attr; + pthread_attr_t *attrp = null; /* set to &attr if we initialize + a thread attributes object */ + + attrp = get_thread_attributes_from_cl(argc, argv, &attr); + + if (attrp != null) { + printf("thread attributes object after initializations:\en"); + display_stack_related_attributes(attrp, "\et"); + printf("\en"); + } + + s = pthread_create(&thr, attrp, &thread_start, null); + if (s != 0) + handle_error_en(s, "pthread_create"); + + if (attrp != null) { + s = pthread_attr_destroy(attrp); + if (s != 0) + handle_error_en(s, "pthread_attr_destroy"); + } + + pause(); /* terminates when other thread calls exit() */ +} +.ee +.sh see also +.ad l +.nh +.br pthread_attr_getaffinity_np (3), +.br pthread_attr_getdetachstate (3), +.br pthread_attr_getguardsize (3), +.br pthread_attr_getinheritsched (3), +.br pthread_attr_getschedparam (3), +.br pthread_attr_getschedpolicy (3), +.br pthread_attr_getscope (3), +.br pthread_attr_getstack (3), +.br pthread_attr_getstackaddr (3), +.br pthread_attr_getstacksize (3), +.br pthread_attr_init (3), +.br pthread_create (3), +.br pthreads (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/casin.3 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" +.\" modified 1993-03-29, david metcalfe +.\" modified 1993-04-28, lars wirzenius +.\" modified 1993-07-24, rik faith (faith@cs.unc.edu) +.\" modified 1995-05-18, rik faith (faith@cs.unc.edu) to add +.\" better discussion of problems with rand on other systems. +.\" (thanks to esa hyyti{ (ehyytia@snakemail.hut.fi).) +.\" modified 1998-04-10, nicolás lichtmaier +.\" with contribution from francesco potorti +.\" modified 2003-11-15, aeb, added rand_r +.\" 2010-09-13, mtk, added example program +.\" +.th rand 3 2021-03-22 "" "linux programmer's manual" +.sh name +rand, rand_r, srand \- pseudo-random number generator +.sh synopsis +.nf +.b #include +.pp +.b int rand(void); +.bi "int rand_r(unsigned int *" seedp ); +.bi "void srand(unsigned int " seed ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br rand_r (): +.nf + since glibc 2.24: + _posix_c_source >= 199506l + glibc 2.23 and earlier + _posix_c_source +.fi +.sh description +the +.br rand () +function returns a pseudo-random integer in the range 0 to +.br rand_max +inclusive (i.e., the mathematical range [0,\ \fbrand_max\fr]). +.pp +the +.br srand () +function sets its argument as the seed for a new +sequence of pseudo-random integers to be returned by +.br rand (). +these sequences are repeatable by calling +.br srand () +with the same seed value. +.pp +if no seed value is provided, the +.br rand () +function is automatically seeded with a value of 1. +.pp +the function +.br rand () +is not reentrant, since it +uses hidden state that is modified on each call. +this might just be the seed value to be used by the next call, +or it might be something more elaborate. +in order to get reproducible behavior in a threaded +application, this state must be made explicit; +this can be done using the reentrant function +.br rand_r (). +.pp +like +.br rand (), +.br rand_r () +returns a pseudo-random integer in the range [0,\ \fbrand_max\fr]. +the +.i seedp +argument is a pointer to an +.ir "unsigned int" +that is used to store state between calls. +if +.br rand_r () +is called with the same initial value for the integer pointed to by +.ir seedp , +and that value is not modified between calls, +then the same pseudo-random sequence will result. +.pp +the value pointed to by the +.i seedp +argument of +.br rand_r () +provides only a very small amount of state, +so this function will be a weak pseudo-random generator. +try +.br drand48_r (3) +instead. +.sh return value +the +.br rand () +and +.br rand_r () +functions return a value between 0 and +.br rand_max +(inclusive). +the +.br srand () +function returns no value. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br rand (), +.br rand_r (), +.br srand () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +the functions +.br rand () +and +.br srand () +conform to svr4, 4.3bsd, c89, c99, posix.1-2001. +the function +.br rand_r () +is from posix.1-2001. +posix.1-2008 marks +.br rand_r () +as obsolete. +.sh notes +the versions of +.br rand () +and +.br srand () +in the linux c library use the same random number generator as +.br random (3) +and +.br srandom (3), +so the lower-order bits should be as random as the higher-order bits. +however, on older +.br rand () +implementations, and on current implementations on different systems, +the lower-order bits are much less random than the higher-order bits. +do not use this function in applications intended to be portable +when good randomness is needed. +(use +.br random (3) +instead.) +.sh examples +posix.1-2001 gives the following example of an implementation of +.br rand () +and +.br srand (), +possibly useful when one needs the same sequence on two different machines. +.pp +.in +4n +.ex +static unsigned long next = 1; + +/* rand_max assumed to be 32767 */ +int myrand(void) { + next = next * 1103515245 + 12345; + return((unsigned)(next/65536) % 32768); +} + +void mysrand(unsigned int seed) { + next = seed; +} +.ee +.in +.pp +the following program can be used to display the +pseudo-random sequence produced by +.br rand () +when given a particular seed. +.pp +.in +4n +.ex +#include +#include + +int +main(int argc, char *argv[]) +{ + int r, nloops; + unsigned int seed; + + if (argc != 3) { + fprintf(stderr, "usage: %s \en", argv[0]); + exit(exit_failure); + } + + seed = atoi(argv[1]); + nloops = atoi(argv[2]); + + srand(seed); + for (int j = 0; j < nloops; j++) { + r = rand(); + printf("%d\en", r); + } + + exit(exit_success); +} +.ee +.in +.sh see also +.br drand48 (3), +.br random (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/tmpnam.3 + +.so man3/pthread_setschedparam.3 + +.so man3/getprotoent_r.3 + +.so man3/getopt.3 + +.so man3/inet_addr.3 + +.so man3/y0.3 + +.\" copyright (c) 2005 by michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th pthreads 7 2021-03-22 "linux" "linux programmer's manual" +.sh name +pthreads \- posix threads +.sh description +posix.1 specifies a set of interfaces (functions, header files) for +threaded programming commonly known as posix threads, or pthreads. +a single process can contain multiple threads, +all of which are executing the same program. +these threads share the same global memory (data and heap segments), +but each thread has its own stack (automatic variables). +.pp +posix.1 also requires that threads share a range of other attributes +(i.e., these attributes are process-wide rather than per-thread): +.ip \- 3 +process id +.ip \- 3 +parent process id +.ip \- 3 +process group id and session id +.ip \- 3 +controlling terminal +.ip \- 3 +user and group ids +.ip \- 3 +open file descriptors +.ip \- 3 +record locks (see +.br fcntl (2)) +.ip \- 3 +signal dispositions +.ip \- 3 +file mode creation mask +.rb ( umask (2)) +.ip \- 3 +current directory +.rb ( chdir (2)) +and +root directory +.rb ( chroot (2)) +.ip \- 3 +interval timers +.rb ( setitimer (2)) +and posix timers +.rb ( timer_create (2)) +.ip \- 3 +nice value +.rb ( setpriority (2)) +.ip \- 3 +resource limits +.rb ( setrlimit (2)) +.ip \- 3 +measurements of the consumption of cpu time +.rb ( times (2)) +and resources +.rb ( getrusage (2)) +.pp +as well as the stack, posix.1 specifies that various other +attributes are distinct for each thread, including: +.ip \- 3 +thread id (the +.i pthread_t +data type) +.ip \- 3 +signal mask +.rb ( pthread_sigmask (3)) +.ip \- 3 +the +.i errno +variable +.ip \- 3 +alternate signal stack +.rb ( sigaltstack (2)) +.ip \- 3 +real-time scheduling policy and priority +.rb ( sched (7)) +.pp +the following linux-specific features are also per-thread: +.ip \- 3 +capabilities (see +.br capabilities (7)) +.ip \- 3 +cpu affinity +.rb ( sched_setaffinity (2)) +.ss pthreads function return values +most pthreads functions return 0 on success, and an error number on failure. +the error numbers that can be returned have the same meaning as +the error numbers returned in +.i errno +by conventional system calls and c library functions. +note that the pthreads functions do not set +.ir errno . +for each of the pthreads functions that can return an error, +posix.1-2001 specifies that the function can never fail with the error +.br eintr . +.ss thread ids +each of the threads in a process has a unique thread identifier +(stored in the type +.ir pthread_t ). +this identifier is returned to the caller of +.br pthread_create (3), +and a thread can obtain its own thread identifier using +.br pthread_self (3). +.pp +thread ids are guaranteed to be unique only within a process. +(in all pthreads functions that accept a thread id as an argument, +that id by definition refers to a thread in +the same process as the caller.) +.pp +the system may reuse a thread id after a terminated thread has been joined, +or a detached thread has terminated. +posix says: "if an application attempts to use a thread id whose +lifetime has ended, the behavior is undefined." +.ss thread-safe functions +a thread-safe function is one that can be safely +(i.e., it will deliver the same results regardless of whether it is) +called from multiple threads at the same time. +.pp +posix.1-2001 and posix.1-2008 require that all functions specified +in the standard shall be thread-safe, +except for the following functions: +.pp +.in +4n +.ex +asctime() +basename() +catgets() +crypt() +ctermid() if passed a non-null argument +ctime() +dbm_clearerr() +dbm_close() +dbm_delete() +dbm_error() +dbm_fetch() +dbm_firstkey() +dbm_nextkey() +dbm_open() +dbm_store() +dirname() +dlerror() +drand48() +ecvt() [posix.1-2001 only (function removed in posix.1-2008)] +encrypt() +endgrent() +endpwent() +endutxent() +fcvt() [posix.1-2001 only (function removed in posix.1-2008)] +ftw() +gcvt() [posix.1-2001 only (function removed in posix.1-2008)] +getc_unlocked() +getchar_unlocked() +getdate() +getenv() +getgrent() +getgrgid() +getgrnam() +gethostbyaddr() [posix.1-2001 only (function removed in + posix.1-2008)] +gethostbyname() [posix.1-2001 only (function removed in + posix.1-2008)] +gethostent() +getlogin() +getnetbyaddr() +getnetbyname() +getnetent() +getopt() +getprotobyname() +getprotobynumber() +getprotoent() +getpwent() +getpwnam() +getpwuid() +getservbyname() +getservbyport() +getservent() +getutxent() +getutxid() +getutxline() +gmtime() +hcreate() +hdestroy() +hsearch() +inet_ntoa() +l64a() +lgamma() +lgammaf() +lgammal() +localeconv() +localtime() +lrand48() +mrand48() +nftw() +nl_langinfo() +ptsname() +putc_unlocked() +putchar_unlocked() +putenv() +pututxline() +rand() +readdir() +setenv() +setgrent() +setkey() +setpwent() +setutxent() +strerror() +strsignal() [added in posix.1-2008] +strtok() +system() [added in posix.1-2008] +tmpnam() if passed a non-null argument +ttyname() +unsetenv() +wcrtomb() if its final argument is null +wcsrtombs() if its final argument is null +wcstombs() +wctomb() +.ee +.in +.ss async-cancel-safe functions +an async-cancel-safe function is one that can be safely called +in an application where asynchronous cancelability is enabled (see +.br pthread_setcancelstate (3)). +.pp +only the following functions are required to be async-cancel-safe by +posix.1-2001 and posix.1-2008: +.pp +.in +4n +.ex +pthread_cancel() +pthread_setcancelstate() +pthread_setcanceltype() +.ee +.in +.ss cancellation points +posix.1 specifies that certain functions must, +and certain other functions may, be cancellation points. +if a thread is cancelable, its cancelability type is deferred, +and a cancellation request is pending for the thread, +then the thread is canceled when it calls a function +that is a cancellation point. +.pp +the following functions are required to be cancellation points by +posix.1-2001 and/or posix.1-2008: +.pp +.\" fixme +.\" document the list of all functions that are cancellation points in glibc +.in +4n +.ex +accept() +aio_suspend() +clock_nanosleep() +close() +connect() +creat() +fcntl() f_setlkw +fdatasync() +fsync() +getmsg() +getpmsg() +lockf() f_lock +mq_receive() +mq_send() +mq_timedreceive() +mq_timedsend() +msgrcv() +msgsnd() +msync() +nanosleep() +open() +openat() [added in posix.1-2008] +pause() +poll() +pread() +pselect() +pthread_cond_timedwait() +pthread_cond_wait() +pthread_join() +pthread_testcancel() +putmsg() +putpmsg() +pwrite() +read() +readv() +recv() +recvfrom() +recvmsg() +select() +sem_timedwait() +sem_wait() +send() +sendmsg() +sendto() +sigpause() [posix.1-2001 only (moves to "may" list in posix.1-2008)] +sigsuspend() +sigtimedwait() +sigwait() +sigwaitinfo() +sleep() +system() +tcdrain() +usleep() [posix.1-2001 only (function removed in posix.1-2008)] +wait() +waitid() +waitpid() +write() +writev() +.ee +.in +.pp +the following functions may be cancellation points according to +posix.1-2001 and/or posix.1-2008: +.pp +.in +4n +.ex +access() +asctime() +asctime_r() +catclose() +catgets() +catopen() +chmod() [added in posix.1-2008] +chown() [added in posix.1-2008] +closedir() +closelog() +ctermid() +ctime() +ctime_r() +dbm_close() +dbm_delete() +dbm_fetch() +dbm_nextkey() +dbm_open() +dbm_store() +dlclose() +dlopen() +dprintf() [added in posix.1-2008] +endgrent() +endhostent() +endnetent() +endprotoent() +endpwent() +endservent() +endutxent() +faccessat() [added in posix.1-2008] +fchmod() [added in posix.1-2008] +fchmodat() [added in posix.1-2008] +fchown() [added in posix.1-2008] +fchownat() [added in posix.1-2008] +fclose() +fcntl() (for any value of cmd argument) +fflush() +fgetc() +fgetpos() +fgets() +fgetwc() +fgetws() +fmtmsg() +fopen() +fpathconf() +fprintf() +fputc() +fputs() +fputwc() +fputws() +fread() +freopen() +fscanf() +fseek() +fseeko() +fsetpos() +fstat() +fstatat() [added in posix.1-2008] +ftell() +ftello() +ftw() +futimens() [added in posix.1-2008] +fwprintf() +fwrite() +fwscanf() +getaddrinfo() +getc() +getc_unlocked() +getchar() +getchar_unlocked() +getcwd() +getdate() +getdelim() [added in posix.1-2008] +getgrent() +getgrgid() +getgrgid_r() +getgrnam() +getgrnam_r() +gethostbyaddr() [posix.1-2001 only (function removed in + posix.1-2008)] +gethostbyname() [posix.1-2001 only (function removed in + posix.1-2008)] +gethostent() +gethostid() +gethostname() +getline() [added in posix.1-2008] +getlogin() +getlogin_r() +getnameinfo() +getnetbyaddr() +getnetbyname() +getnetent() +getopt() (if opterr is nonzero) +getprotobyname() +getprotobynumber() +getprotoent() +getpwent() +getpwnam() +getpwnam_r() +getpwuid() +getpwuid_r() +gets() +getservbyname() +getservbyport() +getservent() +getutxent() +getutxid() +getutxline() +getwc() +getwchar() +getwd() [posix.1-2001 only (function removed in posix.1-2008)] +glob() +iconv_close() +iconv_open() +ioctl() +link() +linkat() [added in posix.1-2008] +lio_listio() [added in posix.1-2008] +localtime() +localtime_r() +lockf() [added in posix.1-2008] +lseek() +lstat() +mkdir() [added in posix.1-2008] +mkdirat() [added in posix.1-2008] +mkdtemp() [added in posix.1-2008] +mkfifo() [added in posix.1-2008] +mkfifoat() [added in posix.1-2008] +mknod() [added in posix.1-2008] +mknodat() [added in posix.1-2008] +mkstemp() +mktime() +nftw() +opendir() +openlog() +pathconf() +pclose() +perror() +popen() +posix_fadvise() +posix_fallocate() +posix_madvise() +posix_openpt() +posix_spawn() +posix_spawnp() +posix_trace_clear() +posix_trace_close() +posix_trace_create() +posix_trace_create_withlog() +posix_trace_eventtypelist_getnext_id() +posix_trace_eventtypelist_rewind() +posix_trace_flush() +posix_trace_get_attr() +posix_trace_get_filter() +posix_trace_get_status() +posix_trace_getnext_event() +posix_trace_open() +posix_trace_rewind() +posix_trace_set_filter() +posix_trace_shutdown() +posix_trace_timedgetnext_event() +posix_typed_mem_open() +printf() +psiginfo() [added in posix.1-2008] +psignal() [added in posix.1-2008] +pthread_rwlock_rdlock() +pthread_rwlock_timedrdlock() +pthread_rwlock_timedwrlock() +pthread_rwlock_wrlock() +putc() +putc_unlocked() +putchar() +putchar_unlocked() +puts() +pututxline() +putwc() +putwchar() +readdir() +readdir_r() +readlink() [added in posix.1-2008] +readlinkat() [added in posix.1-2008] +remove() +rename() +renameat() [added in posix.1-2008] +rewind() +rewinddir() +scandir() [added in posix.1-2008] +scanf() +seekdir() +semop() +setgrent() +sethostent() +setnetent() +setprotoent() +setpwent() +setservent() +setutxent() +sigpause() [added in posix.1-2008] +stat() +strerror() +strerror_r() +strftime() +symlink() +symlinkat() [added in posix.1-2008] +sync() +syslog() +tmpfile() +tmpnam() +ttyname() +ttyname_r() +tzset() +ungetc() +ungetwc() +unlink() +unlinkat() [added in posix.1-2008] +utime() [added in posix.1-2008] +utimensat() [added in posix.1-2008] +utimes() [added in posix.1-2008] +vdprintf() [added in posix.1-2008] +vfprintf() +vfwprintf() +vprintf() +vwprintf() +wcsftime() +wordexp() +wprintf() +wscanf() +.ee +.in +.pp +an implementation may also mark other functions +not specified in the standard as cancellation points. +in particular, an implementation is likely to mark +any nonstandard function that may block as a cancellation point. +(this includes most functions that can touch files.) +.pp +it should be noted that even if an application is not using +asynchronous cancellation, that calling a function from the above list +from an asynchronous signal handler may cause the equivalent of +asynchronous cancellation. +the underlying user code may not expect +asynchronous cancellation and the state of the user data may become +inconsistent. +therefore signals should be used with caution when +entering a region of deferred cancellation. +.\" so, scanning "cancellation point" comments in the glibc 2.8 header +.\" files, it looks as though at least the following nonstandard +.\" functions are cancellation points: +.\" endnetgrent +.\" endspent +.\" epoll_pwait +.\" epoll_wait +.\" fcloseall +.\" fdopendir +.\" fflush_unlocked +.\" fgetc_unlocked +.\" fgetgrent +.\" fgetgrent_r +.\" fgetpwent +.\" fgetpwent_r +.\" fgets_unlocked +.\" fgetspent +.\" fgetspent_r +.\" fgetwc_unlocked +.\" fgetws_unlocked +.\" fputc_unlocked +.\" fputs_unlocked +.\" fputwc_unlocked +.\" fputws_unlocked +.\" fread_unlocked +.\" fwrite_unlocked +.\" gai_suspend +.\" getaddrinfo_a +.\" getdate_r +.\" getgrent_r +.\" getgrouplist +.\" gethostbyaddr_r +.\" gethostbyname2 +.\" gethostbyname2_r +.\" gethostbyname_r +.\" gethostent_r +.\" getnetbyaddr_r +.\" getnetbyname_r +.\" getnetent_r +.\" getnetgrent +.\" getnetgrent_r +.\" getprotobyname_r +.\" getprotobynumber_r +.\" getprotoent_r +.\" getpw +.\" getpwent_r +.\" getservbyname_r +.\" getservbyport_r +.\" getservent_r +.\" getspent +.\" getspent_r +.\" getspnam +.\" getspnam_r +.\" getutmp +.\" getutmpx +.\" getw +.\" getwc_unlocked +.\" getwchar_unlocked +.\" initgroups +.\" innetgr +.\" mkostemp +.\" mkostemp64 +.\" mkstemp64 +.\" ppoll +.\" pthread_timedjoin_np +.\" putgrent +.\" putpwent +.\" putspent +.\" putw +.\" putwc_unlocked +.\" putwchar_unlocked +.\" rcmd +.\" rcmd_af +.\" rexec +.\" rexec_af +.\" rresvport +.\" rresvport_af +.\" ruserok +.\" ruserok_af +.\" setnetgrent +.\" setspent +.\" sgetspent +.\" sgetspent_r +.\" updwtmpx +.\" utmpxname +.\" vfscanf +.\" vfwscanf +.\" vscanf +.\" vsyslog +.\" vwscanf +.ss compiling on linux +on linux, programs that use the pthreads api should be compiled using +.ir "cc \-pthread" . +.ss linux implementations of posix threads +over time, two threading implementations have been provided by +the gnu c library on linux: +.tp +.b linuxthreads +this is the original pthreads implementation. +since glibc 2.4, this implementation is no longer supported. +.tp +.br nptl " (native posix threads library)" +this is the modern pthreads implementation. +by comparison with linuxthreads, nptl provides closer conformance to +the requirements of the posix.1 specification and better performance +when creating large numbers of threads. +nptl is available since glibc 2.3.2, +and requires features that are present in the linux 2.6 kernel. +.pp +both of these are so-called 1:1 implementations, meaning that each +thread maps to a kernel scheduling entity. +both threading implementations employ the linux +.br clone (2) +system call. +in nptl, thread synchronization primitives (mutexes, +thread joining, and so on) are implemented using the linux +.br futex (2) +system call. +.ss linuxthreads +the notable features of this implementation are the following: +.ip \- 3 +in addition to the main (initial) thread, +and the threads that the program creates using +.br pthread_create (3), +the implementation creates a "manager" thread. +this thread handles thread creation and termination. +(problems can result if this thread is inadvertently killed.) +.ip \- 3 +signals are used internally by the implementation. +on linux 2.2 and later, the first three real-time signals are used +(see also +.br signal (7)). +on older linux kernels, +.b sigusr1 +and +.b sigusr2 +are used. +applications must avoid the use of whichever set of signals is +employed by the implementation. +.ip \- 3 +threads do not share process ids. +(in effect, linuxthreads threads are implemented as processes which share +more information than usual, but which do not share a common process id.) +linuxthreads threads (including the manager thread) +are visible as separate processes using +.br ps (1). +.pp +the linuxthreads implementation deviates from the posix.1 +specification in a number of ways, including the following: +.ip \- 3 +calls to +.br getpid (2) +return a different value in each thread. +.ip \- 3 +calls to +.br getppid (2) +in threads other than the main thread return the process id of the +manager thread; instead +.br getppid (2) +in these threads should return the same value as +.br getppid (2) +in the main thread. +.ip \- 3 +when one thread creates a new child process using +.br fork (2), +any thread should be able to +.br wait (2) +on the child. +however, the implementation allows only the thread that +created the child to +.br wait (2) +on it. +.ip \- 3 +when a thread calls +.br execve (2), +all other threads are terminated (as required by posix.1). +however, the resulting process has the same pid as the thread that called +.br execve (2): +it should have the same pid as the main thread. +.ip \- 3 +threads do not share user and group ids. +this can cause complications with set-user-id programs and +can cause failures in pthreads functions if an application +changes its credentials using +.br seteuid (2) +or similar. +.ip \- 3 +threads do not share a common session id and process group id. +.ip \- 3 +threads do not share record locks created using +.br fcntl (2). +.ip \- 3 +the information returned by +.br times (2) +and +.br getrusage (2) +is per-thread rather than process-wide. +.ip \- 3 +threads do not share semaphore undo values (see +.br semop (2)). +.ip \- 3 +threads do not share interval timers. +.ip \- 3 +threads do not share a common nice value. +.ip \- 3 +posix.1 distinguishes the notions of signals that are directed +to the process as a whole and signals that are directed to individual +threads. +according to posix.1, a process-directed signal (sent using +.br kill (2), +for example) should be handled by a single, +arbitrarily selected thread within the process. +linuxthreads does not support the notion of process-directed signals: +signals may be sent only to specific threads. +.ip \- 3 +threads have distinct alternate signal stack settings. +however, a new thread's alternate signal stack settings +are copied from the thread that created it, so that +the threads initially share an alternate signal stack. +(a new thread should start with no alternate signal stack defined. +if two threads handle signals on their shared alternate signal +stack at the same time, unpredictable program failures are +likely to occur.) +.ss nptl +with nptl, all of the threads in a process are placed +in the same thread group; +all members of a thread group share the same pid. +nptl does not employ a manager thread. +.pp +nptl makes internal use of the first two real-time signals; +these signals cannot be used in applications. +see +.br nptl (7) +for further details. +.pp +nptl still has at least one nonconformance with posix.1: +.ip \- 3 +threads do not share a common nice value. +.\" fixme . bug report filed for nptl nice nonconformance +.\" http://bugzilla.kernel.org/show_bug.cgi?id=6258 +.\" sep 08: there is a patch by denys vlasenko to address this +.\" "make setpriority posix compliant; introduce prio_thread extension" +.\" monitor this to see if it makes it into mainline. +.pp +some nptl nonconformances occur only with older kernels: +.ip \- 3 +the information returned by +.br times (2) +and +.br getrusage (2) +is per-thread rather than process-wide (fixed in kernel 2.6.9). +.ip \- 3 +threads do not share resource limits (fixed in kernel 2.6.10). +.ip \- 3 +threads do not share interval timers (fixed in kernel 2.6.12). +.ip \- 3 +only the main thread is permitted to start a new session using +.br setsid (2) +(fixed in kernel 2.6.16). +.ip \- 3 +only the main thread is permitted to make the process into a +process group leader using +.br setpgid (2) +(fixed in kernel 2.6.16). +.ip \- 3 +threads have distinct alternate signal stack settings. +however, a new thread's alternate signal stack settings +are copied from the thread that created it, so that +the threads initially share an alternate signal stack +(fixed in kernel 2.6.16). +.pp +note the following further points about the nptl implementation: +.ip \- 3 +if the stack size soft resource limit (see the description of +.b rlimit_stack +in +.br setrlimit (2)) +is set to a value other than +.ir unlimited , +then this value defines the default stack size for new threads. +to be effective, this limit must be set before the program +is executed, perhaps using the +.i ulimit \-s +shell built-in command +.ri ( "limit stacksize" +in the c shell). +.ss determining the threading implementation +since glibc 2.3.2, the +.br getconf (1) +command can be used to determine +the system's threading implementation, for example: +.pp +.in +4n +.ex +bash$ getconf gnu_libpthread_version +nptl 2.3.4 +.ee +.in +.pp +with older glibc versions, a command such as the following should +be sufficient to determine the default threading implementation: +.pp +.in +4n +.ex +bash$ $( ldd /bin/ls | grep libc.so | awk \(aq{print $3}\(aq ) | \e + egrep \-i \(aqthreads|nptl\(aq + native posix threads library by ulrich drepper et al +.ee +.in +.ss selecting the threading implementation: ld_assume_kernel +on systems with a glibc that supports both linuxthreads and nptl +(i.e., glibc 2.3.\fix\fp), the +.b ld_assume_kernel +environment variable can be used to override +the dynamic linker's default choice of threading implementation. +this variable tells the dynamic linker to assume that it is +running on top of a particular kernel version. +by specifying a kernel version that does not +provide the support required by nptl, we can force the use +of linuxthreads. +(the most likely reason for doing this is to run a +(broken) application that depends on some nonconformant behavior +in linuxthreads.) +for example: +.pp +.in +4n +.ex +bash$ $( ld_assume_kernel=2.2.5 ldd /bin/ls | grep libc.so | \e + awk \(aq{print $3}\(aq ) | egrep \-i \(aqthreads|nptl\(aq + linuxthreads\-0.10 by xavier leroy +.ee +.in +.sh see also +.ad l +.nh +.br clone (2), +.br fork (2), +.br futex (2), +.br gettid (2), +.br proc (5), +.br attributes (7), +.br futex (7), +.br nptl (7), +.br sigevent (7), +.br signal (7) +.pp +various pthreads manual pages, for example: +.br pthread_atfork (3), +.br pthread_attr_init (3), +.br pthread_cancel (3), +.br pthread_cleanup_push (3), +.br pthread_cond_signal (3), +.br pthread_cond_wait (3), +.br pthread_create (3), +.br pthread_detach (3), +.br pthread_equal (3), +.br pthread_exit (3), +.br pthread_key_create (3), +.br pthread_kill (3), +.br pthread_mutex_lock (3), +.br pthread_mutex_unlock (3), +.br pthread_mutexattr_destroy (3), +.br pthread_mutexattr_init (3), +.br pthread_once (3), +.br pthread_spin_init (3), +.br pthread_spin_lock (3), +.br pthread_rwlockattr_setkind_np (3), +.br pthread_setcancelstate (3), +.br pthread_setcanceltype (3), +.br pthread_setspecific (3), +.br pthread_sigmask (3), +.br pthread_sigqueue (3), +and +.br pthread_testcancel (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2006 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th mq_notify 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +mq_notify \- register for notification when a message is available +.sh synopsis +.nf +.b #include +.pp +.bi "int mq_notify(mqd_t " mqdes ", const struct sigevent *" sevp ); +.fi +.pp +link with \fi\-lrt\fp. +.sh description +.br mq_notify () +allows the calling process to register or unregister for delivery of +an asynchronous notification when a new message arrives on +the empty message queue referred to by the message queue descriptor +.ir mqdes . +.pp +the +.i sevp +argument is a pointer to a +.i sigevent +structure. +for the definition and general details of this structure, see +.br sigevent (7). +.pp +if +.i sevp +is a non-null pointer, then +.br mq_notify () +registers the calling process to receive message notification. +the +.i sigev_notify +field of the +.i sigevent +structure to which +.i sevp +points specifies how notification is to be performed. +this field has one of the following values: +.tp +.b sigev_none +a "null" notification: the calling process is registered as the target +for notification, but when a message arrives, no notification is sent. +.\" when is sigev_none useful? +.tp +.b sigev_signal +notify the process by sending the signal specified in +.ir sigev_signo . +see +.br sigevent (7) +for general details. +the +.i si_code +field of the +.i siginfo_t +structure will be set to +.br si_mesgq . +in addition, +.\" i don't know of other implementations that set +.\" si_pid and si_uid -- mtk +.i si_pid +will be set to the pid of the process that sent the message, and +.i si_uid +will be set to the real user id of the sending process. +.tp +.b sigev_thread +upon message delivery, invoke +.i sigev_notify_function +as if it were the start function of a new thread. +see +.br sigevent (7) +for details. +.pp +only one process can be registered to receive notification +from a message queue. +.pp +if +.i sevp +is null, and the calling process is currently registered to receive +notifications for this message queue, then the registration is removed; +another process can then register to receive a message notification +for this queue. +.pp +message notification occurs only when a new message arrives and +the queue was previously empty. +if the queue was not empty at the time +.br mq_notify () +was called, then a notification will occur only after +the queue is emptied and a new message arrives. +.pp +if another process or thread is waiting to read a message +from an empty queue using +.br mq_receive (3), +then any message notification registration is ignored: +the message is delivered to the process or thread calling +.br mq_receive (3), +and the message notification registration remains in effect. +.pp +notification occurs once: after a notification is delivered, +the notification registration is removed, +and another process can register for message notification. +if the notified process wishes to receive the next notification, +it can use +.br mq_notify () +to request a further notification. +this should be done before emptying all unread messages from the queue. +(placing the queue in nonblocking mode is useful for emptying +the queue of messages without blocking once it is empty.) +.sh return value +on success +.br mq_notify () +returns 0; on error, \-1 is returned, with +.i errno +set to indicate the error. +.sh errors +.tp +.b ebadf +the message queue descriptor specified in +.i mqdes +is invalid. +.tp +.b ebusy +another process has already registered to receive notification +for this message queue. +.tp +.b einval +.i sevp\->sigev_notify +is not one of the permitted values; or +.i sevp\->sigev_notify +is +.b sigev_signal +and +.i sevp\->sigev_signo +is not a valid signal number. +.tp +.b enomem +insufficient memory. +.pp +posix.1-2008 says that an implementation +.i may +generate an +.b einval +.\" linux does not do this +error if +.i sevp +is null, and the caller is not currently registered to receive +notifications for the queue +.ir mqdes . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br mq_notify () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001. +.sh notes +.\" +.ss c library/kernel differences +in the glibc implementation, the +.br mq_notify () +library function is implemented on top of the system call of the same name. +when +.i sevp +is null, or specifies a notification mechanism other than +.br sigev_thread , +the library function directly invokes the system call. +for +.br sigev_thread , +much of the implementation resides within the library, +rather than the kernel. +(this is necessarily so, +since the thread involved in handling the notification is one +that must be managed by the c library posix threads implementation.) +the implementation involves the use of a raw +.br netlink (7) +socket and creates a new thread for each notification that is +delivered to the process. +.sh examples +the following program registers a notification request for the +message queue named in its command-line argument. +notification is performed by creating a thread. +the thread executes a function which reads one message from the +queue and then terminates the process. +.ss program source +.ex +#include +#include +#include +#include +#include + +#define handle_error(msg) \e + do { perror(msg); exit(exit_failure); } while (0) + +static void /* thread start function */ +tfunc(union sigval sv) +{ + struct mq_attr attr; + ssize_t nr; + void *buf; + mqd_t mqdes = *((mqd_t *) sv.sival_ptr); + + /* determine max. msg size; allocate buffer to receive msg */ + + if (mq_getattr(mqdes, &attr) == \-1) + handle_error("mq_getattr"); + buf = malloc(attr.mq_msgsize); + if (buf == null) + handle_error("malloc"); + + nr = mq_receive(mqdes, buf, attr.mq_msgsize, null); + if (nr == \-1) + handle_error("mq_receive"); + + printf("read %zd bytes from mq\en", nr); + free(buf); + exit(exit_success); /* terminate the process */ +} + +int +main(int argc, char *argv[]) +{ + mqd_t mqdes; + struct sigevent sev; + + if (argc != 2) { + fprintf(stderr, "usage: %s \en", argv[0]); + exit(exit_failure); + } + + mqdes = mq_open(argv[1], o_rdonly); + if (mqdes == (mqd_t) \-1) + handle_error("mq_open"); + + sev.sigev_notify = sigev_thread; + sev.sigev_notify_function = tfunc; + sev.sigev_notify_attributes = null; + sev.sigev_value.sival_ptr = &mqdes; /* arg. to thread func. */ + if (mq_notify(mqdes, &sev) == \-1) + handle_error("mq_notify"); + + pause(); /* process will be terminated by thread function */ +} +.ee +.sh see also +.br mq_close (3), +.br mq_getattr (3), +.br mq_open (3), +.br mq_receive (3), +.br mq_send (3), +.br mq_unlink (3), +.br mq_overview (7), +.br sigevent (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/log2.3 + +.\" extended attributes manual page +.\" +.\" copyright (c) 2000, 2002, 2007 andreas gruenbacher +.\" copyright (c) 2001, 2002, 2004, 2007 silicon graphics, inc. +.\" all rights reserved. +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual. if not, see +.\" . +.\" %%%license_end +.\" +.th xattr 7 2020-06-09 "linux" "linux programmer's manual" +.sh name +xattr \- extended attributes +.sh description +extended attributes are name:value pairs associated permanently with +files and directories, similar to the environment strings associated +with a process. +an attribute may be defined or undefined. +if it is defined, its value may be empty or non-empty. +.pp +extended attributes are extensions to the normal attributes which are +associated with all inodes in the system (i.e., the +.br stat (2) +data). +they are often used to provide additional functionality +to a filesystem\(emfor example, additional security features such as +access control lists (acls) may be implemented using extended attributes. +.pp +users with search access to a file or directory may use +.br listxattr (2) +to retrieve a list of attribute names defined for that file or directory. +.pp +extended attributes are accessed as atomic objects. +reading +.rb ( getxattr (2)) +retrieves the whole value of an attribute and stores it in a buffer. +writing +.rb ( setxattr (2)) +replaces any previous value with the new value. +.pp +space consumed for extended attributes may be counted towards the disk quotas +of the file owner and file group. +.ss extended attribute namespaces +attribute names are null-terminated strings. +the attribute name is always specified in the fully qualified +.ir namespace.attribute +form, for example, +.ir user.mime_type , +.ir trusted.md5sum , +.ir system.posix_acl_access , +or +.ir security.selinux . +.pp +the namespace mechanism is used to define different classes of extended +attributes. +these different classes exist for several reasons; +for example, the permissions +and capabilities required for manipulating extended attributes of one +namespace may differ to another. +.pp +currently, the +.ir security , +.ir system , +.ir trusted , +and +.ir user +extended attribute classes are defined as described below. +additional classes may be added in the future. +.ss extended security attributes +the security attribute namespace is used by kernel security modules, +such as security enhanced linux, and also to implement file capabilities (see +.br capabilities (7)). +read and write access permissions to security attributes depend on the +policy implemented for each security attribute by the security module. +when no security module is loaded, all processes have read access to +extended security attributes, and write access is limited to processes +that have the +.b cap_sys_admin +capability. +.ss system extended attributes +system extended attributes are used by the kernel to store system +objects such as access control lists. +read and write +access permissions to system attributes depend on the policy implemented +for each system attribute implemented by filesystems in the kernel. +.ss trusted extended attributes +trusted extended attributes are visible and accessible only to processes that +have the +.b cap_sys_admin +capability. +attributes in this class are used to implement mechanisms in user +space (i.e., outside the kernel) which keep information in extended attributes +to which ordinary processes should not have access. +.ss user extended attributes +user extended attributes may be assigned to files and directories for +storing arbitrary additional information such as the mime type, +character set or encoding of a file. +the access permissions for user +attributes are defined by the file permission bits: +read permission is required to retrieve the attribute value, +and writer permission is required to change it. +.pp +the file permission bits of regular files and directories are +interpreted differently from the file permission bits of special files +and symbolic links. +for regular files and directories the file +permission bits define access to the file's contents, while for device special +files they define access to the device described by the special file. +the file permissions of symbolic links are not used in access checks. +these differences would allow users to consume filesystem resources in +a way not controllable by disk quotas for group or world writable +special files and directories. +.pp +for this reason, +user extended attributes are allowed only for regular files and directories, +and access to user extended attributes is restricted to the +owner and to users with appropriate capabilities for directories with the +sticky bit set (see the +.br chmod (1) +manual page for an explanation of the sticky bit). +.ss filesystem differences +the kernel and the filesystem may place limits on the maximum number +and size of extended attributes that can be associated with a file. +the vfs imposes limitations that an attribute names is limited to 255 bytes +and an attribute value is limited to 64\ kb. +the list of attribute names that +can be returned is also limited to 64\ kb +(see bugs in +.br listxattr (2)). +.pp +some filesystems, such as reiserfs (and, historically, ext2 and ext3), +require the filesystem to be mounted with the +.b user_xattr +mount option in order for user extended attributes to be used. +.pp +in the current ext2, ext3, and ext4 filesystem implementations, +the total bytes used by the names and values of all of a file's +extended attributes must fit in a single filesystem block (1024, 2048 +or 4096 bytes, depending on the block size specified when the +filesystem was created). +.pp +in the btrfs, xfs, and reiserfs filesystem implementations, there is no +practical limit on the number of extended attributes +associated with a file, and the algorithms used to store extended +attribute information on disk are scalable. +.pp +in the jfs, xfs, and reiserfs filesystem implementations, +the limit on bytes used in an ea value is the ceiling imposed by the vfs. +.pp +in the btrfs filesystem implementation, +the total bytes used for the name, value, and implementation overhead bytes +is limited to the filesystem +.i nodesize +value (16\ kb by default). +.sh conforming to +extended attributes are not specified in posix.1, but some other systems +(e.g., the bsds and solaris) provide a similar feature. +.sh notes +since the filesystems on which extended attributes are stored might also +be used on architectures with a different byte order and machine word +size, care should be taken to store attribute values in an +architecture-independent format. +.pp +this page was formerly named +.br attr (5). +.\" .sh authors +.\" andreas gruenbacher, +.\" .ri < a.gruenbacher@bestbits.at > +.\" and the sgi xfs development team, +.\" .ri < linux-xfs@oss.sgi.com >. +.sh see also +.br attr (1), +.br getfattr (1), +.br setfattr (1), +.br getxattr (2), +.br ioctl_iflags (2), +.br listxattr (2), +.br removexattr (2), +.br setxattr (2), +.br acl (5), +.br capabilities (7), +.br selinux (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1993 by thomas koenig (ig25@rz.uni-karlsruhe.de) +.\" and copyright (c) 2014 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified sat jul 24 17:28:34 1993 by rik faith +.\" modified sun jun 01 17:16:34 1997 by jochen hein +.\" +.\" modified thu apr 25 00:43:19 2002 by bruno haible +.\" +.th locale 7 2021-03-22 "linux" "linux programmer's manual" +.sh name +locale \- description of multilanguage support +.sh synopsis +.nf +.b #include +.fi +.sh description +a locale is a set of language and cultural rules. +these cover aspects +such as language for messages, different character sets, lexicographic +conventions, and so on. +a program needs to be able to determine its locale +and act accordingly to be portable to different cultures. +.pp +the header +.i +declares data types, functions, and macros which are useful in this +task. +.pp +the functions it declares are +.br setlocale (3) +to set the current locale, and +.br localeconv (3) +to get information about number formatting. +.pp +there are different categories for locale information a program might +need; they are declared as macros. +using them as the first argument +to the +.br setlocale (3) +function, it is possible to set one of these to the desired locale: +.tp +.br lc_address " (gnu extension, since glibc 2.2)" +.\" see iso/iec technical report 14652 +change settings that describe the formats (e.g., postal addresses) +used to describe locations and geography-related items. +applications that need this information can use +.br nl_langinfo (3) +to retrieve nonstandard elements, such as +.b _nl_address_country_name +(country name, in the language of the locale) +and +.b _nl_address_lang_name +(language name, in the language of the locale), +which return strings such as "deutschland" and "deutsch" +(for german-language locales). +(other element names are listed in +.ir .) +.tp +.b lc_collate +this category governs the collation rules used for +sorting and regular expressions, +including character equivalence classes and +multicharacter collating elements. +this locale category changes the behavior of the functions +.br strcoll (3) +and +.br strxfrm (3), +which are used to compare strings in the local alphabet. +for example, +the german sharp s is sorted as "ss". +.tp +.b lc_ctype +this category determines the interpretation of byte sequences as characters +(e.g., single versus multibyte characters), character classifications +(e.g., alphabetic or digit), and the behavior of character classes. +on glibc systems, this category also determines +the character transliteration rules for +.br iconv (1) +and +.br iconv (3). +it changes the behavior of the character handling and +classification functions, such as +.br isupper (3) +and +.br toupper (3), +and the multibyte character functions such as +.br mblen (3) +or +.br wctomb (3). +.tp +.br lc_identification " (gnu extension, since glibc 2.2)" +.\" see iso/iec technical report 14652 +change settings that relate to the metadata for the locale. +applications that need this information can use +.br nl_langinfo (3) +to retrieve nonstandard elements, such as +.b _nl_identification_title +(title of this locale document) +and +.b _nl_identification_territory +(geographical territory to which this locale document applies), +which might return strings such as "english locale for the usa" +and "usa". +(other element names are listed in +.ir .) +.tp +.b lc_monetary +this category determines the formatting used for +monetary-related numeric values. +this changes the information returned by +.br localeconv (3), +which describes the way numbers are usually printed, with details such +as decimal point versus decimal comma. +this information is internally +used by the function +.br strfmon (3). +.tp +.b lc_messages +this category affects the language in which messages are displayed +and what an affirmative or negative answer looks like. +the gnu c library contains the +.br gettext (3), +.br ngettext (3), +and +.br rpmatch (3) +functions to ease the use of this information. +the gnu gettext family of +functions also obey the environment variable +.br language +(containing a colon-separated list of locales) +if the category is set to a valid locale other than +.br """c""" . +this category also affects the behavior of +.br catopen (3). +.tp +.br lc_measurement " (gnu extension, since glibc 2.2)" +change the settings relating to the measurement system in the locale +(i.e., metric versus us customary units). +applications can use +.br nl_langinfo (3) +to retrieve the nonstandard +.b _nl_measurement_measurement +element, which returns a pointer to a character +that has the value 1 (metric) or 2 (us customary units). +.tp +.br lc_name " (gnu extension, since glibc 2.2)" +.\" see iso/iec technical report 14652 +change settings that describe the formats used to address persons. +applications that need this information can use +.br nl_langinfo (3) +to retrieve nonstandard elements, such as +.b _nl_name_name_mr +(general salutation for men) +and +.b _nl_name_name_ms +(general salutation for women) +elements, which return strings such as "herr" and "frau" +(for german-language locales). +(other element names are listed in +.ir .) +.tp +.b lc_numeric +this category determines the formatting rules used for nonmonetary +numeric values\(emfor example, +the thousands separator and the radix character +(a period in most english-speaking countries, +but a comma in many other regions). +it affects functions such as +.br printf (3), +.br scanf (3), +and +.br strtod (3). +this information can also be read with the +.br localeconv (3) +function. +.tp +.br lc_paper " (gnu extension, since glibc 2.2)" +.\" see iso/iec technical report 14652 +change the settings relating to the dimensions of the standard paper size +(e.g., us letter versus a4). +applications that need the dimensions can obtain them by using +.br nl_langinfo (3) +to retrieve the nonstandard +.b _nl_paper_width +and +.b _nl_paper_height +elements, which return +.i int +values specifying the dimensions in millimeters. +.tp +.br lc_telephone " (gnu extension, since glibc 2.2)" +.\" see iso/iec technical report 14652 +change settings that describe the formats to be used with telephone services. +applications that need this information can use +.br nl_langinfo (3) +to retrieve nonstandard elements, such as +.b _nl_telephone_int_prefix +(international prefix used to call numbers in this locale), +which returns a string such as "49" (for germany). +(other element names are listed in +.ir .) +.tp +.b lc_time +this category governs the formatting used for date and time values. +for example, most of europe uses a 24-hour clock versus the +12-hour clock used in the united states. +the setting of this category affects the behavior of functions such as +.br strftime (3) +and +.br strptime (3). +.tp +.b lc_all +all of the above. +.pp +if the second argument to +.br setlocale (3) +is an empty string, +.ir """""" , +for the default locale, it is determined using the following steps: +.ip 1. 3 +if there is a non-null environment variable +.br lc_all , +the value of +.b lc_all +is used. +.ip 2. +if an environment variable with the same name as one of the categories +above exists and is non-null, its value is used for that category. +.ip 3. +if there is a non-null environment variable +.br lang , +the value of +.b lang +is used. +.pp +values about local numeric formatting is made available in a +.i struct lconv +returned by the +.br localeconv (3) +function, which has the following declaration: +.pp +.in +4n +.ex +struct lconv { + + /* numeric (nonmonetary) information */ + + char *decimal_point; /* radix character */ + char *thousands_sep; /* separator for digit groups to left + of radix character */ + char *grouping; /* each element is the number of digits in + a group; elements with higher indices + are further left. an element with value + char_max means that no further grouping + is done. an element with value 0 means + that the previous element is used for + all groups further left. */ + + /* remaining fields are for monetary information */ + + char *int_curr_symbol; /* first three chars are a currency + symbol from iso 4217. fourth char + is the separator. fifth char + is \(aq\e0\(aq. */ + char *currency_symbol; /* local currency symbol */ + char *mon_decimal_point; /* radix character */ + char *mon_thousands_sep; /* like \fithousands_sep\fp above */ + char *mon_grouping; /* like \figrouping\fp above */ + char *positive_sign; /* sign for positive values */ + char *negative_sign; /* sign for negative values */ + char int_frac_digits; /* international fractional digits */ + char frac_digits; /* local fractional digits */ + char p_cs_precedes; /* 1 if currency_symbol precedes a + positive value, 0 if succeeds */ + char p_sep_by_space; /* 1 if a space separates + currency_symbol from a positive + value */ + char n_cs_precedes; /* 1 if currency_symbol precedes a + negative value, 0 if succeeds */ + char n_sep_by_space; /* 1 if a space separates + currency_symbol from a negative + value */ + /* positive and negative sign positions: + 0 parentheses surround the quantity and currency_symbol. + 1 the sign string precedes the quantity and currency_symbol. + 2 the sign string succeeds the quantity and currency_symbol. + 3 the sign string immediately precedes the currency_symbol. + 4 the sign string immediately succeeds the currency_symbol. */ + char p_sign_posn; + char n_sign_posn; +}; +.ee +.in +.ss posix.1-2008 extensions to the locale api +posix.1-2008 standardized a number of extensions to the locale api, +based on implementations that first appeared in version 2.3 +of the gnu c library. +these extensions are designed to address the problem that +the traditional locale apis do not mix well with multithreaded applications +and with applications that must deal with multiple locales. +.pp +the extensions take the form of new functions for creating and +manipulating locale objects +.rb ( newlocale (3), +.br freelocale (3), +.br duplocale (3), +and +.br uselocale (3)) +and various new library functions with the suffix "_l" (e.g., +.br toupper_l (3)) +that extend the traditional locale-dependent apis (e.g., +.br toupper (3)) +to allow the specification of a locale object that should apply when +executing the function. +.sh environment +the following environment variable is used by +.br newlocale (3) +and +.br setlocale (3), +and thus affects all unprivileged localized programs: +.tp +.b locpath +a list of pathnames, separated by colons (\(aq:\(aq), +that should be used to find locale data. +if this variable is set, +only the individual compiled locale data files from +.b locpath +and the system default locale data path are used; +any available locale archives are not used (see +.br localedef (1)). +the individual compiled locale data files are searched for under +subdirectories which depend on the currently used locale. +for example, when +.i en_gb.utf\-8 +is used for a category, the following subdirectories are searched for, +in this order: +.ir en_gb.utf\-8 , +.ir en_gb.utf8 , +.ir en_gb , +.ir en.utf\-8 , +.ir en.utf8 , +and +.ir en . +.sh files +.tp +.i /usr/lib/locale/locale\-archive +usual default locale archive location. +.tp +.i /usr/lib/locale +usual default path for compiled individual locale files. +.sh conforming to +posix.1-2001. +.\" +.\" the gnu gettext functions are specified in li18nux2000. +.sh see also +.br iconv (1), +.br locale (1), +.br localedef (1), +.br catopen (3), +.br gettext (3), +.br iconv (3), +.br localeconv (3), +.br mbstowcs (3), +.br newlocale (3), +.br ngettext (3), +.br nl_langinfo (3), +.br rpmatch (3), +.br setlocale (3), +.br strcoll (3), +.br strfmon (3), +.br strftime (3), +.br strxfrm (3), +.br uselocale (3), +.br wcstombs (3), +.br locale (5), +.br charsets (7), +.br unicode (7), +.br utf\-8 (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" rtc.4 +.\" copyright 2002 urs thuermann (urs@isnogud.escape.de) +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" $id: rtc.4,v 1.4 2005/12/05 17:19:49 urs exp $ +.\" +.\" 2006-02-08 various additions by mtk +.\" 2006-11-26 cleanup, cover the generic rtc framework; david brownell +.\" +.th rtc 4 2021-03-22 "linux" "linux programmer's manual" +.sh name +rtc \- real-time clock +.sh synopsis +.nf +#include +.pp +.bi "int ioctl(" fd ", rtc_" request ", " param ");" +.fi +.sh description +this is the interface to drivers for real-time clocks (rtcs). +.pp +most computers have one or more hardware clocks which record the +current "wall clock" time. +these are called "real time clocks" (rtcs). +one of these usually has battery backup power so that it tracks the time +even while the computer is turned off. +rtcs often provide alarms and other interrupts. +.pp +all i386 pcs, and acpi-based systems, have an rtc that is compatible with +the motorola mc146818 chip on the original pc/at. +today such an rtc is usually integrated into the mainboard's chipset +(south bridge), and uses a replaceable coin-sized backup battery. +.pp +non-pc systems, such as embedded systems built around system-on-chip +processors, use other implementations. +they usually won't offer the same functionality as the rtc from a pc/at. +.ss rtc vs system clock +rtcs should not be confused with the system clock, which is +a software clock maintained by the kernel and used to implement +.br gettimeofday (2) +and +.br time (2), +as well as setting timestamps on files, and so on. +the system clock reports seconds and microseconds since a start point, +defined to be the posix epoch: 1970-01-01 00:00:00 +0000 (utc). +(one common implementation counts timer interrupts, once +per "jiffy", at a frequency of 100, 250, or 1000 hz.) +that is, it is supposed to report wall clock time, which rtcs also do. +.pp +a key difference between an rtc and the system clock is that rtcs +run even when the system is in a low power state (including "off"), +and the system clock can't. +until it is initialized, the system clock can only report time since +system boot ... not since the posix epoch. +so at boot time, and after resuming from a system low power state, the +system clock will often be set to the current wall clock time using an rtc. +systems without an rtc need to set the system clock using another clock, +maybe across the network or by entering that data manually. +.ss rtc functionality +rtcs can be read and written with +.br hwclock (8), +or directly with the +.br ioctl (2) +requests listed below. +.pp +besides tracking the date and time, many rtcs can also generate +interrupts +.ip * 3 +on every clock update (i.e., once per second); +.ip * +at periodic intervals with a frequency that can be set to +any power-of-2 multiple in the range 2 hz to 8192 hz; +.ip * +on reaching a previously specified alarm time. +.pp +each of those interrupt sources can be enabled or disabled separately. +on many systems, the alarm interrupt can be configured as a system wakeup +event, which can resume the system from a low power state such as +suspend-to-ram (str, called s3 in acpi systems), +hibernation (called s4 in acpi systems), +or even "off" (called s5 in acpi systems). +on some systems, the battery backed rtc can't issue +interrupts, but another one can. +.pp +the +.i /dev/rtc +(or +.ir /dev/rtc0 , +.ir /dev/rtc1 , +etc.) +device can be opened only once (until it is closed) and it is read-only. +on +.br read (2) +and +.br select (2) +the calling process is blocked until the next interrupt from that rtc +is received. +following the interrupt, the process can read a long integer, of which +the least significant byte contains a bit mask encoding +the types of interrupt that occurred, +while the remaining 3 bytes contain the number of interrupts since the +last +.br read (2). +.ss ioctl(2) interface +the following +.br ioctl (2) +requests are defined on file descriptors connected to rtc devices: +.tp +.b rtc_rd_time +returns this rtc's time in the following structure: +.ip +.in +4n +.ex +struct rtc_time { + int tm_sec; + int tm_min; + int tm_hour; + int tm_mday; + int tm_mon; + int tm_year; + int tm_wday; /* unused */ + int tm_yday; /* unused */ + int tm_isdst; /* unused */ +}; +.ee +.in +.ip +the fields in this structure have the same meaning and ranges as for the +.i tm +structure described in +.br gmtime (3). +a pointer to this structure should be passed as the third +.br ioctl (2) +argument. +.tp +.b rtc_set_time +sets this rtc's time to the time specified by the +.i rtc_time +structure pointed to by the third +.br ioctl (2) +argument. +to set the +rtc's time the process must be privileged (i.e., have the +.b cap_sys_time +capability). +.tp +.br rtc_alm_read ", " rtc_alm_set +read and set the alarm time, for rtcs that support alarms. +the alarm interrupt must be separately enabled or disabled using the +.br rtc_aie_on ", " rtc_aie_off +requests. +the third +.br ioctl (2) +argument is a pointer to an +.i rtc_time +structure. +only the +.ir tm_sec , +.ir tm_min , +and +.i tm_hour +fields of this structure are used. +.tp +.br rtc_irqp_read ", " rtc_irqp_set +read and set the frequency for periodic interrupts, +for rtcs that support periodic interrupts. +the periodic interrupt must be separately enabled or disabled using the +.br rtc_pie_on ", " rtc_pie_off +requests. +the third +.br ioctl (2) +argument is an +.i "unsigned long\ *" +or an +.ir "unsigned long" , +respectively. +the value is the frequency in interrupts per second. +the set of allowable frequencies is the multiples of two +in the range 2 to 8192. +only a privileged process (i.e., one having the +.b cap_sys_resource +capability) can set frequencies above the value specified in +.ir /proc/sys/dev/rtc/max\-user\-freq . +(this file contains the value 64 by default.) +.tp +.br rtc_aie_on ", " rtc_aie_off +enable or disable the alarm interrupt, for rtcs that support alarms. +the third +.br ioctl (2) +argument is ignored. +.tp +.br rtc_uie_on ", " rtc_uie_off +enable or disable the interrupt on every clock update, +for rtcs that support this once-per-second interrupt. +the third +.br ioctl (2) +argument is ignored. +.tp +.br rtc_pie_on ", " rtc_pie_off +enable or disable the periodic interrupt, +for rtcs that support these periodic interrupts. +the third +.br ioctl (2) +argument is ignored. +only a privileged process (i.e., one having the +.b cap_sys_resource +capability) can enable the periodic interrupt if the frequency is +currently set above the value specified in +.ir /proc/sys/dev/rtc/max\-user\-freq . +.tp +.br rtc_epoch_read ", " rtc_epoch_set +many rtcs encode the year in an 8-bit register which is either +interpreted as an 8-bit binary number or as a bcd number. +in both cases, +the number is interpreted relative to this rtc's epoch. +the rtc's epoch is +initialized to 1900 on most systems but on alpha and mips it might +also be initialized to 1952, 1980, or 2000, depending on the value of +an rtc register for the year. +with some rtcs, +these operations can be used to read or to set the rtc's epoch, +respectively. +the third +.br ioctl (2) +argument is an +.i "unsigned long\ *" +or an +.ir "unsigned long" , +respectively, and the value returned (or assigned) is the epoch. +to set the rtc's epoch the process must be privileged (i.e., have the +.b cap_sys_time +capability). +.tp +.br rtc_wkalm_rd ", " rtc_wkalm_set +some rtcs support a more powerful alarm interface, using these ioctls +to read or write the rtc's alarm time (respectively) with this structure: +.pp +.rs +.in +4n +.ex +struct rtc_wkalrm { + unsigned char enabled; + unsigned char pending; + struct rtc_time time; +}; +.ee +.in +.re +.ip +the +.i enabled +flag is used to enable or disable the alarm interrupt, +or to read its current status; when using these calls, +.br rtc_aie_on " and " rtc_aie_off +are not used. +the +.i pending +flag is used by +.b rtc_wkalm_rd +to report a pending interrupt +(so it's mostly useless on linux, except when talking +to the rtc managed by efi firmware). +the +.i time +field is as used with +.b rtc_alm_read +and +.b rtc_alm_set +except that the +.ir tm_mday , +.ir tm_mon , +and +.i tm_year +fields are also valid. +a pointer to this structure should be passed as the third +.br ioctl (2) +argument. +.sh files +.tp +.ir /dev/rtc ", " /dev/rtc0 ", " /dev/rtc1 ", etc." +rtc special character device files. +.tp +.ir /proc/driver/rtc +status of the (first) rtc. +.sh notes +when the kernel's system time is synchronized with an external +reference using +.br adjtimex (2) +it will update a designated rtc periodically every 11 minutes. +to do so, the kernel has to briefly turn off periodic interrupts; +this might affect programs using that rtc. +.pp +an rtc's epoch has nothing to do with the posix epoch which is +used only for the system clock. +.pp +if the year according to the rtc's epoch and the year register is +less than 1970 it is assumed to be 100 years later, that is, between 2000 +and 2069. +.pp +some rtcs support "wildcard" values in alarm fields, to support +scenarios like periodic alarms at fifteen minutes after every hour, +or on the first day of each month. +such usage is nonportable; +portable user-space code expects only a single alarm interrupt, and +will either disable or reinitialize the alarm after receiving it. +.pp +some rtcs support periodic interrupts with periods that are multiples +of a second rather than fractions of a second; +multiple alarms; +programmable output clock signals; +nonvolatile memory; +and other hardware +capabilities that are not currently exposed by this api. +.sh see also +.br date (1), +.br adjtimex (2), +.br gettimeofday (2), +.br settimeofday (2), +.br stime (2), +.br time (2), +.br gmtime (3), +.br time (7), +.br hwclock (8) +.pp +.i documentation/rtc.txt +in the linux kernel source tree +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/scalbln.3 + +.\" copyright (c) 2000 by michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" created, 14 dec 2000 by michael kerrisk +.\" +.th basename 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +basename, dirname \- parse pathname components +.sh synopsis +.nf +.b #include +.pp +.bi "char *dirname(char *" path ); +.bi "char *basename(char *" path ); +.fi +.sh description +warning: there are two different functions +.br basename (); +see below. +.pp +the functions +.br dirname () +and +.br basename () +break a null-terminated pathname string into directory +and filename components. +in the usual case, +.br dirname () +returns the string up to, but not including, the final \(aq/\(aq, and +.br basename () +returns the component following the final \(aq/\(aq. +trailing \(aq/\(aq characters are not counted as part of the pathname. +.pp +if +.i path +does not contain a slash, +.br dirname () +returns the string "." while +.br basename () +returns a copy of +.ir path . +if +.i path +is the string "/", then both +.br dirname () +and +.br basename () +return the string "/". +if +.i path +is a null pointer or points to an empty string, then both +.br dirname () +and +.br basename () +return the string ".". +.pp +concatenating the string returned by +.br dirname (), +a "/", and the string returned by +.br basename () +yields a complete pathname. +.pp +both +.br dirname () +and +.br basename () +may modify the contents of +.ir path , +so it may be desirable to pass a copy when calling one of +these functions. +.pp +these functions may return pointers to statically allocated memory +which may be overwritten by subsequent calls. +alternatively, they may return a pointer to some part of +.ir path , +so that the string referred to by +.i path +should not be modified or freed until the pointer returned by +the function is no longer required. +.pp +the following list of examples (taken from susv2) +shows the strings returned by +.br dirname () +and +.br basename () +for different paths: +.rs +.ts +lb lb lb +l l l l. +path dirname basename +/usr/lib /usr lib +/usr/ / usr +usr . usr +/ / / +\&. . . +\&.. . .. +.te +.re +.sh return value +both +.br dirname () +and +.br basename () +return pointers to null-terminated strings. +(do not pass these pointers to +.br free (3).) +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br basename (), +.br dirname () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +there are two different versions of +.br basename () +- the posix version described above, and the gnu version, which one gets +after +.pp +.in +4n +.ex +.br " #define _gnu_source" " /* see feature_test_macros(7) */" +.b " #include " +.ee +.in +.pp +the gnu version never modifies its argument, and returns the +empty string when +.i path +has a trailing slash, and in particular also when it is "/". +there is no gnu version of +.br dirname (). +.pp +with glibc, one gets the posix version of +.br basename () +when +.i +is included, and the gnu version otherwise. +.sh bugs +in the glibc implementation, +the posix versions of these functions modify the +.i path +argument, and segfault when called with a static string +such as "/usr/". +.pp +before glibc 2.2.1, the glibc version of +.br dirname () +did not correctly handle pathnames with trailing \(aq/\(aq characters, +and generated a segfault if given a null argument. +.sh examples +the following code snippet demonstrates the use of +.br basename () +and +.br dirname (): +.in +4n +.ex +char *dirc, *basec, *bname, *dname; +char *path = "/etc/passwd"; + +dirc = strdup(path); +basec = strdup(path); +dname = dirname(dirc); +bname = basename(basec); +printf("dirname=%s, basename=%s\en", dname, bname); +.ee +.in +.sh see also +.br basename (1), +.br dirname (1) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2010 by michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th aio_init 3 2020-08-13 "linux" "linux programmer's manual" +.sh name +aio_init \- asynchronous i/o initialization +.sh synopsis +.nf +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b "#include " +.pp +.bi "void aio_init(const struct aioinit *" init ); +.fi +.pp +link with \fi\-lrt\fp. +.sh description +the gnu-specific +.br aio_init () +function allows the caller to provide tuning hints to the +glibc posix aio implementation. +use of this function is optional, but to be effective, +it must be called before employing any other functions in the posix aio api. +.pp +the tuning information is provided in the buffer pointed to by the argument +.ir init . +this buffer is a structure of the following form: +.pp +.in +4n +.ex +struct aioinit { + int aio_threads; /* maximum number of threads */ + int aio_num; /* number of expected simultaneous + requests */ + int aio_locks; /* not used */ + int aio_usedba; /* not used */ + int aio_debug; /* not used */ + int aio_numusers; /* not used */ + int aio_idle_time; /* number of seconds before idle thread + terminates (since glibc 2.2) */ + int aio_reserved; +}; +.ee +.in +.pp +the following fields are used in the +.i aioinit +structure: +.tp +.i aio_threads +this field specifies the maximum number of worker threads that +may be used by the implementation. +if the number of outstanding i/o operations exceeds this limit, +then excess operations will be queued until a worker thread becomes free. +if this field is specified with a value less than 1, the value 1 is used. +the default value is 20. +.tp +.i aio_num +this field should specify the maximum number of simultaneous i/o requests +that the caller expects to enqueue. +if a value less than 32 is specified for this field, +it is rounded up to 32. +.\" fixme . but, if aio_num > 32, the behavior looks strange. see +.\" http://sourceware.org/bugzilla/show_bug.cgi?id=12083 +the default value is 64. +.tp +.i aio_idle_time +this field specifies the amount of time in seconds that a +worker thread should wait for further requests before terminating, +after having completed a previous request. +the default value is 1. +.sh versions +the +.br aio_init () +function is available since glibc 2.1. +.sh conforming to +this function is a gnu extension. +.sh see also +.br aio (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" and copyright 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's "posix programmer's guide" (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" +.\" modified 1993-07-24 by rik faith (faith@cs.unc.edu) +.\" modified 1996-05-27 by martin schulze (joey@linux.de) +.\" modified 2003-11-15 by aeb +.\" 2008-11-07, mtk, added an example program for getpwnam_r(). +.\" +.th getpwnam 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +getpwnam, getpwnam_r, getpwuid, getpwuid_r \- get password file entry +.sh synopsis +.nf +.b #include +.b #include +.pp +.bi "struct passwd *getpwnam(const char *" name ); +.bi "struct passwd *getpwuid(uid_t " uid ); +.pp +.bi "int getpwnam_r(const char *restrict " name \ +", struct passwd *restrict " pwd , +.bi " char *restrict " buf ", size_t " buflen , +.bi " struct passwd **restrict " result ); +.bi "int getpwuid_r(uid_t " uid ", struct passwd *restrict " pwd , +.bi " char *restrict " buf ", size_t " buflen , +.bi " struct passwd **restrict " result ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br getpwnam_r (), +.br getpwuid_r (): +.nf + _posix_c_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.sh description +the +.br getpwnam () +function returns a pointer to a structure containing +the broken-out fields of the record in the password database +(e.g., the local password file +.ir /etc/passwd , +nis, and ldap) +that matches the username +.ir name . +.pp +the +.br getpwuid () +function returns a pointer to a structure containing +the broken-out fields of the record in the password database +that matches the user id +.ir uid . +.pp +the \fipasswd\fp structure is defined in \fi\fp as follows: +.pp +.in +4n +.ex +struct passwd { + char *pw_name; /* username */ + char *pw_passwd; /* user password */ + uid_t pw_uid; /* user id */ + gid_t pw_gid; /* group id */ + char *pw_gecos; /* user information */ + char *pw_dir; /* home directory */ + char *pw_shell; /* shell program */ +}; +.ee +.in +.pp +see +.br passwd (5) +for more information about these fields. +.pp +the +.br getpwnam_r () +and +.br getpwuid_r () +functions obtain the same information as +.br getpwnam () +and +.br getpwuid (), +but store the retrieved +.i passwd +structure in the space pointed to by +.ir pwd . +the string fields pointed to by the members of the +.i passwd +structure are stored in the buffer +.i buf +of size +.ir buflen . +a pointer to the result (in case of success) or null (in case no entry +was found or an error occurred) is stored in +.ir *result . +.pp +the call +.pp + sysconf(_sc_getpw_r_size_max) +.pp +returns either \-1, without changing +.ir errno , +or an initial suggested size for +.ir buf . +(if this size is too small, +the call fails with +.br erange , +in which case the caller can retry with a larger buffer.) +.sh return value +the +.br getpwnam () +and +.br getpwuid () +functions return a pointer to a +.i passwd +structure, or null if the matching entry is not found or +an error occurs. +if an error occurs, +.i errno +is set to indicate the error. +if one wants to check +.i errno +after the call, it should be set to zero before the call. +.pp +the return value may point to a static area, and may be overwritten +by subsequent calls to +.br getpwent (3), +.br getpwnam (), +or +.br getpwuid (). +(do not pass the returned pointer to +.br free (3).) +.pp +on success, +.br getpwnam_r () +and +.br getpwuid_r () +return zero, and set +.ir *result +to +.ir pwd . +if no matching password record was found, +these functions return 0 and store null in +.ir *result . +in case of error, an error number is returned, and null is stored in +.ir *result . +.sh errors +.tp +.br 0 " or " enoent " or " esrch " or " ebadf " or " eperm " or ..." +the given +.i name +or +.i uid +was not found. +.tp +.b eintr +a signal was caught; see +.br signal (7). +.tp +.b eio +i/o error. +.tp +.b emfile +the per-process limit on the number of open file descriptors has been reached. +.tp +.b enfile +the system-wide limit on the total number of open files has been reached. +.tp +.b enomem +.\" not in posix +insufficient memory to allocate +.i passwd +structure. +.\" this structure is static, allocated 0 or 1 times. no memory leak. (libc45) +.tp +.b erange +insufficient buffer space supplied. +.sh files +.tp +.i /etc/passwd +local password database file +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lb lb lbx +l l l. +interface attribute value +t{ +.br getpwnam () +t} thread safety t{ +mt-unsafe race:pwnam locale +t} +t{ +.br getpwuid () +t} thread safety t{ +mt-unsafe race:pwuid locale +t} +t{ +.br getpwnam_r (), +.br getpwuid_r () +t} thread safety t{ +mt-safe locale +t} +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, svr4, 4.3bsd. +the +.i pw_gecos +field is not specified in posix, but is present on most implementations. +.sh notes +the formulation given above under "return value" is from posix.1-2001. +it does not call "not found" an error, and hence does not specify what value +.i errno +might have in this situation. +but that makes it impossible to recognize +errors. +one might argue that according to posix +.i errno +should be left unchanged if an entry is not found. +experiments on various +unix-like systems show that lots of different values occur in this +situation: 0, enoent, ebadf, esrch, ewouldblock, eperm, and probably others. +.\" more precisely: +.\" aix 5.1 - gives esrch +.\" osf1 4.0g - gives ewouldblock +.\" libc, glibc up to version 2.6, irix 6.5 - give enoent +.\" glibc since version 2.7 - give 0 +.\" freebsd 4.8, openbsd 3.2, netbsd 1.6 - give eperm +.\" sunos 5.8 - gives ebadf +.\" tru64 5.1b, hp-ux-11i, sunos 5.7 - give 0 +.pp +the +.i pw_dir +field contains the name of the initial working directory of the user. +login programs use the value of this field to initialize the +.b home +environment variable for the login shell. +an application that wants to determine its user's home directory +should inspect the value of +.b home +(rather than the value +.ir getpwuid(getuid())\->pw_dir ) +since this allows the user to modify their notion of +"the home directory" during a login session. +to determine the (initial) home directory of another user, +it is necessary to use +.i getpwnam("username")\->pw_dir +or similar. +.sh examples +the program below demonstrates the use of +.br getpwnam_r () +to find the full username and user id for the username +supplied as a command-line argument. +.pp +.ex +#include +#include +#include +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + struct passwd pwd; + struct passwd *result; + char *buf; + size_t bufsize; + int s; + + if (argc != 2) { + fprintf(stderr, "usage: %s username\en", argv[0]); + exit(exit_failure); + } + + bufsize = sysconf(_sc_getpw_r_size_max); + if (bufsize == \-1) /* value was indeterminate */ + bufsize = 16384; /* should be more than enough */ + + buf = malloc(bufsize); + if (buf == null) { + perror("malloc"); + exit(exit_failure); + } + + s = getpwnam_r(argv[1], &pwd, buf, bufsize, &result); + if (result == null) { + if (s == 0) + printf("not found\en"); + else { + errno = s; + perror("getpwnam_r"); + } + exit(exit_failure); + } + + printf("name: %s; uid: %jd\en", pwd.pw_gecos, + (intmax_t) pwd.pw_uid); + exit(exit_success); +} +.ee +.sh see also +.br endpwent (3), +.br fgetpwent (3), +.br getgrnam (3), +.br getpw (3), +.br getpwent (3), +.br getspnam (3), +.br putpwent (3), +.br setpwent (3), +.br passwd (5) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" this manpage copyright 1998 by andi kleen. +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" subject to the gpl. +.\" %%%license_end +.\" +.\" based on the original comments from alexey kuznetsov +.\" $id: netlink.3,v 1.1 1999/05/14 17:17:24 freitag exp $ +.\" +.th netlink 3 2014-03-20 "gnu" "linux programmer's manual" +.sh name +netlink \- netlink macros +.sh synopsis +.nf +.b #include +.b #include +.pp +.bi "int nlmsg_align(size_t " len ); +.bi "int nlmsg_length(size_t " len ); +.bi "int nlmsg_space(size_t " len ); +.bi "void *nlmsg_data(struct nlmsghdr *" nlh ); +.bi "struct nlmsghdr *nlmsg_next(struct nlmsghdr *" nlh ", int " len ); +.bi "int nlmsg_ok(struct nlmsghdr *" nlh ", int " len ); +.bi "int nlmsg_payload(struct nlmsghdr *" nlh ", int " len ); +.fi +.sh description +.i +defines several standard macros to access or create a netlink datagram. +they are similar in spirit to the macros defined in +.br cmsg (3) +for auxiliary data. +the buffer passed to and from a netlink socket should +be accessed using only these macros. +.tp +.br nlmsg_align () +round the length of a netlink message up to align it properly. +.tp +.br nlmsg_length () +given the payload length, +.ir len , +this macro returns the aligned length to store in the +.i nlmsg_len +field of the +.ir nlmsghdr . +.tp +.br nlmsg_space () +return the number of bytes that a netlink message with payload of +.i len +would occupy. +.tp +.br nlmsg_data () +return a pointer to the payload associated with the passed +.ir nlmsghdr . +.tp +.\" this is bizarre, maybe the interface should be fixed. +.br nlmsg_next () +get the next +.i nlmsghdr +in a multipart message. +the caller must check if the current +.i nlmsghdr +didn't have the +.b nlmsg_done +set\(emthis function doesn't return null on end. +the +.i len +argument is an lvalue containing the remaining length +of the message buffer. +this macro decrements it by the length of the message header. +.tp +.br nlmsg_ok () +return true if the netlink message is not truncated and +is in a form suitable for parsing. +.tp +.br nlmsg_payload () +return the length of the payload associated with the +.ir nlmsghdr . +.sh conforming to +these macros are nonstandard linux extensions. +.sh notes +it is often better to use netlink via +.i libnetlink +than via the low-level kernel interface. +.sh see also +.br libnetlink (3), +.br netlink (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man7/system_data_types.7 + +.\" copyright 1993 rickard e. faith (faith@cs.unc.edu) +.\" and copyright (c) 2008, 2010, 2015, michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified thu oct 31 12:04:29 1996 by eric s. raymond +.\" modified, 27 may 2004, michael kerrisk +.\" added notes on capability requirements +.\" 2008-05-03, mtk, expanded and rewrote parts of description and return +.\" value, made style of page more consistent with man-pages style. +.\" +.th getgroups 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +getgroups, setgroups \- get/set list of supplementary group ids +.sh synopsis +.nf +.b #include +.pp +.bi "int getgroups(int " size ", gid_t " list []); +.pp +.b #include +.pp +.bi "int setgroups(size_t " size ", const gid_t *" list ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br setgroups (): +.nf + since glibc 2.19: + _default_source + glibc 2.19 and earlier: + _bsd_source +.fi +.sh description +.br getgroups () +returns the supplementary group ids of the calling process in +.ir list . +the argument +.i size +should be set to the maximum number of items that can be stored in the +buffer pointed to by +.ir list . +if the calling process is a member of more than +.i size +supplementary groups, then an error results. +.pp +it is unspecified whether the effective group id of the calling process +is included in the returned list. +(thus, an application should also call +.br getegid (2) +and add or remove the resulting value.) +.pp +if +.i size +is zero, +.i list +is not modified, but the total number of supplementary group ids for the +process is returned. +this allows the caller to determine the size of a dynamically allocated +.i list +to be used in a further call to +.br getgroups (). +.pp +.br setgroups () +sets the supplementary group ids for the calling process. +appropriate privileges are required (see the description of the +.br eperm +error, below). +the +.i size +argument specifies the number of supplementary group ids +in the buffer pointed to by +.ir list . +a process can drop all of its supplementary groups with the call: +.pp +.in +4n +.ex +setgroups(0, null); +.ee +.in +.sh return value +on success, +.br getgroups () +returns the number of supplementary group ids. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.pp +on success, +.br setgroups () +returns 0. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b efault +.i list +has an invalid address. +.pp +.br getgroups () +can additionally fail with the following error: +.tp +.b einval +.i size +is less than the number of supplementary group ids, but is not zero. +.pp +.br setgroups () +can additionally fail with the following errors: +.tp +.b einval +.i size +is greater than +.b ngroups_max +(32 before linux 2.6.4; 65536 since linux 2.6.4). +.tp +.b enomem +out of memory. +.tp +.b eperm +the calling process has insufficient privilege +(the caller does not have the +.br cap_setgid +capability in the user namespace in which it resides). +.tp +.br eperm " (since linux 3.19)" +the use of +.br setgroups () +is denied in this user namespace. +see the description of +.ir /proc/[pid]/setgroups +in +.br user_namespaces (7). +.sh conforming to +.br getgroups (): +svr4, 4.3bsd, posix.1-2001, posix.1-2008. +.pp +.br setgroups (): +svr4, 4.3bsd. +since +.br setgroups () +requires privilege, it is not covered by posix.1. +.sh notes +a process can have up to +.b ngroups_max +supplementary group ids +in addition to the effective group id. +the constant +.b ngroups_max +is defined in +.ir . +the set of supplementary group ids +is inherited from the parent process, and preserved across an +.br execve (2). +.pp +the maximum number of supplementary group ids can be found at run time using +.br sysconf (3): +.pp +.in +4n +.ex +long ngroups_max; +ngroups_max = sysconf(_sc_ngroups_max); +.ee +.in +.pp +the maximum return value of +.br getgroups () +cannot be larger than one more than this value. +since linux 2.6.4, the maximum number of supplementary group ids is also +exposed via the linux-specific read-only file, +.ir /proc/sys/kernel/ngroups_max . +.pp +the original linux +.br getgroups () +system call supported only 16-bit group ids. +subsequently, linux 2.4 added +.br getgroups32 (), +supporting 32-bit ids. +the glibc +.br getgroups () +wrapper function transparently deals with the variation across kernel versions. +.\" +.ss c library/kernel differences +at the kernel level, user ids and group ids are a per-thread attribute. +however, posix requires that all threads in a process +share the same credentials. +the nptl threading implementation handles the posix requirements by +providing wrapper functions for +the various system calls that change process uids and gids. +these wrapper functions (including the one for +.br setgroups ()) +employ a signal-based technique to ensure +that when one thread changes credentials, +all of the other threads in the process also change their credentials. +for details, see +.br nptl (7). +.sh see also +.br getgid (2), +.br setgid (2), +.br getgrouplist (3), +.br group_member (3), +.br initgroups (3), +.br capabilities (7), +.br credentials (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/tailq.3 + +.\" copyright (c) 2014 red hat, inc. all rights reserved. +.\" written by david howells (dhowells@redhat.com) +.\" and copyright (c) 2016 michael kerrisk +.\" +.\" %%%license_start(gplv2+_sw_onepara) +.\" this program is free software; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license +.\" as published by the free software foundation; either version +.\" 2 of the license, or (at your option) any later version. +.\" %%%license_end +.\" +.th keyrings 7 2021-03-22 linux "linux programmer's manual" +.sh name +keyrings \- in-kernel key management and retention facility +.sh description +the linux key-management facility +is primarily a way for various kernel components +to retain or cache security data, +authentication keys, encryption keys, and other data in the kernel. +.pp +system call interfaces are provided so that user-space programs can manage +those objects and also use the facility for their own purposes; see +.br add_key (2), +.br request_key (2), +and +.br keyctl (2). +.pp +a library and some user-space utilities are provided to allow access to the +facility. +see +.br keyctl (1), +.br keyctl (3), +and +.br keyutils (7) +for more information. +.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.ss keys +a key has the following attributes: +.tp +serial number (id) +this is a unique integer handle by which a key is referred to in system calls. +the serial number is sometimes synonymously referred as the key id. +programmatically, key serial numbers are represented using the type +.ir key_serial_t . +.tp +type +a key's type defines what sort of data can be held in the key, +how the proposed content of the key will be parsed, +and how the payload will be used. +.ip +there are a number of general-purpose types available, plus some specialist +types defined by specific kernel components. +.tp +description (name) +the key description is a printable string that is used as the search term +for the key (in conjunction with the key type) as well as a display name. +during searches, the description may be partially matched or exactly matched. +.tp +payload (data) +the payload is the actual content of a key. +this is usually set when a key is created, +but it is possible for the kernel to upcall to user space to finish the +instantiation of a key if that key wasn't already known to the kernel +when it was requested. +for further details, see +.br request_key (2). +.ip +a key's payload can be read and updated if the key type supports it and if +suitable permission is granted to the caller. +.tp +access rights +much as files do, +each key has an owning user id, an owning group id, and a security label. +each key also has a set of permissions, +though there are more than for a normal unix file, +and there is an additional category\(empossessor\(embeyond the usual user, +group, and other (see +.ir possession , +below). +.ip +note that keys are quota controlled, since they require unswappable kernel +memory. +the owning user id specifies whose quota is to be debited. +.tp +expiration time +each key can have an expiration time set. +when that time is reached, +the key is marked as being expired and accesses to it fail with the error +.br ekeyexpired . +if not deleted, updated, or replaced, then, after a set amount of time, +an expired key is automatically removed (garbage collected) +along with all links to it, +and attempts to access the key fail with the error +.br enokey . +.tp +reference count +each key has a reference count. +keys are referenced by keyrings, by currently active users, +and by a process's credentials. +when the reference count reaches zero, +the key is scheduled for garbage collection. +.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.ss key types +the kernel provides several basic types of key: +.tp +.i """keyring""" +.\" note that keyrings use different fields in struct key in order to store +.\" their data - index_key instead of type/description and name_link/keys +.\" instead of payload. +keyrings are special keys which store a set of links +to other keys (including other keyrings), +analogous to a directory holding links to files. +the main purpose of a keyring is to prevent other keys from +being garbage collected because nothing refers to them. +.ip +keyrings with descriptions (names) +that begin with a period (\(aq.\(aq) are reserved to the implementation. +.tp +.i """user""" +this is a general-purpose key type. +the key is kept entirely within kernel memory. +the payload may be read and updated by user-space applications. +.ip +the payload for keys of this type is a blob of arbitrary data +of up to 32,767 bytes. +.ip +the description may be any valid string, though it is preferred that it +start with a colon-delimited prefix representing the service +to which the key is of interest +(for instance +.ir """afs:mykey""" ). +.tp +.ir """logon""" " (since linux 3.3)" +.\" commit 9f6ed2ca257fa8650b876377833e6f14e272848b +this key type is essentially the same as +.ir """user""" , +but it does not provide reading (i.e., the +.br keyctl (2) +.br keyctl_read +operation), +meaning that the key payload is never visible from user space. +this is suitable for storing username-password pairs +that should not be readable from user space. +.ip +the description of a +.ir """logon""" +key +.i must +start with a non-empty colon-delimited prefix whose purpose +is to identify the service to which the key belongs. +(note that this differs from keys of the +.ir """user""" +type, where the inclusion of a prefix is recommended but is not enforced.) +.tp +.ir """big_key""" " (since linux 3.13)" +.\" commit ab3c3587f8cda9083209a61dbe3a4407d3cada10 +this key type is similar to the +.i """user""" +key type, but it may hold a payload of up to 1\ mib in size. +this key type is useful for purposes such as holding kerberos ticket caches. +.ip +the payload data may be stored in a tmpfs filesystem, +rather than in kernel memory, +if the data size exceeds the overhead of storing the data in the filesystem. +(storing the data in a filesystem requires filesystem structures +to be allocated in the kernel. +the size of these structures determines the size threshold +above which the tmpfs storage method is used.) +since linux 4.8, +.\" commit 13100a72f40f5748a04017e0ab3df4cf27c809ef +the payload data is encrypted when stored in tmpfs, +thereby preventing it from being written unencrypted into swap space. +.pp +there are more specialized key types available also, +but they aren't discussed here +because they aren't intended for normal user-space use. +.pp +key type names +that begin with a period (\(aq.\(aq) are reserved to the implementation. +.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.ss keyrings +as previously mentioned, keyrings are a special type of key that contain +links to other keys (which may include other keyrings). +keys may be linked to by multiple keyrings. +keyrings may be considered as analogous to unix directories +where each directory contains a set of hard links to files. +.pp +various operations (system calls) may be applied only to keyrings: +.ip adding +a key may be added to a keyring by system calls that create keys. +this prevents the new key from being immediately deleted +when the system call releases its last reference to the key. +.ip linking +a link may be added to a keyring pointing to a key that is already known, +provided this does not create a self-referential cycle. +.ip unlinking +a link may be removed from a keyring. +when the last link to a key is removed, +that key will be scheduled for deletion by the garbage collector. +.ip clearing +all the links may be removed from a keyring. +.ip searching +a keyring may be considered the root of a tree or subtree in which keyrings +form the branches and non-keyrings the leaves. +this tree may be searched for a key matching +a particular type and description. +.pp +see +.br keyctl_clear (3), +.br keyctl_link (3), +.br keyctl_search (3), +and +.br keyctl_unlink (3) +for more information. +.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.ss anchoring keys +to prevent a key from being garbage collected, +it must be anchored to keep its reference count elevated +when it is not in active use by the kernel. +.pp +keyrings are used to anchor other keys: +each link is a reference on a key. +note that keyrings themselves are just keys and +are also subject to the same anchoring requirement to prevent +them being garbage collected. +.pp +the kernel makes available a number of anchor keyrings. +note that some of these keyrings will be created only when first accessed. +.tp +process keyrings +process credentials themselves reference keyrings with specific semantics. +these keyrings are pinned as long as the set of credentials exists, +which is usually as long as the process exists. +.ip +there are three keyrings with different inheritance/sharing rules: +the +.br session\-keyring (7) +(inherited and shared by all child processes), +the +.br process\-keyring (7) +(shared by all threads in a process) and +the +.br thread\-keyring (7) +(specific to a particular thread). +.ip +as an alternative to using the actual keyring ids, +in calls to +.br add_key (2), +.br keyctl (2), +and +.br request_key (2), +the special keyring values +.br key_spec_session_keyring , +.br key_spec_process_keyring , +and +.br key_spec_thread_keyring +can be used to refer to the caller's own instances of these keyrings. +.tp +user keyrings +each uid known to the kernel has a record that contains two keyrings: the +.br user\-keyring (7) +and the +.br user\-session\-keyring (7). +these exist for as long as the uid record in the kernel exists. +.ip +as an alternative to using the actual keyring ids, +in calls to +.br add_key (2), +.br keyctl (2), +and +.br request_key (2), +the special keyring values +.br key_spec_user_keyring +and +.br key_spec_user_session_keyring +can be used to refer to the caller's own instances of these keyrings. +.ip +a link to the user keyring is placed in a new session keyring by +.br pam_keyinit (8) +when a new login session is initiated. +.tp +persistent keyrings +there is a +.br persistent\-keyring (7) +available to each uid known to the system. +it may persist beyond the life of the uid record previously mentioned, +but has an expiration time set such that it is automatically cleaned up +after a set time. +the persistent keyring permits, for example, +.br cron (8) +scripts to use credentials that are left in the persistent keyring after +the user logs out. +.ip +note that the expiration time of the persistent keyring +is reset every time the persistent key is requested. +.tp +special keyrings +there are special keyrings owned by the kernel that can anchor keys +for special purposes. +an example of this is the \fisystem keyring\fr used for holding +encryption keys for module signature verification. +.ip +these special keyrings are usually closed to direct alteration +by user space. +.pp +an originally planned "group keyring", +for storing keys associated with each gid known to the kernel, +is not so far implemented, is unlikely to be implemented. +nevertheless, the constant +.br key_spec_group_keyring +has been defined for this keyring. +.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.ss possession +the concept of possession is important to understanding the keyrings +security model. +whether a thread possesses a key is determined by the following rules: +.ip (1) 4 +any key or keyring that does not grant +.i search +permission to the caller is ignored in all the following rules. +.ip (2) +a thread possesses its +.br session\-keyring (7), +.br process\-keyring (7), +and +.br thread\-keyring (7) +directly because those keyrings are referred to by its credentials. +.ip (3) +if a keyring is possessed, then any key it links to is also possessed. +.ip (4) +if any key a keyring links to is itself a keyring, then rule (3) applies +recursively. +.ip (5) +if a process is upcalled from the kernel to instantiate a key (see +.br request_key (2)), +then it also possesses the requester's keyrings as in +rule (1) as if it were the requester. +.pp +note that possession is not a fundamental property of a key, +but must rather be calculated each time the key is needed. +.pp +possession is designed to allow set-user-id programs run from, say +a user's shell to access the user's keys. +granting permissions to the key possessor while denying them +to the key owner and group allows the prevention of access to keys +on the basis of uid and gid matches. +.pp +when it creates the session keyring, +.br pam_keyinit (8) +adds a link to the +.br user\-keyring (7), +thus making the user keyring and anything it contains possessed by default. +.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.ss access rights +each key has the following security-related attributes: +.ip * 3 +the owning user id +.ip * +the id of a group that is permitted to access the key +.ip * +a security label +.ip * +a permissions mask +.pp +the permissions mask contains four sets of rights. +the first three sets are mutually exclusive. +one and only one will be in force for a particular access check. +in order of descending priority, these three sets are: +.ip \fiuser\fr +the set specifies the rights granted +if the key's user id matches the caller's filesystem user id. +.ip \figroup\fr +the set specifies the rights granted +if the user id didn't match and the key's group id matches the caller's +filesystem gid or one of the caller's supplementary group ids. +.ip \fiother\fr +the set specifies the rights granted +if neither the key's user id nor group id matched. +.pp +the fourth set of rights is: +.ip \fipossessor\fr +the set specifies the rights granted +if a key is determined to be possessed by the caller. +.pp +the complete set of rights for a key is the union of whichever +of the first three sets is applicable plus the fourth set +if the key is possessed. +.pp +the set of rights that may be granted in each of the four masks +is as follows: +.tp +.i view +the attributes of the key may be read. +this includes the type, +description, and access rights (excluding the security label). +.tp +.i read +for a key: the payload of the key may be read. +for a keyring: the list of serial numbers (keys) to +which the keyring has links may be read. +.tp +.i write +the payload of the key may be updated and the key may be revoked. +for a keyring, links may be added to or removed from the keyring, +and the keyring may be cleared completely (all links are removed), +.tp +.i search +for a key (or a keyring): the key may be found by a search. +for a keyring: keys and keyrings that are linked to by the +keyring may be searched. +.tp +.i link +links may be created from keyrings to the key. +the initial link to a key that is established when the key is created +doesn't require this permission. +.tp +.i setattr +the ownership details and security label of the key may be changed, +the key's expiration time may be set, and the key may be revoked. +.pp +in addition to access rights, any active linux security module (lsm) may +prevent access to a key if its policy so dictates. +a key may be given a +security label or other attribute by the lsm; +this label is retrievable via +.br keyctl_get_security (3). +.pp +see +.br keyctl_chown (3), +.br keyctl_describe (3), +.br keyctl_get_security (3), +.br keyctl_setperm (3), +and +.br selinux (8) +for more information. +.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.ss searching for keys +one of the key features of the linux key-management facility +is the ability to find a key that a process is retaining. +the +.br request_key (2) +system call is the primary point of +access for user-space applications to find a key. +(internally, the kernel has something similar available +for use by internal components that make use of keys.) +.pp +the search algorithm works as follows: +.ip (1) 4 +the process keyrings are searched in the following order: the thread +.br thread\-keyring (7) +if it exists, the +.br process\-keyring (7) +if it exists, and then either the +.br session\-keyring (7) +if it exists or the +.br user\-session\-keyring (7) +if that exists. +.ip (2) +if the caller was a process that was invoked by the +.br request_key (2) +upcall mechanism, then the keyrings of the original caller of +.br request_key (2) +will be searched as well. +.ip (3) +the search of a keyring tree is in breadth-first order: +each keyring is searched first for a match, +then the keyrings referred to by that keyring are searched. +.ip (4) +if a matching key is found that is valid, +then the search terminates and that key is returned. +.ip (5) +if a matching key is found that has an error state attached, +that error state is noted and the search continues. +.ip (6) +if no valid matching key is found, +then the first noted error state is returned; otherwise, an +.b enokey +error is returned. +.pp +it is also possible to search a specific keyring, in which case only steps +(3) to (6) apply. +.pp +see +.br request_key (2) +and +.br keyctl_search (3) +for more information. +.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.ss on-demand key creation +if a key cannot be found, +.br request_key (2) +will, if given a +.i callout_info +argument, create a new key and then upcall to user space to +instantiate the key. +this allows keys to be created on an as-needed basis. +.pp +typically, +this will involve the kernel creating a new process that executes the +.br request\-key (8) +program, which will then execute the appropriate handler based on its +configuration. +.pp +the handler is passed a special authorization key that allows it +and only it to instantiate the new key. +this is also used to permit searches performed by the +handler program to also search the requester's keyrings. +.pp +see +.br request_key (2), +.br keyctl_assume_authority (3), +.br keyctl_instantiate (3), +.br keyctl_negate (3), +.br keyctl_reject (3), +.br request\-key (8), +and +.br request\-key.conf (5) +for more information. +.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.ss /proc files +the kernel provides various +.i /proc +files that expose information about keys or define limits on key usage. +.tp +.ir /proc/keys " (since linux 2.6.10)" +this file exposes a list of the keys for which the reading thread has +.i view +permission, providing various information about each key. +the thread need not possess the key for it to be visible in this file. +.\" david howells, dec 2016 linux-man@: +.\" this [the thread need not possess the key for it to be visible in +.\" this file.] is correct. see proc_keys_show() in security/keys/proc.c: +.\" +.\" rc = key_task_permission(key_ref, ctx.cred, key_need_view); +.\" if (rc < 0) +.\" return 0; +.\" +.\"possibly it shouldn't be, but for now it is. +.\" +.ip +the only keys included in the list are those that grant +.i view +permission to the reading process +(regardless of whether or not it possesses them). +lsm security checks are still performed, +and may filter out further keys that the process is not authorized to view. +.ip +an example of the data that one might see in this file +(with the columns numbered for easy reference below) +is the following: +.ip +.ex + (1) (2) (3)(4) (5) (6) (7) (8) (9) +009a2028 i\-\-q\-\-\- 1 perm 3f010000 1000 1000 user krb_ccache:primary: 12 +1806c4ba i\-\-q\-\-\- 1 perm 3f010000 1000 1000 keyring _pid: 2 +25d3a08f i\-\-q\-\-\- 1 perm 1f3f0000 1000 65534 keyring _uid_ses.1000: 1 +28576bd8 i\-\-q\-\-\- 3 perm 3f010000 1000 1000 keyring _krb: 1 +2c546d21 i\-\-q\-\-\- 190 perm 3f030000 1000 1000 keyring _ses: 2 +30a4e0be i\-\-\-\-\-\- 4 2d 1f030000 1000 65534 keyring _persistent.1000: 1 +32100fab i\-\-q\-\-\- 4 perm 1f3f0000 1000 65534 keyring _uid.1000: 2 +32a387ea i\-\-q\-\-\- 1 perm 3f010000 1000 1000 keyring _pid: 2 +3ce56aea i\-\-q\-\-\- 5 perm 3f030000 1000 1000 keyring _ses: 1 +.ee +.ip +the fields shown in each line of this file are as follows: +.rs +.tp +id (1) +the id (serial number) of the key, expressed in hexadecimal. +.tp +flags (2) +a set of flags describing the state of the key: +.rs +.ip i 4 +.\" key_flag_instantiated +the key has been instantiated. +.ip r +.\" key_flag_revoked +the key has been revoked. +.ip d +.\" key_flag_dead +the key is dead (i.e., the key type has been unregistered). +.\" unregister_key_type() in the kernel source +(a key may be briefly in this state during garbage collection.) +.ip q +.\" key_flag_in_quota +the key contributes to the user's quota. +.ip u +.\" key_flag_user_construct +the key is under construction via a callback to user space; +see +.br request\-key (2). +.ip n +.\" key_flag_negative +the key is negatively instantiated. +.ip i +.\" key_flag_invalidated +the key has been invalidated. +.re +.tp +usage (3) +this is a count of the number of kernel credential +structures that are pinning the key +(approximately: the number of threads and open file references +that refer to this key). +.tp +timeout (4) +the amount of time until the key will expire, +expressed in human-readable form (weeks, days, hours, minutes, and seconds). +the string +.i perm +here means that the key is permanent (no timeout). +the string +.i expd +means that the key has already expired, +but has not yet been garbage collected. +.tp +permissions (5) +the key permissions, expressed as four hexadecimal bytes containing, +from left to right, the possessor, user, group, and other permissions. +within each byte, the permission bits are as follows: +.ip +.pd 0 +.rs 12 +.tp +0x01 +.i view +.tp +ox02 +.i read +.tp +0x04 +.i write +.tp +0x08 +.i search +.tp +0x10 +.i link +.tp +0x20 +.i setattr +.re +.pd +.tp +uid (6) +the user id of the key owner. +.tp +gid (7) +the group id of the key. +the value \-1 here means that the key has no group id; +this can occur in certain circumstances for keys created by the kernel. +.tp +type (8) +the key type (user, keyring, etc.) +.tp +description (9) +the key description (name). +this field contains descriptive information about the key. +for most key types, it has the form +.ip + name[: extra\-info] +.ip +the +.i name +subfield is the key's description (name). +the optional +.i extra\-info +field provides some further information about the key. +the information that appears here depends on the key type, as follows: +.rs +.tp +.ir """user""" " and " """logon""" +the size in bytes of the key payload (expressed in decimal). +.tp +.ir """keyring""" +the number of keys linked to the keyring, +or the string +.ir empty +if there are no keys linked to the keyring. +.tp +.ir """big_key""" +the payload size in bytes, followed either by the string +.ir [file] , +if the key payload exceeds the threshold that means that the +payload is stored in a (swappable) +.br tmpfs (5) +filesystem, +or otherwise the string +.ir [buff] , +indicating that the key is small enough to reside in kernel memory. +.re +.ip +for the +.ir """.request_key_auth""" +key type +(authorization key; see +.br request_key (2)), +the description field has the form shown in the following example: +.ip + key:c9a9b19 pid:28880 ci:10 +.ip +the three subfields are as follows: +.rs +.tp +.i key +the hexadecimal id of the key being instantiated in the requesting program. +.tp +.i pid +the pid of the requesting program. +.tp +.i ci +the length of the callout data with which the requested key should +be instantiated +(i.e., the length of the payload associated with the authorization key). +.re +.re +.tp +.ir /proc/key\-users " (since linux 2.6.10)" +this file lists various information for each user id that +has at least one key on the system. +an example of the data that one might see in this file is the following: +.ip +.in +4n +.ex + 0: 10 9/9 2/1000000 22/25000000 + 42: 9 9/9 8/200 106/20000 +1000: 11 11/11 10/200 271/20000 +.ee +.in +.ip +the fields shown in each line are as follows: +.rs +.tp +.i uid +the user id. +.tp +.i usage +this is a kernel-internal usage count for the kernel structure +used to record key users. +.tp +.ir nkeys / nikeys +the total number of keys owned by the user, +and the number of those keys that have been instantiated. +.tp +.ir qnkeys / maxkeys +the number of keys owned by the user, +and the maximum number of keys that the user may own. +.tp +.ir qnbytes / maxbytes +the number of bytes consumed in payloads of the keys owned by this user, +and the upper limit on the number of bytes in key payloads for that user. +.re +.tp +.ir /proc/sys/kernel/keys/gc_delay " (since linux 2.6.32)" +.\" commit 5d135440faf7db8d566de0c6fab36b16cf9cfc3b +the value in this file specifies the interval, in seconds, +after which revoked and expired keys will be garbage collected. +the purpose of having such an interval is so that there is a window +of time where user space can see an error (respectively +.br ekeyrevoked +and +.br ekeyexpired ) +that indicates what happened to the key. +.ip +the default value in this file is 300 (i.e., 5 minutes). +.tp +.ir /proc/sys/kernel/keys/persistent_keyring_expiry " (since linux 3.13)" +.\" commit f36f8c75ae2e7d4da34f4c908cebdb4aa42c977e +this file defines an interval, in seconds, +to which the persistent keyring's expiration timer is reset +each time the keyring is accessed (via +.br keyctl_get_persistent (3) +or the +.br keyctl (2) +.b keyctl_get_persistent +operation.) +.ip +the default value in this file is 259200 (i.e., 3 days). +.pp +the following files (which are writable by privileged processes) +are used to enforce quotas on the number of keys +and number of bytes of data that can be stored in key payloads: +.tp +.ir /proc/sys/kernel/keys/maxbytes " (since linux 2.6.26)" +.\" commit 0b77f5bfb45c13e1e5142374f9d6ca75292252a4 +.\" previously: keyquota_max_bytes 10000 +this is the maximum number of bytes of data that a nonroot user +can hold in the payloads of the keys owned by the user. +.ip +the default value in this file is 20,000. +.tp +.ir /proc/sys/kernel/keys/maxkeys " (since linux 2.6.26)" +.\" commit 0b77f5bfb45c13e1e5142374f9d6ca75292252a4 +.\" previously: keyquota_max_keys 100 +this is the maximum number of keys that a nonroot user may own. +.ip +the default value in this file is 200. +.tp +.ir /proc/sys/kernel/keys/root_maxbytes " (since linux 2.6.26)" +this is the maximum number of bytes of data that the root user +(uid 0 in the root user namespace) +can hold in the payloads of the keys owned by root. +.ip +.\"738c5d190f6540539a04baf36ce21d46b5da04bd +the default value in this file is 25,000,000 (20,000 before linux 3.17). +.\" commit 0b77f5bfb45c13e1e5142374f9d6ca75292252a4 +.tp +.ir /proc/sys/kernel/keys/root_maxkeys " (since linux 2.6.26)" +.\" commit 0b77f5bfb45c13e1e5142374f9d6ca75292252a4 +this is the maximum number of keys that the root user +(uid 0 in the root user namespace) +may own. +.ip +.\"738c5d190f6540539a04baf36ce21d46b5da04bd +the default value in this file is 1,000,000 (200 before linux 3.17). +.pp +with respect to keyrings, +note that each link in a keyring consumes 4 bytes of the keyring payload. +.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.ss users +the linux key-management facility has a number of users and usages, +but is not limited to those that already exist. +.pp +in-kernel users of this facility include: +.tp +network filesystems - dns +the kernel uses the upcall mechanism provided by the keys to upcall to +user space to do dns lookups and then to cache the results. +.tp +af_rxrpc and kafs - authentication +the af_rxrpc network protocol and the in-kernel afs filesystem +use keys to store the ticket needed to do secured or encrypted traffic. +these are then looked up by +network operations on af_rxrpc and filesystem operations on kafs. +.tp +nfs - user id mapping +the nfs filesystem uses keys to store mappings of +foreign user ids to local user ids. +.tp +cifs - password +the cifs filesystem uses keys to store passwords for accessing remote shares. +.tp +module verification +the kernel build process can be made to cryptographically sign modules. +that signature is then checked when a module is loaded. +.pp +user-space users of this facility include: +.tp +kerberos key storage +the mit kerberos 5 facility (libkrb5) can use keys to store authentication +tokens which can be made to be automatically cleaned up a set time after +the user last uses them, +but until then permits them to hang around after the user +has logged out so that +.br cron (8) +scripts can use them. +.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.sh see also +.ad l +.nh +.br keyctl (1), +.br add_key (2), +.br keyctl (2), +.br request_key (2), +.br keyctl (3), +.br keyutils (7), +.br persistent\-keyring (7), +.br process\-keyring (7), +.br session\-keyring (7), +.br thread\-keyring (7), +.br user\-keyring (7), +.br user\-session\-keyring (7), +.br pam_keyinit (8), +.br request\-key (8) +.pp +the kernel source files +.ir documentation/crypto/asymmetric\-keys.txt +and under +.ir documentation/security/keys +(or, before linux 4.13, in the file +.ir documentation/security/keys.txt ). +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2003 john levon +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified 2004-06-17 michael kerrisk +.\" +.th lookup_dcookie 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +lookup_dcookie \- return a directory entry's path +.sh synopsis +.nf +.br "#include " " /* definition of " sys_* " constants */" +.b #include +.pp +.bi "int syscall(sys_lookup_dcookie, uint64_t " cookie ", char *" buffer , +.bi " size_t " len ); +.fi +.pp +.ir note : +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 . +the cookie is an opaque identifier uniquely identifying a particular +directory entry. +the buffer given is filled in with the full path of the directory entry. +.pp +for +.br lookup_dcookie () +to return successfully, +the kernel must still hold a cookie reference to the directory entry. +.sh return value +on success, +.br lookup_dcookie () +returns the length of the path string copied into the buffer. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b efault +the buffer was not valid. +.tp +.b einval +the kernel has no registered cookie/directory entry mappings at the +time of lookup, or the cookie does not refer to a valid directory entry. +.tp +.b enametoolong +the name could not fit in the buffer. +.tp +.b enomem +the kernel could not allocate memory for the temporary buffer holding +the path. +.tp +.b eperm +the process does not have the capability +.b cap_sys_admin +required to look up cookie values. +.tp +.b erange +the buffer was not large enough to hold the path of the directory entry. +.sh versions +available since linux 2.5.43. +the +.b enametoolong +error return was added in 2.5.70. +.sh conforming to +.br lookup_dcookie () +is linux-specific. +.sh notes +.br lookup_dcookie () +is a special-purpose system call, currently used only by the +.br oprofile (1) +profiler. +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. +.sh see also +.br oprofile (1) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1993 by thomas koenig (ig25@rz.uni-karlsruhe.de) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified sun jul 25 11:05:58 1993 by rik faith (faith@cs.unc.edu) +.\" modified sat feb 10 16:18:03 1996 by urs thuermann (urs@isnogud.escape.de) +.\" modified mon jun 16 20:02:00 1997 by nicolás lichtmaier +.\" modified mon feb 6 16:41:00 1999 by nicolás lichtmaier +.\" modified tue feb 8 16:46:45 2000 by chris pepper +.\" modified fri sep 7 20:32:45 2001 by tammy fox +.th hier 7 2021-03-22 "linux" "linux programmer's manual" +.sh name +hier \- description of the filesystem hierarchy +.sh description +a typical linux system has, among others, the following directories: +.tp +.i / +this is the root directory. +this is where the whole tree starts. +.tp +.i /bin +this directory contains executable programs which are needed in +single user mode and to bring the system up or repair it. +.tp +.i /boot +contains static files for the boot loader. +this directory holds only +the files which are needed during the boot process. +the map installer +and configuration files should go to +.i /sbin +and +.ir /etc . +the operating system kernel (initrd for example) must be located in either +.i / +or +.ir /boot . +.tp +.i /dev +special or device files, which refer to physical devices. +see +.br mknod (1). +.tp +.i /etc +contains configuration files which are local to the machine. +some +larger software packages, like x11, can have their own subdirectories +below +.ir /etc . +site-wide configuration files may be placed here or in +.ir /usr/etc . +nevertheless, programs should always look for these files in +.i /etc +and you may have links for these files to +.ir /usr/etc . +.tp +.i /etc/opt +host-specific configuration files for add-on applications installed +in +.ir /opt . +.tp +.i /etc/sgml +this directory contains the configuration files for sgml (optional). +.tp +.i /etc/skel +when a new user account is created, files from this directory are +usually copied into the user's home directory. +.tp +.i /etc/x11 +configuration files for the x11 window system (optional). +.tp +.i /etc/xml +this directory contains the configuration files for xml (optional). +.tp +.i /home +on machines with home directories for users, these are usually beneath +this directory, directly or not. +the structure of this directory +depends on local administration decisions (optional). +.tp +.i /lib +this directory should hold those shared libraries that are necessary +to boot the system and to run the commands in the root filesystem. +.tp +.i /lib +these directories are variants of +.i /lib +on system which support more than one binary format requiring separate +libraries (optional). +.tp +.i /lib/modules +loadable kernel modules (optional). +.tp +.i /lost+found +this directory contains items lost in the filesystem. +these items are usually chunks of files mangled as a consequence of +a faulty disk or a system crash. +.tp +.i /media +this directory contains mount points for removable media such as cd +and dvd disks or usb sticks. +on systems where more than one device exists +for mounting a certain type of media, +mount directories can be created by appending a digit +to the name of those available above starting with '0', +but the unqualified name must also exist. +.tp +.i /media/floppy[1\-9] +floppy drive (optional). +.tp +.i /media/cdrom[1\-9] +cd-rom drive (optional). +.tp +.i /media/cdrecorder[1\-9] +cd writer (optional). +.tp +.i /media/zip[1\-9] +zip drive (optional). +.tp +.i /media/usb[1\-9] +usb drive (optional). +.tp +.i /mnt +this directory is a mount point for a temporarily mounted filesystem. +in some distributions, +.i /mnt +contains subdirectories intended to be used as mount points for several +temporary filesystems. +.tp +.i /opt +this directory should contain add-on packages that contain static files. +.tp +.i /proc +this is a mount point for the +.i proc +filesystem, which provides information about running processes and +the kernel. +this pseudo-filesystem is described in more detail in +.br proc (5). +.tp +.i /root +this directory is usually the home directory for the root user (optional). +.tp +.i /run +this directory contains information which describes the system since it was booted. +once this purpose was served by +.ir /var/run +and programs may continue to use it. +.tp +.i /sbin +like +.ir /bin , +this directory holds commands needed to boot the system, but which are +usually not executed by normal users. +.tp +.i /srv +this directory contains site-specific data that is served by this system. +.tp +.i /sys +this is a mount point for the sysfs filesystem, which provides information +about the kernel like +.ir /proc , +but better structured, following the formalism of kobject infrastructure. +.tp +.i /tmp +this directory contains temporary files which may be deleted with no +notice, such as by a regular job or at system boot up. +.tp +.i /usr +this directory is usually mounted from a separate partition. +it should hold only shareable, read-only data, so that it can be mounted +by various machines running linux. +.tp +.i /usr/x11r6 +the x\-window system, version 11 release 6 (present in fhs 2.3, removed +in fhs 3.0). +.tp +.i /usr/x11r6/bin +binaries which belong to the x\-window system; often, there is a +symbolic link from the more traditional +.i /usr/bin/x11 +to here. +.tp +.i /usr/x11r6/lib +data files associated with the x\-window system. +.tp +.i /usr/x11r6/lib/x11 +these contain miscellaneous files needed to run x; often, there is a +symbolic link from +.i /usr/lib/x11 +to this directory. +.tp +.i /usr/x11r6/include/x11 +contains include files needed for compiling programs using the x11 +window system. +often, there is a symbolic link from +.i /usr/include/x11 +to this directory. +.tp +.i /usr/bin +this is the primary directory for executable programs. +most programs +executed by normal users which are not needed for booting or for +repairing the system and which are not installed locally should be +placed in this directory. +.tp +.i /usr/bin/mh +commands for the mh mail handling system (optional). +.tp +.i /usr/bin/x11 +this is the traditional place to look for x11 executables; on linux, it +usually is a symbolic link to +.ir /usr/x11r6/bin . +.tp +.i /usr/dict +replaced by +.ir /usr/share/dict . +.tp +.i /usr/doc +replaced by +.ir /usr/share/doc . +.tp +.i /usr/etc +site-wide configuration files to be shared between several machines +may be stored in this directory. +however, commands should always +reference those files using the +.i /etc +directory. +links from files in +.i /etc +should point to the appropriate files in +.ir /usr/etc . +.tp +.i /usr/games +binaries for games and educational programs (optional). +.tp +.i /usr/include +include files for the c compiler. +.tp +.i /usr/include/bsd +bsd compatibility include files (optional). +.tp +.i /usr/include/x11 +include files for the c compiler and the x\-window system. +this is +usually a symbolic link to +.ir /usr/x11r6/include/x11 . +.tp +.i /usr/include/asm +include files which declare some assembler functions. +this used to be a +symbolic link to +.ir /usr/src/linux/include/asm . +.tp +.i /usr/include/linux +this contains information which may change from system release to +system release and used to be a symbolic link to +.i /usr/src/linux/include/linux +to get at operating-system-specific information. +.ip +(note that one should have include files there that work correctly with +the current libc and in user space. +however, linux kernel source is not +designed to be used with user programs and does not know anything +about the libc you are using. +it is very likely that things will break +if you let +.i /usr/include/asm +and +.i /usr/include/linux +point at a random kernel tree. +debian systems don't do this +and use headers from a known good kernel +version, provided in the libc*-dev package.) +.tp +.i /usr/include/g++ +include files to use with the gnu c++ compiler. +.tp +.i /usr/lib +object libraries, including dynamic libraries, plus some executables +which usually are not invoked directly. +more complicated programs may +have whole subdirectories there. +.tp +.i /usr/libexec +directory contains binaries for internal use only and they are not meant +to be executed directly by users shell or scripts. +.tp +.i /usr/lib +these directories are variants of +.i /usr/lib +on system which support more than one binary format requiring separate +libraries, except that the symbolic link +.i /usr/lib/x11 +is not required (optional). +.tp +.i /usr/lib/x11 +the usual place for data files associated with x programs, and +configuration files for the x system itself. +on linux, it usually is +a symbolic link to +.ir /usr/x11r6/lib/x11 . +.tp +.i /usr/lib/gcc\-lib +contains executables and include files for the gnu c compiler, +.br gcc (1). +.tp +.i /usr/lib/groff +files for the gnu groff document formatting system. +.tp +.i /usr/lib/uucp +files for +.br uucp (1). +.tp +.i /usr/local +this is where programs which are local to the site typically go. +.tp +.i /usr/local/bin +binaries for programs local to the site. +.tp +.i /usr/local/doc +local documentation. +.tp +.i /usr/local/etc +configuration files associated with locally installed programs. +.tp +.i /usr/local/games +binaries for locally installed games. +.tp +.i /usr/local/lib +files associated with locally installed programs. +.tp +.i /usr/local/lib +these directories are variants of +.i /usr/local/lib +on system which support more than one binary format requiring separate +libraries (optional). +.tp +.i /usr/local/include +header files for the local c compiler. +.tp +.i /usr/local/info +info pages associated with locally installed programs. +.tp +.i /usr/local/man +man pages associated with locally installed programs. +.tp +.i /usr/local/sbin +locally installed programs for system administration. +.tp +.i /usr/local/share +local application data that can be shared among different architectures +of the same os. +.tp +.i /usr/local/src +source code for locally installed software. +.tp +.i /usr/man +replaced by +.ir /usr/share/man . +.tp +.i /usr/sbin +this directory contains program binaries for system administration +which are not essential for the boot process, for mounting +.ir /usr , +or for system repair. +.tp +.i /usr/share +this directory contains subdirectories with specific application data, that +can be shared among different architectures of the same os. +often one finds stuff here that used to live in +.i /usr/doc +or +.i /usr/lib +or +.ir /usr/man . +.tp +.i /usr/share/color +contains color management information, like international color consortium (icc) +color profiles (optional). +.tp +.i /usr/share/dict +contains the word lists used by spell checkers (optional). +.tp +.i /usr/share/dict/words +list of english words (optional). +.tp +.i /usr/share/doc +documentation about installed programs (optional). +.tp +.i /usr/share/games +static data files for games in +.i /usr/games +(optional). +.tp +.i /usr/share/info +info pages go here (optional). +.tp +.i /usr/share/locale +locale information goes here (optional). +.tp +.i /usr/share/man +manual pages go here in subdirectories according to the man page sections. +.tp +.i /usr/share/man//man[1\-9] +these directories contain manual pages for the +specific locale in source code form. +systems which use a unique language and code set for all manual pages +may omit the substring. +.tp +.i /usr/share/misc +miscellaneous data that can be shared among different architectures of the +same os. +.tp +.i /usr/share/nls +the message catalogs for native language support go here (optional). +.tp +.i /usr/share/ppd +postscript printer definition (ppd) files (optional). +.tp +.i /usr/share/sgml +files for sgml (optional). +.tp +.i /usr/share/sgml/docbook +docbook dtd (optional). +.tp +.i /usr/share/sgml/tei +tei dtd (optional). +.tp +.i /usr/share/sgml/html +html dtd (optional). +.tp +.i /usr/share/sgml/mathtml +mathml dtd (optional). +.tp +.i /usr/share/terminfo +the database for terminfo (optional). +.tp +.i /usr/share/tmac +troff macros that are not distributed with groff (optional). +.tp +.i /usr/share/xml +files for xml (optional). +.tp +.i /usr/share/xml/docbook +docbook dtd (optional). +.tp +.i /usr/share/xml/xhtml +xhtml dtd (optional). +.tp +.i /usr/share/xml/mathml +mathml dtd (optional). +.tp +.i /usr/share/zoneinfo +files for timezone information (optional). +.tp +.i /usr/src +source files for different parts of the system, included with some packages +for reference purposes. +don't work here with your own projects, as files +below /usr should be read-only except when installing software (optional). +.tp +.i /usr/src/linux +this was the traditional place for the kernel source. +some distributions put here the source for the default kernel they ship. +you should probably use another directory when building your own kernel. +.tp +.i /usr/tmp +obsolete. +this should be a link +to +.ir /var/tmp . +this link is present only for compatibility reasons and shouldn't be used. +.tp +.i /var +this directory contains files which may change in size, such as spool +and log files. +.tp +.i /var/account +process accounting logs (optional). +.tp +.i /var/adm +this directory is superseded by +.i /var/log +and should be a symbolic link to +.ir /var/log . +.tp +.i /var/backups +reserved for historical reasons. +.tp +.i /var/cache +data cached for programs. +.tp +.i /var/cache/fonts +locally generated fonts (optional). +.tp +.i /var/cache/man +locally formatted man pages (optional). +.tp +.i /var/cache/www +www proxy or cache data (optional). +.tp +.i /var/cache/ +package specific cache data (optional). +.tp +.ir /var/catman/cat[1\-9] " or " /var/cache/man/cat[1\-9] +these directories contain preformatted manual pages according to their +man page section. +(the use of preformatted manual pages is deprecated.) +.tp +.i /var/crash +system crash dumps (optional). +.tp +.i /var/cron +reserved for historical reasons. +.tp +.i /var/games +variable game data (optional). +.tp +.i /var/lib +variable state information for programs. +.tp +.i /var/lib/color +variable files containing color management information (optional). +.tp +.i /var/lib/hwclock +state directory for hwclock (optional). +.tp +.i /var/lib/misc +miscellaneous state data. +.tp +.i /var/lib/xdm +x display manager variable data (optional). +.tp +.i /var/lib/ +editor backup files and state (optional). +.tp +.i /var/lib/ +these directories must be used for all distribution packaging support. +.tp +.i /var/lib/ +state data for packages and subsystems (optional). +.tp +.i /var/lib/ +packaging support files (optional). +.tp +.i /var/local +variable data for +.ir /usr/local . +.tp +.i /var/lock +lock files are placed in this directory. +the naming convention for +device lock files is +.i lck.. +where +.i +is the device's name in the filesystem. +the format used is that of hdu uucp lock files, that is, lock files +contain a pid as a 10-byte ascii decimal number, followed by a newline +character. +.tp +.i /var/log +miscellaneous log files. +.tp +.i /var/opt +variable data for +.ir /opt . +.tp +.i /var/mail +users' mailboxes. +replaces +.ir /var/spool/mail . +.tp +.i /var/msgs +reserved for historical reasons. +.tp +.i /var/preserve +reserved for historical reasons. +.tp +.i /var/run +run-time variable files, like files holding process identifiers (pids) +and logged user information +.ir (utmp) . +files in this directory are usually cleared when the system boots. +.tp +.i /var/spool +spooled (or queued) files for various programs. +.tp +.i /var/spool/at +spooled jobs for +.br at (1). +.tp +.i /var/spool/cron +spooled jobs for +.br cron (8). +.tp +.i /var/spool/lpd +spooled files for printing (optional). +.tp +.i /var/spool/lpd/printer +spools for a specific printer (optional). +.tp +.i /var/spool/mail +replaced by +.ir /var/mail . +.tp +.i /var/spool/mqueue +queued outgoing mail (optional). +.tp +.i /var/spool/news +spool directory for news (optional). +.tp +.i /var/spool/rwho +spooled files for +.br rwhod (8) +(optional). +.tp +.i /var/spool/smail +spooled files for the +.br smail (1) +mail delivery program. +.tp +.i /var/spool/uucp +spooled files for +.br uucp (1) +(optional). +.tp +.i /var/tmp +like +.ir /tmp , +this directory holds temporary files stored for an unspecified duration. +.tp +.i /var/yp +database files for nis, +formerly known as the sun yellow pages (yp). +.sh conforming to +the filesystem hierarchy standard (fhs), version 3.0, published march 19, 2015 +.ur https://refspecs.linuxfoundation.org/fhs.shtml +.ue . +.sh bugs +this list is not exhaustive; different distributions and systems may be configured +differently. +.sh see also +.br find (1), +.br ln (1), +.br proc (5), +.br file\-hierarchy (7), +.br mount (8) +.pp +the filesystem hierarchy standard +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2012, vincent weaver +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" this document is based on the perf_event.h header file, the +.\" tools/perf/design.txt file, and a lot of bitter experience. +.\" +.th perf_event_open 2 2021-08-27 "linux" "linux programmer's manual" +.sh name +perf_event_open \- set up performance monitoring +.sh synopsis +.nf +.br "#include " " /* definition of " perf_* " constants */" +.br "#include " " /* definition of " hw_* " constants */" +.br "#include " " /* definition of " sys_* " constants */" +.b #include +.pp +.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 : +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 () +returns a file descriptor, for use in subsequent system calls +.rb ( read "(2), " mmap "(2), " prctl "(2), " fcntl "(2), etc.)." +.pp +a call to +.br perf_event_open () +creates a file descriptor that allows measuring performance +information. +each file descriptor corresponds to one +event that is measured; these can be grouped together +to measure multiple events simultaneously. +.pp +events can be enabled and disabled in two ways: via +.br ioctl (2) +and via +.br prctl (2). +when an event is disabled it does not count or generate overflows but does +continue to exist and maintain its count value. +.pp +events come in two flavors: counting and sampled. +a +.i counting +event is one that is used for counting the aggregate number of events +that occur. +in general, counting event results are gathered with a +.br read (2) +call. +a +.i sampling +event periodically writes measurements to a buffer that can then +be accessed via +.br mmap (2). +.ss arguments +the +.i pid +and +.i cpu +arguments allow specifying which process and cpu to monitor: +.tp +.br "pid == 0" " and " "cpu == \-1" +this measures the calling process/thread on any cpu. +.tp +.br "pid == 0" " and " "cpu >= 0" +this measures the calling process/thread only +when running on the specified cpu. +.tp +.br "pid > 0" " and " "cpu == \-1" +this measures the specified process/thread on any cpu. +.tp +.br "pid > 0" " and " "cpu >= 0" +this measures the specified process/thread only +when running on the specified cpu. +.tp +.br "pid == \-1" " and " "cpu >= 0" +this measures all processes/threads on the specified cpu. +this requires +.b cap_perfmon +(since linux 5.8) or +.b cap_sys_admin +capability or a +.i /proc/sys/kernel/perf_event_paranoid +value of less than 1. +.tp +.br "pid == \-1" " and " "cpu == \-1" +this setting is invalid and will return an error. +.pp +when +.i pid +is greater than zero, permission to perform this system call +is governed by +.b cap_perfmon +(since linux 5.9) and a ptrace access mode +.b ptrace_mode_read_realcreds +check on older linux versions; see +.br ptrace (2). +.pp +the +.i group_fd +argument allows event groups to be created. +an event group has one event which is the group leader. +the leader is created first, with +.ir group_fd " = \-1." +the rest of the group members are created with subsequent +.br perf_event_open () +calls with +.i group_fd +being set to the file descriptor of the group leader. +(a single event on its own is created with +.ir group_fd " = \-1" +and is considered to be a group with only 1 member.) +an event group is scheduled onto the cpu as a unit: it will +be put onto the cpu only if all of the events in the group can be put onto +the cpu. +this means that the values of the member events can be +meaningfully compared\(emadded, divided (to get ratios), and so on\(emwith each +other, since they have counted events for the same set of executed +instructions. +.pp +the +.i flags +argument is formed by oring together zero or more of the following values: +.tp +.br perf_flag_fd_cloexec " (since linux 3.14)" +.\" commit a21b0b354d4ac39be691f51c53562e2c24443d9e +this flag enables the close-on-exec flag for the created +event file descriptor, +so that the file descriptor is automatically closed on +.br execve (2). +setting the close-on-exec flags at creation time, rather than later with +.br fcntl (2), +avoids potential race conditions where the calling thread invokes +.br perf_event_open () +and +.br fcntl (2) +at the same time as another thread calls +.br fork (2) +then +.br execve (2). +.tp +.br perf_flag_fd_no_group +this flag tells the event to ignore the +.i group_fd +parameter except for the purpose of setting up output redirection +using the +.b perf_flag_fd_output +flag. +.tp +.br perf_flag_fd_output " (broken since linux 2.6.35)" +.\" commit ac9721f3f54b27a16c7e1afb2481e7ee95a70318 +this flag re-routes the event's sampled output to instead +be included in the mmap buffer of the event specified by +.ir group_fd . +.tp +.br perf_flag_pid_cgroup " (since linux 2.6.39)" +.\" commit e5d1367f17ba6a6fed5fd8b74e4d5720923e0c25 +this flag activates per-container system-wide monitoring. +a container +is an abstraction that isolates a set of resources for finer-grained +control (cpus, memory, etc.). +in this mode, the event is measured +only if the thread running on the monitored cpu belongs to the designated +container (cgroup). +the cgroup is identified by passing a file descriptor +opened on its directory in the cgroupfs filesystem. +for instance, if the +cgroup to monitor is called +.ir test , +then a file descriptor opened on +.i /dev/cgroup/test +(assuming cgroupfs is mounted on +.ir /dev/cgroup ) +must be passed as the +.i pid +parameter. +cgroup monitoring is available only +for system-wide events and may therefore require extra permissions. +.pp +the +.i perf_event_attr +structure provides detailed configuration information +for the event being created. +.pp +.in +4n +.ex +struct perf_event_attr { + __u32 type; /* type of event */ + __u32 size; /* size of attribute structure */ + __u64 config; /* type\-specific configuration */ + + union { + __u64 sample_period; /* period of sampling */ + __u64 sample_freq; /* frequency of sampling */ + }; + + __u64 sample_type; /* specifies values included in sample */ + __u64 read_format; /* specifies values returned in read */ + + __u64 disabled : 1, /* off by default */ + inherit : 1, /* children inherit it */ + pinned : 1, /* must always be on pmu */ + exclusive : 1, /* only group on pmu */ + exclude_user : 1, /* don\(aqt count user */ + exclude_kernel : 1, /* don\(aqt count kernel */ + exclude_hv : 1, /* don\(aqt count hypervisor */ + exclude_idle : 1, /* don\(aqt count when idle */ + mmap : 1, /* include mmap data */ + comm : 1, /* include comm data */ + freq : 1, /* use freq, not period */ + inherit_stat : 1, /* per task counts */ + enable_on_exec : 1, /* next exec enables */ + task : 1, /* trace fork/exit */ + watermark : 1, /* wakeup_watermark */ + precise_ip : 2, /* skid constraint */ + mmap_data : 1, /* non\-exec mmap data */ + sample_id_all : 1, /* sample_type all events */ + exclude_host : 1, /* don\(aqt count in host */ + exclude_guest : 1, /* don\(aqt count in guest */ + exclude_callchain_kernel : 1, + /* exclude kernel callchains */ + exclude_callchain_user : 1, + /* exclude user callchains */ + mmap2 : 1, /* include mmap with inode data */ + comm_exec : 1, /* flag comm events that are + due to exec */ + use_clockid : 1, /* use clockid for time fields */ + context_switch : 1, /* context switch data */ + write_backward : 1, /* write ring buffer from end + to beginning */ + namespaces : 1, /* include namespaces data */ + ksymbol : 1, /* include ksymbol events */ + bpf_event : 1, /* include bpf events */ + aux_output : 1, /* generate aux records + instead of events */ + cgroup : 1, /* include cgroup events */ + text_poke : 1, /* include text poke events */ + + __reserved_1 : 30; + + union { + __u32 wakeup_events; /* wakeup every n events */ + __u32 wakeup_watermark; /* bytes before wakeup */ + }; + + __u32 bp_type; /* breakpoint type */ + + union { + __u64 bp_addr; /* breakpoint address */ + __u64 kprobe_func; /* for perf_kprobe */ + __u64 uprobe_path; /* for perf_uprobe */ + __u64 config1; /* extension of config */ + }; + + union { + __u64 bp_len; /* breakpoint length */ + __u64 kprobe_addr; /* with kprobe_func == null */ + __u64 probe_offset; /* for perf_[k,u]probe */ + __u64 config2; /* extension of config1 */ + }; + __u64 branch_sample_type; /* enum perf_branch_sample_type */ + __u64 sample_regs_user; /* user regs to dump on samples */ + __u32 sample_stack_user; /* size of stack to dump on + samples */ + __s32 clockid; /* clock to use for time fields */ + __u64 sample_regs_intr; /* regs to dump on samples */ + __u32 aux_watermark; /* aux bytes before wakeup */ + __u16 sample_max_stack; /* max frames in callchain */ + __u16 __reserved_2; /* align to u64 */ + +}; +.ee +.in +.pp +the fields of the +.i perf_event_attr +structure are described in more detail below: +.tp +.i type +this field specifies the overall event type. +it has one of the following values: +.rs +.tp +.b perf_type_hardware +this indicates one of the "generalized" hardware events provided +by the kernel. +see the +.i config +field definition for more details. +.tp +.b perf_type_software +this indicates one of the software-defined events provided by the kernel +(even if no hardware support is available). +.tp +.b perf_type_tracepoint +this indicates a tracepoint +provided by the kernel tracepoint infrastructure. +.tp +.b perf_type_hw_cache +this indicates a hardware cache event. +this has a special encoding, described in the +.i config +field definition. +.tp +.b perf_type_raw +this indicates a "raw" implementation-specific event in the +.ir config " field." +.tp +.br perf_type_breakpoint " (since linux 2.6.33)" +.\" commit 24f1e32c60c45c89a997c73395b69c8af6f0a84e +this indicates a hardware breakpoint as provided by the cpu. +breakpoints can be read/write accesses to an address as well as +execution of an instruction address. +.tp +dynamic pmu +since linux 2.6.38, +.\" commit 2e80a82a49c4c7eca4e35734380f28298ba5db19 +.br perf_event_open () +can support multiple pmus. +to enable this, a value exported by the kernel can be used in the +.i type +field to indicate which pmu to use. +the value to use can be found in the sysfs filesystem: +there is a subdirectory per pmu instance under +.ir /sys/bus/event_source/devices . +in each subdirectory there is a +.i type +file whose content is an integer that can be used in the +.i type +field. +for instance, +.i /sys/bus/event_source/devices/cpu/type +contains the value for the core cpu pmu, which is usually 4. +.tp +.br kprobe " and " uprobe " (since linux 4.17)" +.\" commit 65074d43fc77bcae32776724b7fa2696923c78e4 +.\" commit e12f03d7031a977356e3d7b75a68c2185ff8d155 +.\" commit 33ea4b24277b06dbc55d7f5772a46f029600255e +these two dynamic pmus create a kprobe/uprobe and attach it to the +file descriptor generated by perf_event_open. +the kprobe/uprobe will be destroyed on the destruction of the file descriptor. +see fields +.ir kprobe_func , +.ir uprobe_path , +.ir kprobe_addr , +and +.i probe_offset +for more details. +.re +.tp +.i "size" +the size of the +.i perf_event_attr +structure for forward/backward compatibility. +set this using +.i sizeof(struct perf_event_attr) +to allow the kernel to see +the struct size at the time of compilation. +.ip +the related define +.b perf_attr_size_ver0 +is set to 64; this was the size of the first published struct. +.b perf_attr_size_ver1 +is 72, corresponding to the addition of breakpoints in linux 2.6.33. +.\" commit cb5d76999029ae7a517cb07dfa732c1b5a934fc2 +.\" this was added much later when perf_attr_size_ver2 happened +.\" but the actual attr_size had increased in 2.6.33 +.b perf_attr_size_ver2 +is 80 corresponding to the addition of branch sampling in linux 3.4. +.\" commit cb5d76999029ae7a517cb07dfa732c1b5a934fc2 +.b perf_attr_size_ver3 +is 96 corresponding to the addition +of +.i sample_regs_user +and +.i sample_stack_user +in linux 3.7. +.\" commit 1659d129ed014b715b0b2120e6fd929bdd33ed03 +.b perf_attr_size_ver4 +is 104 corresponding to the addition of +.i sample_regs_intr +in linux 3.19. +.\" commit 60e2364e60e86e81bc6377f49779779e6120977f +.b perf_attr_size_ver5 +is 112 corresponding to the addition of +.i aux_watermark +in linux 4.1. +.\" commit 1a5941312414c71dece6717da9a0fa1303127afa +.tp +.i "config" +this specifies which event you want, in conjunction with +the +.i type +field. +the +.i config1 +and +.i config2 +fields are also taken into account in cases where 64 bits is not +enough to fully specify the event. +the encoding of these fields are event dependent. +.ip +there are various ways to set the +.i config +field that are dependent on the value of the previously +described +.i type +field. +what follows are various possible settings for +.i config +separated out by +.ir type . +.ip +if +.i type +is +.br perf_type_hardware , +we are measuring one of the generalized hardware cpu events. +not all of these are available on all platforms. +set +.i config +to one of the following: +.rs 12 +.tp +.b perf_count_hw_cpu_cycles +total cycles. +be wary of what happens during cpu frequency scaling. +.tp +.b perf_count_hw_instructions +retired instructions. +be careful, these can be affected by various +issues, most notably hardware interrupt counts. +.tp +.b perf_count_hw_cache_references +cache accesses. +usually this indicates last level cache accesses but this may +vary depending on your cpu. +this may include prefetches and coherency messages; again this +depends on the design of your cpu. +.tp +.b perf_count_hw_cache_misses +cache misses. +usually this indicates last level cache misses; this is intended to be +used in conjunction with the +.b perf_count_hw_cache_references +event to calculate cache miss rates. +.tp +.b perf_count_hw_branch_instructions +retired branch instructions. +prior to linux 2.6.35, this used +the wrong event on amd processors. +.\" commit f287d332ce835f77a4f5077d2c0ef1e3f9ea42d2 +.tp +.b perf_count_hw_branch_misses +mispredicted branch instructions. +.tp +.b perf_count_hw_bus_cycles +bus cycles, which can be different from total cycles. +.tp +.br perf_count_hw_stalled_cycles_frontend " (since linux 3.0)" +.\" commit 8f62242246351b5a4bc0c1f00c0c7003edea128a +stalled cycles during issue. +.tp +.br perf_count_hw_stalled_cycles_backend " (since linux 3.0)" +.\" commit 8f62242246351b5a4bc0c1f00c0c7003edea128a +stalled cycles during retirement. +.tp +.br perf_count_hw_ref_cpu_cycles " (since linux 3.3)" +.\" commit c37e17497e01fc0f5d2d6feb5723b210b3ab8890 +total cycles; not affected by cpu frequency scaling. +.re +.ip +if +.i type +is +.br perf_type_software , +we are measuring software events provided by the kernel. +set +.i config +to one of the following: +.rs 12 +.tp +.b perf_count_sw_cpu_clock +this reports the cpu clock, a high-resolution per-cpu timer. +.tp +.b perf_count_sw_task_clock +this reports a clock count specific to the task that is running. +.tp +.b perf_count_sw_page_faults +this reports the number of page faults. +.tp +.b perf_count_sw_context_switches +this counts context switches. +until linux 2.6.34, these were all reported as user-space +events, after that they are reported as happening in the kernel. +.\" commit e49a5bd38159dfb1928fd25b173bc9de4bbadb21 +.tp +.b perf_count_sw_cpu_migrations +this reports the number of times the process +has migrated to a new cpu. +.tp +.b perf_count_sw_page_faults_min +this counts the number of minor page faults. +these did not require disk i/o to handle. +.tp +.b perf_count_sw_page_faults_maj +this counts the number of major page faults. +these required disk i/o to handle. +.tp +.br perf_count_sw_alignment_faults " (since linux 2.6.33)" +.\" commit f7d7986060b2890fc26db6ab5203efbd33aa2497 +this counts the number of alignment faults. +these happen when unaligned memory accesses happen; the kernel +can handle these but it reduces performance. +this happens only on some architectures (never on x86). +.tp +.br perf_count_sw_emulation_faults " (since linux 2.6.33)" +.\" commit f7d7986060b2890fc26db6ab5203efbd33aa2497 +this counts the number of emulation faults. +the kernel sometimes traps on unimplemented instructions +and emulates them for user space. +this can negatively impact performance. +.tp +.br perf_count_sw_dummy " (since linux 3.12)" +.\" commit fa0097ee690693006ab1aea6c01ad3c851b65c77 +this is a placeholder event that counts nothing. +informational sample record types such as mmap or comm +must be associated with an active event. +this dummy event allows gathering such records without requiring +a counting event. +.re +.pp +.rs +if +.i type +is +.br perf_type_tracepoint , +then we are measuring kernel tracepoints. +the value to use in +.i config +can be obtained from under debugfs +.i tracing/events/*/*/id +if ftrace is enabled in the kernel. +.re +.pp +.rs +if +.i type +is +.br perf_type_hw_cache , +then we are measuring a hardware cpu cache event. +to calculate the appropriate +.i config +value, use the following equation: +.rs 4 +.pp +.in +4n +.ex +config = (perf_hw_cache_id) | + (perf_hw_cache_op_id << 8) | + (perf_hw_cache_op_result_id << 16); +.ee +.in +.pp +where +.i perf_hw_cache_id +is one of: +.rs 4 +.tp +.b perf_count_hw_cache_l1d +for measuring level 1 data cache +.tp +.b perf_count_hw_cache_l1i +for measuring level 1 instruction cache +.tp +.b perf_count_hw_cache_ll +for measuring last-level cache +.tp +.b perf_count_hw_cache_dtlb +for measuring the data tlb +.tp +.b perf_count_hw_cache_itlb +for measuring the instruction tlb +.tp +.b perf_count_hw_cache_bpu +for measuring the branch prediction unit +.tp +.br perf_count_hw_cache_node " (since linux 3.1)" +.\" commit 89d6c0b5bdbb1927775584dcf532d98b3efe1477 +for measuring local memory accesses +.re +.pp +and +.i perf_hw_cache_op_id +is one of: +.rs 4 +.tp +.b perf_count_hw_cache_op_read +for read accesses +.tp +.b perf_count_hw_cache_op_write +for write accesses +.tp +.b perf_count_hw_cache_op_prefetch +for prefetch accesses +.re +.pp +and +.i perf_hw_cache_op_result_id +is one of: +.rs 4 +.tp +.b perf_count_hw_cache_result_access +to measure accesses +.tp +.b perf_count_hw_cache_result_miss +to measure misses +.re +.re +.pp +if +.i type +is +.br perf_type_raw , +then a custom "raw" +.i config +value is needed. +most cpus support events that are not covered by the "generalized" events. +these are implementation defined; see your cpu manual (for example +the intel volume 3b documentation or the amd bios and kernel developer +guide). +the libpfm4 library can be used to translate from the name in the +architectural manuals to the raw hex value +.br perf_event_open () +expects in this field. +.pp +if +.i type +is +.br perf_type_breakpoint , +then leave +.i config +set to zero. +its parameters are set in other places. +.pp +if +.i type +is +.b kprobe +or +.br uprobe , +set +.i retprobe +(bit 0 of +.ir config , +see +.ir /sys/bus/event_source/devices/[k,u]probe/format/retprobe ) +for kretprobe/uretprobe. +see fields +.ir kprobe_func , +.ir uprobe_path , +.ir kprobe_addr , +and +.i probe_offset +for more details. +.re +.tp +.ir kprobe_func ", " uprobe_path ", " kprobe_addr ", and " probe_offset +these fields describe the kprobe/uprobe for dynamic pmus +.b kprobe +and +.br uprobe . +for +.br kprobe : +use +.i kprobe_func +and +.ir probe_offset , +or use +.i kprobe_addr +and leave +.i kprobe_func +as null. +for +.br uprobe : +use +.i uprobe_path +and +.ir probe_offset . +.tp +.ir sample_period ", " sample_freq +a "sampling" event is one that generates an overflow notification +every n events, where n is given by +.ir sample_period . +a sampling event has +.ir sample_period " > 0." +when an overflow occurs, requested data is recorded +in the mmap buffer. +the +.i sample_type +field controls what data is recorded on each overflow. +.ip +.i sample_freq +can be used if you wish to use frequency rather than period. +in this case, you set the +.i freq +flag. +the kernel will adjust the sampling period +to try and achieve the desired rate. +the rate of adjustment is a +timer tick. +.tp +.i sample_type +the various bits in this field specify which values to include +in the sample. +they will be recorded in a ring-buffer, +which is available to user space using +.br mmap (2). +the order in which the values are saved in the +sample are documented in the mmap layout subsection below; +it is not the +.i "enum perf_event_sample_format" +order. +.rs +.tp +.b perf_sample_ip +records instruction pointer. +.tp +.b perf_sample_tid +records the process and thread ids. +.tp +.b perf_sample_time +records a timestamp. +.tp +.b perf_sample_addr +records an address, if applicable. +.tp +.b perf_sample_read +record counter values for all events in a group, not just the group leader. +.tp +.b perf_sample_callchain +records the callchain (stack backtrace). +.tp +.b perf_sample_id +records a unique id for the opened event's group leader. +.tp +.b perf_sample_cpu +records cpu number. +.tp +.b perf_sample_period +records the current sampling period. +.tp +.b perf_sample_stream_id +records a unique id for the opened event. +unlike +.b perf_sample_id +the actual id is returned, not the group leader. +this id is the same as the one returned by +.br perf_format_id . +.tp +.b perf_sample_raw +records additional data, if applicable. +usually returned by tracepoint events. +.tp +.br perf_sample_branch_stack " (since linux 3.4)" +.\" commit bce38cd53e5ddba9cb6d708c4ef3d04a4016ec7e +this provides a record of recent branches, as provided +by cpu branch sampling hardware (such as intel last branch record). +not all hardware supports this feature. +.ip +see the +.i branch_sample_type +field for how to filter which branches are reported. +.tp +.br perf_sample_regs_user " (since linux 3.7)" +.\" commit 4018994f3d8785275ef0e7391b75c3462c029e56 +records the current user-level cpu register state +(the values in the process before the kernel was called). +.tp +.br perf_sample_stack_user " (since linux 3.7)" +.\" commit c5ebcedb566ef17bda7b02686e0d658a7bb42ee7 +records the user level stack, allowing stack unwinding. +.tp +.br perf_sample_weight " (since linux 3.10)" +.\" commit c3feedf2aaf9ac8bad6f19f5d21e4ee0b4b87e9c +records a hardware provided weight value that expresses how +costly the sampled event was. +this allows the hardware to highlight expensive events in +a profile. +.tp +.br perf_sample_data_src " (since linux 3.10)" +.\" commit d6be9ad6c960f43800a6f118932bc8a5a4eadcd1 +records the data source: where in the memory hierarchy +the data associated with the sampled instruction came from. +this is available only if the underlying hardware +supports this feature. +.tp +.br perf_sample_identifier " (since linux 3.12)" +.\" commit ff3d527cebc1fa3707c617bfe9e74f53fcfb0955 +places the +.b sample_id +value in a fixed position in the record, +either at the beginning (for sample events) or at the end +(if a non-sample event). +.ip +this was necessary because a sample stream may have +records from various different event sources with different +.i sample_type +settings. +parsing the event stream properly was not possible because the +format of the record was needed to find +.br sample_id , +but +the format could not be found without knowing what +event the sample belonged to (causing a circular +dependency). +.ip +the +.b perf_sample_identifier +setting makes the event stream always parsable +by putting +.b sample_id +in a fixed location, even though +it means having duplicate +.b sample_id +values in records. +.tp +.br perf_sample_transaction " (since linux 3.13)" +.\" commit fdfbbd07e91f8fe387140776f3fd94605f0c89e5 +records reasons for transactional memory abort events +(for example, from intel tsx transactional memory support). +.ip +the +.i precise_ip +setting must be greater than 0 and a transactional memory abort +event must be measured or no values will be recorded. +also note that some perf_event measurements, such as sampled +cycle counting, may cause extraneous aborts (by causing an +interrupt during a transaction). +.tp +.br perf_sample_regs_intr " (since linux 3.19)" +.\" commit 60e2364e60e86e81bc6377f49779779e6120977f +records a subset of the current cpu register state +as specified by +.ir sample_regs_intr . +unlike +.b perf_sample_regs_user +the register values will return kernel register +state if the overflow happened while kernel +code is running. +if the cpu supports hardware sampling of +register state (i.e., pebs on intel x86) and +.i precise_ip +is set higher than zero then the register +values returned are those captured by +hardware at the time of the sampled +instruction's retirement. +.tp +.br perf_sample_phys_addr " (since linux 4.13)" +.\" commit fc7ce9c74c3ad232b084d80148654f926d01ece7 +records physical address of data like in +.br perf_sample_addr . +.tp +.br perf_sample_cgroup " (since linux 5.7)" +.\" commit 96aaab686505c449e24d76e76507290dcc30e008 +records (perf_event) cgroup id of the process. +this corresponds to the +.i id +field in the +.b perf_record_cgroup +event. +.re +.tp +.i read_format +this field specifies the format of the data returned by +.br read (2) +on a +.br perf_event_open () +file descriptor. +.rs +.tp +.b perf_format_total_time_enabled +adds the 64-bit +.i time_enabled +field. +this can be used to calculate estimated totals if +the pmu is overcommitted and multiplexing is happening. +.tp +.b perf_format_total_time_running +adds the 64-bit +.i time_running +field. +this can be used to calculate estimated totals if +the pmu is overcommitted and multiplexing is happening. +.tp +.b perf_format_id +adds a 64-bit unique value that corresponds to the event group. +.tp +.b perf_format_group +allows all counter values in an event group to be read with one read. +.re +.tp +.i disabled +the +.i disabled +bit specifies whether the counter starts out disabled or enabled. +if disabled, the event can later be enabled by +.br ioctl (2), +.br prctl (2), +or +.ir enable_on_exec . +.ip +when creating an event group, typically the group leader is initialized +with +.i disabled +set to 1 and any child events are initialized with +.i disabled +set to 0. +despite +.i disabled +being 0, the child events will not start until the group leader +is enabled. +.tp +.i inherit +the +.i inherit +bit specifies that this counter should count events of child +tasks as well as the task specified. +this applies only to new children, not to any existing children at +the time the counter is created (nor to any new children of +existing children). +.ip +inherit does not work for some combinations of +.ir read_format +values, such as +.br perf_format_group . +.tp +.i pinned +the +.i pinned +bit specifies that the counter should always be on the cpu if at all +possible. +it applies only to hardware counters and only to group leaders. +if a pinned counter cannot be put onto the cpu (e.g., because there are +not enough hardware counters or because of a conflict with some other +event), then the counter goes into an 'error' state, where reads +return end-of-file (i.e., +.br read (2) +returns 0) until the counter is subsequently enabled or disabled. +.tp +.i exclusive +the +.i exclusive +bit specifies that when this counter's group is on the cpu, +it should be the only group using the cpu's counters. +in the future this may allow monitoring programs to +support pmu features that need to run alone so that they do not +disrupt other hardware counters. +.ip +note that many unexpected situations may prevent events with the +.i exclusive +bit set from ever running. +this includes any users running a system-wide +measurement as well as any kernel use of the performance counters +(including the commonly enabled nmi watchdog timer interface). +.tp +.i exclude_user +if this bit is set, the count excludes events that happen in user space. +.tp +.i exclude_kernel +if this bit is set, the count excludes events that happen in kernel space. +.tp +.i exclude_hv +if this bit is set, the count excludes events that happen in the +hypervisor. +this is mainly for pmus that have built-in support for handling this +(such as power). +extra support is needed for handling hypervisor measurements on most +machines. +.tp +.i exclude_idle +if set, don't count when the cpu is running the idle task. +while you can currently enable this for any event type, it is ignored +for all but software events. +.tp +.i mmap +the +.i mmap +bit enables generation of +.b perf_record_mmap +samples for every +.br mmap (2) +call that has +.b prot_exec +set. +this allows tools to notice new executable code being mapped into +a program (dynamic shared libraries for example) +so that addresses can be mapped back to the original code. +.tp +.i comm +the +.i comm +bit enables tracking of process command name as modified by the +.br execve (2) +and +.br prctl (pr_set_name) +system calls as well as writing to +.ir /proc/self/comm . +if the +.i comm_exec +flag is also successfully set (possible since linux 3.16), +.\" commit 82b897782d10fcc4930c9d4a15b175348fdd2871 +then the misc flag +.b perf_record_misc_comm_exec +can be used to differentiate the +.br execve (2) +case from the others. +.tp +.i freq +if this bit is set, then +.i sample_frequency +not +.i sample_period +is used when setting up the sampling interval. +.tp +.i inherit_stat +this bit enables saving of event counts on context switch for +inherited tasks. +this is meaningful only if the +.i inherit +field is set. +.tp +.i enable_on_exec +if this bit is set, a counter is automatically +enabled after a call to +.br execve (2). +.tp +.i task +if this bit is set, then +fork/exit notifications are included in the ring buffer. +.tp +.i watermark +if set, have an overflow notification happen when we cross the +.i wakeup_watermark +boundary. +otherwise, overflow notifications happen after +.i wakeup_events +samples. +.tp +.ir precise_ip " (since linux 2.6.35)" +.\" commit ab608344bcbde4f55ec4cd911b686b0ce3eae076 +this controls the amount of skid. +skid is how many instructions +execute between an event of interest happening and the kernel +being able to stop and record the event. +smaller skid is +better and allows more accurate reporting of which events +correspond to which instructions, but hardware is often limited +with how small this can be. +.ip +the possible values of this field are the following: +.rs +.ip 0 3 +.b sample_ip +can have arbitrary skid. +.ip 1 +.b sample_ip +must have constant skid. +.ip 2 +.b sample_ip +requested to have 0 skid. +.ip 3 +.b sample_ip +must have 0 skid. +see also the description of +.br perf_record_misc_exact_ip . +.re +.tp +.ir mmap_data " (since linux 2.6.36)" +.\" commit 3af9e859281bda7eb7c20b51879cf43aa788ac2e +this is the counterpart of the +.i mmap +field. +this enables generation of +.b perf_record_mmap +samples for +.br mmap (2) +calls that do not have +.b prot_exec +set (for example data and sysv shared memory). +.tp +.ir sample_id_all " (since linux 2.6.38)" +.\" commit c980d1091810df13f21aabbce545fd98f545bbf7 +if set, then tid, time, id, stream_id, and cpu can +additionally be included in +.rb non- perf_record_sample s +if the corresponding +.i sample_type +is selected. +.ip +if +.b perf_sample_identifier +is specified, then an additional id value is included +as the last value to ease parsing the record stream. +this may lead to the +.i id +value appearing twice. +.ip +the layout is described by this pseudo-structure: +.ip +.in +4n +.ex +struct sample_id { + { u32 pid, tid; } /* if perf_sample_tid set */ + { u64 time; } /* if perf_sample_time set */ + { u64 id; } /* if perf_sample_id set */ + { u64 stream_id;} /* if perf_sample_stream_id set */ + { u32 cpu, res; } /* if perf_sample_cpu set */ + { u64 id; } /* if perf_sample_identifier set */ +}; +.ee +.in +.tp +.ir exclude_host " (since linux 3.2)" +.\" commit a240f76165e6255384d4bdb8139895fac7988799 +when conducting measurements that include processes running +vm instances (i.e., have executed a +.b kvm_run +.br ioctl (2)), +only measure events happening inside a guest instance. +this is only meaningful outside the guests; this setting does +not change counts gathered inside of a guest. +currently, this functionality is x86 only. +.tp +.ir exclude_guest " (since linux 3.2)" +.\" commit a240f76165e6255384d4bdb8139895fac7988799 +when conducting measurements that include processes running +vm instances (i.e., have executed a +.b kvm_run +.br ioctl (2)), +do not measure events happening inside guest instances. +this is only meaningful outside the guests; this setting does +not change counts gathered inside of a guest. +currently, this functionality is x86 only. +.tp +.ir exclude_callchain_kernel " (since linux 3.7)" +.\" commit d077526485d5c9b12fe85d0b2b3b7041e6bc5f91 +do not include kernel callchains. +.tp +.ir exclude_callchain_user " (since linux 3.7)" +.\" commit d077526485d5c9b12fe85d0b2b3b7041e6bc5f91 +do not include user callchains. +.tp +.ir mmap2 " (since linux 3.16)" +.\" commit 13d7a2410fa637f450a29ecb515ac318ee40c741 +.\" this is tricky; was committed during 3.12 development +.\" but right before release was disabled. +.\" so while you could select mmap2 starting with 3.12 +.\" it did not work until 3.16 +.\" commit a5a5ba72843dd05f991184d6cb9a4471acce1005 +generate an extended executable mmap record that contains enough +additional information to uniquely identify shared mappings. +the +.i mmap +flag must also be set for this to work. +.tp +.ir comm_exec " (since linux 3.16)" +.\" commit 82b897782d10fcc4930c9d4a15b175348fdd2871 +this is purely a feature-detection flag, it does not change +kernel behavior. +if this flag can successfully be set, then, when +.i comm +is enabled, the +.b perf_record_misc_comm_exec +flag will be set in the +.i misc +field of a comm record header if the rename event being +reported was caused by a call to +.br execve (2). +this allows tools to distinguish between the various +types of process renaming. +.tp +.ir use_clockid " (since linux 4.1)" +.\" commit 34f439278cef7b1177f8ce24f9fc81dfc6221d3b +this allows selecting which internal linux clock to use +when generating timestamps via the +.i clockid +field. +this can make it easier to correlate perf sample times with +timestamps generated by other tools. +.tp +.ir context_switch " (since linux 4.3)" +.\" commit 45ac1403f564f411c6a383a2448688ba8dd705a4 +this enables the generation of +.b perf_record_switch +records when a context switch occurs. +it also enables the generation of +.b perf_record_switch_cpu_wide +records when sampling in cpu-wide mode. +this functionality is in addition to existing tracepoint and +software events for measuring context switches. +the advantage of this method is that it will give full +information even with strict +.i perf_event_paranoid +settings. +.tp +.ir write_backward " (since linux 4.6)" +.\" commit 9ecda41acb971ebd07c8fb35faf24005c0baea12 +this causes the ring buffer to be written from the end to the beginning. +this is to support reading from overwritable ring buffer. +.tp +.ir namespaces " (since linux 4.11)" +.\" commit e422267322cd319e2695a535e47c5b1feeac45eb +this enables the generation of +.b perf_record_namespaces +records when a task enters a new namespace. +each namespace has a combination of device and inode numbers. +.tp +.ir ksymbol " (since linux 5.0)" +.\" commit 76193a94522f1d4edf2447a536f3f796ce56343b +this enables the generation of +.b perf_record_ksymbol +records when new kernel symbols are registered or unregistered. +this is analyzing dynamic kernel functions like ebpf. +.tp +.ir bpf_event " (since linux 5.0)" +.\" commit 6ee52e2a3fe4ea35520720736e6791df1fb67106 +this enables the generation of +.b perf_record_bpf_event +records when an ebpf program is loaded or unloaded. +.tp +.ir auxevent " (since linux 5.4)" +.\" commit ab43762ef010967e4ccd53627f70a2eecbeafefb +this allows normal (non-aux) events to generate data for aux events +if the hardware supports it. +.tp +.ir cgroup " (since linux 5.7)" +.\" commit 96aaab686505c449e24d76e76507290dcc30e008 +this enables the generation of +.b perf_record_cgroup +records when a new cgroup is created (and activated). +.tp +.ir text_poke " (since linux 5.8)" +.\" commit e17d43b93e544f5016c0251d2074c15568d5d963 +this enables the generation of +.b perf_record_text_poke +records when there's a change to the kernel text +(i.e., self-modifying code). +.tp +.ir wakeup_events ", " wakeup_watermark +this union sets how many samples +.ri ( wakeup_events ) +or bytes +.ri ( wakeup_watermark ) +happen before an overflow notification happens. +which one is used is selected by the +.i watermark +bit flag. +.ip +.i wakeup_events +counts only +.b perf_record_sample +record types. +to receive overflow notification for all +.b perf_record +types choose watermark and set +.i wakeup_watermark +to 1. +.ip +prior to linux 3.0, setting +.\" commit f506b3dc0ec454a16d40cab9ee5d75435b39dc50 +.i wakeup_events +to 0 resulted in no overflow notifications; +more recent kernels treat 0 the same as 1. +.tp +.ir bp_type " (since linux 2.6.33)" +.\" commit 24f1e32c60c45c89a997c73395b69c8af6f0a84e +this chooses the breakpoint type. +it is one of: +.rs +.tp +.b hw_breakpoint_empty +no breakpoint. +.tp +.b hw_breakpoint_r +count when we read the memory location. +.tp +.b hw_breakpoint_w +count when we write the memory location. +.tp +.b hw_breakpoint_rw +count when we read or write the memory location. +.tp +.b hw_breakpoint_x +count when we execute code at the memory location. +.pp +the values can be combined via a bitwise or, but the +combination of +.b hw_breakpoint_r +or +.b hw_breakpoint_w +with +.b hw_breakpoint_x +is not allowed. +.re +.tp +.ir bp_addr " (since linux 2.6.33)" +.\" commit 24f1e32c60c45c89a997c73395b69c8af6f0a84e +this is the address of the breakpoint. +for execution breakpoints, this is the memory address of the instruction +of interest; for read and write breakpoints, it is the memory address +of the memory location of interest. +.tp +.ir config1 " (since linux 2.6.39)" +.\" commit a7e3ed1e470116c9d12c2f778431a481a6be8ab6 +.i config1 +is used for setting events that need an extra register or otherwise +do not fit in the regular config field. +raw offcore_events on nehalem/westmere/sandybridge use this field +on linux 3.3 and later kernels. +.tp +.ir bp_len " (since linux 2.6.33)" +.\" commit 24f1e32c60c45c89a997c73395b69c8af6f0a84e +.i bp_len +is the length of the breakpoint being measured if +.i type +is +.br perf_type_breakpoint . +options are +.br hw_breakpoint_len_1 , +.br hw_breakpoint_len_2 , +.br hw_breakpoint_len_4 , +and +.br hw_breakpoint_len_8 . +for an execution breakpoint, set this to +.ir sizeof(long) . +.tp +.ir config2 " (since linux 2.6.39)" +.\" commit a7e3ed1e470116c9d12c2f778431a481a6be8ab6 +.i config2 +is a further extension of the +.i config1 +field. +.tp +.ir branch_sample_type " (since linux 3.4)" +.\" commit bce38cd53e5ddba9cb6d708c4ef3d04a4016ec7e +if +.b perf_sample_branch_stack +is enabled, then this specifies what branches to include +in the branch record. +.ip +the first part of the value is the privilege level, which +is a combination of one of the values listed below. +if the user does not set privilege level explicitly, the kernel +will use the event's privilege level. +event and branch privilege levels do not have to match. +.rs +.tp +.b perf_sample_branch_user +branch target is in user space. +.tp +.b perf_sample_branch_kernel +branch target is in kernel space. +.tp +.b perf_sample_branch_hv +branch target is in hypervisor. +.tp +.b perf_sample_branch_plm_all +a convenience value that is the three preceding values ored together. +.pp +in addition to the privilege value, at least one or more of the +following bits must be set. +.tp +.b perf_sample_branch_any +any branch type. +.tp +.b perf_sample_branch_any_call +any call branch (includes direct calls, indirect calls, and far jumps). +.tp +.b perf_sample_branch_ind_call +indirect calls. +.tp +.br perf_sample_branch_call " (since linux 4.4)" +.\" commit c229bf9dc179d2023e185c0f705bdf68484c1e73 +direct calls. +.tp +.b perf_sample_branch_any_return +any return branch. +.tp +.br perf_sample_branch_ind_jump " (since linux 4.2)" +.\" commit c9fdfa14c3792c0160849c484e83aa57afd80ccc +indirect jumps. +.tp +.br perf_sample_branch_cond " (since linux 3.16)" +.\" commit bac52139f0b7ab31330e98fd87fc5a2664951050 +conditional branches. +.tp +.br perf_sample_branch_abort_tx " (since linux 3.11)" +.\" commit 135c5612c460f89657c4698fe2ea753f6f667963 +transactional memory aborts. +.tp +.br perf_sample_branch_in_tx " (since linux 3.11)" +.\" commit 135c5612c460f89657c4698fe2ea753f6f667963 +branch in transactional memory transaction. +.tp +.br perf_sample_branch_no_tx " (since linux 3.11)" +.\" commit 135c5612c460f89657c4698fe2ea753f6f667963 +branch not in transactional memory transaction. +.br perf_sample_branch_call_stack " (since linux 4.1)" +.\" commit 2c44b1936bb3b135a3fac8b3493394d42e51cf70 +branch is part of a hardware-generated call stack. +this requires hardware support, currently only found +on intel x86 haswell or newer. +.re +.tp +.ir sample_regs_user " (since linux 3.7)" +.\" commit 4018994f3d8785275ef0e7391b75c3462c029e56 +this bit mask defines the set of user cpu registers to dump on samples. +the layout of the register mask is architecture-specific and +is described in the kernel header file +.ir arch/arch/include/uapi/asm/perf_regs.h . +.tp +.ir sample_stack_user " (since linux 3.7)" +.\" commit c5ebcedb566ef17bda7b02686e0d658a7bb42ee7 +this defines the size of the user stack to dump if +.b perf_sample_stack_user +is specified. +.tp +.ir clockid " (since linux 4.1)" +.\" commit 34f439278cef7b1177f8ce24f9fc81dfc6221d3b +if +.i use_clockid +is set, then this field selects which internal linux timer to +use for timestamps. +the available timers are defined in +.ir linux/time.h , +with +.br clock_monotonic , +.br clock_monotonic_raw , +.br clock_realtime , +.br clock_boottime , +and +.b clock_tai +currently supported. +.tp +.ir aux_watermark " (since linux 4.1)" +.\" commit 1a5941312414c71dece6717da9a0fa1303127afa +this specifies how much data is required to trigger a +.b perf_record_aux +sample. +.tp +.ir sample_max_stack " (since linux 4.8)" +.\" commit 97c79a38cd454602645f0470ffb444b3b75ce574 +when +.i sample_type +includes +.br perf_sample_callchain , +this field specifies how many stack frames to report when +generating the callchain. +.ss reading results +once a +.br perf_event_open () +file descriptor has been opened, the values +of the events can be read from the file descriptor. +the values that are there are specified by the +.i read_format +field in the +.i attr +structure at open time. +.pp +if you attempt to read into a buffer that is not big enough to hold the +data, the error +.b enospc +results. +.pp +here is the layout of the data returned by a read: +.ip * 2 +if +.b perf_format_group +was specified to allow reading all events in a group at once: +.ip +.in +4n +.ex +struct read_format { + u64 nr; /* the number of events */ + u64 time_enabled; /* if perf_format_total_time_enabled */ + u64 time_running; /* if perf_format_total_time_running */ + struct { + u64 value; /* the value of the event */ + u64 id; /* if perf_format_id */ + } values[nr]; +}; +.ee +.in +.ip * +if +.b perf_format_group +was +.i not +specified: +.ip +.in +4n +.ex +struct read_format { + u64 value; /* the value of the event */ + u64 time_enabled; /* if perf_format_total_time_enabled */ + u64 time_running; /* if perf_format_total_time_running */ + u64 id; /* if perf_format_id */ +}; +.ee +.in +.pp +the values read are as follows: +.tp +.i nr +the number of events in this file descriptor. +available only if +.b perf_format_group +was specified. +.tp +.ir time_enabled ", " time_running +total time the event was enabled and running. +normally these values are the same. +multiplexing happens if the number of events is more than the +number of available pmu counter slots. +in that case the events run only part of the time and the +.i time_enabled +and +.i time running +values can be used to scale an estimated value for the count. +.tp +.i value +an unsigned 64-bit value containing the counter result. +.tp +.i id +a globally unique value for this particular event; only present if +.b perf_format_id +was specified in +.ir read_format . +.ss mmap layout +when using +.br perf_event_open () +in sampled mode, asynchronous events +(like counter overflow or +.b prot_exec +mmap tracking) +are logged into a ring-buffer. +this ring-buffer is created and accessed through +.br mmap (2). +.pp +the mmap size should be 1+2^n pages, where the first page is a +metadata page +.ri ( "struct perf_event_mmap_page" ) +that contains various +bits of information such as where the ring-buffer head is. +.pp +before kernel 2.6.39, there is a bug that means you must allocate an mmap +ring buffer when sampling even if you do not plan to access it. +.pp +the structure of the first metadata mmap page is as follows: +.pp +.in +4n +.ex +struct perf_event_mmap_page { + __u32 version; /* version number of this structure */ + __u32 compat_version; /* lowest version this is compat with */ + __u32 lock; /* seqlock for synchronization */ + __u32 index; /* hardware counter identifier */ + __s64 offset; /* add to hardware counter value */ + __u64 time_enabled; /* time event active */ + __u64 time_running; /* time event on cpu */ + union { + __u64 capabilities; + struct { + __u64 cap_usr_time / cap_usr_rdpmc / cap_bit0 : 1, + cap_bit0_is_deprecated : 1, + cap_user_rdpmc : 1, + cap_user_time : 1, + cap_user_time_zero : 1, + }; + }; + __u16 pmc_width; + __u16 time_shift; + __u32 time_mult; + __u64 time_offset; + __u64 __reserved[120]; /* pad to 1 k */ + __u64 data_head; /* head in the data section */ + __u64 data_tail; /* user\-space written tail */ + __u64 data_offset; /* where the buffer starts */ + __u64 data_size; /* data buffer size */ + __u64 aux_head; + __u64 aux_tail; + __u64 aux_offset; + __u64 aux_size; + +} +.ee +.in +.pp +the following list describes the fields in the +.i perf_event_mmap_page +structure in more detail: +.tp +.i version +version number of this structure. +.tp +.i compat_version +the lowest version this is compatible with. +.tp +.i lock +a seqlock for synchronization. +.tp +.i index +a unique hardware counter identifier. +.tp +.i offset +when using rdpmc for reads this offset value +must be added to the one returned by rdpmc to get +the current total event count. +.tp +.i time_enabled +time the event was active. +.tp +.i time_running +time the event was running. +.tp +.ir cap_usr_time " / " cap_usr_rdpmc " / " cap_bit0 " (since linux 3.4)" +.\" commit c7206205d00ab375839bd6c7ddb247d600693c09 +there was a bug in the definition of +.i cap_usr_time +and +.i cap_usr_rdpmc +from linux 3.4 until linux 3.11. +both bits were defined to point to the same location, so it was +impossible to know if +.i cap_usr_time +or +.i cap_usr_rdpmc +were actually set. +.ip +starting with linux 3.12, these are renamed to +.\" commit fa7315871046b9a4c48627905691dbde57e51033 +.i cap_bit0 +and you should use the +.i cap_user_time +and +.i cap_user_rdpmc +fields instead. +.tp +.ir cap_bit0_is_deprecated " (since linux 3.12)" +.\" commit fa7315871046b9a4c48627905691dbde57e51033 +if set, this bit indicates that the kernel supports +the properly separated +.i cap_user_time +and +.i cap_user_rdpmc +bits. +.ip +if not-set, it indicates an older kernel where +.i cap_usr_time +and +.i cap_usr_rdpmc +map to the same bit and thus both features should +be used with caution. +.tp +.ir cap_user_rdpmc " (since linux 3.12)" +.\" commit fa7315871046b9a4c48627905691dbde57e51033 +if the hardware supports user-space read of performance counters +without syscall (this is the "rdpmc" instruction on x86), then +the following code can be used to do a read: +.ip +.in +4n +.ex +u32 seq, time_mult, time_shift, idx, width; +u64 count, enabled, running; +u64 cyc, time_offset; + +do { + seq = pc\->lock; + barrier(); + enabled = pc\->time_enabled; + running = pc\->time_running; + + if (pc\->cap_usr_time && enabled != running) { + cyc = rdtsc(); + time_offset = pc\->time_offset; + time_mult = pc\->time_mult; + time_shift = pc\->time_shift; + } + + idx = pc\->index; + count = pc\->offset; + + if (pc\->cap_usr_rdpmc && idx) { + width = pc\->pmc_width; + count += rdpmc(idx \- 1); + } + + barrier(); +} while (pc\->lock != seq); +.ee +.in +.tp +.ir cap_user_time " (since linux 3.12)" +.\" commit fa7315871046b9a4c48627905691dbde57e51033 +this bit indicates the hardware has a constant, nonstop +timestamp counter (tsc on x86). +.tp +.ir cap_user_time_zero " (since linux 3.12)" +.\" commit fa7315871046b9a4c48627905691dbde57e51033 +indicates the presence of +.i time_zero +which allows mapping timestamp values to +the hardware clock. +.tp +.i pmc_width +if +.ir cap_usr_rdpmc , +this field provides the bit-width of the value +read using the rdpmc or equivalent instruction. +this can be used to sign extend the result like: +.ip +.in +4n +.ex +pmc <<= 64 \- pmc_width; +pmc >>= 64 \- pmc_width; // signed shift right +count += pmc; +.ee +.in +.tp +.ir time_shift ", " time_mult ", " time_offset +.ip +if +.ir cap_usr_time , +these fields can be used to compute the time +delta since +.i time_enabled +(in nanoseconds) using rdtsc or similar. +.ip +.in +4n +.ex +u64 quot, rem; +u64 delta; + +quot = cyc >> time_shift; +rem = cyc & (((u64)1 << time_shift) \- 1); +delta = time_offset + quot * time_mult + + ((rem * time_mult) >> time_shift); +.ee +.in +.ip +where +.ir time_offset , +.ir time_mult , +.ir time_shift , +and +.i cyc +are read in the +seqcount loop described above. +this delta can then be added to +enabled and possible running (if idx), improving the scaling: +.ip +.in +4n +.ex +enabled += delta; +if (idx) + running += delta; +quot = count / running; +rem = count % running; +count = quot * enabled + (rem * enabled) / running; +.ee +.in +.tp +.ir time_zero " (since linux 3.12)" +.\" commit fa7315871046b9a4c48627905691dbde57e51033 +.ip +if +.i cap_usr_time_zero +is set, then the hardware clock (the tsc timestamp counter on x86) +can be calculated from the +.ir time_zero , +.ir time_mult , +and +.i time_shift +values: +.ip +.in +4n +.ex +time = timestamp \- time_zero; +quot = time / time_mult; +rem = time % time_mult; +cyc = (quot << time_shift) + (rem << time_shift) / time_mult; +.ee +.in +.ip +and vice versa: +.ip +.in +4n +.ex +quot = cyc >> time_shift; +rem = cyc & (((u64)1 << time_shift) \- 1); +timestamp = time_zero + quot * time_mult + + ((rem * time_mult) >> time_shift); +.ee +.in +.tp +.i data_head +this points to the head of the data section. +the value continuously increases, it does not wrap. +the value needs to be manually wrapped by the size of the mmap buffer +before accessing the samples. +.ip +on smp-capable platforms, after reading the +.i data_head +value, +user space should issue an rmb(). +.tp +.i data_tail +when the mapping is +.br prot_write , +the +.i data_tail +value should be written by user space to reflect the last read data. +in this case, the kernel will not overwrite unread data. +.tp +.ir data_offset " (since linux 4.1)" +.\" commit e8c6deac69629c0cb97c3d3272f8631ef17f8f0f +contains the offset of the location in the mmap buffer +where perf sample data begins. +.tp +.ir data_size " (since linux 4.1)" +.\" commit e8c6deac69629c0cb97c3d3272f8631ef17f8f0f +contains the size of the perf sample region within +the mmap buffer. +.tp +.ir aux_head ", " aux_tail ", " aux_offset ", " aux_size " (since linux 4.1)" +.\" commit 45bfb2e50471abbbfd83d40d28c986078b0d24ff +the aux region allows +.br mmap (2)-ing +a separate sample buffer for +high-bandwidth data streams (separate from the main perf sample buffer). +an example of a high-bandwidth stream is instruction tracing support, +as is found in newer intel processors. +.ip +to set up an aux area, first +.i aux_offset +needs to be set with an offset greater than +.ir data_offset + data_size +and +.i aux_size +needs to be set to the desired buffer size. +the desired offset and size must be page aligned, and the size +must be a power of two. +these values are then passed to mmap in order to map the aux buffer. +pages in the aux buffer are included as part of the +.b rlimit_memlock +resource limit (see +.br setrlimit (2)), +and also as part of the +.i perf_event_mlock_kb +allowance. +.ip +by default, the aux buffer will be truncated if it will not fit +in the available space in the ring buffer. +if the aux buffer is mapped as a read only buffer, then it will +operate in ring buffer mode where old data will be overwritten +by new. +in overwrite mode, it might not be possible to infer where the +new data began, and it is the consumer's job to disable +measurement while reading to avoid possible data races. +.ip +the +.i aux_head +and +.i aux_tail +ring buffer pointers have the same behavior and ordering +rules as the previous described +.i data_head +and +.ir data_tail . +.pp +the following 2^n ring-buffer pages have the layout described below. +.pp +if +.i perf_event_attr.sample_id_all +is set, then all event types will +have the sample_type selected fields related to where/when (identity) +an event took place (tid, time, id, cpu, stream_id) described in +.b perf_record_sample +below, it will be stashed just after the +.i perf_event_header +and the fields already present for the existing +fields, that is, at the end of the payload. +this allows a newer perf.data +file to be supported by older perf tools, with the new optional +fields being ignored. +.pp +the mmap values start with a header: +.pp +.in +4n +.ex +struct perf_event_header { + __u32 type; + __u16 misc; + __u16 size; +}; +.ee +.in +.pp +below, we describe the +.i perf_event_header +fields in more detail. +for ease of reading, +the fields with shorter descriptions are presented first. +.tp +.i size +this indicates the size of the record. +.tp +.i misc +the +.i misc +field contains additional information about the sample. +.ip +the cpu mode can be determined from this value by masking with +.b perf_record_misc_cpumode_mask +and looking for one of the following (note these are not +bit masks, only one can be set at a time): +.rs +.tp +.b perf_record_misc_cpumode_unknown +unknown cpu mode. +.tp +.b perf_record_misc_kernel +sample happened in the kernel. +.tp +.b perf_record_misc_user +sample happened in user code. +.tp +.b perf_record_misc_hypervisor +sample happened in the hypervisor. +.tp +.br perf_record_misc_guest_kernel " (since linux 2.6.35)" +.\" commit 39447b386c846bbf1c56f6403c5282837486200f +sample happened in the guest kernel. +.tp +.b perf_record_misc_guest_user " (since linux 2.6.35)" +.\" commit 39447b386c846bbf1c56f6403c5282837486200f +sample happened in guest user code. +.re +.pp +.rs +since the following three statuses are generated by +different record types, they alias to the same bit: +.tp +.br perf_record_misc_mmap_data " (since linux 3.10)" +.\" commit 2fe85427e3bf65d791700d065132772fc26e4d75 +this is set when the mapping is not executable; +otherwise the mapping is executable. +.tp +.br perf_record_misc_comm_exec " (since linux 3.16)" +.\" commit 82b897782d10fcc4930c9d4a15b175348fdd2871 +this is set for a +.b perf_record_comm +record on kernels more recent than linux 3.16 +if a process name change was caused by an +.br execve (2) +system call. +.tp +.br perf_record_misc_switch_out " (since linux 4.3)" +.\" commit 45ac1403f564f411c6a383a2448688ba8dd705a4 +when a +.b perf_record_switch +or +.b perf_record_switch_cpu_wide +record is generated, this bit indicates that the +context switch is away from the current process +(instead of into the current process). +.re +.pp +.rs +in addition, the following bits can be set: +.tp +.b perf_record_misc_exact_ip +this indicates that the content of +.b perf_sample_ip +points +to the actual instruction that triggered the event. +see also +.ir perf_event_attr.precise_ip . +.tp +.br perf_record_misc_ext_reserved " (since linux 2.6.35)" +.\" commit 1676b8a077c352085d52578fb4f29350b58b6e74 +this indicates there is extended data available (currently not used). +.tp +.b perf_record_misc_proc_map_parse_timeout +.\" commit 930e6fcd2bcce9bcd9d4aa7e755678d33f3fe6f4 +this bit is not set by the kernel. +it is reserved for the user-space perf utility to indicate that +.i /proc/i[pid]/maps +parsing was taking too long and was stopped, and thus the mmap +records may be truncated. +.re +.tp +.i type +the +.i type +value is one of the below. +the values in the corresponding record (that follows the header) +depend on the +.i type +selected as shown. +.rs +.tp 4 +.b perf_record_mmap +the mmap events record the +.b prot_exec +mappings so that we can correlate +user-space ips to code. +they have the following structure: +.ip +.in +4n +.ex +struct { + struct perf_event_header header; + u32 pid, tid; + u64 addr; + u64 len; + u64 pgoff; + char filename[]; +}; +.ee +.in +.rs +.tp +.i pid +is the process id. +.tp +.i tid +is the thread id. +.tp +.i addr +is the address of the allocated memory. +.i len +is the length of the allocated memory. +.i pgoff +is the page offset of the allocated memory. +.i filename +is a string describing the backing of the allocated memory. +.re +.tp +.b perf_record_lost +this record indicates when events are lost. +.ip +.in +4n +.ex +struct { + struct perf_event_header header; + u64 id; + u64 lost; + struct sample_id sample_id; +}; +.ee +.in +.rs +.tp +.i id +is the unique event id for the samples that were lost. +.tp +.i lost +is the number of events that were lost. +.re +.tp +.b perf_record_comm +this record indicates a change in the process name. +.ip +.in +4n +.ex +struct { + struct perf_event_header header; + u32 pid; + u32 tid; + char comm[]; + struct sample_id sample_id; +}; +.ee +.in +.rs +.tp +.i pid +is the process id. +.tp +.i tid +is the thread id. +.tp +.i comm +is a string containing the new name of the process. +.re +.tp +.b perf_record_exit +this record indicates a process exit event. +.ip +.in +4n +.ex +struct { + struct perf_event_header header; + u32 pid, ppid; + u32 tid, ptid; + u64 time; + struct sample_id sample_id; +}; +.ee +.in +.tp +.br perf_record_throttle ", " perf_record_unthrottle +this record indicates a throttle/unthrottle event. +.ip +.in +4n +.ex +struct { + struct perf_event_header header; + u64 time; + u64 id; + u64 stream_id; + struct sample_id sample_id; +}; +.ee +.in +.tp +.b perf_record_fork +this record indicates a fork event. +.ip +.in +4n +.ex +struct { + struct perf_event_header header; + u32 pid, ppid; + u32 tid, ptid; + u64 time; + struct sample_id sample_id; +}; +.ee +.in +.tp +.b perf_record_read +this record indicates a read event. +.ip +.in +4n +.ex +struct { + struct perf_event_header header; + u32 pid, tid; + struct read_format values; + struct sample_id sample_id; +}; +.ee +.in +.tp +.b perf_record_sample +this record indicates a sample. +.ip +.in +4n +.ex +struct { + struct perf_event_header header; + u64 sample_id; /* if perf_sample_identifier */ + u64 ip; /* if perf_sample_ip */ + u32 pid, tid; /* if perf_sample_tid */ + u64 time; /* if perf_sample_time */ + u64 addr; /* if perf_sample_addr */ + u64 id; /* if perf_sample_id */ + u64 stream_id; /* if perf_sample_stream_id */ + u32 cpu, res; /* if perf_sample_cpu */ + u64 period; /* if perf_sample_period */ + struct read_format v; + /* if perf_sample_read */ + u64 nr; /* if perf_sample_callchain */ + u64 ips[nr]; /* if perf_sample_callchain */ + u32 size; /* if perf_sample_raw */ + char data[size]; /* if perf_sample_raw */ + u64 bnr; /* if perf_sample_branch_stack */ + struct perf_branch_entry lbr[bnr]; + /* if perf_sample_branch_stack */ + u64 abi; /* if perf_sample_regs_user */ + u64 regs[weight(mask)]; + /* if perf_sample_regs_user */ + u64 size; /* if perf_sample_stack_user */ + char data[size]; /* if perf_sample_stack_user */ + u64 dyn_size; /* if perf_sample_stack_user && + size != 0 */ + u64 weight; /* if perf_sample_weight */ + u64 data_src; /* if perf_sample_data_src */ + u64 transaction; /* if perf_sample_transaction */ + u64 abi; /* if perf_sample_regs_intr */ + u64 regs[weight(mask)]; + /* if perf_sample_regs_intr */ + u64 phys_addr; /* if perf_sample_phys_addr */ + u64 cgroup; /* if perf_sample_cgroup */ +}; +.ee +.in +.rs 4 +.tp 4 +.i sample_id +if +.b perf_sample_identifier +is enabled, a 64-bit unique id is included. +this is a duplication of the +.b perf_sample_id +.i id +value, but included at the beginning of the sample +so parsers can easily obtain the value. +.tp +.i ip +if +.b perf_sample_ip +is enabled, then a 64-bit instruction +pointer value is included. +.tp +.ir pid ", " tid +if +.b perf_sample_tid +is enabled, then a 32-bit process id +and 32-bit thread id are included. +.tp +.i time +if +.b perf_sample_time +is enabled, then a 64-bit timestamp +is included. +this is obtained via local_clock() which is a hardware timestamp +if available and the jiffies value if not. +.tp +.i addr +if +.b perf_sample_addr +is enabled, then a 64-bit address is included. +this is usually the address of a tracepoint, +breakpoint, or software event; otherwise the value is 0. +.tp +.i id +if +.b perf_sample_id +is enabled, a 64-bit unique id is included. +if the event is a member of an event group, the group leader id is returned. +this id is the same as the one returned by +.br perf_format_id . +.tp +.i stream_id +if +.b perf_sample_stream_id +is enabled, a 64-bit unique id is included. +unlike +.b perf_sample_id +the actual id is returned, not the group leader. +this id is the same as the one returned by +.br perf_format_id . +.tp +.ir cpu ", " res +if +.b perf_sample_cpu +is enabled, this is a 32-bit value indicating +which cpu was being used, in addition to a reserved (unused) +32-bit value. +.tp +.i period +if +.b perf_sample_period +is enabled, a 64-bit value indicating +the current sampling period is written. +.tp +.i v +if +.b perf_sample_read +is enabled, a structure of type read_format +is included which has values for all events in the event group. +the values included depend on the +.i read_format +value used at +.br perf_event_open () +time. +.tp +.ir nr ", " ips[nr] +if +.b perf_sample_callchain +is enabled, then a 64-bit number is included +which indicates how many following 64-bit instruction pointers will +follow. +this is the current callchain. +.tp +.ir size ", " data[size] +if +.b perf_sample_raw +is enabled, then a 32-bit value indicating size +is included followed by an array of 8-bit values of length size. +the values are padded with 0 to have 64-bit alignment. +.ip +this raw record data is opaque with respect to the abi. +the abi doesn't make any promises with respect to the stability +of its content, it may vary depending +on event, hardware, and kernel version. +.tp +.ir bnr ", " lbr[bnr] +if +.b perf_sample_branch_stack +is enabled, then a 64-bit value indicating +the number of records is included, followed by +.i bnr +.i perf_branch_entry +structures which each include the fields: +.rs +.tp +.i from +this indicates the source instruction (may not be a branch). +.tp +.i to +the branch target. +.tp +.i mispred +the branch target was mispredicted. +.tp +.i predicted +the branch target was predicted. +.tp +.ir in_tx " (since linux 3.11)" +.\" commit 135c5612c460f89657c4698fe2ea753f6f667963 +the branch was in a transactional memory transaction. +.tp +.ir abort " (since linux 3.11)" +.\" commit 135c5612c460f89657c4698fe2ea753f6f667963 +the branch was in an aborted transactional memory transaction. +.tp +.ir cycles " (since linux 4.3)" +.\" commit 71ef3c6b9d4665ee7afbbe4c208a98917dcfc32f +this reports the number of cycles elapsed since the +previous branch stack update. +.pp +the entries are from most to least recent, so the first entry +has the most recent branch. +.pp +support for +.ir mispred , +.ir predicted , +and +.i cycles +is optional; if not supported, those +values will be 0. +.pp +the type of branches recorded is specified by the +.i branch_sample_type +field. +.re +.tp +.ir abi ", " regs[weight(mask)] +if +.b perf_sample_regs_user +is enabled, then the user cpu registers are recorded. +.ip +the +.i abi +field is one of +.br perf_sample_regs_abi_none , +.br perf_sample_regs_abi_32 , +or +.br perf_sample_regs_abi_64 . +.ip +the +.i regs +field is an array of the cpu registers that were specified by +the +.i sample_regs_user +attr field. +the number of values is the number of bits set in the +.i sample_regs_user +bit mask. +.tp +.ir size ", " data[size] ", " dyn_size +if +.b perf_sample_stack_user +is enabled, then the user stack is recorded. +this can be used to generate stack backtraces. +.i size +is the size requested by the user in +.i sample_stack_user +or else the maximum record size. +.i data +is the stack data (a raw dump of the memory pointed to by the +stack pointer at the time of sampling). +.i dyn_size +is the amount of data actually dumped (can be less than +.ir size ). +note that +.i dyn_size +is omitted if +.i size +is 0. +.tp +.i weight +if +.b perf_sample_weight +is enabled, then a 64-bit value provided by the hardware +is recorded that indicates how costly the event was. +this allows expensive events to stand out more clearly +in profiles. +.tp +.i data_src +if +.b perf_sample_data_src +is enabled, then a 64-bit value is recorded that is made up of +the following fields: +.rs +.tp 4 +.i mem_op +type of opcode, a bitwise combination of: +.ip +.pd 0 +.rs +.tp 24 +.b perf_mem_op_na +not available +.tp +.b perf_mem_op_load +load instruction +.tp +.b perf_mem_op_store +store instruction +.tp +.b perf_mem_op_pfetch +prefetch +.tp +.b perf_mem_op_exec +executable code +.re +.pd +.tp +.i mem_lvl +memory hierarchy level hit or miss, a bitwise combination of +the following, shifted left by +.br perf_mem_lvl_shift : +.ip +.pd 0 +.rs +.tp 24 +.b perf_mem_lvl_na +not available +.tp +.b perf_mem_lvl_hit +hit +.tp +.b perf_mem_lvl_miss +miss +.tp +.b perf_mem_lvl_l1 +level 1 cache +.tp +.b perf_mem_lvl_lfb +line fill buffer +.tp +.b perf_mem_lvl_l2 +level 2 cache +.tp +.b perf_mem_lvl_l3 +level 3 cache +.tp +.b perf_mem_lvl_loc_ram +local dram +.tp +.b perf_mem_lvl_rem_ram1 +remote dram 1 hop +.tp +.b perf_mem_lvl_rem_ram2 +remote dram 2 hops +.tp +.b perf_mem_lvl_rem_cce1 +remote cache 1 hop +.tp +.b perf_mem_lvl_rem_cce2 +remote cache 2 hops +.tp +.b perf_mem_lvl_io +i/o memory +.tp +.b perf_mem_lvl_unc +uncached memory +.re +.pd +.tp +.i mem_snoop +snoop mode, a bitwise combination of the following, shifted left by +.br perf_mem_snoop_shift : +.ip +.pd 0 +.rs +.tp 24 +.b perf_mem_snoop_na +not available +.tp +.b perf_mem_snoop_none +no snoop +.tp +.b perf_mem_snoop_hit +snoop hit +.tp +.b perf_mem_snoop_miss +snoop miss +.tp +.b perf_mem_snoop_hitm +snoop hit modified +.re +.pd +.tp +.i mem_lock +lock instruction, a bitwise combination of the following, shifted left by +.br perf_mem_lock_shift : +.ip +.pd 0 +.rs +.tp 24 +.b perf_mem_lock_na +not available +.tp +.b perf_mem_lock_locked +locked transaction +.re +.pd +.tp +.i mem_dtlb +tlb access hit or miss, a bitwise combination of the following, shifted +left by +.br perf_mem_tlb_shift : +.ip +.pd 0 +.rs +.tp 24 +.b perf_mem_tlb_na +not available +.tp +.b perf_mem_tlb_hit +hit +.tp +.b perf_mem_tlb_miss +miss +.tp +.b perf_mem_tlb_l1 +level 1 tlb +.tp +.b perf_mem_tlb_l2 +level 2 tlb +.tp +.b perf_mem_tlb_wk +hardware walker +.tp +.b perf_mem_tlb_os +os fault handler +.re +.pd +.re +.tp +.i transaction +if the +.b perf_sample_transaction +flag is set, then a 64-bit field is recorded describing +the sources of any transactional memory aborts. +.ip +the field is a bitwise combination of the following values: +.rs +.tp +.b perf_txn_elision +abort from an elision type transaction (intel-cpu-specific). +.tp +.b perf_txn_transaction +abort from a generic transaction. +.tp +.b perf_txn_sync +synchronous abort (related to the reported instruction). +.tp +.b perf_txn_async +asynchronous abort (not related to the reported instruction). +.tp +.b perf_txn_retry +retryable abort (retrying the transaction may have succeeded). +.tp +.b perf_txn_conflict +abort due to memory conflicts with other threads. +.tp +.b perf_txn_capacity_write +abort due to write capacity overflow. +.tp +.b perf_txn_capacity_read +abort due to read capacity overflow. +.re +.ip +in addition, a user-specified abort code can be obtained from +the high 32 bits of the field by shifting right by +.b perf_txn_abort_shift +and masking with the value +.br perf_txn_abort_mask . +.tp +.ir abi ", " regs[weight(mask)] +if +.b perf_sample_regs_intr +is enabled, then the user cpu registers are recorded. +.ip +the +.i abi +field is one of +.br perf_sample_regs_abi_none , +.br perf_sample_regs_abi_32 , +or +.br perf_sample_regs_abi_64 . +.ip +the +.i regs +field is an array of the cpu registers that were specified by +the +.i sample_regs_intr +attr field. +the number of values is the number of bits set in the +.i sample_regs_intr +bit mask. +.tp +.i phys_addr +if the +.b perf_sample_phys_addr +flag is set, then the 64-bit physical address is recorded. +.tp +.i cgroup +if the +.b perf_sample_cgroup +flag is set, +then the 64-bit cgroup id (for the perf_event subsystem) is recorded. +to get the pathname of the cgroup, the id should match to one in a +.b perf_record_cgroup . +.re +.tp +.b perf_record_mmap2 +this record includes extended information on +.br mmap (2) +calls returning executable mappings. +the format is similar to that of the +.b perf_record_mmap +record, but includes extra values that allow uniquely identifying +shared mappings. +.ip +.in +4n +.ex +struct { + struct perf_event_header header; + u32 pid; + u32 tid; + u64 addr; + u64 len; + u64 pgoff; + u32 maj; + u32 min; + u64 ino; + u64 ino_generation; + u32 prot; + u32 flags; + char filename[]; + struct sample_id sample_id; +}; +.ee +.in +.rs +.tp +.i pid +is the process id. +.tp +.i tid +is the thread id. +.tp +.i addr +is the address of the allocated memory. +.tp +.i len +is the length of the allocated memory. +.tp +.i pgoff +is the page offset of the allocated memory. +.tp +.i maj +is the major id of the underlying device. +.tp +.i min +is the minor id of the underlying device. +.tp +.i ino +is the inode number. +.tp +.i ino_generation +is the inode generation. +.tp +.i prot +is the protection information. +.tp +.i flags +is the flags information. +.tp +.i filename +is a string describing the backing of the allocated memory. +.re +.tp +.br perf_record_aux " (since linux 4.1)" +.\" commit 68db7e98c3a6ebe7284b6cf14906ed7c55f3f7f0 +this record reports that new data is available in the separate +aux buffer region. +.ip +.in +4n +.ex +struct { + struct perf_event_header header; + u64 aux_offset; + u64 aux_size; + u64 flags; + struct sample_id sample_id; +}; +.ee +.in +.rs +.tp +.i aux_offset +offset in the aux mmap region where the new data begins. +.tp +.i aux_size +size of the data made available. +.tp +.i flags +describes the aux update. +.rs +.tp +.b perf_aux_flag_truncated +if set, then the data returned was truncated to fit the available +buffer size. +.tp +.b perf_aux_flag_overwrite +.\" commit 2023a0d2829e521fe6ad6b9907f3f90bfbf57142 +if set, then the data returned has overwritten previous data. +.re +.re +.tp +.br perf_record_itrace_start " (since linux 4.1)" +.\" ec0d7729bbaed4b9d2d3fada693278e13a3d1368 +this record indicates which process has initiated an instruction +trace event, allowing tools to properly correlate the instruction +addresses in the aux buffer with the proper executable. +.ip +.in +4n +.ex +struct { + struct perf_event_header header; + u32 pid; + u32 tid; +}; +.ee +.in +.rs +.tp +.i pid +process id of the thread starting an instruction trace. +.tp +.i tid +thread id of the thread starting an instruction trace. +.re +.tp +.br perf_record_lost_samples " (since linux 4.2)" +.\" f38b0dbb491a6987e198aa6b428db8692a6480f8 +when using hardware sampling (such as intel pebs) this record +indicates some number of samples that may have been lost. +.ip +.in +4n +.ex +struct { + struct perf_event_header header; + u64 lost; + struct sample_id sample_id; +}; +.ee +.in +.rs +.tp +.i lost +the number of potentially lost samples. +.re +.tp +.br perf_record_switch " (since linux 4.3)" +.\" commit 45ac1403f564f411c6a383a2448688ba8dd705a4 +this record indicates a context switch has happened. +the +.b perf_record_misc_switch_out +bit in the +.i misc +field indicates whether it was a context switch into +or away from the current process. +.ip +.in +4n +.ex +struct { + struct perf_event_header header; + struct sample_id sample_id; +}; +.ee +.in +.tp +.br perf_record_switch_cpu_wide " (since linux 4.3)" +.\" commit 45ac1403f564f411c6a383a2448688ba8dd705a4 +as with +.b perf_record_switch +this record indicates a context switch has happened, +but it only occurs when sampling in cpu-wide mode +and provides additional information on the process +being switched to/from. +the +.b perf_record_misc_switch_out +bit in the +.i misc +field indicates whether it was a context switch into +or away from the current process. +.ip +.in +4n +.ex +struct { + struct perf_event_header header; + u32 next_prev_pid; + u32 next_prev_tid; + struct sample_id sample_id; +}; +.ee +.in +.rs +.tp +.i next_prev_pid +the process id of the previous (if switching in) +or next (if switching out) process on the cpu. +.tp +.i next_prev_tid +the thread id of the previous (if switching in) +or next (if switching out) thread on the cpu. +.re +.tp +.br perf_record_namespaces " (since linux 4.11)" +.\" commit e422267322cd319e2695a535e47c5b1feeac45eb +this record includes various namespace information of a process. +.ip +.in +4n +.ex +struct { + struct perf_event_header header; + u32 pid; + u32 tid; + u64 nr_namespaces; + struct { u64 dev, inode } [nr_namespaces]; + struct sample_id sample_id; +}; +.ee +.in +.rs +.tp +.i pid +is the process id +.tp +.i tid +is the thread id +.tp +.i nr_namespace +is the number of namespaces in this record +.re +.ip +each namespace has +.i dev +and +.i inode +fields and is recorded in the +fixed position like below: +.rs +.tp +.br net_ns_index = 0 +network namespace +.tp +.br uts_ns_index = 1 +uts namespace +.tp +.br ipc_ns_index = 2 +ipc namespace +.tp +.br pid_ns_index = 3 +pid namespace +.tp +.br user_ns_index = 4 +user namespace +.tp +.br mnt_ns_index = 5 +mount namespace +.tp +.br cgroup_ns_index = 6 +cgroup namespace +.re +.tp +.br perf_record_ksymbol " (since linux 5.0)" +.\" commit 76193a94522f1d4edf2447a536f3f796ce56343b +this record indicates kernel symbol register/unregister events. +.ip +.in +4n +.ex +struct { + struct perf_event_header header; + u64 addr; + u32 len; + u16 ksym_type; + u16 flags; + char name[]; + struct sample_id sample_id; +}; +.ee +.in +.rs +.tp +.i addr +is the address of the kernel symbol. +.tp +.i len +is the length of the kernel symbol. +.tp +.i ksym_type +is the type of the kernel symbol. +currently the following types are available: +.rs +.tp +.b perf_record_ksymbol_type_bpf +the kernel symbol is a bpf function. +.re +.tp +.i flags +if the +.b perf_record_ksymbol_flags_unregister +is set, then this event is for unregistering the kernel symbol. +.re +.tp +.br perf_record_bpf_event " (since linux 5.0)" +.\" commit 6ee52e2a3fe4ea35520720736e6791df1fb67106 +this record indicates bpf program is loaded or unloaded. +.ip +.in +4n +.ex +struct { + struct perf_event_header header; + u16 type; + u16 flags; + u32 id; + u8 tag[bpf_tag_size]; + struct sample_id sample_id; +}; +.ee +.in +.rs +.tp +.i type +is one of the following values: +.rs +.tp +.b perf_bpf_event_prog_load +a bpf program is loaded +.tp +.b perf_bpf_event_prog_unload +a bpf program is unloaded +.re +.tp +.i id +is the id of the bpf program. +.tp +.i tag +is the tag of the bpf program. +currently, +.b bpf_tag_size +is defined as 8. +.re +.tp +.br perf_record_cgroup " (since linux 5.7)" +.\" commit 96aaab686505c449e24d76e76507290dcc30e008 +this record indicates a new cgroup is created and activated. +.ip +.in +4n +.ex +struct { + struct perf_event_header header; + u64 id; + char path[]; + struct sample_id sample_id; +}; +.ee +.in +.rs +.tp +.i id +is the cgroup identifier. +this can be also retrieved by +.br name_to_handle_at (2) +on the cgroup path (as a file handle). +.tp +.i path +is the path of the cgroup from the root. +.re +.tp +.br perf_record_text_poke " (since linux 5.8)" +.\" commit e17d43b93e544f5016c0251d2074c15568d5d963 +this record indicates a change in the kernel text. +this includes addition and removal of the text +and the corresponding length is zero in this case. +.ip +.in +4n +.ex +struct { + struct perf_event_header header; + u64 addr; + u16 old_len; + u16 new_len; + u8 bytes[]; + struct sample_id sample_id; +}; +.ee +.in +.rs +.tp +.i addr +is the address of the change +.tp +.i old_len +is the old length +.tp +.i new_len +is the new length +.tp +.i bytes +contains old bytes immediately followed by new bytes. +.re +.re +.ss overflow handling +events can be set to notify when a threshold is crossed, +indicating an overflow. +overflow conditions can be captured by monitoring the +event file descriptor with +.br poll (2), +.br select (2), +or +.br epoll (7). +alternatively, the overflow events can be captured via sa signal handler, +by enabling i/o signaling on the file descriptor; see the discussion of the +.br f_setown +and +.br f_setsig +operations in +.br fcntl (2). +.pp +overflows are generated only by sampling events +.ri ( sample_period +must have a nonzero value). +.pp +there are two ways to generate overflow notifications. +.pp +the first is to set a +.i wakeup_events +or +.i wakeup_watermark +value that will trigger if a certain number of samples +or bytes have been written to the mmap ring buffer. +in this case, +.b poll_in +is indicated. +.pp +the other way is by use of the +.b perf_event_ioc_refresh +ioctl. +this ioctl adds to a counter that decrements each time the event overflows. +when nonzero, +.b poll_in +is indicated, but +once the counter reaches 0 +.b poll_hup +is indicated and +the underlying event is disabled. +.pp +refreshing an event group leader refreshes all siblings and +refreshing with a parameter of 0 currently enables infinite +refreshes; +these behaviors are unsupported and should not be relied on. +.\" see https://lkml.org/lkml/2011/5/24/337 +.pp +starting with linux 3.18, +.\" commit 179033b3e064d2cd3f5f9945e76b0a0f0fbf4883 +.b poll_hup +is indicated if the event being monitored is attached to a different +process and that process exits. +.ss rdpmc instruction +starting with linux 3.4 on x86, you can use the +.\" commit c7206205d00ab375839bd6c7ddb247d600693c09 +.i rdpmc +instruction to get low-latency reads without having to enter the kernel. +note that using +.i rdpmc +is not necessarily faster than other methods for reading event values. +.pp +support for this can be detected with the +.i cap_usr_rdpmc +field in the mmap page; documentation on how +to calculate event values can be found in that section. +.pp +originally, when rdpmc support was enabled, any process (not just ones +with an active perf event) could use the rdpmc instruction to access +the counters. +starting with linux 4.0, +.\" 7911d3f7af14a614617e38245fedf98a724e46a9 +rdpmc support is only allowed if an event is currently enabled +in a process's context. +to restore the old behavior, write the value 2 to +.ir /sys/devices/cpu/rdpmc . +.ss perf_event ioctl calls +various ioctls act on +.br perf_event_open () +file descriptors: +.tp +.b perf_event_ioc_enable +this enables the individual event or event group specified by the +file descriptor argument. +.ip +if the +.b perf_ioc_flag_group +bit is set in the ioctl argument, then all events in a group are +enabled, even if the event specified is not the group leader +(but see bugs). +.tp +.b perf_event_ioc_disable +this disables the individual counter or event group specified by the +file descriptor argument. +.ip +enabling or disabling the leader of a group enables or disables the +entire group; that is, while the group leader is disabled, none of the +counters in the group will count. +enabling or disabling a member of a group other than the leader +affects only that counter; disabling a non-leader +stops that counter from counting but doesn't affect any other counter. +.ip +if the +.b perf_ioc_flag_group +bit is set in the ioctl argument, then all events in a group are +disabled, even if the event specified is not the group leader +(but see bugs). +.tp +.b perf_event_ioc_refresh +non-inherited overflow counters can use this +to enable a counter for a number of overflows specified by the argument, +after which it is disabled. +subsequent calls of this ioctl add the argument value to the current +count. +an overflow notification with +.b poll_in +set will happen on each overflow until the +count reaches 0; when that happens a notification with +.b poll_hup +set is sent and the event is disabled. +using an argument of 0 is considered undefined behavior. +.tp +.b perf_event_ioc_reset +reset the event count specified by the +file descriptor argument to zero. +this resets only the counts; there is no way to reset the +multiplexing +.i time_enabled +or +.i time_running +values. +.ip +if the +.b perf_ioc_flag_group +bit is set in the ioctl argument, then all events in a group are +reset, even if the event specified is not the group leader +(but see bugs). +.tp +.b perf_event_ioc_period +this updates the overflow period for the event. +.ip +since linux 3.7 (on arm) +.\" commit 3581fe0ef37ce12ac7a4f74831168352ae848edc +and linux 3.14 (all other architectures), +.\" commit bad7192b842c83e580747ca57104dd51fe08c223 +the new period takes effect immediately. +on older kernels, the new period did not take effect until +after the next overflow. +.ip +the argument is a pointer to a 64-bit value containing the +desired new period. +.ip +prior to linux 2.6.36, +.\" commit ad0cf3478de8677f720ee06393b3147819568d6a +this ioctl always failed due to a bug +in the kernel. +.tp +.b perf_event_ioc_set_output +this tells the kernel to report event notifications to the specified +file descriptor rather than the default one. +the file descriptors must all be on the same cpu. +.ip +the argument specifies the desired file descriptor, or \-1 if +output should be ignored. +.tp +.br perf_event_ioc_set_filter " (since linux 2.6.33)" +.\" commit 6fb2915df7f0747d9044da9dbff5b46dc2e20830 +this adds an ftrace filter to this event. +.ip +the argument is a pointer to the desired ftrace filter. +.tp +.br perf_event_ioc_id " (since linux 3.12)" +.\" commit cf4957f17f2a89984915ea808876d9c82225b862 +this returns the event id value for the given event file descriptor. +.ip +the argument is a pointer to a 64-bit unsigned integer +to hold the result. +.tp +.br perf_event_ioc_set_bpf " (since linux 4.1)" +.\" commit 2541517c32be2531e0da59dfd7efc1ce844644f5 +this allows attaching a berkeley packet filter (bpf) +program to an existing kprobe tracepoint event. +you need +.b cap_perfmon +(since linux 5.8) or +.b cap_sys_admin +privileges to use this ioctl. +.ip +the argument is a bpf program file descriptor that was created by +a previous +.br bpf (2) +system call. +.tp +.br perf_event_ioc_pause_output " (since linux 4.7)" +.\" commit 86e7972f690c1017fd086cdfe53d8524e68c661c +this allows pausing and resuming the event's ring-buffer. +a paused ring-buffer does not prevent generation of samples, +but simply discards them. +the discarded samples are considered lost, and cause a +.br perf_record_lost +sample to be generated when possible. +an overflow signal may still be triggered by the discarded sample +even though the ring-buffer remains empty. +.ip +the argument is an unsigned 32-bit integer. +a nonzero value pauses the ring-buffer, while a +zero value resumes the ring-buffer. +.tp +.br perf_event_modify_attributes " (since linux 4.17)" +.\" commit 32ff77e8cc9e66cc4fb38098f64fd54cc8f54573 +this allows modifying an existing event without the overhead +of closing and reopening a new event. +currently this is supported only for breakpoint events. +.ip +the argument is a pointer to a +.i perf_event_attr +structure containing the updated event settings. +.tp +.br perf_event_ioc_query_bpf " (since linux 4.16)" +.\" commit f371b304f12e31fe30207c41ca7754564e0ea4dc +this allows querying which berkeley packet filter (bpf) +programs are attached to an existing kprobe tracepoint. +you can only attach one bpf program per event, but you can +have multiple events attached to a tracepoint. +querying this value on one tracepoint event returns the id +of all bpf programs in all events attached to the tracepoint. +you need +.b cap_perfmon +(since linux 5.8) or +.b cap_sys_admin +privileges to use this ioctl. +.ip +the argument is a pointer to a structure +.in +4n +.ex +struct perf_event_query_bpf { + __u32 ids_len; + __u32 prog_cnt; + __u32 ids[0]; +}; +.ee +.in +.ip +the +.i ids_len +field indicates the number of ids that can fit in the provided +.i ids +array. +the +.i prog_cnt +value is filled in by the kernel with the number of attached +bpf programs. +the +.i ids +array is filled with the id of each attached bpf program. +if there are more programs than will fit in the array, then the +kernel will return +.b enospc +and +.i ids_len +will indicate the number of program ids that were successfully copied. +.\" +.ss using prctl(2) +a process can enable or disable all currently open event groups +using the +.br prctl (2) +.b pr_task_perf_events_enable +and +.b pr_task_perf_events_disable +operations. +this applies only to events created locally by the calling process. +this does not apply to events created by other processes attached +to the calling process or inherited events from a parent process. +only group leaders are enabled and disabled, +not any other members of the groups. +.ss perf_event related configuration files +files in +.i /proc/sys/kernel/ +.rs 4 +.tp +.i /proc/sys/kernel/perf_event_paranoid +the +.i perf_event_paranoid +file can be set to restrict access to the performance counters. +.ip +.pd 0 +.rs +.ip 2 4 +allow only user-space measurements (default since linux 4.6). +.\" default changed in commit 0161028b7c8aebef64194d3d73e43bc3b53b5c66 +.ip 1 +allow both kernel and user measurements (default before linux 4.6). +.ip 0 +allow access to cpu-specific data but not raw tracepoint samples. +.ip \-1 +no restrictions. +.re +.pd +.ip +the existence of the +.i perf_event_paranoid +file is the official method for determining if a kernel supports +.br perf_event_open (). +.tp +.i /proc/sys/kernel/perf_event_max_sample_rate +this sets the maximum sample rate. +setting this too high can allow +users to sample at a rate that impacts overall machine performance +and potentially lock up the machine. +the default value is +100000 (samples per second). +.tp +.i /proc/sys/kernel/perf_event_max_stack +.\" introduced in c5dfd78eb79851e278b7973031b9ca363da87a7e +this file sets the maximum depth of stack frame entries reported +when generating a call trace. +.tp +.i /proc/sys/kernel/perf_event_mlock_kb +maximum number of pages an unprivileged user can +.br mlock (2). +the default is 516 (kb). +.re +.pp +files in +.i /sys/bus/event_source/devices/ +.pp +.rs 4 +since linux 2.6.34, the kernel supports having multiple pmus +available for monitoring. +information on how to program these pmus can be found under +.ir /sys/bus/event_source/devices/ . +each subdirectory corresponds to a different pmu. +.tp +.ir /sys/bus/event_source/devices/*/type " (since linux 2.6.38)" +.\" commit abe43400579d5de0078c2d3a760e6598e183f871 +this contains an integer that can be used in the +.i type +field of +.i perf_event_attr +to indicate that you wish to use this pmu. +.tp +.ir /sys/bus/event_source/devices/cpu/rdpmc " (since linux 3.4)" +.\" commit 0c9d42ed4cee2aa1dfc3a260b741baae8615744f +if this file is 1, then direct user-space access to the +performance counter registers is allowed via the rdpmc instruction. +this can be disabled by echoing 0 to the file. +.ip +as of linux 4.0 +.\" a66734297f78707ce39d756b656bfae861d53f62 +.\" 7911d3f7af14a614617e38245fedf98a724e46a9 +the behavior has changed, so that 1 now means only allow access +to processes with active perf events, with 2 indicating the old +allow-anyone-access behavior. +.tp +.ir /sys/bus/event_source/devices/*/format/ " (since linux 3.4)" +.\" commit 641cc938815dfd09f8fa1ec72deb814f0938ac33 +this subdirectory contains information on the architecture-specific +subfields available for programming the various +.i config +fields in the +.i perf_event_attr +struct. +.ip +the content of each file is the name of the config field, followed +by a colon, followed by a series of integer bit ranges separated by +commas. +for example, the file +.i event +may contain the value +.i config1:1,6\-10,44 +which indicates that event is an attribute that occupies bits 1,6\(en10, and 44 +of +.ir perf_event_attr::config1 . +.tp +.ir /sys/bus/event_source/devices/*/events/ " (since linux 3.4)" +.\" commit 641cc938815dfd09f8fa1ec72deb814f0938ac33 +this subdirectory contains files with predefined events. +the contents are strings describing the event settings +expressed in terms of the fields found in the previously mentioned +.i ./format/ +directory. +these are not necessarily complete lists of all events supported by +a pmu, but usually a subset of events deemed useful or interesting. +.ip +the content of each file is a list of attribute names +separated by commas. +each entry has an optional value (either hex or decimal). +if no value is specified, then it is assumed to be a single-bit +field with a value of 1. +an example entry may look like this: +.ir event=0x2,inv,ldlat=3 . +.tp +.i /sys/bus/event_source/devices/*/uevent +this file is the standard kernel device interface +for injecting hotplug events. +.tp +.ir /sys/bus/event_source/devices/*/cpumask " (since linux 3.7)" +.\" commit 314d9f63f385096580e9e2a06eaa0745d92fe4ac +the +.i cpumask +file contains a comma-separated list of integers that +indicate a representative cpu number for each socket (package) +on the motherboard. +this is needed when setting up uncore or northbridge events, as +those pmus present socket-wide events. +.re +.sh return value +on success, +.br perf_event_open () +returns the new file descriptor. +on error, \-1 is returned and +.i errno +is set to indicate the error. +.sh errors +the errors returned by +.br perf_event_open () +can be inconsistent, and may +vary across processor architectures and performance monitoring units. +.tp +.b e2big +returned if the +.i perf_event_attr +.i size +value is too small +(smaller than +.br perf_attr_size_ver0 ), +too big (larger than the page size), +or larger than the kernel supports and the extra bytes are not zero. +when +.b e2big +is returned, the +.i perf_event_attr +.i size +field is overwritten by the kernel to be the size of the structure +it was expecting. +.tp +.b eacces +returned when the requested event requires +.b cap_perfmon +(since linux 5.8) or +.b cap_sys_admin +permissions (or a more permissive perf_event paranoid setting). +some common cases where an unprivileged process +may encounter this error: +attaching to a process owned by a different user; +monitoring all processes on a given cpu (i.e., specifying the +.i pid +argument as \-1); +and not setting +.i exclude_kernel +when the paranoid setting requires it. +.tp +.b ebadf +returned if the +.i group_fd +file descriptor is not valid, or, if +.b perf_flag_pid_cgroup +is set, +the cgroup file descriptor in +.i pid +is not valid. +.tp +.br ebusy " (since linux 4.1)" +.\" bed5b25ad9c8a2f5d735ef0bc746ec870c01c1b0 +returned if another event already has exclusive +access to the pmu. +.tp +.b efault +returned if the +.i attr +pointer points at an invalid memory address. +.tp +.b eintr +returned when trying to mix perf and ftrace handling +for a uprobe. +.tp +.b einval +returned if the specified event is invalid. +there are many possible reasons for this. +a not-exhaustive list: +.i sample_freq +is higher than the maximum setting; +the +.i cpu +to monitor does not exist; +.i read_format +is out of range; +.i sample_type +is out of range; +the +.i flags +value is out of range; +.i exclusive +or +.i pinned +set and the event is not a group leader; +the event +.i config +values are out of range or set reserved bits; +the generic event selected is not supported; or +there is not enough room to add the selected event. +.tp +.b emfile +each opened event uses one file descriptor. +if a large number of events are opened, +the per-process limit on the number of open file descriptors will be reached, +and no more events can be created. +.tp +.b enodev +returned when the event involves a feature not supported +by the current cpu. +.tp +.b enoent +returned if the +.i type +setting is not valid. +this error is also returned for +some unsupported generic events. +.tp +.b enospc +prior to linux 3.3, if there was not enough room for the event, +.\" commit aa2bc1ade59003a379ffc485d6da2d92ea3370a6 +.b enospc +was returned. +in linux 3.3, this was changed to +.br einval . +.b enospc +is still returned if you try to add more breakpoint events +than supported by the hardware. +.tp +.b enosys +returned if +.b perf_sample_stack_user +is set in +.i sample_type +and it is not supported by hardware. +.tp +.b eopnotsupp +returned if an event requiring a specific hardware feature is +requested but there is no hardware support. +this includes requesting low-skid events if not supported, +branch tracing if it is not available, sampling if no pmu +interrupt is available, and branch stacks for software events. +.tp +.br eoverflow " (since linux 4.8)" +.\" 97c79a38cd454602645f0470ffb444b3b75ce574 +returned if +.b perf_sample_callchain +is requested and +.i sample_max_stack +is larger than the maximum specified in +.ir /proc/sys/kernel/perf_event_max_stack . +.tp +.b eperm +returned on many (but not all) architectures when an unsupported +.ir exclude_hv ", " exclude_idle ", " exclude_user ", or " exclude_kernel +setting is specified. +.ip +it can also happen, as with +.br eacces , +when the requested event requires +.b cap_perfmon +(since linux 5.8) or +.b cap_sys_admin +permissions (or a more permissive perf_event paranoid setting). +this includes setting a breakpoint on a kernel address, +and (since linux 3.13) setting a kernel function-trace tracepoint. +.\" commit a4e95fc2cbb31d70a65beffeaf8773f881328c34 +.tp +.b esrch +returned if attempting to attach to a process that does not exist. +.sh version +.br perf_event_open () +was introduced in linux 2.6.31 but was called +.\" commit 0793a61d4df8daeac6492dbf8d2f3e5713caae5e +.br perf_counter_open (). +it was renamed in linux 2.6.32. +.\" commit cdd6c482c9ff9c55475ee7392ec8f672eddb7be6 +.sh conforming to +this +.br perf_event_open () +system call linux-specific +and should not be used in programs intended to be portable. +.sh notes +the official way of knowing if +.br perf_event_open () +support is enabled is checking +for the existence of the file +.ir /proc/sys/kernel/perf_event_paranoid . +.pp +.b cap_perfmon +capability (since linux 5.8) provides secure approach to +performance monitoring and observability operations in a system +according to the principal of least privilege (posix ieee 1003.1e). +accessing system performance monitoring and observability operations +using +.b cap_perfmon +rather than the much more powerful +.b cap_sys_admin +excludes chances to misuse credentials and makes operations more secure. +.b cap_sys_admin +usage for secure system performance monitoring and observability +is discouraged in favor of the +.b cap_perfmon +capability. +.sh bugs +the +.b f_setown_ex +option to +.br fcntl (2) +is needed to properly get overflow signals in threads. +this was introduced in linux 2.6.32. +.\" commit ba0a6c9f6fceed11c6a99e8326f0477fe383e6b5 +.pp +prior to linux 2.6.33 (at least for x86), +.\" commit b690081d4d3f6a23541493f1682835c3cd5c54a1 +the kernel did not check +if events could be scheduled together until read time. +the same happens on all known kernels if the nmi watchdog is enabled. +this means to see if a given set of events works you have to +.br perf_event_open (), +start, then read before you know for sure you +can get valid measurements. +.pp +prior to linux 2.6.34, +.\" fixme . cannot find a kernel commit for this one +event constraints were not enforced by the kernel. +in that case, some events would silently return "0" if the kernel +scheduled them in an improper counter slot. +.pp +prior to linux 2.6.34, there was a bug when multiplexing where the +wrong results could be returned. +.\" commit 45e16a6834b6af098702e5ea6c9a40de42ff77d8 +.pp +kernels from linux 2.6.35 to linux 2.6.39 can quickly crash the kernel if +"inherit" is enabled and many threads are started. +.\" commit 38b435b16c36b0d863efcf3f07b34a6fac9873fd +.pp +prior to linux 2.6.35, +.\" commit 050735b08ca8a016bbace4445fa025b88fee770b +.b perf_format_group +did not work with attached processes. +.pp +there is a bug in the kernel code between +linux 2.6.36 and linux 3.0 that ignores the +"watermark" field and acts as if a wakeup_event +was chosen if the union has a +nonzero value in it. +.\" commit 4ec8363dfc1451f8c8f86825731fe712798ada02 +.pp +from linux 2.6.31 to linux 3.4, the +.b perf_ioc_flag_group +ioctl argument was broken and would repeatedly operate +on the event specified rather than iterating across +all sibling events in a group. +.\" commit 724b6daa13e100067c30cfc4d1ad06629609dc4e +.pp +from linux 3.4 to linux 3.11, the mmap +.\" commit fa7315871046b9a4c48627905691dbde57e51033 +.i cap_usr_rdpmc +and +.i cap_usr_time +bits mapped to the same location. +code should migrate to the new +.i cap_user_rdpmc +and +.i cap_user_time +fields instead. +.pp +always double-check your results! +various generalized events have had wrong values. +for example, retired branches measured +the wrong thing on amd machines until linux 2.6.35. +.\" commit f287d332ce835f77a4f5077d2c0ef1e3f9ea42d2 +.sh examples +the following is a short example that measures the total +instruction count of a call to +.br printf (3). +.pp +.ex +#include +#include +#include +#include +#include +#include +#include + +static long +perf_event_open(struct perf_event_attr *hw_event, pid_t pid, + int cpu, int group_fd, unsigned long flags) +{ + int ret; + + ret = syscall(__nr_perf_event_open, hw_event, pid, cpu, + group_fd, flags); + return ret; +} + +int +main(int argc, char *argv[]) +{ + struct perf_event_attr pe; + long long count; + int fd; + + memset(&pe, 0, sizeof(pe)); + pe.type = perf_type_hardware; + pe.size = sizeof(pe); + pe.config = perf_count_hw_instructions; + pe.disabled = 1; + pe.exclude_kernel = 1; + pe.exclude_hv = 1; + + fd = perf_event_open(&pe, 0, \-1, \-1, 0); + if (fd == \-1) { + fprintf(stderr, "error opening leader %llx\en", pe.config); + exit(exit_failure); + } + + ioctl(fd, perf_event_ioc_reset, 0); + ioctl(fd, perf_event_ioc_enable, 0); + + printf("measuring instruction count for this printf\en"); + + ioctl(fd, perf_event_ioc_disable, 0); + read(fd, &count, sizeof(count)); + + printf("used %lld instructions\en", count); + + close(fd); +} +.ee +.sh see also +.br perf (1), +.br fcntl (2), +.br mmap (2), +.br open (2), +.br prctl (2), +.br read (2) +.pp +.ir documentation/admin\-guide/perf\-security.rst +in the kernel source tree +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" written feb 1994 by steve greenland (stevegr@neosoft.com) +.\" and copyright 2001, 2017 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" updated 1999.12.19 by karl m. hegbloom +.\" +.\" updated 13 oct 2001, michael kerrisk +.\" added description of vsyslog +.\" added descriptions of log_odelay and log_nowait +.\" added brief description of facility and option arguments +.\" added conforming to section +.\" 2001-10-13, aeb, minor changes +.\" modified 13 dec 2001, martin schulze +.\" modified 3 jan 2002, michael kerrisk +.\" +.th syslog 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +closelog, openlog, syslog, vsyslog \- send messages to the system logger +.sh synopsis +.nf +.b #include +.pp +.bi "void openlog(const char *" ident ", int " option ", int " facility ); +.bi "void syslog(int " priority ", const char *" format ", ...);" +.b "void closelog(void);" +.pp +.bi "void vsyslog(int " priority ", const char *" format ", va_list " ap ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br vsyslog (): +.nf + since glibc 2.19: + _default_source + glibc 2.19 and earlier: + _bsd_source +.fi +.sh description +.ss openlog() +.br openlog () +opens a connection to the system logger for a program. +.pp +the string pointed to by +.i ident +is prepended to every message, and is typically set to the program name. +if +.i ident +is null, the program name is used. +(posix.1-2008 does not specify the behavior when +.i ident +is null.) +.pp +the +.i option +argument specifies flags which control the operation of +.br openlog () +and subsequent calls to +.br syslog (). +the +.i facility +argument establishes a default to be used if +none is specified in subsequent calls to +.br syslog (). +the values that may be specified for +.i option +and +.i facility +are described below. +.pp +the use of +.br openlog () +is optional; it will automatically be called by +.br syslog () +if necessary, in which case +.i ident +will default to null. +.\" +.ss syslog() and vsyslog() +.br syslog () +generates a log message, which will be distributed by +.br syslogd (8). +.pp +the +.i priority +argument is formed by oring together a +.i facility +value and a +.i level +value (described below). +if no +.i facility +value is ored into +.ir priority , +then the default value set by +.br openlog () +is used, or, if there was no preceding +.br openlog () +call, a default of +.br log_user +is employed. +.pp +the remaining arguments are a +.ir format , +as in +.br printf (3), +and any arguments required by the +.ir format , +except that the two-character sequence +.b %m +will be replaced by +the error message string +.ir strerror ( errno ). +the format string need not include a terminating newline character. +.pp +the function +.br vsyslog () +performs the same task as +.br syslog () +with the difference that it takes a set of arguments which have +been obtained using the +.br stdarg (3) +variable argument list macros. +.\" +.ss closelog() +.br closelog () +closes the file descriptor being used to write to the system logger. +the use of +.br closelog () +is optional. +.\" +.ss values for \fioption\fp +the +.i option +argument to +.br openlog () +is a bit mask constructed by oring together any of the following values: +.tp 15 +.b log_cons +write directly to the system console if there is an error while sending to +the system logger. +.tp +.b log_ndelay +open the connection immediately (normally, the connection is opened when +the first message is logged). +this may be useful, for example, if a subsequent +.br chroot (2) +would make the pathname used internally by the logging facility unreachable. +.tp +.b log_nowait +don't wait for child processes that may have been created while logging +the message. +(the gnu c library does not create a child process, so this +option has no effect on linux.) +.tp +.b log_odelay +the converse of +.br log_ndelay ; +opening of the connection is delayed until +.br syslog () +is called. +(this is the default, and need not be specified.) +.tp +.b log_perror +(not in posix.1-2001 or posix.1-2008.) +also log the message to +.ir stderr . +.tp +.b log_pid +include the caller's pid with each message. +.\" +.ss values for \fifacility\fp +the +.i facility +argument is used to specify what type of program is logging the message. +this lets the configuration file specify that messages from different +facilities will be handled differently. +.tp 15 +.b log_auth +security/authorization messages +.tp +.b log_authpriv +security/authorization messages (private) +.tp +.b log_cron +clock daemon +.rb ( cron " and " at ) +.tp +.b log_daemon +system daemons without separate facility value +.tp +.b log_ftp +ftp daemon +.tp +.b log_kern +kernel messages (these can't be generated from user processes) +.\" log_kern has the value 0; if used as a facility, zero translates to: +.\" "use the default facility". +.tp +.br log_local0 " through " log_local7 +reserved for local use +.tp +.b log_lpr +line printer subsystem +.tp +.b log_mail +mail subsystem +.tp +.b log_news +usenet news subsystem +.tp +.b log_syslog +messages generated internally by +.br syslogd (8) +.tp +.br log_user " (default)" +generic user-level messages +.tp +.b log_uucp +uucp subsystem +.\" +.ss values for \filevel\fp +this determines the importance of the message. +the levels are, in order of decreasing importance: +.tp 15 +.b log_emerg +system is unusable +.tp +.b log_alert +action must be taken immediately +.tp +.b log_crit +critical conditions +.tp +.b log_err +error conditions +.tp +.b log_warning +warning conditions +.tp +.b log_notice +normal, but significant, condition +.tp +.b log_info +informational message +.tp +.b log_debug +debug-level message +.pp +the function +.br setlogmask (3) +can be used to restrict logging to specified levels only. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br openlog (), +.br closelog () +t} thread safety mt-safe +t{ +.br syslog (), +.br vsyslog () +t} thread safety mt-safe env locale +.te +.hy +.ad +.sp 1 +.sh conforming to +the functions +.br openlog (), +.br closelog (), +and +.br syslog () +(but not +.br vsyslog ()) +are specified in susv2, posix.1-2001, and posix.1-2008. +.pp +posix.1-2001 specifies only the +.b log_user +and +.b log_local* +values for +.ir facility . +however, with the exception of +.b log_authpriv +and +.br log_ftp , +the other +.i facility +values appear on most unix systems. +.pp +the +.b log_perror +value for +.i option +is not specified by posix.1-2001 or posix.1-2008, but is available +in most versions of unix. +.\" .sh history +.\" a +.\" .br syslog () +.\" function call appeared in 4.2bsd. +.\" 4.3bsd documents +.\" .br openlog (), +.\" .br syslog (), +.\" .br closelog (), +.\" and +.\" .br setlogmask (). +.\" 4.3bsd-reno also documents +.\" .br vsyslog (). +.\" of course early v* functions used the +.\" .i +.\" mechanism, which is not compatible with +.\" .ir . +.sh notes +the argument +.i ident +in the call of +.br openlog () +is probably stored as-is. +thus, if the string it points to +is changed, +.br syslog () +may start prepending the changed string, and if the string +it points to ceases to exist, the results are undefined. +most portable is to use a string constant. +.pp +never pass a string with user-supplied data as a format, +use the following instead: +.pp +.in +4n +.ex +syslog(priority, "%s", string); +.ee +.in +.sh see also +.br journalctl (1), +.br logger (1), +.br setlogmask (3), +.br syslog.conf (5), +.br syslogd (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" this man-page is copyright (c) 1997 john s. kallal +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" correction, aeb, 970825 +.th full 4 2019-03-06 "linux" "linux programmer's manual" +.sh name +full \- always full device +.sh configuration +if your system does not have +.i /dev/full +created already, it +can be created with the following commands: +.pp +.in +4n +.ex +mknod \-m 666 /dev/full c 1 7 +chown root:root /dev/full +.ee +.in +.sh description +the file +.i /dev/full +has major device number 1 +and minor device number 7. +.pp +writes to the +.i /dev/full +device fail with an +.b enospc +error. +this can be used to test how a program handles disk-full errors. +.pp +reads from the +.i /dev/full +device will return \e0 characters. +.pp +seeks on +.i /dev/full +will always succeed. +.sh files +.i /dev/full +.sh see also +.br mknod (1), +.br null (4), +.br zero (4) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/asinh.3 + +.so man3/list.3 + +.so man3/getprotoent.3 + +.so man3/malloc.3 + +.\" copyright (c) 2009 michael kerrisk, +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th pthread_setconcurrency 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +pthread_setconcurrency, pthread_getconcurrency \- set/get +the concurrency level +.sh synopsis +.nf +.b #include +.pp +.bi "int pthread_setconcurrency(int " new_level ); +.bi "int pthread_getconcurrency(" void ); +.pp +compile and link with \fi\-pthread\fp. +.fi +.sh description +the +.br pthread_setconcurrency () +function informs the implementation of the application's +desired concurrency level, specified in +.ir new_level . +the implementation takes this only as a hint: +posix.1 does not specify the level of concurrency that +should be provided as a result of calling +.br pthread_setconcurrency (). +.pp +specifying +.i new_level +as 0 instructs the implementation to manage the concurrency level +as it deems appropriate. +.pp +.br pthread_getconcurrency () +returns the current value of the concurrency level for this process. +.sh return value +on success, +.br pthread_setconcurrency () +returns 0; +on error, it returns a nonzero error number. +.pp +.br pthread_getconcurrency () +always succeeds, returning the concurrency level set by a previous call to +.br pthread_setconcurrency (), +or 0, if +.br pthread_setconcurrency () +has not previously been called. +.sh errors +.br pthread_setconcurrency () +can fail with the following error: +.tp +.b einval +.i new_level +is negative. +.pp +posix.1 also documents an +.br eagain +error ("the value specified by +.i new_level +would cause a system resource to be exceeded"). +.sh versions +these functions are available in glibc since version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br pthread_setconcurrency (), +.br pthread_getconcurrency () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +the default concurrency level is 0. +.pp +concurrency levels are meaningful only for m:n threading implementations, +where at any moment a subset of a process's set of user-level threads +may be bound to a smaller number of kernel-scheduling entities. +setting the concurrency level allows the application to +give the system a hint as to the number of kernel-scheduling entities +that should be provided for efficient execution of the application. +.pp +both linuxthreads and nptl are 1:1 threading implementations, +so setting the concurrency level has no meaning. +in other words, +on linux these functions merely exist for compatibility with other systems, +and they have no effect on the execution of a program. +.sh see also +.br pthread_attr_setscope (3), +.br pthreads (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/rpc.3 + +.so man3/rpc.3 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" single unix specification, version 2 +.\" modified thu apr 8 15:00:12 1993, david metcalfe +.\" modified sat jul 24 18:44:45 1993, rik faith (faith@cs.unc.edu) +.\" modified fri feb 14 21:47:50 1997 by andries brouwer (aeb@cwi.nl) +.\" modified mon oct 11 11:11:11 1999 by andries brouwer (aeb@cwi.nl) +.\" modified wed nov 10 00:02:26 1999 by andries brouwer (aeb@cwi.nl) +.\" modified sun may 20 22:17:20 2001 by andries brouwer (aeb@cwi.nl) +.th putenv 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +putenv \- change or add an environment variable +.sh synopsis +.nf +.b #include +.pp +.bi "int putenv(char *" string ); +.\" not: const char * +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br putenv (): +.nf + _xopen_source + || /* glibc since 2.19: */ _default_source + || /* glibc <= 2.19: */ _svid_source +.fi +.sh description +the +.br putenv () +function adds or changes the value of environment +variables. +the argument \fistring\fp is of the form \finame\fp=\fivalue\fp. +if \finame\fp does not already exist in the environment, then +\fistring\fp is added to the environment. +if \finame\fp does exist, +then the value of \finame\fp in the environment is changed to +\fivalue\fp. +the string pointed to by \fistring\fp becomes part of the environment, +so altering the string changes the environment. +.sh return value +the +.br putenv () +function returns zero on success. +on failure, it returns a nonzero value, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b enomem +insufficient space to allocate new environment. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br putenv () +t} thread safety mt-unsafe const:env +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, svr4, 4.3bsd. +.sh notes +the +.br putenv () +function is not required to be reentrant, and the +one in glibc 2.0 is not, but the glibc 2.1 version is. +.\" .lp +.\" description for libc4, libc5, glibc: +.\" if the argument \fistring\fp is of the form \finame\fp, +.\" and does not contain an \(aq=\(aq character, then the variable \finame\fp +.\" is removed from the environment. +.\" if +.\" .br putenv () +.\" has to allocate a new array \fienviron\fp, +.\" and the previous array was also allocated by +.\" .br putenv (), +.\" then it will be freed. +.\" in no case will the old storage associated +.\" to the environment variable itself be freed. +.pp +since version 2.1.2, the glibc implementation conforms to susv2: +the pointer \fistring\fp given to +.br putenv () +is used. +in particular, this string becomes part of the environment; +changing it later will change the environment. +(thus, it is an error to call +.br putenv () +with an automatic variable +as the argument, then return from the calling function while \fistring\fp +is still part of the environment.) +however, glibc versions 2.0 to 2.1.1 differ: a copy of the string is used. +on the one hand this causes a memory leak, and on the other hand +it violates susv2. +.pp +the 4.4bsd version, like glibc 2.0, uses a copy. +.pp +susv2 removes the \ficonst\fp from the prototype, and so does glibc 2.1.3. +.pp +the gnu c library implementation provides a nonstandard extension. +if +.i string +does not include an equal sign: +.pp +.in +4n +.ex +putenv("name"); +.ee +.in +.pp +then the named variable is removed from the caller's environment. +.sh see also +.br clearenv (3), +.br getenv (3), +.br setenv (3), +.br unsetenv (3), +.br environ (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/catanh.3 + +.\" copyright (c) 1992 drew eckhardt (drew@cs.colorado.edu), march 28, 1992 +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified by michael haardt +.\" modified sat jul 24 14:13:40 1993 by rik faith +.\" additions by joseph s. myers , 970909 +.\" +.th time 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +time \- get time in seconds +.sh synopsis +.nf +.b #include +.pp +.bi "time_t time(time_t *" tloc ); +.fi +.sh description +.br time () +returns the time as the number of seconds since the +epoch, 1970-01-01 00:00:00 +0000 (utc). +.pp +if +.i tloc +is non-null, +the return value is also stored in the memory pointed to by +.ir tloc . +.sh return value +on success, the value of time in seconds since the epoch is returned. +on error, \fi((time_t)\ \-1)\fp is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b efault +.i tloc +points outside your accessible address space (but see bugs). +.ip +on systems where the c library +.br time () +wrapper function invokes an implementation provided by the +.br vdso (7) +(so that there is no trap into the kernel), +an invalid address may instead trigger a +.b sigsegv +signal. +.sh conforming to +svr4, 4.3bsd, c89, c99, posix.1-2001. +.\" under 4.3bsd, this call is obsoleted by +.\" .br gettimeofday (2). +posix does not specify any error conditions. +.sh notes +posix.1 defines +.i seconds since the epoch +using a formula that approximates the number of seconds between a +specified time and the epoch. +this formula takes account of the facts that +all years that are evenly divisible by 4 are leap years, +but years that are evenly divisible by 100 are not leap years +unless they are also evenly divisible by 400, +in which case they are leap years. +this value is not the same as the actual number of seconds between the time +and the epoch, because of leap seconds and because system clocks are not +required to be synchronized to a standard reference. +the intention is that the interpretation of seconds since the epoch values be +consistent; see posix.1-2008 rationale a.4.15 for further rationale. +.pp +on linux, a call to +.br time () +with +.i tloc +specified as null cannot fail with the error +.br eoverflow , +even on abis where +.i time_t +is a signed 32-bit integer and the clock reaches or exceeds 2**31 seconds +(2038-01-19 03:14:08 utc, ignoring leap seconds). +(posix.1 permits, but does not require, the +.b eoverflow +error in the case where the seconds since the epoch will not fit in +.ir time_t .) +instead, the behavior on linux is undefined when the system time is out of the +.i time_t +range. +applications intended to run after 2038 should use abis with +.i time_t +wider than 32 bits. +.sh bugs +error returns from this system call are indistinguishable from +successful reports that the time is a few seconds +.i before +the epoch, so the c library wrapper function never sets +.i errno +as a result of this call. +.pp +the +.i tloc +argument is obsolescent and should always be null in new code. +when +.i tloc +is null, the call cannot fail. +.\" +.ss c library/kernel differences +on some architectures, an implementation of +.br time () +is provided in the +.br vdso (7). +.sh see also +.br date (1), +.br gettimeofday (2), +.br ctime (3), +.br ftime (3), +.br time (7), +.br vdso (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/remainder.3 + +.\" copyright (c) 2006, 2010 michael kerrisk +.\" copyright (c) 2009 petr baudis +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th sigevent 7 2021-03-22 "gnu" "linux programmer's manual" +.sh name +sigevent \- structure for notification from asynchronous routines +.sh synopsis +.nf +#include +.pp +union sigval { /* data passed with notification */ + int sival_int; /* integer value */ + void *sival_ptr; /* pointer value */ +}; +.pp +struct sigevent { + int sigev_notify; /* notification method */ + int sigev_signo; /* notification signal */ + union sigval sigev_value; + /* data passed with notification */ + void (*sigev_notify_function)(union sigval); + /* function used for thread + notification (sigev_thread) */ + void *sigev_notify_attributes; + /* attributes for notification thread + (sigev_thread) */ + pid_t sigev_notify_thread_id; + /* id of thread to signal + (sigev_thread_id); linux-specific */ +}; +.fi +.sh description +the +.i sigevent +structure is used by various apis +to describe the way a process is to be notified about an event +(e.g., completion of an asynchronous request, expiration of a timer, +or the arrival of a message). +.pp +the definition shown in the synopsis is approximate: +some of the fields in the +.i sigevent +structure may be defined as part of a union. +programs should employ only those fields relevant +to the value specified in +.ir sigev_notify . +.pp +the +.i sigev_notify +field specifies how notification is to be performed. +this field can have one of the following values: +.tp +.br sigev_none +a "null" notification: don't do anything when the event occurs. +.tp +.br sigev_signal +notify the process by sending the signal specified in +.ir sigev_signo . +.ip +if the signal is caught with a signal handler that was registered using the +.br sigaction (2) +.b sa_siginfo +flag, then the following fields are set in the +.i siginfo_t +structure that is passed as the second argument of the handler: +.rs +.tp 10 +.i si_code +this field is set to a value that depends on the api +delivering the notification. +.tp +.i si_signo +this field is set to the signal number (i.e., the same value as in +.ir sigev_signo ). +.tp +.i si_value +this field is set to the value specified in +.ir sigev_value . +.re +.ip +depending on the api, other fields may also be set in the +.i siginfo_t +structure. +.ip +the same information is also available if the signal is accepted using +.br sigwaitinfo (2). +.tp +.br sigev_thread +notify the process by invoking +.i sigev_notify_function +"as if" it were the start function of a new thread. +(among the implementation possibilities here are that +each timer notification could result in the creation of a new thread, +or that a single thread is created to receive all notifications.) +the function is invoked with +.i sigev_value +as its sole argument. +if +.i sigev_notify_attributes +is not null, it should point to a +.i pthread_attr_t +structure that defines attributes for the new thread (see +.br pthread_attr_init (3)). +.tp +.br sigev_thread_id " (linux-specific)" +.\" | sigev_signal vs not? +currently used only by posix timers; see +.br timer_create (2). +.sh see also +.br timer_create (2), +.br aio_fsync (3), +.br aio_read (3), +.br aio_write (3), +.br getaddrinfo_a (3), +.br lio_listio (3), +.br mq_notify (3), +.br aio (7), +.br pthreads (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/mq_receive.3 + +.so man3/getutent.3 + +.so man7/system_data_types.7 + +.so man3/random.3 + +.\" copyright (c) 2002 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th sigwaitinfo 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +sigwaitinfo, sigtimedwait, rt_sigtimedwait \- synchronously wait +for queued signals +.sh synopsis +.nf +.b #include +.pp +.bi "int sigwaitinfo(const sigset_t *restrict " set , +.bi " siginfo_t *restrict " info ); +.bi "int sigtimedwait(const sigset_t *restrict " set , +.bi " siginfo_t *restrict " info , +.bi " const struct timespec *restrict " timeout ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br sigwaitinfo (), +.br sigtimedwait (): +.nf + _posix_c_source >= 199309l +.fi +.sh description +.br sigwaitinfo () +suspends execution of the calling thread until one of the signals in +.i set +is pending +(if one of the signals in +.i set +is already pending for the calling thread, +.br sigwaitinfo () +will return immediately.) +.pp +.br sigwaitinfo () +removes the signal from the set of pending +signals and returns the signal number as its function result. +if the +.i info +argument is not null, +then the buffer that it points to is used to return a structure of type +.i siginfo_t +(see +.br sigaction (2)) +containing information about the signal. +.pp +if multiple signals in +.i set +are pending for the caller, the signal that is retrieved by +.br sigwaitinfo () +is determined according to the usual ordering rules; see +.br signal (7) +for further details. +.pp +.br sigtimedwait () +operates in exactly the same way as +.br sigwaitinfo () +except that it has an additional argument, +.ir timeout , +which specifies the interval for which +the thread is suspended waiting for a signal. +(this interval will be rounded up to the system clock granularity, +and kernel scheduling delays mean that the interval +may overrun by a small amount.) +this argument is of the following type: +.pp +.in +4n +.ex +struct timespec { + long tv_sec; /* seconds */ + long tv_nsec; /* nanoseconds */ +} +.ee +.in +.pp +if both fields of this structure are specified as 0, a poll is performed: +.br sigtimedwait () +returns immediately, either with information about a signal that +was pending for the caller, or with an error +if none of the signals in +.i set +was pending. +.sh return value +on success, both +.br sigwaitinfo () +and +.br sigtimedwait () +return a signal number (i.e., a value greater than zero). +on failure both calls return \-1, with +.i errno +set to indicate the error. +.sh errors +.tp +.b eagain +no signal in +.i set +became pending within the +.i timeout +period specified to +.br sigtimedwait (). +.tp +.b eintr +the wait was interrupted by a signal handler; see +.br signal (7). +(this handler was for a signal other than one of those in +.ir set .) +.tp +.b einval +.i timeout +was invalid. +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +in normal usage, the calling program blocks the signals in +.i set +via a prior call to +.br sigprocmask (2) +(so that the default disposition for these signals does not occur if they +become pending between successive calls to +.br sigwaitinfo () +or +.br sigtimedwait ()) +and does not establish handlers for these signals. +in a multithreaded program, +the signal should be blocked in all threads, in order to prevent +the signal being treated according to its default disposition in +a thread other than the one calling +.br sigwaitinfo () +or +.br sigtimedwait ()). +.pp +the set of signals that is pending for a given thread is the +union of the set of signals that is pending specifically for that thread +and the set of signals that is pending for the process as a whole (see +.br signal (7)). +.pp +attempts to wait for +.b sigkill +and +.b sigstop +are silently ignored. +.pp +if multiple threads of a process are blocked +waiting for the same signal(s) in +.br sigwaitinfo () +or +.br sigtimedwait (), +then exactly one of the threads will actually receive the +signal if it becomes pending for the process as a whole; +which of the threads receives the signal is indeterminate. +.pp +.br sigwaitinfo () +or +.br sigtimedwait (), +can't be used to receive signals that +are synchronously generated, such as the +.br sigsegv +signal that results from accessing an invalid memory address +or the +.br sigfpe +signal that results from an arithmetic error. +such signals can be caught only via signal handler. +.pp +posix leaves the meaning of a null value for the +.i timeout +argument of +.br sigtimedwait () +unspecified, permitting the possibility that this has the same meaning +as a call to +.br sigwaitinfo (), +and indeed this is what is done on linux. +.\" +.ss c library/kernel differences +on linux, +.br sigwaitinfo () +is a library function implemented on top of +.br sigtimedwait (). +.pp +the glibc wrapper functions for +.br sigwaitinfo () +and +.br sigtimedwait () +silently ignore attempts to wait for the two real-time signals that +are used internally by the nptl threading implementation. +see +.br nptl (7) +for details. +.pp +the original linux system call was named +.br sigtimedwait (). +however, with the addition of real-time signals in linux 2.2, +the fixed-size, 32-bit +.i sigset_t +type supported by that system call was no longer fit for purpose. +consequently, a new system call, +.br rt_sigtimedwait (), +was added to support an enlarged +.ir sigset_t +type. +the new system call takes a fourth argument, +.ir "size_t sigsetsize" , +which specifies the size in bytes of the signal set in +.ir set . +this argument is currently required to have the value +.ir sizeof(sigset_t) +(or the error +.b einval +results). +the glibc +.br sigtimedwait () +wrapper function hides these details from us, transparently calling +.br rt_sigtimedwait () +when the kernel provides it. +.\" +.sh see also +.br kill (2), +.br sigaction (2), +.br signal (2), +.br signalfd (2), +.br sigpending (2), +.br sigprocmask (2), +.br sigqueue (3), +.br sigsetops (3), +.br sigwait (3), +.br signal (7), +.br time (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sat jul 24 17:46:57 1993 by rik faith (faith@cs.unc.edu) +.\" modified 2001-11-17, aeb +.th tmpfile 3 2021-03-22 "" "linux programmer's manual" +.sh name +tmpfile \- create a temporary file +.sh synopsis +.nf +.b #include +.pp +.b file *tmpfile(void); +.fi +.sh description +the +.br tmpfile () +function opens a unique temporary file +in binary read/write (w+b) mode. +the file will be automatically deleted when it is closed or the +program terminates. +.sh return value +the +.br tmpfile () +function returns a stream descriptor, or null if +a unique filename cannot be generated or the unique file cannot be +opened. +in the latter case, +.i errno +is set to indicate the error. +.sh errors +.tp +.b eacces +search permission denied for directory in file's path prefix. +.tp +.b eexist +unable to generate a unique filename. +.tp +.b eintr +the call was interrupted by a signal; see +.br signal (7). +.tp +.b emfile +the per-process limit on the number of open file descriptors has been reached. +.tp +.b enfile +the system-wide limit on the total number of open files has been reached. +.tp +.b enospc +there was no room in the directory to add the new filename. +.tp +.b erofs +read-only filesystem. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br tmpfile () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c89, c99, svr4, 4.3bsd, susv2. +.sh notes +posix.1-2001 specifies: +an error message may be written to +.i stdout +if the stream +cannot be opened. +.pp +the standard does not specify the directory that +.br tmpfile () +will use. +glibc will try the path prefix +.i p_tmpdir +defined +in +.ir , +and if that fails, then the directory +.ir /tmp . +.sh see also +.br exit (3), +.br mkstemp (3), +.br mktemp (3), +.br tempnam (3), +.br tmpnam (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) markus kuhn, 1996 +.\" and copyright (c) linux foundation, 2008, written by michael kerrisk +.\" +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" 1996-04-10 markus kuhn +.\" first version written +.\" modified, 2004-10-24, aeb +.\" 2008-06-24, mtk +.\" minor rewrites of some parts. +.\" notes: describe case where clock_nanosleep() can be preferable. +.\" notes: describe clock_realtime versus clock_nanosleep +.\" replace crufty discussion of hz with a pointer to time(7). +.th nanosleep 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +nanosleep \- high-resolution sleep +.sh synopsis +.nf +.b #include +.pp +.bi "int nanosleep(const struct timespec *" req ", struct timespec *" rem ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br nanosleep (): +.nf + _posix_c_source >= 199309l +.fi +.sh description +.br nanosleep () +suspends the execution of the calling thread +until either at least the time specified in +.ir *req +has elapsed, or the delivery of a signal +that triggers the invocation of a handler in the calling thread or +that terminates the process. +.pp +if the call is interrupted by a signal handler, +.br nanosleep () +returns \-1, sets +.i errno +to +.br eintr , +and writes the remaining time into the structure pointed to by +.i rem +unless +.i rem +is null. +the value of +.i *rem +can then be used to call +.br nanosleep () +again and complete the specified pause (but see notes). +.pp +the structure +.i timespec +is used to specify intervals of time with nanosecond precision. +it is defined as follows: +.pp +.in +4n +.ex +struct timespec { + time_t tv_sec; /* seconds */ + long tv_nsec; /* nanoseconds */ +}; +.ee +.in +.pp +the value of the nanoseconds field must be in the range 0 to 999999999. +.pp +compared to +.br sleep (3) +and +.br usleep (3), +.br nanosleep () +has the following advantages: +it provides a higher resolution for specifying the sleep interval; +posix.1 explicitly specifies that it +does not interact with signals; +and it makes the task of resuming a sleep that has been +interrupted by a signal handler easier. +.sh return value +on successfully sleeping for the requested interval, +.br nanosleep () +returns 0. +if the call is interrupted by a signal handler or encounters an error, +then it returns \-1, with +.i errno +set to indicate the error. +.sh errors +.tp +.b efault +problem with copying information from user space. +.tp +.b eintr +the pause has been interrupted by a signal that was +delivered to the thread (see +.br signal (7)). +the remaining sleep time has been written +into +.i *rem +so that the thread can easily call +.br nanosleep () +again and continue with the pause. +.tp +.b einval +the value in the +.i tv_nsec +field was not in the range 0 to 999999999 or +.i tv_sec +was negative. +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +if the interval specified in +.i req +is not an exact multiple of the granularity underlying clock (see +.br time (7)), +then the interval will be rounded up to the next multiple. +furthermore, after the sleep completes, there may still be a delay before +the cpu becomes free to once again execute the calling thread. +.pp +the fact that +.br nanosleep () +sleeps for a relative interval can be problematic if the call +is repeatedly restarted after being interrupted by signals, +since the time between the interruptions and restarts of the call +will lead to drift in the time when the sleep finally completes. +this problem can be avoided by using +.br clock_nanosleep (2) +with an absolute time value. +.pp +posix.1 specifies that +.br nanosleep () +should measure time against the +.b clock_realtime +clock. +however, linux measures the time using the +.b clock_monotonic +clock. +.\" see also http://thread.gmane.org/gmane.linux.kernel/696854/ +.\" subject: nanosleep() uses clock_monotonic, should be clock_realtime? +.\" date: 2008-06-22 07:35:41 gmt +this probably does not matter, since the posix.1 specification for +.br clock_settime (2) +says that discontinuous changes in +.b clock_realtime +should not affect +.br nanosleep (): +.rs +.pp +setting the value of the +.b clock_realtime +clock via +.br clock_settime (2) +shall +have no effect on threads that are blocked waiting for a relative time +service based upon this clock, including the +.br nanosleep () +function; ... +consequently, these time services shall expire when the requested relative +interval elapses, independently of the new or old value of the clock. +.re +.ss old behavior +in order to support applications requiring much more precise pauses +(e.g., in order to control some time-critical hardware), +.br nanosleep () +would handle pauses of up to 2 milliseconds by busy waiting with microsecond +precision when called from a thread scheduled under a real-time policy +like +.b sched_fifo +or +.br sched_rr . +this special extension was removed in kernel 2.5.39, +and is thus not available in linux 2.6.0 and later kernels. +.sh bugs +if a program that catches signals and uses +.br nanosleep () +receives signals at a very high rate, +then scheduling delays and rounding errors in the kernel's +calculation of the sleep interval and the returned +.ir remain +value mean that the +.ir remain +value may steadily +.ir increase +on successive restarts of the +.br nanosleep () +call. +to avoid such problems, use +.br clock_nanosleep (2) +with the +.br timer_abstime +flag to sleep to an absolute deadline. +.pp +in linux 2.4, if +.br nanosleep () +is stopped by a signal (e.g., +.br sigtstp ), +then the call fails with the error +.b eintr +after the thread is resumed by a +.b sigcont +signal. +if the system call is subsequently restarted, +then the time that the thread spent in the stopped state is +.i not +counted against the sleep interval. +this problem is fixed in linux 2.6.0 and later kernels. +.sh see also +.br clock_nanosleep (2), +.br restart_syscall (2), +.br sched_setscheduler (2), +.br timer_create (2), +.br sleep (3), +.br usleep (3), +.br time (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2012 michael kerrisk +.\" a few fragments remain from a version +.\" copyright (c) 1996 free software foundation, inc. +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th init_module 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +init_module, finit_module \- load a kernel module +.sh synopsis +.nf +.br "#include " " /* definition of " module_* " constants */" +.br "#include " " /* definition of " sys_* " constants */" +.b #include +.pp +.bi "int syscall(sys_init_module, void *" module_image ", unsigned long " len , +.bi " const char *" param_values ); +.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, +performs any necessary symbol relocations, +initializes module parameters to values provided by the caller, +and then runs the module's +.i init +function. +this system call requires privilege. +.pp +the +.i module_image +argument points to a buffer containing the binary image +to be loaded; +.i len +specifies the size of that buffer. +the module image should be a valid elf image, built for the running kernel. +.pp +the +.i param_values +argument is a string containing space-delimited specifications of the +values for module parameters (defined inside the module using +.br module_param () +and +.br module_param_array ()). +the kernel parses this string and initializes the specified +parameters. +each of the parameter specifications has the form: +.pp +.ri " " name [\c +.bi = value\c +.rb [ ,\c +.ir value ...]] +.pp +the parameter +.i name +is one of those defined within the module using +.ir module_param () +(see the linux kernel source file +.ir include/linux/moduleparam.h ). +the parameter +.i value +is optional in the case of +.i bool +and +.i invbool +parameters. +values for array parameters are specified as a comma-separated list. +.ss finit_module() +the +.br finit_module () +.\" commit 34e1169d996ab148490c01b65b4ee371cf8ffba2 +.\" https://lwn.net/articles/519010/ +system call is like +.br init_module (), +but reads the module to be loaded from the file descriptor +.ir fd . +it is useful when the authenticity of a kernel module +can be determined from its location in the filesystem; +in cases where that is possible, +the overhead of using cryptographically signed modules to +determine the authenticity of a module can be avoided. +the +.i param_values +argument is as for +.br init_module (). +.pp +the +.i flags +argument modifies the operation of +.br finit_module (). +it is a bit mask value created by oring +together zero or more of the following flags: +.\" commit 2f3238aebedb243804f58d62d57244edec4149b2 +.tp +.b module_init_ignore_modversions +ignore symbol version hashes. +.tp +.b module_init_ignore_vermagic +ignore kernel version magic. +.pp +there are some safety checks built into a module to ensure that +it matches the kernel against which it is loaded. +.\" http://www.tldp.org/howto/module-howto/basekerncompat.html +.\" is dated, but informative +these checks are recorded when the module is built and +verified when the module is loaded. +first, the module records a "vermagic" string containing +the kernel version number and prominent features (such as the cpu type). +second, if the module was built with the +.b config_modversions +configuration option enabled, +a version hash is recorded for each symbol the module uses. +this hash is based on the types of the arguments and return value +for the function named by the symbol. +in this case, the kernel version number within the +"vermagic" string is ignored, +as the symbol version hashes are assumed to be sufficiently reliable. +.pp +using the +.b module_init_ignore_vermagic +flag indicates that the "vermagic" string is to be ignored, and the +.b module_init_ignore_modversions +flag indicates that the symbol version hashes are to be ignored. +if the kernel is built to permit forced loading (i.e., configured with +.br config_module_force_load ), +then loading continues, otherwise it fails with the error +.b enoexec +as expected for malformed modules. +.sh return value +on success, these system calls return 0. +on error, \-1 is returned and +.i errno +is set to indicate the error. +.sh errors +.tp +.br ebadmsg " (since linux 3.7)" +module signature is misformatted. +.tp +.b ebusy +timeout while trying to resolve a symbol reference by this module. +.tp +.b efault +an address argument referred to a location that +is outside the process's accessible address space. +.tp +.br enokey " (since linux 3.7)" +.\" commit 48ba2462ace6072741fd8d0058207d630ce93bf1 +.\" commit 1d0059f3a468825b5fc5405c636a2f6e02707ffa +.\" commit 106a4ee258d14818467829bf0e12aeae14c16cd7 +module signature is invalid or +the kernel does not have a key for this module. +this error is returned only if the kernel was configured with +.br config_module_sig_force ; +if the kernel was not configured with this option, +then an invalid or unsigned module simply taints the kernel. +.tp +.b enomem +out of memory. +.tp +.b eperm +the caller was not privileged +(did not have the +.b cap_sys_module +capability), +or module loading is disabled +(see +.ir /proc/sys/kernel/modules_disabled +in +.br proc (5)). +.pp +the following errors may additionally occur for +.br init_module (): +.tp +.b eexist +a module with this name is already loaded. +.tp +.b einval +.i param_values +is invalid, or some part of the elf image in +.ir module_image +contains inconsistencies. +.\" .tp +.\" .br einval " (linux 2.4 and earlier)" +.\" some +.\" .i image +.\" slot is filled in incorrectly, +.\" .i image\->name +.\" does not correspond to the original module name, some +.\" .i image\->deps +.\" entry does not correspond to a loaded module, +.\" or some other similar inconsistency. +.tp +.b enoexec +the binary image supplied in +.i module_image +is not an elf image, +or is an elf image that is invalid or for a different architecture. +.pp +the following errors may additionally occur for +.br finit_module (): +.tp +.b ebadf +the file referred to by +.i fd +is not opened for reading. +.tp +.b efbig +the file referred to by +.i fd +is too large. +.tp +.b einval +.i flags +is invalid. +.tp +.b enoexec +.i fd +does not refer to an open file. +.pp +in addition to the above errors, if the module's +.i init +function is executed and returns an error, then +.br init_module () +or +.br finit_module () +fails and +.i errno +is set to the value returned by the +.i init +function. +.sh versions +.br finit_module () +is available since linux 3.8. +.sh conforming to +.br init_module () +and +.br finit_module () +are linux-specific. +.sh notes +the +.br init_module () +system call is not supported by glibc. +no declaration is provided in glibc headers, but, through a quirk of history, +glibc versions before 2.23 did export an abi for this system call. +therefore, in order to employ this system call, +it is (before glibc 2.23) sufficient to +manually declare the interface in your code; +alternatively, you can invoke the system call using +.br syscall (2). +.pp +information about currently loaded modules can be found in +.ir /proc/modules +and in the file trees under the per-module subdirectories under +.ir /sys/module . +.pp +see the linux kernel source file +.i include/linux/module.h +for some useful background information. +.ss linux 2.4 and earlier +in linux 2.4 and earlier, the +.br init_module () +system call was rather different: +.pp +.b " #include " +.pp +.bi " int init_module(const char *" name ", struct module *" image ); +.pp +(user-space applications can detect which version of +.br init_module () +is available by calling +.br query_module (); +the latter call fails with the error +.br enosys +on linux 2.6 and later.) +.pp +the older version of the system call +loads the relocated module image pointed to by +.i image +into kernel space and runs the module's +.i init +function. +the caller is responsible for providing the relocated image (since +linux 2.6, the +.br init_module () +system call does the relocation). +.pp +the module image begins with a module structure and is followed by +code and data as appropriate. +since linux 2.2, the module structure is defined as follows: +.pp +.in +4n +.ex +struct module { + unsigned long size_of_struct; + struct module *next; + const char *name; + unsigned long size; + long usecount; + unsigned long flags; + unsigned int nsyms; + unsigned int ndeps; + struct module_symbol *syms; + struct module_ref *deps; + struct module_ref *refs; + int (*init)(void); + void (*cleanup)(void); + const struct exception_table_entry *ex_table_start; + const struct exception_table_entry *ex_table_end; +#ifdef __alpha__ + unsigned long gp; +#endif +}; +.ee +.in +.pp +all of the pointer fields, with the exception of +.i next +and +.ir refs , +are expected to point within the module body and be +initialized as appropriate for kernel space, that is, relocated with +the rest of the module. +.sh see also +.br create_module (2), +.br delete_module (2), +.br query_module (2), +.br lsmod (8), +.br modprobe (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/ccosh.3 + +.so man3/exec.3 + +.so man3/key_setsecret.3 + +.so man3/pthread_mutexattr_init.3 + +.\" copyright (c) 2008 linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th pthread_cancel 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +pthread_cancel \- send a cancellation request to a thread +.sh synopsis +.nf +.b #include +.pp +.bi "int pthread_cancel(pthread_t " thread ); +.pp +compile and link with \fi\-pthread\fp. +.fi +.sh description +the +.br pthread_cancel () +function sends a cancellation request to the thread +.ir thread . +whether and when the target thread +reacts to the cancellation request depends on +two attributes that are under the control of that thread: +its cancelability +.i state +and +.ir type . +.pp +a thread's cancelability state, determined by +.br pthread_setcancelstate (3), +can be +.i enabled +(the default for new threads) or +.ir disabled . +if a thread has disabled cancellation, +then a cancellation request remains queued until the thread +enables cancellation. +if a thread has enabled cancellation, +then its cancelability type determines when cancellation occurs. +.pp +a thread's cancellation type, determined by +.br pthread_setcanceltype (3), +may be either +.ir asynchronous +or +.ir deferred +(the default for new threads). +asynchronous cancelability +means that the thread can be canceled at any time +(usually immediately, but the system does not guarantee this). +deferred cancelability means that cancellation will be delayed until +the thread next calls a function that is a +.ir "cancellation point" . +a list of functions that are or may be cancellation points is provided in +.br pthreads (7). +.pp +when a cancellation requested is acted on, the following steps occur for +.ir thread +(in this order): +.ip 1. 3 +cancellation clean-up handlers are popped +(in the reverse of the order in which they were pushed) and called. +(see +.br pthread_cleanup_push (3).) +.ip 2. +thread-specific data destructors are called, +in an unspecified order. +(see +.br pthread_key_create (3).) +.ip 3. +the thread is terminated. +(see +.br pthread_exit (3).) +.pp +the above steps happen asynchronously with respect to the +.br pthread_cancel () +call; +the return status of +.br pthread_cancel () +merely informs the caller whether the cancellation request +was successfully queued. +.pp +after a canceled thread has terminated, +a join with that thread using +.br pthread_join (3) +obtains +.b pthread_canceled +as the thread's exit status. +(joining with a thread is the only way to know that cancellation +has completed.) +.sh return value +on success, +.br pthread_cancel () +returns 0; +on error, it returns a nonzero error number. +.sh errors +.tp +.b esrch +no thread with the id +.i thread +could be found. +.\" .sh versions +.\" available since glibc 2.0 +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br pthread_cancel () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +on linux, cancellation is implemented using signals. +under the nptl threading implementation, +the first real-time signal (i.e., signal 32) is used for this purpose. +on linuxthreads, the second real-time signal is used, +if real-time signals are available, otherwise +.b sigusr2 +is used. +.sh examples +the program below creates a thread and then cancels it. +the main thread joins with the canceled thread to check +that its exit status was +.br pthread_canceled . +the following shell session shows what happens when we run the program: +.pp +.in +4n +.ex +$ ./a.out +thread_func(): started; cancellation disabled +main(): sending cancellation request +thread_func(): about to enable cancellation +main(): thread was canceled +.ee +.in +.ss program source +\& +.ex +#include +#include +#include +#include +#include + +#define handle_error_en(en, msg) \e + do { errno = en; perror(msg); exit(exit_failure); } while (0) + +static void * +thread_func(void *ignored_argument) +{ + int s; + + /* disable cancellation for a while, so that we don\(aqt + immediately react to a cancellation request. */ + + s = pthread_setcancelstate(pthread_cancel_disable, null); + if (s != 0) + handle_error_en(s, "pthread_setcancelstate"); + + printf("thread_func(): started; cancellation disabled\en"); + sleep(5); + printf("thread_func(): about to enable cancellation\en"); + + s = pthread_setcancelstate(pthread_cancel_enable, null); + if (s != 0) + handle_error_en(s, "pthread_setcancelstate"); + + /* sleep() is a cancellation point. */ + + sleep(1000); /* should get canceled while we sleep */ + + /* should never get here. */ + + printf("thread_func(): not canceled!\en"); + return null; +} + +int +main(void) +{ + pthread_t thr; + void *res; + int s; + + /* start a thread and then send it a cancellation request. */ + + s = pthread_create(&thr, null, &thread_func, null); + if (s != 0) + handle_error_en(s, "pthread_create"); + + sleep(2); /* give thread a chance to get started */ + + printf("main(): sending cancellation request\en"); + s = pthread_cancel(thr); + if (s != 0) + handle_error_en(s, "pthread_cancel"); + + /* join with thread to see what its exit status was. */ + + s = pthread_join(thr, &res); + if (s != 0) + handle_error_en(s, "pthread_join"); + + if (res == pthread_canceled) + printf("main(): thread was canceled\en"); + else + printf("main(): thread wasn\(aqt canceled (shouldn\(aqt happen!)\en"); + exit(exit_success); +} +.ee +.sh see also +.ad l +.nh +.br pthread_cleanup_push (3), +.br pthread_create (3), +.br pthread_exit (3), +.br pthread_join (3), +.br pthread_key_create (3), +.br pthread_setcancelstate (3), +.br pthread_setcanceltype (3), +.br pthread_testcancel (3), +.br pthreads (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/lround.3 + +.so man3/getpwnam.3 + +.so man2/setfsuid.2 + +.so man3/strcat.3 + +.so man3/strstr.3 + +.so man3/fmin.3 + +# spdx-license-identifier: gpl-2.0-only +######################################################################## +# +# (c) copyright 2020, 2021, alejandro colomar +# these functions are free software; you can redistribute them and/or +# modify them under the terms of the gnu general public license +# as published by the free software foundation; version 2. +# +# these functions are distributed in the hope that they will be useful, +# but without any warranty; without even the implied warranty of +# merchantability or fitness for a particular purpose. see the +# gnu general public license for more details +# (http://www.gnu.org/licenses/gpl-2.0.html). +# +######################################################################## + +######################################################################## +# exit status + +ex_ok=0; +ex_usage=64; + +######################################################################## +# c + +# sed_rm_ccomments() removes c comments. +# it can't handle multiple comments in a single line correctly, +# nor mixed or embedded //... and /*...*/ comments. +# use as a filter (see man_lsfunc() in this file). + +function sed_rm_ccomments() +{ + sed 's%/\*.*\*/%%' \ + |sed -e '\%/\*%,\%\*/%{\%(\*/|/\*)%!d; s%/\*.*%%; s%.*\*/%%;}' \ + |sed 's%//.*%%'; +} + +######################################################################## +# linux kernel + +# grep_syscall() finds the prototype of a syscall in the kernel sources, +# printing the filename, line number, and the prototype. +# it should be run from the root of the linux kernel source tree. +# usage example: .../linux$ grep_syscall openat2; + +function grep_syscall() +{ + if (($# != 1)); then + >&2 echo "usage: ${funcname[0]} "; + return ${ex_usage}; + fi + + find * -type f \ + |grep '\.c$' \ + |sort \ + |xargs pcregrep -mn "(?s)^\w*syscall_define.\(${1},.*?\)" \ + |sed -e 's/^[^:]+:[0-9]+:/&\n/'; + + find * -type f \ + |grep '\.[ch]$' \ + |sort \ + |xargs pcregrep -mn "(?s)^asmlinkage\s+[\w\s]+\**sys_${1}\s*\(.*?\)" \ + |sed -e 's/^[^:]+:[0-9]+:/&\n/'; +} + +# grep_syscall_def() finds the definition of a syscall in the kernel sources, +# printing the filename, line number, and the function definition. +# it should be run from the root of the linux kernel source tree. +# usage example: .../linux$ grep_syscall_def openat2; + +function grep_syscall_def() +{ + if (($# != 1)); then + >&2 echo "usage: ${funcname[0]} "; + return ${ex_usage}; + fi + + find * -type f \ + |grep '\.c$' \ + |sort \ + |xargs pcregrep -mn "(?s)^\w*syscall_define.\(${1},.*?^}" \ + |sed -e 's/^[^:]+:[0-9]+:/&\n/'; +} + +######################################################################## +# linux man-pages + +# man_section() prints specific manual page sections (description, synopsis, +# ...) of all manual pages in a directory (or in a single manual page file). +# usage example: .../man-pages$ man_section man2 synopsis 'conforming to'; + +function man_section() +{ + if (($# < 2)); then + >&2 echo "usage: ${funcname[0]}
..."; + return ${ex_usage}; + fi + + local page="$1"; + shift; + local sect="$@"; + + find "${page}" -type f \ + |xargs wc -l \ + |grep -v -e '\b1 ' -e '\btotal\b' \ + |awk '{ print $2 }' \ + |sort \ + |while read -r manpage; do + cat \ + <(<${manpage} sed -n '/^\.th/,/^\.sh/{/^\.sh/!p}') \ + <(for s in ${sect}; do + <${manpage} \ + sed -n \ + -e "/^\.sh ${s}/p" \ + -e "/^\.sh ${s}/,/^\.sh/{/^\.sh/!p}"; \ + done;) \ + |man -p cat -l - 2>/dev/null; + done; +} + +# man_lsfunc() prints the name of all c functions declared in the synopsis +# of all manual pages in a directory (or in a single manual page file). +# each name is printed in a separate line +# usage example: .../man-pages$ man_lsfunc man2; + +function man_lsfunc() +{ + if (($# < 1)); then + >&2 echo "usage: ${funcname[0]} ..."; + return ${ex_usage}; + fi + + for arg in "$@"; do + man_section "${arg}" 'synopsis'; + done \ + |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; +} + +# man_lsvar() prints the name of all c variables declared in the synopsis +# of all manual pages in a directory (or in a single manual page file). +# each name is printed in a separate line +# usage example: .../man-pages$ man_lsvar man3; + +function man_lsvar() +{ + if (($# < 1)); then + >&2 echo "usage: ${funcname[0]} ..."; + return ${ex_usage}; + fi + + for arg in "$@"; do + man_section "${arg}" 'synopsis'; + done \ + |sed_rm_ccomments \ + |pcregrep -mv '(?s)^ [\w ]+ \**\w+\([\w\s(,)[\]*]+?(...)?\s*\); *$' \ + |pcregrep -mn \ + -e '(?s)^ +extern [\w ]+ \**\(\*+[\w ]+\)\([\w\s(,)[\]*]+?\s*\); *$' \ + -e '^ +extern [\w ]+ \**[\w ]+; *$' \ + |grep '^[0-9]' \ + |grep -v 'typedef' \ + |sed -e 's/^[0-9]+: +extern [^(]+ \**\(\*+(\w* )?(\w+)\)\(.*/\2/' \ + |sed 's/^[0-9]\+: \+extern .* \**\(\w\+\); */\1/' \ + |uniq; +} + +# pdfman() renders a manual page in pdf +# usage example: .../man-pages$ pdfman man2/membarrier.2; + +function pdfman() +{ + if (($# != 1)); then + >&2 echo "usage: ${funcname[0]} "; + return ${ex_usage}; + fi; + + local tmp="$(mktemp -t "${1##*/}.xxxxxx")"; + + <${1} \ + man -tps -l - \ + |ps2pdf - - \ + >${tmp}; + xdg-open ${tmp}; +} + +# man_gitstaged prints a list of all files with changes staged for commit +# (basename only if the files are within ), separated by ", ". +# usage example: .../man-pages$ git commit -m "$(man_gitstaged): msg"; + +function man_gitstaged() +{ + git diff --staged --name-only \ + |sed "s/$/, /" \ + |sed "s%man[1-9]/%%" \ + |tr -d '\n' \ + |sed "s/, $//" +} + +######################################################################## +# glibc + +# grep_glibc_prototype() finds a function prototype in the glibc sources, +# printing the filename, line number, and the prototype. +# it should be run from the root of the glibc source tree. +# usage example: .../glibc$ grep_glibc_prototype printf; + +function grep_glibc_prototype() +{ + if (($# != 1)); then + >&2 echo "usage: ${funcname[0]} "; + return ${ex_usage}; + fi + + find * -type f \ + |grep '\.h$' \ + |sort \ + |xargs pcregrep -mn \ + "(?s)^[\w[][\w\s(,)[:\]]+\s+\**${1}\s*\([\w\s(,)[\]*]+?(...)?\)[\w\s(,)[:\]]*;" \ + |sed -e 's/^[^:]+:[0-9]+:/&\n/'; +} + +.\" copyright (c) 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sat jul 24 18:46:01 1993 by rik faith (faith@cs.unc.edu) +.\" modified 11 june 1995 by andries brouwer (aeb@cwi.nl) +.\" 2007-07-30 ulrich drepper : document fdopendir(). +.th opendir 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +opendir, fdopendir \- open a directory +.sh synopsis +.nf +.b #include +.b #include +.pp +.bi "dir *opendir(const char *" name ); +.bi "dir *fdopendir(int " fd ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br fdopendir (): +.nf + since glibc 2.10: + _posix_c_source >= 200809l + before glibc 2.10: + _gnu_source +.fi +.sh description +the +.br opendir () +function opens a directory stream corresponding to the +directory \finame\fp, and returns a pointer to the directory stream. +the stream is positioned at the first entry in the directory. +.pp +the +.br fdopendir () +function +is like +.br opendir (), +but returns a directory stream for the directory referred +to by the open file descriptor +.ir fd . +after a successful call to +.br fdopendir (), +.i fd +is used internally by the implementation, +and should not otherwise be used by the application. +.sh return value +the +.br opendir () +and +.br fdopendir () +functions return a pointer to the directory stream. +on error, null is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eacces +permission denied. +.tp +.b ebadf +.i fd +is not a valid file descriptor opened for reading. +.tp +.b emfile +the per-process limit on the number of open file descriptors has been reached. +.tp +.b enfile +the system-wide limit on the total number of open files has been reached. +.tp +.b enoent +directory does not exist, or \finame\fp is an empty string. +.tp +.b enomem +insufficient memory to complete the operation. +.tp +.b enotdir +\finame\fp is not a directory. +.sh versions +.br fdopendir () +is available in glibc since version 2.4. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br opendir (), +.br fdopendir () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +.br opendir () +is present on svr4, 4.3bsd, and specified in posix.1-2001. +.br fdopendir () +is specified in posix.1-2008. +.sh notes +filename entries can be read from a directory stream using +.br readdir (3). +.pp +the underlying file descriptor of the directory stream can be obtained using +.br dirfd (3). +.pp +the +.br opendir () +function sets the close-on-exec flag for the file descriptor underlying the +.ir "dir *" . +the +.br fdopendir () +function leaves the setting of the close-on-exec +flag unchanged for the file descriptor, +.ir fd . +posix.1-200x leaves it unspecified whether a successful call to +.br fdopendir () +will set the close-on-exec flag for the file descriptor, +.ir fd . +.sh see also +.br open (2), +.br closedir (3), +.br dirfd (3), +.br readdir (3), +.br rewinddir (3), +.br scandir (3), +.br seekdir (3), +.br telldir (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/fenv.3 + +.\" copyright (c) 2015 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th dlinfo 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +dlinfo \- obtain information about a dynamically loaded object +.sh synopsis +.nf +.b #define _gnu_source +.b #include +.b #include +.pp +.br "int dlinfo(void *restrict " handle ", int " request \ +", void *restrict " info ); +.pp +link with \fi\-ldl\fp. +.fi +.sh description +the +.br dlinfo () +function obtains information about the dynamically loaded object +referred to by +.ir handle +(typically obtained by an earlier call to +.br dlopen (3) +or +.br dlmopen (3)). +the +.i request +argument specifies which information is to be returned. +the +.i info +argument is a pointer to a buffer used to store information +returned by the call; the type of this argument depends on +.ir request . +.pp +the following values are supported for +.ir request +(with the corresponding type for +.ir info +shown in parentheses): +.tp +.br rtld_di_lmid " (\filmid_t *\fp)" +obtain the id of the link-map list (namespace) in which +.i handle +is loaded. +.tp +.br rtld_di_linkmap " (\fistruct link_map **\fp)" +obtain a pointer to the +.i link_map +structure corresponding to +.ir handle . +the +.ir info +argument points to a pointer to a +.i link_map +structure, defined in +.i +as: +.ip +.in +4n +.ex +struct link_map { + elfw(addr) l_addr; /* difference between the + address in the elf file and + the address in memory */ + char *l_name; /* absolute pathname where + object was found */ + elfw(dyn) *l_ld; /* dynamic section of the + shared object */ + struct link_map *l_next, *l_prev; + /* chain of loaded objects */ + + /* plus additional fields private to the + implementation */ +}; +.ee +.in +.tp +.br rtld_di_origin " (\fichar *\fp)" +copy the pathname of the origin of the shared object corresponding to +.ir handle +to the location pointed to by +.ir info . +.tp +.br rtld_di_serinfo " (\fidl_serinfo *\fp)" +obtain the library search paths for the shared object referred to by +.ir handle . +the +.i info +argument is a pointer to a +.i dl_serinfo +that contains the search paths. +because the number of search paths may vary, +the size of the structure pointed to by +.ir info +can vary. +the +.b rtld_di_serinfosize +request described below allows applications to size the buffer suitably. +the caller must perform the following steps: +.rs +.ip 1. 3 +use a +.b rtld_di_serinfosize +request to populate a +.i dl_serinfo +structure with the size +.ri ( dls_size ) +of the structure needed for the subsequent +.b rtld_di_serinfo +request. +.ip 2. +allocate a +.i dl_serinfo +buffer of the correct size +.ri ( dls_size ). +.ip 3. +use a further +.b rtld_di_serinfosize +request to populate the +.i dls_size +and +.i dls_cnt +fields of the buffer allocated in the previous step. +.ip 4. +use a +.b rtld_di_serinfo +to obtain the library search paths. +.re +.ip +the +.i dl_serinfo +structure is defined as follows: +.ip +.in +4n +.ex +typedef struct { + size_t dls_size; /* size in bytes of + the whole buffer */ + unsigned int dls_cnt; /* number of elements + in \(aqdls_serpath\(aq */ + dl_serpath dls_serpath[1]; /* actually longer, + \(aqdls_cnt\(aq elements */ +} dl_serinfo; +.ee +.in +.ip +each of the +.i dls_serpath +elements in the above structure is a structure of the following form: +.ip +.in +4n +.ex +typedef struct { + char *dls_name; /* name of library search + path directory */ + unsigned int dls_flags; /* indicates where this + directory came from */ +} dl_serpath; +.ee +.in +.ip +the +.i dls_flags +field is currently unused, and always contains zero. +.tp +.br rtld_di_serinfosize " (\fidl_serinfo *\fp)" +populate the +.i dls_size +and +.i dls_cnt +fields of the +.i dl_serinfo +structure pointed to by +.ir info +with values suitable for allocating a buffer for use in a subsequent +.b rtld_di_serinfo +request. +.tp +.br rtld_di_tls_modid " (\fisize_t *\fp, since glibc 2.4)" +obtain the module id of this shared object's tls (thread-local storage) +segment, as used in tls relocations. +if this object does not define a tls segment, zero is placed in +.ir *info . +.tp +.br rtld_di_tls_data " (\fivoid **\fp, since glibc 2.4)" +obtain a pointer to the calling +thread's tls block corresponding to this shared object's tls segment. +if this object does not define a pt_tls segment, +or if the calling thread has not allocated a block for it, +null is placed in +.ir *info . +.sh return value +on success, +.br dlinfo () +returns 0. +on failure, it returns \-1; the cause of the error can be diagnosed using +.br dlerror (3). +.sh versions +.br dlinfo () +first appeared in glibc 2.3.3. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br dlinfo () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +this function is a nonstandard gnu extension. +.sh notes +this function derives from the solaris function of the same name +and also appears on some other systems. +the sets of requests supported by the various implementations +overlaps only partially. +.sh examples +the program below opens a shared objects using +.br dlopen (3) +and then uses the +.b rtld_di_serinfosize +and +.b rtld_di_serinfo +requests to obtain the library search path list for the library. +here is an example of what we might see when running the program: +.pp +.in +4n +.ex +$ \fb./a.out /lib64/libm.so.6\fp +dls_serpath[0].dls_name = /lib64 +dls_serpath[1].dls_name = /usr/lib64 +.ee +.in +.ss program source +\& +.ex +#define _gnu_source +#include +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + void *handle; + dl_serinfo serinfo; + dl_serinfo *sip; + + if (argc != 2) { + fprintf(stderr, "usage: %s \en", argv[0]); + exit(exit_failure); + } + + /* obtain a handle for shared object specified on command line. */ + + handle = dlopen(argv[1], rtld_now); + if (handle == null) { + fprintf(stderr, "dlopen() failed: %s\en", dlerror()); + exit(exit_failure); + } + + /* discover the size of the buffer that we must pass to + rtld_di_serinfo. */ + + if (dlinfo(handle, rtld_di_serinfosize, &serinfo) == \-1) { + fprintf(stderr, "rtld_di_serinfosize failed: %s\en", dlerror()); + exit(exit_failure); + } + + /* allocate the buffer for use with rtld_di_serinfo. */ + + sip = malloc(serinfo.dls_size); + if (sip == null) { + perror("malloc"); + exit(exit_failure); + } + + /* initialize the \(aqdls_size\(aq and \(aqdls_cnt\(aq fields in the newly + allocated buffer. */ + + if (dlinfo(handle, rtld_di_serinfosize, sip) == \-1) { + fprintf(stderr, "rtld_di_serinfosize failed: %s\en", dlerror()); + exit(exit_failure); + } + + /* fetch and print library search list. */ + + if (dlinfo(handle, rtld_di_serinfo, sip) == \-1) { + fprintf(stderr, "rtld_di_serinfo failed: %s\en", dlerror()); + exit(exit_failure); + } + + for (int j = 0; j < serinfo.dls_cnt; j++) + printf("dls_serpath[%d].dls_name = %s\en", + j, sip\->dls_serpath[j].dls_name); + + exit(exit_success); +} +.ee +.sh see also +.br dl_iterate_phdr (3), +.br dladdr (3), +.br dlerror (3), +.br dlopen (3), +.br dlsym (3), +.br ld.so (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man7/uri.7 + +.\" copyright 2002 dimitri papadopoulos (dpo@club-internet.fr) +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th iso_8859-9 7 2020-08-13 "linux" "linux programmer's manual" +.sh name +iso_8859-9 \- iso 8859-9 character set encoded in octal, decimal, +and hexadecimal +.sh description +the iso 8859 standard includes several 8-bit extensions to the ascii +character set (also known as iso 646-irv). +iso 8859-9 encodes the +characters used in turkish. +.ss iso 8859 alphabets +the full set of iso 8859 alphabets includes: +.ts +l l. +iso 8859-1 west european languages (latin-1) +iso 8859-2 central and east european languages (latin-2) +iso 8859-3 southeast european and miscellaneous languages (latin-3) +iso 8859-4 scandinavian/baltic languages (latin-4) +iso 8859-5 latin/cyrillic +iso 8859-6 latin/arabic +iso 8859-7 latin/greek +iso 8859-8 latin/hebrew +iso 8859-9 latin-1 modification for turkish (latin-5) +iso 8859-10 lappish/nordic/eskimo languages (latin-6) +iso 8859-11 latin/thai +iso 8859-13 baltic rim languages (latin-7) +iso 8859-14 celtic (latin-8) +iso 8859-15 west european languages (latin-9) +iso 8859-16 romanian (latin-10) +.te +.ss iso 8859-9 characters +the following table displays the characters in iso 8859-9 that +are printable and unlisted in the +.br ascii (7) +manual page. +.ts +l l l c lp-1. +oct dec hex char description +_ +240 160 a0   no-break space +241 161 a1 ¡ inverted exclamation mark +242 162 a2 ¢ cent sign +243 163 a3 £ pound sign +244 164 a4 ¤ currency sign +245 165 a5 ¥ yen sign +246 166 a6 ¦ broken bar +247 167 a7 § section sign +250 168 a8 ¨ diaeresis +251 169 a9 © copyright sign +252 170 aa ª feminine ordinal indicator +253 171 ab « left-pointing double angle quotation mark +254 172 ac ¬ not sign +255 173 ad ­ soft hyphen +256 174 ae ® registered sign +257 175 af ¯ macron +260 176 b0 ° degree sign +261 177 b1 ± plus-minus sign +262 178 b2 ² superscript two +263 179 b3 ³ superscript three +264 180 b4 ´ acute accent +265 181 b5 µ micro sign +266 182 b6 ¶ pilcrow sign +267 183 b7 · middle dot +270 184 b8 ¸ cedilla +271 185 b9 ¹ superscript one +272 186 ba º masculine ordinal indicator +273 187 bb » right-pointing double angle quotation mark +274 188 bc ¼ vulgar fraction one quarter +275 189 bd ½ vulgar fraction one half +276 190 be ¾ vulgar fraction three quarters +277 191 bf ¿ inverted question mark +300 192 c0 à latin capital letter a with grave +301 193 c1 á latin capital letter a with acute +302 194 c2 â latin capital letter a with circumflex +303 195 c3 ã latin capital letter a with tilde +304 196 c4 ä latin capital letter a with diaeresis +305 197 c5 å latin capital letter a with ring above +306 198 c6 æ latin capital letter ae +307 199 c7 ç latin capital letter c with cedilla +310 200 c8 è latin capital letter e with grave +311 201 c9 é latin capital letter e with acute +312 202 ca ê latin capital letter e with circumflex +313 203 cb ë latin capital letter e with diaeresis +314 204 cc ì latin capital letter i with grave +315 205 cd í latin capital letter i with acute +316 206 ce î latin capital letter i with circumflex +317 207 cf ï latin capital letter i with diaeresis +320 208 d0 ğ latin capital letter g with breve +321 209 d1 ñ latin capital letter n with tilde +322 210 d2 ò latin capital letter o with grave +323 211 d3 ó latin capital letter o with acute +324 212 d4 ô latin capital letter o with circumflex +325 213 d5 õ latin capital letter o with tilde +326 214 d6 ö latin capital letter o with diaeresis +327 215 d7 × multiplication sign +330 216 d8 ø latin capital letter o with stroke +331 217 d9 ù latin capital letter u with grave +332 218 da ú latin capital letter u with acute +333 219 db û latin capital letter u with circumflex +334 220 dc ü latin capital letter u with diaeresis +335 221 dd i̇ latin capital letter i with dot above +336 222 de ş latin capital letter s with cedilla +337 223 df ß latin small letter sharp s +340 224 e0 à latin small letter a with grave +341 225 e1 á latin small letter a with acute +342 226 e2 â latin small letter a with circumflex +343 227 e3 ã latin small letter a with tilde +344 228 e4 ä latin small letter a with diaeresis +345 229 e5 å latin small letter a with ring above +346 230 e6 æ latin small letter ae +347 231 e7 ç latin small letter c with cedilla +350 232 e8 è latin small letter e with grave +351 233 e9 é latin small letter e with acute +352 234 ea ê latin small letter e with circumflex +353 235 eb ë latin small letter e with diaeresis +354 236 ec ì latin small letter i with grave +355 237 ed í latin small letter i with acute +356 238 ee î latin small letter i with circumflex +357 239 ef ï latin small letter i with diaeresis +360 240 f0 ğ latin small letter g with breve +361 241 f1 ñ latin small letter n with tilde +362 242 f2 ò latin small letter o with grave +363 243 f3 ó latin small letter o with acute +364 244 f4 ô latin small letter o with circumflex +365 245 f5 õ latin small letter o with tilde +366 246 f6 ö latin small letter o with diaeresis +367 247 f7 ÷ division sign +370 248 f8 ø latin small letter o with stroke +371 249 f9 ù latin small letter u with grave +372 250 fa ú latin small letter u with acute +373 251 fb û latin small letter u with circumflex +374 252 fc ü latin small letter u with diaeresis +375 253 fd ı latin small letter dotless i +376 254 fe ş latin small letter s with cedilla +377 255 ff ÿ latin small letter y with diaeresis +.te +.sh notes +iso 8859-9 is also known as latin-5. +.sh see also +.br ascii (7), +.br charsets (7), +.br utf\-8 (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/unimplemented.2 + +.\" copyright (c) 2003 nick clifford (zaf@nrc.co.nz), jan 25, 2003 +.\" copyright (c) 2003 andries brouwer (aeb@cwi.nl), aug 24, 2003 +.\" copyright (c) 2020 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" 2003-08-23 martin schulze improvements +.\" 2003-08-24 aeb, large parts rewritten +.\" 2004-08-06 christoph lameter , smp note +.\" +.th clock_getres 2 2021-03-22 "" "linux programmer's manual" +.sh name +clock_getres, clock_gettime, clock_settime \- clock and time functions +.sh synopsis +.nf +.b #include +.pp +.bi "int clock_getres(clockid_t " clockid ", struct timespec *" res ); +.pp +.bi "int clock_gettime(clockid_t " clockid ", struct timespec *" tp ); +.bi "int clock_settime(clockid_t " clockid ", const struct timespec *" tp ); +.fi +.pp +link with \fi\-lrt\fp (only for glibc versions before 2.17). +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br clock_getres (), +.br clock_gettime (), +.br clock_settime (): +.nf + _posix_c_source >= 199309l +.fi +.sh description +the function +.br clock_getres () +finds the resolution (precision) of the specified clock +.ir clockid , +and, if +.i res +is non-null, stores it in the \fistruct timespec\fp pointed to by +.ir res . +the resolution of clocks depends on the implementation and cannot be +configured by a particular process. +if the time value pointed to by the argument +.i tp +of +.br clock_settime () +is not a multiple of +.ir res , +then it is truncated to a multiple of +.ir res . +.pp +the functions +.br clock_gettime () +and +.br clock_settime () +retrieve and set the time of the specified clock +.ir clockid . +.pp +the +.i res +and +.i tp +arguments are +.i timespec +structures, as specified in +.ir : +.pp +.in +4n +.ex +struct timespec { + time_t tv_sec; /* seconds */ + long tv_nsec; /* nanoseconds */ +}; +.ee +.in +.pp +the +.i clockid +argument is the identifier of the particular clock on which to act. +a clock may be system-wide and hence visible for all processes, or +per-process if it measures time only within a single process. +.pp +all implementations support the system-wide real-time clock, +which is identified by +.br clock_realtime . +its time represents seconds and nanoseconds since the epoch. +when its time is changed, timers for a relative interval are +unaffected, but timers for an absolute point in time are affected. +.pp +more clocks may be implemented. +the interpretation of the +corresponding time values and the effect on timers is unspecified. +.pp +sufficiently recent versions of glibc and the linux kernel +support the following clocks: +.tp +.b clock_realtime +a settable system-wide clock that measures real (i.e., wall-clock) time. +setting this clock requires appropriate privileges. +this clock is affected by discontinuous jumps in the system time +(e.g., if the system administrator manually changes the clock), +and by the incremental adjustments performed by +.br adjtime (3) +and ntp. +.tp +.br clock_realtime_alarm " (since linux 3.0; linux-specific)" +like +.br clock_realtime , +but not settable. +see +.br timer_create (2) +for further details. +.tp +.br clock_realtime_coarse " (since linux 2.6.32; linux-specific)" +.\" added in commit da15cfdae03351c689736f8d142618592e3cebc3 +a faster but less precise version of +.br clock_realtime . +this clock is not settable. +use when you need very fast, but not fine-grained timestamps. +requires per-architecture support, +and probably also architecture support for this flag in the +.br vdso (7). +.tp +.br clock_tai " (since linux 3.10; linux-specific)" +.\" commit 1ff3c9677bff7e468e0c487d0ffefe4e901d33f4 +a nonsettable system-wide clock derived from wall-clock time +but ignoring leap seconds. +this clock does +not experience discontinuities and backwards jumps caused by ntp +inserting leap seconds as +.br clock_realtime +does. +.ip +the acronym tai refers to international atomic time. +.tp +.b clock_monotonic +a nonsettable system-wide clock that +represents monotonic time since\(emas described +by posix\(em"some unspecified point in the past". +on linux, that point corresponds to the number of seconds that the system +has been running since it was booted. +.ip +the +.b clock_monotonic +clock is not affected by discontinuous jumps in the system time +(e.g., if the system administrator manually changes the clock), +but is affected by the incremental adjustments performed by +.br adjtime (3) +and ntp. +this clock does not count time that the system is suspended. +all +.b clock_monotonic +variants guarantee that the time returned by consecutive calls will not go +backwards, but successive calls may\(emdepending on the architecture\(emreturn +identical (not-increased) time values. +.tp +.br clock_monotonic_coarse " (since linux 2.6.32; linux-specific)" +.\" added in commit da15cfdae03351c689736f8d142618592e3cebc3 +a faster but less precise version of +.br clock_monotonic . +use when you need very fast, but not fine-grained timestamps. +requires per-architecture support, +and probably also architecture support for this flag in the +.br vdso (7). +.tp +.br clock_monotonic_raw " (since linux 2.6.28; linux-specific)" +.\" added in commit 2d42244ae71d6c7b0884b5664cf2eda30fb2ae68, john stultz +similar to +.br clock_monotonic , +but provides access to a raw hardware-based time +that is not subject to ntp adjustments or +the incremental adjustments performed by +.br adjtime (3). +this clock does not count time that the system is suspended. +.tp +.br clock_boottime " (since linux 2.6.39; linux-specific)" +.\" commit 7fdd7f89006dd5a4c702fa0ce0c272345fa44ae0 +.\" commit 70a08cca1227dc31c784ec930099a4417a06e7d0 +a nonsettable system-wide clock that is identical to +.br clock_monotonic , +except that it also includes any time that the system is suspended. +this allows applications to get a suspend-aware monotonic clock +without having to deal with the complications of +.br clock_realtime , +which may have discontinuities if the time is changed using +.br settimeofday (2) +or similar. +.tp +.br clock_boottime_alarm " (since linux 3.0; linux-specific)" +like +.br clock_boottime . +see +.br timer_create (2) +for further details. +.tp +.br clock_process_cputime_id " (since linux 2.6.12)" +this is a clock that measures cpu time consumed by this process +(i.e., cpu time consumed by all threads in the process). +on linux, this clock is not settable. +.tp +.br clock_thread_cputime_id " (since linux 2.6.12)" +this is a clock that measures cpu time consumed by this thread. +on linux, this clock is not settable. +.pp +linux also implements dynamic clock instances as described below. +.ss dynamic clocks +in addition to the hard-coded system-v style clock ids described above, +linux also supports +posix clock operations on certain character devices. +such devices are +called "dynamic" clocks, and are supported since linux 2.6.39. +.pp +using the appropriate macros, open file +descriptors may be converted into clock ids and passed to +.br clock_gettime (), +.br clock_settime (), +and +.br clock_adjtime (2). +the following example shows how to convert a file descriptor into a +dynamic clock id. +.pp +.in +4n +.ex +#define clockfd 3 +#define fd_to_clockid(fd) ((\(ti(clockid_t) (fd) << 3) | clockfd) +#define clockid_to_fd(clk) ((unsigned int) \(ti((clk) >> 3)) + +struct timespec ts; +clockid_t clkid; +int fd; + +fd = open("/dev/ptp0", o_rdwr); +clkid = fd_to_clockid(fd); +clock_gettime(clkid, &ts); +.ee +.in +.sh return value +.br clock_gettime (), +.br clock_settime (), +and +.br clock_getres () +return 0 for success. +on error, \-1 is returned and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eacces +.br clock_settime () +does not have write permission for the dynamic posix +clock device indicated. +.tp +.b efault +.i tp +points outside the accessible address space. +.tp +.b einval +the +.i clockid +specified is invalid for one of two reasons. +either the system-v style +hard coded positive value is out of range, or the dynamic clock id +does not refer to a valid instance of a clock object. +.\" linux also gives this error on attempts to set clock_process_cputime_id +.\" and clock_thread_cputime_id, when probably the proper error should be +.\" eperm. +.tp +.b einval +.rb ( clock_settime ()): +.i tp.tv_sec +is negative or +.i tp.tv_nsec +is outside the range [0..999,999,999]. +.tp +.b einval +the +.i clockid +specified in a call to +.br clock_settime () +is not a settable clock. +.tp +.br einval " (since linux 4.3)" +.\" commit e1d7ba8735551ed79c7a0463a042353574b96da3 +a call to +.br clock_settime () +with a +.i clockid +of +.b clock_realtime +attempted to set the time to a value less than +the current value of the +.b clock_monotonic +clock. +.tp +.b enodev +the hot-pluggable device (like usb for example) represented by a +dynamic +.i clk_id +has disappeared after its character device was opened. +.tp +.b enotsup +the operation is not supported by the dynamic posix clock device +specified. +.tp +.b eperm +.br clock_settime () +does not have permission to set the clock indicated. +.sh versions +these system calls first appeared in linux 2.6. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br clock_getres (), +.br clock_gettime (), +.br clock_settime () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, susv2. +.pp +on posix systems on which these functions are available, the symbol +.b _posix_timers +is defined in \fi\fp to a value greater than 0. +the symbols +.br _posix_monotonic_clock , +.br _posix_cputime , +.b _posix_thread_cputime +indicate that +.br clock_monotonic , +.br clock_process_cputime_id , +.b clock_thread_cputime_id +are available. +(see also +.br sysconf (3).) +.sh notes +posix.1 specifies the following: +.rs +.pp +setting the value of the +.b clock_realtime +clock via +.br clock_settime () +shall have no effect on threads that are blocked waiting for a relative time +service based upon this clock, including the +.br nanosleep () +function; nor on the expiration of relative timers based upon this clock. +consequently, these time services shall expire when the requested relative +interval elapses, independently of the new or old value of the clock. +.re +.pp +according to posix.1-2001, a process with "appropriate privileges" may set the +.b clock_process_cputime_id +and +.b clock_thread_cputime_id +clocks using +.br clock_settime (). +on linux, these clocks are not settable +(i.e., no process has "appropriate privileges"). +.\" see http://bugzilla.kernel.org/show_bug.cgi?id=11972 +.\" +.ss c library/kernel differences +on some architectures, an implementation of +.br clock_gettime () +is provided in the +.br vdso (7). +.\" +.ss historical note for smp systems +before linux added kernel support for +.b clock_process_cputime_id +and +.br clock_thread_cputime_id , +glibc implemented these clocks on many platforms using timer +registers from the cpus +(tsc on i386, ar.itc on itanium). +these registers may differ between cpus and as a consequence +these clocks may return +.b bogus results +if a process is migrated to another cpu. +.pp +if the cpus in an smp system have different clock sources, then +there is no way to maintain a correlation between the timer registers since +each cpu will run at a slightly different frequency. +if that is the case, then +.i clock_getcpuclockid(0) +will return +.b enoent +to signify this condition. +the two clocks will then be useful only if it +can be ensured that a process stays on a certain cpu. +.pp +the processors in an smp system do not start all at exactly the same +time and therefore the timer registers are typically running at an offset. +some architectures include code that attempts to limit these offsets on bootup. +however, the code cannot guarantee to accurately tune the offsets. +glibc contains no provisions to deal with these offsets (unlike the linux +kernel). +typically these offsets are small and therefore the effects may be +negligible in most cases. +.pp +since glibc 2.4, +the wrapper functions for the system calls described in this page avoid +the abovementioned problems by employing the kernel implementation of +.b clock_process_cputime_id +and +.br clock_thread_cputime_id , +on systems that provide such an implementation +(i.e., linux 2.6.12 and later). +.sh examples +the program below demonstrates the use of +.br clock_gettime () +and +.br clock_getres () +with various clocks. +this is an example of what we might see when running the program: +.pp +.in +4n +.ex +$ \fb./clock_times x\fp +clock_realtime : 1585985459.446 (18356 days + 7h 30m 59s) + resolution: 0.000000001 +clock_tai : 1585985496.447 (18356 days + 7h 31m 36s) + resolution: 0.000000001 +clock_monotonic: 52395.722 (14h 33m 15s) + resolution: 0.000000001 +clock_boottime : 72691.019 (20h 11m 31s) + resolution: 0.000000001 +.ee +.in +.ss program source +\& +.ex +/* clock_times.c + + licensed under gnu general public license v2 or later. +*/ +#define _xopen_source 600 +#include +#include +#include +#include +#include +#include + +#define secs_in_day (24 * 60 * 60) + +static void +displayclock(clockid_t clock, const char *name, bool showres) +{ + struct timespec ts; + + if (clock_gettime(clock, &ts) == \-1) { + perror("clock_gettime"); + exit(exit_failure); + } + + printf("%\-15s: %10jd.%03ld (", name, + (intmax_t) ts.tv_sec, ts.tv_nsec / 1000000); + + long days = ts.tv_sec / secs_in_day; + if (days > 0) + printf("%ld days + ", days); + + printf("%2dh %2dm %2ds", + (int) (ts.tv_sec % secs_in_day) / 3600, + (int) (ts.tv_sec % 3600) / 60, + (int) ts.tv_sec % 60); + printf(")\en"); + + if (clock_getres(clock, &ts) == \-1) { + perror("clock_getres"); + exit(exit_failure); + } + + if (showres) + printf(" resolution: %10jd.%09ld\en", + (intmax_t) ts.tv_sec, ts.tv_nsec); +} + +int +main(int argc, char *argv[]) +{ + bool showres = argc > 1; + + displayclock(clock_realtime, "clock_realtime", showres); +#ifdef clock_tai + displayclock(clock_tai, "clock_tai", showres); +#endif + displayclock(clock_monotonic, "clock_monotonic", showres); +#ifdef clock_boottime + displayclock(clock_boottime, "clock_boottime", showres); +#endif + exit(exit_success); +} +.ee +.sh see also +.br date (1), +.br gettimeofday (2), +.br settimeofday (2), +.br time (2), +.br adjtime (3), +.br clock_getcpuclockid (3), +.br ctime (3), +.br ftime (3), +.br pthread_getcpuclockid (3), +.br sysconf (3), +.br time (7), +.br time_namespaces (7), +.br vdso (7), +.br hwclock (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/drand48.3 + +.so man3/drand48.3 + +.so man2/select.2 + +.so man3/argz_add.3 + +.\" copyright 1995 yggdrasil computing, incorporated. +.\" and copyright 2003, 2015 michael kerrisk +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th dlsym 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +dlsym, dlvsym \- obtain address of a symbol in a shared object or executable +.sh synopsis +.nf +.b #include +.pp +.bi "void *dlsym(void *restrict " handle ", const char *restrict " symbol ); +.pp +.b #define _gnu_source +.b #include +.pp +.bi "void *dlvsym(void *restrict " handle ", const char *restrict " symbol , +.bi " const char *restrict " version ); +.pp +link with \fi\-ldl\fp. +.fi +.sh description +the function +.br dlsym () +takes a "handle" of a dynamic loaded shared object returned by +.br dlopen (3) +along with a null-terminated symbol name, +and returns the address where that symbol is +loaded into memory. +if the symbol is not found, in the specified +object or any of the shared objects that were automatically loaded by +.br dlopen (3) +when that object was loaded, +.br dlsym () +returns null. +(the search performed by +.br dlsym () +is breadth first through the dependency tree of these shared objects.) +.pp +in unusual cases (see notes) the value of the symbol could actually be null. +therefore, a null return from +.br dlsym () +need not indicate an error. +the correct way to distinguish an error from a symbol whose value is null +is to call +.br dlerror (3) +to clear any old error conditions, then call +.br dlsym (), +and then call +.br dlerror (3) +again, saving its return value into a variable, and check whether +this saved value is not null. +.pp +there are two special pseudo-handles that may be specified in +.ir handle : +.tp +.b rtld_default +find the first occurrence of the desired symbol +using the default shared object search order. +the search will include global symbols in the executable +and its dependencies, +as well as symbols in shared objects that were dynamically loaded with the +.br rtld_global +flag. +.tp +.br rtld_next +find the next occurrence of the desired symbol in the search order +after the current object. +this allows one to provide a wrapper +around a function in another shared object, so that, for example, +the definition of a function in a preloaded shared object +(see +.b ld_preload +in +.br ld.so (8)) +can find and invoke the "real" function provided in another shared object +(or for that matter, the "next" definition of the function in cases +where there are multiple layers of preloading). +.pp +the +.b _gnu_source +feature test macro must be defined in order to obtain the +definitions of +.b rtld_default +and +.b rtld_next +from +.ir . +.pp +the function +.br dlvsym () +does the same as +.br dlsym () +but takes a version string as an additional argument. +.sh return value +on success, +these functions return the address associated with +.ir symbol . +on failure, they return null; +the cause of the error can be diagnosed using +.br dlerror (3). +.sh versions +.br dlsym () +is present in glibc 2.0 and later. +.br dlvsym () +first appeared in glibc 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br dlsym (), +.br dlvsym () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001 describes +.br dlsym (). +the +.br dlvsym () +function is a gnu extension. +.sh notes +there are several scenarios when the address of a global symbol is null. +for example, a symbol can be placed at zero address by the linker, via +a linker script or with +.i \-\-defsym +command-line option. +undefined weak symbols also have null value. +finally, the symbol value may be the result of +a gnu indirect function (ifunc) resolver function that returns +null as the resolved value. +in the latter case, +.br dlsym () +also returns null without error. +however, in the former two cases, the +behavior of gnu dynamic linker is inconsistent: relocation processing +succeeds and the symbol can be observed to have null value, but +.br dlsym () +fails and +.br dlerror () +indicates a lookup error. +.\" +.ss history +the +.br dlsym () +function is part of the dlopen api, derived from sunos. +that system does not have +.br dlvsym (). +.sh examples +see +.br dlopen (3). +.sh see also +.br dl_iterate_phdr (3), +.br dladdr (3), +.br dlerror (3), +.br dlinfo (3), +.br dlopen (3), +.br ld.so (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/j0.3 + +.so man3/sqrt.3 + +.so man3/nextafter.3 + +.\" this man page is copyright (c) 2000 andi kleen . +.\" +.\" %%%license_start(verbatim_one_para) +.\" permission is granted to distribute possibly modified copies +.\" of this page provided the header is included verbatim, +.\" and in case of nontrivial modification author and date +.\" of the modification is added to the header. +.\" %%%license_end +.\" +.\" $id: ipv6.7,v 1.3 2000/12/20 18:10:31 ak exp $ +.\" +.\" the following socket options are undocumented +.\" all of the following are from: +.\" commit 333fad5364d6b457c8d837f7d05802d2aaf8a961 +.\" author: yoshifuji hideaki +.\" support several new sockopt / ancillary data in advanced api (rfc3542). +.\" ipv6_2292pktinfo (2.6.14) +.\" formerly ipv6_pktinfo +.\" ipv6_2292hopopts (2.6.14) +.\" formerly ipv6_hopopts, which is documented +.\" ipv6_2292dstopts (2.6.14) +.\" formerly ipv6_dstopts, which is documented +.\" ipv6_2292rthdr (2.6.14) +.\" formerly ipv6_rthdr, which is documented +.\" ipv6_2292pktoptions (2.6.14) +.\" formerly ipv6_pktoptions +.\" ipv6_2292hoplimit (2.6.14) +.\" formerly ipv6_hoplimit, which is documented +.\" +.\" ipv6_recvhoplimit (2.6.14) +.\" ipv6_recvhopopts (2.6.14) +.\" ipv6_rthdrdstopts (2.6.14) +.\" ipv6_recvrthdr (2.6.14) +.\" ipv6_recvdstopts (2.6.14) +.\" +.\" ipv6_recvpathmtu (2.6.35, flag value added in 2.6.14) +.\" commit 793b14731686595a741d9f47726ad8b9a235385a +.\" author: brian haley +.\" ipv6_pathmtu (2.6.35, flag value added in 2.6.14) +.\" commit 793b14731686595a741d9f47726ad8b9a235385a +.\" author: brian haley +.\" ipv6_dontfrag (2.6.35, flag value added in 2.6.14) +.\" commit 793b14731686595a741d9f47726ad8b9a235385a +.\" author: brian haley +.\" commit 4b340ae20d0e2366792abe70f46629e576adaf5e +.\" author: brian haley +.\" +.\" ipv6_recvtclass (2.6.14) +.\" commit 41a1f8ea4fbfcdc4232f023732584aae2220de31 +.\" author: yoshifuji hideaki +.\" based on patch from david l stevens +.\" +.\" ipv6_checksum (2.2) +.\" ipv6_nexthop (2.2) +.\" ipv6_join_anycast (2.4.21 / 2.6) +.\" ipv6_leave_anycast (2.4.21 / 2.6) +.\" ipv6_flowlabel_mgr (2.2.7 / 2.4) +.\" ipv6_flowinfo_send (2.2.7 / 2.4) +.\" ipv6_ipsec_policy (2.6) +.\" ipv6_xfrm_policy (2.6) +.\" ipv6_tclass (2.6) +.\" +.\" ipv6_addr_preferences (2.6.26) +.\" commit 7cbca67c073263c179f605bdbbdc565ab29d801d +.\" author: yoshifuji hideaki +.\" ipv6_minhopcount (2.6.35) +.\" commit e802af9cabb011f09b9c19a82faef3dd315f27eb +.\" author: stephen hemminger +.\" ipv6_origdstaddr (2.6.37) +.\" actually a cmsg rather than a sockopt? +.\" in header file, we have ipv6_recvorigdstaddr == ipv6_origdstaddr +.\" commit 6c46862280c5f55eda7750391bc65cd7e08c7535 +.\" author: balazs scheidler +.\" ipv6_recvorigdstaddr (2.6.37) +.\" commit 6c46862280c5f55eda7750391bc65cd7e08c7535 +.\" author: balazs scheidler +.\" support for ipv6_recvorigdstaddr sockopt for udp sockets +.\" were contributed by harry mason. +.\" ipv6_transparent (2.6.37) +.\" commit 6c46862280c5f55eda7750391bc65cd7e08c7535 +.\" author: balazs scheidler +.\" ipv6_unicast_if (3.4) +.\" commit c4062dfc425e94290ac427a98d6b4721dd2bc91f +.\" author: erich e. hoover +.\" +.th ipv6 7 2021-03-22 "linux" "linux programmer's manual" +.sh name +ipv6 \- linux ipv6 protocol implementation +.sh synopsis +.nf +.b #include +.b #include +.pp +.ib tcp6_socket " = socket(af_inet6, sock_stream, 0);" +.ib raw6_socket " = socket(af_inet6, sock_raw, " protocol ");" +.ib udp6_socket " = socket(af_inet6, sock_dgram, " protocol ");" +.fi +.sh description +linux 2.2 optionally implements the internet protocol, version 6. +this man page contains a description of the ipv6 basic api as +implemented by the linux kernel and glibc 2.1. +the interface +is based on the bsd sockets interface; see +.br socket (7). +.pp +the ipv6 api aims to be mostly compatible with the +ipv4 api (see +.br ip (7)). +only differences are described in this man page. +.pp +to bind an +.b af_inet6 +socket to any process, the local address should be copied from the +.i in6addr_any +variable which has +.i in6_addr +type. +in static initializations, +.b in6addr_any_init +may also be used, which expands to a constant expression. +both of them are in network byte order. +.pp +the ipv6 loopback address (::1) is available in the global +.i in6addr_loopback +variable. +for initializations, +.b in6addr_loopback_init +should be used. +.pp +ipv4 connections can be handled with the v6 api by using the +v4-mapped-on-v6 address type; +thus a program needs to support only this api type to +support both protocols. +this is handled transparently by the address +handling functions in the c library. +.pp +ipv4 and ipv6 share the local port space. +when you get an ipv4 connection +or packet to an ipv6 socket, its source address will be mapped +to v6 and it will be mapped to v6. +.ss address format +.in +4n +.ex +struct sockaddr_in6 { + sa_family_t sin6_family; /* af_inet6 */ + in_port_t sin6_port; /* port number */ + uint32_t sin6_flowinfo; /* ipv6 flow information */ + struct in6_addr sin6_addr; /* ipv6 address */ + uint32_t sin6_scope_id; /* scope id (new in 2.4) */ +}; + +struct in6_addr { + unsigned char s6_addr[16]; /* ipv6 address */ +}; +.ee +.in +.pp +.i sin6_family +is always set to +.br af_inet6 ; +.i sin6_port +is the protocol port (see +.i sin_port +in +.br ip (7)); +.i sin6_flowinfo +is the ipv6 flow identifier; +.i sin6_addr +is the 128-bit ipv6 address. +.i sin6_scope_id +is an id depending on the scope of the address. +it is new in linux 2.4. +linux supports it only for link-local addresses, in that case +.i sin6_scope_id +contains the interface index (see +.br netdevice (7)) +.pp +ipv6 supports several address types: unicast to address a single +host, multicast to address a group of hosts, +anycast to address the nearest member of a group of hosts +(not implemented in linux), ipv4-on-ipv6 to +address an ipv4 host, and other reserved address types. +.pp +the address notation for ipv6 is a group of 8 4-digit hexadecimal +numbers, separated with a \(aq:\(aq. +\&"::" stands for a string of 0 bits. +special addresses are ::1 for loopback and ::ffff: +for ipv4-mapped-on-ipv6. +.pp +the port space of ipv6 is shared with ipv4. +.ss socket options +ipv6 supports some protocol-specific socket options that can be set with +.br setsockopt (2) +and read with +.br getsockopt (2). +the socket option level for ipv6 is +.br ipproto_ipv6 . +a boolean integer flag is zero when it is false, otherwise true. +.tp +.b ipv6_addrform +turn an +.b af_inet6 +socket into a socket of a different address family. +only +.b af_inet +is currently supported for that. +it is allowed only for ipv6 sockets +that are connected and bound to a v4-mapped-on-v6 address. +the argument is a pointer to an integer containing +.br af_inet . +this is useful to pass v4-mapped sockets as file descriptors to +programs that don't know how to deal with the ipv6 api. +.tp +.b ipv6_add_membership, ipv6_drop_membership +control membership in multicast groups. +argument is a pointer to a +.ir "struct ipv6_mreq" . +.tp +.b ipv6_mtu +.br getsockopt (): +retrieve the current known path mtu of the current socket. +valid only when the socket has been connected. +returns an integer. +.ip +.br setsockopt (): +set the mtu to be used for the socket. +the mtu is limited by the device +mtu or the path mtu when path mtu discovery is enabled. +argument is a pointer to integer. +.tp +.b ipv6_mtu_discover +control path-mtu discovery on the socket. +see +.b ip_mtu_discover +in +.br ip (7) +for details. +.tp +.b ipv6_multicast_hops +set the multicast hop limit for the socket. +argument is a pointer to an +integer. +\-1 in the value means use the route default, otherwise it should be +between 0 and 255. +.tp +.b ipv6_multicast_if +set the device for outgoing multicast packets on the socket. +this is allowed only for +.b sock_dgram +and +.b sock_raw +socket. +the argument is a pointer to an interface index (see +.br netdevice (7)) +in an integer. +.tp +.b ipv6_multicast_loop +control whether the socket sees multicast packets that it has send itself. +argument is a pointer to boolean. +.tp +.br ipv6_recvpktinfo " (since linux 2.6.14)" +set delivery of the +.b ipv6_pktinfo +control message on incoming datagrams. +such control messages contain a +.ir "struct in6_pktinfo" , +as per rfc 3542. +allowed only for +.b sock_dgram +or +.b sock_raw +sockets. +argument is a pointer to a boolean value in an integer. +.tp +.nh +.b ipv6_rthdr, ipv6_authhdr, ipv6_dstopts, ipv6_hopopts, ipv6_flowinfo, ipv6_hoplimit +.hy +set delivery of control messages for incoming datagrams containing +extension headers from the received packet. +.b ipv6_rthdr +delivers the routing header, +.b ipv6_authhdr +delivers the authentication header, +.b ipv6_dstopts +delivers the destination options, +.b ipv6_hopopts +delivers the hop options, +.b ipv6_flowinfo +delivers an integer containing the flow id, +.b ipv6_hoplimit +delivers an integer containing the hop count of the packet. +the control messages have the same type as the socket option. +all these header options can also be set for outgoing packets +by putting the appropriate control message into the control buffer of +.br sendmsg (2). +allowed only for +.b sock_dgram +or +.b sock_raw +sockets. +argument is a pointer to a boolean value. +.tp +.b ipv6_recverr +control receiving of asynchronous error options. +see +.b ip_recverr +in +.br ip (7) +for details. +argument is a pointer to boolean. +.tp +.b ipv6_router_alert +pass forwarded packets containing a router alert hop-by-hop option to +this socket. +allowed only for +.b sock_raw +sockets. +the tapped packets are not forwarded by the kernel, it is the +user's responsibility to send them out again. +argument is a pointer to an integer. +a positive integer indicates a router alert option value to intercept. +packets carrying a router alert option with a value field containing +this integer will be delivered to the socket. +a negative integer disables delivery of packets with router alert options +to this socket. +.tp +.b ipv6_unicast_hops +set the unicast hop limit for the socket. +argument is a pointer to an integer. +\-1 in the value means use the route default, +otherwise it should be between 0 and 255. +.tp +.br ipv6_v6only " (since linux 2.4.21 and 2.6)" +.\" see rfc 3493 +if this flag is set to true (nonzero), then the socket is restricted +to sending and receiving ipv6 packets only. +in this case, an ipv4 and an ipv6 application can bind +to a single port at the same time. +.ip +if this flag is set to false (zero), +then the socket can be used to send and receive packets +to and from an ipv6 address or an ipv4-mapped ipv6 address. +.ip +the argument is a pointer to a boolean value in an integer. +.ip +the default value for this flag is defined by the contents of the file +.ir /proc/sys/net/ipv6/bindv6only . +the default value for that file is 0 (false). +.\" flowlabel_mgr, flowinfo_send +.sh errors +.tp +.b enodev +the user tried to +.br bind (2) +to a link-local ipv6 address, but the +.i sin6_scope_id +in the supplied +.i sockaddr_in6 +structure is not a valid +interface index. +.sh versions +linux 2.4 will break binary compatibility for the +.i sockaddr_in6 +for 64-bit +hosts by changing the alignment of +.i in6_addr +and adding an additional +.i sin6_scope_id +field. +the kernel interfaces stay compatible, but a program including +.i sockaddr_in6 +or +.i in6_addr +into other structures may not be. +this is not +a problem for 32-bit hosts like i386. +.pp +the +.i sin6_flowinfo +field is new in linux 2.4. +it is transparently passed/read by the kernel +when the passed address length contains it. +some programs that pass a longer address buffer and then +check the outgoing address length may break. +.sh notes +the +.i sockaddr_in6 +structure is bigger than the generic +.ir sockaddr . +programs that assume that all address types can be stored safely in a +.i struct sockaddr +need to be changed to use +.i struct sockaddr_storage +for that instead. +.pp +.br sol_ip , +.br sol_ipv6 , +.br sol_icmpv6 , +and other +.b sol_* +socket options are nonportable variants of +.br ipproto_* . +see also +.br ip (7). +.sh bugs +the ipv6 extended api as in rfc\ 2292 is currently only partly +implemented; +although the 2.2 kernel has near complete support for receiving options, +the macros for generating ipv6 options are missing in glibc 2.1. +.pp +ipsec support for eh and ah headers is missing. +.pp +flow label management is not complete and not documented here. +.pp +this man page is not complete. +.sh see also +.br cmsg (3), +.br ip (7) +.pp +rfc\ 2553: ipv6 basic api; +linux tries to be compliant to this. +rfc\ 2460: ipv6 specification. +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/getspnam.3 + +.\" copyright (c) 2016 by michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" +.th cgroup_namespaces 7 2020-11-01 "linux" "linux programmer's manual" +.sh name +cgroup_namespaces \- overview of linux cgroup namespaces +.sh description +for an overview of namespaces, see +.br namespaces (7). +.pp +cgroup namespaces virtualize the view of a process's cgroups (see +.br cgroups (7)) +as seen via +.ir /proc/[pid]/cgroup +and +.ir /proc/[pid]/mountinfo . +.pp +each cgroup namespace has its own set of cgroup root directories. +these root directories are the base points for the relative +locations displayed in the corresponding records in the +.ir /proc/[pid]/cgroup +file. +when a process creates a new cgroup namespace using +.br clone (2) +or +.br unshare (2) +with the +.br clone_newcgroup +flag, its current +cgroups directories become the cgroup root directories +of the new namespace. +(this applies both for the cgroups version 1 hierarchies +and the cgroups version 2 unified hierarchy.) +.pp +when reading the cgroup memberships of a "target" process from +.ir /proc/[pid]/cgroup , +the pathname shown in the third field of each record will be +relative to the reading process's root directory +for the corresponding cgroup hierarchy. +if the cgroup directory of the target process lies outside +the root directory of the reading process's cgroup namespace, +then the pathname will show +.i ../ +entries for each ancestor level in the cgroup hierarchy. +.pp +the following shell session demonstrates the effect of creating +a new cgroup namespace. +.pp +first, (as superuser) in a shell in the initial cgroup namespace, +we create a child cgroup in the +.i freezer +hierarchy, and place a process in that cgroup that we will +use as part of the demonstration below: +.pp +.in +4n +.ex +# \fbmkdir \-p /sys/fs/cgroup/freezer/sub2\fp +# \fbsleep 10000 &\fp # create a process that lives for a while +[1] 20124 +# \fbecho 20124 > /sys/fs/cgroup/freezer/sub2/cgroup.procs\fp +.ee +.in +.pp +we then create another child cgroup in the +.i freezer +hierarchy and put the shell into that cgroup: +.pp +.in +4n +.ex +# \fbmkdir \-p /sys/fs/cgroup/freezer/sub\fp +# \fbecho $$\fp # show pid of this shell +30655 +# \fbecho 30655 > /sys/fs/cgroup/freezer/sub/cgroup.procs\fp +# \fbcat /proc/self/cgroup | grep freezer\fp +7:freezer:/sub +.ee +.in +.pp +next, we use +.br unshare (1) +to create a process running a new shell in new cgroup and mount namespaces: +.pp +.in +4n +.ex +# \fbps1="sh2# " unshare \-cm bash\fp +.ee +.in +.pp +from the new shell started by +.br unshare (1), +we then inspect the +.ir /proc/[pid]/cgroup +files of, respectively, the new shell, +a process that is in the initial cgroup namespace +.ri ( init , +with pid 1), and the process in the sibling cgroup +.ri ( sub2 ): +.pp +.in +4n +.ex +sh2# \fbcat /proc/self/cgroup | grep freezer\fp +7:freezer:/ +sh2# \fbcat /proc/1/cgroup | grep freezer\fp +7:freezer:/.. +sh2# \fbcat /proc/20124/cgroup | grep freezer\fp +7:freezer:/../sub2 +.ee +.in +.pp +from the output of the first command, +we see that the freezer cgroup membership of the new shell +(which is in the same cgroup as the initial shell) +is shown defined relative to the freezer cgroup root directory +that was established when the new cgroup namespace was created. +(in absolute terms, +the new shell is in the +.i /sub +freezer cgroup, +and the root directory of the freezer cgroup hierarchy +in the new cgroup namespace is also +.ir /sub . +thus, the new shell's cgroup membership is displayed as \(aq/\(aq.) +.pp +however, when we look in +.ir /proc/self/mountinfo +we see the following anomaly: +.pp +.in +4n +.ex +sh2# \fbcat /proc/self/mountinfo | grep freezer\fp +155 145 0:32 /.. /sys/fs/cgroup/freezer ... +.ee +.in +.pp +the fourth field of this line +.ri ( /.. ) +should show the +directory in the cgroup filesystem which forms the root of this mount. +since by the definition of cgroup namespaces, the process's current +freezer cgroup directory became its root freezer cgroup directory, +we should see \(aq/\(aq in this field. +the problem here is that we are seeing a mount entry for the cgroup +filesystem corresponding to the initial cgroup namespace +(whose cgroup filesystem is indeed rooted at the parent directory of +.ir sub ). +to fix this problem, we must remount the freezer cgroup filesystem +from the new shell (i.e., perform the mount from a process that is in the +new cgroup namespace), after which we see the expected results: +.pp +.in +4n +.ex +sh2# \fbmount \-\-make\-rslave /\fp # don\(aqt propagate mount events + # to other namespaces +sh2# \fbumount /sys/fs/cgroup/freezer\fp +sh2# \fbmount \-t cgroup \-o freezer freezer /sys/fs/cgroup/freezer\fp +sh2# \fbcat /proc/self/mountinfo | grep freezer\fp +155 145 0:32 / /sys/fs/cgroup/freezer rw,relatime ... +.ee +.in +.\" +.sh conforming to +namespaces are a linux-specific feature. +.sh notes +use of cgroup namespaces requires a kernel that is configured with the +.b config_cgroups +option. +.pp +the virtualization provided by cgroup namespaces serves a number of purposes: +.ip * 2 +it prevents information leaks whereby cgroup directory paths outside of +a container would otherwise be visible to processes in the container. +such leakages could, for example, +reveal information about the container framework +to containerized applications. +.ip * +it eases tasks such as container migration. +the virtualization provided by cgroup namespaces +allows containers to be isolated from knowledge of +the pathnames of ancestor cgroups. +without such isolation, the full cgroup pathnames (displayed in +.ir /proc/self/cgroups ) +would need to be replicated on the target system when migrating a container; +those pathnames would also need to be unique, +so that they don't conflict with other pathnames on the target system. +.ip * +it allows better confinement of containerized processes, +because it is possible to mount the container's cgroup filesystems such that +the container processes can't gain access to ancestor cgroup directories. +consider, for example, the following scenario: +.rs 4 +.ip \(bu 2 +we have a cgroup directory, +.ir /cg/1 , +that is owned by user id 9000. +.ip \(bu +we have a process, +.ir x , +also owned by user id 9000, +that is namespaced under the cgroup +.ir /cg/1/2 +(i.e., +.i x +was placed in a new cgroup namespace via +.br clone (2) +or +.br unshare (2) +with the +.br clone_newcgroup +flag). +.re +.ip +in the absence of cgroup namespacing, because the cgroup directory +.ir /cg/1 +is owned (and writable) by uid 9000 and process +.i x +is also owned by user id 9000, process +.i x +would be able to modify the contents of cgroups files +(i.e., change cgroup settings) not only in +.ir /cg/1/2 +but also in the ancestor cgroup directory +.ir /cg/1 . +namespacing process +.ir x +under the cgroup directory +.ir /cg/1/2 , +in combination with suitable mount operations +for the cgroup filesystem (as shown above), +prevents it modifying files in +.ir /cg/1 , +since it cannot even see the contents of that directory +(or of further removed cgroup ancestor directories). +combined with correct enforcement of hierarchical limits, +this prevents process +.i x +from escaping the limits imposed by ancestor cgroups. +.sh see also +.br unshare (1), +.br clone (2), +.br setns (2), +.br unshare (2), +.br proc (5), +.br cgroups (7), +.br credentials (7), +.br namespaces (7), +.br user_namespaces (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +==================== changes in man-pages-2.00 ==================== + +released: 2004-12-16 + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +alberto bertogli +anand kumria +andrey kiselev +andries brouwer +chris green +branden robinson +emmanuel colbus +enrico zini +eric estievenart +fabian kreutz +florian weimer +jan kuznik +joey (martin) schulze +johannes berg +john v. belmonte +karel kulhavy +luis javier merino morán +martin pool +richard kreckel +vasya pupkin + +apologies if i missed anyone! + +global changes +-------------- + +various pages + fabian kreutz + many math pages had their synopses compressed, as per suggestion + from fabian kreutz. + +various pages + fabian kreutz / aeb + many minor content and formatting bug fixes were made to the math + pages, following suggestions from fabian kreutz (who recently + translated many of the 1.70 math pages into german) and + andries brouwer. + +various pages + mtk + for consistency, all instances of "super-user" were changed + to the more common "superuser". + +various pages + vasya pupkin / mtk + after a note from vasya pupkin, i added to the synopsis + of several section 2 pages using the _syscalln() macros. + + in addition: + -- erroneous semicolons at the end of _syscalln() were removed + on various pages. + + -- types such as "uint" in syscalln() declarations were changed + to "unsigned int", etc. + + -- various other minor breakages in the synopses were fixed. + + the affected pages are: + + getdents.2 + gettid.2 + llseek.2 + mmap2.2 + modify_ldt.2 + pivot_root.2 + quotactl.2 + readdir.2 + sysctl.2 + syslog.2 + tkill.2 + +typographical or grammatical errors have been corrected in several +other places. + +changes to individual pages +--------------------------- + +bind.2 + florian weimer + added 'const' to declaration of 'my_addr' in prototype. + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=239762. + +fcntl.2 + martin pool + added o_noatime to list of flags that can be changed via f_setfl. + mtk/aeb + noted f_getown bug after suggestion from aeb. + see also: + http://marc.theaimsgroup.com/?l=linux-kernel&m=108380640603164&w=2 + +getrlimit.2 + mtk + material on getrusage.2 has been separated out into its own page. + rewrote discussion on rlimit_memlock to incorporate kernel + 2.6.9 changes. + added note on rlimit_cpu error in older kernels. + added rlimit_sigpending. + also made a few other minor changes. + +getrusage.2 + mtk + this page is new(ish) -- it was created by splitting + getrlimit.2. + + repaired note on sigchld behavior to note that the + posix non-conformance has been fixed in 2.6.9. + +kill.2 + modified after suggestion from emmanuel colbus + changed wording of sentence under notes describing + when signals can be sent to init(1). + +mlock.2 +munlock.2 +mlockall.2 +munlockall.2 + these have been consolidated into a single mlock.2 page. + in the process, much duplication was eliminated + and new information was added about rlimit_memlock + and the changes in memory locking in kernel 2.6.9, + +mmap.2 + mtk + added cross-ref to setrlimit(2) concerning memory locking limits. + eric estievenart + note that map_fixed replaces existing mappings + +msgctl.2 + mtk + substantial language and formatting clean-ups. + added msqid_ds and ipc_perm structure definitions. + +msgget.2 + mtk + substantial language and formatting clean-ups. + added notes on /proc files. + +msgop.2 + mtk + substantial language and formatting clean-ups. + added notes on /proc files. + +open.2 + martin pool + added o_noatime (new in linux 2.6.8) + mtk + reordered list of 'flags' description alphabetically + +personality.2 + 2004-11-03 applied patch from martin schulze + +semctl.2 + mtk + substantial language and formatting clean-ups. + rewrote semun text. + added semid_ds and ipc_perm structure definitions. + +semget.2 + mtk + substantial language and formatting clean-ups. + added notes on /proc files. + rewrote bugs note about semget()'s failure to initialize + semaphore values. + +semop.2 + mtk + substantial language and formatting clean-ups. + added notes on /proc files. + +shmctl.2 + mtk + substantial language and formatting clean-ups. + updated shmid_ds structure definitions. + added information on shm_dest and shm_locked flags. + noted that cap_ipc_lock is not required for shm_unlock + since kernel 2.6.9. + added notes on 2.6.9 rlimit_memlock changes. + added rlimit_sigpending (new in linux 2.6.8) + +shmget.2 + mtk + substantial language and formatting clean-ups. + added notes on /proc files. + +shmop.2 + mtk + substantial language and formatting clean-ups. + changed wording and placement of sentence regarding attachment + of segments marked for destruction. + +sigaction.2 + mtk + added mention of sigcont under sa_nocldstop. + added sa_nocldwait. + updated discussion for posix.1-2001 and sigchld and sa_flags. + noted that cld_continued is supported since linux 2.6.9. + added si_tkill (new in linux 2.4.19). + other minor changes. + +signal.2 + mtk + removed text on ignoring sigchld; replaced with pointer + to sigaction.2. + +sigwaitinfo.2 + after bug report from andrey kiselev + fixed prototype: "timeout" --> "*timeout" + as per: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=222145 + +stat.2 + enrico zini + added text to clarify that s_is*() macros should be applied to + st_mode field. + as per: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=249698 + +swapon.2 + after debian bug report from anand kumria + added "no swap space signature" to einval error. + mtk + added einval error for swapoff() ("not currently a swap area"). + added ebusy error for swapon(). + a few formatting fixes. + +times.2 + mtk + in linux 2.6, the return value of times changed; it is no + longer time since boot, but rather: + + boot_time + 2^32 / hz - 300 + + repaired note on sigchld behavior to note that the + posix non-conformance has been fixed in 2.6.9. + some formatting fixes. + +undocumented.2 + after bug report from johannes berg + changed + .th unimplemented + to: + .th undocumented + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=220741 + +wait.2 + mtk + added waitid(2). + added wcontinued and wifcontinued (new in 2.6.10). + added text on sa_nocldstop. + updated discussion of sa_nocldwait to reflect 2.6 behavior. + much other text rewritten. + +wait4.2 + mtk + rewrote this page, removing much duplicated information, + and replacing with pointers to wait.2. + luis javier merino morán / mtk + conforming to said "svr4, posix". changed to "4.3bsd" + +waitid.2 + mtk + new link to wait.2 + +assert.3 + after bug report from branden robinson + the assert() failure message goes to stderr not stdout. + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=284814 + +ctime.3 + mtk + noted that 0 in tm_mday is interpreted to mean the last day + of the preceding month. + +getnameinfo.3 + http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=229618 + getnameinfo() does not set errno, it returns a non-zero + value indicating the error. + mtk + added eai_overflow error + +killpg.3 + mtk + minor changes to see also and conforming to. + +lseek64.3 + aeb + new page by andries brouwer + +tzset.3 + richard kreckel + change "null" to "empty" when talking about the value of tz. + http://sources.redhat.com/bugzilla/show_bug.cgi?id=601 + +printf.3 + after bug report from jan kuznik + http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=205736 + fixed bad realloc() use in snprintf() example + +realpath.3 + mtk + added discussion of resolved_path == null. + +random.4 + after bug report from john v. belmonte + updated init and quit scripts to reflect kernel 2.4/2.6 reality + (scripts taken from drivers/char/random.c) + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=247779 + +proc.5 + mtk + updated description of /proc/loadavg to include + nr_running(), nr_threads, last_pid. + + rtsig-max and rtsig-nr went away in 2.6.8 + + updated statm, and fixed error in order of list + +boot.7 + applied patch from martin schulze + +capabilities.7 + mtk + added o_noatime for cap_fowner + +netdevice.7 + karel kulhavy and aeb + formatting fix after note from karel kulhavy and aeb, plus a + few wording fixes. + +signal.7 + mtk + /proc/sys/kernel/rtsig-* were superseded by rlimit_sigpending + in kernel 2.6.8. + +tcp.7 + mtk/aeb + updated details of interaction of tcp_cork and tcp_nodelay. + +==================== changes in man-pages-2.01 ==================== + +released: 2004-12-20 + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +carsten hey +johannes berg +joshua kwan +marek habersack +martin schulze +matthew dempsky +matthew gregan +pedro zorzenon neto +tony crawford + +apologies if i missed anyone! + +global changes +-------------- + +accept.2 +close.2 +send.2 +setsid.2 +socket.2 +closedir.3 +initgroups.3 +mkstemp.3 +opendir.3 +readdir.3 +telldir.3 + matthew dempsky, mtk + triggered by http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=283179 + the wording describing how errno is set was fixed up in these pages. + +typographical or grammatical errors have been corrected in several +other places. + +changes to individual pages +--------------------------- + +sendfile.2 + mtk + adjusted descriptions of argument file types to be closer to + 2.6 reality. + wording and formatting changes. + +ctan.3 +ctanh.3 + tony crawford + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=270817 + formulae on the pages should be t = s / c not t = c / s. + +errno.3 + martin schulze, mtk + removed errno declaration from prototype, added notes + on historical need for this declaration. + http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=174175 + +aio_return.3 + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=224953 + changed erroneous "aio_return(2)" to "aio_return(3)". + +posix_openpt.3 + mtk + new by mtk + +ptsname.3 + mtk + added description of ptsname_r(). + added errors. + +ptsname_r.3 + mtk + new link to ptsname.3. + +shm_open.3 + matthew gregan + add to synopsis + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=271243 + +strcasecmp.3 + marek habersack + .sh "conforming to" + -bsd 4.4 + +bsd 4.4, susv3 + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=234443 + +strfry.3 + joshua kwan + added _gnu_source to prototype + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=213538 + +strftime.3 + cartsen hey + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=276248 + + changed range for "%s" from 0..61 to 0..60. + + susv3 says 0..60. i think the manual page probably says + 0..61, because that's what susv2 said. + (some other implementations' man pages also say 0..61 -- + e.g., solaris 8 & 9, tru64 5.1b; freebsd 5.1 says 0..60.) + + the glibc manual currently says 0..60. + + given that susv3 says 0..60, i've changed the + manual page to also say this: + + -the second as a decimal number (range 00 to 61). + +the second as a decimal number (range 00 to 60). + +(the range is up to 60 to allow for occasional leap seconds.) + +sysconf.3 + johannes berg + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=226974 + -.br posix2_fort_run " - " _sc_2_fort_dev + +.br posix2_fort_dev " - " _sc_2_fort_dev + +system.3 + pedro zorzenon + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=242638 + noted use of _xopen_source to get macros from + for wait(2). + + mtk + changed name of argument from 'string' to 'command' (like posix). + + noted that glibc does nowadays explicitly check for the existence + of the shell if 'command' is null, rather than the older behavior + of assuming the shell exists and always returning 1 if + 'command' is null. + + other wording and formatting clean-ups. + +undocumented.3 + remove some functions names that *are* documented. + + +==================== changes in man-pages-2.02 ==================== + +released: 2005-04-14 + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +andries brouwer +branden robinson +colin watson +david lloyd +gordon jin +heikki orsila +jamie lokier +johan walles +kai makisara +marko kohtala +martin pool +martin (joey) schulze +matthias lang +michael haardt +michael mühlebach +mike frysinger +sasa stevanovic +serguei leontiev + +apologies if i missed anyone! + +global changes +-------------- + +ctime.3 +tzselect.8 +zdump.8 +zic.8 + martin (joey) schulze + removed see also reference to nonexistent newctime(3). + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=236884 + +typographical or grammatical errors have been corrected in several +other places. + +changes to individual pages +--------------------------- + +clone.2 + mtk + noted the pid caching behavior of nptl's getpid() + wrapper under bugs. + + added futex(2), set_thread_area(2), set_tid_address(2), + tkill(2) under see also. + +epoll_ctl.2 +epoll_create.2 + marko kohtala / mtk + improved various error descriptions. + +epoll_wait.2 + david lloyd / mike frysinger, marko kohtala + added eintr to errors. + +fcntl.2 + jamie lokier / mtk + improved discussion of f_setown and f_setsig with respect to + multi-threaded programs. + generally cleaned up the discussion of f_setown. + + updated conforming to to note that f_getown and f_setown are + now in posix. + +link.2 + mtk + noted discrepancy between linux and posix.1 when oldpath + is a symbolic link. + see: http://bugs.linuxbase.org/show_bug.cgi?id=367 + and: http://www.opengroup.org/austin/mailarchives/ag/msg08152.html + + michael haardt / mtk + clarified exdev error description: it isn't possible to link + across mount points, even if the mount points refer to the same + file system. + +mincore.2 + mtk, after note from gordon jin + updated errors. + +pipe.2 + as per message from serguei leontiev + removed svr2, at&t, and bsd from conforming to, since + a pipe on those systems is actually bidirectional. + (pipes are implemented as streams on the former, and + sockets on the latter.) + +posix_fadvise.2 + mtk + noted kernel version where posix_fadvise() appeared and + noted bug in handling of 'len' in kernels < 2.6.6. + +rename.2 + michael haardt + clarified exdev error description: it isn't possible to rename + a file across mount points, even if the mount points refer to + the same file system. + +semop.2 + mtk + noted kernel version numbers for semtimedop(). + +setitimer.2 + matthias lang, mtk + noted max_sec_in_jiffies ceiling. + added note about treatment of out-of-range tv_usec values. + +sigqueue.2 + johan walles, martin (joey) schulze + added sigqueue.2 to see also. + +times.2 + mtk + added notes on non-standard behavior: linux allows 'buf' to + be null, but posix.1 doesn't specify this and it's non-portable. + +uselib.2 + andries brouwer + improved description; clarified distinction between + eacces and enoexec. + +bcopy.3 + heikki orsila + bcopy() handles overlapping case, but memcpy() does not, + so for consistency memmove() should be also mentioned. + +getmntent_r.3 + martin (joey) schulze + new link to man3/getmntent.3. + +memcpy.3 + small wording change after suggestion from sasa stevanovic. + +strcasestr.3 + mtk + created as link to strstr.3. + +strftime.3 + mtk + noted that susv2 allowed a range of 00 to 61 for %s specifier. + +strstr.3 + mtk + added description of strcasestr(). + +random.4 + aeb + improved description of read from /dev/urandom. + +st.4 + kai makisara + substantial updates. + +man.7 + martin schulze + branden robinson + colin watson + mention the .url macro more verbosely. + + +==================== changes in man-pages-2.03 ==================== + +released: 2005-06-02 + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +andries brouwer +joey (martin) schulze +johannes nicolai +justin pryzby +klaus ethgen +pavel heimlich +ross boylan +vincent fourmond + +apologies if i missed anyone! + +global changes +-------------- + +console.4 +console_ioctl.4 +mouse.4 +tty.4 +vcs.4 + pavel heimlich + change `ttys(4)' to `ttys(4)'. + +typographical or grammatical errors have been corrected in several +places. + +changes to individual pages +--------------------------- + +clone.2 + mtk + substantially enhanced discussion of clone_thread. + + added clone_sysvsem, clone_untraced, clone_stopped. + + other minor fixes. + +execve.2 + aeb + noted effect of ptracing when execing a set-uid program. + +fcntl.2 + johannes nicolai / mtk + noted f_setown bug for socket file descriptor in linux 2.4 + and earlier. + + added text on permissions required to send signal to owner. + +flock.2 + mtk + noted that lock conversions are not atomic. + +getrusage.2 + mtk + ru_nswap has never contained useful information. + kernel 2.6.6 clarified that with a patch + ("[patch] eliminate nswap and cnswap"). see also: + http://www.ussg.iu.edu/hypermail/linux/kernel/0404.1/0720.html + +kill.2 + mtk + clarified wording of the 'pid == -1' case. + +mount.2 + mtk + added mnt_expire, plus a few other tidy-ups. + +sched_setaffinity.2 + mtk + added text to note that sched_setaffinity() will migrate the + affected process to one of the specified cpus if necessary. + + added a note to point out that the affinity mask is actually a + per-thread attribute that can be adjusted independently for + each thread in a thread group. + +shmctl.2 + mtk + noted aberrant linux behavior with respect to new attaches to a + segment that has already been marked for deletion. + + noted changes in permissions required for shm_lock/shm_unlock. + +wait.2 + mtk + noted that the __w* flags can't be used with waitid(). + +confstr.3 + mtk + added _cs_gnu_libc_version and _cs_gnu_libpthread_version. + +hosts.5 + ross boylan / martin schulze + various changes as per + http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=304242 + +proc.5 + mtk + minor changes to discussion of /proc/pid/stat signal fields. + added 'rt_priority' and 'policy' to /proc/pid/stat. + +capabilities.7 + mtk + 1,$s/inherited/inheritable/g + +regex.7 + vincent fourmond / joey (martin) schulze + removed discussion of `[[:<:]]' and `[[:>:]]' since they do + not seem to be in the glibc implementation. + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=295666 + +tzselect.8 + joey (martin) schulze / klaus ethgen + the default zoneinfo directory is now /usr/share/zoneinfo. + (was: /usr/local/etc/zoneinfo) + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=267471 + + +==================== changes in man-pages-2.04 ==================== + +released: 2005-06-21 + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +andries brouwer +baurjan ismagulov +dave love +dieter brueggemann +geoff clare +guido trotter +kabloom +kevin ryde +justin pryzby +mike furr +olivier croquette +olivier guilyardi +peter cordes +philipp spitzer +tanaka akira +thierry excoffier +thomas hood +vincent lefevre +walter harms + +apologies if i missed anyone! + +global changes +-------------- + +various pages + mtk + for consistency across pages: + + 1,$s/nonzero/non-zero/g + +typographical or grammatical errors have been corrected in several +places. + + +new pages +--------- + +pthreads.7 + mtk + an overview of the linux implementations of posix threads. + + +changes to individual pages +--------------------------- + +_exit.2 + mtk + various minor changes. + +epoll_ctl.2 + mike furr + bugs: in kernels < 2.6.9, epoll_ctl_del required a non-null + 'event', even though this argument is ignored. + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=306517 + +flock.2 + mtk / kevin ryde + clarified semantics of relationship between flock() locks + and open file entries and file descriptors. + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=291121 + +getitimer.2 + olivier croquette, thierry excoffier + noted the existence of the short sleep bug (up to 1 jiffy). + +getrlimit.2 + mtk + rlimit_rss only has affect "in 2.4.x", not "in 2.4 and later". + +getrusage.2 + geoff clare + since linux 2.6, the ru_nvcsw and ru_nivcsw fields are used. + +nice.2 + mtk / guido trotter + rewrote description of return value. + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=296183 + +open.2 + walter harms + o_direct needs _gnu_source. + mtk + o_async works for pipes and fifos in linux 2.6. + various minor fixes. + +atexit.3 + mtk + various minor changes. + +exit.3 + mtk + various minor changes. + +getopt.3 + mtk / philipp spitzer + fix description of return value. + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=308359 + +hsearch.3 + mtk + changed (char *) to (void *) in example. + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=313607 + +log1p.3 + justin pryzby + make log(3) see also log1p(3), + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=309578 + +makecontext.3 + tanaka akira + fix description of return value for makecontext(), + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=311800 + +on_exit.3 + mtk + various minor changes. + +rand.3 + kabloom + small fix to a code example, + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=194842 + +realpath.3 + mtk / thomas hood + when specifying resolved_path as null, realpath() + will (still) only allocate up to path_max bytes. + plus other minor changes. + see also http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=239424 + +rcmd.3 + dave love + the required header file for these functions on linux is , + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=311680 + +scanf.3 + olivier guilyardi + arg for %p is a pointer to _a pointer to_ void, + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=263109 + +stdin.3 + vincent lefevre + freopen() can change the descriptors associated with + stdin/stdout/stderr, as per + http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=295859 + +strerror.3 + baurjan ismagulov + strerror_r(3) requires #define _xopen_source 600, + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=290880 + +sysconf.3 + peter cordes / mtk + fix typo: "_sc_2_dev" should be "_sc_2_c_dev". + +proc.5 + mtk + added pointers under /proc/sys/net to tcp.7 and ip.7. + +ip.7 + mtk + various wording and formatting fixes. + reordered /proc/sys/net/ipv4/ip_* file descriptions alphabetically. + +tcp.7 + dieter brueggemann / mtk + fixes to the discussion of siocatmark and tcp_stdurg. + mtk + various wording and formatting fixes. + incorporated some new /proc/sys/net/ipv4/tcp_* file descriptions + from the 2.6.12 source file documentation/networking/ip-sysctl.txt. + + +==================== changes in man-pages-2.05 ==================== + +released: 2005-06-27 + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +a costa +andries brouwer +bas zoetekouw +dan jacobson +delian krustev +dora anna volgyesi +martin (joey) schulze +ove kaaven + +apologies if i missed anyone! + +global changes +-------------- + +typographical or grammatical errors have been corrected in several +places. (special thanks to a costa.) + + +changes to individual pages +--------------------------- + +_exit.2 + mtk / aeb + reversed 2.04 introduction of the term "process termination + function". + +close.2 + mtk + clarified what type of lock close() affects. + minor formatting changes. + +dup.2 + mtk + consistent use of terms "open file description", + "file status flags", and "file descriptor flags". + removed mention of lock sharing -- it was not accurate. + minor formatting fixes. + +fcntl.2 + mtk + consistent use of terms "open file description", + "file status flags", and "file descriptor flags". + some rewriting of discussion of file descriptor flags + under f_dupfd, replaced some text duplicated in dup.2 + with a cross ref to dup.2 + minor wording and formatting fixes. + +fpclassify.3 + mtk / martin (joey) schulze / bas zoetekouw + the return value of isinf() changed in glibc 2.02 + to differentiate positive and negative infinity. + see: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=285765 + +getgid.2 +getuid.2 + delian krustev + remove confusing text describing real and effective ids. + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=285852 + +getitimer.2 + mtk + the short sleep bug (up to 1 jiffy) that was newly noted in + man-pages-2.04 has just been fixed in 2.6.12. + +getpriority.2 + mtk + changed range documented in main text from -20..20 to -20..19. + noted that the range is -20..20 on some systems. + +open.2 + mtk / aeb + clarification of term "open file description" along with + explanation of what information it maintains. + other wording improvements. + various minor wording changes. + +atexit.3 + mtk / aeb + reversed 2.04 introduction of the term "process termination + function". + mtk + noted use of atexit() for establishing function to be invoked on + shared library unload. + noted that atexit()-registered functions are not invoked on + abnormal termination. + formatting fixes. + +exit.3 + mtk / aeb + reversed 2.04 introduction of the term "process termination + function". + mtk + minor rewording and formatting changes. + +getloadavg.3 + mtk + added #define _bsd_source to prototype. + +log2.3 + martin (joey) schulze + add erange error. + +readdir.3 + mtk + added definition of linux dirent structure. + some formatting cleanups. + +strtod.3 + dora anna volgyesi / mtk + strtold() and strtof() need _isoc99_source or _xopen_source=600 + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=246668 + +tdestroy.3 + mtk + new link to tsearch.3. + +tsearch.3 + mtk + added tdestroy to .th line. + +mem.4 + mtk + change "chown root:mem /dev/mem" to "chown root:kmem /dev/mem". + +null.4 + mtk + change "chown root:mem /dev/null /dev/zero" to + "chown root:root /dev/null /dev/zero". + +vcs.4 + dan jacobson / martin (joey) schulze + replaced "selection(1)" by "gpm(8)" under see also + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=253515 + +signal.7 + ove kaaven + sa_sigaction should be sa_siginfo + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=305369 + +urn.7 + mtk + new link to uri.7 + + +==================== changes in man-pages-2.06 ==================== + +released: 2005-07-15 + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +alain portal +andries brouwer +bhavesh p davda +clau weber +dov murik +david lloyd +frederik deweerdt +justin pryzby +lars wirzenius +martin pool +mike frysinger +petter reinholdtsen +steven murdoch +walter harms + +apologies if i missed anyone! + +global changes +-------------- + +typographical or grammatical errors have been corrected in several +places. + +many uses of hyphens and dashes were corrected. + + +new pages +--------- + +canonicalize_file_name.3 + walter harms / mtk + +removed pages +------------- + +sstk.2 + mtk + afaik, this system call has never actually done anything (other + than be a stub) on any unix. + +changes to individual pages +--------------------------- + +accept.2 + mtk + various wording and formatting fixes. + +bind.2 + mtk + minor formatting changes + +clone.2 + mtk + various minor wording improvements; some formatting fixes + +connect.2 + mtk + various wording and formatting fixes. + +epoll_create.2 + bhavesh p davda + s/positive/non-negative/ [for file descriptor] + +getrlimit.2 + mtk + documented rlimit_msgqueue limit. + rlimit_rss ceased to have any effect in 2.4 in kernel 2.4.30. + (it already didn't have any effect in 2.2.x and 2.6.x.) + s/madvise_willneed/madv_willneed/ + +listen.2 + mtk + removed historic comment on bsd backlog ceiling. + minor wording and formatting changes. + +semop.2 + mtk + added bug: in some circumstances, a process that is + waiting for a semaphore to become zero is not woken + up when the value does actually reach zero. + http://marc.theaimsgroup.com/?l=linux-kernel&m=110260821123863&w=2 + http://marc.theaimsgroup.com/?l=linux-kernel&m=110261701025794&w=2 + +socket.2 + mtk + various minor wording improvements + +umask.2 + mtk + added mkdir(2) to discussion, made term "file mode creation + mask" clearer. + various, mostly small, wording changes + +errno.3 + martin pool + change description for estale + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=237344 + +fgetgrent.3 +getgrent.3 +getgrent_r.3 + david lloyd + added see also putgrent(3) + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=211336 + +getgrent.3 +getgrnam.3 +getpwent.3 +getpwnam.3 + lars wirzenius / mtk + replace mention of /etc/{passwd,group} by references to + "passwd/group database", and ldap and nis. + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=316117 + mtk + miscellaneous wording improvements + consistent description and errors wording across these pages. + +getnameinfo.3 + mtk + relocate misplaced text describing gai_strerror(). + +getnetent.3 + petter reinholdtsen + s/endservent/endnetent/ + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=316517 + +getspnam.3 + lars wirzenius / mtk + replace mention of /etc/shadow by references to + "shadow password database", and ldap and nis. + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=316117 + mtk, claus weber + miscellaneous wording improvements + consistent description wording vis-a-vis getpwnam.3 etc. + +hsearch.3 + frederik deweerdt + fix hsearch_r() prototype + +scanf.3 + justin pryzby / mtk + fix description of return value + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=317037 + mtk + various parts substantially rewritten; added description of + %n$ form; various text incorporated from the gnu c library + documentation ((c) the free software foundation). + +shm_open.3 + mtk + modified details of how user and group ownership of a new + object are set. + various minor wording and formatting cleanups. + +elf.5 + mike frysinger + tweaked the short description to include definition of 'elf' + add elfosabi_none to the elfosabi_ list + tweak/add more machines to em_ list for ehdr->e_machine + fix indenting to be consistent + tweak the display of the elf_st_* macros + document the elf_dyn structure + +proc.5 + mtk + updated discussion of /proc/stat. + added text on the /proc/sys/fs/mqueue/* files. + +ip.7 + steven murdoch + change protocol in udp prototype. + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=182635 + +tcp.7 + dov murik + the first sentence under notes about so_keepalive and sigpipe + makes no grammatical sense (and possibly also no technical sense). + it has been removed. + + +==================== changes in man-pages-2.07 ==================== + +released: 2005-07-19 + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +andries brouwer +mike frysinger + +apologies if i missed anyone! + +global changes +-------------- + +various pages + mtk + the terms "set-user-id" and "set-group-id" are now used + consistently (no abbreviations) across all manual pages. + +various pages + mtk + consistent use of "saved set-user-id" and "saved set-group-id" + (no more "saved user id", "saved effective uid", + saved group id", etc.) + +various pages + mtk + global fixes in textual descriptions: + + uid --> uid + gid --> gid + pid --> pid + id --> id + +various pages + mtk + consistent use of st_atime, st_ctime, st_mtime, with + explanatory text, instead of atime/ctime/mtime. + +various pages + mtk + classical bsd versions are now always named x.ybsd (formerly + there was a mix of x.ybsd and bsd x.y). + +typographical or grammatical errors have been corrected in several +places. + + +changes to individual pages +--------------------------- + +setresuid.2 + mtk + some rewording. + +stat.2 + mike frysinger + improve description of st_dev and st_rdev. + mtk + various wording and formatting improvements. + +truncate.2 + mtk + some formatting fixes + + +==================== changes in man-pages-2.08 ==================== + +released: 2005-09-21 + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +adrian bunk +alain portal +andrew pimlott +andries brouwer +baurzhan ismagulov +bernhard r. link +bodo stroesser +david n. welton +dov murik +heikki orsila +hasso tepper +hrvoje niksic +justin pryzby +ludovic courtes +mike frysinger +nicolas françois +norbert buchmuller +paul brook +ramiro aceves +tommy pettersson +walter harms + +apologies if i missed anyone! + +global changes +-------------- + +various pages + mtk + rfc references are now always written as "rfc\ nnn" + (not "rfc nnn" or "rfcnnn"). + +typographical or grammatical errors have been corrected in several +places. + + +changes to individual pages +--------------------------- + +du.1 + mike frysinger + to get an effect like "-h", blocksize must start with "human", + not "human". + +time.1 + mike frysinger + s/standard output/standard error/ + +clone.2 + paul brook / mtk + fix small error in description of clone_parent_settid + +connect.2 + heikki orsila + add eintr error + see http://lkml.org/lkml/2005/7/12/254 + +getpriority.2 + mtk + expanded discussion of relationship between user and kernel + representations of the nice value. + + added discussion of rlimit_nice and a cross reference to + getrlimit.2 under the description of the eacces error. + + noted 2.6.12 change in credentials checking for setpriority(). + +getrlimit.2 + mtk + added description of rlimit_rtprio + + added description of rlimit_nice + +mmap.2 + mtk + noted bug in map_populate for kernels before 2.6.7. + +mremap.2 + mtk + added _gnu_source to prototype. + rewrote description of mremap_maymove. + rewrote description of eagain error. + added discussion of resizing of memory locks. + added entries to see also. + some formatting fixes. + +msgctl.2 + mtk + added ipc_info, msg_info, msg_stat descriptions. + +nanosleep.2 + baurzhan ismagulov + add to prototype: define _posix_c_source 199309 + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=314435 + +nice.2 + mtk + added sentence noting that range of the nice value is described + in getpriority.2. + added cross-reference to setrlimit(2) for discussion on + rlimit_nice. + +outb.2 + david n. welton / justin pryzby / mtk + clarified the order of value and port arguments; + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=263756 + +pause.2 + mtk + added see also for sigsuspend.2 + some formatting fixes. + +poll.2 + tommy pettersson + nfds should be prototyped as nfds_t + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=322934 + + mtk + some wording and formatting improvements. + +prctl.2 + mtk + since kernel 2.6.13 pr_set_dumpable can also have the value 2. + +rand.3 + hrvoje niksic / mtk + remove misleading text describing freebsd's sranddev() function. + as per debian bug 328629 + +readv.2 + mtk / walter harms + added linux notes on trickery performed by glibc when + vector size exceeds iov_max. + + formatting clean-ups. + +remap_file_pages.2 + mtk + added text to note that start and size are both rounded downward. + +sched_setparam.2 + mtk + modified discussion of privileges; added pointer to + sched_setscheduler.2 for a discussion of privileges and + resource limits. + +sched_setscheduler.2 + mtk + modified discussion of privileges; added discussion of rlimit_rtprio. + +semctl.2 + mtk + added ipc_info, sem_info, sem_stat descriptions. + +shmctl.2 + mtk + added ipc_info, shm_info, shm_stat descriptions. + +sigaction.2 + mtk + split sigpending(), sigprocmask(), and sigsuspend() out + into separate new pages. + + other minor changes + + mtk + notes: described sa_nodefer / sa_mask bug which was present in + all kernels up to and including 2.6.13. + see http://marc.theaimsgroup.com/?l=linux-kernel&m=112360948603171&w=2 + and http://marc.theaimsgroup.com/?l=linux-kernel&m=112362164911432&w=2 + list: linux-kernel + subject: signal handling possibly wrong + from: bodo stroesser + date: 2005-08-09 17:44:06 + +signal.2 + mtk + updated see also to reflect splitting of sigaction.2 into + sigaction.2, sigsuspend.2, sigpending.2, sigprocmask.2 + +sigpending.2 + mtk + new page created by splitting out from sigaction.2 + changed conforming to. + +sigprocmask.2 + mtk + new page created by splitting out from sigaction.2 + added text on effect of null for 'set' argument. + added text noting effect of ignoring sigbus, sigfpe, sigill, + and sigsegv. + noted that sigprocmask() can't be used in multithreaded process. + fixed einval error diagnostic. + changed conforming to. + +sigsuspend.2 + mtk + new page created by splitting out from sigaction.2 + added notes on usage. + added new text to description. + changed conforming to. + +stat.2 + mike frysinger + improve st_blocks description. + +carg.3 + ramiro aceves / aeb + change: + one has carg(z) = atan(creal(z) / cimag(z)) + to: + one has tan(carg(z)) = cimag(z) / creal(z) + + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=326720 + +cmsg.3 + mtk + s/sol_tcp/ipproto_tcp/ (posix standard name) + +dlopen.3 + alain portal + s/-nostartupfiles/-nostartfiles/ + +getaddrinfo.3 + mtk + nowadays (since 2.3.4) glibc only sets the first ai_canonname + field if ai_canonname was specified (the current behavior + is all that susv3 requires). + + 1,$s/pf_/af_/g + + added descriptions of ai_all, ai_addrconfig, ai_v4mapped, + and ai_numericserv. + + some wording and formatting fixes. + +getpwnam.3 + bernhard r. link / mtk + add notes text describing relationship of pw_dir and home and + pointing out that applications should preferentially inspect home. + +inet.3 + mike frysinger + mention "little endian" and "big endian". + added note about octal and hex interpretation of + numbers-and-dots notation. + +rpc.3 + mtk / ludovic courtes + commented out references to rpc_secure(3) -- we don't currently + have such a page in the man-pages set. + in response to http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=325115 + +setenv.3 + mtk + glibc 2.3.4 fixed the "name contains '='" bug. + +strnlen.3 + mike frysinger + added "#define _gnu_source" to prototype. + +initrd.4 + norbert buchmuller / mtk + added text noting that the use or real-root-dev for changing + the root device is obsolete, in favor of pivot root. + (however, the page still needs to be rewritten to actually + describe the pivot_root method...) + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=323621 + +proc.5 + mtk + improve text describing /proc/sys/fs/mqueue/* files. + + describe /proc/sys/fs/suid_dumpable (new in 2.6.13). + + added placeholder mention of /proc/zoneinfo (new in 2.6.13). + more needs to be said about this file. + + repaired earlier cut and paste mistake which resulted + in part of the text of this page being duplicated. + +utmp.5 + mike frysinger + added text on biarch details for ut_session and ut_tv. + +capabilities.7 + mtk + added cap_audit_control and cap_audit_write. + +ip.7 + mtk / andrew pimlott + add a couple of words to make it clear that port is a 16-bit number. + reformat long source lines (no text changed). + + s/sol_ip/ipproto_ip/ (posix standard name) + + hasso tepper + fix discussion of ipc_recvttl / ip_ttl. + +signal.7 + mtk + updated see also to reflect splitting of sigaction.2 into + sigaction.2, sigsuspend.2, sigpending.2, sigprocmask.2. + +socket.7 + mtk + clarified details of use of so_peercred. + +tcp.7 + mtk + s/sol_tcp/ipproto_tcp/ (posix standard name) + s/sol_ip/ipproto_ip/ (posix standard name) + +udp.7 + mtk + added description of udp_cork socket option. + + s/sol_udp/ipproto_udp/ (posix standard name) + s/sol_ip/ipproto_ip/ (posix standard name) + + +==================== changes in man-pages-2.09 ==================== + +released: 2005-10-13 + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +justin pryzby +peter chubb +samuel thibault +tomas pospisek +trond myklebust + +apologies if i missed anyone! + +global changes +-------------- + +ptsname.3 +getpt.3 +unlockpt.3 +openpty.3 +posix_openpt.3 +grantpt.3 +pts.4 +tty_ioctl.4 + mtk + added see also for new pty.7 page. + +typographical or grammatical errors have been corrected in several +places. + + +new pages +--------- + +pty.7 + mtk + overview of unix 98 and bsd pseudo-terminals. + + +changes to individual pages +--------------------------- + +ldd.1 + mtk + remove "-v" option (fix from fedora man-pages-2.07-7). + +fcntl.2 + peter chubb / trond myklebust / mtk + since kernel 2.6.10, a read lease can only be placed on a + file descriptor that is opened read-only. + see the following lkml thread of aug 2005 + ("fcntl(f getlease) semantics??"): + http://marc.theaimsgroup.com/?l=linux-kernel&m=112371777712197&w=2 + http://marc.theaimsgroup.com/?l=linux-kernel&m=112374818213000&w=2 + http://marc.theaimsgroup.com/?l=linux-kernel&m=112376335305284&w=2 + http://marc.theaimsgroup.com/?l=linux-kernel&m=112377294030092&w=2 + +mprotect.2 + mtk + add new text to enomem error. + +mremap.2 + mtk + added description of mremap_fixed and 'new_address' argument + under notes. + revised text of einval error. + +read.2 + samuel thibault / mtk + read() can fail with einval when using o_direct + mtk + added open(2) to see also. + +shmget.2 + mtk + s/int/size_t/ for type of 'size' argument (fix from + fedora man-pages-2.07-7). + +write.2 + samuel thibault / mtk + write() can fail with einval when using o_direct + +atanh.3 + mtk + fix: s/acosh/atanh/ (fix from fedora man-pages-2.07-7). + +fopen.3 + mtk + improved "a+" description (fix from fedora man-pages-2.07-7). + +getrpcent.3 + mtk + s/getrpcent/setrpcent/ (fix from fedora man-pages-2.07-7). + +stdio.3 + mtk / justin pryzby + removed references to fropen() and fwopen(), which are + bsdisms that don't appear in glibc. + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=331174 + +strftime.3 + mtk + typo fix: %ry ==> %ey [susv3 mentions...] (fix from + fedora man-pages-2.07-7). + +nsswitch.conf.5 + mtk + s/network/networks/ (fix from fedora man-pages-2.07-7). + +proc.5 + mtk + added description of /proc/sys/vm/legacy_va_layout. + +socket.7 + mtk + update description of so_rcvlowat and so_sndlowat. + (fix derived from fedora man-pages-2.07-7). + + +==================== changes in man-pages-2.10 ==================== + +released: 2005-10-19 + +global changes +-------------- + +the changes in this release consist *solely* of formatting fixes, with +the aim bringing greater consistency to the manual pages according to +the following rules: + +-- function name references should *always* be followed by + parentheses, "()" (possibly containing a manual page section + number). + +-- the parentheses following a function name should *not* be + formatted. thus, for example, instead of: + + .b name() + + one should write: + + .br name () + +much of the change was automated using two scripts: +add_parens_for_own_funcs.sh and unformat_parens.sh. +for the (possible) benefit of downstream manual page maintainers and +translators, i have placed these scripts in a new subdirectory 'scripts'. + +note the following points well: + +-- these scripts provide a computer-assisted solution to the above + two goals. however, they are not perfect, and their output should + be scanned by a human. (to see what changes the two scripts + *would* make, without making them, use the "-n" command line option.) + +-- the scripts do not fix all instances that violate the above rules: + some manual fixes are required. two further scripts are provided + to help find remaining instances of function names without + following "()": find_dots_no_parens.sh and find_slashes_no_parens.sh. + +the following changes were made: + +-- add_parens_for_own_funcs.sh was applied to the pages in sections + 2 and 3. + +-- unformat_parens.sh was applied to pages in sections 2, 3, 4, and 7 + (the only sections where such changes were required). + +-- further changes (not so very many) were performed by hand. + (found places to fix with the assistance of find_dots_no_parens.sh + and find_slashes_no_parens.sh). + + +==================== changes in man-pages-2.11 ==================== + +released: 2005-10-24 + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +alain portal + +apologies if i missed anyone! + +global changes +-------------- + +various pages + mtk + most instances of the constant "null" are not formatted (bolded) in + man pages, but a few are. for consistency, formatting on "null" has + been removed where it occurred. + + many minor formatting fixes were made. + +typographical or grammatical errors have been corrected in several +places. + + +changes to individual pages +--------------------------- + +getrlimit.2 + mtk + added einval error for rlim_cur > rlim_max when calling setrlimit(). + +path_resolution.2 + mtk + repaired discussion of capabilities and file system uid, which + mistakenly had involved exec() in the discussion. + +prctl.2 + mtk + removed text saying there is no library interface. there + is nowadays. + +mkfifo.3 + mtk + minor change to return value text. + +sk98lin.4 + alain portal + formatting fixes. + +capabilities.7 + mtk + minor changes. + + +==================== changes in man-pages-2.12 ==================== + +released: 2005-10-31 + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +akihiro motoki +andries brouwer +brian m. carlson +herbert +martin landers +michael benedict + +apologies if i missed anyone! + +global changes +-------------- + +typographical or grammatical errors have been corrected in several +places. + + +changes to individual pages +--------------------------- + +mlock.2 + mtk + reworded text around pagesize, noting also that + sysconf(_sc_pagesize) can be used. + +path_resolution.2 + mtk / aeb + removed words "as well" (added in 2.11) from the phrase + "and it gets these last five capabilities if its fsuid is 0 as well" + since there are (unusual) situations in which fsuid can be 0 while + the effective uid is not. + + reworked (cut down) discussion of capabilities, moving part of + it into capabilities.7 + +setresuid.2 + mtk + add text to note that setresuid() always modifies the file + system uid, and setresgid() likewise always modifies the file + system gid. + +shmget.2 + mtk + added (brief) description of shm_hugetlb. + +sigaltstack.2 + mtk / martin landers + noted that ss_sp is automatically aligned by the kernel. + +byteorder.3 + brian m. carlson / herbert + change to in prototype; add text + explaining that some systems need the former header. + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=265244 + +capabilities.7 + mtk + reworked part of the discussion of exec() and capabilities. + added sub-section "effect of user id changes on capabilities". + reworked discussion of cap_sys_admin and file-max. + + +==================== changes in man-pages-2.13 ==================== + +released: 2005-11-03 + +this release consists entirely of formatting and typographical fixes. + +global changes +-------------- + +typographical or grammatical errors have been corrected in several +places. + +various pages + mtk + function and page cross references that were italicized were + made bold (which is how the majority of function and page + cross references were already done). + +various pages + mtk + instances of things like "null-terminated string" were changed to + "null-terminated string". + +various pages + mtk + pathnames, structures, arguments, and that were + bold were changed to italics. + +various pages + mtk + instances of the constant "null" that were bold-faced were made + unformatted (which is how most instances of "null" were already + formatted.) + + +==================== changes in man-pages-2.14 ==================== + +released: 2005-11-17 + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +angelo +avery pennarun +justin pryzby +martin (joey) schulze +stefan brüns +volker reichelt + +apologies if i missed anyone! + +global changes +-------------- + +typographical or grammatical errors have been corrected in several +places. + +new pages +--------- + +rexec.3 + mtk / justin pryzby + this page is taken as is from the freebsd 5.4 distribution. + (not checked against linux reality, but likely things are + the same.) + see also http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=336875 + +changes to individual pages +--------------------------- + +arch_prctl.2 + mtk + updated discussion about lack of prototype in glibc. + +execve.2 + mtk + improved description of e2big error: it relates to the sum + of the bytes in both environment and argument list. + +fcntl.2 + mtk + clarified parts of the discussion of file leases, + noting effect of open(o_nonblock), interruption + by signal handler, or termination by signal in + lease breaker. in response to + http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=339037 + +stat.2 + mtk / stefan brüns + added linux notes describing nanosecond timestamps. + +frexp.3 + volker reichelt / mtk + fixed to point out that frexp() returns a number whose + *absolute* value is >= 0.5 and < 1. amended the example + program to demonstrate this. + +open.2 + mtk / avery pennarun + add ewouldblock error for file leases. + in response to + http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=339037 + +putenv.3 + mtk + although the glibc implementation returns -1 on error (and some + other man pages (e.g., the bsds) also document that value for + error returns), susv3 merely says "non-zero" (and this is + what manual pages on many implementations also say). + +posix_memalign.3 + mtk + formerly, the page said that all systems declare memalign() in + . in fact, many declare it in . + +strtok.3 + mtk + almost a complete rewrite after angelo pointed out + that the existing page was deficient. + +sd.4 + martin schulze + remove see also for nonexistent scsi.4. + +proc.5 + mtk + updated discussion of /proc/sys/kernel/pid_max. + +signal.7 + mtk + added pthreads.7 to see also. + +ld.so.8 + mtk + fix typo: s/ld_debug_output/ld_profile_output/ + + +==================== changes in man-pages-2.15 ==================== + +released: 2005-11-30 + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +andries brouwer +james vega +malcolm scott +senthil kumar + +apologies if i missed anyone! + +global changes +-------------- + +typographical or grammatical errors have been corrected in several +places. + +new pages +--------- + +sigvec.3 -- for details, see below. + +sigset.3 -- for details, see below. + +changes to individual pages +--------------------------- + +kill.2 + mtk + added text describing the 2.6.[0-7] eperm bug that occurred + when sending signals to a process group. + +sigaction.2 + mtk + noted that si_signo is unused on linux. + +sigpending.2 + mtk + added bugs noting wrapper function problem that existed + in glibc versions <= 2.2.1. + +sigpause.2 + mtk + moved to section 3; see also sigpause.3 below. + +sigsetops.3 + mtk + added a glibc notes section describing sigisemptyset(), + sigandset(), and sigorset(). + +sigvec.2 +sigblock.2 + mtk + these pages have been deleted, and replaced by a new sigvec.3 + man page that more fully describes the bsd signal api. + +siggetmask.2 +sigmask.2 +sigsetmask.2 + mtk + these links to the now-deleted sigblock.2 have been also been + deleted. they are replaced by corresponding links in section 3: + sigmask.3, sigsetmask.3, siggetmask.3. + +sigvec.3 + mtk + this new page is provides a fuller description of the + bsd signal api than was provided in the now-deleted sigvec.2 + and sigblock.2. + +sigblock.3 +siggetmask.3 +sigmask.3 +sigsetmask.3 + mtk + created as links to sigvec.3. + +sigpause.3 + mtk + moved here from section 2. + + some minor wording fixes; clarified system v origins of + x/open flavor of this function. + +sigset.3 + mtk + new page describing the system v signal api: sigset(), sighold(), + sigrelse(), sigignore(). + +strftime.3 + james vega + add further text clarifying that %+ specifier is not supported in + glibc2. + mtk + added glibc notes section describing optional 'flag' and 'width' + components of conversion specifiers. + some wording changes to bring terminology closer to susv3. + added an example program. + +vm86old.2 + mtk / aeb + add as new link to vm86.2. + +intro.7 + mtk + added a few words to reflect the fact that several of the section + 7 pages provide overviews of various topics. + +signal.7 + mtk + added some see also entries. + +socket.7 + senthil kumar / mtk + added text noting that select()/poll() do not respect so_rcvlowat. + +udp.7 + malcolm scott + s/tcp_socket/udp_socket/ in example + fixes http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=340927 + + +==================== changes in man-pages-2.16 ==================== + +released: 2005-12-02 + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +alan stern +andries brouwer +urs thuermann + +apologies if i missed anyone! + +global changes +-------------- + +typographical or grammatical errors have been corrected in several +places. + + +changes to individual pages +--------------------------- + +howtohelp + urs thuermann + added instructions for finding maintainer in debian package. + +poll.2 + mtk + added notes about inftim constant provided on some other + implementations. + +shmop.2 + alan stern + the -1 error return of shmat() should be cast "(void *)". + +strftime.3 + aeb + remove junk text (actually intended as source code comment + in page). + +ip.7 + urs thuermann + fix a typo: s/sock_raw/sock_packet/ + +packet.7 + urs thuermann + clarification: s%sock_packet%pf_inet/sock_packet% + + +==================== changes in man-pages-2.17 ==================== + +released: 2005-12-13 + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +justin pryzby +michael haardt +urs thuermann +walter harms + +apologies if i missed anyone! + + +global changes +-------------- + +typographical or grammatical errors have been corrected in several +places. + + +new pages +--------- + +fmemopen.3 + walter harms / mtk + new documentation for the glibc-specific fmemopen() and + open_memstream(). based on glibc info page. + +pipe.7 + mtk (with prompting and suggestions for improvements by + michael haardt) + new page providing overview of pipes and fifos. + + +changes to individual pages +--------------------------- + +howtohelp + mtk + added notes on how to write example programs for manual pages. + +fork.2 + mtk + added pointers to examples of fork() in wait.2 and pipe.2. + +pipe.2 + mtk + added an example program. + added see also for new pipe.7 page. + +wait.2 + mtk + added example program demonstrating use of fork() and waitpid(). + +carg.3 + justin pryzby + delete line that should have been deleted when applying + 2.08 fix for this page. + +getaddrinfo.3 + mtk + rearranged eai_* list alphabetically. + +inet.3 + mtk + added glibc notes describing feature test macros required + to expose declaration of inet_aton(). + +open_memstream.3 + mtk + new link to new fmemopen.3. + +fifo.4 + mtk + added see also for new pipe.7 page. + +environ.5 + mtk + removed browser, since it seems not in fact to be common. + +socket.7 + urs thuermann + added documentation of so_timestamp. + +tcp.7 + mtk + noted 200 millisecond ceiling imposed on tcp_cork. + +udp.7 + mtk + rearranged options into something approximating alphabetical order. + + +==================== changes in man-pages-2.18 ==================== + +released: 2005-12-15 + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +justin pryzby +karsten sperling +martin (joey) schulze +mike frysinger +stefan puiu + +apologies if i missed anyone! + + +global changes +-------------- + +typographical or grammatical errors have been corrected in several +places. + + +changes to individual pages +--------------------------- + +bind.2 + mtk + added mention of af_inet6 address family. + added discussion of sockaddr structure and an example in the + unix domain. + +recv.2 + mtk + put 'flags' list in alphabetical order. + +send.2 + mtk + added cross-reference from discussion of msg_more to udp_cork + in udp(7). + + put 'flags' list in alphabetical order. + +err.3 + mtk + added conforming to section noting that these are + non-standard bsdisms. + +errno.3 + justin pryzby + added see also for err.3. + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=306867 + +gethostbyname.3 + martin (joey) schulze / mtk + added references to nsswitch.conf(5); remove cross references + to resolv+(8). + see also http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=308397 + +perror.3 + justin pryzby + added see also for err.3 . + http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=306867 + +resolver.3 + mtk / martin (joey) schulze + remove cross references to resolv+(8); add cross references to + resolv.conf(5). + see also http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=214892 + + added see also entry for resolver(5); + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=251122 + +strerror.3 + mtk / stefan puiu + rewrote and extended the discussion of the two flavors of + strerror_r(), and added some additional information on + strerror(). + justin pryzby + added see also for err.3, as per + http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=306867 + + +elf.5 + mike frysinger + fix three typos in identifier names. + +operator.7 + karsten sperling + the + operator should be in the list of unary operators. + +raw.7 + mtk + small wording changes around discussion of so_bsdcompat. + fixed a couple of wording errors elsewhere. + reformatted some long lines. + +socket.7 + mtk, after a note by stefan puiu + updated discussion of so_bsdcompat. + + reformatted some long lines. + + noted the linux-specific feature whereby setsockopt() doubles + the value given for so_sndbuf and so_rcvbuf. + + noted kernel-imposed minimum values for so_sndbuf and so_rcvbuf. + +udp.7 + mtk, after a note by stefan puiu + updated discussion of so_bsdcompat. + +unix.7 + mtk + added new (un)supported features section in which it is noted + that unix domain sockets do not support msg_oob or msg_more. + + noted details of so_snbuf and so_rcvbuf support for + unix domain sockets. + + +==================== changes in man-pages-2.19 ==================== + +released: 2005-12-23 + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +andries brouwer +walter harms +stefan puiu + +apologies if i missed anyone! + + +global changes +-------------- + +typographical or grammatical errors have been corrected in several +places. + + +changes to individual pages +--------------------------- + +howtohelp + mtk + minor changes. + +bind.2 + stefan puiu / mtk + remove text under einval error: "this may change in the future: + see linux/unix/sock.c for details." this behavior has been + unchanged for a long time, and seems unlikely to change. + + add eaddrinuse to errors. + +send.2 + aeb + add cmsg(3) to see also. + +fopen.3 + walter harms / mtk + added description of 'x' mode character (exclusive open). + +pipe.7 + mtk / aeb + some wording changes to description of pipes. + + +==================== changes in man-pages-2.20 ==================== + +released: 2006-01-03 + +global changes +-------------- + +typographical or grammatical errors have been corrected in several +places. + + +changes to individual pages +--------------------------- + +sigaltstack.2 + mtk + added some text to explain the usual scenario in which + sigaltstack() is employed. + +getloadavg.3 + mtk + noted that this function is available since glibc 2.2. + +strcpy.3 + mtk + s/nulls/null bytes/ + +capabilities.7 + mtk + noted that capability bounding set appeared with kernel 2.2.11. + +arp.7 +icmp.7 +ip.7 +ipv6.7 +netdevice.7 +packet.7 +raw.7 +rtnetlink.7 +socket.7 +tcp.7 +unix.7 +udp.7 + mtk + the only changes to these pages have been for formatting: + -- structure definitions were changed to k&r style + -- some long source lines were broken to fit into ~70 + character lines. + no changes were made to the content of these pages (yet...). + + +==================== changes in man-pages-2.21 ==================== + +released: 2006-01-16 + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +andries brouwer +falk hueffner +mike frysinger +senthil kumar +stefan puiu + +apologies if i missed anyone! + + +global changes +-------------- + +dd.1 cp.1 +truncate.2 gethostname.2 lseek.2 listxattr.2 readlink.2 +sysfs.2 stat.2 ustat.2 uname.2 getdomainname.2 +argz_add.3 asprintf.3 confstr.3 bstring.3 bzero.3 dlopen.3 fwide.3 +gethostbyname.3 getline.3 getlogin.3 getnameinfo.3 getpass.3 hsearch.3 +perror.3 printf.3 readdir.3 scanf.3 stpcpy.3 strdup.3 strfmon.3 +strftime.3 string.3 strptime.3 sysconf.3 termios.3 ttyname.3 +dsp56k.4 tty_ioctl.4 +elf.5 proc.5 termcap.5 +charsets.7 unix.7 + mtk + various pages use inconsistent terms for 'null byte' (which + is the c99/susv3 term for the '\0' character). + + to rectify this the following changes were made in the above + pages: + + replace 'zero byte' with 'null byte'. + replace 'null character' with 'null byte'. + replace 'nulls' with 'null bytes'. + replace 'nul-terminated' by 'null-terminated'. + replace 'nul' by 'null byte'. + replace 'terminating nul' by 'terminating null byte'. + replace 'final nul' by 'terminating null byte'. + replace 'nul character' by 'null byte'. + +various pages + mtk + replace "sysv"/"sysv" by "system v". + +typographical or grammatical errors have been corrected in several +places. + + +changes to individual pages +--------------------------- + +capget.2 + mtk + noted bug that could wrongly cause eperm in unprivileged + capset() with 'pid' field == getpid(). + +epoll_ctl.2 + mtk + noted that epolloneshot was added in 2.6.2. + +gethostname.2 + mtk + added glibc notes describing operation of glibc's + gethostname() wrapper function. + +mmap.2 + mtk / mike frysinger + clarify relationship between mmap2(2) and mmap64(3). + mtk + a few other small rewordings. + +mmap64.3 + mike frysinger + new link to mmap.2. + +open.2 + mtk + added bug noting that o_async can't be enabled via + open(): fcntl() must be used for this purpose. + +recv.2 + stefan puiu + relocate misplaced discussion of msg_dontwait. + +dlopen.3 + mtk + rewrote discussion of dlopen() 'flag' argument; + added descriptions of rtld_noload, rtld_delete, + and rtld_deepbind. + + noted use of atexit() to register a function that is + automatically called when a library is unloaded. + +fmemopen.3 + mtk + rewrote substantial parts of the page, and relicensed under gpl. + +fseeko.3 + mike frysinger + add return value section. + +getopt.3 + mtk + noted historical use of to declare getopt(). + +qsort.3 + mtk / falk hueffner + clarify how strcmp() should be used as the 'compar' + function by providing an example. + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=348072 + +proc.5 + mtk + noted that /proc/mounts is pollable since kernel 2.6.15. + + documented /proc/pid/task. + + noted that the contents of /proc/pid/{cwd,exe,fd,root,task} + are not available if the main thread has terminated. + + senthil kumar + add pointer to random(4) for description of files under + /proc/sys/kernel/random. + +udp.7 + stefan puiu / mtk + small rewording of discussion of so_bsdcompat + (add cross-ref to socket(7)). + + +==================== changes in man-pages-2.22 ==================== + +released: 2006-02-02 + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +alain portal +andre noll +andries brouwer +colin tuckley +stefan puiu +thomas hood +thorsten kukuk +walter harms + + +global changes +-------------- + +typographical or grammatical errors have been corrected in several +places. + +changes to individual pages +--------------------------- + +mmap.2 + aeb / mtk + noted that portable applications should specify fd as -1 + when using map_anonymous. + some rewriting of description of map_anonymous. + +rt_sigreturn.2 + thorsten kukuk + new link to sigreturn.2. + +rt_sigsuspend.2 + mtk + new link to sigsuspend.2. + +waitid.2 + mtk + noted that waitid() does not set infop->si_uid field on + most other implementations. + +getopt.3 + walter harms / mtk + make clear that when calling getopt_long() and there are no + short options, then 'optstring' should be "", not null. + +openpty.3 + thomas hood / mtk + in glibc 2.0.92, openpty() was modified to preferably open + unix 98 ptys instead of bsd ptys. + +qsort.3 + mtk + small rewording under examples. + +strtol.3 +strtoul.3 + stefan puiu + s/string must begin/string may begin/ + +proc.5 + mtk + documented inotify files under /proc/sys/fs/inotify: + max_queued_events, max_user_instances, and max_user_watches. + + +==================== changes in man-pages-2.23 ==================== + +released: 2006-02-10 + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +andi kleen +britton leo kerin +dan jacobson +justin pryzby +luc van oostenryck +kurt wall +martin (joey) schulze +matthias andree +robert love +samuel thibault +urs thuermann + +apologies if i missed anyone! + +global changes +-------------- + +typographical or grammatical errors have been corrected in several +places. + + +new pages +--------- + +inotify_init.2 +inotify_add_watch.2 +inotify_rm_watch.2 + robert love, with some additions by mtk. + new pages describing the inotify api. + +mbind.2 +get_mempolicy.2 +set_mempolicy.2 + andi kleen, with additional work by mtk + new pages describing the numa memory allocation policy api. + drawn from the set at ftp://ftp.suse.com/pub/people/ak/numa. + +rtc.4 + urs thuermann, with additional work by mtk + new page describing the real-time clock driver. + +inotify.7 + mtk + overview of the inotify api. + +changes to individual pages +--------------------------- + +clone.2 + andi kleen + on x86, clone() should not be called through vsyscall, + but directly through "int $0x80". + +fcntl.2 + mtk + small wording changes. + + added cross-ref to inotify.7 under the description of dnotify. + +kill.2 + mtk / britton leo kerin + small wording change under notes to clarify + what happens when a process sends a signal to itself. + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=350236 + +mlock.2 + mtk / matthias andree + added bugs txt on interaction between mcl_future and + rlimit_memlock. + see the following lkml thread: + http://marc.theaimsgroup.com/?l=linux-kernel&m=113801392825023&w=2 + "rationale for rlimit_memlock" + +msgop.2 + mtk / samuel thibault + rewrote declaration of 'msgp' to be "void *" in response + to http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=350884 + various other wording fixes. + +open.2 + mtk + clarify distinction between "file creation flags" and + "file status flags". + +read.2 + justin pryzby + add see also for pread(2). + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=351873 + +sched_setaffinity.2 + mtk + major rewrite. + +select.2 + mtk + added return types to prototypes for fd_set(), fd_clr(), + fd_zero, and fd_isset(). + other minor wording changes. + +read.2 + mtk + add see also for pwrite(2). + (analogous with read.2 change above.) + +errno.3 + kurt wall / mtk + add linux specific errors to this page. + +localeconv.3 + mtk + added cross-ref to locale.7 for 'struct lconv' defn. + other minor wording changes. + martin (joey) schulze + added see also refs for nl_langinfo.3 + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=351831 + +scanf.3 + mtk / justin pryzby + minor formatting & wording fixes. + +setlocale.3 + martin (joey) schulze + added see also refs for nl_langinfo.3 + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=351831 + +proc.5 + mtk + migrated description of inotify files to the new inotify.7 page. + +ascii.7 + dan jacobson / mtk + add text describing characters 001 to 037. + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=342173 + +locale.7 + mtk + minor wording and formatting changes. + + +==================== changes in man-pages-2.24 ==================== + +released: 2006-02-17 + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +joerg habenicht +luc van oostenryck +mike frysinger +samuel thibault + +apologies if i missed anyone! + + +new pages +--------- + +get_kernel_syms.2 +create_module.2 +delete_module.2 +init_module.2 +query_module.2 + fsf / mtk (with assistance of luc van oostenryck) + man-pages finally gets pages for these system calls, several + of which are obsolete in linux 2.6. + took the old gpled pages dated 1996 and made a number of + clean-ups and minor additions. + + +global changes +-------------- + +various pages + mtk + change "file name" to "filename" + change "path name" to "pathname" + +stpncpy.3 +strstr.3 +strcmp.3 +toupper.3 +strlen.3 +stpcpy.3 +puts.3 +strdup.3 +strtok.3 +isalpha.3 +strspn.3 +gets.3 +strpbrk.3 + mtk after a suggestion from samuel thibault + added see also pointers to wide character equivalent functions + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=351996 + +typographical or grammatical errors have been corrected in several +places. + + +changes to individual pages +--------------------------- + +clone.2 + mtk + remove duplicate clone_stopped text. + commented out crufty text describing einval error + for the now obsolete clone_detached flag. + under clone_sighand, noted that 'flags' must also include + clone_vm if clone_sighand is specified. + +fcntl.2 + mtk + under errors: separate out eagain error for locking mmaped files. + +inotify_add_watch.2 + mtk + minor wording fix. + +msgop.2 + mtk + documented the eagain error for msgrcv(). + +fnmatch.3 + mike frysinger / mtk + expand explanation of fnm_pathname. + +lockf.3 + joerg habenicht / mtk + fix up discussion of eagain/eaccess errors. + + +==================== changes in man-pages-2.25 ==================== + +released: 2006-03-02 + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +james peach +krzysztof benedyczak +marten von gagern +michael haardt +michael wronksi + +apologies if i missed anyone! + + +new pages +--------- + +mq_close.3 +mq_getattr.3 +mq_notify.3 +mq_open.3 +mq_receive.3 +mq_send.3 +mq_unlink.3 + mtk + new pages describing posix message queue api. + +posix_fallocate.3 + mtk, after a suggestion by james peach + new page describing posix_fallocate(). + +mq_overview.7 + mtk + new page giving overview of the posix message queue api. + + +changes to individual pages +--------------------------- + +lseek.2 + michael haardt + add a case to the einval error text. + mtk + various minor wording fixes + added see also referring to new posix_fallocate.3. + +posix_fadvise.2 + mtk + added "#define _xopen_source 600" to prototype. + added see also referring to new posix_fallocate.3. + +proc.5 + mtk + migrated information on posix message queues to new mqueue.7 page. + +inotify.7 + marten von gagern + fix thinko: s/assuming a non-blocking/assuming a blocking/ + + +==================== changes in man-pages-2.26 ==================== + +released: 2006-03-21 + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +alain portal +andi kleen +andries brouwer +christoph lameter +hasso tepper +justin pryzby +martin (joey) schulze +nicolas françois +paul brook +siward de groot +steve beattie +walter harms + +apologies if i missed anyone! + +global changes +-------------- + +clone.2 +getdents.2 +gettid.2 +llseek.2 +mmap2.2 +modify_ldt.2 +pivot_root.2 +quotactl.2 +readdir.2 +sysctl.2 +syslog.2 +tkill.2 + mtk, aeb, steve beattie + added comment in synopsis to note that syscall(2) may be + preferable over _syscalln (see intro(2)). + +various minor formatting changes were done on a range of +pages in section 7. (no content was changed.) + +new pages +--------- + +openat.2 + mtk + new page describing openat(2), added in kernel 2.6.16, + and some notes on rationale for the at*(2) system calls. + +mbind.2 + andi kleen, christoph lameter, mtk + added mpol_mf_move and mpol_mf_move_all descriptions, + from numactl-0.9.2 man page. + plus a few other smaller fixes. + +fexecve.3 + mtk + new page describing fexecve(3). + +futimes.3 + mtk + new page describing futimes(3). + +changes to individual pages +--------------------------- + +execve.2 + mtk + added see also pointing to new fexecve.3. + +intro.2 + mtk, aeb, steve beattie + added some notes on syscall(2) versus _syscall. + +msgctl.2 +msgget.2 +msgop.2 + mtk + added see also pointing to mq_overview.7. + +open.2 + mtk + added see also pointing to new openat.2. + + split out part of the return value text into separate + notes section. + + modified wording referring to raw(8) to + indicate that this interface is deprecated. + +poll.2 + mtk + added discussion of ppoll(2), which is new in 2.6.16. + +ppoll.2 + mtk + new link to poll.2. + +recvmsg.2 +sendmsg.2 + mtk / paul brook + added text to note that although posix says msg_controllen + should be socklen_t, glibc actually uses size_t. + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=356502 + and the associated glibc bug report. + http://sourceware.org/bugzilla/show_bug.cgi?id=2448 + mtk + various formatting fixes. + +select.2 + mtk + updated to reflect the fact that pselect() has been implemented + in the kernel in 2.6.16; various other minor wording changes. + + pselect() prototype needs "#define _xopen_source 600". + +tempnam.3 + justin pryzby + clean up description of eexist error. + http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=357893 + +unlink.2 + mtk + added a little extra text to clarify eisdir vs eperm. + +utime.2 + mtk + added new see also entry pointing to new futimes.3 page. + +exec.3 + mtk + added see also pointing to new fexecve.3. + +shm_unlink.3 + mtk + new link to shm_open.3 (should have been made when page + was originally written). + +swab.3 + walter harms + add needed "#define _xopen_source". + +undocumented.3 + mtk + updated to remove a few function names that are now documented. + +capabilities.7 + mtk + various changes to bring this page closer to + current kernel versions. + +inotify.7 + mtk + noted that glibc 2.4 is required to get glibc support + for inotify. + +mq_overview.7 + mtk + some rewording and added a few words about system v + message queues. + +netlink.7 + hasso tepper + substantial updates to various parts of this page. + mtk, alain portal + minor fixes + +pthreads.7 + mtk + updated to reflect that the nptl limitation that only the main + thread could call setsid() and setpgid() was removed in 2.6.16. + +raw.7 + hasso tepper + removed text implying that only in kernel 2.2 does ip_hdrincl + prevent datagrams from being fragmented. + +socket.7 + mtk + documented so_sndbufforce and so_rcvbufforce socket options, + new in 2.6.14. + + placed socket options in alphabetical order. + + +==================== changes in man-pages-2.27 ==================== + +released: 2006-03-24 + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +andries brouwer +charles p. wright +christoph lameter +chuck ebbert <76306.1226@compuserve.com> +daniel jacobowitz +ingo molnar +heiko carstens +janak desai +paolo (blaisorblade) giarrusso +stefan puiu + +apologies if i missed anyone! + + +global changes +-------------- + +man7/* + mtk + various minor formatting changes were done on a range of + pages in section 7. (no content was changed.) + + +new pages +--------- + +unshare.2 + mtk, with reference to documentation by janak desai + new page describing unshare(2), added in kernel 2.6.16. + + +changes to individual pages +--------------------------- + +clone.2 +fork.2 +vfork.2 + mtk + added see also pointing to new unshare.2. + +mbind.2 + christoph lameter + mpol_mf_move_all requires cap_sys_nice not cap_sys_resource. + +mremap.2 + mtk + clarified the description of mremap_fixed and restructured + the text to reflect the fact that this flag is exposed + by glibc since version 2.4. + +ptrace.2 + chuck ebbert, with assistance from daniel jacobowitz, + paolo (blaisorblade) giarrusso, and charles p. wright; + after a suggestion from heiko carstens. + document the following ptrace requests: + ptrace_setoptions (2.4.6) + plus associated flags: + ptrace_o_tracesysgood (2.4.6) + ptrace_o_tracefork (2.5.46) + ptrace_o_tracevfork (2.5.46) + ptrace_o_traceclone (2.5.46) + ptrace_o_traceexec (2.5.46) + ptrace_o_tracevforkdone (2.5.60) + ptrace_o_traceexit (2.5.60) + ptrace_setsiginfo (2.3.99-pre6) + ptrace_getsiginfo (2.3.99-pre6) + ptrace_geteventmsg (2.5.46) + ptrace_sysemu (since linux 2.6.14) + ptrace_sysemu_singlestep (since linux 2.6.14) + +sched_get_priority_max.2 +sched_setscheduler.2 +sched_setparam.2 + mtk, ingo molnar + modified to document sched_batch policy, new in kernel 2.6.16. + + text describing sched_batch was added to sched_setscheduler.2, + and was drawn in part from ingo molnar's description in the + mail message containing the patch that implemented this policy. + + various other minor rewordings and formatting fixes. + +proc.5 + mtk, using text from documentation/filesystems/proc.txt + document /proc/sys/vm/drop_caches, new in kernel 2.6.16. + mtk, using information from changelog-2.6.14. + document /proc/pid/smaps, new in kernel 2.6.14. + +capabilities.7 + mtk + noted affect of cap_sys_nice for mbind(mpol_mf_move_all). + +pthreads.7 + mtk + kernel 2.6.16 eliminated buggy behavior with respect to + the alternate signal stack. + + +==================== changes in man-pages-2.28 ==================== + +released: 2006-03-31 + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +aleksandr blokhin +greg johnson + +apologies if i missed anyone! + + +new pages +--------- + +sem_post.3 +sem_getvalue.3 +sem_close.3 +sem_open.3 +sem_destroy.3 +sem_wait.3 +sem_unlink.3 +sem_init.3 +sem_overview.7 + mtk + new pages describing the posix semaphores api. + + these pages supersede and provide a superset of the information + in the glibc (3thr) "semaphores(3)" manual page. + + +changes to individual pages +--------------------------- + +ppoll.2 + aleksandr blokhin + fix broken link. + +ptrace.2 + mtk + wrapped long lines (no content changes). + +semctl.2 +semget.2 +semop.2 + mtk + add see also pointing to the new sem_overview.7 page. + +elf.5 + greg johnson + removed see also reference to nonexistent core(5). + + +==================== changes in man-pages-2.29 ==================== + +released: 2006-04-06 + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +michael haardt +roberto jimenoca +stefan puiu + +apologies if i missed anyone! + + +global changes +-------------- + +getrlimit.2 +prctl.2 +sigaction.2 +elf.5 +signal.7 + mtk + added see also entry referring to new core.5 page. + + +new pages +--------- + +mkdirat.2 + mtk + new page describing mkdirat(2), new in 2.6.16. + +mknodat.2 + mtk + new page describing mknodat(2), new in 2.6.16. + +core.5 + mtk + new page describing core dump files. + +mkfifoat.3 + mtk + new page describing mkfifoat(3). + + +changes to individual pages +--------------------------- + +accept.2 +getpeername.2 +getsockname.2 + michael haardt / mtk + document einval error for 'len' argument < 0. + +fcntl.2 + mtk + expanded discussion of mandatory locking. + +getrlimit.2 + mtk + added bugs text on 2.6.x handling of rlimit_cpu limit + of zero seconds. see + http://marc.theaimsgroup.com/?l=linux-kernel&m=112256338703880&w=2 + +mkdir.2 + mtk + added see also entry referring to new mkdirat.2. + +mknod.2 + mtk + added see also entry referring to new mknodat.2. + +open.2 + mtk / roberto jimenoca + clarified discussion of file types affected by o_nonblock. + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=360243 + +openat.2 + mtk + rewrote notes describing rationale for openat(). + various other minor changes. + +recv.2 + stefan puiu + removed a misleading cross-ref to socket.2. + +shmop.2 + mtk + since 2.6.17-rc1, shmdt() gives the error einval in a further + circumstance: if shmaddr is not aligned on a page boundary. + +unshare.2 + mtk + remove text saying that specifying invalid flags "is likely + to cause compatibility problems" since the kernel now + (2.6.17-rc1) contains an explicit check for invalid bits + with a consequent einval error. + +mkfifo.3 + mtk + added see also entry referring to new mkfifoat.3. + +proc.5 + mtk + information on core_pattern and core_uses_pid has + been migrated to the new core.5 page. + +ip.7 + stefan puiu + removed paragraph referring to obsolete ipchains / ipfw(4). + +sem_overview.7 + mtk + add see also entry referring to pthreads.7. + + +==================== changes in man-pages-2.30 ==================== + +released: 2006-04-17 + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +andre lehovich +andries brouwer +karel kulhavy +stefan puiu + +apologies if i missed anyone! + + +new pages +--------- + +linkat.2 + mtk + new page describing linkat(), new in kernel 2.6.16 + +renameat.2 + mtk + new page describing renameat(), new in kernel 2.6.16 + +symlinkat.2 + mtk + new page describing symlinkat(), new in kernel 2.6.16 + +unlinkat.2 + mtk + new page describing unlinkat(), new in kernel 2.6.16 + + +changes to individual pages +--------------------------- + +link.2 + mtk + added see also entry pointing to new linkat.2 page. + +openat.2 + mtk + added see also entries pointing to new *at.2 pages. + +rename.2 + mtk + added see also entry pointing to new renameat.2 page. + +rmdir.2 + mtk + added see also entry pointing to new unlinkat.2 page. + +symlink.2 + mtk + added see also entry pointing to new symlinkat.2 page. + +unlink.2 + mtk + added see also entry pointing to new unlinkat.2 page. + +termios.3 + mtk / karel kulhavy + document the feature test macros required to expose various flags. + karel kulhavy + clarify 'speed' argument for cfsetispeed() text. + karel kulhavy / mtk + note that loblk is not implemented on linux. + mtk + clarify arguments for cfsetspeed(). + various formatting changes. + +full.4 + andre lehovich + add a sentence describing the purpose of full(4). + +core.5 + aeb / mtk + rework text describing circumstances in which + core dump files are not produced. + mtk / stefan puiu + a core dump of a multithreaded process always includes the + pid in the core filename. + mtk / stefan puiu + eliminate some accidentally duplicated text. + + +==================== changes in man-pages-2.31 ==================== + +released: 2006-05-02 + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +joshua kwan +justin pryzby +karel kulhavy +mark glines +martin (joey) schulze +nishanth aravamudan +reuben thomas +ryan s. arnold +ulrich drepper + +apologies if i missed anyone! + + +page renamings +-------------- + +the following pages have been relocated into section 7, since +that is their more natural home. see also references in various +other pages have been adjusted. + +epoll.4 +fifo.4 +futex.4 +complex.5 +environ.5 + (many pages outside man-pages actually *expect* + 'environ' to be in section 7.) + +ipc.5 + renamed to svipc.7 + +".so" link files have been created to link the old file locations to the +new file locations. these links are added just to ensure that cross +references from any other (non-man-pages) pages will remain valid; +eventually these links will be removed. + + +new pages +--------- + +fstatat.2 + mtk + new page for fstatat(2), new in 2.6.16. + +adjtime.3 + mtk + new page for adjtime(3). + +error.3 + justin pryzby / mtk + new page describing error() and error_at_line() + fixes http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=186307 + +program_invocation_name.3 + mtk + new page describing program_invocation_name and + program_invocation_short_name variables. + +sockatmark.3 + mtk + new page for sockatmark(3). + +ftm.7 + mtk + new page describing feature test macros. + +time.7 + mtk + new page giving an overview of "time" on linux systems. + + +global changes +-------------- + +getgroups.2 +wait4.2 +chown.2 +chdir.2 +gettimeofday.2 +initgroups.3 +dirfd.3 + mtk + simplified wording around requirement for _bsd_source + feature test macro. + +times.2 +time.2 +gettimeofday.2 +getitimer.2 +nanosleep.2 +ctime.3 +rtc.4 + mtk + added see also referring to new time.7. + +err.3 +errno.3 +perror.3 +strerror.3 + justin pryzby / mtk + add see also referring to new error.3. + +getdate.3 +printf.3 +scanf.3 + mtk + added see also entry referring to setlocale.3. + + +changes to individual pages +--------------------------- + +accept.2 + mark glines + remove mention of sock_rdm from this page, since this socket + type does not support accept()ing connections. + +adjtimex.2 + mtk + modified text referring to adjtime(); added see also for new + adjtime.3 page. + +fsync.2 + mtk, after a note by karel kulhavy + rewrote most of the description, as well as some other parts + the page, to clarify use and operation of, and rationale for, + fsync(2) and fdatasync(2). + +getitimer.2 + mtk + updated discussion of maximum timer value to reflect the fact + that the default jiffy is now 4 milliseconds. + + added text to note that current incorrect behavior of + normalizing tv_usec >= 1000000 will be repaired in a future + kernel; applications should be fixed now. + +gettimeofday.2 + karel kulhavy + point out more explicitly that 'tz' argument should + normally be null. + mtk + various other minor edits and formatting fixes. + +mount.2 + mtk + since kernel 2.6.16, ms_noatime and ms_nodiratime are settable + on a per-mount basis. + detail exactly which mount flags can be changed on ms_remount. + +nanosleep.2 + mtk / karel kulhavy + clarify return value discussion. + +openat.2 + mtk + add see also reference pointing to new fstatat.2. + +program_invocation_short_name.3 + mtk + new link to new program_invocation_name.3. + +recv.2 + mtk + added see also for new sockatmark.3. + +rmdir.2 + joshua kwan / martin (joey) schulze / mtk + correct wording of ebusy case. + mtk + add ".." case to enotempty error + +select.2 + karel kulhavy + note more clearly that fd_set arguments can be null. + mtk / karel kulhavy + improve opening paragraph describing purpose of select(). + mtk + various other minor edits and formatting fixes. + +semget.2 + mtk / nishanth aravamudan + add text to noting that the initial values of semaphores + in a new set are indeterminate. + +shmget.2 + mtk + add text noting that contents of newly created segment are zero + values. + +sigwaitinfo.2 + mtk + noted that all threads should block signal being waited for. + +stat.2 + nishanth aravamudan / mtk + added note that st_size is always returned as zero for most + /proc files. + mtk + add see also reference pointing to new fstatat.2. + +syscall.2 + justin pryzby / mtk + remove bogus bugs text. + +utime.2 + mtk + various minor changes. + +confstr.3 + mtk + rewrote return value discussion. + updated conforming to. + removed bugs. + +ctanh.3 + martin (joey) schulze / mtk + fix errors in description. + +ctime.3 + mtk + the range of tm_sec is 0..60 (not 0..61). + +error_at_line.3 +error_message_count.3 +error_on_per_line.3 +error_print_progname.3 + mtk + new links to new error.3. + +fmemopen.3 + mtk / ryan s. arnold + add text noting that explicitly controlling output buffering + may be useful to catch errors on output operations on an + fmemopen() stream. + +getline.3 + justin pryzby + add see also pointing to getline.3. + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=364772 + +strtod.3 +strtoul.3 + mtk + describe correct handling of errno in order to + distinguish error from success after the call. + + added example section which points to strtol.3 which provides + an example of the use of the analogous strtol(3). + +strtol.3 + mtk / justin pryzby + add an example program. + mtk + describe correct handling or errno in order to + distinguish error from success after the call. + +tmpfile.3 + reuben thomas + description does not need to say "temporary file name" + just "temporary file", since the name is in any case + unavailable to the user. + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=363518 + mtk + in description: + change /automatically deleted when the program terminates normally/ + to /automatically deleted when the program terminates/ + since deletion occurs on both normal and abnormal termination. + +ip.7 + karel kulhavy / mtk + various wording improvements and clarifications. + +signal.7 + mtk / ulrich drepper + add text noting that a signal's disposition is process-wide, + shared by all threads. + mtk + add text on changing signal dispositions. + add text on "signal mask and pending signals". + other minor edits. + +time.7 + mtk + added see also for new adjtime.3. + +ld.so.8 + justin pryzby + remove bogus duplicate line. + + +==================== changes in man-pages-2.32 ==================== + +released: 2006-05-13 + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +andries brouwer +johannes weiner +justin pryzby +karel kulhavy +paul brook +pavel heimlich + +apologies if i missed anyone! + + +new pages +--------- + +faccessat.2 + mtk + new page for faccessat(2), new in 2.6.16. + +fchmodat.2 + mtk + new page for fchmodat(2), new in 2.6.16. + +fchownat.2 + mtk + new page for fchownat(2), new in 2.6.16. + +futimesat.2 + mtk + new page for futimesat(2), new in 2.6.16. + + +changes to individual pages +--------------------------- + +access.2 + mtk + add see also reference pointing to new faccessat.2 page. + +capget.2 + mtk + reworded to reflect that capabilities are per-thread. + +chmod.2 + mtk + add see also reference pointing to new fchmodat.2 page. + +chown.2 + mtk + add see also reference pointing to new fchownat.2 page. + +mmap.2 + mtk + updated discussion of map_noreserve since it is no longer + restricted to map_private mappings. + add reference to discussion of /proc/sys/vm/overcommit_memory + in proc.5. + +openat.2 + mtk + add see also reference pointing to new faccessat.2, fchmodat.2, + fchownat.2, futimesat.2 pages. + +shmget.2 + mtk + document shm_noreserve flag, new in 2.6.15. + +truncate.2 + paul brook / mtk + expand text noting that ftruncate()/truncate() may fail if + asked to extend a file beyond its current length. + add eperm error. + +utime.2 + mtk + add see also reference pointing to new futimesat.2 page. + +fopen.3 + justin pryzby / mtk + document 'm' (mmap) flag. + http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=365754 + mtk + document 'c' (notcancel) flag. + +futimes.3 + mtk + add see also reference pointing to new futimesat.2 page. + +qsort.3 + johannes weiner + add missing "const" qualifies to cast in example. + mtk + slight rewording of comments in example. + +termios.3 + karel kulhavy + clarify meaning of ixany. + clarify relationship of min with vmin and time with vtime. + mtk + noted that cibaud, ofdel, and delecho are not implemented + on linux. + added explanatory paragraph for phrases "not in posix" and + "xsi". + +capabilities.7 + mtk + reworded to reflect that capabilities are per-thread. + add ioprio_set() to list of operations permitted by + cap_sys_nice. + add ioprio_set() ioprio_class_rt and ioprio_class_idle + scheduling classes to list of operations permitted by + cap_sys_admin. + note effects of cap_sys_nice for migrate_pages(). + + +==================== changes in man-pages-2.33 ==================== + +released: 2006-05-23 + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +andries brouwer +justin pryzby +martin osvald" +stefan puiu + +apologies if i missed anyone! + + +page renamings +-------------- + +ftm.7 + mtk / stefan puiu + renamed to the more suggestive feature_test_macros.7 + + +new pages +--------- + +mq_getsetattr.2 + mtk + new page briefly describing mq_getsetattr(2), the system + call that underlies mq_setattr(3) and mq_getattr(3). + +rpmatch.3 + justin pryzby / mtk + new page for rpmatch(3). + + +changes to individual pages +--------------------------- + +chmod.2 + mtk + remove mention of non-standard s_iread, s_iwrite, s_iexec. + posix does now document eloop. + +open.2 + mtk + remove mention of non-standard s_iread, s_iwrite, s_iexec. + +mmap.2 + justin pryzby + add mincore(2) to see also. + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=367401 + +msync.2 + justin pryzby + note that einval can also be caused by + flags == ms_sync | ms_async. + +sched_setaffinity.2 + mtk + add cpu_isset, cpu_clr, cpu_set, cpu_zero to name section. + +select.2 + mtk + various minor changes. + +select_tut.2 + mtk + removed much material that is redundant with select.2. + various other changes. + +umask.2 + mtk + substantial rewrite of description of 'mask'. + +cpu_isset.3 +cpu_clr.3 +cpu_set.3 +cpu_zero.3 + mtk + new links to sched_setaffinity.2 + +fd_clr.3 +fd_isset.3 +fd_set.3 +fd_zero.3 + mtk + new links to select.2. + +fts.3 + justin pryzby + add see also referring to ftw.3. + +ftw.3 + justin pryzby + add see also referring to fts.3. + +getline.3 + justin pryzby + various minor clarifications. + +mkstemp.3 + mtk + clarify that o_excl is an open(2) flag. + +mq_open.3 + martin osvald + fix prototype declaration for 'attr'. + +mq_notify.3 + martin osvald + s/sigev_signal/sigev_signo/ + +mq_setattr.3 + mtk + new link to mq_getattr.3. + +mq_timedreceive.3 + mtk + new link to mq_receive.3. + +mq_timedsend.3 + mtk + new link to mq_send.3. + +setlocale.3 + justin pryzby + added see also referring to rpmatch.3. + +sigandset.3 +sigisemptyset.3 +sigorset.3 + mtk + new links to sigsetops.3. + +stdio.3 + justin pryzby + added see also referring to unlocked_stdio.3 + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=367667 + +strchr.3 + justin pryzby + add description of strchrnul(). + +strchrnul.3 + mtk + new link to strchr.3. + +undocumented.3 + justin pryzby / mtk + updated to remove some functions that don't exist, and + therefore don't need to be documented. + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=367671 + +unlocked_stdio.3 + justin pryzby + added see also referring to stdio.3 + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=367667 + +mq_overview.7 + mtk + added section describing relationship between library + interfaces and system calls. + added see also referring to new mq_getsetattr.2. + +feature_test_macros.7 + stefan puiu + fix typo: s/_posix_c_source/_posix_source/ + + +==================== changes in man-pages-2.34 ==================== + +released: 2006-06-20 + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +aristeu sergio rozanski filho +bert hubert +chris curtis +eduardo madeira fleury +joerg scheurich +justin pryzby +kenichi okuyama +marc lehmann +martin (joey) schulze +mats wichmann +mike frysinger +peter eiserloh +stefan puiu +thomas dickey +walter harms + +apologies if i missed anyone! + + +global changes +-------------- + +tzselect.8 +zdump.8 +zic.8 + mtk, joey + added header comment noting that these pages are in the public + domain. + +bindresvport.3 +getrpcent.3 +getrpcport.3 +rpc.3 +xdr.3 +rpc.5 + mtk, aeb, joey + added following to top of these pages to clarify origin and + license: + .\" this page was taken from the 4.4bsd-lite cdrom (bsd license) + +new pages +--------- + +ioprio_set.2 + eduardo madeira fleury, with edits by mtk, and review by jens axboe + new page for ioprio_get(2) and ioprio_set(2), new in 2.6.13. + +offsetof.3 + justin pryzby / mtk + new page describing offsetof() macro. + + +changes to individual pages +--------------------------- + +_exit.2 + mtk + add see also referring to exit_group.2. + +acct.2 + mtk + add see also referring to acct.5. + +fcntl.2 + mtk + explicitly mention term "dnotify" in discussion of f_notify. + +inotify_add_watch.2 + aristeu sergio rozanski filho / mtk + s/// in prototypes. + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=369960 + mtk + renamed argument from 'path' to 'pathname'. + reword introductory paragraph to clarify that + inotify_add_watch() may also modify an existing watch item. + mtk + the einval error can also occur if 'fd' is not an inotify + file descriptor. + mtk + moved bugs section from this page to inotify.7. + +inotify_init.2 + aristeu sergio rozanski filho / mtk + s/// in prototypes. + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=369960 + +inotify_rm_watch.2 + aristeu sergio rozanski filho / mtk + s/// in prototypes. + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=369960 + mtk + the einval error can also occur if 'fd' is not an inotify + file descriptor. + +ioprio_get.2 + mtk + new link to new ioprio_set.2. + +mmap.2 + mtk + add see also referring to remap_file_pages.2. + +mount.2 + kenichi okuyama + s/mnt_force/mnt_expire/ under einval error. + +mremap.2 + mike frysinger + s/unsigned long flags/int flags/ in synopsis. + +pipe.2 + mtk + add see also referring to popen.3. + +posix_fadvise.2 + mtk + add see also referring to readahead.2. + +read.2 + mtk + see also for readv should refer to section 2, not 3. + +readahead.2 + mtk + add see also referring to posix_fadvise.2. + +send.2 + peter eiserloh + fix missing arguments in statement about equivalent send() + and sendto() calls. + +setsid.2 + mtk + add see also referring to tcgetsid.3. + +shmctl.2 + mtk + minor wording change at start of description. + +stat.2 + mtk + add see also referring to access.2. + +statfs.2 + mtk + relocated "note" about f_fsid. + +write.2 + mtk + see also for writev should refer to section 2, not 3. + +__setfpucw.3 + mtk, joey + added license statement (gpl) after consultation with + joerg scheurich. + +assert_perror.3 + justin pryzby + add #define _gnu_source to prototype + +difftime.3 + joey + added note about time_t representation on other systems. + added conforming to. + +ftw.3 + justin pryzby / mtk + a fairly major revision... + document ftw_actionretval; include .sh "return value"; + reorganized and rewrote much of the page + added an example program. + +inet.3 + marc lehmann + fixed typo in notes. + http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=370277 + +isalpha.3 + joey + updated conforming to. + +mktemp.3 + mtk + updated conforming to. + +printf.3 + walter harms + add documentation of %m. + +readdir.3 + mtk + added see also referring to ftw.3. + +re_comp.3 + mtk + note that these functions are obsolete in favor of regcomp(3). + justin pryzby + add see also referring to regcomp.3 + +scandir.3 + mats wichmann + reworded conforming to statement on scandir() and alphasort(). + +strchr.3 + stefan puiu + fix prototype for strchrnul(). + +strtoul.3 + stefan puiu + add text clarifying treatment of strings starting with + minus sign. + +tmpnam.3 + mtk, after comments by justin pryzby + add text noting the need to use open(o_excl). + mtk + clarify discussion of use of free(3). + various other minor changes to text and formatting. + +tmpfile.3 + mtk + updated conforming to. + +tmpnam.3 + mtk, after comments by justin pryzby + add text noting the need to use open(o_excl). + updated conforming to. + +undocumented.3 + mtk + remove offsetof(), which is now documented. + +null.4 + mtk + added see also referring to full.4. + +console_codes.4 + thomas dickey + various improvements and corrections. + +epoll.7 + mtk + added conforming to section mentioning freebsd kqueue and + solaris /dev/poll. + +feature_test_macros.7 + mtk + added pointer to location of lfs specification. + +futex.7 + mtk, after suggestion by joey. + added license statement to page, after discussion with + original author, bert hubert. + mtk + reformat long lines; no content changes. + +inotify.7 + mtk + 'path' argument renamed to 'pathname'. + a few minor rewordings. + added bugs section describing a couple of bugs. + +ip.7 + mtk + add see also referring to byteorder.3. + +man.7 + justin pryzby + add see also referring to groff_man(7). + http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=369253 + + +==================== changes in man-pages-2.35 ==================== + +released: 2006-07-06 + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +alain portal +andi kleen +andrew morton +bauke jan douma +davide libenzi +denis barbier +horacio rodriguez montero +johan lithander +justin pryzby +mike frysinger +stefan puiu +thorsten kukuk + +apologies if i missed anyone! + + +global changes +-------------- + +typographical or grammatical errors have been corrected in several +places. + +new pages +--------- + +sync_file_range.2 + andrew morton / mtk + new page for sync_file_range(2), new in kernel 2.6.17. + +changes to individual pages +--------------------------- + +adjtime.3 + mtk + noted bug that occurs if 'delta' is specified as null. + see http://bugzilla.kernel.org/show_bug.cgi?id=6761 + +bind.2 + stefan puiu + add eaddrnotavail error. + stefan puiu / mtk + make example code more complete. + +epoll_ctl.2 + mtk / davide libenzi + added epollrdhup description. + mtk + added see also referring to poll.2. + +poll.2 + mtk / davide libenzi + added pollrdhup description. + mtk + the correct header file is , not . + rewrote and reformatted various other parts. + +readlink.2 + mtk + nowadays, readlink() returns 'ssize_t', as required in + posix.1-2001. + +wavelan.4 + mtk + added license statement. + +nscd.conf.5 + thorsten kukuk + add documentation for various new fields. + +passwd.5 + horacio rodriguez montero + add explanation of 'x' character in 'password' field. + mtk + the proper name of "*" is "asterisk" not "star". + +tcp.7 + johan lithander + update rfc reference for ecn. + andi kleen + add sentence on "low memory" limit for tcp_mem on 32-bit systems. + + +==================== changes in man-pages-2.36 ==================== + +released: 2006-07-11 + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +alain portal +jens axboe +justin pryzby +kyle mcmartin + +apologies if i missed anyone! + +global changes +-------------- + +typographical or grammatical errors have been corrected in several +places. + +new pages +--------- + +maintaining + mtk + how to maintain man-pages. + +todo + mtk + things that it would be nice to get done for man-pages one day. + +scripts/fixme_list.sh + mtk + this script, intended for use by manual page maintainers, + displays the fixmes in the manual page source files. + +changes to individual pages +--------------------------- + +fdatasync.2 +fsync.2 + mtk + added see also referring to sync_file_range.2. + +sendfile.2 + mtk / jens axboe + fix description of 'offset' argument to explain the case + where 'offset' is null. + +ferror.3 + justin pryzby + add see also referring to fdopen.3. + +intro.3 + mtk + removed information about section 3 subsections -- it doesn't + reflect current reality, and probably never has. + + added see also referring to intro.2. + +tcp.7 + kyle mcmartin + correction: tcp_window_scaling is enabled by default. + + +==================== changes in man-pages-2.37 ==================== + +released: 2006-08-02 + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +alain portal +dean gaudet +frank van viegen +helmut grohne +ivana varekova +thomas huriaux +ville skyttä + +apologies if i missed anyone! + +global changes +-------------- + +thomas huriaux / mtk + + various formatting problems found as a result of reviewing the + following command were fixed. + + for a in $(wc -l man?/*.?| awk '$1 > 2 {print $2}' | grep -v total); do + echo $a; groff -tascii -wmac -mman $a > /dev/null; + done 2>&1 | less + + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=378544 + +typographical or grammatical errors have been corrected in several +places. + +new pages +--------- + +readlinkat.2 + mtk (after prompting from ivana varekova) + new page for readlinkat(2), new in kernel 2.6.16. + +changes to individual pages +--------------------------- + +ldd.1 + ville skyttä + document "-u" option. + +chdir.2 + mtk + noted effect of fork() and execve() on current working directory. + +chroot.2 + mtk + noted effect of fork() and execve() on root directory. + +epoll_ctl.2 + frank van viegen / mtk + fix description of ebadf error. + +exevce.2 + mtk + add text noting that effective ids are copied to + saved set-ids during execve(). + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=379297 + +getitimer.2 + mtk + noted effect of fork() and execve() on interval timers. + +getrlimit.2 + mtk + noted effect of fork() and execve() on resource limits. + +getpriority.2 + mtk + noted effect of fork() and execve(). + +inotify_add_watch.2 + mtk + some rewording; included text describing required file + permissions. + +intro.2 + mtk + revised description of standards under conforming to. + +makecontext.3 + helmut grohne / mtk + point out that args following 'argc' are int. + mtk + added an example program. + various minor wording fixes. + +mmap.2 + mtk + expand description of map_populate. + mtk, after prompting by dean gaudet + expand description map_nonblock. + mtk + various minor formatting fixes. + +openat.2 + mtk + added see also linking to readlinkat.2. + +nanosleep.2 + mtk + noted buggy behavior in linux 2.4 and earlier when + nanosleep() is restarted after receiving stop+sigcont signals. + +nice.2 + mtk + very minor rewording. + +readlink.2 + mtk + added see also linking to readlinkat.2. + +sched_setscheduler.2 + mtk + noted preservation of scheduling parameters across execve(). + +setpgid.2 + mtk + noted effect of fork() and execve() on process group id. + +setsid.2 + mtk + noted effect of fork() and execve() on session id. + +umask.2 + mtk + noted effect of fork() and execve() on umask. + +atexit.3 + mtk + noted inheritance of registrations across fork(). + +capabilities.7 + mtk + added material on privileges required for move_pages(). + clone_newns needs cap_sys_admin. + keyctl(keyctl_chown) and keyctl(keyctl_setperm) require + cap_sys_admin. + + +==================== changes in man-pages-2.38 ==================== + +released: 2006-08-03 + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +alain portal + +apologies if i missed anyone! + +global changes +-------------- + +most pages + mtk + there was a major reworking of the conforming to sections + in most manual pages. + + * generally try to rationalize the names used for standards. + the preferred names are now documented as the head words + of the list in standards(7). for the future: there is + probably no need to talk about anything more than + c89, c99, posix.1-2001 (or later), xbsd, and svr4. + (in particular, i've eliminated most references to xpg + and svid, replacing them with references to sus or svr4.) + + * eliminate discussion of errors that can occur on other + systems. this information exists only patchily in the + manual pages, is probably of limited use, is hard to maintain, + and was in some cases simply wrong (and probably always was). + + * tried to ensure that those interfaces specified in c99 or + posix.1-2001 are marked as such in their manual pages. + +intro.1 +intro.2 +intro.3 +intro.4 +intro.5 +intro.7 +feature_test_macros.7 + mtk + added see also referring to new standards.7. + +various pages + mtk + changed instances of "hp ux" to "hp-ux". + +various pages + mtk + changed instances of "dg-ux to "dg/ux" + +typographical or grammatical errors have been corrected in several +places. + +new pages +--------- + +standards.7 + mtk + based on material taken from intro.2, but expanded to + include discussion of many additional standards. + +changes to individual pages +--------------------------- + +bind.2 + mtk + minor wording change for enotsock error. + +intro.2 + mtk + removed information on standards to new standards.7. + + +==================== changes in man-pages-2.39 ==================== + +released: 2006-08-05 + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +alain portal + +apologies if i missed anyone! + +global changes +-------------- + +various pages + mtk + updated conforming to and/or standards references + in various pages that were missed for 2.38. + +typographical or grammatical errors have been corrected in several +places. + +changes to individual pages +--------------------------- + + +chdir.2 + mtk + _xopen_source=500 also gets fchdir() prototype. + +standards.7 + mtk + added a few more standards, and expand some explanations. + + +==================== changes in man-pages-2.40 ==================== + +released: 2006-09-04 + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +alain portal +andi kleen +andries brouwer +christoph hellwig +chuck ebbert <76306.1226@compuserve.com> +samuel thibault +toralf förster + +apologies if i missed anyone! + +global changes +-------------- + +faccessat.2 +fchmodat.2 +fchownat.2 +fstatat.2 +futimesat.2 +linkat.2 +mkdirat.2 +mknodat.2 +openat.2 +readlinkat.2 +renameat.2 +symlinkat.2 + mtk (after a note by alain portal) + make naming of 'pathname' argument consistent; various + minor rewordings. + +typographical or grammatical errors have been corrected in several +places. + +changes to individual pages +--------------------------- + +clone.2 + mtk + reinstate text on clone_detached, and add a few words. + +execve.2 + mtk + added list of process attributes that are not preserved on exec(). + +fork.2 + mtk, after a suggestion by christoph hellwig + greatly expanded, to describe all attributes that differ + in parent and child. + +linkat.2 + mtk + document at_symlink_follow (new in 2.6.18). + +set_mempolicy.2 + mtk / andi kleen + memory policy is preserved across execve(). + +write.2 + mtk / alain portal + see also for writev should refer to section 2, not 3. + (i.e., really make the change that was logged in 2.34) + +getcwd.3 + samuel thibault / mtk + fix synopsis and conforming to text for getwd() and + get_current_dir(). + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=381692 + +proc.5 + chuck ebbert + document /proc/pid/auxv. + +capabilities.7 + alain portal + restore text accidentally deleted in 2.39. + +regex.7 + mtk / alain portal + change references to "1003.2" to "posix.2". + + +==================== changes in man-pages-2.41 ==================== + +released: 2006-10-12 + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +andi kleen +andries brouwer +andrew morton +britton leo kerin +dan jacobson +guillem jover +hrvoje niksic +jens axboe +justin pryzby +kevin ryde +marcel holtmann +senthil kumar +stefan puiu +stuart macdonald +trond myklebust + +apologies if i missed anyone! + + +global changes +-------------- + +typographical or grammatical errors have been corrected in several +places. + + +new pages +--------- + +splice.2 +tee.2 +vmsplice.2 + jens axboe / michael kerrisk + see also: + http://lwn.net/articles/118760/ + http://lwn.net/articles/178199/ + http://lwn.net/articles/179492/ + http://kerneltrap.org/node/6505 + http://lwn.net/articles/179434/ + +changes to individual pages +--------------------------- + +ldd.1 + stefan puiu + note glibc version where "ldd -u" appeared. + +execve.2 + mtk + the pr_set_name setting is not preserved across an execve(). + +fork.2 + mtk + mappings marked with madvise(madv_dontfork) are not inherited + by child. + +getdtablesize.2 + mtk + noted that sysconf(_sc_open_max) is preferred in portable + applications. + +getpagesize.2 + mtk + noted that sysconf(_sc_page_size) is preferred in portable + applications. + _sc_page_size is available on most systems. + +madvise.2 + mtk + document madv_remove, new in 2.6.16. + document madv_dontfork / madv_dofork, new in 2.6.16. + +mount.2 + mtk / trond myklebust + mnt_force can cause data loss. + +mmap.2 + mtk + added note on linux's old (pre-2.6.12) buggy treatment of + length==0. + justin pryzby / mtk + added some einval errors. + +mremap.2 + mtk + remove superfluous "#include " from synopsis. + +msync.2 + mtk + added ebusy error for case where ms_invalidate is applied to + a locked region. + +posix_fadvise.2 + andrew morton + since 2.6.18, posix_fadv_noreuse is a no-op. + +prctl.2 + marcel holtmann / mtk + since kernel 2.6.18, setting 2 for pr_set_dumpable is no longer + possible. + guillem jover + updated linux versions where the options where introduced. + added pr_set_timing, pr_get_timing, pr_set_name, pr_get_name, + pr_set_unalign, pr_get_unalign, pr_set_fpemu, pr_get_fpemu, + pr_set_fpexc, pr_get_fpexc. + michael kerrisk + document pr_get_endian and pr_set_endian. + +remap_file_pages.2 + mtk + add "#define _gnu_source" to synopsis. + +sync_file_range.2 + mtk + noted that sync_file_range() appeared in kernel 2.6.17. + +vfork.2 + mtk + noted interactions with fork handlers in multithreaded programs. + +wait4.2 + mtk + added feature test macros to synopsis. + +clog2.3 + mtk / aeb / kevin ryde + fix broken text in description. + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=386214 + +clog10.3 + kevin ryde + fix broken text in description. + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=386214 + +mq_receive.3 + britton leo kerin + fix return type in synopsis; should be "ssize_t" not "mqd_t". + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=387551 + +qsort.2 + hrvoje niksic + fix wording referring to the use of strcmp() in 'compar' + function. + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=391402 + +sendfile.2 + mtk + added see also referring to new splice.2 page. + +termios.3 + mtk + documented iutf8 (which was new in kernel 2.6.4). + +tzset.3 + mtk + added some tz examples. + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=386087 + +proc.5 + mtk + added delayacct_blkio_ticks (new in 2.6.18) to /proc/pid/statm. + +ip.7 + stuart macdonald / andi kleen + fix discussion for tcp error queue /ip_recverr on tcp. + +pthreads.7 + mtk + noted effect of rlimit_stack resource limit for nptl. + +socket.7 + senthil kumar + place socket options in alphabetical order. + + +==================== changes in man-pages-2.42 ==================== + +released: 2006-11-24 + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +andrew morton +chuck ebbert <76306.1226@compuserve.com> +doug goldstein +eduard bloch +evan teran +pavel heimlich +petr baudis +randy dunlap +ulrich drepper + +apologies if i missed anyone! + + +global changes +-------------- + +typographical or grammatical errors have been corrected in several +places. + + +changes to individual pages +--------------------------- + +brk.2 + evan teran / mtk + add text describing behavior of the linux brk() system call + and point out that the glibc brk() wrapper provides different + behavior. + mtk + note that sbrk() is implemented as a library function in glibc + that calls the brk() system call. + +futex.2 + mtk + futex_fd is scheduled for removal in june 2007. + +getaddrinfo.3 +getnameinfo.3 + ulrich drepper, with edits by mtk + add text describing internationalized domain name + extensions. + +open.2 + mtk / eduard bloch + fix description of o_largefile to mention required feature test + macros. + +ptrace.2 + chuck ebbert + since linux 2.6.18, the pid of the new process is also available + for ptrace_event_vforkdone. + +syslog.3 + doug goldstein + fix header file required for vsyslog() in synopsis. + +wcwidth.3 + petr baudis + fix conforming to. + +core.5 + mtk + linux 2.4.21 added core_pattern (which was already in 2.6). + noted a few more reasons why a core dump file might not + be produced. + + +==================== changes in man-pages-2.43 ==================== + +released: 2006-11-29 + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +andi kleen +david brownell +eduard bloch +egmont koblinger +reuben thomas + +apologies if i missed anyone! + + +global changes +-------------- + +typographical or grammatical errors have been corrected in several +places. + + +changes to individual pages +--------------------------- + +ioperm.2 + mtk + clarify discussion of privilege requirements. + added enomem to errors. + +open.2 + mtk / eduard bloch + clarify description of o_largefile. + +crypt.3 + egmont koblinger + make description of md5 output string less ambiguous. + +strerror.3 + reuben thomas + add c99 to conforming to; see + http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=400634 + +rtc.4 + david brownell + + update the rtc man page to reflect the new rtc class framework: + + - generalize ... it's not just for pc/at style rtcs, and there + may be more than one rtc per system. + + - not all rtcs expose the same feature set as pc/at ones; most + of these ioctls will be rejected by some rtcs. + + - be explicit about when {a,p}ie_{on,off} calls are needed. + + - describe the parameter to the get/set epoch request; correct + the description of the get/set frequency parameter. + + - document rtc_wkalm_{rd,set}, which don't need aie_{on,off} and + which support longer alarm periods. + + - hey, not all system clock implementations count timer irqs any + more now that the new rt-derived clock support is merging. + +proc.5 + mtk + s/fseek(3)/lseek(2)/ under /proc/pid/mem entry. + +feature_test_macros.7 + mtk / eduard bloch + the lfs spec is now at http://opengroup.org/platform/lfs.html + +raw.7 +udp.7 + andi kleen + describe the correct default for udp/raw path mtu discovery. + + +==================== changes in man-pages-2.44 ==================== + +released: 2007-04-04 + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +andre majorel +benjamin gilbert +carlo marcelo arenas belon +chuck ebbert <76306.1226@compuserve.com> +ivana varekova +jakub jelinek +john ward +jorge peixoto de morais neto +julien blache +julien cristau +justin pryzby +martín ferrari +mike frysinger +nick piggin +nick pollitt +nicolas françois +pádraig brady +premysl hruby +reuben thomas +samuel thibault +serge e. hallyn +thomas huriaux +timo sirainen +val henson + +apologies if i missed anyone! + + +new pages +--------- + +termio.7 + mtk, after a bit of prodding by reuben thomas + a brief discussion of the old system v termio interface, + with pointers to pages that will contain the information + that the reader probably wants. + +scripts/find_repeated_words.sh + mtk + find consecutive duplicate words in a man page, some of + which may be grammar errors. + +global changes +-------------- + +various pages + justin pryzby / mtk + add "#define _atfile_source" to synopsis in following pages: + faccessat.2 + fchmodat.2 + fchownat.2 + fstatat.2 + futimesat.2 + linkat.2 + mkdirat.2 + mknodat.2 + openat.2 + readlinkat.2 + renameat.2 + symlinkat.2 + unlinkat.2 + mkfifoat.3 + +various pages + mtk + various references to "getty" were changed to "mingetty", since + that is the manual page more likely to be found on current systems. + +various pages + mtk, after a suggestion by reuben thomas + updated various header pages to accurately reflect which functions + are and are not part of c89. also fixed/improved a few other + conforming to entries. + +various pages + mtk + s/unices/unix systems/ on the 5 pages where it appears. + +various pages + mtk + wrapped long source lines in the following files + getsockopt.2 + mknodat.2 + io_setup.2 + select_tut.2 + select.2 + readlinkat.2 + io_cancel.2 + syslog.2 + wcsncat.3 + getipnodebyname.3 + cmsg.3 + wcpncpy.3 + wcsrtombs.3 + wcstok.3 + fgetwc.3 + wmemcmp.3 + wcsspn.3 + div.3 + modf.3 + stdio_ext.3 + ctermid.3 + des_crypt.3 + wcsncmp.3 + wmemchr.3 + wcsstr.3 + wmemcpy.3 + wprintf.3 + wcsnrtombs.3 + termios.3 + erf.3 + ceil.3 + lround.3 + nextafter.3 + wcsncpy.3 + wmemset.3 + getw.3 + console_ioctl.4 + sk98lin.4 + environ.7 + unix.7 + time.7 + +various pages + mtk + added a see also reference for feature_test_macros(7) to all + pages where a feature test macro appears in the synopsis. + +various pages + mtk + added see also entry pointing to time.7 + alarm.2 + nanosleep.2 + ualarm.3 + usleep.3 + +various pages + justin pryzby / mtk + fixed consecutive duplicate word typos on a number of pages. + +typographical or grammatical errors have been corrected in several +places. (special thanks to nicolas françois!) + + +changes to individual pages +--------------------------- + +access.2 + mtk + since 2.6.20, access() honors the ms_noexec mount flag. + jorge peixoto de morais neto / mtk + improve enoent description. + +clone.2 + mtk + added some detail to the prototype. + added some notes on ia-64's clone2(). + +epoll_ctl.2 + mtk + add text to note that epollrdhup appeared in kernel 2.6.17. + +faccessat.2 + justin pryzby + various fixes as per + http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=411177 + * s/effective/real/ in description text. + * added to synopsis. + * various other changes. + +getrlimit.2 + mtk / fedora downstream patches; thanks to ivana varekova + added a few words to note that rlimit_nproc is really a limit on + threads. + +io_cancel.2 +io_destroy.2 +io_getevents.2 +io_setup.2 +io_submit.2 + fedora downstream patches; thanks to ivana varekova + s%linux/aio.h%libaio.h% in synopsis. + changed return type from "long" to "int". + +mbind.2 + samuel thibault / mtk + fix einval description. + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=411777 + +mincore.2 + nick piggin + kernel 2.6.21 fixes several earlier bugs in mincore(). + nick pollitt + remove words "of a file" -- mincore() is describing + memory residence information, not properties of a file. + mtk + rewrote various parts to make the page clearer. + +mmap.2 + mtk + rewrote and reorganized various parts to be clearer. + taken from fedora downstream patches; thanks to ivana varekova + removed text stating that mmap() never returns 0; that's + not true. + +mount.2 + mtk / val henson + document ms_relatime, new in linux 2.6.20. + +open.2 + andre majorel / mtk + on linux, the error returned when opening a large file on a + 32-bit system is actually efbig, not eoverflow. + +posix_fadvise.2 + pádraig brady + fix return value description: returns error number of failure. + +rename.2 + mtk / timo sirainen + various improvements to description. + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=416012 + +semop.2 + mtk + if sops contains multiple operations, then these are performed + in array order. all unix systems that i know of do this, + and some linux applications depend on this behavior. susv3 + made no explicit statement here, but susv4 will explicitly + require this behavior. + small rewording of explanation of "atomically". + +signal.2 + nicolas françois + fix incorrect argument name in description. + mtk + small wording improvement. + +socket.2 + nicolas françois + add reference to ipv6.7 page. + +socketcall.2 + nicolas françois + fix .th line. + +splice.2 + benjamin gilbert + fix inconsistent argument names in synopsis and description. + +statvfs.2 + mtk + small wording clarification. + +symlink.2 + mtk / nicolas françois + removed cryptic text under conforming to referring to + "open(2) and nfs". there is no relevant text in open.2 as + far as i (mtk) can see. + +time.2 + mtk / reuben thomas + remove sentence "gettimeofday() obsoleting time() on 4.3bsd". + this information is old, and probably no longer relevant. + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=403888 + +write.2 + mtk, after an idea from a downstream fedora patch. + clarified discussion of /count == 0/ case. + +ptrace.2 + chuck ebbert + when the parent receives an event with ptrace_event_* set, + the child is not in the normal signal delivery path. this + means the parent cannot do ptrace(ptrace_cont) with a signal + or ptrace(ptrace_kill). kill() with a sigkill signal can be + used instead to kill the child process after receiving one + of these messages. + +sched_setaffinity.2 + mtk + fix glibc version number in description of 'cpusetsize' argument. + +vfork.2 + mtk + stripped some excess/outdated text from the bugs section. + +basename.3 + mtk / jorge peixoto de morais neto + add text to clarify that the pointer returned by these + functions may be into some part of 'path'. + +dlopen.3 + taken from fedora downstream patches; thanks to ivana varekova + + carlo marcelo arenas belon + add "#include " to example program. + +fclose.3 + mtk + complete rewrite. the existing page was hard to read, + and the return value description seems to be wrong. + +getopt.3 + mtk + added getopt() example program. + mtk + add a few words to clarify the operation of the gnu-specific + double-colon feature, which allows options to have optional + arguments. + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=352139 + +glob.3 + nicolas françois + fix prototype. + +inet_network.3 + mtk, after an idea from a downstream fedora patch. + clarified description of inet_network(). + +log.3 + nicolas françois + fix .th line. + +log10.3 + nicolas françois + fix .th line. + +malloc.3 + nicolas françois + small rewording to mention calloc(). + +posix_openpt.3 + martín ferrari + fix return type in synopsis; as per + http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=400971 + needs _xopen_source == 600; as per + http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=400975 + julien blache + s/ptsname/posix_openpt/ in return value + +re_comp.3 + taken from fedora downstream patches; thanks to ivana varekova + add "#define _regex_re_comp" to synopsis. + +regex.3 + nicolas françois + fix .th line. + +termios.3 + mtk + added .ss headers to give some structure to this page; and a small + amount of reordering. + mtk + added a section on canonical and non-canonical mode. + mtk + enhanced the discussion of "raw" mode for cfmakeraw(). + mtk + document cmspar. + mtk + make description of parodd a little clearer. + reuben thomas + add see also link to tty_ioctl.4 + mtk + add see also link to console_ioctl.4 + +ualarm.3 + mtk + removed bsd prototype from synopsis. + various rewordings. + +usleep.3 + mtk + removed bsd prototype from synopsis. + various rewordings. + +termcap.5 + taken from fedora downstream patches; thanks to ivana varekova + s/curses/ncurses/ under see also + +bootparam.7 + taken from fedora downstream patches; thanks to ivana varekova + documented "mem=nopentium". + +feature_test_macros.7 + mtk + the default treatment of _posix_c_source changed in glibc 2.4. + mtk, after a suggestion by justin pryzby + added some text warning that the "__" macros that + defines internally should never be + directly defined by programs. + mtk, based on notes by jakub jelinek + document _fortify_source + (see http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html ) + mtk + document _reentrant and _thread_safe. + +mdoc.7 + mtk / nicolas françois + remove configuration section, since this does not seem to be + true for linux. + +svipc.7 + nicolas françois + fix data types in associated data structures; + remove nonexistent semzcnt and semncnt fields. + +time.7 + mtk + since kernel 2.6.20, the software clock can also be 300 hz. + + +==================== changes in man-pages-2.45 ==================== + +released: 2007-04-05 + +global changes +-------------- + +this release consists mainly of formatting fixes (to a large +number of pages) to achieve greater consistency across pages. +with the exception of the few individual changes noted below, +no changes were made to content. + +changes to individual pages +--------------------------- + +io_destroy.2 +io_getevents.2 +io_setup.2 +io_cancel.2 +io_submit.2 + mtk + clarified return value text + +bindresvport.3 + mtk + rewrote prototype using modern c syntax. + + +==================== changes in man-pages-2.46 ==================== + +released: 2007-04-06 + +global changes +-------------- + +this release consists mainly of formatting fixes (to a large +number of pages) to achieve greater consistency across pages: + +* most instances of two or more consecutive blank lines in man + page output were shrunk to a single line. +* a number of example programs were reformatted + to more closely match k&r style. +* in various places (mainly code examples), the use of tabs was + replaced by spaces + +with the exception of the few individual changes noted below, +no changes were made to content. + + +changes to individual pages +--------------------------- + +bdflush.2 + mtk + add header file to synopsis. + +sched_rr_get_interval.2 + mtk + moved timespec definition from synopsis into description. + +select_tut.2 + mtk + make synopsis match select.2. + + +==================== changes in man-pages-2.47 ==================== + +released: 2007-05-04 + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +andi kleen +john heffner + +apologies if i missed anyone! + + +global changes +-------------- + +this release consists mainly of changes to source file layout +(wrapped long lines; stripped trailing white space; started new +sentences on new lines). + +there is very little change to output formatting or content (see the +notes below). + + +changes to individual pages +--------------------------- + +sched_rr_get_interval.2 + mtk + remove crufty statement that this system call is not implemented. + the nice interval can be used to control the size of + the round-robin quantum. + corrected .th line. + +ip.7 + john heffner / mtk + document ip_pmtudisc_probe, which will be in 2.6.22. + + +==================== changes in man-pages-2.48 ==================== + +released: 2007-05-04 + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +colin watson +justin pryzby + +apologies if i missed anyone! + + +global changes +-------------- + +this release consists mainly of changes to source file layout +(wrapped long lines; stripped trailing white space; started new +sentences on new lines). + +there is very little change to output formatting or content (see the +notes below). + +various pages + mtk + in various places where it occurred, + s/nonnegative/non-negative/ + +various pages + mtk + s/wide character/wide-character/ when used attributively. + + +changes to individual pages +--------------------------- + +man.7 + justin pryzby / colin watson / mtk + .sh doesn't require quotes. + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=411303 + + +==================== changes in man-pages-2.49 ==================== + +released: 2007-05-20 + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +akihiro motoki +bruno haible +justin pryzby + +apologies if i missed anyone! + + +new pages +--------- + +bsd_signal.3 + mtk + documentation of bsd_signal(). + +euidaccess.3 + mtk + manual page for euidaccess() and eaccess(). + +getsubopt.3 + mtk / justin pryzby + documentation of getsubopt(). + +sysv_signal.3 + mtk + documentation of sysv_signal(). + + +new links +--------- + +epoll_pwait.2 + mtk + new link to epoll_wait.2. + +eaccess.3 + mtk + new link to new euidaccess.3, + +sem_timedwait.3 + mtk + new link to sem_wait.3. + +sem_trywait.3 + mtk + new link to sem_wait.3. + + +global changes +-------------- + +typographical or grammatical errors have been corrected in several +places. + + +changes to individual pages +--------------------------- + +access.3 + mtk + added see also ref to new euidaccess.3 page. + +epoll_wait.2 + mtk + added description of epoll_pwait(), new in kernel 2.6.19. + +execve.2 + mtk + add text noting that linux allows 'argv' and 'envp' to be + null, but warning that this is non-standard and non-portable, + and should be avoided in portable programs. + bug filed (http://bugzilla.kernel.org/show_bug.cgi?id=8408) + to get this changed, but maybe that won't be done because it + is an abi change. + mtk + added an example program. + mtk + expanded the discussion of interpreter scripts and the + 'optional-arg' argument of an interpreter script. + for further info, see + http://homepages.cwi.nl/~aeb/std/hashexclam-1.html + http://www.in-ulm.de/~mascheck/various/shebang/ + mtk + added text noting that fd_cloexec causes record locks to be + released. + mtk + mention effect of ms_nosuid mount(2) flag for set-user-id + programs. + mtk + expanded description of handling of file descriptors during + execve(), adding text to note that descriptors 0, 1, and 2 + may be treated specially. + +faccessat.3 + mtk + added see also ref to new euidaccess.3 page. + +mmap.2 + mtk + place map_* flags list in alphabetical order. + +readv.2 + mtk + a fairly substantial rewrite, which among other things + fixes the problem reported by kyle sluder in + http://bugzilla.kernel.org/show_bug.cgi?id=8399 + and added some example code. + +sigaction.2 + mtk + added text referring to the discussion of async-signal-safe + functions in signal(7). + a few other minor formatting and wording changes. + +signal.2 + mtk + moved the discussion of async-signal-safe functions to signal(7). + added text referring to the discussion of async-signal-safe + functions in signal(7). + added see also entries referring to new bsd_signal.3 and + sysv_signal.3 pages. + +copysign.3 + bruno haible + clarify discussion of negative zero. + +getopt.3 + mtk + add see also ref to new getsubopt.3. + +iconv_open.3 + bruno haible + describe the glibc/libiconv //translit and //ignore extensions + for 'tocode'. + +iswblank.3 + bruno haible + update conforming to; iswblank() is in posix.1-2001. + +inotify.7 + mtk + definitions for in_dont_follow, in_mask_add, and in_onlydir + were added to glibc in version 2.5. + +signal.7 + mtk + incorporated (and slightly modified) the text on + async-signal-safe functions that was formerly in signal(2). + added see also entries referring to new bsd_signal.3 and + sysv_signal.3 pages. + + +==================== changes in man-pages-2.50 ==================== + +released: 2007-05-21 + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +andreas halter +laird shaw +mike frysinger + +apologies if i missed anyone! + +removed pages (!) +----------------- + +most section 1 man pages are removed + mtk (with help from mike frysinger, laird shaw, andreas halter) + once upon time andries added a number of section 1 manual pages + to man-pages. however, since that time, those pages have not + seen much maintenance, and are not in fact distributed in most + distributions. instead most distributions supply the + coreutils versions of these pages, which are currently + maintained. in addition, man-pages provides the 1p pages, + which document the portable subset of functionality of these + commands. since the man1 pages are mostly unneeded, and + out of date, i'm removing them. the following pages disappear: + + chgrp.1 + chmod.1 + chown.1 + cp.1 + dd.1 + df.1 + diff.1 + dir.1 + dircolors.1 + du.1 + install.1 + ln.1 + ls.1 + mkdir.1 + mkfifo.1 + mknod.1 + mv.1 + rm.1 + rmdir.1 + touch.1 + vdir.1 + + the following section 1 pages will be kept: + + intro.1 + ldd.1 + time.1 + + +==================== changes in man-pages-2.51 ==================== + +released: 2007-05-28 + +global changes +-------------- + +various pages + mtk + (hopefully) all cross references outside a page now include a + section number. this should permit better resulting output + from a man2html-type conversion. + +various pages + mtk + convert function formatting of the form "\fbname\fp()" to + ".br name ()". + + +changes to individual pages +--------------------------- + +futimesat.2 + mtk + s/futimes/futimesat/ in .sh name line. + +msgop.2 + mtk + put "msgrcv" and "msgsnd" in .sh name line. + +mount.2 + mtk + add "umount2" to .sh name line. + +wait.2 + mtk + add "waitid" to .sh name line. + +getopt.3 + mtk + add "getopt_long" and "getopt_long_only" in .sh name line. + +sem_wait.3 + mtk + add "sem_timedwait" and "sem_trywait" to .sh name line. + +stdarg.3 + mtk + add "va_start", "va_arg", "va_end", "va_copy" to .sh name line. + + +==================== changes in man-pages-2.52 ==================== + +released: 2007-05-29 + + "a foolish consistency is the hobgoblin of little minds, adored by + little statesmen and philosophers and divines" + + ralph waldo emerson (1803-1882) + + "but damn it, these man pages are a mess!" + + +global changes +-------------- + +most of the changes below are about bringing greater consistency +to manual pages, including reducing the wide range of .sh +section headings. + +typographical or grammatical errors have been corrected in several +places. + +various pages + mtk + make 'manual' component of .th line into the string + "linux programmer's manual". + reason: consistency. + +various pages + mtk + changed date in .th line into form yyyy-dd-mm. + reason: consistency. + +various pages + mtk + some .sh header lines were made into .ss lines. (one of the aims + here is to reduce the number of non-standard .sh lines.) + +various pages + mtk + change title .sh sections named "note" to "notes", in some cases + also changing the location of the section within the page. + reason: consistency. + +various pages + mtk + commented out .sh author sections; the right place for + documentation authorship sections is usually comments at the + top of the page source. + +various pages + mtk + changed .sh history to .sh versions. + reason: in many cases, history was being used to describe + linux/glibc version information, as was already done for + versions sections in other pages. + +various pages + mtk + removed history section, or moved it as a subsection or paragraphs + under another section e.g., notes. + reason: there are too many arbitrary section (.sh) names, and + a history section never was consistently used across linux + manual pages. + +various pages + mtk + moved see also section to be last section on the page + reason: consistency -- and this is where see also should be! + +various pages + mtk + relocated glibc notes as subsection under notes + reason: reduce number of arbitrary section (.sh) names. + +various pages + mtk + relocated linux notes as subsection under notes + reason: reduce number of arbitrary section (.sh) names. + +various pages + mtk + renamed some "availability" sections to "versions". + reason: consistency. + +various pages + mtk + renamed some "diagnostics" sections to "return value". + reason: consistency. + +getopt.3 +tzselect.8 + mtk + s/\.sh environment variables/.sh environment/ + reason: consistency. + +intro.2 +select.2 +sysctl.2 +bsearch.3 +dlopen.3 +envz_add.3 +fmtmsg.3 +getgrent_r.3 +getgrouplist.3 +getpwent_r.3 +getutent.3 +hsearch.3 +rtime.3 +strptime.3 +tsearch.3 +vcs.4 +wordexp.3 + mtk + s/return 0/exit(exit_failure)/ in main() of function example + program. + reason: consistency. + +mprotect.2 +select_tut.2 +dlopen.3 +getgrent_r.3 +getopt.3 +getpwent_r.3 +hsearch.3 +select_tut.2 +tsearch.3 + mtk + use symbolic constants (exit_success, exit_failure) in calls + to exit(). + reason: consistency. + +access.2 +chown.2 +lseek.2 +open.2 +read.2 +utmp.5 + mtk + renamed restrictions section to notes, or moved text in a + restrictions section under existing notes section. + reason: consistency, and reduce number of arbitrary section (.sh) + names. + + +changes to individual pages +--------------------------- + +capget.2 + mtk + s/\.sh further information/.sh notes/ + +dup.2 + mtk + s/\.sh warning/.sh notes/ + +kill.2 + mtk + renamed linux history section to linux notes, and relocated + within page. + +select_tut.2 + mtk + relocated example program and made its .sh title "example". + +sigaltstack.2 + mtk + move code example into its own example section. + +sigreturn.2 + mtk + s/\.sh warning/.sh notes/ + +setuid.2 + mtk + s/\.sh "linux-specific remarks"/.sh linux notes/ + +shmget.2 + mtk + remove section about effect of fork()/exec()/exit(); shmop.2 + contains the same text, and it only needs to be said once. + +shmop.2 + mtk + minor rewording under description. + +daemon.3 + mtk + minor wording and formatting changes. + +encrypt.3 + mtk + removed statement that glibc unconditionally exposes declarations + of encrypt() and setkey(), since portable applications must + use and define _xopen_source to obtain the declarations + of setkey() and encrypt(). adjusted example program accordingly. + +mkstemp.3 + mtk + slight rewording. + +ldp.7 + mtk + minor wording and formatting changes. + +man.7 + mtk + substantial rewrite, revising and extending the discussion + about desired conventions for writing pages. + there will be further updates to this page in the next few + man-pages releases. + + +==================== changes in man-pages-2.53 ==================== + +released: 2007-05-30 + + "a foolish consistency is the hobgoblin of little minds, adored by + little statesmen and philosophers and divines" + + ralph waldo emerson (1803-1882) + + "but damn it, these man pages are a mess!" + + +global changes +-------------- + +many many pages + mtk + reordered sections to be more consistent, in some cases renaming + sections or shifting paragraphs between sections. + +man7/* + mtk + in various pages in this section, .sh headings were + converted to .ss. + + +==================== changes in man-pages-2.54 ==================== + +released: 2007-06-07 + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +emmanuel mogenet +michael berg + +apologies if i missed anyone! + + +global changes +-------------- + +various pages + mtk + where there is an instruction in the synopsis about linking + or compiling with a certain option, the option is now + marked up in italics (e.g., "\fi-lm\fp"). + +various pages + mtk + added page numbers to page cross references. + +a few pages + mtk + s/manpage/man page/, for consistency. + +typographical or grammatical errors have been corrected in several +places. + + +new pages +--------- + +man-pages.7 + mtk + a description of the conventions that should be followed + when writing pages for the man-pages package. + +removed pages +------------- + +man1/readme + mtk + already deleted most of the man1 pages previously, so + this doesn't need to stay. + +ldp.7 + mtk + removed this page since it is out of date, and the proper place + to go for up-to-date information is http://www.tldp.org/ + +ksoftirq.9 + mtk + reason: this was the only section 9 page, and it is old + (linux 2.4). the man9 section never took off as an idea, and + i see little point in keeping a section 9 with just a single + old page. + + +changes to individual pages +--------------------------- + +howtohelp + mtk + moved some material out of here into new man-pages.7. + +alloc_hugepages.2 + mtk + minor rewrites, eliminating some duplication, and removing + some outdated text. + +epoll_pwait.2 + michael berg + fix broken link path; + http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=425570 + +fcntl.2 + mtk + remove misleading text about setting o_async when calling + open(); one must use fcntl() f_setfl for this task. + +fdatasync.2 + mtk + converted outdated bugs note about fdatasync() being + equivalent to fsync() on linux 2.2 into a notes note + about this historical behavior. + +futex.2 + mtk + small rewording to fix "fails with the error ewouldblock" + rather than "returns ewouldblock". + see red hat bug 172828. + +mprotect.2 + mtk, after an observation by emmanuel mogenet + a much improved example program. + mtk + significant rewrites and additions to description. + +mremap.2 + mtk + remove text about the nonexistent bsd mremap() -- too + much information, in my opinion. + +sched_yield.2 + mtk + added errors section. + +set_mempolicy.2 + mtk + moved text for "versions and library support". + +set_tid_address.2 + mtk + small rewording in return value section. + +sigaction.2 + mtk + add example section with a pointer to example in mprotect.2. + +sync_file_range.2 + mtk + fix return type in synopsis. add return value section. + +atexit.3 + mtk + small rearrangement of text under notes. + +bindresvport.3 + mtk + rewrite and substantial additional text. + +exec.3 + mtk + minor clarifications for text on execlp() and execvp(). removed + files section, since it provides no useful additional info. + +fenv.3 + mtk + moved link instructions from notes to synopsis. + added feenableexcept, fedisableexcept, fegetexcept + to .sh name list. + +fputwc.3 + mtk + added 'putwc' to .sh name list. + +gethostbyname.3 + mtk + s/int/socklen_t/ for type of gethostbyaddr() 'len' argument, + and add a few more words in notes about the type used here. + +login.3 + mtk + removed remark from notes about linking with -lutil; add + text on that point to synopsis. + +openpty.3 + mtk + removed redundant remark from notes about linking with -lutil + since there is text on that point under synopsis. + +sysconf.3 + mtk + added see also referring to getconf(1). + +unlocked_stdio.3 + mtk + revised .sh name section. + +ascii.7 + mtk + minor rearrangement of order of text. + +capabilities.7 + mtk + s/exec()/execve(2)/ in various places. + +complex.7 + mtk + changed "atan(1)" to "atan(1.0)" to prevent some versions of + man2html(1) from mistaking that string as a page cross reference. + +rtnetlink.7 + mtk + small restructuring to avoid 'cannot adjust line' from man(1). + +ldconfig.8 + mtk + removed now very out-of-date sentence about need to link shared + libraries with -lc. + +man.7 + mtk + various text was moved out of this page into the new man-pages.7. + +mdoc.7 + mtk + added see also referring to new man-pages.7. + +mdoc.samples.7 + mtk + a few changes, hopefully done right, to eliminate some + errors to stderr when rendering with man(1). + +rtnetlink.7 + mtk + shorten a line in table so it fits in 80 columns. + minor rewording under bugs. + +tzselect.8 + mtk + moved exit status section. + + +==================== changes in man-pages-2.55 ==================== + +released: 2007-06-10 + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +alexander taboriskiy +joey hess +john reiser +julien cristau +justin pryzby +martin (joey) schulze +mike frysinger +serge van den boom +ulrich drepper +xose vazquez perez + +apologies if i missed anyone! + + +global changes +-------------- + +clone.2 +getdents.2 +gettid.2 +ioprio_set.2 +llseek.2 +mmap2.2 +modify_ldt.2 +mq_getsetattr.2 +pivot_root.2 +quotactl.2 +readdir.2 +sysctl.2 +syslog.2 +tkill.2 + mtk, after a note by mike frysinger + updated to reflect the fact that the _syscalln() macros + have gone away, + +several pages + mtk + change reference to path_resolution.2 to path_resolution.7. + +typographical or grammatical errors have been corrected in several +places. + + +moved pages +----------- + +path_resolution.2 has been moved to section 7, thus path_resolution.7 + mtk + reason: this is an overview page, not one describing as + a specific system call. + + +changes to individual pages +--------------------------- + +maintaining + mtk, after a note from xose vazquez perez + added pointer to red hat man-pages bugzilla. + mtk + added a release philosophy note on separating out big + formatting changes into their own release that contains minimal + content changes. + +accept.2 + mtk + add new example section with pointer to example in bind.2. + +arch_prctl.2 + mtk + added return value section. + +bind.2 + mtk + expand example program, and move it to new example section. + added text pointing to example in getaddrinfo.3. + +cacheflush.2 + mtk + convert notes section to conforming to and note that + this call is linux-specific. + other minor rewordings. + +connect.2 + mtk + added new example section pointing to example in getaddrinfo.3. + +create_module.2 + mtk + add enosys error. + +fcntl.2 +flock.2 + mtk + small rewrite of see also text pointing to documentation/* in + kernel source. + +get_kernel_syms.2 + mtk + added errors heading + add enosys error. + +getdtablesize.2 + mtk + added an errors section. + +getsid.2 + mtk + added a return value section. + +getpid.2 + mtk + added an errors section (stating that the calls are + always successful). + +ioctl_list.2 + mtk + add see also reference to ioctl.2. + +listen.2 + mtk + add new example section with pointer to example in bind.2. + +query_module.2 + martin (joey) schulze + add enosys error. + +recv.2 + mtk + added new example section pointing to example in getaddrinfo.3. + +sched_get_priority_max.2 +sched_rr_get_interval.2 +sched_setscheduler.2 +sched_yield.2 + mtk + modified .th line + +send.2 + mtk + added new example section pointing to example in getaddrinfo.3. + +set_tid_address.2 + mtk + added an errors section (stating that the call is + always successful). + +signal.2 + mtk, after a note from alexander taboriskiy + strengthen warning against the use of signal(). + added siginterrupt(3) to see also list. + mtk + rewrote various parts; added an errors section. + +socket.2 + mtk + added new example section pointing to example in getaddrinfo.3. + +stat.2 + mtk + added example program. + +syscall.2 + mtk + converted to -man format; some rewrites; added an example. + +sysctl.2 + mtk + improved the example program. + +getnameinfo.3 + mtk + add text pointing to example in getaddrinfo.3. + +getaddrinfo.3 + mtk + add example programs. + add getnameinfo() to see also list. + +memmove.3 + mtk / serge van den boom + clarify discussion of what happens if 'src' and 'dest' overlap. + +regex.3 + justin pryzby + add grep(1) to see also list. + +sigpause.3 + mtk after a note from ulrich drepper + clarify discussion of feature test macros that are needed to + expose system v and bsd versions of this function in glibc. + +undocumented.3 + mtk + removed some functions that have been documented. + +wprintf.2 + martin (joey) schulze + remove wscanf.3 from see also list, since that page does not exist. + +utmp.5 + joey hess + removed outdated note on xdm. + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=418009 + martin (joey) schulze + removed outdated note about debian and libc5. + +bootparam.7 + martin (joey) schulze + fix order of commands listed under 'init='. + +hier.7 + joey hess + add /media, remove /dos. + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=418234 + +inotify.7 + mtk + added text describing what happens when the buffer given to + read(2) is too small to return information about the next event, + and noting the behavior change in 2.6.21. + +man-pages.7 + mtk + added text to note that errors list should be in alphabetical order. + +mdoc.7 +mdoc.samples.7 + mtk + added see also reference to groff_mdoc(7). + +unix.7 + mtk + added example section with pointer to bind.2 example. + +ld.so.8 + mtk + simplify text describing --inhibit-rpath. + mtk, after a note by john reiser + describe use of $origin in rpath. + + +==================== changes in man-pages-2.56 ==================== + +released: 2007-06-11 + +global changes +-------------- + +many pages + mtk + removed version numbers in .th lines. + reason: these were only arbitrarily updated, and so impart no + useful information. version information goes into a + versions section nowadays, and the date in the .th line should + be updated to reflect the date of the last (significant) + change to the page. + +typographical or grammatical errors have been corrected in several +places. + + +==================== changes in man-pages-2.57 ==================== + +released: 2007-06-17 + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +samuel thibault + +apologies if i missed anyone! + + +global changes +-------------- + +many pages + mtk + fix section numbers in page cross references. + + +changes to individual pages +--------------------------- + +access.2 + mtk + minor wording fixes. + small clarification of description of 'mode'. + +bind.2 + mtk + small reworking of example program. + +exit_group.2 + mtk + minor wording fixes. + +exit.3 + mtk + added more detail on exit handlers. + minor wording fixes. + +ioctl.2 + mtk + remove see also reference to nonexistent mt.4. + +modify_ldt.2 + samuel thibault / mtk + in linux 2.6, the 'modify_ldt_ldt_s' structure was renamed + 'user_desc'. + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=378668 + mtk + include definition of 'user_desc' structure. + minor rewordings. + +mprotect.2 + mtk + small reworking of example program. + +sigaction.2 + mtk + removed reference to nonexistent sigsend(2). + +a64l.3 + mtk + remove see also reference to nonexistent itoa.3. + +dysize.3 + mtk + removed see also reference to nonexistent time.3. + +encrypt.3 + mtk + removed see also reference to nonexistent fcrypt.3. + +fmemopen.3 + mtk + small reworking of example program. + +fpurge.3 + mtk + remove see also reference to nonexistent fclean.3. + +getutent.3 + mtk + s/ttyname(0)/ttyname(stdin_fileno)/ in program example. + +vcs.4 + mtk + s/exit(1)/exit(exit_failure)/ + +environ.7 + mtk + correct some section numbers in page cross references. + +man-pages.7 + mtk + modify requirements for example programs a little. + +uri.7 + mtk + wrapped long source lines. + + +==================== changes in man-pages-2.58 ==================== + +released: 2007-06-24 + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +marc boyer +mike frysinger + +apologies if i missed anyone! + + +global changes +-------------- + +various pages, as detailed below + mtk + added or updated versions sections. + +killpg.2 +setuid.2 +faccessat.2 +fork.2 +setfsuid.2 +kill.2 +getsid.2 +wait.2 +execve.2 +getpid.2 +setgid.2 +seteuid.2 +setresuid.2 +setfsgid.2 +access.2 +initgroups.3 +euidaccess.3 +tcgetpgrp.3 +path_resolution.7 +capabilities.7 +unix.7 + mtk + add see also link to new credentials.7. + + +new pages +--------- + +credentials.7 + mtk + an overview of linux process identifiers (pids, ppids, + pgids, sids, uids, gids). + + +changes to individual pages +--------------------------- + +bind.2 + mtk + added some comments to example program. + +getxattr.2 + mtk + versions: in kernel since 2.4; glibc support since 2.3. + +listen.2 + mtk + updated discussion of somaxconn limit. + +listxattr.2 + mtk + versions: in kernel since 2.4; glibc support since 2.3. + +posix_fadvise.2 + mtk + versions: glibc support has been provided since version 2.2. + +readahead.2 + mtk + added versions section. + +remap_file_pages.2 + mtk + updated versions section with text on glibc support. + +removexattr.2 + mtk + versions: in kernel since 2.4; glibc support since 2.3. + +semop.2 + mtk + added versions section with info on semtimedop(). + +setxattr.2 + mtk + versions: in kernel since 2.4; glibc support since 2.3. + +dl_iterate_phdr.3 + mtk + versions: supported since glibc 2.2.4. + +getloadavg.3 + mtk + added versions section. + +posix_openpt.3 + mtk + versions: supported since glibc 2.2.1. + +printf.3 + mtk after a suggestion by mike frysinger + add text to the introductory part of description, about the + 'size' argument of snprintf() and vsnprintf(). + +shm_open.3 + mtk + added versions section; rewrote info about linking with -lrt. + +strcat.3 + marc boyer + improve the discussion of strncat(). + +strcpy.3 + marc boyer + improve the discussion of strncpy(). + +proc.5 + mtk + added discussion of /proc/sys/net/core/somaxconn. + + +==================== changes in man-pages-2.59 ==================== + +released: 2007-06-25 + +global changes +-------------- + +manual pages are now standardized on american spelling. see +http://en.wikipedia.org/wiki/american_and_british_english_spelling_differences +for more information on the differences. formerly, different pages (and +sometimes even a single page!) employed american and british spelling +conventions; best to standardize on one spelling, and american english +is the standard in computer science. + +changes to individual pages +--------------------------- + +man-pages.7 + mtk + note that man-pages has now standardized on american spelling + conventions. + +execve.2 +getxattr.2 +listxattr.2 +removexattr.2 +setxattr.2 +signal.2 +syscall.2 +aio_cancel.3 +bindresvport.3 +stdarg.3 +charmap.5 +bootparam.7 +ipv6.7 +man.7 +path_resolution.7 +uri.7 +nscd.8 + mtk + corrected minor spelling/wording mistakes (i.e., changes + independent of fixes for american spelling). + + +==================== changes in man-pages-2.60 ==================== + +released: 2007-06-25 + + +global changes +-------------- + +various pages + mtk + wrapped lines in some files. + +various pages + mtk + change "e.g. " to "e.g., ", or in some cases, "for example, ". + +various pages + mtk + change "i.e. " to i.e., ", or in some cases, "that is, ". + +various pages + mtk + removed authors section. + +typographical or grammatical errors have been corrected in several +places. + + +changes to individual pages +--------------------------- + +vfork.2 + mtk + s/w.r.t/with respect to/ + +man-pages.7 + mtk + strengthened warning against use of authors section. + + +==================== changes in man-pages-2.61 ==================== + +released: 2007-07-01 + + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +alain portal +benno schulenberg +florian ernst +ivana varekova +jeff schroeder +joey (martin) schulze +justin pryzby +loïc minier +michael gehring +serge van den boom +stefan puiu +stepan kasal + +apologies if i missed anyone! + + +global changes +-------------- + +various pages + mtk + substitute `\\0' by '\\0'. + +various pages + mtk + s/`/'/ when the thing being quoted is a character. + +accept.2 +bind.2 +connect.2 +getsockopt.2 +listen.2 +socket.2 +socketpair.2 + mtk after a note by martin (joey) schulze + add notes paragraph noting that isn't required by + posix.1-2001 or linux, but was required on some implementations. + +accept.2 +getsockname.2 +recv.2 +vm86.2 +send.2 +getgrouplist.3 +memmem.3 +nsswitch.conf.5 +putenv.3 +wprintf.3 + mtk + replace form `...' with \fi...\fp where the enclosed string + is a pathname, type name, or argument name. + +a few files + mtk + s/process' /process's/ + +gets.3 +qsort.3 +getaddrinfo.3 +rpc.3 +ungetwc.3 +wcsnrtombs.3 +capabilities.7 + mtk + add section number to page cross references. + +time.1 +bind.2 +pivot_root.2 +sysctl.2 + mtk + reordered .sh sections. + +full.4 +mouse.4 +random.4 +sd.4 + mtk + made config/configuring heading ==> configuration + +time.1 +console_codes.4 +random.4 +sk98lin.4 +charmap.5 +ftpusers.5 +bootparam.7 +charsets.7 +glob.7 +mq_overview.7 +unicode.7 +uri.7 +utf-8.7 + mtk + reformatted headings + + +new pages +--------- + +backtrace.3 + mtk, with input from justin pryzby and stefan puiu + documents backtrace(), backtrace_symbols(), and + backtrace_symbols_fd(). + + +new links +--------- + +backtrace_symbols.3 +backtrace_symbols_fd.3 + mtk + links to backtrace.3. + +__clone.2 + stepan kasal + link to clone.2. + + +changes to individual pages +--------------------------- + +makefile + serge van den boom + fix setting of 'prefix' macro. + +eval.1p + benno schulenberg + fix bad text (concatenated line). + +chdir.2 + mtk + fixed description of eacces error. + added sentence defining "current working directory". + other minor wording changes. + +cfree.3 + mtk + added see also section. + +clone.2 + mtk + s/clone2/__clone2/. + +fdatasync.2 + mtk + minor wording changes. + +fork.2 + alain portal + fix small wording error. + +gethostid.2 + stefan puiu / mtk + add notes on what happens if gethostid() can't open /etc/hostid. + +idle.2 + mtk + made notes text into a versions section, since that's what it + really describes. + +ioperm.2 + mtk + minor wording changes. + +intro.2 + mtk + rewrite to reflect the fact that the _syscalln + macros are no longer available. + +io_cancel.2 + mtk + add "link with -laio" to synopsis. + +io_destroy.2 + mtk + add "link with -laio" to synopsis. + +io_getevents.2 + mtk + add "link with -laio" to synopsis. + +io_setup.2 + mtk + add "link with -laio" to synopsis. + +io_submit.2 + ivana varekova + fix include in synopsis. + mtk + add "link with -laio" to synopsis. + +ipc.2 + mtk + add semtimedop() to see also. + note that some architectures don't have ipc(2); instead + real system calls are provided for shmctl(), semctl(), etc. + +killpg.2 + mtk + minor wording changes. + +listen.2 + mtk + added to synopsis. + +sched_setscheduler.2 + mtk + add notes para about permissions required to call + sched_setscheduler() on other systems. + +select.2 + mtk + noted that 'timeout' can also be changed if select() is + interrupted by a signal. + +setup.2 + mtk + remove reference to _syscall0() macro. + +shmop.2 + mtk + changed text for einval error. + +socketcall.2 + mtk + add recvmsg() and sendmsg() to see also. + note that some architectures don't have socketcall(2); instead + real system calls are provided for socket(), bind(), etc. + +swapon.2 + ivana varekova / mtk + update text for eperm error describing the maximum number of + swap files. (from downstream fedora patch.) + +write.2 + mtk + added details about seekable files and file offset. + noted that write() may write less than 'count' bytes, and + gave some examples of why this might occur. + noted what happens if write() is interrupted by a signal. + minor wording changes. + +__setfpucw.3 + mtk + added a conforming to section; other minor edits. + +confstr.3 + mtk + minor rewrites in code example. + +ctime.3 + justin pryzby + make see also refer to timegm.3 + +daemon.3 + mtk + small wording change. + +dl_iterate_phdr.3 + michael gehring + comment was missing closing "*/". + +dlopen.3 + mtk + formatting changes, and minor rewordings. + mtk, after a note by serge van den boom + add a comment explaining the need for the rather + strange cast of the return value of dlsym(). + +fpclassify.3 + mtk + add "isinf" to name section. + +getgrouplist.3 + mtk + minor rewording. + +getline.3 + mtk + minor rewording, and note that '*n* is ignored + if '*lineptr' is null. + +malloc.3 + ivana varekova / mtk + update description of malloc_check_ to include description + for value 3. (from downstream fedora patch.) + +netlink.3 + mtk + added a conforming to section; other minor edits. + +openpty.3 + mtk + minor changes to synopsis. + +program_invocation_name.3 + mtk + shortened page title to invocation_name. + +rtnetlink.3 + mtk + added a conforming to section; other minor edits. + +scanf.3 + florian ernst + fix duplicated word "the". + (really fix http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=412467 !) + +select_tut.3 + mtk + small wording change. + +setnetgrent.3 + mtk + added a conforming to section. + +sigpause.3 + mtk + added a conforming to section. + +strftime.3 + just pryzby + small wording fix. + mtk + note use of "gcc -wno-format-y2k" to avoid the "`%c' yields only + last 2 digits of year in some locales" warning. + +strstr.3 + mtk + add "strcasestr" to name section. + +syslog.3 + mtk + small wording change. + + +termios.3 + mtk + reformat synopsis. + added a conforming to section. + +timegm.3 + mtk + small wording changes. + +ulimit.3 + mtk + remove erroneous text saying that glibc does not provide + ; it does. + +initrd.4 + mtk + various reformattings. + +core.5 + mtk + added a sentence noting why core dumps named "core.pid" were useful + with linuxthreads. + +bootparam.7 + mtk + fix capitalization in .ss headings. + +epoll.7 + mtk + language clean ups. + +feature_test_macros.7 + mtk + added see also section. + +mq_overview.7 + mtk + reformatted headings; minor rewrites. + +sem_overview.7 + mtk + reformatted headings; minor rewrites. + +socket.7 + loïc minier + document argument type for so_reuseaddr. + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=255881 + +uri.7 + mtk + wrap long line in synopsis. + +ldconfig.8 + mtk + added see also section. + + +==================== changes in man-pages-2.62 ==================== + +released: 2007-07-09 + +this release consists solely of formatting fixes. there are no changes +to content. + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +stepan kasal + +apologies if i missed anyone! + + +global changes +-------------- + +many many pages + mtk + many many formatting fixes. + +man[013]p/* + stepan kasal + add section number to .th line for posix pages in man[013]p. + + +==================== changes in man-pages-2.63 ==================== + +released: 2007-07-16 + + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +arnd bergmann +eduardo m. fleury +ivana varekova +justin pryzby +marc boyer +martin (joey) schulze +martin röhricht +patrick mansfield +pierre habouzit +stepan kasal + +apologies if i missed anyone! + + +global changes +-------------- + +gettimeofday.2 +madvise.2 +msgctl.2 +select.2 +semctl.2 +shmctl.2 +syslog.2 +stat.2 +a64l.3 +printf.3 +termios.3 +xdr.3 +sd.4 + mtk + minor wording changes. + +obsolete.2 +syscall.2 +unimplemented.2 + mtk + added see also reference to syscalls.2. + + +new pages +--------- + +sgetmask.2 + mtk + a real man page for sgetmask(2) and ssetmask(2). + (this page replaces a previous link of the same name, which + linked to signal.2.) + +spu_create.2 + arnd bergmann with additional work by eduardo m. fleury and mtk + document the powerpc spu spu_create() system call. + (originally taken from the kernel source file + documentation/filesystems/spufs.txt.) + +spu_run.2 + arnd bergmann with additional work by eduardo m. fleury and mtk + document the powerpc spu spu_run() system call. + (originally taken from the kernel source file + documentation/filesystems/spufs.txt.) + +spufs.7 + arnd bergmann with additional work by eduardo m. fleury and mtk + document the powerpc spu file system. + (originally taken from the kernel source file + documentation/filesystems/spufs.txt.) + + +removed pages +------------- + +__clone.2 + mtk + this file was created by accident in 2.61, as a copy of clone.2. + (it should have been a link to clone.2.) + +obsolete.2 + mtk + details on this page are covered in syscalls.2 and in + respective syscall man pages (stat.2, uname.2). + +undocumented.2 + mtk + this page is very out of date, and in any case difficult + to maintain. information about undocumented system calls + is maintained in the howtohelp file, and probably in other + places soon. + +killpg.3 + mtk + this rather incomplete page seems unnecessary since there + is a killpg.2. + + +new links +--------- + +chown32.2 +fchown32.2 +getegid32.2 +geteuid32.2 +getgid32.2 +getgroups32.2 +getresgid32.2 +getresuid32.2 +getuid32.2 +lchown32.2 +setfsgid32.2 +setfsuid32.2 +setgid32.2 +setgroups32.2 +setregid32.2 +setresgid32.2 +setresuid32.2 +setreuid32.2 +setuid32.2 + mtk + added as link to corresponding page without "32". + +fcntl64.2 +fstat64.2 +fstatat64.2 +fstatfs64.2 +ftruncate64.2 +getdents64.2 +lstat64.2 +pread64.2 +pwrite64.2 +sendfile64.2 +stat64.2 +statfs64.2 +truncate64.2 + mtk + added as link to corresponding page without "64". + +__clone2.2 +clone2.2 + mtk + links to clone.2. + +ugetrlimit.2 + mtk + link to getrlimit.2. + +mq_notify.2 +mq_open.2 +mq_timedreceive.2 +mq_timedsend.2 +mq_unlink.2 + mtk + added as links to corresponding section 3 pages. + +fadvise64.2 +fadvise64_64.2 + mtk + links to posix_fadvise.2. + +rt_sigaction.2 +rt_sigpending.2 +rt_sigprocmask.2 +rt_sigtimedwait.2 + mtk + added as link to corresponding page without "rt_" prefix. + +rt_sigqueueinfo.2 + mtk + link to sigqueue.2. + +madvise1.2 +tuxcall.2 +vserver.2 + mtk / ivana varekova + link to unimplemented.2. + + +changes to individual pages +--------------------------- + +access.2 + mtk + fairly substantial rewrites of various parts, + and a few additions. + +chmod.2 + mtk + update synopsis to reflect the fact that fchmod(2) needs + either "#define _xopen_source 500" or "#define _bsd_source". + +chown.2 + mtk + update synopsis to reflect the fact that fchmod(2) and lchown(2) + need either "#define _xopen_source 500" or "#define _bsd_source". + added an example program. + +killpg.2 + mtk + note that killpg() is actually a library function on linux. + +mmap.2 + mtk + added note that glibc mmap() wrapper nowadays invokes mmap2(). + +mmap2.2 + ivana varekova / mtk + on most platforms the unit for 'offset' is 4096 bytes, not + the system page size. + mtk + rewrote notes to note that glibc mmap() wrapper nowadays + invokes this system call. + mtk + added an example program. + +oldfstat.2 +oldlstat.2 +oldstat.2 + mtk + changed link to point to stat.2 (instead of obsolete.2). + +olduname.2 +oldolduname.2 + mtk + changed link to point to uname.2 (instead of obsolete.2). + +sched_setaffinity.2 + martin röhricht + added _gnu_source to synopsis. + +semctl.2 + mtk + remove reference discussion of ipc(2), since none of the + other system v ipc pages mention ipc(2). + +semop.2 + mtk + add an example code segment. + +shmctl.2 + mtk + add svipc(7) to see also list. + +sigaction.2 + mtk + reformatted tables as lists; other minor reformattings and + wording changes. + +sigqueue.2 + mtk + added info on rt_sigqueueinfo(2). + +sigwaitinfo.2 + mtk + noted that sigwaitinfo() is a library function implemented on + top of sigtimedwait(). + +ssetmask.2 + mtk + make this link point to new sgetmask.2 instead of signal.2. + +stat.2 + mtk + add notes on the different system call interfaces that + have appeared over time. + +syscalls.2 + mtk + a fairly substantial rewrite of this page, + bringing it up to date with the current + kernel version, and listing all system calls + in tabular form. + +uname.2 + mtk + add notes on the different system call interfaces that + have appeared over time. + +unimplemented.2 + mtk + add vserver, madvise1 to name line. + removed see also reference to obsolete.2. + ivana varekova + add tuxcall to name line. + +mktemp.3 + patrick mansfield + fix description of return value. + +strcat.3 + marc boyer + minor fix to example program. + +undocumented.3 + mtk + add section numbers to function names; remove some functions + since they are documented. + +proc.5 + mtk + update/correct text on /proc/malloc. + mtk, after a note by pierre habouzit, and a few comments by justin pryzby + update description of /proc/pid/stat to match 2.6.21. + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=417933 + +inotify.7 + mtk + in_dont_follow and in_onlydir are only available from 2.6.15. + +signal.7 + stepan kasal / mtk + note sigrtmin value depends on glibc. + mtk + various rewrites and additions to the text in real-time signals. + add see also reference to sgetmask.2. + +svipc.7 + mtk + add ipc(2) to see also. + + +==================== changes in man-pages-2.64 ==================== + +released: 2007-07-27 + + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +aleksandr koltsoff +andries brouwer +justin pryzby + +apologies if i missed anyone! + + +global changes +-------------- + +infinity.3 +_exit.2 +a64l.3 +abs.3 +acct.2 +acosh.3 +addseverity.3 +adjtime.3 +asinh.3 +atanh.3 +atoi.3 +brk.2 +cbrt.3 +cfree.3 +chdir.2 +chmod.2 +chown.2 +clearenv.3 +clock_getres.3 +clone.2 +confstr.3 +copysign.3 +ctermid.3 +ctime.3 +daemon.3 +dirfd.3 +div.3 +drand48.3 +drand48_r.3 +dysize.3 +ecvt.3 +ecvt_r.3 +erf.3 +euidaccess.3 +exp2.3 +expm1.3 +fdatasync.2 +ferror.3 +fexecve.3 +fgetgrent.3 +fgetpwent.3 +finite.3 +flockfile.3 +fopen.3 +fpclassify.3 +fsync.2 +futimes.3 +fwide.3 +gamma.3 +gcvt.3 +getcwd.3 +getdate.3 +getdirentries.3 +getdomainname.2 +getdtablesize.2 +getgrent.3 +getgrent_r.3 +getgrouplist.3 +getgroups.2 +gethostbyname.3 +gethostid.2 +gethostname.2 +getlogin.3 +getmntent.3 +getpagesize.2 +getpw.3 +getpwent.3 +getpwent_r.3 +getpwnam.3 +getsid.2 +getspnam.3 +gettimeofday.2 +getumask.3 +getusershell.3 +gsignal.3 +hypot.3 +inet.3 +initgroups.3 +insque.3 +isalpha.3 +iswblank.3 +j0.3 +kill.2 +killpg.2 +lgamma.3 +lockf.3 +log1p.3 +log2.3 +logb.3 +longjmp.3 +lrint.3 +lround.3 +madvise.2 +mbsnrtowcs.3 +memfrob.3 +mincore.2 +mkdtemp.3 +mknod.2 +mkstemp.3 +mktemp.3 +nan.3 +nanosleep.2 +nextafter.3 +nice.2 +on_exit.3 +perror.3 +posix_memalign.3 +posix_openpt.3 +printf.3 +profil.3 +psignal.3 +putenv.3 +putpwent.3 +qecvt.3 +rand.3 +random.3 +rcmd.3 +readahead.2 +readlink.2 +realpath.3 +remainder.3 +remquo.3 +rexec.3 +rint.3 +round.3 +rpmatch.3 +scalb.3 +scandir.3 +scanf.3 +seekdir.3 +select.2 +sem_wait.3 +semop.2 +setbuf.3 +setenv.3 +seteuid.2 +setjmp.3 +setnetgrent.3 +setpgid.2 +setresuid.2 +setreuid.2 +sigaltstack.2 +siginterrupt.3 +significand.3 +sigqueue.2 +sigvec.3 +sigwaitinfo.2 +sockatmark.3 +stat.2 +stime.2 +strdup.3 +strerror.3 +strsep.3 +strtod.3 +strtok.3 +strtol.3 +strtoul.3 +symlink.2 +sync.2 +syscall.2 +syslog.3 +tcgetsid.3 +telldir.3 +tempnam.3 +termios.3 +tgamma.3 +timegm.3 +toascii.3 +trunc.3 +truncate.2 +ttyslot.3 +tzset.3 +ualarm.3 +unlocked_stdio.3 +unshare.2 +usleep.3 +vfork.2 +vhangup.2 +wait.2 +wait4.2 +wcscasecmp.3 +wcsncasecmp.3 +wcsnlen.3 +wcsnrtombs.3 +wcswidth.3 +wordexp.3 +wprintf.3 + mtk + added/updated feature test macro requirements for + glibc; see feature_test_macros.7 for details. + +changes to individual pages +--------------------------- + +mq_notify.2 +mq_open.2 +mq_timedreceive.2 +mq_timedsend.2 +mq_unlink.2 + mtk + fix broken link + +setpgid.2 + mtk + fairly substantial changes and corrections, including adding + coverage of all of the interfaces that get/set pgids. + +syscalls.2 + mtk / aeb + various rewordings; clear up some imprecisions. + +lgamma.3 + mtk + added 'signgam' to synopsis and name line. + +strerror.3 + mtk + note that the xpg version is provided since glibc 2.3.4. + the page formerly said that the gnu-specific version + is provided by default. that certainly isn't true + nowadays, since _posix_c_source is set to 200112l by + default, so that the xsi-compliant version is supplied + by default. + +man-pages.7 + mtk + added note pointing to feature_test_macros.7 for a description + of how feature test macro requirements should be specified in + manual pages. various other minor fixes and changes. + +feature_test_macros.7 + mtk + added note about how feature test macros are specified + in manual pages. + many other corrections, improvements, additions, and + details about differences across glibc versions. + + +==================== changes in man-pages-2.65 ==================== + +released: 2007-09-17 + + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +aleksandr koltsoff +andi kleen +anton blanchard +ari entlich +carsten emde +françois diakhate +geoff clare +jon burgess +julien cristau +lee schermerhorn +mats wichmann +maxime bizon +maxime vaudequin +michael prokop +mike frysinger +nicolas françois +nicolas george +paul brook +reuben thomas +sam varshavchik +samuel thibault +thomas huriaux +tolga dalman +ulrich drepper +vincent lefevre + +apologies if i missed anyone! + + +global changes +-------------- + +typographical or grammatical errors have been corrected in several +places. + +various pages + mtk + use 'glibc' consistently to refer to gnu c library. + +various pages + mtk + order errors under errors alphabetically. + +various pages + nicolas françois + spelling and formatting fixes, as per + http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=439560 + +intro.2 +select.2 +fmtmsg.3 +getgrent_r.3 +envz_add.3 +rtime.3 +strptime.3 +wordexp.3 + maxime vaudequin + add "#include " (to declare exit(3)) to example program. + + +new pages +--------- + +timeradd.3 + mtk + description of timeradd(), timersub(), timerclear(), + timerisset(), timercmp() macros for operating on + struct timeval. + + +removed pages +------------- + +fdatasync.2 + mtk + somehow, over time, material on fdatasync(2) crept into + fsync.2, and fdatasync also got added to the name section + of fsync.2. all of the material in fdatasync.2 that was + not already in fsync.2 has now been moved there, and + the former page has been removed. + in place of the content there, is now a link to fsync.2. + + +new links +--------- + +clock_getres.2 +clock_gettime.2 +clock_settime.2 + mtk + link to man3/clock_getres.3. + +fdatasync.2 + mtk + link to fsync.2. + +fdopendir.3 + mtk + link to opendir.3. + +gethostbyaddr_r.3 + mats wichmann + link to gethostbyaddr.3. + +timerclear.3 +timercmp.3 +timerisset.3 +timersub.3 + mtk + links to new timeradd.3. + + +changes to individual pages +--------------------------- + +makefile + mike frysinger + make the install target of man-pages respect the standard + "destdir" variable as well as check the exit status of the + install command so errors aren't ignored. + +get_mempolicy.2 + lee schermerhorn + changed the "policy" parameter to "mode" through out the + descriptions in an attempt to promote the concept that the memory + policy is a tuple consisting of a mode and optional set of nodes. + + added requirement to link '-lnuma' to synopsis + + rewrite portions of description for clarification. + + added all errors currently returned by sys call. + + removed cautionary note that use of mpol_f_node|mpol_f_addr + is not supported. this is no longer true. + + added mmap(2) to see also list. + +getitimer.2 + mtk + since kernel 2.6.22, linux setitimer() now conforms to posix.1, + giving an einval error for a non-canonical tv_usec value. + +gettimeofday.2 + mtk + replace discussion of timer* macros with a pointer + to new page timeradd.3. + +ioctl_list.2 + nicolas george + fixed argument type for blkgetsize. + +mbind.2 + lee schermerhorn + + changed the "policy" parameter to "mode" throughout the + descriptions in an attempt to promote the concept that the memory + policy is a tuple consisting of a mode and optional set of nodes. + + rewrite portions of description for clarification. + + clarify interaction of policy with mmap()'d files and shared + memory regions, including shm_huge regions. + + defined how "empty set of nodes" specified and what this + means for mpol_preferred. + + mention what happens if local/target node contains no + free memory. + + clarify semantics of multiple nodes to bind policy. + note: subject to change. we'll fix the man pages when/if + this happens. + + added all errors currently returned by sys call. + + added mmap(2), shmget(2), shmat(2) to see also list. + +mmap.2 +mprotect.2 + françois diakhate + add text noting that prot_write may (and on x86 does) + imply prot_read. + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=441387 + +nfsservctl.2 + aleksandr koltsoff + fix prototype. + +oldfstat.2 +oldlstat.2 +oldstat.2 + mtk + fix broken link + +prctl.2 + mtk + update arches/kernel versions for pr_set_unalaign / pr_get_unalign. + +readahead.2 + mtk + removed see also reference to nonexistent fadvise.2. + +reboot.2 + mtk + place synopsis comments inside c comments (/* ... */). + +sched_setaffinity.2 + samuel thibault + note what thread is affected if 'pid' is specified + as 0, or as the value returned by getpid(). + +sched_setscheduler.2 + carsten emde + add text on real-time features of mainline linux kernel. + +select_tut.2 + mtk + sync synopsis with select.2 + +set_mempolicy.2 + lee schermerhorn + + changed the "policy" parameter to "mode" throughout the + descriptions in an attempt to promote the concept that the memory + policy is a tuple consisting of a mode and optional set of nodes. + + added requirement to link '-lnuma' to synopsis + + rewrite portions of description for clarification. + + clarify interaction of policy with mmap()'d files. + + defined how "empty set of nodes" specified and what this + means for mpol_preferred. + + mention what happens if local/target node contains no + free memory. + + clarify semantics of multiple nodes to bind policy. + note: subject to change. we'll fix the man pages when/if + this happens. + + added all errors currently returned by sys call. + + added mmap(2) to see also list. + +sigaction.2 + mtk + s/si_sign/si_errno/ in statement about which field is unused. + ari entlich + s/sigill/sigchld/ for paragraph describing sigchld. + +stat.2 + mtk + improve text describing underlying system calls. + +swapon.2 + michael prokop + einval also occurs if target path is on tmpfs or similar. + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=435885 + +sync.2 + mtk + incorporated material from now deleted fdatasync.2. + +syscall.2 + mtk + small fix in example program. + +uname.2 + mtk + improve text describing underlying system calls. + +utime.2 + vincent lefevre / mtk + clarify utimes() behaviour when 'times' is null. + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=431480 + mtk + other minor clarifications of description of utimes(). + +copysign.3 + vincent lefevre + s/sign/sign bit/ to remove ambiguity in description. + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=435415 + +euidaccess.3 + mtk + changed notes to versions. + +ffsl.3 + mtk + add ffsl and ffsll to name line. + +fts.3 + mtk + removed statement that fts functions are expected to appear + soon in posix; it's years old and has not yet come to pass. + +ftw.3 + mtk / geoff clare + fixes/improvements for example program. + +getdate.3 + mtk + add getdate_r to name section. + +getaddrinfo.3 + mtk / geoff clare + fixes/improvements for example program. + +gethostbyaddr.3 + mats wichmann + add documentation for gethostbyaddr_r(). + plus a few other small fixes. + +gethostbyname.3 + mtk + add gethostbyname2, gethostbyname2_r, gethostbyname_r, + gethostent_r to name line. + +getmntent.3 + mtk + fix misnamed function references. + +getopt.3 + jon burgess + fix small error in example program. + +getrpcent.3 + mtk + add setrpcent and endrpcent to name line. + +gsignal.3 + aleksandr koltsoff + fix gsignal() prototype. + +hsearch.3 + mtk + add hcreate_r, hdestroy_r, hsearch_r to name line. + +inet.3 + maxime bizon + correct definition of "struct in_addr". + +isatty.3 + mtk + minor wording fix. + +isgreater.3 + mtk + add islessequal to name line. + +lgamma.3 + vincent lefevre + fix conforming to section. + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=417592 + +log1p.3 + mtk + add log1pf and log1pl to name line. + +longjmp.3 + paul brook / mtk + after a call to longjmp(), the values of modified, non-volatile + variables in the function that called setjmp() are unspecified. + +makecontext.3 + aleksandr koltsoff + fix makecontext() prototype. + +malloc.3 + mtk / tolga dalman + explain what happens for malloc(0), or calloc() where one of the + arguments is 0. + mtk + added notes on malloc()'s use of sbrk() and mmap(). + mtk + add mmap(2), alloca(3) to see also. + +mq_close.3 +mq_getattr.3 +mq_notify.3 +mq_open.3 +mq_receive.3 +mq_send.3 +mq_unlink.3 + mtk + add "link with -lrt." to synopsis. + +opendir.3 + ulrich drepper; some edits and additional text by mtk + document fdopendir(). + +readdir.3 + mtk, after a note by andi kleen + document dt_* constants for d_type. + ulrich drepper / mtk + rework discussion of non-standard structure fields. + +sem_wait.3 + mtk + minor improvements to example program. + +syslog.3 + mtk + add vsyslog to name section. + +termios.3 + nicolas françois + fix xcase feature test macro description. + +wcsspn.3 + aleksandr koltsoff + add return type to prototype. + +proc.5 + mtk + improve description of num_threads field under /proc/pid/stat. + maxime vaudequin + fix path error (s%proc/sys%proc/sys/kernel%) in mentions of + /proc/sys/ostype, /proc/sys/osrelease and proc/sys/version. + maxime vaudequin + i noticed things to correct and to clarify in subsection + "/proc/filesystems" of proc.5: + - clarify filesystems listing: not only fs compiled + into the kernel, also fs kernel modules currently loaded + - add a reference to fs(5) + - add an explanation for fs marked with "nodev" + - s/mount(1)/mount(8)/, also corrected in section "see also" + - clarify usage by mount: the current wording may lead to + think /proc/filesystems is always used by mount when no fs + is specified. so, usage of "may" which imho is more + appropriate + additional explanations + in mount(8) we can see: + + if no -t option is given, or if the auto type is + specified, mount will try to guess the desired type. + if mount was compiled with the blkid library, the + guessing is done by this library. otherwise, mount + guesses itself by probing the superblock; if that + does not turn up anything that looks familiar, + mount will try to read the file /etc/filesystems, + or, if that does not exist, /proc/filesystems. + all of the filesystem types listed there will be + tried, except for those that are labeled "nodev" + (e.g., devpts, proc and nfs). if /etc/filesystems + ends in a line with a single * only, mount will + read /proc/filesystems afterwards. + samuel thibault + since linux 2.6.11, /proc/stat has an eighth value for cpu + lines: stolen time, which is the time spent in other operating + systems when running in a virtualized environment. + +arp.7 + updated bugs text referring to jiffies; refer to time.7 instead. + +credentials.7 + mtk + add words to note that file system id is linux specific. + +hier.7 + maxime vaudequin + this is some corrections for hier.7: + - missing period for /media and /mnt + - /mnt description is not totally correct, it is true for some + distributions but in others /mnt is used as a temporary fs + mount point, as it is specified by fhs: + http://www.pathname.com/fhs/pub/fhs-2.3.html#mntmountpointforatemporarilymount + - s/x-windows/x-window/ (3 occurrences) + - section "see also": s/mount(1)/mount(8)/ + +man-pages.7 +man.7 +mdoc.7 +mdoc.samples.7 + mtk / nicolas françois + nowadays tmac.xxx are called xxx.tmac. + +pthreads.7 + mtk + update text about modern threading implementations + (nptl vs linuxthreads). + +socket.7 + mtk, after a note by andi kleen + clarify that so_sndtimeo and so_rcvtimeo only have effect for + socket i/o calls; not for multiplexing system calls like + select() and poll(). + +time.7 + mtk + add see also reference to new timeradd.3. + + +==================== changes in man-pages-2.66 ==================== + +released: 2007-10-01 + + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +amit k. arora +david chinner +fredrik noring +mats wichmann +maxime vaudequin +ollie wild +ulrich drepper + +apologies if i missed anyone! + + +global changes +-------------- + +typographical or grammatical errors have been corrected in several +places. + + +new pages +--------- + +fallocate.2 + david chinner, with some input from amit amora and mtk + describes the fallocate() system call, new in 2.6.23. + + +changes to individual pages +--------------------------- + +close.2 + fredrik noring + add text cautioning about use of close() in + multithreaded programs. + +execve.2 + ollie wild / mtk + add text describing limit on total size of argv + envp, + and changes that occurred with 2.6.23. + mtk + add getopt(3) to see also list. + +open.2 + mtk, acked by ulrich drepper + added description of o_cloexec (new in 2.6.23) + other + minor fixes for o_direct. + +recv.2 + mtk + added description of msg_cmsg_cloexec (new in 2.6.23). + +sysctl.2 + mtk + strengthened the warning against using this system call + and note that it may disappear in a future kernel version. + +rpc.3 + mats wichmann + fix type definition for 'protocol' in prototypes of pmap_set() + and pmap_getport(). + + +==================== changes in man-pages-2.67 ==================== + +released: 2007-10-08 + + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +andi kleen +andrew josey +maxime vaudequin + +apologies if i missed anyone! + + +global changes +-------------- + +*.1p +*.3p + mtk, after a note by andi kleen and consultation with andrew josey. + add a prolog section: + this manual page is part of the posix programmer's manual. + the linux implementation of this interface may differ + (consult the corresponding linux manual page for details + of linux behavior), or the interface may not be implemented + on linux. + +*.0p +*.1p +*.3p + mtk + some formatting fixes, mostly to get rid of unwanted + spaces before "," in formatted output. + +* +*/* + mtk + change all occurrences of my email address in man-pages source + to my new gmail address. + +many many pages + maxime vaudequin + i noticed useless use of macros with alternating formatting + (".ir" instead ".i" which suffices, ".br" instead ".b", etc.) + because there is only one element. for example in ldconfig.8: + + -.br /sbin/ldconfig + +.b /sbin/ldconfig + + this is not very important, it only makes the sources more tidy. + to find these i used: + + egrep '^\.(b[ri]|r[ib]|i[rb]) ([^ ]+|\"[^\"]\+\")$' + + and if you want to make these changes, you can use: + + sed 's/^\(\.[bri]\)[bri]\( \([^ ]\+\|\"[^\"]\+\"\)\)$/\1\2/g' + + +==================== changes in man-pages-2.68 ==================== + +released: 2007-11-19 + + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +a. costa +andrew mcdonald +geoff clare +heikki orsila +hyokyong kim +ivana varekova +justin pryzby +maxime vaudequin +mike frysinger +nicolas françois +pádraig brady +sam varshavchik +timo juhani lindfors +ulrich drepper + +apologies if i missed anyone! + + +global changes +-------------- + +faccessat.2 +fchmodat.2 +fchownat.2 +fstatat.2 +futimesat.2 +linkat.2 +mkdirat.2 +mknodat.2 +readlinkat.2 +renameat.2 +symlinkat.2 +mkfifoat.3 + mtk, after http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=445436 + by timo juhani lindfors + added to synopsis. + +typographical or grammatical errors have been corrected in several places. + + +new pages +--------- + +_syscall.2 + mtk + created as a new page, by taking the content specific to + the _syscall() macros from intro(2). + + +changes to individual pages +--------------------------- + +readme + mtk + brought up to date. + +man-pages-*-announce + mtk + brought the info in here up to date. + +intro.1 + mtk + added intro paragraph about section, plus a paragraph + about exit status values. + move "user intro" text to notes. + +get_mempolicy.2 + mtk + reorder errors sections alphabetically + +intro.2 + mtk + pretty much a complete rewrite, covering some additional topics. + moved _syscalln() material to new _syscall(2) page. + +mbind.2 + mtk + reorder errors sections alphabetically + +mmap.2 + maxime vaudequin + fix syntax error in example program. + +prctl.2 + mtk + linux 2.6.22 added support on alpha for pr_set_unalign. + +ptrace.2 + nicolas françois / mtk + s/ptrace_pokeusr/ptrace_pokeuser/ + s/ptrace_peekusr/ptrace_peekuser/ + +read.2 + mtk / geoff clare + add text describing timerfd einval error for read(2). + +set_mempolicy.2 + mtk + reorder errors sections alphabetically + +syscall.2 + mtk + added _syscall(2) and intro(2) to see also section. + +syscalls.2 + mtk + added fallocate(2); removed timerfd(2). + +sysinfo.2 + mtk + removed reference to example in intro(2). + +dlopen.3 + mtk + added "link with -ldl." to synopsis. + +getaddrinfo.3 + ulrich drepper / mtk + remove references to getipnodebyname.3 and getipnodebyaddr.3. + +gethostbyname.3 + mtk / ulrich drepper + remove see also references to getipnodebyname.3 and + getipnodebyaddr.3. + + pádraig brady / mtk / ulrich drepper + point out that the functions described on this page + are made obsolete by getaddrinfo(3) and getnameinfo(3). + +getipnodebyname.3 + mtk + clarify that glibc does not implement these functions. + +glob.3 + ulrich drepper / mtk + fix description of glob_onlydir. + mtk + added description of glob_tilde_nomatch. + expanded the description of various flags. + various wording fixes.. + +intro.3 + mtk + pretty much a complete rewrite, covering some additional topics. + +posix_fallocate.3 + mtk + add see also referring to fallocate.2. + +rpc.3 + sam varshavchik + add some arg declarations to prototypes; fix typos. + +setbuf.3 + mike frysinger + fix text in bugs section. + +sigset.3 + mtk + the sigset() bugs were fixed in glibc 2.5. + see http://sourceware.org/bugzilla/show_bug.cgi?id=1951 + +intro.4 + mtk + minor rewrites. + +st.4 + maxime vaudequin + various small corrections, formattings and modifications. + +elf.5 + mike frysinger + document: + - new p_flag: pt_gnu_stack + - new sections: .gnu.version .gnu.version_d .gnu.version_r + .note.gnu-stack + - new structures: elfn_verdef elfn_verdaux elfn_verneed + elfn_vernaux + +intro.5 + mtk + minor rewrites. + +proc.5 + ivana varekova / mtk + add text noting that since kernel 2.6.16, /proc/slabinfo is + only available if config_slab is enabled. + maxime vaudequin + update description of /proc/pci. + maxime vaudequin + give italic formatting to file names in proc.5. + mtk + the display type of the /proc/pid/stat fields changed + %lu to %u in linux 2.6.22: + flags + rt_priority + policy + +slabinfo.5 + ivana varekova / mtk + add text noting that since kernel 2.6.16, /proc/slabinfo is + only available if config_slab is enabled. + +intro.6 + mtk + minor rewrites. + +bootparam.7 + maxime vaudequin + update references to files in kernel "documentation" directory. + +intro.7 + mtk + minor rewrites. + +ipv6.7 + andrew mcdonald + fix description of ipv6_router_alert option. + +standards.7 + mtk + note online location of c99 standard. + +intro.8 + mtk + some rewrites, plus new paragraph on exit status values. + + +==================== changes in man-pages-2.69 ==================== + +released: 2007-12-03 + + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +adam borowski +alain portal +andries e. brouwer +j. bruce fields +david härdeman +jeremy kerr +luke browning +mats wichmann +maxime vaudequin +mike frysinger +reuben thomas +sam varshavchik + +apologies if i missed anyone! + + +global changes +-------------- + +*.[013]p + mtk + many whitespace clean-ups in formatted output. + +mprotect.2 +bind.2 +mq_notify.3 +makecontext.3 +fmemopen.3 + david härdeman / mtk + rename error handling function in example program + (s/die/handle_error/). + +typographical or grammatical errors have been corrected in several places. + + +removed pages +------------- + +howtohelp +maintaining + mtk + the content of these files is now available in html format. + +new links +--------- + +cfsetspeed.3 + mtk + link to termios.3. + + +changes to individual pages +--------------------------- + +time.1 + alain portal + added "linux user's manual" to .th line. + +_syscall.2 + aeb / mtk + remove outdated text about pointer blocks for syscalls that have + more than 5 arguments. + +fcntl.2 + j. bruce fields + add warning that mandatory locking is unreliable. + j. bruce fields + clarify details in description of file leases. + j. bruce fields / mtk + minor wording edits. + j. bruce fields + add f_getlease under return value. + +mmap.2 + mtk + handle errors using a custom handle_error() macro. + +sched_setscheduler.2 + mats wichmann + add bugs text noting that the return value from linux + sched_setschuler() does not conform to posix. + +spu_create.2 + jeremy kerr + various updates and improvements. + luke browning + refinement of text describing a "gang". + mtk + minor edits. + +spu_run.2 + jeremy kerr + various updates and improvements. + mtk + minor edits. + +err.3 + mtk + remove history section. + +fopen.3 + mike frysinger + document 'e' (close-on-exec) option, new in glibc 2.7. + +getloadavg.3 + alain portal / mtk + remove history section. + +printf.3 + andries e. brouwer / mtk + fix the discussion of stdarg macros in the description of + vprintf() description. + +sem_wait.3 + mtk + handle errors using a custom handle_error() macro. + +sigsetops.3 + mats wichmann + note that sigset_t objects must be initialized + with sigemptyset() or sigfillset() before the other + macros are employed. + +termios.3 + mtk, after a note by alain portal + added cfsetspeed() to synopsis. added text under conforming to + noting that cfsetspeed() is bsd specific. + +ttyslot.3 + alain portal + various references to "getty" were changed to "mingetty", since + that is the manual page more likely to be found on current + systems. (completes changes that were made in man-pages-2.44.) + +initrd.4 + mtk, after a note by alain portal + move "configuration" section to top of page (like other + section 4 pages) and make it a .sh section. + +full.4 + mtk + re-ordered configuration section to go before description. + +sk98lin.4 + maxime vaudequin + fix reference to kernel documentation file. + +elf.5 + mtk + renamed history section to notes, and removed bsd specific info. + +proc.5 + maxime vaudequin + mention grub(8) in same sentence as lilo(8). + maxime vaudequin + improve description of /proc/sys/abi and + /proc/sys/kernel/modprobe. + +utmp.5 + alain portal + various references to "getty" were changed to "mingetty", since + that is the manual page more likely to be found on current + systems. (completes changes that were made in man-pages-2.44.) + +iso_8859-2.7 + adam borowski + reverse the 2.68 change applied by mtk in response to + http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=445085 + that replaced "sorbian" with "serbian". + (sorbian is a language of 50000 people in brandenburg.) + +man-pages.7 + mtk + added configuration to list of "standard" section names. + +spufs.7 + jeremy kerr + various updates and improvements. + mtk + minor edits. + +tcp.7 + maxime vaudequin + fix reference to kernel documentation file. + + +==================== changes in man-pages-2.70 ==================== + +released: 2007-12-06 + + +global changes +-------------- + +many pages + mtk + remove section numbers for page references where the + reference refers to the page itself. (this stops man2html + producing links from a page back to itself.) + +typographical or grammatical errors have been corrected in several places. + + +changes to individual pages +--------------------------- + +get_mempolicy.2 + mtk + add conforming to section. + +io_getevents.2 + mtk + remove redundant see also entry. + +mbind.2 + mtk + add conforming to section. + +msgop.2 + mtk + remove redundant see also entries. + +sigprocmask.2 + mtk + remove redundant see also entry. + +splice.2 + mtk + remove redundant see also entry. + add see also referring to vmsplice(2). + +csin.3 + mtk + remove redundant see also entry. + add see also referring to ccos(3). + +gethostbyname.3 + mtk + add gethostbyaddr_r to name section. + +rint.3 + mtk + remove redundant see also entry. + +sigsetops.3 + mtk + minor rewording. + +epoll.7 + mtk + minor rewording. + + +==================== changes in man-pages-2.71 ==================== + +released: 2007-12-14 + + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +alain portal +john sigler +josh triplett +mats wichmann +pascal malaise +sam varshavchik + +apologies if i missed anyone! + + +global changes +-------------- + +err.3 +fts.3 +getloadavg.3 +queue.3 +rcmd.3 +rexec.3 +stdin.3 +elf.5 +operator.7 + mtk + replaced the use of mdoc macros on these pages with man + macros. the only pages in man-pages that still use + mdoc macros are mdoc.7 and mdoc.samples.7. + +typographical or grammatical errors have been corrected in several places. + + +deleted pages +------------- + +todo + mtk + this information is now on the website. + + +changes to individual pages +--------------------------- + +changes.old + mtk + reformat various change log entries to use a consistent format. + expand debian bug report numbers to be urls. + other minor tidy-ups. + +fcntl.2 + mtk + document the f_dupfd_cloexec operation, which is + new in kernel 2.6.24. + +listen.2 + josh triplett + fix incorrect path for somaxconn. + +getpw.3 + alain portal + add enoent error to errors. + +sysconf.3 + mats wichmann + add documentation of _sc_nprocessors_conf and _sc_nprocessors_onln. + +tty.4 + john sigler + add tty_ioctl(4) to see also list. + +regex.7 + pascal malaise + separate text on back references from that describing basic regexps, + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=379829. + mtk + remove crufty text about word boundaries. + + +==================== changes in man-pages-2.72 ==================== + +released: 2007-12-14 + + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +alain portal +alex tuninga +bert wesarg +maxime vaudequin +rob weryk +sam varshavchik + +apologies if i missed anyone! + + +global changes +-------------- + +various pages + alain portal / mtk + format include files consistently (".i <.*\.h>"). + +various pages + alain portal / mtk + format pathname in italics (.i). + +dbopen.3 +mpool.3 +recno.3 + alain portal + remove brackets ([]) around error names. + +console.4 +tty.4 +ttys.4 +issue.5 +ttytype.5 +utmp.5 + mtk / maxime vaudequin + some systems have mingetty(8), others have agetty(8), so both + should be mentioned when we are talking about getty-style programs. + + +typographical or grammatical errors have been corrected in several places. + + +renamed pages +------------- + +filesystems.5 + mtk / alain portal + was previously fs.5 + + +new links +--------- + +argz.3 + bert wesarg / mtk + link to argz_add.3. + +envz.3 + bert wesarg / mtk + link to envz_add.3. + +fs.5 + mtk / alain portal + link to filesystems.5. + + +changes to individual pages +--------------------------- + +readahead.2 + rob weryk + fix declaration of 'offset' in synopsis. + +seteuid.2 + mtk + s/setguid/seteuid/ in .th line. + +__setfpucw.3 + mtk + fixed include files references / formatting. + +abort.3 + mtk, after a note by alex tuninga + a fairly significant rewrite to clarify operation of abort(). + +argz_add.3 + bert wesarg / mtk + s/envz/envz_add/ in see also. + +basename.3 + mtk + s/dirname/basename/ in .th line, and swap function names + in name section. + +envz_add.3 + bert wesarg / mtk + s/argz/argz_add/ in see also. + +flockfile.3 + mtk + s/lockfile/flockfile/ in .th line. + +getgrent_r.3 + mtk + s/getgrent/getgrent_r/ in .th line. + +stdio.3 + sam varshavchik + reformat function list at end of page as a proper table. + +ttyslot.3 + maxime vaudequin + revert earlier s/getty/mingetty/. this page talks about + historical behavior, and that means "getty(8)". + +undocumented.3 + mtk + remove reference to "obstack stuff"; it's not clear what + that is about. + +console_ioctl.4 + mtk + s/console_ioctls/console_ioctl/ in .th line. + +proc.5 + mtk + s/fs (5)/filesystems (5)/ + +man-pages.7 + mtk / alain portal + improve discussion of formatting of file names. + + +==================== changes in man-pages-2.73 ==================== + +released: 2007-12-14 + + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +alain portal +pádraig brady +reuben thomas + +apologies if i missed anyone! + + +global changes +-------------- + +various pages + alain portal + formatting fixes. + +typographical or grammatical errors have been corrected in several places. + + +changes to individual pages +--------------------------- + +mknod.2 + mtk, after a report by reuben thomas + clarify use of mkfifo() versus mknod(). + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=455825 + +fgetgrent.3 + mtk + small rewording. + +fgetpwent.3 + mtk + small rewording. + +rcmd.3 + mtk + noted feature test macro requirements. + bugs: noted that iruserok() is not declared in glibc headers. + +filesystems.5 + mtk + added reiserfs, xfs, jfs to list of file systems. + + +==================== changes in man-pages-2.74 ==================== + +released: 2007-12-20 + + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +alain portal +andrew morton +david brown +jeremy kerr +mats wichmann +sam morris +sam varshavchik +samuel thibault + +apologies if i missed anyone! + + +global changes +-------------- + +various pages + alain portal + formatting fixes. + +various pages + mtk / alain portal + s/``...''/"..."/ + +various pages + mtk + s/epoch/epoch/ + +various pages + mtk + make the standard indent for code samples, shell session + logs, etc. to be ".in +4n". + +typographical or grammatical errors have been corrected in several places. + + +changes to individual pages +--------------------------- + +_syscall.2 + mtk + nowadays there is _syscall6() also. + +chroot.2 + mtk + various minor formatting changes. + +epoll_wait.2 + mtk + fix types in structs. + formatting fixes. + +mount.2 + mtk, after a note by sam morris + clarify that ms_nodiratime provides a subset of the + functionality provided by ms_noatime. + +sched_setaffinity.2 + mtk + minor rearrangement of text. + +select_tut.2 + mtk + fix (my) typos in argument names. + formatting fixes. + +spu_create.2 + jeremy kerr + we can use context fds for the dirfd argument to the *at() syscalls. + +times.2 + mtk, after a note from david brown and andrew morton + http://marc.info/?l=linux-kernel&m=119447727031225&w=2 + rework the text describing the return value to be closer + to the requirements of posix.1; move linux details + to notes and add a warning not to rely on those details. + add a warning about the -1 to -4095 bug which results + in a 41 second window where the glibc wrapper will wrongly + return -1 indicating an error. + mtk + remove cruft hz text. + clarify text describing return value of clock(3). + +getw.3 + mats wichmann + conforming to: getw() and putw() were in susv2, but are not + in posix.1-2001. + +hash.3 + mtk / alain portal + minor rewordings + formatting fixes. + +st.4 + alain portal / mtk + many formatting fixes. + mtk + place errors in alphabetical order. + +vcs.4 + samuel thibault + document vt_gethifontmask (new in 2.6.18) and add to example program; + attribute/text characters are in the host byte order. + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=456437 + mtk + minor edits. + +bootparam.7 + alain portal + formatting fixes. + +inotify.7 + mtk + minor heading changes and reformattings. + +man-pages.7 + mtk + note that code segments, structure definitions, shell session + logs, should be indented by 4 spaces. + +spufs.7 + jeremy kerr + add a little information about the differences to mbox. + + +==================== changes in man-pages-2.75 ==================== + +released: 2008-01-08 + + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +alain portal +andi kleen +andreas henriksson +jeremy kerr +justin pryzby +phil endecott +sam varshavchik +thomas huriaux +timo sirainen +trond myklebust + +apologies if i missed anyone! + + +global changes +-------------- + +various pages + mtk + (grammatical) hyphenation was fixed in many places. + +epoll_wait.2 +mbind.2 +spu_run.2 +ecvt.3 +fmtmsg.3 +getnameinfo.3 +rtc.4 +proc.5 +charsets.7 +ip.7 +ipv6.7 +raw.7 +uri.7 + justin pryzby / mtk + fix incorrect usage of "a" and "an" before following vowel / + consonant, by reviewing the output of the following scripts: + + for a in $(wc */*.? | awk '$1 > 10 {print $4}' | gv total); do + echo $a + manwidth=4000 man -l $a 2>/dev/null | + egrep '(^| )an [^aeiou][a-z]' + done | less + + for a in $(wc */*.? | awk '$1 > 10 {print $4}' | gv total); do + echo $a + manwidth=4000 man -l $a 2>/dev/null | + egrep '(^| )a [aeiou][a-z]' + done| less + +err.3 +fts.3 +queue.3 +rcmd.3 +rexec.3 +stdin.3 +elf.5 + mtk, after a note by alain portal + improve macros used in 2.71 to convert from "mdoc" to "man". + +_exit.2 +chroot.2 +getgid.2 +getpid.2 +getrusage.2 +getsid.2 +gettid.2 +getuid.2 +iopl.2 +kill.2 +personality.2 +pivot_root.2 +ptrace.2 +sched_setparam.2 +sched_setscheduler.2 +sched_yield.2 +seteuid.2 +setgid.2 +setpgid.2 +setresuid.2 +setreuid.2 +setuid.2 +unlink.2 +wait.2 +openpty.3 +raise.3 +setlogmask.3 +sleep.3 +ttyslot.3 +ulimit.3 +tty.4 +tty_ioctl.4 +path_resolution.7 + mtk + s/current process/calling process/ + +cacheflush.2 +clone.2 +fcntl.2 +getitimer.2 +getrlimit.2 +mmap.2 +mprotect.2 +times.2 +adjtime.3 +byteorder.3 +inet.3 +offsetof.3 +rtc.4 +icmp.7 +pipe.7 +time.7 + mtk + s/x86/i386/ since that is the name used in 'arch' directories + in the kernel source, and previously both i386 and x86 were both + used in man pages; also nowadays 'x86' is somewhat ambiguous, + since it is the name of the 'arch' directory for i386 and x86-64. + +conj.3 +cacos.3 +cacosh.3 +cabs.3 +carg.3 +casin.3 +casinh.3 +catan.3 +catanh.3 +ccos.3 +ccosh.3 +cexp.3 +cimag.3 +clog.3 +cosh.3 +creal.3 +csin.3 +csinh.3 +ctan.3 +ctanh.3 +sinh.3 +tanh.3 + mtk + various reformattings. + +various pages + alain portal + formatting fixes. + +mlock.2 +mprotect.2 +mpool.3 +offsetof.3 + alain portal + format synopsis in a manner consistent with other pages. + +various pages + mtk / alain portal + format casts so that there is a non-breaking space after the + type, and remove unnecessary parentheses around the casted value. + thus, for example, the following: + + .ir "(size_t) (\-1)" . + + becomes: + + .ir "(size_t)\ \-1" . + +various pages + mtk / alain portal + replace "-" by "\-" where a real dash is required. + +various pages + mtk + make the formatting of instances of '*varname' consistent, changing + instances such as: + + .ri * varname + + to: + + .i *varname + +pciconfig_read.2 +nfsservctl.2 +bstring.3 +cpow.3 +getipnodebyname.3 +getpwnam.3 +getrpcent.3 +lsearch.3 +malloc_hook.3 +mpool.3 +stdin.3 +strtol.3 +strtoul.3 +unlocked_stdio.3 +regex.3 +sd.4 +resolv.conf.5 +utmp.5 +futex.7 + mtk + format synopsis consistently. + +drand48.3 +drand48_r.3 +flockfile.3 +erf.3 +sigvec.3 +timeradd.3 +wprintf.3 + mtk, after a note by alain portal + standardize sentence used under "feature test macro requirements" + when referring to all functions shown in the synopsis. + +get_kernel_syms.2 +getdents.2 +getitimer.2 +nanosleep.2 +query_module.2 +statvfs.2 +clock_getres.3 +getaddrinfo.3 +getgrent.3 +getipnodebyname.3 +console_ioctl.4 +tty_ioctl.4 +rtnetlink.7 + mtk + indent structure definitions by +4n. + +recv.2 +btree.3 +dbopen.3 +ether_aton.3 +fts.3 +hash.3 +mpool.3 +profil.3 +rcmd.3 +recno.3 +rpc.3 +xdr.3 +console_ioctl.4 +ddp.7 +ip.7 +ipv6.7 +svipc.7 + mtk + use c99 standard types in declarations. + s/u_long/unsigned long/ + s/ulong/unsigned long/ + s/u_char/unsigned char/ + s/u_short/unsigned short/ + s/ushort/unsigned short/ + s/u_int8_t/uint8_t/ + s/u_int16_t/uint16_t/ + s/u_int32_t/uint32_t/ + s/u_int/unsigned int/ + +exit_group.2 +fallocate.2 +getdents.2 +ioctl_list.2 +nfsservctl.2 +sched_setaffinity.2 +set_tid_address.2 +ustat.2 +argz_add.3 +confstr.3 +envz_add.3 +getline.3 +getpwnam.3 +gets.3 +getw.3 +inet_ntop.3 +inet_pton.3 +offsetof.3 +console_ioctl.4 +termcap.5 +ascii.7 +feature_test_macros.7 +netlink.7 +operator.7 +svipc.7 + mtk + fix unbalanced .nf/.fi pairs. + +chmod.2 +getxattr.2 +listxattr.2 +lseek.2 +removexattr.2 +setxattr.2 +stat.2 +feature_test_macros.7 +fpathconf.3 +fopen.3 + + mtk + rename argument: s/file*des/fd/ , since that is the name most + commonly used on man pages for a file descriptor argument. + +bindresvport.3 +des_crypt.3 +getopt.3 +getrpcent.3 +realpath.3 +rpc.3 +xdr.3 + mtk + removed .sm macros. + +madvise.2 +getdirentries.3 +printf.3 +sigvec.3 + mtk + remove extraneous .br macro before/after .sh/.ss. + +_syscall.2 +lookup_dcookie.2 +aio_cancel.3 +aio_error.3 +aio_fsync.3 +aio_read.3 +aio_return.3 +aio_write.3 +canonicalize_file_name.3 +envz_add.3 +getgrouplist.3 +getttyent.3 +key_setsecret.3 +mtrace.3 +tcgetpgrp.3 +tcgetsid.3 +ttyslot.3 +tty_ioctl.4 + mtk + remove extraneous .sp macros. + +fcntl.2 +outb.2 +send.2 +syscalls.2 +getopt.3 +proc.5 +man-pages.7 +standards.7 +tcp.7 + mtk + remove/replace extraneous .sp macros. + +typographical or grammatical errors have been corrected in several places. + + +changes to individual pages +--------------------------- + +_syscall.2 + mtk + nowadays there are seven macros (see 2.74 change log also). + +arch_prctl.2 + mtk, acked by andi kleen + clarify interpretation of 'addr'; plus a few other minor edits + and updates. + +bind.2 + mtk + minor rewrites. + +close.2 + mtk + clarify relationship between file descriptor and open file + description. + +connect.2 + mtk, acked by andi kleen + since kernel 2.2, af_unspec for unconnecting a connected + socket *is* supported. + +execve.2 + alain portal + minor rewordings. + +futimesat.2 + alain portal + remove duplicate "#include " from synopsis. + +getgid.2 + mtk + add getresgid(2) and credentials(7) to see also. + +getpagesize.2 + mtk + small rewording. + +getresuid.2 + mtk + rewrote various parts. + +getuid.2 + mtk + add getresuid(2) and credentials(7) to see also. + +ioctl_list.2 + alain portal + use proper tables for layout, and various formatting fixes. + mtk + various formatting fixes. + +listen.2 + mtk + rewrote various parts. + +mbind.2 + andi kleen / mtk / alain portal + modify explanation of einval 'maxnode' error. + +mmap.2 + mtk + add comma to clarify meaning of a sentence. + +open.2 + mtk + clarify initial description of o_excl. + clarify description of behaviors of o_creat | o_excl + for symbolic links. + clarify text describing use of lockfiles without o_excl. + mtk, with input from timo sirainen and trond myklebust + o_excl is supported on nfsv3 and later, with linux 2.6 and later. + +pipe.2 + mtk + rename 'filedes' argument 'pipefd'. + +pivot_root.2 + mtk + s/cwd/current working directory/ + +seteuid.2 + mtk + minor changes. + +setpgid.2 + mtk + add credentials(7) to see also, and updated copyright credits, + to reflect my rewrite of a few months ago. + +setsid.2 + mtk + add getsid(2) and credentials(7) to see also. + +spu_create.2 + alain portal / mtk; acked by jeremy kerr + minor formatting/wording changes. + mtk + put eperm in right alphabetical position in errors list. + +argz_add.3 + mtk + formatting fixes. + +atexit.3 + mtk + minor changes to example program. + +cerf.3 + mtk + these functions are still not present as at glibc 2.7. + +dbopen.3 + alain portal / mtk + various minor spelling and formatting fixes. + +envz_add.3 + mtk + formatting fixes. + +fexecve.3 + mtk + fix placement of feature test macro in synopsis. + +fmax.3 +fmin.3 + mtk + small rewording. + +getline.3 + mtk + minor changes to example program. + +getrpcent.3 +getrpcport.3 + mtk + use modern c prototypes in synopsis. + +getutent.3 + alain portal / mtk + formatting fixes. + +mbsnrtowcs.3 +mbsrtowcs.3 +mbstowcs.3 + mtk + use .ip tags to create properly formatted lists. + +rpc.3 + mtk + convert function declarations to use modern c prototypes. + add text and start of page describing header files + and types required by functions. + reformat discussion of request under clnt_control(). + +xdr.3 + mtk + convert function declarations to use modern c prototypes. + remove crufty "int empty" from xdrrec_eof() description. + +console_codes.4 + phil endecott + relocate misplaced line: + "and if lf/nl (new line mode) is set also a carriage return;" + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=458338. + +console_ioctl.4 + mtk + formatting fixes. + +bootparam.7 + mtk, after a note by alan portal + fix reference to kernel documentation source file in the + "the sound driver" subsection. + +man-pages.7 + alain portal + move configuration description after synopsis description. + mtk / alain portal + note that header files should be surrounded by angle brackets (<>). + +posixoptions.7 + mtk + minor formatting and wording fixes. + +rtnetlink.7 + andreas henriksson + fix description of rtm_f_equalize. + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=458325. + +signal.7 + mtk + minor formatting and wording fixes. + +socket.7 + mtk + small rewording of discussion of o_async. + +spufs.7 + mtk / jeremy kerr / alain portal + s/spe/spu/ + + +==================== changes in man-pages-2.76 ==================== + +released: 2008-01-14 + + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +alain portal +carlo marcelo arenas belon +jeremy kerr +sam varshavchik +trond myklebust + +apologies if i missed anyone! + + +global changes +-------------- + +longjmp.3 +printf.3 +scanf.3 +setbuf.3 +setjmp.3 +sk98lin.4 +environ.7 + mtk + rework/remove use of ".ad" macros. + +ioctl_list.2 +mlock.2 +mprotect.2 +mremap.2 +syslog.2 +cfree.3 +mpool.3 +offsetof.3 +rpc.3 +stdin.3 + mtk + fix unbalanced quotes in formatting macros. + +ftok.3 + mtk + s/i-node/inode/, for consistency with other pages and posix.1-2001. + +typographical or grammatical errors have been corrected in several places. + + +changes to individual pages +--------------------------- + +chown.2 + mtk + minor wording change. + +dup.2 + mtk + reordered text in description and added some details for dup2(). + +open.2 + trond myklebust / mtk + minor fix to o_excl changes in previous release. + +gettid.2 + mtk + rewrote description; noted that thread id is not the same + thing as a posix thread id. + +pipe.2 + mtk + rewrote description; minor additions to example text. + +umask.2 + mtk + a few rewrites and additions. + +strptime.3 + carlo marcelo arenas belon / mtk + add "#define _xopen_source" to example program. + +initrd.4 + mtk + use quotes more consistently in formatting macros. + +random.4 + mtk, after a report by daniel kahn gilmor + add 2.6 details for /proc/sys/kernel/random/poolsize. + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=459232. + +pthreads.7 + mtk + minor changes. + +spufs.7 + mtk / jeremy kerr + define abbreviation "mss". + + +==================== changes in man-pages-2.77 ==================== + +released: 2008-01-31 + + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +pavel heimlich +phil endecott +thomas huriaux +vincent lefevre +wang cong + +apologies if i missed anyone! + + +global changes +-------------- + +stdarg.3 +bootparam.7 + thomas huriaux + fix broken use of single quotes at start of line, + as per: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=462636 + +typographical or grammatical errors have been corrected in several places. + +new pages +--------- + +remove_colophon.sh + mtk + script to remove the colophon section from the man pages provided + as command-line arguments. this is useful to remove the colophon + sections from all of the man pages in two different release trees + in order to do a "diff -run" to see the "real" differences + between the trees. + + +changes to individual pages +--------------------------- + +fcntl.2 + mtk + replace tables with .tp macros. + +fork.2 + mtk + added discussion of directory streams. + removed "#include " from synopsis. + changed authorship notice. + +futex.2 + mtk + add enosys error to errors. + phil endecott + explicitly describe return value in the event of an error. + +inotify_add_watch.2 + mtk + minor wording changes. + +splice.2 + wang cong + fix types for 2 and 4 arguments in splice prototype. + +wait.2 + phil endecott + clarify description of return value for wnohang. + +tkill.2 + mtk + rewrote description; emphasized that tkill() is obsoleted by + tgkill(). + +alloca.3 + mtk + change description in name section. + various rewrites and additions (including notes on longjmp() and + sigsegv). + mtk / vincent lefevre + weaken warning against use of alloca(), and + point out some cases where it can be useful; + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=461100. + +bootparam.7 + pavel heimlich + remove junk line. + +inotify.7 + mtk + replace tables with .tp macros. + s/multisource synchronization/multisource synchronization (mss)/ + + +==================== changes in man-pages-2.78 ==================== + +released: 2008-02-15 + + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +davide libenzi +greg banks +michael tokarev +phil endecott + +apologies if i missed anyone! + + +global changes +-------------- + +sigaction.2 +signal.2 +sigwaitinfo.2 +signal.7 + mtk + add see also entry referring to new signalfd.2 page. + +typographical or grammatical errors have been corrected in several places. + + +new pages +--------- + +eventfd.2 + mtk, with input and review from davide libenzi + documents the eventfd() system call, new in 2.6.22. + +signalfd.2 + mtk, with input and review from davide libenzi + documents the signalfd() system call, new in 2.6.22. + +changes to individual pages +--------------------------- + +futex.2 + mtk / phil endecott + improve wording describing error returns. + +open.2 + greg banks + greatly expand the detail on o_direct. + +reboot.2 + mtk / michael tokarev + fix return value description: in some cases reboot() does not + return. + mtk + rename the 'flag' argument to 'cmd', since that is more meaningful, + and also what is used in the kernel source. + other minor wording changes. + + +==================== changes in man-pages-2.79 ==================== + +released: 2008-03-07 + + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +andries e. brouwer +chris heath +davide libenzi +fernando luis vázquez cao +heikki orsila +jeremy kerr +justin pryzby +lasse kärkkäinen +michael haardt +mike frysinger +ron burk +sam varshavchik +samuel thibault +walter harms + +apologies if i missed anyone! + + +global changes +-------------- + +typographical or grammatical errors have been corrected in several places. + + +new pages +--------- + +timerfd_create.2 + mtk, with input and review from davide libenzi + documents the timerfd_create(), timerfd_settime(), and + timerfd_gettime() system calls, which are new in 2.6.25. + + +new links +--------- + +timerfd_gettime.2 +timerfd_settime.2 + mtk + links to new timerfd_create.2 page. + +eventfd_read.3 +eventfd_write.3 + mtk + links to eventfd.2. + + +changes to individual pages +--------------------------- + +makefile + aeb + remove code relating to man1/readme, which no longer exists. + +execve.2 + mtk + clarify detail of rlimit_stack/4 limit for argv+environ. + +getitimer.2 + mtk + added see also entry referring to timerfd_create.2. + +getrusage.2 + mtk + minor rewordings. + +open.2 + michael haardt + move discussion of 'mode' argument under description of o_creat. + +signalfd.2 + mtk + fix type for 'ssi_ptr' field. + see http://sources.redhat.com/ml/libc-hacker/2008-01/msg00002.html. + +syscalls.2 + mtk + add timerfd_create(), timerfd_settime(), and timerfd_gettime() + to list. + +syslog.2 + jeremy kerr + add info on command type 10. + add details on types 6, 7, 8, and 9. + minor grammar fix. + mtk + update log_buf_len details. + update return value section. + notes capability requirements under eperm error. + minor fix to description of type==3 and type==4. + other minor edits. + +ctime.3 + walter harms + note that posix requires localtime() to act as though tzset() + was called, but localtime_r() does not have the same requirement. + see also http://thread.gmane.org/gmane.comp.time.tz/2034/ + +getaddrinfo.3 + mtk + clarify discussion of null 'hints' argument; other minor rewrites. + mtk / sam varshavchik + remove some duplicated text. + +malloc.3 + lasse kärkkäinen / mike frysinger / mtk + clarify description of realloc() behavior for + ((size == 0) && (ptr != null)). + +posix_fallocate.3 + samuel thibault + s/stdlib.h/fcntl.h/ in synopsis. + +proc.5 + fernando luis vázquez cao + update /proc/[number]/cmdline description. + it used to be true that the command line arguments were + not accessible when the process had been swapped out. + in ancient kernels (circa 2.0.*) the problem was that the + kernel relied on get_phys_addr to access the user space buffer, + which stopped working as soon as the process was swapped out. + recent kernels use get_user_pages for the same purpose and thus + they should not have that limitation. + +epoll.7 + davide libenzi / mtk + clarify the somewhat unintuitive behavior that occurs if a file + descriptor in an epoll set is closed while other file descriptors + referring to the same underlying open file description remain + open. + see also http://thread.gmane.org/gmane.linux.kernel/596462/. + mtk + clarify error that occurs if we add an epoll fd to its own set. + mtk + a few minor rewordings. + mtk, after a note by chris heath + rework q1/a1, describing what happens when adding the same + file descriptor twice to an epoll set, and when adding duplicate + file descriptors to the same epoll set. + heikki orsila / mtk / davide libenzi + clarify q9/a9 to discuss packet/token-oriented files. + mtk, after comments by davide libenzi and chris heath + added q0/a0, making explicit that the key for items in an epoll + set is [file descriptor, open file description]. + mtk, after a note by ron burk + change a3, to note that when events are available, + the epoll file descriptor will indicate as being readable. + mtk + add some further explanation to q5/a5 about why an epoll file + descriptor cannot be passed across a unix domain socket. + +posixoptions.7 + mtk + add see also entry for standards(7). + +regex.7 + mtk + add grep(1) to see also. + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=348552. + +standards.7 + mtk + add see also entry for posixoptions(7). + +time.7 + mtk + added see also entry referring to timerfd_create.2. + + +==================== changes in man-pages-2.80 ==================== + +released: 2008-06-05 + + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +adrian bunk +alain portal +andreas herrmann +andrew morton +andries e. brouwer +anoop +aurelien gerome +daniel burr +davide libenzi +felix kater +folkert van heusden +hamaji shinichiro +heikki orsila +ingo molnar +justin pryzby +karsten weiss +martin pitt +marty leisner +nicolas françois +nick piggin +petter reinholdtsen +reuben thomas +sam varshavchik +stuart brady +theodoros v. kalamatianos +thomas huriaux +tim stoakes +timothy baldwin +tolga dalman + +apologies if i missed anyone! + + +global changes +-------------- + +bdflush.2 +inotify_add_watch.2 +mprotect.2 +sigprocmask.2 +ctime.3 +getusershell.3 +setbuf.3 +st.4 +ip.7 +packet.7 + mtk + replace "(il)legal" by "(not) permitted" or "(in)valid". + +read.2 +utime.2 +filesystems.5 +packet.7 + mtk + s/time stamp/timestamp/, for consistency with majority use + in other pages, and in posix.1. + +madvise.2 +mbind.2 +mincore.2 +mmap.2 +mmap2.2 +msync.2 +remap_file_pages.2 + mtk + change name of 'start' argument to 'addr' for consistency + with: + * other memory-related interfaces + * posix specification (for those interfaces in posix) + * linux and glibc source code (in at least some cases) + +various pages + mtk + s/filesystem/file system/, for consistency with majority use + in other pages, and in posix.1. + +various pages + mtk + s/zeroes/zeros/, for consistency with majority use + in other pages, and in posix.1. + +abs.3 +proc.5 + mtk + s/builtin/built-in/, for consistency with majority use + in other pages, and in posix.1. + +mknod.2 +ftw.3 + mtk + s/normal file/regular file/ + +various pages + mtk + s/nonempty/non-empty/ + +various pages + mtk + s/nonzero/non-zero/ + +various pages + mtk + s/realtime/real-time/, for consistency with majority usage. + +various pages + mtk + s/command line/command-line/ when used attributively. + +various pages + mtk + use "run time" when non-attributive, "run-time" when attributive. + +various pages + mtk + various pages that i wrote carried a slightly modified version + of the "verbatim" license. in the interests of minimizing + license proliferation, i've reverted the modified form + so that the license is exactly the same as on other pages + carrying the verbatim license. + +epoll_ctl.2 +getitimer.2 +getrlimit.2 +unix.7 + mtk + s/since kernel x.y.z/since linux x.y.z/ + +wait.2 +inotify.7 + mtk + reformat kernel version information for flags. + +typographical or grammatical errors have been corrected in several places. +(special thanks to nicolas françois.) + + +new pages +--------- + +random_r.3 + mtk, after a suggestion by aeb + documents random_r(3), srandom_r(3), initstate_r(3), and + setstate_r(3), which are the reentrant equivalents of + random(3), srandom(3), initstate(3), and setstate(3). + + +new links +--------- + +lutimes.3 + mtk + link to futimes.3. + +initstate_r.3 +setstate_r.3 +srandom_r.3 + mtk + links to random_r.3. + +daylight.3 +timezone.3 +tzname.3 + mtk + links to tzset.3. + +isnanf.3 +isnanl.3 + mtk + links to finite.3. + +encrypt_r.3 +setkey_r.3 + mtk + links to encrypt.3. + + +changes to individual pages +--------------------------- + +clone.2 + mtk + added note that clone_stopped (which no-one uses anyway) is + now deprecated. + +epoll_create.2 + mtk + add notes section pointing out that 'size' argument is unused + since kernel 2.6.8. + +epoll_ctl.2 + mtk + added portability note to bugs text for epoll_ctl_del. + +epoll_wait.2 + mtk + if the 'sigmask' is null, then epoll_pwait() is equivalent + to epoll_wait(). + +fork.2 + mtk + notes: since glibc 2.3.3, the glibc nptl fork() wrapper + bypasses the fork() system call to invoke clone() with + flags providing equivalent functionality. + +futex.2 + mtk, after a note from adrian bunk + futex_fd has been removed, as of kernel 2.6.26. + +futimesat.2 + mtk + note that this system call is made obsolete by utimensat(2). + +getgroups.2 + petter reinholdtsen + see also: add getgrouplist(3). + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=479284. + mtk + ngroups_max increased in kernel 2.6.4. + see also: add credentials(7). + mtk + reformat description and return value sections to be more + consistent with man-pages style. + add some more detail to descriptions of system calls. + clarified what happens if caller of getgroups() is a member of + more than 'size' supplementary groups. + errors: add enomem. + +getpriority.2 + mtk, after a note from ingo molnar + add text in notes about the punchier effect of nice values in + kernel 2.6.23 and later. + add documentation/scheduler/sched-nice-design.txt to see also list. + +gettid.2 + mtk + added versions section noting that this system call first + appeared in 2.4.11. + +kill.2 + marty leisner / mtk + add text explicitly noting that sig==0 can be used to check for + the existence of a pid or pgid. + mtk + a few minor rewordings. + +mbind.2 + mtk + the location of the numactl package has changed. + +mmap.2 + mtk + added some .ss headings to make structure of page a little + more obvious. + mtk, with input from nick piggin + map_populate supports both file and anonymous mappings. + since 2.6.23, map_populate supports private mappings. + since 2.6.23, map_nonblock causes map_populate to be a no-op. + mtk + notes: added details on mapping address that is selected by + kernel when map_fixed is / isn't specified. + +mount.2 + mtk + the ms_remount changes in 2.4 were at 2.4.10 (not 2.4). + mtk + minor wording change. + +msgctl.2 + mtk + clarify that "unused" fields in msginfo structure are + "unused within the kernel". + msginfo.msgpool is measured in kilobytes, not bytes. + minor rewordings in comments for msginfo structure. + +msgop.2 + mtk + various minor rewordings and restructurings for clarity. + mtk, after a note from reuben thomas + remove "msgop" from name section. + +mkdir.2 + mtk + clarify meaning of "bsd group semantics". + see also: add chown(2). + +mknod.2 + mtk + see also: add chown(2) and chmod(2). + +mmap.2 + mtk + see also: add mprotect(2) and shmat(2). + +mprotect.2 + hamaji shinichiro + synopsis: s/size_t \*len/size_t len/ + +open.2 + mtk + note that o_cloexec should be in the next posix.1 revision. + mtk + more than just ext2 supports "mount -o bsdgroups" nowadays, + so make the discussion about group ownership of new files a bit + more generic. + mtk + see also: add chown(2) and chmod(2). + +poll.2 + mtk + if the 'sigmask' is null, then ppoll() is equivalent to poll() + with respect to signal mask manipulations. + +posix_fadvise.2 + mtk + s/posix_madvise (2)/posix_madvise (3)/; + (the referred-to page still doesn't exist yet, but hopefully + will do sometime soon.) + +ptrace.2 + anoop, acked by roland mcgrath. + re ptrace_peekuser: the offsets and data returned might not + match with the definition of struct user. + see also http://lkml.org/lkml/2008/5/8/375 + +recv.2 + felix kater / mtk + improve wording for eagain error in discussion of msg_dontwait. + +rmdir.2 + martin pitt + posix.1 also allows eexist for the enotempty error condition. + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=467552. + +sched_setscheduler.2 + mtk, with input from ingo molnar + add description of sched_idle policy (new in 2.6.23). + tweak description of sched_batch. + minor rewordings. + +select_tut.2 + justin pryzby + various wording clean-ups. + +semctl.2 + mtk + clarify that "unused" fields in seminfo structure are + "unused within the kernel". + minor rewordings in comments for seminfo structure. + +semop.2 + aurelien gerome + small fix in example code. + +setpgid.2 + mtk / karsten weiss + clarify description of setpgid() a little. + +shmctl.2 + mtk + clarify that "unused" fields in shminfo structure are + "unused within the kernel". + minor rewordings in comments for shminfo structure. + +shmop.2 + mtk, after a note from reuben thomas + remove "shmop" from name section. + +signalfd.2 + mtk + added bugs text noting that before kernel 2.6.25, the ssi_int + and ssi_ptr fields are not set. + added comments describing fields in signalfd_siginfo structure. + update field names in example program (s/signo/ssi_signo/). + various small fixes, and remove duplicated sentence. + minor edits to structure definition. + +sigqueue.2 + mtk + added some comments to code in notes. + +stat.2 + mtk + minor wording change. + +symlink.2 + mtk + see also: add lchown(2). + +sync_file_range.2 + mtk / andrew morton + remove statement that (sync_file_range_wait_before | + sync_file_range_write | sync_file_range_wait_after) is + a traditional fdatasync(2) operation. + see https://bugzilla.mozilla.org/show_bug.cgi?id=421482 + comments 129 to 131. + +syscalls.2 + mtk + this page is now up to date as at kernel 2.6.25. + +syslog.2 + mtk + small tidy up of language relating to permissions/capabilities. + +timerfd_create.2 + mtk + minor change to example program. + minor wording change. + +utime.2 + reuben thomas + remove unnecessary subheading for utimes(). + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=477402. + mtk + change description in name line ("or" is not correct: these calls + always change *both* timestamps). + conforming to: utimes() is in posix.1-2001. + mtk + rename 'buf' argument of utime() to 'times' (like utimes()). + clarify explanation of eacces and eperm errors. + remove bugs section, since it doesn't seem to add useful + information. + clarified discussion of capabilities, and noted that + cap_dac_override also has a role. + other minor rewordings. + +wait.2 + mtk, after a note by justin pryzby + add a sentence clarifying that even though the default disposition + of sigchld is "ignore", explicitly setting the disposition to + sig_ign results in different treatment of zombies. + +aio_cancel.3 +aio_error.3 +aio_fsync.3 +aio_read.3 +aio_return.3 +aio_suspend.3 +aio_write.3 + kevin o'gorman + add "link with -lrt" to synopsis. + +backtrace.3 + nicolas françois + s/backtrace_symbols/backtrace_symbols_fd/ in one sentence. + mtk + fix bogus reference to variable 'strings': should be: + "the array of pointers". + +ctime.3 + mtk + add warning under notes that asctime(), ctime(), gmtime(), and + localtime() may each overwrite the static object returned by any + of the other calls. + other minor edits. + +dlopen.3 + mtk + add more detail to the description of the fields in the + structure returned by dladdr(). + +fexecve.3 + mtk + clean up synopsis after work by cut-and-paste-pete: + the necessary header file is not ! + +futimes.3 + mtk + add documentation of lutimes(), which appeared in glibc 2.6. + mtk + change description in name line ("or" is not correct: these calls + always change *both* timestamps). + conforming to: futimes() did not come from 4.2bsd. (it came from + freebsd; see the freebsd man page.) + +getenv.3 + mtk + noted that caller must not modify returned value string. + noted that getenv() is not reentrant: the buffer may be statically + allocated and overwritten by later calls to getenv(), putenv(), + setenv(), or unsetenv(). + other minor rewrites. + +getgrent.3 + petter reinholdtsen + see also: add getgrouplist(3). + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=479284. + +gethostbyname.3 + mtk + add 'h_errno' to name list. + +getopt.3 + mtk + add 'optarg', 'optind', 'opterr', and 'optopt' to name section. + add subheading for getopt_long() and getopt_long_only() + description. + +getpt.3 + mtk + point out that this function should be avoided in favor of + posix_openpt(). + add errors section referring to open(2). + +getsubopt.3 + daniel burr + synopsis: fix declaration of valuep. + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=476672. + +malloc.3 + mtk + return value: note circumstances in which successful malloc() and + calloc() can return null. + +mq_open.3 + mtk, after a note by marty leisner + note that is needed for o_* constants and + is needed for 'mode' constants. + +opendir.3 + mtk + describe treatment of close-on-exec flag by opendir() and + fdopendir(). + +openpty.3 + mtk + see also: add ttyname(3). + +raise.3 + mtk / timothy baldwin + clarify semantics of raise() when called from a multithreaded + program. + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=476484. + mtk + rewrites and additions to various parts of the page. + +rand.3 + tolga dalman / aeb / mtk + remove outdated warning in notes; encourage the use of + random(3) instead. + folkert van heusden + clarify wording describing range of values returned by rand(). + +random.3 + aeb / mtk / tolga dalman + recommend use or random_r(3) for multithreaded applications + that need independent, reproducible sequences of random numbers. + + move references to "the art of computer programming" and + "numerical recipes", formerly in rand(3), to this page. + + add drand48(93) to see also list. + +regex.3 + heikki orsila + clarify description of 'rm_eo' field. + +sem_open.3 + mtk, after a note by marty leisner + note that is needed for o_* constants and is + needed for 'mode' constants. + +sem_post.3 + mtk + added pointer to example in sem_wait(3). + +sem_close.3 +sem_destroy.3 +sem_getvalue.3 +sem_init.3 +sem_open.3 +sem_post.3 +sem_unlink.3 +sem_wait.3 + mtk, after a note from marty leisner + add text to synopsis noting the need to link with "-lrt" or + "-pthread". + +setenv.3 + mtk + setenv() copies 'name' and 'value' (contrast with putenv()). + unsetenv() of a nonexistent variable does nothing and is + considered successful. + noted that setenv() and unsetenv() need not be reentrant. + +shm_open.3 + mtk, after a note by marty leisner + note that is needed for o_* constants and is + needed for 'mode' constants. + +undocumented.3 + mtk + initstate_r(3), setkey_r(3), setstate_r(3) are now documented. + +utmp.5 + nicolas françois + small rewording. + +resolv.conf.5 + nicolas françois + gethostname() is in section 2, not section 3. + +ascii.7 + stuart brady + fix rendering of ' (backtick) and apostrophe (') in tables + +charsets.7 + nicolas françois + s/unicode.com/unicode.org/ + +credentials.7 + mtk + notes: pthreads requires that all threads share the same uids and + gids. but the linux kernel maintains separate uids and gids for + every thread. nptl does some work to ensure that credential + changes by any thread are carried through to all posix threads in + a process. + mtk + sysconf(_sc_ngroups_max) can be used to determine the number of + supplementary groups that a process may belong to. + clarify that supplementary group ids are specified in posix.1-2001. + +epoll.7 + mtk, after a note from sam varshavchik + for answer a2, change "not recommended" to "careful programming + may be required". + +inotify.7 + mtk + document sigio feature (new in 2.6.25) for inotify file descriptors. + mtk + note that select()/poll()/epoll_wait() indicate a ready inotify + file descriptor as readable. + mtk + document in_attrib in a little more detail. + +pthreads.7 + justin pryzby + grammar fix, plus fix typo in script. + mtk + add list of thread-safe functions. + +standards.7 + mtk + add a section on the upcoming posix revision. + +ld.so.8 + justin pryzby / mtk + various wording improvements. + + +==================== changes in man-pages-3.00 ==================== + +released: 2008-06-12, konolfingen + + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +andries brouwer +stuart brady + +apologies if i missed anyone! + + +global changes +-------------- + +the posix.1 man pages (sections 0p, 1p, 3p) have been moved out +of this package into the separate man-pages-posix package. +this made sense because those pages are seldom changed (only formatting +fixes, etc.) so that it was unnecessary to redistribute them with each +man-pages release. + + +console_codes.4 +random.4 +dir_colors.5 +proc.5 +glob.7 + stuart brady + s/`/\`/ for backquotes used in command substitution, for + proper rendering in utf-8. + +various pages + mtk, after a note from stuart brady + using /'x'/ to denote a character (string) renders poorly in + utf-8, where the two ' characters render as closing single + quotes. on the other hand, using /`x'/ renders nicely on utf-8, + where proper opening and closing single quotes are produced by + groff(1), but looks ugly when rendered in ascii. using the + sequence /\\aqx\\aq/ produces a reasonable rendering ('\\aq' + is a vertical "apostrophe quote") in both utf-8 and ascii. + so that change is made in a number of pages. + see also http://www.cl.cal.ac.uk/~mgk25/ucs/quotes.html. + +various pages + mtk + replace form /`string'/ by /"string"/, since the former renders + poorly in ascii. + +termios.3 +console_codes.4 +tty_ioctl.4 +termcap.5 +charsets.7 + mtk + control character names (^x) are written boldface, without + quotes. + +printf.3 +scanf.3 +proc.5 +glob.7 +regex.7 + mtk + various edits to try and bring some consistency to the use of + quotes. + + +changes to individual pages +--------------------------- + +tty_ioctl.4 + mtk + small rewordings in description of packet mode. + +locale.7 + mtk + minor formatting fixes. + + +==================== changes in man-pages-3.01 ==================== + +released: 2008-06-25, munich + + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +alain portal +andreas herrmann +andrew p +andrew clayton +bart van assche +christian borntraeger +christoph hellwig +daniele giacomini +dorin lazar +george spelvin +jason englander +jeff moyer +laurent vivier +masatake yamoto +matt mackall +neil horman +pavel machek +peter zijlstra +petr baudis +petr gajdos +roman zippel +sam varshavchik +samuel thibault +stephane chazelas +stuart cunningham +thomas gleixner +tolga dalman +yao zhao +wang cong + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +acct.5 + mtk + a complete rewrite of this page, now with much more detail. + +hostname.7 + mtk + a description of hostname resolution. taken from freebsd 6.2, + and lightly edited for man-pages style. + +symlink.7 + mtk + a description of symbolic links. taken from freebsd 6.2, but + heavily edited for linux details, improved readability, and + man-pages style. + + +newly documented interfaces in existing pages +--------------------------------------------- + +getrlimit.2 + mtk / peter zijlstra + add description of rlimit_rttime limit, new in 2.6.25. + +mkstemp.3 + mtk + add description of mkostemp(), new in glibc 2.7. + +core.5 + mtk, after a note by petr gajdos; review by neil horman + document core_pattern pipe syntax, which appeared in + kernel 2.6.19. + add an example program demonstrating use of core_pattern + pipe syntax. + mtk + document /proc/pid/coredump_filter, new in kernel 2.6.23. + documentation was based on the text in + documentation/filesystems/proc.txt, plus testing, and + checking the kernel source. + +proc.5 + mtk + document /proc/pid/oom_score, which was new in kernel 2.6.11. + this file displays the "badness" score of the process, which + provides the basis for oom-killer decisions. + mtk + document /proc/pid/oom_adj, which was new in kernel 2.6.11. + this file influences the oom_score of a process. + mtk + document /proc/pid/limits, which was new in 2.6.24. + this file displays a process's resource limits. + mtk + document /proc/pid/fdinfo/*, which was new in 2.6.22. + these files display info about each descriptor opened by the + process: the current file offset, and the file access mode + + file status flags as set in open() or fcntl(f_setfl). + mtk + document /proc/pid/mountinfo, which was new in 2.6.26. + this file displays information about mount points. + closely based on text from documentation/filesystems/proc.txt. + mtk + document /proc/pid/mountstats, which was new in 2.6.17. + this file displays statistics about mount points. + mtk + document /proc/pid/status. + samuel thibault / mtk, review by laurent vivier, + christian borntraeger, and andrew p + document guest (virtual cpu) time field in /proc/stat. + document guest (virtual cpu) time fields in /proc/pid/stat. + + +new links +--------- + +mkostemp.3 + mtk + link to mkstemp.3. + +getcwd.2 + mtk + link to getcwd.3, which describes several interfaces, among + them getcwd(), which is in fact a system call. + + +global changes +-------------- + +sched_setaffinity.2 +sched_setscheduler.2 +set_mempolicy.2 +mbind.2 + mtk + see also: add cpuset(7). + +chown.2 +faccessat.2 +fchmodat.2 +fchownat.2 +fstatat.2 +getxattr.2 +link.2 +linkat.2 +listxattr.2 +open.2 +readlink.2 +removexattr.2 +rename.2 +setxattr.2 +stat.2 +symlink.2 +symlinkat.2 +unlink.2 +futimes.3 +remove.3 +path_resolution.7 + mtk + see also: add symlink(7). + +intro.1 +time.1 +fcntl.2 +gethostbyname.3 +ioctl_list.2 + mtk + wrap source lines so that new sentence starts on new line. + +addseverity.3 +backtrace.3 +dlopen.3 +fmtmsg.3 +getnameinfo.3 +getpt.3 +grantpt.3 +makecontext.3 +ptsname.3 +tcgetsid.3 +unlockpt.3 +wordexp.3 + mtk + added versions section. + +msgctl.2 +msgget.2 +semget.2 +semop.2 +pciconfig_read.2 +basename.3 +cmsg.3 +ftok.3 +console_ioctl.4 +tzfile.5 +mq_overview.7 +pty.7 + mtk + for consistency, "fix" cases where argument of .b or .i was + on the following source line. + +adjtimex.2 +getrusage.2 +io_getevents.2 +poll.2 +select.2 +semop.2 +sigwaitinfo.2 +aio_suspend.3 +clock_getres.3 +mq_receive.3 +mq_send.3 +sem_wait.3 +proc.5 + mtk + see also: add time(7) + +typographical or grammatical errors have been corrected in several places. +(special thanks to nicolas françois and alain portal.) + + +changes to individual pages +--------------------------- + +acct.2 + mtk + add a few more words to description. + notes: add pointer to acct(5). + +alarm.2 + alain portal + s/process/calling process/ so as to say that the alarm signal is + delivered to the calling process. + +brk.2 + yao zhao / mtk + clarify discussion of return value of sbrk(). + mtk + description: add some sentences giving an overview of these + interfaces. + add note recommending use of malloc(3). + change name of brk() argument to the simpler 'addr'. + add "(void *)" cast to "-1" for error return of sbrk(). + removed some incorrect text about "brk(0)". + note that susv2 specified the return value of sbrk(). + added a detail on the glibc brk() wrapper. + remove discussions of old standards (c89 and posix.1-1990); + conforming to already discusses the situation with respect + to more recent standards. + +chmod.2 + mtk + clarify description of chmod() and fchmod(). + add further detail on s_isuid, s_isgid, and s_isvtx permissions. + reformat list of permissions bits. + +chown.2 + mtk + describe rules governing ownership of new files (bsdgroups + versus sysvgroups, and the effect of the parent directory's + set-group-id permission bit). + +chroot.2 + alain portal + clarify description a little. + s/changes the root directory/ + changes the root directory of the calling process/ + +execve.2 + mtk + fix text that warns against use of null argv and envp. + using a null envp does in fact seem to be portable (works + on solaris and freebsd), but the linux semantics for a null + argv certainly aren't consistent with other implementations. + see http://bugzilla.kernel.org/show_bug.cgi?id=8408. + +getdents.2 + mtk, after a note from george spelvin + document d_type field, present since kernel 2.6.4. + other minor edits. + +getitimer.2 + mtk + noted that posix.1 leaves interactions with alarm(), sleep(), + and usleep() unspecified. + linux 2.6.16 removed the max_sec_in_jiffies ceiling on timer + values. + other minor changes. + +io_cancel.2 +io_destroy.2 +io_getevents.2 +io_setup.2 +io_submit.2 + mtk, after a note by masatake yamoto and input from jeff moyer + describe the unconventional error return provided by the + wrapper function in libaio (and contrast with behavior if + the system call is invoked via syscall(2)). + see http://thread.gmane.org/gmane.linux.ltp/4445/ + alain portal / mtk + re-order errors and see also entries to be alphabetical. + +io_getevents.2 + alain portal + small wording fix. + +io_submit.2 + jeff moyer + s/aio request blocks/aio control blocks/ + +mknod.2 + mtk + note that eexist applies, even if the pathname is a + (possibly dangling) symbolic link. + +nanosleep.2 + mtk, after a report from stephane chazelas + remove crufty discussion of hz, and replace with a pointer + to time(7). + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=485636 + mtk, after some discussions with bart van assche and roman zippel + notes: describe clock_realtime versus clock_nanosleep + see also http://thread.gmane.org/gmane.linux.kernel/696854/ + "nanosleep() uses clock_monotonic, should be clock_realtime?" + mtk + replace mentions of "process' by "thread". + notes: describe case where clock_nanosleep() can be preferable. + some minor rewrites. + +open.2 + mtk, after a note from christoph hellwig + notes: note that access mode flags are not single bits, + and document the linuxism "access mode 3". + see also http://thread.gmane.org/gmane.linux.kernel/653123. + +readdir.2 + mtk + minor wording fixes. + +recv.2 + alain portal + add comment to 'ee_pad' field in structure definition. + +sched_setscheduler.2 + mtk + add pointer to discussion of rlimit_rttime in getrlimit.2. + mtk, after a note by andrew clayton + rewrote and restructured various parts of the page for greater + clarity. + mtk + add more detail to the rules that are applied when an + unprivileged process with a non-zero rlimit_rtprio limit + changes policy and priority. + see also: add documentation/scheduler/sched-rt-group.txt + +sync_file_range.2 + pavel machek + sync_file_range_write can block on writes greater than request + queue size. for some background, see + http://thread.gmane.org/gmane.linux.kernel/687713/focus=688340 + +syscalls.2 + mtk + added system call history back to version 1.2. + fix typo on kernel version for pivot_root(). + +syslog.2 + wang cong + document enosys error, which can occur if kernel was built without + config_printk. + +utime.2 + nicolas françois + clarify description of 'times' array for utimes(). + +adjtime.3 + mtk + the longstanding bug that if delta was null, olddelta + didn't return the outstanding clock adjustment, is now fixed + (since glibc 2.8 + kernel 2.6.26). + http://sourceware.org/bugzilla/show_bug?id=2449 + http://bugzilla.kernel.org/show_bug.cgi?id=6761 + +dprintf.3 + mtk + note that these functions are included in the next posix revision. + remove editorial discussion about what the functions should have + been named. + +ftime.3 + mtk + rewrote various pieces, and added some details. + +getaddrinfo.3 + mtk + improve description or 'hints' and 'res' arguments. + add details on numeric strings that can be specified for 'node'. + other fairly major restructurings and rewrites to improve + logical structure and clarity of the page. + see also: add hostname(7). + +gethostbyname.3 + mtk + description: add reference to inet_addr(3) for dotted notation. + see also: add inet(3). + mtk + added bugs section noting that gethostbyname() does not + recognize hexadecimal components in dotted address strings; + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=482973 + +getmntent.3 + mtk, after stuart cunningham pointed out the typo + remove statement that lsb deprecates the functions + "endmntent(), setmntent() [sic] and setmntent()". + this doesn't seem to be true (i can't find mention of it + being deprecated in any of the lsb specs). rather, lsb simply + doesn't specify these functions. (lsb 1.3 had a spec of + setmntent(), but not getmntent() or endmntent(), and noted + that having a spec of setmntent() was of little use without + also having a spec of getmntent().) + see also https://lists.linux-foundation.org/pipermail/lsb-discuss/2006-october/003078.html + +getnameinfo.3 + tolga dalman + remove mention of sa_len field from example code. + that field is a bsdism not present on linux. + mtk + various minor changes. + +inet.3 + mtk / stephane chazelas + inet_aton() is *not* in posix.1. + rewrote discussion of why inet_addr() is disfavored. + see also: add getaddrinfo(3). + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=482979. + mtk, after a note by stephane chazelas + describe the various address forms supported by inet_aton(). + mtk + rewrite description of inet_network(). + clarify discussion of inet_lnaof(), inet_netof(), and inet_makeaddr(). + add discussion of classful addressing, noting that it is obsolete. + added an example program. + mtk + relocate discussion of i386 byte order to notes. + note that inet_aton() returns an address in network byte order. + see also: add byteorder(3) and getnameinfo(3). + +inet_ntop.3 + mtk + remove unneeded header files from synopsis. + see also: add inet(3) and getnameinfo(3). + make name line more precise. + move errors to an errors section. + add example section pointing to inet_pton(3). + +inet_pton.3 + mtk / stephane chazelas + remove statement that inet_pton() extends inet_ntoa(); + that's not really true, since inet_pton() doesn't support + all of the string forms that are supported by inet_ntoa(). + see also: add getaddrinfo(3). + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=482987. + mtk + describe ipv6 address formats. + describe dotted decimal format in more detail. + add an example program. + mtk + remove unneeded header files from synopsis. + make name line more precise. + make description of return value more precise. + see also: add inet(3). + +mkfifo.3 + mtk + note that eexist applies, even if the pathname is a + (possibly dangling) symbolic link. + +mkstemp.3 + mtk + fix discussion of o_excl flag. + these functions may also fail for any of the errors described + in open(2). + various other rewordings. + +readdir.3 + mtk + document dt_lnk (symbolic link) for d_type field. + reorder dt_ entries alphabetically. + +remainder.3 + mtk + recommend against drem(), in favor of remainder(). + +scanf.3 + mtk, after a note from stephane chazelas + add an errors section documenting at least some of the errors + that may occur for scanf(). + see also http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=487254. + mtk, after a note from stephane chazelas; review by stephane chazelas + document the gnu 'a' modifier for dynamically allocating strings. + see also http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=487254. + document the gnu 'm' modifier for dynamically allocating strings. + +strcat.3 + andreas herrmann + s/strcat/strncat/ (a typo that changed the semantics in + description). + +strerror.3 + mtk, after a note from daniele giacomini + modify synopsis to show prototypes of both versions of strerror_r(), + and make other small clarifications of the description regarding + the two versions. + +random.4 + george spelvin (taking time out from his busy broadway schedule), + with some tweaks by matt mackall and mtk + add a usage subsection that recommends most users to use + /dev/urandom, and emphasizes parsimonious usage of + /dev/random. + +locale.5 + petr baudis + lc_time: describe first_weekday and first_workday. + +proc.5 + mtk + the various cpu time fields in /proc/stat and /proc/pid/stat + return time in clock ticks (user_hz, cputime_to_clock_t(), + sysconf(_sc_clk_tck)). + updated, clarified and expanded the description several + fields in /proc/[number]/stat. + mtk + clarified and expanded the description of /proc/[number]/fd. + mtk + updated and clarified the description of /proc/[number]/statm. + mtk + updated and clarified the description of /proc/sys/fs/dentry-state. + mtk + many formatting, wording, and grammar fixes. + +man-pages.7 + mtk + enhanced description of versions section. + +mq_overview.7 + mtk + note that linux does not currently support acls for posix + message queues. + +sem_overview.7 + mtk + note that linux supports acls on posix named semaphores + since 2.6.19. + +time.7 + mtk, with some suggestions from bart van assche and thomas gleixner + added some details about where jiffies come into play. + added section on high-resolution timers. + mentioned a few other time-related interfaces at various + points in the page. + see http://thread.gmane.org/gmane.linux.kernel/697378. + +unix.7 + mtk, after a note by samuel thibault + provide a clear description of the three types of address that + can appear in the sockaddr_un structure: pathname, unnamed, + and abstract. + + +==================== changes in man-pages-3.02 ==================== + +released: 2008-07-02, konolfingen + + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +alain portal +andries brouwer +reuben thomas +sam varshavchik +stephane chazelas +wang cong + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +clock_nanosleep.2 + mtk + a description of the clock_nanosleep() system call, + which was added in kernel 2.6. + +getgrouplist.3 + mtk + a near complete rewrite, including additional information and + a new example program. + +getutmp.3 + mtk + documents getutmp(3) and getutmpx(3). + +gnu_get_libc_version.3 + mtk + documents gnu_get_libc_version(3) and gnu_get_libc_release(3). + +sigwait.3 + mtk + documents sigwait(3). + +shm_overview.7 + mtk + an overview of the posix shared memory api. + + +newly documented interfaces in existing pages +--------------------------------------------- + +updwtmp.3 + mtk + document updwtmpx(3). + + +new links +--------- + +getutmpx.3 + mtk + link to getutmp.3. + +gnu_get_libc_release.3 + mtk + link to gnu_get_libc_version.3 + +updwtmpx.3 + mtk + link to updwtmp.3 + +utmpxname.3 + mtk + link to getutent.3. + +utmpx.5 + mtk + link to utmp.5. + + +global changes +-------------- + +various pages + mtk + s/user name/username/ + +various pages + mtk + s/host name/hostname/ + + +changes to individual pages +--------------------------- + +fchmodat.2 + alain portal + see also: add symlink.7. (3.01 changelog wrongly said this + had been done.) + +io_setup.2 + alain portal + remove superfluous text from return value. + +mmap.2 + mtk + see also: add mmap(2), shm_overview(7). + +shmget.2 +shmop.2 + mtk + see also: add shm_overview(7). + +sigreturn.2 + mtk + added a bit more detail on what sigreturn() actually does. + +signalfd.2 +sigsuspend.2 + mtk + see also: add sigwait(3). + +sigwaitinfo.2 + mtk + describe behavior when multiple threads are blocked in + sigwaitinfo()/sigtimedwait(). + see also: add sigwait(3). + +dirfd.3 + mtk + return value: describe return value on success. + add an errors section documenting posix.1-specified errors. + +getaddrinfo.3 + mtk, after a note by stephane chazelas + getaddrinfo() supports specifying ipv6 scope-ids. + +getlogin.3 + mtk + errors: add enotty. + see also: add utmp(5). + +getutent.3 + wang cong + utmpname() does return a value. + mtk + add paragraph to start of description recommending + use of posix.1 "utmpx" functions. + conforming to: mention utmpxname(). + add an errors section. + there are no utmpx equivalents of the _r reentrant functions. + clarify discussion of return values. + add pointer to definition of utmp structure in utmp(5). + clarify discussion of utmpx file on other systems (versus + linux situation). + +getutent.3 + mtk + see also: add getutmp(3) + +inet_pton.3 + stephane chazelas + fix error in description of ipv6 presentation format: + s/x.x.x.x.x.x.x.x/x:x:x:x:x:x:x:x/. + +setbuf.3 + reuben thomas / mtk + fix confused wording for return value of setvbuf(). + fixes http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=488104. + mtk + other minor rewordings. + +shm_open.3 + mtk + see also: add shm_overview(7). + +random.4 + mtk, after a note by alain portal + slight rewording to make life easier for non-native english + speakers. + +utmp.5 + mtk + add discussion of posix.1 utmpx specification. + provide a little more detail on fields of utmp structure. + added comments to macros for ut_type field. + correct the description of the ut_id field. + mtk + consolidate duplicated information about ut_tv and ut_session + on biarch platforms. + mtk + move some text from conforming to to notes. + removed some crufty text. + see also: add login(3), logout(3), logwtmp(3). + ut_linesize is 32 (not 12). + mtk + see also: add getutmp(3) + +man-pages.7 + mtk + enhanced the discussion of font conventions. + +signal.7 + mtk + note that the delivery order of multiple pending standard + signals is unspecified. + see also: add sigwait(3). + + +==================== changes in man-pages-3.03 ==================== + +released: 2008-07-08, konolfingen + + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +alain portal +andi kleen +hidetoshi seto +li zefan +paul jackson +sam varshavchik + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +getcpu.2 + andi kleen, with some text and edits by mtk + documents the getcpu(2) system call, introduced in linux 2.6.19. + +sched_getcpu.3 + mtk + documents sched_getcpu(3), a wrapper for getcpu(2), provided + since glibc 2.6. + +cpuset.7 + paul jackson, with review and editing by mtk, and comments by + hidetoshi seto and li zefan + a description of the cpuset file system, the mechanism introduced + kernel 2.6.12 for confining processes to designated processors + and nodes. (becomes the fourth largest page in man-pages!) + + +newly documented interfaces in existing pages +--------------------------------------------- + +readdir.3 + mtk + add documentation of readdir_r(). + + +new links +--------- + +updwtmpx.3 + alain portal + link to updwtmp.3 (3.02 changelog wrongly said this had been done). + +readdir_r.3 + mtk + link to readdir.3. + + +global changes +-------------- + +get_mempolicy.2 +mbind.2 +sched_setaffinity.2 +set_mempolicy.2 + mtk + see also: add getcpu(2). + +accept.2 +close.2 +connect.2 +dup.2 +epoll_wait.2 +fcntl.2 +flock.2 +futex.2 +msgop.2 +poll.2 +read.2 +recv.2 +select.2 +semop.2 +send.2 +sigwaitinfo.2 +spu_run.2 +wait.2 +write.2 +aio_suspend.3 +mq_receive.3 +mq_send.3 +scanf.3 +sem_wait.3 +usleep.3 +inotify.7 + mtk + errors: added reference to signal(7) in discussion of eintr. + +various pages + mtk + wrapped very long source lines. + + +changes to individual pages +--------------------------- + +accept.2 + mtk + small wording change. + +io_getevents.2 + mtk + errors: add eintr error. + +open.2 + mtk + errors: add eintr error. + +sigaction.2 + mtk + note circumstances in which each sa_* flag is meaningful. + mtk + describe posix specification, and linux semantics for + sa_nocldwait when establishing a handler for sigchld. + mtk + add pointer under sa_restart to new text in signal(7) + describing system call restarting. + mtk + other minor edits. + +truncate.2 + mtk + errors: added eintr error. + a few minor rewordings. + +wait.2 + mtk + remove statement that wuntraced and wcontinued only have effect + if sa_nocldstop has not been set for sigchld. that's not true. + +errno.3 + mtk + add a pointer to signal(7) for further explanation of eintr. + +getgrouplist.3 + mtk + see also: add passwd(5). + +readdir.3 + mtk + remove from synopsis; posix.1-2001 does not + require it. + some minor rewordings. + +sleep.3 + mtk + return value: explicitly mention interruption by signal handler. + see also: add signal(7). + +usleep.3 + mtk + posix.1-2001 also only documents einval. + +group.5 + mtk + see also: add getgrent(3), getgrnam(3). + +passwd.5 + mtk + see also: add getpwent(3), getpwnam(3). + +proc.5 + mtk + add pointer to description of /proc/pid/cpuset in cpuset(7). + +signal.7 + mtk + add a section describing system call restarting, and noting + which system calls are affected by sa_restart, and which + system calls are never restarted. + mtk + describe the aberrant linux behavior whereby a stop signal + plus sigcont can interrupt some system calls, even if no + signal handler has been established, and note the system + calls that behave this way. + mtk + note a few more architectures on which signal numbers are valid. + see also: added a number of pages. + mtk + update async-signal-safe function list for posix.1-2004 (which + adds sockatmark()). + + +==================== changes in man-pages-3.04 ==================== + +released: 2008-07-15, konolfingen + + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +alain portal +andrea arcangeli +andreas mohr +andrew morgan +erik bosman +john brooks +nikanth karthikesan +pavel heimlich +petr gajdos +sam varshavchik +serge hallyn +sripathi kodi +vincent lefevre + +apologies if i missed anyone! + + +web site +-------- + +licenses.html + mtk + a page describing the preferred licenses for new pages that + are contributed to man-pages. + + +new and rewritten pages +----------------------- + +utimensat.2 + mtk + new page documenting the utimensat() system call, new in 2.6.22, + and futimens() library function. + +end.3 + mtk + documents etext, edata, and end symbols. + + +newly documented interfaces in existing pages +--------------------------------------------- + +memchr.3 + mtk + add description of rawmemchr(). + +proc.5 + mtk + document /proc/config.gz (new in kernel 2.6). + mtk, based on text from documentation/vm/sysctl.txt + document /proc/sys/vm/oom_kill_allocating_task + (new in linux 2.6.24). + document /proc/sys/vm/oom_dump_tasks + (new in linux 2.6.25). + document /proc/sys/vm/panic_on_oom + (new in linux 2.6.18). + + +new links +--------- + +edata.3 +etext.3 + mtk + links to end.3. + +futimens.3 + mtk + link to new utimensat.2. + +getdate_err.3 + mtk + link to getdate.3. + +h_errno.3 + mtk + link to gethostbyname.3. + +optarg.3 +opterr.3 +optind.3 +optopt.3 + mtk + links to getopt.3. + +rawmemchr.3 + mtk + link to memchr.3. + +sys_errlist.3 +sys_nerr.3 + mtk + links to perror.3. + + +global changes +-------------- + +various pages + mtk + s/parameter/argument/ when talking about the things given + to a function call, for consistency with majority usage. + +various pages + mtk + s/unix/unix/, when not used as part of a trademark, + for consistency with majority usage in pages. + +various pages + mtk, after a note from alain portal + put see also entries into alphabetical order. + +various pages + mtk + remove period at end of see also list. + +various pages + mtk, after a note by alain portal + even when the conforming to section is just a list of standards, + they should be terminated by a period. + +getpriority.2 +mb_len_max.3 +mb_cur_max.3 +fwide.3 +mblen.3 +rtime.3 +st.4 +proc.5 +bootparam.7 +man-pages.7 +utf-8.7 +tcp.5 + mtk / alain portal + small wording fixes -- express <=, <, >=, > in words when in + running text. + +sched_setparam.2 +sched_setscheduler.2 +getgrent_r.3 +hash.3 + mtk + minor rewording w.r.t. use of the term "parameter". + +typographical or grammatical errors have been corrected in several +other places. (many, many thanks to alain portal!) + + +changes to individual pages +--------------------------- + +capget.2 + andrew morgan + update in line with addition of file capabilities and + 64-bit capability sets in kernel 2.6.2[45]. + +clock_nanosleep.2 + mtk + add "link with -lrt" to synopsis. + +getrusage.2 + sripathi kodi + document rusage_thread, new in 2.6.26. + mtk + improve description of rusage_children. + add pointer to /proc/pid/stat in proc(5). + other minor clean-ups. + +ioprio_set.2 + nikanth karthikesan + since linux 2.6.25, cap_sys_admin is longer required to set + a low priority (ioprio_class_idle). + +mount.2 + mtk + since linux 2.6.26, ms_rdonly honors bind mounts. + +openat.2 + mtk + see also: add utimensat(3). + +prctl.2 + serge hallyn, with some edits/input from mtk + document pr_capbset_read and pr_capbset_drop. + erik bosman + document pr_get_tsc and pr_set_tsc. + mtk, reviewed by andrea arcangeli + document pr_set_seccomp and pr_get_seccomp. + mtk + pr_set_keepcaps and pr_get_keepcaps operate on a per-thread + setting, not a per-process setting. + mtk + clarify fork(2) details for pr_set_pdeathsig. + mtk + add description of pr_set_securebits and pr_get_securebits, + as well as pointer to further info in capabilities(7). + mtk + pr_get_endian returns endianness info in location pointed to by + arg2 (not as function result, as was implied by previous text). + mtk + expand description of pr_set_name and pr_get_name. + mtk + return value: bring up to date for various options. + mtk + various improvements in errors. + mtk + note that pr_set_timing setting of pr_timing_timestamp is not + currently implemented. + mtk + minor changes: + * clarify wording for pr_get_unalign, pr_get_fpemu, and + pr_get_fpexc. + * some reformatting of kernel version information. + * reorder pr_get_endian and pr_set_endian entries. + +readlinkat.2 + john brooks / mtk + fix and reword erroneous return value text. + +recv.2 + mtk + noted which flags appeared in linux 2.2. + +sched_setaffinity.2 + mtk, after a fedora downstream patch + update type used for cpusetsize argument in synopsis. + +select.2 + andreas mohr / mtk + clarify "zero timeout" case. + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=490868. + +send.2 + mtk + noted which flags appeared in linux 2.2. + +sigaction.2 + mtk + document si_overrun and si_tid fields of siginfo structure. + add some text for si_trapno field. + the si_errno field is *generally* unused. + mtk + put descriptions of sa_* constants in alphabetical order. + +signal.2 + mtk + rewrote and expanded portability discussion. + notes: show the raw prototype of signal() (without use of + sighandler_t). + +signalfd.2 + mtk + modify description of ssi_trapno field. + +swapon.2 + mtk + fix two version number typos for max_swapfiles discussion: + s/2.6.10/2.4.10/ + +utime.2 + mtk + see also: add utimensat(2), futimens(3). + +dl_iterate_phdr.3 + alain portal + see also: add elf(5). + +crypt.3 + mtk, after a fedora downstream patch + describe additional encryption algorithms. + see also: https://bugzilla.redhat.com/show_bug.cgi?id=428280. + +errno.3 + mtk + small rewrites in description. + +exec.3 + mtk, after a note from alain portal + small rewording. + +exp10.3 + alain portal + see also: add log10(3). + +exp2.3 + alain portal + add c99 to conforming to. + +fgetgrent.3 + alain portal + add references to group(5). + mtk + minor rewordings. + see also: add fopen(3). + +fgetpwent.3 + alain portal + add reference to passwd(5). + mtk + minor rewordings. + see also: add fopen(3). + +frexp.3 + alain portal + add c99 to conforming to. + +futimes.3 + mtk + see also: remove futimesat(2); add utimensat(2). + +getopt.3 + mtk + add details on initial value of optind, and note that it can + be reset (to 1) to restart scanning of an argument vector. + add a notes section describing the glibc-specific behavior + when optind is reset to 0 (rather than 1). + see http://groups.google.com/group/comp.unix.programmer/browse_thread/thread/be0d0b7a07a165fb + mtk + note glibc extensions under conforming to. + +getspnam.3 + mtk + improve comments on struct spwd. + +getpw.3 + alain portal + return value: note that errno is set on error. + mtk + add einval error. + +insque.3 + mtk / alain portal + minor rewordings. + +log.3 + alain portal + remove unnecessary sentence in errors. + +log10.3 + mtk + see also: add exp10(3). + +offsetof.3 + alain portal + small wording improvement. + +pow.3 + alain portal + remove unnecessary sentence in errors. + +printf.3 + mtk / alain portal + many small formatting fixes. + +proc.5 + mtk + remove redundant summary list of files in description of + /proc/sys/kernel. + make kernel version for /proc/sys/kernel/panic_on_oops more precise. + make kernel version for /proc/sys/kernel/pid_max more precise. + add documentation/sysctl/vm.txt to see also. + other minor edits. + +profil.3 + mtk / alain portal + small wording improvement. + +rtime.3 + mtk, after a note by alain portal + clarify meaning of midnight on 1 jan 1900/1970. + mtk + remove netdate(1) and rdate(1) from see also, since these pages + don't seem to exist on linux systems. + +scanf.3 + vincent lefevre / mtk + clarify treatment of initial white space by %% conversion + specification. + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=435648. + mtk + many small formatting fixes. + +stdin.3 + alain portal + rename considerations section to notes, and relocate + to appropriate place on page. + +tmpfile.3 + mtk, after a note by alain portal + prepend "posix.1-2001 specifies that: " to the sentence stating + that tmpfile() may write to stdout. (afaics, glibc's tmpfile() + does not do this.) + +ttyname.3 + alain portal + remove unnecessary sentence in errors. + +wcsdup.3 + alain portal + make wording more precise: the memory allocated by wcsdup(3) + *should* be freed with free(3). + +wordexp.3 + alain portal / mtk + move example into proper example section. + +tty_ioctl.4 + mtk / petr gajdos + the features in the "get and set window size" subsection + require the inclusion of . + +capabilities.7 + serge hallyn, plus a bit of work by mtk + document file capabilities, per-process capability bounding set, + changed semantics for cap_setpcap, and other changes in 2.6.2[45]. + add cap_mac_admin, cap_mac_override, cap_setfcap. + various smaller fixes. + mtk, plus review by serge hallyn and andrew morgan + add text detailing how cap_setpcap (theoretically) permits -- on + pre-2.6.25 kernels, and 2.6.25 and later kernels with file + capabilities disabled -- a thread to change the capability sets + of another thread. + add section describing rules for programmatically adjusting + thread capability sets. + add some words describing purpose of inheritable set. + note existence of config_security_capabilities config option. + describe rationale for capability bounding set. + document securebits flags (new in 2.6.26). + remove obsolete bugs section. + see also: add getcap(8), setcap(8), and various libcap pages. + mtk + add text noting that if we set the effective flag for one + file capability, then we must also set the effective flag for all + other capabilities where the permitted or inheritable bit is set. + mtk + since linux 2.6.25, cap_sys_admin is no longer required for + ioprio_set() to set ioprio_class_idle class. + mtk + reword discussion of cap_linux_immutable to be file-system neutral. + +man-pages.7 + mtk + a list of standards in the conforming to list should be + terminated by a period. + the list of pages in a see also list should not be + terminated by a period. + +tcp.7 + mtk + correct a detail for sysctl_tcp_adv_win_scale. + formatting fixes. + + +==================== changes in man-pages-3.05 ==================== + +released: 2008-07-23, konolfingen + + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +alain portal +andries brouwer +brian m. carlson +fabian kreutz +franck jousseaume +sam varshavchik +uli schlacter + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +matherr.3 + mtk, with review by andries brouwer + a description of the svid-specified mechanism for reporting + math exceptions. + see http://thread.gmane.org/gmane.linux.man/266. + +math_error.7 + mtk, with review and suggested input from andries brouwer + a description of how math functions report errors. + see http://thread.gmane.org/gmane.linux.man/249. + + +global changes +-------------- + +various pages + mtk + s/floating point/floating-point/ when used attributively. + +various pages + mtk + for consistency with majority usage: + s/plus infinity/positive infinity/ + s/minus infinity/negative infinity/ + +typographical or grammatical errors have been corrected in several +other places. + + +changes to individual pages +--------------------------- + +brk.2 + mtk + see also: add end(3). + +open.2 + brian m. carlson / mtk + remove ambiguity in description of support for o_excl on nfs. + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=491791. + +prctl.2 + mtk + place options in some semblance of alphabetical order. + (no content or formatting changes were made.) + +cerf.3 + mtk + bump version number: these functions are still missing in + glibc 2.8. + +fenv.3 + mtk + see also: add math_error(7). + +infinity.3 + mtk + see also: add math_error(7). + +nan.3 + mtk + remove unneeded "compile with" piece in synopsis. + see also: add math_error(7). + +rpc.3 + mtk / franck jousseaume + fix errors introduced into a few prototypes when converting + function declarations to use modern c prototypes in man-pages-2.75. + +ipv6.7 + mtk, after a report from uli schlacter + document the ipv6_v6only flag. + + +==================== changes in man-pages-3.06 ==================== + +released: 2008-08-05, konolfingen + + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +andreas jaeger +andries brouwer +fabian kreutz +gernot tenchio +sam varshavchik +tolga dalman + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +erfc.3 + mtk + created after removing the erfc() material from erf.3. + documents the complementary error function. + +y0.3 + mtk + created after removing the y*() material from j0.3. + documents the bessel functions of the second kind. + included errors section; noted that an exception is not + raised on underflow, see also + http://sources.redhat.com/bugzilla/show_bug.cgi?id=6806; + and errno is not set on overflow, see also + http://sources.redhat.com/bugzilla/show_bug.cgi?id=6808; + included bugs section noting that errno is incorrectly + set for pole error; see also + http://sources.redhat.com/bugzilla/show_bug.cgi?id=6807. + +scalbln.3 + mtk + created after removing the scalbln*() and scalbn*() material + from scalb.3. documents scalbln() and scalbn() functions. + included errors section; noted that errno is not set; see + also http://sources.redhat.com/bugzilla/show_bug.cgi?id=6803. + + +new and changed links +--------------------- + +erfcf.3 +erfcl.3 + mtk + changed these links to point to new erfc.3 page. + +scalblnf.3 +scalblnl.3 +scalbn.3 +scalbnf.3 +scalbnl.3 + mtk + changed these links to point to new scalbln.3 page. + +y0f.3 +y0l.3 +y1.3 +y1f.3 +y1l.3 +yn.3 +ynf.3 +ynl.3 + mtk + changed these links to point to new y0.3 page. + + +global changes +-------------- + +various pages + mtk + s/floating point/floating-point/ when used attributively. + +typographical or grammatical errors have been corrected in several +other places. + + +changes to individual pages +--------------------------- + +crypt.3 + mtk + tweak discuss text describing support for blowfish. + +ctime.3 + mtk / gernot tenchio + added some words to make clear that the string returned by + ctime() and asctime() is null-terminated. + +math_error.7 + sam varshavchik + reverse order of synopsis and name sections. + mtk + notes: summarize the state of glibc support for exceptions + and errno for error reporting. + + +changes to individual pages (math functions) +-------------------------------------------- + +almost all of the changes in this release relate to math man pages. +very many changes were made to the math pages, including: + +* fixed feature test macros (ftms). often, the ftm requirements + for the "float" and "long double" versions of a math function are + different from the requirements for the "double" version. each math + page now shows the correct ftm requirements for all three versions + of the function(s) it describes. this may have required either + a change to the existing ftm text (if the requirements for the + "double" function were already described), or the addition of an ftm + description to a synopsis where one was not previously present + (typically because the "double" version of the function does not + require any ftms to be defined). +* conforming to: in many cases, posix.1-2001 was not mentioned. + where a function is specified in posix.1-2001, this is now noted. + also, statements about what other standards a function conforms to + were generally clarified. (the wording about which functions conformed + to c99 was previously often done as an add on sentence; now it is made + part of the first sentence of the conforming to section, along with + posix.1-2001.) +* return value: in many cases, pages lacked descriptions of the return + value when the function arguments are special values such as +0, -0, + nan (not-a-number), +infinity, -infinity, etc. this has been fixed. + i carried out tests on glibc 2.8 to ensure that all of these + functions match the return value descriptions (and the posix.1-2001 + requirements). +* errors: many pages lacked a clear (or indeed any) description of + how errno is set on error and what exception is raised for each error. + this has been fixed. the errors sections are now generally headed up + as per the posix.1 way of doing things, describing pole / range / + domain errors, as applicable. + i carried out tests on glibc 2.8 to ensure that all of these + functions match the errors descriptions. deviations from posix.1-2001 + requirements have been filed as glibc bug reports, and noted in the + man pages. (the pages now describe the situation for errors as at glibc + 2.8; i may eventually try and extend the text with descriptions of + changes in older versions of glibc.) + note: one point that has not been covered in any page is the + circumstances that generate inexact (fe_inexact) exceptions. + (the details for these exceptions are not specified in posix.1-2001, + and i haven't gone looking for the standards that describe the details.) + +acos.3 + mtk + synopsis: added feature test macro requirements. + return value: added details for special argument cases. + rewrote errors section. + updated conforming to. + +acosh.3 + mtk + synopsis: fixed feature test macro requirements. + added return value section. + rewrote errors section. + updated conforming to. + +asin.3 + mtk + synopsis: added feature test macro requirements. + return value: added details for special argument cases. + rewrote errors section. + updated conforming to. + +asinh.3 + mtk + synopsis: added feature test macro requirements. + description: some rewording. + return value: added details for special argument cases. + added (null) errors section. + updated conforming to. + +atan.3 + mtk + synopsis: added feature test macro requirements. + description: some rewording. + return value: added details for special argument cases. + added (null) errors section. + updated conforming to. + +atan2.3 + mtk + synopsis: added feature test macro requirements. + description: some rewording. + return value: added details for special argument cases. + added (null) errors section. + updated conforming to. + +atanh.3 + mtk + synopsis: fixed feature test macro requirements. + added return value section. + rewrote errors section. + updated conforming to. + added bugs section noting that pole error sets errno to edom, + when it should be erange instead; see also + http://sources.redhat.com/bugzilla/show_bug.cgi?id=6759. + +cbrt.3 + mtk + synopsis: fixed feature test macro requirements. + added return value section. + added (null) errors section. + updated conforming to. + +ceil.3 + mtk + synopsis: added feature test macro requirements. + description: enhanced. + return value: added details for special argument cases. + rewrote errors section. + updated conforming to. + notes: added some details. + +copysign.3 + mtk + added return value section. + updated conforming to. + +cos.3 + mtk + synopsis: added feature test macro requirements. + rewrote return value section. + added errors section; noted errno is not set: + http://sources.redhat.com/bugzilla/show_bug.cgi?id=6780. + updated conforming to. + +cosh.3 + mtk + synopsis: added feature test macro requirements. + added return value section. + added errors section. + updated conforming to. + +erf.3 + mtk + removed the erfc() material (there is now a new erfc page). + reason: the functions are logically separate; also their + return values differ, and it would have been confusing + to document them on the same page. + synopsis: fixed feature test macro requirements. + added return value section. + added errors section; noted that errno is not set; see + http://sources.redhat.com/bugzilla/show_bug.cgi?id=6785. + updated conforming to. + +exp.3 + mtk + synopsis: added feature test macro requirements. + added return value section. + added errors section; noted that errno is not set; see + http://sources.redhat.com/bugzilla/show_bug.cgi?id=6786. + updated conforming to. + +exp10.3 + mtk + synopsis: added feature test macro requirements. + added return value section. + added errors section; noted that errno is not set for underflow; + see http://sources.redhat.com/bugzilla/show_bug.cgi?id=6787. + +exp2.3 + mtk + added return value and errors sections. + updated conforming to. + +expm1.3 + mtk + synopsis: fixed feature test macro requirements. + added return value section. + added errors section; noted that errno is not set for overflow; + see http://sources.redhat.com/bugzilla/show_bug.cgi?id=6788. + updated conforming to. + added bugs section, describing bogus underflow exception for -large, + see http://sources.redhat.com/bugzilla/show_bug.cgi?id=6778; + and describing bogus invalid exception for certain +large, + see http://sources.redhat.com/bugzilla/show_bug.cgi?id=6814. + +fabs.3 + mtk + synopsis: added feature test macro requirements. + added return value section. + updated conforming to. + +fdim.3 + mtk + synopsis: added feature test macro requirements. + description: some rewording. + added return value section. + added errors section; noted that errno is not set; see + also http://sources.redhat.com/bugzilla/show_bug.cgi?id=6796. + updated conforming to. + +fenv.3 + mtk + make style of writing exception names consistent with other + pages and posix.1-2001. + updated conforming to. + +finite.3 + mtk + synopsis: fixed feature test macro requirements. + +floor.3 + mtk + synopsis: added feature test macro requirements. + description: enhanced. + return value: added details for special argument cases. + rewrote errors section. + updated conforming to. + +fma.3 + mtk + synopsis: added feature test macro requirements. + description: some rewording. + added return value section. + added errors section; noted that errno is not set; see + also http://sources.redhat.com/bugzilla/show_bug.cgi?id=6801. + updated conforming to. + +fmax.3 +fmin.3 + mtk + name: make description clearer + synopsis: added feature test macro requirements. + synopsis: remove unneeded "compile with" piece. + conforming to: added posix.1-2001. + added return value and errors sections. + +fmod.3 + mtk + synopsis: added feature test macro requirements. + return value: added details for special argument cases. + rewrote errors section; noted that errno is not always set; see + also http://sources.redhat.com/bugzilla/show_bug.cgi?id=6783. + updated conforming to. + +fpclassify.3 + mtk + minor wording changes. + conforming to: added posix.1-2001. + see also: add signbit(3). + +frexp.3 + mtk + synopsis: added feature test macro requirements. + added details to return value section. + added (null) errors section. + conforming to: added posix.1-2001. + +gamma.3 + mtk + synopsis: fixed feature test macro requirements. + added (null) return value section referring to tgamma(3). + added (null) errors section referring to tgamma(3). + conforming to: rewrote. + +hypot.3 + mtk + synopsis: fixed feature test macro requirements. + description: note that calculation is done without causing + undue overflow or underflow. + added return value section. + added errors section; noted that errno is not always set; see + also http://sources.redhat.com/bugzilla/show_bug.cgi?id=6795. + updated conforming to. + +ilogb.3 + mtk + synopsis: added feature test macro requirements. + rewrote return value section. + rewrote errors section; noted that errno is not set, and in some + cases an exception is not raised; see also + http://sources.redhat.com/bugzilla/show_bug.cgi?id=6794. + conforming to: added posix.1-2001. + +isgreater.3 + mtk + name: make description clearer + improve the description of isunordered(). + added return value and errors sections. + formatting fixes. + a few wording improvements. + +j0.3 + mtk + removed material for the y*() functions to a separate y0.3 page. + reason: the return values and errors/exceptions differ, and it + would have been confusing to document them on the same page. + added return value section. + added errors section; noted that errno is not set; see + also http://sources.redhat.com/bugzilla/show_bug.cgi?id=6805. + +ldexp.3 + mtk + synopsis: added feature test macro requirements. + added return value and errors sections. + updated conforming to. + +lgamma.3 + mtk + note that these functions are deprecated. + synopsis: fixed feature test macro requirements. + added return value and errors sections referring to lgamma(3). + added bugs section noting that pole error sets errno to edom, + when it should be erange instead; see also + http://sources.redhat.com/bugzilla/show_bug.cgi?id=6777. + +log.3 + mtk + synopsis: added feature test macro requirements. + added return value section. + rewrote errors section. + updated conforming to. + +log10.3 + mtk + synopsis: added feature test macro requirements. + added return value section. + rewrote errors section. + updated conforming to. + +log1p.3 + mtk + synopsis: fixed feature test macro requirements. + added return value section. + added errors section; noted that errno is not set; see + also http://sources.redhat.com/bugzilla/show_bug.cgi?id=6792. + updated conforming to. + +log2.3 + mtk + added return value section. + rewrote errors section. + updated conforming to. + +logb.3 + mtk + synopsis: fixed feature test macro requirements. + description: added a little detail; some rewordings. + return value: added details for special argument cases. + rewrote errors section; noted that errno is not set; see + also http://sources.redhat.com/bugzilla/show_bug.cgi?id=6793. + conforming to: added posix.1-2001. + +lrint.3 + mtk + description: some rewording. + return value: added details for special argument cases. + added errors section; noted that errno is not set; see + also http://sources.redhat.com/bugzilla/show_bug.cgi?id=6798. + conforming to: added posix.1-2001. + +lround.3 + mtk + return value: added details for special argument cases. + rewrote errors section; noted that errno is not set; see + also http://sources.redhat.com/bugzilla/show_bug.cgi?id=6797. + conforming to: added posix.1-2001. + +modf.3 + mtk + synopsis: added feature test macro requirements. + return value: added details for special argument cases. + added (null) errors section. + conforming to: added posix.1-2001. + +nan.3 + mtk + small wording changes. + conforming to: added posix.1-2001. + +nextafter.3 + mtk + synopsis: fixed feature test macro requirements. + return value: added details for special argument cases. + added errors section; noted that errno is not set; see + also http://sources.redhat.com/bugzilla/show_bug.cgi?id=6799. + conforming to: added posix.1-2001. + +pow.3 + mtk + synopsis: added feature test macro requirements. + added return value section. + rewrote errors section. + updated conforming to. + added bugs section noting that pole error sets errno to edom, + when it should be erange instead; see also + http://sources.redhat.com/bugzilla/show_bug.cgi?id=6776. + +remainder.3 + mtk + synopsis: fixed feature test macro requirements. + description: added some details. + return value: added details for special argument cases. + rewrote errors section; noted that errno is not always set; see + also http://sources.redhat.com/bugzilla/show_bug.cgi?id=6783. + updated conforming to. + added bugs section noting that remainder(nan(""), 0) + wrongly causes a domain error; see + http://sources.redhat.com/bugzilla/show_bug.cgi?id=6779 + +remquo.3 + mtk + added return value section. + added errors section; noted that errno is not set; see + also http://sources.redhat.com/bugzilla/show_bug.cgi?id=6801. + updated conforming to. + +fmax.3 +fmin.3 + mtk + name: make description clearer + synopsis: added feature test macro requirements. + synopsis: remove unneeded "compile with" piece. + conforming to: added posix.1-2001. + added return value and errors sections. + +fmod.3 + mtk + synopsis: added feature test macro requirements. + return value: added details for special argument cases. + rewrote errors section; noted that errno is not always set; see + also http://sources.redhat.com/bugzilla/show_bug.cgi?id=6783. + updated conforming to. + +fpclassify.3 + conforming to: added posix.1-2001. + +rint.3 + mtk + synopsis: fixed feature test macro requirements. + description: added some details. + return value: added details for special argument cases. + errors: no errors can occur (previous text was misleading). + conforming to: added posix.1-2001. + notes: point out that lrint() may be preferred in some cases. + +round.3 + mtk + description: added some details. + return value: added details for special argument cases. + errors: no errors can occur (previous text was misleading). + conforming to: added posix.1-2001. + notes: point out that lround() may be preferred in some cases. + +scalb.3 + mtk + removed the scalbn() and scalbln() material to a separate + scalbln.3 page. reason: scalb() is obsolete; also the + exception/error conditions differ somewhat, so that it + would have been confusing to document them on the same page. + synopsis: fixed feature test macro requirements. + description: some rewrites and added details. + added return value section. + added errors section; noted that errno is not set; see + also http://sources.redhat.com/bugzilla/show_bug.cgi?id=6803 + and http://sources.redhat.com/bugzilla/show_bug.cgi?id=6804. + conforming to: rewrote. + +signbit.3 + mtk + synopsis: added feature test macro requirements. + synopsis: remove unneeded "compile with" piece. + added return value section. + added (null) errors section. + conforming to: added posix.1-2001. + +sin.3 + mtk + synopsis: added feature test macro requirements. + added return value section. + added errors section; noted errno is not set: + http://sources.redhat.com/bugzilla/show_bug.cgi?id=6781. + updated conforming to. + +sincos.3 + mtk + description: added details for special argument cases. + added (null) return value section. + added errors section. + +sinh.3 + mtk + synopsis: added feature test macro requirements. + added return value section. + added errors section. + updated conforming to. + +sqrt.3 + mtk + synopsis: added feature test macro requirements. + added return value section. + rewrote errors section. + updated conforming to. + +tan.3 + mtk + synopsis: added feature test macro requirements. + added return value section. + added errors section. + added errors section; noted errno is not set: + http://sources.redhat.com/bugzilla/show_bug.cgi?id=6782. + updated conforming to. + +tanh.3 + mtk + synopsis: added feature test macro requirements. + added return value section. + added (null) errors section. + updated conforming to. + +tgamma.3 + mtk + added return value section. + rewrote errors section; noted that errno is not set / + incorrectly set in some cases; see also + http://sources.redhat.com/bugzilla/show_bug.cgi?id=6809 + and http://sources.redhat.com/bugzilla/show_bug.cgi?id=6810. + conforming to: added posix.1-2001. + added notes section to hold text explaining origin of tgamma(). + +trunc.3 + mtk + return value: small rewording. + conforming to: added posix.1-2001. + added notes section explaining that result may be too large + to store in an integer type. + + +==================== changes in man-pages-3.07 ==================== + +released: 2008-08-12, konolfingen + + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +alain portal +andries brouwer +christoph lameter +cliff wickman +fabian kreutz +filippo santovito +gerrit renker +heikki orsila +khalil ghorbal +lee schermerhorn +maxin john +reuben thomas +samuel thibault +sam varshavchik +soh kam yung +stephane chazelas +pavel heimlich +reuben thomas + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +move_pages.2 + christoph lameter, various edits and improvements by mtk + documentation of the move_pages() system call. + this page was formerly part of the numactl package, but really + belongs in man-pages (since it describes a kernel interface). + +clock_getcpuclockid.3 + mtk + new page documenting the clock_getcpuclockid() library function, + available since glibc 2.2. + +udplite.7 + gerrit renker + document the linux implementation of the udp-lite protocol, + new in linux 2.6.20. + + +newly documented interfaces in existing pages +--------------------------------------------- + +proc.5 + christoph lameter, minor edits and improvements by mtk + documentation of the /proc/pid/numa_maps file. + this material was formerly the numa_maps.5 page in the numactl + package, but really belongs in man-pages (since it describes + a kernel interface). + + +global changes +-------------- + +nanosleep.2 +inet_ntop.3 +inet_pton.3 +scanf.3 +initrd.4 + mtk + fix mis-ordered (.sh) sections. + +connect.2 +socket.2 +rtnetlink.3 +arp.7 +ddp.7 +ip.7 +ipv6.7 +netlink.7 +packet.7 +raw.7 +rtnetlink.7 +socket.7 +tcp.7 +udp.7 +unix.7 +x25.7 + mtk + s/pf_/af_/ for socket family constants. reasons: the af_ and + pf_ constants have always had the same values; there never has + been a protocol family that had more than one address family, + and posix.1-2001 only specifies the af_* constants. + +typographical or grammatical errors have been corrected in several +other places. + + +changes to individual pages +--------------------------- + +execve.2 + mtk + the floating-point environment is reset to the default + during an execve(). + +get_mempolicy.2 + lee schermerhorn + misc cleanup of get_mempolicy(2): + + mention that any mode flags will be saved with mode. + i don't bother to document mode flags here because we + already have a pointer to set_mempolicy(2) for more info + on memory policy. mode flags are discussed there. + + remove some old, obsolete [imo] notes and 'roff comments. + lee schermerhorn + update the get_mempolicy(2) man page to add in the description of + the mpol_f_mems_allowed flag, added in 2.6.23. + mtk + document additional einval error that occurs is mpol_f_mems_allowed + is specified with either mpol_f_addr or mpol_f_node. + +getitimer.2 + mtk + conforming to: posix.1-2008 marks getitimer() and setitimer() + obsolete. + +mbind.2 + lee schermerhorn + fix error conditions, now that the kernel silently ignores + nodes outside the task's cpuset, as long as one valid node + remains. + + now that cpuset man page exists, we can refer to it. remove + stale comment regarding lack thereof. + lee schermerhorn + add brief discussion of mode flags. + lee schermerhorn + attempt to clarify discussion of mpol_default. + mtk + fix uri reference for libnuma. + +mprotect.2 + mtk / maxin john + remove efault from errors. under enomem error, note that + efault was the error produced in some cases for kernels before + 2.4.19. + +msgctl.2 + mtk, after a note from filippo santovito + in the ipc_perm structure definition, some fields were + incorrectly named: s/key/__key/ and s/seq/__seq/. + +set_mempolicy.2 + lee schermerhorn + fix up the error return for nodemask containing nodes disallowed by + the process' current cpuset. disallowed nodes are now silently ignored, + as long as the nodemask contains at least one node that is on-line, + allowed by the process' cpuset and has memory. + + now that we have a cpuset man page, we can refer to cpusets directly + in the man page text. + + lee schermerhorn + another attempt to rationalize description of mpol_default. + + since ~2.6.25, the system default memory policy is "local allocation". + mpol_default itself is a request to remove any non-default policy and + "fall back" to the surrounding context. try to say that without delving + into implementation details. + + lee schermerhorn + add discussion of mempolicy mode flags to set_mempolicy(2). + this adds another reason for einval. + +setpgid.2 + mtk + conforming to: posix.1-2008 marks setpgrp() obsolete. + +semctl.2 + mtk, after a note from filippo santovito + in the ipc_perm structure definition, some fields were + incorrectly named: s/key/__key/ and s/seq/__seq/. + +shmctl.2 + filippo santovito / mtk + in the ipc_perm structure definition, some fields were + incorrectly named: s/key/__key/ and s/seq/__seq/. + +utime.2 + mtk + conforming to: posix.1-2008 marks utime() obsolete. + conforming to: posix.1-2008 removes the posix.1-2001 legacy + marking of utimes(), so mention of this point has been + removed from the page. + +vfork.2 + mtk + conforming to: posix.1-2008 removes the specification of vfork(). + +atan2.3 + fabian kreutz + see also add carg(3). + +bcmp.3 + mtk + conforming to: posix.1-2008 removes the specification of bcmp(). + +bsd_signal.3 + mtk + conforming to: posix.1-2008 removes the specification ofcw + bsd_signal(). + +bzero.3 + mtk + conforming to: posix.1-2008 removes the specification of bzero(). + +cexp2.3 + mtk + availability: these functions are still not in glibc + as at version 2.8. + +clock_getres.3 + mtk + see also: add clock_getcpuclockid(3). + +clog2.3 + mtk + availability: these functions are still not in glibc + as at version 2.8. + +ctime.3 + mtk + posix.1-2008 marks asctime(), asctime_r(), ctime(), and ctime_r() + as obsolete. + +dprintf.3 + mtk + conforming to: these functions are nowadays in posix.1-2008. + +ecvt.3 + mtk + conforming to: posix.1-2008 removes the specifications of + ecvt() and fcvt(). + +ftime.3 + mtk + conforming to: posix.1-2008 removes the specification of ftime(). + +ftw.3 + mtk + conforming to: posix.1-2008 marks ftw() as obsolete. + +gcvt.3 + mtk + conforming to: posix.1-2008 removes the specification of gcvt(). + +getcwd.3 + reuben thomas / mtk + clarify description of getcwd() for buf==null case; + conforming to: according to posix.1, the behavior of getcwd() + is unspecified for the buf==null case. + mtk + add an introductory paragraph giving an overview of what these + functions do. + fix error in description of getwd(): it does not truncate the + pathname; rather, it gives an error if the pathname exceeds + path_max bytes. + rewrote return value section. + add einval enametoolong errors for getwd(). + various other clarifications and wording fixes. + conforming to: posix.1-2001 does not define any errors for + getwd(). + conforming to: posix.1-2008 removes the specification of getwd(). + +gethostbyname.3 + mtk + conforming to: posix.1-2008 removes the specifications of + gethostbyname(), gethostbyaddr(), and h_errno. + +gets.3 + mtk + conforming to: posix.1-2008 removes the specification of gets(). + +iconv.3 +iconv_close.3 +iconv_open.3 + mtk + versions: these functions are available in glibc since version 2.1. + +index.3 + mtk + conforming to: posix.1-2008 removes the specifications of + index() and rindex(). + +isalpha.3 + mtk + conforming to: posix.1-2008 marks isalpha() as obsolete. + +makecontext.3 + mtk + conforming to: posix.1-2008 removes the specifications of + makecontext() and swapcontext(). + +memchr.3 + mtk + versions: memrchr() since glibc 2.2; rawmemchr() since glibc 2.1. + +mempcpy.3 + mtk + versions: mempcpy() since glibc 2.1. + +mktemp.3 + mtk + conforming to: posix.1-2008 removes the specification of mktemp(). + +opendir.3 + mtk + conforming to: posix.1-2008 specifies fdopendir(). + +rand.3 + mtk + conforming to: posix.1-2008 marks rand_r() as obsolete. + +siginterrupt.3 + mtk + conforming to: posix.1-2008 marks siginterrupt() as obsolete. + +sigset.3 + mtk + conforming to: posix.1-2008 marks sighold(), sigignore(), + sigpause(), sigrelse(), and sigset() as obsolete. + +strchr.3 + mtk + versions: strchrnul() since glibc 2.1.1. + +tempnam.3 + mtk + conforming to: posix.1-2008 marks tempnam() as obsolete. + +tmpnam.3 + mtk + conforming to: posix.1-2008 marks tmpnam() as obsolete. + +toascii.3 + mtk + conforming to: posix.1-2008 marks toascii() as obsolete. + +ualarm.3 + mtk + conforming to: posix.1-2008 removes the specification of ualarm(). + +ulimit.3 + mtk + conforming to: posix.1-2008 marks ulimit() as obsolete. + +usleep.3 + mtk + conforming to: posix.1-2008 removes the specification of usleep(). + +standards.7 + mtk + updated details for posix.1-2008, and noted that if + posix.1-2001 is listed in the conforming to section of a man + page, then the reader can assume that the interface is also + specified in posix.1-2008, unless otherwise noted. + +time.7 + mtk + see also: add clock_getcpuclockid(3). + +udp.7 + mtk + see also: add udplite(7). + + +changes to individual pages (math functions) +-------------------------------------------- + +various changes here following on from the big update to the +math pages in the previous release. test results going back +glibc 2.3.2 (so far) allowed updates to various pages to note +changes in historical behavior for error reporting by math +functions. thanks to the following people for providing me +with test results on various distributions and glibc versions: +alain portal, andries brouwer, fabian kreutz, heikki orsila, +khalil ghorbal, pavel heimlich, reuben thomas, samuel thibault, +soh kam yung, and stephane chazelas + +cabs.3 +cacos.3 +cacosh.3 +carg.3 +casin.3 +casinh.3 +catan.3 +catanh.3 +ccos.3 +ccosh.3 +cexp.3 +cimag.3 +clog.3 +clog10.3 +conj.3 +cpow.3 +cproj.3 +creal.3 +csin.3 +csinh.3 +csqrt.3 +ctan.3 +ctanh.3 +exp10.3 +exp2.3 +fdim.3 +fenv.3 +fma.3 +fmax.3 +fmin.3 +log2.3 +lrint.3 +lround.3 +nan.3 +pow10.3 +remquo.3 +round.3 +scalbln.3 +sincos.3 +tgamma.3 +trunc.3 + mtk + added versions section noting that these functions first + appeared in glibc in version 2.1. + +cosh.3 + mtk + bugs: in glibc 2.3.4 and earlier, an fe_overflow exception is not + raised when an overflow occurs. + +fenv.3 + mtk / fabian kreuz + provide more detail in the description of rounding modes. + add text describing flt_rounds (formerly in fma.3). + add bugs section pointing out the flt_rounds does not reflect + changes by fesetround(). + +fma.3 + mtk + remove text about flt_rounds, replacing with a cross-reference + to fenv(3). + +fpclassify.3 + mtk + conforming to: note that the standards provide a weaker guarantee + for the return value of isinf(). + +log.3 + mtk + bugs: in glibc 2.5 and earlier, log(nan("")) produces a bogus + fe_invalid exception. + +lround.3 + mtk + add reference to fenv(3) for discussion of current rounding mode. + +nextafter.3 + mtk + bugs: in glibc 2.5 and earlier these functions do not raise an + fe_underflow exception on underflow. + +pow.3 + mtk + bugs: described buggy nan return when x is negative and y is large. + see also: http://sources.redhat.com/bugzilla/show_bug.cgi?id=3866. + bugs: note the bogus fe_invalid exception that occurred in glibc + 2.3.2 and earlier on overflow and underflow. + +remainder.3 + mtk + add reference to fenv(3) for discussion of current rounding mode. + +round.3 + mtk + add reference to fenv(3) for discussion of current rounding mode. + +scalb.3 + mtk + conforming to: posix.1-2008 removes the specification of scalb(). + +tgamma.3 + mtk + bugs: in glibc 2.3.3, tgamma(+-0) produced a domain error + instead of a pole error. + +y0.3 + mtk + in glibc 2.3.2 and earlier, these functions do not raise an + fe_invalid exception for a domain error. + +math_error.7 + mtk + rewrite introductory paragraph. + point out that a nan is commonly returned by functions that report + a domain error. + + +==================== changes in man-pages-3.08 ==================== + +released: 2008-08-27, zurich + + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +gerrit renker +li zefan +mike bianchi +sam varshavchik +venkatesh srinivas +vijay kumar + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +getnetent_r.3 + mtk + documents getnetent_r(), getnetbyname_r(), + and getnetbyaddr_r(), the reentrant equivalents of + getnetent(), getnetbyname(), and getnetbyaddr(). + +getprotoent_r.3 + mtk + documents getprotoent_r(), getprotobyname_r(), and + getprotobynumber_r(), the reentrant equivalents of + getprotoent(), getprotobyname(), and getprotobynumber(). + +getrpcent_r.3 + mtk + documents getrpcent_r(), getrpcbyname_r(), and + getrpcbynumber_r(), the reentrant equivalents of + getrpcent(), getrpcbyname(), and getrpcbynumber(). + +getservent_r.3 + mtk + documents getservent_r(), getservbyname_r(), and + getservbyport_r(), the reentrant equivalents of + getservent(), getservbyname(), and getservbyport(). + +numa.7 + mtk + a new page giving overview details for the linux numa interfaces. + incorporates some material from mbind.2, and the description + of /proc/pid/numa_maps from proc.5. + + +newly documented interfaces in existing pages +--------------------------------------------- + +crypt.3 + mtk + add description of crypt_r(). + + +new and changed links +--------------------- + +crypt.3 + mtk + new link to crypt.3. + +getnetbyname_r.3 +getnetbyaddr_r.3 + mtk + new links to new getnetent_r.3. + +getprotobyname_r.3 +getprotobynumber_r.3 + mtk + new links to new getprotoent_r.3. + +getrpcbyname_r.3 +getrpcbynumber_r.3 + mtk + new links to new getrpcent_r.3. + +getservbyname_r.3 +getservbyport_r.3 + mtk + new links to new getservent_r.3. + +numa_maps.5 + mtk + link to new numa(7) page, which incorporates the + /proc/pid/numa_maps description. + as part of the numactl() package, the /proc/pid/numa_maps + documentation was in a numa_maps.5 page; this link + ensures that "man 5 numa_maps" still works. + (eventually, we may want to remove this link.) + + +global changes +-------------- + +get_mempolicy.2 +mbind.2 +move_pages.2 +set_mempolicy.2 + mtk + add reference to numa(7) for information on library support. + added a versions section. + see also: add numa(7). + +faccessat.2 +fchmodat.2 +fchownat.2 +fstatat.2 +mkdirat.2 +mknodat.2 +linkat.2 +openat.2 +readlinkat.2 +renameat.2 +symlinkat.2 +unlinkat.2 +mkfifoat.3 +psignal.3 +strsignal.3 + mtk + these interfaces are specified in posix.1-2008. + + +changes to individual pages +--------------------------- + +eventfd.2 + vijay kumar + when an eventfd overflows, select() indicates the file as both + readable and writable (not as having an exceptional condition). + +fcntl.2 + mtk + f_dupfd_cloexec is specified in posix.1-2008. + +getrlimit.2 + mtk + notes: add text mentioning the shell 'ulimit' (or 'limit') + built-in command for setting resource limits. + +gettimeofday.2 + mtk + conforming to: posix.1-2008 marks gettimeofday() as obsolete. + +link.2 + mtk + note kernel version where linux stopped following symbolic + links in 'oldpath'; see also http://lwn.net/articles/294667. + posix.1-2008 makes it implementation-dependent whether or not + 'oldpath' is dereferenced if it is a symbolic link. + add a reference to linkat(2) for an interface that allows + precise control of the treatment of symbolic links. + +mbind.2 + mtk + remove material on library support and numactl; that material + is now in numactl.7. + +mmap.2 + mtk + add kernel version numbers for map_32bit. + add some details on map_32bit (see http://lwn.net/articles/294642). + +move_pages.2 + mtk + added versions (from kernel 2.6.18) and conforming to sections. + +open.2 + mtk + o_cloexec is specified in posix.1-2008. + +socket.2 + mtk + s/d/domain/ for name of argument. + add reference to socket(2) for further information on + domain, type, and protocol arguments. + +utimensat.2 + mtk + conforming to: posix.1-2008 specifies utimensat() and futimens(). + +dirfd.3 + mtk + conforming to: add posix.1-2008; other minor changes. + +exec.3 + mtk + small rewording: "s/returned/failed with/ [an error]". + +fmemopen.3 + mtk + since glibc 2.7, it is possible to seek past the end of + a stream created by open_memstream(). add a bugs section + describing the bug in earlier glibc versions. + +gethostbyname.3 + mtk + clarify exactly which functions are obsoleted by getnameinfo() + and getaddrinfo(). + +getnetent.3 + mtk + rephrase description in terms of a database, rather than a file. + note that each of the get*() functions opens a connection to + the database if necessary. + the database connection is held open between get*() calls if + 'stayopen' is non-zero (not necessarily 1). + s/zero terminated list/null-terminated list/ + mtk + in glibc 2.2, the type of the 'net' argument for getnetbyaddr() + changed from 'long' to 'uint32_t'. + mtk + note that the gethostbyaddr() 'net' argument is in host byte order. + mtk + return value: emphasize that returned pointer points to a + statically allocated structure. + see also: add getnetent_r.3. + +getprotoent.3 + mtk + rephrase description in terms of a database, rather than a file. + note that each of the get*() functions opens a connection to + the database if necessary. + the database connection is held open between get*() calls if + 'stayopen' is non-zero (not necessarily 1). + s/zero terminated list/null-terminated list/ + mtk + return value: emphasize that returned pointer points to a + statically allocated structure. + see also: add getprotoent_r.3. + +getrpcent.3 + mtk + s/rpc/rpc/. + rephrase description in terms of a database, rather than a file. + note that each of the get*() functions opens a connection to + the database if necessary. + s/zero terminated list/null-terminated list/ + mtk + return value: emphasize that returned pointer points to a + statically allocated structure. + see also: add getrpcent_r.3. + +getservent.3 + mtk + rephrase description in terms of a database, rather than a file. + note that each of the get*() functions opens a connection to + the database if necessary. + the database connection is held open between get*() calls if + 'stayopen' is non-zero (not necessarily 1). + s/zero terminated list/null-terminated list/ + mtk + return value: emphasize that returned pointer points to a + statically allocated structure. + see also: add getservent_r.3. + +mkdtemp.3 + mtk + conforming to: this function is specified in posix.1-2008. + +mq_notify.3 + venkatesh srinivas + s/sigev_notify_function/sigev_thread_function/ + as per http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=494956. + +realpath.3 + mtk + relocate text for resolved_path==null case to description. + posix.1-2001 leaves the resolved_path==null case as + implementation-defined; posix.1-2008 specifies the behavior + described in this man page. + +sem_init.3 + mtk + posix.1-2008 rectifies the posix.1-2001 omission, specifying + that zero is returned by a successful sem_init() call. + +core.5 + mike bianchi / mtk + make the page more helpful to non-programmers by referencing + the documentation of the shell's 'ulimit' command in the + discussion of rlimit_core and rlimit_fsize. + see also: add bash(1). + mtk + note that a core dump file can be used in a debugger. + +proc.5 + mtk + remove /proc/pid/numa_maps material (it is now in numa(7)). + +cpuset.7 + mtk + see also: add numa(7). + +inotify.7 + mtk / li zefan + explain bug that occurred in coalescing identical events in + kernels before 2.6.25. + (see commit 1c17d18e3775485bf1e0ce79575eb637a94494a2 + "a potential bug in inotify_user.c" in the 2.6.25 changelog.) + +pthreads.7 + mtk + update thread-safe functions list with changes in posix.1-2008. + see also: add proc(5). + +signal.7 + mtk + update list of async-signal-safe functions for posix.1-2008. + + +==================== changes in man-pages-3.09 ==================== + +released: 2008-09-10, munich + + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +bernd eckenfels +bruno haible +carsten emde +christopher head +h. peter anvin +jan engelhardt +joe korty +marko kreen +martin (joey) schulze +mats wichmann +michael schurter +mike bianchi +mike frysinger +sam varshavchik +suka +timothy s. nelson +tolga dalman +török edwin + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +fopencookie.3 + mtk + document fopencookie(3), a library function that allows + custom implementation of a stdio stream. + +networks.5 + martin (joey) schulze, with a few light edits by mtk + documents the /etc/networks file. + + +global changes +-------------- + +various pages + mtk + s/time zone/timezone/ for consistency across pages and + with posix.1. + +kill.2 +sigaction.2 +sigpending.2 +sigprocmask.2 +sigsuspend.2 +confstr.3 +ctermid.3 +ctime.3 +ferror.3 +flockfile.3 +fopen.3 +getaddrinfo.3 +getgrnam.3 +getnameinfo.3 +getopt.3 +getpwnam.3 +longjmp.3 +popen.3 +rand.3 +readdir.3 +setjmp.3 +sigsetops.3 +sigwait.3 +strtok.3 +tzset.3 +unlocked_stdio.3 + mtk + add/fix feature test macro requirements. + + +changes to individual pages +--------------------------- + +fcntl.2 + mtk, after a note by mike bianchi + more clearly and consistently describe whether + or not the third argument to fcntl() is required, + and what its type should be. + mtk + move description of negative l_len from notes, integrating + it into the discussion of file locking. + minor rewrites of the text on file locking. + +getrusage.2 + bernd eckenfels + see also: add clock(3), clock_gettime(3). + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=353475 + +ioctl_list.2 + mtk + remove old sentence about where to send updates for this page. + add more detail on mount options that prevent updates to atime. + +sched_setscheduler.2 + carsten emde + update kernel version numbers relating to real-time support. + +stat.2 + h. peter anvin + note that lstat() will generally not trigger automounter + action, whereas stat() will. + +clock.3 + bernd eckenfels + see also: add clock_gettime(3). + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=353475 + +clock_getres.3 + tolga dalman / mtk + add "link with -lrt" to synopsis; remove now redundant + sentence mentioning librt from notes. + +getdate.3 + mtk + rewrite description of getdate_r() and integrate into main text + (rather than describing in notes). + other parts rewritten for greater clarity. + make it clearer in the main text that glibc does not implement %z; + remove discussion of that point from notes. + added an example program. + +hsearch.3 + mtk + noted that table size as specified by 'nel' is immutable. + described differences between hsearch() and hsearch_r(). + added missing pieces to return value. + added a number of new entries under errors. + notes: added some basic advice on sizing the hash table; + noted that when a table is destroyed, the caller is responsible + for freeing the buffers pointed to by 'key' and 'data' fields. + one of the bugs was fixed in glibc 2.3. + rewrote and clarified various other pieces. + rename arguments for reentrant functions, using same name as + glibc headers: s/ret/retval/; s/tab/htab/. + mtk, after a suggestion by timothy s. nelson + integrate discussion of reentrant functions into main discussion + (rather than as a short paragraph at the end). + +iconv.3 + bruno haible + describe "shift sequence" input. + +ptsname.3 + sukadev + fix return type of ptsname_r() in synopsis. + +readdir.3 + h. peter anvin + s/stat(2)/lstat(2)/ when discussing d_type (since we + are talking about a case where we might be interested to + whether the file itself is a symbolic link). + +sigsetops.3 + chris head, signed-off-by: mike frysinger + fix typo: s/sigdelset/sigorset/ + +proc.5 + mats wichmann / mtk + s/\[number]/[pid]/ in file names for /proc/pid files. + and similar changes for task/[tid] sub-directories. + mtk / mats wichmann + in the description if /proc/[pid]/environ, remove reference to + lilo(8)/grub(8) since there seems to be nothing in those pages + that related to this /proc file. + michael schurter / mtk + remove sentence wrongly saying that /proc/meminfo reports + info in bytes; + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=462969 + mtk + note that /proc/meminfo reports system-wide memory usage + statistics. + joe korty + document new fields in /proc/interrupts that were added in + linux 2.6.24. + +unix.7 + marko kreen + since glibc 2.8, _gnu_source must be defined in order to get + the definition of the ucred structure from . + + +==================== changes in man-pages-3.10 ==================== + +released: 2008-09-23, munich + + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +andré goddard rosa +george spelvin +pavel heimlich +sam varshavchik +john reiser + +apologies if i missed anyone! + + +global changes +-------------- + +closedir.3 +dirfd.3 +readdir.3 +rewinddir.3 +scandir.3 +seekdir.3 +telldir.3 + mtk + fix 'dir' argument name: should be 'dirp'. + posix.1-2008 and glibc call this argument 'dirp' (consistent + with the fact that it is a *pointer* to a dir structure). + + +changes to individual pages +--------------------------- + +clone.2 + mtk, after a comment by john reiser + clarify text describing getpid() caching bug for clone() wrapper. + see also: + http://sourceware.org/bugzilla/show_bug.cgi?id=6910 + https://bugzilla.redhat.com/show_bug.cgi?id=417521 + +getpid.2 + mtk, after a comment by john reiser + describe getpid()'s pid caching and its consequences. + +timerfd_create.2 + sam varshavchik + s/it_interval/it_value/ when talking about timerfd_abstime. + +closedir.3 + george spelvin + clarify closedir()'s treatment of underlying file descriptor. + +tsearch.3 + andré goddard rosa + fix memory leak in example program. + add use of tdestroy to example program. + mtk + add "#define _gnu_source" to example program. + +protocols.5 + mtk, after a note from pavel heimlich + remove see also references to nonexistent guides to yellow pages + +services.5 + mtk + remove some out-of-date bugs. + mtk, after a note from pavel heimlich + remove see also references to nonexistent guides to yellow pages + and bind/hesiod docs. + mtk + remove crufty text about use of comma instead of slash to separate + port and protocol. + + +==================== changes in man-pages-3.11 ==================== + +released: 2008-10-07, munich + + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +andré goddard rosa +eugene v. lyubimkin +gergely soos +kirill a. shutemov +marko kreen +maxin b. john +maxin john +michael kerrisk +nicolas françois +pavel heimlich +ricardo catalinas jiménez +sam varshavchik + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +umount.2 + michael kerrisk + create a new page for umount() and umount2() by extracting + existing material from mount.2 page. + + +new and changed links +--------------------- + +umount2.2 + michael kerrisk + change link to point to new umount.2 + the umount2() material migrated from mount.2 to umount.2 + + +changes to individual pages +--------------------------- + +execve.2 + michael kerrisk + _sc_arg_max is no longer necessarily constant + posix.1-2001 says that the values returned by sysconf() + are constant for the life of the process. + but the fact that, since linux 2.6.23, arg_max is settable + via rlimit_stack means _sc_arg_max is no longer constant, + since it can change at each execve(). + michael kerrisk + linux now imposes a floor on the arg_max limit + starting with linux 2.6.23, the arg_max limit became + settable via (1/4 of) rlimit_stack. this broke abi + compatibility if rlimit_stack was set such that arg_max + was < 32 pages. document the fact that since 2.6.25 + linux imposes a floor on arg_max, so that the old limit + of 32 pages is guaranteed. + + for some background on the changes to arg_max in + kernels 2.6.23 and 2.6.25, see: + http://sourceware.org/bugzilla/show_bug.cgi?id=5786 + http://bugzilla.kernel.org/show_bug.cgi?id=10095 + http://thread.gmane.org/gmane.linux.kernel/646709/focus=648101, + checked into 2.6.25 as + commit a64e715fc74b1a7dcc5944f848acc38b2c4d4ee2. + + also some reordering/rewording of the discussion of arg_max. + +fallocate.2 + michael kerrisk + note lack of glibc wrapper; caller must use syscall(2) + glibc doesn't (and quite probably won't) include a + wrapper for this system call. therefore, point out that + potential callers will need to use syscall(2), and rewrite + the return value text to show things as they would be if + syscall() is used. + + michael kerrisk + refer reader to posix_fallocate(3) for portable interface + add a para to start of page that points out that this is the + low-level, linux-specific api, and point the reader to + posix_fallocate(3) for the portable api. + +getdents.2 +readdir.3 + michael kerrisk + d_type is currently only supported on ext[234] + as at kernel 2.6.27, only ext[234] support d_type. + on other file systems, d_type is always set to dt_unknown (0). + +getdents.2 + michael kerrisk + add an example program + michael kerrisk + comment out linux_dirent fields with varying location + the location of the fields after d_name varies according to + the size of d_name. we can't properly declare them in c; + therefore, put those fields inside a comment. + michael kerrisk + the dt_* constants are defined in + michael kerrisk + remove header files from synopsis + none of the header files provides what is needed. + calls are made via syscall(2). + michael kerrisk + the programmer must define the linux_dirent structure + point out that this structure is not defined in glibc headers. + michael kerrisk + s/dirent/linux_dirent/ + the structure isn't currently defined in glibc headers, + and the kernel name of the structure is 'linux_dirent' (as + was already used in some, but not all, places in this page). + +getrlimit.2 + michael kerrisk + reword/relocate discussion of bsd's historical rlimit_ofile + the old sentence sat on its own in an odd place, and anyway the + modern bsds use the name rlimit_nofile. + michael kerrisk + refer to execve(2) for rlimit_stack's effect on arg_max + refer the reader to new text in execve(2) that describes how + (since linux 2.6.23) rlimit_stack determines the value of arg_max. + +getrusage.2 + michael kerrisk + rusage measures are preserved across execve(2) + +mlock.2 + maxin john + add eagain error. + +move_pages.2 + nicolas françois + make a detail of eperm error more precise + +mount.2 + michael kerrisk + add description of per-process namespaces + describe per-process namespaces, including discussion + of clone() and unshare clone_newns, and /proc/pid/mounts. + michael kerrisk + list a few other file systems that we may see in /proc/filesystems + add some modern file systems to that list (xfs, jfs, ext3, + reiserfs). + michael kerrisk + document ms_silent (and ms_verbose) + +mount.2 +umount.2 + michael kerrisk + split umount*() out into a separate page + the length of this page means that it's becoming difficult + to parse which info is specific to mount() versus + umount()/umount2(), so split the umount material out into + its own page. + +pause.2 + michael kerrisk + remove mention of words "library function" + this really is a system call. + +readdir.2 + michael kerrisk + the programmer must declare the old_linux_dirent structure + glibc does not provide a definition of this structure. + michael kerrisk + s/dirent/old_linux_dirent/ + nowadays, this is the name of the structure in the + kernel sources. + michael kerrisk + remove words "which may change" + these words are slightly bogus: although the interface + is obsolete, for abi-compatibility reasons, the kernel folk + should never be changing this interface. + michael kerrisk + remove header files from synopsis + glibc doesn't provide any support for readdir(2), + so remove these header files (which otherwise suggest + that glibc does provide the required pieces). + +recv.2 + nicolas françois + move kernel version number to first mention to msg_errqueue. + +semop.2 + kirill a. shutemov + fix typo in example + (the '&' before sop in the semop() call is unneeded.) + +send.2 + michael kerrisk + make kernel version for msg_confirm more precise + s/2.3+ only/since linux 2.3.15/ + +sigaction.2 + michael kerrisk + refer reader to signal(7) for an overview of signals + explain semantics of signal disposition during fork() and execve() + refer to signal(7) for more details on signal mask. + +sigaltstack.2 + michael kerrisk + explain inheritance of alternate signal stack across fork(2) + +sigwaitinfo.2 + michael kerrisk + distinguish per-thread and process-wide signals + a sentence clarifying that pending signal set is union of + per-thread and process-wide pending signal sets. + + michael kerrisk + these interfaces have per-thread semantics + the page was previously fuzzy about whether these interfaces + have process-wide or per-thread semantics. (e.g., now the + page states that the calling *thread* (not process) is suspended + until the signal is delivered.) + +sigpending.2 + michael kerrisk + explain effect of fork() and execve() for pending signal set + michael kerrisk + explain how thread's pending signal set is defined + the pending set is the union of per-thread pending signals + and process-wide pending signals. + +sigprocmask.2 + michael kerrisk + explain effects of fork() and execve() for signal mask + +splice.2 + michael kerrisk + note that splice_f_move is a no-op since kernel 2.6.21 + +syscall.2 + michael kerrisk + add more detail about wrapper functions + add a few more details about work generally done by wrapper + functions. note that syscall(2) performs the same steps. + +tkill.2 + michael kerrisk + einval error can also occur for invalid tgid + the einval error on an invalid tgid for tgkill() was + not documented; this change documents it. + +utimensat.2 + michael kerrisk + posix.1-2008 revision will likely affect ftms for futimens() + make it clear that the posix.1 revision that is likely + to affect the feature test macro requirements for futimens() + is posix.1-2008. + nicolas françois + make various wordings a little more precise. + the times argument point to *an array of* structures, and the + man-page should say that consistently. + +wait4.2 + michael kerrisk + wait3() is a library function layered on wait4(). + on linux wait3() is a library function implemented on top + of wait4(). (knowing this is useful when using strace(2), + for example.) + +atan2.3 + nicolas françois + fix error in description of range or return value + in recent changes to the man page, mtk accidentally changed + the description of the return value range to -pi/2..pi/2; + the correct range is -pi..pi. + +cmsg.3 + nicolas françois + add parentheses after macro names. + +ctime.3 + michael kerrisk + clarify mktime()'s use of tm_isdst + describe use of tm_isdst for input to mktime(); + explain how mktime() modifies this field. + (this field is left unchanged in case of error.) + + http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=500178 + michael kerrisk + clarify wording for ctime_r() and asctime_r() to indicate that + the buffer must be at least 26 *bytes*. + michael kerrisk + minor rewording of mktime() description. + +floor.3 + nicolas françois + floor.3: fix error in description: s/smallest/largest/ + +hsearch.3 + andré goddard rosa + call hdestroy() after using hash table created by hcreate(), + for the sake of completeness + +mq_getattr.3 + michael kerrisk + mq_getattr() and mq_setattr() are layered on mq_getsetattr(2) + mq_getattr() and mq_setattr() are library functions layered on + top of the mq_getsetattr(2) system call. + (this is useful info for users of strace(1).) + +mq_receive.3 + michael kerrisk + mq_send() is a library function layered on mq_timedreceive() syscall + this info is useful for users of strace(1). + +mq_send.3 + michael kerrisk + mq_send() is a library function layered on mq_timedsend() syscall + this info is useful for users of strace(1). + +nextafter.3 + nicolas françois + make description more precise: s/next/largest/ + +readdir.3 + michael kerrisk + see also: add getdents(2) + because readdir() is implemented on top of getdents(2). + +realpath.3 + michael kerrisk + clarify that returned pathname is null terminated + also clarify that null-byte is included in path_max limit. + +proc.5 + michael kerrisk + rewrite and simplify description of /proc/mounts + most of the relevant discussion is now under /proc/pid/mounts; + all that needs to be here is a mention of the pre-2.4.19 + system-wide namespace situation, and a reference to the + discussion under /proc/pid/mounts. + michael kerrisk + add description of /proc/pid/mounts + largely cribbed from existing /proc/mounts discussion, which is + about to be rewritten. + +mq_overview.7 + michael kerrisk + add mq_notify() to list of lib. functions and syscalls in mq api + +signal.7 + michael kerrisk + improve description in name section + add mention of sigaltstack(2). + describe syscalls that synchronously wait for a signal, + give overview of syscalls that block until a signal is caught + add overview of interfaces for sending signals. + + michael kerrisk + describe semantics w.r.t. fork() and execve() + include text describing semantics of fork() and execve() for + signal dispositions, signal mask, and pending signal set. + + +==================== changes in man-pages-3.12 ==================== + +released: 2008-10-29, bucaramanga + + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +bert wesarg +christian grigis +christoph hellwig +didier +halesh s +j.h.m. dassen (ray) +jason spiro +lefteris dimitroulakis +michael b. trausch +pierre cazenave +stefan puiu + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +pthread_attr_init.3 + michael kerrisk + new page for pthread_attr_init(3) and pthread_attr_destroy(3) + +pthread_attr_setdetachstate.3 + michael kerrisk + new page for pthread_attr_setdetachstate(3) and + pthread_attr_getdetachstate(3) + +pthread_attr_setguardsize.3 + michael kerrisk + new page for pthread_attr_setguardsize(3) and + pthread_attr_getguardsize(3) + +pthread_attr_setscope.3 + michael kerrisk + new page for pthread_attr_setscope(3) and pthread_attr_getscope(3) + +pthread_attr_setstack.3 + michael kerrisk + new page for pthread_attr_setstack(3) and pthread_attr_getstack(3) + +pthread_attr_setstackaddr.3 + michael kerrisk + new page for pthread_attr_setstackaddr(3) and + pthread_attr_getstackaddr(3) + +pthread_attr_setstacksize.3 + michael kerrisk + new page for pthread_attr_setstacksize(3) and + pthread_attr_getstacksize(3) + +pthread_create.3 + michael kerrisk + new page describing pthread_create(3) + +pthread_detach.3 + michael kerrisk + new page for pthread_detach(3) + +pthread_equal.3 + michael kerrisk + new page for pthread_equal(3) + +pthread_exit.3 + michael kerrisk + new page describing pthread_exit(3) + +pthread_getattr_np.3 + michael kerrisk + new page for pthread_getattr_np(3) + +pthread_join.3 + michael kerrisk + new page for pthread_join(3) + +pthread_self.3 + michael kerrisk + new page for pthread_self(3) + +pthread_tryjoin_np.3 + michael kerrisk + new page for pthread_tryjoin_np(3) and pthread_timedjoin_np(3) + + +newly documented interfaces in existing pages +--------------------------------------------- + +dup.2 + michael kerrisk + add description of dup3() + dup3() was added in kernel 2.6.27. + +epoll_create.2 + michael kerrisk + add description of new epoll_create1() + the new epoll_create1() system call appeared in linux 2.6.27. + +eventfd.2 + michael kerrisk + describe eventfd2() and efd_nonblock and efd_cloexec + linux 2.6.27 added eventfd(), which supports a flags argument + that eventfd() did not provide. the flags so far implemented + are efd_nonblock and efd_cloexec, + +inotify_init.2 + michael kerrisk + add description of inotify_init1() + the inotify_init1() system call was added in linux 2.6.27. + +pipe.2 + michael kerrisk + add description of new pipe2() syscall + pipe2() was added in 2.6.27. describe the o_nonblock and + o_cloexec flags. + +signalfd.2 + michael kerrisk + describe signalfd4() and sfd_nonblock and sfd_cloexec + linux 2.6.27 added signalfd4(), which supports a flags argument + that signalfd() did not provide. the flags so far implemented + are sfd_nonblock and sfd_cloexec. + + +new and changed links +--------------------- + +dup3.2 + michael kerrisk + new link to dup.2 + dup.2 now contains the description of the new dup3() syscall. + +epoll_create1.2 + michael kerrisk + new link to epoll_create.2 + epoll_create.2 now includes a description of the new + epoll_create1() system call. + +eventfd2.2 + michael kerrisk + new link to eventfd.2 + the eventfd.2 page has some details on the eventfd2() system call, + which was new in linux 2.6.27. + +inotify_init1.2 + michael kerrisk + new link to inotify_init.2 + inotify_init.2 now includes a description of the new + inotify_init1() system call. + +pipe2.2 + michael kerrisk + new link to pipe.2 + pipe(2) now contains a description of the new pipe2() syscall. + +pthread_attr_destroy.3 + michael kerrisk + new link to new pthread_attr_init.3 + +pthread_attr_getdetachstate.3 + michael kerrisk + new link to new pthread_attr_setdetachstate.3 + +pthread_attr_getguardsize.3 + michael kerrisk + new link to new pthread_attr_setguardsize.3 + +pthread_attr_getscope.3 + michael kerrisk + new link to new pthread_attr_setscope.3 + +pthread_attr_getstack.3 + michael kerrisk + new link to new pthread_attr_setstack.3 + +pthread_attr_getstackaddr.3 + michael kerrisk + new link to new pthread_attr_setstackaddr.3 + +pthread_attr_getstacksize.3 + michael kerrisk + new link to new pthread_attr_setstacksize.3 + +pthread_timedjoin_np.3 + michael kerrisk + new link to new pthread_tryjoin_np.3 + +signalfd4.2 + michael kerrisk + new link to signalfd.2 + signalfd.2 now includes text describing signalfd4() system call, + new in linux 2.6.27. + + +global changes +-------------- + +eventfd.2, getdents.2, mprotect.2, signalfd.2, timerfd_create.2, +wait.2, backtrace.3, clock_getcpuclockid.3, end.3, fmemopen.3, +fopencookie.3, getdate.3, getgrouplist.3, getprotoent_r.3, +getservent_r.3, gnu_get_libc_version.3, inet.3, inet_pton.3, +makecontext.3, matherr.3, offsetof.3, pthread_attr_init.3, +pthread_create.3, pthread_getattr_np.3, sem_wait.3, strtol.3, core.5 + michael kerrisk + add ".ss program source" to example + add ".ss program source" to clearly distinguish shell session and + descriptive text from actual program code. + +eventfd.2, execve.2, getdents.2, ioprio_set.2, mprotect.2, +signalfd.2, timerfd_create.2, wait.2, backtrace.3, +clock_getcpuclockid.3, end.3, fmemopen.3, fopencookie.3, frexp.3, +getdate.3, getgrouplist.3, getprotoent_r.3, getservent_r.3, +gnu_get_libc_version.3, inet.3, inet_pton.3, makecontext.3, +malloc.3, matherr.3, offsetof.3, pthread_attr_init.3, +pthread_create.3, pthread_getattr_np.3, sem_wait.3, strftime.3, +strtok.3, strtol.3, core.5, proc.5, cpuset.7, mq_overview.7 + michael kerrisk + format user input in shell sessions in boldface + +frexp.3, strftime.3, strtok.3 + michael kerrisk + relocate shell session above example program + move the shell session text that demonstrates the use of + the example program so that it precedes the actual + example program. this makes the page consistent with the + majority of other pages. + + +changes to individual pages +--------------------------- + +epoll_create.2 + michael kerrisk + say more about unused epoll_create() 'size' arg + supply a little more explanation about why the 'size' argument + of epoll_create() is nowadays ignored. + +eventfd.2 + michael kerrisk + remove crufty text relating to flags argument + remove sentence saying that glibc adds a flags argument + to the syscall; that was only relevant for the older + eventfd() system call. +getdents.2 + christoph hellwig + fix text relating to dt_unknown and 'd_type' support + some file systems provide partial support for 'dt_type', + returning dt_unknown for cases they don't support. + update the discussion of 'd_type' and dt_unknown to + support this. + +getpeername.2, getsockname.2 + michael kerrisk + see also: add ip(7) and unix(7) + +getsockopt.2 + michael kerrisk + einval can also occur if 'optval' is invalid + in some cases, einval can occur if 'optval' is invalid. + note this, and point reader to an example in ip(7). + in response to: + http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=216092 + +inotify_init.2 +pipe.2 +timerfd_create.2 + michael kerrisk + clarify *_nonblock description + make it clear that the nonblock flag sets an attribute in the new + open file description. + +sched_yield.2 + michael kerrisk + rewrite description in terms of threads + the text formerly described the operation of sched_yield() in + terms of processes. it should be in terms of threads. + michael kerrisk + add notes text on appropriate use of sched_yield() + strategic calls to sched_yield() can be used to improve + performance, but unnecessary use should be avoided. + +sigaction.2 + michael kerrisk + clarify that sa_mask affects the *per-thread* signal mask + the page didn't previously clearly explain the scope of the + signal mask that is affected by sa_mask. + +signalfd.2 + michael kerrisk + remove crufty text relating to flags argument + remove sentence saying that glibc adds a flags argument + to the syscall; that was only relevant for the older + signalfd() system call. + +sigprocmask.2 + michael kerrisk + clarify that sigprocmask() operates on a per-thread mask + the first sentence of the page was vague on the scope of the + attribute changed by sigprocmask(). reword to make this + clearer and add a sentence in notes to explicitly state that + the signal mask is a per-thread attribute. + +socket.2 + michael kerrisk + document sock_nonblock and sock_cloexec flags + these flags, specified in the 'type' argument, are supported + since linux 2.6.27. + +socketpair.2 + michael kerrisk + refer to socket(2) for sock_cloexec and sock_nonblock + refer the reader to socket(2) for a description of the sock_cloexec + and sock_nonblock flags, which are supported by socketpair() since + linux 2.6.27. + +syscalls.2 + michael kerrisk + add new 2.6.27 system calls + add pipe2(), dup3(), epoll_create1(), inotify_init1(), + eventfd2(), signalfd4(). + +timerfd_create.2 + michael kerrisk + document timerfd_create() tfd_cloexec and tfd_nonblock + tfd_cloexec and tfd_nonblock are supported since linux 2.6.27. + +vfork.2 + michael kerrisk + clarify meaning of "child releases the parent's memory" + the man page was not explicit about how the memory used by + the child is released back to the parent. + +ctime.3 + michael kerrisk + ctime_r() and localtime_r() need not set 'timezone' and 'daylight' + the man page already noted that these functions need not set + 'tzname', but things could be clearer: it tzset() is not called, + then the other two variables also are not set. + + also, clarify that ctime() does set 'timezone' and 'daylight'. + +dlopen.3 + michael kerrisk + ld_library_path is inspected once, at program start-up + make it clear that ld_library_path is inspected *once*, at + program start-up. (verified from source and by experiment.) + +fmemopen.3 + michael kerrisk + document binary mode (mode 'b') + glibc 2.9 adds support to fmemopen() for binary mode opens. + binary mode is specified by inclusion of the letter 'b' in + the 'mode' argument. + +getaddrinfo.3 + michael kerrisk + clarify error descriptions with some examples + clarify the description of some errors by giving examples + that produce the errors. (text added for eai_service and + eai_socktype.) + + also, add an error case for eai_badflags. + +gethostbyname.3 + michael kerrisk + rationalize text on posix.1-2001 obsolete interfaces + posix.1 marks gethostbyname(), gethostbyaddr(), and 'h_errno' + as obsolete. the man page explained this, but with some + duplication. remove the duplication, and otherwise tidy up + discussion of this point. + +popen.3 + michael kerrisk + change one-line description in name + s%process i/o%pipe stream to or from a process% + michael kerrisk + document 'e' (close-on-exec) flag + glibc 2.9 implements the 'e' flag in 'type', which sets the + close-on-exec flag on the underlying file descriptor. + +raise.3 + michael kerrisk + see also: add pthread_kill(3) + +readdir.3 + christoph hellwig + fix text relating to dt_unknown and 'd_type' support + (this mirrors the previous change to getdents.2) + some file systems provide partial support for 'dt_type', + returning dt_unknown for cases they don't support. + update the discussion of 'd_type' and dt_unknown to + support this. + +strcpy.3 + jason spiro + strengthen warning about checking against buffer overruns + http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=413940 + +tty_ioctl.4 + michael kerrisk + explain capability requirements for tioccons + explain capability requirements for tioccons, and describe + changes in 2.6.10 relating to capabilities. + michael kerrisk + explain capability requirements for various ioctls + for tiocslcktrmios, tiocsctty, tiocexcl, explain the exact + capability that is required (the text formerly just said "root" + in each case). + +proc.5 + michael kerrisk + document /proc/sys/kernel/threads-max + defines the system-wide limit on the number of threads (tasks). + +utmp.5 + pierre cazenave + it is just "other" who should not have write perms on utmp + the page was vague before, saying that utmp should not be + writable by any user. this isn't true: it can be, and + typically is, writable by user and group. + +epoll.7 + michael kerrisk + mention epoll_create1() as part of epoll api + epoll_create1() was added in linux 2.6.27, and extends the + functionality of epoll_create(). + +inotify.7 + michael kerrisk + mention inotify_init1() in overview of api + discuss the new inotify_init1() system call in the overview of + the inotify api. + +ip.7 + michael kerrisk + detail einval error for ip_add_membership socket option + in response to: + http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=216092 + +iso_8859-7.7 + lefteris dimitroulakis + add drachma, euro, and greek ypogegrammeni + also, amend description of characters 0241 and 0242. + +man-pages.7 + michael kerrisk + example shell sessions should have user input boldfaced + +pthreads.7 + michael kerrisk + describe return value from pthreads functions + describe the usual success (0) and failure (non-zero) returns, + and note that posix.1-2001 specifies that pthreads functions + can never fail with the error eintr. + +signal.7 + michael kerrisk + timeouts make socket interfaces non-restartable + if setsockopt() is used to set a timeout on a socket(), + then the various socket interfaces are not automatically + restarted, even if sa_restart is specified when + establishing the signal handler. analogous behavior occurs + for the "stop signals" case. + +socket.7 + michael kerrisk + see also: add unix(7) + +ld.so.8 + michael kerrisk + document ld_use_load_bias + drawing heavily on jakub jelinek's description in + http://sources.redhat.com/ml/libc-hacker/2003-11/msg00127.html + (subject: [patch] support ld_use_load_bias) + --inhibit-rpath is ignored for setuid/setgid ld.so + the --inhibit-rpath option is ignored if ld.so is setuid/setgid + (not if the executable is setuid/setgid). + michael kerrisk + since glibc 2.4, setuid/setgid programs ignore ld_origin_path + michael kerrisk + fix description of ld_profile and ld_profile_output + clarify that ld_profile is pathname or a soname, + and identify name of profiling output file. + fix description of ld_profile_output, which wasn't even close to + the truth. (but why did it remain unfixed for so many years?) + michael kerrisk + since glibc 2.3.4, setuid/setgid programs ignore ld_dynamic_weak + michael kerrisk + since version 2.3.5, setuid/setgid programs ignore ld_show_auxv + michael kerrisk + reorder lists of ld_* environment variables alphabetically + michael kerrisk + since glibc 2.3.4, setuid/setgid programs ignore ld_debug + + +==================== changes in man-pages-3.13 ==================== + +released: 2008-11-07, bucaramanga + + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +bert wesarg +karsten weiss +lefteris dimitroulakis +olaf van der spek +sam varshavchik +török edwin +ulrich mueller +valdis kletnieks + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +pthread_attr_setaffinity_np.3 + michael kerrisk + new page for pthread_attr_setaffinity_np(3) and + pthread_attr_getaffinity_np(3) + +pthread_attr_setschedparam.3 + michael kerrisk + new page for pthread_attr_setschedparam(3) and + pthread_attr_getschedparam(3) + +pthread_attr_setschedpolicy.3 + michael kerrisk + new page for pthread_attr_setschedpolicy(3) and + pthread_attr_getschedpolicy(3) + +pthread_setaffinity_np.3 + michael kerrisk + new page for pthread_setaffinity_np(3) and pthread_getaffinity_np(3) + +pthread_setschedparam.3 + michael kerrisk + new page for pthread_setschedparam(3) and pthread_getschedparam(3) + +pthread_setschedprio.3 + michael kerrisk + new page for pthread_setschedprio(3) + + +new and changed links +--------------------- + +pthread_attr_getaffinity_np.3 + michael kerrisk + new link to new pthread_attr_setaffinity_np.3 + +pthread_attr_getschedparam.3 + michael kerrisk + new link to new pthread_attr_setschedparam.3 + +pthread_attr_getschedpolicy.3 + michael kerrisk + new link to new pthread_attr_setschedpolicy.3 + +pthread_getaffinity_np.3 + michael kerrisk + new link to new pthread_setaffinity_np.3 + +pthread_getschedparam.3 + michael kerrisk + new link to new pthread_setschedparam.3 + + +global changes +-------------- + +pthread_attr_setaffinity_np.3 +pthread_getattr_np.3 +pthread_setaffinity_np.3 +pthread_tryjoin_np.3 + michael kerrisk + explain _np suffix + add text to conforming to explaining that the "_np" + suffix is because these functions are non-portable. + + +changes to individual pages +--------------------------- + +sched_setaffinity.2 + michael kerrisk + see also: add sched_getcpu(3) + +sched_setaffinity.2 + michael kerrisk + see also: add pthread_setaffinity_np(3) + +sched_setaffinity.2 + michael kerrisk + clarify einval error for cpusetsize < kernel mask size + for sched_setaffinity(), the einval error that occurs + if 'cpusetsize' is smaller than the kernel cpu set size only + occurs with kernels before 2.6.9. + +vfork.2 + michael kerrisk + child holds parent's memory until execve() or *termination* + the page was phrased in a few places to describe the child as + holding the parent's memory until the child does an execve(2) + or an _exit(2). the latter case should really be the more + general process termination (i.e., either _exit(2) or abnormal + termination). + +clock_getres.3 + michael kerrisk + clock_process_cputime_id and clock_thread_cputime_id not settable + according to posix.1-2001, the clock_process_cputime_id and + clock_thread_cputime_id clocks should be settable, but + currently they are not. + +pthread_attr_setstacksize.3 + michael kerrisk, after a report by karsten weiss + einval occurs on some systems if stacksize != page-size + on macos x at least, pthread_attr_setstacksize(3) can fail + with einval if 'stacksize' is not a multiple of the system + page size. best to mention this so as to aid people writing + portable programs. + +pthread_create.3 + karsten weiss + fix bug in example program + the calloc() line should read like this instead: + + tinfo = calloc(num_threads, sizeof(struct thread_info)); + +pthread_exit.3 + michael kerrisk + bugs: thread group with a dead leader and stop signals + document the bug that can occur when a stop signal + is sent to a thread group whose leader has terminated. + http://thread.gmane.org/gmane.linux.kernel/611611 + http://marc.info/?l=linux-kernel&m=122525468300823&w=2 + +resolver.3 + michael kerrisk + fix prototype of dn_expand() + the 4th argument is "char *", not "unsigned char *". + http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=504708 + +epoll.7 + michael kerrisk + fix error handling after accept() in example code + simply continuing after an error is in most cases wrong, + and can lead to infinite loops (e.g., for emfile). + so handle an error by terminating. + http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=504202 + +epoll.7 + michael kerrisk + add error handling for epoll_wait() call in example code + +epoll.7 + michael kerrisk + improve example code + fill in some gaps in example code (variable declarations, + adding listening socket to epoll set). + give variables more meaningful names. + other minor changes. + http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=504202 + +iso_8859-7.7 + lefteris dimitroulakis + add characters for drachma and greek ypogegrammeni + lines for these two characters were added in the previous patch, + but the actual characters were not included in the 4th column + of the table. this fixes that. + +pthreads.7 + michael kerrisk + add a section describing thread ids + in particular, note that in each pthreads function that takes + a thread id argument, that id by definition refers to a thread + in the same process as the caller. + + +==================== changes in man-pages-3.14 ==================== + +released: 2008-11-25, bucaramanga + + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +andreas henriksson +bert wesarg +cedric le goater +chris heath +eric biederman +eugen dedu +ivana varekova +jen axboe +jens axboe +loïc domaigne +masanari iida +paul evans +pavel emelyanov +pierre-paul paquin +serge e. hallyn +stefano teso +stew benedict +vegard nossum + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +cpu_set.3 + michael kerrisk + new page documenting cpu_* macros + this page contains material moved out of sched_setscheduler(2). + it overwrites a previously existing link file with the same name. + michael kerrisk + add description of macros for dynamically allocated cpu sets + add descriptions of cpu_alloc(), cpu_alloc_size(), cpu_free(), + cpu_set_s(), cpu_clr_s(), cpu_isset_s(), cpu_zero_s(), + cpu_count_s(), cpu_and_s(), cpu_or_s(), cpu_xor_s(), and + cpu_equal_s(). + michael kerrisk + add documentation of cpu_count() + michael kerrisk + add description of cpu_and(), cpu_or, cpu_xor(), and cpu_equal() + plus a few other small clean-ups of the text + michael kerrisk + various improvements in description + after review comments by bert wesarg: + * explain that cpu_set_t is a bitset, but should be considered + opaque. + * a cpu set can be duplicated with memset(). + * size of a cpu set is rounded up to size of long. + * cpu_setsize is in bits, but the setsize argument is in bytes. + michael kerrisk + document cpu_alloc()/cpu_alloc_size() bug + these macros return twice what they should because of thinko + in glibc 2.8 and earlier. the bug is fixed for glibc 2.9. + http://sourceware.org/bugzilla/show_bug.cgi?id=7029 + michael kerrisk + notes: discuss use of types in "prototypes" for these macros + the synopsis shows types for arguments and return values, but + these are really just suggestions: since the interfaces are + macros, the compiler won't catch all violations of + the "type rules". warn the reader of this. + +pthread_attr_setinheritsched.3 + michael kerrisk + new page for pthread_attr_setinheritsched(3) and + pthread_attr_getinheritsched(3) + +pthread_cancel.3 + michael kerrisk + new page for pthread_cancel(3) + +pthread_cleanup_push.3 + michael kerrisk + new page for pthread_cleanup_push(3) and pthread_cleanup_pop(3) + +pthread_setcancelstate.3 + michael kerrisk + new page for pthread_setcancelstate(3) and pthread_setcanceltype(3) + +pthread_testcancel.3 + michael kerrisk + new page for pthread_testcancel(3) + + +newly documented interfaces in existing pages +--------------------------------------------- + +clone.2 + jens axboe + document clone_io (new in linux 2.6.25) + some text also by mtk. + michael kerrisk + document clone_newnet + michael kerrisk + document clone_newuts (new in linux 2.6.19) + michael kerrisk + document clone_newipc flag (new in linux 2.6.19) + michael kerrisk + document clone_newpid flag (new in linux 2.6.24) + +mmap.2 + michael kerrisk + document map_stack flag (new in linux 2.6.27) + +arp.7 + michael kerrisk + document /proc file retrans_time_ms (new in linux 2.6.12) + michael kerrisk + document /proc file base_reachable_time_ms (new in linux 2.6.12) + +icmp.7 + michael kerrisk + document icmp_ignore_bogus_error_responses (new in linux 2.2) + text taken from documentation/networking/ip-sysctl.txt + michael kerrisk + document icmp_ratelimit and icmp_ratemask (new in linux 2.4.10) + text taken from documentation/networking/ip-sysctl.txt + michael kerrisk + document icmp_echo_ignore_broadcasts (new in linux 2.6.12) + text taken from documentation/networking/ip-sysctl.txt + +tcp.7 + michael kerrisk + document /proc file tcp_slow_start_after_idle (new in linux 2.6.18) + text taken from documentation/networking/ip-sysctl.txt + michael kerrisk + document /proc file tcp_base_mss (new in linux 2.6.17) + text taken from documentation/networking/ip-sysctl.txt + michael kerrisk + document /proc file tcp_frto_response (new in linux 2.6.22) + text taken from documentation/networking/ip-sysctl.txt + michael kerrisk + document /proc file tcp_moderate_rcvbuf (new in linux 2.4.17/2.6.7) + text taken from documentation/networking/ip-sysctl.txt + michael kerrisk + document /proc file tcp_congestion_control (new in linux 2.4.13) + text taken from documentation/networking/ip-sysctl.txt + michael kerrisk + document /proc file tcp_no_metrics_save (new in linux 2.6.6) + text taken from documentation/networking/ip-sysctl.txt + michael kerrisk + document /proc file tcp_mtu_probing (new in linux 2.6.17) + text taken from documentation/networking/ip-sysctl.txt + michael kerrisk + document /proc file tcp_dma_copybreak (new in linux 2.6.24) + text taken from documentation/networking/ip-sysctl.txt + michael kerrisk + document /proc file tcp_tso_win_divisor (new in linux 2.6.9) + text taken from documentation/networking/ip-sysctl.txt + michael kerrisk + document /proc file tcp_allowed_congestion_control (new in linux 2.4.20) + text taken from documentation/networking/ip-sysctl.txt + michael kerrisk + document /proc file tcp_workaround_signed_windows (new in linux 2.6.26) + text taken from documentation/networking/ip-sysctl.txt + michael kerrisk + document /proc file tcp_available_congestion_control (new in linux 2.4.20) + text taken from documentation/networking/ip-sysctl.txt + michael kerrisk + document /proc file tcp_abc (new in linux 2.6.15) + text taken from documentation/networking/ip-sysctl.txt + +udp.7 + michael kerrisk + document /proc files udp_mem, udp_rmem_min, and udp_wmem_min + all of these are new in linux 2.6.25 + + +new and changed links +--------------------- + +cpu_alloc.3 +cpu_alloc_size.3 +cpu_and.3 +cpu_and_s.3 +cpu_clr_s.3 +cpu_count.3 +cpu_count_s.3 +cpu_equal.3 +cpu_equal_s.3 +cpu_free.3 +cpu_isset_s.3 +cpu_or.3 +cpu_or_s.3 +cpu_set_s.3 +cpu_xor.3 +cpu_xor_s.3 +cpu_zero_s.3 + michael kerrisk + new link to new cpu_set.3 + +cpu_clr.3 +cpu_isset.3 +cpu_zero.3 + michael kerrisk + update links to point to cpu_set.3 + the documentation of the cpu_* macros migrated to a new + location: cpu_set.3. + +pthread_attr_getinheritsched.3 + michael kerrisk + new link to new pthread_attr_setinheritsched.3 + +pthread_cleanup_pop.3 + michael kerrisk + new link to new pthread_cleanup_push.3 + +pthread_setcanceltype.3 + michael kerrisk + new link to new pthread_setcancelstate.3 + + +global changes +-------------- + +clone.2 +mount.2 +unshare.2 +proc.5 +path_resolution.7 + michael kerrisk + global fix: s/namespace/mount-point namespace/, as appropriate + in recent times, a number of other namespace flags have been + added to clone(2). as such, it is no longer clear to use + the generic term "namespace" to refer to the particular + namespace controlled by clone_newns; instead, use the + term "mount-point namespace". + michael kerrisk + global fix: s/mount-point namespace/mount namespace/ + this is more consistent with the term "mounts namespace" + used in the 2008 acm sigops paper, "virtual servers + and checkpoint/restart in mainstream linux". + (i avoided the "s", because using the plural strikes me + as klunky english, and anyway we don't talk about + the "pids namespace" or the "networks namespace", etc..) + +connect.2 +listen.2 +send.2 +uname.2 +cmsg.3 +proc.5 +arp.7 +ddp.7 +icmp.7 +ip.7 +raw.7 +socket.7 +tcp.7 +udp.7 + michael kerrisk + global fix: eliminate mention of the obsolete sysctl(2) interface + many pages still mention use of the obsolete sysctl(2) system + call, or used the term "sysctls"; rewrite these mentions to + instead be in terms of /proc interfaces. + +fcntl.2 +signal.2 +mbsnrtowcs.3 +mbsrtowcs.3 +mbtowc.3 +wcrtomb.3 +wcsnrtombs.3 +wcsrtombs.3 +wctomb.3 + michael kerrisk + global fix: s/multi-thread/multithread/ + +getdents.2 +pthread_attr_init.3 +pthread_create.3 +pthread_getattr_np.3 +pthread_setaffinity_np.3 +pthread_setschedparam.3 +pthread_tryjoin_np.3 + michael kerrisk + use consistent error-handling function names + many older pages use a handle_error() macro to do simple + error handling from system and library function calls. + switch these pages to do similar. + + +changes to individual pages +--------------------------- + +time.1 + michael kerrisk + note that some shells have a 'time' built-in command + therefore, to access the functionality described on this page, + it may be necessary to specify the full pathname. + +clone.2 + michael kerrisk + place list of clone_* flags in alphabetical order + (no content changes.) +fsync.2 + michael kerrisk + update feature test macro requirements for fsync() + since glibc 2.8, the fsync() declaration is also exposed if + _posix_c_source >= 200112l + +sched_setaffinity.2 + michael kerrisk + add note on system-imposed restrictions on cpus actually used + after loïc domaigne's suggestion for pthread_setaffinity_np(3), add + similar text to this page noting that the system silently + limits the set of cpus on which the process actually runs to + the set of cpus physically present and the limits imposed by + cpuset(7). + +sched_setaffinity.2 + michael kerrisk + removed discussion of cpu_* macros() + these macros are now moving to a separate page. + michael kerrisk + refer reader to pthread_setaffinity_np(3) + pthread_setaffinity_np() is preferable for setting + thread cpu affinity if using the posix threads api. + +sysctl.2 + michael kerrisk + add prominent warning against using this system call + this was already stated under notes, but make it even more + prominent by adding a sentence at the start of the description. + +uname.2 + michael kerrisk + add c comments describing fields in utsname structure + +atan2.3 + stefano teso + fix description of range of function value return + the range is not [-pi/2, pi/2], but [-pi, pi]. + + (mtk: this error was reported by nicolas françois, and + should have been fixed in 3.11, but somewhere along the way, + the fix got lost.) + + http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=506299 + +bindresvport.3 + michael kerrisk + since glibc 2.8, epfnosupport error is now eafnosupport + glibc switched to using a posix-specified error code for + this error case. + + http://bugs.linuxbase.org/show_bug.cgi?id=2375 + +clock_getres.3 + michael kerrisk + clock_process_cputime_id and clock_thread_cputime_id not settable + according to posix.1-2001, the clock_process_cputime_id and + clock_thread_cputime_id clocks should be settable, but + currently they are not. + +getgrnam.3 + michael kerrisk + clarify and add more detail in return value description + the page was a bit fuzzy in describing the return values for + various cases. in particular, it needed to be more explicit + in describing what happens for the "not found" case. + + this is an analogous change to the change for + getpwnam.3, made after andreas henriksson's report. + http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=504787 + michael kerrisk + rename arguments to getgrnam_r() and getgrgid_r() + s/gbuf/grp/ and s/gbufp/result/, for consistency + with posix.1 argument names. + michael kerrisk + clarify return value description + the page was a bit fuzzy in describing the return values for + various cases. in particular, it needed to be more explicit + in describing what happens for the "not found" case. + + http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=504708 + +getpwnam.3 + michael kerrisk + rename arguments to getpwnam_r() and getpwuid_r() + s/pwbuf/pwd/ and s/pwbufp/result/, for consistency + with posix.1 argument names. + michael kerrisk + clarify and add more detail in return value description + the page was a bit fuzzy in describing the return values for + various cases. in particular, it needed to be more explicit + in describing what happens for the "not found" case. + + http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=504787 + michael kerrisk + add an example program for getpwnam_r() + +inet_ntop.3 + michael kerrisk + rename 'cnt' argument to 'size' + this is consistent with posix.1, and also a more sensible name. + michael kerrisk + rework text describing 'size' argument + (after a suggestion by vegard nossum.) + also made a few other small rewordings to in the initial + paragraph. + +makecontext.3 + michael kerrisk + add text on use of pointer arguments to makecontext() + passing pointer arguments to makecontext() is possible, + but only on some architectures, and with no guarantees + of portability. + + http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=504699 + +pthread_attr_setaffinity_np.3 + michael kerrisk + various fixes after review by loïc domaigne + reviewed-by: loïc domaigne + +pthread_attr_setaffinity_np.3 +pthread_setaffinity_np.3 + michael kerrisk + update to reflect new location of cpu_*() documentation + the cpu_*() macros are now documented in cpu_set.3; + update to reflect that fact. + michael kerrisk + remove redundant text relating to cpu sets + information about cpu_setsize can be found in cpu_set.3, so + remove discussion of it here. + +pthread_attr_setschedparam.3 +pthread_setschedparam.3 + michael kerrisk + remove text saying that only sched_priority is required by posix.1 + loïc domaigne points out that if a system implements + sched_sporadic (which linux does not), then other + fields are also specified in sched_param. the simple + solution is just to remove that phrase from the man + page. + +pthread_cancel.3 +pthread_detach.3 +pthread_join.3 +pthread_setaffinity_np.3 + michael kerrisk + make text of esrch error consistent + +pthread_setaffinity_np.3 + michael kerrisk + add text to einval error mentioning cpuset(7) + michael kerrisk + various improvements after review by loïc domaigne + various fix-ups after loïc's review. + + reviewed-by: loïc domaigne + +pthread_setschedparam.3 + michael kerrisk + pthread_inherit_sched is default for inherit scheduler attribute + in example, note that pthread_inherit_sched is the default for + the inherit scheduler attribute. + +syslog.3 + masanari iida + log_kern messages can't be generated from user processes + masanari notes that this is an faq for logger(1) and that + solaris and freebsd document this point in syslog(3). + the glibc info page also hides this comment in its source: + + internally, there is also log_kern, but log_kern == 0, + which means if you try to use it here, just selects default. + +proc.5 + ivana varekova + fix reference to kernel source file + use relative reference to documentation/mtrr.txt. + +arp.7 + michael kerrisk + add kernel version numbers for /proc interfaces + +cpuset.7 + michael kerrisk + see also: add cpu_set(3) + +epoll.7 + michael kerrisk + note glibc version that added epoll support + +icmp.7 + michael kerrisk + add kernel version numbers to /proc file descriptions + +inotify.7 + vegard nossum + fix description of max_user_watches + it seems that inotify(7) is wrong here: + + "/proc/sys/fs/inotify/max_user_watches + this specifies a limit on the number of watches that can be + associated with each inotify instance." + + on my system, the default value for this variable is 8192. but i + cannot create more than 8192 watches in total for the same uid + even when they are on different inotify instances. so i suggest + to rephrase this as: "this specifies an upper limit on the + number of watches that can be created per real user id." + +ip.7 + michael kerrisk + reorder socket options alphabetically + michael kerrisk + added kernel version numbers for ip_* socket options + michael kerrisk + relocate kernel version information for ip_pmtudisc_probe + michael kerrisk + add kernel version numbers for /proc/sys/net/ipv4/ip_* files + michael kerrisk + remove mention of kernel header from description of ip_recverr + looks like glibc has had this definition since about version 2.1. + michael kerrisk + relocate kernel version information for ip_mreqn structure + michael kerrisk + relocate info about linux-specific sockopts to notes + also add some source comments about non-standard linux-specific + options that are not yet documented. + +netlink.7 + vegard nossum + fix incorrect variable names in example code + s/snl/sa/ * 2 + +pthreads.7 + michael kerrisk + add section on cancellation points + this section includes a list of the functions that must and + may be cancellation points. + michael kerrisk + rework, and fix small error in, thread-safe function list + integrate the changes that occurred in posix.1-2008 into the + main list (to be consistent with the list, elsewhere on this + page, of functions that are cancellation points). + + also, fix an error that said that strerror() was added to + the list in posix.1-2008. it was strsignal() that was + added. (strerror() was already in the list in posix.1-2001.) + michael kerrisk + tweak text on sigpause() cancellation point + in posix.1-2008, this function moves from the "must be" + to the "may be" list. + michael kerrisk + add ref to signal(7) for further info on use of real-time signals + signal(7) provides some further details on the use of real-time + signals by the two linux threading implementations. + michael kerrisk + see also: add pthread_attr_init() and pthread_cancel() + +tcp.7 + michael kerrisk + update description of tcp_rmem defaults for linux 2.6 + michael kerrisk + add kernel version numbers for tcp_* socket options + note kernel version were each socket option first appeared. + michael kerrisk + the tcp_bic* proc files disappeared in linux 2.6.13 + michael kerrisk + tcp_vegas_cong_avoid disappeared in linux 2.6.13 + michael kerrisk + add mention of rfc 4138 for 'tcp_frto' /proc file + michael kerrisk + remove mention of /proc in versions + this information is not indicated for each /proc interface + michael kerrisk + clarify that tcp_mem measures in units of the system page size + michael kerrisk + update tcp_frto description for 2.6.22 changes + linux 2.6.22 added a mode value 2 ("enable sack-enhanced + f-rto if flow uses sack"). + michael kerrisk + fix alphabetical order in /proc file list + a few entries were slightly out of order. + michael kerrisk + remove obsolete statement about /proc from versions + much of the text has been updated to 2.6.27 or so, + so this statement no longer applies. + michael kerrisk + add kernel version numbers for each /proc interface + note kernel version where each /proc interface first appeared + michael kerrisk + tcp_westwood /proc file disappeared in linux 2.6.13 + michael kerrisk + update description of tcp_wmem defaults for linux 2.6 + + +==================== changes in man-pages-3.15 ==================== + +released: 2008-12-05, bucaramanga + + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +andre majorel +andries e. brouwer +chris heath +drake wilson +mats wichmann +mel gorman +michael kerrisk +mike fedyk +pavel machek +petr baudis +phil endecott +rob landley +sam varshavchik + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +makedev.3 + michael kerrisk + new page for makedev(), major(), and minor() macros + +pthread_cleanup_push_defer_np.3 + michael kerrisk + new page for pthread_cleanup_push_defer_np(3) and + pthread_cleanup_pop_restore_np(3) + + +newly documented interfaces in existing pages +--------------------------------------------- + +accept.2 + michael kerrisk + document accept4() system call, new in linux 2.6.28 + +fmemopen.3 + petr baudis + add description of open_wmemstream(3) + +tcp.7 + michael kerrisk + document msg_trunc flag for tcp sockets + +new and changed links +--------------------- + +accept4.2 + michael kerrisk + new link to accept.2 + accept.2 now documents the new accept4() system call. + +open_wmemstream.3 + petr baudis + new link to fmemopen.3 + fmemopen.3 now documents open_wmemstream(). +pthread_cleanup_pop_restore_np.3 + michael kerrisk + new link to new pthread_cleanup_push_defer_np.3 + + +global changes +-------------- + +accept.2 +listen.2 +recv.2 +getpeername.2 +getsockname.2 +shutdown.2 +socketpair.2 + michael kerrisk + global fix: see also: add socket(7) + +bind.2 +rcmd.3 +capabilities.7 +ip.7 + michael kerrisk + global fix: s/reserved port/privileged port/ + some pages used one term, some pages the other term; + make some consistency. + +connect.2 +getpeername.2 +getsockname.2 + michael kerrisk + use consistent argument names + most other sockets pages are using the names 'addr' + and 'addrlen'; make these pages do the same. + +getpeername.2 +getsockname.2 +getsockopt.2 +recv.2 +send.2 +shutdown.2 +sockatmark.3 +socket.7 +udplite.7 + michael kerrisk + synopsis: rename socket file descriptor argument to 'sockfd' + many sockets man pages use the name 'sockfd' already. + for consistency, changes the others to do so as well. + +gnu_dev_major.3 +gnu_dev_makedev.3 +gnu_dev_minor.3 +major.3 +minor.3 + michael kerrisk + new links to new makedev(3) page + + +changes to individual pages +--------------------------- + +_exit.2 + michael kerrisk + since glibc 2.3, the exit() wrapper function invokes exit_group(2) + this information is useful to users of strace(1). + +accept.2 + michael kerrisk + clarify details when returned address is truncated + if the returned address is truncated, the 'addrlen' argument + indicates the actual size of the address, rather than a count + of the number of bytes in the truncated buffer. + + also clarify that if 'addr' argument is null, then 'addrlen' + should is unused, and should also be null. + michael kerrisk + reorder errors list + some errors were listed under a separate "may" heading. + there's probably no real need to do this; integrate + those errors into the main list. + +exit_group.2 + michael kerrisk + note that since glibc 2.3, exit(2) invokes exit_group() + +futex.2 + michael kerrisk + mention that glibc provides no wrapper function for futex() + +get_thread_area.2 + michael kerrisk + note that glibc provides no wrapper for this system call + +getdomainname.2 + michael kerrisk + substantial rewrite + expand description of setdomainname() and getdomainname(). + note that getdomainname() is implemented as a library function + in glibc. + note limits on size of domain name. + reorganize errors list. + +gethostname.2 + michael kerrisk + various parts rewritten + write a paragraph describing sethostname(). + + clarify differences between glibc's gethostbyname() and + the kernel gethostbyname() system calls. + +gethostname.2 + michael kerrisk + note that host_name_max is 64 on linux + also note that in pre-1.0 days, the limit on hostnames + was 8 bytes. + +getpeername.2 + michael kerrisk + note that returned address may be truncated if buffer is too small + +getsid.2 + michael kerrisk + simplified version information and moved to a new versions section + +getsockname.2 + michael kerrisk + note that returned address is truncated if buffer is too small + +mknod.2 + michael kerrisk + refer reader to makedev(3) to build a device id + +mmap.2 + michael kerrisk + loosen language around how 'addr' hint is interpreted + mel gorman reported that in linux 2.6.27, 'addr' is rounded + down to a page boundary. + + before kernel 2.6.26, if 'addr' was taken as a hint, it was + rounded up to the next page boundary. since linux 2.6.24, + it is rounded down. therefore, loosen the description of + this point to say that the address is rounded to "a nearby + page boundary". + +open.2 + michael kerrisk + efbig error is now eoverflow (since linux 2.6.24) + when a 32-bit app opens a file whose size is too big to be + represented in 31-bits, posix.1 specifies the error eoverflow. + linux used to give efbig for this case, but 2.6.24 fixed this. + + also, add some text to describe the error scenario in + more detail. + +pread.2 + michael kerrisk + note that glibc emulation for these calls uses lseek(2) + (this makes it clearer that the emulated calls are not atomic.) + +recv.2 +send.2 + michael kerrisk + make names of "address" and "address length" args more consistent + make the names of these arguments more consistent with other + sockets man pages. + +recv.2 + michael kerrisk + clarify details when returned address is truncated + if the recvfrom() returned address is truncated, the 'fromlen' + argument indicates the actual size of the address, rather than + a count of the number of bytes in the truncated buffer. + + also clarify that the 'from' argument can be null, in which + case 'fromlen' should is unused, and should also be null. + michael kerrisk + internet datagram and netlink sockets support msg_trunc for recv(2) + internet datagram (since linux 2.4.27/2.6.8), + and netlink (since linux 2.6.22) sockets support + the msg_trunc flag for recv(2). + +select.2 + michael kerrisk + rewrote text describing feature test macros requirement for pselect() + +select_tut.2 + michael kerrisk + fix shut_fd* macros in example program + add "do {} while (0)" + +set_thread_area.2 + michael kerrisk + note that glibc provides no wrapper for this system call + +setfsgid.2 +setfsuid.2 + michael kerrisk + simplify version information and move to a versions section + +setsid.2 + michael kerrisk + rework return value section; add an errors section + +setup.2 + michael kerrisk + relocate some conforming to text to versions and notes + +stat.2 + michael kerrisk + document eoverflow error + michael kerrisk + refer reader to major() and minor() to decompose a device id + +syscalls.2 + michael kerrisk + fix version numbers for a few system calls + some 2.6 system calls were wrongly mentioned as also being + backported into a 2.4.x kernel. + +uname.2 + michael kerrisk + description: point reader at notes for further info on field lengths + +atan.3 + andries e. brouwer + fix return value description + the correct range for the return value is [-pi/2,pi/2]. + (mtk's fix in the last change to the return value text was + a botch-up of a (correct) suggestion by nicolas françois.) + +atexit.3 + michael kerrisk + atexit() and on_exit(3) register functions on the same list + michael kerrisk + terminating registered function using longjmp() is undefined + according to posix.1, using longjmp() to terminate execution of + a function registered using atexit() produces undefined results. + michael kerrisk + calling exit(3) more than once produces undefined results + if an exit handler itself calls exit(3), the results are + undefined (see the posix.1-2001 specification of exit(3)). + michael kerrisk + the same exit handler may be registered multiple times + michael kerrisk + calling _exit(2) terminates processing of exit handlers + michael kerrisk + terminating registered function using longjmp() is undefined + according to posix.1, using longjmp() to terminate execution of + a function registered using atexit() produces undefined results. + +bindresvport.3 + mats wichmann + synopsis: s/\*\*/*/ in prototype + michael kerrisk + fix errors regarding port used, plus other rewrites + glibc's bindresvport() takes no notice of sin->sin_port: + it always returns an arbitrary reserved port in the + anonymous range (512-1023). (reported by mats wichmann.) + + also: + * add eaddrinuse and eacces errors. + * mention use of getsockname(2). + * other minor rewrites and reorderings of the text. + * explicitly note that glib's bindresvport() ignores + sin->sin_port. + * change license there's now virtually no text remaining from + the 1.70 version of this page. + + reviewed-by: mats wichmann + reviewed-by: petr baudis + +dlopen.3 + petr baudis + describe confusing dladdr() behavior + dladdr() will act unexpectedly if called from non-pic code on a + compile-time-generated function pointer. + +fmemopen.3 + michael kerrisk + add versions section + petr baudis + see open: add fopencookie(3) + fopencookie(3) is used to implement fmemopen(). + +fopen.3 + petr baudis + see also: add fmemopen(3) and fopencookie(3) + +fopencookie.3 + petr baudis + fopencookie() needs _gnu_source feature test macro + +getaddrinfo.3 + petr baudis + document results ordering and /etc/gai.conf + this patch documents the order of the getaddrinfo(3) results + (rfc 3484), how should the application deal with that, + mentions the extremely common cause of having multiple + results per query (both ipv4 and ipv6 addresses available) + and mentions /etc/gai.conf. + + (mtk: minor tweaks, and note glibc version for /etc/gai.conf) + +isatty.3 + michael kerrisk + complete rewrite of this page, with rather more detail + +memmem.3 + michael kerrisk + remove sentence saying that libc 5.0.9 is still widely used + that was a *long* time ago. + +on_exit.3 + michael kerrisk + document handling of registrations on fork(2) and execve(2) + treatment in these cases is the same as for atexit(3). + michael kerrisk + arg given to registered function is status from *last* call to exit() + it's a subtle point, but if a registered function itself + calls exit(3), then subsequent functions that were registered + with on_exit(3) will see the exit status given to the more + recent exit(3) call. + michael kerrisk + note that same function may be registered multiple times + +setlocale.3 +locale.7 + michael kerrisk + clean up the description of language environment variable + clean up the $language description, by removing bogus comments + from setlocale(3) and expanding the mention in locale(7). + + maybe you will decide that a more detailed description + should be left to the gettext(3) documentation, but i + actually care about the invisible part of the patch more + since the comments have put me off the track initially + ($language has nothing to do with setlocale(3) and is + completely isolated to gettext, as obvious from the + glibc sources). + +proc.5 + michael kerrisk + /proc/stat: s/minor/disk_idx/ in description of /proc/stat + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=225619 + +capabilities.7 + drake wilson + various minor fixes as per debian bug 471029 + the relevant pieces of + http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=471029 are: + + - delete duplicate subentry for keyctl_chown/keyctl_setperm + operations in the cap_sys_admin entry. (it feels like that + capability entry should be converted to a list, but i've + left it in semicolon-delimited form for now.) + + - remove text about enfile from the text about the + /proc/sys/fs/file-max limit in the cap_sys_admin entry, since + this is already described in the man pages for the relevant + ofile-creating system calls. + + - correct or clarify a few other bits of grammar and such; + see the diff file itself for details. + +socket.7 + michael kerrisk + see also: add tcp(7) and udp(7) + +tcp.7 + michael kerrisk + relocate out-of-band data discussion + move to a new subsection entitled "sockets api". + michael kerrisk + note that msg_peek can be used on out-of-band data + +time.7 + michael kerrisk + see also: add clock_gettime(3) + +unix.7 + michael kerrisk + unix domain sockets don't support the recv() msg_trunc flag + michael kerrisk + retitled subsection "(un)supported features" to "sockets api" + this is consistent with the recent change in tcp(7). + + + +==================== changes in man-pages-3.16 ==================== + +released: 2009-01-13, christchurch + + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +colin watson +florentin duneau +petr baudis + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +pthread_getcpuclockid.3 + michael kerrisk + new page documenting pthread_getcpuclockid(3) + +libc.7 + michael kerrisk + new page giving brief overview of c libraries on linux + +rtld-audit.7 + michael kerrisk + new page documenting dynamic linker auditing api + + +newly documented interfaces in existing pages +--------------------------------------------- + +ld.so.8 + petr baudis + document ld_audit + petr baudis + document ld_pointer_guard + + +new and changed links +--------------------- + +gethostid.2 + michael kerrisk + new link to new page location in section 3 + +sethostid.2 + michael kerrisk + change link to point to new page location in section 3 + +sethostid.3 + michael kerrisk + new link to relocated page in section 3 + +glibc.7 + michael kerrisk + new link to new libc.7 + + +global changes +-------------- + +syscalls.2 +feature_test_macros.7 +standards.7 + michael kerrisk + see also: add libc(7) + +dlopen.3 +ld.so.8 + michael kerrisk + see also: add rtld-audit(7) + + +changes to individual pages +--------------------------- + +gethostid.2 + michael kerrisk + move to section 3 + the interfaces documented in this page are purely glibc. + +syscalls.2 + michael kerrisk + kernel 2.6.28 adds accept4() + +clock_getres.3 + michael kerrisk + see also: add pthread_getcpuclockid(3) + +fmemopen.3 + michael kerrisk + fix versions information + +gethostid.3 + michael kerrisk + before version 2.2, glibc stored the host id in /var/adm/hostid + also: rewrite some text describing the /etc/hostid file, so that + this location is referred to just once on the page. + michael kerrisk + return value: describe return value of sethostid() + michael kerrisk + added bugs section noting that id can't be guaranteed to be unique + michael kerrisk + added errors section describing errors for sethostid() + michael kerrisk + update section number to reflect relocation into section 3 + +printf.3 + michael kerrisk + source and destination buffers may not overlap for *s*printf() + http://sourceware.org/bugzilla/show_bug.cgi?id=7075 + + some existing code relies on techniques like the following to + append text to a buffer: + + $ cat s.c + #include + char buf[80] = "not "; + main() + { + sprintf(buf, "%sfail", buf); + puts(buf); + return 0; + } + + $ cc s.c + $ ./a.out + not fail + + however, the standards say the results are undefined if source + and destination buffers overlap, and with suitable compiler + options, recent changes can cause unexpected results: + + $ cc -v 2>&1 | grep gcc + gcc version 4.3.1 20080507 (prerelease) [gcc-4_3-branch revision 135036] (suse linux) + $ cc -d_fortify_source -o2 s.c + $ ./a.out + fail + +readdir.3 + michael kerrisk + rewrite text describing 'dirent' fields standardized in posix.1 + michael kerrisk + clarify text for return value/errno setting for end-of-stream case + +nscd.8 + petr baudis + correct notes section on reloading configuration files + it behaved this way at least since + "sun oct 18 15:02:11 1998 +0000", + some four months after including the nscd implementation + in glibc. but there does seem to be a short window between + glibc-2.1 and glibc-2.1.3 when nscd -i was not available, + i don't think it's worth muddling the point of the page + with that, though. + + +==================== changes in man-pages-3.17 ==================== + +released: 2009-01-19, hobart + + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +adeodato simó +bastien roucaries +davide libenzi +lefteris dimitroulakis +mads martin joergensen +marc lehmann +martin (joey) schulze +michael kerrisk +petr baudis +sam varshavchik +vegard nossum + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +endian.3 + michael kerrisk + new page documenting byte order conversion functions + document functions (new in glibc 2.9) for conversion between + host byte order and big-/little- endian byte order: + htobe16(), htole16(), be16toh(), le16toh(), + htobe32(), htole32(), be32toh(), le32toh(), + htobe64(), htole64(), be64toh(), le64toh() + +getifaddrs.3 + petr baudis + new page documenting getifaddrs(3) and freeifaddrs(3) + many edits and changes of petr's initial draft by mtk + +cp1251.7 + lefteris dimitroulakis + new page documenting cp 1251 (windows cyrillic) character set + +iso-8859-10.7 + lefteris dimitroulakis + new page documenting iso 8859-10 character set + +iso_8859-13.7 + lefteris dimitroulakis + new page documenting iso 8859-13 character set + +iso_8859-14.7 + lefteris dimitroulakis + new page documenting iso 8859-14 character set + +iso_8859-3.7 + lefteris dimitroulakis + new page documenting iso 8859-3 character set + +iso_8859-5.7 + lefteris dimitroulakis + new page documenting iso 8859-5 character set + +iso_8859-8.7 + lefteris dimitroulakis + new page documenting iso 8859-8 character set + +koi8-u.7 + lefteris dimitroulakis + new page documenting koi8-u character set + + +newly documented interfaces in existing pages +--------------------------------------------- + +epoll.7 + michael kerrisk + document /proc interfaces for limiting kernel memory usage + document the following /proc files that were added in + linux 2.6.28: + /proc/sys/fs/epoll/max_user_instances + /proc/sys/fs/epoll/max_user_watches + +netdevice.7 + michael kerrisk + document recently added interface flags + iff_lower_up (since linux 2.6.17) + iff_dormant (since linux 2.6.17) + iff_echo (since linux 2.6.25) + + documentation taken from comments in + + +new and changed links +--------------------- + +freeifaddrs.3 + michael kerrisk + new link to new getifaddrs.3 + +htobe16.3 +htole16.3 +be16toh.3 +le16toh.3 +htobe32.3 +htole32.3 +be32toh.3 +le32toh.3 +htobe64.3 +htole64.3 +be64toh.3 +le64toh.3 + michael kerrisk + new links to new endian.3 + +iso-8859-10.7 +iso_8859_10.7 +latin6.7 + michael kerrisk + new links to new iso_8859-10.7 + +iso-8859-13.7 +iso_8859_13.7 +latin7.7 + michael kerrisk + new links to new iso_8859-13.7 + +iso-8859-14.7 +iso_8859_14.7 +latin8.7 + michael kerrisk + new links to new iso_8859-14.7 + +iso-8859-3.7 +iso_8859_3.7 +latin3.7 + michael kerrisk + new links to new iso_8859-3.7 + +iso-8859-5.7 +iso_8859_5.7 + michael kerrisk + new links to new iso_8859-5.7 + +iso-8859-8.7 +iso_8859_8.7 + michael kerrisk + new links to new iso_8859-8.7 + + +changes to individual pages +--------------------------- + +bind.2 + michael kerrisk + see also: add getifaddrs(3) + +epoll_create.2 + michael kerrisk + document emfile error + this error is encountered when the limit imposed by + /proc/sys/fs/epoll/max_user_instances is encountered. + michael kerrisk + clarify distinction between epoll instance and epoll file descriptor + reword so that the notion of an epoll instance is made clear, + and made distinct from the notion of an epoll file descriptor. + some other minor rewordings also. + +epoll_ctl.2 + michael kerrisk + reordered parts of the text + michael kerrisk + introduce notion of epoll instance + introduce notion of epoll instance as distinct from + epoll file descriptor. plus other wording clean-ups. + michael kerrisk + document enospc error (new in linux 2.6.28) + this error results when the limit imposed by + /proc/sys/fs/epoll/max_user_watches is encountered. + +epoll_wait.2 + michael kerrisk + introduce the notion of an epoll instance into text + +getdents.2 + michael kerrisk + before kernel < 2.6.4, 'd_type' was effectively always dt_unknown + +gethostid.2 + michael kerrisk + rename file (was misnamed gethostd.2 in previous release) + +getsockname.2 + michael kerrisk + see also: add getifaddrs(3) + +signalfd.2 + michael kerrisk + fix description of fork() semantics + the page text described the semantics of the initial + implementation of signalfd(). these were changed early on, + but the man page wasn't updated. + +byteorder.3 + michael kerrisk + see also: add endian(3) + +longjmp.3 + michael kerrisk + clarify wording re saving/restoring signal mask + michael kerrisk + siglongjmp() restores signal mask iff 'savesigs' was non-zero + note that siglongjmp() restores signal mask if, and only + if, 'savesigs' argument of sigsetjmp() was non-zero. (previous + text omitted the "and only if".) + +memccpy.3 + michael kerrisk + fix conforming to: s/c99/posix.1-2001/ + michael kerrisk + if the memory areas overlap, the results are undefined + +sethostid.3 + michael kerrisk + rename file (was misnamed sethostd.3 in previous release) + +setjmp.3 + michael kerrisk + clarify wording re saving/restoring signal mask + michael kerrisk + clarify when setjmp() provides bsd vs system v signal mask semantics + +strsep.3 + michael kerrisk + bugs: explicitly list problems afflicting strsep() + previously, the page said this function suffered the same + problems as strtok(), but in fact strsep() doesn't suffer + from all of the same problems as strtok(), so explicitly + list just the problems of strsep() in the strsep.3 page. + +proc.5 + michael kerrisk + add pointer to epoll(7) for description of epoll /proc files + +epoll.7 + michael kerrisk + various wording changes to improve clarity and consistency + + +==================== changes in man-pages-3.18 ==================== + +released: 2009-02-10, christchurch + + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +andi kleen +bastien roucaries +christian siebert +christopher head +florentin duneau +guillem jover +lefteris dimitroulakis +lucio maciel +michael kerrisk +mike frysinger +peter zijlstra +petr baudis +sam varshavchik +satyam sharma +sebastian kienzl +timo sirainen +vegard nossum + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +armscii-8.7 + lefteris dimitroulakis + new page documenting armscii-8 character set + +iso_8859-11.7 + lefteris dimitroulakis + new page documenting iso 8859-11 character set + +iso_8859-4.7 + lefteris dimitroulakis + new page documenting iso 8859-4 character set + +iso_8859-6.7 + lefteris dimitroulakis + new page describing iso 8859-6 character set + +pthread_kill.3 + michael kerrisk + new page documenting pthread_kill(3) + +pthread_kill_other_threads_np.3 + michael kerrisk + new page documenting pthread_kill_other_threads_np(3) + +pthread_sigmask.3 + michael kerrisk + new page documenting pthread_sigmask(3) + + +newly documented interfaces in existing pages +--------------------------------------------- + +clock_getres.3 + michael kerrisk + document clock_monotonic_raw, new in 2.6.28 + + +new and changed links +--------------------- + +clock_gettime.2 +clock_settime.2 +clock_getres.3 +clock_gettime.3 +clock_settime.3 + michael kerrisk + update links to reflect the fact that clock_* pages are now in + section 2 + +iso-8859-11.7 +iso_8859_11.7 + michael kerrisk + new links to new iso_8859-11.7 + +iso-8859-4.7 +iso_8859_4.7 +latin4.7 + michael kerrisk + new links to new iso_8859-4.7 + +iso-8859-6.7 +iso_8859_6.7 + michael kerrisk + new links to new iso_8859-6.7 + +tis-620.7 + michael kerrisk + new link to new iso_8859-11.7 + + +global changes +-------------- + +clock_nanosleep.2 +getrusage.2 +timerfd_create.2 +clock.3 +clock_getcpuclockid.3 +ftime.3 +pthread_create.3 +pthread_getcpuclockid.3 +pthread_tryjoin_np.3 +sem_wait.3 +time.7 + michael kerrisk + global fix: fix xrefs to clock_*.? pages to reflect move to section 2 + +clock_nanosleep.2 +execve.2 +fork.2 +nanosleep.2 +sigaction.2 +timerfd_create.2 +pthread_getcpuclockid.3 +ualarm.3 +usleep.3 +pthreads.7 +time.7 + michael kerrisk + global fix: s/(3)/(2)/ in section number xrefs for timer_*() api + the posix timers api is implemented (mostly) within the kernel, + so these interfaces are system calls. although there are as yet + no man pages, when they are added they should be in section 2, + not 3. therefore fix those pages that currently refer to these + interfaces as being in section 3. + + +changes to individual pages +--------------------------- + +capget.2 + andi kleen + add some details and relocate a paragraph + while writing a little program using capset + i found the capset manpage quite light on crucial + details and i had to resort to rtfs. + + this patch improves the points i found unclear + and also moves one misplaced paragraph around. + +clock_getres.2 + michael kerrisk + move page from section 3 to section 2 + +eventfd.2 + michael kerrisk + glibc eventfd() supports the use of eventfd2() since version 2.9 + +fork.2 + michael kerrisk + see also: add daemon(3) + +getdents.2 + michael kerrisk + remove unneeded have_d_type from example program + since d_type will always just return dt_unknown before + kernel 2.6.4, we don't need to use a conditional for + determining whether we use this flag. + +nanosleep.2 + michael kerrisk + relocated misplaced bugs heading + +select_tut.2 + michael kerrisk + clean up error checking in example program (no semantic changes) + michael kerrisk + many parts tidied and rewritten + remove some redundant text, clarify various pieces, + tidy example code, etc. + michael kerrisk + bug fixes + rewrites in example program + sebastien pointed out that the first example program + wrongly thinks it can count signals. + also, some further rewrites by mtk. + +socket.2 + michael kerrisk + bugs: remove discussion sock_uucp + as time goes on, this sentence becomes less a piece of humor, + and more a puzzle. + +stat.2 + michael kerrisk + note that open(o_noatime) also causes st_atime not to be updated + +timerfd_create.2 + michael kerrisk + add bugs noting that timerfd supports fewer clock types than + timer_create() + +btowc.3 + michael kerrisk + see also: add wctob(3) + +clock_getcpuclockid.3 + michael kerrisk + see also: add pthread_getcpuclockid(3) + +cos.3 + michael kerrisk + see also: add sincos(3) + +fexecve.3 + timo sirainen + note that fexecve() depends on a mounted /proc + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=514043 + michael kerrisk + conforming to: note addition of fexecve() in posix.1-2008 + michael kerrisk + 'fd' must be opened read-only and refer to a file that is executable + +fmemopen.3 + michael kerrisk + conforming to: note that these functions are in posix.1-2008 + +getifaddrs.3 + lucio maciel + fix memory leak in example program + petr baudis + various small fixes + +getpwnam.3 + michael kerrisk + see also: add getspnam(3) + +getumask.3 + michael kerrisk + updated glibc version number in notes + +ilogb.3 + michael kerrisk + see also: add significand(3) + +intro.3 + michael kerrisk + see also: add libc(7) + +isalpha.3 + michael kerrisk + fix statement that isalpa() is obsolete; should be isascii() + http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=512709 + michael kerrisk + see also: add toascii(3) + +mq_notify.3 + michael kerrisk + add cross reference to pthread_attr_init(3) + +pthread_attr_setaffinity_np.3 + michael kerrisk + synopsis: fix declaration of 'attr' + +pthread_getcpuclockid.3 + michael kerrisk + synopsis: fix type of 'thread' + +qsort.3 + michael kerrisk + example: remove unnecessary "#include " + +random.3 + michael kerrisk + see also: add random_r(3) + +remainder.3 + michael kerrisk + see also: add div(3) + +scandir.3 + michael kerrisk + conforming to: alphasort() and scandir() are added to posix.1-2008 + michael kerrisk + conforming to: note that versionsort() was added to glibc in + version 2.1 + +sem_wait.3 + michael kerrisk + see also: add clock_gettime(2) + +significand.3 + michael kerrisk + add conforming to noting that this function is unstandardized + +sigwait.3 + michael kerrisk + add examples section referring to pthread_sigmask(3) + +sin.3 + michael kerrisk + see also: add sincos(3) + +stpcpy.3 + michael kerrisk + add bugs section noting the possibility of buffer overruns + michael kerrisk + add missing pieces/fix various problems in example program + michael kerrisk + conforming to: stpcpy() is nowadays on the bsds + michael kerrisk + see also: add stpcpy.3 + +wcscasecmp.3 + michael kerrisk + conforming to: note that this function is added in posix.1-2008 + +wcsdup.3 + michael kerrisk + conforming to: note that this function was added in posix.1-2008 + +wcsncasecmp.3 + michael kerrisk + conforming to: note that this function is added in posix.1-2008 + +wctob.3 + michael kerrisk + see also: add btowc(3) + +proc.5 + michael kerrisk + remove mention of epoll/max_user_instances + (since this interface appeared in 2.6.28, and then + disappeared in 2.6.29.) + +ascii.7 + michael kerrisk + update see also list to include pages added in 3.17 + michael kerrisk + see also: add recently added iso_8859-*(7) pages + +epoll.7 + michael kerrisk + remove documentation of /proc/sys/fs/epoll/max_user_instances + this /proc interface appeared in 2.6.28. but will be + removed in 2.6.29. + + also, document change in default value of + /proc/sys/fs/epoll/max_user_watches (was 1/32 of lowmem, + now 1/25 of lowmem). + +koi8-r.7 + michael kerrisk + see also: add koi8-u(7); remove crufty text + +standards.7 + michael kerrisk + update to note that latest posix/sus was ratified in 2008 + +time.7 + michael kerrisk + see also: add pthread_getcpuclockid(3) + + +==================== changes in man-pages-3.19 ==================== + +released: 2009-02-20, putaruru + + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +christian siebert +jan engelhardt +jens thoms toerring +kir kolyshkin +mark hills +michael kerrisk +parag warudkar +peter zijlstra +sami liedes + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +timer_create.2 + michael kerrisk + new page documenting timer_create(2) + +timer_delete.2 + michael kerrisk + new page documenting timer_delete(2) + +timer_getoverrun.2 + michael kerrisk + new page documenting timer_getoverrun(2) + +timer_settime.2 + michael kerrisk + new page documenting timer_settime(2) and timer_gettime(2) + + +new and changed links +--------------------- + +timer_gettime.2 + michael kerrisk + new link to new timer_settime.2 + + +global changes +-------------- + +various pages + kir kolyshkin + trivial punctuation fixes in see also + in see also, when a few man pages are referenced, those + are divided by commas. every reference is on a separate + line, and all lines but the last one should end with + comma. i spotted one place where there is no comma in + between references, and mocked up an awk script to find + similar places: + + for f in man*/*; do + awk ' + /^.sh ["]see also["]/ { + sa=1; print "== " filename " =="; print; next + } + /^\.(pp|sh)/ { + sa=0; no=0; next + } + /^\.br/ { + if (sa==1) { + print; + if (no == 1) + print "missing comma in " filename " +" fnr-1; no=0 + } + } + /^\.br .*)$/ { + if (sa==1) + no=1; + next + } + /\.\\"/ {next} + /.*/ { + if (sa==1) { + print; next + } + } + ' $f; + done | fgrep 'missing comma' + + this patch fixes all the places found by the above script. + + also, there is an extra dot at the end of uri.7 "see also" + section. removed as per man-pages(7) recommendation. + + +changes to individual pages +--------------------------- + +getitimer.2 +clock_getcpuclockid.3 +time.7 + michael kerrisk + see also: add timer_create(2) + +getitimer.2 + michael kerrisk + rename arguments for consistency with other timer pages + also some other minor wording improvements + +splice.2 + mark hills + errors: add einval case for file opened o_append + target file cannot be opened in append (o_append) mode + + in kernels prior to v2.6.27 splice() to a file in + append mode is broken, and since that version it is + disallowed. it is possible this behaviour may change + in the future; see the kernel commit message + (efc968d450e013049a662d22727cf132618dcb2f) for more + information. + +syscalls.2 + michael kerrisk + note that getpmsg(2) and putmsg(2) are unimplemented + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=514771 + +timerfd_create.2 + michael kerrisk + errors: add efault + +timerfd_create.2 + michael kerrisk + rename timerfd_settime() 'curr_value' arg to 'old_value' + for consistency with related pages. + +vm86.2 + parag warudkar + conforming to: add 32-bit specific + note that this call is only on *32-bit* intel + +mq_open.3 + michael kerrisk + errors: add enoent error for name == "/" + +mq_open.3 + michael kerrisk + errors: add eacces error for name containing > 1 slash + +sem_open.3 + michael kerrisk + errors: add einval error where name == "/" + +sem_open.3 + jens thoms toerring + add case of non-well-formed name to enoent + +shm_open.3 + michael kerrisk + clarify rules for construction of shared memory object names + +proc.5 + michael kerrisk + add description of /proc/sys/kernel/sysrq + reported by: goerghe cosorea + +proc.5 + michael kerrisk + put /proc/modules entry in correct alphabetical order + +ascii.7 + kir kolyshkin + fix formatting of tables on second page to use monospaced font + +mq_overview.7 + michael kerrisk + clarify construction rules for message queue object names + +sem_overview.7 + michael kerrisk + clarify construction rules for semaphore object names + see also http://groups.google.com/group/comp.os.linux.development.apps/browse_thread/thread/b4a67caa765cb65f + + + +==================== changes in man-pages-3.20 ==================== + +released: 2009-03-31, christchurch + + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +alan curry +américo wang +andi kleen +carlos o'donell +chunming chang +colin watson +eelco dolstra +jan engelhardt +jens thoms toerring +johannes stezenbach +leandro a. f. pereira +martin gebert +michael kerrisk +mike o'connor +mike frysinger +nikanth karthikesan +reuben thomas +reuben thomas +roland mcgrath +sam varshavchik +simon gomizelj +tanaka akira +teddy hogeborn +walter jontofsohn + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +cpuid.4 + andi kleen + new page for cpuid access device + +msr.4 + andi kleen + new page documenting x86 cpu msr access device + + +newly documented interfaces in existing pages +--------------------------------------------- + +proc.5 + américo wang + document /proc/sys/vm/swappiness + michael kerrisk + document /proc/sysrq-trigger + + +global changes +-------------- + +timer_create.2 +timer_delete.2 +timer_getoverrun.2 +timer_settime.2 +numa.7 + michael kerrisk + make source layout of 'link with' text consistent with other pages + no actual change to formatted output, but this makes the + page sources more consistent for the purpose of grepping, etc. + +mempcpy.3 +signbit.3 +significand.3 + michael kerrisk + global fix: acknowledge fsf in copyright + these pages are heavily based on original material in + glibc info pages, but the comments in the source of the pages + did not acknowledge the fsf copyright on the original material. + fix that. + +accept.2 +read.2 +recv.2 +send.2 +write.2 + michael kerrisk + fix discussion of eagain/ewouldblock errors + for a non-blocking socket, posix.1-2001/2008 allow either + eagain or ewouldblock to be returned in cases where a call + would have blocked. although these constants are defined + with the same value on most linux architectures (pa-risc + is the exception), posix.1 does not require them to have + the same value. therefore, a portable application using + the sockets api should test for both errors when checking + this case. + + (nb posix.1 only mentions ewouldblock in the context of + the sockets interfaces.) + + change made after a note cross-posted on linux-arch@vger, + http://thread.gmane.org/gmane.linux.debian.ports.hppa/5615 + and a suggestion for write(2) from carlos o'donell + +basename.3 +getgrent.3 +getgrnam.3 +getpwent.3 +getpwnam.3 +readdir.3 + michael kerrisk + note that returned pointer should not be given to free() + +armscii-8.7 +cp1251.7 +iso_8859-10.7 +iso_8859-11.7 +iso_8859-13.7 +iso_8859-14.7 +iso_8859-15.7 +iso_8859-16.7 +iso_8859-2.7 +iso_8859-3.7 +iso_8859-4.7 +iso_8859-5.7 +iso_8859-6.7 +iso_8859-7.7 +iso_8859-8.7 +iso_8859-9.7 +koi8-r.7 +koi8-u.7 + michael kerrisk + add explicit character set encoding to first line of source + nowadays mandb has provision to understand a character set + encoding that is explicitly indicated in the first line + of the source. as pointed out by colin watson, including + such an explicit indication on pages encoded in anything + other than iso 8859-1 or utf-8 is useful for man-pages + that aren't shipped in utf-8. + + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=519209 + and for some other background (responded to by colin watson + in the above report): + http://thread.gmane.org/gmane.comp.internationalization.linux/6040 + ("man page encoding", 5 jul 2005) + + +changes to individual pages +--------------------------- + +fallocate.2 + michael kerrisk + versions: glibc support is provided since version 2.10 + +fcntl.2 + michael kerrisk + remove mention of ewouldblock from discussion of mandatory locking + in the kernel, the error on encountering a mandatory lock is + eagain. although eagain and ewouldblock are the same on + most linux architectures, on some they are not, so don't + mention ewouldblock as it is misleading. (mea culpa.) + +getcontext.2 + michael kerrisk + note that posix.1-2008 removes the specification of getcontext() + +getitimer.2 + michael kerrisk + note that posix.1-2008 recommends posix timers api instead of this api + +gettimeofday.2 + michael kerrisk + note that posix.1-2008 recommends clock_gettime() instead of this api + +ptrace.2 + michael kerrisk + note use of 'data' for ptrace_sys{call,emu} and ptrace_*_singlestep + these operations use the 'data' argument as a signal number, + like ptrace_cont. + +ptrace.2 + mike frysinger + only reference + the kernel no longer installs linux/user.h, so update + references to sys/user.h. + +recv.2 + michael kerrisk + add 'iovec' defn to defn of 'msghdr' structure + the 'msghdr' structure includes a field of type 'iovec', + so show the definition of that structure in this page. + +rename.2 + michael kerrisk + make enoent description consistent with posix.1-2008 + +timerfd_create.2 + michael kerrisk + errors: add einval for invalid 'flags' for timer_settime() + +truncate.2 + michael kerrisk + synopsis: fix description of feature test macro requirements + after a report by arvid norlander. + +bcopy.3 + michael kerrisk + note that posix.1-2008 removes specification of bcopy() + +bsd_signal.3 + michael kerrisk + note that posix.1-2008 recommends sigaction(2) instead of this api + +ctime.3 + michael kerrisk + note that posix.1-2008 recommends strftime(3) instead of these functions + +ecvt.3 + michael kerrisk + note that posix.1-2008 recommends sprintf(3) instead of these functions + +gcvt.3 + michael kerrisk + note that posix.1-2008 recommends sprintf(3) instead of this function + +getcwd.3 + michael kerrisk + note that getcwd() should be used instead of the obsolete getwd() + +getgrent.3 + michael kerrisk + returned buffer may be statically allocated and overwritten by + later calls + +gethostbyname.3 + michael kerrisk + posix.1-2008 recommends getaddrinfo(3) and getnameinfo(3) instead + +getnetent_r.3 + michael kerrisk + fix function name in text: s/getnetbynumber_r/getnetbyaddr_r/ + the synopsis showed the right function name (getnetbyaddr_r), + but the text repeatedly used the wrong name (getnetbynumber_r). + probably, this was a cut-and-paste error. + +getpwent.3 + michael kerrisk + returned buffer may be statically allocated and overwritten by + later calls + +index.3 + michael kerrisk + note that posix.1-2008 recommends strchr(3) and strrchr(3) instead + +isalpha.3 + michael kerrisk + explain why posix.1-2008 marks isascii(3) obsolete + +lockf.3 + nikanth karthikesan + update pointer to documentation in kernel source + +makecontext.3 + michael kerrisk + note that posix.1-2008 recommends the use of posix threads instead + +mq_notify.3 + michael kerrisk + document the posix.1-2008 optional einval error + posix.1-2008 allows an optional einval error if + notification==null and the caller is not currently + registered to receive notifications. + +posix_fallocate.3 + michael kerrisk + clarify that einval also occurs of 'len' *equals* zero + see http://bugzilla.kernel.org/show_bug.cgi?id=12919 + +posix_fallocate.3 + michael kerrisk + document posix.1-2001 and posix.1-2008 specifications for einval error + see http://bugzilla.kernel.org/show_bug.cgi?id=12919 + +posix_memalign.3 + michael kerrisk + document handling of size==0 case for posix_memalign() + +pthread_exit.3 + michael kerrisk + fix error in description: s/pthread_create/pthread_exit/ + +realpath.3 + michael kerrisk + rework resolved_path==null discussion w.r.t. posix.1-200[18] + although the page already mentioned the resolved_path==null + feature, and that this feature was added in posix.1-2008, there + was still some crufty text in bugs that hadn't been updated to + reflect the posix.1-2008 changes. + + also, some other minor wording and grammar fixes. + +scalb.3 + michael kerrisk + note that posix.1-2008 recommends scalbln*(3) instead + +seekdir.3 + michael kerrisk + synopsis: fix type of 'offset' argument: s/off_t/long/ + and add a notes section pointing out that 'off_t' + was indeed used in glibc 2.1.1 and earlier. + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=519230 + +sem_post.3 + michael kerrisk + document eoverflow error + +shm_open.3 + michael kerrisk + recast discussion on name length to exclude terminating null byte + probably it's clearer to describe the length of the ipc object + name as a count that excludes the null terminator. + +siginterrupt.3 + michael kerrisk + note that posix.1-2008 recommends sigaction() instead + +sigset.3 + michael kerrisk + note apis that posix.1-2008 recommends instead of these obsolete apis + +strftime.3 + michael kerrisk + small fix to description of %g + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=516677 + +strftime.3 + michael kerrisk + add details on iso 8601 week-based dates + iso 8602 week-based dates are relevant for %g, %g, and %v, + and the existing details on these dates are a little thin. + +strftime.3 + michael kerrisk + remove mention of year from iso 8601 standard + the text mentioned the 1988 8601 standard, but there have + already been two revisions of the standard since then, so + simply remove mention of the year. + +telldir.3 + michael kerrisk + synopsis: fix return type: s/off_t/long/ + and add a notes section pointing out that 'off_t' + was indeed used in glibc 2.1.1 and earlier. + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=519230 + +timeradd.3 + michael kerrisk + note that on some systems, <=, >=, == don't work for timercmp() + +timeradd.3 + michael kerrisk + synopsis: fix return types of timerisset() and timercmp() + +toascii.3 + michael kerrisk + note why posix.1-2008 marks this function obsolete + +console_ioctl.4 + alan curry + fix 'argp' type for kdgetled description + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=517485 + +group.5 + michael kerrisk + various minor rewordings and improvements + +resolv.conf.5 + michael kerrisk + document 'ip6-bytestring' option + +resolv.conf.5 + michael kerrisk + document 'edns0' option + +resolv.conf.5 + michael kerrisk + document 'ip6-dotint' / 'no-ip6-dotint' option + +resolv.conf.5 + michael kerrisk + note that maximum value of 'ndots' option is capped to 15 + +resolv.conf.5 + michael kerrisk + note that maximum value of 'timeout' option is capped to 30 + +hier.7 + michael kerrisk + add description of /srv + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=520904 + +ip.7 + michael kerrisk + fix type used to declare sin6_port + the page should use the type specified by posix, + rather than the (equivalent) type used in the kernel + +ipv6.7 + teddy hogeborn + fix types used to declare sin6_family and sin6_port + the page should use the types specified by posix, + rather than the (equivalent) types used in the kernel. + + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=517074 + +mq_overview.7 + michael kerrisk + recast discussion on name length to exclude terminating null byte + probably it's clearer to describe the length of the ipc object + name as a count that excludes the null terminator. + +rtld-audit.7 + michael kerrisk + note that multiple libraries in ld_audit doesn't work + this is reportedly fixed in glibc 2.10. + see http://sourceware.org/bugzilla/show_bug.cgi?id=9733 + +sem_overview.7 + michael kerrisk + fix discussion of length of semaphore names + because of the "sem." prefix added by glibc to a semaphore + name, the limit on the length of the name (excluding the + terminating null byte) is 251 characters. + + +==================== changes in man-pages-3.21 ==================== + +released: 2009-04-15, los gatos + + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +frank dana +michael kerrisk +roman byshko + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +pthread_setconcurrency.3 + michael kerrisk + new page documenting pthread_setconcurrency(3) and + pthread_getconcurrency(3) + +pthread_yield.3 + michael kerrisk + new page documenting pthread_yield(3) + + +new and changed links +--------------------- + +pthread_getconcurrency.3 + michael kerrisk + new link to new pthread_setconcurrency(3) + +changes to individual pages +--------------------------- + +initrd.4 + michael kerrisk + various minor wording improvements + +initrd.4 + frank dana + add missing word in description + +feature_test_macros.7 + michael kerrisk + update for glibc 2.10 changes to + from glibc 2.10, understands the values 200809 + for _posix_c_source and 700 for _xopen_source, and makes + corresponding changes to defaults for other feature test macros. + michael kerrisk + add an example program + this example program makes it possible to explore what + feature test macros are set depending on the glibc version + and the macros that are explicitly set. + +ldconfig.8 + michael kerrisk + /etc/ld.so.conf also include libraries found in /lib and /usr/lib + + +==================== changes in man-pages-3.22 ==================== + +released: 2009-07-25, munich + + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +adrian dewhurst +alexander lamaison +bryan østergaard +christopher head +doug goldstein +florentin duneau +gokdeniz karadag +jeff moyer +kosaki motohiro +lucian adrian grijincu +mark hills +michael kerrisk +mike frysinger +petr baudis +reimar döffinger +ricardo garcia +rui rlex +shachar shemesh +tolga dalman +ku roi +sobtwmxt + +apologies if i missed anyone! + + +changes to individual pages +--------------------------- + +clone.2 + michael kerrisk + rewrite crufty text about number of args in older version of clone() + some bit rot had crept in regarding the discussion of the + number of arguments in older versions of this syscall. + simplify the text to just say that linux 2.4 and earlier + didn't have ptid, tls, and ctid arguments. + + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=533868 + michael kerrisk + fix version number for clone_newipc + it's 2.6.19, not 2.4.19. + michael kerrisk + fix errors in argument names in text (ptid, ctd) + +execve.2 + mike frysinger + remove erroneous statement that pending signal set is cleared + on execve(2). + +fcntl.2 + michael kerrisk + the kernel source file mandatory.txt is now mandatory-locking.txt + michael kerrisk + the documentation/* files are now in documentation/filesystems + +flock.2 + michael kerrisk + remove unneeded reference to documentation/mandatory.txt + mandatory locks are only implemented by fcntl() locking + michael kerrisk + the documentation/* files are now in documentation/filesystems + +fork.2 + jeff moyer + document fork() behaviour for the linux native aio io_context + it was noted on lkml that the fork behaviour is documented + for the posix aio calls, but not for the linux native calls. + here is a patch which adds a small blurb that folks will + hopefully find useful. + + upon fork(), the child process does not inherit the + io_context_t data structures returned by io_setup, + and thus cannot submit further asynchronous i/o or + reap event completions for said contexts. + +getdents.2 + michael kerrisk + the d_type field is fully supported on btrfs + +mount.2 + michael kerrisk + document ms_strictatime, update description of ms_relatime + starting with linux 2.6.30, the ms_relatime behavior became + the default, and ms_strictatime is required to obtain the + traditional semantics. + +poll.2 + michael kerrisk + remove ebadf error from errors + as reported by motohiro: + + "man poll" describe this error code. + + >errors + > ebadf an invalid file descriptor was given in one of the sets. + + but current kernel implementation ignore invalid file descriptor, + not return ebadf. + ... + + in the other hand, susv3 talk about + + > pollnval + > the specified fd value is invalid. this flag is only valid in the + > revents member; it shall ignored in the events member. + + and + + > if the value of fd is less than 0, events shall be ignored, and + > ireevents shall be set to 0 in that entry on return from poll(). + + but, no desribe ebadf. + (see http://www.opengroup.org/onlinepubs/009695399/functions/poll.html) + + so, i think the implementation is correct. + + why don't we remove ebadf description? + +sigaction.2 + michael kerrisk + expand description of si_utime and si_stime fields of siginfo_t + +stat.2 + michael kerrisk + improve wording of enotdir error + +syscalls.2 + michael kerrisk + add preadv() and pwritev(), new in kernel 2.6.30 + +wait.2 + gokdeniz karadag + document cld_dumped and cld_trapped si_code values + +daemon.3 + michael kerrisk + clarify discussion of 'noclose' and 'nochdir' arguments + +ffs.3 + petr baudis + see also: add memchr(3) + +fmemopen.3 + petr baudis + relocate bugs section to correct position + petr baudis + notes: there is no file descriptor associated with the returned stream + alexander lamaison pointed out that this is not obvious + from the documentation, citing an example with passing the + file * handle to a function that tries to fstat() its + fileno() in order to determine the buffer size. + michael kerrisk + conforming to: remove note that these functions are gnu extensions + that sentence is now redundant, since these functions + are added in posix.1-2008. + +lockf.3 + michael kerrisk + clarify relationship between fcntl() and lockf() locking + +memchr.3 + petr baudis + see also: add ffs(3) + +readdir.3 + michael kerrisk + the d_type field is fully supported on btrfs + +setjmp.3 + mike frysinger + fix typo and clarify return description + the word "signal" was duplicated in notes, and the return + section refers to setjmp() and sigsetjmp(), and mentions + longjmp(), but not siglongjmp(). + +strcmp.3 + petr baudis + see also: add strverscmp(3) + +strcpy.3 + mark hills + see also: add strdup(3) + +complex.7 + michael kerrisk + add missing header file for example program + reimar döffinger + fix type used in example code + man complex (from release 3.18) contains the following code: + complex z = cexp(i * pi); + reading the c99 standard, "complex" is not a valid type, + and several compilers (intel icc, arm rvct) will refuse to compile. + it should be + double complex z = cexp(i * pi); instead. + +environ.7 + michael kerrisk + note that last element in environ array is null + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=528628 + michael kerrisk + wording fixes + +mq_overview.7 + michael kerrisk + note that mkdir and mount commands here need superuser privilege + michael kerrisk + fix example showing contents of /dev/mqueue file + +standards.7 + michael kerrisk + remove references to dated books + gallmeister and lewine are rather old books. probably, + there are better books to consult nowadays, and anyway, + this man page isn't intended to be a bibliography. + + +==================== changes in man-pages-3.23 ==================== + +released: 2009-09-30, munich + + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +aaron gardner +andrey vihrov +christoph hellwig +georg sauthoff +leslie p. polzer +marc lehmann +mark hills +michael kerrisk +mike frysinger +nicolas françois +serge hallyn +siward de groot +rui rlex + +apologies if i missed anyone! + + +changes to individual pages +--------------------------- + +execve.2 +pipe.2 +tee.2 +fmemopen.3 +mq_notify.3 +qsort.3 + michael kerrisk + replace use of assert() by code that checks argc + see http://bugzilla.kernel.org/show_bug.cgi?id=13569 + + as noted by andrey: + the purpose of the assert macro, defined in , + is to provide a tool to check for programming mistakes + or program logic errors. however, the assert macro must + never be used to perform checks for run time errors, + since, with the ndebug macro defined, expressions within + the assert macro invocations are not evaluated/checked + for, resulting in behavior that was not originally intended. + ... + the pages affected in the core package are + + execve(2) + pipe(2) + tee(2) + fmemopen(3) + mq_notify(3) + qsort(3) + +getrusage.2 + michael kerrisk + ru_inblock and ru_oublock are now implemented + these fields of the rusage structure are filled in since + linux 2.6.22. + +mmap.2 + michael kerrisk + add brief documentation of map_hugetlb + this flag is new in 2.6.32, and serves a similar + purpose to the shmget() shm_hugetlb flag. + +open.2 + christoph hellwig + add some comments on o_sync and friends + +poll.2 + michael kerrisk + clarify wording describing of 'nfds' argument. + reported by: rui rlex + +semctl.2 + nicolas françois + remove some redundant words + +setpgid.2 + michael kerrisk + add an explanation of orphaned process groups + +splice.2 +tee.2 +vmsplice.2 + mark hills + fix return type + since glibc 2.7, the return type for these functions + is ssize_t (formerly it was long). + +stat.2 + nicolas françois + fix small bug in example program + since it is a failure, exit_failure looks more appropriate + than exit_success. + +umount.2 + michael kerrisk + glibc only exposes mnt_detach and mnt_expire since version 2.11 + see http://sourceware.org/bugzilla/show_bug.cgi?id=10092 + +exit.3 + michael kerrisk + add a pointer to explanation of orphaned process groups in setpgid(2) + +fflush.3 + michael kerrisk + fflush() discards buffered input + +ffs.3 + michael kerrisk + clarify that ffsl() and ffsll() are gnu extensions + +getaddrinfo.3 + michael kerrisk + note nonstandard assumed hints.ai_flags value when hints is null + when hints is null, glibc assumes hints.ai_flags is + ai_v4mapped|ai_addrconfig whereas posix says 0. + according to ulrich drepper, glibc's behavior is better. + +getmntent.3 + mike frysinger + setmntent() argument is 'filename' not 'fp' + the description of setmntent() formerly used the wrong + argument name. + +posix_fallocate.3 + nicolas françois + fix reference to posix.1-2008 + the sentence mentions twice posix.1-2001. + i guess the second one should be posix.1-2008. + this should be checked in the standard. + +setenv.3 + michael kerrisk + improve errors section + add enomem error; improve einval description. also, make + return value section a little more accurate in its mention + of errno. + +strftime.3 + nicolas françois + fix error in description: s/monday/thursday/ + +proc.5 + nicolas françois + fix page cross reference + max_user_watches is better explained in epoll(7) than inotify(7). + +proc.5 + michael kerrisk + dmesg is in section 1, not section 8 + +capabilities.7 + michael kerrisk + fs uid manipulations affect cap_linux_immutable and cap_mknod + nowadays, file system uid manipulations also affect + cap_linux_immutable (since 2.6.3) and cap_mknod (since 2.6.29). + +capabilities.7 + michael kerrisk + fix version number for cap_mknod in fs uid manipulations + a recent patch said "since 2.6.29". it should have + been "since 2.6.30". + +capabilities.7 + nicolas françois + reword a bad sentence in description of capability bounding set. + +mq_overview.7 + michael kerrisk + change documented ranges for msg_max and msgsize_max + linux 2.6.28 changed the permissible ranges for + these /proc files. + +tcp.7 +udp.7 + nicolas françois + replace references to syctl interfaces with /proc + + +==================== changes in man-pages-3.24 ==================== + +released: 2010-02-25, munich + + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +andi kleen +andries e. brouwer +ansgar burchardt +bela lubkin +bill o. gallmeister +christoph hellwig +colin watson +dan jacobson +david howells +denis barbier +doug manley +edward welbourne +fang wenqi +frédéric brière +garrett cooper +ihar hrachyshka +jann poppinga +jason goldfine-middleton +jason noakes +jonathan nieder +kevin +mark hills +markus peuhkuri +michael kerrisk +michael witten +mike frysinger +sam liao +samy al bahra +stuart kemp +sunjiangangok +tobias stoeckmann +vlastimil babka +yuri kozlov + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +add_key.2 + david howells + new page documenting add_key(2) + taken from keyutils-1.1 package. + +keyctl.2 + david howells + new page documenting keyctl(2) + taken from keyutils-1.1 package. + +request_key.2 + david howells + new page documenting request_key(2) + taken from keyutils-1.1 package. + + +global changes +-------------- + +various pages + michael kerrisk + global fix: s/non-root/unprivileged/ + +various pages + michael kerrisk + global fix: s/non-privileged/unprivileged/ + +various pages + michael kerrisk + global fix: /non-superuser/unprivileged user/ + +various pages + michael kerrisk + s/non-/non/ + the tendency in english, as prescribed in style guides like + chicago mos, is toward removing hyphens after prefixes + like "non-" etc. + +various pages + michael kerrisk + global fix: s/re-/re/ + the tendency in english, as prescribed in style guides like + chicago mos, is toward removing hyphens after prefixes + like "re-" etc. + +various pages + michael kerrisk + global fix: s/multi-/multi/ + the tendency in english, as prescribed in style guides like + chicago mos, is toward removing hyphens after prefixes + like "multi-" etc. + +various pages + michael kerrisk + global fix: s/pre-/pre/ + the tendency in english, as prescribed in style guides like + chicago mos, is toward removing hyphens after prefixes + like "pre-" etc. + +various pages + michael kerrisk + global fix: s/sub-/sub/ + the tendency in english, as prescribed in style guides like + chicago mos, is toward removing hyphens after prefixes + like "sub-" etc. + +stime.2 +time.2 +utimensat.2 +ctime.3 +difftime.3 +ftime.3 +getspnam.3 +mq_receive.3 +mq_send.3 +rtime.3 +sem_wait.3 +strftime.3 +strptime.3 +timeradd.3 +rtc.4 +core.5 +proc.5 +icmp.7 +time.7 + michael witten + global fix: consistently define the epoch + all definitions of the epoch have been refactored to the following: + + 1970-01-01 00:00:00 +0000 (utc) + + that form is more consistent, logical, precise, and internationally + recognizable than the other variants. + + also, some wording has been altered as well. + +spu_create.2 +getopt.3 +passwd.5 + michael kerrisk + global fix: s/non-existing/nonexistent/ + +faccessat.2 +fchmodat.2 +fchownat.2 +fstatat.2 +futimesat.2 +linkat.2 +mkdirat.2 +mknodat.2 +openat.2 +readlinkat.2 +renameat.2 +symlinkat.2 +unlinkat.2 +utimensat.2 +mkfifoat.3 + michael kerrisk + update feature test macro requirements + starting in glibc 2.10, defining _xopen_source >= 700, + or _posix_c_source >= 200809 exposes the declarations of + these functions. + + +changes to individual pages +--------------------------- + +clock_getres.2 + michael kerrisk + update text on nonsetabble clock_*_cputime_id clocks + susv3 permits, but does not require clock_thread_cputime_id and + clock_process_cputime_id to be settable. + see http://bugzilla.kernel.org/show_bug.cgi?id=11972. + +execve.2 + colin watson + fix description of treatment of caught signals + caught signals reset to their default on an execve() (not + to being ignored). + +fcntl.2 + michael kerrisk + s/f_owner_gid/f_owner_pgrp/ + peter zijlstra took the name change i suggested. + michael kerrisk + document f_[sg]etown_ex; update details on f_setown + linux 2.6.32 adds f_setown_ex and f_getown_ex. + linux 2.6.12 changed (broke) the former behavior of + f_setown with respect to threads. + +intro.2 +intro.3 + michael kerrisk + make subsection heading consistent with other intro.? pages + these pages used "copyright terms"; the other intro.? pages + used "copyright conditions". make these pages like the others. + +sendfile.2 + michael kerrisk + clarify behavior when 'offset' is null + +seteuid.2 + michael kerrisk + note unstandardized behavior for effective id + posix.1 doesn't require that the effective id can be changed + to the same value it currently has (a no-op). the man page + should note this, since some other implementations + don't permit it. + +setgid.2 + michael kerrisk + fix eperm error description + s/effective group id/real group id/ + this bug lived in man pages for 15 years before jason + spotted it! i checked back in linux 1.0, and the behavior + was as the fixed man page describes. + +setreuid.2 + michael kerrisk + add more detail on posix.1 specification for these syscalls + +setuid.2 + michael kerrisk + remove crufty statement that seteuid() is not in posix + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=569812 + +stime.2 +strftime.3 +tzset.3 +zic.8 + michael witten + gmt -> utc (where appropriate) + +sync_file_range.2 + christoph hellwig + add some big warnings re data integrity + this system call is by design completely unsuitable for any data + integrity operations. make that very clear in the manpage. + +cpu_set.3 + vlastimil babka + synopsis: fix return types for cpu_count_*() + these functions return 'int' not void'. + +confstr.3 + michael kerrisk + fix feature test macro requirements + +daemon.3 + michael kerrisk + fix description of 'nochdir' argument. + http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=554819 + +gethostbyname.3 + michael kerrisk + document feature test macro requirements for herror() and hstrerror() + since glibc 2.8, one of _bsd_source, _svid_source, + or _gnu_source is required. + +getline.3 + michael kerrisk + update to reflect that these functions were standardized in posix.1-2008 + +getnameinfo.3 + michael kerrisk + document feature test macros requirements for ni_maxhost and ni_maxserv + since glibc 2.8, one of _bsd_source, _svid_source, or _gnu_source + must be defined to obtain these definitions. + +getopt.3 + jonathan nieder + fix feature test macro requirements + +memchr.3 + michael kerrisk + add feature test macro requirements for memrchr() + +nextafter.3 + michael kerrisk + fix notable error in description. + "less than y" should be "less than x". + +popen.3 + michael kerrisk + fix feature test macro requirements + +pthread_attr_setdetachstate.3 +pthread_attr_setschedparam.3 +pthread_attr_setschedpolicy.3 + denis barbier + argument name is 'attr' not 'thread' + the function argument was misnamed in the description on these + three pages. + +rtnetlink.3 + michael kerrisk + various fixes in example code + edward reported a problem in the example code, where a variable + seems to be misnamed. upon inspection, there seem to be a few + such instances, and this patch is my best guess at how things + should look. + +sched_getcpu.3 + michael kerrisk + place correct header file in synopsis + +sleep.3 + bill o. gallmeister + sleep() puts calling *thread* to sleep (not calling *process*) + +sleep.3 + bill o. gallmeister + add nanosleep(2) to see also + +strftime.3 + michael kerrisk + %z is defined in susv3 + so, substitute "gnu" tag in man page by "su". + +strftime.3 + michael witten + move 822-compliant date format example to examples section + the rfc 822-compliant date format given in the description + of `%z' is now moved to the `examples' section (note: `example' + has been renamed `examples'). + + furthermore, that format example is now actually + rfc 822-compliant (using `%y' instead of `%y') and has been + qualified as being correct only when in the context of at least + an english locale. also, `%t' is used in place of `%h:%m:%s'. + + for completeness, an rfc 2822-compliant format example has been + similarly added. + +strftime.3 + michael witten + expand introductory text + +strftime.3 + michael witten + clarification of %z specifier + +string.3 + mark hills + add stpcpy() to this list of string functions + +strptime.3 + michael kerrisk + initialize tm structure in example program + +undocumented.3 + michael kerrisk + remove pages now documented + by now, the following are documented: + + fopencookie(3) + freeifaddrs(3) + rawmemchr(3) + readdir_r(3) + getutmp(3) + getutmpx(3) + utmpxname(3) + + http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=554819 + +group.5 + michael kerrisk + s/passwd/password/ + the page inconsistently used "passwd" and "password" + to refer to the same field. + +capabilities.7 + michael kerrisk + update securebits discussion to use secbit_* flags + +feature_test_macros.7 + michael kerrisk + _posix_c_source >= 200808 defines _atfile_source + since glibc 2.10, _posix_c_source >= 200808 defines _atfile_source + +path_resolution.7 + michael kerrisk + add readlink(2) to see also + michael kerrisk + fix name line + the poorly constructed part preceding "\-" causes apropos + not to be able to find the subject. + + http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=558300 + +signal.7 + michael kerrisk + fix discussion of sigunused + clarify that this signal really is synonymous with sigsys. + see http://bugzilla.kernel.org/show_bug.cgi?id=14449 + + +==================== changes in man-pages-3.25 ==================== + +released: 2010-06-20, munich + + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +alexander e. patrakov +andi kleen +andrew klossner +andré goddard rosa +bo borgerson +christian franke +daisuke hatayama +david sommerseth +denis barbier +eric blake +fang wenqi +francesco cosoleto +gernot tenchio +hugh dickins +ivana hutarova varekova +jan blunck +jan engelhardt +jan kara +jeff barry +manfred schwarb +mark hills +martin (joey) schulze +michael kerrisk +mihai paraschivescu +mike frysinger +miklos szeredi +petr baudis +petr gajdos +petr uzel +pierre habouzit +reuben thomas +rob landley +robert wohlrab +serge e. hallyn +tolga dalman +tom swigg +walter harms +yuri kozlov + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +migrate_pages.2 + andi kleen + new page documenting migrate_pages(2). + andi's text based on the move_pages.2 page; + additional edits by mtk. + migrate_pages(2) was new in linux 2.6.16. + +quotactl.2 + jan kara + major updates + update the page to consolidate information from the + outdated man-pages quotactl.2 page and the quotactl.2 + page in the "quota-tools" package. the page in "quota-tools" + has now been dropped by jan kara, so that there is just one + canonical quotactl.2 page (in pan-pages). + michael kerrisk + various other pieces added to the page by mtk. + + +newly documented interfaces in existing pages +--------------------------------------------- + +fcntl.2 + michael kerrisk + document f_setpipe_sz and f_getpipe_sz + these commands, new in kernel 2.6.35, set and get the capacity + of pipes. + +madvise.2 + andi kleen + document madv_hwpoison + michael kerrisk + added documentation of madv_mergeable and madv_unmergeable + these flags (used for kernel samepage merging, ksm) + are new in 2.6.32. + andi kleen + document madv_soft_offline + this operation was added in linux 2.6.33. + +mmap.2 + michael kerrisk + document map_uninitialized flag + new in linux 2.6.33. + +prctl.2 + andi kleen + document the hwpoison prctls in 2.6.32 + +sched_setscheduler.2 + michael kerrisk + document sched_reset_on_fork + new in linux 2.6.32 + +umount.2 + michael kerrisk + document umount_nofollow + new in linux 2.6.34. + +mkstemp.3 + michael kerrisk + document mkstemps() and mkostemps() + these functions are new in glibc 2.11. they allow the template + string to include a suffix after the "xxxxxx" string. + +proc.5 + michael kerrisk + document /proc/sys/vm/memory_failure_early_kill + new in 2.6.32. description based on the text in + documentation/sysctl/vm.txt. + michael kerrisk + document /proc/sys/vm/memory_failure_recovery + new in linux 2.6.32. description based on the text in + documentation/sysctl/vm.txt. + michael kerrisk + document /proc/sys/fs/pipe-max-size + +socket.7 + jan engelhardt + document so_domain and so_protocol + these read-only socket options were new in linux 2.6.32. + + +new and changed links +--------------------- + +fstatvfs.2 + michael kerrisk + adjust link to point to section 3 + +fstatvfs.3 +statvfs.2 + michael kerrisk + new link to page relocated to section 3 + +mkstemps.3 +mkostemps.3 + michael kerrisk + new links to mkstemp.3 + mkstemp.3 now describes mkstemps(3) and mkostemps(3). + +timer_create.2 +timer_delete.2 +timer_getoverrun.2 +timer_settime.2 +getline.3 + michael kerrisk + add 'l' to constants in feature test macro specifications + be consistent with posix, which uses constants such as 200809l. + + +global changes +-------------- + +open.2 +sync_file_range.2 +umount.2 + michael kerrisk + global fix: s/filesystem/file system/ + + +changes to individual pages +--------------------------- + +fcntl.2 + michael kerrisk + note that glibc 2.11 papers over the kernel f_getown bug + since version 2.11, glibc works around the kernel limitation for + process groups ids < 4096 by implementing f_getown via f_getown_ex. + +futex.2 + michael kerrisk + various fixes in see also + +getpriority.2 +nice.2 + francesco cosoleto + move renice from section 8 to section 1 + +getrusage.2 + mark hills + add ru_maxrss + see kernel commit 1f10206. + mark hills + description of maintained fields + these descriptions are taken from netbsd 5.0's getrusage(2). + michael kerrisk + enhanced description of various fields + +mlock.2 + michael kerrisk + /proc/pid/status vmlck shows how much memory a process has locked + after a note from tom swigg, it seems sensible mention vmlck here. + +mount.2 + petr uzel + fix incorrect path + +move_pages.2 + andi kleen + clarify includes/libraries + +mremap.2 + michael kerrisk + clarify existence of fifth argument. + +msgctl.2 +semctl.2 +shmctl.2 + francesco cosoleto + move ipcs from section 8 to section 1 + +open.2 + michael kerrisk + remove ambiguity in text on nfs and o_excl. + +poll.2 + michael kerrisk + fix discussion of ppoll() timeout argument + 1. rename ppoll)(_ argument to "timeout_ts" to distinguish it + from the poll() argument in the text. + 2. more accurately describe the poll() call that is equivalent + to ppoll(). + +posix_fadvise.2 + michael kerrisk + add sync_file_range(2) under see also + +prctl.2 + michael kerrisk + correct pr_set_keepcaps description + the "keep capabilities" flag only affects the treatment of + permitted capabilities, not effective capabilities. + also: other improvements to make the pr_set_keepcaps text clearer. + +select_tut.2 + michael kerrisk + fix bug in example program + +sigaction.2 + michael kerrisk + add trap_branch and trap_hwbkpt to si_code values for sigtrap + michael kerrisk + rearrange text describing fields set by sigqueue(2) + michael kerrisk + add details for signals sent by posix message queue notifications + michael kerrisk + improve description of various siginfo_t fields + michael kerrisk + add some details for sigtrap and si_trapno + andi kleen + document hwpoison signal extensions + +statfs.2 + michael kerrisk + bring statfs struct type declarations closer to glibc reality + fang wenqi + add definition ext4_super_magic = 0xef53 + michael kerrisk + document f_frsize field. + +statvfs.2 + michael kerrisk + move this page to section 3 (since it's a library call) + +swapon.2 + ivana hutarova varekova + note effect of config_memory_failure on max_swapfiles + from 2.6.32, max_swapfiles is decreased by 1 if the kernel is + built with config_memory_failure. + +syscalls.2 + michael kerrisk + bring system call list up to date with linux 2.6.33 + michael kerrisk + fix kernel version number for utimes() + +cproj.3 + michael kerrisk + note fix for c99 conformance in glibc 2.12. + +crypt.3 + petr baudis + correct note on key portion significance + as marcel moreaux notes: + + the linux manpage for crypt()[1] contains the following + statement as the last sentence of the notes section: + + in the sha implementation the entire key is significant + (instead of only the first 8 bytes in md5). + + it should probably say "des" where it says "md5" (and maybe + "md5/sha" where it says "sha"), because in md5 password hashing, + the entire key is significant, not just the first 8 bytes. + + this patch fixes the wording. + +fmemopen.3 + michael kerrisk + bug fix in example program + +ftw.3 + michael kerrisk + note that if 'fn' changes cwd, the results are undefined + michael kerrisk + clarify description of fpath argument + as reported by pierre habouzit, 'fpath' is not relative + to 'dirpath'. it is either relative to the calling process's + current working directory (if 'dirpath' was relative), or it + is absolute (if 'dirpath' was absolute). + +getaddrinfo.3 + christian franke + fix a field name mixup: s/ai_family/ai_flags/ + +getline.3 + robert wohlrab + remove unneeded check before free() + the manpage of getline shows an example with an extra null pointer + check before it calls free. this is unneeded according to free(3): + + if ptr is null, no operation is performed. + + this patch removes the "if" check. + + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=572508 + +log.3 +log10.3 +log2.3 + jan engelhardt + add cross-references to other-base logarithmic functions + +opendir.3 + petr baudis + specify feature test macro requirements for fdopendir(3) + currently, there is no note on the fact that fdopendir() is + posix.2008-only. + +openpty.3 + eric blake + use const as appropriate + michael kerrisk + note glibc version that added "const" to function arguments + michael kerrisk + explicitly note that these functions are not in posix + +resolver.3 + michael kerrisk + fix declaration of dn_comp() in synopsis + remove the second 'exp_dn' from the calling signature. + +termios.3 + michael kerrisk + change noflsh text to speak of characters, not signals + +core.5 + michael kerrisk + update description of coredump_filter + kernel 2.6.24 added mmf_dump_elf_headers. + kernel 2.6.28 added mmf_dump_hugetlb_private and + mmf_dump_hugetlb_shared. + +elf.5 + daisuke hatayama + document pn_xnum extension + in linux-2.6.34-rc1, an elf core extension was added; user-land + tools manipulating elf core dump such as gdb and binutils has + already been modified before; so elf.5 needs to be modified + accordingly. + + you can follow information on the elf extension via the lkml post: + http://lkml.org/lkml/2010/1/3/103 + date mon, 04 jan 2010 10:06:07 +0900 (jst) + subject ... elf coredump: add extended numbering support + + this linux-specific extension was added in kernel 2.6.34. + + reviewed-by: petr baudis + + michael kerrisk + remove ei_brand + as reported by yuri kozlov and confirmed by mike frysinger, + ei_brand is not in gabi + (http://www.sco.com/developers/gabi/latest/ch4.eheader.html) + it looks to be a bsdism + michael kerrisk + remove words under '.note': "described below" + the existing text is broken, because there is + no '"note section" format' describe below. simplest + solution is to remove the words "described below". + +filesystems.5 + jeff barry + add discussion of ntfs and ext4 + +proc.5 + michael kerrisk + simplify description of /proc/sys and /proc/sys/fs + in the description of these directories, there's no need + to list all the files and subdirectories that they contain; + that information is provided by the entries that follow. + +services.5 + yuri kozlov + remove crufty reference to nonexistent bugs section + +capabilities.7 + michael kerrisk + document cap_sys_resource and f_setpipe_sz + with cap_sys_resource, a process can increase pipe capacity above + /proc/sys/ps/pipe-max-size. + michael kerrisk + add get_robust_list() info under cap_sys_ptrace + michael kerrisk + add madv_hwpoison under cap_sys_admin + +signal.7 + michael kerrisk + make a clearer statement about nonportable aspect of signal(2) + make a clearer statement that signal(2) is less portable for + establishing a signal handler. + +socket.7 + michael kerrisk + use consistent language to describe read-only socket options + +udp.7 + michael kerrisk + add fionread warning. + warn that fionread can't distinguish case of a zero-length + datagram from the case where no datagrams are available. + + +==================== changes in man-pages-3.26 ==================== + +released: 2010-09-04, munich + + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +alexander shishkin +brian sutin +denis barbier +guillem jover +jianhua li +linus nilsson +lenaic huard +mac +martin schulze +maxin john +michael kerrisk +nicholas hunt +peng haitao +peter stuge +przemyslaw szczepaniak +scott walls +tan yee fan +wu fengguang +yitzchak gale +yuri kozlov + +apologies if i missed anyone! + +newly documented interfaces in existing pages +--------------------------------------------- + +eventfd.2 + michael kerrisk + document efd_semaphore + document the efd_semaphore flag, added in kernel 2.6.30. + also restructured some parts of the text to fit with the + addition of the efd_semaphore text. + + +global changes +-------------- + +getaddrinfo.3 +getipnodebyname.3 +st.4 + michael kerrisk + s/logical or/bitwise or/ + + +changes to individual pages +--------------------------- + +clock_nanosleep.2 + michael kerrisk + fix discussion of return value when interrupted by a signal + +epoll_ctl.2 + yuri kozlov + small fix to types in data structures + +eventfd.2 + alexander shishkin + clarified close-on-exec behavior + +madvise.2 + michael kerrisk + improve discussion of madv_soft_offline + +mkdir.2 + michael kerrisk + add emlink error to errors + +mq_getsetattr.2 +mq_close.3 +mq_getattr.3 +mq_notify.3 +mq_send.3 +mq_unlink.3 + lnac huard + fix return type in synopsis (s/mqd_t/int/) + +recv.2 +send.2 + michael kerrisk + remove obsolete reference to glibc version in notes + +recv.2 +send.2 + nicholas hunt + adjust type shown for msg_controllen to glibc reality + this patch fixes the type of msg_controllen in the struct msghdr + definition given in send.2 and recv.2 to match the definition in + glibc and the kernel. + +select.2 + michael kerrisk + update notes on old glibc pselect() + make it clear that modern glibc uses the kernel pselect() + on systems where it is available. + see https://bugzilla.kernel.org/show_bug.cgi?id=14411 + +statfs.2 + guillem jover + fix copy & paste error for __sword_type definition + +sysfs.2 + michael kerrisk + clarify that this syscall is obsolete. + and strengthen recommendation to use /proc/filesystems instead. + +write.2 + michael kerrisk + add edestaddrreq error + +a64l.3 + peng haitao + fix error in notes, s/a64l/l64a/ + +error.3 + linus nilsson + change "perror" to "strerror" in description of error() + +mq_send.3 + michael kerrisk + fix eagain description (s/empty/full) + +initrd.4 + yuri kozlov + fix ip address in explanation of nfs example + +tzfile.5 + michael kerrisk + add information on version 2 format timezone files + updated using information from the tzcode 2010l release at + ftp://elsie.nci.nih.gov/pub. + (it's an open question whether or not a version of tzfile.5 + should live independently in man-pages. it was added to the + man-pages set many years ago. for now, i'll follow a + conservative course that causes least pain to downstream, + by continuing to maintain a separate copy in man-pages.) + + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=594219 + + +==================== changes in man-pages-3.27 ==================== + +released: 2010-09-22, nuernberg + + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +caishuxian +denis barbier +denis silakov +der mouse +jan kratochvil +jim belton +jiri olsa +kosaki motohiro +mark hills +matthew flaschen +michael kerrisk +ozgur gurcan +petr baudis +remi denis-courmont +tanaka akira +tim stoakes +w. trevor king +yuri kozlov + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +sigevent.7 + petr baudis, michael kerrisk + new page to centralize description of sigevent structure + several interfaces use this structure. best to centralize the + common details in one place. content taken from the existing + timerfd_create.2 and mq_open.3 pages, with additions by + petr baudis and michael kerrisk. + + +newly documented interfaces in existing pages +--------------------------------------------- + +ip.7 + jiri olsa + document ip_nodefrag + this option is new in linux 2.6.36 + +unix.7 + michael kerrisk + document siocinq ioctl() operation + + +global changes +-------------- + +_exit.2 +brk.2 +chdir.2 +chmod.2 +chown.2 +chroot.2 +clock_nanosleep.2 +getdtablesize.2 +gethostname.2 +getpagesize.2 +getsid.2 +killpg.2 +mknod.2 +mknodat.2 +posix_fadvise.2 +pread.2 +readlink.2 +setpgid.2 +setreuid.2 +sigaltstack.2 +stat.2 +symlink.2 +sync.2 +truncate.2 +vfork.2 +wait.2 +wait4.2 +a64l.3 +abs.3 +acos.3 +acosh.3 +asin.3 +asinh.3 +atan.3 +atan2.3 +atanh.3 +atoi.3 +cbrt.3 +ceil.3 +clock_getcpuclockid.3 +copysign.3 +cos.3 +cosh.3 +dirfd.3 +div.3 +dprintf.3 +ecvt.3 +erf.3 +erfc.3 +exp.3 +exp2.3 +expm1.3 +fabs.3 +fdim.3 +fexecve.3 +ffs.3 +floor.3 +fma.3 +fmax.3 +fmemopen.3 +fmin.3 +fmod.3 +fpclassify.3 +frexp.3 +fwide.3 +gamma.3 +gcvt.3 +getcwd.3 +getdate.3 +getgrent.3 +gethostid.3 +getpass.3 +getpwent.3 +getsubopt.3 +getw.3 +hypot.3 +ilogb.3 +insque.3 +isalpha.3 +isgreater.3 +iswblank.3 +j0.3 +j0.3 +ldexp.3 +lockf.3 +log.3 +log10.3 +log1p.3 +log2.3 +logb.3 +lrint.3 +lround.3 +mbsnrtowcs.3 +mkdtemp.3 +mkstemp.3 +mktemp.3 +modf.3 +mq_receive.3 +mq_send.3 +nan.3 +nextafter.3 +posix_fallocate.3 +posix_memalign.3 +pow.3 +printf.3 +qecvt.3 +random.3 +realpath.3 +remainder.3 +remquo.3 +rint.3 +rint.3 +round.3 +scalb.3 +scalbln.3 +scanf.3 +siginterrupt.3 +signbit.3 +sigset.3 +sin.3 +sinh.3 +sqrt.3 +stpcpy.3 +stpncpy.3 +strdup.3 +strdup.3 +strnlen.3 +strsignal.3 +strtod.3 +strtol.3 +strtoul.3 +tan.3 +tanh.3 +tgamma.3 +trunc.3 +ttyslot.3 +ualarm.3 +usleep.3 +wcpcpy.3 +wcpncpy.3 +wcscasecmp.3 +wcsdup.3 +wcsncasecmp.3 +wcsnlen.3 +wcsnrtombs.3 +wprintf.3 + michael kerrisk + add/fix/update feature test macro requirements in synopsis + various changes to: + * update feature test requirements to note changes in + recent glibc releases + * correct errors in feature test macro requirements + * add feature test macro requirements to pages where + the requirements were not previously stated. + +accept.2 +clone.2 +dup.2 +fallocate.2 +pipe.2 +readahead.2 +sched_setaffinity.2 +unshare.2 +cpu_set.3 +endian.3 +euidaccess.3 +fexecve.3 +getpt.3 +getpw.3 +getumask.3 +getutmp.3 +gnu_get_libc_version.3 +makedev.3 +matherr.3 +mbsnrtowcs.3 +memfrob.3 +pthread_attr_setaffinity_np.3 +pthread_getattr_np.3 +pthread_setaffinity_np.3 +pthread_tryjoin_np.3 +tcgetsid.3 +wcscasecmp.3 +wcsncasecmp.3 +wcsnlen.3 +wcsnrtombs.3 +wcswidth.3 +rtld-audit.7 + michael kerrisk + synopsis: add reference to feature_test_macros(7) + these pages specify feature test macros in the function + prototypes. add a reference to feature_test_macros(7), + so that readers are pointed to the information that + feature test macros must be defined before including + *any* header file. + +clock_nanosleep.2 +clock_getcpuclockid.3 +getnetent_r.3 +getprotoent_r.3 +getrpcent_r.3 +getservent_r.3 +sigwait.3 + michael kerrisk + return value: note that "positive error numbers" are listed in errors + +fcntl.2 +intro.2 +open.2 +poll.2 +ftw.3 +intro.3 +matherr.3 +system.3 +tmpnam.3 +unix.7 + michael kerrisk + note that feature test macros must be defined before *any* includes + programmers often make the mistake of including a feature test + macro only after having already included some header files. + this patch adds some text at opportune places to remind + programmers to do things the right way. + +index.3 +stpcpy.3 +strcasecmp.3 +strcat.3 +strchr.3 +strcmp.3 +strcoll.3 +strcpy.3 +strdup.3 +strfry.3 +strpbrk.3 +strsep.3 +strspn.3 +strstr.3 +strtok.3 +strxfrm.3 + michael kerrisk + see also: add reference to string(3) + the idea here is to provide a route to discover other + string functions. + +armscii-8.7 +cp1251.7 +iso_8859-3.7 +iso_8859-5.7 +iso_8859-6.7 +iso_8859-8.7 +iso_8859-10.7 +iso_8859-11.7 +iso_8859-13.7 +iso_8859-14.7 +koi8-u.7 + denis barbier + fix decimal values in encoding tables + octal and hexadecimal values are right, but there are some + off-by one errors in decimal values. correct values are + printed by this command: + + perl -pi -e 'if (s/^([0-7]+)\t([0-9]+)\t([0-9a-fa-f]+)//) + {printf "%03o\t%d\t%s", hex($3), hex($3), $3;};' man7/*.7 + + +changes to individual pages +--------------------------- + +capget.2 + michael kerrisk + synopsis: remove unneeded "undef _posix_source" + +fcntl.2 + michael kerrisk + add feature test macro requirements for f_getown and f_setown + +fcntl.2 + michael kerrisk + note feature test macro requirements for f_dupfd_cloexec + +getrlimit.2 + michael kerrisk + document units for rlimit_rttime limit + this limit is in microseconds + + http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=596492 + +lseek.2 + michael kerrisk + removed note about return type on ancient systems + +mount.2 + michael kerrisk + definitions of various ms_* constants only appeared in glibc 2.12 + see http://sourceware.org/bugzilla/show_bug.cgi?id=11235 + +stat.2 + michael kerrisk + update information on nanosecond timestamp fields + update feature test macro requirements for exposing these fields. + note that these fields are specified in posix.1-2008. + +timer_create.2 + michael kerrisk + factor out generic material that was moved to new sigevent(7) page + +aio_fsync.3 + michael kerrisk + add reference to new sigevent(7) page + +atanh.3 + michael kerrisk + glibc 2.10 fixed pole error bug + http://sourceware.org/bugzilla/show_bug.cgi?id=6759 + was resolved. + +cerf.3 + michael kerrisk + make it clearer that this function is unimplemented + +cos.3 + michael kerrisk + errno is now correctly set to edom on a domain error + http://sources.redhat.com/bugzilla/show_bug.cgi?id=6780 + was (silently) resolved. + +expm1.3 + michael kerrisk + errno is now correctly set to erange on a range error + http://sources.redhat.com/bugzilla/show_bug.cgi?id=6788 + was (silently) resolved. + +fmod.3 + michael kerrisk + errno is now correctly set to edom for the x==inf domain error + http://sources.redhat.com/bugzilla/show_bug.cgi?id=6784 + was (silently) resolved. + +insque.3 + michael kerrisk + noted prev == null bug in glibc 2.4 and earlier + as noted by remi denis-courmont, glibc nowadays allows + 'prev' to be null, as required by posix for initializing + a linear list. but in glibc 2.4 and earlier, 'prev' could + not be null. add a bugs section noting this. + + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=551201 + michael kerrisk + added info on circular lists, and initializing circular lists + michael kerrisk + added example program + +lgamma.3 + michael kerrisk + glibc 2.10 fixed pole error bug + http://sourceware.org/bugzilla/show_bug.cgi?id=6777 + was (silently) resolved. + +log2.3 + matthew flaschen + log2() function does not conform to c89 + log2(), log2f(), and log2l() do not conform to c89. + they are defined in c99. see http://flash-gordon.me.uk/ansi.c.txt + and http://www.schweikhardt.net/identifiers.html + +mq_notify.3 + michael kerrisk + factor out generic material that was moved to new sigevent(7) page + +pow.3 + michael kerrisk + errno is now correctly set to erange on a pole error + http://sources.redhat.com/bugzilla/show_bug.cgi?id=6776 + was (silently) resolved. + +pthread_kill_other_threads_np.3 + michael kerrisk + conforming to: note meaning of "_np" suffix + +rand.3 + michael kerrisk + clarify description of range of returned value + michael kerrisk + add an example program + michael kerrisk + expand description of rand_r() + +random.3 + w. trevor king + update initstate() return value description to match glibc + +readdir.3 + michael kerrisk + clarify that "positive error numbers" are listed in errors + +rexec.3 + michael kerrisk + synopsis: add header file and feature test macro requirements + +sigpause.3 + michael kerrisk + correct discussion of when bsd vs sysv version is used in glibc + +sin.3 + michael kerrisk + errno is now correctly set to edom on a domain error + http://sources.redhat.com/bugzilla/show_bug.cgi?id=6781 + was (silently) resolved. + +tan.3 + michael kerrisk + errno is now correctly set to edom on a domain error + http://sources.redhat.com/bugzilla/show_bug.cgi?id=6782 + was (silently) resolved. + +wcscasecmp.3 +wcsncasecmp.3 +wcsnlen.3 + michael kerrisk + added versions section + +boot.7 + yuri kozlov + update list of major linux distributions + +feature_test_macros.7 + michael kerrisk + make text on required placement of macros more prominent + move the text that notes the requirement that feature test macros + must be defined before including any header files to the top of + the page, and highlight the text further, so that the reader will + not miss this point. + +pthreads.7 +signal.7 + michael kerrisk + add see also reference to new sigevent(7) page + +tcp.7 + michael kerrisk + clarify header file details for siocinq and siocoutq + also note synonymous fionread and tiocoutq. + + +==================== changes in man-pages-3.28 ==================== + +released: 2010-10-04, munich + + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +andries e. brouwer +denis barbier +jan kara +landijk +lennart poettering +michael haardt +michael kerrisk +petr baudis +sam varshavchik + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +getaddrinfo_a.3 + petr baudis + new page documenting getaddrinfo_a() + the page also documents gai_suspend(), gai_cancel(), + and gai_error(). + +aio.7 + michael kerrisk + new page providing an overview of posix asynchronous i/o + + +newly documented interfaces in existing pages +--------------------------------------------- + +exec.3 + michael kerrisk + document execvpe() + this function was added to glibc in version 2.11. + also various other small rewrites in the page. + + +new and changed links +--------------------- + +gai_cancel.3 +gai_error.3 +gai_suspend.3 + petr baudis + new links to new getaddrinfo_a.3 page + +error_one_per_line.3 + michael kerrisk + fix misnamed link file (was error_on_per_line.3) + +execvpe.3 + michael kerrisk + new link to exec.3 + +sigstack.3 + michael kerrisk + new link to sigaltstack.2 + no new programs should use sigstack(3). point the user to the + better sigaltstack(2), whose man page briefly mentions sigstack(3). + +vlimit.3 + michael kerrisk + new link to getrlimit.2 + no new programs should use vlimit(3). point the user to the + better setrlimit(2), whose man page briefly mentions vlimit(3). + +vtimes.3 + michael kerrisk + new link to getrusage.2 + no new programs should use vtimes(3). point the user to the + better getrusage(2), whose man page briefly mentions vtimes(3). + + +global changes +-------------- + +various pages + michael kerrisk + switch to american usage: "-wards" ==> "-ward" + american english uses "afterward" in preference to "afterwards", + and so on + +chdir.2 +chmod.2 +chown.2 +gethostname.2 +getsid.2 +pread.2 +setpgid.2 +sigaltstack.2 +stat.2 +truncate.2 +wait.2 +dirfd.3 +getsubopt.3 +mkdtemp.3 +mkstemp.3 +siginterrupt.3 +strdup.3 + michael kerrisk + simplify feature test macro requirements + + +changes to individual pages +--------------------------- + +getrlimit.2 + michael kerrisk + add mention of the ancient vlimit() function + +getrusage.2 + michael kerrisk + add mention of the ancient vtimes() function + +io_cancel.2 +io_destroy.2 +io_getevents.2 +io_setup.2 +io_submit.2 + michael kerrisk + see also: add aio(7) + +sched_setscheduler.2 + michael kerrisk + errors: note that null 'param' yields einval + +stat.2 + michael kerrisk + note feature test macro requirements for blkcnt_t and blksize_t + +timer_create.2 + michael kerrisk + standardize on name 'sevp' for sigevent argument + +truncate.2 + michael kerrisk + correct and simplify ftruncate() feature test macro requirements + the glibc 2.12 feature test macro requirements for ftruncate() are + buggy; see http://sourceware.org/bugzilla/show_bug.cgi?id=12037. + corrected the requirements in the synopsis, and added a bugs + section describing the problem in glibc 2.12. + +aio_cancel.3 + michael kerrisk + add pointer to aio(7) for example program + refer the reader to aio(7) for a description of the aiocb structure + conforming to: add posix.1-2008; add versions section + +aio_error.3 + michael kerrisk + wording improvements in return value + add pointer to aio(7) for example program + refer the reader to aio(7) for a description of the aiocb structure + conforming to: add posix.1-2008; add versions section + +aio_fsync.3 + michael kerrisk + refer the reader to aio(7) for a description of the aiocb structure + conforming to: add posix.1-2008; add versions section + +aio_read.3 + michael kerrisk + various minor rewordings and additions + add pointer to sigevent(7) for details of notification of i/o completion + add pointer to aio(7) for example program + refer the reader to aio(7) for a description of the aiocb structure + conforming to: add posix.1-2008; add versions section + +aio_return.3 + michael kerrisk + improve description in return value + add pointer to aio(7) for example program + refer the reader to aio(7) for a description of the aiocb structure + conforming to: add posix.1-2008; add versions section + +aio_suspend.3 + michael kerrisk + various additions and rewordings. + give some arguments more meaningful names. + more explicitly describe the 'nitems' argument. + explicitly note that return is immediate if an i/o operation + has already completed. + note that aio_error(3) should be used to scan the aiocb list + after a successful return. + add references to other relevant pages. + various other pieces rewritten. + refer the reader to aio(7) for a description of the aiocb structure + conforming to: add posix.1-2008; add versions section + +aio_write.3 + michael kerrisk + add pointer to sigevent(7) for details of notification of i/o completion + various minor rewordings and additions + refer the reader to aio(7) for a description of the aiocb structure + conforming to: add posix.1-2008; add versions section + +clearenv.3 + michael kerrisk + fix error in feature test macro requirements + +dysize.3 + michael kerrisk + remove crufty statement about old sco bug + +exec.3 + michael kerrisk + add feature test macro requirements for execvpe() + rewrite description of path and mention _cs_path + note execvp() and execlp() behavior for filename containing a slash + +getaddrinfo.3 + michael kerrisk + add see also reference to new getaddrinfo_a.3 page + +gethostbyname.3 + michael kerrisk + fix formatting of feature test macros + +getw.3 + michael kerrisk + fix feature test macros + +malloc.3 + landijk + remove editorializing comments on memory overcommitting + see https://bugzilla.kernel.org/show_bug.cgi?id=19332 + michael kerrisk + various minor reorganizations and wording fix-ups + +mq_notify.3 + michael kerrisk + standardize on name 'sevp' for sigevent argument + +nl_langinfo.3 + michael haardt + make it clear that nl_langinfo() interacts with setlocale() + add an example program + +posix_openpt.3 + michael kerrisk + fix feature test macro requirements + +rand.3 + michael kerrisk + remove duplicate #include in example program + +strtok.3 + petr baudis + add reference to strtok() example in getaddrinfo(3) + +inotify.7 + michael kerrisk + added section noting limitations and caveats of inotify + +sigevent.7 + michael kerrisk + add see also reference to new getaddrinfo_a.3 page + add see also referring to new aio(7) page + +suffixes.7 + michael kerrisk + change explanation of ".rpm" to "rpm software package" + + +==================== changes in man-pages-3.29 ==================== + +released: 2010-10-19, detroit + + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +balazs scheidler +david prevot +denis barbier +guillem jover +ivana varekova +lennart poettering +michael kerrisk +sam varshavchik +simon paillard +stephan mueller +thomas jarosch +yuri kozlov + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +subpage_prot.2 + michael kerrisk + new page documenting the powerpc-specific subpage_prot(2) + +aio_init.3 + michael kerrisk + new page documenting aio_init(3) + + +newly documented interfaces in existing pages +--------------------------------------------- + +posix_fadvise.2 + michael kerrisk + document the architecture-specific arm_fadvise64_64() system call + this arm-specific system call fixes the argument ordering + for that architecture. since linux 2.6.14. + +sync_file_range.2 + michael kerrisk + document the architecture-specific sync_file_range2() system call + as described in commit edd5cd4a9424f22b0fa08bef5e299d41befd5622, + the sync_file_range() argument order is broken for some + architectures (powerpc, arm, tile). the remedy was a different + system call using the right argument order on those architectures. + +psignal.3 + guillem jover + document psiginfo() + psiginfo() was added to glibc in version 2.10. + michael kerrisk + add details, versions, and bugs for psiginfo() + +ip.7 + balazs scheidler + document ip_recvorigdstaddr + document ip_transparent + michael kerrisk + document ip_freebind + text based on input from lennart poettering and balazs scheidler. + see https://bugzilla.kernel.org/show_bug.cgi?id=20082 + + +new and changed links +--------------------- + +arm_fadvise64_64.2 + michael kerrisk + new link to posix_fadvise.2 + +arm_sync_file_range.2, sync_file_range2.2 + michael kerrisk + new links to sync_file_range.2 + +arrm_fadvise.2 + michael kerrisk + new link to posix_fadvise.2 + +psiginfo.3 + guillem jover + new link to psignal.3 + + +global changes +-------------- + +many pages + michael kerrisk + global fix: s/unix/unix/ + the man pages were rather inconsistent in the use of "unix" + versus "unix". let's go with the trademark usage. + +various pages + michael kerrisk + global fix: s/pseudo-terminal/pseudoterminal/ + +grantpt.3, ptsname.3, unlockpt.3, pts.4 + michael kerrisk + global fix: s/pty/pseudoterminal/ + +recv.2, cmsg.3, unix.7 + michael kerrisk + global fix: s/unix socket/unix domain socket/ + +fmtmsg.3, gethostbyname.3, termios.3 + michael kerrisk + global fix: s/unixware/unixware/ + + +changes to individual pages +--------------------------- + +inotify_rm_watch.2 + michael kerrisk + synopsis: fix type of 'wd' argument + +posix_fadvise.2 + michael kerrisk + rewrite versions, noting that the system call is fadvise64() + +syscalls.2 + michael kerrisk + add the powerpc-specific subpage_prot() system call + add sync_file_range2() + +truncate.2 + michael kerrisk + fix feature test macros + +aio_cancel.3 +aio_error.3 +aio_fsync.3 +aio_read.3 +aio_return.3 +aio_suspend.3 +aio_write.3 + michael kerrisk + see also: add lio_listio(3) + +gai_cancel.3 +gai_error.3 +gai_suspend.3 + michael kerrisk + make these into links + in the previous release, these files were accidentally made copies + of getaddrinfo_a.3, instead of being made as link files. + +getifaddrs.3 + thomas jarosch + prevent possible null pointer access in example program + +malloc.3 + michael kerrisk + emphasize that malloc() and realloc() do not initialize allocated memory + +malloc_hook.3 + ivana varekova + warn that these functions are deprecated + +strcpy.3 + michael kerrisk + formatting fixes in strncpy() example implementation code + +ip.7 + michael kerrisk + reword notes on linux-specific options + +sigevent.7 + michael kerrisk + see also: add aio_read(3), aio_write(3), and lio_listio(3) + +unix.7 + michael kerrisk + document the autobind feature + michael kerrisk + fix description of abstract socket names + as reported by lennart poettering: + the part about "abstract" sockets is misleading as it suggests + that the sockaddr returned by getsockname() would necessarily + have the size of sizeof(struct sockaddr), which however is not + the case: getsockname() returns exactly the sockaddr size that + was passed in on bind(). in particular, two sockets that are + bound to the same sockaddr but different sizes are completely + independent. + see https://bugzilla.kernel.org/show_bug.cgi?id=19812 + michael kerrisk + fix description of "pathname" sockets + as reported by lennart poettering: + the part about "pathname" sockets suggests usage of + sizeof(sa_family_t) + strlen(sun_path) + 1 + for calculating the sockaddr size. due to alignment/padding + this is probably not a good idea. instead, one should use + offsetof(struct sockaddr_un, sun_path) + strlen() + 1 + or something like that. + see https://bugzilla.kernel.org/show_bug.cgi?id=19812 + + +==================== changes in man-pages-3.30 ==================== + +released: 2010-11-01, munich + + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +andi kleen +bernhard walle +david prevot +eric w. biederman +florian lehmann +jan engelhardt +lucian adrian grijincu +michael kerrisk +paul mackerras +pádraig brady +reuben thomas +scarlettsp +yuri kozlov + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +kexec_load.2 + andi kleen + new page documenting kexec_load(2) + michael kerrisk + add license + michael kerrisk + incorporate fixes from eric w. biederman + eric noted that a few instances of "virtual" should + be "physical" and noted: + + there is an expectation that at hand off from sys_kexec that + virtual and physical addresses will be identity mapped. but + this isn't the old alpha booting convention where you have + a virtual address and then you have to parse the page table + to figure out where your kernel was actually loaded. + michael kerrisk + additions and edits by mtk + various wording and layout improvements. + fixed the name of a constant: s/kexec_arch_i386/kexec_arch_386/. + added return value and errors sections. + added versions section + note that config_kexec is needed + removed details of using syscall; the reader can find them in + syscall(2). + added some details for kexec_preserve_context. + revised the text mentioning the kernel header, since it is + not yet exported, and it's not certain that it will be. + +lio_listio.3 + michael kerrisk + new page documenting lio_listio(3) + + +newly documented interfaces in existing pages +--------------------------------------------- + +reboot.2 + andi kleen + document linux_reboot_kexec + some fix-ups by michael kerrisk + michael kerrisk + place 'cmd' values in alphabetical order. + +unshare.2 + michael kerrisk + document clone_newipc + michael kerrisk + document clone_newnet + lucian adrian grijincu + improve description of clone_newnet + clone_newnet creates a new network namespace from scratch. + you don't have anything from the old network namespace in + the new one. even the loopback device is new. + michael kerrisk + document clone_sysvsem + michael kerrisk + document clone_newuts + michael kerrisk + relocate discussion of cap_sys_admin to clone_newns section + and rewrite the eperm description to be more general in + preparation for the new flags to be documented. + + +global changes +-------------- + +various pages + michael kerrisk + add reference to feature_test_macros(7) + some pages simply list feature test macro requirements in + the form: + + #define #gnu_source + #include + + for these pages, add a "see feature_test_macros(7)" comment + on the "#define" line. + +various pages + michael kerrisk + see also: remove redundant reference to feature_test_macros(7) + +various pages + david prevot + use greater consistency in name line + (remove definite article at start of descriptive clause.) + +various pages + michael kerrisk + see also: place entries in correct order + +various pages + michael kerrisk + errors: place entries in correct order + +various pages + michael kerrisk + add section number to references to functions documented in other pages + +various pages + michael kerrisk + remove redundant section number in page references + remove section number in function references that are for + functions documented on this page. + +armscii-8.7 +iso_8859-3.7 +iso_8859-4.7 +iso_8859-5.7 +iso_8859-6.7 +iso_8859-10.7 +iso_8859-11.7 +iso_8859-13.7 +iso_8859-14.7 +koi8-u.7 + david prevot + capitalize hexadecimal numbers + + +changes to individual pages +--------------------------- + +access.2 + michael kerrisk + note use of faccessat(2) for checking symbolic link permissions + michael kerrisk + give an example of a safer alternative to using access() + +clone.2 + michael kerrisk + clarify when clone_newnet implementation was completed + +faccessat.2 + michael kerrisk + note that faccessat() is racy + +fcntl.2 + michael kerrisk + return value: improve description of f_getfd and f_getfl + +inotify_add_watch.2 + michael kerrisk + document enoent error + +mlock.2 + michael kerrisk + improve wording describing /proc/pid/status /vmlck field + michael kerrisk + shmctl() shm_locked memory is not included in vmlck + +reboot.2 + michael kerrisk + place 'cmd' values in alphabetical order + +subpage_prot.2 + michael kerrisk + change 1-line page description + michael kerrisk + improvements after review by paul mackerras + +timer_settime.3 + michael kerrisk + remove redundant see also reference + +euidaccess.3 + michael kerrisk + note the use of faccessat(2) to operate on symbolic links + michael kerrisk + note that the use of euidaccess() is racy + +fenv.3 + michael kerrisk + clarify wording relating to glibc version + +getgrent.3 +getgrent_r.3 +getgrnam.3 + michael kerrisk + refer reader for group(5) for more info on group structure + +getopt.3 + bernhard walle + use constants in getopt_long() example + the description of getopt_long() mentions the constants + required_argument, no_argument and optional_argument. + use them in the example to make the code easier to understand. + +getpw.3 + michael kerrisk + change comment describing pw_gecos + +getpw.3 +getpwent.3 +getpwent_r.3 + michael kerrisk + refer reader to passwd(5) for more info on the passwd structure + +getpwent.3 +getpwnam.3 + michael kerrisk + note that pw_gecos is not in posix + and change the comment describing this field + +getpwent_r.3 + michael kerrisk + change comment describing pw_gecos + +getpwnam.3 + michael kerrisk + some rewording and restructuring + +sched_getcpu.3 + michael kerrisk + fix feature test macro requirements + +strnlen.3 + michael kerrisk + fix feature test macro requirements + +group.5 + michael kerrisk + various minor rewordings + +hosts.5 +protocols.5 +spufs.7 +termio.7 + david prevot + remove definite article from name section + please find inline another tiny patch in order to shrink + the definite article from some other pages (found with + "rgrep -i ' \\\- the' man*"). + +passwd.5 + michael kerrisk + various minor rewordings + +proc.5 + michael kerrisk + add reference to mlock(2) for further info on /proc/pid/status vmlck + +armscii-8.7 + david prevot + write the character set name as armscii + +cp1251.7 + david prevot + capitalize hexadecimal numbers + +ip.7 + david prevot + fix name of socket option: s/ip_ttl/ip_transparent/ + david prevot + place socket options in alphabetical order + +koi8-r.7 + david prevot + fix special character names + comparing to koi8-u.7, i noticed some inconsistencies in special + character names. after checking with the following unicode related + pages, please find inline (and gzipped attached, hopefully not + messing with encoding), a patch in order to make it right, on an + unicode point of view. + + http://www.unicode.org/charts/pdf/u2500.pdf + http://www.unicode.org/charts/pdf/u25a0.pdf + http://www.unicode.org/charts/pdf/u0080.pdf + http://www.unicode.org/charts/pdf/u1d400.pdf + david prevot + fix see also reference and letter names + the koi8-r(7) (russian net character set) manual page refers + to iso-8859-7(7) manual page, which is the latin/greek one. + i guess it should refer instead to the iso-8859-5(7) + (latin/cyrillic) one. this is addressed at the end of the patch. + + it has also been spotted that letter names are different in + this manual page and in the unicode related page [0], the + first part of the page address this. + + 0: http://www.unicode.org/charts/pdf/u0400.pdf + +man-pages.7 + michael kerrisk + update example + the old example used the chmod(2) man page, but the + feature test macro requirements on that page had changed. + update to use an example from a different page (acct(2), + whose feature test macro requirements are probably unlikely + to change in the future). + + +==================== changes in man-pages-3.31 ==================== + +released: 2010-11-12, munich + + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +andi kleen +david prevot +denis barbier +krzysztof żelechowski +michael kerrisk +yuri kozlov + +apologies if i missed anyone! + + +newly documented interfaces in existing pages +--------------------------------------------- + +getrlimit.2 + michael kerrisk + added documentation of prlimit() + prlimit() is new in kernel 2.6.36. + +inotify.7 + michael kerrisk + document in_excl_unlink + this flag was added in linux 2.6.36. + see kernel commit 8c1934c8d70b22ca8333b216aec6c7d09fdbd6a6. + + +new and changed links +--------------------- + +prlimit.2 + michael kerrisk + new link to getrlimit.2 + + +changes to individual pages +--------------------------- + +getrlimit.2 + michael kerrisk + remove unneeded text in description + +intro.2 + michael kerrisk + added various pages to see also + +kexec_load.2 + michael kerrisk + add kernel version where kexec_preserve_context first appeared + added kernel version number where kexec_on_crash first appeared + fix copyright + make copyright in the name of intel corporation + versions: fix version number + kexec_load() was first implemented in 2.6.13, though the entry + in the system call table was reserved starting in 2.6.7. + +migrate_pages.2 + michael kerrisk + see also: add reference to documentation/vm/page_migration + +sched_setaffinity.2 + michael kerrisk + add missing word "real" to "user id" + +syscalls.2 + michael kerrisk + fix kernel version number for kexec_load + kexec_load() was first implemented in 2.6.13, though the entry + in the system call table was reserved starting in 2.6.7. + michael kerrisk + add prlimit() to list + +intro.3 + michael kerrisk + added various pages to see also + +printf.3 + michael kerrisk + formatting fixes in example code + +hostname.7 + michael kerrisk + small improvement to description of domains + see: https://bugzilla.novell.com/show_bug.cgi?id=651900 + + +==================== changes in man-pages-3.32 ==================== + +released: 2010-12-03, munich + + +contributors +------------ + +the following people contributed notes, ideas, or patches that have +been incorporated in changes in this release: + +a. costa +denis barbier +emil mikulic +eugene kapun +hugh dickins +ivana hutarova varekova +joern heissler +lars wirzenius +martin eberhard schauer +michael kerrisk +petr uzel +roger pate +török edwin +yuri kozlov + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +pthread_sigqueue.3 + michael kerrisk + new page documenting pthread_sigqueue() + pthread_sigqueue() is new in glibc 2.11 (requires a kernel with + rt_tgsigqueinfo(), added in linux 2.6.31). + + +newly documented interfaces in existing pages +--------------------------------------------- + +readv.2 + michael kerrisk + add documentation of preadv() and pwritev() + the preadv() and pwritev() system calls were added in + linux 2.6.30. + + +new and changed links +--------------------- + +preadv.2 + michael kerrisk + new link to readv.2 + +pwritev.2 + michael kerrisk + new link to readv.2 + + +changes to individual pages +--------------------------- + +chdir.2 + michael kerrisk + remove redundant and incorrect info on ftms from notes + +chown.2 + michael kerrisk + add notes explaining 32-bit system calls added in linux 2.4 + +clock_nanosleep.2 + michael kerrisk + clarify that clock_nanosleep() suspends the calling *thread* + +epoll_create.2 + michael kerrisk + note that 'size' argument must be greater than 0 + see https://bugzilla.kernel.org/show_bug.cgi?id=23872 + michael kerrisk + added versions section + +epoll_ctl.2 + michael kerrisk + added versions section + +epoll_wait.2 + michael kerrisk + updated versions section + +fcntl.2 + michael kerrisk + add notes on fcntl64() + +fstatat.2 + michael kerrisk + add notes on fstatat64(), the name of the underlying system call + +getdents.2 + michael kerrisk + added notes on getdents64() + +getgid.2 + michael kerrisk + add notes explaining 32-bit system calls added in linux 2.4 + +getgroups.2 + michael kerrisk + add notes explaining 32-bit system calls added in linux 2.4 + +getpagesize.2 + michael kerrisk + improve description of getpagesize() + improve description of getpagesize() and relocate discussion + of sysconf(_sc_pagesize). + + in part inspired by + http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=537272 + +getresuid.2 + michael kerrisk + add notes explaining 32-bit system calls added in linux 2.4 + +getrlimit.2 + michael kerrisk + add example program for prlimit() + +getuid.2 + michael kerrisk + add notes explaining 32-bit system calls added in linux 2.4 + +open.2 + ivana hutarova varekova + o_excl can be used without o_creat for block devices + since linux 2.6 there is a possibility to use o_excl without + o_creat. see patch: http://lkml.org/lkml/2003/8/10/221. + +pread.2 + michael kerrisk + add notes on pread64() and pwrite64() + see https://bugzilla.kernel.org/show_bug.cgi?id=23072 + michael kerrisk + see also: add readv(3) + +readv.2 + michael kerrisk + wording fix: readv() and writev() are system calls, not functions + +sendfile.2 + michael kerrisk + add notes on sendfile64() + +setfsgid.2 + michael kerrisk + add notes explaining 32-bit system calls added in linux 2.4 + +setfsuid.2 + michael kerrisk + add notes explaining 32-bit system calls added in linux 2.4 + +setgid.2 + michael kerrisk + add notes explaining 32-bit system calls added in linux 2.4 + +setresuid.2 + michael kerrisk + add notes explaining 32-bit system calls added in linux 2.4 + +setreuid.2 + michael kerrisk + add notes explaining 32-bit system calls added in linux 2.4 + +setuid.2 + michael kerrisk + add notes explaining 32-bit system calls added in linux 2.4 + +sigqueue.2 +pthreads.7 +signal.7 + michael kerrisk + see also: add pthread_sigqueue(3) + +stat.2 + michael kerrisk + fix eoverflow error description + 2<<31 should read 1<<31 (which equals 2^31). + +statfs.2 + michael kerrisk + add notes on statfs64() and fstatfs64() + +swapon.2 + hugh dickins + document swap_flag_discard and discarding of swap pages + +truncate.2 + michael kerrisk + add notes on truncate64() and ftruncate64() + +memcpy.3 + michael kerrisk + change "should not overlap" to "must not overlap" + glibc 2.12 changed things so that applications that use memcpy() on + overlapping regions will encounter problems. (the standards have + long said that the behaviors is undefined if the memory areas + overlap.) + + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=603144 + in reference of http://lwn.net/articles/414467/ + and http://article.gmane.org/gmane.comp.lib.glibc.alpha/15278 + +usleep.3 + petr uzel + usleep() suspends calling thread, not process + +core.5 + michael kerrisk + change single quote to double quote in shell session example + the example section has a sample shell session containing: + + echo '|$pwd/core_pattern_pipe_test %p uid=%u gid=%g sig=%s' + + but $pwd won't be expanded in single quotes. it should be double + quotes around the entire argument or some other form. + +pthreads.7 + michael kerrisk + added description of async-cancel-safe functions + +unix.7 + michael kerrisk + reworded the text of various errors + michael kerrisk + added enoent error + + +==================== changes in man-pages-3.33 ==================== + +released: 2011-09-16, munich + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes and ideas that have been +incorporated in changes in this release: + +akira fujita +alexander schuch +andries brouwer +brian m. carlson +dan jacobson +folkert van heusden +graham gower +hendrik jan thomassen +jan engelhardt +joey adams +johannes laire +jon grant +josh triplett +konstantin ritt +luis javier merino +michael kerrisk +mike frysinger +mikel ward +nick black +paul evans +petr pisar +przemyslaw pawelczyk +regid ichira +reuben thomas +richard b. kreckel +ryan mullen +sebastian geiger +sebastian unger +seonghun lim +serge e. hallyn +simon cross +simon paillard +stan sieler +timmy lee +tolga dalman +tomislav jonjic +yuri kozlov +wei luosheng + +apologies if i missed anyone! + + +newly documented interfaces in existing pages +--------------------------------------------- + +sync.2 + michael kerrisk + added new syncfs() system call + syncfs() was added in linux 2.6.39. + + +new and changed links +--------------------- + +syncfs.2 + michael kerrisk + new link for sync(2). + + +global changes +-------------- + +various pages + simon paillard + global fix: properly escape minus sign + + +changes to individual pages +--------------------------- + +clone.2 + michael kerrisk + note that clone_stopped was removed in 2.6.38 + +execve.2 + michael kerrisk [sebastian geiger] + note that the first argv[] value should contain name of executable + +fcntl.2 + michael kerrisk [reuben thomas] + note that f_getfl also retrieves file access mode + +getrlimit.2 + michael kerrisk [ryan mullen] + remove mention of kernel versions in discussion of rlimit_cpu + michael kerrisk [seonghun lim] + fix example program and add _file_offset_bits requirement + +mlock.2 + michael kerrisk [brian m. carlson] + clarify einval error + see http://bugs.debian.org/cgi-bin/bugreport.cgi?625747 + michael kerrisk [seonghun lim] + simplify and correct text for eperm error + +mprotect.2 + seonghun lim + fix off-by-one error in a memory range + seonghun lim + fix small bug in example program + the description of the example program says that it makes the + third page "read-only". thus use prot_read instead of prot_none. + +open.2 + folkert van heusden + remove text describing o_cloexec as linux-specific + o_cloexec is specified in posix.1-2008, as noted + elsewhere in the page. + +readlink.2 + michael kerrisk [dan jacobson] + see also: add readlink(1) + +sendfile.2 + akira fujita + since 2.6.33, 'out_fd' can refer to any file type + linux kernel commit cc56f7de7f00d188c7c4da1e9861581853b9e92f + meant sendfile(2) can work with any output file. + michael kerrisk + shift text on falling back to read()/write() to notes + michael kerrisk [tolga dalman] + remove mention of kernel version for 'in_fd' argument + tolga dalman + add an explicit reference to splice(2) + unlike sendfile(), splice() can transfer data + between a pair of sockets. + +sigaction.2 + michael kerrisk [tolga dalman] + add a little info about ucontext_t + +stat.2 + michael kerrisk [jon grant] + small rewording of enametoolong error + +sync.2 + michael kerrisk + some rewrites to description of sync() + +syscalls.2 + michael kerrisk + added fanotify_init() and fanotify_mark() to syscall list + michael kerrisk + added new 2.6.39 system calls + michael kerrisk + updated for linux 3.0 system calls + michael kerrisk + update kernel version at head of syscall list + michael kerrisk + update to mention 3.x kernel series + +syslog.2 + michael kerrisk [serge e. hallyn] + update for kernel 2.6.37 changes + document /proc/sys/kernel/dmesg_restrict. + document cap_syslog. + +time.2 + michael kerrisk [alexander schuch] + notes: fix description of "seconds since the epoch" + +timerfd_create.2 + michael kerrisk [josh triplett] + note behavior when timerfd_settime() old_value is null + see http://bugs.debian.org/cgi-bin/bugreport.cgi?641513 + tomislav jonjic + fix small error in description of timerfd_settime() + +truncate.2 + seonghun lim + remove redundant eintr description + +unlink.2 + hendrik jan thomassen + improve ebusy description + +cacos.3 +cacosh.3 +catan.3 +catanh.3 + michael kerrisk [richard b. kreckel, andries brouwer] + fix formula describing function + the man pages for cacos(), cacosh(), catan(), catanh() + contain incorrect formulae describing the functions. + +cacos.3 + michael kerrisk + add example program + +cacosh.3 + michael kerrisk + add example program + +cacosh.3 +casinh.3 +catan.3 +catanh.3 + michael kerrisk + see also: add reference to inverse function + +catan.3 + michael kerrisk + add example program + +catanh.3 + michael kerrisk + add example program + +ccos.3 +ccosh.3 +csin.3 +csinh.3 +ctan.3 +ctanh.3 + michael kerrisk + see also add reference to "arc" inverse function + +cexp.3 + michael kerrisk + see also: add cexp(3) + +clog.3 + michael kerrisk + see also: add reference to clog(2) + +crypt.3 + michael kerrisk [jan engelhardt] + fix header file and feature test macro requirements for crypt_r() + +err.3 + seonghun lim + clean up description of error message source + in the second paragraph of description section, one of the + sources of error messages is incorrect: the four functions obtain + error message only from errno, and "a code" is just relevant + with errc() and warnc(), which are not present on linux. + see http://www.unix.com/man-page/freebsd/3/err/ . + + then, the third paragraph becomes a duplicate. + +fflush.3 + regid ichira + fix wording error + see http://bugs.debian.org/cgi-bin/bugreport.cgi?614021 + +hsearch.3 + seonghun lim + update errors section + einval can occur for hdestroy_r(). + einval can't occur for hcreate(). + other minor fixes. + +lockf.3 + michael kerrisk [mikel ward] + errors: ebadf can also occur for nonwritable file descriptor + as noted in the description, the file descriptor must be writable + in order to place a lock. + +malloc.3 + seonghun lim + reorder prototypes in synopsis + calloc() comes before realloc() in the other sections, + so should do in synopsis, too. + +mbstowcs.3 + michael kerrisk + see also: add reference to wcstombs(3) + +memcmp.3 + michael kerrisk [sebastian unger] + clarify that comparison interprets bytes as "unsigned char" + +realpath.3 + michael kerrisk [seonghun lim] + fix einval error + since glibc 2.3, resolved_path can be non-null (with the + semantics already documented in the page). + +scandir(3) + mike frysinger + add enoent/enotdir errors + +siginterrupt.3 + michael kerrisk [luis javier merino] + remove misleading sentence about signal(2) and system call interruption + +strlen.3 + michael kerrisk [jon grant] + see also: add strnlen(3) + +strnlen.3 + michael kerrisk [jon grant] + conforming to: note that strnlen() is in posix.1-2008 + +strtoul.3 + michael kerrisk [tolga dalman] + fix notes section constants + +termios.3 + michael kerrisk + use "terminal special characters" consistently throughout page + michael kerrisk [paul evans] + add documentation of _posix_vdisable + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=627841 + michael kerrisk + add a description of status character + michael kerrisk + added description of swtch character + michael kerrisk + add names of terminal special characters + michael kerrisk + list terminal special characters in alphabetical order + +wcstombs.3 + michael kerrisk + see also: add mbstowcs(3) + +console_codes.4 + petr pisar + add esc [ 3 j + linux 3.0 (commit f8df13e0a901fe55631fed66562369b4dba40f8b) + implements \e[3j to allow scrambling content of console + including scroll-back buffer + (http://thread.gmane.org/gmane.linux.kernel/1125792). + +proc.5 + michael kerrisk [stan sieler] + add description of 'ppid' field of /proc/pid/status + michael kerrisk [stan sieler] + add description of 'sigq' field of /proc/pid/status + +capabilities.7 + michael kerrisk [serge e. hallyn] + document cap_syslog and related changes in linux 2.6.37 + michael kerrisk + file capabilities are no longer optional + starting with linux 2.6.33, the config_security_file_capabilities + has been removed, and file capabilities are always part of the + kernel. + +complex.7 + michael kerrisk + updated see also list to include all complex math functions + +ipv6.7 + michael kerrisk [simon cross] + fix description of address notation: "8 4-digit hexadecimal numbers" + +signal.7 + seonghun lim + remove crufty repeated info about linuxthreads + +unix.7 + michael kerrisk + add pointer to cmsg(3) for an example of the use of scm_rights + + +==================== changes in man-pages-3.34 ==================== + +released: 2011-09-23, munich + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes and ideas that have been +incorporated in changes in this release: + +alan curry +benjamin poirier +brian m. carlson +david howells +david prévot +denis barbier +doug goldstein +eric blake +guillem jover +jon grant +michael kerrisk +neil horman +paul pluzhnikov +reuben thomas +stefan puiu +stephan mueller +stephen cameron +sunil mushran + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +rt_sigqueueinfo.2 + michael kerrisk [stephan mueller] + new page for rt_sigqueueinfo(2) and rt_tgsigqueueinfo(2) + this replaces the previous '.so' man page link file for + rt_sigqueueinfo.2, which linked to this sigqueue() man page. + +cciss.4 + stephen m. cameron + new man page for cciss driver + i obtained the information in this man page as a consequence + of having worked on the cciss driver for the past several years, + and having written considerable portions of it. + michael kerrisk + copyedit by mtk + +hpsa.4 + stephen m. cameron + new man page for the hpsa driver + i obtained the information in this man page as a consequence + of being the main author of the hpsa driver. + michael kerrisk + copyedits my mtk + + +newly documented interfaces in existing pages +--------------------------------------------- + +fstatat.2 + michael kerrisk [david howells] + document at_no_automount + this flag was added in linux 2.6.38. + +lseek.2 + michael kerrisk [eric blake, sunil mushran] + document seek_hole and seek_data + these flags, designed for discovering holes in a file, + were added in linux 3.1. included comments from eric + blake and sunil mushran. + +madvise.2 + doug goldstein + add madv_hugepage and madv_nohugepage + document the madv_hugepage and madv_nohugepage flags added to + madvise() in linux 2.6.38. + + +new and changed links +--------------------- + +rt_tgsigqueueinfo.2 + michael kerrisk + new link to new rt_sigqueueinfo.2 page + +sigqueue.2 + michael kerrisk + create link to page that was relocated to section 3 + + +global changes +-------------- + +various pages + michael kerrisk + change reference to "sigqueue(2)" to "sigqueue(3)" + + +changes to individual pages +--------------------------- + +fallocate.2 + michael kerrisk + errors: add eperm and espipe errors + +lseek.2 + michael kerrisk [alan curry, reuben thomas] + remove suspect note about 'whence' being incorrect english + +prctl.2 + paul pluzhnikov + pr_set_dumpable makes process non-ptrace-attachable + +readlink.2 + guillem jover + document using st_size to allocate the buffer + michael kerrisk + added copyright text + changelog note for guillem jover's patch + +sched_setscheduler.2 + michael kerrisk + document 2.6.39 changes to rules governing changes from sched_idle policy + since linux 2.6.39, unprivileged processes under the + sched_idle policy can switch to another nonrealtime + policy if their nice value falls within the range + permitted by their rlimit_nice limit. + +tkill.2 + michael kerrisk + see also: add rt_sigqueueinfo (2) + +btowc.3, wctob.3 + michael kerrisk [brian m. carlson] + add pointers to better, thread-safe alternative functions + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=606899 + +fwide.3 + michael kerrisk + add _isoc95_source to feature test macro requirements + since glibc 2.12, _isoc95_source can also be used to expose + prototype of this function. + +index.3 + michael kerrisk [jon grant] + fix text mentioning terminating null + +pthread_sigqueue.3 + michael kerrisk + replace explicit mention of rt_tgsigqueueinfo() with see also reference + +sigqueue.3 + michael kerrisk + move this page to section 3 + now that the underlying system call rt_sigqueueinfo(2) is + properly documented, move sigqueue() to section 3, since + it is really a library function. + michael kerrisk + update text in line with existence of new rt_sigqueueinfo.2 page + +wcsnlen.3 + jon grant + improve description of 'maxlen' argument + it's worth clarifying 'maxlen' is in wide-char units, not bytes. + +wprintf.3 + michael kerrisk + add _isoc95_source to feature test macro requirements + since glibc 2.12, _isoc95_source can also be used to expose + prototype of these functions. + +feature_test_macros.7 + michael kerrisk + document _isoc95_source + _isoc95_source was added in glibc 2.12 as a means + to expose c90 amendment 1 definitions. + +ip.7 + benjamin poirier [neil horman] + improve description of ip_mtu_discover + +signal.7 + michael kerrisk + see also: add rt_sigqueueinfo(2) + + +==================== changes in man-pages-3.35 ==================== + +released: 2011-10-04, munich + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes and ideas that have been +incorporated in changes in this release: + +andi kleen +david prévot +denis barbier +eric w. biederman +guillem jover +jon grant +kevin lyda +michael kerrisk +mike frysinger +reuben thomas + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +recvmmsg.2 + andi kleen, michael kerrisk + new man page for recvmmsg(2) + +setns.2 + eric w. biederman + new manual page for setns(2) + michael kerrisk + various improvements + + +global changes +-------------- + +various pages + michael kerrisk + global fix: remove spaces around em-dash + normal english typographical convention is not to have + spaces around em dashes. + +various pages + michael kerrisk + global fix: s/null pointer/null pointer/ + +various pages + michael kerrisk + global fix: use oring + use "oring", not "or'ing", nor an italic ".ir or ing". + +various pages + michael kerrisk + global fix: consistent use of "null wide character" + bring more consistency to the discussion of + "[terminating] null wide character" + by writing (at least in the initial use in a page) + "[terminating] null wide character (l'\0')". + +various pages + michael kerrisk + global fix: consistent use of "null byte" + bring more consistency to the discussion of + "[terminating] null byte" + by writing (at least in the initial use in a page) + "[terminating] null byte ('\0')". + +mount.2, prctl.2 + michael kerrisk + s/task/thread/ for consistency with other pages + + +changes to individual pages +--------------------------- + +lseek.2 + guillem jover + conforming to: note other systems that have seek_hole+seek_data + +recv.2 + michael kerrisk + add mention of recvmmsg(2) + +recvmmsg.2 + michael kerrisk + see also: add sendmmsg(2) + +send.2 + michael kerrisk + conforming to: posix.1-2008 adds msg_nosignal + +sigwaitinfo.2 + michael kerrisk + note that attempts to wait for sigkill and sigstop are silently ignored + +stat.2 + michael kerrisk + note posix.1-2001 and posix.1-2008 requirements for lstat() + michael kerrisk + regarding automounter action, add a reference to fstatat(2) + michael kerrisk + clean up text describing which posix describes s_if* constants + +aio_cancel.3 + michael kerrisk [jon grant] + clarify meaning of "return status" and "error status" + +gets.3 + michael kerrisk + posix.1-2008 marks gets() obsolescent + the page formerly erroneously stated that posix.1-2008 + removed the specification of this function. + +mbsnrtowcs.3 + michael kerrisk + conforming to: add posix.1-2008 + this function is specified in the posix.1-2008 revision. + +regex.3 + michael kerrisk [reuben thomas] + change "terminating null" to "terminating null byte" + +stpcpy.3 +stpncpy.3 + mike frysinger + note that these functions are in posix.1-2008 + update the "conforming to" sections of these functions to + note that they are now part of the posix.1-2008 standard. + +stpncpy.3 + michael kerrisk + change "terminating null" to "terminating null byte" + +strcpy.3 + mike frysinger + see also: add stpncpy(3) + +strdup.3 + michael kerrisk + conforming to: strndup() is in posix.1-2008 + +wcpcpy.3 +wcpncpy.3 +wcsnlen.3 +wcsnrtombs.3 + michael kerrisk + conforming to: add posix.1-2008 + these functions are specified in the posix.1-2008 revision. + +proc.5 + eric w. biederman + document /proc/[pid]/ns/ + michael kerrisk + some edit's to eric biederman's /proc/[pid]/ns/ additions + +capabilities.7 + michael kerrisk + list setns(2) as an operation allowed by cap_sys_admin + + +==================== changes in man-pages-3.36 ==================== + +released: 2012-02-27, christchurch + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes and ideas that have been +incorporated in changes in this release: + +alain benedetti +carado +christoph hellwig +clemens ladisch +david prévot +elie de brauwer +guillem jover +jessica mckellar +josef bacik +junjiro okajima +lucian adrian grijincu +michael kerrisk +mike frysinger +pat pannuto +salvo tomaselli +simone piccardi +slaven rezic +starlight +stephan mueller +vijay rao +walter haidinger +walter harms +yang yang + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +sendmmsg.2 + michael kerrisk [stephan mueller] + new page for sendmmsg(2) + some pieces inspired by an initial attempt by stephan mueller. + + +newly documented interfaces in existing pages +--------------------------------------------- + +fallocate.2 + lucian adrian grijincu + document falloc_fl_punch_hole + falloc_fl_punch_hole was added in linux 2.6.38, + for punching holes in the allocated space in a file. + + +changes to individual pages +--------------------------- + +dup.2 + michael kerrisk + synopsis: add "#include " for o_* constants + +fallocate.2 + michael kerrisk + substantial restructuring of description + the addition of a second class of operation ("hole punching") + to the man page made it clear that some significant restructuring + is required. so i substantially reworked the page, including the + preexisting material on the default "file allocation" operation. + michael kerrisk [josef bacik] + add further details for falloc_fl_punch_hole + michael kerrisk + errors: add eperm error case for falloc_fl_punch_hole + +fork.2 + michael kerrisk + notes: describe clone() call equivalent to fork() + +fsync.2 + christoph hellwig + various improvements + - explain the situation with disk caches better + - remove the duplicate fdatasync() explanation in the notes + section + - remove an incorrect note about fsync() generally requiring two + writes + - remove an obsolete ext2 example note + - fsync() works on any file descriptor (doesn't need to be + writable); correct the ebadf error code explanation + michael kerrisk [guillem jover] + note that some systems require a writable file descriptor + an edited version of guillem jover's comments: + [while the file descriptor does not need to be writable on linux] + that's not a safe portable assumption to make on posix in general + as that behavior is not specified and as such is + implementation-specific. some unix systems do actually fail on + read-only file descriptors, for example [hp-ux and aix]. + +mount.2 + michael kerrisk [junjiro okajima] + removed erroneous statement about ms_rdonly and bind mounts + +open.2 + jessica mckellar + fix grammar in o_direct description + some small grammar fixes to the o_direct description. + +pipe.2 + michael kerrisk [salvo tomaselli] + synopsis: add "#include " for o_* constants + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=659750 + +sched_rr_get_interval.2 + clemens ladisch + update notes on modifying quantum + since linux 2.6.24, it is no longer possible to + modify the sched_rr quantum using setpriority(2). + (slight edits to clemens' patch by mtk.) + michael kerrisk + reordered various pieces of text + michael kerrisk + reworded text of esrch error + +send.2 + michael kerrisk + add mention of sendmmsg(2) + +sync.2 + michael kerrisk [simone piccardi] + prototype: fix return type of syncfs() + +vfork.2 + michael kerrisk [starlight] + clarify what is duplicated in the child + add some words to make it clear to the reader that vfork(), + like fork(), creates duplicates of process attributes + in the child. + michael kerrisk + note clone() flags equivalent to vfork() + michael kerrisk [starlight, mike frysinger] + add some notes on reasons why vfork() still exists + michael kerrisk [starlight] + clarify that calling *thread* is suspended during vfork() + michael kerrisk + conforming to: note that posix.1-2001 marked vfork() obsolete + +gets.3 + michael kerrisk + document c11 and glibc 2.16 changes affecting gets() + +pthread_sigmask.3 + michael kerrisk [pat pannuto] + fix comment that was inconsistent with code in example program + +sem_wait.3 + walter harms + example: remove extraneous line of output from shell session + +wcsnrtombs.3 +wcsrtombs.3 +wcstombs.3 + michael kerrisk + fix-ups for e9c23bc636426366d659809bc99cd84661e86464 + +core.5 + michael kerrisk [junjiro okajima] + document %e specifier for core_pattern + +passwd.5 + michael kerrisk [walter haidinger] + s/asterisk/asterisk (*)/ to improve clarity + michael kerrisk + correct note on passwd field value when shadowing is enabled + when password shadowing is enabled, the password field + contains an 'x' (not "*'). + +proc.5 + elie de brauwer + fix description of fourth field of /proc/loadavg + signed-off-by: elie de brauwer + +resolv.conf.5 + michael kerrisk [slaven rezic] + describe syntax used for comments + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=656994 + +feature_test_macros.7 + michael kerrisk + document _isoc11_source + +inotify.7 + michael kerrisk [yang yang] + note that 'cookie' field is set to zero when unused + +man.7 + michael kerrisk + various fixes for description of name section + as noted by reporter: + * the code sample given for the name section is incomplete because + the actual content sample is not given. + * additionally, the description assumes that the item described is + a command, which need not be the case. + * the command makewhatis is not present on my system; the + documented tool to create the whatis database is called mandb. + * the description on .sh name in man(7) should either copy the + relevant paragraph of lexgrog(1) or refer to it. + + +==================== changes in man-pages-3.37 ==================== + +released: 2012-03-06, christchurch + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes and ideas that have been +incorporated in changes in this release: + +denys vlasenko +mark r. bannister +michael kerrisk +oleg nesterov +tejun heo + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +getent.1 + mark r. bannister + new page to document 'getent' binary provided by glibc + + +changes to individual pages +--------------------------- + +bdflush.2 + michael kerrisk + note that bdflush() is deprecated, and does nothing + +nfsservctl.2 + michael kerrisk + note that this system call was removed in linux 3.1 + +ptrace.2 + denys vlasenko [oleg nesterov, tejun heo] + add extended description of various ptrace quirks + changes include: + + s/parent/tracer/g, s/child/tracee/g - ptrace interface now + is sufficiently cleaned up to not treat tracing process + as parent. + + deleted several outright false statements: + - pid 1 can be traced + - tracer is not shown as parent in ps output + - ptrace_attach is not "the same behavior as if tracee had done + a ptrace_traceme": ptrace_attach delivers a sigstop. + - sigstop _can_ be injected. + - removed mentions of sunos and solaris as irrelevant. + - added a few more known bugs. + + added a large block of text in description which doesn't focus + on mechanical description of each flag and operation, but rather + tries to describe a bigger picture. the targeted audience is + a person which is reasonably knowledgeable in unix but did not + spend years working with ptrace, and thus may be unaware of its + quirks. this text went through several iterations of review by + oleg nesterov and tejun heo. + this block of text intentionally uses as little markup as possible, + otherwise future modifications to it will be very hard to make. + michael kerrisk + global clean-up of page + * wording and formatting fixes to existing text and + denys vlasenko's new text. + * various technical amendments and improvements to + denys vlasenko's new text. + * added fixme for various problems with the current text. + michael kerrisk + integrated changes after further review from denys vlasenko + +syscalls.2 + michael kerrisk + note that nfsservctl(2) was removed in linux 3.1 + note that bdflush(2) is deprecated + +capabilities.7 + michael kerrisk + add cap_wake_alarm + michael kerrisk + add various operations under cap_sys_admin + add perf_event_open(2) to cap_sys_admin + add vm86_request_irq vm86(2) command to cap_sys_admin + update cap_net_admin with notes from include/linux/capability.h + add nfsservctl(2) to cap_sys_admin + michael kerrisk + add ioctl(fibmap) under cap_sys_rawio + michael kerrisk + add virtual terminal ioctl()s under cap_sys_tty_config + michael kerrisk + update cap_net_raw with notes from include/linux/capability.h + michael kerrisk + add f_setpipe_sz case to cap_sys_resource + add posix messages queues queues_max case to cap_sys_resource + update cap_sys_resource with notes from include/linux/capability.h + michael kerrisk + see also: add libcap(3) + +ld.so.8 + michael kerrisk + add --audit command-line option + + +==================== changes in man-pages-3.38 ==================== + +released: 2012-03-25, christchurch + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +akihiro motoki +artyom pervukhin +beňas petr +ben bacarisse +bjarni ingi gislason +david prévot +denis barbier +denys vlasenko +eric blake +iain fraser +justin t pryzby +kirill brilliantov +mark r bannister +matthew gregan +michael kerrisk +nix +peter schiffer +sergei zhirikov + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +get_nprocs_conf.3 + beňas petr + new page documenting get_nprocs_conf(3) and get_nprocs(3) + michael kerrisk + some additions and improvements + +malloc_get_state.3 + michael kerrisk + new page documenting malloc_get_state(3) and malloc_set_state(3) + +mallopt.3 + michael kerrisk + new man page for mallopt(3) + +mtrace.3 + michael kerrisk + complete rewrite of page, adding much more detail + +scandirat.3 + mark r bannister + new page for scandirat(3) (new in glibc 2.15) + + +newly documented interfaces in existing pages +--------------------------------------------- + +posix_memalign.3 + michael kerrisk + document aligned_alloc(3) + aligned_alloc() is new in c11. + michael kerrisk + document pvalloc(3) + +qsort.3 + mark r bannister + add documentation of qsort_r(3) + ben bacarisse + improvements to mark r bannister's qsort_r() patch + michael kerrisk + add versions section for qsort_r() + + +new and changed links +--------------------- + +aligned_alloc.3 + michael kerrisk + new link to posix_memalign.3 + +get_nprocs.3 + beňas petr + link to new get_nprocs_conf.3 page + +malloc_set_state.3 + michael kerrisk + link to new malloc_get_state.3 page + +pvalloc.3 + michael kerrisk + new link to posix_memalign.3 + + +global changes +-------------- + +various pages + michael kerrisk + global formatting fix: balance .nf/.fi pairs + +various pages + michael kerrisk + global fix: place sections in correct order + +various pages + michael kerrisk [justin t pryzby] + global fix: remove duplicated words + remove instances of duplicate words found using justin's + grep-fu: + + for f in man?/*.[1-9]; do + grep -he ' ([[:alpha:]]{2,} +)\1' "$f" | + grep -evw '(proc|hugetlbfs|xxx*|root|long) *\1'; + done | grep -e --colo ' ([[:alpha:]]{2,} +)\1' + +various pages + michael kerrisk + correct order of see also entries + + +changes to individual pages +--------------------------- + +futimesat.2 + michael kerrisk + prototype: correct header file and feature test macro requirements + +keyctl.2 + bjarni ingi gislason + strip trailing tabs from source line + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=664688 + +ptrace.2 + denys vlasenko + document ptrace_geteventmsg for ptrace_event_exec + denys vlasenko + various fixes to recent updates of this page + +symlinkat.2 + michael kerrisk [eric blake] + prototype: correct header file + +syscalls.2 + michael kerrisk + remove unimplemented system calls from main syscall list + the unimplemented system calls are in any case noted lower down + in the page. also: rearrange the text describing the unimplemented + system calls. + michael kerrisk + note a few system calls that were removed in linux 2.6 + michael kerrisk + add process_vm_readv(2) and process_vm_writev(2) + +unlinkat.2 + michael kerrisk [eric blake] + prototype: correct header file + michael kerrisk + prototype: add for at_* constants + +utimensat.2 + michael kerrisk + prototype: add for at_* constants + +copysign.3 + michael kerrisk [tolga dalman] + description: add a couple of examples + +malloc.3 + michael kerrisk + notes: add a short discussion of arenas + michael kerrisk + replace discussion of malloc_check_ with pointer to mallopt(3) + michael kerrisk + see also: add mtrace(3) + see also: add malloc_get_state(3) + +posix_memalign.3 + michael kerrisk + rename memalign() argument + rename "boundary" to "alignment" for consistency + with posix_memalign(). + michael kerrisk + improve discussion of feature test macros and header files for valloc(3) + +rtnetlink.3 + kirill brilliantov [sergei zhirikov] + fix example code, rta_len assignment should use rta_length() + see also http://bugs.debian.org/655088 + +scandir.3 + mark r bannister + see also: add scandirat(3) + +sigqueue.3 + nix + remove rt_sigqueueinfo from th line + rt_sigqueueinfo() now has its own manual page, so should not + be listed in the .th line of this page. + +tzset.3 + peter schiffer + correct description for julian 'n' date format + the julian 'n' date format counts starting from 0, not 1. + michael kerrisk + add some clarifying remarks to discussion of julian day formats + +packet.7 + michael kerrisk [iain fraser] + fix comment on 'sll_hatype' field + +tcp.7 + michael kerrisk [artyom pervukhin] + correct rfc for time_wait assassination hazards + + +==================== changes in man-pages-3.39 ==================== + +released: 2012-04-17, christchurch + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +abhijith das +alexander kruppa +andreas jaeger +armin rigo +cyrill gorcunov +denys vlasenko +eric blake +felix +jak +jeff mahoney +jesus otero +jonathan nieder +kevin o'gorman +mark r bannister +michael kerrisk +michael welsh duggan +mike frysinger +petr gajdos +regid ichira +reuben thomas +ricardo catalinas jiménez +simone piccardi +tetsuo handa + + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +malloc_trim.3 + michael kerrisk + new man page for malloc_trim(3) + +malloc_usable_size.3 + michael kerrisk + new man page for malloc_usable_size(3) + + +newly documented interfaces in existing pages +--------------------------------------------- + +prctl.2 + cyrill gorcunov + document pr_set_mm (new in linux 3.3) + michael kerrisk + various edits and improvements to cyrill's patch + + +changes to individual pages +--------------------------- + +epoll_create.2 + michael kerrisk + rework discussion of 'size' argument + michael kerrisk + add .ss for description of epoll_create1() + +epoll_wait.2 + michael kerrisk [armin rigo] + another thread can add to epoll instance while epoll_wait is blocked + see https://bugzilla.kernel.org/show_bug.cgi?id=43072 + michael kerrisk + clarify that epoll_pwait() blocks calling *thread* + a few wording improvements + +fchmodat.2 + michael kerrisk [mike frysinger] + note difference between glibc wrapper and underlying system call + the wrapper function has a 'flags' argument (which currently + serves no purpose), while the underlying system call does not. + +fcntl.2 + abhijith das + explain behaviour of f_getlease during lease break + michael kerrisk [eric blake] + change type of arg from "long" to "int" + various fcntl(2) commands require an integral 'arg'. + the man page said it must be "long" in all such cases. + however, for the cases covered by posix, there is an + explicit requirement that these arguments be "int". + update the man page to reflect. probably, all of the + other "long" cases (not specified in posix) should + be "int", and this patch makes them so. based on a + note fromeric blake, relating to f_dupfd_cloexec. + +gettimeofday.2 + michael kerrisk + reorganize content + the main change is to move the historical information about + the 'tz_dsttime' to notes. + michael kerrisk [felix] + note that compiler issues warnings if 'tv' is null + +mmap.2 + michael kerrisk [kevin o'gorman] + clarify that this system call should not be invoked directly + see https://bugzilla.kernel.org/show_bug.cgi?id=42892 + michael kerrisk + clarify notes discussion of mmap() versus mmap2() + +poll.2 + michael kerrisk [michael welsh duggan] + document negative value in 'fd' field + michael kerrisk + document semantics of passing zero in 'events' field + +ptrace.2 + denys vlasenko + various fixes + for some reason, the ptrace_traceme paragraph talks about some + general aspects of ptraced process behavior. it repeats the + "tracee stops on every signal" information even though that was + already explained just a few paragraphs before. then it describes + legacy sigtrap on execve(). + + this patch deletes the first part, and moves the second part up, + into the general ptrace description. it also adds + "if ptrace_o_traceexec option is not in effect" to the description + of the legacy sigtrap on execve(). + + the patch also amends the part which says "for requests other + than ptrace_kill, the tracee must be stopped." - ptrace_attach + also doesn't require that. + +sigaction.2 + michael kerrisk [andreas jaeger, ] + clarify that the use of si_sigio is for linux 2.2 only + see also http://sourceware.org/bugzilla/show_bug.cgi?id=6745 + +sigprocmask.2 + mike frysinger + errors: add efault + +times.2 + michael kerrisk [simone piccardi] + errors: add efault + +div.3 + michael kerrisk [reuben thomas] + conforming to: add c99 + +fread.3 + regid ichira + clarify further that return value is number of items, not bytes + see also http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=665780 + +getaddrinfo.3 + michael kerrisk [jak] + correct type of ai_addrlen field + +malloc.3 + michael kerrisk + see also: add malloc_usable_size(3) + see also: add malloc_trim(3) + +mallopt.3 + michael kerrisk + fix text describing m_perturb and free() + see also: add malloc_trim(3) + +memchr.3 + michael kerrisk [reuben thomas] + remove mention of terminating null in description of rawmemchr() + +perror.3 + michael kerrisk [jesus otero] + note that use of 'sys_errlist' is deprecated + +rcmd.3 + michael kerrisk + glibc eventually added a declaration of iruserok() in version 2.12 + +sysconf.3 + michael kerrisk [ricardo catalinas jiménez] + add mention of _sc_symloop_max + +nologin.5 + michael kerrisk [tetsuo handa] + nologin must not only exist, but *be readable* to be effective + +nsswitch.conf.5 + mark r bannister + significant rewrites and improvements + this patch applies to nsswitch.conf.5 in man-pages-3.36. + + my changes almost completely rewrite large sections of the + man page. they are needed to add clarity, correct grammar, + reduce confusion, and bring up-to-date with the latest glibc. + i have checked the man page against the nss source code in + glibc 2.14.90. + + historical notes are demoted to the footer. + + the rewrite makes the man page much clearer to + understand, more authoratitive, and easier to read. + michael kerrisk + light edits to mark bannister's changes + +capabilities.7 + michael kerrisk + add prctl(pr_set_mm) to cap_sys_resource + +epoll.7 + michael kerrisk + some minor clarifications at start of description + +netlink.7 + jeff mahoney [petr gajdos] + note cases where nonprivileged users can use netlink multicast groups + see also https://bugzilla.novell.com/show_bug.cgi?id=754611 + +unix.7 + michael kerrisk [tetsuo handa] + add a detail on autobind feature + +ld.so.8 + jonathan nieder [reuben thomas] + document effect of hwcaps on search path + wording by aurelien jarno from debian glibc's r4701 (2011-06-04). + + addresses http://bugs.debian.org/622385 + + +==================== changes in man-pages-3.40 ==================== + +released: 2012-04-27, christchurch + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +alexey toptygin +bernhard walle +brian f. g. bidulock +brian m. carlson +christopher yeoh +daniel j blueman +eric blake +eugen dedu +james hunt +john sullivan +jon grant +lepton +marcel holtmann +michael kerrisk +mike frysinger +petr baudis +simon paillard +stefan puiu +ulrich drepper +vadim mikhailov + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +process_vm_readv.2 + mike frysinger, christopher yeoh, michael kerrisk + new page for process_vm_readv(2) and process_vm_writev(2) + +mcheck.3 + michael kerrisk + new man page for mcheck(3) and related functions + also describes mcheck_check_all(3), mcheck_pedantic(3), + and mprobe(3) + + +newly documented interfaces in existing pages +--------------------------------------------- + +rcmd.3 + michael kerrisk + document "_af" variants of these functions + document rcmd_af(), rresvport_af(), iruserok_af(), ruserok_af(). + also some restructuring and other clarifications. + +rexec.3 + michael kerrisk + document rexec_af() + + +new and changed links +--------------------- + +iruserok_af.3 +rcmd_af.3 +rresvport_af.3 +ruserok_af.3 + michael kerrisk + new links to rcmd.3 + +rexec_af.3 + michael kerrisk + new link to rexec.3 + + +changes to individual pages +--------------------------- + +clock_getres.2 + michael kerrisk + clarify difference between clock_monotonic and clock_monotonic_raw + note interactions of these two clocks with discontinuous + adjustments to the system time and ntp/adjtime(2). + +fallocate.2 + michael kerrisk [john sullivan] + fix description of enosys and eopnotsup errors + as reported in https://bugzilla.redhat.com/show_bug.cgi?id=680214 + +fchmodat.2 + michael kerrisk [mike frysinger] + improve discussion of difference between wrapper and underlying syscall + +gettimeofday.2 + michael kerrisk + gettimeofday() is affected by discontinuous jumps in the system time + advise reader to use clock_gettime(2), if they need a + monotonically increasing time source. + michael kerrisk + see also: add clock_gettime(2) + +prctl.2 + michael kerrisk + add pr_task_perf_events_disable and pr_task_perf_events_enable + add some basic documentation of these operations, with a pointer to + tools/perf/design.txt for more information. + michael kerrisk [marcel holtmann] + amend details of pr_set_pdeathsig + +ptrace.2 + michael kerrisk [mike frysinger] + note sparc deviation with respect to get/set regs + sparc reverses the use of 'addr' and 'data' for + ptrace_getregs, ptrace_getfpregs, ptrace_setregs, + and ptrace_setfpregs. + +send.2 + stefan puiu + document eacces error case for udp + +sigaction.2 + michael kerrisk + remove mention of raise(3) for si_user + for a long time now, glibc's raise(3) didn't yield si_user + for the signal receiver, so remove mention of raise(3) + here. the user can deduce the details, if needed, by looking + at the recently updated raise(3) page. + +aio_cancel.3 + michael kerrisk [jon grant] + rewrite return value section to be clearer + +aio_init.3 + michael kerrisk [jon grant] + remove extraneous "posix" from name section + +btree.3 +dbopen.3 +hash.3 +mpool.3 +recno.3 + michael kerrisk [brian m. carlson] + note that glibc no longer provides these interfaces + glibc stopped providing these interfaces with v2.2. + nowadays, the user that finds these pages probably wants + the libdb api, so note this in the page. + + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=337581 + +fopen.3 + michael kerrisk + bugs: note limitation on number of flag characters parsed in 'mode' + michael kerrisk + note that 'c' and 'e' flags are ignored for fdopen() + determined from reading libio/iofdopen.c. + michael kerrisk + document ",ccs=string" feature of 'mode' for fopen()/freopen() + +getgrnam.3 + michael kerrisk [ulrich drepper] + fix discussion of _sc_getgr_r_size_max + the value is not meant to be a maximum (as was specified in + susv3) but an initial guess at the required size + (as specified in susv4). + +getpwnam.3 + michael kerrisk [ulrich drepper] + fix discussion of _sc_getpw_r_size_max + the value is not meant to be a maximum (as was specified in + susv3) but an initial guess at the required size + (as specified in susv4). + +malloc.3 +mallopt.3 +mtrace.3 + michael kerrisk + see also: add mcheck(3) + +memchr.3 + michael kerrisk + clarify description, omitting mention of "strings" and "characters" + the existing text slipped into talking about characters and + strings, which could mislead readers into thing that, for + example, searches for the byte '\0' are treated specially. + therefore, rewrite in terms of "bytes" and "memory areas". + + at the same time, make a few source file clean-ups. + +mkstemp.3 + michael kerrisk + add "mkstemps" and "mkostemps" to name line + +posix_openpt.3 + michael kerrisk [vadim mikhailov] + add some details on use of the slave pathname + an explicit pointer to ptsname(3) is useful, as is a note + of the fact that the slave device pathname exists only as + long as the master device is held open. + +raise.3 + michael kerrisk + add some notes on underlying system call that is used + +rcmd.3 + michael kerrisk + add some details of the rresvport() 'port' argument + +resolver.3 + petr baudis + note that many options are documented in resolv.conf(5) + +scandir.3 + michael kerrisk [daniel j blueman] + improve example source code: s/0/null/ in scandir() call + +strchr.3 + james hunt + explain behavior when searching for '\0' + +strerror.3 + eric blake [stefan puiu] + improve strerror_r() description + posix requires that perror() not modify the static storage + returned by strerror(). posix 2008 and c99 both require that + strerror() never return null (a strerror() that always + returns "" for all inputs is valid for c99, but not for posix). + + http://sourceware.org/bugzilla/show_bug.cgi?id=12204 + documents glibc's change to come into compliance with posix + regarding strerror_r() return value. the gnu strerror_r() use + of 'buf' was confusing - i ended up writing a test program that + proves that 'buf' is unused for valid 'errnum', but contains + truncated "unknown message" for out-of-range 'errnum'. + + see also http://austingroupbugs.net/view.php?id=382 + bernhard walle + correct description of error return for xsi strerror_r() + michael kerrisk [eric blake] + note how to use 'errno' to detect errors when calling strerror() + michael kerrisk [jon grant] + add an example of the kind of string returned by strerror() + +resolv.conf.5 + petr baudis + document "single-request" option + +inotify.7 + michael kerrisk + note buffer size that guarantees being able to read at least one event + james hunt + correct description of size of inotify_event structure + +iso_8859-1.7 + eugen dedu + add "-" for soft hyphen + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=156154 + +netdevice.7 + brian f. g. bidulock + document some sioc configuration ioctls + this patch adds common but missing sioc configuration ioctls to + the netdevice.7 manual pages that are not documented anywhere + else. siocsifpflags and siocgifpflags are linux-specific. flag + values come from linux 2.6.25 kernel headers for sockios. the + others are standard bsd ioctls that have always been implemented + by linux and were verified from inspecting netdevice.c kernel + code. + +socket.7 + michael kerrisk [alexey toptygin] + correct description of so_broadcast + +tcp.7 + lepton + correct description for tcp_maxseg on modern kernel + + +==================== changes in man-pages-3.41 ==================== + +released: 2012-05-11, christchurch + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +akihiro motoki +andries e. brouwer +angelo borsotti +bjarni ingi gislason +brian m. carlson +casper dik +david prévot +d. barbier +eric blake +hugh dickins +ivana varekova +jakub jelinek +jan kara +jason baron +jean-michel vourgère +jeff moyer +josh triplett +kasper dupont +kosaki motohiro +lauri kasanen +mel gorman +michael kerrisk +mike frysinger +nick piggin +paul pluzhnikov +petr baudis +ralph corderoy +rich felker +simone piccardi +simon paillard +stefan puiu +stephen hemminger +vincent lefevre +yuri kozlov + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +get_robust_list.2 + ivana varekova [michael kerrisk] + new page documenting get_robust_list(2) and set_robust_list(2) + +mallinfo.3 + michael kerrisk [kosaki motohiro, paul pluzhnikov] + new page for mallinfo(3) + +malloc_info.3 + michael kerrisk [jakub jelinek] + new page for malloc_info(3) + +malloc_stats.3 + michael kerrisk [kosaki motohiro] + new man page for malloc_stats(3) + + +newly documented interfaces in existing pages +--------------------------------------------- + +madvise.2 + jason baron + document madv_dontdump and madv_dodump + + +new and changed links +--------------------- + +set_robust_list.2 + michael kerrisk + new link to new get_robust_list.2 page + +list_entry.3 +list_head.3 +list_init.3 +list_insert_after.3 +list_insert_head.3 +list_remove.3 +tailq_entry.3 +tailq_head.3 +tailq_init.3 +tailq_insert_after.3 +tailq_insert_head.3 +tailq_insert_tail.3 +tailq_remove.3 +circleq_entry.3 +circleq_head.3 +circleq_init.3 +circleq_insert_after.3 +circleq_insert_before.3 +circleq_insert_head.3 +circleq_insert_tail.3 +circleq_remove.3 + michael kerrisk + new link to queue.3 + the queue(3) page documents these macros, so it makes sense to + have links for the names. + +des_failed.3 + michael kerrisk + new link to des_crypt.3 + the des_crypt(3) page documents this macro, so it makes sense + to have a link for the name. + +qsort_r.3 + michael kerrisk + new link to qsort.3 + overlooked to add this link in 3.38, when documentation of + qsort_r() was added to the qsort.3 page. + + +global changes +-------------- + +faccessat.2 +fchmodat.2 +fchownat.2 +fstatat.2 +futimesat.2 +inotify_init.2 +linkat.2 +mkdirat.2 +mknodat.2 +openat.2 +readlinkat.2 +renameat.2 +setns.2 +splice.2 +symlinkat.2 +sync.2 +tee.2 +unlinkat.2 +vmsplice.2 + michael kerrisk [lauri kasanen] + global fix: note glibc version that added library support + +confstr.3 +strcasecmp.3 +strcat.3 +strcmp.3 +strcpy.3 +strdup.3 +strftime.3 +strlen.3 +strnlen.3 +strpbrk.3 +strspn.3 +strtok.3 +strxfrm.3 + michael kerrisk [andries e. brouwer] + clarify that these functions operate on bytes, not (wide) characters + change 'character(s)' to 'byte(s)' to make clear that these + functions operate on bytes, not wide / utf8 characters. + (posix uses 'byte(s)' similarly, to make this point.) + +icmp.7 +ipv6.7 +packet.7 +raw.7 +rtnetlink.7 +unix.7 +x25.7 + michael kerrisk + remove names of constants from name line + some of the sockets/network protocol pages included names of + the corresponding address family constants in the name line, + but this wasn't done consistently across all pages, and probably + it adds little value in those pages that did do this. so, remove + these constants from those pages that have them in the name + section. + + +changes to individual pages +--------------------------- + +clock_getres.2 + michael kerrisk [josh triplett] + expand description of clock_realtime + make it clear that this clock may be discontinuous, and is + affected my incremental ntp and clock-adjtime(2) adjustments. + + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=540872 + +epoll_wait.2 + michael kerrisk + clarify that 'timeout' is a *minimum* interval + make it clear that 'timeout' is a minimum interval; the actual + interval will be rounded up to the system clock granularity, + and may overrun because of kernel scheduling delays. + +execve.2 + michael kerrisk + rewording to deemphasize libc5 details + +fork.2 + mike frysinger + errors: add enosys + can occur on, for example, non-mmu hardware. + +getcpu.2 + mike frysinger + add return value and errors sections + michael kerrisk + refer reader to notes for more info about 'tcache' + michael kerrisk + description: reword a sentence to be clearer + +io_cancel.2 +io_destroy.2 +io_getevents.2 +io_setup.2 +io_submit.2 + michael kerrisk + rewrite to focus on system call api + rewrite to focus on the system call interface, adding + some notes on the libaio wrapper differences. + see the following mail: + 2012-05-07 "aio manuals", linux-man@vger + http://thread.gmane.org/gmane.linux.man/1935/focus=2910 + + other minor rewrites. + +mount.2 + michael kerrisk + comment out an old linux libc detail + +open.2 + nick piggin [kosaki motohiro, jan kara, hugh dickins] + describe race of direct i/o and fork() + rework 04cd7f64, which didn't capture the details correctly. + see the april/may 2012 linux-man@ mail thread "[patch] + describe race of direct read and fork for unaligned buffers" + http://thread.gmane.org/gmane.linux.kernel.mm/77571 + +poll.2 + michael kerrisk + clarify that 'timeout' is a *minimum* interval + make it clear that 'timeout' is a minimum interval; the actual + interval will be rounded up to the system clock granularity, + and may overrun because of kernel scheduling delays. + michael kerrisk + clarify discussion of wrapper function emulation + clarify that glibc (as well as old libc) provides emulation + using select(2) on older kernels that don't have a poll() + system call. + michael kerrisk + make the meaning of a zero timeout explicit + clarify that timeout==0 causes an immediate return, even if + no file descriptors are ready. + +pread.2 + michael kerrisk [kasper dupont] + bugs: note o_append + pwrite() does the wrong thing + see https://bugzilla.kernel.org/show_bug.cgi?id=43178 + +recvmmsg.2 + michael kerrisk + clarify that 'timeout' is a *minimum* interval + make it clear that 'timeout' interval will be rounded up to the + system clock granularity, and may overrun because of kernel + scheduling delays. + +select.2 + michael kerrisk + clarify that 'timeout' is a *minimum* interval + make it clear that 'timeout' is a minimum interval; the actual + interval will be rounded up to the system clock granularity, + and may overrun because of kernel scheduling delays. + michael kerrisk + expand description of the self-pipe trick + michael kerrisk + add further details on pselect6() system call that underlies pselect() + +semop.2 + michael kerrisk + clarify that 'timeout' of semtimedop() is a *minimum* interval + make it clear that 'timeout' interval will be rounded up to the + system clock granularity, and may overrun because of kernel + scheduling delays. + +signal.2 + michael kerrisk + note that 'sig_t' requires _bsd_source + also remove some old linux libc details + +sigwaitinfo.2 + michael kerrisk + clarify that 'timeout' of sigtimedwait() is a *minimum* interval + make it clear that 'timeout' is a minimum interval; the actual + interval will be rounded up to the system clock granularity, + and may overrun because of kernel scheduling delays. + +stat.2 + bjarni ingi gislason + formatting fixes + from "groff -ww" (or "man --warnings=w ..."): + + warning: around line 442: table wider than line width + + gnu man uses line length of 78. + + use text blocks. two spaces between sentences or better: start + each sentence in a new line. + +syscalls.2 + bjarni ingi gislason + formatting fixes + from "groff -ww ..." (or "man --warnings=w ..."): + + warning: around line 157: table wider than line width + + have to use text blocks. move some text to its correct column. + split text to two columns to avoid hyphenation. + +sysinfo.2 + michael kerrisk + remove reference to obsolete libc5 + +syslog.2 + michael kerrisk + remove some details about obsolete linux libc + +aio_cancel.3 +aio_error.3 +aio_fsync.3 +aio_read.3 +aio_return.3 +aio_suspend.3 +aio_write.3 + michael kerrisk + errors: add/update enosys error + +aio_cancel.3 + michael kerrisk + clarify what happens when a request isn't successfully canceled + michael kerrisk + add pointers to aio(7) and sigevent(7) + +dbopen.3 + michael kerrisk + synopsis: add header file + upstreamed from debian, and consistent with freebsd + dbopen(3) man page. + +fmemopen.3 + michael kerrisk + note details of posix.1-2008 specification of 'b' in 'mode' + michael kerrisk [rich felker] + bugs: fmemopen() doesn't correctly set file position in some cases + if 'mode' is append, but 'size' does not cover a null byte + in 'buf', then fmemopen() incorrectly sets the initial file + position to -1, rather than the next byte after the end of + the buffer. + + see http://sourceware.org/bugzilla/show_bug.cgi?id=13151 + michael kerrisk + bugs: fmemopen() incorrectly handles size==0 case + if size is zero, fmemopen() fails, this is surprising behavior, + and not specified in posix.1-2008. + + see http://sourceware.org/bugzilla/show_bug.cgi?id=11216 + + reported-by; alex shinn + michael kerrisk + bugs: note silent abi change for fmemopen() in glibc 2.9 + michael kerrisk [rich felker] + bugs: append mode does not force writes to append + append mode correctly sets the initial offset but does + not force subsequent writes to append at end of stream. + + see http://sourceware.org/bugzilla/show_bug.cgi?id=13152 + michael kerrisk [eric blake] + bugs: note inconsistent treatment of 'b' in 'mode' + fopen() permits, for example, both "w+b" and "wb+", + but only the latter is meaningful to fmemopen(). + + see http://sourceware.org/bugzilla/show_bug.cgi?id=12836 + +fopencookie.3 + michael kerrisk [petr baudis] + correct description of return for user-supplied 'write' function + see http://sourceware.org/bugzilla/show_bug.cgi?id=2074 + +getaddrinfo.3 + jean-michel vourgère + note that ai_addrconfig is not affected by loopback addresses + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=660479 + +iconv.3 + michael kerrisk + upstream useful note from debian + warn the reader that the pointer arguments can't be + interpreted as c style strings. also, note possible + alignment requirements for the referenced bytes sequences, + michael kerrisk + write a better paragraph introducing iconv() and its arguments + +isgreater.3 + michael kerrisk [vincent lefevre] + clarify that the arguments to these macros must be real-floating + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=609033 + +lio_listio.3 + michael kerrisk + clarify that async notification occurs when *all* i/os complete + +makedev.3 + michael kerrisk + synopsis: correct return types of major() and minor() + see https://bugzilla.redhat.com/show_bug.cgi?id=754188 + + reported-by; zdenek kabelac + +malloc.3 + michael kerrisk + see also: add malloc_info(3) + +malloc_get_state.3 + michael kerrisk + fix wordos in function names in name line + +mallopt.3 + michael kerrisk + fix example program + the example code was a version that was not consistent with + the shell output shown on the page. + + reported-by: simon paillard + michael kerrisk + restore accidentally omitted line in shell session + michael kerrisk + see also: add malloc_stats(3) + +mmap64.3 + michael kerrisk + change target of link to mmap.2 (was mmap2.2) + upstreamed from red hat / fedora + +realpath.3 + michael kerrisk [casper dik] + remove note about solaris possibly returning a relative path + +syslog.3 + michael kerrisk [ralph corderoy] + document behavior when 'ident' argument to openlog() is null + see https://bugs.launchpad.net/ubuntu/+source/manpages/+bug/382096 + michael kerrisk + update conforming to for posix.1-2008 + posix.1-2008 doesn't change any details, but make + that more explicit. + +undocumented.3 + michael kerrisk + remove some functions that have been documented + +sd.4 + michael kerrisk + remove reference to nonexistent scsi(4) page + upstreamed from redhat / fedora + +sk98lin.4 + michael kerrisk [stephen hemminger] + note that this driver was removed in 2.6.28 + see https://bugs.launchpad.net/ubuntu/+source/manpages/+bug/528020 + +passwd.5 + michael kerrisk + upstream pieces from red hat/fedora + note mention of empty password field. + add description of "*np*" in password field. + michael kerrisk + various minor fixes and improvements + +proc.5 + michael kerrisk + note that cap_sys_admin processes can override file-max + upstreamed from red hat / fedora + michael kerrisk + document /proc/[pid]/cgroup + upstreamed from red hat / fedora + +resolv.conf.5 + michael kerrisk + take a debian improvement into upstream + +tzfile.5 + michael kerrisk + mention timezone directories in description + note that timezone files are usually in /usr/lib/zoneinfo + or /usr/share/zoneinfo. + michael kerrisk + drop synopsis + the synopsis doesn't correspond to a user-visible file. + michael kerrisk + see also: add pointer to glibc source file timezone/tzfile.h + michael kerrisk + see also: add tzset(3) and tzselect(8) + +ascii.7 + bjarni ingi gislason + indent for "troff" makes table too wide + fix following from "groff -t -ww ...": + + warning: around line 53: table wider than line width + + extra indent for "troff" makes the table look misplaced + (default "ps" output). + +cp1251.7 + bjarni ingi gislason + table too wide + from "nroff -ww -t ...": + + warning: around line 44: table wider than line width + + columns are made narrower (column gutter decreased). + +ipv6.7 + stefan puiu + add enodev error for bind() to link-local ipv6 address + +signal.7 + michael kerrisk [simone piccardi] + clarify that siglost is unused + michael kerrisk + comment out crufty bugs text on siglost + it must be a very long time since the statement there + about siglost was true. (the text seems to date back to + 1996.) + michael kerrisk + update architectures for tables of signal numbers + +utf-8.7 + brian m. carlson + two clarifications + this patch clarifies that 0xc0 and 0xc1 are not valid in any utf-8 + encoding[0], and it also references rfc 3629 instead of rfc 2279. + + [0] in order to have 0xc0, you'd have to have a two-byte encoding + with all the data bits zero in the first byte (and thus only six + bits of data), which would be an ascii character encoded in the + non-shortest form. similarly with 0xc1. + + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=538641 + +ldconfig.8 +nscd.8 + michael kerrisk + remove path prefix from name line + command names shown in name are normally just the basename, + not the full pathname of the command. + + +==================== changes in man-pages-3.42 ==================== + +released: 2012-08-14, konolfingen + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +aaron peschel +adrian dabrowski +akihiro motoki +alan curry +bjarni ingi gislason +christoph lameter +colin mccabe +daniel zingaro +david prévot +denys vlasenko +henry hu +herbert xu +jan engelhardt +jim hill +joonsoo kim +kalle olavi niemitalo +martin h +michael kerrisk +michael s. tsirkin +rasmus villemoes +sami kerola +sam varshavchik +shawn landden +simon paillard +tolga dalman +ulrich drepper +марк коренберг + +apologies if i missed anyone! + + +global changes +-------------- + +various pages + sami kerola + global fix: use ur macro where applicable + the syntax .ur http://example.com paired with .ue will create + links which one can interact, if the pager allows that. one + way to see the effect is ask the man(1) command to use browser + display, e.g.: + + man -h man7/uri.7 + + ("\:" is optional groff syntax to permit hyphenless line breaks.) + + +changes to individual pages +--------------------------- + +ldd.1 + michael kerrisk + add security note on untrusted executables + see also http://www.catonmat.net/blog/ldd-arbitrary-code-execution/ + and + http://tldp.org/howto/program-library-howto/shared-libraries.html + +clone.2 + michael kerrisk + rewrite discussion of sys_clone + +futex.2 + марк коренберг + consolidate error descriptions to errors + michael kerrisk + various wording fix-ups + michael kerrisk + fix description of einval error + the current text seems incorrect. replace with a more general + description. + +getdents.2 +select_tut.2 +atof.3 +atoi.3 +pthread_create.3 +pthread_sigmask.3 +rtime.3 +setbuf.3 +tsearch.3 +netlink.7 + michael kerrisk [jan engelhardt] + remove unneeded casts + +get_robust_list.2 +get_thread_area.2 +getcpu.2 +getdents.2 +gettid.2 +io_cancel.2 +io_destroy.2 +io_getevents.2 +io_setup.2 +io_submit.2 +ioprio_set.2 +kexec_load.2 +llseek.2 +modify_ldt.2 +mq_getsetattr.2 +pivot_root.2 +readdir.2 +rt_sigqueueinfo.2 +set_thread_area.2 +sgetmask.2 +spu_create.2 +spu_run.2 +subpage_prot.2 +sysctl.2 +tkill.2 + michael kerrisk + add note to synopsis that there is no glibc wrapper for system call + reduce the chance that the reader may be misled into thinking + that there is a wrapper function for this system call by noting + explicitly in the synopsis that there is no glibc wrapper and + pointing the reader to notes for further details. + +ioprio_set.2 + colin mccabe + clarify the multithreaded behavior of ioprio_set(2) + michael kerrisk [марк коренберг, kalle olavi niemitalo] + document who==0 for ioprio_who_process and ioprio_who_pgrp + for ioprio_who_process, who==0 means operate on the caller. + for ioprio_who_pgrp, who==0 means operate on the caller's + process group. + + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=652443 + +migrate_pages.2 + michael kerrisk [christoph lameter, joonsoo kim] + fix description of return value + +mount.2 + michael kerrisk + for ms_remount, source is ignored + +mprotect.2 + michael kerrisk [rasmus villemoes] + 'addr' argument is not const + as reported by rasmus: + + both my system's man-pages (3.22) and the latest online + (3.41) show: + + int mprotect(const void *addr, size_t len, int prot); + + as the prototype for mprotect(2). however, posix [1] and the + actual sys/mman.h (on all the systems i checked) do not have + the const qualifier on the first argument. + +msgctl.2 +semctl.2 +shmctl.2 +svipc.7 + michael kerrisk + don't mention that ipc_perm is defined in + there's no need to mention that the 'ipc_perm' structure + is defined in . that's an implementation detail, + and furthermore is itself included by the other + system v ipc header files. the current text might lead the + reader to conclude that they must include , which + is not the case (it is required neither on linux, nor by the + standards). + +msgctl.2 +msgget.2 +msgop.2 +semctl.2 +semget.2 +semop.2 +shmctl.2 +shmget.2 + michael kerrisk + notes: and aren't strictly needed + add text to notes to say that the and + header files aren't required by linux or the standards, but may + be needed for portability to old systems. + +ptrace.2 + denys vlasenko + explain wnohang behavior and eintr bug + i didn't like the "sigkill operates similarly, with exceptions" + phrase (if it's different, then it's not "similar", right?), + and now i got around to changing it. now it says simply: + "sigkill does not generate signal-delivery-stop and therefore + the tracer can't suppress it." + + replaced "why wnohang is not reliable" example with a more + realistic one (the one which actually inspired to add this + information to man page in the first place): we got + esrch - process is gone! - but waitpid(wnohang) can still + confusingly return 0 "no processes to wait for". + + replaced "this means that unneeded trailing arguments may + be omitted" part with a much better recommendation + to never do that and to supply zero arguments instead. + (the part about "undocumentedness" of gcc behavior was bogus, + btw - deleted). + + expanded bugs section with the explanation and an example + of visible strace behavior on the buggy syscalls which + exit with eintr on ptrace attach. i hope this will lead + to people submitting better bug reports to lkml about + such syscalls. + +seteuid.2 + michael kerrisk + note glibc version where setegid() implementation changed + in glibc 2.2/2.3, setegid() switched from setregid() to setresgid(). + +set_tid_address.2 + michael kerrisk + rename 'ctid' argument for consistency with clone(2) page + michael kerrisk + some rewordings and minor clarifications + +sigwaitinfo.2 + michael kerrisk [daniel zingaro] + some wording clarifications + mainly rewording things like "is delivered" to "becomes pending", + which is more accurate terminology. + +syscall.2 + michael kerrisk + add some more details to the description of syscall(2) + and add another example of using syscall() to the program example. + +syscalls.2 + michael kerrisk + add kcmp(2) + michael kerrisk + move discussion of set_zone_reclaim(2) out of main table + this system call was never visible to user space, so it makes + sense to move it out of the main table of system calls into + the notes below the table. + +getifaddrs.3 + michael kerrisk [adrian dabrowski] + note that ifa_addr and ifa_netmask can be null + +readdir.3 + michael kerrisk [jan engelhardt] + handle -1 error from pathconf() in example code snippet + improve the example demonstrating allocation of a buffer + for readdir_r() to handle -1 error return from pathconf(). + otherwise, naive readers may think that pathconf() return + value can be used without checking. + +realpath.3 + shawn landden + use past tense with ancient history (libc4, libc5) + +regex.3 + michael kerrisk + correct see also reference to glibc manual "regex" section + +rtime.3 + michael kerrisk [jan engelhardt] + fix broken pointer cast in example code + +sem_close.3 +sem_destroy.3 +sem_getvalue.3 +sem_init.3 +sem_open.3 +sem_post.3 +sem_unlink.3 +sem_wait.3 +sem_overview.7 + michael kerrisk + note that "cc -pthread" is required; "-lrt" no longer works + see https://bugs.launchpad.net/ubuntu/+source/manpages/+bug/874418 + +sigwait.3 + michael kerrisk + reword "is delivered" to "becomes pending" + +strcat.3 + michael kerrisk + add some text to emphasize the dangers of buffer overruns + michael kerrisk + notes: add discussion of strlcat() + +strcpy.3 + michael kerrisk + note that info is lost when strncpy() doesn't null terminate + michael kerrisk + add some text to emphasize possibility of buffer runs with strcpy() + michael kerrisk + notes: add a discussion of strlcpy() + inspired by https://lwn.net/articles/506530/ + michael kerrisk + fix description of the null-byte padding performed by strncpy() + +tsearch.3 + michael kerrisk + notes: remove redundant discussion of unorthodox use of term "postorder" + this point is already covered at greater length in the main + text of the page (see the piece "more commonly, ..."). + michael kerrisk + clarify use for first argument to the twalk() 'action' function + there's a number of details in posix that are omitted in + the current version of this page. + michael kerrisk + some wording fixes + +core.5 + michael kerrisk + note effect of madvise(2) madv_dontdump flag + +capabilities.7 + michael kerrisk + document cap_block_suspend + +glob.7 + bjarni ingi gislason + change 8 bit characters to 7 bit representation + fixes rendering errors for accented 'a' characters. + michael kerrisk [aaron peschel] + update bash(1) command used to obtain classical globbing behavior + the man page formerly noted the bash(1) v1 command to do this. + +iso_8859-1.7 + bjarni ingi gislason + explanation of soft hyphen and the code for it + :89: warning: can't find special character `shc' + + this is the only "iso_8859-*.7" file that has this (now) + undefined character. the code in column four in "iso_8859-1.7" is + "0x2d" ("hyphen, minus sign" or "hyphen-minus") instead of "0xad". + see debian bug 156154 (or package "manpages"). + + there should be an explanation for this graphic character and the + code should be 0xad in iso_8859-1.7 (as in all others), even + though "[gn]roff" does not display a "hyphen" in that position of + the table. + + the line with "soft hyphen" gets a footnote and a short + explanation. + +mdoc.7 + bjarni ingi gislason + fixing a warning and a table + fis warning from "groff -ww ..." (or "man --warnings=w ..."): + + :294: warning: + tab character in unquoted macro argument + + in one table the distance between columns is too small in the + "ps" output. (bug in the groff "doc.tmac" macro?) + +mdoc.samples.7 + bjarni ingi gislason + fix warnings from [ng]roff, corrections + from "man -ww ..." (groff -ww ...): + + :541: warning: + tab character in unquoted macro argument + [+3 similar warnings] + :813: warning: macro `pu' not defined + usage: .rv -std in sections 2 and 3 only (#1669) + mdoc warning: a .bl directive has no matching .el (#1821) + + string "pu" defined as a row of punctuation characters. + ".bl" and ".el" fixed. + some arguments, that start with a period or are the name of a + macro, protected with "\&". + variable name for macro ".rv" corrected. + +netdevice.7 + bjarni ingi gislason + line in table too long + fix warning from "man ..." ("nroff -ww ..."): + + nroff: netdevice.7: warning: around line 98: + table wider than line width + + fix: no right adjustment in text blocks in tables. + + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=673873 + +netlink.7 + bjarni ingi gislason + line in table is too long + fix warning from "man ..." ("nroff -ww ..."): + + nroff: netlink.7: warning: around line 195: + table wider than line width + + horizontal line incorporated into table. + no right adjustment of text blocks in tables. + + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=673875 + simon paillard [herbert xu] + change description of "*_pid" fields to "port id" + as reported by herbert xu, these should not be considered as pids. + + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=383296 + +rtnetlink.7 + bjarni ingi gislason + line in table too long + fix warning from "man ..." ("nroff -ww ..."): + + nroff: rtnetlink.7: warning: around line 415: + table wider than line width + + column gutter reduced to fit line length. + right adjustment in text blocks removed in tables. + some header made centered in tables. + one table put on same page. + + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=674051 + +socket.7 + martin h + document so_mark socket option + commit 4a19ec5800fc3bb64e2d87c4d9fdd9e636086fe0 in jan 2008 added + the new so_mark socket option. + + this patch is based on text from the commit message. + + see https://bugzilla.kernel.org/show_bug.cgi?id=16461. + +svipc.7 + michael kerrisk + synopsis: remove include of and + including and isn't needed on linux + and isn't really relevant for the explanation on this page. + + +==================== changes in man-pages-3.43 ==================== + +released: 2012-10-05, munich + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +adrian bunk +anatoli klassen +andreas schwab +bjarni ingi gislason +david prévot +eric dumazet +florian weimer +frédéric brière +fredrik arnerup +guillem jover +jan engelhardt +michael kerrisk +simon josefsson +stephane fillod +trevor woerner +yuri kozlov + +apologies if i missed anyone! + + +newly documented interfaces in existing pages +--------------------------------------------- + +getenv.3 + michael kerrisk [florian weimer, andreas schwab] + document secure_getenv(3) + + +new and changed links +--------------------- + +phys.2 + michael kerrisk + new link to unimplemented.2 + +secure_getenv.3 + michael kerrisk + new link to getenv.3 + + +global changes +-------------- + +various pages + michael kerrisk + global fix: s/-/\\-/ when real hyphen is required (e.g., in code) + +various pages + david prévot [michael kerrisk] + global fix: various consistency fixes for see also + +various pages + michael kerrisk + global fix: use "linux kernel source" consistently + rather than "kernel source". + +various pages + michael kerrisk + global fix: disable justification and hyphenation in see also + for a better visual result, disable justification and hyphenation + in see also where page names are long. + +syscalls.2 +uname.2 +boot.7 + michael kerrisk + global fix: s/os/operating system/ + + +changes to individual pages +--------------------------- + +epoll_wait.2 + michael kerrisk [fredrik arnerup] + describe timeout limitation in kernels < 2.6.37 + as reported by fredrik (and as far as i can tell the problem + went back to 2.6.0): + + the timeout argument has an upper limit. any values above that + limit are treated the same as -1, i.e. to wait indefinitely. + the limit is given by: + + #define ep_max_mstimeo min(1000ull * max_schedule_timeout / hz, \ + (long_max - 999ull) / hz) + + that is, the limit depends on the size of a long and the timer + frequency. assuming the long is never smaller than 32 bits + and hz never larger than 1000, the worst case is 35 minutes. + i think this should be mentioned under "bugs". + + although this is likely to be fixed in the future + (http://lkml.org/lkml/2010/8/8/144), the problem exists in + at least 2.6.14 - 2.6.35. i don't know if select(2) and poll(2) + are affected. + + https://bugzilla.kernel.org/show_bug.cgi?id=20762 + michael kerrisk + add pointer to select(2) for discussion of close in another thread + +getitimer.2 + michael kerrisk [trevor woerner] + note linux's odd handling of the new_value==null case + michael kerrisk [trevor woerner] + fix types used to declare fields in timeval struct + +keyctl.2 + david prévot + reorder see also, without .br + +poll.2 + michael kerrisk + add pointer to select(2) for discussion of close in another thread + +select.2 + michael kerrisk [stephane fillod] + note behavior if monitored file descriptor is closed in another thread + executive summary: a sane application can't rely on any + particular behavior if another thread closes a file descriptor + being monitored by select(). + + see https://bugzilla.kernel.org/show_bug.cgi?id=40852 + michael kerrisk + clarify equivalent pselect() code in terms of threads + s/sigprogmask/pthread_sigmask/ + +semop.2 + michael kerrisk + recast discussion of blocking behavior in terms of threads + semop() blocks the calling thread, not the process. + michael kerrisk + see also: add clone(2) + give reader a clue about clone_sysvsem. + +shutdown.2 + michael kerrisk [eric dumazet] + document einval error (and associated bug) + eric dumazet noted that einval was not documented. some further + digging shows that it's also not diagnosed consistently. + see https://bugzilla.kernel.org/show_bug.cgi?id=47111. + +sigaction.2 + michael kerrisk + tweak sa_resethand description + +timer_settime.2 + michael kerrisk + small rewording around discussion of pointer arguments + +wait4.2 + adrian bunk + note that these functions are nonstandard and recommend alternatives + some edits to adrian's patch by mtk. + michael kerrisk + conforming to: note sus details for wait3() + +gnu_get_libc_version.3 + michael kerrisk + remove unneeded "#define _gnu_source" from synopsis + +pthread_kill.3 +pthread_sigqueue.3 + michael kerrisk + remove wording "another" + writing "another thread" in these pages implies that these + functions can't be used to send a signal to the calling thread + itself, which is of course untrue. + +sigvec.3 + michael kerrisk + add "int" arg to sv_handler definition in sigvec structure + michael kerrisk + fix small error in discussion of blocking of signals + the signal that causes the handler to be invoked is blocked, + but saying "by default" implies that this can be changed via + the api. it cannot. (one needs sigaction(2) for that.) + +syslog.3 + simon josefsson + remove (apparently bogus) text claiming log_auth is deprecated + log_auth is in posix, and widely available. there + seems to be no basis to the claim it is deprecated. + + quoting simon: + i cannot find any other source that claim log_auth is + deprecated in any way. log_auth is distinct from + log_authpriv. the gnu c library manual only documents + log_auth. the header files contains both without any + comment. common systems like debian appear to refer to + both auth and authpriv facilities in syslog configurations. + popular daemons appear to use both facilities. + both facilities are discussed in several rfcs. + + see https://bugzilla.kernel.org/show_bug.cgi?id=46091 + +ttyname.3 + michael kerrisk + see also: add ctermid(3) + +proc.5 + michael kerrisk + clarify header file related to 'flags' field of /proc/pid/stat + michael kerrisk [frédéric brière] + update description of 'starttime' field of /proc/pid/stat + the unit of measurement changed from jiffies to clock ticks in + linux 2.6. + + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=675891 + michael kerrisk + document /proc/sys/kernel/kptr_restrict + michael kerrisk [kees cook] + document /proc/sys/fs/protected_symlinks + based on text in documentation/sysctl/fs.txt by kees cook + michael kerrisk [kees cook] + document /proc/sys/fs/protected_hardlinks + based on text in documentation/sysctl/fs.txt by kees cook + +capabilities.7 + michael kerrisk + document interaction of cap_syslog and /proc/sys/kernel/kptr_restrict + +ip.7 + michael kerrisk + see also: add ipv6(7) + see also: add icmp(7) + +man-pages.7 + michael kerrisk + add some advice about disabling hyphenation in see also + +ld.so.8 + michael kerrisk + describe interpretation of slashes in dependency strings + michael kerrisk + repeat note that ld_library_path is ignored in privileged programs + this point is already noted when discussing search order for + libraries, but it's worth repeating under the specific discussion + of ld_library_path further down the page. + michael kerrisk + add some details for ld_preload + note that ld_preload list separator can be space or colon + + +==================== changes in man-pages-3.44 ==================== + +released: 2012-11-07, barcelona + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +bert hubert +david prévot +james youngman +kees cook +lars wirzenius +lucas de marchi +michael kerrisk +rusty russell +simon paillard +thomas habets + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +delete_module.2 + michael kerrisk + rewrite to linux 2.6+ reality + michael kerrisk + change license and copyright + there is now nothing left of the original fsf-copyrighted + page. so, change the copyright and license. + michael kerrisk [lucas de marchi, rusty russell] + substantial reorganization after comments from rusty russell + rusty notes that o_nonblock is almost always used in + practice. therefore, it would be better to reorganize + the page to consider that "the default". + +init_module.2 + michael kerrisk + rewrite to linux 2.6+ reality + michael kerrisk + change copyright and license + little of the original page now remains. change + copyright and license + michael kerrisk [rusty russell] + changes after review comments from rusty russell + kees cook + add various pieces describing linux 2.6+ behavior + pieces take from, or inspired by, a patch sent by kees. + +getauxval.3 + michael kerrisk + document getauxval() function added in glibc 2.16 + + +global changes +-------------- + +various pages + michael kerrisk + global fix: use consistent capitalization in name section + the line(s) in the name section should only use capitals + where english usage dictates that. otherwise, use + lowercase throughout. + +various pages + michael kerrisk + global fix: "userspace" ==> "user space" or "user-space" + existing pages variously use "userspace or "user space". + but, "userspace" is not quite an english word. + so change "userspace" to "user space" or, when used + attributively, "user-space". + + +changes to individual pages +--------------------------- + +clock_getres.2 +clock_nanosleep.2 + michael kerrisk + linking with -lrt is no longer needed from glibc 2.17 onward + +create_module.2 + michael kerrisk + note that this system call is present only in kernels before 2.6 + michael kerrisk + note that enosys probably indicates kernel 2.6+ + +execve.2 + michael kerrisk + document treatment of pr_set_pdeathsig on execve() + michael kerrisk + document treatment of secbit_keep_caps securebits flag on execve() + +fork.2 + michael kerrisk + note treatment of default timer slack value on fork() + +getdomainname.2 + simon paillard [lars wirzenius] + point out that these calls relate to nis, not dns + see http://bugs.debian.org/295635 + +get_kernel_syms.2 + michael kerrisk + note that this system call is present only in kernels before 2.6 + +ipc.2 + michael kerrisk + update note on architectures that don't have ipc() + replace mention of ia64 with x86-64 and arm. + +link.2 + michael kerrisk + add eperm error triggered by /proc/sys/fs/protected_hardlink + +prctl.2 + michael kerrisk + mention documentation/prctl/no_new_privs.txt for pr_set_no_new_privs + kees cook + update seccomp sections for mode 2 (bpf) + this adds a short summary of the arguments used + for "mode 2" (bpf) seccomp. + michael kerrisk + small improvements to pr_set_seccomp discussion + note type of 'arg3' for seccomp_mode_filter. + add pointer to documentation/prctl/seccomp_filter.txt. + michael kerrisk + note 'seccomp' semantics with respect to fork(), execve(), and prctl() + michael kerrisk + document pr_set_timerslack and pr_get_timerslack + michael kerrisk + reword pr_set_name and pr_get_name in terms of threads + plus tfix + kees cook + document pr_set_no_new_privs, pr_get_no_new_privs + this adds a short description of the no_new_privs bit, + as described in documentation/prctl/no_new_privs.txt. + +ptrace.2 + michael kerrisk + clarify that some operations are not present on all architectures + ptrace_getregs, ptrace_setgrefs, ptrace_getfpregs, + and ptrace_getspregs are not present on all architectures. + ptrace_sysemu and ptrace_sysemu_singlestep are present only + on x86. + + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=122383 + +query_module.2 + michael kerrisk + add a few words clarifying reference to /sys/module + michael kerrisk + note that this system call is present only in kernels before 2.6 + michael kerrisk + note that enosys probably indicates kernel 2.6+ + michael kerrisk + see also: add modinfo(8) and lsinfo(8) + michael kerrisk + move some information in notes to versions + +socketcall.2 + michael kerrisk + update note on architectures that don't have socketcall() + replace mention of ia64 with x86-64 and arm. + +times.2 + thomas habets + recommend clock_gettime(2) as alternative to times(2) + +clock_getcpuclockid.3 + michael kerrisk + linking with -lrt is no longer needed from glibc 2.17 onward + +fts.3 + simon paillard [james youngman] + improve description of physical vs. logical tree walking + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=633505 + +getenv.3 + michael kerrisk + see also: add getauxval(3) + +proc.5 + michael kerrisk + document /proc/meminfo + info mostly taken from documentation/filesystems/proc.txt + and documentation/vm/hugetlbpage.txt. + michael kerrisk + default for /proc/sys/fs/protected_{hardlinks,symlinks} is now 0 + the default setting of 1 in/proc/sys/fs/protected_hardlinks + and /proc/sys/fs/protected_symlinks caused one too many + breakages for linus's taste, so commit 561ec64ae67e changed + the default for both files to 0. + note system call error yielded by /proc/sys/fs/protected_symlinks + note that violating 'protected_symlinks' restrictions + causes system calls to fail with the error eacces. + michael kerrisk + since linux 2.6.27, /proc/sys/kernel/modprobe depends on config_modules + +ipv6.7 + bert hubert + document ipv6_recvpktinfo + +man-pages.7 + michael kerrisk + note rules for capitalization in name section + +time.7 + michael kerrisk + add a subsection on timer slack + +ld.so.8 + michael kerrisk + see also: add getauxval(3) + + +==================== changes in man-pages-3.45 ==================== + +released: 2012-12-21, christchurch + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +andi kleen +cyril hrubis +david prévot +elie de brauwer +eric dumazet +felipe pena +florian weimer +gao feng +jan glauber +jim paris +jon grant +julien cristau +michael kerrisk +mike frysinger +rens van der heijden +simon paillard +thierry vignaud +trevor woerner +yoshifuji hideaki + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +s390_runtime_instr.2 + jan glauber + new page for s390-specific s390_runtime_instr(2) + +if_nameindex.3 + yoshifuji hideaki + document if_nameindex(3) and if_freenameindex(3) + michael kerrisk + edits, improvements and corrections to hideaki's page + michael kerrisk + add an example program + +if_nametoindex.3 + yoshifuji hideaki + new page documenting if_nametoindex(3) and if_indextoname(3) + + +new and changed links +--------------------- + +if_freenameindex.3 + michael kerrisk + new link to if_nameindex.3 + +if_indextoname.3 + michael kerrisk + new link to if_nametoindex.3 + + +global changes +-------------- + +sysconf.3 +cciss.4 + michael kerrisk + global fix: s/runtime/run time/ + + +changes to individual pages +--------------------------- + +clone.2 + michael kerrisk + since 2.6.30, clone_newipc also supports posix message queues + +delete_module.2 + michael kerrisk + small rewording of description of effect of o_trunc + +getrlimit.2 + michael kerrisk [trevor woerner] + document linux's nonstandard treatment or rlimit_cpu soft limit + upon encountering the rlimit_cpu soft limit when a sigxcpu handler + has been installed, linux invokes the signal handler *and* raises + the soft limit by one second. this behavior repeats until the + limit is encountered. no other implementation that i tested + (solaris 10, freebsd 9.0, openbsd 5.0) does this, and it seems + unlikely to be posix-conformant. the (linux-specific) + rlimit_rttime soft limit exhibits similar behavior. + michael kerrisk + point reader at discussion of /proc/[pid]/limits in proc(5) + +io_getevents.2 + michael kerrisk + io_getevents() may cause segfault when called with invalid ctx_id + for reference see: http://marc.info/?l=linux-aio&m=130089887002435&w=2 + +recv.2 + michael kerrisk [eric dumazet] + unix domain sockets support msg_trunc since 3.4 + +sendmmsg.2 + elie de brauwer + add example program for sendmmsg() + +stat.2 + simon paillard + clarify description of eoverflow error + the eoverflow error is not only for st_size, but also + inode and block size fields. see glibc source file + sysdeps/unix/sysv/linux/xstatconv.c and kernel source + file fs/stat.c. also, fix bit/byte confusion + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=604928 + +syscalls.2 + michael kerrisk + update various references to "i386" to "x86" + michael kerrisk + add s390_runtime_instr(2) + +sysctl.2 + michael kerrisk + mention config_sysctl_syscall + michael kerrisk + calls to sysctl() log warnings to the kernel log since 2.6.24 + +syslog.2 + michael kerrisk + substantially reorganize discussion of commands + make the layout of the discussion of the commands + more readable. + michael kerrisk + add kernel symbolic 'type' names + michael kerrisk + clarify syslog_action_size_unread semantics + syslog_action_size_unread returns the number of bytes + available for reading via syslog_action_read. + michael kerrisk + clarify where syslog_action_read_all places data it reads + michael kerrisk + clarify semantics of syslog_action_clear + the syslog_action_clear command (5) does not really clear + the ring buffer; rather it affects the semantics of what + is returned by commands 3 (syslog_action_read_all) and + 4 (syslog_action_read_clear). + michael kerrisk + clarify discussion of privileges for commands 3 and 10 + michael kerrisk + add mention of config_log_buf_shift + +wait.2 + michael kerrisk + bugs: document odd waitid() behavior when 'infop' is null + +getifaddrs.3 + michael kerrisk [julien cristau] + update description of ifa_data to linux 2.6+ reality + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=526778 + +memcmp.3 + michael kerrisk [jon grant] + enhance return value text and remove redundant text from description + note that sign of result equals sign of difference between + first two bytes that differ (treated as "unsigned char")." + +mkstemp.3 + michael kerrisk [florian weimer] + deemphasize discussion of mode 066 in glibc 2.0.6 + glibc 2.0.6 is now so ld that the discussion of details + of that version can be deemphasized placing just under + notes. + + see https://bugzilla.kernel.org/show_bug.cgi?id=51811 + +strcmp.3 + michael kerrisk [jon grant] + enhance return value text and remove redundant text from description + note that sign of result equals sign of difference between + first two bytes that differ (treated as "unsigned char")." + +ttyname.3 + michael kerrisk + fix confused text in errors + the existing text suggested that the errors applied + only for ttyname_r(). however, 2 of the 3 errors + can occur for ttyname(). + +undocumented.3 + michael kerrisk + remove some now documented functions + +proc.5 + michael kerrisk [jim paris] + correct description of swapfree in /proc/meminfo + michael kerrisk + note change of /proc/[pid]/limits file permissions in 2.6.36 + +resolv.conf.5 + simon paillard + document ipv6 format for nameserver + see: http://bugs.debian.org/610036 + +capabilities.7 + michael kerrisk [rens van der heijden] + correct url for posix.1e draft + +ipv6.7 + gao feng + add description of getsockopt() for ipv6_mtu + in ipv4,ip_mtu is only supported by getsockopt. + in ipv6, we can use ipv6_mtu to set socket's mtu, + but the return value of getsockopt() is the path mtu. + +rtnetlink.7 + michael kerrisk [julien cristau] + update description of ifla_stats to linux 2.6+ reality + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=526778 + +socket.7 + michael kerrisk [yoshifuji hideaki] + document 'sockaddr' and 'sockaddr_storage' types + andi kleen + explain effect of so_sndtimeo for connect() + when so_sndtimeo is set before connect(), then connect() + may return ewouldblock when the timeout fires. + + +==================== changes in man-pages-3.46 ==================== + +released: 2013-01-27, canberra + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +andrew perepechko +cédric boutillier +cyrill gorcunov +daan spitz +david prévot +elie de brauwer +garrett cooper +james noble +justin lebar +kees cook +lucas de marchi +mark hills +maxin b. john +michael kerrisk +michal gorny +peter budny +peter lekeynstein +rusty russell +samuel thibault +sam varshavchik +shawn landden +simon paillard +starlight +theodore ts'o +wolfgang rohdewald +zsbán ambrus + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +kcmp.2 + cyrill gorcunov, michael kerrisk + new page for kcmp(2) + + +newly documented interfaces in existing pages +--------------------------------------------- + +init_module.2 + michael kerrisk [kees cook, rusty russell, lucas de marchi] + document finit_module(2) + rusty russell [lucas de marchi, kees cook] + document finit_module() 'flags' argument + document module_init_ignore_modversions and + module_init_ignore_vermagic. (some edits by mtk.) + + +new and changed links +--------------------- + +finit_module.2 + michael kerrisk + new link to init_module.2 + +__after_morecore_hook.3 +__free_hook.3 +__malloc_initialize_hook.3 +__memalign_hook.3 +__realloc_hook.3 + michael kerrisk + new link to malloc_hook.3 + + +global changes +-------------- + +various pages + michael kerrisk + global fix: s/tty/terminal/ + + +changes to individual pages +--------------------------- + +clone.2 + michael kerrisk + add kernel versions for various clone_* constants + michael kerrisk + clone_newipc governs mechanisms that don't have filesystem pathnames + michael kerrisk + clone_newipc doesn't mount the posix mq file system + michael kerrisk + add an example program (clone_newuts) + michael kerrisk + some reworking of clone_newipc text + no substantial content changes. + michael kerrisk + see also: add kcmp(2) + see also: add setns(2) + +fallocate.2 + michael kerrisk + falloc_fl_* flags are defined in glibc only since 2.18 + +getxattr.2 +removexattr.2 +setxattr.2 + michael kerrisk [andrew perepechko, ] + note that enoattr is a synonym for enodata + various people have pointed out that strace(1) shows enodata + for the case where the named attribute does not exist, or + the process has no access to this attribute. enodata + and enoattr are in fact defined as synonyms. point this out + in the man page, so that people understand the strace(1) info. + + see https://bugzilla.kernel.org/show_bug.cgi?id=51871 + +getxattr.2 +listxattr.2 +removexattr.2 +setxattr.2 + michael kerrisk + put errors under errors section + the errno values on these pages were listed in a nonstandard + way under the return value section. put them in errors sections. + +init_module.2 + michael kerrisk [rusty russell] + errors: add errors for module signatures (ebadmsg, enokey) + +link.2 +mkdir.2 +mknod.2 +open.2 +rename.2 +symlink.2 +write.2 +mkfifo.3 + mark hills + document edquot error + the return error edquot is not documented in open(2), write(2), + symlink(2) etc. + + whether inodes or disk blocks are required for each function + is something i based on received wisdom and bsd documentation, + rather than tracing the code to the kernel. for symlink(2) + this certainly depends on the file system type. + +listxattr.2 + michael kerrisk [theodore ts'o] + fix return value description + on success, 0 may be returned, so change wording from + "positive number" to "nonnegative number". + +outb.2 + michael kerrisk + add synopsis + +prctl.2 + kees cook + document pr_set_ptracer + document the yama lsm's prctl handler that allows processes to + declare ptrace restriction exception relationships via + pr_set_ptracer. + michael kerrisk + make it explicit that pr_set_ptracer replaces previous setting + the attribute is a scalar, not a list. + shawn landden + document einval error for pr_set_ptracer + michael kerrisk + document pr_get_tid_address + +ptrace.2 + michael kerrisk + document ptrace_o_exitkill + michael kerrisk + place ptrace_setoptions list in alphabetical order + +query_module.2 + michael kerrisk + must be called using syscall(2) + yes, the call is way obsolete, but add this info + for completeness. + +recvmmsg.2 + elie de brauwer + add/correct kernel version info for recvmmsg() and msg_waitfornone + this patch isolates the since/version related fixes as requested. + this change introduces the following delta: + * the page states it was added in 2.6.32 but it is only added + 2.6.33 (ref: http://kernelnewbies.org/linux_2_6_33) + * the msg_waitforone flag was in turn only added in 2.6.34 + (ref: http://kernelnewbies.org/linux_2_6_34) + elie de brauwer + add an example program + +setns.2 + michael kerrisk + add example program + +sigaction.2 + michael kerrisk [zsbán ambrus] + note feature test macro requirements for 'siginfo_t' + see https://bugzilla.kernel.org/show_bug.cgi?id=52931 + +syscalls.2 + michael kerrisk + add kern_features(2) + michael kerrisk + add utrap_install(2) + sparc-specific, present since ancient times + michael kerrisk + add finit_module(2) + +sysctl.2 + michael kerrisk [garrett cooper] + errors: eacces as a synonym for eprm + see https://bugzilla.kernel.org/show_bug.cgi?id=46731 + and http://thread.gmane.org/gmane.linux.ltp/11413/focus=957635 + from: garrett cooper gmail.com> + subject: re: [ltp] [patch] sysctl03: sysctl returns eacces after 2.6.33-rc1 + newsgroups: gmane.linux.kernel, gmane.linux.ltp + date: 2010-03-04 18:35:33 gmt + +unshare.2 + michael kerrisk + update notes on unimplemented flags + michael kerrisk + fix text problems in description of clone_fs + michael kerrisk + see also: add kcmp(2) + see also: add setns(2) + michael kerrisk + reorder clone_newuts entry in list + +difftime.3 + michael kerrisk [michal gorny] + remove crufty text about 'time_t' on "other systems" + back in 2006, some text came in via debian patches that seems + crufty. remove it. + + see https://bugzilla.kernel.org/show_bug.cgi?id=46731 + +getaddrinfo.3 +getnameinfo.3 + michael kerrisk [peter budny] + fix some confused references to function names + see https://bugzilla.kernel.org/show_bug.cgi?id=52741 + +getspnam.3 + michael kerrisk [wolfgang rohdewald] + errors: add eacces + see https://bugzilla.kernel.org/show_bug.cgi?id=52681 + +__setfpucw.3 + michael kerrisk + add proper page cross refs for alternate functions + +core.5 +proc.5 + kees cook + clarify suid_dumpable versus core_pattern + in linux 3.6, additional requirements were placed on core_pattern + when suid_dumpable is set to 2. document this and include commit + references. + justin lebar + statm's "shared" field refers to pages backed by files + i noticed that statm's "shared" field doesn't match the sum of + all the "shared" entries in smaps [1]. + + the kernel docs explain that statm's "shared" field is "number of + pages that are shared (i.e. backed by a file)" [2]. smaps appears + to call a page shared if it's mapped by at least two processes, + which explains this discrepancy. + + i'm not a kernel hacker, but it appears to me they do mean "i.e." + and not "e.g." in the statm description: in + fs/proc/task_mmu.c::task_statm, i see + + *shared = get_mm_counter(mm, mm_filepages); + + here's a patch which updates the man page to match the (hopefully + correct) kernel docs. + + [1] https://bugzilla.mozilla.org/show_bug.cgi?id=807181 + [2] http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=blob;f=documentation/filesystems/proc.txt;h=a1793d670cd01bd374eddf54ffdfc768504291ff;hb=head + +proc.5 + kees cook + put /proc/sys/kernel/hotplug in alphabetical order + kees cook + document /proc/sys/kernel/dmesg_restrict + kees cook + linux 3.4 changed permissions needed to change kptr_restrict + michael kerrisk [samuel thibault, simon paillard] + add field numbers for /proc/pid/stat + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=553413 + add numbering to /proc/stat "cpu" fields + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=553413 + michael kerrisk + reorganize text describing /proc/stat "cpu" fields + michael kerrisk + rewording of suid_dumpable text after comments from kees cook + michael kerrisk [samuel thibault, simon paillard] + add field numbers for /proc/[pid]/statm + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=553413 + michael kerrisk + document /proc/stat "cpu" "nice_guest" field + info taken from commit ce0e7b28fb75cb003cfc8d0238613aaf1c55e797 + michael kerrisk [peter lekeynstein] + document /prod/[pid]/oom_score_adj + text taken directly from documentation/filesystems/proc.txt, + with some light editing. + + see https://bugzilla.kernel.org/show_bug.cgi?id=50421 + +shells.5 + michael kerrisk + add /etc/bash to list of example shells + +ttytype.5 + michael kerrisk + add proper xref for termcap and terminfo pages + +capabilities.7 + michael kerrisk + add kcmp(2) under cap_sys_ptrace + +man-pages.7 + michael kerrisk + update description of section 7 + + +==================== changes in man-pages-3.47 ==================== + +released: 2013-02-12, christchurch + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +david prévot +d. barbier +lennart poettering +michael kerrisk +mike frysinger +peter schiffer +radek pazdera +reuben thomas +shawn landden +simon paillard +vince weaver + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +perf_event_open.2 + vincent weaver + new page documenting perf_event_open(2) + +pthread_setname_np.3 + chandan apsangi, michael kerrisk + new page for pthread_setname_np(3) and pthread_getname_np(3) + +sln.8 + michael kerrisk [peter schiffer] + new page documenting the 'sln' command provided by glibc + inspired by a red hat downstream page, but with rather + more detail. + + +newly documented interfaces in existing pages +--------------------------------------------- + +prctl.2 + michael kerrisk [shawn landden, lennart poettering] + document pr_set_child_subreaper and pr_get_child_subreaper + +ip.7 + radek pazdera + add source-specific multicast sockopts + this patch adds documentation of several source-specific multicast + socket options that were added to kernel with implementation + of igmpv3 in 2.5.68. + + the following socket options were added: + ip_add_source_membership + ip_drop_source_membership + ip_block_source + ip_unblock_source + ip_msfilter + + +pages moved across sections +--------------------------- + +getcontext.3 + michael kerrisk + this page really belongs in section 3 (moved from section 2) + +getdtablesize.3 + michael kerrisk + move from section 2 + + +new and changed links +--------------------- + +getcontext.2 + michael kerrisk + make link to page moved into section 3 + +getdtablesize.2 + michael kerrisk + link to renamed getdtablesize.3 + +setcontext.2 + michael kerrisk + modify link to point to section 3 + +pthread_getname_np.3 + michael kerrisk + new link to new pthread_setname_np.3 + +setcontext.3 + michael kerrisk + link to getcontext page renamed into section 3 + + +changes to individual pages +--------------------------- + +fallocate.2 + michael kerrisk + see also: add fallocate(1) + +flock.2 + michael kerrisk + see also: add flock(1) + +fork.2 + michael kerrisk + see also: add exit(2) + +getpriority.2 + michael kerrisk + bugs: note that nice value is per-thread on linux + +getrlimit.2 + michael kerrisk + see also: add prlimit(1) + +gettid.2 + michael kerrisk + see also: add various system calls that use thread ids + +ioprio_set.2 + michael kerrisk + see also: add ionice(1) + +sched_setaffinity.2 + michael kerrisk + see also: add taskset(1) + +sched_setparam.2 + michael kerrisk + scheduling policy and parameters are per-thread on linux + direct the reader to the discussion in sched_setscheduler(2). + +sched_setscheduler.2 + michael kerrisk + scheduling policy and parameters are per-thread on linux + michael kerrisk + see also: add chrt(1) + +setsid.2 + michael kerrisk + see also: add setsid(1) + +shmop.2 + michael kerrisk [peter schiffer] + errors: add eidrm + taken from red hat downstream patch + +sigaction.2 +makecontext.3 + michael kerrisk + change getcontext/setcontext page ref to section 3 + +signal.2 + michael kerrisk [reuben thomas] + clarify system v vs bsd semantics for signal() + +syscalls.2 + michael kerrisk + the list on this page is not just syscalls common to all platforms + michael kerrisk + add perfctr(2) + add ppc_rtas(2) + michael kerrisk + add kernel version number of utrap_install(2) + +unimplemented.2 + michael kerrisk [peter schiffer] + remove mention of kernel version number in description + +inet.3 + michael kerrisk [peter schiffer] + fix error in example using inet_aton() + see https://bugzilla.redhat.com/show_bug.cgi?id=837090 + patch taken from red hat downstream. + +posix_fallocate.3 + michael kerrisk + see also: add fallocate(1) + +regex.3 + reuben thomas + clarify details of matching + the first is that it's far from clear that the end points of the + complete string match are stored in the zero'th element of the + regmatch_t array; secondly, the phrase "next largest substring + match" is positively misleading, implying some sort of size + ordering, whereas in fact they are ordered according to their + appearance in the regex pattern. + +scanf.3 + michael kerrisk + clarify meaning of "string conversions" for 'm' modifier + mike frysinger + update %a vs %m documentation + posix.1-2008 adopted the 'm' flag for dynamic allocation. update + page to cover it and relegate the glibc-specific 'a' flag to + notes. + +strtol.3 + michael kerrisk [peter schiffer] + replace some bogus text about "thousands separator" + see https://bugzilla.redhat.com/show_bug.cgi?id=652870 + +sysconf.3 + michael kerrisk [peter schiffer] + use "_sc_pagesize" consistently on page + s/_sc_page_size/_sc_pagesize/ in one instance. + from red hat downstream patch. + +nscd.conf.5 + peter schiffer + add max-db-size and auto-propagate descriptions, default values, + misc + * added missing valid services (services and netgroup) + * added many default values for options + * reordered options according to the nscd.conf file + (logical order) + * added 2 missing options: max-db-size and auto-propagate + +nsswitch.conf.5 + peter schiffer + mention initgroups db + +proc.5 + michael kerrisk + document /proc/profile + michael kerrisk [peter schiffer] + update /proc/sys/fs/file-nr to include linux 2.6 details + michael kerrisk + clarify relationship between file-max and file-nr + the third value in /proc/sys/fs/file-nr is the same as + the value in /proc/sys/fs/file-max. + michael kerrisk + note message written to kernel log when file-max limit is hit + info from documentation/sysctl/fs.txt. + michael kerrisk + mention lscpu(1) under discussion of /proc/cpuinfo + +resolv.conf.5 + michael kerrisk [peter schiffer] + document "single-request-reopen" option + taken from red hat downstream patch + + see https://bugzilla.redhat.com/show_bug.cgi?id=717770 + see http://thread.gmane.org/gmane.linux.man/3161 + +utmp.5 + michael kerrisk + see also: add utmpdump(1) + +cpuset.7 + simon paillard + add missing 'cpuset.' prefix for some flags + see kernel commit e21a05cb408bb9f244f11a0813d4b355dad0822e + +svipc.7 + michael kerrisk + see also: add ipcmk(1), ipcrm(1), ipcs(1) + +termio.7 + michael kerrisk + see also: add reset(1), setterm(1), stty(1), tty(4) + +ld.so.8 + michael kerrisk [peter schiffer] + ld_verbose does not work with ld.so --list and --verify + from red hat downstream patch + + see https://bugzilla.redhat.com/show_bug.cgi?id=532629 + michael kerrisk + see also: add sln(8) + +zdump.8 + michael kerrisk [peter schiffer] + bring up to date with zdump --help + patch taken from red hat downstream. + + +==================== changes in man-pages-3.48 ==================== + +released: 2013-03-05, munich + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +andrey vagin +aristeu rozanski +colin walters +cyril hrubis +cyrill gorcunov +daniel p. berrange +david prévot +d. barbier +denys vlasenko +flavio leitner +graham gower +ivana varekova +kai kunschke +marcela maslanova +marc lehmann +marshel abraham +michael kerrisk +nathan stratton treadway +pavel emelyanov +peter schiffer +simon heimberg +simon paillard +török edwin +ulrich drepper +zack weinberg + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +getunwind.2 + marcela maslanova + new page documenting getunwind(2) + taken from red hat downstream man pages set + michael kerrisk + much rewriting + some text taken from arch/ia64/kernel/unwind.c. + +perfmonctl.2 + ivana varekova + new page documenting ia-64-specific perfmonctl(2) + taken from red hat downstream man pages + michael kerrisk + rework discussion of pfm_create_context + add versions and conforming to + note that there is no glibc wrapper + remove pfm_create_evtsets, pfm_delete_evtsets, pfm_getinfo_evtsets + these don't exist, and it appears they never have. + fix argument types for pfm_write_pmcs, pfm_write_pmds, pfm_read_pmds + the types that were being used don't exist! + briefly document pfm_get_features, pfm_debug, pfm_get_pmc_reset_val + +gai.conf.5 + ulrich drepper + new page documenting gai.conf + taken from red hat downstream pages + +nss.5 + ulrich drepper + new page describing nss.conf + + +newly documented interfaces in existing pages +--------------------------------------------- + +clock_getres.2 + cyril hrubis + document clock_realtime_coarse and clock_monotonic_coarse + cyril hrubis + document clock_boottime + michael kerrisk + some improvements to clock_boottime description + +ptrace.2 + denys vlasenko + document ptrace_getregset, ptrace_setregset, ptrace_seize, and friends + document ptrace_getregset, ptrace_setregset, + ptrace_seize, ptrace_interrupt, and ptrace_listen. + + +new and changed links +--------------------- + +fattach.2 +fdetach.2 +getmsg.2 +isastream.2 +putmsg.2 + michael kerrisk [peter schiffer] + new link to unimplemented.2 + taken from red hat downstream. + + see https://bugzilla.redhat.com/show_bug.cgi?id=436407 + + +global changes +-------------- + +many pages + michael kerrisk + global fix: remove unneeded double quotes in .sh headings + +many pages + michael kerrisk + global fix: remove unneeded double quotes in .ss headings + +many pages + michael kerrisk + global fix: use consistent capitalization in .ss headings + capitalization in .ss sections across pages (and sometimes even + within a single page) is wildly inconsistent. make it consistent. + capitalize first word in heading, but otherwise use lower case, + except where english usage (e.g., proper nouns) or programming + language requirements (e.g., identifier names) dictate otherwise. + +many pages + michael kerrisk [denys vlasenko] + remove double blank lines in output + +various pages + michael kerrisk + fix order of sh sections + + +changes to individual pages +--------------------------- + +accept.2 + michael kerrisk + name: add "accept4" + +access.2 + colin walters + note that access() may also fail for fuse + since in some cases (e.g. libguestfs's guestmount) it also has the + semantics where files can appear owned by root, but are actually + mutable by the user, despite what one might infer from the unix + permissions. + +getpeername.2 + michael kerrisk [kai kunschke] + clarify semantics of getpeername() for datagram sockets + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=674034 + +getuid.2 + michael kerrisk + remove duplicate section heading + +mmap.2 + cyril hrubis + add note about partial page in bugs section + this adds a note about linux behavior with partial page at the end + of the object. the problem here is that a page that contains only + part of a file (because the file size is not multiple of page_size) + stays in page cache even after the mapping is unmapped and the file + is closed. so if some process dirties such page, other mappings + will see the changes rather than zeroes. + michael kerrisk [török edwin] + some 'flags' values require a feature test macro to be defined + add text to notes noting that some map_* constants are + defined only if a suitable feature test macro is defined. + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=542601 + cyril hrubis + document eoverflow error + +open.2 + michael kerrisk + clarify list of file creation flags + posix.1-2008 tc1 clarified this, so that o_cloexec, + o_directory, and o_nofollow are also in this list. + +prctl.2 + cyrill gorcunov + add some details for pr_get_tid_address + +read.2 + michael kerrisk [zack weinberg] + clarify interaction of count==0 and error checking + posix deliberately leaves this case open, so the man + page should be less specific about what happens. + + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=533232 + michael kerrisk [marc lehmann] + remove crufty text about o_nonblock on files + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=700529 + michael kerrisk + clarify details for seekable files + +unimplemented.2 + michael kerrisk [peter schiffer] + add various streams interfaces to name + taken from red hat downstream. + + see https://bugzilla.redhat.com/show_bug.cgi?id=436407 + +cexp2.3 + michael kerrisk + still does not exist in glibc 2.17 + +exit.3 + michael kerrisk + note that a call to execve() clears exit handler registrations + +getaddrinfo.3 + michael kerrisk + see also: add gai.conf(5) + +malloc_trim.3 + michael kerrisk + remove duplicate section title + +printf.3 + marshel abraham [graham gower, graham gower] + fix error handling in example code + see https://bugzilla.kernel.org/show_bug.cgi?id=23282 + +pthread_yield.3 + michael kerrisk [aristeu rozanski] + add _gnu_source feature test macro to synopsis + +resolver.3 +resolv.conf.5 + michael kerrisk [nathan stratton treadway, simon heimberg] + res_debug is only available if glibc is compiled with debug support + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=692136 + and https://bugzilla.kernel.org/show_bug.cgi?id=43061 + +strtol.3 + michael kerrisk [peter schiffer] + remove crufty text from previous fix + +core.5 + michael kerrisk + document config_coredump + +capabilities.7 + andrey vagin + nonexistent bits are no longer shown as set in /proc/pid/status cap* + +inotify.7 + michael kerrisk + a monitoring process can't easily distinguish events triggered by itself + +ip.7 + flavio leitner [peter schiffer] + improve explanation about calling listen() or connect() + +man-pages.7 + michael kerrisk + describe rules for capitalization in .ss headings + +rtnetlink.7 + pavel emelyanov + add info about ability to create links with given index + since kernel v3.7 the rtm_newlink message now accepts nonzero + values in ifi_index field. mention this fact in the respective + rtnetlink.7 section. + +socket.7 + pavel emelyanov + so_bindtodevice is now readable + so_bindtodevice is readable since kernel 3.8. + + +==================== changes in man-pages-3.49 ==================== + +released: 2013-03-10, munich + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +michael kerrisk + + +global changes +-------------- + +the goal of the changes below to consistently format copyright +and license information in the comments in the page source +at the top of each page. this allows for easy scripting to +extract that information. following these changes the comments +the top of the page source should now consistently have the form: + + .\" + .\" + .\" %%%license_start() + .\" + .\" %%%license_end + .\" + +note that the 'license-type' is merely descriptive. its purpose is +to simplify scripting for the purpose of gathering statistics on +types of licenses used in man-pages. it is not a statement about +the actual licensing of the page; that license is contain inside the +license_start...license_end clause. + +all pages + michael kerrisk + add a license_start()...license_end clause in source at + top of each page that encapsulates the license text. + michael kerrisk + put copyright info at top of page, followed by blank line and license + +various pages + michael kerrisk + update info in source comments on where to get a copy of the gpl + +various pages + michael kerrisk + remove "hey emacs" comment in page source + only certain pages have this; there is no consistency, so + remove it from all pages + michael kerrisk + remove "-*- nroff -*-" comment at top of source + + +==================== changes in man-pages-3.50 ==================== + +released: 2013-03-15, munich + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +andrey vagin +bernhard kuemel +elie de brauwer +erik saule +florian weimer +friedrich delgado friedrichs +jonathan nieder +jose luis domingo lopez +mark r bannister +michael kerrisk +sam varshavchik +simon paillard + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +canonicalize_file_name.3 + michael kerrisk + rewrite page, adding much more detail + + +global changes +-------------- + +various pages + michael kerrisk + global fix: s/end_license/license_end/ + +various pages + michael kerrisk + global fix: s/bitmask/bit mask/ + + +changes to individual pages +--------------------------- + +getent.1 + mark r bannister + netgroup description incorrectly refers to initgroups + +capget.2 + michael kerrisk + update url for libcap + +fork.2 + michael kerrisk + port access permission bits (ioperm()) are turned off in the child + +futex.2 + michael kerrisk + 'timeout' is a minimum duration that the call will wait, not a maximum + +ioperm.2 + michael kerrisk + note that iopl() level of 3 is needed to access ports + michael kerrisk + 'num' is *bits* not bytes! + michael kerrisk + linux 2.6.8 lifted the port limit to 65,536 + see http://article.gmane.org/gmane.linux.kernel/202624/ + from: stas sergeev aknet.ru> + subject: [patch][rfc] larger io bitmap + date: 2004-05-07 19:55:03 gmt + michael kerrisk + ioperm() operates on the calling *thread* (not process) + michael kerrisk + clarify meaning of 'turn_on' argument + plus form formatting fixes. + michael kerrisk + clarify that default state of permission bits in child is off + michael kerrisk + notes: add mention of /proc/ioports + michael kerrisk + see also: add outb(2) + +iopl.2 + michael kerrisk + cap_sys_rawio is required to *raise* the i/o privilege level + michael kerrisk + clarify that the two least significant bits of 'level' are what matter + michael kerrisk + see also: add outb(2) + +syscalls.2 + michael kerrisk + add version information for all (other) syscalls + michael kerrisk + add perfmonctl(2) + +futimes.3 + michael kerrisk [jonathan nieder] + errors: add enosys for lutimes() + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=620746 + +getpass.3 + michael kerrisk [erik saule] + suggest use of the echo flag as an alternative + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=644261 + +realpath.3 + michael kerrisk + document gnu extensions for eacces and enoent errors + +stdarg.3 + michael kerrisk [friedrich delgado friedrichs] + describe va_copy() + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=575077 + +termios.3 + michael kerrisk [bernhard kuemel] + mention that noncanonical mode does not do input processing + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=643854 + +random.4 + elie de brauwer + document write and document the ioctl interface of /dev/random + the update consists out of two parts: + - a minor thing which just documents what happens if a write to + /dev/(u)random is performed, which is used in the example + script but not explicitly mentioned. + - the other (biggest) part is the documentation of the ioctl() + interface which /dev/(u)random exposes. this ioctl() lives in + drivers/char/random.c and the primitives can be found in + include/linux/random.h + + one comment remains, there used to be an rndgetpool ioctl() which + disappeared in v2.6.9. i found two patches on the net: + - http://www.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.8.1/2.6.8.1-mm4/broken-out/dev-random-remove-rndgetpool-ioctl.patch + - https://lkml.org/lkml/2004/3/25/168 + + but as far as i can tell the first one got applied but the 2nd + one seems more correct. the result is that even today one can + still find traces of the rndgetpool ioctl() in the header files. + is this there for historical reasons or because it might break + userspace, even though using it will just give an einval. + +bootparam.7 + jose luis domingo lopez + document 'rootfstype' option + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=182014 + +capabilities.7 + michael kerrisk + add various pieces under cap_sys_rawio + info obtained by grepping the kernel source. + michael kerrisk + add cap_sys_resource /proc/pid/oom_score_adj case + +netlink.7 + andrey vagin + add a note about broadcast messages to multiple groups + +socket.7 + michael kerrisk [florian weimer] + define _gnu_source to obtain the definition of 'struct ucred' + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=572210 + + +==================== changes in man-pages-3.51 ==================== + +released: 2013-04-17, munich + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +andreas jaeger +andrew clayton +brian m. carlson +changhee han +cyril hrubis +damien grassart +david prévot +denis barbier +jeff moyer +krzysztof konopko +kyle mcmartin +mark h weaver +michael kerrisk +mike frysinger +nicolas hillegeer +pavel emelyanov +peter schiffer +radek pazdera +ralph loader +simon paillard +the wanderer + +apologies if i missed anyone! + + +newly documented interfaces in existing pages +--------------------------------------------- + +sched_rr_get_interval.2 + michael kerrisk + document /proc/sys/kernel/sched_rr_timeslice_ms + +proc.5 + pavel emelyanov + document /proc/[pid]/map_files directory + this directory was added in linux v3.3 and provides info about + files being mmap-ed in a way very similar to how /proc/[pid]/fd + works. + + v2: added examples of how links look like and noted dependency + on kernel config option config_checkpoint_restore. + michael kerrisk + document /proc/sys/kernel/shm_rmid_forced + +capabilities.7 + michael kerrisk + document /proc/sys/kernel/cap_last_cap + + +global changes +-------------- + +various pages + michael kerrisk + global fix: fix placement of word "only" + +various pages + simon paillard + license headers: consistent format + +various pages + michael kerrisk + global fix: s/since kernel/since linux/ + +various system v ipc pages in section 2 + michael kerrisk + add "system v" to .th line and text + make it clear that these pages relate to system v ipc, + not posix ipc. + + +changes to individual pages +--------------------------- + +access.2 + michael kerrisk [the wanderer] + clarify return value for f_ok + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=705293 + +alarm.2 + michael kerrisk + correct the description of behavior when 'seconds' is 0 + +clone.2 + michael kerrisk [peter schiffer] + add prototype for syscall to synopsis + and further clarify the distinction between the system call + and the wrapper function in the introductory text. + michael kerrisk + update feature test macro requirements + the requirements quietly changed in glibc 2.14 + + see also http://www.sourceware.org/bugzilla/show_bug.cgi?id=4749 + michael kerrisk [mike frysinger] + clarify differences between clone2() syscall and wrapper function + michael kerrisk [mike frysinger] + note those architectures where the sys_clone argument order differs + michael kerrisk [mike frysinger] + add short subsection noting that blackfin, m68k, and sparc are different + michael kerrisk + move clone2() text to subsection in description + the description of ia64 clone2() should follow the discussion + of the raw system call interface. + michael kerrisk + change subhead for ia64 discussion + +getcpu.2 + michael kerrisk + recommend that 'tcache' should be specified as null nowadays + +io_cancel.2 + jeff moyer, michael kerrisk [cyril hrubis] + improve description + +io_destroy.2 + jeff moyer + improve description + the description was rather vague, citing a "list of i/o contexts" + and stating that it "can" cancel outstanding requests. this + update makes things more concrete so that the reader knows exactly + what's going on. + +io_getevents.2 + jeff moyer + the 'timeout' argument is not updated + i looked back through the kernel code, and the timeout was + never updated in any case. i've submitted a patch upstream + to change the comment above io_getevents. + +io_setup.2 + jeff moyer + clarify nr_events + nr_events is technically the number of completion events that can + be stored in the completion ring. the wording of the man page: + "capable of receiving at least nr_events" seems dubious to me, + only because i worry that folks might interpret that to mean + 'nr_events' total, instead of 'nr_events' concurrently. + + further, i've added information on where to find the per-user + limit on 'nr_events', /proc/sys/fs/aio-max-nr. let me know if + you think that is not relevant. + +listxattr.2 + michael kerrisk + explain use of 'size' argument + +lseek.2 + michael kerrisk [andreas jaeger] + _gnu_source must be defined to get seek_data and seek_hole definitions + see http://sourceware.org/bugzilla/show_bug.cgi?id=15312 + +mmap.2 + michael kerrisk + add pointers to relevant /proc files described in proc(5) + +posix_fadvise.2 +pread.2 +readahead.2 +sync_file_range.2 +truncate.2 + michael kerrisk + refer to syscall(2) for abi semantics on certain 32-bit architectures + also: in sync_file_range.2 and posix_fadvise.2 remove description + of conventional calling signature as flawed, and in + posix_fadvise.2, de-emphasize focus on arm, and rather phrase + as a more general discussion of certain architectures. + +readdir.2 + michael kerrisk + readdir(2) doesn't exist on x86-64 + +semop.2 + michael kerrisk + clarify the discussion of 'semadj' + +shmctl.2 + michael kerrisk + refer to proc(5) for description of /proc/sys/kernel/shm_rmid_forced + +syscall.2 + changhee han + add notes that caution users when passing arguments to syscall() + for example, passing 'long long' on arm-32 requires special + treatment. + mike frysinger [michael kerrisk] + document the exact calling convention for architecture system calls + mike frysinger [kyle mcmartin] + add pa-risc details under calling conventions + michael kerrisk [mike frysinger] + refine discussion of arm and other abis + +syscalls.2 + michael kerrisk + update kernel version number at start of list + +umask.2 + michael kerrisk + see also: add acl(5) + +unshare.2 + michael kerrisk + update feature test macro requirements + the requirements quietly changed in glibc 2.14 + + see also http://www.sourceware.org/bugzilla/show_bug.cgi?id=4749 + +fopencookie.3 + michael kerrisk [ralph loader] + correct definition of cookie_io_functions_t + +pthread_setname_np.3 + andrew clayton + the thread argument is passed in by value + +readir.3 +seekdir.3 +telldir.3 + michael kerrisk + eliminate the implication that these functions deal with "offsets" + the directory position dealt with by the readdir() and + friends is not a simple file offset in modern file systems. + typically, it is some kind of cookie value. add text and + make other changes to these pages to eliminate the + implication that this is an offset, and warn the reader + that directory positions should be treated strictly as + opaque values. + + in the process, rename the 'offset' argument of seekdir(3) + to 'loc', and add some text to readdir(3) to note that + the 'd_off' field is the same value returned by telldir(3) + at the current directory position. + + see also https://lwn.net/articles/544298/ + +scalb.3 + mark h weaver + fix prototypes for scalbf() and scalbl() + +sched_getcpu.3 + michael kerrisk + update feature test macro requirements + the requirements quietly changed in glibc 2.14 + + see also http://www.sourceware.org/bugzilla/show_bug.cgi?id=4749 + +ualarm.3 + michael kerrisk [nicolas hillegeer] + add note on the behavior when 'usecs' is zero + posix.1-2001 does not specify the behavior in this case + and no other system that i checked documented the behavior. + probably, most or all systems do what linux does in this + case: cancel any pending alarm, just as alarm(0) does. + add that info in notes. + +elf.5 + mike frysinger + add byte positions for all ei_xxx fields + when describing e_ident, most of the ei_xxx defines mention the + exact byte number. this is useful when manually hacking an elf + with a hex editor. however, the last few fields don't do this, + which means you have to count things up yourself. + add a single word to each so you don't have to do that. + +proc.5 + michael kerrisk + refer to sched_rr_get_interval(2) for info on sched_rr_timeslice_ms + since linux 3.9, /proc/sys/kernel/sched_rr_timeslice_ms can + be used to change the sched_rr quantum. + michael kerrisk + see also: add sysctl(8) + krzysztof konopko + simplify the example of printing out environ + the binutils package contains a very handy utility to + print out null-byte delimited strings from a file. this + can replace a rather complex expression with cat(1) + provided as an example for printing out /proc/[pid]/environ. + michael kerrisk + update /proc/pid/maps example + update to 64-bit example that includes "[heap]", "[stack], + and "[vdso]" + michael kerrisk + formatting fixes for /proc/pid/maps + mike frysinger + document the "pathname" field of /proc/pid/maps + michael kerrisk + add reference to capabilities(7) for /proc/sys/kernel/cap_last_cap + michael kerrisk + /proc/pid/maps: add a reference to mmap(2) + +ip.7 + radek pazdera + document ip_multicast_all + this commit adds documentation for the ip_multicast_all socket + option. + + the option was added to the linux kernel in 2.6.31: + + author nivedita singhvi + commit f771bef98004d9d141b085d987a77d06669d4f4f + + the description is based on a previous one [3] posted by the + original author of the code -- nivedita, but it is slightly + re-worded. + + i tested it myself and it works as described. + + references: + [1] http://lxr.free-electrons.com/source/net/ipv4/ip_sockglue.c#l972 + [2] http://lxr.free-electrons.com/source/net/ipv4/igmp.c#l2267 + [3] http://patchwork.ozlabs.org/patch/28902/ + +units.7 + brian m. carlson + units should use an actual µ + the units(7) man page uses an ascii u in place of the actual greek + letter mu. since we're in the twenty-first century, with + utf-8-compatible terminals and terminal emulators, we should use + the actual letter µ instead of an ascii approximation. + + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=704787 + + +==================== changes in man-pages-3.52 ==================== + +released: 2013-07-04, christchurch + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +adrian bunk +andrea remondini +anthony foiani +brian norris +cyril hrubis +dan jacobson +david prévot +eric s. raymond +georg sauthoff +jeff moyer +jérémie galarneau +jon grant +manuel traut +марк коренберг +michael kerrisk +mike frysinger +pavel emelyanov +peng haitao +peter ladow +petr gajdos +regid +siddhesh poyarekar +simone piccardi +simon paillard +vince weaver +yuri kozlov + +apologies if i missed anyone! + + +newly documented interfaces in existing pages +--------------------------------------------- + +perf_event_open.2 + vince weaver + add perf_ioc_flag_group documentation + the perf_event_open() enable/disable/reset ioctls can take an + argument, perf_ioc_flag_group. this wasn't documented at all + until about a year ago (despite the support being there from + the beginning) so i missed this when initially writing + the man page. + +socket.7 + pavel emelyanov, michael kerrisk + document so_peek_off option + since linux 3.4 there appeared an ability to specify the + offset in bytes from which the data will be msg_peek-ed. + describe this socket option in the socket(7) page, where + all the other socket options are described. + + +global changes +-------------- + +various pages + michael kerrisk + convert inline formatting (\fx...\fp) to dot-directive formatting + +readdir.2 +asprintf. +getline.3 +getlogin.3 +pthread_setname_np.3 +readdir.3 +strerror.3 + michael kerrisk [jon grant] + clarify that terminating null byte is '\0' + + +changes to individual pages +--------------------------- + +execve.2 + peter ladow + add envp to the linux notes about null pointers + during the review of static analysis results, we discovered a + functional, but non-portable, use of execve(). for example: + + char *cmd[] = { "/path/to/some/file", null }; + execve(cmd[0], cmd, null); + + the call succeeds. yet, the static analysis tool (rightly) + pointed out that envp could be dereferenced. but digging into + glibc and the kernel, it appears that like argv, envp when null + is treated as if it were an empty list. + + so, to clear things up, i'm submitting this patch to update the + man page to indicate that envp is treated like argv. + +fallocate.2 + michael kerrisk + return value: mention that 'errno' is set on error + +io_setup.2 + cyril hrubis [jeff moyer] + clarify the nr_events parameter + currently the io_setup.2 man page describes what the kernel really + does, i.e., that the resulting context may be able to hold more + than the 'nr_event's operations because the memory allocated in + kernel is rounded to be multiple of page size. + + it is better not to expose this implementation detail and + simply state that the resulting context is suitable for + 'nr_events' operations. + +perf_event_open.2 + vince weaver + clarify the perf_event_open() wakeup_events/wakeup_watermark fields + clarify the perf_event_open() wakeup_events/wakeup_watermark + fields a bit, based on info from kernel commit cfeb1d90a1b1. + vince weaver + update to match the linux 3.10 release + this patch updates the perf_event_open() documentation to include + new interfaces added in the 3.10 kernel. + + it also documents a few [to be documented] instances left over + from the 3.7 kernel. + vince weaver + small correction to description of 'flags' argument + +prctl.2 + michael kerrisk + note equivalents of pr_set_name + pthread_setname_np() and pthread_getname_np() and + /proc/self/task/tid/comm provide access to the same + attribute. + +pread.2 + michael kerrisk [марк коренберг] + pread() and pwrite() are especially useful in multithreaded applications + +recv.2 + michael kerrisk + return value: mention that 'errno' is set on error + +semctl.2 + michael kerrisk [simone piccardi] + 'sem_nsems' is 'unsigned long' since linux 2.4 + +shmget.2 + michael kerrisk + rewrite return value and mention that 'errno' is set on error + +sigaction.2 + michael kerrisk [brian norris] + return value: mention that 'errno' is set on error + +signal.2 + michael kerrisk + return value: mention that 'errno' is set on error + +sigpending.2 + michael kerrisk + return value: mention that 'errno' is set on error + +sigprocmask.2 + michael kerrisk + return value: mention that 'errno' is set on error + +sigsuspend.2 + michael kerrisk + return value: mention that 'errno' is set on error + +syscall.2 + mike frysinger + document s390/s390x calling convention + +a64l.3 + peng haitao + attributes: note function that is not thread-safe + the function l64a() is not thread safe. + +abs.3 + peng haitao + attributes: note functions that are thread-safe + the functions abs(), labs(), llabs() and imaxabs() are + thread-safe. + +aio_error.3 + peng haitao + attributes: note function that is thread-safe + the function aio_error() is thread safe. + +aio_return.3 + peng haitao + attributes: note function that is thread-safe + the function aio_return() is thread safe. + +alloca.3 + adrian bunk + correct information on getting non-inlined version with gcc+glibc + - remove the incorrect information that -fno-builtin would help + - add -std=c11 to the list of strict options + - emphasize more that both the gcc option and not including + alloca.h are needed + - add the #ifdef from the glibc alloca.h to make the situation + clearer + +bindresvport.3 + peng haitao + attributes: note function that is thread-safe + before glibc 2.17, bindresvport() is not thread-safe. + since glibc 2.17, it is thread-safe, the patch can refer to url: + http://sourceware.org/git/?p=glibc.git;a=commit;h=f6da27e53695ad1cc0e2a9490358decbbfdff5e5 + +canonicalize_file_name.3 + michael kerrisk + put conforming to section in right location + +catgets.3 + michael kerrisk [jon grant] + clarify that null byte is '\0' + +ceil.3 + peng haitao + attributes: note functions that are thread-safe + the functions ceil(), ceilf() and ceill() are thread safe. + +cimag.3 + peng haitao + attributes: note functions that are thread-safe + the functions cimag(), cimagf() and cimagl() are thread safe. + +clock_getcpuclockid.3 + peng haitao + attributes: note function that is thread-safe + the function clock_getcpuclockid() is thread safe. + +conj.3 + peng haitao + attributes: note functions that are thread-safe + the functions conj(), conjf() and conjl() are thread safe. + +crypt.3 + peng haitao + attributes: note function that is not thread-safe + the function crypt() is not thread safe. + +ctermid.3 + peng haitao + attributes: note function that is thread safe with exceptions + the function ctermid() is thread safe with exceptions. + +dirfd.3 + michael kerrisk + return value: mention that 'errno' is set on error + +drand48.3 + peng haitao + attributes: note functions that are not thread-safe + the functions drand48(), erand48(), lrand48(), nrand48(), + mrand48(), jrand48(), srand48(), seed48() and lcong48() are + not thread safe. + +ecvt.3 + peng haitao + attributes: note functions that are not thread-safe + the functions ecvt() and fcvt() return a string located in a + static buffer which is overwritten by the next call to the + functions, so they are not thread-safe. + +encrypt.3 + peng haitao + attributes: note functions that are not thread-safe + the functions encrypt() and setkey() are not thread safe. + +ether_aton.3 + peng haitao + attributes: note functions that are not thread-safe + the functions ether_aton() and ether_ntoa() are not thread safe. + +fcloseall.3 + peng haitao + attributes: note function that is not thread-safe + the function fcloseall() is not thread safe. + +ferror.3 + peng haitao + attributes: note functions that are thread-safe + the functions ferror(), clearerr(), feof() and fileno() are + thread safe. + +fgetgrent.3 + michael kerrisk + return value: mention that 'errno' is set on error + +fgetpwent.3 + michael kerrisk + return value: mention that 'errno' is set on error + +fgetwc.3 + michael kerrisk + return value: mention that 'errno' is set on error + +fmtmsg.3 + peng haitao + attributes: note function that is thread-safe + before glibc 2.16, fmtmsg() is not thread-safe. + since glibc 2.16, it is thread-safe, the patch can refer to url: + http://sourceware.org/git/?p=glibc.git;a=commit;h=7724defcf8873116fe4efab256596861eef21a94 + +fputwc.3 + michael kerrisk + return value: mention that 'errno' is set on error + +getdate.3 + peng haitao + attributes: note functions that are and aren't thread-safe + +getgrent.3 + peng haitao + attributes: note function that is not thread-safe + the function getgrent() is not thread safe. + +getgrnam.3 + peng haitao + attributes: note functions that are and aren't thread-safe + +getline.3 + michael kerrisk + return value: mention that 'errno' is set on error + +getlogin.3 + peng haitao + attributes: note function that is not thread-safe + the function getlogin() is not thread safe. + the function cuserid() is thread-safe with exceptions. + michael kerrisk + return value: mention that 'errno' is set on error + +getpass.3 + peng haitao + attributes: note functions that are not thread-safe + +getpwent.3 + peng haitao + attributes: note function that is not thread-safe + the function getpwent() is not thread safe. + +getpwnam.3 + peng haitao + attributes: note functions that are and aren't thread-safe + +getspnam.3 + michael kerrisk + return value: mention that 'errno' is set on error + +getttyent.3 + peng haitao + attributes: note functions that are not thread-safe + +getusershell.3 + peng haitao + attributes: note functions that are not thread-safe + the functions getusershell(), setusershell() and endusershell() + are not thread safe. + +getutent.3 + michael kerrisk + return value: mention that 'errno' is set on error + +hsearch.3 + michael kerrisk + return value: mention that 'errno' is set on error + +hsearch.3 + peng haitao + attributes: note functions that are not thread-safe + the functions hsearch(), hcreate() and hdestroy() are not + thread-safe. + +localeconv.3 + peng haitao + attributes: note functions that are not thread-safe + the function localeconv() returns a pointer to a structure which + might be overwritten by subsequent calls to localeconv() or by + calls to setlocale(), so it is not thread-safe. + peng haitao + add return value section + +malloc_info.3 + michael kerrisk + return value: mention that 'errno' is set on error + +mblen.3 + peng haitao + attributes: note function that is not thread-safe + the function mblen() is not thread safe. + +mbrlen.3 + peng haitao + attributes: note function that is thread safe with exceptions + the function mbrlen() is thread safe with exceptions. + +mbrtowc.3 + peng haitao + attributes: note function that is thread safe with exceptions + the function mbrtowc() is thread safe with exceptions. + +mktemp.3 + michael kerrisk + return value: mention that 'errno' is set on error + +modf.3 + peng haitao + attributes: note functions that are thread-safe + the functions modf(), modff() and modfl() are thread safe. + +popen.3 + michael kerrisk + return value: mention that 'errno' is set on error + +pthread_attr_setinheritsched.3 + michael kerrisk + note the scheduling attributes affected by this function + +pthread_attr_setschedparam.3 +pthread_attr_setschedpolicy.3 +pthread_attr_setscope.3 + michael kerrisk [manuel traut, siddhesh poyarekar] + the inherit-scheduler attribute must be set to pthread_explicit_sched + in order for the attributes set by these functions to have + an effect, the caller must use pthread_attr_setinheritsched(3) + to set the inherit-scheduler attribute of the attributes object + to pthread_explicit_sched. + +ptsname.3 + peng haitao + attributes: note function that is not thread-safe + the function ptsname() is not thread safe. + +putenv.3 + michael kerrisk + return value: mention that 'errno' is set on error + +putpwent.3 + michael kerrisk + return value: mention that 'errno' is set on error + +qecvt.3 + peng haitao + attributes: note functions that are not thread-safe + the functions qecvt() and qfcvt() are not thread-safe. + +random.3 + michael kerrisk + return value: mention that 'errno' is set on error + michael kerrisk + add einval error for setstate() + michael kerrisk + bugs: initstate() does not return null on error + http://sourceware.org/bugzilla/show_bug.cgi?id=15380 + +random_r.3 + michael kerrisk + return value: mention that 'errno' is set on error + +readdir.3 + peng haitao + attributes: note functions that are not thread-safe + the data returned by readdir() may be overwritten by subsequent + calls to readdir() for the same directory stream, so it is not + thread-safe. + +re_comp.3 + peng haitao + attributes: note functions that are not thread-safe + the functions re_comp() and re_exec() are not thread safe. + +rexec.3 + peng haitao + attributes: note functions that are not thread-safe + the functions rexec() and rexec_af() are not thread safe. + +round.3 + peng haitao + attributes: note functions that are thread-safe + the functions round(), roundf() and roundl() are thread safe. + +scalbln.3 + peng haitao + attributes: note functions that are thread-safe + the functions scalbn(), scalbnf(), scalbnl(), scalbln(), + scalblnf() and scalblnl() are thread safe. + +scandir.3 + michael kerrisk + return value: mention that 'errno' is set on error + +siginterrupt.3 + michael kerrisk + return value: mention that 'errno' is set on error + +signbit.3 + peng haitao + attributes: note macro that is thread-safe + the macro signbit() is thread safe. + +sigsetops.3 + michael kerrisk + return value: mention that 'errno' is set on error + +stdio_ext.3 + peng haitao + attributes: note functions that are not thread-safe + the functions __fbufsize(), __fpending(), __fpurge() and + __fsetlocking() are not thread safe. + +strdup.3 + michael kerrisk + return value: mention that 'errno' is set on error + +strerror.3 + peng haitao + attributes: note function that is not thread-safe + the function strerror() is not thread safe. + +strftime.3 + michael kerrisk + clarify details of return value + michael kerrisk + bugs: 'errno' is not set if the result string would exceed 'max' bytes + +strtok.3 + peng haitao + attributes: note function that is not thread-safe + the function strtok() is not thread safe. + michael kerrisk [georg sauthoff] + add more detail on the operation of strtok() + add a number of missing details on the operation of strtok() + +tempnam.3 + michael kerrisk + return value: mention that 'errno' is set on error + +timegm.3 + jérémie galarneau + copy the string returned by getenv() + the example of a portable version of timegm() uses the string + returned by getenv() after calling setenv() on the same + environment variable. the tz string may be invalid as per + getenv.3: + + "the string pointed to by the return value of getenv() + may be statically allocated, and can be modified by a + subsequent call to getenv(), putenv(3), setenv(3), or + unsetenv(3)." + +tmpnam.3 + peng haitao + attributes: note function that is thread safe with exceptions + the function tmpnam() is thread safe with exceptions. + +trunc.3 + peng haitao + attributes: note functions that are thread-safe + the functions trunc(), truncf() and truncl() are thread safe. + +ttyname.3 + michael kerrisk + attributes: note functions that are and aren't thread-safe + +ttyslot.3 + michael kerrisk + attributes: note functions that are not thread-safe + +usleep.3 + michael kerrisk + return value: mention that 'errno' is set on error + +wcsdup.3 + michael kerrisk + return value: mention that 'errno' is set on error + +core.5 + michael kerrisk + implicitly adding the pid to a core filename was dropped in 2.6.27 + +proc.5 + michael kerrisk + document /proc/[pid]/fd/ anon_inode symlinks + mike frysinger + document /proc/[pid]/fd/ symlinks a bit more + describe the type:[inode] syntax used in this dir + +bootparam.7 + michael kerrisk [dan jacobson] + remove outdated text on lilo and loadlin + strike the discussion of lilo and loadlin, which + are long obsolete, and make a brief mention of grub. + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=604019 + regid + remove mention of the deprecated rdev(8) + the deprecated rdev(8) command was removed from util-linux in 2010. + see https://git.kernel.org/?p=utils/util-linux/util-linux.git;a=commit;h=a3e40c14651fccf18e7954f081e601389baefe3fo + andrea remondini + document the 'resume' boot parameter + +inotify.7 + michael kerrisk [jon grant] + clarify that null byte is '\0' + +iso_8859-2.7 + eric s. raymond + remove incorrect reference to nonexistent groff glyph \[shc] + the reference incorrectly attempted to duplicate an + actual soft hyphen (hex 0xad) just before it in the file. + +man-pages.7 + peng haitao + add description of "attributes" + "attributes" section can mention thread safety, + cancellation safety, and async-cancel-safety. + +socket.7 + michael kerrisk + note that 'optval' for socket options is an 'int' in most cases + +tcp.7 + michael kerrisk + note that 'optval' for socket options is an 'int' in most cases + +udp.7 + michael kerrisk + note that 'optval' for socket options is an 'int' in most cases + + +==================== changes in man-pages-3.53 ==================== + +released: 2013-07-31, munich + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +al viro +andrey vagin +benjamin poirier +chris heath +chuck coffing +david prévot +denys vlasenko +dmitry v. levin +felix schulte +graud +michael kerrisk +oleg nesterov +peng haitao +peter schiffer +simon paillard +vince weaver + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +restart_syscall.2 + michael kerrisk + new page for restart_syscall(2) system call + + +newly documented interfaces in existing pages +--------------------------------------------- + +fchownat.2 + michael kerrisk + document at_empty_path + +fstatat.2 + michael kerrisk + document at_empty_path + +linkat.2 + michael kerrisk + document at_empty_path + +open.2 + michael kerrisk [al viro] + document o_path + see also https://bugzilla.redhat.com/show_bug.cgi?id=885740 + + +changes to individual pages +--------------------------- + +clock_nanosleep.2 +futex.2 +nanosleep.2 +poll.2 +sigaction.2 +sigreturn.2 +signal.7 + michael kerrisk + see also: add restart_syscall(2) + +open.2 + michael kerrisk [geoffrey thomas] + remove warning that o_directory is only for use with opendir(3) + o_directory can also be used with, for example, o_path. + +perf_event_open.2 + vince weaver + improve perf_sample_branch_stack documentation + vince weaver + fix indentation of the mmap layout section + the indentation of the mmap layout section wasn't quite right. + i think this improves things but i admit i'm not an expert at the + low-level indentation directives. + vince weaver + update perf_ioc_flag_group info + it turns out perf_ioc_flag_group was broken from 75f937f24bd9 + (in linux 2.6.31, the initial perf_event release) until + 724b6daa1 (linux 3.4). + + i've done some extensive kernel source code digging plus + running tests of various kernels and i hope the info + presented is accurate now. + + (patch edited somewhat by mtk.) + vince weaver + improve sysfs files documentation + this improves the documentation of the various + perf_event_open()-related sysfs files. + +ptrace.2 + denys vlasenko [oleg nesterov, dmitry v. levin] + if seize was used, initial auto-attach stop is event_stop + for every ptrace_o_tracefoo option, mention that old-style sigstop + is replaced by ptrace_event_stop if ptrace_seize attach was used. + + mention the same thing again in the description of + ptrace_event_stop. + denys vlasenko [oleg nesterov, dmitry v. levin] + mention that ptrace_peek* libc api and kernel api are different + denys vlasenko [oleg nesterov, dmitry v. levin] + clarify ptrace_interrupt, ptrace_listen, and group-stop behavior + +readlink.2 + michael kerrisk + document use of empty 'pathname' argument + michael kerrisk + change error check in example program from "< 0" to "== -1" + chuck coffing + fix possible race condition in readlink.2 example + i noticed that the example in the readlink.2 man pages does error + checking for a race condition that would cause the value of the + symbolic link to get larger. however, it doesn't handle the + opposite case, in which the value gets shorter. (the null + terminator is always set at the old, longer offset.) this could + cause the program to operate on uninitialized data. + +setpgid.2 + michael kerrisk [graud] + s/sigtstp/sigttin/ when discussing reads from terminal + see https://bugzilla.kernel.org/show_bug.cgi?id=60504 + +clog2.3 + michael kerrisk + note that these functions are still not present in glibc 2.17 + +dirfd.3 + peng haitao + attributes: note function that is thread-safe + the function dirfd() is thread safe. + +div.3 + peng haitao + attributes: note functions that are thread-safe + the functions div(), ldiv(), lldiv() and imaxdiv() are thread + safe. + +fabs.3 + peng haitao + attributes: note functions that are thread-safe + the functions fabs(), fabsf() and fabsl() are thread safe. + +fdim.3 + peng haitao + attributes: note functions that are thread-safe + the functions fdim(), fdimf() and fdiml() are thread safe. + +fflush.3 + peng haitao + attributes: note function that is thread-safe + the function fflush() is thread safe. + +finite.3 + peng haitao + attributes: note functions that are thread-safe + the functions finite(), finitef(), finitel(), isinf(), isinff(), + isinfl(), isnan(), isnanf() and isnanl() are thread safe. + +flockfile.3 + peng haitao + attributes: note functions that are thread-safe + the functions flockfile(), ftrylockfile() and funlockfile() are + thread safe. + +floor.3 + peng haitao + attributes: note functions that are thread-safe + the functions floor(), floorf() and floorl() are thread safe. + +resolv.conf.5 + simon paillard + explain how to set empty domain + see http://bugs.debian.org/463575 + +capabilities.7 + michael kerrisk + add open_by_handle_at(2) under cap_dac_read_search + +inotify.7 + michael kerrisk [felix schulte] + clarify description of in_moved_from and in_moved_to + +man-pages.7 + michael kerrisk + description should note versions for new interface features or behavior + +udp.7 + benjamin poirier + add missing #include directive + using the udp_cork socket option documented in udp.7 requires + including . + +ld.so.8 + michael kerrisk + rework rpath token expansion text + michael kerrisk + describe $platform rpath token + michael kerrisk + describe $lib rpath token + michael kerrisk + document ld_bind_not + michael kerrisk [simon paillard] + add reference to pthreads(7) in discussion of ld_assume_kernel + + +==================== changes in man-pages-3.54 ==================== + +released: 2013-09-17, munich + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +a. costa +akihiro motoki +andreas wiese +andrew hunter +chen gang +christopher hall +christos tsopokis +david prévot +d. barbier +doug goldstein +elie de brauwer +eugen dedu +felix janda +g.raud +hannes landeholm +j. bruce fields +j. bruce fields +johan erlandsson +jon grant +magnus reftel +marko myllynen +michael kerrisk +oleg nesterov +peng haitao +peter schiffer +robert harris +rodrigo campos +simon paillard +stas +vince weaver +will newton +zdenek pavlas +zsbán ambrus + +apologies if i missed anyone! + + + +newly documented interfaces in existing pages +--------------------------------------------- + +ioctl_list.2 + zsbán ambrus + document fat_ioctl_get_attributes + the attached patch adds four ioctls from linux/msdos_fs.h to the + ioctl_list(2) manpage. + + the ioctl fat_ioctl_get_attributes reads fat attributes of a + file a mounted vfat file system. i tested this on linux + 2.6.33, an example script can be found at + http://www.perlmonks.com/?node_id=832623 + + +global changes +-------------- + +various pages + michael kerrisk + global fix: s/file system/filesystem/ + notwithstanding 24d01c530c5a3f75217543d02bf6712395e5f90c, + "filesystem" is the form used by the great majority of man pages + outside the man-pages project and in a number of other sources, + so let's go with that. + + +changes to individual pages +--------------------------- + +access.2 + j. bruce fields + fix outdated nfs information + note that nfs versions since version 3 support an "access" call + so that the client doesn't have to guess permissions or id + mapping on its own. + + (see rfc 1813 sections 1.7 and 3.3.4.) + +adjtimex.2 + michael kerrisk + see also: add adjtimex(8) + +clock_getres.2 + michael kerrisk [rodrigo campos] + note circumstances in which "smp" note applies. + michael kerrisk + add kernel version for clock_*_cputime_id + clock_process_cputime_id and clock_thread_cputime_id + appeared in 2.6.12. + michael kerrisk + add versions section + +futex.2 + michael kerrisk + the 'timeout' can be rounded upwards by clock granularity and also overrun + +kill.2 + michael kerrisk + small improvements to text on historical rules for permissions + +nfsservctl.2 + michael kerrisk + note commands that were only in linux 2.4.x and earlier + +open.2 + robert harris + add mmap(2) to list of calls that fail when given an o_path descriptor + doug goldstein + add einval to errors list + einval can be returned by open(2) when the underlying filesystem + doesn't support o_direct. it is documented in the notes section + but this patch adds it to the list of possible errors. + +perf_event_open.2 + vince weaver + perf_sample_branch_stack updates + this started out as just adding the new perf_event_open features + from linux 3.11 (which was the addition of transactional memory + defines for perf_sample_branch_stack samples) but turned into a + general cleanup of the perf_sample_branch_stack documentation. + + the main clarification is that at least one of the non-privilege + values must be set or else perf_event_open() will return an einval + error. + michael kerrisk + reorder text describing fields of 'perf_event_header' structure + place the fields with the shorter descriptions first, to make the + information easier to read. + +poll.2 + michael kerrisk + clarify wording of 'timeout' as a "minimum" interval + +sched_setaffinity.2 + michael kerrisk [christos tsopokis] + clarify that these system calls affect a per-thread attribute + +sched_setparam.2 + michael kerrisk + clarify that this system call applies to threads (not processes) + +sched_setscheduler.2 + michael kerrisk + clarify that this system call applies to threads (not processes) + +select.2 + michael kerrisk [g.raud] + clarify wording of 'timeout' as a "minimum" interval + +setfsgid.2 + michael kerrisk [oleg nesterov] + clarify description of return value + more clearly describe the weirdness in the return value of this + system call, and note the problems it creates in bugs + michael kerrisk + correct header file in synopsis + michael kerrisk + refer to setfsuid(2) for an explanation of why setfsgid() is obsolete + michael kerrisk + wording improvements + +setfsuid.2 + michael kerrisk [oleg nesterov] + clarify description of return value + more clearly describe the weirdness in the return value of this + system call, and note the problems it creates in bugs + michael kerrisk [chen gang] + clarify historical details and note that setfsuid() is obsolete + michael kerrisk + wording improvements + michael kerrisk + correct header file in synopsis + +sigwaitinfo.2 + michael kerrisk + clarify wording of 'timeout' as a "minimum" interval + +syscall.2 + johan erlandsson + add missing argument in example + johan erlandsson + correct registers for arm/eabi + registers was off by one. + + reference: + http://www.arm.linux.org.uk/developer/patches/viewpatch.php?id=3105/4 + + see also: + http://peterdn.com/post/e28098hello-world!e28099-in-arm-assembly.aspx + https://wiki.debian.org/armeabiport + http://en.wikipedia.org/wiki/calling_convention#arm + +wait.2 + michael kerrisk [hannes landeholm] + add details on the fifth argument provided by raw waitid() system call + see https://bugzilla.kernel.org/show_bug.cgi?id=60744 + +clock.3 + michael kerrisk + clock() switched from using times(2) to clock_gettime() in glibc 2.18 + +drand48_r.3 + peng haitao + attributes: note functions that are thread-safe + the functions drand48_r(), erand48_r(), lrand48_r(), + nrand48_r(), mrand48_r(), jrand48_r(), srand48_r(), seed48_r(), + and lcong48_r() are thread safe. + +fma.3 + peng haitao + attributes: note functions that are thread-safe + the functions fma(), fmaf() and fmal() are thread safe. + +fmax.3 + peng haitao + attributes: note functions that are thread-safe + the functions fmax(), fmaxf() and fmaxl() are thread safe. + +fmin.3 + peng haitao + attributes: note functions that are thread-safe + the functions fmin(), fminf() and fminl() are thread safe. + +fpclassify.3 + peng haitao + attributes: note functions that are thread-safe + the functions fpclassify(), isfinite(), isnormal(), isnan(), and + isinf() are thread safe. + +frexp.3 + peng haitao + attributes: note functions that are thread-safe + the functions frexp(), frexpf() and frexpl() are thread safe. + +gethostbyname.3 + michael kerrisk [jon grant] + gai_strerror() is the modern replacement for herror() and hstrerror() + michael kerrisk + update feature test macro requirements for herror() and hstrerror() + michael kerrisk + add feature test macro requirements for h_errno + +ilogb.3 + peng haitao + attributes: note functions that are thread-safe + the functions ilogb(), ilogbf() and ilogbl() are thread safe. + +ldexp.3 + peng haitao + attributes: note functions that are thread-safe + the functions ldexp(), ldexpf() and ldexpl() are thread safe. + +lrint.3 + peng haitao + attributes: note functions that are thread-safe + the functions lrint(), lrintf(), lrintl(), llrint(), llrintf(), + and llrintl() are thread safe. + +lround.3 + peng haitao + attributes: note functions that are thread-safe + the functions lround(), lroundf(), lroundl(), llround(), + llroundf() and llroundl() are thread safe. + +lseek64.3 + peng haitao + attributes: note function that is thread-safe + the function lseek64() is thread safe. + +mbsinit.3 + peng haitao + attributes: note function that is thread-safe + the function mbsinit() is thread safe. + +nextafter.3 + peng haitao + attributes: note functions that are thread-safe + the functions nextafter(), nextafterf(), nextafterl(), + nexttoward(), nexttowardf() and nexttowardl() are thread safe. + +posix_memalign.3 + michael kerrisk [will newton] + 'errno" is indeterminate after a call to posix_memalign() + michael kerrisk [will newton] + clarify wording on "return value" when size==0 + +printf.3 + christopher hall + correctly describe the meaning of a negative precision + the printf(3) manpage says that a negative precision is taken to + be zero, whereas printf(3p) says that a negative precision is + taken as if the precision were omitted. glibc agrees with the + latter (posix) specification. + + test code: + + printf("%f\n",42.0); // "42.000000" + printf("%.*f\n",0,42.0); // "42" + printf("%.*f\n",-1,42.0); // "42.000000" + + this patch corrects the explanation to match what actually happens. + +rewinddir.3 + peng haitao + attributes: note function that is thread-safe + the function rewinddir() is thread safe. + +rint.3 + peng haitao + attributes: note functions that are thread-safe + the functions nearbyint(), nearbyintf(), nearbyintl(), rint(), + rintf() and rintl() are thread safe. + +seekdir.3 + peng haitao + attributes: note function that is thread-safe + the function seekdir() is thread safe. + +telldir.3 + peng haitao + attributes: note function that is thread-safe + the function telldir() is thread safe. + +wctomb.3 + peng haitao + attributes: note function that is not thread-safe + the function wctomb() is not thread safe. + +wavelan.4 + michael kerrisk [elie de brauwer] + this driver disappeared in 2.56.35 + +dir_colors.5 + michael kerrisk [stas] + add various synonyms + see http://bugs.debian.org/553477 + simon paillard [stas] + add keywords suid, sgid, sticky, sticky_other_writable, other_writable + see http://bugs.debian.org/553477 + see ls.c and dircolors.c in coreutils + +proc.5 + peter schiffer + document /proc/[pid]/io file + attempt to document fields in the /proc/[pid]/io file, based on + the documentation/filesystems/proc.txt. the text will probably + need some grammar corrections. + michael kerrisk [marko myllynen] + /proc/sys/fs/inode-max went away in linux 2.4 + also, the 'preshrink' field in /proc/sys/fs/inode-state became + a dummy value in linux 2.4. + + see https://bugzilla.kernel.org/show_bug.cgi?id=60836 + michael kerrisk [a. costa] + note block size used by /proc/partitions + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=666972 + michael kerrisk + add rationale on drop_caches and note that it can hurt performance + see also http://lwn.net/articles/562211/ + +bootparam.7 + michael kerrisk [eugen dedu] + remove "lilo" entries from see also + see http://bugs.debian.org/604019 + +inotify.7 + michael kerrisk + see also: add inotifywait(1) and inotifywatch(1) + +ip.7 + simon paillard + ip_multicast_if setsockopt recognizes struct mreq (compatibility) + kernel added compatibility only recently in + 3a084ddb4bf299a6e898a9a07c89f3917f0713f7 + see: http://bugs.debian.org/607979 + +standards.7 + michael kerrisk + add mention of susv4-tc1 (posix.1-2013) + + +==================== changes in man-pages-3.55 ==================== + +released: 2013-12-12, christchurch + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +alfred agrell +andreas sandberg +christoph hellwig +david gibson +david prévot +fabrice bauzac +greg price +jon grant +kosaki motohiro +liu jiaming +maxin b. john +michael kerrisk +paolo bonzini +peng haitao +robert p. j. day +rodrigo campos +shawn landden +trevor bramwell +vince weaver +yang yang +yuanhang zheng +yuri kozlov +janh + +apologies if i missed anyone! + + +global changes +-------------- + +assert.3 +assert_perror.3 +rexec.3 +rpc.3 + michael kerrisk [jon grant] + reword a sentence to use more gender-neutral language + + +changes to individual pages +--------------------------- + +execve.2 + michael kerrisk + 'arg...' for interpreter scripts starts with argv[1] + +fallocate.2 + christoph hellwig + clarify the zeroing behavior + fallocate() zeroes only space that did not previously contain + data, but leaves existing data untouched. + +futex.2 + rodrigo campos + fix link to rusty's futex example library + when i asked to webmaster@kernel.org, konstantin ryabitsev + answered that the ".nl." is "an obsolete scheme and really + should be changed to just ftp.kernel.org". + +getgroups.2 + michael kerrisk + note that ngroups_max is defined in + michael kerrisk + clarify that sysconf(_sc_ngroups_max) is a run-time technique + michael kerrisk + document /proc/sys/kernel/ngroups_max + +ioctl.2 + michael kerrisk [kosaki motohiro, david gibson] + 'request' argument is typed as 'unsigned long' in glibc + see https://bugzilla.kernel.org/show_bug.cgi?id=42705 + +perf_event_open.2 + vince weaver + linux 3.12 rdpmc/mmap + it turns out that the perf_event mmap page rdpmc/time setting was + broken, dating back to the introduction of the feature. due + to a mistake with a bitfield, two different values mapped to + the same feature bit. + + a new somewhat backwards compatible interface was introduced + in linux 3.12. a much longer report on the issue can be found + here: + https://lwn.net/articles/567894/ + vince weaver + linux 3.12 adds perf_sample_identifier + a new perf_sample_identifier sample type was added in linux 3.12. + vince weaver + e2big documentation + the following documents the e2big error return for + perf_event_open(). + + i actually ran into this error the hard way and it took me + half a day to figure out why my ->size value was changing. + vince weaver + linux 3.12 adds perf_event_ioc_id + a new perf_event related ioctl, perf_event_ioc_id, was added + in linux 3.12. + vince weaver + perf_count_sw_dummy support + support for the perf_count_sw_dummy event type was added in + linux 3.12. + vince weaver [andreas sandberg] + perf_event_ioc_period update + the perf_event_ioc_period ioctl was broken until 2.6.36, + and it turns out that the arm architecture has some + differing behavior too. + +pipe.2 + trevor bramwell + fix error in example program + +poll.2 + michael kerrisk [paolo bonzini] + clarify meaning of events==0 + events==0 does not mean that revents is always returned as + zero. the "output only" events (pollhup, pollerr, pollnval) + can still be returned. + + see https://bugzilla.kernel.org/show_bug.cgi?id=61911 + +readlink.2 + michael kerrisk [yuanhang zheng] + fix typo in error message in example program + +recv.2 + michael kerrisk + remove out-of-date statement that unix domain does not support msg_trunc + should have removed that sentence as part of + commit a25601b48b822eb1882ae336574b8d062a17e564 + +sched_get_priority_max.2 + michael kerrisk + add sched_idle to discussion + +send.2 + michael kerrisk + return value: these calls return number of bytes (not characters) sent + +setreuid.2 + michael kerrisk + small clarification to description of when saved set-user-id is set + +sigpending.2 + michael kerrisk + note treatment of signals that are blocked *and* ignored + +stat.2 + michael kerrisk + note filesystem support for nanosecond timestamps + add some detail on which native filesystems do and don't + support nanosecond timestamps. + michael kerrisk + cosmetic reworking of timestamp discussion in notes + michael kerrisk [yang yang] + update discussion of nanosecond timestamps + the existing text describes the timestamp fields as 'time_t' + and delegates discussion of nanosecond timestamps under notes. + nanosecond timestamps have been around for a while now, + and are in posix.1-2008, so reverse the orientation of the + discussion, putting the nanosecond fields into description + and detailing the historical situation under notes. + +symlink.2 + michael kerrisk + further fine tuning of argument names + follow-up to f2ae6dde0c68448bec986d12fe32268a2c98bfd9 + see https://sourceware.org/bugzilla/show_bug.cgi?id=16073 + michael kerrisk [fabrice bauzac] + give arguments of symlink() more meaningful names + +adjtime.3 + peng haitao + attributes: note function that is thread-safe + the function adjtime() is thread safe. + +alloca.3 + peng haitao + attributes: note function that is thread-safe + the function alloca() is thread safe. + +asinh.3 + peng haitao + attributes: note functions that are thread-safe + the functions asinh(), asinhf() and asinhl() are thread safe. + +atan.3 + peng haitao + attributes: note functions that are thread-safe + the functions atan(), atanf() and atanl() are thread safe. + +atof.3 + peng haitao + attributes: note function that is thread safe with exceptions + the function atof() is thread safe with exceptions. + +atoi.3 + peng haitao + attributes: note functions that are thread safe with exceptions + the functions atoi(), atol() and atoll() are thread safe with + exceptions. + +bcmp.3 + peng haitao + attributes: note function that is thread-safe + the function bcmp() is thread safe. + +bcopy.3 + peng haitao + attributes: note function that is thread-safe + the function bcopy() is thread safe. + +bsd_signal.3 + peng haitao + attributes: note function that is thread-safe + the function bsd_signal() is thread safe. + +bzero.3 + peng haitao + attributes: note function that is thread-safe + the function bzero() is thread safe. + +cbrt.3 + peng haitao + attributes: note functions that are thread-safe + the functions cbrt(), cbrtf() and cbrtl() are thread safe. + +copysign.3 + peng haitao + attributes: note functions that are thread-safe + the functions copysign(), copysignf() and copysignl() are thread + safe. + +cos.3 + peng haitao + attributes: note functions that are thread-safe + the functions cos(), cosf() and cosl() are thread safe. + +cproj.3 + peng haitao + attributes: note functions that are thread-safe + the functions cproj(), cprojf() and cprojl() are thread safe. + +creal.3 + peng haitao + attributes: note functions that are thread-safe + the functions creal(), crealf() and creall() are thread safe. + +daemon.3 + peng haitao + attributes: note function that is thread-safe + the function daemon() is thread safe. + +des_crypt.3 + peng haitao + attributes: note functions that are thread-safe + the functions ecb_crypt(), cbc_crypt() and des_setparity() are + thread safe. + +difftime.3 + peng haitao + attributes: note function that is thread-safe + the function difftime() is thread safe. + +dysize.3 + peng haitao + attributes: note function that is thread-safe + the function dysize() is thread safe. + +erf.3 + peng haitao + attributes: note functions that are thread-safe + the functions erf(), erff() and erfl() are thread safe. + +erfc.3 + peng haitao + attributes: note functions that are thread-safe + the functions erfc(), erfcf() and erfcl() are thread safe. + +euidaccess.3 + peng haitao + attributes: note functions that are thread-safe + the functions euidaccess() and eaccess() are thread safe. + +expm1.3 + peng haitao + attributes: note functions that are thread-safe + the functions expm1(), expm1f() and expm1l() are thread safe. + +fexecve.3 + michael kerrisk + posix.1-2008 specifies fexecve() + michael kerrisk + explain the use and rationale of fexecve() + +ftime.3 + peng haitao + attributes: note function that is thread-safe + the function ftime() is thread safe. + +ftok.3 + peng haitao + attributes: note function that is thread-safe + the function ftok() is thread safe. + +ftw.3 + michael kerrisk + nftw() visits directories with ftw_d if ftw_depth was not specified + michael kerrisk + explain probable cause of ftw_ns + +futimes.3 + peng haitao + attributes: note functions that are thread-safe + the functions futimes() and lutimes() are thread safe. + +getaddrinfo.3 + michael kerrisk + explain one use case for ai_addrconfig + michael kerrisk + highlight difference in ai_flags when hints==null + notes already described how glibc differs from posix. + add a pointer to that text from the point in description + where hints==null is discussed. + +kcmp.3 + shawn landden + reword slightly awkward section + +malloc.3 + greg price + scale back promises of alignment + it's not true that the return value is suitably aligned for "any + variable"; for example, it's unsuitable for a variable like + float *x __attribute__ ((__vector_size__ (32))); + which requires 32-byte alignment. types like this are defined in + , and with 16-byte alignment in and + , so the application programmer need not even know + that a vector_size attribute has been applied. + + on an x86 architecture, a program that loads from or stores to a + pointer with this type derived from malloc can crash because gcc + generates an aligned load/store, like movdqa. + + the c99 standard (tc3, as of n1256) does say the return value is + suitably aligned for "any type of object". the c11 standard (as + of n1570) revises this to any type with "fundamental alignment", + which means an alignment "supported by the implementation in all + contexts", which i suppose tautologically includes aligning + malloc/realloc return values. + + the actual behavior of current glibc malloc is to align to the + greater of 2 * sizeof(size_t) and __alignof__ (long double), + which may be one bit greater than this commit promises. + +mq_receive.3 + michael kerrisk [janh] + msg_len must be greater than *or equal to* mq_msgsize + see https://bugzilla.kernel.org/show_bug.cgi?id=64571 + +setenv.3 + michael kerrisk + clarify that setenv() returns success in the overwrite==0 case + +sigsetops.3 + michael kerrisk [robert p. j. day] + add 'const' to sigisemptyset(), sigorset(), sigandset() declarations + michael kerrisk + rework text describing sigisemptyset(), sigorset(), and sigandset() + +statvfs.3 + peng haitao + attributes: note functions that are thread-safe + the functions statvfs() and fstatvfs() are thread safe. + +stdarg.3 + peng haitao + attributes: note macros that are thread-safe + the macros va_start(), va_arg(), va_end() and va_copy() are + thread safe. + +termios.3 + peng haitao + attributes: note functions that are thread-safe + the functions tcgetattr(), tcsetattr(), tcsendbreak(), + tcdrain(), tcflush(), tcflow(), cfmakeraw(), cfgetispeed(), + cfgetospeed(), cfsetispeed(), cfsetospeed() and cfsetspeed() + are thread safe. + +ungetwc.3 + peng haitao + attributes: note function that is thread-safe + the function ungetwc() is thread safe. + +unlockpt.3 + peng haitao + attributes: note function that is thread-safe + the function unlockpt() is thread safe. + +usleep.3 + peng haitao + attributes: note function that is thread-safe + the function usleep() is thread safe. + +wcpcpy.3 + peng haitao + attributes: note function that is thread-safe + the function wcpcpy() is thread safe. + +wcscasecmp.3 + peng haitao + attributes: note function that is thread safe with exceptions + the function wcscasecmp() is thread safe with exceptions. + +wcscat.3 + peng haitao + attributes: note function that is thread-safe + the function wcscat() is thread safe. + +wcschr.3 + peng haitao + attributes: note function that is thread-safe + the function wcschr() is thread safe. + +wcscmp.3 + peng haitao + attributes: note function that is thread-safe + the function wcscmp() is thread safe. + +wcscpy.3 + peng haitao + attributes: note function that is thread-safe + the function wcscpy() is thread safe. + +wcscspn.3 + peng haitao + attributes: note function that is thread-safe + the function wcscspn() is thread safe. + +wcslen.3 + peng haitao + attributes: note function that is thread-safe + the function wcslen() is thread safe. + +wcsncasecmp.3 + peng haitao + attributes: note function that is thread safe with exceptions + the function wcsncasecmp() is thread safe with exceptions. + +wcsncat.3 + peng haitao + attributes: note function that is thread-safe + the function wcsncat() is thread safe. + +wcsncmp.3 + peng haitao + attributes: note function that is thread-safe + the function wcsncmp() is thread safe. + +wcsncpy.3 + peng haitao + attributes: note function that is thread-safe + the function wcsncpy() is thread safe. + +wcsnlen.3 + peng haitao + attributes: note function that is thread-safe + the function wcsnlen() is thread safe. + +wcspbrk.3 + peng haitao + attributes: note function that is thread-safe + the function wcspbrk() is thread safe. + +wcsrchr.3 + peng haitao + attributes: note function that is thread-safe + the function wcsrchr() is thread safe. + +wcsspn.3 + peng haitao + attributes: note function that is thread-safe + the function wcsspn() is thread safe. + +wcsstr.3 + peng haitao + attributes: note function that is thread-safe + the function wcsstr() is thread safe. + +wcstoimax.3 + peng haitao + attributes: note functions that are thread safe with exceptions + the functions wcstoimax() and wcstoumax() are thread safe with + exceptions. + +wcstok.3 + peng haitao + attributes: note function that is thread-safe + the function wcstok() is thread safe. + +wcswidth.3 + peng haitao + attributes: note function that is thread safe with exceptions + the function wcswidth() is thread safe with exceptions. + +wctrans.3 + peng haitao + attributes: note function that is thread safe with exceptions + the function wctrans() is thread safe with exceptions. + +wctype.3 + peng haitao + attributes: note function that is thread safe with exceptions + the function wctype() is thread safe with exceptions. + +wcwidth.3 + peng haitao + attributes: note function that is thread safe with exceptions + the function wcwidth() is thread safe with exceptions. + +wmemchr.3 + peng haitao + attributes: note function that is thread-safe + the function wmemchr() is thread safe. + +wmemcmp.3 + peng haitao + attributes: note function that is thread-safe + the function wmemcmp() is thread safe. + +wmemcpy.3 + peng haitao + attributes: note function that is thread-safe + the function wmemcpy() is thread safe. + +wmemmove.3 + peng haitao + attributes: note function that is thread-safe + the function wmemmove() is thread safe. + +wmemset.3 + peng haitao + attributes: note function that is thread-safe + the function wmemset() is thread safe. + +tty_ioctl.4 + michael kerrisk [liu jiaming] + note that 'arg' should be 0 in the usual case when using tiocsctty + michael kerrisk + rework text on root to discuss just in terms of capabilities + +proc.5 + michael kerrisk + document /proc/sys/kernel/ngroups_max + +capabilities.7 + michael kerrisk + fix 2 version numbers under "effect of user id changes on capabilities" + +feature_test_macros.7 + michael kerrisk + add _isoc11_source to example program + +tcp.7 + michael kerrisk + fix (nontrivial) wordo in discussion of msg_trunc + s/msg_peek/msg_trunc/ + +ld.so.8 + michael kerrisk [alfred agrell] + fix crufty wording in one sentence + + +==================== changes in man-pages-3.56 ==================== + +released: 2014-01-11, christchurch + +in memory of doris church (1939-2013) + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +andre majorel +arif zaman +bert wesarg +daniel borkmann +david malcolm +david prévot +dongsheng song +elie de brauwer +james smith +janne blomqvist +joseph s. myers +luke hutchison +marco dione +mathieu desnoyers +mathieu malaterre +matthias klose +michael kerrisk +mike frysinger +moritz 'morty' strübe +nadav har'el +ondřej bílka +prádraig brady +peng haitao +raphael geissert +shawn landden +simon paillard +stephen kell +sudhanshu goswami +sworddragon2 +vince weaver +willem de bruijn +yuri kozlov + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +fgetc.3 +gets.3 + david malcolm + split gets(3) to isolate unsafe gets(3) to a page on its own + currently man3/gets.3 documents various safe i/o functions, along + with the toxic "gets" function. + + at the risk of being melodramatic, this strikes me as akin to + storing rat poison in a food cabinet, in the same style of + packaging as the food, but with a post-it note on it saying + "see warnings below". + + i think such "never use this" functions should be quarantined + into their own manpages, rather than listing them alongside + sane functions. + + the attached patch does this for "gets", moving the documentation + of the good functions from man3/gets.3 into man3/fgetc.3, + updating the so links in the relevant functions to point at the + latter. + + it then rewrites man3/gets.3 to spell out that "gets" is toxic + and should never be used (with a link to cwe-242 for good + measure). + michael kerrisk [andre majorel] + tweaks to david malcolm's patch + +vdso.7 + mike frysinger + new page documenting the vdso mapped into each process by the kernel + + +newly documented interfaces in existing pages +--------------------------------------------- + +reboot.2 + elie de brauwer + document linux_reboot_sw_suspend + + +new and changed links +--------------------- + +fgets.3 +getc.3 +getchar.3 +ungetc.3 + michael kerrisk + adjust links to gets(3) to point to fgetc(3) + + +global changes +-------------- + +various pages + michael kerrisk + global fix of "null pointer" + change "null pointer" to "null" or null pointer". + posix uses the term "null pointer", not "null pointer". + +various pages + michael kerrisk + stylistic changes to code example + for ease of reading, don't embed assignments inside if(). + +various pages + michael kerrisk + replace uses of "i.e.," in main text with "that is" or similar + usual man-pages style is to use "i.e." only within + parenthetical expressions. + +various pages + michael kerrisk + replace uses of "e.g." in main text with "for example" or similar + usual man-pages style is to use "e.g." only within + parenthetical expressions. + +various pages + michael kerrisk + add "program source" subheading under example + +various pages + michael kerrisk + add "static" to global variables and functions in example program + + +changes to individual pages +--------------------------- + +clock_getres.2 + michael kerrisk [nadav har'el] + improve description of clock_process_cputime_id + see https://bugzilla.kernel.org/show_bug.cgi?id=67291 + +close.2 + michael kerrisk [p?draig brady] + note that errors from close() should be used only for diagnosis + in particular, retrying after eintr is a bad idea. + + see http://austingroupbugs.net/view.php?id=529 + + see http://thread.gmane.org/gmane.comp.lib.glibc.alpha/37702 + subject: [rfc][bz #14627] make linux close errno to einprogress + when interrupted in signal. + +execve.2 + michael kerrisk [marco dione] + add further cases to efault error + see https://sourceware.org/bugzilla/show_bug.cgi?id=16402 + +perf_event_open.2 + vince weaver [sudhanshu goswami] + clarify issues with the disabled bit + clarify the perf_event_open behavior with respect to the disabled + bit and creating event groups. + vince weaver [sudhanshu goswami] + clarify issues with the exclusive bit + warn that using the perf_event_open "exclusive" bit, while + it might seem like a good idea, might lead to all 0 results + in some common usage cases. + +reboot.2 + elie de brauwer + mention rb_power_off + the manpage did not mention rb_power_off which is the glibc + symbolic name for linux_reboot_cmd_power_off. + + $ cd /usr/include + $ cat x86_64-linux-gnu/sys/reboot.h | grep power_off + define rb_power_off 0x4321fedc + elie de brauwer + add "linux" to kernel version numbers + michael kerrisk + add rb_sw_suspend synonym + michael kerrisk + add rb_kexec synonym + +setpgid.2 + michael kerrisk [joseph s. myers] + bsd getpgrp() and setpgrp() go away in glibc 2.19 + +socket.2 + michael kerrisk [dongsheng song] + remove crufty statement that af_inet does not support sock_seqpacket + linux af_inet supports sock_seqpacket via sctp. + +syscall.2 + mike frysinger + fix ia64 registers + the original list of registers was created by confusing strace + source code--this is for parsing legacy 32-bit code (which is + dead and no one cares). update the list to reflect native ia64 + syscall interface. + +syscall.2 +syscalls.2 +getauxval.3 + mike frysinger + add references to new vdso(7) page + +utimensat.2 + michael kerrisk + small wording improvement for times!=null case + +dlopen.3 + michael kerrisk [mike frysinger] + update remarks on cast needed when assigning dlsym() return value + posix.1-2013 eases life when casting the dlsym() return value to a + function pointer + michael kerrisk [stephen kell] + fix description of dli_sname + see https://sourceware.org/bugzilla/show_bug.cgi?id=16262 + +getline.3 + michael kerrisk [luke hutchison] + correct description of how '*n' is used when '*lineptr' == null + see https://sourceware.org/bugzilla/show_bug.cgi?id=5468 + michael kerrisk + remove see also reference to unsafe gets(3) + +mcheck.3 + simon paillard [raphael geissert] + typo in compiler flag + see http://bugs.debian.org/732464 + +mkstemp.3 + michael kerrisk [janne blomqvist] + better describe 'flags' that can be specified for mkostemp() + +printf.3 + michael kerrisk [arif zaman] + fix memory leak in snprintf() example + see http://stackoverflow.com/questions/19933479/snprintf-man-page-example-memory-leak + +pthread_kill.3 + michael kerrisk [mathieu desnoyers] + posix.1-2008 removes esrch + posix.1-2001 mistakenly documented an esrch error, and + posix.1-2008 removes this error. glibc does return + this error in cases where it can determine that a thread id + is invalid, but equally, the use of an invalid thread id + can cause a segmentation fault. + +puts.3 + michael kerrisk + see also: replace reference to gets(3) with fgets(3) + +scanf.3 + michael kerrisk [ondřej bílka] + improve discussion of obsolete 'a' dynamic allocation modifier + +setjmp.3 + michael kerrisk [joseph s. myers] + bsd setjmp() semantics go away in glibc 2.19 + +sigpause.3 + michael kerrisk [joseph s. myers] + bsd sigpause() goes away in glibc 2.19 + michael kerrisk + correct feature text macro requirements + peng haitao + attributes: note function that is thread-safe + the function sigpause() is thread safe. + +sigqueue.3 + peng haitao + attributes: note function that is thread-safe + the function sigqueue() is thread safe. + +sigwait.3 + peng haitao + attributes: note function that is thread-safe + the function sigwait() is thread safe. + +sin.3 + peng haitao + attributes: note functions that are thread-safe + the functions sin(), sinf() and sinl() are thread safe. + +sincos.3 + peng haitao + attributes: note functions that are thread-safe + the functions sincos(), sincosf() and sincosl() are thread safe. + +string.3 + moritz 'morty' strübe + add short description of the functions + it is helpful to have a short description about what the different + functions in string.h do. + michael kerrisk + fixes and enhancements to moritz strübe's patch + +strptime.3 + michael kerrisk [mathieu malaterre, simon paillard] + add number ranges to comments in 'tm' structure + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=729570 + michael kerrisk + point to ctime(3) for more details on 'tm' structure + michael kerrisk + some rewording and reorganization + +strsep.3 + michael kerrisk + clarify description + the use of "symbols" in the existing description is confusing; + it's "bytes". other fixes as well. + +strspn.3 + michael kerrisk [mathieu malaterre] + improve description in name + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=723659 + +strstr.3 + michael kerrisk + clarify return value: s/substring/located substring/ + +sysv_signal.3 + peng haitao + attributes: note function that is thread-safe + the function sysv_signal() is thread safe. + +tan.3 + peng haitao + attributes: note functions that are thread-safe + the functions tan(), tanf() and tanl() are thread safe. + +tanh.3 + peng haitao + attributes: note functions that are thread-safe + the functions tanh(), tanhf() and tanhl() are thread safe. + +toascii.3 + peng haitao + attributes: note function that is thread-safe + the function toascii() is thread safe. + +toupper.3 + peng haitao + attributes: note functions that are thread safe with exceptions + the functions toupper() and tolower() are thread safe with + exceptions. + +towctrans.3 + peng haitao + attributes: note function that is thread-safe + the function towctrans() is thread safe. + +towlower.3 + peng haitao + attributes: note function that is thread safe with exceptions + the function towlower() is thread safe with exceptions. + +towupper.3 + peng haitao + attributes: note function that is thread safe with exceptions + the function towupper() is thread safe with exceptions. + +ualarm.3 + peng haitao + attributes: note function that is thread-safe + the function ualarm() is thread safe. + +wcpncpy.3 + peng haitao + attributes: note function that is thread-safe + the function wcpncpy() is thread safe. + +proc.5 + michael kerrisk [sworddragon2] + fix formula for commitlimit under /proc/meminfo + see https://bugzilla.kernel.org/show_bug.cgi?id=60991 + +credentials.7 + michael kerrisk + list apis that operate on process groups + michael kerrisk + add details on controlling terminal and foreground/background jobs + +feature_test_macros.7 + michael kerrisk + document _default_source + michael kerrisk [joseph s. myers] + from glibc 2.19, _bsd_source no longer causes __favor_bsd + starting with glibc 2.19, _bsd_source no longer causes bsd + definitions to be favored in cases where standards conflict. + +libc.7 + mike frysinger + see also: add various entries + +man-pages.7 + michael kerrisk [mike frysinger] + add style guide section + incorporate some of the existing material in the page + into the style guide, and add a lot more material, mainly + drawn from the "global changes" sections in the release + changelogs. + michael kerrisk + add historical note on reason for use of american spelling + michael kerrisk [mike frysinger] + various improvements to style guide + +packet.7 + willem de bruijn [daniel borkmann] + document fanout, ring, and auxiliary options + this patch adds descriptions of the common packet socket options + packet_auxdata, packet_fanout, packet_rx_ring, packet_statistics, + packet_tx_ring + and the ring-specific options + packet_loss, packet_reserve, packet_timestamp, packet_version + michael kerrisk + add kernel version numbers for packet_version and packet_timestamp + +ld.so.8 + michael kerrisk [matthias klose] + default output file for d_debug is stderr not stdout + see https://sourceware.org/bugzilla/show_bug.cgi?id=6874 + + + +==================== changes in man-pages-3.57 ==================== + +released: 2014-01-24, munich + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +andi kleen +andre majorel +andrey vagin +andy lutomirski +axel beckert +bernhard walle +brandon edens +eliezer tamir +gioele barabucci +ian abbott +jerry chu +jonas jonsson +marc lehmann +michael kerrisk +mike frysinger +peng haitao +reuben thomas +simone piccardi +simon paillard +thomas posch +tilman schmidt +vince weaver +yuri kozlov +марк коренберг + +apologies if i missed anyone! + + +newly documented interfaces in existing pages +--------------------------------------------- + +msgop.2 + michael kerrisk + document msg_copy + +open.2 + michael kerrisk, andy lutomirski + document o_tmpfile + o_tmpfile is new in linux 3.11 + +perf_event_open.2 + vince weaver [andi kleen] + perf_sample_transaction support in linux 3.13 + the following patch adds descriptions of the new perf_event_open.2 + perf_sample_transaction sample type as added in linux 3.13. + + the descriptions are based on information provided by andi kleen, + both in the e-mail + + [patch 1/6] perf, core: add generic transaction flags v5 + + sent to the linux-kernel list as well as an e-mail + + [patch] document transaction flags in perf_event_open manpage + + sent to the linux-man list. + + the implementation is based heavily on the intel haswell + processor. documentation can be found at this page: + http://software.intel.com/en-us/blogs/2013/05/03/intelr-transactional-synchronization-extensions-intelr-tsx-profiling-with-linux-0 + as well as in section 18.11.5.1 of volume 3 of the + intel 64 and ia-32 architecture software developer's manual. + +ptrace.2 + andrey vagin + add description for ptrace_peeksiginfo + retrieve signals without removing them from a queue. + andrey vagin + add description for ptrace_getsigmask and ptrace_setsigmask + these two commands allow to examine and change mask of blocked + signals. + +socket.7 + eliezer tamir + add description for so_busy_poll + add description for the so_busy_poll socket option. + +tcp.7 + michael kerrisk [jerry chu] + document tcp_user_timeout + text slightly adapted from jerry chu's (excellent) commit + message (commit dca43c75e7e545694a9dd6288553f55c53e2a3a3). + michael kerrisk + document tcp_congestion + + +global changes +-------------- + +various pages + michael kerrisk + reword to avoid use of "etc." + +various pages + peng haitao [andre majorel] + make wording around thread-safety and setlocale() more precise + +getdate.3 +strptime.3 +locale.5 + michael kerrisk + replace "weekday" with less ambiguous language + notwithstanding posix's use of the term "weekday", in everyday + english, "weekday" is commonly understood to mean a day in the + set [monday..friday] (vs one of the "weekend" days). + + +changes to individual pages +--------------------------- + +epoll_wait.2 + michael kerrisk [jonas jonsson] + clarify wording of eintr error + see https://bugzilla.kernel.org/show_bug.cgi?id=66571 + +faccessat.2 + michael kerrisk + note that the system call takes only three arguments + +fallocate.2 + michael kerrisk + note filesystems that support falloc_fl_punch_hole operation + +fcntl.2 + michael kerrisk + bugs: the o_sync and o_dsync flags are not modifiable using f_setfl + michael kerrisk + add subsections under bugs + there's several bugs listed. it's helpful to mark + them separately. + michael kerrisk + posix.1 specifies f_setown and f_getown for sockets/sigurg + +getrlimit.2 + michael kerrisk [марк коренберг] + note that rlim_cur can be set lower than current resource consumption + +getsockopt.2 + michael kerrisk + see also: add ip(7) and udp(7) + +keyctl.2 + michael kerrisk + see also: mention documentation/security/keys.txt + +linkat.2 + michael kerrisk + add enoent for o_tmpfile created with o_excl + michael kerrisk + errors: add einval + +lseek.2 + michael kerrisk + note which filesystems support seek_hole/seek_data + +msgop.2 + michael kerrisk + note that msg_except is linux-specific + +open.2 + michael kerrisk + update conforming to + add posix.1-2008. add mention of o_tmpfile. + update text on various flags that were added in posix.1-2008, and + whose definitions can, since glibc 2.12, be obtained by suitably + defining _posix_c_source or _xopen_source + michael kerrisk + add pointer in description to bugs, for o_async limitation + michael kerrisk + remove crufty duplicate text on modifying file status flags + +ptrace.2 + michael kerrisk + add details to descriptions of ptrace_getsigmask and ptrace_setsigmask + +select.2 + michael kerrisk [marc lehmann] + return value: fix discussion of treatment of file descriptor sets + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=574370 + +syscalls.2 + michael kerrisk + remove madvise1() from main list + madvise1() is one of the system calls that was never + implemented, and listed toward the bottom of the page. + +timer_create.2 + michael kerrisk + add pointer to proc(5) for info on /proc/[pid]/timers + +unlinkat.2 + michael kerrisk [mike frysinger:] + errors: add eisdir + see https://bugzilla.kernel.org/show_bug.cgi?id=29702 + +ferror.3 + michael kerrisk + clearerr(), feof(), and ferror() are also posix-conformant + michael kerrisk [reuben thomas] + conforming to: add fileno() + +gets.3 + ian abbott + see also: add fgets(3) + +mq_receive.3 +mq_send.3 + michael kerrisk [simone piccardi] + synopsis: s/unsigned/unsigned int/ + +printf.3 + michael kerrisk + small reorganization of text in example + +rand.3 + michael kerrisk + s/unsigned/unsigned int/ in example + +stpcpy.3 + peng haitao + attributes: note function that is thread-safe + the function stpcpy() is thread safe. + +stpncpy.3 + peng haitao + attributes: note function that is thread-safe + the function stpncpy() is thread safe. + +strcat.3 + peng haitao + attributes: note functions that are thread-safe + the functions strcat() and strncat() are thread safe. + +strchr.3 + peng haitao + attributes: note functions that are thread-safe + the functions strchr(), strrchr() and strchrnul() are thread safe. + +strcmp.3 + peng haitao + attributes: note functions that are thread-safe + the functions strcmp() and strncmp() are thread safe. + +strftime.3 + brandon edens + change "week day" to "day of week" + see https://bugzilla.kernel.org/show_bug.cgi?id=68861 + +strstr.3 + peng haitao + attributes: note function that is thread safe with exceptions + the function strstr() is thread safe. + the function strcasestr() is thread safe with exceptions. + +strtod.3 + peng haitao + attributes: note functions that are thread safe with exceptions + the functions strtod(), strtof() and strtold() are thread safe + with exceptions. + +strtoimax.3 + peng haitao + attributes: note functions that are thread safe with exceptions + the functions strtoimax() and strtoumax() are thread safe with + exceptions. + +strtol.3 + peng haitao + attributes: note functions that are thread safe with exceptions + the functions strtol(), strtoll() and strtoq() are thread safe + with exceptions. + +tcgetpgrp.3 + peng haitao + attributes: note functions that are thread-safe + the functions tcgetpgrp() and tcsetpgrp() are thread safe. + +tcgetsid.3 + peng haitao + attributes: note function that is thread-safe + the function tcgetsid() is thread safe. + +core.5 + bernhard walle + mention that %e exists since linux 3.0 + '%e' in the 'core_pattern' has been introduced in kernel commit + 57cc083ad9e1bfeeb4a0ee831e7bb008c8865bf0 which was included in + version 3.0. add that information to the manual page. + +filesystems.5 + michael kerrisk [axel beckert] + add reference to proc(5) for more details on /proc/filesystems + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=735590 + +locale.5 + michael kerrisk + see also: add locale(7) + +proc.5 + michael kerrisk + document /proc/[pid]/timers + michael kerrisk + update discussion of wchan + remove crufty reference to /etc/psdatabase in /proc/pid/stat. + add /proc/pid/wchan. + + see https://bugs.launchpad.net/ubuntu/+source/manpages/+bug/737452 + +environ.7 + michael kerrisk [gioele barabucci] + correct reference to locale(7) (not locale(5)) + locale(7) is the right place for details of the lc_* + environment variables. + + see http://bugs.debian.org/638186 + michael kerrisk + improve references for discussion of locale environment variables + michael kerrisk + see also: add catopen(3) + michael kerrisk + see also: add locale(5) + +man-pages.7 + michael kerrisk + prefer "usable" over "useable" + +netdevice.7 + tilman schmidt + document siocgifconf case ifc_req==null + add the missing description of the possibility to call siocgifconf + with ifc_req==null to determine the needed buffer size, as + described in + http://lkml.indiana.edu/hypermail/linux/kernel/0110.1/0506.html + and verified against source files net/core/dev_ioctl.c and + net/ipv4/devinet.c in the current kernel git tree. + this functionality has been present since the beginning of the 2.6 + series. it's about time it gets documented. + + while i'm at it, also generally clarify the section on + siocgifconf. + +standards.7 + michael kerrisk + enhance description of v7 + michael kerrisk + add c11 + +tcp.7 + michael kerrisk + describe format of tcp_*_congestion_control /proc files + describe format of tcp_allowed_congestion_control and + tcp_available_congestion_control. + + +==================== changes in man-pages-3.58 ==================== + +released: 2014-02-11, munich + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +cyril hrubis +daniel borkmann +david prévot +fabrice bauzac +michael kerrisk +mike frysinger +network nut +ola olsson +peng haitao +peter schiffer +simone piccardi +simon paillard +yuri kozlov +марк коренберг +未卷起的浪 + +apologies if i missed anyone! + + +newly documented interfaces in existing pages +--------------------------------------------- + +pipe.2 + michael kerrisk + document the pipe2() o_direct flag added in linux 3.4 + +packet.7 + daniel borkmann + document packet_qdisc_bypass + new in linux 3.14. + + +global changes +-------------- + +various pages + simon paillard + formatting fix: add space between function and () if br or ir + detected through the regex: + git grep -p '^\.(br|ir) [\w]*\([\d]*\)$' + +various pages + simon paillard + formatting fix: add space between word and punctuation if br or ir + detected through the regex: + git grep -p '^\.(br|ir) [^ ]*[,\.]$' + + could probably be extended to match more cases and fix in perl. + +various pages + michael kerrisk + use oxford comma + +gettid.2 +restart_syscall.2 +passwd.5 +socket.7 + michael kerrisk + fix order of see also entries + + +changes to individual pages +--------------------------- + +epoll_wait.2 + michael kerrisk [network nut] + remove word "minimum" from the description of 'timeout' + +epoll_wait.2 +poll.2 +select.2 + michael kerrisk + go into more detail on timeout and when call will cease blocking + +getxattr.2 +listxattr.2 +removexattr.2 +setxattr.2 + michael kerrisk [fabrice bauzac] + correct header file is (not ) + see https://bugzilla.kernel.org/show_bug.cgi?id=70141 + +msgctl.2 + cyril hrubis + add note about ignored arg to ipc_rmid + +prctl.2 + michael kerrisk [марк коренберг] + pr_set_pdeathsig value is preserved across execve(2) + +recv.2 + michael kerrisk + rework and reorganize the text in various parts of the page. + isolate details specific to recv() vs recvfrom() vs recvmsg() + place details specific to each system call under a + separate subheading. + rework discussion of 'src_addr' and 'addrlen' for recvfrom() + add description of 'buf' and 'len' in recvfrom() section + 'addrlen' should be 0 (*not* null) when 'src_addr' is null + improve text describing recvfrom() call that is equivalent to recv() + michael kerrisk [未卷起的浪] + describe the various cases where the return value can be 0 + +shmctl.2 + michael kerrisk + note that 'buf' is ignored for ipc_rmid + +symlinkat.2 + michael kerrisk + make argument names consistent with symlink(2) page + +isalpha.3 + peng haitao + attributes: note functions that are thread-safe + the functions isalnum(), isalpha(), isascii(), isblank(), + iscntrl(), isdigit(), isgraph(), islower(), isprint(), + ispunct(), isspace(), isupper() and isxdigit() are thread safe. + +isatty.3 + peng haitao + attributes: note function that is thread-safe + the function isatty() is thread safe. + +isgreater.3 + peng haitao + attributes: note macros that are thread-safe + the macros isgreater(), isgreaterequal(), isless(), + islessequal(), islessgreater() and isunordered() are thread safe. + +iswalnum.3 + peng haitao + attributes: note function that is thread safe with exceptions + the function iswalnum() is thread safe with exceptions. + +iswalpha.3 + peng haitao + attributes: note function that is thread safe with exceptions + the function iswalpha() is thread safe with exceptions. + +iswblank.3 + peng haitao + attributes: note function that is thread safe with exceptions + the function iswblank() is thread safe with exceptions. + +iswcntrl.3 + peng haitao + attributes: note function that is thread safe with exceptions + the function iswcntrl() is thread safe with exceptions. + +lockf.3 + michael kerrisk [simone piccardi] + fix incorrect argument mentioned under einval error + +pthread_kill.3 + michael kerrisk + add feature test macro requirements + +pthread_sigmask.3 + michael kerrisk + add feature test macro requirements + +strtoul.3 + peng haitao + attributes: note functions that are thread safe with exceptions + the functions strtoul(), strtoull() and strtouq() are thread safe + with exceptions. + +nscd.conf.5 + peter schiffer + add note about default values + +proc.5 + michael kerrisk + see also: add some further kernel documentation/sysctl files + +man-pages.7 + michael kerrisk + attributes sections come after versions + peng haitao has consistently ordered the attributes after + versions, so adjust the text in man-pages.7 + +vdso.7 + michael kerrisk + add words "virtual dynamic shared object" in description + + +==================== changes in man-pages-3.59 ==================== + +released: 2014-02-16, munich + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +michael kerrisk +peter schiffer +weizhou pan + +apologies if i missed anyone! + + +global changes +-------------- + +various pages + peter schiffer, michael kerrisk [weizhou pan] + convert pages containing non-ascii in source code comments to use utf-8 + done using a slightly modified version of peter schiffer's + convert_to_utf_8.sh script. the script was modified so as *not* + a "coding:" marker to the groff source. for now, we'll only put + that marker on pages that contain non-ascii characters in the + rendered text. + + see https://bugzilla.kernel.org/show_bug.cgi?id=60807 + +armscii-8.7 +cp1251.7 +iso_8859-1.7 +iso_8859-10.7 +iso_8859-11.7 +iso_8859-13.7 +iso_8859-14.7 +iso_8859-15.7 +iso_8859-16.7 +iso_8859-2.7 +iso_8859-3.7 +iso_8859-4.7 +iso_8859-5.7 +iso_8859-6.7 +iso_8859-7.7 +iso_8859-8.7 +iso_8859-9.7 +koi8-r.7 +koi8-u.7 + peter schiffer, michael kerrisk [weizhou pan] + convert pages containing non-ascii to use utf-8 + done using peter schiffer's convert_to_utf_8.sh script. + these pages containing non-ascii in the rendered characters, and + so the script inserts a "coding:" marker into the groff source. + + see https://bugzilla.kernel.org/show_bug.cgi?id=60807 + + +==================== changes in man-pages-3.60 ==================== + +released: 2014-02-18, munich + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +david prévot +d. barbier +kalle olavi niemitalo +michael kerrisk +simon paillard + +apologies if i missed anyone! + + +changes to individual pages +--------------------------- +sigvec.3 + michael kerrisk [kalle olavi niemitalo] + fix error in code snippet + s/sigpause/sigmask/ + +armscii-8.7 +cp1251.7 +iso_8859-1.7 +iso_8859-10.7 +iso_8859-11.7 +iso_8859-13.7 +iso_8859-14.7 +iso_8859-15.7 +iso_8859-16.7 +iso_8859-2.7 +iso_8859-3.7 +iso_8859-4.7 +iso_8859-5.7 +iso_8859-6.7 +iso_8859-7.7 +iso_8859-8.7 +iso_8859-9.7 +koi8-u.7 + michael kerrisk [simon paillard] + remove comment that glyphs in column 4 may not display correctly + with the conversion to utf-8, the glyphs in column 4 of the + tables in these pages will display regardless of whether the + environment is configured for the corresponding character set. + +iso_8859-11.7 +iso_8859-13.7 + d. barbier [simon paillard] + fix encoding mistakes in 5f7f4042b8848127d852c6fa7c02e31ccfaeeae5 + fixed via: + + for f in iso_8859-11 iso_8859-13; do + cp man7/$f.7 $f + iconv -f utf8 -t latin1 $f | iconv -f iso-${f#iso_} -t utf8 > man7/$f.7 + done + + + + +==================== changes in man-pages-3.61 ==================== + +released: 2014-02-26, munich + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +andrew hunter +carlos o'donell +christoph hellwig +daniel borkmann +duncan de wet +kir kolyshkin +kosaki motohiro +michael kerrisk +neil horman +peng haitao +simon paillard +sulaiman mustafa +xiawei chen + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +a note from christoph hellwig prompted me to perform a task that has +been queued for a while: merging the text of the man pages for the +*at([23]) ("directory file descriptor") apis into their corresponding +traditional pages. when the *at([23]) pages were originally written +(mostly in 2006), the apis were not part of posix and (in most cases) +were not available on other systems. so, it made some sense to wall +them off into their own separate pages. eight years later, with the +apis now all in posix (except scandirat()), it is much more sensible +to document the newer apis alongside their traditional counterparts, +so that the newer apis are not "hidden", and the reader can more +easily see the differences between the apis. + +thus, the text of 14 pairs of pages has been merged, and the "merged +from" pages have been converted to links to the "merged to" pages. +along the way, a few other fixes were made to the pages, as noted +below. + +one page that did not undergo such a change was utimensat(2), which +is different enough from utime(2) that it warrants a separate page. +unlike the other *at() pages, the utimensat(2) page was also already +self-contained, rather than defining itself in terms of differences +from utime(2) as the other *at() pages did. + +access.2 + michael kerrisk + merge text from faccessat(2) + michael kerrisk + remove faccessat() race warning + that point is already covered in existing text in this page. + michael kerrisk + access() also conforms to posix.1-2008 + +chmod.2 + michael kerrisk + merge text from fchmodat(2) + michael kerrisk + use argument name 'pathname' throughout page + (some apis were using 'path' while others used 'pathname') + michael kerrisk + conforming to: chmod() and fchmod() are also in posix.1-2008 + +chown.2 + michael kerrisk + merge text of fchownat(2) + michael kerrisk + at_empty_path is linux-specific and requires _gnu_source + michael kerrisk + use argument name 'pathname' throughout page + (some apis were using 'path' while others used 'pathname') + michael kerrisk + remove sentence that fchownat() is present on solaris + that point was only really relevant before fchownat() was + standardized in posix.1.2008. + michael kerrisk + conforming to: chown(), fchown(), lchown() are in posix.1-2008 + +link.2 + michael kerrisk + merge text of linkat(2) + michael kerrisk + conforming to: link() is in posix.1-2008 + michael kerrisk + at_empty_path is linux-specific and requires _gnu_source + +mkdir.2 + michael kerrisk + merge text of mkdirat(2) + michael kerrisk + conforming to: mkdir() is in posix.1-2008 + +mknod.2 + michael kerrisk + merge text of mknodat(2) + michael kerrisk + conforming to: mknod(2) is in posix.1-2008 + +open.2 + michael kerrisk + merge text from openat(2) + michael kerrisk + remove sentence that openat() is present on solaris + that point was only really relevant before openat() was + standardized in posix.1.2008. + +readlink.2 + michael kerrisk + merge text of readlinkat(2) + michael kerrisk + conforming to: readlink() is in posix.1-2008. + michael kerrisk + use argument name 'pathname' throughout page + (some apis were using 'path' while others used 'pathname') + +rename.2 + michael kerrisk + merge text of renameat(2) + michael kerrisk + conforming to: rename(2) is in posix.1-2008 + +stat.2 + michael kerrisk + merge text from fstatat(2) + michael kerrisk + at_empty_path and at_no_automount are linux-specific + these flags require _gnu_source. + michael kerrisk + use argument name 'pathname' throughout page + (some apis were using 'path' while others used 'pathname') + michael kerrisk + remove sentence that fstatat() is present on solaris + that point was only really relevant before fstatat() was + standardized in posix.1.2008. + michael kerrisk + conforming to: stat(), fstat(), lstat() are specified in posix.1-2008 + +symlink.2 + michael kerrisk + merge text of symlinkat(2) + michael kerrisk + conforming to: symlink() is in posix.1-2008 + +unlink.2 + michael kerrisk + merge text of unlinkat(2) + michael kerrisk + remove sentence that unlinkat() is present on solaris + that point was only really relevant before unlinkat() was + standardized in posix.1.2008. + michael kerrisk + conforming to: unlink() is in posix.1-2008 + +mkfifo.3 + michael kerrisk + merge text of mkfifoat(3) + michael kerrisk + conforming to: mkfifo() is in posix.1-2008 + +scandir.3 + michael kerrisk + merge text of scandirat(3) + michael kerrisk + update feature test macro requirements + the ftm requirements changed in glibc 2.10. + michael kerrisk + remove libc4/libc5 note under conforming to + no-one much cares about linux libc these days. + michael kerrisk + put detail about alphasort under a notes heading + this text was under conforming to, which made no sense. + michael kerrisk + rework conforming to text + + +newly documented interfaces in existing pages +--------------------------------------------- + +prctl.2 + kir kolyshkin + document pr_set_mm options in linux 3.5 + some of the pr_set_mm options were merged to vanilla kernel + later, and appeared in linux 3.5. those are: + + - pr_set_mm_arg_start + - pr_set_mm_arg_end + - pr_set_mm_env_start + - pr_set_mm_env_end + - pr_set_mm_auxv + - pr_set_mm_exe_file + +socket.7 + neil horman + document the so_rxq_ovfl socket option + michael kerrisk + add kernel version number for so_rxq_ovfl + + +new and changed links +--------------------- + +faccessat.2 + michael kerrisk + convert to link to access.2 + +fchmodat.2 + michael kerrisk + convert to link to chmod.2 + +fchownat.2 + michael kerrisk + convert to link to chown.2 + +fstatat.2 + michael kerrisk + convert to link to stat.2 + +linkat.2 + michael kerrisk + convert to link to link.2 + +mkdirat.2 + michael kerrisk + convert to link to mkdir.2 + +mknodat.2 + michael kerrisk + convert to link to mknod.2 + +openat.2 + michael kerrisk + convert to link to open.2 + +readlinkat.2 + michael kerrisk + convert to link to symlink.2 + +renameat.2 + michael kerrisk + convert to link rename.2 + +symlinkat.2 + michael kerrisk + convert to link to symlink.2 + +unlinkat.2 + michael kerrisk + convert to link to unlink.2 + +mkfifoat.3 + michael kerrisk + convert to link to mkfifo.3 + +scandirat.3 + michael kerrisk + convert to link to scandir.3 + + +changes to individual pages +--------------------------- + +alarm.2 + michael kerrisk + note semantics of alarm with respect to fork() and execve() + +fcntl.2 + michael kerrisk + warn that f_getlk info may already be out of date when the call returns + +intro.2 + michael kerrisk + describe policy on documenting differences between syscall and glibc api + +mmap2.2 + michael kerrisk + reword note on glibc mmap() wrapper invocation of mmap2() + michael kerrisk + this system call does not exist on x86-64 + +msgctl.2 + michael kerrisk + errors: add eperm for unprivileged attempt to set msg_qbytes > msgmnb + +prctl.2 + michael kerrisk [xiawei chen] + clarify that pr_get_timerslack is returned as the function result + michael kerrisk + clarify that pr_get_seccomp is returned as function result + michael kerrisk + clarify that pr_get_no_new_privs is returned as function result + +ptrace.2 + michael kerrisk [andrew hunter] + make it clearer that glibc and syscall apis differ for ptrace_peek* + thanks to denys vlasenko's additions in 78686915aed6bd12 + this page does note that the glibc api for ptrace_peek* + differs from the raw syscall interface. but, as the report + at https://bugzilla.kernel.org/show_bug.cgi?id=70801 shows, + this information could be more obvious. this patch makes its so. + +sgetmask.2 + michael kerrisk + note that these system calls don't exist on x86-64 + +swapon.2 + michael kerrisk + split einval cases into separate entries under errors + michael kerrisk + add einval error for invalid flags to swapon() + +syscalls.2 + michael kerrisk + see also: add intro(2) + +umount.2 + michael kerrisk + split einval cases into separate items + michael kerrisk + errors: add einval case that was new in 2.6.34 + +utime.2 + michael kerrisk + add note that modern applications probably want utimensat(2) etc. + +crypt.3 + michael kerrisk [kosaki motohiro] + errors: add einval and eperm errors + see https://bugzilla.kernel.org/show_bug.cgi?id=69771 + +getifaddrs.3 + michael kerrisk + enhance example program + print statistics for af_packet interfaces. + add missing feature test macro definition. + reformat output. + +iswctype.3 + peng haitao + attributes: note function that is thread-safe + the function iswctype() is thread safe. + +sem_post.3 + peng haitao + attributes: note function that is thread-safe + the function sem_post() is thread safe. + +sem_unlink.3 + peng haitao + attributes: note function that is thread-safe + the function sem_unlink() is thread safe. + +sem_wait.3 + peng haitao + attributes: note functions that are thread-safe + the functions sem_wait(), sem_trywait() and sem_timedwait() are + thread safe. + +setbuf.3 + peng haitao + attributes: note functions that are thread-safe + the functions setbuf(), setbuffer(), setlinebuf() and setvbuf() + are thread safe. + +strlen.3 + peng haitao + attributes: note function that is thread-safe + the function strlen() is thread safe. + +strnlen.3 + peng haitao + attributes: note function that is thread-safe + the function strnlen() is thread safe. + +strpbrk.3 + peng haitao + attributes: note function that is thread-safe + the function strpbrk() is thread safe. + +strsep.3 + peng haitao + attributes: note function that is thread-safe + the function strsep() is thread safe. + +swab.3 + peng haitao + attributes: note function that is thread-safe + the function swab() is thread safe. + +resolv.conf.5 + carlos o'donell + description: mention that the data is trusted + in a recent discussion about dnssec it was brought to my + attention that not all system administrators may understand + that the information in /etc/resolv.conf is fully trusted. + the resolver implementation in glibc treats /etc/resolv.conf + as a fully trusted source of dns information and passes on + the ad-bit for dnssec as trusted. + + this patch adds a clarifying sentence to make it absolutely + clear that indeed this source of information is trusted. + +ascii.7 + michael kerrisk [sulaiman mustafa] + fix rendering of single quote (decimal character 39) + michael kerrisk + see also: add utf-8(7) + michael kerrisk [duncan de wet] + remove mention of iso 8859-1 as being the default encoding on linux + +packet.7 + neil horman + document packet_fanout_qm fanout mode + michael kerrisk + add kernel version for packet_fanout_qm + daniel borkmann + improve packet_qdisc_bypass description + +socket.7 + michael kerrisk + add kernel version number for so_busy_poll + + +==================== changes in man-pages-3.62 ==================== + +released: 2014-03-11, munich + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +cyril hrubis +joseph s. myers +marius gaubas +michael kerrisk +mike frysinger +peng haitao +rick stanley +simon paillard + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +locale.1 + michael kerrisk [review from mike frysinger] + new page describing locale(1) + + +newly documented interfaces in existing pages +--------------------------------------------- + +locale.5 + michael kerrisk + document lc_address + michael kerrisk + document lc_identification + michael kerrisk + document lc_measurement + michael kerrisk + document lc_name + michael kerrisk + document lc_paper + michael kerrisk + document lc_telephone + + +removed pages +------------- + +sync.8 + michael kerrisk [christoph hellwig, pádraig brady] + sometime in the 20th century (before my watch), a sync(8) + page into man-pages. it documents the sync command from + "fileutils", which long ago become coreutils, and the + piece under notes note some behavior of sync(2) + that ceased to be true many years ago. the man-pages + project generally focuses on only linux kernel and + (g)libc interfaces, so this sync(8) page doesn't really + belong. furthermore, coreutils has a sync(1) page which + covers the same command. after discussions on the + coreutils list, i've decided to retire this page from + man-pages. + +changes to individual pages +--------------------------- + +clone.2 + michael kerrisk + note that clone_thread also in effect requires clone_vm + +stat.2 + michael kerrisk [marius gaubas] + warn the reader that the 'stat' structure definition is not precise + padding fields aren't shown, and the order of fields varies + somewhat across architectures. + +gethostbyname.3 + michael kerrisk + remove redundant ftm requirements + _gnu_source implies _svid_source and _bsd_source, so + + _bsd_source || _svid_source || _gnu_source + + is the same as + + _bsd_source || _svid_source + +getutmp.3 + michael kerrisk + see also: add utmpdump(1) + +log1p.3 + peng haitao + attributes: note functions that are thread-safe + the functions log1p(), log1pf() and log1pl() are thread safe. + +logb.3 + peng haitao + attributes: note functions that are thread-safe + the functions logb(), logbf() and logbl() are thread safe. + +memccpy.3 + peng haitao + attributes: note function that is thread-safe + the function memccpy() is thread safe. + +memchr.3 + peng haitao + attributes: note functions that are thread-safe + the functions memchr(), memrchr() and rawmemchr() are thread safe. + +mktemp.3 + michael kerrisk + make warning not to use this function more prominent + +qecvt.3 + michael kerrisk [joseph s. myers] + recommend snprintf(3) not sprintf(3) + +raise.3 + peng haitao + attributes: note function that is thread-safe + the function raise() is thread safe. + +remove.3 + peng haitao + attributes: note function that is thread-safe + the function remove() is thread safe. + +sem_destroy.3 + peng haitao + attributes: note function that is thread-safe + the function sem_destroy() is thread safe. + +sem_getvalue.3 + peng haitao + attributes: note function that is thread-safe + the function sem_getvalue() is thread safe. + +sem_init.3 + peng haitao + attributes: note function that is thread-safe + the function sem_init() is thread safe. + +sockatmark.3 + peng haitao + attributes: note function that is thread-safe + the function sockatmark() is thread safe. + +strcpy.3 + peng haitao + attributes: note functions that are thread-safe + the functions strcpy() and strncpy() are thread safe. + michael kerrisk [rick stanley] + fix a bug, and improve discussion of forcing termination with strncpy() + +strspn.3 + peng haitao + attributes: note functions that are thread-safe + the functions strspn() and strcspn() are thread safe. + +tempnam.3 + michael kerrisk + make warning not to use this function more prominent + +tmpnam.3 + michael kerrisk + recommend use mkstemp(3) or tmpfile(3) instead + +locale.5 + michael kerrisk + add intro section that lists all of the lc categories + michael kerrisk + 'p_cs_precedes' is for *positive* values + michael kerrisk + clarify 'p_sign_posn' and 'n_sign_posn'; simplify 'n_sign_posn' + add initial sentence for 'p_sign_posn' and 'n_sign_posn'. + remove repeated list for 'n_sign_posn'. + michael kerrisk + document lc_messages 'yesstr' and 'nostr' + michael kerrisk + clarify lc_monetary 'n_cs_precedes' + michael kerrisk + lc_monetary: document 'int_p_sign_posn' and 'int_n_sign_posn' + michael kerrisk + clarify/rework 'p_cs_precedes' and 'n_cs_precedes' + michael kerrisk + lc_monetary: document 'int_p_sep_by_space' and 'int_n_sep_by_space' + michael kerrisk + remove crufty reference to posix.2 + michael kerrisk + lc_monetary: document 'int_p_cs_precedes' and 'int_n_cs_precedes' + michael kerrisk + clarify/simplify 'n_sep_by_space' + michael kerrisk + lc_time: document 'cal_direction' and 'date_fmt' + michael kerrisk + clarify 'p_sep_by_space' + +feature_test_macros.7 + michael kerrisk + _bsd_source and _svid_source are deprecated in glibc 2.20 + michael kerrisk + _gnu_source implicitly defines other macros + saying that _gnu_source has the "effects of" other macros is not + quite precise. + michael kerrisk + reword glibc version for _isoc95_source + michael kerrisk + _isoc99_source also exposes c95 definitions + michael kerrisk + _isoc11_source implies the effects of _isoc99_source + michael kerrisk + note version number for _posix_c_source >= 200112l implies c99/c95 + _posix_c_source >= 200112l causes c95 definitions to be + exposed only since glibc 2.12 and c99 definitions only + since 2.10. + michael kerrisk + _xopen_source may implicitly define _posix_source and _posix_c_source + michael kerrisk + reword glibc version for _isoc99_source + michael kerrisk + rework discussion of _isoc99_source + michael kerrisk + improve discussion of _default_source + michael kerrisk + _posix_c_source >= 200112l implies c95 and c95 features + + + +==================== changes in man-pages-3.63 ==================== + +released: 2014-03-18, munich + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +carlos o'donell +christoph hellwig +corrado zoccolo +gregory p. smith +joseph s. myers +michael kerrisk +mike frysinger +peng haitao +phillip susi +robert p. j. day +stefan puiu +zhu yanhai + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +duplocale.3 + michael kerrisk + new page documenting duplocale(3) + +newlocale.3 + michael kerrisk [mike frysinger] + new page documenting newlocale(3) and freelocale(3) + +towlower.3 + michael kerrisk + largely rewrite description of towlower() to be simpler and clearer + +towupper.3 + michael kerrisk + largely rewrite description of towupper() to be simpler and clearer + +uselocale.3 + michael kerrisk + new page documenting uselocale(3) + + +newly documented interfaces in existing pages +--------------------------------------------- + +open.2 + michael kerrisk + document o_dsync and rewrite discussion of o_sync + +isalpha.3 + michael kerrisk + document the "_l" locale apis + the gnu c library v2.3 added some locale apis, most of which + were later specified in posix.1-2008, namely: + + isalnum_l() + isalpha_l() + isblank_l() + iscntrl_l() + isdigit_l() + isgraph_l() + islower_l() + isprint_l() + ispunct_l() + isspace_l() + isupper_l() + isxdigit_l() + isascii_l() + + also update and correct various pieces in conforming to + (and remove a few crufty old pieces there). + +strerror.3 + michael kerrisk + document strerror_l() + +toupper.3 + michael kerrisk + document toupper_l() and tolower_l() + +towlower.3 + michael kerrisk + document towlower_l() + +towupper.3 + michael kerrisk + document towupper_l() + +proc.5 + michael kerrisk + document /proc/sys/kernel/random/uuid + +locale.7 + michael kerrisk + document lc_address + document lc_identification + document lc_measurement + document lc_name + document lc_paper + document lc_telephone + + +new and changed links +--------------------- + +freelocale.3 + michael kerrisk + new link to new newlocale.3 page + +isalnum_l.3 +isascii_l.3 +isblank_l.3 +iscntrl_l.3 +isdigit_l.3 +isgraph_l.3 +islower_l.3 +isprint_l.3 +ispunct_l.3 +isspace_l.3 +isupper_l.3 +isxdigit_l.3 + michael kerrisk + new links to isalpha.3 + +tolower_l.3 +toupper_l.3 + michael kerrisk + new links to toupper.3 + +towlower_l.3 + michael kerrisk + new link to towlower.3 + +towupper_l.3 + michael kerrisk + new link to towupper.3 + + +global changes +-------------- + +various pages + michael kerrisk + global change: "upper case" ==> "uppercase", "lower case" ==> lowercase" + + +changes to individual pages +--------------------------- + +mount.2 + michael kerrisk + see also: add blkid(1) + +msgop.2 + michael kerrisk + document two msg_copy failure modes + since linux 3.14, the kernel now diagnoses two errors + when using msgrcv() msg_copy: + * msg_copy must be specified with ipc_nowait + * msg_copy can't be specified with msg_except + +open.2 + michael kerrisk + organize some material under additional subheadings in notes + there's an amorphous mass of material under notes. structure + it with some subheadings, and do a little reorganizing. + michael kerrisk + add other system calls and functions that are like openat() + fanotify_mark(2), name_to_handle_at(2), and scandirat(3) have a + directory file descriptor argument for the same reason as openat(). + also: reword the rationale for the *at() functions somewhat. + michael kerrisk + clarify eloop error interaction with o_path + +readahead.2 + phillip susi [corrado zoccolo, gregory p. smith, zhu yanhai, michael kerrisk, christoph hellwig] + don't claim the call blocks until all data has been read + the readahead(2) man page was claiming that the call blocks until + all data has been read into the cache. this is incorrect. + + see https://bugzilla.kernel.org/show_bug.cgi?id=54271 + +stat.2 + michael kerrisk + see also: add ls(1) and stat(1) + +fts.3 + christoph hellwig [michael kerrisk] + the fts(3) api does not work with lfs builds + as pointed out during a recent discussion on libc-hacker the + fts(3) apis can't be used with large file offsets: + + https://sourceware.org/bugzilla/show_bug.cgi?id=15838 + +mbrtowc.3 +mbsnrtowcs.3 +mbsrtowcs.3 +mbtowc.3 + michael kerrisk + add entries in see also + mainly inspired by the posix pages. + +mbsinit.3 + michael kerrisk + see also: add mbrlen(3), mbrtowc(3), and wcrtomb(3) + +mbsrtowcs.3 +wcsrtombs.3 + michael kerrisk + see also: add mbsinit(3) + +mbstowcs.3 + michael kerrisk [stefan puiu] + add example program + and add some see also entries + +memcmp.3 + peng haitao + attributes: note function that is thread-safe + the function memcmp() is thread safe. + +memcpy.3 + peng haitao + attributes: note function that is thread-safe + the function memcpy() is thread safe. + +memfrob.3 + peng haitao + attributes: note function that is thread-safe + the function memfrob() is thread safe. + +memmem.3 + peng haitao + attributes: note function that is thread-safe + the function memmem() is thread safe. + +memmove.3 + peng haitao + attributes: note function that is thread-safe + the function memmove() is thread safe. + +mempcpy.3 + peng haitao + attributes: note functions that are thread-safe + the functions mempcpy() and wmempcpy() are thread safe. + +memset.3 + peng haitao + attributes: note function that is thread-safe + the function memset() is thread safe. + +strerror.3 + michael kerrisk + conforming to: strerror() and strerror_r() are in posix.1-2008 + michael kerrisk + add ss heading for strerror_r() + +toupper.3 + michael kerrisk + rewrite to more explicitly bring locales into the discussion + michael kerrisk + retitle bugs section to notes + these are not really bugs, just background info. + +wcrtomb.3 +wcsnrtombs.3 +wcsrtombs.3 +wcstombs.3 +wctomb.3 + michael kerrisk + see also: add various entries + mainly inspired by posix + +core.5 + mike frysinger [michael kerrisk] + document core_pattern %d specifier + document %p core_pattern specifier + michael kerrisk + rearrange core_pattern specifiers alphabetically + +locale.5 + michael kerrisk + see also: add newlocale(3) + duplocale(3) + +feature_test_macros.7 + michael kerrisk [joseph s. myers] + remove mention of bogus _isoc95_source macro + the _isoc95_source macro is defined in , but it + does nothing. so remove discussion of it, and move some of + the discussion of c95 under the _isoc99_source subhead. + michael kerrisk [carlos o'donell] + add packaging note for _bsd_source/_svid_source/_default_source + to compile warning-free across glibc < 2.20 and glibc >= 2.20 + code may been to define both _default_source and either + _bsd_source or _svid_source. + michael kerrisk + reword description of c90 + +locale.7 + michael kerrisk + add subsection on posix.1-2008 (originally gnu) extensions to locale api + michael kerrisk + remove reference to li18nux2000 + li18nux2000 is difficult to even find these days, and in any case + this page does not document gettext(), so notes about gettext() + in the conforming to section here make no sense. + michael kerrisk + see also: add mbstowcs(3) and wcstombs(3) + see also: add newlocale(3) + duplocale(3) + +man-pages.7 + michael kerrisk + add preferred term "superblock" + michael kerrisk + add preferred terms "uppercase" and "lowercase" + + + +==================== changes in man-pages-3.64 ==================== + +released: 2014-04-06, munich + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +abhay sachan +alexey samsonov +andrey vagin +aneesh kumar k.v +christoph hellwig +david prévot +eric dumazet +eric w. biederman +jan kara +kir kolyshkin +michael kerrisk +mike frysinger +neilbrown +peng haitao +peter hurley +petr gajdos +robert p. j. day +vince weaver +yuri kozlov + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +open_by_handle_at.2 + michael kerrisk [mike frysinger, neil brown, aneesh kumar k.v, + christoph hellwig] + new page describing name_to_handle_at(2) and open_by_handle_at(2) + +inotify.7 + michael kerrisk + rewrite introductory section + reorganize "limitations and caveats" subsection + michael kerrisk + further describe the race when adding a watch to a new subtree + michael kerrisk + directory renames may invalidate multiple paths cached by application + michael kerrisk + add paragraph on cache consistency checking + michael kerrisk + mention cache rebuilding to handle overflow events + michael kerrisk + moving an object to another filesystem generates in_delete_self + michael kerrisk [jan kara] + add text on dealing with rename() events + michael kerrisk + note rationale and consequences of event coalescing + michael kerrisk [eric w. biederman] + inotify doesn't work for remote and pseudo filesystems + michael kerrisk + add some examples of events generated by various system calls + michael kerrisk + bugs: in_oneshot does now cause in_ignored when the watch is dropped + a silent change as a result of the fanotify work in kernel 2.6.36. + michael kerrisk + note that in_delete_self will be followed by in_ignored + michael kerrisk + note that in_unmount will be followed by an in_ignored event + michael kerrisk + inotify does not report events for mmap(2) and msync(2) + michael kerrisk + add examples of syscalls that trigger in_attrib + michael kerrisk + add some examples of syscalls that trigger in_modify + michael kerrisk + execve(2) also generates in_access + michael kerrisk + add examples of syscalls that trigger in_create + + +newly documented interfaces in existing pages +--------------------------------------------- + +perf_event_open.2 + vince weaver [michael kerrisk] + document the perf_flag_fd_cloexec flag + the linux 3.14 release adds support for the perf_flag_fd_cloexec + flag. + +feature_test_macros.7 + michael kerrisk + document _largefile_source + +tcp.7 + michael kerrisk [eric dumazet] + document /proc/sys/net/ipv4/tcp_autocorking + text heavily based on documentation/networking/ip-sysctl.txt + + +new and changed links +--------------------- + +name_to_handle_at.2 + michael kerrisk + new link to new open_by_handle_at(2) page + + +global changes +-------------- + +fmemopen.3 +getaddrinfo.3 +mq_notify.3 +offsetof.3 +aio.7 + michael kerrisk + print size_t/ssize_t values using %z printf() modifier + there are fewer and fewer systems these days that don't + support the %z specifier mandated in c99. so replace the + use of %ld/%lu + (long) cast with %zd/%zu. + + +changes to individual pages +--------------------------- + +bdflush.2 +fsync.2 +sync.2 + kir kolyshkin + see also: remove update(8) reference + remove reference to update(8) man page, since there is no such + page. this is an ancient bsd leftover i believe. + +chown.2 + michael kerrisk + note that 'dirfd' can be at_fdcwd when at_empty_path is used + +getxattr.2 + abhay sachan + fix return value description + a ea can have length zero. + +inotify_add_watch.2 + michael kerrisk + errors: add enametoolong + +inotify_init.2 + michael kerrisk + add pointer to inotify(7) + +link.2 + michael kerrisk + when at_empty_path is specified, 'olddirfd' must not refer to a + directory + +mmap.2 + andrey vagin + the file descriptor for a file mapping must be readable + there is no difference between map_shared and map_private. + +open.2 + michael kerrisk + see also: add open_by_name_at(2) + +perf_event_open.2 + vince weaver + document perf_event_ioc_period behavior change + linux 3.14 (in commit bad7192b842c83e580747ca57104dd51fe08c223) + changes the perf_event perf_event_ioc_period ioctl() behavior + on all architectures to update immediately, to match the behavior + found on arm. + +stat.2 + michael kerrisk + note that 'dirfd' can be at_fdcwd when at_empty_path is used + +syscalls.2 + michael kerrisk + add sched_getattr() and sched_setattr() + and update kernel version to 3.14 + +abort.3 + peng haitao + attributes: note function that is thread-safe + the function abort() is thread safe. + +confstr.3 + michael kerrisk + see also: add getconf(1), fpathconf(3), sysconf(3), pathconf(3) + +exit.3 + peng haitao + attributes: note function that is not thread-safe + the function exit() is not thread safe. + +fenv.3 + peng haitao + attributes: note functions that are thread-safe + the functions feclearexcept(), fegetexceptflag(), feraiseexcept(), + fesetexceptflag(), fetestexcept(), fegetround(), fesetround(), + fegetenv(), feholdexcept(), fesetenv(), feupdateenv(), + feenableexcept(), fedisableexcept() and fegetexcept() are thread + safe. + +fpathconf.3 + michael kerrisk + see also: add confstr(3) + +fseek.3 + michael kerrisk [petr gajdos] + document einval error for negative file offset + +fseeko.3 + michael kerrisk + add feature test macro requirements + +fts.3 + michael kerrisk [mike frysinger] + remove mention of "32-bit systems" in bugs + +fwide.3 +wprintf.3 + michael kerrisk [robert p. j. day] + remove mention of bogus _isoc95_source feature test macro + +getline.3 + alexey samsonov + caller should free the allocated buffer even if getline() failed + relevant discussion in glibc bugzilla: + https://sourceware.org/bugzilla/show_bug.cgi?id=5666 + +getloadavg.3 + peng haitao + attributes: note function that is thread-safe + the function getloadavg() is thread safe. + +getpt.3 + peng haitao + attributes: note function that is thread-safe + the function getpt() is thread safe. + +if_nametoindex.3 + peng haitao + attributes: note functions that are thread-safe + the functions if_nametoindex() and if_indextoname() are thread safe. + +index.3 + peng haitao + attributes: note functions that are thread-safe + the functions index() and rindex() are thread safe. + +mkfifo.3 + peng haitao + attributes: note functions that are thread-safe + the functions mkfifo() and mkfifoat() are thread safe. + +netlink.3 + michael kerrisk + see also: make the reference for libnetlink the libnetlink(3) man page + +random.3 + peng haitao + attributes: note functions that are thread-safe + the functions random(), srandom(), initstate() and setstate() + are thread safe. + +random_r.3 + peng haitao + attributes: note functions that are thread-safe + the functions random_r(), srandom_r(), initstate_r() and + setstate_r() are thread safe. + +sigvec.3 + peng haitao + attributes: note functions that are thread-safe + the functions sigvec(), sigblock(), sigsetmask() and + siggetmask() are thread safe. + + the macro sigmask() is thread safe. + +sysconf.3 + michael kerrisk + see also: add confstr(3) + +termios.3 + michael kerrisk [peter hurley] + fix error in discussion of min > 0, time == 0 noncanonical mode + as reported by peter hurley, for the min > 0, time == 0 case: + + read() may unblock when min bytes are available but return + up to the 'count' parameter if more input arrives in between + waking and copying into the user buffer. + ... + read() may also _not_ return until min bytes have been + received, even if 'count' bytes have been received. + michael kerrisk + add a note on interaction of o_nonblock with noncanonical min/time + posix leaves the behavior open. + michael kerrisk + clarify termination conditions for min > 0, time > 0 + michael kerrisk + clarify behavior if data is available before noncanonical read() + michael kerrisk + add descriptive titles to noncanonical read() cases + +symlink.7 + michael kerrisk + add subsection on opening a symbolic link with o_path + michael kerrisk + name_to_handle_at(2) and open_by_handle_at(2) optionally follow symlinks + michael kerrisk + mention use of readlink(2) to read contents of a symlink + + +==================== changes in man-pages-3.65 ==================== + +released: 2014-04-20, munich + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +alex thorlton +ashish sangwan +christopher covington +christoph hellwig +craig mcqueen +dave chinner +david prévot +greg troxel +matthew dempsky +michael kerrisk +mike frysinger +namjae jeon +peng haitao +petr gajdos +richard hansen +simon paillard +steven stewart-gallus +vince weaver +yuri kozlov + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +inet_net_pton.3 + michael kerrisk + new page describing inet_net_pton(3) and inet_net_ntop(3) + + +newly documented interfaces in existing pages +--------------------------------------------- + +fallocate.2 + michael kerrisk, namjae jeon [christoph hellwig, dave chinner] + document falloc_fl_collapse_range + +prctl.2 + michael kerrisk [alex thorlton] + document pr_set_thp_disable and pr_get_thp_disable + +proc.5 + michael kerrisk + document /proc/[pid]/stack + michael kerrisk + document /proc/[pid]/clear_refs + + +new and changed links +--------------------- + +inet_net_ntop.3 + michael kerrisk + new link to new inet_net_pton.3 + + +changes to individual pages +--------------------------- + +fcntl.2 + michael kerrisk + note the race when o_cloexec is used at same time as fork()+execve() + +madvise.2 + michael kerrisk + see also: see prctl(2) + because of pr_set_thp_disable. + +mlock.2 + michael kerrisk + describe treatment of mcl_future during fork(2) and execve(2) + +msync.2 + michael kerrisk [richard hansen, greg troxel] + warn that one of ms_sync or ms_async is required + +open.2 + michael kerrisk + add more detail on the race that o_cloexec is designed to avoid + michael kerrisk [matthew dempsky] + remove crufty text stating that o_directory is linux-specific + michael kerrisk + note which filesystems support o_tmpfile + +perf_event_open.2 + vince weaver [michael kerrisk] + clarify eacces and eperm errors + clarify the reasons for eacces and eperm errors. + vince weaver [michael kerrisk] + make the errors section more comprehensive. + determined both by code inspection and by writing a large + number of test programs. + +personality.2 + michael kerrisk + available execution domains are listed in + michael kerrisk + fix discussion of return value + +prctl.2 + michael kerrisk + errors: document einval for pr_get_no_new_privs + errors: document einval for pr_set_pdeathsig + errors: document einval for pr_set_timing + errors: document einval for pr_set_dumpable + errors: document einval for pr_set_no_new_privs + +shmget.2 + michael kerrisk + rewrite description of shmmni default value + michael kerrisk + note default value of shmmax + note default value for shmall + +byteorder.3 + peng haitao + attributes: note functions that are thread-safe + the functions htonl(), htons(), ntohl() and ntohs() are thread + safe. + +fexecve.3 + michael kerrisk [steven stewart-gallus] + if 'fd' is a close-on-exec file descriptor for a script, fexecve() fails + see https://bugzilla.kernel.org/show_bug.cgi?id=74481 + +ffs.3 + peng haitao + attributes: note functions that are thread-safe + the functions ffs(), ffsl() and ffsll() are thread safe. + +getauxval.3 + peng haitao + attributes: note function that is thread-safe + the function getauxval() is thread safe. + +getcontext.3 + peng haitao + attributes: note functions that are thread-safe + the functions getcontext() and setcontext() are thread safe. + +getsubopt.3 + peng haitao + attributes: note function that is thread-safe + the function getsubopt() is thread safe. + +getutmp.3 + peng haitao + attributes: note functions that are thread-safe + the functions getutmp() and getutmpx() are thread safe. + +inet.3 + michael kerrisk + note success and error return for inet_aton() + +inet.3 + michael kerrisk [craig mcqueen] + the form 'a.b' if is suitable for class a addresses (not class c) + michael kerrisk + see also: add inet_net_pton(3) + +makecontext.3 + peng haitao + attributes: note functions that are thread-safe + the functions makecontext() and swapcontext() are thread safe. + +pthread_attr_setdetachstate.3 + peng haitao + attributes: note functions that are thread-safe + the functions pthread_attr_setdetachstate() and + pthread_attr_getdetachstate() are thread safe. + +pthread_attr_setguardsize.3 + peng haitao + attributes: note functions that are thread-safe + the functions pthread_attr_setguardsize() and + pthread_attr_getguardsize() are thread safe. + +sigsetops.3 + peng haitao + attributes: note functions that are thread-safe + the functions sigemptyset(), sigfillset(), sigaddset(), + sigdelset(), sigismember(), sigisemptyset(), sigorset() and + sigandset() are thread safe. + +proc.5 + petr gajdos + improve /proc/[pid]/smaps entries description + michael kerrisk + /proc/pid/smaps is present only if config_proc_page_monitor + michael kerrisk + note kernel version for /proc/sys/kernel/{shmall,shmmax} + michael kerrisk + note kernel version for /proc/sys/kernel/{msgmax,msgmnb} + +capabilities.7 + michael kerrisk + see also: add capsh(1) + +libc.7 + michael kerrisk + add musl libc + + +==================== changes in man-pages-3.66 ==================== + +released: 2014-05-08, munich + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +alan curry +carsten andrich +daniel borkmann +david prévot +eric siegerman +heinrich schuchardt +jan kara +jan moskyto matejka +john marshall +lukáš czerner +manfred spraul +michael kerrisk +miklos szeredi +neil horman +peng haitao +peter schiffer +randy dunlap +silvan jegen +simon paillard +stefan puiu +steven stewart-gallus +stijn hinterding +willem de bruijn +yuri kozlov + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +fanotify_init.2 + heinrich schuchardt, michael kerrisk + new page documenting fanotify_init(2) + +fanotify_mark.2 + heinrich schuchardt, michael kerrisk + new page documenting fanotify_mark(2) + +sched_setscheduler.2 + michael kerrisk + page rewritten + stripped out the general scheduling material, which + moved to sched(7), and rewrote much of the remainder. + changed copyright and license since pretty much all + of the content was or is written by mtk. + +fanotify.7 + heinrich schuchardt, michael kerrisk + new page providing overview of the fanotify api + +sched.7 + michael kerrisk + new page providing an overview of the scheduling apis + most of this content derives from sched_setscheduler(2). in + preparation for adding a sched_setattr(2) page, it makes + sense to isolate out this general content to a separate + page that is referred to by the other scheduling pages. + + +newly documented interfaces in existing pages +--------------------------------------------- + +fallocate.2 + lukas czerner [michael kerrisk] + document falloc_fl_zero_range + falloc_fl_zero_range was added in linux 3.14, + for zeroing ranges in the allocated space in a file. + +rename.2 + miklos szeredi [michael kerrisk] + document renameat2() system call added in linux 3.15 + +shmop.2 + michael kerrisk + document shm_exec + + +changes to individual pages +--------------------------- + +flock.2 + michael kerrisk + employ term "open file description" in description + and include reference to open(2) for an explanation of the term. + +getpriority.2 + michael kerrisk + see also: add sched(7) + +getsockopt.2 + carsten andrich + see also: add packet(7) + +link.2 + michael kerrisk [steven stewart-gallus] + document enoent error for linkat() + see https://bugzilla.kernel.org/show_bug.cgi?id=73301 + +msgget.2 + michael kerrisk + reword eexist error + +msgop.2 + michael kerrisk + note capability required to raise mq size beyond msgmnb + +msync.2 + michael kerrisk [heinrich schuchardt] + s/flushes... back to disk/flushes... back to filesystem/ + +nice.2 + michael kerrisk + see also: add sched(7) + +open.2 + peter schiffer + update note on alignment of user buffer and file offset for o_direct + the sentence in open(2) man page in notes for o_direct flag: + + "under linux 2.6, alignment to 512-byte boundaries suffices." + + is not universally correct. the alignment is a property of the + storage, for example, 4k-sector drives with no 512 byte sector + emulation will be unable to perform 512-byte direct i/o. + michael kerrisk + note some of the various synonyms for "open file description" + michael kerrisk + remove repetitious text on use of fcntl() to change file status flags + +open_by_handle_at.2 + michael kerrisk + mention freebsd analogs + +posix_fadvise.2 + michael kerrisk [eric siegerman] + fix wording error under "architecture-specific variants" + see https://bugzilla.kernel.org/show_bug.cgi?id=75431 + +process_vm_readv.2 + michael kerrisk [stijn hinterding] + add feature test macro requirements + the _gnu_source ftm must be defined. + +read.2 + michael kerrisk + bugs: detail nonatomicity bug with respect to file offset updates + this bug was fixed in linux 3.14, with commit + 9c225f2655e36a470c4f58dbbc99244c5fc7f2d4 + see also http://thread.gmane.org/gmane.linux.kernel/1649458 + +sched_get_priority_max.2 + michael kerrisk + small changes consistent with migration of content to sched(7) + +sched_rr_get_interval.2 + michael kerrisk + small changes consistent with migration of content to sched(7) + +sched_setaffinity.2 + michael kerrisk + small changes consistent with migration of content to sched(7) + +sched_setparam.2 + michael kerrisk + small changes consistent with migration of content to sched(7) + +sched_yield.2 + michael kerrisk + small changes consistent with migration of content to sched(7) + +semget.2 + michael kerrisk + consolidate discussion on noninitialization of semaphores + the fact that semget() does not initialize the semaphores + in a new set was covered in two places (in description + and bugs). consolidate these into one place (in notes) + and also point out that posix.1-2008 says that a future + version of the standard may require an implementation to + initialize the semaphores to 0. + michael kerrisk + clarify semmns versus semmsl*semmni + michael kerrisk + rework einval text a little + michael kerrisk + clarify wording for eexist error + +shmget.2 + manfred spraul + clarify shmall + the default for shmall is a limit of 8 gb, regardless of + page_size. the current documentation does not mention that + and is therefore more difficult to understand than necessary. + manfred spraul + correct math error + 2097152 is 2^21, not 2^20. + michael kerrisk + reword eexist error + michael kerrisk + clarify one of the einval cases + michael kerrisk + note that shm_noreserve is a linux extension + michael kerrisk [simon paillard] + fix kernel version numbers in discussion of shmall + michael kerrisk + rework einval text + michael kerrisk + move and rework discussion of mode bits + michael kerrisk + reword description of o_excl + +shmop.2 + michael kerrisk + move fork(2), execve(2), _exit(2) discussion to notes + michael kerrisk + add subheads for shmat() and shmdt() + michael kerrisk + rework discussion of shm_rdonly and shm_remap into list format + michael kerrisk + structure the attach cases as a list + +sigaction.2 + alan curry + fix bad cross reference (times(2) not time(2)) + the system call that reports child cpu usage is times(2), + not time(2). + +symlink.2 + michael kerrisk [steven stewart-gallus] + document enoent error for symlinkat() + see https://bugzilla.kernel.org/show_bug.cgi?id=73301 + +syscalls.2 + michael kerrisk + add renameat2() + and bump kernel version. + +write.2 + michael kerrisk + bugs: detail nonatomicity bug with respect to file offset updates + this bug was fixed in linux 3.14, with commit + 9c225f2655e36a470c4f58dbbc99244c5fc7f2d4 + see also http://thread.gmane.org/gmane.linux.kernel/1649458 + +pthread_attr_setinheritsched.3 + peng haitao + attributes: note functions that are thread-safe + the functions pthread_attr_setinheritsched() and + pthread_attr_getinheritsched() are thread safe. + +pthread_attr_setschedparam.3 + peng haitao + attributes: note functions that are thread-safe + the functions pthread_attr_setschedparam() and + pthread_attr_getschedparam() are thread safe. + +pthread_attr_setschedpolicy.3 + peng haitao + attributes: note functions that are thread-safe + the functions pthread_attr_setschedpolicy() and + pthread_attr_getschedpolicy() are thread safe. + +pthread_attr_setscope.3 + peng haitao + attributes: note functions that are thread-safe + the functions pthread_attr_setscope() and pthread_attr_getscope() + are thread safe. + +pthread_attr_setstack.3 + peng haitao + attributes: note functions that are thread-safe + the functions pthread_attr_setstack() and pthread_attr_getstack() + are thread safe. + +sched_getcpu.3 + michael kerrisk + see also: add sched(7) + +termios.3 + michael kerrisk [yuri kozlov] + rework intro text for 'c_oflag' + michael kerrisk + ofdel is in posix.1-2001, so remove "(not in posix)" text + +proc.5 + jan moskyto matejka [randy dunlap] + improve description of /proc/stat 'intr' field + the sum at the beginning of line "intr" includes also + unnumbered interrupts. + +packet.7 + carsten andrich [neil horman] + improve sockopt documentation for packet sockets + carsten andrich [willem de bruijn] + packet_loss has inverse meaning + stefan puiu [daniel borkmann, carsten andrich] + status in packet_rx_ring is actually a bit mask + michael kerrisk [carsten andrich] + see also: add /tools/testing/selftests/net/psock_tpacket.c + + +==================== changes in man-pages-3.67 ==================== + +released: 2014-05-21, munich + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +andy lutomirski +aurelien jarno +bill allombert +christoph hellwig +davidlohr bueso +heinrich schuchardt +ingo schwarze +jan kara +jon grant +juri lelli +lucas de marchi +michael kerrisk +peng haitao +peter zijlstra +rasmus villemoes +sam varshavchik +simon paillard +steven stewart-gallus +török edwin +william morriss +yuri kozlov + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +sched_setattr.2 + michael kerrisk, peter zijlstra [juri lelli] + new page describing sched_setattr(2) and sched_getattr(2) + +system.3 + michael kerrisk + rewrote large parts of the page and added a number of details + + +newly documented interfaces in existing pages +--------------------------------------------- + +sched.7 + peter zijlstra, michael kerrisk [juri lelli] + document sched_deadline + +new and changed links +--------------------- + +renameat2.2 + michael kerrisk + new link to rename.2 + +sched_getattr.2 + michael kerrisk + new link to new sched_setattr + + +changes to individual pages +--------------------------- + +bind.2 + michael kerrisk + errors: add eaddrinuse for ephemeral port range exhaustion + +chown.2 + michael kerrisk + notes: add some subheadings + +connect.2 + michael kerrisk [william morriss] + errors: add eaddrnotavail for ephemeral port range exhaustion + verified from testing and the kernel source. + see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=745775 + michael kerrisk + remove mention of ip_local_port_range under eagain error + +create_module.2 +delete_module.2 +init_module.2 +query_module.2 + michael kerrisk [lucas de marchi] + clarify glibc header file declaration/abi wrapper details + create_module(), delete_module(), init_module(), and + query_module() are not declared in header files, but + through an accident of history glibc provides an abi + for them that it continues to maintain, for + compatibility reasons. + +execve.2 + michael kerrisk [steven stewart-gallus] + note sigkill case when execve() fails beyond the point of no return + michael kerrisk + notes: add a subheading and reorder paragraphs + +fanotify_init.2 + heinrich schuchardt [michael kerrisk] + document range of permitted flags for event_f_flags + with a new patch included in the mm tree, event_f_flags is + checked for allowable values. + +fcntl.2 + michael kerrisk + add "file locking" subheading under notes + +fork.2 + michael kerrisk + errors: sched_deadline tasks can fail with eagain + sched_deadline tasks can fail with eagain unless the + reset-on-fork flag is set. + +futex.2 + michael kerrisk + note that there is no glibc wrapper + +getpriority.2 + rasmus villemoes + fix prototypes for getpriority() and setpriority() + the who argument has type id_t (which happens to be u32 on linux). + +get_robust_list.2 + rasmus villemoes + add to synopsis of get_robust_list() + if one were to implement wrappers for [gs]et_robust_list() using the + given prototypes, one would also have to include sys/types.h to get + a definition of size_t. + +getrusage.2 + michael kerrisk [bill allombert] + _gnu_source must be defined to obtain rusage_thread definition + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=746569 + +link.2 +open.2 + andy lutomirski [michael kerrisk] + update at_empty_path and o_path documentation + +listen.2 + michael kerrisk + errors: add eaddrinuse for ephemeral port range exhaustion + +mbind.2 + rasmus villemoes + fix prototype for mbind(2) + the nmask argument is const. the return type in numaif.h is long. + (well, at least says nmask is const. the current kernel + does not define it as a const argument, but sys_mbind() only + passes it to get_nodes(), which does treat it as const.) + +msgop.2 + davidlohr bueso [michael kerrisk] + enhance description of "full queue" criteria + +poll.2 + rasmus villemoes + add to synopsis for ppoll() + one needs to #include to get the definition of the + type (sigset_t) of the mask argument to ppoll(). + +readlink.2 + rasmus villemoes + fix return type of readlinkat() + +recv.2 + michael kerrisk + clarify details of msg_name and msg_namelen fields + +recvmmsg.2 + michael kerrisk + describe timeout bug + see https://bugzilla.kernel.org/show_bug.cgi?id=75371 + and http://thread.gmane.org/gmane.linux.man/5677 + +remap_file_pages.2 + andy lutomirski [christoph hellwig, andy lutomirski] + remap_file_pages() has no benefit for real files + linux commit 3ee6dafc677a68e461a7ddafc94a580ebab80735 caused + remap_file_pages to be emulated when used on real file. + +sched_get_priority_max.2 + michael kerrisk + 'policy' can also be sched_deadline + +sched_setaffinity.2 + rasmus villemoes + fix prototype for sched_setaffinity() + the mask argument is const. + +sched_setparam.2 + michael kerrisk + errors: mark errors that apply just for sched_setparam() + michael kerrisk + errors: add einval for invalid arguments + michael kerrisk + see also: add sched_setattr(2) + +sched_setscheduler.2 + michael kerrisk + errors: mark errors that apply just to sched_setscheduler() + michael kerrisk + errors: add einval case for pid < 0 + michael kerrisk + errors: separate out einval cases + +semget.2 + michael kerrisk + notes: add subheadings and reorder paragraphs + +semop.2 + rasmus villemoes + fix prototypes for semop() and semtimedop() + the nsops arguments have type size_t, not unsigned, and the + timeout argument of semtimedop() is const. + michael kerrisk + notes: add a subheading + +send.2 + michael kerrisk + add details on various 'msghdr' fields + michael kerrisk + errors: add eagain for ephemeral port range exhaustion + michael kerrisk + add some subheadings under description + +shmget.2 + michael kerrisk + notes: add a subheading + +stat.2 + michael kerrisk [aurelien jarno] + describe feature test macro requirements for file type test macros + see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=728240 + michael kerrisk + update ftm requirements for lstat() + michael kerrisk + split discussion of 'st_mode' fields into type and permissions + michael kerrisk + move text on s_i*() macros to follow text on s_i* macros + that ordering is more logical + +stime.2 + rasmus villemoes + fix prototype for stime() + the argument is const, both according to the actual header files and + according to . + +syscall.2 + rasmus villemoes + fix prototype for syscall() + the first argument and the return value of syscall() has type long, + not int. + +getopt.3 + michael kerrisk + example: add subheadings to distinguish the two example programs + +malloc.3 + michael kerrisk + reword text referring to mallopt(3) + linux libc is no longer "recent"; drop mention of it. + +pthread_attr_setinheritsched.3 +pthread_attr_setschedparam.3 +pthread_attr_setschedpolicy.3 +pthread_setaffinity_np.3 +pthread_setschedparam.3 +pthread_setschedprio.3 +pthread_yield.3 +pthreads.7 + michael kerrisk + change references to "sched_setscheduler(2)" to "sched(7)" + change consistent with the fact that the scheduling overview + page is now sched(7) not sched_setscheduler(2). + +pthread_attr_setstackaddr.3 + peng haitao + attributes: note functions that are thread-safe + the functions pthread_attr_setstackaddr() and + pthread_attr_getstackaddr() are thread safe. + +pthread_attr_setstacksize.3 + peng haitao + attributes: note functions that are thread-safe + the functions pthread_attr_setstacksize() and + pthread_attr_getstacksize() are thread safe. + +pthread_kill.3 + peng haitao + attributes: note function that is thread-safe + the function pthread_kill() is thread safe. + +pthread_kill_other_threads_np.3 + peng haitao + attributes: note function that is thread-safe + the function pthread_kill_other_threads_np() is thread safe. + +pthread_self.3 + peng haitao + attributes: note function that is thread-safe + the function pthread_self() is thread safe. + +pthread_setcancelstate.3 + michael kerrisk + add paragraph breaks to "asynchronous cancelability" subsection + +pthread_setcancelstate.3 + peng haitao + attributes: note functions that are thread-safe + the functions pthread_setcancelstate() and + pthread_setcanceltype() are thread safe. + michael kerrisk + notes: add some subheadings + +pthread_setschedparam.3 + peng haitao + attributes: note functions that are thread-safe + the functions pthread_setschedparam() and pthread_getschedparam() + are thread safe. + +pthread_setschedprio.3 + peng haitao + attributes: note function that is thread-safe + the function pthread_setschedprio() is thread safe. + +pthread_sigmask.3 + peng haitao + attributes: note function that is thread-safe + the function pthread_sigmask() is thread safe. + +pthread_sigqueue.3 + peng haitao + attributes: note function that is thread-safe + the function pthread_sigqueue() is thread safe. + +pthread_testcancel.3 + peng haitao + attributes: note function that is thread-safe + the function pthread_testcancel() is thread safe. + +pthread_yield.3 + peng haitao + attributes: note function that is thread-safe + the function pthread_yield() is thread safe. + +remquo.3 + peng haitao + attributes: note functions that are thread-safe + the functions remquo(), remquof() and remquol() are thread safe. + +rtime.3 + peng haitao + attributes: note function that is thread-safe + the function rtime() is thread safe. + +sched_getcpu.3 + peng haitao + attributes: note function that is thread-safe + the function sched_getcpu() is thread safe. + +stpcpy.3 + ingo schwarze + note some history of stpcpy() + quoting ingo: + i just noticed that the stpcpy(3) manual contains a speculation + that appears to be untrue on closer investigation: that function + did not originate in ms dos, but in lattice c on amigados. + + here is a patch against the git master head to fix that, and add + some more historical information. to provide some background and + allow you to more easily verify the correctness of the patch, i'm + appending my mail to , where i'm giving some + more details about the history and pointing to some primary + sources. that mail also contains the (similar, but shorter) + patch i just committed to the openbsd manual page. + +strcasecmp.3 + michael kerrisk [aurelien jarno, török edwin] + explain why strcasecmp()+strncasecmp() are also declared in + see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=729436 + +strcpy.3 + michael kerrisk + notes: add a subheading + +fd.4 + michael kerrisk [sam varshavchik] + fix floppy disk device names + the naming convention shown in the page was ancient. + now, the page is consistent with documentation/devices.txt + (where it is noted that "the use of the capital letters + d, h and e for the 3.5" models have been deprecated, since + the drive type is insignificant for these devices" + +proc.5 + michael kerrisk + document /proc/timer_stats + michael kerrisk + (briefly) document /proc/timer_list + michael kerrisk + add /proc/sys/kernel/{sched_rt_period_us,sched_rt_runtime_us} + reference sched(7) for an explanation of these two files + +capabilities.7 + michael kerrisk + mention sched_setattr(2) under cap_sys_nice + +cpuset.7 + michael kerrisk + see also: add sched(7) + +credentials.7 + michael kerrisk + mention sched_getattr() as a place where credentials are checked + +fanotify.7 + heinrich schuchardt [jan kara] + bugs: error events can be lost when reading from fanotify fd + michael kerrisk [heinrich schuchardt] + fix description of fan_event_next() + fan_event_next() does not update 'meta'; rather, it returns a + pointer to the next metadata structure. in addition, generally + rework the description to be a bit clearer and more detailed. + heinrich schuchardt + document fan_event_metadata_len + +ip.7 + michael kerrisk + note cases where an ephemeral port is used + michael kerrisk + remove bugs text on glibc failing to declare in_pktinfo + michael kerrisk + clarify 'ip_local_port_range' and mention the term "ephemeral ports" + michael kerrisk + note some more details about assignment of ephemeral ports + michael kerrisk + bugs: ephemeral port range exhaustion is diagnosed inconsistently + different system calls use different 'errno' values to diagnose + exhaustion of the ephemeral port range. + +sched.7 + michael kerrisk + document sched_rt_period_us and sched_rt_runtime_us /proc files + and rework and relocate the text on dealing with runaway + real-time processes. + michael kerrisk + mention sched_setattr(2) in list of apis that can change policies + michael kerrisk + sched_setattr(2) can also be used to set 'nice' value + michael kerrisk + remove mention of sched_setscheduler() when talking about sched_priority + there are nowadays multiple ways to set sched_priority (and + in fact there always were, since we also had sched_setparam(2)). + michael kerrisk + see also: add documentation/scheduler/sched-design-cfs.txt + michael kerrisk + don't mention sched_setscheduler(2) in discussions of setting policies + in a couple of places, sched_setscheduler(2) is mentioned as the + way of setting policies. but now there is sched_setattr(2) as + well, rewrite the text in a more generic way. + michael kerrisk + rework summary text describing sched_setattr(2) and sched_getattr(2) + note that these apis are a superset of sched_setscheduler(2) + and sched_getscheduler(2). + michael kerrisk + remove crufty text relating to sched_setscheduler() + all of the removed text is in sched_setscheduler(2) and + should have been trimmed from this page. + michael kerrisk + see also: mention more files in documentation/scheduler/ directory + + +==================== changes in man-pages-3.68 ==================== + +released: 2014-05-28, munich + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +alastair mckinstry +carsten grohmann +colin williams +heinrich schuchardt +lars wirzenius +marko myllynen +michael kerrisk +peng haitao +rasmus villemoes +richard braakman +simon paillard + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +localedef.1 + marko myllynen, richard braakman, alastair mckinstry, lars wirzenius + new page for localedef(1) + add new page based on debian localedef(1) page. + + +new and changed links +--------------------- + +procfs.5 + new link to proc.5 + since the term "procfs" is widely used, it seems reasonable to have + a link from that name to proc(5). + + +changes to individual pages +--------------------------- + +locale.1 + marko myllynen + provide a step-by-step example of how to use a custom locale + marko myllynen + use lc_telephone instead of lc_messages in the example + yesstr/nostr in lc_messages are planned to be changed at some + point [1], so it's better to provide an example which won't + be obsoleted by that change. + + [1] https://sourceware.org/bugzilla/show_bug.cgi?id=16975 + +adjtimex.2 + michael kerrisk + add feature test macro requirements + +clone.2 + michael kerrisk + errors: add cross-reference to fork(2) for explanation of eagain + +fork.2 + michael kerrisk + errors: add pid_max and threads-max to eagain + and rewrite text to be the same as pthread_create(3). + +getrlimit.2 + michael kerrisk + rlimit_nproc is not enforced if cap_sys_admin or cap_sys_resource + +remap_file_pages.2 + rasmus villemoes + fix prototype + the pgoff argument has type size_t, not ssize_t (and in the + kernel it is unsigned long). + +set_mempolicy.2 + rasmus villemoes + fix prototype for set_mempolicy(2) + the nodemask argument is const. the return type in numaif.h is long. + +swapon.2 + rasmus villemoes + remove header from synopsis + the header is not readily available, and the comment + seems to indicate that it is for getting page_size. but it is + never mentioned why one would need to know that, and it is in any + case better obtained using sysconf(), provided by . + +a64l.3 + rasmus villemoes + fix prototype for a64l() + the argument is const, both according to posix and the + glibc headers. + +adjtime.3 + rasmus villemoes + add required header + the prototype for adjtime(3) is declared in . + +argz_add.3 + rasmus villemoes + fix prototypes + update the prototypes of argz_{delete,extract,next} to agree with + glibc headers and manual. + +bstring.3 + rasmus villemoes + fix prototypes + the length parameter n has type size_t in bcmp(), bcopy() and + bzero(). + +envz_add.3 + rasmus villemoes + fix prototypes + the envz_len parameters for envz_entry() and envz_get() are not + passed by reference. + +fpathconf.3 + rasmus villemoes + fix prototype + the path argument to pathconf() is const. + +fseek.3 + rasmus villemoes + fix prototype + the pos argument to fsetpos() is const. + +gcvt.3 + rasmus villemoes + fix prototype + the ndigit parameter to gcvt() has type int. + +getaddrinfo_a.3 + rasmus villemoes + fix prototype + the pointer arguments to gai_suspend() are const. + +getauxval.3 + rasmus villemoes + fix permissions + there doesn't seem to be any reason for getauxval.3 to be + executable... + +getnameinfo.3 + rasmus villemoes + fix prototype + the hostlen and servlen parameters have type socklen_t. + (the types changed in glibc 2.2) + michael kerrisk + note types of 'hostlen'; and 'servlen' in glibc < 2.2 + +getrpcent.3 + rasmus villemoes + fix prototype + the argument to getrpcbyname() is const. + +getrpcport.3 + rasmus villemoes + add #include and fix prototype + the prototype for getrpcport() is obtained by #include'ing + . also, update its prototype. + +getspnam.3 + rasmus villemoes + fix prototype + the struct spwd argument to putspent() is const. + +getutent.3 + rasmus villemoes + fix prototypes + the arguments to getutid(), getutline(), and pututline() + are const. + +inet.3 + rasmus villemoes + fix prototype + the parameters to inet_makeaddr have type in_addr_t. + +inet_net_pton.3 + rasmus villemoes + srcfix, cfix + use a consistent style throughout the man-pages. + +key_setsecret.3 + rasmus villemoes + fix prototypes + remove const qualifiers from arguments to key_decryptsession, + key_encryptsession, and key_setsecret. + +makecontext.3 + rasmus villemoes + fix prototype + the second argument to swapcontext() is const. + +makedev.3 + rasmus villemoes + fix prototype + gnu_dev_makedev, and hence its trivial macro wrapper makedev, takes + two unsigned int parameters; this is consistent with it being the + inverse of (gnu_dev_)major/minor, which return unsigned int. + +malloc_trim.3 + rasmus villemoes + fix prototype + as mentioned further down, malloc_trim returns an integer. + +mq_getattr.3 + rasmus villemoes + fix prototype + the newattr parameter to mq_setattr is const. + +newlocale.3 + marko myllynen + list all available category masks + michael kerrisk + add lc_all_mask description + +nl_langinfo.3 + marko myllynen + expand the example code a bit + better illustrate querying elements from different categories. + +perror.3 + rasmus villemoes + fix declaration + the elements of the array sys_errlist are also const. + +pthread_attr_setaffinity_np.3 +pthread_attr_setdetachstate.3 +pthread_attr_setguardsize.3 +pthread_attr_setinheritsched.3 +pthread_attr_setschedparam.3 +pthread_attr_setschedpolicy.3 +pthread_attr_setscope.3 +pthread_attr_setstack.3 +pthread_attr_setstackaddr.3 +pthread_attr_setstacksize.3 + rasmus villemoes + constify parameters + each of the pthread_attr_get* functions extract some piece of + information from a pthread_attr_t, which is passed by const + reference. add the const keyword to the prototypes of these + functions. + +pthread_cleanup_push_defer_np.3 + michael kerrisk [rasmus villemoes] + add feature test macro requirements + +pthread_create.3 + michael kerrisk [carsten grohmann] + add pid_max limit to eagain error cases + +pthread_equal.3 + peng haitao + attributes: note function that is thread-safe + the function pthread_equal() is thread safe. + +pthread_exit.3 + peng haitao + attributes: note function that is thread-safe + the function pthread_exit() is thread safe. + +pthread_getcpuclockid.3 + peng haitao + attributes: note function that is thread-safe + the function pthread_getcpuclockid() is thread safe. + +pthread_setaffinity_np.3 + peng haitao + attributes: note functions that are thread-safe + the functions pthread_setaffinity_np() and + pthread_getaffinity_np() are thread safe. + +pthread_setconcurrency.3 + peng haitao + attributes: note functions that are thread-safe + the functions pthread_setconcurrency() and + pthread_getconcurrency() are thread safe. + +pthread_setname_np.3 + rasmus villemoes + fix prototype + the name parameter of pthread_getname_np is an output parameter and + hence not const. + +pthread_setschedparam.3 + rasmus villemoes + fix prototypes + add return type for pthread_{s,g}etschedparam. + +pthread_setschedprio.3 + rasmus villemoes + fix prototype + add return type for pthread_setschedprio. + +pthread_sigqueue.3 + rasmus villemoes + add missing #include + +rcmd.3 + rasmus villemoes + fix prototypes + unlike the bsds, the second argument of rcmd() and rcmd_af() has + type unsigned short. + the first argument of iruserok_af() has type const void*. + +re_comp.3 + rasmus villemoes + fix prototypes + re_comp and re_exec take const char* arguments. + +resolver.3 + rasmus villemoes + fix prototypes and extern-declaration + fix const- and signedness of various char* parameters. + + also, there is no "struct state", but _res is a struct + __res_state. (actually, _res is errno-like in that it is really a + macro expanding to (*__res_state()).) + +rexec.3 + rasmus villemoes + fix prototypes + the user, passwd and cmd arguments to rexec and rexec_af are all + const. + +rtime.3 + rasmus villemoes + replace header + the header does not provide rtime(); + does, as is also implied in both the notes and + example sections. + +scandir.3 + rasmus villemoes + fix prototypes + the alphasort and versionsort functions take arguments of type + const struct dirent **, not const void *. + +setlocale.3 + michael kerrisk [marko myllynen] + simplify locale category listing and add gnu-specific locale categories + some information that was here will move to locale(7). + marko myllynen + remove now obsolete notes section + +setnetgrent.3 + rasmus villemoes + fix prototype + the buflen argument to getnetgrent_r has type size_t. + +sigvec.3 + rasmus villemoes + fix prototype + the vec argument to sigvec is const. + +tsearch.3 + rasmus villemoes + fix prototype + the rootp argument to tfind is "void * const *", + not "const void **". + +core.5 + michael kerrisk + core dump files are nowadays core.pid by default + +locale.5 + marko myllynen + document mon_grouping and grouping properly + michael kerrisk + note default value for 'first_workday' + michael kerrisk [marko myllynen] + add brief descriptions of collating-element and collating-symbol + marko myllynen + t_fmt_ampm is needed only for locales that employ am/pm convention + michael kerrisk [marko myllynen] + remove crufty reference to /usr/lib/nls/src + that file is nowhere to be found + marko myllynen + clarify lc_time/am_pm and lc_name keywords usage + am_pm should be defined only if am/pm convention is used to signal + applications they should not try to print them when using them in + unwanted. + + same for all lc_name keywords expect for name_fmt which should be + always defined. + marko myllynen + clarify lang_term / lang_lib + as noted by keld simonsen in the lib-locales@sourceware mailing + list: + + https://sourceware.org/ml/libc-locales/2014-q2/msg00008.html + from: keld simonsen + to: marko myllynen + date: tue, 29 apr 2014 17:02:09 +0200 + + lang_term reflects iso 639-2/t (terminology) codes, while + lang_lib reflects iso 639-2/b (bibliographic) codes. + lang_term is preferred over lang_lib codes for locale names. + there are 20 specific iso 639-2/b codes. + marko myllynen + correct the files section + +proc.5 + michael kerrisk + 'pid_max' is a system-wide limit on number of threads and processes + since pids > /proc/sys/kernel/pid_max are not allocated, this + file thus also imposes a system-wide limit on the number of + threads and processes. + +capabilities.7 + michael kerrisk + cap_sys_admin allows overriding rlimit_nproc + michael kerrisk + cap_sys_ptrace allows process_vm_readv(2) and process_vm_writev(2) + +charsets.7 + michael kerrisk [marko myllynen] + remove crufty statement that romanian may be switching to iso 8859-16 + michael kerrisk + remove ancient paragraph on charsets supported in glibc 2.3.2 + that test is rather ancient, and probably of little use. + +fanotify.7 + heinrich schuchardt + fix to example program: fanotify read() should use aligned buffer + +inotify.7 + heinrich schuchardt + add example program + this example of the usage of the inotify api shows the + usage of inotify_init1(2) and inotify_add_watch(2) as well + as polling and reading from the inotify file descriptor. + heinrich schuchardt + munmap() does not generate inotify events + +locale.7 + marko myllynen [michael kerrisk] + document the locpath environment variable + michael kerrisk + add further details on various categories + + + +==================== changes in man-pages-3.69 ==================== + +released: 2014-06-14, munich + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +cyril hrubis +jan chaloupka +jeff layton +kirill a. shutemov +kosaki motohiro +marko myllynen +michael kerrisk +neilbrown +peng haitao +petr gajdos +qian lei +rasmus villemoes +vasiliy kulikov +walter harms +yuri kozlov + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +iconv.1 + marko myllynen [michael kerrisk] + new page for the iconv(1) command + +iconvconfig.8 + marko myllynen + new page for iconvconfig(8) + + +newly documented interfaces in existing pages +--------------------------------------------- + +fcntl.2 + jeff layton, michael kerrisk + document open file description locks + as provided by the fcntl() operations f_ofd_setlk, + f_ofd_setlkw, and f_ofd_getlk + + +changes to individual pages +--------------------------- + +locale.1 + marko myllynen + add files section, add charmap(5) reference + marko myllynen + align with recent charmap(5) / repertoiremap(5) changes + +execve.2 + michael kerrisk [neilbrown] + before kernel 2.6.0, rlimit_nproc had no effect for set*uid() + michael kerrisk [vasiliy kulikov] + rlimit_nproc is checked only if preceded by set*uid() + michael kerrisk [vasiliy kulikov, neilbrown, kosaki motohiro] + document eagain error + see also https://bugzilla.kernel.org/show_bug.cgi?id=42704 + +fcntl.2 + michael kerrisk + detail the limitations of traditional (process-associated) locks + michael kerrisk [jeff layton] + describe how to check whether the kernel supports a particular command + michael kerrisk + errors: add einval for invalid 'cmd' + michael kerrisk + add para introducing advisory locks and noting existence of ofd locks + michael kerrisk [jeff layton] + add notes on f_setlkw deadlock detection and its limitations + michael kerrisk + add an explicit note that mandatory locking is not in posix + michael kerrisk + rewrite introductory paragraphs on mandatory locking + make the structure more logical, and also explicitly mention + ofd locks. + michael kerrisk [jeff layton] + reword discussion of mandatory lock bug a little + jeff layton confirmed that the bug remains even in modern kernels. + michael kerrisk + explain posix background to eacces/eagain error for f_getlk + michael kerrisk + add notes subhead for record locking and nfs + michael kerrisk [neilbrown] + note treatment of locks when an nfs client loses contact with the server + michael kerrisk [jeff layton] + nfsv4leasetime controls the "contact lost" interval for nfsv4 + +flock.2 + michael kerrisk + in some modern bsds, fcntl() and flock() locks do interact + so, reword and extend the discussion of this topic in notes. + michael kerrisk + move notes text describing implementation of flock() + michael kerrisk [neilbrown] + add more details on nfs, including linux 2.6.37 changes + also: move notes text describing interaction of fcntl() + and flock() locks. + +fork.2 + michael kerrisk + add notes on inheritance of flock() and ofd locks across fork() + +lseek.2 + michael kerrisk + add reference to open(2) for discussion of file descriptors and ofds + +open.2 + michael kerrisk + rework and extend the discussion of open file descriptions + +open_by_handle_at.2 + rasmus villemoes + add reference to feature_test_macros(7) + +recvmmsg.2 + rasmus villemoes + add reference to feature_test_macros(7) + +remap_file_pages.2 + michael kerrisk [kirill a. shutemov] + note that remap_file_pages() is deprecated + +sendmmsg.2 + rasmus villemoes + add reference to feature_test_macros(7) + +seteuid.2 + michael kerrisk + seteuid() and setegid() are implemented as library functions + michael kerrisk + error checking should always be performed, even when caller is uid 0 + +setresuid.2 + michael kerrisk + document eagain error that can occur after kernel alloc_uid() failure + michael kerrisk + since linux 3.1, the eagain case for rlimit_nproc no longer occurs + michael kerrisk + correct the description of the eagain error + michael kerrisk + error checking should always be performed, even when caller is uid 0 + +setreuid.2 + michael kerrisk + document eagain error that can occur after kernel alloc_uid() failure + michael kerrisk + error checking should always be performed, even when caller is uid 0 + michael kerrisk + add eagain error for hitting rlimit_nproc limit + michael kerrisk + since linux 3.1, the eagain case for rlimit_nproc no longer occurs + +setuid.2 + michael kerrisk + document eagain error that can occur after kernel alloc_uid() failure + michael kerrisk + correct the description of the eagain error + michael kerrisk + error checking should always be performed, even when caller is uid 0 + michael kerrisk + since linux 3.1, the eagain case for rlimit_nproc no longer occurs + +statfs.2 + cyril hrubis + update magic constants + most of the updates are taken from /usr/include/linux/magic.h, + some were found by grepping the linux source code. + cyril hrubis [michael kerrisk] + fstatfs(2) was broken on file descriptors from pipe(2) + +syscalls.2 + michael kerrisk + note that remap_file_pages() is deprecated + +basename.3 + peng haitao + attributes: note functions that are thread-safe + the functions basename() and dirname() are thread safe. + +catgets.3 + peng haitao + attributes: note function that is thread-safe + the function catgets() is thread safe. + +getdate.3 + rasmus villemoes + use blank definition of _gnu_source in example program + +getdirentries.3 + peng haitao + attributes: note function that is thread-safe + the function getdirentries() is thread safe. + +getdtablesize.3 + peng haitao + attributes: note function that is thread-safe + the function getdtablesize() is thread safe. + +iconv.3 + qian lei [peng haitao] + attributes: note function that is thread-safe + the function iconv() is thread safe. + michael kerrisk + see also: add iconvconfig(8) + +lockf.3 + qian lei [peng haitao] + attributes: note function that is thread-safe + the function lockf() is thread safe. + +malloc_get_state.3 + rasmus villemoes + synopsis: use correct header + the nonstandard functions malloc_set_state() and + malloc_get_state() are provided by not . + +malloc_usable_size.3 + qian lei + attributes: note function that is thread-safe + the function malloc_usable_size() is thread safe. + +matherr.3 + qian lei [peng haitao] + attributes: note function that is thread-safe + the function matherr() is thread safe. + +mkdtemp.3 + peng haitao + attributes: note function that is thread-safe + the function mkdtemp() is thread safe. + +mkstemp.3 + peng haitao + attributes: note functions that are thread-safe + the functions mkstemp(), mkostemp(), mkstemps() and mkostemps() + are thread safe. + +mq_close.3 + qian lei + attributes: note function that is thread-safe + the function mq_close() is thread safe. + +mq_getattr.3 + qian lei + attributes: note function that is thread-safe + the functions mq_getattr() and mq_setattr() are thread safe. + +mq_open.3 + peng haitao + attributes: note function that is thread-safe + the function mq_open() is thread safe. + +mq_receive.3 + peng haitao + attributes: note functions that are thread-safe + the functions mq_receive() and mq_timedreceive() are thread safe. + +mq_send.3 + peng haitao + attributes: note functions that are thread-safe + the functions mq_send() and mq_timedsend() are thread safe. + +mq_unlink.3 + qian lei + attributes: note function that is thread-safe + the function mq_unlink() is thread safe. + +posix_fallocate.3 + peng haitao + attributes: note function that is thread-safe + the function posix_fallocate() is thread safe. + +posix_openpt.3 + peng haitao + attributes: note function that is thread-safe + the function posix_openpt() is thread safe. + +siginterrupt.3 + peng haitao + attributes: note function that is not thread-safe + the function siginterrupt() is not thread safe. + +system.3 + peng haitao + attributes: note function that is thread-safe + the function system() is thread safe. + +charmap.5 + marko myllynen + update to match current glibc + charmap(5) was outdated, bring it to closer to reality by fixing + syntax descriptions to match current glibc code and practices, + adding missing options, removing obsolete comments and references, + and removing now incorrect examples. + +locale.5 + marko myllynen + clarify am/pm settings a bit + localedef(1) complains if really undefined, should be empty instead. + also: add some see also references. + marko myllynen + document glibc conventions regarding days and week + based on existing practice and glibc community wiki page at + https://sourceware.org/glibc/wiki/locales + +proc.5 + michael kerrisk [jan chaloupka, walter harms] + add a brief description of /proc/fs + +repertoiremap.5 + marko myllynen + new page for repertoiremap(5) + rather obsolete feature but localedef(1) refers to repertoiremaps. + +bootparam.7 + petr gajdos + describe 'rootflags' and 'rootdelay' kernel parameters + patch based on text from documentation/kernel-parameters.txt + +charsets.7 + marko myllynen + update to reflect past developments + rewrite the introduction to make unicode's prominence more obvious. + reformulate parts of the text to reflect current unicode world. + minor clarification for ascii/iso sections, some other minor fixes. + marko myllynen + list cjk encodings in the order of c, j, k + +environ.7 + michael kerrisk + see also: add env(1), printenv(1), ld.so(8) + +locale.7 + marko myllynen + add some see also references + +man-pages.7 + michael kerrisk + note that .th 'date' field is nowadays automatically updated by scripts + +signal.7 + michael kerrisk + describe eintr semantics for recvmmsg(2) + michael kerrisk + clarify text describing eintr semantics for socket interfaces + +unicode.7 + marko myllynen + update to reflect past developments + the unicode(7) page will look more modern with few small changes: + + - drop old bugs section, editors cope with utf-8 ok these days, + and perhaps the state-of-the-art is better described elsewhere + anyway than in a man page + - drop old suggestion about avoiding combined characters + - refer to lanana for linux zone, add registry file reference + - drop a reference to an inactive/dead mailing list + - update some reference urls + +utf-8.7 + marko myllynen + drop an old comment about utf-8 replacing iso 8859 + and add locale(1) under see also. + + +==================== changes in man-pages-3.70 ==================== + +released: 2014-07-08, munich + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +carlos o'donell +elie de brauwer +florian weimer +heinrich schuchardt +marko myllynen +michael kerrisk +nadav har'el +neilbrown +rich felker +robert p. j. day +simon paillard +tomi salminen +walter harms +yuri kozlov +кирилл + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +sprof.1 + michael kerrisk [marko myllynen] + new page for the glibc sprof(1) command + + +newly documented interfaces in existing pages +--------------------------------------------- + +epoll_ctl.2 + neilbrown + document epollwakeup + +epoll.7 + neilbrown + document epollwakeup + + +changes to individual pages +--------------------------- + +iconv.1 +iconvconfig.8 + marko myllynen + clarify gconv file terminology a bit + +ldd.1 + michael kerrisk + see also: add sprof(1) + +connect.2 + michael kerrisk + errors: add eprototype + see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=708394 + +dup.2 + michael kerrisk [rich felker] + fix erroneous discussion regarding closing 'newfd' before calling dup2() + and propose a workaround if the caller cares about catching + close() time errors. + + see http://stackoverflow.com/questions/23440216/race-condition-when-using-dup2#comment36888604_23444465 + and http://austingroupbugs.net/view.php?id=411 + michael kerrisk + rework and enhance discussion of dup2() + in particular, note that dup2() performs the steps of closing + and reusing 'newfd' atomically. + michael kerrisk + add subhead for dup3() + +epoll_ctl.2 + michael kerrisk + bugs: epollwakeup is silently ignored without cap_block_suspend + if the caller does not have cap_block_suspend, then epollwakeup + is silently ignored. + +fcntl.2 + michael kerrisk [tomi salminen] + the return value for f_setpipe_sz is the pipe capacity + michael kerrisk + errors: document enotdir error for f_notify + michael kerrisk + use proper page cross-references in f_notify discussion + michael kerrisk + suggest the use of real-time signals with f_notify + +getitimer.2 + michael kerrisk + rewrite a few pieces to clarify some details + +inotify_add_watch.2 + michael kerrisk + clarify that the target of a watch is an i-node + the target of a watch is an i-node, not a pathname. clarify + the text to prevent the reader possibly misunderstanding + that establishing watches by two different links to the same + file might create different watch descriptors. + +open.2 + michael kerrisk [кирилл] + o_cloexec is also one the flags not ignored when o_path is specified + +pipe.2 + elie de brauwer + pipe_buf is defined in limits.h + to make use of pipe_buf in an application one should include + . adding a reference to this inclusion. + +poll.2 + michael kerrisk [nadav har'el] + the negate-fd-to-ignore technique does not work for file descriptor 0 + see https://bugzilla.kernel.org/show_bug.cgi?id=79411 + +set_tid_address.2 + michael kerrisk [rich felker] + use "thread" rather than "process" in description + michael kerrisk + see also: add gettid(2) + +shmop.2 + michael kerrisk + explain shmlba in much more detail + +splice.2 + michael kerrisk + document eagain error + see https://bugzilla.kernel.org/show_bug.cgi?id=48641 + +syscalls.2 + carlos o'donell + add prlimit64(2) + while trying to reconcile the new features in glibc with the + documented entries in the linux kernel man pages i noticed that + glibc exports prlimit64 for use by 32-bit applications (as does + the linux kernel), but that prlimit64 was not defined in the + syscalls list or in the prlimit-related page. + + this is not the complete fix for this, but i don't have the time + to explain why and when prlimit64 should be used (or how it should + be used safely). therefore i'm just patching the syscalls.2 list + to show that prlimit64 exists and was added in 2.6.36 (verified + with git by checking out the tags before and after). + +syslog.2 + michael kerrisk + rework introductory paragraph + michael kerrisk [robert p. j. day] + rework text describing loglevels + the kernel header file mentioned in the discussion of the kern_* + constants has morphed and is no longer exported inside glibc. + and the definitions of the constants themselves changed subtly + with kernel commit 04d2c8c83d0e3ac5f78aeede51babb3236200112. + so, rewrite the description of the constants to be a bit more + abstract. + michael kerrisk + rewrite parts of the page, and import /proc/sys/kernel/printk + * move /proc/sys/kernel/printk from proc(5) to this page, + and correct various details in the discussion of that file. + * rewrite and correct various other details on the page. + * clean out some crufty text. + * miscellaneous minor fixes. + michael kerrisk + update syslog_action_console_off + syslog_action_console_on description + details changed in linux 2.6.32 + +tee.2 + michael kerrisk + document eagain error + see https://bugzilla.kernel.org/show_bug.cgi?id=48641 + +vmsplice.2 + michael kerrisk + document eagain error + see https://bugzilla.kernel.org/show_bug.cgi?id=48641 + +ether_aton.3 + michael kerrisk + make description of ether_line() bug a little more informative + +mallopt.3 + michael kerrisk [florian weimer] + malloc_mmap_threshold_ and malloc_mmap_max_ *do* work in setgid programs + my testing on this point was bogus, overlooking details of + strace(1)'s behavior with setuid programs. + + see https://sourceware.org/bugzilla/show_bug.cgi?id=12155 + +printf.3 + michael kerrisk [rich felker] + remove libc4 and libc5 details + rich felker noted that "scare text" in the man page warned about + the use of snprintf() on libc, and that some people had cited + this as a reason not to use snprintf(). linux libc is now + ancient history, so there is no real need to keep that text. + but, while we're at it, we may as well clear out all of the + other ancient libc4 and libc5 pieces in the page. they are + nowadays more clutter than help. + michael kerrisk + susv3 and later agree with c99 for the snprintf() return value + determined by inspection of the susv3 and susv4 specifications. + michael kerrisk + remove some old text about glibc 2.0 changes + we probably don't now need such ancient info. + michael kerrisk + update references to standards for c and s conversion specifiers + +profil.3 + michael kerrisk + see also: add sprof(1) + +charmap.5 + marko myllynen + various minor updates and improvements + - more precise title + - extend description a bit + - document previously omitted width_default + marko myllynen + remove accidental iso c compliance reference + glibc refers in locale/programs/charmap.c to iso c 99 section + 7.17.(2) and iso c 99 section 5.2.1.(3) that if a character map + is not ascii compatible then the locale using it is not iso c + compliant. this does not state anything about the character set + itself. + +proc.5 + michael kerrisk + replace /proc/sys/kernel/printk discussion with reference to syslog(2) + it makes more sense to have the /proc/sys/kernel/printk with + the related material in syslog(2). + michael kerrisk + rewrite /proc/sys/kernel/printk description + +inotify.7 + michael kerrisk + clarify which events are generated for watched directories + really, with respect to watched directories, events fall into + three classes (not two, as was shown): + + * events that can be generated only for the watched directory. + * events that can be generated only for objects that are inside + the watched directory. + * events that can be generated both for the watched directory + and for objects inside the directory. + + so, mark these three classes more clearly in the list of inotify + events. + heinrich schuchardt [michael kerrisk] + bugs: note possible bug triggered by watch descriptor reuse + watch descriptor ids are returned by inotify_add_watch(). + when calling inotify_rm_watch() an in_ignored is placed on the + inotify queue pointing to the id of the removed watch. + + inotify_add_watch() should not return a watch descriptor id for + which events are still on the queue but should return an + unused id. + + unfortunately, the existing kernel code does not provide such a + guarantee. + + actually, in rare cases watch descriptor ids are returned by + inotify_add_watch() for which events are still on the inotify + queue. + + see https://bugzilla.kernel.org/show_bug.cgi?id=77111 + michael kerrisk + add further detail to the watch descriptor reuse bug + as well as inotify_rm_watch(), file deletion and unmounting a + filesystem can also cause a watch descriptor to be deleted. + michael kerrisk + the watch descriptor reuse bug may be hard to hit in practice + explain the circumstances in detail, indicating that the + bug may be very unlikely to occur in practice. + michael kerrisk + clarify description of in_excl_unlink + clarify the text a little, in particular making it clearer + that the target of a watch is an i-node (not a pathname). + michael kerrisk + clarify in_oneshot explanation + make it clearer that the target of monitoring is an i-node, + not a pathname. + michael kerrisk + make comment on 'mask' field more accurate + +libc.7 + michael kerrisk + clarify man-pages policy on documenting c libraries other than glibc + michael kerrisk + use absolute dates in discussion of libc vs glibc + +pipe.7 + elie de brauwer + add reference that the pipe capacity can be changed + in fcntl(2) f_setpipe_sz, f_getpipe_sz and + /proc/sys/fs/pipe-max-size are defined, however + pipe(7) still defines the pipe capacity as being + a static entity. adding a reference to fcntl(2). + michael kerrisk [walter harms] + clarify that since 2.6.35, 65535 bytes is the default pipe capacity + +ld.so.8 + michael kerrisk + clarify that ld_profile can specify just a single shared object + michael kerrisk + clarify that ld_profile output is appended to target file + the ld_profile output is appended to any existing + contents of the target file. + michael kerrisk + see also: add sprof(1) + + +==================== changes in man-pages-3.71 ==================== + +released: 2014-08-17, chicago + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +adrian bunk +damir nedzibovic +david prévot +d. barbier +jakub wilk +jan chaloupka +marko myllynen +michael kerrisk +mike frysinger +neilbrown +paul jackson +peng haitao +rahul bedarkar +rob landley +ryan hammonds +simon paillard +ville ylenius +vince weaver +yuri kozlov + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +group_member.3 + michael kerrisk + new page documenting group_member(3) + +isfdtype.3 + michael kerrisk + new page documenting isfdtype(3) + + +newly documented interfaces in existing pages +--------------------------------------------- + +perf_event_open.2 + vince weaver + document new comm_exec flag + linux 3.16 (more specifically, commit 82b897782d10fcc4 ) + added support for differentiating between process renames + caused by exec versus those caused by other methods. + vince weaver + document new mmap2 record type + linux 3.16 (more specifically, commit a5a5ba72843dd05f9 ) + enabled the enhanced mmap2 record support. + the interface was added in linux 3.12 but disabled until + linux 3.16. + vince weaver + document perf_sample_branch_cond + linux 3.16 (more specifically, commit bac52139f0b7ab31330 ) + adds support for gathering perf_sample_branch_cond + conditional branch values when doing perf_sample_branch_stack + sampling. + +proc.5 + michael kerrisk + document /proc/pid/comm + michael kerrisk + document /proc/pid/pagemap + michael kerrisk + document /proc/pid/personality + michael kerrisk + document /proc/pid/syscall + michael kerrisk + document /proc/kpagecount + michael kerrisk + document /proc/kpageflags + michael kerrisk + document /proc/sys/vm/overcommit_kbytes + +capabilities.7 + michael kerrisk + add cap_audit_read + cap_audit_read is new in linux 3.16. + + +global changes +-------------- + +ldd.1 +clone.2 +execve.2 +getpagesize.2 +ioperm.2 +msgop.2 +readv.2 +recv.2 +select.2 +send.2 +seteuid.2 +shmop.2 +signal.2 +sync.2 +sysinfo.2 +utime.2 +abs.3 +atoi.3 +catopen.3 +clearenv.3 +ctime.3 +des_crypt.3 +ecvt.3 +flockfile.3 +fseeko.3 +ftime.3 +ftok.3 +ftw.3 +getcwd.3 +getdtablesize.3 +getline.3 +getpass.3 +getpass.3 +getutent.3 +glob.3 +insque.3 +lseek64.3 +memmem.3 +mkstemp.3 +mktemp.3 +on_exit.3 +openpty.3 +putenv.3 +putenv.3 +qecvt.3 +realpath.3 +realpath.3 +remove.3 +setbuf.3 +sigpause.3 +strftime.3 +strptime.3 +tzset.3 +xcrypt.3 +utmp.5 +environ.7 +ipv6.7 +packet.7 + michael kerrisk + remove ancient linux libc details + +access.2 +brk.2 +chmod.2 +eventfd.2 +gethostname.2 +getpriority.2 +mmap.2 +poll.2 +ptrace.2 +readv.2 +sched_setaffinity.2 +select.2 +seteuid.2 +signalfd.2 +sync_file_range.2 +timer_create.2 +uname.2 +wait.2 + michael kerrisk + notes: add "c library/kernel abi differences" subheading + + +changes to individual pages +--------------------------- + +access.2 + michael kerrisk + glibc falls back to using access() on kernels that lack faccessat() + +bdflush.2 +fsync.2 +sync.2 +proc.5 + adrian bunk + change "sync(1)" to "sync(8)" + +bind.2 + michael kerrisk [ryan hammonds] + correct einval error description + as pointed out by ryan: + + my application is trying to bind an ipv4 udp socket to an + address. i've found that passing an invalid address length + to bind() causes bind to return einval. according to the + bind(2) manpage, this should only occur when using unix + domain sockets (which i am not). + +chmod.2 + michael kerrisk + glibc falls back to chmod() on kernels that don't support fchmodat() + michael kerrisk + glibc falls back to chown()/lchown() on kernels that lack fchownat() + +epoll_wait.2 + michael kerrisk + notes: describe raw epoll_pwait() system call differences + +getgroups.2 + michael kerrisk + see also: add group_member(3) + +getpriority.2 + michael kerrisk + enhance discussion of kernel nice range versus user-space nice range + michael kerrisk + move text describing nice range on other systems + +getrlimit.2 + michael kerrisk + add cross reference to core(5) in discussion of rlimit_core + michael kerrisk + describe the "large" resource limit bug on 32-bit platforms + see https://bugzilla.kernel.org/show_bug.cgi?id=5042. + michael kerrisk + glibc's setrlimit() and getrlimit() are implemented using prlimit() + +kexec_load.2 + michael kerrisk + note limit of 16 for 'nr_segments' + michael kerrisk + clarify the 'flags' bits that contain the architecture + michael kerrisk + add kexec_arch_68k to list of architectures for 'flags' + michael kerrisk + reword description of 'flags' a little + +link.2 + michael kerrisk + glibc falls back to link() on kernels that lack linkat() + unless 'flags' contains at_symlink_follow. + +mkdir.2 + michael kerrisk + glibc falls back to mkdir() on kernels that don't support mkdirat() + +perf_event_open.2 + vince weaver + clarify perf_sample_stack_user usage + this clarifies the perf_sample_stack_user section. + i found these issue while implementing some code that uses + the option. the important change is fixing the name of the + sample_stack_user parameter, the rest is just some wording + fixes and minor clarifications. + vince weaver + clarify perf_sample_data_src usage + when checking the fields in the perf_sample_data_src type samples + you need to shift the masks before doing the compare. + + although the value you are checking (perf_mem_data_src) is + specified as a bitfield so this might all fall apart if trying + to access the field in a cross-endian way. the power people + were working on this issue, not sure if they resolved it. + +poll.2 + michael kerrisk + describe fifth argument (sigsetsize) of raw ppoll() system call + +process_vm_readv.2 + michael kerrisk [ville ylenius] + fix typo in example program + +readlink.2 + michael kerrisk + glibc falls back to readlink() on kernels that lack readlinkat() + +recv.2 + michael kerrisk + 'addrlen' should be null (not 0) if we don't need sender address + +rename.2 + michael kerrisk + glibc falls back to rename() when the kernel doesn't have renameat() + +sigwaitinfo.2 + michael kerrisk + the raw sigtimedwait() system call has a fifth argument + +symlink.2 + michael kerrisk + glibc falls back to symlink() on kernels that lack symlinkat() + +sysinfo.2 + michael kerrisk + add versions section + +unlink.2 + michael kerrisk + glibc falls back to unlink() or rmdir() on kernels that lack unlinkat() + +atoi.3 + michael kerrisk + downgrade discussion of atoq() + remove most references to atoq() in this page, since this function + was present only in linux libc (not glibc). + +cerf.3 +cexp2.3 +clog2.3 + michael kerrisk + update version number on "not yet in glibc" sentence + +fgetgrent.3 +getgrent.3 +getgrent_r.3 +getgrnam.3 + michael kerrisk [rob landley] + clarify that 'gr_mem' is a null-terminated array of pointers + +fseeko.3 + michael kerrisk + add versions section + +ftw.3 + michael kerrisk + add versions section + +getauxval.3 + michael kerrisk + document enoent error + and add an entry to bugs explaining the ambiguity that was + present before the addition of this error. + +getgrouplist.3 + michael kerrisk + see also: add group_member(3) + +getline.3 + rahul bedarkar + close opened file at end of example program + +memmem.3 + michael kerrisk + rewrite text of glibc 2.0 bug + +printf.3 + michael kerrisk [jakub wilk] + clarify details of the %n conversion specifier + see http://bugs.debian.org/756602 + michael kerrisk [jakub wilk] + note use of 'j', 'z', and 't' length modifiers for '%n' + see http://bugs.debian.org/756602 + michael kerrisk + update with some susv3 details + +setbuf.3 + michael kerrisk + remove ancient linux libc and 4.x bsd details + +strstr.3 + michael kerrisk + remove discussion of linux libc bugs + linux libc is old enough that we needn't care any longer. + +strtod.3 + michael kerrisk + explain nan(n-char-sequence) + +strtod.3 + michael kerrisk + see also: add nan(3), nanf(3), nanl(3) + +updwtmp.3 + michael kerrisk + replace availability section with note to link logwtmp() using -lutil + linux libc details are no longer needed these days. + +core.5 + rahul bedarkar + close opened file in example program + +proc.5 + michael kerrisk + fix kernel version numbers for /proc/pid/stat fields + +proc.5 + jan chaloupka + add missing proc stats fields + adding missing proc stats fields from + https://www.kernel.org/doc/documentation/filesystems/proc.txt + michael kerrisk [simon paillard] + remove crufty text under 'timer_stats' + michael kerrisk + update /proc/pid/stat 'state' field documentation + michael kerrisk + improve description of /proc/pid/stat fields added in linux 3.3 and 3.5 + michael kerrisk + refer to getauxval(3) in discussion of /proc/pid/auxv + michael kerrisk + rework formatting of /proc/pid/stat list + make the field numbers more prominent. + michael kerrisk + note that /proc/pid/cmdline is read-only + michael kerrisk + rework discussion of commitlimit and /proc/sys/vm/overcommit_memory + michael kerrisk + improve discussion of /proc/sys/vm/overcommit_ratio + +charsets.7 + david prévot [marko myllynen] + tidy up list + remove german from main list, to be consistent with earlier + removal of dutch and french (in commit a8ed5f7430e0d1). + +inotify.7 + michael kerrisk + note that in_only_dir can be used to avoid races + michael kerrisk + note that insertion of in_moved_from+in_moved_to pair is not atomic + michael kerrisk + mention use of timeout when reading in_moved_to after in_moved_from + +man-pages.7 + michael kerrisk + add description of "c library/kernel abi differences" subsection + michael kerrisk + rework text describing sections (stylistic improvements) + +vdso.7 + mike frysinger + add new i386 vdso symbols in linux 3.15 + michael kerrisk + note kernel version that exports new i386 symbols (linux 3.15) + + +==================== changes in man-pages-3.72 ==================== + +released: 2014-09-07, mountain view + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +christian von roques +holger hans peter freyther +michael haardt +michael kerrisk +mike frysinger +peter schiffer +rusty russell +sorin dumitru + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +memusage.1 + peter schiffer, michael kerrisk [jan chaloupka] + new page for glibc memusage(1) command + +memusagestat.1 + peter schiffer [jan chaloupka, michael kerrisk] + new page for glibc memusagestat(1) command + +mtrace.1 + peter schiffer [jan chaloupka] + new page describing the glibc mtrace(1) command + + +changes to individual pages +--------------------------- + +connect.2 + michael haardt + note that a new socket should be used if connect() fails + +fcntl.2 + michael kerrisk + one must define _gnu_source to get the f_ofd_* definitions + +poll.2, select.2 + rusty russell + fix erroneous description of "available for write". + posix says: "pollout normal data may be written without + blocking.". this "may" is misleading, see the posix + write page: + + write requests to a pipe or fifo shall be handled in the + same way as a regular file with the following exceptions: + ... + if the o_nonblock flag is clear, a write request may cause + the thread to block, but on normal completion it shall + return nbyte. + ... + when attempting to write to a file descriptor (other than a + pipe or fifo) that supports non-blocking writes and cannot + accept the data immediately: + + if the o_nonblock flag is clear, write() shall block the + calling thread until the data can be accepted. + + if the o_nonblock flag is set, write() shall not block the + thread. if some data can be written without blocking the + thread, write() shall write what it can and return the + number of bytes written. otherwise, it shall return -1 and + set errno to [eagain]. + + the net result is that write() of more than 1 byte on a + socket, pipe or fifo which is "ready" may block: write() + (unlike read!) will attempt to write the entire buffer and + only return a short write under exceptional circumstances. + + indeed, this is the behaviour we see in linux: + + https://github.com/rustyrussell/ccan/commit/897626152d12d7fd13a8feb36989eb5c8c1f3485 + https://plus.google.com/103188246877163594460/posts/bktgtmhdfgz + +errno.3 + michael kerrisk + see also: add errno(1) + +rtnetlink.3 + holger hans peter freyther + fix parameters for the send() call in the example + +inotify.7 + michael kerrisk + in_open and in_close_nowrite can also occur for directories + michael kerrisk + in_close_write occurs only for files (not monitored directory) + michael kerrisk + in_modify is generated for files only (not monitored directories) + michael kerrisk + in_access occurs only for files inside directories + in_access does not occur for monitored directory. + +packet.7 + sorin dumitru + fix include file + it looks like most of the socket options from this man pages + are not defined in . they are defined in + so we should include that one. + + +==================== changes in man-pages-3.73 ==================== + +released: 2014-09-21, munich + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +david prévot +eric w. biederman +j. bruce fields +justin cormack +lorenzo beretta +michael kerrisk +rob landley +serge e. hallyn +serge hallyn +vasily kulikov +vincent lefevre +vitaly rybnikov +yuri kozlov + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +namespaces.7 + michael kerrisk [eric w. biederman] + new page providing overview of linux namespaces + +pid_namespaces.7 + michael kerrisk [eric w. biederman, vasily kulikov, rob landley, + serge hallyn] + new page describing pid namespaces + +user_namespaces.7 + michael kerrisk [eric w. biederman, andy lutomirski, serge hallyn] + new page describing user namespaces. + + +newly documented interfaces in existing pages +--------------------------------------------- + +clone.2 + eric w. biederman [michael kerrisk] + document clone_newuser for creating a new user namespace + +setns.2 + eric w. biederman, michael kerrisk + document the pid, user, and mount namespace support + document clone_newpid, clone_newuser, and clone_newns flags. + +unshare.2 + michael kerrisk [eric w. biederman] + document clone_newpid + michael kerrisk [eric w. biederman] + document clone_newuser + michael kerrisk + document clone_thread, clone_sighand, and clone_vm + + +changes to individual pages +--------------------------- + +clone.2 + michael kerrisk + move some clone_newnet text to namespaces.7 + michael kerrisk + move some clone_newuts text 2 to namespaces.7 + michael kerrisk + move some clone_newipc text to namespaces.7 + michael kerrisk + reword discussion of clone_newns, removing text also in namespaces(7) + michael kerrisk + standardize text on clone_new* flags and cap_sys_admin + michael kerrisk + einval if (clone_newuser|clone_newpid) && (clone_thread|clone_parent) + michael kerrisk + add more detail on the meaning of clone_sysvsem + +flock.2 + michael kerrisk [j. bruce fields] + don't mention "classical bsd" in discussion of fcntl()/flock interaction + the noninteraction of flock(2) and fcntl(2) locks does + not seem to be classical bsd semantics (at least, checking + the 4.4bsd sources suggest that the lock types do interact, + although there have been other systems also where fcntl() + and flock() locks do not interact). so, fix the text + discussing "classical bsd" lock semantics. + +getunwind.2 + michael kerrisk [yuri kozlov] + fix description of return value + s/size of unwind table/size of the unwind data/ + +mount.2 + eric w. biederman + clarify use of 'mountflags' and 'data' for ms_remount + +reboot.2 + michael kerrisk [justin cormack, eric w. biederman] + document effect of reboot() inside pid namespaces + +semop.2 + michael kerrisk + refer to clone(2) for semantics of clone_sysvsem and semadj lists + +seteuid.2 +setgid.2 +setresuid.2 +setreuid.2 +setuid.2 + michael kerrisk + einval can occur if uid/gid is not valid in caller's user namespace + +setns.2 + michael kerrisk [eric w. biederman] + clarify capabilities required for reassociating with a mount namespace + michael kerrisk + specify kernel version on each clone_new* flag + and remove text on flags from versions. + +unshare.2 + michael kerrisk + add an example program + michael kerrisk + clarify semantics of clone_sysvsem + michael kerrisk + clone_sysvsem does not require cap_sys_admin + michael kerrisk + note flags implied by clone_thread and clone_vm + +clock.3 + michael kerrisk [vincent lefevre] + the implementation uses clock_gettime() was to improve *accuracy* + (the man page text mistakenly used the word "precision".) + +drand48.3 + michael kerrisk [lorenzo beretta] + remove crufty text about svid 3 marking drand48() obsolete + see http://bugs.debian.org/758293 + +proc.5 + michael kerrisk + move /proc/[pid]/mounts text to namespaces.7 + michael kerrisk + move /proc/[pid]/mountstats text to namespaces.7 + +capabilities.7 + michael kerrisk + refer reader to user_namespaces(7) for a discussion of capabilities + michael kerrisk + document cap_setuid and cap_setgid for user namespace mappings + michael kerrisk + setns() needs cap_sys_admin in the *target* namespace + michael kerrisk + since linux 3.8, user namespaces no longer require cap_sys_admin + +mq_overview.7 + michael kerrisk + refer to namespaces(7) for info on posix mqs and ipc namespaces + +svipc.7 + michael kerrisk + refer to namespaces(7) for info on system v ipc and ipc namespaces + + +==================== changes in man-pages-3.74 ==================== + +released: 2014-10-03, munich + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +arto bendiken +ben hutchings +benjamin herr +c. alex north-keys +carlos o'donell +cyril hrubis +davidlohr bueso +doug ledford +elie de brauwer +heinrich schuchardt +jonny grant +lanchon +manfred spraul +marko myllynen +michael kerrisk +shriramana sharma +thomas mack +wieland hoffmann + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +pldd.1 + michael kerrisk + new page for pldd(1) command added to glibc in version 2.15 + +cp1252.7 + marko myllynen + new page documenting cp 1252 + cp 1252 is probably one of the most used windows code pages so + let's add a page for it alongside with the already provided + cp 1251 page. + + table generated from /usr/share/i18n/charmaps/cp1252. + + +newly documented interfaces in existing pages +--------------------------------------------- + +mq_overview.7 + michael kerrisk + document /proc/sys/fs/mqueue/msgsize_default + michael kerrisk + document /proc/sys/fs/mqueue/msg_default + + +changes to individual pages +--------------------------- + +ldd.1 + michael kerrisk + see also: add pldd(1) + +execve.2 + michael kerrisk [c. alex north-keys] + remove unneeded ".sh" extension in interpreter script example + see https://bugzilla.kernel.org/show_bug.cgi?id=84701 + +fanotify_init.2 + heinrich schuchardt + bugs: o_cloexec is ignored + michael kerrisk [heinrich schuchardt] + the 'event_f_flags' failure to check invalid flags was fixed in 3.15 + +fanotify_mark.2 + michael kerrisk + note that various bugs were fixed in linux 3.16 + +getrlimit.2 + michael kerrisk [doug ledford] + since linux 3.5, the accounting formula for rlimit_msgqueue has changed + +open.2 + michael kerrisk [shriramana sharma] + fix number and formula in description of eoverflow error + +readlink.2 + michael kerrisk [ben hutchings] + fix description of readlinkat() with empty 'pathname' + michael kerrisk + see also: add realpath(3) + +sched_setattr.2 +sched_setscheduler.2 + michael kerrisk + see also: add chrt(1) + +shmget.2 + manfred spraul [michael kerrisk, davidlohr bueso] + update for increase of shmall and shmmax + the default values of shmall and shmmax have been increased. + +syscalls.2 + michael kerrisk + add 3 new system calls added in linux 3.17 + +vmsplice.2 + cyril hrubis + vmsplice() does not fail when nr_segs==0 + this nr_segs==0 case is no-op; the call succeeds and no + einval error is returned. + +dlopen.3 + michael kerrisk + see also: add pldd(1) + +fseeko.3 + michael kerrisk [thomas mack] + _file_offset_bits must be defined before including any header file + +getgrent.3 + carlos o'donell + add enoent and eagain to error list + +mq_getattr.3 + michael kerrisk + add an example program + the example program can be used to discover the default + 'mq_maxmsg' and 'mq_msgsize' values used to create a queue with + a mq_open(3) call in which 'attr' is null. + +mq_open.3 + michael kerrisk + two /proc files control the defaults for the attrp==null case + refer the reader to the discussion in mq_overview(7) for a + discussion of these files, which exist since linux 3.5. + +realpath.3 + michael kerrisk + see also: add realpath(1) + +proc.5 + elie de brauwer + document /proc/buddyinfo + this patch adds a short description about the contents of + /proc/buddyinfo and how this file can be used to assist + in checking for memory fragmentation issues. + michael kerrisk + mention pmap(1) in discussion of /proc/pid/smaps + +armscii-8.7 + marko myllynen + charset pages unification, minor cleanups + +ascii.7 + marko myllynen + charset pages unification, minor cleanups + this and [the related *.7] patches will provide unification of + charset pages, minor cleanups, and some unifying cosmetic + changes. references are adjusted so that all pages include + a reference to charsets(7), which contains a description of + these sets, stray comments are removed, some obsolete + statements (like iso 8859-1 being the de-facto ascii + replacement) are removed, and some minor reformatting + to minimize diff's between the pages are done. + + the actual substance, the character tables, remain unchanged. + + this series changes the following pages (under man7): ascii, + armscii, cp1251, koi8-r, koi8-u, and all of iso_8859-*. + +cp1251.7 + marko myllynen + charset pages unification, minor cleanups + +iso_8859-10.7 + marko myllynen + charset pages unification, minor cleanups + +iso_8859-11.7 + marko myllynen + charset pages unification, minor cleanups + +iso_8859-13.7 + marko myllynen + charset pages unification, minor cleanups + +iso_8859-14.7 + marko myllynen + charset pages unification, minor cleanups + +iso_8859-15.7 + marko myllynen + charset pages unification, minor cleanups + +iso_8859-16.7 + marko myllynen + charset pages unification, minor cleanups + +iso_8859-1.7 + marko myllynen + charset pages unification, minor cleanups + +iso_8859-2.7 + marko myllynen + charset pages unification, minor cleanups + +iso_8859-3.7 + marko myllynen + charset pages unification, minor cleanups + +iso_8859-4.7 + marko myllynen + charset pages unification, minor cleanups + +iso_8859-5.7 + marko myllynen + charset pages unification, minor cleanups + +iso_8859-6.7 + marko myllynen + charset pages unification, minor cleanups + +iso_8859-7.7 + marko myllynen + charset pages unification, minor cleanups + +iso_8859-8.7 + marko myllynen + charset pages unification, minor cleanups + +iso_8859-9.7 + marko myllynen + charset pages unification, minor cleanups + +koi8-r.7 + marko myllynen + charset pages unification, minor cleanups + - remove stray comments, streamline description + (charsets(7) and wikipedia provide more detailed + and up-to-date description) + - list differences between koi8-r.7 vs koi8-u.7 + +koi8-u.7 + marko myllynen + charset pages unification, minor cleanups + - remove stray comments, streamline description + (charsets(7) and wikipedia provide more detailed + and up-to-date description) + - list differences between koi8-r.7 vs koi8-u.7 + +mq_overview.7 + michael kerrisk + update queues_max details for linux 3.14 + and in general rework the text a little. + michael kerrisk + update discussion of hard_msgmax + the limit has changed in 2.6.33 and then again in 3.5. + michael kerrisk [arto bendiken] + update details for 'queues_max' limit + things changed in linux 3.5. + see https://bugs.launchpad.net/bugs/1155695 + michael kerrisk + update details on defaults and ceiling for 'msgsize_max' limit + michael kerrisk + rework discussion of hard_msgmax + michael kerrisk [davidlohr bueso] + various fixes after review from davidlohr bueso + +sched.7 + michael kerrisk + see also: add taskset(1) + +ld.so.8 + michael kerrisk + see also: add pldd(1) + michael kerrisk + see also: add dlopen(3) + michael kerrisk + see also: add ld(1) + + + +==================== changes in man-pages-3.75 ==================== + +released: 2014-10-15, düsseldorf + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +jonny grant +michael kerrisk +robert schweikert +tetsuo handa +walter harms + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +pthread_rwlockattr_setkind_np.3 + robert schweikert [michael kerrisk] + new page documenting pthread_rwlockattr_[sg]etkind_np(3) + documents pthread_rwlockattr_setkind_np(3) and + pthread_rwlockattr_getkind_np(3). + + +new and changed links +--------------------- + +pthread_rwlockattr_getkind_np.3 + robert schweikert + new link to pthread_rwlockattr_setkind_np(3) + + +changes to individual pages +--------------------------- + +readlink.2 + michael kerrisk [jonny grant] + add free() call to example program + +readv.2 + michael kerrisk + the raw preadv() and pwritev() syscalls split 'offset' into 2 arguments + +signal.7 + michael kerrisk + pthread_mutex_lock() and pthread_cond_wait() are restartable + pthread_mutex_lock(, pthread_cond_wait(), and related apis are + automatically restarted if interrupted by a signal handler. + +unix.7 + michael kerrisk [carlos o'donell, david miller, tetsuo handa] + various additions and rewordings + notable changes: + * clarify some details for pathname sockets. + * add some advice on portably coding with pathname sockets. + * note the "buggy" behavior for pathname sockets when + the supplied pathname is 108 bytes (after a report by + tetsuo handa). + + +==================== changes in man-pages-3.76 ==================== + +released: 2014-12-31, munich + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +adam jiang +andrea balboni +andreas schwab +bernhard walle +carlos o'donell +david wragg +florian westphal +heinrich schuchardt +huxiaoxiang +jan chaloupka +jonathan wakely +jonny grant +josh triplett +kamezawa hiroyuki +laurent georget +manuel lópez-ibáñez +marko myllynen +ma shimiao +mel gorman +michael gehring +michael haardt +michael kerrisk +mike frysinger +rasmus villemoes +richard weinberger +rich felker +scott harvey +siddhesh poyarekar +simon newton +simon paillard +sven hoexter +tobias werth +weijie yang +will newton +yuri kozlov +刘湃 +尹杰 + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +adjtimex.2 + laurent georget + add fields in struct timex description + this patch updates the man page with the new fields added in + struct timex since last edition of the man page. + laurent georget [michael kerrisk] + document adj_tai + michael kerrisk + improve description of adj_offset_singleshot + michael kerrisk + add brief documentation of adj_micro and adj_nano + michael kerrisk + reformat return value list + and remove numeric values, since they're not needed + michael kerrisk + other 'modes' bits are ignored on adj_offset_* + other bits in 'modes' are ignored if modes contains + adj_offset_singleshot or adj_offset_ss_read. + michael kerrisk + add nanosecond details + fixes https://bugzilla.kernel.org/show_bug.cgi?id=61171. + michael kerrisk + document adj_offset_ss_read + michael kerrisk + reformat 'times' flags as list + and remove numeric values, since they're not needed. + michael kerrisk + note effect of adj_nano for adj_setoffset + michael kerrisk + add comment noting that timex structure contains padding bytes + michael kerrisk + add more details to description of 'tai' field + michael kerrisk + note meaning of "pll" abbreviation + michael kerrisk + clarify which 'timex' field is used by each 'modes' bit + michael kerrisk + document timex 'status' bits + michael kerrisk + clarify treatment of other 'modes' bits for adj_offset_* + michael kerrisk + update rfc number: rfc 5905 obsoletes rfc 1305 + michael kerrisk + briefly document adj_setoffset + michael kerrisk + note pps (pulse per second) fields in timex structure + +sigreturn.2 + michael kerrisk + add (a lot) more detail on the signal trampoline + and rewrite much of the page. + + +newly documented interfaces in existing pages +--------------------------------------------- + +proc.5 + bernhard walle + document /proc/thread-self + /proc/thread-self has been introduced in linux 3.17 with + commit 0097875bd41528922fb3bb5f348c53f17e00e2fd. + sven hoexter [michael kerrisk, kamezawa hiroyuki] + document "vmswap" field of /proc/[pid]/status + florian westphal + document /proc/net/netfilter/nfnetlink_queue + + +changes to individual pages +--------------------------- + +localedef.1 + marko myllynen + mention default path for compiled files + +clock_nanosleep.2 + michael kerrisk + note that 'clock_id' can also be a cpu clock id + +epoll_ctl.2 + michael kerrisk + regular files and directories can't be monitored with epoll_ctl() + +ioctl.2 + heinrich schuchardt + rename 'd' argument to 'fd' in text + in most other manpages file descriptors are called 'fd'. + this patches renames attribute 'd' to 'fd'. + +madvise.2 + michael kerrisk + versions: support for madvise() is now configurable + support for this system call now depends on the + config_advise_syscalls configuration option. + +open.2 + michael kerrisk + enhance rationale discussion for openat() and friends + +posix_fadvise.2 + mel gorman + document the behavior of partial page discard requests + it is not obvious from the interface that "partial page discard" + requests are ignored. it should be spelled out. + michael kerrisk [weijie yang] + errors: since 2.6.16, the kernel correctly deals with the espipe case + michael kerrisk + support for fadvise64() is now configurable + support for this system call now depends on the + config_advise_syscalls configuration option. + +prctl.2 + andreas schwab + correct description of null-termination in pr_get_name and pr_set_name + the size of the process name has always been at most 16 byte + _including_ the null terminator. this also means that the + name returned by pr_get_name is always null-terminated. + michael kerrisk + pr_set_name silently truncates strings that exceed 16 bytes + +restart_syscall.2 + michael kerrisk + add some text explaining why restart_syscall() exists + +sched_setaffinity.2 + michael kerrisk + notes: add paragraph on how to discover set of cpus available on system + michael kerrisk + see also: add nproc(1) and lscpu(1) + +select.2 + michael kerrisk + see also: add restart_syscall(2) + +semop.2 + michael kerrisk + add note that interrupted semtimedop() returns 'timeout' unchanged + michael kerrisk + remove information about semtimedop() eagain that is repeated elsewhere + michael kerrisk + add subsection head for semtimedop() + +setsid.2 + michael kerrisk + rewrite some pieces and add some details + among other changes, add an explanation of why setsid() can't + be called from a process group leader + +sgetmask.2 + michael kerrisk + since 3.16, support for these system calls is configurable + support for these calls is now dependent on the setting of the + config_sgetmask_syscall option. + +sigaction.2 + michael kerrisk + document sa_restorer + michael kerrisk + add some detail on the sa_restorer field + michael kerrisk + see also: add sigreturn(2) + +splice.2 + michael kerrisk + reformat description of 'fd_in' and 'off_in' to improve readability + +syscall.2 + michael kerrisk + see also: add errno(3) + +syscalls.2 + michael kerrisk + see also: add errno(3) + michael kerrisk + 3.19 adds execveat() + michael kerrisk + add bpf(2) to list + +tee.2 + michael kerrisk + add shell session demonstrating use of the example program + +tkill.2 + michael kerrisk [rich felker] + remove bogus text saying tgid==-1 makes tgkill() equivalent to tkill() + +abort.3 + michael kerrisk + note that sigabrt is raised as though raise(3) is called + also note that abort() is posix.1-2008 compliant. + +cmsg.3 + david wragg + ensure buf is suitably aligned in sending example + inspection of the definition of cmsg_firsthdr (both in glibc and + the suggested definition in rfc3542) shows that it yields the + msg_control field. so when sending, the pointer placed in + msg_control should be suitably aligned as a struct cmsghdr. + in the sending example, buf was declared as a bare char array, + and so is not necessarily suitably aligned. + + the solution here involves placing buf inside a union, and is + based on the sockets/scm_rights_send.c sample from the linux + programming interface "dist" source code collection. + +exp10.3 + michael kerrisk + before glibc 2.19, exp() did not give erange error on underflow + http://sources.redhat.com/bugzilla/show_bug.cgi?id=6787 + +ftw.3 + michael kerrisk + ftw_chdir has no effect on the 'fpath' argument passed to fn() + +getopt.3 + michael kerrisk [jonny grant] + ensure that 'nsecs' is used + +ilogb.3 + michael kerrisk [will newton] + since glibc 2.16, ilogb() does correctly diagnose domain errors + +memcmp.3 + michael haardt + document return value for n==0 case + michael haardt + warn against use of memcmp() for comparing security-critical data + +mq_open.3 + michael kerrisk + document the o_cloexec flag + michael kerrisk + place 'flags' constants in alphabetical order + +pow.3 + manuel lópez-ibáñez + add note on performance characteristics of pow() + +pthread_setschedparam.3 + simon newton + fix logic error in example program + the example program will crash if -a is used, since 'attr' + is uninitialized. + + $ ./a.out -a + *** error in `./a.out': free(): invalid pointer: 0xb779c3c4 *** + aborted (core dumped) + 刘湃 + small fixes to example program + +sigvec.3 + michael kerrisk + starting with version 2.21, glibc no longer exports sigvec() + +sysconf.3 + josh triplett + document _sc_ngroups_max + already documented in getgroups(2), but not in sysconf(3). + +termios.3 + michael kerrisk + see also: add tset(1) + +tgamma.3 + michael kerrisk + since glibc 2.18, errno is correctly set to edom when (x == -infinity)) + +wordexp.3 + carlos o'donell + make it clear that wrde_nocmd prevents command substitution + the use of wrde_nocmd prevents command substitution. if the flag + wrde_nocmd is set then no command substitution shall occur and + the error wrde_cmdsub will be returned if such substitution is + requested when processing the words. + + the manual page as-is makes it seem like the command substitution + occurs, and an error is returned *after* the substitution. + this patch clarifies that. + +locale.5 + marko myllynen + describe the formats of values + locale(5) describes what a locale should define but doesn't + spell out how (in what format). the patch attempts to address + this, it also has few trivial additional enhancements. + + * reference to locale(7) for category descriptions. + * clarify first_workday in notes a bit. + * add upstream bz reference for two missing lc_address fields. + marko myllynen + fix miscoded character + +resolv.conf.5 + jan chaloupka + add missing no-tld-query option + based on commit [1], the no-tld-query option exists for + resolv.conf configuration file. description of this option + is provided in [2]. this patch just copies this option + into resolv.conf.5 man page. plus changes 'a' member + into 'an' before 'unqualified name as if it ...' + on the third line of [2]. based on [3], this option + was added in glibc 2.14 as solving [4] bug. + + [1] https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=f87dfb1f11c01f2ccdc40d81e134cd06b32e28e8 + [2] http://www.daemon-systems.org/man/resolv.conf.5.html man page. + [3] https://sourceware.org/git/?p=glibc.git;a=blob;f=news;h=952f32af17e7fb49c4c1a305de673a13075bfaf5;hb=f87dfb1f11c01f2ccdc40d81e134cd06b32e28e8 + [4] https://sourceware.org/bugzilla/show_bug.cgi?id=12734 + +credentials.7 + josh triplett + cross-reference getgroups(2) + since credentials.7 discusses supplementary gids, it should + reference getgroups(2). + +fanotify.7 + heinrich schuchardt + allow relative paths in example + the current example code requires passing an absolute + path to the mount to be watched. + + by passing at_fdcwd to fanotify_mark it can use both + absolute and relative paths. + heinrich schuchardt + fallocate(2) creates no events + fallocate(2) should create fan_modify events but does not. + heinrich schuchardt [michael kerrisk] + fanotify notifies only events generated on the same mount + unfortunately, fanotify does not inform listeners for all paths + under which a touched filesystem object is visible, but only the + listener using the same path as the process touching the + filesystem object. + heinrich schuchardt + update bugs to note bugs still not fixed in 3.17 + i bumped the linux version number in the bugs section to 3.17. + +inotify.7 + heinrich schuchardt + fallocate(2) does not trigger inotify events + calling fallocate(2) does not result in inotify events. + +locale.7 + marko myllynen + improve locpath description + locpath is ignored by privileged programs. + + add locale archive references. + + add files section. + +man-pages.7 + michael kerrisk [laurent georget] + clarify that see also entries may refer to pages from other projects + +signal.7 + michael kerrisk + mention other "slow devices" + reads from eventfd(2), signalfd(2), timerfd(2), inotify(7), + and fanotify(7) file descriptors are also slow operations + that are restartable. + michael kerrisk + fix so_recvtimeo/ so_sendtimeo confusion in text + michael kerrisk + since linux 3.8, reads on inotify(7) file descriptors are restartable + michael kerrisk + inotify(7) reads no longer show the odd eintr error after sigcont + since kernel 3.7, reads from inotify(7) file descriptors no longer + show the (linux oddity) behavior of failing with eintr when the + process resumes after a stop signal + sigcont. + michael kerrisk + see also: add sigreturn(2) + +unix.7 + michael kerrisk [scott harvey] + fix buglet in code snippet in bugs section + +ld.so.8 + carlos o'donell + add --inhibit-cache option + the dynamic loader has 6 options, only 5 are documented. + this patch documents the sixth option i.e. `--inhibit-cache`. + jonathan wakely [siddhesh poyarekar] + correct documentation of $origin + as noted by siddhesh: + + the ld.so man page says: + + $origin (or equivalently ${origin}) + this expands to the directory containing the + application executable. thus, an application located + in somedir/app could be compiled with + + this is incorrect since it expands to the directory containing + the dso and not the application executable. this seems like + deliberate behaviour in dl-object.c, so it needs to be fixed in + the man page. + + see http://stackoverflow.com/questions/26280738/what-is-the-equivalent-of-loader-path-for-rpath-specification-on-linux/26281226#26281226 + + + +==================== changes in man-pages-3.77 ==================== + +released: 2015-01-10, munich + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +akihiro motoki +alexandre bique +andre majorel +andy lutomirski +daniel borkmann +dave hansen +elie de brauwer +heinrich schuchardt +ignat loskutov +jeff epler +jérôme pouiller +kees cook +laurent georget +masanari iida +michael haardt +michael kerrisk +mike frysinger +richard cochran +stephan mueller +troy davis +vince weaver +will drewry + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +seccomp.2 + kees cook, michael kerrisk, will drewry [andy lutomirski] + new page documenting seccomp(2) + combines documentation from prctl, in-kernel seccomp_filter.txt + and dropper.c, along with details specific to the new system call. + + +newly documented interfaces in existing pages +--------------------------------------------- + +netlink.7 + stephan mueller [michael kerrisk] + add netlink_crypto + + +changes to individual pages +--------------------------- + +adjtimex.2 + laurent georget [richard cochran, jeff epler] + clarify the 'ppm scaling' used in struct timex + this patch makes explicit and clarifies the unit used for + the fields "freq", "ppsfreq" and "stabil" in struct timex. + michael kerrisk [masanari iida] + note that time_error is the modern synonym for time_bad + +perf_event_open.2 + vince weaver + clarify the perf_flag_fd_* flags + this change clarifies the behavior of the perf_flag_fd_output and + perf_flag_fd_no_group flags to perf_event_open(), and removes + the related fixme comments. + + while writing tests to validate the behavior of these flags i + discovered that perf_flag_fd_output has been broken since the + 2.6.35 kernel release. + +prctl.2 + dave hansen [michael kerrisk] + add description of intel mpx calls + the 3.19 kernel will have support for intel mpx, including + a pair of new prctl() calls (pr_mpx_enable_management and + pr_mpx_disable_management) for enabling and disabling the + kernel's management of the "bounds tables". add a + descriptions of the interface. + michael kerrisk + add mention of seccomp(2) under pr_set_seccomp + michael kerrisk + suggest /proc/pid/status "seccomp" as alternative to pr_get_seccomp + michael kerrisk + sigkill can also occur pr_get_seccomp in seccomp_mode_filter mode + kees cook [andy lutomirski] + document seccomp_mode_filter vs efault + this notes the distinction made between einval and efault when + attempting to use seccomp_mode_filter with pr_set_seccomp. + +setns.2 +pid_namespaces.7 + mike frysinger + elaborate discussion of the pid namespace descendant limitation + the setns(2) man page already mentions that clone_newpid may only + be used with descendant namespaces, but this nuance could be + listed in a few more places so it is not missed. + +shmget.2 + michael kerrisk [akihiro motoki] + make wording of shmall description a little clearer + +sigaction.2 + michael kerrisk + add siginfo_t fields for seccomp_ret_trap + +memchr.3 +strstr.3 + alexandre bique + reference memmem(3) in see also section + +memcmp.3 + michael kerrisk [michael haardt] + notes: add some detail on avoiding memcmp() of cryptographic data + wording largely based on comments from michael haardt. + +pthread_tryjoin_np.3 + jérôme pouiller [michael kerrisk] + document einval error for pthread_timedjoin_np() + +mem.4 + elie de brauwer + /dev/kmem depends on config_devkmem + elie de brauwer + correct /dev/port group in example + mem.4 mentions that group for /dev/port should be set to 'mem' + however, all other files (/dev/mem and /dev/kmem) use the kmem + group in their examples and on my system /dev/port belongs to + kmem. hence the 'mem' group was probably a typo: + elie de brauwer + add config_strict_devmem + since 2.6.26 the config_nonpromisc_devmem options limits the + physical addresses which can be accessed through /dev/mem. + +random.4 + heinrich schuchardt + describe handling of o_nonblock + /dev/random and /dev/urandom treat o_nonblock differently. + this should be described in the manpage. + heinrich schuchardt + mention prng used by urandom + /dev/urandom uses a pseudo-random number generator to replace + missing entropy. + +proc.5 + michael kerrisk + document "seccomp" field of /proc/pid/status + +epoll.7 + michael kerrisk [ignat loskutov] + use epoll_create1() rather than epoll_create() in the code example + epoll_create1() is more or less the preferred api for new + applications, since it allows for some flags and avoids the + misdesigned epoll_create() argument, and so it seems sensible + to use that in the example, rather than epoll_create(). + +tcp.7 + troy davis + clarify tcp_tw_recycle on internet-facing hosts + clarify that tcp_tw_recycle will break communication with many + general-purpose remote internet hosts (namely, remote nat devices) + even when the linux device itself is not behind nat. + + +==================== changes in man-pages-3.78 ==================== + +released: 2015-01-22, munich + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +akihiro motoki +alexey ishchuk +carlos o'donell +christian seiler +daniel j blueman +david drysdale +david herrmann +elie de brauwer +elliot hughes +jessica mckellar +kees cook +michael hayes +michael kerrisk +rich felker +vince weaver + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +execveat.2 + david drysdale, michael kerrisk [rich felker] + new page for execveat(2) + +memfd_create.2 + michael kerrisk, david herrmann + new page for memfd_create() system call + including notes about file sealing + +s390_pci_mmio_write.2 + alexey ishchuk + new page for s390 s390_pci_mmio_write() and s390_pci_mmio_read() + new manual page for the new pci mmio memory access system + calls, s390_pci_mmio_write() and s390_pci_mmio_read(), + added for the s390 platform. + + +newly documented interfaces in existing pages +--------------------------------------------- + +fcntl.2 + david herrmann [michael kerrisk] + document f_add_seals and f_get_seals commands + +proc.5 + elie de brauwer + document /proc/sys/vm/compact_memory + michael kerrisk + document /proc/sys/fs/nr_open + + +new and changed links +--------------------- + +s390_pci_mmio_read.2 + michael kerrisk + new link to new s390_pci_mmio_write(2) page + + +changes to individual pages +--------------------------- + +dup.2 + michael kerrisk + add reference to rlimit_nofile for emfile error + michael kerrisk + add reference to rlimit_nofile for ebadf error on 'newfd'. + +execve.2 +fexecve.3 + michael kerrisk + see also: add execveat(2) + +fallocate.2 +mmap.2 +open.2 +truncate.2 +write.2 + michael kerrisk + errors: add eperm for operation denied by file seal + +fcntl.2 + michael kerrisk + errors: add ebusy case for f_setpipe_sz + michael kerrisk + add reference to rlimit_nofile for f_dupfd einval error on 'arg'. + michael kerrisk + errors: add open file description lock error cases + +getrlimit.2 + michael kerrisk + update text on rlimit_nofile ceiling to refer to /proc/sys/fs/file-max + +mbind.2 + michael kerrisk [daniel j blueman] + clarify efault text + +mmap.2 +shmget.2 +shm_open.3 + michael kerrisk + see also: add memfd_create(2) + +open.2 + michael kerrisk + refer to rlimit_nofile for explanation of emfile error + michael kerrisk + add execveat(2) in system call list under "rationale for openat()" + +perf_event_open.2 + vince weaver + clarify description of overflow events + update the perf_event_open manpage to be more consistent when + discussing overflow events. it merges the discussion of + poll-type notifications with those generated by sigio + signal handlers. + this addresses the remaining fixmes is the document. + vince weaver + remove inaccurate paragraph describing attr.config + remove an inaccurate paragraph about values in the attr.config + field. this information was never true in any released kernel; + it somehow snuck into the manpage because it is still described + this way in tools/perf/design.txt in the kernel source tree. + michael kerrisk + correct the kernel version number for perf_count_hw_cache_node + michael kerrisk + add some kernel version numbers to various fields and constants + +ptrace.2 +sigaction.2 +seccomp.2 + kees cook + ptrace and siginfo details + while writing some additional seccomp tests, i realized + ptrace_event_seccomp wasn't documented yet. fixed this, and added + additional notes related to ptrace events sigtrap details. + +readv.2 + michael kerrisk + update details on glibc readv()/writev() wrapper behavior + and add a historical detail about linux 2.0. + +select.2 + michael kerrisk + mention rlimit_nofile as a possible cause of einval error + +syscall.2 + kees cook + add arm64 and mips + add mips and arm64 to tables, along with some further + details on these architectures, + +syscalls.2 + michael kerrisk + add s390_pci_mmio_read(2) and s390_pci_mmio_write(2) + michael kerrisk + note kernel() version that introduced get_kernel_syms() + note kernel version that introduced ppc_rtas() + note kernel version that introduced create_module() + note kernel version that added setup() + michael kerrisk + remove some details for sync_file_range2() + make the table a bit simpler. the details can anyway be + found in the system call man page. + +utimensat.2 + michael kerrisk [elliot hughes] + if both tv_sec fields are utime_omit, the file need not exist + as noted by elliot, if both tv_sec fields are utime_omit, + utimensat() will return success even if the file does not exist. + +errno.3 + michael kerrisk + the rlimit_nofile resource limit is a common cause of emfile + +exec.3 + michael kerrisk + see also: add execveat(2) + +fclose.3 + carlos o'donell + consistency fix: use "stream" as name for "file *" argument + harmonize all the manual pages to use "stream" for file* + instead of randomly using "fp" or "stream." choosing something + and being consistent helps users scan the man pages quickly + and understand what they are looking at. + +fexecve.3 + michael kerrisk + rewrite the script+close-on-exec problem as a bug + also, add one or two details about this scenario. + michael kerrisk + the natural idiom when using fexecve() is to use the close-on-exec flag + +fmemopen.3 + michael kerrisk + consistency fix: use "stream" as name for "file *" argument + +fopencookie.3 + michael kerrisk + consistency fix: use "stream" as name for "file *" argument + +getgrent_r.3 + carlos o'donell + consistency fix: use "stream" as name for "file *" argument + +getline.3 + michael kerrisk + consistency fix: use "stream" as name for "file *" argument + +getmntent.3 + carlos o'donell + consistency fix: use "stream" as name for "file *" argument + +getpw.3 + michael kerrisk [carlos o'donell] + describe return value when 'uid' is not found + +getpwent_r.3 + carlos o'donell + consistency fix: use "stream" as name for "file *" argument + +getspnam.3 + carlos o'donell + consistency fix: use "stream" as name for "file *" argument + +malloc_info.3 + carlos o'donell + consistency fix: use "stream" as name for "file *" argument + +posix_fallocate.3 + michael kerrisk + note that posix_fallocate() is implemented using fallocate(2) + +putgrent.3 + carlos o'donell + consistency fix: use "stream" as name for "file *" argument + harmonize all the manual pages to use "stream" for file* + instead of randomly using "fp" or "stream." choosing something + and being consistent helps users scan the man pages quickly + and understand what they are looking at. + +locale.5 + akihiro motoki + correct variable name + +proc.5 + michael kerrisk + remove bogus statement about nr_open being a ceiling for file-max + + +==================== changes in man-pages-3.79 ==================== + +released: 2015-02-01, munich + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +akihiro motoki +heinrich schuchardt +j william piggott +masanari iida +michael kerrisk +scot doyle +sergey v. zubkov +stephan mueller +vince weaver +vivek goyal + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +getrandom.2 + heinrich schuchardt, theodore t'so, michael kerrisk + new page documenting getrandom(2) + kernel 3.17 introduces a new system call getrandom(2). + +kexec_load.2 + vivek goyal, michael kerrisk + add documentation of kexec_file_load(2) + michael kerrisk, vivek goyal + rewrite and extend documentation of kexec_load(). + + +new and changed links +--------------------- + +kexec_file_load.2 + michael kerrisk + new link to kexec_load.2 + +changes to individual pages +--------------------------- + +personality.2 + michael kerrisk + see also: add setarch(8) + +prctl.2 + michael kerrisk + unused arguments of pr_mpx_(en,dis}able_management must be zero + +reboot.2 + michael kerrisk + see also: add kexec_load(2) + +socket.2 + stephan mueller + document af_alg + add a reference to the af_alg protocol accessible via socket(2). + +fflush.3 + michael kerrisk [sergey v. zubkov] + clarify that flushing of input streams occurs only for seekable files + see https://bugzilla.kernel.org/show_bug.cgi?id=91931 + michael kerrisk [sergey v. zubkov] + posix.1-2008 specifies the behavior when flushing input streams + posix.1-2001 did not have a specification for input streams, + but posix.1-2008 added one. + +getopt.3 + michael kerrisk + see also: add getopt(1) + +random.3 + heinrich schuchardt + see also: add getrandom(2) + +termios.3 + michael kerrisk + see also: add reset(1), setterm(1), tput(1) + +tzset.3 + j william piggott + document behavior when tz filespec omits the colon + if the tz filespec omits the leading colon, glibc will parse + it for any valid format, i.e., it will still work. + j william piggott + add description for posixrules file + j william piggott + correct system timezone file path + j william piggott + there are only two tz formats + tzset(3) currently states that there are three tz formats. the + first two it lists are actually variations of the posix-style + tz format, of which there are at least five variations. + + this patch corrects this to match the posix specification of + tz having only two formats. + j william piggott + filespec omitted incorrect + paragraph three of the description section says + that when tz is set, but empty, then utc is used. + + later it says if the tz filespec is omitted then the file + /usr/share/zoneinfo/localtime is used. this is incorrect, + it will use utc in that case as well. + j william piggott + fix incorrect tz string representation + the tz string representation indicates that the start/end + rules are required; this is incorrect. + j william piggott + add environment section + other rearrangements + files section was overly verbose and included + environment variables. added environment section, + removing env vars from the files section. + +random.4 + heinrich schuchardt + see also: add getrandom(2) + +passwd.5 + michael kerrisk + see also: add chfn(1), chsh(1) + +capabilities.7 + michael kerrisk + see also: add setpriv(1) + +signal.7 + michael kerrisk + add getrandom(2) to list of restartable system calls + michael kerrisk + add f_ofd_setlkw to list of restartable operations + + + +==================== changes in man-pages-3.80 ==================== + +released: 2015-02-21, munich + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +akihiro motoki +andy lutomirski +bill mcconnaughey +chris mayo +christophe blaess +david wilson +denys vlasenko +doug goldstein +eric wong +heinrich schuchardt +j william piggott +james hunt +jan chaloupka +jan stancek +jeff layton +jens thoms toerring +kevin easton +luke faraone +mark seaborn +mathieu malaterre +michael kerrisk +michal hocko +minchan kim +patrick horgan +peng haitao +ralf baechle +rob somers +simon paillard +stephen smalley +tao ma +tobias herzke +vince weaver +vlastimil babka +zbigniew brzeziński + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +ioctl_fat.2 + heinrich schuchardt [michael kerrisk] + new man page for the ioctl(2) fat api + the ioctl(2) system call may be used to retrieve information about + the fat file system and to set file attributes. + +madvise.2 + michael kerrisk + summary: this page has been significantly reorganised and rewritten + michael kerrisk + recast discussion of 'advice' into two groups of values + madvise() is one of those system calls that has congealed over + time, as has the man page. it's helpful to split the discussion + of 'advice' into those flags into two groups: + + * those flags that are (1) widespread across implementations; + (2) have counterparts in posix_madvise(3); and (3) were present + in the initial linux madvise implementation. + * the rest, which are values that (1) may not have counterparts + in other implementations; (2) have no counterparts in + posix_madvise(3); and (3) were added to linux in more recent + times. + michael kerrisk + explicitly list the five flags provided by posix_fadvise() + over time, bit rot has afflicted this page. since the original + text was written many new linux-specific flags have been added. + so, now it's better to explicitly list the flags that + correspond to the posix analog of madvise(). + jan chaloupka [hugh dickins, michael kerrisk] + starting with linux 3.5, more file systems support madv_remove + michael kerrisk + split einval error into separate cases + michael kerrisk + explain madv_remove in terms of file hole punching + michael kerrisk + madv_remove can be applied only to shared writable mappings + michael kerrisk + madv_remove cannot be applied to locked or huge tlb pages + michael kerrisk [vlastimil babka] + clarify that madv_dontneed has effect on pages only if it succeeds + michael kerrisk [vlastimil babka] + clarifications for madv_dontneed + michael kerrisk [michal hocko] + improve madv_dontneed description + michael kerrisk + madv_dontneed cannot be applied to huge tlb or locked pages + michael kerrisk [vlastimil babka] + remove mention of "shared pages" as a cause of einval for madv_dontneed + michael kerrisk [vlastimil babka] + note huge tlb as a cause of einval for madv_dontneed + michael kerrisk [minchan kim] + add mention of vm_pfnmap in discussion of madv_dontneed and madv_remove + michael kerrisk + drop sentence saying that kernel may ignore 'advice' + the sentence creates misunderstandings, and does not really + add information. + michael kerrisk + note that some linux-specific 'advice' change memory-access semantics + michael kerrisk + notes: remove crufty text about "command" versus "advice" + the point made in this fairly ancient text is more or less evident + from the description, and it's not clear what "standard" is being + referred to. + michael kerrisk + mention posix.1-2008 addition of posix_madv_noreuse + michael kerrisk + remove "posix.1b" from conforming to + michael kerrisk + move mention of posix_fadvise() from conforming to to see also + michael kerrisk + errors: add eperm error case for madv_hwpoison + michael kerrisk + note that madvise() is nonstandard, but widespread + + +newly documented interfaces in existing pages +--------------------------------------------- + +proc.5 + michael kerrisk + (briefly) document /proc/pid/attr/socketcreate + michael kerrisk + (briefly) document /proc/pid/attr/keycreate + michael kerrisk [stephen smalley] + document /proc/pid/attr/{current,exec,fscreate,prev} + heavily based on stephen smalley's text in + https://lwn.net/articles/28222/ + from: stephen smalley + to: lkml and others + subject: [rfc][patch] process attribute api for security modules + date: 08 apr 2003 16:17:52 -0400 + michael kerrisk + document /proc/sys/kernel/auto_msgmni + +socket.7 + david wilson [michael kerrisk] + document so_reuseport socket option + + +new and changed links +--------------------- + +get_thread_area.2 + andy lutomirski + make get_thread_area.2 a link to rewritten set_thread_area.2 page + + +changes to individual pages +--------------------------- + +time.1 + michael kerrisk + make option argument formatting consistent with other pages + +access.2 + denys vlasenko + explain how access() check treats capabilities + we have users who are terribly confused why their binaries + with cap_dac_override capability see eaccess from access() calls, + but are able to read the file. + + the reason is access() isn't the "can i read/write/execute this + file?" question, it is the "(assuming that i'm a setuid binary,) + can *the user who invoked me* read/write/execute this file?" + question. + + that's why it uses real uids as documented, and why it ignores + capabilities when capability-endorsed binaries are run by non-root + (this patch adds this information). + + to make users more likely to notice this less-known detail, + the patch expands the explanation with rationale for this logic + into a separate paragraph. + +arch_prctl.2 +set_thread_area.2 +get_thread_area.2 + andy lutomirski + improve tls documentation + the documentation for set_thread_area was very vague. this + improves it, accounts for recent kernel changes, and merges + it with get_thread_area.2. + + get_thread_area.2 now becomes a link. + + while i'm at it, clarify the related arch_prctl.2 man page. + +cacheflush.2 + ralf baechle + update some portability details and bugs + michael kerrisk + refer reader to bugs in discussion of einval error + +capget.2 + michael kerrisk + document v3 capabilities constants + michael kerrisk + rewrite discussion of kernel versions that support file capabilities + file capabilities ceased to be optional in linux 2.6.33. + +clone.2 + peng haitao + fix description of clone_parent_settid + clone_parent_settid only stores child thread id in parent memory. + +clone.2 +execve.2 + kevin easton + document interaction of execve(2) with clone_files + this patch the fact that a successful execve(2) in a process that + is sharing a file descriptor table results in unsharing the table. + + i discovered this through testing and verified it by source + inspection - there is a call to unshare_files() early in + do_execve_common(). + +fcntl.2 + michael kerrisk [jeff layton] + clarify cases of conflict between traditional record and ofd locks + verified by experiment on linux 3.15 and 3.19rc4. + +fork.2 + michal hocko + eagain is not reported when task allocation fails + i am not sure why we have: + + "eagain fork() cannot allocate sufficient memory to copy + the parent's page tables and allocate a task structure + or the child." + + the text seems to be there from the time when man-pages + were moved to git so there is no history for it. + + and it doesn't reflect reality: the kernel reports both + dup_task_struct and dup_mm failures as enomem to the + userspace. this seems to be the case from early 2.x times + so let's simply remove this part. + heinrich schuchardt + child and parent run in separate memory spaces + fork.2 should clearly point out that child and parent + process run in separate memory spaces. + michael kerrisk + notes: add "c library/kernel abi differences" subheading + +getpid.2 + michael kerrisk + notes: add "c library/kernel abi differences" subheading + +getxattr.2 + michael kerrisk + various rewordings plus one or two details clarified + michael kerrisk + add pointer to example in listxattr(2) + +killpg.2 + michael kerrisk + notes: add "c library/kernel abi differences" subheading + +listxattr.2 + heinrich schuchardt + provide example program + michael kerrisk + reword discussion of size==0 case + michael kerrisk + add note on handling increases in sizes of keys or values + michael kerrisk + remove mention of which filesystems implement acls + such a list will only become outdated (as it already was). + +migrate_pages.2 + jan stancek + document efault and einval errors + i encountered these errors while writing testcase for migrate_pages + syscall for ltp (linux test project). + + i checked stable kernel tree 3.5 to see which paths return these. + both can be returned from get_nodes(), which is called from: + syscall_define4(migrate_pages, pid_t, pid, unsigned long, maxnode, + const unsigned long __user *, old_nodes, + const unsigned long __user *, new_nodes) + + the testcase does following: + efault + a) old_nodes/new_nodes is area mmaped with prot_none + b) old_nodes/new_nodes is area not mmapped in process address + space, -1 or area that has been just munmmaped + + einval + a) maxnodes overflows kernel limit + b) new_nodes contain node, which has no memory or does not exist + or is not returned for get_mempolicy(mpol_f_mems_allowed). + +modify_ldt.2 + andy lutomirski + overhaul the documentation + this clarifies the behavior and documents all four functions. + andy lutomirski + clarify the lm bit's behavior + the lm bit should never have existed in the first place. sigh. + +mprotect.2 + mark seaborn + mention effect of read_implies_exec personality flag + i puzzled over mprotect()'s effect on /proc/*/maps for a while + yesterday -- it was setting "x" without prot_exec being specified. + here is a patch to add some explanation. + +msgget.2 + michael kerrisk + add details of msgmni default value + +msgop.2 + michael kerrisk + clarify wording of msgmax and msgmnb limits + +perf_event_open.2 + vince weaver + clarify perf_event_ioc_refresh behavior + currently the perf_event_ioc_refresh ioctl, when applied to a group + leader, will refresh all children. also if a refresh value of 0 + is chosen then the refresh becomes infinite (never runs out). + back in 2011 papi was relying on these behaviors but i was told + that both were unsupported and subject to being removed at any time. + (see https://lkml.org/lkml/2011/5/24/337 ) + however the behavior has not been changed. + + this patch updates the manpage to still list the behavior as + unsupported, but removes the inaccurate description of it + only being a problem with 2.6 kernels. + +prctl.2 + michael kerrisk [bill mcconnaughey] + mention file capabilities in discussion of pr_set_dumpable + michael kerrisk + greatly expand discussion of "dumpable" flag + in particular, detail the interactions with + /proc/sys/fs/suid_dumpable. + michael kerrisk + reorder paragraphs describing pr_set_dumpable + michael kerrisk + mention suid_dump_disable and suid_dump_user under pr_set_dumpable + michael kerrisk + executing a file with capabilities also resets the parent death signal + +ptrace.2 + james hunt + explain behaviour should ptrace tracer call execve(2) + this behaviour was verified by reading the kernel source and + confirming the behaviour using a test program. + denys vlasenko + add information on ptrace_seize versus ptrace_attach differences + extend description of ptrace_seize with the short summary of its + differences from ptrace_attach. + + the following paragraph: + + ptrace_event_stop + stop induced by ptrace_interrupt command, or group-stop, or ini- + tial ptrace-stop when a new child is attached (only if attached + using ptrace_seize), or ptrace_event_stop if ptrace_seize was used. + + has an editing error (the part after last comma makes no sense). + removing it. + + mention that legacy post-execve sigtrap is disabled by ptrace_seize. + +sched_setattr.2 + michael kerrisk [christophe blaess] + synopsis: remove 'const' from 'attr' sched_getattr() argument + +semget.2 + michael kerrisk + note default value for semmni and semmsl + +semop.2 + michael kerrisk + note defaults for semopm and warn against increasing > 1000 + +sendfile.2 + eric wong + caution against modifying sent pages + +setxattr.2 + michael kerrisk + errors: add enotsup for invalid namespace prefix + michael kerrisk + remove redundant text under enotsup error + michael kerrisk + note that zero-length attribute values are permitted + michael kerrisk + rework text describing 'flags' argument + +stat.2 + michael kerrisk + notes: add "c library/kernel abi differences" subheading + +statfs.2 + michael kerrisk [jan chaloupka] + document the 'f_flags' field added in linux 2.6.36 + michael kerrisk + clarify that 'statfs' structure has some padding bytes + the number of padding bytes has changed over time, as some + bytes are used, so describe this aspect of the structure + less explicitly. + tao ma + add ocfs2_super_magic + michael kerrisk + use __fsword_t in statfs structure definition + this more closely matches modern glibc reality. + michael kerrisk + add a note on the __fsword_t type + michael kerrisk + document 'f_spare' more vaguely + +wait.2 + michael kerrisk + note that waitpid() is a wrapper for wait4() + michael kerrisk + note that wait() is a library function implemented via wait4() + +wait4.2 + michael kerrisk + notes: add "c library/kernel abi differences" subheading + +encrypt.3 + rob somers + improve code example + i (and some others) found that the original example code + did not seem to work as advertised. the new code (used by + permission of the original author, jens thoms toerring) + was found on comp.os.linux.development. + +mktemp.3 + luke faraone + description reference to bugs corrected + mktemp(3)'s description referenced notes, but no such + section exists. corrected to refer to bugs. + +pthread_attr_setschedparam.3 + tobias herzke + describe einval in errors + +resolver.3 +host.conf.5 + simon paillard + host.conf 'order' option deprecated, replaced by nsswitch.conf(5) + http://www.sourceware.org/bugzilla/show_bug.cgi?id=2389 + http://repo.or.cz/w/glibc.git/commit/b9c65d0902e5890c4f025b574725154032f8120a + + reported at http://bugs.debian.org/270368, + http://bugs.debian.org/396633, and http://bugs.debian.org/344233. + +statvfs.3 + michael kerrisk + document missing 'f_flag' bit values + and reorganize information relating to which flags are in + posix.1. + michael kerrisk [jan chaloupka] + statvfs() now populates 'f_flag' from statfs()'s f_flag field + these changes came with glibc 2.13, and the kernel's addition of + a 'f_flags' field in linux 2.6.36. + +syslog.3 + michael kerrisk [doug goldstein] + remove unneeded + vsyslog() does not need this. + +tzset.3 + j william piggott + add offset format + tzset.3 does not illustrate the posix offset format. + specifically, there is no indication in the manual + what the optional components of it are. + +random.4 + michael kerrisk + note maximum number of bytes returned by read(2) on /dev/random + michael kerrisk [mathieu malaterre] + since linux 3.16, reads from /dev/urandom return at most 32 mb + see https://bugs.debian.org/775328 and + https://bugzilla.kernel.org/show_bug.cgi?id=80981#c9 + +core.5 + michael kerrisk [bill mcconnaughey] + executing a file that has capabilities also prevents core dumps + michael kerrisk + document "%i" and "%i" core_pattern specifiers + +intro.5 + michael kerrisk + remove words "and protocols" + there are no protocol descriptions in section 5. protocols are + in section 7. + +proc.5 + michael kerrisk + add reference to prctl(2) in discussion of /proc/sys/fs/suid_dumpable + and note that /proc/sys/fs/suid_dumpable defines the + value assigned to the process "dumpable" flag in certain + circumstances. + michael kerrisk + note that cap_sys_admin is required to list /proc/pid/map_files + this might however change in the future; see the jan 2015 lkml thread: + + re: [rfc][patch v2] procfs: always expose /proc//map_files/ + and make it readable + +resolv.conf.5 + michael kerrisk + see also: add nsswitch.conf(5) + +capabilities.7 + michael kerrisk + mention secbit_keep_caps as an alternative to prctl() pr_set_keepcaps + chris mayo + notes: add last kernel versions for obsolete options + the config_security_capabilities option was removed by + commit 5915eb53861c5776cfec33ca4fcc1fd20d66dd27 + + the config_security_file_capabilities option removed in + linux 2.6.33 as already mentioned in description. + +pthreads.7 + michael kerrisk + see also: add fork(2) + +unix.7 + jan chaloupka + mention sock_stream socket for ioctl_type of ioctl() + from https://bugzilla.redhat.com/show_bug.cgi?id=1110401. + + unix.7 is not clear about socket type of ioctl_type argument of + ioctl() function. the description of siocinq is applicable only + for sock_stream socket. for sock_dgram, udp(7) man page gives + correct description of siocinq + +ldconfig.8 + michael kerrisk + place options in alphabetical order + michael kerrisk + note glibc version number for '-l' option + michael kerrisk + document -c/--format option + michael kerrisk + add long form of some options + michael kerrisk [patrick horgan] + ld.so.conf uses only newlines as delimiters + mtk: confirmed by reading source of parse_conf() in + elf/ldconfig.c. + michael kerrisk + document -v/--version option + michael kerrisk + document -i/--ignore-aux-cache option + +ld.so.8 + michael kerrisk + relocate "hardware capabilities" to be a subsection under notes + this is more consistent with standard man-pages headings + and layout. + michael kerrisk + (briefly) document ld_trace_prelinking + michael kerrisk + remove duplicate description of ld_bind_not + + +==================== changes in man-pages-3.81 ==================== + +released: 2015-03-02, munich + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +alexandre oliva +carlos o'donell +ma shimiao +michael kerrisk +peng haitao + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +attributes.7 + alexandre oliva, michael kerrisk [carlos o'donell] + new page describing posix safety concepts + + +global changes +-------------- + +many pages + peng haitao, michael kerrisk + reformat existing thread-safety information to use a + tabular format, rather than plain text. + + +changes to individual pages +--------------------------- + +mmap.2 + ma shimiao + attributes: note functions that are thread-safe + the function mmap() and munmap() are thread safe. + +a64l.3 + ma shimiao + modify thread-safety information + as annotation in glibc manual is more detailed, change the + thread-safety information to be the same as glibc manual. + +acos.3 + ma shimiao + attributes: note functions that are thread-safe + the function acos(), acosf() and acosl() are thread safe. + +acosh.3 + ma shimiao + attributes: note functions that are thread-safe + the function acosh(), acoshf() and acoshl() are thread safe. + +addseverity.3 + ma shimiao + attributes: note function is thread-safe + the function addseverity() is thread safe. + +aio_cancel.3 + ma shimiao + attributes: note function that is thread-safe + the function aio_cancel() is thread safe. + +aio_fsync.3 + ma shimiao + attributes: note function that is thread-safe + the function aio_fsync() is thread safe. + +aio_read.3 + ma shimiao + attributes: note function that is thread-safe + the function aio_read() is thread safe. + +aio_suspend.3 + ma shimiao + attributes: note function that is thread-safe + the function aio_suspend() is thread safe. + +aio_write.3 + ma shimiao + attributes: note function that is thread-safe + the function aio_write() is thread safe. + +argz_add.3 + ma shimiao + attributes: note functions that are thread-safe + +asin.3 + ma shimiao + attributes: note functions that are thread-safe + the function asin(), asinf() and asinl() are thread safe. + +assert.3 + ma shimiao + attributes: note function that is thread-safe + its marking matches glibc marking. + +assert_perror.3 + ma shimiao + attributes: note function that is thread-safe + its marking matches glibc marking. + +atan2.3 + ma shimiao + attributes: note functions that are thread-safe + the function atan2(), atan2f() and atan2l() are thread safe. + +atanh.3 + ma shimiao + attributes: note functions that are thread-safe + the function atanh(), atanhf() and atanhl() are thread safe. + +backtrace.3 + ma shimiao + attributes: note function that is thread-safe + the markings match glibc markings. + +btowc.3 + ma shimiao + attributes: note function that is thread-safe + the function btowc() in glibc is thread safe. + its marking matches glibc marking. + +cabs.3 + ma shimiao + attributes: note functions that are thread-safe + the function cabs(), cabsf() and cabsl() are thread safe. + +cacos.3 + ma shimiao + attributes: note functions that are thread-safe + the function cacos(), cacosf() and cacosl() are thread safe. + +cacosh.3 + ma shimiao + attributes: note functions that are thread-safe + the functions cacosh(), cacoshf() and cacoshl() in glibc are + thread safe. its markings match glibc markings. + +canonicalize_file_name.3 + ma shimiao + attributes: note function that is thread-safe + the functions canonicalize_file_name() in glibc is thread safe. + its marking matches glibc marking. + +carg.3 + ma shimiao + attributes: note functions that are thread-safe + the function carg(), cargf() and cargl() are thread safe. + +casin.3 + ma shimiao + attributes: note functions that are thread-safe + the functions casin(), casinf() and casinl() are thread safe. + their markings match glibc markings. + +casinh.3 + ma shimiao + attributes: note functions that are thread-safe + the functions casinh(), casinhf() and casinhl() in glibc are + thread safe. its markings match glibc markings. + +catan.3 + ma shimiao + attributes: note functions that are thread-safe + the functions catan(), catanf() and catanl() are thread safe. + their markings match glibc markings. + +catanh.3 + ma shimiao + attributes: note functions that are thread-safe + the functions catanh(), catanhf() and catanhl() in glibc are + thread safe. its markings match glibc markings. + +catopen.3 + peng haitao + attributes: note functions that are thread-safe + the functions catopen() and catclose() are thread safe. + +cfree.3 + ma shimiao + attributes: note function that is thread-safe + the function cfree() in glibc is thread safe. + its marking matches glibc marking. + +clog10.3 + ma shimiao + attributes: note functions that are thread-safe + the functions clog10(), clog10f() and clog10l() in glibc are + thread safe. its markings match glibc markings. + +clog.3 + ma shimiao + attributes: note functions that are thread-safe + the function clog(), clogf() and clogl() are thread safe. + +closedir.3 + ma shimiao + attributes: note function that is thread-safe + the function closedir() in glibc is thread safe. + its marking matches glibc marking. + +confstr.3 + ma shimiao + attributes: note function that is thread-safe + the function confstr() is thread safe. + +cosh.3 + ma shimiao + attributes: note functions that are thread-safe + the functions cosh(), coshf() and coshl() in glibc are thread safe. + its markings match glibc markings. + +cpow.3 + ma shimiao + attributes: note functions that are thread-safe + the functions cpow(), cpowf() and cpowl() in glibc are thread safe. + its markings match glibc markings. + +crypt.3 + ma shimiao + modify thread-safety information + as annotation in glibc manual is more detailed, change the + thread-safety information to be the same as glibc manual. + +ctermid.3 + ma shimiao + modify thread-safety information + according to the change of source code, ctermid's level has been + changed from mt-unsafe to mt-safe. after modifying, the marking + matches the glibc marking. + +drand48.3 + ma shimiao + modify thread-safety information + as annotation in glibc manual is more detailed, change the + thread-safety information to be the same as glibc manual. + +drand48_r.3 + ma shimiao + modify thread-safety information + as annotation in glibc manual is more detailed, change the + thread-safety information to be the same as glibc manual. + +ecvt.3 + ma shimiao + modify thread-safety information + as annotation in glibc manual is more detailed, change the + thread-safety information to be same as glibc manual. + +ecvt_r.3 + ma shimiao + attributes: note function that is thread-safe + the markings match glibc markings. + +encrypt.3 + ma shimiao + modify thread-safety information + as annotation in glibc manual is more detailed, change the + thread-safety information to be the same as glibc manual. + +envz_add.3 + ma shimiao + attributes: note functions that are thread-safe + the markings match glibc markings. + +exec.3 + peng haitao + attributes: note functions that are thread-safe + the functions execl(), execlp(), execle(), execv(), execvp() and + execvpe() are thread safe. + +exit.3 + ma shimiao + modify thread-safety information + as annotation in glibc manual is more detailed, change the + thread-safety information to be the same as glibc manual. + +exp10.3 + ma shimiao + attributes: note functions that are thread-safe + +exp2.3 + ma shimiao + attributes: note functions that are thread-safe + the function exp2(), exp2f() and exp2l() are thread safe. + +exp.3 + ma shimiao + attributes: note functions that are thread-safe + the function exp(), expf() and expl() are thread safe. + +fclose.3 + ma shimiao + attributes: note function that is thread-safe + the function fclose() is thread safe. + its marking matches glibc marking. + +fcloseall.3 + ma shimiao + modify thread-safety information + as annotation in glibc manual is more detailed, change the + thread-safety information to be the same as glibc manual. + +fgetc.3 + ma shimiao + attributes: note functions that are thread-safe + the markings match glibc markings. + +fgetwc.3 + ma shimiao + attributes: note functions that are thread-safe + the markings match glibc markings. + +fgetws.3 + ma shimiao + attributes: note function that is thread-safe + the marking matches glibc marking. + +fmod.3 + ma shimiao + attributes: note functions that are thread-safe + the function fmod(), fmodf() and fmodl() are thread safe. + +fnmatch.3 + peng haitao + attributes: note function that is thread safe with exceptions + the function fnmatch() is thread safe with exceptions. + +fopen.3 + ma shimiao + attributes: note function that is thread-safe + the markings match glibc markings. + +fopencookie.3 + ma shimiao + attributes: note function that is thread-safe + the marking matches glibc marking. + +fread.3 + peng haitao + attributes: note functions that are thread-safe + the functions fread() and fwrite() are thread safe. + +gamma.3 + peng haitao + attributes: note functions that are not thread-safe + the functions gamma(), gammaf() and gammal() are not thread safe. + ma shimiao + modify thread-safety information + as annotation in glibc manual is more detailed, change the + thread-safety information to be the same as glibc manual. + +getcontext.3 + ma shimiao + modify thread-safety information + as annotation in glibc manual is more detailed, change the + thread-safety information to be the same as glibc manual. + +getcwd.3 + peng haitao + attributes: note functions that are thread-safe + the functions getcwd(), getwd() and get_current_dir_name() are + thread safe. + +getdate.3 + ma shimiao + modify thread-safety information + as annotation in glibc manual is more detailed, change the + thread-safety information to be the same as glibc manual. + +getenv.3 + peng haitao + attributes: note functions that are thread-safe + the functions getenv() and secure_getenv() are thread safe. + +getfsent.3 + peng haitao + attributes: note functions that are not thread-safe + the functions setfsent(), getfsent(), endfsent(), getfsspec() + and getfsfile() are not thread safe. + ma shimiao + modify thread-safety information + as annotation in glibc manual is more detailed, change the + thread-safety information to be the same as glibc manual. + +getgrent.3 + ma shimiao + attributes: note function that is thread-safe + its marking matches glibc marking. + ma shimiao + modify thread-safety information + as annotation in glibc manual is more detailed, change the + thread-safety information to be the same as glibc manual. + +getgrnam.3 + ma shimiao + modify thread-safety information + as annotation in glibc manual is more detailed, change the + thread-safety information to be the same as glibc manual. + +getgrouplist.3 + peng haitao + attributes: note function that is thread safe with exceptions + the function getgrouplist() is thread safe with exceptions. + +getlogin.3 + ma shimiao + modify thread-safety information + as annotation in glibc manual is more detailed, change the + thread-safety information to be the same as glibc manual. + +getopt.3 + peng haitao + attributes: note functions that are not thread-safe + the functions getopt(), getopt_long() and getopt_long_only() are + not thread safe. + ma shimiao + modify thread-safety information + as annotation in glibc manual is more detailed, change the + thread-safety information to be the same as glibc manual. + +getpass.3 + ma shimiao + modify thread-safety information + as annotation in glibc manual is more detailed, change the + thread-safety information to be the same as glibc manual. + +getpwent.3 + ma shimiao + modify thread-safety information + as annotation in glibc manual is more detailed, change the + thread-safety information to be the same as glibc manual. + +getpwnam.3 + ma shimiao + modify thread-safety information + as annotation in glibc manual is more detailed, change the + thread-safety information to be the same as glibc manual. + +gets.3 + ma shimiao + attributes: note function that is thread-safe + its marking matches glibc marking. + +getw.3 + peng haitao + attributes: note functions that are thread-safe + the functions getw() and putw() are thread safe. + +gnu_get_libc_version.3 + peng haitao + attributes: note functions that are thread-safe + the functions gnu_get_libc_version() and gnu_get_libc_release() + are thread safe. + +hsearch.3 + ma shimiao + modify thread-safety information + as annotation in glibc manual is more detailed, change the + thread-safety information to be the same as glibc manual. + +iconv.3 + peng haitao + modify thread-safety information + +inet.3 + peng haitao + attributes: note functions that are thread safe with exceptions + the functions inet_aton() and inet_addr() are thread safe with + exceptions. + the functions inet_network(), inet_ntoa(), inet_makeaddr(), + inet_lnaof() and inet_netof() are thread safe. + modify thread-safety information + after researching and talking, we think inet_network() and + inet_ntoa() should be marked with locale. + after changing, the markings match glbc markings. + +inet_pton.3 + peng haitao + attributes: note function that is thread safe with exceptions + the function inet_pton() is thread safe with exceptions. + +iswdigit.3 + peng haitao + attributes: note function that is thread safe with exceptions + the function iswdigit() is thread safe with exceptions. + +iswgraph.3 + peng haitao + attributes: note function that is thread safe with exceptions + the function iswgraph() is thread safe with exceptions. + +iswlower.3 + peng haitao + attributes: note function that is thread safe with exceptions + the function iswlower() is thread safe with exceptions. + +iswprint.3 + peng haitao + attributes: note function that is thread safe with exceptions + the function iswprint() is thread safe with exceptions. + +iswpunct.3 + peng haitao + attributes: note function that is thread safe with exceptions + the function iswpunct() is thread safe with exceptions. + +iswspace.3 + peng haitao + attributes: note function that is thread safe with exceptions + the function iswspace() is thread safe with exceptions. + +iswupper.3 + peng haitao + attributes: note function that is thread safe with exceptions + the function iswupper() is thread safe with exceptions. + +iswxdigit.3 + peng haitao + attributes: note function that is thread safe with exceptions + the function iswxdigit() is thread safe with exceptions. + +j0.3 + ma shimiao + attributes: note functions that are thread-safe + the function j0(), j1f() jnl() and so on are thread safe. + +lio_listio.3 + ma shimiao + attributes: note function that is thread-safe + its marking matches glibc marking. + +log10.3 + ma shimiao + attributes: note functions that are thread-safe + the function log10(), log10f() and log10l() are thread safe. + +log2.3 + ma shimiao + attributes: note functions that are thread-safe + the function log2(), log2f() and log2l() are thread safe. + +log.3 + ma shimiao + attributes: note functions that are thread-safe + the function log(), logf() and logl() are thread safe. + +makecontext.3 + ma shimiao + modify thread-safety information + as annotation in glibc manual is more detailed, change the + thread-safety information to be the same as glibc manual. + +makedev.3 + peng haitao + attributes: note macros that are thread-safe + the macros makedev(), major() and minor() are thread safe. + +malloc.3 + ma shimiao + attributes: note functions that are thread-safe + the function malloc(), free(), calloc() and realloc() are + thread safe. + +mblen.3 + ma shimiao + modify thread-safety information + as annotation in glibc manual is more detailed, change the + thread-safety information to be the same as glibc manual. + +mbstowcs.3 + ma shimiao + attributes: note function that is thread-safe + the marking matches glibc marking. + +mbtowc.3 + peng haitao + attributes: note function that is not thread-safe + the function mbtowc() is not thread safe. + ma shimiao + modify thread-safety information + as annotation in glibc manual is more detailed, change the + thread-safety information to be the same as glibc manual. + +mktemp.3 + peng haitao + attributes: note function that is thread-safe + the function mktemp() is thread safe. + +mtrace.3 + peng haitao + attributes: note functions that are not thread-safe + the functions mtrace() and muntrace() are not thread safe. + +nan.3 + ma shimiao + attributes: note functions that are thread-safe + the markings match glibc markings. + +nl_langinfo.3 + peng haitao + attributes: note function that is thread safe with exceptions + the function nl_langinfo() is thread safe with exceptions. + +opendir.3 + ma shimiao + attributes: note function that is thread-safe + the markings match glibc markings. + +pow10.3 + ma shimiao + attributes: note functions that are thread-safe + the function pow10(), pow10f() and pow10l() are thread safe. + +pow.3 + ma shimiao + attributes: note functions that are thread-safe + the function pow(), powf() and powl() are thread safe. + +pthread_setcancelstate.3 + michael kerrisk + add async-signal-safety information + +ptsname.3 + ma shimiao + modify thread-safety information + as annotation in glibc manual is more detailed, change the + thread-safety information to be the same as glibc manual. + +putenv.3 + ma shimiao + attributes: note function that is thread-unsafe + the function putenv() is thread unsafe. + +puts.3 + peng haitao + attributes: note functions that are thread-safe + the functions fputc(), fputs(), putc(), putchar() and puts() are + thread safe. + +putwchar.3 + ma shimiao + attributes: note function that is thread-safe + the marking matches glibc marking. + +qecvt.3 + ma shimiao + modify thread-safety information + as annotation in glibc manual is more detailed, change the + thread-safety information to be same as glibc manual. + +rand.3 + peng haitao + attributes: note macros that are thread-safe + the functions rand(), rand_r() and srand() are thread safe. + +random_r.3 + ma shimiao + modify thread-safety information + as annotation in glibc manual is more detailed, change the + thread-safety information to be the same as glibc manual. + +readdir.3 + ma shimiao + modify thread-safety information + as annotation in glibc manual is more detailed, change the + thread-safety information to be same as glibc manual. + +realpath.3 + ma shimiao + attributes: note function that is thread-safe + the marking matches glibc marking. + +regex.3 + peng haitao + attributes: note functions that are thread safe with exceptions + the functions regcomp() and regexec() are thread safe with + exceptions. + the functions regerror() and regfree() are thread safe. + +remainder.3 + ma shimiao + attributes: note function that is thread-safe + the markings match glibc markings. + +scalb.3 + ma shimiao + attributes: note functions that are thread-safe + the function scalb(), scalbf() and scalbl() are thread safe. + +setenv.3 + ma shimiao + attributes: note functions that are thread-unsafe + the function setenv() and unsetenv() are thread unsafe. + +siginterrupt.3 + ma shimiao + modify thread-safety information + as annotation in glibc manual is more detailed, change the + thread-safety information to be the same as glibc manual. + +sigset.3 + peng haitao + attributes: note macros that are thread-safe + the functions sigset(), sighold(), sigrelse() and sigignore() + are thread safe. + +sinh.3 + ma shimiao + attributes: note functions that are thread-safe + the function sinh(), sinhf() and sinhl() are thread safe. + +sqrt.3 + ma shimiao + attributes: note functions that are thread-safe + the function sqrt(), sqrtf() and sqrtl() are thread safe. + +stdarg.3 + ma shimiao + modify thread-safety information + as annotation in glibc manual is more detailed, change the + thread-safety information to be the same as glibc manual. + +stdio_ext.3 + ma shimiao + modify thread-safety information + change the thread safety information to be the same as glibc. + +strcasecmp.3 + peng haitao + attributes: note functions that are thread safe with exceptions + the functions strcasecmp() and strncasecmp() are thread safe + with exceptions. + +strerror.3 + ma shimiao + modify thread-safety information + as annotation in glibc manual is more detailed, change the + thread-safety information to be the same as glibc manual. + +strfmon.3 + ma shimiao + attributes: note function that is thread-safe + its marking matches glibc marking. + +strfry.3 + peng haitao + attributes: note function that is thread-safe + the function strfry() is thread safe. + +strftime.3 + peng haitao + attributes: note function that is thread safe with exceptions + the function strftime() is thread safe with exceptions. + +strptime.3 + peng haitao + attributes: note function that is thread safe with exceptions + the function strptime() is thread safe with exceptions. + +strtok.3 + ma shimiao + modify thread-safety information + as annotation in glibc manual is more detailed, change the + thread-safety information to be the same as glibc manual. + +strverscmp.3 + peng haitao + attributes: note function that is thread-safe + the function strverscmp() is thread safe. + +strxfrm.3 + ma shimiao + attributes: note function that is thread-safe + the marking matches glibc marking. + +syslog.3 + peng haitao + attributes: note functions that are thread safe with exceptions + the functions openlog() and closelog() are thread safe. + the functions syslog() and vsyslog() are thread safe with + exceptions. + +tempnam.3 + peng haitao + attributes: note function that is thread-safe + the function tempnam() is thread safe. + +termios.3 + ma shimiao + modify thread-safety information + as annotation in glibc manual is more detailed, change the + thread-safety information to be the same as glibc manual. + ma shimiao + modify thread-safety information + as this is man page for linux, we don't need thread safety + information for bsd + +tgamma.3 + ma shimiao + attributes: note functions that are thread-safe + the functions tgamma(), tgammaf() and tgammal() in glibc are + thread safe. its markings match glibc markings. + +timegm.3 + peng haitao + attributes: note functions that are thread safe with exceptions + the functions timelocal() and timegm() are thread safe with + exceptions. + +tmpfile.3 + ma shimiao + attributes: note function that is thread-safe + its markings match glibc markings. + +tmpnam.3 + peng haitao + modify thread-safety information + when the argument s is null, tmpnam() should be mt-unsafe. + +toupper.3 + ma shimiao + modify thread-safety information + after researching and talking, we think toupper() and tolower() + should not be marked with locale. + after changing, the markings match glbc markings. + +tsearch.3 + ma shimiao + attributes: note functions that are thread-safe + the functions' markings match glibc markings. + +ttyname.3 + ma shimiao + modify thread-safety information + as annotation in glibc manual is more detailed, change the + thread-safety information to be same as glibc manual. + +tzset.3 + peng haitao + attributes: note function that is thread safe with exceptions + the function tzset() is thread safe with exceptions. + +wcsdup.3 + ma shimiao + attributes: note function that is thread-safe + its marking matches glibc marking. + +wctomb.3 + ma shimiao + modify thread-safety information + as annotation in glibc manual is more detailed, change the + thread-safety information to be the same as glibc manual. + +y0.3 + ma shimiao + attributes: note functions that are thread-safe + the function y0(), y1f() ynl() and so on are thread safe. + +man-pages.7 + michael kerrisk + refer reader to attributes(7) for details of attributes section + michael kerrisk + see also: add attributes(7) + +pthreads.7 + michael kerrisk + see also: add attributes(7) + +standards.7 + michael kerrisk + see also: add attributes(7) + + + +==================== changes in man-pages-3.82 ==================== + +released: 2015-03-29, paris + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +alban crequy +andy lutomirski +bert wesarg +bill pemberton +chris delozier +david madore +dmitry deshevoy +eric w. biederman +heinrich schuchardt +jakub wilk +jann horn +jason vas dias +josh triplett +j william piggott +kees cook +konstantin shemyak +ma shimiao +matt turner +michael kerrisk +michael witten +mikael pettersson +namhyung kim +nicolas francois +paul e condon +peter adkins +scot doyle +shawn landden +stéphane aulery +stephen smalley +taisuke yamada +torvald riegel +vincent lefevre + +yuri kozlov + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +nptl.7 + michael kerrisk + new page with details of the nptl posix threads implementation + + +newly documented interfaces in existing pages +--------------------------------------------- + +user_namespaces.7 + eric w. biederman [michael kerrisk] + document /proc/[pid]/setgroups + + +changes to individual pages +--------------------------- + +intro.1 + stéphane aulery + prompt is not % but $ + stéphane aulery + various improvements + - add reference to other common shells dash(1), ksh(1) + - add a reference to stdout(3) + - separate cp and mv descriptions + - add examples of special cases of cd + - add su(1) and shutdown(8) references for section logout + and poweroff + - move control-d to section logout and poweroff + - fix some little formatting errors + stéphane aulery + add cross references cited + stéphane aulery + order see also section + +clone.2 + josh triplett + document that clone() silently ignores clone_pid and clone_stopped + normally, system calls return einval for flags they don't support. + explicitly document that clone does *not* produce an error for + these two obsolete flags. + michael kerrisk + small rewording of explanation of clone() wrt threads + clone has so many effects that it's an oversimplification to say + that the *main* use of clone is to create a thread. (in fact, + the use of clone() to create new processes may well be more + common, since glibc's fork() is a wrapper that calls clone().) + +getgroups.2 + michael kerrisk [shawn landden] + add discussion of nptl credential-changing mechanism + at the kernel level, credentials (uids and gids) are a per-thread + attribute. nptl uses a signal-based mechanism to ensure that + when one thread changes its credentials, all other threads change + credentials to the same values. by this means, the nptl + implementation conforms to the posix requirement that the threads + in a process share credentials. + michael kerrisk + errors: add eperm for the case where /proc/pid/setgroups is "deny" + michael kerrisk + note capability associated with eperm error for setgroups(2) + michael kerrisk + refer reader to user_namespaces(7) for discussion of /proc/pid/setgroups + the discussion of /proc/pid/setgroups has moved from + proc(5) to user_namespaces(7). + +getpid.2 + michael kerrisk + note that getppid() returns 0 if parent is in different pid namespace + +getsockopt.2 + konstantin shemyak + note return value details when netfilter is involved + +ioctl_list.2 + heinrich schuchardt + see also ioctl_fat.2 + add fat_ioctl_get_volume_id + see also ioctl_fat.2 + heinrich schuchardt + include/linux/ext2_fs.h + include linux/ext2_fs.h does not contain any ioctl definitions + anymore. + + request codes ext2_ioc* have been replaced by fs_ioc* in + linux/fs.h. + + some definitions of fs_ioc_* use long* but the actual code expects + int* (see fs/ext2/ioctl.c). + +msgop.2 + bill pemberton + remove eagain as msgrcv() errno + the list of errnos for msgrcv() lists both eagain and enomsg as + the errno for no message available with the ipc_nowait flag. + enomsg is the errno that will be set. + bill pemberton + add an example program + +open.2 + michael kerrisk [jason vas dias] + mention blocking semantics for fifo opens + see https://bugzilla.kernel.org/show_bug.cgi?id=95191 + +seccomp.2 + jann horn [kees cook, mikael pettersson, andy lutomirski] + add note about alarm(2) not being sufficient to limit runtime + jann horn + explain blacklisting problems, expand example + michael kerrisk [kees cook] + add mention of libseccomp + +setgid.2 + michael kerrisk + clarify that setgid() changes all gids when caller has cap_setgid + michael kerrisk [shawn landden] + add discussion of nptl credential-changing mechanism + at the kernel level, credentials (uids and gids) are a per-thread + attribute. nptl uses a signal-based mechanism to ensure that + when one thread changes its credentials, all other threads change + credentials to the same values. by this means, the nptl + implementation conforms to the posix requirement that the threads + in a process share credentials. + +setresuid.2 + michael kerrisk [shawn landden] + add discussion of nptl credential-changing mechanism + at the kernel level, credentials (uids and gids) are a per-thread + attribute. nptl uses a signal-based mechanism to ensure that + when one thread changes its credentials, all other threads change + credentials to the same values. by this means, the nptl + implementation conforms to the posix requirement that the threads + in a process share credentials. + +setreuid.2 + michael kerrisk [shawn landden] + add discussion of nptl credential-changing mechanism + at the kernel level, credentials (uids and gids) are a per-thread + attribute. nptl uses a signal-based mechanism to ensure that + when one thread changes its credentials, all other threads change + credentials to the same values. by this means, the nptl + implementation conforms to the posix requirement that the threads + in a process share credentials. + michael kerrisk + see also: add credentials(7) + +setuid.2 + michael kerrisk + clarify that setuid() changes all uids when caller has cap_setuid + michael kerrisk [shawn landden] + add discussion of nptl credential-changing mechanism + at the kernel level, credentials (uids and gids) are a per-thread + attribute. nptl uses a signal-based mechanism to ensure that + when one thread changes its credentials, all other threads change + credentials to the same values. by this means, the nptl + implementation conforms to the posix requirement that the threads + in a process share credentials. + +sigaction.2 + michael kerrisk + add discussion of rt_sigaction(2) + michael kerrisk + note treatment of signals used internally by nptl + the glibc wrapper gives an einval error on attempts to change the + disposition of either of the two real-time signals used by nptl. + +sigpending.2 + michael kerrisk + add discussion of rt_sigpending(2) + +sigprocmask.2 + michael kerrisk + add discussion of rt_sigprocmask(2) + michael kerrisk + note treatment of signals used internally by nptl + the glibc wrapper silently ignores attempts to block the two + real-time signals used by nptl. + +sigreturn.2 + michael kerrisk + add discussion of rt_sigreturn(2) + +sigsuspend.2 + michael kerrisk + add discussion of rt_sigsuspend(2) + +sigwaitinfo.2 + michael kerrisk + note treatment of signals used internally by nptl + the glibc wrappers silently ignore attempts to wait for + signals used by nptl. + michael kerrisk + add discussion of rt_sigtimedwait(2) + +socket.2 + heinrich schuchardt + see also close(2) + the description mentions close(2). hence it should also be + referenced in the see also section. + +syscall.2 + jann horn + add x32 abi + +umount.2 + eric w. biederman + document the effect of shared subtrees on umount(2) + eric w. biederman + correct the description of mnt_detach + i recently realized that i had been reasoning improperly about + what umount(mnt_detach) did based on an insufficient description + in the umount.2 man page, that matched my intuition but not the + implementation. + + when there are no submounts, mnt_detach is essentially harmless to + applications. where there are submounts, mnt_detach changes what + is visible to applications using the detach directories. + michael kerrisk + move "shared mount + umount" text to a subsection in notes + +aio_return.3 + stéphane aulery + document the return value on error + reported by alexander holler + +clock.3 + stéphane aulery + clocks_per_sec = 1000000 is required by xsi, not posix + debian bug #728213 reported by tanaka akira + + see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=728213 + +dlopen.3 + michael kerrisk + amend error in description of dlclose() behavior + the current text says that unloading depends on whether + the reference count falls to zero *and no other libraries + are using symbols in this library*. that latter text has + been there since man-pages-1.29, but it seems rather dubious. + how could the implementation know whether other libraries + are still using symbols in this library? furthermore, no + other implementation's man page mentions this point. + seems best to drop this point. + michael kerrisk + add some details for rtld_default + michael kerrisk + add some details on rtld_next and preloading + michael kerrisk + rtld_next works for symbols generally, not just functions + the common use case is for functions, but rtld_next + also applies to variable symbols. + michael kerrisk + dlclose() recursively closes dependent libraries + note that dlclose() recursively closes dependent libraries + that were loaded by dlopen() + michael kerrisk + rename second dlopen() argument from "flag" to "flags" + this is more consistent with other such arguments + michael kerrisk + reformat text on rtld_default and rtld_next + +fmemopen.3 + ma shimiao + attributes: note functions that are thread-safe + the markings match glibc markings. + +fpathconf.3 + ma shimiao + attributes: note functions that are thread-safe + the marking matches glibc marking. + +fputwc.3 + ma shimiao + attributes: note functions that are thread-safe + the marking matches glibc marking. + +fputws.3 + ma shimiao + attributes: note function that is thread-safe + the marking matches glibc marking. + +fseek.3 + ma shimiao + attributes: note functions that are thread-safe + the markings match glibc markings. + +fseeko.3 + ma shimiao + attributes: note functions that are thread-safe + the markings match glibc markings. + +gcvt.3 + ma shimiao + attributes: note function that is thread-safe + the marking matches glibc marking. + +getline.3 + ma shimiao + attributes: note functions that are thread-safe + the marking matches glibc marking. + +getwchar.3 + ma shimiao + attributes: note function that is thread-safe + the marking matches glibc marking. + +hypot.3 + ma shimiao + attributes: note functions that are thread-safe + the markings match glibc markings. + +iconv_open.3 + ma shimiao + attributes: note function that is thread-safe + the marking matches glibc marking. + +if_nameindex.3 + ma shimiao + attributes: note functions that are thread-safe + the markings match glibc markings. + +initgroups.3 + ma shimiao + attributes: note function that is thread-safe + the markings match glibc markings. + +mq_open.3 + torvald riegel + add einval error case for invalid name + this behavior is implementation-defined by posix. if the name + doesn't start with a '/', glibc returns einval without attempting + the syscall. + +popen.3 + ma shimiao + attributes: note functions that are thread-safe + the marking matches glibc marking. + +pthread_kill.3 + michael kerrisk + note treatment of signals used internally by nptl + the glibc pthread_kill() function gives an error on attempts + to send either of the real-time signals used by nptl. + +pthread_sigmask.3 + michael kerrisk + note treatment of signals used internally by nptl + the glibc implementation silently ignores attempts to block the two + real-time signals used by nptl. + +pthread_sigqueue.3 + michael kerrisk + note treatment of signals used internally by nptl + the glibc pthread_sigqueue() function gives an error on attempts + to send either of the real-time signals used by nptl. + +resolver.3 + stéphane aulery [jakub wilk] + document missing options used by _res structure indicate defaults + missing options: res_insecure1, res_insecure2, res_noaliases, + use_inet6, rotate, nocheckname, res_keeptsig, blast, usebstring, + noip6dotint, use_edns0, snglkup, snglkupreop, res_use_dnssec, + notldquery, default + + written from the glibc source and resolv.conf.5. + + see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=527136 + stéphane aulery + res_igntc is implemented + +rint.3 + matt turner + document that halfway cases are rounded to even + per ieee-754 rounding rules. + + the round(3) page describes the behavior of rint and nearbyint + in the halfway cases by saying: + + these functions round x to the nearest integer, but round + halfway cases away from zero [...], instead of to the + nearest even integer like rint(3) + +sigqueue.3 + michael kerrisk + notes: add "c library/kernel abi differences" subheading + michael kerrisk + clarify version info (mention rt_sigqueueinfo()) + +sigsetops.3 + michael kerrisk + note treatment of signals used internally by nptl + the glibc sigfillset() function excludes the two real-time + signals used by nptl. + +sigwait.3 + michael kerrisk + note treatment of signals used internally by nptl + the glibc sigwait() silently ignore attempts to wait for + signals used by nptl. + +strcoll.3 + ma shimiao + attributes: note function that is thread-safe + the markings match glibc markings. + +strdup.3 + ma shimiao + attributes: note functions that are thread-safe + the marking matches glibc marking. + +tzset.3 + j william piggott + add 'std' quoting information + +ulimit.3 + ma shimiao + attributes: note function that is thread-safe + the marking matches glibc marking. + +wcstombs.3 + ma shimiao + attributes: note function that is thread-safe + the marking matches glibc marking. + +wctob.3 + ma shimiao + attributes: note function that is thread-safe + the marking matches glibc marking. + +xdr.3 + taisuke yamada + clarified incompatibility and correct usage of xdr api + see http://bugs.debian.org/628099 + +console_codes.4 + scot doyle + add console private csi sequence 15 + an undocumented escape sequence in drivers/tty/vt/vt.c brings the + previously accessed virtual terminal to the foreground. + mtk: patch misattributed to taisuke yamada in git commit + because of a muck up on my part. + michael kerrisk + add kernel version number for csi sequence 15 + +random.4 + michael kerrisk + fix permissions shown for the devices + these days, the devices are rw for everyone. + +filesystems.5 + michael kerrisk + remove dubious claim about comparative performance of ext2 + perhaps it was the best filesystem performance-wise in + the 20th century, when that text was written. that probably + ceased to be true quite a long time ago, though. + stéphane aulery + add cross references for ext filesystems + stéphane aulery + specifies the scope of this list and its limits. + +host.conf.5 +hosts.5 +resolv.conf.5 + stéphane aulery [paul e condon] + cross references of these pages. + see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=298259 + +host.conf.5 + stéphane aulery + rework discussion of nospoof, spoofalert, spoof and resolv_spoof_check + the keywords and environment variables "nospoof", "spoofalert", + "spoof" and resolv_spoof_check were added to glibc 2.0.7 but + never implemented + + move descriptions to historical section and reorder it for clarity + + see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=773443 + +hosts.5 + stéphane aulery [vincent lefevre] + mention 127.0.1.1 for fqdn and ipv6 examples + see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=562890 + +proc.5 + taisuke yamada + document /proc/pid/status vmpin field + see https://bugs.launchpad.net/bugs/1071746 + michael kerrisk + document (the obsolete) /proc/pid/seccomp + michael kerrisk + replace description of 'uid_map' with a reference to user_namespaces(7) + all of the information in proc(5) was also present in + user_namespaces(7), but the latter was more detailed + and up to date. + taisuke yamada + fix selinux /proc/pid/attr/current example + since the /proc/pid/attr api was added to the kernel, there + have been a couple of changes to the selinux handling of + /proc/pid/attr/current. fix the selinux /proc/pid/attr/current + example text to reflect these changes and note which kernel + versions first included the changes. + +securetty.5 + stéphane aulery [nicolas francois] + note that the pam_securetty module also uses this file + see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=528015 + + this patch is a modified version of the one proposed without + parts specific to debian. + +boot.7 + michael witten + copy edit + while a lot of the changes are issues of presentation, + there are also issues of grammar and punctuation. + michael witten + mention `systemd(1)' and its related `bootup(7)' + it's important that the reader receive contemporary information. + +credentials.7 + michael kerrisk + see also: add pthreads(7) + michael kerrisk + add reference to nptl(7) + +feature_test_macros.7 + michael kerrisk + update discussion of _fortify_source + since the initial implementation a lot more checks were added. + describe all the checks would be too verbose (and would soon + fall out of date as more checks are added). so instead, describe + the kinds of checks that are done more generally. + also a few other minor edits to the text. + +hier.7 + stéphane aulery + first patch of a series to achieve compliance with fhs 2.3 + stéphane aulery + sgml and xml directories are separated in fhs 2.3 + stéphane aulery + add missing directories defined by fhs 2.3 + stéphane aulery + identify which directories are optional + stéphane aulery + document /initrd, /lost+found and /sys + ubuntu bug #70094 reported by brian beck + https://bugs.launchpad.net/ubuntu/+source/manpages/+bug/70094 + stéphane aulery + explain yp, which is not obvious + +ipv6.7 + stéphane aulery [david madore] + sol_ipv6 and other sol_* options socket are not portable + see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=472447 + +man-pages.7 + michael kerrisk [bill pemberton] + add indent(1) command that produces desired formatting for example code + stéphane aulery + improve description of sections in accordance with intro pages + +packet.7 + michael kerrisk + rework description of fanout algorithms as list + michael kerrisk + remove mention of needing uid 0 to create packet socket + the existing text makes no sense. the check is based + purely on a capability check. (kernel function + net/packet/af_packet.c::packet_create() + michael kerrisk + remove text about ancient glibc not defining sol_packet + this was fixed in glibc 2.1.1, which is a long while ago. + and in any case, there is nothing special about this case; + it's just one of those times when glibc lags. + michael kerrisk + rework description of 'sockaddr_ll' fields as a list + michael kerrisk + various minor edits + +pthreads.7 + michael kerrisk + add references to nptl(7) + +raw.7 + michael kerrisk + rephrase "linux 2.2" language to "linux 2.2 or later" + the man page was written in the linux 2.2 timeframe, and + some phrasing was not future-proof. + +signal.7 + michael kerrisk + note when linux added realtime signals + michael kerrisk + correct the range of realtime signals + michael kerrisk + summarize 2.2 system call changes that resulted from larger signal sets + michael kerrisk + see also: add nptl(7) + +tcp.7 + peter adkins + document removal of tcp_synq_hsize + looking over the man page for 'tcp' i came across a reference to + tuning the 'tcp_synq_hsize' parameter when increasing + 'tcp_max_syn_backlog' above 1024. however, this static sizing was + removed back in linux 2.6.20 in favor of dynamic scaling - as + part of commit 72a3effaf633bcae9034b7e176bdbd78d64a71db. + +user_namespaces.7 + eric w. biederman + update the documentation to reflect the fixes for negative groups + files with access permissions such as rwx---rwx give fewer + permissions to their group then they do to everyone else. which + means dropping groups with setgroups(0, null) actually grants a + process privileges. + + the unprivileged setting of gid_map turned out not to be safe + after this change. privileged setting of gid_map can be + interpreted as meaning yes it is ok to drop groups. [ eric + additionally noted: setting of gid_map with privilege has been + clarified to mean that dropping groups is ok. this allows + existing programs that set gid_map with privilege to work + without changes. that is, newgidmap(1) continues to work + unchanged.] + + to prevent this problem and future problems, user namespaces were + changed in such a way as to guarantee a user can not obtain + credentials without privilege that they could not obtain without + the help of user namespaces. + + this meant testing the effective user id and not the filesystem + user id, as setresuid(2) and setregid(2) allow setting any process + uid or gid (except the supplementary groups) to the effective id. + + furthermore, to preserve in some form the useful applications + that have been setting gid_map without privilege, the file + /proc/[pid]/setgroups was added to allow disabling setgroups(2). + with setgroups(2) permanently disabled in a user namespace, it + again becomes safe to allow writes to gid_map without privilege. + michael kerrisk + rework some text describing permission rules for updating map files + no (intentional) change to the facts, but this restructuring + should make the meaning easier to grasp. + michael kerrisk + update kernel version associated with 5-line limit for map files + as at linux 3.18, the limit is still five lines, so mention the + more recent kernel version in the text. + michael kerrisk [alban crequy] + handle /proc/pid/setgroups in the example program + michael kerrisk + rework text describing restrictions on updating /proc/pid/setgroups + no (intentional) changes to factual description, but the + restructured text is hopefully easier to grasp. + michael kerrisk + explain why the /proc/pid/setgroups file was added + +ldconfig.8 + michael kerrisk + note use of /lib64 and /usr/lib64 on some 64-bit architectures + +ld.so.8 + michael kerrisk + note the use of /lib64 and /usr/lib64 on some 64-bit architectures + + + +==================== changes in man-pages-3.83 ==================== + +released: 2015-04-19, munich + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +andreas baak +andreas dilger +cdlscpmv +cyrill gorcunov +darrick j. wong +david rientjes +dima tisnek +eric sandeen +fabien pichot +felix sedlmeier +gleb fotengauer-malinovskiy +heinrich schuchardt +jann horn +jon grant +jonny grant +kees cook +masanari iida +ma shimiao +michael kerrisk +nikos mavrogiannopoulos +omar sandoval +pierre chifflier +robin h. johnson +rob landley +theodore ts'o +vlastimil babka +walter harms +william woodruff +yoshifuji hideaki +zeng linggang + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +posix_madvise.3 + michael kerrisk + new page documenting posix_madvise(3) + +ftw.3 + michael kerrisk + reorganize the page to give primacy to nftw() + nftw() is the better api, and posix.1-2008 marks ftw() obsolete. + +newly documented interfaces in existing pages +--------------------------------------------- + +getdents.2 + michael kerrisk [dima tisnek] + document getdents64() + see https://bugzilla.kernel.org/show_bug.cgi?id=14795 + +mount.2 + michael kerrisk, theodore ts'o [eric sandeen, andreas dilger, + omar sandoval, darrick j. wong] + document ms_lazytime + +proc.5 + michael kerrisk + document /proc/sys/kernel/randomize_va_space + michael kerrisk + document /proc/pid/fdinfo epoll format + michael kerrisk + describe /proc/pid/fdinfo eventfd format + michael kerrisk + document /proc/pid/fdinfo signalfd format + + +new and changed links +--------------------- + +newfstatat.2 + michael kerrisk + new link to fstatat64.2 + +prlimit64.2 + michael kerrisk + new link to getrlimit.2 + + +global changes +-------------- + +various section 3 math pages + michael kerrisk + note that these functions are also in posix.1-2001 and posix.1-2008 + + +changes to individual pages +--------------------------- + +getent.1 + robin h. johnson + document options + the options to getent are now documented, after being around for + nearly a decade without changes. + michael kerrisk + document help and version options + +fallocate.2 + michael kerrisk + fix kernel version number for falloc_fl_zero_range + falloc_fl_zero_range was added in 3.15, not 3.14. + michael kerrisk + note that smb3 added falloc_fl_zero_range support in linux 3.17 + +getrlimit.2 + michael kerrisk + note that the underlying system call for prlimit() is prlimit64() + michael kerrisk + remove "_file_offset_bits == 64" from prlimit() ftm requirements + "_file_offset_bits == 64" is not needed to get the prlimit() + declaration. + +ioctl_list.2 + nikos mavrogiannopoulos + siocaddrt accepts in6_rtmsg in inet6 protocol + heinrich schuchardt + tfd_ioc_set_ticks + timerfd_create.2 mentions tfd_ioc_set_ticks. we should add it to + ioctl_list.2, too. + +llseek.2 + michael kerrisk + advise reader to use lseek(2) instead + michael kerrisk + llseek() exists on 32-bit platforms to support seeking to large offsets + +madvise.2 + david rientjes + specify madv_remove returns einval for hugetlbfs + madvise(2) actually returns with error einval for madv_remove + when used for hugetlb vmas, not eopnotsupp, and this has been + the case since madv_remove was introduced in commit f6b3ec238d12 + ("madvise(madv_remove): remove pages from tmpfs shm backing + store"). specify the exact behavior. + michael kerrisk + see also: add posix_madvise(2) + +poll.2 + michael kerrisk [andreas baak] + see also: add epoll(7) + +posix_fadvise.2 + michael kerrisk + add "c library/kernel abi differences" subsection + +pread.2 + michael kerrisk + add "c library/kernel abi differences" subsection + +seccomp.2 + michael kerrisk [pierre chifflier, kees cook] + note that seccomp_data is read-only + +stat.2 + michael kerrisk + add some details on various "stat" versions + three versions of "stat" appeared on 32-bit systems, + dealing with structures of different (increasing) sizes. + explain some of the details, and also note that the + situation is simpler on modern 64-bit architectures. + michael kerrisk + add mention of newfstatat() + the underlying system call for fstatat() is newfstatat() + on some architectures. + +symlink.2 + michael kerrisk [jonny grant] + errors: add linkpath=="" case for enoent + +syscalls.2 + michael kerrisk + remove prlimit() + there really is only the prlimit64() system call. + michael kerrisk + add some details about the "multiple versions of system calls" + the multiple-system-call-version phenomenon is particularly a + feature of older 32-bit platforms. hint at that fact in the text. + +timerfd_create.2 + cyrill gorcunov [michael kerrisk] + document tfd_ioc_set_ticks ioctl() operation + michael kerrisk + add some details to c library/kernel abi differences + +unshare.2 + michael kerrisk [fabien pichot] + remove mention of "system v" from discussion of clone_newipc + these days, clone_newipc also affects posix message queues. + +asprintf.3 + zeng linggang + attributes: note functions that are thread-safe + +carg.3 + michael kerrisk + add introductory sentence explaining what these functions calculate + +ccos.3 + ma shimiao + attributes: note functions that are thread-safe + michael kerrisk + add introductory sentence explaining what these functions calculate + +ccosh.3 + michael kerrisk + add introductory sentence explaining what these functions calculate + +cexp.3 + ma shimiao + attributes: note functions that are thread-safe + +clock.3 + ma shimiao + attributes: note functions that is thread-safe + +clog.3 + michael kerrisk + add introductory sentence explaining what these functions calculate + +csin.3 + ma shimiao + attributes: note functions that are thread-safe + michael kerrisk + add introductory sentence explaining what these functions calculate + +csinh.3 + ma shimiao + attributes: note functions that are thread-safe + michael kerrisk + add introductory sentence explaining what these functions calculate + +csqrt.3 + ma shimiao + attributes: note functions that are thread-safe + michael kerrisk + simplify description of what these functions calculate + +ctan.3 + ma shimiao + attributes: note functions that are thread-safe + michael kerrisk + add introductory sentence explaining what these functions calculate + +ctanh.3 + ma shimiao + attributes: note functions that are thread-safe + michael kerrisk + add introductory sentence explaining what these functions calculate + +ctime.3 + zeng linggang + attributes: note functions that aren't thread-safe + +exec.3 + michael kerrisk + synopsis: clarify calling signature for execl() and execlp() + michael kerrisk [andreas baak] + correct prototype for execle() + make the prototype shown into correct c. + +ftw.3 + michael kerrisk [felix sedlmeier] + ftw() and nftw() differ for the non-stat-able symlink case + the posix specification of ftw() says that an un-stat-able + symlink may yield either ftw_ns or ftw_sl. the specification + of nftw() does not carry this statement. + michael kerrisk + conforming to: add posix.1-2008 + michael kerrisk + update posix version references in notes + +getcwd.3 + jann horn [michael kerrisk] + note behavior for unreachable current working directory + michael kerrisk + add enomem error + +gethostbyname.3 + michael kerrisk [jonny grant] + clarify that no_address and no_data are synonyms + michael kerrisk + add some detail for no_data + text consistent with posix and freebsd's gethostbyname() man page. + zeng linggang + attributes: note functions that aren't thread-safe + +getnetent.3 + zeng linggang + attributes: note functions that aren't thread-safe + +get_nprocs_conf.3 + zeng linggang + attributes: note functions that are thread-safe + +getutent.3 + zeng linggang + attributes: note functions that aren't thread-safe + +glob.3 + zeng linggang + attributes: note functions that aren't thread-safe + +insque.3 + ma shimiao + attributes: note functions that are thread-safe + +login.3 + zeng linggang + attributes: note functions that aren't thread-safe + +lseek64.3 + michael kerrisk + clarify details with respect to 32-bit and 64-bit systems + +malloc.3 + michael kerrisk + add enomem error + +mbsnrtowcs.3 + zeng linggang + attributes: note function that isn't thread-safe + +mbsrtowcs.3 + zeng linggang + attributes: note function that isn't thread-safe + +mq_notify.3 + michael kerrisk + add "c library/kernel abi differences" subsection + +mq_open.3 + michael kerrisk [fabien pichot] + notes: explain differences from the underlying system call + the check for the slash at the start of a pathname is done in glibc + +openpty.3 + zeng linggang + attributes: note functions that aren't thread-safe + +perror.3 + zeng linggang + attributes: note function that is thread-safe + +posix_memalign.3 + zeng linggang + attributes: note functions that aren't thread-safe + +printf.3 + zeng linggang + attributes: note functions that are thread-safe + walter harms [michael kerrisk] + simplify the example code + +qsort.3 + michael kerrisk [rob landley] + alphasort() and versionsort() are not suitable for 'compar' + in glibc 2.10, the prototypes of alphasort() and versionsort() + were changed so that the arguments switched from 'const void *' to + 'const struct dirent **', to match the posix.1-2008 specification + of alphasort(). as such, compiler warnings will result if + these functions are used as the arguments of qsort(). + + warning: passing argument 4 of 'qsort' from incompatible + pointer type + expected '__compar_fn_t' but argument is of type + 'int (*)(const struct dirent **, const struct dirent **)' + + therefore, remove the ancient notes text suggesting that + alphasort() and versionsort() can be used as suitable + 'compar' arguments for qsort(). + +realpath.3 + michael kerrisk [jon grant] + add enomem error + +scandir.3 + michael kerrisk + glibc 2.10 changed the argument types for alphasort() and versionsort() + zeng linggang + attributes: note functions that are thread-safe + +scanf.3 + zeng linggang + attributes: note functions that are thread-safe + +setnetgrent.3 + zeng linggang + attributes: note functions that aren't thread-safe + +significand.3 + ma shimiao + attributes: note functions that are thread-safe + +strcasecmp.3 + michael kerrisk [jonny grant] + clarify that strcasecmp() does a byte-wise comparison + michael kerrisk + conforming to: add posix.1-2008 + +unlocked_stdio.3 + zeng linggang + attributes: note functions that aren't thread-safe + +updwtmp.3 + zeng linggang + attributes: note functions that aren't thread-safe + +wcrtomb.3 + zeng linggang + attributes: note function that isn't thread-safe + +wcsnrtombs.3 + zeng linggang + attributes: note function that isn't thread-safe + +wcsrtombs.3 + zeng linggang + attributes: note function that isn't thread-safe + +wordexp.3 + zeng linggang + attributes: note functions that aren't thread-safe + +wprintf.3 + zeng linggang + attributes: note functions that are thread-safe + +proc.5 + michael kerrisk + describe "mnt_id" field of /proc/pid/fdinfo + michael kerrisk + note that abstract sockets are included in /proc/net/unix + michael kerrisk + update description /proc/sys/unix 'type' field + the existing text was very crufty. unix domain sockets + support more than sock_stream for a _very_ long time now. + michael kerrisk + add some detail to /proc/pid/timers + michael kerrisk [vlastimil babka] + enhance discussion of /proc/pid/status 'vmswap' field + +epoll.7 + michael kerrisk + see also: add poll(2) and select(2) + +icmp.7 + yoshifuji hideaki/吉藤英明 + document net.ipv4.ping_group_range knob + +nptl.7 + michael kerrisk + add reference to timer_create(2) + + +==================== changes in man-pages-4.00 ==================== + +released: 2015-05-07, munich + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +advait dixi +alain kalker +andi kleen +andreas gruenbacher +andreas heiduk +askar safin +brice goglin +cameron norman +carlos o'donell +chris metcalf +christophe lohr +christopher head +christoph hellwig +david wilcox +denis du +egmont koblinger +filipe brandenburger +filipus klutiero +florian weimer +frédéric maria +gleb fotengauer-malinovskiy +graham shaw +gregor jasny +guillem jover +guy harris +heinrich schuchardt +ian pilcher +jann horn +jason newton +j. bruce fields +jiri pirko +joachim wuttke +joern heissler +jonathan nieder +joonas salo +jussi lehtola +kirill a. shutemov +kosaki motohiro +laurence gonsalves +magnus reftel +michael kerrisk +neilbrown +regid ichira +sam varshavchik +steinar h. gunderson +stéphane aulery +stephane fillod +tetsuo handa +thomas hood +urs thuermann +vasiliy kulikov +vegard nossum +weijie yang +william woodruff +zeng linggang + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +get_phys_pages.3 + william woodruff + document get_phys_pages() and get_avphys_pages() + +loop.4 + urs thuermann, michael kerrisk + new page documenting the loop device + +xattr.7 + andreas gruenbacher + import attr(5) man page from the 'attr' project + after discussions with andreas gruenbacher, it makes sense to + move this page into man-pages, since it mostly relates to + kernel details. since this is an overview page, + we'll move it to section 7. + michael kerrisk + rename page + "xattr" is a more meaningful name than "attr" (it resonates + with the names of the system calls), so as long as we are + moving the page to a new section, we'll change the name as well, + and retain an acl(5) link so that old references remain valid. + + +newly documented interfaces in existing pages +--------------------------------------------- + +mmap.2 + michael kerrisk [andi kleen] + document map_huge_2mb, map_huge_1gb, and map_huge_shift + +shmget.2 + michael kerrisk [andi kleen] + document shm_huge_2mb, shm_huge_1gb, and shm_huge_shift + +resolver.3 + michael kerrisk [jonathan nieder] + add descriptions of some other resolver functions + add res_ninit(), res_nquery(), res_nsearch(), + and res_nquerydomain(), res_nmkquery(), res_nsend(). + +tty_ioctl.4 + frédéric maria [stephane fillod, andreas heiduk] + document tiocmiwait and tiocgicount + michael kerrisk + document tiocgexcl + michael kerrisk + document tiogcpkt + michael kerrisk + document tiocsptlck + michael kerrisk + document tiocgptlck + + +new and changed links +--------------------- + +cmsg_data.3 + michael kerrisk + new link to cmsg(3) + +cmsg_len.3 + michael kerrisk + new link to cmsg(3) + +dprintf.3 + michael kerrisk + convert to a link to printf.3 + +get_avphys_pages.3 + william woodruff + new link to new get_phys_pages.3 page + +res_ninit.3 +res_nmkquery.3 +res_nquery.3 +res_nquerydomain.3 +res_nsearch.3 +res_nsend.3 + michael kerrisk + new links to resolver(3) man page + +loop-control.4 + michael kerrisk + new link to loop.4 + +attr.5 + michael kerrisk + new link to xattr(7) + + +global changes +-------------- + +chown.2 +execve.2 +prctl.2 +truncate.2 +proc.5 +capabilities.7 +ld.so.8 + michael kerrisk + tighter wording: 'mode bit' rather than 'permission bit' + for sticky, set-uid, and set-gid mode bits (as used in posix). + + +changes to individual pages +--------------------------- + +add_key.2 +keyctl.2 +request_key.2 + michael kerrisk + see also: add keyrings(7) + +add_key.2 +request_key.2 + michael kerrisk + see also: add keyctl(3) + +epoll_ctl.2 + michael kerrisk + after epollhup, eof will be seen only after all data has been consumed + +epoll_wait.2 + michael kerrisk + clarify that signal mask treatment in epoll_pwait() is per-thread + s/sigprocmask()/pthread_sigmask()/ + +fcntl.2 + michael kerrisk [vegard nossum] + note an f_setsig corner case + +get_mempolicy.2, set_mempolicy + brice goglin + policy is per thread, not per process + +getxattr.2 +listxattr.2 +removexattr.2 +setxattr.2 +capabilities.7 + michael kerrisk + adjust "attr(5)" references to "xattr(7)" + +ioctl.2 + michael kerrisk + see also: add console_ioctl(2) and tty_ioctl(2) + +listxattr.2 +xattr.7 + michael kerrisk + describe listxattr(2) e2big error and document it as a bug + +mkdir.2 + michael kerrisk + wording fixes + point reader at stat(2) for explanation of file mode + michael kerrisk [andreas grünbacher] + further tweaks to text on s_isvtx and 'mode' argument + +mknod.2 + michael kerrisk + rewordings + point reader at stat(2) for details of mode bits + +mmap.2 + michael kerrisk + remove text that implies that munmap() syncs map_shared mapping to file + the existing text in this page: + + map_shared share this mapping. updates to the mapping + are visible to other processes that map this + file, and are carried through to the underly‐ + ing file. the file may not actually be + updated until msync(2) or munmap() is called. + + implies that munmap() will sync the mapping to the underlying + file. posix doesn't require this, and some light reading of the + code and some light testing (fsync() after munmap() of a large + file) also indicates that linux doesn't do this. + +msync.2 + michael kerrisk + rework text of description + rewrite the text somewhat, for easier comprehension. + no (intentional) changes to factual content + +nfsservctl.2 + michael kerrisk [j. bruce fields] + note that nfsservctl() was replaced by files in nfsd filesystem + +open.2 + michael kerrisk [andreas gruenbacher] + open() honors the s_isvtx, s_isuid, and s_isgid bits in 'mode' + michael kerrisk + tighten wording: use 'mode bit' rather than 'permission bit' + michael kerrisk [neilbrown] + bugs: o_creat | o_directory succeeds if pathname does not exist + +poll.2 + michael kerrisk [ian pilcher] + clarify that signal mask treatment in ppoll() is per-thread + s/sigprocmask()/pthread_sigmask()/ + michael kerrisk [sam varshavchik] + after pollhup, eof will be seen only after all data has been consumed + michael kerrisk + make it clearer which bits are ignored in 'events' + +prctl.2 + michael kerrisk [david wilcox, filipe brandenburger] + note that "parent" for purposes of pr_set_deathsig is a *thread* + see https://bugzilla.kernel.org/show_bug.cgi?id=43300 + +sendfile.2 + michael kerrisk [jason newton] + note that sendfile does not support o_append for 'out_fd' + see https://bugzilla.kernel.org/show_bug.cgi?id=82841 + michael kerrisk [gregor jasny] + return value: note the possibility of "short sends" + see https://bugzilla.kernel.org/show_bug.cgi?id=97491 + michael kerrisk [askar safin] + clarify text on 'out_fd' and regular files in linux 2.4 + see https://bugzilla.kernel.org/show_bug.cgi?id=86001 + +shutdown.2 + michael kerrisk [stéphane aulery] + bugs: unix domain sockets now detect invalid 'how' values + bug fixed in linux 3.7. + see https://bugzilla.kernel.org/show_bug.cgi?id=47111 + +sigaction.2 + michael kerrisk + refer the reader to fcntl(2) f_setsig for further details on si_fd + +stat.2 + jann horn + add note about stat() being racy + andreas gruenbacher + improve description of some mode constants + michael kerrisk [andreas grünbacher] + remove excessive leading zeros on some constants + michael kerrisk + add text on posix terms "file mode bits" and "file permission bits" + recent changes to various pages employ this distinction. + michael kerrisk + tighten wording: use 'mode bit' rather than 'permission bit' + according to posix, the 9 ugo*rwx bits are permissions, and + 'mode' is used to refer to collectively to those bits plus sticky, + set-uid, and set_gid bits. + +syslog.2 + michael kerrisk + see also: add dmesg(1) + +umask.2 +open.2 +mknod.2 +mkdir.2 + andreas gruenbacher + explain what default acls do + explain the effect that default acls have (instead of the umask) + in umask.2. mention that default acls can have an affect in + open.2, mknod.2, and mkdir.2. + +unshare.2 + michael kerrisk [florian weimer] + give the reader a hint that unshare() works on processes or threads + see https://bugzilla.kernel.org/show_bug.cgi?id=59281 + +atexit.3 + zeng linggang + attributes: note function that is thread-safe + +bsearch.3 + zeng linggang + attributes: note function that is thread-safe + +cmsg.3 + michael kerrisk [christopher head] + fix error in scm_rights code sample + remove erroneous second initialization of msg.msg_controllen + in the example code for scm_rights. + see https://bugzilla.kernel.org/show_bug.cgi?id=15952 + +cpu_set.3 + chris metcalf + clarify language about "available" cpus + the cpu_set.3 man page uses the adjective "available" when + explaining what the argument to cpu_set() means. this is + confusing, since "available" isn't well-defined. the kernel + has a set of adjectives (possible, present, online, and active) + that qualify cpus, but normally none of these are what the + cpu_set_t bit index means: it's just "which cpu", using the + kernel's internal numbering system, even if that cpu isn't + possible or present. + + this change removes the word "available" and adds a sentence + warning that cpu sets may not be contiguous due to dynamic + cpu hotplug, etc. + +err.3 + zeng linggang + attributes: note functions that are thread-safe + +ftw.3 + zeng linggang + attributes: note functions that are thread-safe + +gethostbyname.3 + carlos o'donell + nss plugins searched first + carlos o'donell + "order" is obsolete + +gethostid.3 + zeng linggang + attributes: note functions that are/aren't thread-safe + +getmntent.3 + zeng linggang + attributes: note functions that are/aren't thread-safe + +get_nprocs_conf.3 + michael kerrisk + use exit() rather than return in main() + +getopt.3 + michael kerrisk [guy harris] + remove crufty bugs section + see https://bugzilla.kernel.org/show_bug.cgi?id=90261 + +iconv_close.3 + zeng linggang + attributes: note function that is thread-safe + +inet_ntop.3 + zeng linggang + attributes: note function that is thread-safe + +longjmp.3 + zeng linggang + attributes: note functions that are thread-safe + +lsearch.3 + zeng linggang + attributes: note functions that are thread-safe + +mcheck.3 + zeng linggang + attributes: note functions that aren't thread-safe + +on_exit.3 + zeng linggang + attributes: note function that is thread-safe + +printf.3 + michael kerrisk [egmont koblinger] + merge dprintf() and vdprintf() discussion into this page + michael kerrisk + see also: add puts(3) + michael kerrisk + move return value discussion to proper return value section + +putpwent.3 + zeng linggang + attributes: note function that is thread-safe + +qsort.3 + zeng linggang + attributes: note functions that are thread-safe + +regex.3 + michael kerrisk [laurence gonsalves] + fix error in description of 'cflags' + 'cflags' is a bit mask of *zero* (not one) or more flags. + +resolver.3 + stéphane aulery + add info about res_insecure1 and res_insecure2 option in debug mode + +scanf.3 + joern heissler + improve description of %n specifier + +setjmp.3 + zeng linggang + attributes: note functions that are thread-safe + +setlocale.3 + zeng linggang + attributes: note function that isn't thread-safe + +setlogmask.3 + zeng linggang + attributes: note function that isn't thread-safe + +sleep.3 + zeng linggang + attributes: note function that isn't thread-safe + +strsignal.3 + zeng linggang + attributes: note function that isn't thread-safe + +sysconf.3 + zeng linggang + attributes: note function that is thread-safe + +undocumented.3 + william woodruff + remove documented functions + +tty_ioctl.4 + michael kerrisk [denis du] + fix error in code example + +proc.5 + michael kerrisk [cameron norman, vasiliy kulikov] + document /proc mount options + document the 'hidepid' and 'gid' mount options that were added in + linux 3.3. see https://bugzilla.kernel.org/show_bug.cgi?id=90641 + based on text by vasiliy kulikov in + documentation/filesystems/proc.txt. + michael kerrisk [kirill a. shutemov] + improve description of /proc/pid/status + guillem jover + document /proc/pid/exe behaviour on unlinked pathnames + michael kerrisk [weijie yang] + document /proc/pid/status vmpmd + +resolv.conf.5 + stéphane aulery [thomas hood] + document use-vc option added to glibc 2.14 + fix ubuntu bug #1110781: + https://bugs.launchpad.net/ubuntu/+source/manpages/+bug/1110781 + stéphane aulery [thomas hood] + document res_snglkupreop + fix ubuntu bug #1110781: + https://bugs.launchpad.net/ubuntu/+source/manpages/+bug/1110781 + +tzfile.5 + sam varshavchik + add various details on version 2 format + +aio.7 + michael kerrisk + add details and update url for ols 2003 paper on aio + +bootparam.7 + michael kerrisk [alain kalker] + update discussion of 'debug' option + see https://bugzilla.kernel.org/show_bug.cgi?id=97161 + michael kerrisk + summary of multiple changes: remove cruft from this page. + much of the detail on hardware specifics in this page dates + from the 20th century. (the last major update to this page was in + man-pages-1.14!) it's hugely out of date now (many of these + devices disappeared from the kernel years ago.) so, i've taken + a large scythe to the page to remove anything that looks + seriously dated. in the process, the page has shrunk to less + than 50% of its previous size. + michael kerrisk + remove "buff=" details + this seems to have gone away in linux 2.2. + michael kerrisk + remove crufty "mouse drivers" options + michael kerrisk + remove crufty "general non-device-specific boot arguments" options + michael kerrisk + remove crufty "hard disks" options + michael kerrisk + remove crufty "mem=" details + michael kerrisk + remove crufty details on ibm mca bus devices + michael kerrisk + remove 'swap=" details + this seems to have gone away in linux 2.2, + michael kerrisk + remove crufty floppy disk driver options + in the specific case of floppy drives: the drivers still + exist, but it's been a while since most of saw these devices + in the wild. so, just refer the reader to the kernel source + file for details. (the detail in this man page was after all + originally drawn from that file.) + remove crufty "isdn drivers" options + michael kerrisk + remove crufty "line printer driver" options + michael kerrisk + remove crufty "serial port drivers" options + michael kerrisk + remove crufty reference to config_bugi386 + that option disappeared in linux 2.4. + michael kerrisk + remove crufty text + "bootsetups array" dates from linux 2.0. + michael kerrisk + remove crufty "video hardware" options + michael kerrisk + remove crufty scsi device driver options + +fanotify.7 + michael kerrisk [heinrich schuchardt] + since linux 3.19, fallocate(2) generates fan_modify events + +inotify.7 + michael kerrisk [heinrich schuchardt] + since linux 3.19, fallocate(2) generates in_modify events + +ip.7 + michael kerrisk + explain how ip_add_membership determines its argument type + michael kerrisk [jiri pirko, magnus reftel] + clarify details of the ip_multicast_if socket option + michael kerrisk [advait dixi] + remove dubious text that says that so_priority sets ip tos + see https://bugzilla.kernel.org/show_bug.cgi?id=35852 + michael kerrisk + relocate misplaced text describing enoprotoopt error + +packet.7 + graham shaw + add sll_protocol to list of required fields for outbound packets + +pthreads.7 + michael kerrisk [kosaki motohiro] + using thread ids whose lifetime has expired gives undefined behavior + see https://bugzilla.kernel.org/show_bug.cgi?id=53061 + +raw.7 + michael kerrisk [tetsuo handa] + for incoming datagrams, sin_port is set to zero + michael kerrisk + mention sendto(), recvfrom(), and so on when discussing address format + this gives the reader a little context for the following + discussion of 'sin_port'. + michael kerrisk + remove crufty reference to + michael kerrisk + replace reference to rfc 1700 with pointer to iana protocol number list + +signal.7 + michael kerrisk [steinar h. gunderson] + clarify that i/o operations on disks are not interrupted by signals + see https://bugzilla.kernel.org/show_bug.cgi?id=97721 + +unix.7 + michael kerrisk [christophe lohr] + remove mention of unix_path_max + this kernel constant is not exposed to user space. + michael kerrisk + note the 108 bytes for sun_path is how things are done on linux + and refer the reader to notes for discussion of portability. + +xattr.7 + michael kerrisk + document ea limits for btrfs + michael kerrisk + document vfs-imposed limits on eas + vfs imposes a 255-byte limit on ea names, and a 64kb limit on + ea values. + michael kerrisk + the ext[234] block limitation applies to sum of all eas + it is not a per-ea limit. + michael kerrisk + clarify permissions required to work with 'user' eas + michael kerrisk + ext2 and ext3 no longer need mounting with 'user_xattr' for user eas + michael kerrisk + add various relevant pages to see also + michael kerrisk + add conforming to section + michael kerrisk + modify headings to man-pages norms + michael kerrisk + btrfs also supports extended attributes + michael kerrisk + file capabilities are implemented using *security* attributes + not *system* attributes + michael kerrisk + describe limit on ea values for jfs, xfs, and reiserfs + michael kerrisk + explicitly mention some of the xattr system calls in description + naming the system calls helps to orient the reader + +nscd.8 + michael kerrisk + add mention of 'services' and 'netgroup' databases + this makes the page consistent with nscd.conf(5). + + +==================== changes in man-pages-4.01 ==================== + +released: 2015-07-23, munich + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +alexei starovoitov +andries e. brouwer +arjun shankar +ashish sangwan +ben woodard +carlos o'donell +christoph thompson +cortland setlow +daniel borkmann +david leppik +dilyan palauzov +doug klima +eric b munson +florian weimer +hack ndo +jann horn +jens axboe +jian wen +joerg roedel +julian orth +kees cook +laszlo ersek +marko myllynen +mehdi aqadjani memar +michael kerrisk +michal hocko +mike frysinger +mike hayward +miklos szeredi +namhyung kim +namjae jeon +nathan lynch +neilbrown +pádraig brady +pavel machek +peter hurley +sam varshavchik +scot doyle +stephan mueller +tobias stoeckmann +tulio magno quites machado filho +uwe kleine-könig +vegard nossum +ville skyttä +vince weaver +zeng linggang +文剑 + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +bpf.2 + alexei starovoitov, michael kerrisk [daniel borkmann] + new page documenting bpf(2) + +__ppc_get_timebase.3 + tulio magno quites machado filho + new page documenting __ppc_get_timebase() and __ppc_get_timebase_freq() + glibc 2.16 was released with a new function for the power + architecture that can read its time base register. + glibc 2.17 adds a function to read the frequency at which the time + base register of power processors is updated. + +queue.3 + michael kerrisk [david leppik, doug klima] + reimport from latest freebsd page + long ago, doug klima noted that many macros were not + documented in the queue(3) page. fix by reimporting from + latest [1] freebsd man page. + + [1] revision 263142, modified fri mar 14 03:07:51 2014 utc + + this also fixes https://sourceware.org/bugzilla/show_bug.cgi?id=1506 + + this time, i'll learn from past mistakes and not convert + from 'mdoc' to 'man' macros. + michael kerrisk + use subsections in description + michael kerrisk + remove see also reference to nonexistent tree(3) + michael kerrisk + use real hyphens in code samples + michael kerrisk + comment out text for functions not in glibc + michael kerrisk + replace history with conforming to + + +newly documented interfaces in existing pages +--------------------------------------------- + +rename.2 + michael kerrisk [miklos szeredi] + document rename_whiteout + heavily based on text by miklos szeredi. + + +new and changed links +--------------------- + +__ppc_get_timebase_freq.3 + tulio magno quites machado filho + new link to new __ppc_get_timebase(3) page + +list_empty.3 +list_first.3 +list_foreach.3 +list_head_initializer.3 +list_insert_before.3 +list_next.3 +slist_empty.3 +slist_entry.3 +slist_first.3 +slist_foreach.3 +slist_head.3 +slist_head_initializer.3 +slist_init.3 +slist_insert_after.3 +slist_insert_head.3 +slist_next.3 +slist_remove.3 +slist_remove_head.3 +stailq_concat.3 +stailq_empty.3 +stailq_entry.3 +stailq_first.3 +stailq_foreach.3 +stailq_head.3 +stailq_head_initializer.3 +stailq_init.3 +stailq_insert_after.3 +stailq_insert_head.3 +stailq_insert_tail.3 +stailq_next.3 +stailq_remove.3 +stailq_remove_head.3 +tailq_concat.3 +tailq_empty.3 +tailq_first.3 +tailq_foreach.3 +tailq_foreach_reverse.3 +tailq_head_initializer.3 +tailq_insert_before.3 +tailq_last.3 +tailq_next.3 +tailq_prev.3 +tailq_swap.3 + michael kerrisk + new links to queue.3 + + +global changes +-------------- + +various pages + michael kerrisk [andries e. brouwer] + remove "abi" from "c library/kernel abi differences" subheadings + the "abi" doesn't really convey anything significant in + the title. these subsections are about describing differences + between the kernel and (g)libc interfaces. + + +changes to individual pages +--------------------------- + +intro.1 + michael kerrisk [andries e. brouwer] + drop intro paragraph on '$?' shell variable + as andries notes, this piece of text is rather out of place in + a page that was intended to provide a tutorial introduction for + beginners logging in on a linux system. + +locale.1 + marko myllynen + a minor output format clarification + a minor clarification for the locale output format which was + brought up at + https://sourceware.org/bugzilla/show_bug.cgi?id=18516. + + for reference, see + https://sourceware.org/bugzilla/show_bug.cgi?id=18516 + http://pubs.opengroup.org/onlinepubs/9699919799/utilities/locale.html + + add conforming to section + +capget.2 + julian orth + clarify that hdrp->pid==0 is equivalent gettid() not getpid() + +chroot.2 + jann horn + chroot() is not intended for security; document attack + it is unfortunate that this discourages this use of chroot(2) + without pointing out alternative solutions - for example, + openssh and vsftpd both still rely on chroot(2) for security. + + bind mounts should theoretically be usable as a replacement, but + currently, they have a similar problem (cve-2015-2925) that hasn't + been fixed in ~6 months, so i'd rather not add it to the manpage + as a solution before a fix lands. + +clock_getres.2 + zeng linggang + attributes: note functions that are thread-safe + +eventfd.2 + zeng linggang + attributes: note function that is thread-safe + +execve.2 + michael kerrisk + elaborate on envp/argv as null behavior + +_exit.2 + michael kerrisk + open stdio frames are not flushed, temporary files are deleted + many years ago, text was added to the page saying that it is + implementation-dependent whether stdio streams are flushed and + whether temporary are removed. in part, this change appears to + be because posix.1-2001 added text related to this point. + however, that seems to have been an error in posix, and the + text was subsequently removed for posix.1-2008. see + https://collaboration.opengroup.org/austin/interps/documents/9984/ai-085.txt + austin group interpretation reference 1003.1-2001 #085 + +fallocate.2 + namjae jeon [michael kerrisk] + document falloc_fl_insert_range + michael kerrisk + since linux 4.2, ext4 supports falloc_fl_insert_range + +fcntl.2 + michael kerrisk + ofd locks are proposed for inclusion in the next posix revision + +getrlimit.2 + zeng linggang + attributes: note functions that are thread-safe + +getrusage.2 + zeng linggang + attributes: note function that is thread-safe + +gettid.2 + michael kerrisk + note that for a thread group leader, gettid() == getpid() + +iopl.2 + michael kerrisk + remove some historical libc5 and glibc 1 details + these details are ancient, and long ago ceased to be relevant. + +ioprio_set.2 + michael kerrisk [jens axboe] + document meaning of ioprio==0 + +mlock.2 + michael kerrisk [mehdi aqadjani memar] + document another enomem error case + enomem can occur if locking/unlocking in the middle of a region + would increase the number of vmas beyond the system limit (64k). + +mmap.2 + michal hocko [eric b munson] + clarify map_populate + david rientjes has noticed that map_populate wording might promise + much more than the kernel actually provides and intends to provide. + the primary usage of the flag is to pre-fault the range. there is + no guarantee that no major faults will happen later on. the pages + might have been reclaimed by the time the process tries to access + them. + michal hocko [eric b munson] + clarify map_locked semantics + map_locked had a subtly different semantic from mmap(2)+mlock(2) + since it has been introduced. + mlock(2) fails if the memory range cannot get populated to + guarantee that no future major faults will happen on the range. + mmap(map_locked) on the other hand silently succeeds even if + the range was populated only partially. + + fixing this subtle difference in the kernel is rather awkward + because the memory population happens after mm locks have been + dropped and so the cleanup before returning failure (munlock) + could operate on something else than the originally mapped area. + + e.g. speculative userspace page fault handler catching segv and + doing mmap(fault_addr, map_fixed|map_locked) might discard portion + of a racing mmap and lead to lost data. although it is not clear + whether such a usage would be valid, mmap page doesn't explicitly + describe requirements for threaded applications so we cannot + exclude this possibility. + + this patch makes the semantic of map_locked explicit and suggests + using mmap + mlock as the only way to guarantee no later major + page faults. + michael kerrisk + errors: point out that enomem can occur even for munmap() + +mprotect.2 + michael kerrisk + note enomem error that can occur when we reach limit on maximum vmas + +open.2 +read.2 +write.2 + michael kerrisk [mike hayward] + clarify that o_nonblock is a no-op for regular files and block devices + +perf_event_open.2 + vince weaver [joerg roedel] + exclude_host/exclude_guest clarification + this patch relates to the exclude_host and exclude_guest bits added + by the following commit: + + exclude_host, exclude_guest; linux 3.2 + commit a240f76165e6255384d4bdb8139895fac7988799 + author: joerg roedel + date: wed oct 5 14:01:16 2011 +0200 + + perf, core: introduce attrs to count in either host or guest mode + + the updated manpage text clarifies that the "exclude_host" and + "exclude_guest" perf_event_open() attr bits only apply in the + context of a kvm environment and are currently x86 only. + vince weaver + document perf_sample_regs_intr + this patch relates to the addition of perf_sample_regs_intr + support added in the following commit: + + perf_sample_regs_intr; linux 3.19 + commit 60e2364e60e86e81bc6377f49779779e6120977f + author: stephane eranian + + perf: add ability to sample machine state on interrupt + + the primary difference between perf_sample_regs_intr and the + existing perf_sample_regs_user is that the new support will + return kernel register values. also if precise_ip is + set higher than 0 then the pebs register state will be returned + rather than the saved interrupt state. + + this patch incorporates feedback from stephane eranian and + andi kleen. + +prctl.2 +seccomp.2 + michael kerrisk + clarify that seccomp_set_mode_strict disallows exit_group(2) + these days, glibc implements _exit() as a wrapper around + exit_group(2). (when seccomp was originally introduced, this was + not the case.) give the reader a clue that, despite what glibc is + doing, what seccomp_set_mode_strict permits is the true _exit(2) + system call, and not exit_group(2). + +pread.2 +read.2 +readv.2 +sendfile.2 +write.2 + michael kerrisk + clarify that linux limits transfers to a maximum of 0x7ffff000 bytes + see https://bugs.debian.org/629994 and + https://bugs.debian.org/630029. + +pread.2 + michael kerrisk + rewrite return value section + (also drop the text on pwrite() returning zero; that seems bogus.) + +ptrace.2 + michael kerrisk [vegard nossum] + ptrace_o_traceexit clarification + +readv.2 + michael kerrisk + remove bugs heading + the text on mixing i/o syscalls and stdio is a general point + of behavior. it's not a bug as such. + +recv.2 +send.2 + michael kerrisk + explain some subtleties of msg_dontwait versus o_nonblock + +rename.2 + michael kerrisk + michael kerrisk + note that rename_noreplace can't be employed with rename_exchange + +sched_setaffinity.2 + michael kerrisk + add an example program + michael kerrisk [florian weimer] + explain how to deal with 1024-cpu limitation of glibc's cpu_set_t type + michael kerrisk + mention the use of the 'isolcpus' kernel boot option + +sched_setattr.2 + julian orth + remove a const attribute + the attr argument of sched_setattr was documented as const but the + kernel will modify the size field of this struct if it contains an + invalid value. see the documentation of the size field for details. + +seccomp.2 + michael kerrisk + see also: add bpf(2) + +send.2 + michael kerrisk + expand on subtleties of msg_nosignal versus ignoring sigpipe + +sigaltstack.2 + zeng linggang + attributes: note function that is thread-safe + +socket.2 + stephan mueller + update documentation reference for af_alg + +truncate.2 + michael kerrisk + errors: ftruncate() can fail if the file descriptor is not writable + +utimensat.2 + zeng linggang + attributes: note functions that are thread-safe + after research, we think utimensat() and futimens() are thread-safe. + but, there are not markings of utimensat() and futimens() in glibc + document. + +clearenv.3 + zeng linggang + attributes: note function that is not thread-safe + +dl_iterate_phdr.3 + zeng linggang + attributes: note function that is thread-safe + +error.3 + zeng linggang + attributes: note functions that are/aren't thread-safe + +fexecve.3 + zeng linggang + attributes: note function that is thread-safe + +fpurge.3 + zeng linggang + attributes: note function that is thread-safe + +fread.3 + andries e. brouwer + clarify terminology + in the "return value" section the word item is in italics + as if it were one of the function parameters. but the word + "item" occurs here for the first time, earlier the text + uses "element". [patch improves this.] + +fts.3 + zeng linggang + attributes: note functions that are/aren't thread-safe + +getaddrinfo.3 + zeng linggang + attributes: note functions that are thread-safe + +getaddrinfo_a.3 + zeng linggang + attributes: note functions that are thread-safe + +getauxval.3 + michael kerrisk + file capabilities also trigger at_secure + michael kerrisk + (briefly) document at_hwcap2 + +getgrent_r.3 + zeng linggang + attributes: note functions that are/aren't thread-safe + +gethostbyname.3 + michael kerrisk [laszlo ersek] + remove mention of ipv6 addresses, which are not supported + as reported by laszlo ersek: + + gethostbyname(3) fails to resolve the ipv6 address "::1", + but the manual page says: "if name is an ipv4 or ipv6 address, + no lookup is performed and gethostbyname() simply copies name + into the h_name field [...]". + + debian bug report: + http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=455762 + + glibc bug report: + http://sourceware.org/bugzilla/show_bug.cgi?id=5479 + + susv3 link for gethostbyname(3): + http://www.opengroup.org/onlinepubs/000095399/functions/gethostbyname.html + + it seems that the glibc behavior is conformant, and the manual + page is in error. + +getifaddrs.3 + zeng linggang + attributes: note functions that are thread-safe + +getnameinfo.3 + zeng linggang + attributes: note function that is thread-safe + +getnetent_r.3 + zeng linggang + attributes: note functions that are thread-safe + +getprotoent.3 + zeng linggang + attributes: note functions that aren't thread-safe + +getprotoent_r.3 + zeng linggang + attributes: note functions that are thread-safe + +getpw.3 + zeng linggang + attributes: note function that is thread-safe + +getpwent_r.3 + zeng linggang + attributes: note functions that are/aren't thread-safe + +getrpcent.3 + zeng linggang + attributes: note functions that are/aren't thread-safe + +getrpcent_r.3 + zeng linggang + attributes: note functions that are thread-safe + +getrpcport.3 + zeng linggang + attributes: note function that is thread-safe + +getservent.3 + zeng linggang + attributes: note functions that aren't thread-safe + +getservent_r.3 + zeng linggang + attributes: note functions that are thread-safe + +gsignal.3 + zeng linggang + attributes: note functions that are thread-safe + +key_setsecret.3 + zeng linggang + attributes: note functions that are thread-safe + +malloc_get_state.3 + zeng linggang + attributes: note functions that are thread-safe + +malloc_info.3 + zeng linggang + attributes: note function that is thread-safe + +malloc_stats.3 + zeng linggang + attributes: note function that is thread-safe + +malloc_trim.3 + zeng linggang + attributes: note function that is thread-safe + +mb_len_max.3 + michael kerrisk + clarify meaning of mb_len_max + michael kerrisk [pádraig brady] + mb_len_max is 16 in modern glibc versions + +memcpy.3 + michael kerrisk + notes: describe the glibc 2.13 changes that revealed buggy applications + adding a note on this point seems worthwhile as a way of + emphasizing the point that the buffers must not overlap. + +mq_notify.3 + zeng linggang + attributes: note function that is thread-safe + +perror.3 + michael kerrisk + some wording improvements and clarifications + +profil.3 + zeng linggang + attributes: note function that is not thread-safe + +psignal.3 + zeng linggang + attributes: note functions that are thread-safe + +pthread_attr_init.3 + zeng linggang + attributes: note functions that are thread-safe + michael kerrisk + use "%zd" for printing size_t in example code + +pthread_attr_setaffinity_np.3 + zeng linggang + attributes: note functions that are thread-safe + +pthread_cancel.3 + zeng linggang + attributes: note function that is thread-safe + +pthread_cleanup_push.3 + zeng linggang + attributes: note functions that are thread-safe + +pthread_create.3 + zeng linggang + attributes: note function that is thread-safe + +pthread_detach.3 + zeng linggang + attributes: note function that is thread-safe + +pthread_getattr_np.3 + zeng linggang + attributes: note function that is thread-safe + +pthread_join.3 + zeng linggang + attributes: note function that is thread-safe + +pthread_setname_np.3 + zeng linggang + attributes: note functions that are thread-safe + +pthread_tryjoin_np.3 + zeng linggang + attributes: note functions that are thread-safe + +putgrent.3 + zeng linggang + attributes: note function that is thread-safe + +rcmd.3 + zeng linggang + attributes: note functions that are/aren't thread-safe + +resolver.3 + zeng linggang + attributes: note functions that are thread-safe + +rpc.3 + zeng linggang + attributes: note functions that are thread-safe + +rpmatch.3 + zeng linggang + attributes: note function that is thread-safe + +sem_close.3 + zeng linggang + attributes: note function that is thread-safe + +sem_open.3 + zeng linggang + attributes: note function that is thread-safe + +setaliasent.3 + zeng linggang + attributes: note functions that are/aren't thread-safe + +setlocale.3 + marko myllynen + update conforming to + http://pubs.opengroup.org/onlinepubs/9699919799/functions/setlocale.html + +setlocale.3 + marko myllynen + tweak c/posix locale portability description + as discussed earlier, the current description might be a little + bit too stringent, let's avoid the issue by describing the + portability aspect on a slightly higher level. + + references: + + http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/v1_chap06.html + http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/v1_chap07.html + http://pubs.opengroup.org/onlinepubs/9699919799/functions/setlocale.html + +shm_open.3 + zeng linggang + attributes: note functions that are thread-safe + +strfmon.3 + marko myllynen + document strfmon_l(3) + describe strfmon_l(3). + + http://pubs.opengroup.org/onlinepubs/9699919799/functions/strfmon.html + marko myllynen + fix conforming to + afaics strfmon(3) is now defined in posix and the glibc + implementation is as specified there. + + http://pubs.opengroup.org/onlinepubs/9699919799/functions/strfmon.html + marko myllynen + rewrite the example + i think the example is more accurate when we use the exact + locale names and also the euro sign where appropriate. + +xcrypt.3 + zeng linggang + attributes: note functions that are thread-safe + +xdr.3 + zeng linggang + attributes: note functions that are thread-safe + +console_codes.4 + scot doyle [pavel machek, michael kerrisk] + add csi sequence for cursor blink interval + add a console private csi sequence to specify the current + console's cursor blink interval. the interval is specified + as a number of milliseconds until the next cursor display + state toggle, from 50 to 65535. + +null.4 + michael kerrisk + note that reads from /dev/zero are interruptible since linux 2.6.31 + +core.5 + michael kerrisk + mention 'coredump_filter' boot option + +host.conf.5 + michael kerrisk + wording fix: s/resolv+/the resolver library/ + the term "resolv+" seems to be historical cruft. + +hosts.equiv.5 + carlos o'donell + fix format, clarify idm needs, and provide examples. + in some recent work with a red hat customer i had the opportunity + to discuss the fine nuances of the ruserok() function and related + api which are used to implement rlogin and rsh. + + it came to my attention after working with qe on some automated + internal testing that there were no good examples in the hosts.equiv + manual page showing how the format was supposed to work for this + file and for ~/.rhosts, worse the "format" line showed that there + should be spaces between arguments when that would clearly lead + to incorrect behaviour. in addition some things that the format + allows you to write are just wrong like "-host -user" which makes + no sense since the host is already rejected, and should be written + as "host -user" instead. i added notes in the example to make it + clear that "-host -user" is invalid. + + i fixed three things: + + (a) the format line. + - either +, or [-]hostname, or +@netgrp or -@netgrp. + - either +, or [-]username, or +@netgrp or -@netgrp. + - you must specify something in the hostname portion so remove + optional brackets. + + (b) clarify language around credentials + - if the host is not trusted you must provide credentials to + the login system and that could be anything really and it + depends on your configuration e.g. pam or whatever idm you have. + + (c) provide real-world examples + - provide several real world examples and some corner case + examples for how you would write something. hopefully others + can add examples as they see fit. + michael kerrisk [carlos o'donell, arjun shankar] + improve explanation in example + +locale.5 + marko myllynen + document map to_inpunct, map to_outpunct + see e.g. fa_ir for reference. + marko myllynen + document class in lc_ctype + see e.g. the locale zh_cn and + + http://en.cppreference.com/w/cpp/string/wide/towctrans + http://en.cppreference.com/w/cpp/string/wide/wctrans + marko myllynen + add iconv(1) reference + marko myllynen + document character transliteration + see e.g. da_dk for reference. + + (not sure should we actually provide an example here?) + marko myllynen + document era keywords + this patch completes the lc_time section - since these era + keywords are so tightly coupled, i'm providing them as a + single patch. + + based on + http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap07.html + http://www.open-std.org/jtc1/sc22/wg20/docs/n972-14652ft.pdf + marko myllynen + document default_missing + marko myllynen + document outdigit and alt_digits + see e.g. fa_ir for reference. + marko myllynen + refer to locale(7) more prominently + it's probably a good idea to refer to locale(7) so that a reader + can check what a category is about before describing them in + detail. + marko myllynen + document charclass and charconv + see e.g. the locales ja_jp and ko_kr and + + http://en.cppreference.com/w/cpp/string/wide/towctrans + http://en.cppreference.com/w/cpp/string/wide/wctrans + marko myllynen + copy is not exclusive in lc_ctype and lc_collate + see e.g. da_dk for reference. + marko myllynen + remove the fixme for timezone + the timezone of lc_time is not in posix, only 6 (out of ~300) + glibc locales define it, the glibc code comment below from + glibc.git/programs/ld-time.c seems to suggest it's not a good + idea, and there's been a proposal in upstream [1] to remove the + existing timezone definitions from glibc locales so i think + it's actually better to leave this one undocumented: + + /* xxx we don't perform any tests on the timezone value since this is + simply useless, stupid $&$!@... */ + + 1) https://sourceware.org/ml/libc-alpha/2015-06/msg00098.html + + move the remaining lc_collate fixmes together while at it. + marko myllynen + fix country_isbn format + both plain numbers and unicode code points are used in + glibc locales but checking the code reveals that country_isbn + is handled like the rest of its category expect for country_num + which was clarified earlier. + marko myllynen + sort according to the standard + sort the options so that those defined in posix are listed first, + then followed by those defined in iso/iec tr 14652 in the order + of common convention in many widely used glibc locales. + + actual descriptions are unchanged. + + http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/v1_chap07.html + marko myllynen + refer to strftime(3) where appropriate + the relationship between the locale time format syntax + and strftime() cannot be considered as obvious. + marko myllynen + document map "totitle" + see e.g. locales/i18n for reference. + michael kerrisk [marko myllynen] + remove bugs section saying man page is not complete + to some degree, this is true of many pages. and anyway, this + page is much better after recent work by marko. + +proc.5 + michael kerrisk + list /proc/vmstat fields + michael kerrisk + tweak /proc/vmstat text + michael kerrisk + add /proc/crypto entry with a pointer to further information + michael kerrisk [kees cook] + document /proc/sys/kernel/sysctl_writes_strict + based on text in documentation/sysctl/kernel.txt. + michael kerrisk + move misordered /proc/[pid]/timers entry + michael kerrisk + refer to bpf(2) for explanation of /proc/sys/net/core/bpf_jit_enable + +repertoiremap.5 + marko myllynen + symbolic names aka mnemonics + a long time ago in glibc, repertoire maps were used (but they + were removed already in 2000), those mapping files were named + as mnemonics, so "mnemonic" is a term that would almost + certainly come up if somebody studies glibc side (perhaps even + the related standards like iso 9945 [which i don't have access + to]) so i thought it's worth to mention to term in the man page + to make sure we're talking about the same thing, otherwise + someone might wonder is that something different or not. + + iow, symbolic names and mnemonics are often used interchangeably, + let's mention the other often used term in the page, too. + +capabilities.7 + michael kerrisk + cap_sys_admin allows calling bpf(2) + +locale.7 + marko myllynen + lc_ctype determines transliteration rules on glibc systems + +packet.7 + 文剑 [cortland setlow] + fix description of binding a packet socket to an interface + +pty.7 + neilbrown [peter hurley] + clarify asynchronous nature of pty i/o + a pty is not like a pipe - there may be delayed between data + being written at one end and it being available at the other. + + this became particularly apparent after + commit f95499c3030f + ("n_tty: don't wait for buffer work in read() loop") + in linux 3.12 + + see also the mail thread at https://lkml.org/lkml/2015/5/1/35 + date mon, 04 may 2015 12:32:04 -0400 + from peter hurley <> + subject re: [patch bisected regression] input_available_p() + sometimes says 'no' when it should say 'yes' + +rtld-audit.7 + ben woodard + use correct printf() specifier for pointer types + in the example code you used %x rather than %p in the example + code for an audit library. the problem is that it truncates the + pointers on 64b platforms. so you get something like: + + la_symbind64(): symname = strrchr sym->st_value = 0x7f4b8a3f8960 + ndx = 222 flags = 0x0 refcook = 8b53e5c8 defcook = 8b537e30 + + rather than: + + la_symbind64(): symname = fclose sym->st_value = 0x7fa452dd49b0 + ndx = 1135 flags = 0x0 refcook = 0x7fa453f395c8 defcook = 0x7fa453f32e30 + + this has bitten me a handful of times when playing around with + audit test libraries to investigate its behavior. + +sched.7 + michael kerrisk + remove ancient, wildly optimistic prediction about future of rt patches + it seems the patches were not merged by 2.6.30... + +socket.7 + michael kerrisk + see also: add bpf(2) + +vdso.7 + nathan lynch [mike frysinger] + update for arm + the 32-bit arm architecture in linux has gained a vdso as of the + 4.1 release. (i was the primary author.) + + document the symbols exported by the arm vdso. + + accepted kernel submission: + http://lists.infradead.org/pipermail/linux-arm-kernel/2015-march/332573.html + + +==================== changes in man-pages-4.02 ==================== + +released: 2015-08-08, munich + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +carlos o'donell +daniel borkmann +david rientjes +dilyan palauzov +gabriel f. t. gomes +gleb fotengauer-malinovskiy +goswin von brederlow +heinrich schuchardt +jonathan david amery +michael kerrisk +mike frysinger +mike kravetz +nicholas miell +nikola forró +sam varshavchik +yaarit +zeng linggang + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +dladdr.3 + michael kerrisk + new page documenting dladdr() and dladdr1() + relocate/rewrite dladdr() text formerly contained in dlopen(3). + + add documentation of dladdr1(). + zeng linggang + attributes: note functions that are thread-safe + +dlerror.3 + michael kerrisk + migrate dlerror(3) to new separate man page + michael kerrisk + note that the returned message may be in a statically allocated buffer + michael kerrisk + note that the returned string does not include a trailing newline + zeng linggang + attributes: note function that is thread-safe + +dlinfo.3 + michael kerrisk + new page describing dlinfo(3) + zeng linggang + attributes: note function that is thread-safe + +dlopen.3 + michael kerrisk + this page was substantially rewritten and enhanced. notably: + * the dladdr(), dlsym, dlvsym(), and dlerror() content were moved + to separate new pages; + * documentation for dlmopen was added; + * and other changes as noted below. + zeng linggang + attributes: note functions that are thread-safe + michael kerrisk + move atexit() discussion under "initialization and finalization" + michael kerrisk + move discussion of _init() and _fini() to notes + michael kerrisk + rework the discussion of initialization and finalization functions + deemphasize the obsolete _init/_fini and give more prominence + to gcc constructors/destructors. + michael kerrisk + dlclose() will unload the object when all references have been released + michael kerrisk + example: remove mention of "-rdynamic" + that option isn't needed for compiling and running this program. + michael kerrisk + remove reference to ld.so info page + the command "info ld.so" simply shows the man page... + michael kerrisk + add versions section + michael kerrisk + reorganize conformance information for 'flags' + +dlsysm.3 + michael kerrisk + move dlsym() and dlvsym() content to new separate page + zeng linggang + attributes: note functions that are thread-safe + + +newly documented interfaces in existing pages +--------------------------------------------- + +dlopen.3 + michael kerrisk, carlos o'donell + document dlmopen(3) + +nl_langinfo.3 + sam varshavchik, michael kerrisk + add documentation for nl_langinfo_l(3) + +__ppc_set_ppr_med.3 + gabriel f. t. gomes + document ppc functions providing access to ppr + gnu c library 2.18 adds functions (__ppc_set_ppr_low(3), + __ppc_set_ppr_med(3), __ppc_set_ppr_med_low(3)) that provide + access to the program priority register (ppr). + +__ppc_yield.3 + gabriel f. t. gomes + document ppc performance-hint functions + gnu c library 2.18 adds functions __ppc_yield(3), __ppc_mdoio(3), + and __ppc_mdoom(3) that can be used provide a hint that + performance could be improved if shared resources are released + for use by other processors. + + +new and changed links +--------------------- + +dladdr1.3 + michael kerrisk + new link to (new) dladdr(3) page + +dlmopen.3 + michael kerrisk + new link to dlopen.3 + +dlvsym.3 + michael kerrisk + adjust link to point to new self-contained dlsym(3) page + +nl_langinfo_l.3 + michael kerrisk + new link to nl_langinfo.3 + +__ppc_mdoio.3 + gabriel f. t. gomes + new link to __ppc_yield.3 + +__ppc_mdoom.3 + gabriel f. t. gomes + new link to __ppc_yield.3 + +__ppc_set_ppr_low.3 + gabriel f. t. gomes + new link to __ppc_set_ppr_med.3 + +__ppc_set_ppr_med_low.3 + gabriel f. t. gomes + new link to __ppc_set_ppr_med.3 + + +global changes +-------------- + +very many pages + michael kerrisk + update conforming to section to reflect posix.1-2001 and posix.1-2008 + details. (by now, i believe all pages should be up to date with + respect to appropriately mentioning posix.1-2001 and posix.1-2008.) + +ldd.1 +sprof.1 +execve.2 +dlopen.3 +ld.so.8 + michael kerrisk + prefer "shared object" over "shared library" + the man pages variously use "shared library" or "shared object". + try to more consistently use one term ("shared object"), while + also pointing out on a few pages that the terms are synonymous. + + +changes to individual pages +--------------------------- + +accept.2 + michael kerrisk + add mention of posix.1-2008 regarding eagain vs ewouldblock + +bpf.2 + daniel borkmann + various updates/follow-ups to address some fixmes + a couple of follow-ups to the bpf(2) man-page, besides others: + + * description of map data types + * explanation on ebpf tail calls and program arrays + * paragraph on tc holding ref of the ebpf program in the kernel + * updated ascii image with tc ingress and egress invocations + * __sync_fetch_and_add() and example usage mentioned on arrays + * minor reword on the licensing and other minor fixups + +execve.2 + michael kerrisk + reword text on posix and #! + +io_getevents.2 + michael kerrisk + note return value on interruption by a signal handler + michael kerrisk + clarify details of return value for timeout-expired case + michael kerrisk + clarify and extend discussion of 'timeout' argument + +mmap.2 + michael kerrisk + note that 'length' need not be a page-size multiple for munmap() + michael kerrisk [david rientjes, david rientjes, mike kravetz] + describe mmap()/munmap() argument requirements for huge-page mappings + michael kerrisk + move discussion of timestamps to notes + a straight move; no changes to the content. + this content is better placed in notes. + +seccomp.2 + michael kerrisk + see also: mention libseccomp pages + see also: add scmp_sys_resolver(1) + +sigaction.2 + michael kerrisk + correct the list of flags that were added in posix.1-2001 + +socketpair.2 + michael kerrisk [goswin von brederlow] + clarify use of sock_* flags in 'type' argument + see http://bugs.debian.org/794217 + +atexit.3 + michael kerrisk + see also: add dlopen(3) + +clock_getcpuclockid.3 + michael kerrisk + improve wording of eperm error + it's imprecise to say that this is an "optional" error + in posix.1. + +dl_iterate_phdr.3 + michael kerrisk + note that 'size' allows callback() to discover structure extensions + michael kerrisk + see also: add dladdr(3) + michael kerrisk + conforming to: note that this function appears on some other systems + +fseeko.3 + michael kerrisk + remove crufty notes section + this ancient system v detail is unneeded. + +getutent.3 + michael kerrisk + mention posix.1-2008 for the "utmpx" functions + +iconv_close.3 +iconv_open.3 + michael kerrisk + conforming to: change "unix98" to "susv2" + +malloc.3 + michael kerrisk + change "unix 98" to "susv2" + +mktemp.3 + gleb fotengauer-malinovskiy + reference mkdtemp(3) in addition to mkstemp(3) + mention mkdtemp(3) as another secure alternative to mktemp(3). + + see also https://sourceware.org/bugzilla/show_bug.cgi?id=2898. + +mq_receive.3 +mq_send.3 + michael kerrisk + clarify discussion of 'timeout' + in particular, remove the word 'ceiling', which falsely + suggests that the call might return prematurely. + +nl_langinfo.3 + michael kerrisk + explicitly describe the return value on success + michael kerrisk + posix specifies that the caller may not modify the returned string + michael kerrisk + enhance return value description + note some further cases where returned string may be + invalidated or overwritten. + +perror.3 + michael kerrisk + reformat conforming to information + michael kerrisk + note that 'sys_errlist' and 'sys_nerr' are not in posix.1 + +posix_openpt.3 + michael kerrisk + reword text regarding systems that don't have posix_openpt() + +printf.3 + michael kerrisk + conforming to: update details for dprintf() and vdprintf() + +setlogmask.3 + michael kerrisk + remove useless statement in conforming to + saying that the description in psox.1-2001 is flawed, + without saying what the fla is, is not helpful. + (and no, i don't know what the flaw is.) + +shm_open.3 + michael kerrisk + add posix.1-2008 details regarding group id of new shared memory object + +strfmon.3 + michael kerrisk + fix erroneous conforming to + strfmon() is in posix.1. + +fanotify.7 + heinrich schuchardt + clarify effects of file moves + if files or directories are moved to other mounts, the inode is + deleted. fanotify marks are lost. + +mq_overview.7 + michael kerrisk + remove unneeded conforming to section + +nptl.7 + michael kerrisk [nicholas miell] + note that i386 and x86-64 binaries can't share mutexes + +sched.7 + nikola forró + fix descriptions of sched_get_priority_max() / sched_get_priority_min() + +sem_overview.7 + michael kerrisk + remove unneeded conforming to section + +shm_overview.7 + michael kerrisk + remove unneeded conforming to section + +sigevent.7 + michael kerrisk + remove unneeded conforming to section + +symlink.7 + michael kerrisk + update with posix.1-2008 details for link(2) + +ld.so.8 + michael kerrisk [jonathan david amery] + items in ld_library_path can also be delimited by semicolons + see http://bugs.debian.org/794559. + + +==================== changes in man-pages-4.03 ==================== + +released: 2015-12-05, munich + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +alexander shishkin +alexei starovoitov +andy lutomirski +arto bendiken +carlos o'donell +casper ti. vector +daniel borkmann +david drysdale +eric b munson +florian weimer +gabriel f. t. gomes +heinrich schuchardt +ingo molnar +jakub wilk +johannes stüttgen +jonathan wakely +jonny grant +kees cook +maria guseva +masami hiramatsu +meikun wang +michael kerrisk +michal hocko +mike frysinger +namhyung kim +nikola forró +olivier tartrou +peter hurley +peter zijlstra (intel) +ross zwisler +serge hallyn +silvan jegen +stefan tauner +steven rostedt +tobias stoeckmann +tycho andersen +ville skyttä +vince weaver +zeng linggang + +apologies if i missed anyone! + + +newly documented interfaces in existing pages +--------------------------------------------- + +perf_event_open.2 + vince weaver + 4.1 adds aux sample support + vince weaver + 4.1 data_offset and data_size fields + vince weaver [alexander shishkin] + document aux_{head,tail,offset,size} support + vince weaver + 4.0 update rdpmc documentation + vince weaver + 4.1 adds perf_record_itrace_start + vince weaver + document 4.1 clockid support + vince weaver [steven rostedt, masami hiramatsu] + 4.1 perf_event_ioc_set_bpf support + vince weaver + 4.1 adds aux_flag_overwrite support + vince weaver + 4.1 perf_sample_branch_call_stack + vince weaver + 4.1 adds aux_watermark + vince weaver + add possibility of ebusy error + +prctl.2 + andy lutomirski [kees cook, serge hallyn] + document operations for ambient capabilities + michael kerrisk + rework pr_cap_ambient text + note that arg4 and arg5 must be zero for cap_ambient + return value: add pr_cap_ambient + pr_cap_ambient_is_set case + errors: document pr_cap_ambient error cases + +__ppc_set_ppr_med.3 + gabriel f. t. gomes + document ppc functions providing access to ppr + gnu c library commit 1747fcda4902a3b46183d93fb16ed9b436b2608b + extends the priorities that can be set to the program priority + register (ppr), with the functions: __ppc_set_ppr_very_low(3) + and __ppc_set_ppr_med_high(3). + +capabilities.7 + andy lutomirski [kees cook, serge hallyn] + document ambient capabilities + michael kerrisk + various additions and reworkings for ambient capability text + + +new and changed links +--------------------- + +__ppc_set_ppr_med_high.3 + gabriel f. t. gomes + new link to __ppc_set_ppr_med.3 + +__ppc_set_ppr_very_low.3 + gabriel f. t. gomes + new link to __ppc_set_ppr_med.3 + + +changes to individual pages +--------------------------- + +mremap.2 + eric b munson [michal hocko] + add note about mremap() with locked areas + when mremap() is used to move or expand a mapping that is locked + with mlock() or equivalent it will attempt to populate the new + area. however, like mmap(map_locked), mremap() will not fail if + the area cannot be populated. also like mmap(map_locked) this + might come as a surprise to users and should be noted. +open.2 + michael kerrisk [david drysdale] + remove accidental mention of o_tty_init + an earlier edit mentioned o_tty_init as a file creation flag. + that's true, according posix, but linux does not implement + this flag, so remove mention of it. + +pipe.2 + michael kerrisk + see also: add splice(2) + +prctl.2 + michael kerrisk + reorder options alphabetically + employ a pseudo-alphabetical order, ordering options after removal + of any "pr_", "pr_set_", or "pr_get" prefix. + michael kerrisk + fix alphabetical misplacements in errors + +ptrace.2 + tycho andersen + document ptrace_o_suspend_seccomp flag + michael kerrisk + document /proc/sys/kernel/yama/ptrace_scope + michael kerrisk + note that ptrace_attach cannot be applied to nondumpable processes + michael kerrisk + see also: add prctl(2) + +reboot.2 + casper ti. vector + 1-argument reboot() is also provided by alternative libc + +seccomp.2 + michael kerrisk + describe use of 'instruction_pointer' data field + michael kerrisk [kees cook] + note why all filters in a set are executed even after seccomp_ret_kill + +signalfd.2 + michael kerrisk + describe semantics with respect to scm_rights + +syscalls.2 + michael kerrisk + add mlock(2) + michael kerrisk + add userfaultfd() + +daemon.3 + michael kerrisk [johannes stüttgen] + note that daemon() is buggy with respect to controlling tty acquisition + +dirfd.3 + jonathan wakely + remove outdated notes + as stated in the synopsis, since glibc 2.10 this function is also + declared by the relevant x/open and posix macros. + +dlopen.3 + michael kerrisk + make it more explicit that ld_bind_now overrides rtld_lazy + michael kerrisk [florian weimer] + correct the pathname used in example + quoting florian: + + this does not work because libm.so can be a linker script: + + handle = dlopen("libm.so", rtld_lazy); + + the proper way to do this is to include + and use libm_so. + + see https://bugzilla.kernel.org/show_bug.cgi?id=108821 + michael kerrisk + include a shell session showing build/run in example + michael kerrisk + change arguments to main() to "void" in example + +fgetgrent.3 + zeng linggang + attributes: note function that is not thread-safe + +fgetpwent.3 + zeng linggang + attributes: note function that is not thread-safe + +getauxval.3 + michael kerrisk + add some details for at_secure + +getspnam.3 + zeng linggang + attributes: note functions that are/aren't thread-safe + +mallinfo.3 + zeng linggang + attributes: note function that is not thread-safe + +mallopt.3 + carlos o'donell + document m_arena_test and m_arena_max + +posix_fallocate.3 + michael kerrisk + clarify text relating to mt-safety + carlos o'donell + mention glibc emulation caveats + +termios.3 + olivier tartrou + add missing details on behaviour of parmrk + for a serial terminal, with a specific configuration, input bytes + with value 0377 are passed to the program as two bytes, 0377 0377. + +tty_ioctl.4 + michael kerrisk [peter hurley] + note that tiocttygstruct went away in linux 2.5.67 + +core.5 + ross zwisler + add info about dax coredump filtering flags + kernel 4.4 added two new core dump filtering flags, + mmf_dump_dax_private and mmf_dump_dax_shared. + + these flags allow us to explicitly filter dax mappings. + this is desirable because dax mappings, like hugetlb + mappings, have the potential to be very large. + +nsswitch.conf.5 + nikola forró + add list of files being read when "files" service is used + this is not mentioned anywhere. users can assume that the file + being read is something like /etc/$database, but that's not + always the case. it's better to explicitly specify which + file is read for each respective database. the list of + files was acquired from glibc source code. + +proc.5 + heinrich schuchardt [michael kerrisk] + add details for threads-max + add detail information for threads-max. + the checks for minimum and maximum values exist since kernel 4.1. + https://lkml.org/lkml/2015/3/15/96 + heinrich schuchardt + /proc/sys: describe whitespace characters + michael kerrisk + document 'capamb' in /proc/pid/status + michael kerrisk + add reference to ptrace(2) for /proc/sys/kernel/yama/ptrace_scope + +aio.7 + michael kerrisk [meikun wang] + add missing include file, , to example program + +mq_overview.7 + michael kerrisk [arto bendiken] + document qsize bug that appeared in 3.5 and was fixed in 4.2 + +path_resolution.7 + michael kerrisk + clarify recursive resolution of symlinks and note limits + +pipe.7 + michael kerrisk + see also: add splice(2) + +rtld-audit.7 + namhyung kim + fix (typo) error in la_pltenter() description + s/la_pltenter()/la_pltexit()/ + + la_pltenter() is called regardless of the value of + framesizep but la_pltexit() is called only if la_pltenter() + returns with non-zero framesizep set. i spent long time to + figure out why la_pltexit() is not called at all. + +signal.7 + michael kerrisk [michael hocko] + note async-signal-safe functions added by posix.1-2008 tc1 + +tcp.7 + daniel borkmann [michael kerrisk] + improve paragraphs on tcp_ecn and add tcp_ecn_fallback bullet + improve description of tcp_ecn, fix the rfc number and it's + not a boolean anymore since long time, and add a description + for tcp_ecn_fallback. + + see also kernel doc under documentation/networking/ip-sysctl.txt + on tcp_ecn and tcp_ecn_fallback. + +ld.so.8 + michael kerrisk + ld_pointer_guard has been removed in glibc 2.23 + michael kerrisk + describe secure-execution mode + michael kerrisk [maria guseva] + replace mentions of set-uid/set-gid programs with secure-execution mode + inspired by a patch from maria guseva. + maria guseva [silvan jegen] + ld_debug is effective in secure-execution mode if /etc/suid-debug exists + + +==================== changes in man-pages-4.04 ==================== + +released: 2015-12-29, munich + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +alexander monakov +andries e. brouwer +archie cobbs +carlos o'donell +colin rice +darren hart +davidlohr bueso +dmitry v. levin +eric b munson +heinrich schuchardt +h.j. lu +jakub wilk +jonathan wakely +jonny grant +laurent georget +lennart poettering +mathieu desnoyers +michael kerrisk +michal hocko +mike frysinger +pádraig brady +paul eggert +pavel machek +phil blundell +richard voigt +rich felker +rusty russell +thomas gleixner +tom gundersen +torvald riegel +vincent lefevre +vlastimil babka +walter harms +zack weinberg + + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +futex.2 + michael kerrisk, thomas gleixner, torvald riegel [davidlohr bueso, heinrich schuchardt, darren hart, rusty russell, pavel machek, rich felker] + rewrite and massively expand page + +membarrier.2 + mathieu desnoyers [michael kerrisk] + new page documenting membarrier() system call + + +newly documented interfaces in existing pages +--------------------------------------------- + +mlock.2 + eric b munson [michal hocko, vlastimil babka, michael kerrisk] + document mlock2(2) and mcl_onfault + + +new and changed links +--------------------- + +mlock2.2 + eric b munson + new link to mlock.2 + + +global changes +-------------- + +various pages + michael kerrisk + errors: standardize text for emfile error + +various pages + michael kerrisk + errors: standardize error text for enotsock error + +various pages + michael kerrisk + errors: standardize text for enfile error + + +changes to individual pages +--------------------------- + +clock_getres.2 + michael kerrisk + see also: add vdso(7) + +epoll_create.2 + michael kerrisk + errors: add another emfile error case + +fanotify_init.2 + michael kerrisk + errors: add an emfile error case + +fork.2 + michael kerrisk + child of mt-process is restricted to async-signal-safe functions + +getcpu.2 + michael kerrisk + see also: add vdso(7) + +getrlimit.2 + michael kerrisk [lennart poettering] + the init of measurement for rlimit_rss is bytes, not pages + +get_robust_list.2 + michael kerrisk + reword einval error text + +gettimeofday.2 + carlos o'donell + expand on the historical meaning of tz_dsttime + michael kerrisk + see also: add vdso(7) + +inotify_init.2 + michael kerrisk + errors: add an emfile error case + +personality.2 + dmitry v. levin + note kernel and glibc versions that introduced this system call + +poll.2 + richard voigt + timeout_ts is a pointer, so use -> not . for member access + michael kerrisk + shorten name of timeout argument for ppoll() + the name is overly long, and does not hint at the fact + that this argument is a pointer. fix this by renaming: + s/timeout_ts/tmo_p/ + +sendfile.2 + laurent georget + document more errors + +sigreturn.2 + michael kerrisk + see also: add vdso(7) + +socketcall.2 + michael kerrisk + since linux 4.3, x86-32 provides direct system calls for the sockets api + +time.2 + zack weinberg + explain why the glibc time() wrapper never sets 'errno' + michael kerrisk [h.j. lu] + where time() is provided by vdso, an invalid address may give sigsegv + michael kerrisk [paul eggert] + describe eoverflow details + michael kerrisk + see also: add vdso(7) + michael kerrisk + rename 't' argument to 'tloc' + +dlerror.3 + michael kerrisk [jonny grant] + clarify that the string returned by dlerror() is null terminated + +dlopen.3 + michael kerrisk + include a shell session showing build/run in example + michael kerrisk + change arguments to main() to "void" in example + +drand48.3 + michael kerrisk [vincent lefevre] + correct descriptions of ranges returned by these functions + see http://bugs.debian.org/803459 + +errno.3 + michael kerrisk + note probable cause of enfile error + +fnmatch.3 + pádraig brady + describe the fnm_extmatch flag and pattern syntax + +iconv.3 + andries e. brouwer + notes: describe correct usage for flushing partially buffered input + +random_r.3 + michael kerrisk [archie cobbs] + clarify need to use initstate_r() + +tzset.3 + carlos o'donell + clarify "daylight" and remove erroneous note + +random.4 + michael kerrisk [tom gundersen] + rework example scripts to assume 'poolsize' unit is bits, not bytes + michael kerrisk [walter harms] + use modern command substitution syntax in shell session log + +proc.5 + michael kerrisk + reaching /proc/sys/fs/file-max limit normally produces an enfile error + +futex.7 + heinrich schuchardt + see also updates + michael kerrisk + note some other locking primitives that are built with futexes + heinrich schuchardt + nptl, avoid abbreviation + michael kerrisk + note that a futex is 4 bytes on all platforms + +vdso.7 + michael kerrisk + add note on strace(1) and vdso + +ld.so.8 + h.j. lu [michael kerrisk] + document ld_prefer_map_32bit_exec + michael kerrisk + clarify setting of ld_bind_not + michael kerrisk + clarify setting of ld_dynamic_weak + michael kerrisk + clarify setting of ld_trace_prelinking + michael kerrisk + clarify some details for ld_show_auxv + + +==================== changes in man-pages-4.05 ==================== + +released: 2016-03-15, christchurch + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +adhemerval zanella +akihiro suda +alan aversa +alan cox +alec leamas +alex henrie +alexander miller +andreas gruenbacher +andreas schwab +anna schumaker +askar safin +bill o. gallmeister +carlos o'donell +chris pick +christoph hellwig +craig gallek +darrick j. wong +davidlohr bueso +dmitry v. levin +dr. tobias quathamer +eric blake +eric dumazet +florian weimer +gabriel corona +heinrich schuchardt +ivan shapovalov +jakub wilk +jason baron +jason vas dias +jérémie galarneau +jeremy harris +joachim wuttke +joe stein +john stultz +josh triplett +kondo, naoya +krzysztof adamski +manfred spraul +marianne chevrot +marko myllynen +mark post +martin gebert +mats wichmann +matt zimmerman +michael kerrisk ` +mike frysinger +minchan kim +naoya kondo +naresh kamboju +nikola forró +nikos mavrogiannopoulos +orion poplawski +pakin yury +patrick donnelly +paul eggert +paul pluzhnikov +peter hurley +peter wu +petr gajdos +philip semanchuk +rasmus villemoes +rich felker +simon que +stephan bergmann +stéphane aulery +stephen hurd +vincent bernat +william preston +yuri kozlov +zefram + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +copy_file_range.2 + anna schumaker [darrick j. wong, christoph hellwig, michael kerrisk] + new page documenting copy_file_range() + copy_file_range() is a new system call for copying ranges of data + completely in the kernel. this gives filesystems an opportunity to + implement some kind of "copy acceleration", such as reflinks or + server-side-copy (in the case of nfs). + +personality.2 + michael kerrisk + this page has been greatly expanded, to add descriptions of + personality domains. + +fmemopen.3 + michael kerrisk [adhemerval zanella] + significant reworking of this page: + * rework discussion of the (obsolete) binary mode + * split open_memstream(3) description into a separate page. + * note various fmemopen() bugs that were fixed in glibc 2.22 + * greatly expand description of 'mode' argument + * rework description of 'buf' and 'len' arguments + * expand discussion of "current position" for fmemopen() stream + +ntp_gettime.3 + michael kerrisk + new page describing ntp_gettime(3) and ntp_gettimex(3) + +open_memstream.3 + michael kerrisk + new page created by split of fmemopen(3). + at the same time, add and rework a few details in the text. + +posix_spawn.3 + bill o. gallmeister, michael kerrisk + new man page documenting posix_spawn(3) and posix_spawnp(3) + +readdir.3 + michael kerrisk [florian weimer] + split readdir_r() content into separate page + as suggested by florian weimer: + + it may make sense to move this documentation to a separate + manual page, specific to readdir_r. this will keep the + readdir() documentation nice and crisp. most programmers + will never have to consult all these details. + michael kerrisk + near complete restructuring of the page and add some further details + michael kerrisk [florian weimer, rich felker, paul eggert] + add a lot more detail on portable use of the 'd_name' field + +readdir_r.3 + michael kerrisk [florian weimer] + new page created after split of readdir(3). + michael kerrisk [florian weimer] + explain why readdir_r() is deprecated and readdir() is preferred + michael kerrisk [florian weimer] + remove misleading code example using pathconf() + +lirc.4 + alec leamas + new page documenting lirc device driver + + +newly documented interfaces in existing pages +--------------------------------------------- + +adjtimex.2 + michael kerrisk + document ntp_adjtime(3) + +epoll_ctl.2 + michael kerrisk [jason baron] + document epollexclusive + +madvise.2 + minchan kim [michael kerrisk] + document madv_free + document the madv_free flag added to madvise() in linux 4.5. + +proc.5 + michael kerrisk + document cmatotal and cmafree fields of /proc/meminfo + michael kerrisk + document additional /proc/meminfo fields + document directmap4k, directmap4m, directmap2m, directmap1g + michael kerrisk + document memavailable /proc/meminfo field + michael kerrisk + document inotify /proc/pid/fdinfo entries + michael kerrisk + document fanotify /proc/pid/fdinfo entries + michael kerrisk + add some kernel version numbers for /proc/pid/fdinfo entries + michael kerrisk [patrick donnelly] + /proc/pid/fdinfo displays the setting of the close-on-exec flag + note also the pre-3.1 bug in the display of this info. + +socket.7 + craig gallek [michael kerrisk, vincent bernat] + document some bpf-related socket options + document the behavior and the first kernel version for each of the + following socket options: + + so_attach_filter + so_attach_bpf + so_attach_reuseport_cbpf + so_attach_reuseport_ebpf + so_detach_filter + so_detach_bpf + so_lock_filter + + +new and changed links +--------------------- + +isalpha_l.3 + michael kerrisk + new link to isalpha.3 + +longjmp.3 + michael kerrisk + replace page with link to setjmp(3), which now incorporates longjmp() + +ntp_adjtime.3 + michael kerrisk + new link to adjtimex(2) + +ntp_gettimex.3 + michael kerrisk + new link to ntp_gettime.3 + +open_wmemstream.3 + michael kerrisk + update link to point to new open_memstream(2) page + +posix_spawnp.3 + michael kerrisk + new link to new posix_spawn.3 page + +siglongjmp.3 + michael kerrisk + rewire link to point to setjmp(3) + +strerror_l.3 + michael kerrisk + new link to strerror.3 + fix missing link + + +global changes +-------------- + +various pages + michael kerrisk + update ftm requirements (_default_source) + michael kerrisk + update feature test macro requirements + update to use _default_source, and also changes brought by + glibc commit 266865c0e7b79d4196e2cc393693463f03c90bd8. + +various pages + michael kerrisk + simplify ftm requirements + looking at (or feature_test_macros(7)), one can + see that when _xopen_source is defined with the value 700 + (or greater), then _posix_c_source is defined with the value + 200809l (or greater). therefore, terms in the man pages such as + + _xopen_source\ >=\ 700 || _posix_c_source\ >=\ 200809l + + can be simplified to: + + _posix_c_source\ >=\ 200809l + +various pages + michael kerrisk + simplify ftm requirements + looking at (or feature_test_macros(7)), one can + see that when _xopen_source is defined with the value 600 + (or greater), then _posix_c_source is defined with the value + 200112l (or greater). therefore, terms in the man pages such as + + _xopen_source\ >=\ 600 || _posix_c_source\ >=\ 200112l + + can be simplified to: + + _posix_c_source\ >=\ 200112l + +various pages + michael kerrisk + simplify ftm requirements + _xopen_source implies _posix_c_source >=2, so simplify ftm + requirements in various pages. + +various pages + michael kerrisk + remove "or 'cc -std=c99'" from synopsis + under the ftm requirements all of these pages document the + requirement for _isoc99_source. and feature_test_macros(7) now + documents that "cc -std=c99" produces the same effect as defining + _isoc99_source. so, all of these pages don't additionally need + to specify "or 'cc -std=c99'" under the ftm requirements + in the synopsis. removing that redundant text also simplifies + the synopsis a little. + +various pages + michael kerrisk + simplify ftm requirements + looking at (or feature_test_macros(7)), one can + see that when _xopen_source is defined with the value 600 + (or greater), then _posix_c_source is defined with the value + 200112l (or greater). therefore, terms in the man pages such as + + _xopen_source\ >=\ 600 || _posix_c_source\ >=\ 200112l + + can be simplified to: + + _posix_c_source\ >=\ 200112l + +various pages + michael kerrisk + remove references to _xopen_source_extended in synopsis + _xopen_source_extended is obsolete (it existed in susv1, but not + subsequent standards). _xopen_source >= 500 produces the same + effects as (_xopen_source && _xopen_source_extended). modifying + the synopsis of various ages that contain: + + _xopen_source\ >=\ 500 || + _xopen_source\ &&\ _xopen_source_extended + + to just: + + _xopen_source\ >=\ 500 + + this has the following benefits: + + a) simplifying the synopsis by removing ancient + historical information. + + b) preventing users from being misled into using + _xopen_source_extended in new source code. + +various pages + michael kerrisk + remove mention of the obsolete _posix_source macro from synopsis + _posix_source was a posix.1-1990 creation that was soon made + obsolete by _posix_c_source. retaining mention of it + in the feature test macro requirements section of the + synopsis doesn't contain important information, and may + mislead readers into actually trying to use this macro. + a few mentions of it are maintained in a some pages where + defining _posix_source inhibits some behavior. + +various sockets-related pages + michael kerrisk [carlos o'donell] + use consistent argument/variable names for socket addresses and lengths + as noted by carlos, there's quite a bit of inconsistency across + pages. use 'addr' and 'addrlen' consistently in variables and + function arguments. + +various pages + michael kerrisk + wording fix: "current file offset" ==> "file offset" + "file offset" is the preferred posix terminology. + +various pages + michael kerrisk + word "descriptor" more precisely + use either "file descriptor" or "message queue descriptor". + +various pages + michael kerrisk + errors: add reference to signal(7) in description of eintr + + +changes to individual pages +--------------------------- + +locale.1 + marko myllynen + add "locale -c charmap" as an example + addresses https://bugzilla.kernel.org/show_bug.cgi?id=104511. + +localedef.1 + marko myllynen + add hint on purpose of --no-archive + indicate why using --no-archive might be a good idea. the issue + is that if you create a custom locale with localedef(1) and put + it to the locale archive then during the next glibc upgrade the + locale archive is updated as well and your custom locale is gone.) + +accept.2 + michael kerrisk + errors: improve description for ebadf + +adjtimex.2 + michael kerrisk [john stultz] + various improvements after feedback from john stultz + michael kerrisk + remove ftm requirements + it seems that adjtimex() never needed _bsd_source (and my + earlier commit 5918743bc8b02b was simply a blunder). + michael kerrisk + split einval error cases + michael kerrisk + note treatment of out-of-range buf.offset + michael kerrisk + don't refer reader to adjtime(3) + probably, it's not wise to suggest adjtime(3) as the more + portable api. rather, ntp_adjtime(3) should be used. + michael kerrisk [naresh kamboju] + update details of buf.offset einval error + michael kerrisk + see also: add ntp_gettime(3) + michael kerrisk + improve description of some pps timex fields + michael kerrisk + add attributes section + william preston [petr gajdos] + update a detail in adjtimex return value description + michael kerrisk + note range constraints and clamping for adj_frequency + +bdflush.2 + michael kerrisk + note that glibc support for this system call went away in version 2.23 + +bind.2 + michael kerrisk + improve description of enoent error + +bpf.2 + michael kerrisk + document close-on-exec semantics + the close-on-exec file descriptor flag is automatically enabled + for fds returned by bpf(). + +chmod.2 + michael kerrisk + clarify terminology (file mode versus file permission bits) + +chown.2 + michael kerrisk + errors: improve ebadf description + +clone.2 +unshare.2 + michael kerrisk + remove mention of _bsd_source and _svid_source + the right way to expose declarations for these linux-specific + system calls was always _gnu_source. mentioning the historical + use of _bsd_source and _svid_source just clouds the issue. + +connect.2 + michael kerrisk + errors: improve ebadf description + +create_module.2 + michael kerrisk + glibc 2.23 removed last vestiges of support for this system call + +delete_module.2 + michael kerrisk + glibc 2.23 removed last vestiges of support for this system call + +epoll_ctl.2 + michael kerrisk + document eloop error for circular monitoring loops + +eventfd.2 + michael kerrisk + note that eventfd info is available in /proc/pid/fdinfo + +execve.2 + michael kerrisk [krzysztof adamski] + add eperm error for capabilities check of capability-dumb binaries + michael kerrisk + add reference to ld-linux.so(8) + michael kerrisk + see also: add system(3) + +fanotify_init.2 + michael kerrisk + note kernel version that allowed o_cloexec for event_f_flags + +fcntl.2 +flock.2 + michael kerrisk + see also: add lslocks(8) + +fcntl.2 + michael kerrisk [jason vas dias] + rework description of f_setown + as suggested by jason, make it clearer that i/o signalling + requires the use of both f_setown and o_async. while we're at, + make a few other cleanups to the text. + michael kerrisk + remove mention of _bsd_source to get definition of f_setown/f_getown + this usage went away in glibc 2.20, and the simplest remedy + is just to omit mention of it. + +futex.2 + michael kerrisk + futex_clock_realtime can now be used with futex_wait + +get_kernel_syms.2 + michael kerrisk + note that glibc does not support this system call + +init_module.2 + michael kerrisk + glibc 2.23 removed last vestiges of support for this system call + +ioctl_list.2 + heinrich schuchardt + include uapi/linux/wireless.h + add the list of wireless ioctls. + heinrich schuchardt + path to sockios.h + sockios.h is now in include/uapi + heinrich schuchardt + add reference to netdevice.7 + netdevice.7 describes most of the ioctls of sockios.h + heinrich schuchardt + transfer structure (wireless.h ioctls) + the sole parameter to be passed to the wireless.h ioctls is + of type struct iwreq *. + +ioperm.2 + michael kerrisk [alex henrie] + ioperm.2: permissions are inherited across fork(2) + see https://bugzilla.kernel.org/show_bug.cgi?id=99911 + +iopl.2 + michael kerrisk [alex henrie] + permissions are not inherited across fork(2) or preserved on execve(2) + see https://bugzilla.kernel.org/show_bug.cgi?id=99901 + +lseek.2 + michael kerrisk + fuse now supports seek_hole and seek_data + michael kerrisk + nfs supports seek_hole and seek_data + + michael kerrisk + see also: add open(2) + +madvise.2 + michael kerrisk + clarify madv_hwpoison wording to say that it applies to a page range + +mknod.2 + michael kerrisk + see also: add mknod(1) + +mount.2 + michael kerrisk + see also: add findmnt(8) + +open.2 + michael kerrisk + notes: mention existence of proc/pid/fd and /proc/pid/fdinfo + mark post [petr gajdos] + o_tmpfile support is now provided bt btrfs + +pipe.2 + michael kerrisk [eric blake] + note treatment of 'pipefd' on error + +poll.2 + michael kerrisk [josh triplett] + document spurious eagain error that can occur on other systems + light reworking of text proposed by josh triplett. + +readlink.2 + michael kerrisk + clarify einval error description + +recv.2 + heinrich schuchardt + equivalence to read() + describe the recv(2)-read(2) and the recvfrom(2)-recv(2) + equivalences for zero-valued arguments. + michael kerrisk + msg_waitall has no effect for datagram sockets + +recv.2 +cmsg.3 + nikola forró + fix type of cmsg_len member of cmsghdr structure + the type shown for cmsg_len member of cmsghdr structure is socklen_t, + but the actual type used by glibc and the kernel is size_t. + the information was obtained from glibc source code: + http://bit.ly/21m1rmp + michael kerrisk + note that cmsg_len is typed as socklen_t in posix.1 + + +sched_setaffinity.2 + michael kerrisk [florian weimer, florian weimer] + warn that cpu_alloc() may allocate a slightly cpu set than requested + michael kerrisk [florian weimer] + add reference to cpu_alloc(3) + +sched_setattr.2 + michael kerrisk [akihiro suda] + eperm depends on affinity mask of target thread, not calling thread + +select.2 + michael kerrisk [josh triplett] + document spurious eagain error that can occur on other systems + light reworking of text proposed by josh triplett. + nikos mavrogiannopoulos + mention the 'fd_set' size limitation early and refer to poll(2) + change this because of the serious limitation of select() + imposing a limit on the range of file descriptors that can + be monitored. this is currently mentioned too late in the + documentation (in the notes section). the man page should + warn early and refer to poll(2) as soon as possible. + michael kerrisk + add details on the glibc fixed-size fd_set limitation + no modern application should use select() on linux. + +select_tut.2 + michael kerrisk + some readability fixes to example program + michael kerrisk + better variable names in example program + michael kerrisk + simplify 'if' logic in example program + michael kerrisk + use correct type (socklen_t) for addrlen + +semctl.2 + michael kerrisk [davidlohr bueso, manfred spraul, philip semanchuk] + notes: note when 'sempid' is set on various implementations + see https://bugzilla.kernel.org/show_bug.cgi?id=112271 and + http://thread.gmane.org/gmane.linux.kernel/2162754/ + subject: [patch] don't set sempid in semctl syscall. + date: 2016-02-26 12:21:38 gmt + +semop.2 + michael kerrisk + tweak comment describing 'sempid' + +sendfile.2 + askar safin + fix incorrect description in text referring to splice(2) + michael kerrisk + see also: add copy_file_range(2) + +setpgid.2 + michael kerrisk + correct/simplify ftm requirements for bsd setpgrp() and getpgrp() + +signalfd.2 + michael kerrisk + note that signalfd info is available in /proc/pid/fdinfo + +sigprocmask.2 + michael kerrisk [mike frysinger] + explicitly refer the reader to sigsetops(3) + this man page did not make it obvious which functions + should be used for manipulating signals sets, nor where + those functions were documented. + +socketpair.2 + michael kerrisk [eric blake] + note treatment of 'sv' on error + +splice.2 + askar safin + improve description of 0 return value. + see https://bugzilla.kernel.org/show_bug.cgi?id=90911 + +statfs.2 + michael kerrisk [jakub wilk] + use consistent case for hex constants + +sync.2 + christoph hellwig + clarify description and document the linux data integrity guarantees + +syscall.2 + mike frysinger + add more architectures and improve error documentation + move the error register documentation into the main table rather + than listing them in sentences after the fact. + + add sparc error return details. + + add details for alpha/arc/m68k/microblaze/nios2/powerpc/superh/ + tile/xtensa. + +syscalls.2 + michael kerrisk + add copy_file_range(2) + +times.2 + kondo, naoya + fix an incorrect description in notes + the text has an incorrect description in notes, it says + that (2^32/hz) - 300 is about 429 million. it is correct + only if hz=10 which does not look common today. so just + removing "(i.e., about 429 million)" is good enough. + +truncate.2 + michael kerrisk + see also: add truncate(1) + +uselib.2 + michael kerrisk + mention config_uselib + michael kerrisk + note that glibc does not support this (obsolete) system call + +wait.2 +wait4.2 + michael kerrisk + rename the "status" argument to "wstatus" + the fact that exit(3)/_exit(2) has an argument called + "status" and the same name is used in the arguments to the + wait*() calls can a little too easily lead the user into + thinking that the two arguments hold the same information, + when of course they don't. so, use a different name + for the argument of the wait*() functions, to reduce + the chances of such confusion. + +backtrace.3 + michael kerrisk [martin gebert] + small fixes to example program + +clearenv.3 + michael kerrisk [matt zimmerman] + clarify the use and effect of clearenv() + see http://bugs.debian.org/679323 + michael kerrisk + variables can be added to the environment after calling clearenv() + +clog10.3 + michael kerrisk + show an alternative equivalence for clog10() + michael kerrisk + update conforming to + fix grammar error and add c11. + +dl_iterate_phdr.3 + michael kerrisk [paul pluzhnikov] + describe 'struct dl_phdr_info' fields added in glibc 2.4 + see https://bugzilla.kernel.org/show_bug.cgi?id=103011 + michael kerrisk [simon que] + note that first object visited by 'callback' is the main program + see https://bugzilla.kernel.org/show_bug.cgi?id=94141 + +errno.3 + michael kerrisk + add some explanation of enoent error + +exec.3 + michael kerrisk + see also: add system(3) + +exp.3 + michael kerrisk [joachim wuttke] + see also: add expm1(3) + +fopen.3 + michael kerrisk + see also: add open_memstream(3) + +fts.3 + michael kerrisk + bugs: glibc-2.23 now has lfs support for the fts functions + +gamma.3 + michael kerrisk [alan cox] + gamma() was documented in svid 2 + +getaddrinfo.3 + michael kerrisk [andreas schwab, orion poplawski] + update ftm requirements for glibc 2.22 + since glibc 2.22 getaddrinfo() etc. are only declared for + posix.1-2001 or later. + +getcwd.3 + michael kerrisk + see also: add pwd(1) + +opendir.3 + michael kerrisk + help the reader by explicitly mentioning the use of readdir(3) + +perror.3 + michael kerrisk + suggest use of strerror(3) in place of deprecated 'sys_errlist' + +posix_fallocate.3 + jérémie galarneau + errors: add eintr + the glibc implementation of posix_fallocate(), which calls + fallocate(), may be interrupted. the fallocate() emulation + also makes use of pread()/pwrite(), which may also be + interrupted. + +posix_memalign.3 + michael kerrisk [eric blake] + note posix_memalign()'s treatment of 'memptr' on error + +pthread_setaffinity_np.3 + michael kerrisk + see also: add cpu_set(3) + +queue.3 + dr. tobias quathamer + remove double conforming to section + +rcmd.3 + nikola forró + add missing condition concerning .rhosts file + the list of conditions determining if iruserok() and ruserok() + functions automatically fail is incomplete. according to glibc + source code, the functions also fail if the .rhosts file + is hard linked anywhere. + +setbuf.3 + michael kerrisk + see also: add stdbuf(1) + +setjmp.3 + michael kerrisk + rewrite and merge longjmp()/siglongjmp() discussion into this page + the discussion of nonlocal gotos is much easier to read if + setjmp() and longjmp() are discussed in the same page. while + we're at it, rework almost the entire text and add several + more details. + michael kerrisk + note the interactions of longjmp() and non-async-signal-safe functions + posix.1-2008 tc2 adds explicit text on this point. + see http://austingroupbugs.net/view.php?id=516#c1195 + michael kerrisk + explain why nonlocal gotos make code harder to maintain + michael kerrisk + reword warning on longjmp() to function that has already returned + michael kerrisk + remove reference to obsolete _xopen_source_extended + +sleep.3 + michael kerrisk + see also: add sleep(1) + +strftime.3 + michael kerrisk [jeremy harris] + note which 'tm' fields are used to calculate each output string + see https://bugzilla.redhat.com/show_bug.cgi?id=1162218 + +strlen.3 + michael kerrisk [alan aversa] + conforming to: add c11 + +system.3 + michael kerrisk + see also: add execve(2) + +termios.3 + dr. tobias quathamer + document line length in canonical mode + see https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/tty/n_tty.c#n1673 + see https://bugs.debian.org/797479 + michael kerrisk + see also: add tty(1) + michael kerrisk [peter hurley] + further improvements to recent tweaks of canonical mode 4096 char limit + +timegm.3 + michael kerrisk [stephen hurd, mats wichmann] + remove sample implementation of timegm() + stephen and mats both question the wisdom of showing a portable + *non-thread-safe* implementation of timegm(), and i find it + hard to disagree. so, remove this code. + + see https://bugzilla.kernel.org/show_bug.cgi?id=103701 + michael kerrisk + expand description a little + +st4.4 + dr. tobias quathamer + remove spurious copyright section + +tty_ioctl.4 + michael kerrisk + see also: add ldattach(1) + +elf.5 + michael kerrisk [gabriel corona, mike frysinger] + fix description of stv_protected + michael kerrisk + improve description of stv_default + michael kerrisk + improve description of stv_hidden + chris pick + remove erroneous, duplicate shn_* section + michael kerrisk [chris pick] + reword discussion of range values a little + +gai.conf.5 + michael kerrisk + add versions section + +group.5 + michael kerrisk + see also: add groups(2) + see also: add gpasswd(1) + see also: add sg(1) + se also: add gshadow(5) + see also: add chgrp(1) + +locale.5 + marko myllynen [mike frysinger] + tel + fax are deprecated + +nsswitch.conf.5 + nikola forró + update nss compatibility mode description + +utmp.5 + michael kerrisk + see also: add lslogins(1) + +aio.7 + andreas gruenbacher + improve example + when aio_sigevent.sigev_notify is set to sigev_signal, signal + handlers called for asynchronous i/o operations will have + si->si_code set to si_asyncio. check to make sure that + si->si_value.sival_ptr is defined. + +capabilities.7 + michael kerrisk + explain safety check for capability-dumb binaries + michael kerrisk + see also: add sg(1), su(1) + see also: add id(1), group(5), passwd(5) + +credentials.7 + michael kerrisk + see also: add groups(2) + +environ.7 + michael kerrisk + describe the bourne "name=value command" syntax + michael kerrisk + add some details describing hos shell's environment is initialized + michael kerrisk + note that child of fork(2) inherits copy of parent's environment + michael kerrisk + see also: add pam_env(3) + +epoll.7 + michael kerrisk + mention that epoll info is available via /proc/pid/fdinfo + +fanotify.7 + michael kerrisk + refer reader to proc(5) for info on /proc/pid/fdinfo fanotify entries + + +feature_test_macros.7 + michael kerrisk + add a summary of some ftm key points + michael kerrisk + give an early hint about some macros being defined by default + michael kerrisk + clarify relation between _xopen_source >=500 and _xopen_source_extended + emphasize that defining _xopen_source >=500 produces same + effects as defining _xopen_source_extended. + michael kerrisk + note that man pages don't mention _xopen_source_extended + as per previous commit, mention of _xopen_source_extended + has generally been removed from the man pages. + michael kerrisk + note effects of "cc -std=c99" and "cc -std=c11" + michael kerrisk + clarify some _isoc99_source / _default_source details + michael kerrisk + clarify that _xopen_source_extended is obsolete + since susv2, _xopen_source_extended is no longer specified + in the standard. + +inotify.7 + michael kerrisk + refer reader to proc(5) for info on /proc/pid/fdinfo inotify entries + +ip.7 + eric dumazet + document ip_bind_address_no_port socket option + +mq_overview.7 + michael kerrisk + note that the close-on-exec flag is automatically set on mq descriptors + +namespaces.7 + michael kerrisk + see also: add lsns(1) + lsns(1) was recently added in util-linux, probably to appear + in next release (2.28?). + +pipe.7 + michael kerrisk [jason vas dias] + clarify that i/o signalling requires use of both f_setown and o_async + michael kerrisk + see also: add mkfifo(1) + +signal.7 + michael kerrisk + note the interactions of longjmp() and non-async-signal-safe functions + see http://austingroupbugs.net/view.php?id=516#c1195. + +socket.7 + michael kerrisk + see also: add pcap(3) + see also: add wireshark(1) and tcpdump(8) + +standards.7 + michael kerrisk + add posix.1-2008 tc2 (posix.1-2016) + +svipc.7 + michael kerrisk + tweak description of 'sempid' + michael kerrisk + see also: add lsipc(1) + +symlink.7 + michael kerrisk [zefram] + some "magic" symlinks have permissions other than 0777 + see https://bugs.debian.org/743525 + +time.7 + michael kerrisk + see also: add timeout(1) + see also: add ntp_adjtime(3) and ntp_gettime(3) + +unicode.7 + dr. tobias quathamer + document private use areas + see https://bugs.debian.org/285444 + +unix.7 + heinrich schuchardt + add example + a complete example demonstrating the usage of sockets for local + interprocess communication is added. + michael kerrisk + introduce term "sequenced-packet" for sock_seqpacket + michael kerrisk + some wording improvements + + +==================== changes in man-pages-4.06 ==================== + +released: 2016-05-09, oslo + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +alexander miller +alon bar-lev +benjamin poirier +christoph hellwig +colin ian king +dr. tobias quathamer +ed avis +georg sauthoff +heinrich schuchardt +jakub wilk +jordan birks +marko myllynen +michael kerrisk +mike frysinger +nikola forró +rasmus villemoes +serge e. hallyn +serge hallyn +valery reznic +zubair lutfullah kakakhel + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +cgroups.7 + serge hallyn, michael kerrisk + new page documenting cgroups + +cgroup_namespaces.7 + michael kerrisk [serge hallyn] + new page describing cgroup namespaces + + +newly documented interfaces in existing pages +--------------------------------------------- + +clone.2 + michael kerrisk + document clone_newcgroup + +readv.2 + christoph hellwig + document preadv2() and pwritev2() +setns.2 + michael kerrisk + document clone_newcgroup + +unshare.2 + michael kerrisk + document clone_newcgroup + + +changes to individual pages +--------------------------- + +clock_getres.2 + michael kerrisk [rasmus villemoes] + note that coarse clocks need architecture and vdso support + +clone.2 +fork.2 + nikola forró + document erestartnointr error code + +clone.2 + michael kerrisk [colin ian king] + errors: add einval for improperly aligned 'child_stack' value + +execve.2 + michael kerrisk [valery reznic] + since linux 2.6.28, recursive script interpretation is supported + +fcntl.2 + michael kerrisk + note that mandatory locking is now governed by a configuration option + +fsync.2 + michael kerrisk [georg sauthoff] + give some examples of files where sync can fail with einval + +getrlimit.2 + michael kerrisk + see also: add cgroups(7) + +ioctl_fat.2 + heinrich schuchardt + use %04x to print volume id + leading zeroes should be used when display a fat volume id. + +ioprio_set.2 + michael kerrisk + see also: add cgroups(7) + +lseek.2 + michael kerrisk + note that 'off_t' is an integer data type defined by posix + +memfd_create.2 + michael kerrisk + note that memfd_create() does not have a glibc wrapper + +mount.2 + michael kerrisk + ms_mandlock requires cap_sys_admin (since linux 4.5) + +quotactl.2 + michael kerrisk + document q_getnextquota and q_xgetnextquota + michael kerrisk + rework/reorder errors list + make into a single alphabetically ordered list + michael kerrisk + note kernel version that removed q_getstats + michael kerrisk + add kernel version for g_getinfo, q_setinfo, and q_getfmt + +readv.2 + michael kerrisk + clarify that 'size_t' and 'ssize_t' are integer types specified in posix + +semctl.2 + michael kerrisk + from kernel 4.6, linux now updates 'sempid' on setall operations + +sigaction.2 + michael kerrisk + document segv_bnderr + michael kerrisk + document segv_pkuerr + +syscalls.2 + michael kerrisk + add preadv2() and pwritev2() + +write.2 + michael kerrisk + clarify that 'size_t' and 'ssize_t' are integer types specified in posix + +makedev.3 + mike frysinger + use in synopsis + defining these functions via causes problems for + some folk. as noted by zack wein: + + libstdc++ force-enables _gnu_source, which means people + writing in c++ _can't_ avoid these nonstandard macros by + using a strict conformance mode. + + since glibc has basically always used , + update the docs to have people include that instead. + michael kerrisk + notes: mention that may also define these macros + +popen.3 + nikola forró + return value: describe successful case + reference: + http://pubs.opengroup.org/onlinepubs/9699919799/functions/popen.html + http://pubs.opengroup.org/onlinepubs/9699919799/functions/pclose.html + +strtod.3 + michael kerrisk [ed avis] + improve a detail in return value + +core.5 + michael kerrisk + document /proc/sys/kernel/core_pipe_limit + +locale.5 + marko myllynen + adjust lc_identification / abbreviation + tiny tweak to locale.5 based on iso/iec tr 14652: + + http://www.open-std.org/jtc1/sc22/wg20/docs/n972-14652ft.pdf + marko myllynen + update lc_address after glibc change + this patch updates locale.5 to match the recent glibc change + in commit a837257199ffab76237385b830cc7b6179fc2f18 + marko myllynen + complete lc_collate + here's the first attempt to (almost) complete the locale.5 manual + page by documenting all (but perhaps one) of the missing + lc_collate keywords. + mike frysinger + country_car: add a better description + + +nsswitch.conf.5 + marko myllynen + document group merging + document the recently merged glibc group merge support. + glibc commit ced8f8933673f4efda1d666d26a1a949602035ed + https://sourceware.org/glibc/wiki/proposals/groupmerging + +proc.5 + michael kerrisk + move /proc/pid/cgroup discussion to cgroups(7) page + michael kerrisk + add some background on why /proc/pid/mountinfo was added + michael kerrisk + improve description of /proc/pid/mountinfo 'root' field + michael kerrisk + add pointer to cgroups(7) for documentation of /proc/cgroups + michael kerrisk + add reference to core(5) for info on /proc/sys/kernel/core_pipe_limit + +cpuset.7 + michael kerrisk + see also: add cgroups(7) + +ip.7 + benjamin poirier + fix incorrect sockopt name + "ip_leave_group" does not exist. it was perhaps a confusion with + mcast_leave_group. change the text to ip_drop_membership which has + the same function as mcast_leave_group and is documented in the + ip.7 man page. + + reference: + linux kernel net/ipv4/ip_sockglue.c do_ip_setsockopt() + +namespaces.7 + michael kerrisk + see also: add cgroups(7), cgroup_namespaces(7) + +vdso.7 + zubair lutfullah kakakhel [mike frysinger] + update for mips + document the symbols exported by the mips vdso. + vdso support was added from kernel 4.4 onwards. + + see https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/log/arch/mips/vdso + michael kerrisk [rasmus villemoes] + the __kernel_clock_* interfaces don't support *_coarse clocks on powerpc + +ld.so.8 + michael kerrisk [alon bar-lev] + document use of $origin, $lib, and $platform in environment variables + these strings are meaningful in ld_library_path and ld_preload. + + +==================== changes in man-pages-4.07 ==================== + +released: 2016-07-17, ulm + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +alec leamas +andrey vagin +andy lutomirski +carsten grohmann +chris gassib +christoph hellwig +darren hart +darrick j. wong +élie bouttier +eric biggers +eric w. biederman +florian weimer +håkon sandsmark +iustin pop +jacob willoughby +jakub wilk +james h cownie +jann horn +john wiersba +jörn engel +josh triplett +kai mäkisara +kees cook +keno fischer +li peng +marko kevac +marko myllynen +michael kerrisk +michał zegan +miklos szeredi +mitch walker +neven sajko +nikos mavrogiannopoulos +omar sandoval +ori avtalion +rahul bedarkar +robin kuzmin +rob landley +shawn landden +stefan puiu +stephen smalley +szabolcs nagy +thomas gleixner +tobias stoeckmann +tom callaway +tom gundersen +vince weaver +w. trevor king +"yuming ma(马玉明)" + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +ioctl_fideduperange.2 + darrick j. wong [christoph hellwig, michael kerrisk] + new page documenting the fideduperange ioctl + document the fideduperange ioctl, formerly known as + btrfs_ioc_extent_same. + +ioctl_ficlonerange.2 + darrick j. wong [christoph hellwig, michael kerrisk] + new page documenting ficlone and ficlonerange ioctls + document the ficlone and ficlonerange ioctls, formerly known as + the btrfs_ioc_clone and btrfs_ioc_clone_range ioctls. + +nextup.3 + michael kerrisk + new page documenting nextup(), nextdown(), and related functions + +mount_namespaces.7 + michael kerrisk [michael kerrisk] + new page describing mount namespaces + + +newly documented interfaces in existing pages +--------------------------------------------- + +mount.2 + michael kerrisk + document flags used to set propagation type + document ms_shared, ms_private, ms_slave, and ms_unbindable. + michael kerrisk + document the ms_rec flag + +ptrace.2 + michael kerrisk [kees cook, jann horn, eric w. biederman, stephen smalley] + document ptrace access modes + +proc.5 + michael kerrisk + document /proc/[pid]/timerslack_ns + michael kerrisk + document /proc/pid/status 'ngid' field + michael kerrisk + document /proc/pid/status fields: 'nstgid', 'nspid', 'nspgid', 'nssid' + michael kerrisk + document /proc/pid/status 'umask' field + + +new and changed links +--------------------- + +preadv2.2 +pwritev2.2 + michael kerrisk + new links to readv(2) + +nextdown.3 +nextdownf.3 +nextdownl.3 +nextupf.3 +nextupl.3 + michael kerrisk + new links to nextup(3) + + +changes to individual pages +--------------------------- + +ldd.1 + michael kerrisk + add a little more detail on why ldd is unsafe with untrusted executables + michael kerrisk + add more detail on the output of ldd + +localedef.1 + marko myllynen + drop --old-style description + the glibc upstream decided to drop localedef(1) --old-style + option [1] altogether, i think we can do the same with + localedef(1), the option hasn't done anything in over 16 + years and i doubt anyone uses it. + +add_key.2 + mitch walker + empty payloads are not allowed in user-defined keys + +chroot.2 + michael kerrisk + see also: add pivot_root(2) + +clone.2 + michael kerrisk + add reference to mount_namespaces(7) under clone_newns description + +fork.2 + michael kerrisk + add enomem error for pid namespace where "init" has died + +futex.2 + michael kerrisk + correct an enosys error description + since linux 4.5, futex_clock_realtime is allowed with futex_wait. + michael kerrisk [darren hart] + remove crufty text about futex_wait_bitset interpretation of timeout + since linux 4.5, futex_wait also understands + futex_clock_realtime. + michael kerrisk [thomas gleixner] + explain how to get equivalent of futex_wait with an absolute timeout + michael kerrisk + describe futex_bitset_match_any + describe futex_bitset_match_any and futex_wait and futex_wake + equivalences. + michael kerrisk + note that at least one bit must be set in mask for bitset operations + at least one bit must be set in the 'val3' mask supplied for the + futex_wait_bitset and futex_wake_bitset operations. + michael kerrisk [thomas gleixner, darren hart] + fix descriptions of various timeouts + michael kerrisk + clarify clock default and choices for futex_wait + +getitimer.2 + michael kerrisk + substantial rewrites to various parts of the page + michael kerrisk [tom callaway] + change license to note that page may be modified + the page as originally written carried text that said the page may + be freely distributed but made no statement about modification. + in the 20+ years since it was first written, the page has in fact + seen repeated, sometimes substantial, modifications, and only a + small portion of the original text remains. one could i suppose + rewrite the last few pieces that remain from the original, + but as the largest contributor to the pages existing text, + i'm just going to relicense it to explicitly note that + modification is permitted. (i presume the failure by the + original author to grant permission to modify was simply an + oversight; certainly, the large number of people who have + changed the page have taken that to be the case.) + + see also https://bugzilla.kernel.org/show_bug.cgi?id=118311 + +get_mempolicy.2 + michael kerrisk [jörn engel] + correct rounding to 'maxnodes' (bits, not bytes) + michael kerrisk [jörn engel] + fix prototype for get_mempolicy() + in numaif.h, 'addr' is typed as 'void *' + +getpriority.2 + michael kerrisk + make discussion of rlimit_nice more prominent + the discussion of rlimit_nice was hidden under the eperm error, + where it was difficult to find. place some relevant text in + description. + michael kerrisk + note that getpriority()/setpriority deal with same attribute as nice(2) + michael kerrisk [robin kuzmin] + clarify equivalence between lower nice value and higher priority + +get_robust_list.2 + michael kerrisk + get_robust_list() is governed by ptrace_mode_read_realcreds + +ioctl.2 + michael kerrisk + see also: add ioctl_fideduperange(2) and ioctl_ficlonerange(2) + +kcmp.2 + michael kerrisk + kcmp() is governed by ptrace_mode_read_realcreds + shawn landden + note about security_yama +kill.2 + michael kerrisk [john wiersba] + clarify the meaning if sig==0 + +lookup_dcookie.2 + michael kerrisk + see also: add oprofile(1) + +mmap.2 + michael kerrisk [rahul bedarkar] + example: for completeness, add munmap() and close() calls + +mount.2 + michael kerrisk + restructure discussion of 'mountflags' into functional groups + the existing text makes no differentiation between different + "classes" of mount flags. however, certain flags such as + ms_remount, ms_bind, ms_move, etc. determine the general + type of operation that mount() performs. furthermore, the + choice of which class of operation to perform is performed in + a certain order, and that order is significant if multiple + flags are specified. restructure and extend the text to + reflect these details. + michael kerrisk + relocate text on multimounting and mount stacking to notes + the text was somewhat out of place in its previous location; + notes is a better location. + michael kerrisk + remove version numbers attached to flags that are modifiable on remount + this information was simply bogus. mea culpa. + michael kerrisk + refer reader to mount_namespaces(7) for details on propagation types + michael kerrisk + see also: s/namespaces(7)/mount_namespaces(7)/ + omar sandoval + ms_bind still ignores mountflags + this is clear from the do_mount() function in the kernel as of v4.6. + michael kerrisk + note the default treatment of atime flags during ms_remount + the behavior changed in linux 3.17. + michael kerrisk + clarify that ms_move ignores remaining bits in 'mountflags' + michael kerrisk + note kernel version that added ms_move + michael kerrisk + ms_nosuid also disables file capabilities + michael kerrisk + relocate/demote/rework text on ms_mgc_val + the use of this constant has not been needed for 15 years now. + michael kerrisk + clarify that 'source' and 'target' are pathnames, and can refer to files + michael kerrisk + update example list of filesystem types + put more modern examples in; remove many older examples. + michael kerrisk + ms_lazytime and ms_relatime can be changed on remount + michael kerrisk + explicitly note that ms_dirsync setting cannot be changed on remount + michael kerrisk + move text describing 'data' argument higher up in page + in preparation for other reworking. + michael kerrisk + since linux 2.6.26, bind mounts can be made read-only + +open.2 + eric biggers + refer to correct functions in description of o_tmpfile + +pciconfig_read.2 + michael kerrisk [tom callaway] + change license to note that page may be modified + niki rahimi, the author of this page, has agreed that it's okay + to change the license to note that the page can be modified. + + see https://bugzilla.kernel.org/show_bug.cgi?id=118311 + +perf_event_open.2 + michael kerrisk + if pid > 0, the operation is governed by ptrace_mode_read_realcreds + jann horn + document new perf_event_paranoid default + keno fischer [vince weaver] + add a note that dyn_size is omitted if size == 0 + the perf_output_sample_ustack in kernel/events/core.c only writes + a single 64 bit word if it can't dump the user registers. from the + current version of the man page, i would have expected two 64 bit + words (one for size, one for dyn_size). change the man page to + make this behavior explicit. + +prctl.2 + michael kerrisk + some wording improvements in timer slack description + michael kerrisk + refer reader to discussion of /proc/[pid]/timerslack_ns + under discussion of pr_set_timerslack, refer the reader to + the /proc/[pid]/timerslack_ns file, documented in proc(5). + +process_vm_readv.2 + michael kerrisk + rephrase permission rules in terms of a ptrace access mode check + +ptrace.2 + michael kerrisk [jann horn] + update yama ptrace_scope documentation + reframe the discussion in terms of ptrace_mode_attach checks, + and make a few other minor tweaks and additions. + michael kerrisk, jann horn + note that user namespaces can be used to bypass yama protections + michael kerrisk + note that ptrace_seize is subject to a ptrace access mode check + michael kerrisk + rephrase ptrace_attach permissions in terms of ptrace access mode check + +quotactl.2 + michael kerrisk [jacob willoughby] + 'dqb_curspace' is in bytes, not blocks + this error appears to have been injected into glibc + when copying some headers from bsd. + + see https://bugs.debian.org/825548 + +recv.2 + michael kerrisk [tom gundersen] + with pending 0-length datagram read() and recv() with flags == 0 differ + +setfsgid.2 +setfsuid.2 + jann horn [michael kerrisk] + fix note about errors from the syscall wrapper + see sysdeps/unix/sysv/linux/i386/setfsuid.c in glibc-2.2.1. + (this code is not present in modern glibc anymore.) + michael kerrisk + move glibc wrapper notes to "c library/kernel differences" subsection + +sysinfo.2 + michael kerrisk + rewrite and update various pieces + +umask.2 + michael kerrisk + notes: mention /proc/pid/status 'umask' field + +umount.2 + michael kerrisk + see also: add mount_namespaces(7) + +unshare.2 + michael kerrisk + add reference to mount_namespaces(7) under clone_newns description + +utimensat.2 + michael kerrisk [rob landley] + note that the glibc wrapper disallows pathname==null + +wait.2 + michael kerrisk + since linux 4.7, __wall is implied if child being ptraced + michael kerrisk + waitid() now (since linux 4.7) also supports __wnothread/__wclone/__wall + +assert.3 + nikos mavrogiannopoulos + improved description + removed text referring to text not being helpful to users. provide + the error text instead to allow the reader to determine whether it + is helpful. recommend against using ndebug for programs to + exhibit deterministic behavior. moved description ahead of + recommendations. + michael kerrisk + clarify details of message printed by assert() + +fmax.3 +fmin.3 + michael kerrisk + see also: add fdim(3) + +getauxval.3 + cownie, james h + correct at_hwcap result description + +inet_pton.3 + stefan puiu + mention byte order + +malloc_hook.3 + michael kerrisk + glibc 2.24 removes __malloc_initialize_hook + +memmem.3 + michael kerrisk [shawn landden] + note that memmem() is present on some other systems + +mkdtemp.3 +mktemp.3 + michael kerrisk + see also: add mktemp(1) + +printf.3 + michael kerrisk [shawn landden] + note support in other c libraries for %m and %n + +strcasecmp.3 + michael kerrisk [ori avtalion] + make details of strncasecmp() comparison clearer + +strcat.3 + michael kerrisk + add a program that shows the performance characteristics of strcat() + in honor of joel spolksy's visit to munich, let's start educating + schlemiel the painter. + +strtoul.3 + michael kerrisk + see also: add a64l(3) + +strxfrm.3 + michael kerrisk [florian weimer] + remove notes section + strxfrm() and strncpy() are not precisely equivalent in the + posix locale, so this notes section was not really correct. + + see https://bugzilla.kernel.org/show_bug.cgi?id=104221 + +console_codes.4 +console_ioctl.4 +tty.4 +vcs.4 +charsets.7 + marko myllynen + remove console(4) references + 0f9e647 removed the obsolete console(4) page but we still have few + references to it. the patch below removes them or converts to refs + to console_ioctl(4) where appropriate. + +console_ioctl.4 + michael kerrisk [chris gassib] + the argument to kdgetmode is an 'int' + +lirc.4 + alec leamas + update after upstreamed lirc.h, bugfixes. + +st.4 + kai mäkisara + fix description of read() when block is larger than request + kai mäkisara + update mtmkpart for kernels >= 4.6 + update the description of the mtmkpart operation of mtioctop to match + the changes in kernel version 4.6. + +charmap.5 + marko myllynen + clarify keyword syntax + updates charmap(5) to match the syntax all the glibc + charmap files are using currently. + +elf.5 + michael kerrisk + see also: add readelf(1) + +locale.5 + marko myllynen + document missing keywords, minor updates + marko myllynen + clarify keyword syntax + marko myllynen + adjust conformance + +proc.5 +namespaces.7 + michael kerrisk + move /proc/pid/mounts information to proc(5) + there was partial duplication, and some extra information + in namespaces(7). move everything to proc(5). + +proc.5 + michael kerrisk + /proc/pid/fd/* are governed by ptrace_mode_read_fscreds + permission to dereference/readlink /proc/pid/fd/* symlinks is + governed by a ptrace_mode_read_fscreds ptrace access mode check. + michael kerrisk + /proc/pid/timerslack_ns is governed by ptrace_mode_attach_fscreds + permission to access /proc/pid/timerslack_ns is governed by + a ptrace_mode_attach_fscreds ptrace access mode check. + michael kerrisk + document /proc/pid/{maps,mem,pagemap} access mode checks + permission to access /proc/pid/{maps,pagemap} is governed by a + ptrace_mode_read_fscreds ptrace access mode check. + + permission to access /proc/pid/mem is governed by a + ptrace_mode_attach_fscreds ptrace access mode check. + michael kerrisk + note /proc/pid/stat fields that are governed by ptrace_mode_read_fscreds + michael kerrisk + /proc/pid/{cwd,exe,root} are governed by ptrace_mode_read_fscreds + permission to dereference/readlink /proc/pid/{cwd,exe,root} is + governed by a ptrace_mode_read_fscreds ptrace access mode check. + michael kerrisk + /proc/pid/io is governed by ptrace_mode_read_fscreds + permission to access /proc/pid/io is governed by + a ptrace_mode_read_fscreds ptrace access mode check. + michael kerrisk + /proc/pid/{personality,stack,syscall} are governed by ptrace_mode_attach_fscreds + permission to access /proc/pid/{personality,stack,syscall} is + governed by a ptrace_mode_attach_fscreds ptrace access mode check. + michael kerrisk + /proc/pid/{auxv,environ,wchan} are governed by ptrace_mode_read_fscreds + permission to access /proc/pid/{auxv,environ,wchan} is governed by + a ptrace_mode_read_fscreds ptrace access mode check. + michael kerrisk + move shared subtree /proc/pid/mountinfo fields to mount_namespaces(7) + move information on shared subtree fields in /proc/pid/mountinfo + to mount_namespaces(7). + michael kerrisk ["yuming ma(马玉明)"] + note that /proc/net is now virtualized per network namespace + michael kerrisk + add references to mount_namespaces(7) + +repertoiremap.5 + marko myllynen + clarify keyword syntax + +utmp.5 + michael kerrisk + see also: add logname(1) + +capabilities.7 + michael kerrisk [andy lutomirski] + note on secure_no_cap_ambient_raise for capabilities-only environment + michael kerrisk + add a detail on use of securebits + +cgroup_namespaces.7 + michael kerrisk + see also: add namespaces(7) + +cgroups.7 + michael kerrisk + errors: add mount(2) ebusy error + +cp1251.7 +cp1252.7 +iso_8859-1.7 +iso_8859-15.7 +iso_8859-5.7 +koi8-r.7 +koi8-u.7 + marko myllynen + add some charset references + add some references to related charsets here and there. + +credentials.7 + michael kerrisk + see also: add runuser(1) + see also: add newgrp(1) + see also: add sudo(8) + +feature_test_macros.7 + michael kerrisk + emphasize that applications should not directly include + +man-pages.7 + michael kerrisk + clarify which sections man-pages provides man pages for + michael kerrisk [josh triplett] + add a few more details on formatting conventions + add some more details for section 1 and 8 formatting. + separate out formatting discussion into commands, functions, + and "general". + +namespaces.7 + michael kerrisk + /proc/pid/ns/* are governed by ptrace_mode_read_fscreds + permission to dereference/readlink /proc/pid/ns/* symlinks is + governed by a ptrace_mode_read_fscreds ptrace access mode check. + michael kerrisk + nowadays, file changes in /proc/pid/mounts are notified differently + exceptional condition for select(), (e)pollpri for (e)poll + michael kerrisk + remove /proc/pid/mountstats description + this is a duplicate of information in proc(5). + michael kerrisk + refer to new mount_namespaces(7) for information on mount namespaces + +netlink.7 + andrey vagin + describe netlink socket options + michael kerrisk + rework version information + (no changes in technical details.) + +pid_namespaces.7 + michael kerrisk + see also: add namespaces(7) + +unix.7 + michael kerrisk + move discussion on pathname socket permissions to description + michael kerrisk + expand discussion of socket permissions + michael kerrisk + fix statement about permissions needed to connect to a unix domain socket + read permission is not required (verified by experiment). + michael kerrisk + clarify ownership and permissions assigned during socket creation + michael kerrisk [carsten grohmann] + update text on socket permissions on other systems + at least some of the modern bsds seem to check for write + permission on a socket. (i tested openbsd 5.9.) on solaris 10, + some light testing suggested that write permission is still + not checked on that system. + michael kerrisk + note that umask / permissions have no effect for abstract sockets + w. trevor king + fix example code: 'ret' check after accept populates 'data_socket' + michael kerrisk + move some abstract socket details to a separate subsection + michael kerrisk + note that abstract sockets automatically disappear when fds are closed + +user_namespaces.7 + michael kerrisk [michał zegan] + clarify meaning of privilege in a user namespace + having privilege in a user ns only allows privileged + operations on resources governed by that user ns. many + privileged operations relate to resources that have no + association with any namespace type, and only processes + with privilege in the initial user ns can perform those + operations. + + see https://bugzilla.kernel.org/show_bug.cgi?id=120671 + michael kerrisk [michał zegan] + list the mount operations permitted by cap_sys_admin + list the mount operations permitted by cap_sys_admin in a + noninitial userns. + + see https://bugzilla.kernel.org/show_bug.cgi?id=120671 + michael kerrisk [michał zegan] + cap_sys_admin allows mounting cgroup filesystems + see https://bugzilla.kernel.org/show_bug.cgi?id=120671 + michael kerrisk + clarify details of cap_sys_admin and cgroup v1 mounts + with respect to cgroups version 1, cap_sys_admin in the user + namespace allows only *named* hierarchies to be mounted (and + not hierarchies that have a controller). + michael kerrisk + clarify cap_sys_admin details for mounting fs_userns_mount filesystems + michael kerrisk + correct user namespace rules for mounting /proc + michael kerrisk + describe a concrete example of capability checking + add a concrete example of how the kernel checks capabilities in + an associated user namespace when a process attempts a privileged + operation. + michael kerrisk + correct kernel version where xfs added support for user namespaces + linux 3.12, not 3.11. + michael kerrisk + see also: add ptrace(2) + see also: add cgroup_namespaces(7) + +utf-8.7: + shawn landden + include rfc 3629 and clarify endianness which is left ambiguous + the endianness is suggested by the order the bytes are displayed, + but the text is ambiguous. + + +==================== changes in man-pages-4.08 ==================== + +released: 2016-10-08, munich + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +arnaud gaillard +bill pemberton +carlos o'donell +christoph hellwig +david turner +dr. tobias quathamer +elliott hughes +eugene syromyatnikov +heinrich schuchardt +hu keping +igor liferenko +ivan kharpalev +jakub wilk +jann horn +josh triplett +keno fischer +laurent georget +local lembke +mats wichmann +michael kerrisk +mike crowe +mike frysinger +namhyung kim +nikola forró +patrick mclean +peter wu +petr cermak +quentin rameau +ray bellis +rich felker +ruben kerkhof +sam varshavchik +sebastian andrzej siewior +siward de groot +sloane bernstein +stefan tauner +tim savannah +ursache vladimir +zefram +王守堰 + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +quotactl.2 + eugene syromyatnikov [michael kerrisk] + updated information regarding disk quota flags + added information regarding dqf_sys_file flag; updated definition + of v1_dqf_rsquash, which has been defined privately and defined + publicly as dqf_root_squash. + eugene syromyatnikov + updated information regarding xfs-specific quotactl subcommands + added information regarding structure definitions used for + xfs-specific subcommands, updated flag constants, added + information regarding ignored syscall arguments, added notes on + usage of kernel uapi header. + eugene syromyatnikov + additions regarding project quotas + added information regarding presence of project quotas. + +bswap.3 + michael kerrisk + new page documenting bswap_16(), bswap_32(), and bswap_64() + +cgroups.7 + michael kerrisk + substantial rewrites, additions, and corrections. + + +newly documented interfaces in existing pages +--------------------------------------------- + +readv.2 + michael kerrisk + document the pwritev2() rwf_sync and rwf_dsync flags + +proc.5 + michael kerrisk + document /proc/pid/seccomp + jann horn + document /proc/[pid]/task/[tid]/children + document the /proc/[pid]/task/[tid]/children interface from + criu, and more importantly, document why it's usually not + a good interface. + + +new and changed links +--------------------- + +bswap_16.3 +bswap_32.3 +bswap_64.3 + new link to new bswap.3 + + +global changes +-------------- + +various pages + michael kerrisk + fix section ordering + various pages had sections in an order different from + that prescribed in man-pages(7). + +various pages + michael kerrisk [mike frysinger] + consistently use /proc/[pid] (not /proc/pid) + +various pages + michael kerrisk + fix order of see also entries + entries should be ordered first by section, and then alphabetically + within the section. + +various pages + michael kerrisk + order errors alphabetically + +various pages + michael kerrisk + remove section number from page self reference + fix places where pages refer to the function that they describe + and include a section number in that reference. such references + cause some html-rendering tools to create self-references in the + page. + +a few pages + michael kerrisk + eliminate groff "cannot adjust line" warnings + + +changes to individual pages +--------------------------- + +pldd.1 + michael kerrisk [carlos o'donell] + note gdb(1) command that can be used as a replacement for pldd + taken from carlos o'donnell's suggestion in + https://sourceware.org/bugzilla/show_bug.cgi?id=18035#c2 + michael kerrisk + bugs: pldd has not worked since glibc 2.19 + +accept.2 + michael kerrisk + mention epoll(7) alongside poll()/select() + michael kerrisk + demote discussion of decnet to notes + decnet ceased to be important long ago... + +adjtimex.2 + nikola forró + fix kernel version references + +chroot.2 + michael kerrisk + note user namespace requirements for cap_sys_chroot + +clone.2 + keno fischer [josh triplett] + adjust syscall prototype and expand clone_settls description + michael kerrisk [josh triplett, josh triplett] + document raw syscall interfaces on various other architectures + michael kerrisk + change types for 'ptid' and 'ctid' in syscall prototypes + these types changed from 'void *' to 'int *' back in linux 3.8. + michael kerrisk + einval is generated by glibc wrapper for null 'fn' or 'child_stack' + clarify that this error is produced by the wrapper function, not + the underlying system call. in particular, the point is that the + raw system call can accommodate a null pointer for 'child_stack'. + michael kerrisk [elliott hughes] + make the implications of clone_files more explicit + if clone_files is not set, the duplicated fds nevertheless share + file offset and status flags via the open file description. + michael kerrisk + mention kcmp() under notes + +close.2 + michael kerrisk + add mention of the close-on-exec flag + michael kerrisk + clarify discussion noting that close() does not flush buffer cache + +epoll_wait.2 + mike crowe + clarify that the timeout is measured against clock_monotonic + +execve.2 + michael kerrisk + mention use of 'environ' to access environment list + michael kerrisk + note that real uid, real gid, and supplementary gids are unchanged + +fanotify_init.2 + heinrich schuchardt + update bugs information + +fcntl.2 + michael kerrisk + note an important detail of f_setown permission rules for signals + f_setown records the caller's credentials at the time of + the fcntl() call, and it is these saved credentials that + are used for subsequent permission checks. + michael kerrisk + make the description of the effect of close-on-exec a little clearer + michael kerrisk + clarify that f_getfd and f_getfl return flags via the function result + +fork.2 + michael kerrisk + pid of new process also does not match any existing session id + +fsync.2 + michael kerrisk + see also: add pwritev(2) + since linux 4.7, pwritev() has flags related to i/o + integrity completion. + +getdomainname.2 + michael kerrisk + note user namespace requirements for cap_sys_admin + +getgroups.2 + michael kerrisk + note user namespace requirements for cap_setgid + +gethostname.2 + michael kerrisk + note user namespace requirements for cap_sys_admin + +getrlimit.2 + michael kerrisk + note user namespace semantics for cap_sys_resource + +getsid.2 + michael kerrisk + rework description to be somewhat clearer + michael kerrisk + correct the definition of "session id" + +getunwind.2 + michael kerrisk + simplify text referring to vdso(7) + the detail given here is redundant, since this info is also + in vdso(7). + +kcmp.2 + michael kerrisk + add an example program + +kill.2 + michael kerrisk + note the user namespace requirement for cap_kill + +killpg.2 + michael kerrisk + refer reader to kill(2) for signal permission rules + +mlock.2 + sebastian andrzej siewior + document that fork() after mlock() may be a bad idea in a rt process + +mmap.2 + jann horn + describe treatment of 'offset' for map_anonymous + michael kerrisk [siward de groot] + small improvement to description of map_shared + see https://sourceware.org/bugzilla/show_bug.cgi?id=6887 + +msgctl.2 +msgget.2 +msgop.2 +semctl.2 +semget.2 +semop.2 +shmctl.2 +shmget.2 +shmop.2 + michael kerrisk + note the user namespace requirements for cap_ipc_owner + +open.2 + michael kerrisk + clarify user namespace capability requirements for o_noatime + michael kerrisk + notes: kcmp() can be used to test if two fds refer to the same ofd + michael kerrisk + f2fs support for o_tmpfile was added in linux 3.16 + michael kerrisk + clarify the rules about how the group id of a new file is determined + +prctl.2 + michael kerrisk + refer to proc(5) for effects of dumpability on ownership of /proc/pid/* + michael kerrisk + errors: add eacces error for pr_set_seccomp-seccomp_mode_filter + michael kerrisk + simplify list of cases where "dumpable" attribute is reset + michael kerrisk + note user namespace requirements for pr_capbset_drop cap_setpcap + +readlink.2 + michael kerrisk [ursache vladimir] + make example program handle links that report a size of zero + some "magic" symlinks created by the kernel (e.g., those under + /proc and /sys) report 'st_size' as zero. modify the example + program to handle that possibility. + michael kerrisk + emphasize that truncation of returned buffer generates no error + +readv.2 + michael kerrisk [christoph hellwig] + clarify that rwf_dsync and rwf_sync apply only to data being written + michael kerrisk + add preadv2() and pwritev2() to name line + +reboot.2 + michael kerrisk + note user namespace requirements around cap_sys_boot + +rename.2 + michael kerrisk [tim savannah] + clarify that errors may cause rename to fail (not to be nonatomic) + +sched_setaffinity.2 + michael kerrisk + note user namespace requirements for cap_sys_nice + +seccomp.2 + michael kerrisk + cap_sys_admin is required only in caller's user namespace + +select_tut.2 + peter wu + fix various issues in example program + +seteuid.2 + michael kerrisk + note user namespace requirements for cap_setuid and cap_setgid + +setgid.2 + michael kerrisk + note user namespace requirements for cap_setgid + +setpgid.2 + michael kerrisk + add a reference to credentials(7) + +setpgid.2 +setsid.2 + michael kerrisk + relocate some text on sessions and sessions leaders + some text that was in setpgid(2) is better placed in setsid(2). + +setresuid.2 + michael kerrisk + note user namespace requirements for cap_setuid + +setreuid.2 + michael kerrisk + note user namespace requirements for cap_setuid and cap_setgid + +setsid.2 + michael kerrisk + refer to credentials(7) for details for details on controlling terminal + refer to credentials(7) for details of how a session obtains + a controlling terminal. + +set_thread_area.2 + michael kerrisk + add get_thread_area() to name + +setuid.2 + michael kerrisk + note user namespace requirements for cap_setuid + +sigprocmask.2 + keno fischer + expand/clarify libc/kernel sigset_t difference + +stat.2 + michael kerrisk [ursache vladimir, mats wichmann] + improve discussion of 'st_size' for /proc and /sys files + michael kerrisk + _bsd_source and _svid_source no longer expose nanosecond timestamps + +umask.2 + michael kerrisk + provide a rationale for the existence of /proc/pid/status 'umask' field + +wait.2 + michael kerrisk + remove erroneous statement that waitpid() is implemented via wait4() + there is a fallback to wait4(), but only if the kernel does + not provide a waitpid() system call. + +bindresvport.3 +rcmd.3 +ip.7 + michael kerrisk + note user namespace requirements for cap_net_bind_service + +byteorder.3 + michael kerrisk + see also: add bswap(3) + +dlopen.3 + michael kerrisk + dlmopen() is still broken in glibc 2.24 + +endian.3 + michael kerrisk + see also: add bswap(3) + +ffs.3 + michael kerrisk [stefan tauner] + correct feature test macro requirements + +fmemopen.3 + michael kerrisk [rich felker] + remove bogus suggestion to use setbuffer() + +getlogin.3 + michael kerrisk + update feature test macro requirements for cuserid() + +getumask.3 + michael kerrisk + note that getumask() is still unavailable in glibc 2.24 + michael kerrisk + point to umask(2) for a thread-safe way to discover process's umask + +mkstemp.3 + quentin rameau + fix _posix_c_source value for mkstemp() + the correct _posix_c_source value has always been 200809l, + not 200112l. + +pthread_join.3 + michael kerrisk [mats wichmann] + note that the caller might do clean up after joining with a thread + michael kerrisk [王守堰] + clarify use of 'retval' pointer + +resolver.3 + ray bellis + correct arguments to res_ninit(res_state statep) + +strverscmp.3 + michael kerrisk + add an example program + +wcstombs.3 + michael kerrisk [igor liferenko] + wcsrtombs() does not provide thread-safe interface to same functionality + see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=741360 + +core.5 + mike frysinger [michael kerrisk] + add more details for output paths and the crash handler + people sometimes assume that the crash handler runs in the same + context as the crashing process. they would be incorrect :). + +proc.5 + mike frysinger + clarify the root symlink and mount namespaces + if the target process is in a different mount namespace, the root + symlink actually shows that view of the filesystem. + michael kerrisk [mike frysinger] + expand discussion of /proc/[pid]/root + add a shell example showing that /proc/[pid]/root is more + than a symlink. based on an example provided by mike frysinger + in an earlier commit message. + michael kerrisk + explain rules determining ownership of /proc/pid/* files + describe the effect of the "dumpable" attribute on ownership + of /proc/pid files. + michael kerrisk + note effect of 'suid_dumpable' on ownership of /proc/pid files + michael kerrisk + refer to ptrace(2) for info on effect of suid_dumpable on ptraceability + michael kerrisk + add reference to core(5) in discussion of 'suid_dumpable' + michael kerrisk + note that 'suid_dumpable' mode 1 is insecure + michael kerrisk + document /proc/meminfo '+shmemhugepages' and 'shmempmdmapped' fields + michael kerrisk + document /proc/pid/status 'rssanon', 'rssfile', and 'rssshmem' fields + michael kerrisk + document /proc/pid/status 'hugetlbpages' field + michael kerrisk [zefram] + clarify that /proc/pid/statm 'shared' field counts *resident* pages + see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=741360 + michael kerrisk + add reference to umask(2) in discussion of /proc/pid/status 'umask' + michael kerrisk + clarify user namespace requirements for /proc/sys/fs/protected_hardlinks + michael kerrisk + note changes to config option governing /proc/[pid]/task/[tid]/children + michael kerrisk + clarify description of /proc/pid/statm 'lib' and 'dt' fields + these fields are always zero since linux 2.6. + namhyung kim [petr cermak] + add description of clear_refs_mm_hiwater_rss + michael kerrisk + update example vm values in /proc/pid/status + +capabilities.7 + michael kerrisk + add note about nosuid to file capabilities section + michael kerrisk + see also: add proc(5) + michael kerrisk + see also: add setsid(2) and setpgid(2) + +glob.7 + michael kerrisk [arnaud gaillard] + clarify that syntactically incorrect patterns are left unchanged + +packet.7 + michael kerrisk + clarify user namespace requirements for cap_net_raw + +pipe.7 + michael kerrisk [patrick mclean] + document fionread + +raw.7 + michael kerrisk + clarify user namespace requirements for cap_net_raw + also remove mention of uid 0 as a method or creating + a raw socket. as far as i can tell from reading the + kernel source (net/ipv4/af_inet.c), this is not true. + +socket.7 + michael kerrisk + siocspgrp: refer to fcntl(2) f_setown for correct permission rules + the permission rules described for sioccpgrp are wrong. rather + than repeat the rules here, just refer the reader to fcntl(2), + where the rules are described for f_setown. + +unix.7 + michael kerrisk [laurent georget, ivan kharpalev] + remove mention of recvmsg() from discussion of epipe error + see https://bugzilla.kernel.org/show_bug.cgi?id=137351 + +ld.so.8 + michael kerrisk + expand description of ld_debug + provide a list of the categories, and note that multiple + categories can be specified. + michael kerrisk + add glibc version for ld_use_load_bias + michael kerrisk + clarify text describing whether secure-mode programs preload libraries + michael kerrisk + remove discussion of environment variables understood by libc5 + libc5 disappeared long ago, so cease cluttering up this page + with those ancient details. thus, remove discussion of the + following environment variables: ld_aout_library_path, + ld_aout_preload, ld_keepdir, ld_nowarn, and ldd_argv0. + michael kerrisk + remove text with ancient libc4 and linux libc details + michael kerrisk + remove mention of "elf only" + drawing a distinction between elf-only features versus a,out + ceased to be relevant long ago, so cluttering the page + with "elf-only" serves no purpose. + + + +==================== changes in man-pages-4.09 ==================== + +released: 2016-12-12, munich + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +afzal mohammed +andrew clayton +carlos o'donell +christoph lameter +daniel baluta +daniel berrange +daniel wagner +darrick j. wong +dave hansen +dmitry v. levin +dr. tobias quathamer +elliott hughes +eric w. biederman +eugene syromyatnikov +florian weimer +heinrich schuchardt +igor liferenko +jakub wilk +jann horn +jeremy harris +kees cook +keno fischer +laurent georget +laurent georget +marcos mello +michael hausenblas +michael kerrisk +mike frysinger +mike galbraith +miroslav koskar +nikos mavrogiannopoulos +omar sandoval +pavel emelyanov +piotr kwapulinski +siddhesh poyarekar +theodore ts'o +vegard nossum +vincent lefevre +vince weaver +wainer dos santos moschetta +wang long +willy tarreau +zack weinberg + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +pkey_alloc.2 + dave hansen [michael kerrisk] + new page documenting pkey_alloc(2) and pkey_free(2) + +pthread_getattr_default_np.3 + michael kerrisk + new page documenting pthread_getattr_default_np(3) and pthread_setattr_default_np(3) + +strfromd.3 + wainer dos santos moschetta + new page documenting strfromd(3), strfromf(3), and strfroml(3) + the iso/iec ts 18661-1 specifies the strfrom() class + of functions that convert a float-point value to string. + +fuse.4 + keno fischer [michael kerrisk] + new page describing /dev/fuse + this is my writeup of a basic description of /dev/fuse after + playing with it for a few hours today. it is of course woefully + incomplete, and since i neither have a use case nor am working + on this code, i will not be in a position to expand it in the + near future. however, i'm hoping this could still serve as a + handy reference for others looking at this interface. + + [mtk: notwithstanding the incompleteness of this page, + it's a good base for future extension.] + +tmpfs.5 + michael kerrisk + new page documenting the tmpfs filesystem + +pkeys.7 + dave hansen [michael kerrisk] + new page with overview of memory protection keys + +random.7 + michael kerrisk [theodore ts'o, nikos mavrogiannopoulos, laurent georget] + new page providing an overview of interfaces for obtaining randomness + contains material extracted from getrandom(2) and random(4), + as well as new material. + +sock_diag.7 + pavel emelyanov, dmitry v. levin + new page documenting netlink_sock_diag interface + +close.2 +getpriority.2 +nice.2 +timer_create.2 +timerfd_create.2 +random.4 +elf.5 +proc.5 +sched.7 + various authors + these pages also saw substantial updates, as described under + "changes to individual pages". + + +newly documented interfaces in existing pages +--------------------------------------------- + +mmap.2 + michael kerrisk + add (much) more detail on map_growsdown + +mprotect.2 + dave hansen + document the new pkey_mprotect() system call + eugene syromyatnikov + document prot_sem, prot_sao, prot_growsup, and prot_growsdown + +prctl.2 + eugene syromyatnikov + document pr_set_fp_mode and pr_get_fp_mode + +perf_event_open.2 + vince weaver + perf_record_switch support + linux 4.3 introduced two new record types for recording context + switches: perf_record_switch and perf_record_switch_cpu_wide. + vince weaver + add perf_sample_branch_call branch sample type + vince weaver + perf_sample_branch_ind_jump branch_sample_type + linux 4.2 added a new branch_sample_type: perf_sample_branch_ind_jump + vince weaver + document perf_record_misc_proc_map_parse_timeout + vince weaver + document sample_max_stack and /proc/sys/kernel/perf_event_max_stack + linux 4.8 added a new sample_max_stack parameter, as well as + /proc/sys/kernel/perf_event_max_stack which limits it and a new + eoverflow error return. + dave hansen + perf_record_lost_samples record type + linux 4.2 added a new record type: perf_record_lost_samples + it is generated when hardware samples (currently only intel pebs) + are lost. + +ptrace.2 + michael kerrisk + document ptrace_seccomp_get_filter + michael kerrisk + document ptrace_get_thread_area and ptrace_set_thread_area + +namespaces.7 + michael kerrisk [eric w. biederman] + document the ns_get_userns and ns_get_parent ioctl() operations + +sched.7 + michael kerrisk [mike galbraith] + document the autogroup feature + includes documenting autogroup nice value + michael kerrisk + autogrouping breaks traditional semantics of nice in many cases + when autogrouping is enabled (the default in many distros) + there are many traditional use cases where the nice value + ceases to have any effect. + michael kerrisk + add a subsection on nice value and group scheduling + + +new and changed links +--------------------- + +killpg.2 + michael kerrisk + new link to relocated killpg(3) page + +pkey_free.2 + michael kerrisk + new link to new pkey_alloc(2) page + +pkey_mprotect.2 + michael kerrisk + new link to mprotect(2) + +pthread_setattr_default_np.3 + michael kerrisk + new link to new pthread_getattr_default_np.3 + +strfromf.3 + wainer dos santos moschetta + new link to strfromd(3) + +strfroml.3 + wainer dos santos moschetta + new link to strfromd(3) + + +global changes +-------------- + +various pages + michael kerrisk + remove ancient libc4 and libc5 details + it's nearly 20 years now since linux libc went away. + remove some ancient details from the pages. + +various pages + michael kerrisk + add cross references to new tmpfs(5) page + +various pages + michael kerrisk + change section number from 2 to 3 in killpg() references + + +changes to individual pages +--------------------------- + +accept.2 + michael kerrisk + remove editorializing comments about 'socklen_t' + michael kerrisk + simplify the discussion of 'socklen_t' + we don't really need to list the old oses in this discussion. + +adjtimex.2 +clock_getres.2 +gettimeofday.2 + michael kerrisk + see also: add hwclock(8) + +bind.2 +connect.2 +getpeername.2 +getsockname.2 +getsockopt.2 + michael kerrisk + replace discussion of 'socklen_t' with reference to accept(2) + the discussion of 'socklen_t' editorializes and is repeated + across several pages. replace it with a reference to accept(2), + where some details about this type are provided. + +chmod.2 + michael kerrisk + see also: add chmod(1) + +chown.2 + michael kerrisk + see also: add chgrp(1) and chown(1) + +chroot.2 + michael kerrisk + see also: add chroot(1) + +clone.2 + michael kerrisk + the clone_*_settid operations store tid before return to user space + clone_parent_settid and clone_child_settid store the new + tid before clone() returns to user space + +close.2 + michael kerrisk [daniel wagner] + rework and greatly extend discussion of error handling + further clarify that an error return should be used only + for diagnostic or remedial purposes. + michael kerrisk + other unix implementations also close the fd, even if reporting an error + looking at some historical source code suggests + that the "close() always closes regardless of error return" + behavior has a long history, predating even posix.1-1990. + michael kerrisk + note that future posix plans to require that the fd is closed on error + see http://austingroupbugs.net/view.php?id=529#c1200. + michael kerrisk + clarify the variation in eintr behavior per posix and other systems + +fallocate.2 + darrick j. wong + document behavior with shared blocks + note that falloc_fl_unshare may use cow to unshare blocks to + guarantee that a disk write won't fail with enospc. + +fanotify_mark.2 + heinrich schuchardt + mention fan_q_overflow + to receive overflow events it is necessary to set this bit + in fanotify_mark(). + +fcntl.2 + michael kerrisk + f_getpipe_sz allocates next power-of-2 multiple of requested size + add some detail about current implementation, since this helps + the user understand the effect of the user pipe limits added in + linux 4.5 (described in pipe(7)). + michael kerrisk + add eperm that occurs for f_setpipe_sz when user pipe limit is reached + +fideduperange.2 + darrick j. wong [omar sandoval] + fix the discussion of maximum sizes + fix the discussion of the limitations on the dest_count and + src_length parameters to the fideduperange ioctl() to reflect + what's actually in the kernel. + +fsync.2 + michael kerrisk + see also: add fileno(3) + fileno(3) is useful if one is combining fflush(3)/fclose(3) + and fsync(2). + michael kerrisk + see also: add fflush(3) + +getgroups.2 + andrew clayton + ftm requirements fix for setgroups(2) + +gethostname.2 + michael kerrisk + see also: add hostname(1) + +get_mempolicy.2 + michael kerrisk + note that 'addr' must be null when 'flags' is 0 + +getpriority.2 + michael kerrisk + warn that autogrouping voids the effect of 'nice' in many cases + refer the reader to sched(7) for the details. + michael kerrisk + expand discussion of getpriority() return value + michael kerrisk + the nice value supplied to setpriority() is clamped + note that the nice value supplied to setpriority() is clamped + to the permitted range. + michael kerrisk + improve description of setpriority() return value + +getpriority.2 +sched.7 + michael kerrisk + move nice value details from getpriority(2) to sched(7) + centralizing these details in sched(7) is more logical. + +getrandom.2 +random.4 + michael kerrisk + consolidate and improve discussion on usage of randomness + currently, recommendations on how to consume randomness are + spread across both getrandom(2) and random(4) and the general + opinion seems to be that the text in getrandom(2) does a + somewhat better job. consolidate the discussion to a single + page (getrandom(2)) and address some of the concerns + expressed about the existing text in random(4). + [some of this text ultimately made its way into the new + random(7) page.] + +getrandom.2 + michael kerrisk + remove material incorporated into random(7) + michael kerrisk + note advantages of fact that getrandom() doesn't use file descriptors + michael kerrisk + clarify that getrandom() is not "reading" from /dev/{random,urandom} + +getrlimit.2 + michael kerrisk + refer to sched(7) in discussion of rlimit_rtprio and rlimit_rttime + michael kerrisk + describe the range of the rlimit_nice limit + michael kerrisk + refer to sched(7) in the discussion of rlimit_nice + michael kerrisk + see also: add credentials(7) + +ioctl_ficlonerange.2 +ioctl_fideduperange.2 + darrick j. wong + clarify the behavior of the fideduperange ioctl + +kill.2 + michael kerrisk + see also: add kill(1) + +mbind.2 + michael kerrisk [christoph lameter] + memory policy is a per-thread attribute, not a per-process attribute + +mbind.2 +set_mempolicy.2 + piotr kwapulinski [christoph lameter, michael kerrisk] + add mpol_local numa memory policy documentation + +mount.2 + michael kerrisk + see also: add mountpoint(1) + +mprotect.2 + michael kerrisk + conforming to: note that pkey_mprotect() is linux-specific + +nice.2 + michael kerrisk + warn that autogrouping voids the effect of 'nice' in many cases + michael kerrisk + conforming to: remove an ancient svr4 detail on errno values + michael kerrisk + rework discussion of nice() return value and standards conformance + make the text a little clearer. in particular, clarify that the + raw system call (still) returns 0 on success. + michael kerrisk + clarify the range of the nice value, and note that it is clamped + michael kerrisk + add mention of rlimit_nice + michael kerrisk + move discussion of handling the -1 success return to return value + this detail was rather hidden in notes. also, rework the text + a little. + michael kerrisk + clarify that nice() changes the nice value of the calling *thread* + michael kerrisk + add "c library/kernel differences" subsection heading + michael kerrisk + add reference to sched(7) for further details on the nice value + +open.2 + michael kerrisk + ubifs supports o_tmpfile starting with linux 4.9 + michael kerrisk + document enomem that occurs when opening fifo because of pipe hard limit + +perf_event_open.2 + vince weaver + add cycles field in lbr records + linux 4.3 added a cycles field to the perf_sample_branch_stack + last branch records. + vince weaver + update time_shift sample code + linux 4.3 improved the accuracy of the clock/ns conversion routines. + michael kerrisk + clarify the use of signals for capturing overflow events + +pipe.2 + michael kerrisk + add enfile error for user pipe hard limit reached + +prctl.2 + eugene syromyatnikov + some additional details regarding the pr_get_unaligned operation + eugene syromyatnikov + note the output buffer size for pr_get_tid_address operation on x32/n32 + michael kerrisk + remove numeric definitions of pr_fp_mode_fr and pr_fp_mode_fre bits + +ptrace.2 + keno fischer + document the behavior of ptrace_sysemu stops + keno fischer + expand documentation ptrace_event_seccomp traps + in linux 4.8, the order of ptrace_event_seccomp and + syscall-entry-stops was reversed. document both behaviors and + their interaction with the various forms of restart. + +quotactl.2 + eugene syromyatnikov + describe q_xquotasync, which is present but no-op in recent kernels + +reboot.2 + wang long + note errors for invalid commands inside a pid namespace + +sched_setattr.2 + michael kerrisk + fix cross reference for further info on the nice value + the information moved from getpriority(2) to sched(7). + +sched_setscheduler.2 + michael kerrisk [daniel berrange] + mention sched_deadline + give the reader a clue that there is another policy + available that can't be set via sched_setscheduler(2). + +seccomp.2 + jann horn + document changed interaction with ptrace + before kernel 4.8, the seccomp check will not be run again + after the tracer is notified. fixed in kernel 4.9. + michael kerrisk + notes: mention ptrace(ptrace_seccomp_get_filter) to dump seccomp filters + +set_mempolicy.2 + michael kerrisk + reformat list of modes + +setsid.2 + michael kerrisk + improve wording of text on calling setsid() after fork()+_exit() + michael kerrisk + see also: add sched(7) + list sched(7), because setsid(2) is part of the machinery + of autogrouping. + +sigaction.2 + dave hansen + further documentation of segv_pkuerr + +signalfd.2 + michael kerrisk + document ssi_addr_lsb field of signalfd_siginfo + +symlink.2 + michael kerrisk + see also: add namei(1) + +sync_file_range.2 + michael kerrisk + fix description for espipe error + a file descriptor can't refer to a symbolic link. + +syscalls.2 + michael kerrisk + add pkey_alloc(), pkey_free(), and pkey_mprotect() + new system calls in linux 4.9. + michael kerrisk + add ppc_swapcontext(2) + +timer_create.2 + michael kerrisk + document clock_boottime + michael kerrisk + document clock_realtime_alarm and clock_boottime_alarm + +timerfd_create.2 + michael kerrisk + document clock_boottime, clock_realtime_alarm, and clock_boottime_alarm + michael kerrisk + document tfd_timer_cancel_on_set + michael kerrisk + rework discussion on relative and absolute timers + +unlink.2 + michael kerrisk + see also: add unlink(2) + +utime.2 +utimensat.2 + michael kerrisk + see also: add touch(1) + +wait.2 + michael kerrisk + on some architectures, waitpid() is a wrapper that calls wait4(). + +atof.3 + wainer dos santos moschetta + see also: add strfromd(3) + +ctime.3 + michael kerrisk + add errors section + michael kerrisk + return value: describe return values more explicitly + +errno.3 + michael kerrisk [igor liferenko] + add glibc error text for eilseq + +fclose.3 +fflush.3 + michael kerrisk + see also: add fileno(2) + +getlogin.3 + michael kerrisk + remove deprecated _reentrant from ftm requirements for getlogin_r() + michael kerrisk + see also: add logname(1) + +isalpha.3 + michael kerrisk + note circumstances where 'c' must be cast to 'unsigned char' + +killpg.3 + michael kerrisk + move killpg.2 from section to section 3 + +mallopt.3 + michael kerrisk [siddhesh poyarekar] + document 0 as default value of m_arena_max and explain its meaning + michael kerrisk + improve description of m_arena_test + michael kerrisk + document default value for m_arena_test + michael kerrisk + note default value of m_perturb + +mbsnrtowcs.3 + michael kerrisk [igor liferenko] + note behavior of mbsnrtowcs() for an incomplete character + note the behavior of mbsnrtowcs() when an incomplete character + is found at end of the input buffer. + +mbstowcs.3 +wcstombs.3 + michael kerrisk [igor liferenko] + improve language relating to "initial state" + see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=839705 + +mbstowcs.3 + michael kerrisk [igor liferenko] + add missing include to example program + see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=845172 + +mq_close.3 + michael kerrisk + description: add reference to mq_notify(3) + +mq_open.3 + eugene syromyatnikov + clarification regarding usage of mq_flags attribute in mq_open() + +mq_receive.3 +mq_send.3 + eugene syromyatnikov + clarification regarding reasons behind ebadf + +printf.3 + wainer dos santos moschetta + see also: add strfromd(3) + +pthread_attr_init.3 + michael kerrisk + see also: add pthread_setattr_default_np(3) + +pthread_create.3 + michael kerrisk + see also: add pthread_setattr_default_np(3) + +ptsname.3 + michael kerrisk + note that ptsname_r() is proposed for future inclusion in posix.1 + michael kerrisk + conforming to:: clarify that only ptsname() is standardized (so far) + +remainder.3 + michael kerrisk + note fix to remainder(nan(""), 0) handling + the bug https://www.sourceware.org/bugzilla/show_bug.cgi?id=6779 + has been fixed in glibc 2.15. + michael kerrisk + document fixes for edom handling for range errors + the bug http://sources.redhat.com/bugzilla/show_bug.cgi?id=6783 + was fixed in glibc 2.15. + +setjmp.3 + michael kerrisk + _bsd_source must be *explicitly* defined to get bsd setjmp() semantics + +strtod.3 + wainer dos santos moschetta + see also: add strfromd(3) + +tgamma.3 + michael kerrisk + document fixes to give erange for underflow range error + the bug https://www.sourceware.org/bugzilla/show_bug.cgi?id=6810 + was fixed in glibc 2.19. + +timegm.3 + michael kerrisk + add errors section + michael kerrisk [vincent lefevre] + add return value section + +tmpnam.3 + michael kerrisk + properly document tmpnam_r(3) + +toupper.3 + michael kerrisk + note circumstances where 'c' must be cast to 'unsigned char' + +ttyname.3 + michael kerrisk + see also: add tty(1) + +console_ioctl.4 + michael kerrisk + add brief descriptive text for kdgkbmode modes + miroslav koskar + add k_off keyboard mode + +random.4 + michael kerrisk + add reference to new random(7) page + michael kerrisk + rework formatting of /proc interfaces + make the information easier to parse by formatting the file + descriptions as hanging lists. no significant content changes. + nikos mavrogiannopoulos [laurent georget] + provide a more accurate description of /dev/urandom + this documents the "property" of /dev/urandom of being able to + serve numbers prior to pool being initialized, and removes any + suggested usages of /dev/random which are disputable + (i.e., one-time pad). document the fact /dev/random is only + suitable for applications which can afford indeterminate delays + since very few applications can do so. smooth the alarming + language about a theoretical attack, and mention that its + security depends on the cryptographic primitives used by the + kernel, as well as the total entropy gathered. + michael kerrisk [laurent georget, theodore ts'o] + improve discussion of /dev/urandom, blocking reads, and signals + the text currently states that o_nonblock has no effect for + /dev/urandom, which is true. it also says that reads from + /dev/urandom are nonblocking. this is at the least confusing. + if one attempts large reads (say 10mb) from /dev/urandom + there is an appreciable delay, and interruption by a signal + handler will result in a short read. amend the text to + reflect this. + +elf.5 + mike frysinger + add subsection headers at major points + the current pages dumps all the content into one big description + with no real visual break up between logically independent + sections. add some subsection headers to make it easier to + read and scan. + mike frysinger + document notes + document the elf{32,64}_nhdr structure, the sections/segments that + contain notes, and how to interpret them. i've been lazy and only + included the gnu extensions here, especially as others are not + defined in the elf.h header file as shipped by glibc. + +filesystems.5 + michael kerrisk + see also: add fuse(4) + +proc.5 + dave hansen + describe new protectionkey 'smaps' field + michael kerrisk + add example protectionkey output for 'smaps' file + michael kerrisk + add pointers to sched(7) for autogroup files + sched(7) describes /proc/sys/kernel/sched_autogroup_enabled + and /proc/pid/autogroup. + michael kerrisk + add /proc/sys/fs/pipe-user-pages-{hard,soft} entries + michael kerrisk + improve description of the kernelpagesize and mmupagesize 'smaps' fields + michael kerrisk + rework 'smaps' protectionkey text and add some details + michael kerrisk + mention lslocks(8) in discussion of /proc/locks + michael kerrisk + describe shmem field of /proc/meminfo + michael kerrisk + rework 'smaps' vmflags text, and add kernel version and example output + +proc.5 +pipe.7 + michael kerrisk + move /proc/sys/fs/pipe-max-size content from proc(5) to pipe(7) + +resolv.conf.5 + carlos o'donell [florian weimer] + timeout does not map to resolver api calls + +utmp.5 + michael kerrisk + see also: add users(1) + +capabilities.7 + michael kerrisk + cap_sys_admin governs ptrace(2) ptrace_seccomp_get_filter + michael kerrisk + cap_sys_admin allows privileged ioctl() operations on /dev/random + +cgroups.7 + michael kerrisk + add details on 'cpu' cfs bandwidth control + +credentials.7 + michael kerrisk + see also: add setpriv(1) + michael kerrisk + see also: add shadow(5) + +feature_test_macros.7 + michael kerrisk [zack weinberg] + note that _reentrant and _thread_safe are now deprecated + michael kerrisk + note that "cc -pthread" defines _reentrant + +inotify.7 + michael kerrisk + note a subtlety of event generation when monitoring a directory + +libc.7 + michael kerrisk + add a note on why glibc 2.x uses the soname libc.so.6 + michael kerrisk + add a few historical details on linux libc4 and libc5 + just for historical interest. details taken from + http://www.linux-m68k.org/faq/glibcinfo.html. + +mdoc.7 + michael kerrisk + add a cross-reference to groff_mdoc(7) + +mount_namespaces.7 + michael kerrisk + see also: add user_namespaces(7) + +mount_namespaces.7 +user_namespaces.7 + michael kerrisk + migrate subsection on mount restrictions to mount_namespaces(7) + this section material in the user_namespaces(7) page was written + before the creation of the mount_namespaces(7) manual page. + nowadays, this material properly belongs in the newer page. + +netlink.7 + dmitry v. levin + document netlink_inet_diag rename to netlink_sock_diag + dmitry v. levin + add references to sock_diag(7) + +pid_namespaces.7 + michael kerrisk + refer to namespaces(7) for information about ns_get_parent + +pipe.7 + michael kerrisk, vegard nossum [vegard nossum] + document /proc files controlling memory usage by pipes + document /proc/sys/fs/pipe-max-size and + /proc/sys/fs/pipe-user-pages-{soft,hard}. + michael kerrisk + document pre-linux 4.9 bugs in pipe limit checking + +sched.7 + michael kerrisk + add a new introductory paragraph describing the nice value + michael kerrisk + add more precise details on cfs's treatment of the nice value + michael kerrisk + mention rlimit_nice in the discussion of the nice value + michael kerrisk + notes: mention cgroups cpu controller + michael kerrisk + add introductory sentence mentioning cfs scheduler + michael kerrisk + add nice(2), getpriority(2), and setpriority(2) to api list + michael kerrisk + make it clearer that sched_other is always scheduled below real-time + michael kerrisk + give the page a more generic name + the page isn't just about apis. + +standards.7 + michael kerrisk + posix.1-2016 (posix.1-2008 tc2) has now been released + +symlink.7 + michael kerrisk + see also: add namei(1) + +uri.7 + jakub wilk + use "example.com" as example domain + +user_namespaces.7 + michael kerrisk + add reference to namespaces(7) for ns_get_userns operation + michael kerrisk + add reference to namespaces(7) for ns_get_parent operation + + +==================== changes in man-pages-4.10 ==================== + +released: 2017-03-13, paris + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +adam martindale +alex +anders thulin +andreas gruenbacher +brian masney +casey schaufler +david howells +erik kline +erik roland van der meer +eugene syromyatnikov +fabjan sukalia +heinrich schuchardt +helmut eller +hugo guiroux +ian jackson +jakub wilk +jann horn +jan ziak <0xe2.0x9a.0x9b@gmail.com> +john wiersba +jon jensen +kai noda +kasaki motohiro +keno fischer +kent fredic +krzysztof kulakowski +maik zumstrull +mat martineau +michael kerrisk +mike frysinger +nadav har'el +namhyung kim +nicolas biscos +omar sandoval +paul fee +reverend homer +rob landley +sergey polovko +steven luo +tadeusz struk +vincent bernat +vivenzio pagliari +wainer dos santos moschetta +willy tarreau + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +add_key.2 + michael kerrisk [eugene syromyatnikov, david howells] + major improvements and additions + the page has doubled in length. + +ioctl_iflags.2 + michael kerrisk + new page describing inode flags and ioctl() operations + +ioctl_ns.2 + michael kerrisk + new page created by splitting ioctl(2) operations out of namespaces(7) + +keyctl.2 + michael kerrisk, eugene syromyatnikov [david howells, mat martineau] + a vast number of additions and improvements + the page has gone from somewhat over 100 lines to well over + 1000 lines and now more or less documents the complete interface + provided by this system call. + +getentropy.3 + michael kerrisk + new page documenting getentropy(3) + getentropy(3) is added to glibc in version 2.25. + +keyrings.7 + david howells + new page (written by david howells) adopted from keyutils + since this page documents kernel-user-space interfaces, + it makes sense to have it as part of man-pages, rather + than the keyutils package. + michael kerrisk [eugene syromyatnikov, david howells] + very many additions and improvements + michael kerrisk + document /proc/keys + michael kerrisk + document /proc/sys/kernel/keys/persistent_keyring_expiry + michael kerrisk + document /proc/key-users + michael kerrisk + document /proc/sys/kernel/keys/gc_delay + michael kerrisk + document /proc files that define key quotas + +persistent-keyring.7 + michael kerrisk + new page (written by david howells) adopted from keyutils + since this page documents kernel-user-space interfaces, + it makes sense to have it as part of man-pages, rather + than the keyutils package. + michael kerrisk + various clean-ups and additions + +process-keyring.7 + michael kerrisk + new page (written by david howells) adopted from keyutils + since this page documents kernel-user-space interfaces, + it makes sense to have it as part of man-pages, rather + than the keyutils package. + michael kerrisk + various additions and improvements + +request_key.2 + michael kerrisk, eugene syromyatnikov [david howells] + very many additions and improvements + the page is now three times its former length. + +session-keyring.7 + michael kerrisk + new page (written by david howells) adopted from keyutils + since this page documents kernel-user-space interfaces, + it makes sense to have it as part of man-pages, rather + than the keyutils package. + michael kerrisk + various reworking and additions + +signal-safety.7 + michael kerrisk + new page created by migrating the signal-safety discussion from + signal(7). along the way some more details got added. + michael kerrisk [kasaki motohiro] + note async-signal-safety problems caused by pthread_atfork() + see https://bugzilla.kernel.org/show_bug.cgi?id=25292 + michael kerrisk [kasaki motohiro] + note glibc deviations from posix requirements + see https://bugzilla.kernel.org/show_bug.cgi?id=25292 + +thread-keyring.7 + michael kerrisk + new page (written by david howells) adopted from keyutils + since this page documents kernel-user-space interfaces, + it makes sense to have it as part of man-pages, rather + than the keyutils package. + michael kerrisk + various rewordings and additions + +user-keyring.7 + michael kerrisk + new page (written by david howells) adopted from keyutils + since this page documents kernel-user-space interfaces, + it makes sense to have it as part of man-pages, rather + than the keyutils package. + michael kerrisk + various reworking and improvements + +user-session-keyring.7 + michael kerrisk + new page (written by david howells) adopted from keyutils + since this page documents kernel-user-space interfaces, + it makes sense to have it as part of man-pages, rather + than the keyutils package. + michael kerrisk + various rewordings and additions + + +newly documented interfaces in existing pages +--------------------------------------------- + +bzero.3 + michael kerrisk + document explicit_bzero() (new in glibc 2.25) + also, reword the description of bzero somewhat. + +proc.5 + michael kerrisk + document /proc/sys/vm/user_reserve_kbytes + michael kerrisk + document /proc/sys/vm/admin_reserve_kbytes + michael kerrisk + document /proc/sys/fs/mount-max + michael kerrisk + document /proc/pid/status 'nonewprivs' field + + +new and changed links +--------------------- + +explicit_bzero.3 + michael kerrisk + new link to bzero.3 + + +changes to individual pages +--------------------------- + +chmod.2 + michael kerrisk + errors: add eperm error for immutable/append-only file + +chown.2 + michael kerrisk + errors: add eperm error for immutable/append-only file + +chroot.2 + michael kerrisk + see also: add switch_root(8) + +clock_getres.2 + michael kerrisk + note posix.1 requirements re relative time services and clock_realtime + +clone.2 + michael kerrisk + clone() does not execute fork handlers + +execve.2 + michael kerrisk + rework text describing when effective ids aren't transformed by execve() + michael kerrisk + file capabilities can be ignored for the same reasons as set-uid/set-gid + michael kerrisk + the 'no_new_privs' bit inhibits transformations of the effective ids + +fork.2 + michael kerrisk + cgroup pids controller may also be trigger for eagain error + +fsync.2 + michael kerrisk + see also: add posix_fadvise(2) + +getrandom.2 + michael kerrisk + remove getentropy(3) details and defer to new getentropy(3) page + michael kerrisk + starting with glibc 2.25, getrandom() is now declared in + michael kerrisk + glibc support was added in version 2.25 + +getrlimit.2 + michael kerrisk + document role of rlimit_nofile for fd passing over unix sockets + +getxattr.2 +listxattr.2 + andreas gruenbacher + document e2big errors + +inotify_add_watch.2 + michael kerrisk + note "inode" as a synonym for "filesystem object" + consistent with clarifications just made in inotify(7). + +ioctl.2 + michael kerrisk + see also: add ioctl_ns(2), ioctl_iflags(2) + +ioctl_fat.2 + brian masney + correctly reference volume id instead of volume label + +kcmp.2 + michael kerrisk + mention the clone(2) flags relating to various kcmp() 'type' values + michael kerrisk + kcmp_file: note reasons why fds may refer to same open file description + +link.2 + michael kerrisk + when using linkat() at_empty_path, 'olddirfd' must not be a directory + michael kerrisk + errors: add eperm for immutable/append-only files + michael kerrisk + note limits where emlink is encountered on ext4 and btrfs + +listxattr.2 + michael kerrisk + eliminate extra e2big error text + andreas' patch added a second description of e2big that + was (mostly) more detailed than the existing text. combine + the two texts. + +lseek.2 + michael kerrisk + o_append overrides the effect of lseek() when doing file writes + michael kerrisk + remove ancient info about whence values and return values on old systems + michael kerrisk + remove slightly bogus advice about race conditions + the page already (by now) contains a reference to open(2) + for a discussion of open file descriptions. leave it at that, + since the reader can then deduce how things work. + +madvise.2 + michael kerrisk + note that madvise() is generally about improving performance + +mbind.2 + krzysztof kulakowski [michael kerrisk] + update mpol_bind description + the behavior of mpol_bind changed in linux 2.6.26. + +mincore.2 + michael kerrisk + see also: add madvise(2), posix_fadvise(2), posix_madvise(3) + +mlock.2 + michael kerrisk + note pre-4.9 bug in rlimit_memlock accounting for overlapping locks + michael kerrisk + see also: add mincore(2) + +mmap.2 + michael kerrisk + mincore(2) can be used to discover which pages of a mapping are resident + +mount.2 + michael kerrisk [rob landley] + refer to mount_namespaces(7) for details of default propagation type + +nanosleep.2 + michael kerrisk + describe "creeping sleep" problem + nanosleep() has a problem if used in a program that catches + signals and those signals are delivered at a very high rate. + describe the problem, and note that clock_nanosleep(2) + provides a solution. + michael kerrisk + bugs: explicitly note that the linux 2.4 bug was fixed in linux 2.6 + +open.2 + michael kerrisk + make it clear that o_append implies atomicity + michael kerrisk + clarify distinction between file creation flags and file status flags + michael kerrisk + note ambiguity of eloop error when using o_nofollow + michael kerrisk + restructure o_nofollow text for easier parsing + michael kerrisk + clarify that o_nofollow is now in posix + +poll.2 +select.2 + nicolas biscos + add a reference to the sigset discussion in sigprocmask(2) + a little while back, i added a note to sigprocmask.2 that + discussed the difference between the libc's and the kernel's + sigset_t structures. i added that note, because i saw this being + done wrong in a tool tracing system calls (causing subtle bugs). + as it turns out, the same bugs existed for ppoll and pselect, for + the same reason. i'm hoping by adding the reference here, future + writers of similar tools will find that discussion and not make + the same mistake. + +posix_fadvise.2 + michael kerrisk + mention /proc/sys/vm/drop_caches + it may be helpful for the reader of this page to know about + /proc/sys/vm/drop_caches. + michael kerrisk + reorganize some text + details for various flags were hidden under notes. + move them to description, to make the details more + obvious. + michael kerrisk + one can use open(2) + mmap(2) + mincore(2) as a 'fincore' + note that open(2) + mmap(2) + mincore(2) can be used to get a view + of which pages of a file are currently cached. + michael kerrisk [maik zumstrull] + note that posix_fadv_dontneed *may* try to write back dirty pages + michael kerrisk + see also: mincore(2) + +prctl.2 + michael kerrisk + clarify that the ambient capability set is per-thread + keno fischer + be more precise in what causes dumpable to reset + michael kerrisk + the no_new_privs setting is per-thread (not per-process) + michael kerrisk + mention /proc/pid/status 'nonewprivs' field + michael kerrisk + add reference to seccomp(2) in discussion of pr_set_no_new_privs + +ptrace.2 + omar sandoval + clarify description of ptrace_o_exitkill + +read.2 + michael kerrisk [kai noda] + rework text in description that talks about limits for 'count' + see https://bugzilla.kernel.org/show_bug.cgi?id=86061 + michael kerrisk [steven luo] + remove crufty text about eintr and partial read + remove bogus text saying that posix permits partial read + to return -1/eintr on interrupt by a signal handler. + that statement already ceased to be true in susv1 (1995)! + + see https://bugzilla.kernel.org/show_bug.cgi?id=193111 + +readv.2 + michael kerrisk + remove generic advice about mixing stdio and syscalls on same file + there is nothing specific to readv()/writev() about this advice. + +recv.2 + michael kerrisk [vincent bernat] + remove duplicate paragraph + man-pages-1.34 included changes that duplicated an existing + paragraph. remove that duplicate. + michael kerrisk + see also: add ip(7), ipv6(7), tcp(7), udp(7), unix(7) + +remap_file_pages.2 + michael kerrisk + remap_file_pages() has been replaced by a slower in-kernel emulation + +send.2 + michael kerrisk + see also: add ipv6(7), socket(7), unix(7) + +setxattr.2 + michael kerrisk + errors: add eperm for immutable/append-only files + +signalfd.2 + michael kerrisk + signalfd() doesn't play well with helper programs spawned by libraries + see https://lwn.net/articles/415684/. + michael kerrisk + signalfd can't be used to receive synchronously generated signals + signals such as the sigsegv that results from an invalid + memory access can be caught only with a handler. + +stat.2 + michael kerrisk + example: extend program to also show id of the containing device + michael kerrisk + notes: mention fstatat() at_no_automount in discussion of automounting + +statfs.2 + namhyung kim + add more filesystem types + add missing magic numbers from /usr/include/linux/magic.h + +syscall.2 + mike frysinger + add endian details with 64-bit splitting + architectures that split 64-bit values across register pairs + usually do so according to their c abi calling convention (which + means endianness). add some notes to that effect, and change the + readahead example to show a little endian example (since that is + way more common than big endian). + + also start a new list of syscalls that this issue does not apply + to. + mike frysinger + note parisc handling of aligned register pairs + while parisc would normally have the same behavior as arm/powerpc, + they decide to write shim syscall stubs to unpack/realign rather + than expose the padding to userspace. + +tkill.2 + jann horn + document eagain error for real-time signals + +truncate.2 + michael kerrisk + note use of ftruncate() for posix shared memory objects + +unlink.2 + michael kerrisk + errors: add eperm error for immutable/read-only files + +vfork.2 + michael kerrisk + explain why the child should not call exit(3) + michael kerrisk + another reason to use vfork() is to avoid overcommitting memory + michael kerrisk + note some caveats re the use of vfork() + inspired by rich felker's post at http://ewontfix.com/7/. + see also https://sourceware.org/bugzilla/show_bug.cgi?id=14749 and + see also https://sourceware.org/bugzilla/show_bug.cgi?id=14750. + michael kerrisk + see also: add _exit(2) + +write.2 + michael kerrisk [kai noda] + alert the reader that there is a limit on 'count' + see https://bugzilla.kernel.org/show_bug.cgi?id=86061 + +aio_suspend.3 + michael kerrisk + note that the glibc implementation is not async-signal-safe + see https://sourceware.org/bugzilla/show_bug.cgi?id=13172 + +backtrace.3 + michael kerrisk + see also: add addr2line(1) and gdb(1) + +bcmp.3 +bcopy.3 +bzero.3 +memccpy.3 +memchr.3 +memcmp.3 +memcpy.3 +memfrob.3 +memmem.3 +memmove.3 +memset.3 + michael kerrisk + see also: add bstring(3) + +exec.3 + michael kerrisk + execl() and execle() were not async-signal-safe before glibc 2.24 + +fopen.3 + michael kerrisk [helmut eller] + describe freopen() behavior for null pathname argument + see https://bugzilla.kernel.org/show_bug.cgi?id=191261 + michael kerrisk + note the open(2) flags that correspond to the 'mode' argument + michael kerrisk + change argument name: 'path' to 'pathname' + for consistency with open(2). + michael kerrisk + add subsection headings for each function + +fts.3 + michael kerrisk + use better argument name for fts_children() and fts_set() + michael kerrisk + fix minor error in ftsent structure definition + michael kerrisk + improve explanation of 'fts_errno' + michael kerrisk + give a hint that there are further fields in the ftsent structure + michael kerrisk + clarify meaning of zero as 'instr' value for fts_set() + +ftw.3 + michael kerrisk + correctly handle use of stat info for ftw_ns in example program + michael kerrisk + clarify that stat buffer is undefined for ftw_ns + +getline.3 + michael kerrisk + example: better error handling + michael kerrisk [kent fredic] + example: handle null bytes in input + jann horn + document enomem error case + see the error handling in libio/iogetdelim.c + michael kerrisk + example: specify file to be opened as command-line argument + michael kerrisk + use better variable name in example program + +getmntent.3 + michael kerrisk [anders thulin] + prefer '\\' as the escape to get a backslash + see https://bugzilla.kernel.org/show_bug.cgi?id=191611 + +getopt.3 + michael kerrisk + reword discussion of error handling and reporting + the existing description was hard to understand. break + it into a bullet list that separates out the details + in a manner that is easier to parse. + michael kerrisk + correct details of use of to get getopt() declaration + michael kerrisk [john wiersba] + remove some redundant text + +mq_open.3 + michael kerrisk [adam martindale] + include definition of the 'mq_attr' structure in this man page + make the reader's life a little easier by saving them from + having to refer to mq_getattr(3). + +mq_send.3 + michael kerrisk [adam martindale] + refer to mq_overview(7) for details on range of message priority + +__ppc_set_ppr_med.3 + wainer dos santos moschetta + note need for _arch_pwr8 macro + the _arch_pwr8 macro must be defined to get the + __ppc_set_ppr_very_low() and __ppc_set_ppr_med_high() + definitions. + +printf.3 + michael kerrisk + document nonstandard 'z' modifier + michael kerrisk + document 'q' length modifier + michael kerrisk [erik roland van der meer] + fix a small bug in example code + move the second call to va_end(ap) to above the if-block that + precedes it, so that the va_list 'ap' will be cleaned up in + all cases. + michael kerrisk [nadav har'el] + as a nonstandard extension, gnu treats 'll' and 'l' as synonyms + see https://bugzilla.kernel.org/show_bug.cgi?id=190341. + michael kerrisk + add references to setlocale(3) in discussions of locales + michael kerrisk + see also: remove bogus self reference (dprintf(3)) + +random.3 + michael kerrisk + relocate information of "optimal" value of initstate() 'n' argument + the information was a bit hidden in notes. + +random_r.3 + michael kerrisk [jan ziak] + 'buf.state' must be initialized to null before calling initstate_r() + see https://bugzilla.kernel.org/show_bug.cgi?id=192801. + michael kerrisk + add some usage notes for setstate_r() + michael kerrisk + note that 'buf' records a pointer to 'statebuf' + see https://sourceware.org/bugzilla/show_bug.cgi?id=3662. + michael kerrisk + add bugs section pointing out the weirdness of the initstate_r() api + +resolver.3 + michael kerrisk + res_aaonly, res_primary, res_nocheckname, res_keeptsig are deprecated + these options were never implemented; since glibc 2.25, they + are deprecated. + michael kerrisk + the res_noip6dotint is removed in glibc 2.25 + michael kerrisk + note that res_blast was unimplemented and is now deprecated + michael kerrisk + res_use_inet6 is deprecated since glibc 2.25 + michael kerrisk + res_usebstring was removed in glibc 2.25 + +resolver.3 +resolv.conf.5 + michael kerrisk + note that res_usebstring defaults to off + +scandir.3 + michael kerrisk [ian jackson] + fix errors in example program + see http://bugs.debian.org/848231. + michael kerrisk + improve logic of the example program + +scanf.3 + michael kerrisk + document the quote (') modifier for decimal conversions + +sem_post.3 +setjmp.3 + michael kerrisk + see also: add signal-safety(7) + +sem_wait.3 + michael kerrisk [fabjan sukalia] + remove statement that sa_restart does not cause restarting + this has not been true since linux 2.6.22. the description + of eintr maintains a reference to signal(7), which explains + the historical details. + + see https://bugzilla.kernel.org/show_bug.cgi?id=192071 + +sleep.3 + michael kerrisk [mike frysiner] + note that sleep() is implemented via nanosleep(2) + see https://bugzilla.kernel.org/show_bug.cgi?id=73371. + michael kerrisk [mike frysinger] + note that sleep() sleeps for a real-time number of seconds + see https://bugzilla.kernel.org/show_bug.cgi?id=73371. + michael kerrisk + convert bugs text to "portability notes" subsection + the existing text is not a bug, as such. + michael kerrisk + description: minor reworking + +strerror.3 + heinrich schuchardt + indicate reasonable buffer size for strerror_r() and strerror_l() + add a hint which buffer size is needed for + strerror_r() and strerror_l(). + +strverscmp.3 + michael kerrisk [vivenzio pagliari] + fix comparison error in example program + +system.3 + michael kerrisk + in the glibc implementation, fork handlers are not executed by system() + +random.4 + michael kerrisk [jon jensen] + note that entropy_avail will be a number in the range 0..4096 + +core.5 + michael kerrisk + clarify that dumping program's initial cwd is root directory + michael kerrisk + the target of core dump piping can also be a script + +filesystems.5 + michael kerrisk + see also: add btrfs(5), nfs(5), tmpfs(5) + +intro.5 + michael kerrisk + document the reality that by now section 5 also covers filesystems + there are by now, from various filesystem projects, various + pages in section 5 that document different filesystems. + change intro(5) to reflect that. + + documented after following: http://bugs.debian.org/847998 + +proc.5 + mike frysinger [michael kerrisk] + clarify /proc/pid/environ behavior + /proc/pid/environ reflects process environment at + *start* of program execution; it is set at time of execve(2) + michael kerrisk + add reference to slabinfo(5) in discussion of /proc/meminfo 'slab' field + michael kerrisk + add entries for "keys" files that refer reader to keyrings(7) + michael kerrisk + remove duplicate /proc/[pid]/seccomp entry + michael kerrisk + mention other system calls that create 'anon_inode' file descriptors + mention a few other system calls that create file descriptors + that display an 'anon_inode' symlink in /proc/pid/fd + michael kerrisk + add some detail on overcommit_memory value 1 + michael kerrisk + add reference to vdso(7) in discussion of /proc/pid/maps + +resolv.conf.5 + michael kerrisk + ip6-bytestring was removed in glibc 2.25 + michael kerrisk + the ipc-dotint and no-ip6-dotint options were removed in glibc 2.25 + michael kerrisk + the 'inet6' option is deprecated since glibc 2.25 + +slabinfo.5 + michael kerrisk + see also: add slabtop(1) + +capabilities.7 + michael kerrisk [casey schaufler] + add subsection with notes to kernel developers + provide some notes to kernel developers considering how to choose + which capability should govern a new kernel feature. + michael kerrisk + further enhance the recommendation against new uses of cap_sys_admin + michael kerrisk + explicitly point from cap_sys_admin to "notes for kernel developers" + michael kerrisk + add another case for cap_dac_read_search + michael kerrisk + refer to execve(2) for the reasons that file capabilities may be ignored + michael kerrisk + document a new use of cap_sys_resource + michael kerrisk + add some more operations governed by cap_sys_admin + michael kerrisk + adjust references to chattr(1) to point to ioctl_iflags(2) + +environ.7 + michael kerrisk + mention prctl(2) pr_set_mm_env_start and pr_set_mm_env_end operations + +inotify.7 + michael kerrisk + point out that inotify monitoring is inode based + +ip.7 + michael kerrisk + see also: add ip(8) + +man.7 +uri.7 + jakub wilk + use "www.kernel.org" in example urls + apparently www.kernelnotes.org is now a spam site. + +mount_namespaces.7 + michael kerrisk [rob landley] + rework the discussion of defaults for mount propagation types + add rather more detail. in particular, note the cases where the + default propagation type is ms_private vs ms_shared. + +namespaces.7 + michael kerrisk + example: fix an error in shell session + michael kerrisk + example: rename the example program + use a more generic name, since this program may be expanded + in various ways in the future. + michael kerrisk + see also: add ip-netns(8) + michael kerrisk + remove content split out into ioctl_ns(2) + +netlink.7 + michael kerrisk + netlink_ip6_fw went away in linux 3.5 + michael kerrisk + netlink_w1 went away in linux 2.6.18 + michael kerrisk + add netlink_scsitransport to list + michael kerrisk + add netlink_rdma to list + michael kerrisk + netlink_firewall was removed in linux 3.5 + michael kerrisk + netlink_nflog was removed in linux 3.17 + jakub wilk + update libnl homepage url + the original url is 404. + +pid_namespaces.7 +user_namespaces.7 + michael kerrisk + adjust references to namespaces(7) to ioctl_ns(2) + +pid_namespaces.7 + keno fischer + clone_sighand|clone_vm|clone_newpid is no longer disallowed + +pipe.7 + michael kerrisk + since linux 4.9, pipe-max-size is ceiling for the default pipe capacity + michael kerrisk + clarify that default pipe capacity is 16 pages + the statement that the default pipe capacity is 65536 bytes + is accurate only on systems where the page size is 4096b. + see the use of pipe_def_buffers in the kernel source. + +random.7 + michael kerrisk + mention getentropy(3) + michael kerrisk + see also: add getentropy(3) + michael kerrisk + see also: add getauxval(3) + a small hint to the reader that some random bytes arrive + in the auxiliary vector. + +signal.7 + michael kerrisk + sigsys: add reference to seccomp(2) + michael kerrisk + change description of sigsys to "bad system call" + this is the more typical definition. + michael kerrisk + sigpipe: add reference to pipe(7) + michael kerrisk + sigxfsz: add reference to setrlimit(2) + michael kerrisk + add a name for sigemt + michael kerrisk + sigxcpu: add reference to setrlimit(2) + michael kerrisk + migrated signal-safety discussion to new signal-safety(7) page + +unix.7 + michael kerrisk [sergey polovko] + since linux 3.4, unix domain sockets support msg_trunc + this was correctly noted in recv(2), but the unix(7) page + was not correspondingly updated for the linux 3.4 change. + michael kerrisk [willy tarreau] + document etoomanyrefs for scm_rights send exceeding rlimit_nofile limit + +user_namespaces.7 + michael kerrisk + change page cross reference: keyctl(2) ==> keyrings(7) + +ld.so.8 + michael kerrisk + ld_bind_not has effect only for function symbols + michael kerrisk + describe use of ld_debug with ld_bind_not + michael kerrisk + in secure mode, ld_audit restricts the libraries that it will load + michael kerrisk + ld_audit understands $origin, $lib, and $platform + + + +==================== changes in man-pages-4.11 ==================== + +released: 2017-05-03, baden, switzerland + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +alexander alemayhu +alexander miller +andrea arcangeli +andreas dilger +andrew clayton +arnd bergmann +ben dog +carlos o'donell +chema gonzalez +christian brauner +cyril hrubis +david howells +dmitry v. levin +florian weimer +francois saint-jacques +frank theile +georg sauthoff +ian abbott +jakub wilk +jan heberer +marcin ślusarz +marko myllynen +matthew wilcox +michael kerrisk +mike frysinger +mike rapoport +nicolas biscos +nicolas iooss +nikos mavrogiannopoulos +nominal animal +silvan jegen +stephan bergmann +walter harms +zack weinberg +丁贵强 + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +ioctl_userfaultfd.2 + michael kerrisk, mike rapoport + new page describing ioctl(2) operations for userfaultfd + +statx.2 + david howells, michael kerrisk [andreas dilger] + new page describing statx(2) system call added in linux 4.11 + +userfaultfd.2 + mike rapoport, michael kerrisk [andrea arcangeli] + new page describing userfaultfd(2) system call. + +pthread_atfork.3 + michael kerrisk + new page describing pthread_atfork(3) + +slabinfo.5 + michael kerrisk + rewrite to try to bring the content close to current reality + there's still gaps to fill in, but the existing page + was in any case hugely out of date. + +inode.7 + michael kerrisk + new page with information about inodes + david howells provided a statx(2) page that duplicated much of + the information from stat(2). avoid such duplication + by moving the common information in stat(2) and statx(2) + to a new page. + + +renamed pages +-------------- + +ioctl_console.2 + michael kerrisk + renamed from console_ioctl.4 + most ioctl() man pages are in section 2, so move this one there + for consistency. + michael kerrisk + note type of 'argp' for a various operations + for some commands, there was no clear statement about the type + of the 'argp' argument. + +ioctl_tty.2 + michael kerrisk + renamed from tty_ioctl(4) + all other ioctl(2) pages are in section 2. make this + page consistent. + michael kerrisk + packet mode state change events give pollpri events for poll(2) + + +newly documented interfaces in existing pages +--------------------------------------------- + +ioctl_ns.2 + michael kerrisk + document the ns_get_nstype operation added in linux 4.11 + michael kerrisk + document the ns_get_owner_uid operation added in linux 4.11 + +proc.5 + michael kerrisk + document /proc/sys/kernel/sched_child_runs_first + +namespaces.7 + michael kerrisk + document the /proc/sys/user/* files added in linux 4.9 + +socket.7 + francois saint-jacques, michael kerrisk + document so_incoming_cpu + + +new and changed links +--------------------- + +console_ioctl.4 + michael kerrisk + link for old name of ioctl_console(2) page + +tty_ioctl.4 + michael kerrisk + link for old name of ioctl_tty(2) page + + +global changes +-------------- + +various pages + michael kerrisk + change page cross-references from tty_ioctl(4) to ioctl_tty(2) + michael kerrisk + change page cross-references for console_ioctl(4) to ioctl_console(2) + + +changes to individual pages +--------------------------- + +alarm.2 + michael kerrisk + see also: add timer_create(2) and timerfd_create(2) + +chmod.2 +fsync.2 +mkdir.2 +mknod.2 +open.2 +truncate.2 +umask.2 +utime.2 +utimensat.2 + michael kerrisk + add/replace references to inode(7) + +clone.2 + michael kerrisk + clone_newcgroup by an unprivileged process also causes an eperm error + +clone.2 +unshare.2 + michael kerrisk + exceeding one of the limits in /proc/sys/user/* can cause enospc + michael kerrisk + clone_newpid yields enospc if nesting limit of pid namespaces is reached + michael kerrisk + exceeding the maximum nested user namespace limit now gives enospc + formerly, if the limit of 32 nested user namespaces was exceeded, + the error eusers resulted. starting with linux 4.9, the error + is enospc. + +epoll_ctl.2 + michael kerrisk + defer to poll(2) for an explanation of epollin + michael kerrisk [nicolas biscos] + epollerr is also set on write end of a pipe when the read end is closed + michael kerrisk [nicolas biscos] + give the reader a clue that the 'events' field can be zero + 'events' specified as zero still allows epollhup and + epollerr to be reported. + +_exit.2 + michael kerrisk + on exit, child processes may be inherited by a "subreaper" + it is no longer necessarily true that orphaned processes + are inherited by pid 1. + michael kerrisk + only the least significant byte of exit status is passed to the parent + +fcntl.2 + michael kerrisk + mention memfd_create() in the discussion of file seals + give the reader a clue about what kinds of objects can + be employed with file seals. + michael kerrisk + file seals are not generally applicable to tmpfs(5) files + as far as i can see, file seals can be applied only to + memfd_create(2) file descriptors. this was checked by experiment + and by reading mm/shmem.c::shmem_get_inode((), where one finds + the following line that applies to all new shmem files: + + info->seals = f_seal_seal; + + only in the code of the memfd_create() system call is this + setting reversed (in mm/shmem.c::memfd_create): + + if (flags & mfd_allow_sealing) + info->seals &= ~f_seal_seal; + +fork.2 + michael kerrisk + see also: add pthread_atfork(3) + +getdents.2 +open.2 +stat.2 +statx.2 + michael kerrisk + see also: add inode(7) + +getdtablesize.2 +attr.5 + alexander miller + move .so directive to first line + improves compatibility with the man and other dumb tools + that process man page files. + +getpid.2 + michael kerrisk + mention init(1) and "subreapers" in discussion of parent pid + +ioctl_list.2 + cyril hrubis [arnd bergmann] + blkraset/blkraget take unsigned long + +ioctl_ns.2 + michael kerrisk + errors: document enotty + +kexec_load.2 +sched_setaffinity.2 +bootparam.7 + michael kerrisk + documentation/kernel-parameters.txt is now in documentation/admin-guide/ + +lseek.2 + michael kerrisk + see also: add fallocate(2) + both of these pages discuss file holes. + +mincore.2 + michael kerrisk + see also: add fincore(1) + +mmap.2 + michael kerrisk + remove ancient reference to flags that appear on some other systems + map_autogrow, map_autoresrv, map_copy, and map_local may have + appeared on some systems many years ago, but the discussion here + mentions no details and the systems and flags probably ceased to + be relevant long ago. so, remove this text. + michael kerrisk + see also: add userfaultfd(2) + +open.2 + michael kerrisk + add statx() to list of "at" calls in rationale discussion + +poll.2 + michael kerrisk + expand discussion of pollpri + michael kerrisk [nicolas biscos] + pollerr is also set on write end of a pipe when the read end is closed + +posix_fadvise.2 + michael kerrisk + see also: add fincore(1) + +prctl.2 + mike frysinger + pr_set_mm: refine config_checkpoint_restore requirement + the linux 3.10 release dropped the c/r requirement and opened it + up to all users. + mike frysinger + pr_set_mm: document new pr_set_mm_map{,_size} helpers + mike frysinger + pr_set_mm: document arg4/arg5 zero behavior + the kernel will immediately reject calls where arg4/arg5 are not + zero. see kernel/sys.c:prctl_set_mm(). + michael kerrisk + explain rationale for use of subreaper processes + michael kerrisk + note semantics of child_subreaper setting on fork() and exec() + michael kerrisk + improve description of pr_set_child_subreaper + +rename.2 + michael kerrisk [georg sauthoff] + note that there is no glibc wrapper for renameat2() + +sched_setaffinity.2 + michael kerrisk + see also: add get_nprocs(3) + +select.2 + michael kerrisk [matthew wilcox, carlos o'donell] + linux select() is buggy wrt posix in its check for ebadf errors + michael kerrisk + show correspondence between select() and poll() readiness notifications + michael kerrisk + give a hint that sets must be reinitialized if using select() in a loop + michael kerrisk + refer to pollpri in poll(2) for info on exceptional conditions + michael kerrisk + move mislocated text describing the self-pipe text from bugs to notes + +sigaction.2 + michael kerrisk + show the prototype of an sa_siginfo signal handler + +signalfd.2 + michael kerrisk + sigkill and sigstop are silently ignored in 'mask' + +sigprocmask.2 + dmitry v. levin + do not specify an exact value of rt_sigprocmask's 4th argument + as sizeof(kernel_sigset_t) is not the same for all architectures, + it would be better not to mention any numbers as its value. + michael kerrisk + 'set' and 'oldset' can both be null + +sigwaitinfo.2 + michael kerrisk + sigwaitinfo() can't be used to accept synchronous signals + +socketcall.2 + mike frysinger + document call argument + +stat.2 + michael kerrisk + remove information migrated to inode(7) page + michael kerrisk + restructure field descriptions as a hanging list + michael kerrisk + remove "other systems" subsection + these details about other systems were added in 1999, + and were probably of limited use then, and even less today. + however, they do clutter the page, so remove them. + michael kerrisk + description: add list entries for 'st_uid' and 'st_gid' + michael kerrisk + add some subsection headings to ease readability + david howells + errors: correct description of enoent + michael kerrisk + give 'struct stat' argument a more meaningful name ('statbuf') + marcin ślusarz + tweak description of at_empty_path + currently it says when dirfd is at_fdcwd it can be something + other than directory, which doesn't make much sense. just swap + the order of sentences. + michael kerrisk + add slightly expanded description of 'st_ino' field + michael kerrisk + description: add a list entry for 'st_ino' + michael kerrisk + description: add a list entry for 'st_nlinks' field + +syscalls.2 + michael kerrisk + add membarrier(2) + michael kerrisk + fix kernel version for userfaultfd(2) + michael kerrisk + linux 4.11 added statx() + michael kerrisk + include deprecated getunwind(2) in list + +wait.2 + michael kerrisk + orphaned children may be adopted by a "subreaper", rather by than pd 1 + +bzero.3 + michael kerrisk [zack weinberg] + add correct header file for explicit_bzero() + +cfree.3 + michael kerrisk + cfree() is removed from glibc in version 2.26 + +exit.3 + michael kerrisk + improve discussion of zombie processes + +getentropy.3 + nikos mavrogiannopoulos [michael kerrisk, florian weimer] + correct header file + michael kerrisk [frank theile] + synopsis: add missing return type for getentropy() declaration + +grantpt.3 + michael kerrisk + tell a more nuanced story about what grantpt() does or does not do + +insque.3 + michael kerrisk + see also: add queue(3) + +queue.3 + michael kerrisk + see also: add insque(3) + +shm_open.3 + michael kerrisk + clarify that posix shared memory uses tmpfs(5) + +syslog.3 + michael kerrisk [ian abbott, walter harms] + reorganize page text for easier parsing and better readability + michael kerrisk + various rewordings and improvements + michael kerrisk + note default value for 'facility' when calling openlog() + michael kerrisk + see also: add journalctl(1) + +ttyname.3 + dmitry v. levin + document enodev error code + christian brauner + notes: warn about a confusing case that may occur with mount namespaces + +wcsdup.3 + jan heberer + return value: fix error in return value description + return value for failure was accidentally changed from null to + -1 in man-pages commit 572acb41c48b6b8e690d50edff367d8b8b01702a. + +elf.5 + michael kerrisk + see also: add elfedit(1), nm(1), size(1), strings(1), and strip(1) + +nsswitch.conf.5 + florian weimer + mention sudoers + it turns out that sudo drops things into nsswitch.conf, too. + +proc.5 + michael kerrisk + refer to namespaces(7) for discussion of /proc/sys/user/* files + michael kerrisk + simplify /proc/slabinfo entry + don't repeat (out-of-date) info from slabinfo(5); just defer to + that page. + +tmpfs.5 + michael kerrisk + tmpfs supports extended attributes, but not 'user' extended attributes + +environ.7 + jakub wilk + fix name of function that honors tmpdir + tempnam() takes the tmpdir environment variable into account, unlike + tmpnam(), which always creates pathnames within /tmp. + +hostname.7 + marko myllynen + use lower case for hostname example + marko myllynen + use generic names in examples + marko myllynen + describe accepted characters for hostname + +inotify.7 + michael kerrisk [nicolas iooss] + mounting a filesystem on top of a monitored directory causes no event + +man-pages.7 + michael kerrisk + note preferred approach for 'duplicate' errors + +pid_namespaces.7 + michael kerrisk + the maximum nesting depth for pid namespaces is 32 + +user_namespaces.7 + stephan bergmann + fixes to example + while toying around with the userns_child_exec example program on the + user_namespaces(7) man page, i noticed two things: + + * in the example section, we need to mount the new /proc before + looking at /proc/$$/status, otherwise the latter will print + information about the outer namespace's pid 1 (i.e., the real + init). so the two paragraphs need to be swapped. + + * in the program source, make sure to close pipe_fd[0] in the + child before exec'ing. + +pthreads.7 + michael kerrisk + see also: add pthread_rwlockattr_setkind_np(3) + +pty.7 + michael kerrisk + mention a couple of other applications of pseudoterminals + +sem_overview.7 + michael kerrisk + see also: add shm_overview(7) + +signal.7 + michael kerrisk + see also: add sigreturn(2) + +tcp.7 + michael kerrisk + note indications for oob data given by select(2) and poll(2) + chema gonzalez + tcp_abc was removed in 3.9 + +xattr.7 + michael kerrisk + see also: add ioctl_iflags(2) + people sometimes confuse xattrs and inode flags. provide a link + to the page that describes inode flags to give them a tip. + +ld.so.8 + michael kerrisk + mention quoting when using "rpath tokens" in ld_audit and ld_preload + michael kerrisk + expand description of /etc/ld.so.preload + michael kerrisk + mention ldconfig(8) in discussion of /etc/ld.so.cache + +zdump.8 + jakub wilk + add options section heading + + +==================== changes in man-pages-4.12 ==================== + +released: 2017-07-13, london + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +alex henrie +andi kleen +arjun shankar +brad bendily +cameron wright +carlos o'donell +darrick j. wong +david lewis +dj delorie +douglas caetano dos santos +dr. tobias quathamer +eric biggers +ferdinand thiessen +g. branden robinson +heinrich schuchardt +henry bent +jakub wilk +janne snabb +joe brown +jorge nerin +kirill tkhai +lilydjwg +long wang +michael kerrisk +mike frysinger +nadav har'el +neilbrown +pavel tikhomirov +quentin rameau +ruben kerkhof +sulit +石井大貴 + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +ioctl_getfsmap.2 + darrick j. wong + document the getfsmap ioctl + document the new getfsmap ioctl that returns the physical layout of a + (disk-based) filesystem. + + +newly documented interfaces in existing pages +--------------------------------------------- + +namespaces.7 + kirill tkhai [michael kerrisk] + document the /proc/[pid]/ns/pid_for_children file + + +changes to individual pages +--------------------------- + +ldd.1 + michael kerrisk + 'objdump -p prog | grep needed' doesn't give quite same info as 'ldd' + +chmod.2 + michael kerrisk + put fchmod() feature test macro requirements in a more readable format + michael kerrisk + note glibc 2.24 feature test macro requirements changes for fchmod() + +chown.2 + michael kerrisk + when file owner or group is changed, file capabilities are cleared + michael kerrisk + changes to file owner by root also clear set-uid and set-gid bits + +clone.2 + michael kerrisk + update bugs to reflect fact that pid caching was removed in glibc 2.25 + +epoll_wait.2 + michael kerrisk + clarify semantics of returned 'data' field + the returned 'data' is the 'data' most recently set via + epoll_ctl(). + +get_mempolicy.2 + michael kerrisk [nadav har'el, andi kleen] + synopsis: fix return type of get_mempolicy() + see https://bugzilla.kernel.org/show_bug.cgi?id=97051 + +getpid.2 + carlos o'donell, michael kerrisk + note that pid caching is removed as of glibc 2.25 + since glibc 2.25 the pid cache is removed. + + rationale given in the release notes: + https://sourceware.org/glibc/wiki/release/2.25#pid_cache_removal + +ioctl.2 + michael kerrisk + see also: add ioctl_getfsmap(2) + +ioctl_getfsmap.2 + michael kerrisk + fix ordering of sections + michael kerrisk + add versions section + michael kerrisk + errors: order alphabetically + +madvise.2 + michael kerrisk + remove bogus text re posix_madv_noreuse + there is a posix_fadv_noreuse for posix_fadvise(), + but no posix_madv_noreuse for any api in posix. + +membarrier.2 + michael kerrisk + add enosys error for 'nohz_full' cpu setting + +mount.2 + neilbrown + revise description of ms_remount | ms_bind + ms_remount|ms_bind affects all per-mount-point + flag. ms_rdonly is only special because it, + uniquely, is both a per-mount-point flag *and* a + per-filesystem flag. + + so the sections of per-mount-point flags and + ms_remount can usefully be clarified. + +open.2 + michael kerrisk + note some further advantages of the *at() apis + +pipe.2 + michael kerrisk + see also: add tee(2) and vmsplice(2) + +readv.2 + michael kerrisk + glibc 2.26 adds library support for preadv2() and pwritev2() + +sched_setaffinity.2 + michael kerrisk + mention cpuset cgroups as a cause of einval error + +seccomp.2 + mike frysinger + expand seccomp_ret_kill documentation + +sigaction.2 + michael kerrisk + note feature test macro requirements for 'si_code' constants + michael kerrisk + add a subheading for the description of 'si_code' + michael kerrisk + trap_branch and trap_hwbkpt are present only on ia64 + +sigaltstack.2 + michael kerrisk + note that specifying ss_onstack in ss.ss_flags decreases portability + in the illumos source (which presumably mirrors its solaris + ancestry), there is this check in the sigaltstack() + implementation: + + if (ss.ss_flags & ~ss_disable) + return (set_errno(einval)); + + and in the freebsd source we find similar: + + if ((ss->ss_flags & ~ss_disable) != 0) + return (einval); + michael kerrisk + note buggy addition of ss.ss_flags==ss_onstack + note buggy addition of ss.ss_flags==ss_onstack as a synonym + for ss_flags==0. no other implementation does this, afaik. + and it was not needed :-(. + michael kerrisk + specifying 'ss' returns the current settings without changing them + michael kerrisk + give 'oss' argument a more meaningful name: 'old_ss' + michael kerrisk + some minor reworking of the text + michael kerrisk + errors: update description of einval error + +splice.2 +tee.2 +vmsplice.2 + michael kerrisk + see also: add pipe(7) + +splice.2 + michael kerrisk + errors: split einval error cases + michael kerrisk + errors: add einval for case where both descriptors refer to same pipe + +timer_create.2 + michael kerrisk + document the config_posix_timers option added in linux 4.10 + +wait.2 + michael kerrisk + note glibc 2.26 changes to feature test macro requirements for waitid() + +acosh.3 +asinh.3 +atanh.3 + alex henrie + remove c89 designation. + see https://bugzilla.kernel.org/show_bug.cgi?id=196319 + +bsd_signal.3 + michael kerrisk + note feature test macro requirements changes for glibc 2.26 + +dl_iterate_phdr.3 + michael kerrisk + dl_iterate_phdr() shows the order in which objects were loaded + dl_iterate_phdr() tells us not just which objects are + loaded, but also the order in which they are loaded + (the "link-map order"). since the order is relevant for + understanding symbol resolution, give the reader this clue. + michael kerrisk + expand the code example, and show sample output + michael kerrisk + list values for the 'p_type' field + +dlsym.3 + michael kerrisk + _gnu_source is needed to get rtld_default and rtld_next definitions + +flockfile.3 + michael kerrisk + note glibc 2.24 feature test macro requirement changes + +fpathconf.3 + michael kerrisk + rework return value description to add more detail + michael kerrisk + add an errors section + michael kerrisk + largely rewrite the description of _pc_chown_restricted + michael kerrisk + rewrite description of _pc_pipe_buf + the existing description was not accurate, and lacked details. + +ftw.3 + michael kerrisk + bugs: document a probable glibc regression in ftw_sln case + see https://bugzilla.redhat.com/show_bug.cgi?id=1422736 + and http://austingroupbugs.net/view.php?id=1121. + +getaddrinfo.3 + quentin rameau + fix _posix_c_source value for getaddrinfo() + the correct _posix_c_source value is 200112l, not 201112l in features.h. + +getcontext.3 + carlos o'donell + exemplar structure should use 'ucontext_t'. + +getgrent.3 + michael kerrisk + note glibc 2.22 changes for feature test macro requirements + +grantpt.3 +ptsname.3 +unlockpt.3 + ferdinand thiessen [michael kerrisk] + update feature test macro-requirements for glibc 2.24 + +if_nametoindex.3 + douglas caetano dos santos + add enodev error for if_nametoindex() + +malloc.3 + michael kerrisk + document the reallocarray() added in glibc 2.26 + +nl_langinfo.3 + michael kerrisk + note feature test macro requirements for nl_langinfo_l() + +posix_madvise.3 + dr. tobias quathamer + remove paragraph about posix_fadv_noreuse + posix_fadv_noreuse is documented for posix_fadvise, and a + corresponding posix_madv_noreuse flag is not specified by posix. + see https://bugs.debian.org/865699 + +ptsname.3 + michael kerrisk [arjun shankar] + since glibc 2.26, ptsname_r() no longer gives einval for buf==null + +rand.3 + michael kerrisk + note glibc 2.24 feature test macro requirement changes for rand_r() + +resolver.3 + michael kerrisk + add basic notes on 'op' argument of res_nmkquery() and res_mkquery() + +sigpause.3 + michael kerrisk + note glibc 2.26 changes to feature test macro requirements + +sigwait.3 + michael kerrisk + note glibc 2.26 feature test macro changes + +strtol.3 + heinrich schuchardt + mention 0x prefix + the prefix 0x may be capitalized as 0x. + + see iso/iec 9899:1999. + +sysconf.3 + michael kerrisk [pavel tikhomirov] + rework return value description to add more detail + make the discussion clearer, and add a few details. + also, fix the problem report from pavel tikhomirov + who noted that the man page falsely said that errno + is not changed on a successful return. + + addresses https://bugzilla.kernel.org/show_bug.cgi?id=195955 + michael kerrisk + add errors section + +ttyslot.3 + michael kerrisk + fix error in feature test macro requirements + michael kerrisk + note feature test macro requirements changes in glibc 2.24 + michael kerrisk + clarify details of use of file + +unlocked_stdio.3 + michael kerrisk + note glibc 2.24 feature test macro requirement changes + +elf.5 + michael kerrisk + see also: add dl_iterate_phdr(3) + +nsswitch.conf.5 + dj delorie + clarify group merge rules + this minor patch clarifies when merging is not done, + and how duplicate entries are merged. + +proc.5 + michael kerrisk + document that 'iowait' field of /proc/stat is unreliable + text taken from chao fan's kernel commit 9c240d757658a3ae996. + +slabinfo.5 + michael kerrisk [jorge nerin] + see also: add some references to relevant kernel source files + +tmpfs.5 + michael kerrisk + see also: add memfd_create(2), mmap(2), shm_open(3) + +capabilities.7 + michael kerrisk + clarify the effect on process capabilities when uid 0 does execve(2) + michael kerrisk + note effect on capabilities when a process with uid != 0 does execve(2) + michael kerrisk [david lewis] + fix reversed descriptions of cap_mac_override and cap_mac_admin + michael kerrisk + see also: add filecap(8), netcap(8), pscap(8) + +cgroup_namespaces.7 + michael kerrisk + add some further explanation of the example shell session + michael kerrisk + fix a bug in shell session example + +inode.7 + michael kerrisk + note glibc 2.24 feature test macro changes for s_ifsock and s_issock() + +man.7 + g. branden robinson + undocument "url" macro in man(7) in favor .ur+.ue + +pid_namespaces.7 + michael kerrisk + mention /proc/[pid]/ns/pid_for_children + +pipe.7 + michael kerrisk + see also: add tee(2) and vmsplice(2) + +sigevent.7 + michael kerrisk + mention signal.h header file + +signal.7 + michael kerrisk [lilydjwg] + since linux 3.8, read(2) on an inotify fd is restartable with sa_restart + see https://bugzilla.kernel.org/show_bug.cgi?id=195711 + michael kerrisk + read() from an inotify fd is no longer interrupted by a stop signal + (change was in linux 3.8.) + +tcp.7 + michael kerrisk + document value '2' for tcp_timestamps + since linux 4.10, the value '2' is meaningful for tcp_timestamps + ruben kerkhof + change default value of tcp_frto + the default changed in c96fd3d461fa495400df24be3b3b66f0e0b152f9 + (linux 2.6.24). + +ld.so.8 + michael kerrisk + greatly expand the explanation of ld_dynamic_weak + carlos o'donell + expand dt_runpath details. + ld.so.8: expand dt_runpath details. + + every 3 years we get asked why dt_runpath doesn't work like dt_rpath. + the most recent question was here: + https://www.sourceware.org/ml/libc-help/2017-06/msg00013.html + + we need to expand the description of dt_runpath to cover this + situation and explain that the dt_runpath entries apply only to the + immediate dt_needed, not that of another, say dlopen'd child object. + michael kerrisk + since glibc 2.2.5, ld_profile is ignored in secure-execution mode + michael kerrisk + make notes on secure-execute mode more prominent + place each note on secure-execution mode in a separate + paragraph, to make it more obvious. + michael kerrisk + note that libraries in standard directories are not normally set-uid + in secure mode, ld_preload loads only libraries from standard + directories that are marked set-uid. note that it is unusual for + a library to be marked in this way. + michael kerrisk + see also: add elf(5) + michael kerrisk + note version where secure-execution started ignoring ld_use_load_bias + michael kerrisk + correct glibc version that ignores ld_show_auxv in secure-execution mode + ignored since 2.3.4 (not 2.3.5). + michael kerrisk + rewrite ld_debug_output description and note that .pid is appended + + +==================== changes in man-pages-4.13 ==================== + +released: 2017-09-15, munich + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +aleksa sarai +alex henrie +benjamin peterson +bjarni ingi gislason +cyrill gorcunov +darrick j. wong +david wilder +dennis knorr +don brace +douglas caetano dos santos +elliott hughes +eugene syromyatnikov +fabio scotoni +florian weimer +jakub wilk +jason noakes +jens axboe +jonas grabber +kees cook +konstantin shemyak +li zhijian +marko myllynen +mark wielaard +meelis roos +michael kerrisk +mike rapoport +neilbrown +otto ebeling +paul eggert +rick jones +sage weil +sam varshavchik +sergey z. +shrikant giridhar +stephan müller +sukadev bhattiprolu +tej chajed +thiago jung bauermann +vincent bernat +yubin ruan +ильдар низамов + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +pthread_mutex_consistent.3 + yubin ruan, michael kerrisk + new page documenting pthread_mutex_consistent(3) + +pthread_mutexattr_getpshared.3 + michael kerrisk + new page for pthread_mutexattr_getpshared(3) and pthread_mutexattr_setpshared(3) + +pthread_mutexattr_init.3 + michael kerrisk + new page for pthread_mutexattr_init(3) and pthread_mutexattr_destroy(3) + +pthread_mutexattr_setrobust.3 + yubin ruan, michael kerrisk + new page for pthread_mutexattr_setrobust(3) and pthread_mutexattr_getrobust(3) + +sysfs.5 + michael kerrisk [mark wielaard] + new page documenting the sysfs filesystem + just a skeleton page so far, but perhaps it will be filled out + over time. + + +newly documented interfaces in existing pages +--------------------------------------------- + +fcntl.2 + jens axboe, michael kerrisk + describe the set/get write hints commands that are added in linux 4.13 + document f_get_rw_hint, f_set_rw_hint, f_get_file_rw_hint, and + f_set_file_rw_hint. + +ioctl_tty.2 + aleksa sarai, michael kerrisk + add tiocgptpeer documentation + +kcmp.2 + cyrill gorcunov + add kcmp_epoll_tfd description + +keyctl.2 + eugene syromyatnikov + document the keyctl_restrict_keyring operation + eugene syromyatnikov [stephan müller] + document the ability to provide kdf parameters in keyctl_dh_compute + + +new and changed links +--------------------- + +pthread_mutexattr_destroy.3 + michael kerrisk + new link to new pthread_mutexattr_init.3 page + +pthread_mutexattr_getrobust.3 +pthread_mutexattr_getrobust_np.3 +pthread_mutexattr_setrobust_np.3 + michael kerrisk + new links to new pthread_mutexattr_setrobust.3 page + +pthread_mutexattr_setpshared.3 + michael kerrisk + new link to new pthread_mutexattr_getpshared.3 page + + +global changes +-------------- + +various pages + michael kerrisk + use .ex/.ee for example programs + +various pages + michael kerrisk + use consistent markup for code snippets + change .nf/.fi to .ex/.ee + +various pages + michael kerrisk + use consistent markup for code snippets + the preferred form is + + .pp/.ip + .in +4n + .ex + + .ee + .in + .pp/.ip + +various pages + michael kerrisk + formatting fix: replace blank lines with .pp/.ip + blank lines shouldn't generally appear in *roff source (other + than in code examples), since they create large vertical + spaces between text blocks. + +various pages + michael kerrisk [bjarni ingi gislason] + add a non-breaking space between a number and a unit (prefix) + based on a patch by bjarni ingi gislason. + +various pages + michael kerrisk [bjarni ingi gislason] + use en-dash for ranges + based on a patch by bjarni ingi gislason. + +a few pages + michael kerrisk + fix misordering of sections + michael kerrisk + fix order of see also entries + + +changes to individual pages +--------------------------- + +ldd.1 + michael kerrisk + add more detail on ldd security implications, noting glibc 2.27 changes + +add_key.2 +backtrace.3 +syslog.3 + michael kerrisk + fix misordered see also entries + +add_key.2 +request_key.2 +keyrings.7 + eugene syromyatnikov + update linux documentation pointers + +chown.2 + michael kerrisk + update kernel version in note on support for grpid/nogrpid mount options + there has been no change since linux 2.6.25, so update the + kernel version to 4.12. + +execve.2 + michael kerrisk + see also: add get_robust_list(2) + +getrandom.2 + michael kerrisk [fabio scotoni] + synopsis: make return type of getrandom() 'ssize_t' + this accords with glibc headers and the linux kernel source. + +getrlimit.2 + thiago jung bauermann + mention unit used by rlimit_core and rlimit_fsize + michael kerrisk + note that rlimit_as and rlimit_data are rounded down to system page size + michael kerrisk + mention unit for rlimit_data + +getrlimit.2 +mmap.2 +malloc.3 + jonas grabber + rlimit_data affects mmap(2) since linux 4.7 + +get_robust_list.2 + michael kerrisk + detail the operation of robust futex lists + michael kerrisk + since linux 2.6.28, robust futex lists also have an effect for execve(2) + michael kerrisk + clarify that "thread id" means "kernel thread id" + michael kerrisk + see also: add pthread_mutexattr_setrobust(3) + +ioctl_getfsmap.2 + darrick j. wong + correct semantics of fmr_of_last flag + +ioctl_userfaultfd.2 + mike rapoport + document replacement of enospc with esrch + mike rapoport + update uffdio_api.features description + there is no requirement that uffdio_api.features must be zero + for newer kernels. this field actually defines what features + space would like to enable. + +io_submit.2 + sage weil + acknowledge possibility of short return + note that the return value may be a value less than 'nr' + if not all iocbs were queued at once. + +ipc.2 + michael kerrisk + see also: add svipc(7) + +keyctl.2 + eugene syromyatnikov + mention keyctl_dh_compute(3) and keyctl_dh_compute_alloc (3) + these functions have been added in keyutils 1.5.10 + eugene syromyatnikov + mention enomem in errors + eugene syromyatnikov + update kernel documentation path reference + +move_pages.2 + otto ebeling [michael kerrisk] + note permission changes that occurred in linux 4.13 + +mprotect.2 + michael kerrisk [shrikant giridhar] + add warning about the use of printf() in the example code + +open.2 + neilbrown + improve o_path documentation + - fstatfs is now permitted. + - ioctl isn't, and is worth listing explicitly + - o_path allows an automount point to be opened with + triggering the mount. + +prctl.2 +seccomp.2 + eugene syromyatnikov + update pointer to in-kernel seccomp documentation + +prctl.2 +ptrace.2 + eugene syromyatnikov + update pointer to in-kernel yama documentation + +prctl.2 + eugene syromyatnikov + update pointer to in-kernel no_new_privs flag documentation + +readlink.2 + michael kerrisk [jason noakes] + fix an off-by-one error in example code + +seccomp.2 + kees cook + clarify seccomp_ret_kill kills tasks not processes + +select_tut.2 + michael kerrisk [sergey z.] + clarify an ambiguity with respect to select() and eagain + see https://bugzilla.kernel.org/show_bug.cgi?id=196345 + +set_tid_address.2 + elliott hughes + note that there's no glibc wrapper for set_tid_address() + +socket.2 + michael kerrisk [yubin ruan] + socket() uses the lowest available file descriptor + +_syscall.2 + michael kerrisk + remove redundant comment from example + a discussion of the nroff source of the manual + page isn't very useful... + +sysfs.2 + michael kerrisk + add a pointer to sysfs(5) to help possibly confused readers + michael kerrisk + make it clearer near the start of the page that sysfs(2) is obsolete + +timer_create.2 + michael kerrisk + strengthen the warning about use of printf() in the example program + michael kerrisk + update cross reference: signal(7) should be signal-safety(7) + +umount.2 + neilbrown + revise mnt_force description + mnt_force does not allow a busy filesystem to be unmounted. only + mnt_detach allows that. mnt_force only tries to abort pending + transactions, in the hope that might help umount not to block, + + also, other filesystems than nfs support mnt_force. + +unshare.2 + eugene syromyatnikov + update pointer to in-kernel unshare documentation + +wait.2 + michael kerrisk [ильдар низамов] + posix.1-2008 tc1 clarifies treatment of 'si_pid' for waitid() wnohang + +cmsg.3 + sukadev bhattiprolu + add a scatter/gather buffer to sample code + michael kerrisk + reorganize the text somewhat (no content changes) + +crypt.3 + konstantin shemyak [michael kerrisk] + add description of previously undocumented 'rounds' parameter + konstantin shemyak + encryption isn't done with sha-xxx, but with a function based on sha-xxx + konstantin shemyak + clarify that ending of the salt string with '$' is optional + +exit.3 + michael kerrisk + mention the prctl(2) pr_set_pdeathsig operation + michael kerrisk + see also: add get_robust_list(2) + michael kerrisk + add a heading to delimit discussion of signals sent to other processes + +exp2.3 + alex henrie + remove c89 designation + +log1p.3 + alex henrie + document fixes to give edom or erange on error + +matherr.3 + michael kerrisk + note that glibc 2.27 removes the 'matherr' mechanism + michael kerrisk + remove crufty feature test macro requirements + +pow10.3 + michael kerrisk + note that pow10() is now obsolete in favor of exp10() + also, the pow10() functions are no longer supported by glibc, + starting with version 2.27. + +sincos.3 + michael kerrisk + note that sincos() is intended to be more efficient than sin() + cos() + +cciss.4 +hpsa.4 + eugene syromyatnikov [don brace, meelis roos] + mention cciss removal in linux 4.14 + during the linux 4.13 development cycle, the cciss driver has been + removed in favor of the hpsa driver, which has been amended with + some legacy board support. + +initrd.4 +proc.5 +bootparam.7 + eugene syromyatnikov + update pointer to in-kernel initrd documentation + +initrd.4 + eugene syromyatnikov + update pointer to in-kernel root over nfs documentation + +intro.4 + michael kerrisk + see also: add mknod(1) and mknod(2) + +host.conf.5 + michael kerrisk + add cross-reference to hosts(5) + +locale.5 + marko myllynen + refer to existing locales for encoding details + since i don't think it would make sense to try to have different + explanation for each glibc version on the locale(5) man page, i'm + proposing that we apply the below patch so that we refer to + existing locale definition files in general and not spell out the + exact format or any certain locale as a definitive guideline. + +nologin.5 + michael kerrisk + add a sentence explaining why nologin is useful + +proc.5 + eugene syromyatnikov + document removal of htab-reclaim sysctl file + this ppc-specific sysctl option has been removed in linux 2.4.9.2, + according to historic linux repository commit log. + eugene syromyatnikov + add description for cpun lines in /proc/stat + eugene syromyatnikov + add description for softirq line in /proc/stat + eugene syromyatnikov + document removal of timer_stats file + michael kerrisk + note linux 4.9 changes to privileges for /proc/[pid]/timerslack_ns + michael kerrisk + show command used to mount /proc + michael kerrisk + explicitly note in intro that some /proc files are writable + eugene syromyatnikov + update pointer to in-kernel sysrq documentation + michael kerrisk + see also: add sysfs(5) + eugene syromyatnikov + update pointer to in-kernel security keys documentation + benjamin peterson + fix path to binfmt_misc docs + eugene syromyatnikov + update pointer to in-kernel mtrr documentation + eugene syromyatnikov + update reference to kernel's crypto api documentation + +tzfile.5 + paul eggert + sync from tzdb upstream + this makes tzfile.5 a copy of the tzdb version, except that the + tzdb version's first line is replaced by man-pages boilerplate. + the new version documents version 3 format, among other things. + also, it removes the "summary of the timezone information file + format" section, which should no longer be needed due to + improvements in the part of the man page. + +capabilities.7 + michael kerrisk + note semantics for a program that is set-uid-root and has capabilities + note semantics for a program that is both set-user-id-root and has + file capabilities. + michael kerrisk [dennis knorr] + note that a set-uid-root program may have an empty file capability set + +cgroups.7 + michael kerrisk + see also: systemd-cgls(1) + +cpuset.7 + eugene syromyatnikov + update pointer to in-kernel cpusets documentation + +keyrings.7 + eugene syromyatnikov + document description restriction for logon keys + "logon" type has additional check that enforces colon-separated + prefix in key descriptions. + eugene syromyatnikov + add pointers to kernel's documentation + mostly because of asymmetric-keys.txt, which is outside + security/keys for some reason. + +man-pages.7 + michael kerrisk + expand the guidance on formatting code snippets + +netlink.7 + david wilder + change buffer size in example code about reading netlink message + michael kerrisk [rick jones] + add a comment on 8192 buffer size in example code + +pthreads.7 + michael kerrisk + see also: add pthread_mutexattr_destroy(3) and pthread_mutexattr_init(3) + +signal.7 + michael kerrisk + since glibc 2.26, sigunused is no longer defined + +tcp.7 + vincent bernat + tcp_tw_recycle is removed from linux 4.12 + and it is completely broken. + +unicode.7 + eugene syromyatnikov + update pointer to in-kernel unicode terminal support documentation + + +==================== changes in man-pages-4.14 ==================== + +released: 2017-11-27, paris + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +adhemerval zanella +adrian bunk +ahmad fatoum +andrea arcangeli +bastien roucaries +breno leitao +carlos o'donell +christian brauner +christoph hellwig +colm maccárthaigh +craig ringer +cristian rodríguez +david eckardt +don brace +elliot hughes +eric w. biederman +fabio scotoni +fangrui song +florian weimer +g. branden robinson +goldwyn rodrigues +grégory vander schueren +jakub wilk +jann horn +jeff layton +jens axboe +jonny grant +julien gomes +kees cook +křištof želechovski +lennart poettering +lucas werkmeister +marcus folkesson +marin h. +mathieu desnoyers +matthew wilcox +michael kerrisk +michal hocko +michał zegan +mihir mehta +mike frysinger +mike kravetz +mike rapoport +miklos szeredi +neilbrown +oliver ebert +pedro alves +per böhlin +peter zijlstra +petr malat +petr uzel +prakash sangappa +raghavendra d prabhu +rahul bedarkar +ram pai +richard knutsson +rik van riel +scott vokes +seonghun lim +stas sergeev +stefan puiu +thomas gleixner +tobias klausmann +tomas pospisek +tyler hicks +victor porton +walter harms +wesley aptekar-cassels +yubin ruan +zack weinberg +дилян палаузов + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +pthread_spin_init.3 + michael kerrisk [peter zijlstra, thomas gleixner, zack weinberg, + florian weimer] + new page describing pthread_spin_init(3) and pthread_spin_destroy(3) + +pthread_spin_lock.3 + michael kerrisk [carlos o'donell] + new page describing functions that lock and unlock spin locks + add a page describing pthread_spin_lock(3), pthread_spin_unlock(3), + and pthread_spin_trylock(3). + +smartpqi.4 + don brace [michael kerrisk, g. branden robinson] + document the smartpqi scsi driver + +veth.4 + tomáš pospíšek, eric biederman, michael kerrisk + new page documenting veth virtual ethernet devices + based on a page from tomáš pospíšek, with some clean-ups by mtk. + + +removed pages +------------- + +infnan.3: + michael kerrisk + this function was in libc4 and libc5, but never part + of glibc. it ceased to be relevant nearly 20 years + ago. time to remove the man page. + + +newly documented interfaces in existing pages +--------------------------------------------- + +ioctl_userfaultfd.2 +userfaultfd.2 + prakash sangappa [andrea arcangeli, mike rapoport] + add description for uffd_feature_sigbus + +madvise.2 + rik van riel [colm maccárthaigh, michael kerrisk] + document madv_wipeonfork and madv_keeponfork + michael kerrisk + note fork() and execve() semantics for wipe-on-fork setting + +membarrier.2 + mathieu desnoyers + update membarrier manpage for 4.14 + add documentation for these new membarrier() commands: + membarrier_cmd_private_expedited + membarrier_cmd_register_private_expedited + +memfd_create.2 + mike kravetz + add description of mfd_hugetlb (hugetlbfs) support + hugetlbfs support for memfd_create() was recently merged by linus + and should be in the linux 4.14 release. to request hugetlbfs + support a new memfd_create() flag (mfd_hugetlb) was added. + +readv.2 + christoph hellwig + document rwf_nowait added in linux 4.14 + +seccomp.2 + tyler hicks + document the seccomp_get_action_avail operation added in linux 4.14 + tyler hicks + document the seccomp_filter_flag_log flag added in linux 4.14 + tyler hicks + document the seccomp_ret_log action added in linux 4.14 + michael kerrisk [kees cook] + add description of seccomp_ret_kill_process + michael kerrisk + add seccomp_ret_kill_thread description and rework seccomp_ret_kill text + michael kerrisk + document the seccomp audit logging feature added in linux 4.14 + +seccomp.2 +proc.5 + tyler hicks + document the seccomp /proc interfaces added in linux 4.14 + document the seccomp /proc interfaces in linux 4.14: + /proc/sys/kernel/seccomp/actions_avail and + /proc/sys/kernel/seccomp/actions_logged. + +sigaltstack.2 + michael kerrisk [stas sergeev] + document the ss_autodisarm flag added in linux 4.7 + +proc.5 + michael kerrisk + document /proc/locks + oliver ebert + document /proc/kpagecgroup + oliver ebert + add kpf_balloon, kpf_zero_page, and kpf_idle for /proc/kpageflags + +pid_namespaces.7 + michael kerrisk + document /proc/sys/kernel/ns_last_pid + + +new and changed links +--------------------- + +pthread_spin_destroy.3 + michael kerrisk + new link to new pthread_spin_init.3 page + +pthread_spin_trylock.3 +pthread_spin_unlock.3 + michael kerrisk + new links to new pthread_spin_lock.3 page + + +global changes +-------------- + +various pages + michael kerrisk + consistently use "x86-64", not "x86_64" + when referring to the architecture, consistently use "x86-64", + not "x86_64". hitherto, there was a mixture of usages, with + "x86-64" predominant. + +various pages + g. branden robinson + replace incorrect uses of latin abbreviation "cf.". + people seem to be using "cf." ("conferre"), which means "compare", + to mean "see" instead, for which the latin abbreviation would be + "q.v." ("quod vide" -> "which see"). + + in some cases "cf." might actually be the correct term but it's + still not clear what specific aspects of a function/system call + one is supposed to be comparing. + + + +changes to individual pages +--------------------------- + +capget.2 + michael kerrisk + clarify discussion of kernels that have no vfs capability support + +clock_getres.2 + michael kerrisk + clock_gettime() may be implemented in the vdso + +clone.2 + michael kerrisk + warn that the clone() wrapper modifies child_stack in the parent + michael kerrisk + rework the discussion of the historical clone_pid for clarity + michael kerrisk + add notes heading + michael kerrisk + add a reference to new veth(4) page + michael kerrisk + eliminate some redundant phrasing in discussion of "fn()" + michael kerrisk + combine redundant paragraphs describing child_stack==null + michael kerrisk + note that child_stack can be null when using the raw system call + michael kerrisk + remove a redundant paragraph + +connect.2 + michael kerrisk + clarify that econnrefused is for stream sockets + +fcntl.2 + michael kerrisk [jens axboe] + inode read-write hints persist only until the filesystem is unmounted + +flock.2 + michael kerrisk + move nfs details to a headed subsection + michael kerrisk [petr uzel] + placing an exclusive lock over nfs requires the file is open for writing + +fork.2 + rik van riel [colm maccárthaigh, michael kerrisk] + document effect of madv_wipeonfork + +fork.2 +getsid.2 +setpgid.2 +setsid.2 + ahmad fatoum + include in synopsis to obtain declaration of pid_t + +fsync.2 + craig ringer + errors: add enospc + +getcpu.2 + michael kerrisk + getcpu() may have an implementation in the vdso + +getpid.2 + michael kerrisk + mention that pid == tgid, and note contrast with tid + michael kerrisk + see also: add gettid(2) + +getrandom.2 + michael kerrisk [fabio scotoni] + errors: add enosys + +getrlimit.2 + michael kerrisk [scott vokes] + make it clear rlimit_nproc is a limit on current number of processes + https://twitter.com/silentbicycle/status/893849097903505409 + +gettid.2 + michael kerrisk + see also: add getpid(2) + +gettimeofday.2 + michael kerrisk + note that gettimeofday() may be implemented in the vdso + +ioctl_userfaultfd.2 + michael kerrisk + rework version information for feature bits + +io_submit.2 + goldwyn rodrigues + add iocb details to io_submit + add more information about the iocb structure. explains the + fields of the i/o control block structure which is passed to the + io_submit() call. + michael kerrisk + add cross-reference to io_getevents(2) + michael kerrisk + cross reference pwritev(2) in discussion of rwf_sync and rwf_dsync + +membarrier.2 + mathieu desnoyers + update example to take tso into account + the existing example given specifically states that it focus on + x86 (tso memory model), but gives a read-read vs write-write + ordering example, even though this scenario does not require + explicit barriers on tso. + + so either we change the example architecture to a weakly-ordered + architecture, or we change the example to a scenario requiring + barriers on x86. + + let's stay on x86, but provide a dekker as example instead. + mathieu desnoyers + adapt the membarrier_cmd_shared return value documentation to + reflect that it now returns -einval when issued on a system + configured for nohz_full. + +memfd_create.2 + michael kerrisk + note the limit for size of 'name' + +mkdir.2 + michael kerrisk [raghavendra d prabhu] + errors: document einval error for invalid filename + +mmap.2 + michael kerrisk + add explicit text noting that 'length' must be greater than 0 + currently, this detail is hidden in errors. make it clear in + the main text. + michael kerrisk + see also: add ftruncate(2) + +mremap.2 + mike kravetz [florian weimer, jann horn] + add description of old_size == 0 functionality + since at least the 2.6 time frame, mremap() would create a new + mapping of the same pages if 'old_size == 0'. it would also leave + the original mapping. this was used to create a 'duplicate + mapping'. + + a recent change was made to mremap() so that an attempt to create a + duplicate a private mapping will fail. + michael kerrisk [michal hocko, mike kravetz] + bugs: describe older behavior for old_size==0 on private mappings + explain the older behavior, and why it changed. this is a + follow-up to mike kravetz's patch documenting the behavior + for old_size==0 with shared mappings. + michael kerrisk + reformat einval errors as a list + +open.2 + michael kerrisk + by contrast with o_rdonly, no file permissions are required for o_path + note one of the significant advantages of o_path: many of the + operations applied to o_path file descriptors don't require + read permission, so there's no reason why the open() itself + should require read permission. + michael kerrisk + note use of o_path to provide o_exec functionality + michael kerrisk + mention o_path file descriptor use with fexecve(3) + michael kerrisk + errors: document einval error for invalid filename + michael kerrisk + clarify that o_tmpfile creates a *regular* file + michael kerrisk + make it explicit that o_creat creates a regular file + michael kerrisk + since glibc 2.26, the open() wrapper always uses the openat() syscall + michael kerrisk + change pathname used in discussion of rationale for openat() + /path/to/file is a little confusing as a pathname + michael kerrisk + make the purpose of open() a little clearer at the start of the page + +open_by_handle_at.2 + neilbrown + clarifications needed due to nfs reexport + neilbrown [lennart poettering] + clarify max_handle_sz + as hinted in the kernel source, max_handle_sz is a hint + rather than a promise. + +pipe.2 + michael kerrisk [marin h.] + since linux 4.5, fcntl() can be used to set o_direct for a pipe + see https://bugzilla.kernel.org/show_bug.cgi?id=197917 + +pivot_root.2 + michael kerrisk + see also: add switch_root(8) + +pkey_alloc.2 + breno leitao + fix argument order + currently pkey_alloc() syscall has two arguments, and the very + first argument is still not supported and should be set to zero. + the second argument is the one that should specify the + page access rights. + +ptrace.2 + michael kerrisk + see also: add ltrace(1) + +reboot.2 + michael kerrisk [michał zegan] + fix bogus description of reboot() from non-initial pid namespace + the current text was confused (mea culpa). no signal is sent to + the init() process. rather, depending on the 'cmd' given to + reboot(), the 'group_exit_code' value will set to either sighup or + sigint, with the effect that one of those signals is reported to + wait() in the parent process. + + see https://bugzilla.kernel.org/show_bug.cgi?id=195899 + michael kerrisk + see also: remove reboot(8) (synonym for halt(8)); add shutdown(8) + michael kerrisk + see also: add systemctl(1), systemd(1) + +recvmmsg.2 +sendmmsg.2 + elliot hughes + type fixes in synopsis + [mtk: the raw system calls use "unsigned int", but the glibc + wrappers have "int" for the 'flags' argument.] + +sched_setaffinity.2 + michael kerrisk + see also: add numactl(8) + +sched_yield.2 + michael kerrisk [peter zijlstra] + sched_yield() is intended for use with real-time scheduling policies + +seccomp.2 + michael kerrisk [adhemerval zanella, florian weimer, kees cook] + add some caveats regarding the use of seccomp filters + michael kerrisk + document the "default" filter return action + the kernel defaults to either seccomp_ret_kill_process + or seccomp_ret_kill_thread for unrecognized filter + return action values. + michael kerrisk [kees cook] + change seccomp_ret_action to seccomp_ret_action_full + in linux 4.14, the action component of the return value + switched from being 15 bits to being 16 bits. a new macro, + seccomp_ret_action_full, that masks the 16 bits was added, + to replace the older seccomp_ret_action. + michael kerrisk + explicitly note that other threads survive seccomp_ret_kill_thread + michael kerrisk + see also: add strace(1) + +send.2 + grégory vander schueren + add ealready to errors + +setns.2 + michael kerrisk + see also: add nsenter(1) + +shmop.2 + yubin ruan + note that return value of shmat() is page-aligned + +sigaction.2 + michael kerrisk + rework discussion of sa_siginfo handler arguments + expand and rework the text a little, in particular adding + a reference to sigreturn(2) as a source of further + information about the ucontext argument. + michael kerrisk + mention that libc sets the act.sa_restorer field + +sigaltstack.2 + michael kerrisk [walter harms] + reword bugs text to be a little clearer + michael kerrisk + add explicit error handling to example code + michael kerrisk + add use of sigaction() to example code + +sigreturn.2 + michael kerrisk + make it a little clearer that a stack frame is created by the kernel + michael kerrisk + glibc has a simple wrapper for sigreturn() that returns enosys + +splice.2 + michael kerrisk + since linux 2.6.31,'fd_in' and 'fd_out' may both refer to pipes + +stat.2 + michael kerrisk [richard knutsson] + use lstat() instead of stat() + it's more logical to use lstat() in the example code, + since one can then experiment with symbolic links, and + also the s_iflnk case can also occur. + neilbrown + correct at_no_automount text and general revisions + expand on the relationship between fstatat() and the other three + functions, and improve the description of at_no_automount. + specifically, both stat() and lstat() act the same way with + respect to automounts, and that behavior matches fstatat() with + the at_no_automount flag. + +statfs.2 + michael kerrisk + add some comments noting filesystems that are no longer current + michael kerrisk + add comments describing a few filesystem types + +time.2 + michael kerrisk + note that time() may be implemented in the vdso + michael kerrisk [victor porton] + language fix-up: clarify that "tasks" means "work" + see https://bugzilla.kernel.org/show_bug.cgi?id=197183 + +userfaultfd.2 + mike rapoport + bugs: document spurious uffd_event_fork + +write.2 +fsync.2 +close.2 + neilbrown [jeff layton] + update description of error codes + since 4.13, errors from writeback are more reliably reported + to all file descriptors that might be relevant. + + add notes to this effect, and also add detail about enospc and + edquot which can be delayed in a similar many to eio - for nfs + in particular. + +abort.3 + michael kerrisk + starting with glibc 2.27, abort() does not attempt to flush streams + michael kerrisk + see also: add assert(3) + +backtrace_symbols_fd(3) + stefan puiu [walter harms] + backtrace_symbols_fd() can trigger a call to malloc() + +daemon.3 + michael kerrisk + see also: add daemon(7), logrotate(8) + +errno.3 + michael kerrisk + note use of errno(1) to look up error names and numbers + michael kerrisk + update error list for posix.1-2008 + posix.1-2008 specified a couple of new errors not present in + posix.1-2001. + michael kerrisk [walter harms] + note the use of perror(3) and strerror(3) + michael kerrisk + recast the advice against manually declaring 'errno' + recast the advice against manually declaring 'errno' to + a more modern perspective. it's 13 years since the original + text was added, and even then it was describing old behavior. + cast the description to be about behavior further away in + time, and note more clearly that manual declaration will + cause problems with modern c libraries. + michael kerrisk + add some missing errors + michael kerrisk + error numbers are positive values (rather than nonzero values) + posix.1-2008 noted the explicitly the change (to align with + the c standards) that error numbers are positive, rather + than nonzero. + michael kerrisk + reorganize the text and add some subheadings + restructure the text and add some subheadings for better + readability. no (intentional) content changes. + michael kerrisk [wesley aptekar-cassels] + note that error numbers vary somewhat across architectures + added after a patch from wesley aptekar-cassels that proposed + to add error numbers to the text. + michael kerrisk + note the also provides the symbolic error names + michael kerrisk [walter harms] + explicitly note that error numbers vary also across unix systems + +exec.3 + michael kerrisk + glibc 2.24 dropped cwd from the default path + document the glibc 2.24 change that dropped cwd from the default + search path employed by execlp(), execvp() and execvpe() when + path is not defined. + +fexecve.3 + michael kerrisk + o_path file descriptors are also usable with fexecve() + cristian rodríguez + fexecve() is now implemented with execveat(2), where available + michael kerrisk + add some detail on the glibc implementation of fexecve() via execveat(2) + +ffs.3 + michael kerrisk + glibc 2.27 relaxes the ftm requirements for ffsl() and ffsll() + +get_nprocs_conf.3 + michael kerrisk + see also: add nproc(1) + +lround.3 + michael kerrisk [david eckardt] + clarify that lround() rounds *halfway cases" away from zero + see https://bugzilla.kernel.org/show_bug.cgi?id=194601 + +makedev.3 + adrian bunk + glibc has deprecated exposing the definitions via + +mallinfo.3 + jakub wilk + fix the example + remove reference to non-standard "tlpi_hdr.h" and replace calls to + functions that were declared in this header. + +malloc.3 + michael kerrisk + see also: add valgrind(1) + +popen.3 + michael kerrisk + add a cross reference to caveats in system(3) + all of the same risks regarding system() also apply to popen(). + +pthread_detach.3 + michael kerrisk [rahul bedarkar] + improve sentence describing freeing of resources on process termination + as reported by rahul, the existing sentence could be read as + meaning that resources of joined and terminated detached + threads are freed only at process termination. eliminate + that possible misreading. + +pthread_yield.3 + michael kerrisk [peter zijlstra] + pthread_yield() is intended for use with real-time scheduling policies + +setlocale.3 + michael kerrisk [křištof želechovski] + the standards do not specify all of the locale categories + +sockatmark.3 + seonghun lim + fix cruft in code example + +stdio.3 + michael kerrisk + use proper section cross references in function list + michael kerrisk + remove crufty reference to pc(1) + +sysconf.3 + michael kerrisk + mention get_nprocs_conf(3) + mention get_nprocs_conf(3) in discussion of _sc_nprocessors_conf + and _sc_nprocessors_onln. + +system.3 + michael kerrisk [bastien roucaries] + create a "caveats" subsection to hold warnings about the use of system() + see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=882222 + michael kerrisk [bastien roucaries] + mention path explicitly in discussion of system() and set-uid programs + michael kerrisk [bastien roucaries] + note that user input for system() should be carefully sanitized + michael kerrisk + mention file capabilities in discussion of privileged programs + michael kerrisk + correctly note which shell debian uses as (noninteractive) /bin/sh + +core.5 + michael kerrisk + add some notes on systemd and core dumps + michael kerrisk + dumps are not produced if core_pattern is empty and core_uses_pid is 0 + michael kerrisk [per böhlin] + rlimit_core is not enforced when piping core dump to a program + michael kerrisk + see also: add systemd-coredump(8) + michael kerrisk + see also: add coredumpctl(1) + +filesystems.5 + michael kerrisk [jonny grant] + replace crufty url reference for 'smb' with up-to-date url + michael kerrisk [jonny grant] + refer to vfat as an extended fat (not dos) filesystem + +proc.5 + michael kerrisk [miklos szered, ram pai] + correct the description of the parent mount id for /proc/pid/mountinfo + oliver ebert + add mmap-exclusive bit for /proc/[pid]/pagemap + marcus folkesson + update description of /proc//oom_score + lucas werkmeister + clarify permissions in /proc/[pid]/fd/ + michael kerrisk + add reference to pid_namespaces(7) for /proc/sys/kernel/ns_last_pid + +shells.5 + michael kerrisk + see also: add pam_shells(8) + +sysfs.5 + michael kerrisk + add a brief explanation of /sys/kernel + michael kerrisk + add a brief description of /sys/class/net + michael kerrisk + add a brief description of /sys/kernel/mm + michael kerrisk + add brief description of /sys/kernel/debug/tracing + michael kerrisk + add a description of /sys/kernel/mm/hugepages + +arp.7 + michael kerrisk + see also: add arpd(8) + +capabilities.7 + michael kerrisk + add a reference to xattr(7) in the discussion of extended attributes + michael kerrisk + see also: add captest(8) + +epoll.7 + michael kerrisk + note existence of kcmp() kcmp_epoll_tfd operation + +fifo.7 + michael kerrisk + refer reader to pipe(7) for details of i/o semantics of fifos + +hier.7 + michael kerrisk + see also: add file-hierarchy(7) + +icmp.7 + michael kerrisk + see also: add rdisc(8) + +man-pages.7 + michael kerrisk + note that "x86-64" is generally preferred over "x86_64" + g. branden robinson + add a use case for real minus character + +namespaces.7 + michael kerrisk + add a reference to new veth(4) page + michael kerrisk + example: refer also to example in clone(2) + +pid_namespaces.7 + michael kerrisk + see also: add reboot(2) + add because reboot(2) has special semantics for non-initial + pid namespaces. + +pthreads.7 + michael kerrisk + see also: add pthread_spin_init(3) and pthread_spin_lock(3) + +socket.7 + michael kerrisk [petr malat, tobias klausmann] + correct the description of so_rxq_ovfl + +standards.7 + michael kerrisk + see also: add getconf(1), confstr(3), pathconf(3), sysconf(3) + +user_namespaces.7 + christian brauner [michael kerrisk] + document new 340 line idmap limit + +ld.so.8 + michael kerrisk [yubin ruan] + simplify language around conferring capabilities + the statement "conferring permitted or effective capabilities" + to the process is somewhat redundant. binaries with capabilities + confer capabilities only to those process capability sets, so it's + simpler to just say "confers capabilities to the process". + + +==================== changes in man-pages-4.15 ==================== + +released: 2018-02-02, palo alto + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +adam liddell +andrea parri +andries e. brouwer +elie roudninski +eric benton +florian weimer +g. branden robinson +jakub wilk +joel williamson +john hubbard +jorgen hansen +keno fischer +michael kerrisk +michal hocko +neilbrown +nikola forró +nikolay borisov +pradeep kumar +qingfeng hao +ricardo biehl pasquali +roblabla +roman gushchin +shawn landden +stefan hajnoczi +stefan raspl +tejun heo + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +s390_sthyi.2 + qingfeng hao [michael kerrisk] + new page for s390-specific s390_sthyi(2) + +network_namespaces.7 + michael kerrisk + new page describing network namespaces + based on content moved from namespaces(7) + +vsock.7 + stefan hajnoczi [jorgen hansen, michael kerrisk] + document the vsock socket address family + + +newly documented interfaces in existing pages +--------------------------------------------- + +cgroups.7 + michael kerrisk [tejun heo] + document cgroups v2 "thread mode" + michael kerrisk [tejun heo] + document cgroup v2 delegation via the 'nsdelegate' mount option + michael kerrisk + document the cgroup.max.depth and cgroup.max.descendants files + michael kerrisk + document 'release_agent' mount option + michael kerrisk [roman gushchin] + document /sys/kernel/cgroup/delegate + michael kerrisk [roman gushchin] + document /sys/kernel/cgroup/features + michael kerrisk [roman gushchin] + document cgroups v2 cgroup.stat file + + +global changes +-------------- + +various pages + g. branden robinson + standardize on "nonzero" + also add this term to the style guide in man-pages(7). + + +changes to individual pages +--------------------------- + +bpf.2 + nikolay borisov + sync list of supported map types with 4.14 kernel + +copy_file_range.2 + michael kerrisk + library support was added in glibc 2.27 + shawn landden + glibc provides a user-space emulation where the system call is absent + florian weimer + efbig errors are possible, similar to write(2) + michael kerrisk + errors: add eisdir + michael kerrisk + order errors alphabetically + michael kerrisk + add comment to code example explaining use of syscall(2) + +fcntl.2 +read.2 +write.2 + neilbrown + document "lost locks" as cause for eio. + if an advisory lock is lost, then read/write requests on any + affected file descriptor can return eio - for nfsv4 at least. + +memfd_create.2 + michael kerrisk + glibc support for memfd_create() was added in version 2.27 + +mlock.2 + michael kerrisk + make details for mlock_onfault a little more explicit + michael kerrisk + glibc support for mlock2() is added in version 2.27 + +mmap.2 + john hubbard [michael hocko] + map_fixed is no longer discouraged + map_fixed has been widely used for a very long time, yet the man + page still claims that "the use of this option is discouraged". + john hubbard + map_fixed updated documentation + -- expand the documentation to discuss the hazards in + enough detail to allow avoiding them. + + -- mention the upcoming map_fixed_safe flag. + + -- enhance the alignment requirement slightly. + +mount.2 + keno fischer [michael kerrisk] + add einval error condition when ms_binding mnt_locked submounts + +mprotect.2 +pkey_alloc.2 + michael kerrisk + glibc support for memory protection keys was added in version 2.27 + +perf_event_open.2 + michael kerrisk + see also: add perf(1) + +pkey_alloc.2 + michael kerrisk + clarify description of pkey_alloc() 'flags' argument + +prctl.2 + michael kerrisk + defer to capabilities(7) for discussion of the "keep capabilities" flag + +recvmmsg.2 +sendmmsg.2 + nikola forró + point out that error handling is unreliable + +seccomp.2 + michael kerrisk + clarify that seccomp_ret_trap sigsys signal is thread-directed + +syscalls.2 + michael kerrisk + add s390-specific s390_sthyi(2) to syscall list + +unshare.2 + michael kerrisk + clarify that eusers occurred only until kernel 4.8 + +errno.3 + michael kerrisk + 'errno -s' can be used to search for errors by string in description + michael kerrisk + add linux error text corresponding to enomem + +fgetpwent.3 + michael kerrisk + add missing attributes preamble + +fts.3 + michael kerrisk [pradeep kumar] + fts_pathlen = strlen(fts_path) + strlen(fts_name) + +fuse.4 + michael kerrisk + places errors in alphabetical order (no content changes) + +veth.4 + michael kerrisk + add network_namespaces(7) + +sysfs.5 + michael kerrisk + refer to cgroups(7) for information about files in /sys/kernel/cgroup + +capabilities.7 + michael kerrisk + note which capability sets are affected by secbit_no_setuid_fixup + note explicitly that secbit_no_setuid_fixup is relevant for + the permitted, effective, and ambient capability sets. + michael kerrisk + deemphasize the ancient prctl(2) pr_set_keepcaps command + the modern approach is secbits_keep_caps. + michael kerrisk + clarify effect of cap_setfcap + make it clear that cap_setfcap allows setting arbitrary + capabilities on a file. + michael kerrisk + clarify which capability sets are effected by secbit_keep_caps + this flag has relevance only for the process permitted and + effective sets. + michael kerrisk + rephrase cap_setpcap description + * mention kernel versions. + * place current kernel behavior first + michael kerrisk + secbit_keep_caps is ignored if secbit_no_setuid_fixup is set + michael kerrisk + ambient set is also cleared when uids are set to nonzero value + +cgroups.7 + michael kerrisk + add a more complete description of cgroup v1 named hierarchies + michael kerrisk + add a section on unmounting cgroup v1 filesystems + michael kerrisk + add subsection describing cgroups v2 subtree delegation + michael kerrisk + mention enoent error that can occur when writing to subtree_control file + michael kerrisk + add list of currently available version 2 controllers + nikolay borisov + add information about rdma controller + michael kerrisk + rewrite the description of cgroup v2 subtree control + michael kerrisk [tejun heo] + note linux 4.11 changes to cgroup v2 delegation containment rules + michael kerrisk + systemd(1) nowadays automatically mounts the cgroup2 filesystem + michael kerrisk + clarify that cgroup.controllers is read-only + michael kerrisk + elaborate a little on problems of splitting threads across cgroups in v1 + michael kerrisk [tejun heo] + tweak the description of delegation of cgroup.subtree_control + +ip.7 + ricardo biehl pasquali + inaddr_* values cannot be assigned directly to 's_addr' + michael kerrisk + s/inaddr_any/inaddr_loopback/ in discussion of htonl() + inaddr_loopback is a better example, since it is not + byte-order neutral. + +namespaces.7 +network_namespaces.7 + michael kerrisk + move content from namespaces(7) to network_namespaces(7) + +pid_namespaces.7 + michael kerrisk + see also: add mount_namespaces(7) + +sched.7 + michael kerrisk [andrea parri] + correctly describe effect of priority changes for rt threads + the placement of a thread in the run queue for its new + priority depends on the direction of movement in priority. + (this appears to contradict posix, except in the case of + pthread_setschedprio().) + +user_namespaces.7 + michael kerrisk + mention ns_get_owner_uid ioctl() operation + + +==================== changes in man-pages-4.16 ==================== + +released: 2018-04-30, munich + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +adam borowski +andy owen +carlos o'donell +carsten grohmann +elvira khabirova +enrique garcia +frederic brault +heinrich schuchardt +howard johnson +jakub wilk +jan kara +jann horn +john hubbard +jürg billeter +konstantin grinemayer +konstantin khlebnikov +martin mares +mathieu desnoyers +mattias andrée +michael kerrisk +michal hocko +mike frysinger +nikos mavrogiannopoulos +robin kuzmin +ross zwisler +rusty russell +serge e. hallyn +song liu +tomi salminen + +apologies if i missed anyone! + + +newly documented interfaces in existing pages +--------------------------------------------- + +membarrier.2 + mathieu desnoyers [michael kerrisk] + document new membarrier commands introduced in linux 4.16 + document the following membarrier commands introduced in + linux 4.16: + + membarrier_cmd_global_expedited + (the old enum label membarrier_cmd_shared is now an + alias to preserve header backward compatibility) + membarrier_cmd_register_global_expedited + membarrier_cmd_private_expedited_sync_core + membarrier_cmd_register_private_expedited_sync_core + +mmap.2 + jan kara [ross zwisler, michael kerrisk] + add description of map_shared_validate and map_sync + michal hocko [john hubbard, michael kerrisk, jann horn] + document new map_fixed_noreplace flag + 4.17+ kernels offer a new map_fixed_noreplace flag which allows + the caller to atomically probe for a given address range. + +readv.2 +io_submit.2 + jürg billeter + document rwf_append added in linux 4.16 + +capabilities.7 + michael kerrisk + describe file capability versioning + michael kerrisk [serge e. hallyn] + document namespaced-file capabilities + [there's still more work to be done on this new text] + + +changes to individual pages +--------------------------- + +bpf.2 + michael kerrisk + update list of architectures that support jited ebpf + and note kernel version numbers where support is added. + michael kerrisk + kernel 4.15 added config_bpf_jit_always_on + this causes the jit compiler to be always on and + forces bpf_jit_enable to 1. + +execve.2 + michael kerrisk + note that describing execve as "executing a new process" is misleading + this misdescription is so common that it's worth calling it out + explicitly. + michael kerrisk + more explicitly describe effect of execve() in the opening paragraph + +fallocate.2 + michael kerrisk + since linux 4.16, btrfs supports falloc_fl_zero_range + +getrlimit.2 + michael kerrisk + cap_sys_resource capability is required in *initial user namespace* + +io_submit.2 + michael kerrisk + add kernel version numbers for various 'aio_rw_flags' flags + michael kerrisk + place 'aio_rw_flags' in alphabetical order + +mmap.2 + jann horn + map_fixed is okay if the address range has been reserved + clarify that map_fixed is appropriate if the specified address + range has been reserved using an existing mapping, but shouldn't + be used otherwise. + michael kerrisk + move the text on map_fixed to notes + this text has become rather long, making it somewhat + unwieldy in the discussion of the mmap() flags. therefore, + move it to notes, with a pointer in description referring + the reader to notes. + michael kerrisk [heinrich schuchardt] + clarify that when addr==null, address chosen by kernel is page-aligned + michael kerrisk + add a little historical detail on the obsolete map_denywrite + +mount.2 + michael kerrisk + errors: add ebusy for the case of trying to stack same mount twice + michael kerrisk + remove a couple of obsolete ebusy errors + as far as i can tell, these ebusy errors disappeared + with the addition of stackable mounts in linux 2.4. + +msgget.2 +semget.2 +shmget.2 + michael kerrisk + the purpose of "flags" == 0 is to obtain id of an existing ipc object + this was implied in these pages, but the meaning of "flags" == 0 + could be more explicit, as indicated by questions such as + https://stackoverflow.com/questions/49833569/flag-value-of-semget-function + +open.2 + jann horn + document more -etxtbsy conditions + jakub wilk + add missing argument for snprintf() in example code + +perf_event_open.2 + song liu + add type kprobe and uprobe + two new types kprobe and uprobe are being added to + perf_event_open(), which allow creating kprobe or + uprobe with perf_event_open. this patch adds + information about these types. + +ptrace.2 + jann horn + copy retval info for seccomp_get_filter to right section + the "return value" section made a claim that was incorrect for + ptrace_seccomp_get_filter. explicitly describe the behavior of + ptrace_seccomp_get_filter in the "return value" section (as + usual), but leave the now duplicate description in the section + describing ptrace_seccomp_get_filter, since the + ptrace_seccomp_get_filter section would otherwise probably become + harder to understand. + +readv.2 + michael kerrisk + remove redundant sentence + +seccomp.2 + michael kerrisk + note that execve() may change syscall numbers during life of process + on a multiarch/multi-abi platform such as modern x86, each + architecture/abi (x86-64, x32, i386)has its own syscall numbers, + which means a seccomp() filter may see different syscall numbers + over the life of the process if that process uses execve() to + execute programs that has a different architectures/abis. + michael kerrisk + note which architectures support seccomp bpf + michael kerrisk + in example, clearly note that x32 syscalls are >= x32_syscall_bit + +shutdown.2 + carsten grohmann + see also: add close(2) + +syscall.2 + adam borowski + add riscv + +wait.2 + michael kerrisk [robin kuzmin] + wait() and waitpid() block the calling thread (not process) + +wait4.2 + michael kerrisk [martin mares] + soften the warning against the use of wait3()/wait4() + these functions are nonstandard, but there is no replacement. + + see https://bugzilla.kernel.org/show_bug.cgi?id=199215 + +crypt.3 +encrypt.3 + carlos o'donell [michael kerrisk] + add notes about _xopen_crypt + the distribution may choose not to support _xopen_crypt in the + case that the distribution has transitioned from glibc crypt to + libxcrypt. + +fseek.3 + michael kerrisk [andy owen] + errors: ebadf should be espipe + michael kerrisk + improve epipe error text + +getcwd.3 + carlos o'donell + mention that "(unreachable)" is no longer returned for glibc >= 2.27. + +makedev.3 + michael kerrisk + since glibc 2.28, no longer defines these macros + +pthread_create.3 + frederic brault + note default thread stack size for several architectures + +tsearch.3 + jann horn + clarify items vs nodes + the manpage claimed that tsearch() returns a pointer to a data + item. this is incorrect; tsearch() returns a pointer to the + corresponding tree node, which can also be interpreted as a + pointer to a pointer to the data item. + + since this api is quite unintuitive, also add a clarifying + sentence. + jann horn + tdelete() can return dangling pointers + posix says that deleting the root node must cause tdelete() to + return some unspecified non-null pointer. glibc implements it by + returning a dangling pointer to the (freed) root node. + therefore, explicitly note that tdelete() may return bad pointers + that must not be accessed. + +elf.5 + michael kerrisk + see also: add patchelf(1) + +filesystems.5 + michael kerrisk + add an entry for tmpfs(5) + +group.5 + michael kerrisk + see also: add vigr(8) + +passwd.5 + michael kerrisk + see also: add vipw(8) + +sysfs.5 + michael kerrisk + add brief note on /sys/fs/smackfs + +tmpfs.5 + mike frysinger + document current mount options + some of this content is moved from the mount(8) man page. + style was based on proc(5) sections. + michael kerrisk + remove reference to mount(8) for discussion of mount options + the mount options are now described in this page. + michael kerrisk + see also: add documentation/vm/transhuge.txt + michael kerrisk + reformat 'huge' and 'mpol' mount option values as lists + michael kerrisk + describe 'mpol' mount options + based on text from documentation/filesystems/tmpfs.txt. + michael kerrisk + document 'huge' mount options + based on text from documentation/vm/transhuge.txt. + michael kerrisk + see also: add set_mempolicy(2) + michael kerrisk + document mpol=local mount option + +capabilities.7 + michael kerrisk + remove redundant mention of ptrace_seccomp_get_filter + +cgroups.7 + michael kerrisk + cgroup.events transitions generate pollerr as well as pollpri + +mount_namespaces.7 + michael kerrisk + note another case where shared "peer groups" are formed + +namespaces.7 + michael kerrisk [konstantin khlebnikov] + mention that device id should also be checked when comparing ns symlinks + when comparing two namespaces symlinks to see if they refer to + the same namespace, both the inode number and the device id + should be compared. this point was already made clear in + ioctl_ns(2), but was missing from this page. + michael kerrisk + note an idiosyncrasy of /proc/[pid]/ns/pid_for_children + /proc/[pid]/ns/pid_for_children has a value only after first + child is created in pid namespace. verified by experiment. + +network_namespaces.7 + michael kerrisk + network namespaces isolate the unix domain abstract socket namespace + michael kerrisk + add cross reference to unix(7) + for further information on unix domain abstract sockets. + +posixoptions.7 + carlos o'donell + expand xsi options groups + we define in detail the x/open system interfaces i.e. _xopen_unix + and all of the x/open system interfaces (xsi) options groups. + + the xsi options groups include encryption, realtime, advanced + realtime, realtime threads, advanced realtime threads, tracing, + streams, and legacy interfaces. + michael kerrisk + use a more consistent, less cluttered layout for option lists + michael kerrisk + make function lists more consistent and less cluttered + use more consistent layout for lists of functions, and + remove punctuation from the lists to make them less cluttered. + +socket.7 + michael kerrisk [tomi salminen] + fix error in so_incoming_cpu code snippet + the last argument is passed by value, not reference. + +time.7 + michael kerrisk [enrique garcia] + mention clock_gettime()/clock_settime() rather than [gs]ettimeofday() + gettimeofday() is declared obsolete by posix. mention instead + the modern apis for working with the realtime clock. + + see https://bugzilla.kernel.org/show_bug.cgi?id=199049 + +unix.7 + michael kerrisk [rusty russell] + errors: add ebadf for sending closed file descriptor with scm_rights + +vdso.7 + michael kerrisk + vdso symbols (system calls) are not visible to seccomp(2) filters + +xattr.7 + michael kerrisk + see also: add selinux(8) + +ld.so.8 + mike frysinger + make lack of separator escaping explicit + make it clear that the delimiters in ld_preload, ld_library_path, + and ld_audit cannot be escaped so people don't try various methods + (such as \:) to workaround it. + michael kerrisk + remove unneeded mention of path in discussion of ld_library_path + this brief sentence doesn't add value to the text. + + +==================== changes in man-pages-5.00 ==================== + +released: 2019-03-06, munich + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +adam manzanares +alan jenkins +alec leamas +alessandro vesely +alexander e. patrakov +allison randal +amir goldstein +anatoly borodin +andreas gruenbacher +andreas westfeld +andrei vagin +andrew price +anthony iliopoulos +antonio chirizzi +antonio ospite +arkadiusz drabczyk +balbir singh +benjamin peterson +bernd petrovitsch +bert hubert +bjarni ingi gislason +burkhard lück +carlos o'donell +claudio scordino +daniel borkmann +daniel kamil kozar +davidlohr bueso +davidlohr bueso +david newall +dmitry v. levin +elliot hughes +elvira khabirova +emil fihlman +enrico scholz +eric benton +eric sanchis +eugene syromiatnikov +eugene syromyatnikov +felipe gasper +florian weimer +frank theile +g. branden robinson +goldwyn rodrigues +goldwyn rodrigues +göran häggsjö +harry mallon +heinrich schuchardt +heiko carstens +helge deller +henry wilson +hiroya ito +howard johnson +ian turner +ignat loskutov +ingo schwarze +jakub wilk +james weigle +jann horn +jann horn +jason a. donenfeld +jeff moyer +jens thoms toerring +joe lawrence +johannes altmanninger +johannes liebermann +jonny grant +joseph c. sible +joseph sible +josh gao +josh triplett +kees cook +keith thompson +keno fischer +konrad rzeszutek wilk +konst mayer +leah hanson +lucas de marchi +lucas werkmeister +luka macan +marc-andré lureau +marcus gelderie +marcus gelderie +marko myllynen +mark schott +matthew bobrowski +matthew kilgore +mattias engdegård +mauro carvalho chehab +michael becker +michael kerrisk +michael witten +michal hocko +mihir mehta +mike frysinger +mike frysinger +mike rapoport +mike weilgart +nadav har'el +nick gregory +niklas hambüchen +nikola forró +nixiaoming +oded elisha +paul eggert +paul millar +philip dumont +pierre chifflier +quentin monnet +radostin stoyanov +robert o'callahan +robert p. j. day +robin kuzmin +ruschein +sam varshavchik +sean young +shawn landden +simone piccardi +snyh +solal pirelli +stan schwertly +stephan knauss +szabolcs nagy +thomas posch +tobias klauser +troy engel +tycho andersen +tycho kirchner +vince weaver +wang nan +william kucharski +xiao yang + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +s390_guarded_storage.2 + eugene syromyatnikov + new page documenting s390_guarded_storage(2) s390-specific system call + +address_families.7 + michael kerrisk [eugene syromyatnikov] + new page that contains details of socket address families + there is too much detail in socket(2). move most of it into + a new page instead. + +bpf-helpers.7 + michael kerrisk [daniel borkmann, quentin monnet] + add new man page for ebpf helper functions + (autogenerated from kernel source files) + + +removed pages +------------- + +mdoc.7 +mdoc.samples.7 + michael kerrisk [ingo schwarze] + remove mdoc(7) and mdoc.samples(7) + groff_mdoc(7) from the groff project provides a better + equivalent of mdoc.samples(7) and the 'mandoc' project + provides a better mdoc(7). and nowadays, there are virtually + no pages in "man-pages" that use mdoc markup. + + +newly documented interfaces in existing pages +--------------------------------------------- + +fanotify_init.2 +fanotify.7 + nixiaoming [amir goldstein, michael kerrisk] + document fan_report_tid + fanotify_init.2: add new flag fan_report_tid + fanotify.7: update description of member pid in + struct fanotify_event_metadata + amir goldstein + document fan_mark_filesystem + monitor fanotify events on the entire filesystem. + matthew bobrowski [amir goldstein] + document fan_open_exec and fan_open_exec_perm + +io_submit.2 + adam manzanares + document iocb_flag_ioprio + +msgctl.2 +semctl.2 +shmctl.2 + davidlohr bueso [joe lawrence, michael kerrisk] + document stat_any commands + +prctl.2 + konrad rzeszutek wilk [michael kerrisk] + document pr_set_speculation_ctrl and pr_get_speculation_ctrl + +sched_setattr.2 + claudio scordino [michael kerrisk] + document sched_flag_dl_overrun and sched_flag_reclaim + +socket.2 + tobias klauser + document af_xdp + document af_xdp added in linux 4.18. + +inotify.7 + henry wilson + document in_mask_create + +unix.7 + michael kerrisk + document so_passsec + michael kerrisk + document scm_security ancillary data + + +new and changed links +--------------------- + +reallocarray.3 + michael kerrisk + new link to malloc(3) + +precedence.7 + josh triplett + add as a redirect to operator.7 + + +global changes +-------------- + +various pages + michael kerrisk [g. branden robinson] + use '\e' rather than '\\' to get a backslash + +various pages + michael kerrisk [bjarni ingi gislason, g. branden robinson] + use zero‐width space in appropriate locations + +various pages + michael kerrisk + clarify the distinction between "file descriptor" and "file description" + +various pages + mike rapoport + update paths for in-kernel memory management documentation files + +a few pages + michael kerrisk + change references to '2.6.0-test*' series kernels to just '2.6.0' + + +changes to individual pages +--------------------------- + +iconv.1 + marko myllynen + see also: add uconv(1) + +localedef.1 + howard johnson + note that -f and -c, are reversed from what you might expect + +time.1 + michael kerrisk [johannes altmanninger] + document the -q/--quiet option + jakub wilk + update bug reporting address + +bpf.2 + tobias klauser + update jit support list for linux 4.18 + jit support for x86-32 was during the linux 4.18 release cycle. + also correct the entry for mips (only mips64 is supported). + oded elisha + fix bug in example + quentin monnet + see also: add bpf-helpers(7) + +capget.2 + michael kerrisk + remove crufty sentence suggesting use of deprecated functions + remove crufty sentence suggesting use of deprecated capsetp(3) and + capgetp(3); the manual page for those functions has long (at least + as far back as 2007) noted that they are deprecated. + michael kerrisk + remove first paragraph, which repeats details from capabilities(7) + +chroot.2 + michael kerrisk + mention /proc/[pid]/root + +clock_getres.2 + michael kerrisk [jens thoms toerring] + clock_monotonic_raw does not count while the system is suspended + michael kerrisk [jens thoms toerring] + on linux clock_monotonic counts time that the system has run since boot + michael kerrisk [jens thoms toerring] + clock_monotonic does not count while the system is suspended + michael kerrisk + errors: add einval error for noncanonical clock_settime() value + +clone.2 + michael kerrisk + rework discussion of threads and signals + the discussion is phrased in terms of signals sent using kill(2), + but applies equally to a signal sent by the kernel. + jann horn + pending clone_newpid prevents thread creation + michael kerrisk + clarify the discussion of threads and signals + and explicitly introduce the terms "process-directed" and + "thread-directed" signals. + eugene syromyatnikov + add information about clone and clone2 on ia-64 + michael kerrisk + errors: einval occurs with clone_newuser if !config_user_ns + +connect.2 + benjamin peterson + document error semantics of nonblocking unix domain sockets + +epoll_ctl.2 + michael kerrisk + use the term "interest list" consistently + +epoll_wait.2 + michael kerrisk + clarify the behavior when epoll_wait()-ing on an empty interest list + michael kerrisk + note that epoll_wait() round robins through the set of ready descriptors + +eventfd.2 + michael kerrisk + move text noting that eventfd() creates a fd earlier in the page + +fcntl.2 + michael kerrisk + actual pipe capacity may in practice be less than nominal capacity + the number of bytes that can be written to the pipe may be less + (sometimes substantially less) than the nominal capacity. + eugene syromyatnikov + mention that l_sysid is not used even if present + michael kerrisk + briefly explain the meaning of the 'l_sysid' field in 'struct flock' + +futex.2 + benjamin peterson + make the example use c11 atomics rather than gcc builtins + +getcpu.2 + tobias klauser [michael kerrisk] + getcpu() now has a glibc wrapper; remove mention of syscall(2) + the glibc wrapper was added in glibc 2.29, release on 1 feb 2019. + +getgid.2 +getpid.2 +getuid.2 +pipe.2 +syscall.2 + eugene syromiatnikov [michael kerrisk] + describe 2nd return value peculiarity + some architectures (ab)use second return value register for + additional return value in some system calls. let's describe this. + +getgroups.2 + michael kerrisk + note that a process can drop all groups with: setgroups(0, null) + +getrlimit.2 + eugene syromyatnikov + note that setrlimit(rlimit_cpu) doesn't fail + michael kerrisk + resource limits are process-wide attributes shared by all threads + this was already noted in pthreads(7), but bears repeating here. + eugene syromyatnikov + correct information about large limits on 32-bit architectures + +gettid.2 + michael kerrisk + glibc provides a wrapper since version 2.30 + +gettimeofday.2 + michael kerrisk + errors: add einval for noncanonical 'tv' argument to settimeofday() + +gettimeofday.2 +clock_getres.2 + michael kerrisk [jens thoms toerring] + errors: einval can occur if new real time is less than monotonic clock + +getxattr.2 +removexattr.2 +setxattr.2 + michael kerrisk [andreas gruenbacher, enrico scholz] + errors: replace enoattr with enodata + see also https://bugzilla.kernel.org/show_bug.cgi?id=201995 + +inotify_add_watch.2 + paul millar + add in_onlydir based error + henry wilson + note errors that can occur for in_mask_create + +io_submit.2 + jeff moyer + fix the description of aio_data + aio_data is not a kernel-internal field. + +madvise.2 + michal hocko [niklas hambüchen] + madv_free clarify swapless behavior + +memfd_create.2 + marc-andré lureau + update hugetlb file-sealing support + lucas de marchi + fix header for memfd_create() + joseph c. sible + _gnu_source is required + +mmap.2 + elliott hughes + explicitly state that the fd can be closed + jann horn [michal hocko, william kucharski] + fix description of treatment of the hint + the current manpage reads as if the kernel will always pick a free + space close to the requested address, but that's not the case. + +mount.2 + michael kerrisk + clearly distinguish per-mount-point vs per-superblock mount flags + michael kerrisk + ms_silent is ignored when changing propagation type + michael kerrisk + attempts to change ms_silent setting during remount are silently ignored + michael kerrisk [harry mallon] + document erofs for read-only filesystems + see https://bugzilla.kernel.org/show_bug.cgi?id=200649 + michael kerrisk + clarify that per-superblock flags are shared during remount + michael kerrisk + remove crufty sentence about ms_bind + ms_remount + michael kerrisk + mention /proc/pid/mountinfo + many people are unaware of the /proc/pid/mountinfo file. provide + a helpful clue here. + michael kerrisk + mandatory locking also now requires config_mandatory_file_locking + michael kerrisk [simone piccardi] + add ms_strictatime to list of flags that can be used in remount + michael kerrisk + eacces: note some reasons why a filesystem may be read-only + michael kerrisk + see also: add ioctl_iflags(2) + +msgop.2 + michael kerrisk + correct the capability description for msgsnd() eaccess error + +nfsservctl.2 + michael kerrisk + add versions section noting that this system call no longer exists + +open.2 + lucas werkmeister + document enxio for sockets + michael kerrisk + clarify a special use case of o_nonblock for devices + eugene syromiatnikov + mention presence of unused o_rsync definition + o_rsync is defined in on hp pa-risc, but is not + used anyway. + eugene syromiatnikov + document fasync usage in linux uapi headers + andrew price + remove o_direct-related quotation + remove a section that adds no benefit to the discussion of o_direct. + michael kerrisk [robin kuzmin] + clarify that o_nonblock has no effect on poll/epoll/select + +perf_event_open.2 + vince weaver [wang nan] + document the perf_event_ioc_pause_output ioctl + the perf_event_ioc_pause_output ioctl was introduced in linux 4.7. + vince weaver + fix wording in multiplexing description + vince weaver + clarify exclude_idle + vince weaver + document the perf_event_ioc_query_bpf ioctl + vince weaver + document the perf_event_ioc_modify_attributes ioctl + vince weaver + fix prctl behavior description + +pivot_root.2 + elvira khabirova + explain the initramfs case and point to switch_root(8) + joseph sible [joseph c. sible] + document einval if root is rootfs + +pkey_alloc.2 + michael kerrisk [szabolcs nagy] + switch to glibc prototype in synopsis + +poll.2 + michael kerrisk + note that poll() and ppoll() are not affected by o_nonblock + +posix_fadvise.2 + eugene syromyatnikov + describe the difference between fadvise64/fadvise64_64 + +prctl.2 + benjamin peterson + pr_set_mm_exe_file may now be used as many times as desired + michael kerrisk + add some further historical details on pr_set_mm_exe_file + michael kerrisk [jann horn] + explain the circumstances in which the parent-death signal is sent + michael kerrisk + rework the pr_set_pdeathsig description a little, for easier readability + michael kerrisk + add additional info on pr_set_pdeathsig + the signal is process directed and the siginfo_t->si_pid + filed contains the pid of the terminating parent. + michael kerrisk + note libcap(3) apis for operating on ambient capability set + (however, the libcap apis do not yet seem to have + manual pages...) + michael kerrisk + mention libcap apis for operating on capability bounding set + +ptrace.2 + dmitry v. levin + do not say that ptrace_o_tracesysgood may not work + jann horn + bugs: ptrace() may set errno to zero + +readdir.2 + eugene syromyatnikov + fix struct old_linux_dirent in accordance with current definition + +readv.2 + xiao yang [florian weimer] + fix wrong errno for an unknown flag + +rename.2 + michael kerrisk + glibc 2.28 adds library support for renameat2() + tobias klauser + add feature test macro for renameat2() + the glibc wrapper for renameat2() was added in glibc 2.28 and + requires _gnu_source. + eugene syromiatnikov + some additional notes regarding rename_whiteout + lucas werkmeister [michael kerrisk] + add kernel versions for rename_noreplace support + michael kerrisk + rework list of supported filesystems for rename_noreplace + tobias klauser + renameat2() now has a glibc wrapper; remove mention of syscall(2) + +s390_runtime_instr.2 + eugene syromyatnikov + add a note about runtime_instr.h availability + +s390_sthyi.2 + eugene syromyatnikov [heiko carstens] + some minor additions + +sched_setattr.2 + michael kerrisk + add a bit more detail for sched_deadline + +sched_setparam.2 + michael kerrisk + clarify that scheduling parameters are per-thread (not per-process) + +seccomp.2 + michael kerrisk + (briefly) document seccomp_filter_flag_spec_allow + michael kerrisk + see also: add bpfc(1) + +select.2 + michael kerrisk + bugs: the use of value-result arguments is a design bug + michael kerrisk [robin kuzmin] + note that select() and pselect() are not affected by o_nonblock + +select_tut.2 + michael kerrisk [antonio chirizzi] + diagnose inet_aton() errors with simple fprintf() (not perror()) + +setgid.2 + michael kerrisk + clarify eperm capability requirements with respect to user namespaces + +setns.2 + michael kerrisk + when joining a user namespace, it must be a descendant user namespace + michael kerrisk + note capability requirements for changing pid namespace + note capability requirements for changing network, ipc, or uts namespace + note capability requirements for changing cgroup namespace + michael kerrisk + some text restructuring and reordering + +set_thread_area.2 + eugene syromyatnikov + mention related prctl() requests in see also + eugene syromyatnikov + mention that get_thread_area() is also linux-specific + eugene syromyatnikov + describe set_thread_area()/get_thread_area() on m68k/mips + +setuid.2 + michael kerrisk + clarify eperm capability requirements with respect to user namespaces + +sigaction.2 + eugene syromyatnikov [michael kerrisk] + describe obsolete usage of struct sigcontext as signal handler argument + +sigsuspend.2 + michael kerrisk + clarify that sigsuspend() suspends the calling *thread* + +socket.2 + michael kerrisk + remove references to external docs + this information is all in the new address_families(7) + michael kerrisk + add cross reference to address_families(7) + eugene syromyatnikov + reinstate af_vsock mention + michael kerrisk + simplify list of address families + remove many of the details that are in address_families(7) + nikola forró + remove notes concerning af_alg and af_xdp + all address families are now documented in address_families.7. + michael kerrisk + remove some more obscure protocols from address family list + the list of address families in this page is still + overwhelmingly long. so let's shorten it. + the removed entries are all in address_families(7). + michael kerrisk + remove a few obsolete protocols + documentation for these remains in address_families(7) + +socketpair.2 + eugene syromyatnikov + note that af_tipc also supports socketpair(2) + introduced by linux commit v4.12-rc1~64^3~304^2~1. + +stat.2 + michael kerrisk [alessandro vesely] + errors: enoent can occur where a path component is a dangling symlink + see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=909789 + benjamin peterson + see also: add statx(2) + +statx.2 + tobias klauser [michael kerrisk] + statx() now has a glibc wrapper; remove mention of syscall(2) + +syscall.2 + eugene syromyatnikov [michael kerrisk] + elaborate x32 abi specifics + snyh + fix wrong retval register number in alpha architecture + helge deller + parisc needs care with syscall parameters + michael kerrisk + rework table to render within 80 columns + +syscalls.2 + eugene syromyatnikov + change example of a thin syscall wrapper to chdir() + as truncate(3) should dispatch between truncate/truncate64, + as noted later in the page. + eugene syromyatnikov [michael kerrisk] + update syscall table + added: arc_gettls, arc_settls, arc_usr_cmpxchg, arch_prctl, + atomic_barrier, atomic_cmpxchg_32, bfin_spinlock, breakpoint, + clone2, cmpxchg, cmpxchg_badaddr, dma_memcpy, execv, get_tls, + getdomainname, getdtablesize, gethostname, getxgid, getxpid, + getxuid, metag_get_tls, metag_set_fpu_flags,metag_set_tls, + metag_set_global_bit, newfstatat, old_adjtimex, oldumount, + or1k_atomic, pread, pwrite, riscv_flush_icache, + sched_get_affinity, sched_set_affinity, set_tls, setaltroot, + sethae, setpgrp, spill, sram_alloc, sram_free, swapcontext, + switch_endian, sys_debug_setcontext, syscall, sysmips, timerfd, + usr26, usr32, xtensa. + + uncommented: memory_ordering + + renamed: ppc_rtas to rtas (__nr_rtas), ppc_swapcontext to + swapcontext (__nr_swapcontext). + eugene syromyatnikov + note about s390x and old_mmap + michael kerrisk + add s390_guarded_storage(2) + michael kerrisk + update syscall list for linux 4.18 + eugene syromyatnikov + note that not all architectures return errno negated + helge deller + parisc linux does not any longer emulate hp-ux + michael kerrisk + comment out details of a few system calls that only ever briefly existed + +unshare.2 + michael kerrisk [shawn landden] + same einval errors as for clone(2) can also occur with unshare(2) + tycho andersen + note einval when unsharing pid ns twice + the kernel doesn't allow unsharing a pid ns if it has + previously been unshared. + +ustat.2 + michael kerrisk + starting with version 2.28, glibc no longer provides a wrapper function + +vmsplice.2 + andrei vagin + note that vmsplice can splice pages from pipe to memory + +wait.2 + michael kerrisk + add some cross references to core(5) + +write.2 + michael kerrisk [nadav har'el] + return value: clarify details of partial write and + https://bugzilla.kernel.org/show_bug.cgi?id=197961 + goldwyn rodrigues + add details on partial direct i/o writes + +alloca.3 + michael kerrisk [robin kuzmin] + prevent any misunderstanding about when allocated memory is released + +bsd_signal.3 + xiao yang + fix the wrong version of _posix_c_source + +bstring.3 + michael kerrisk [emil fihlman] + correct argument list for memmem() prototype + +cmsg.3 + michael kerrisk + explain zero-initialization requirement for cmsg_nxthdr() + michael kerrisk + remove out of place mention of msg_ctrunc + this detail is covered in recvmsg(2), and now also in unix(7). + michael kerrisk + note that cmsg_firsthdr can return null + michael kerrisk + remove unnecessary 'fdptr' intermediate variable in example code + +des_crypt.3 +encrypt.3 + michael kerrisk + the functions described in these pages are removed in glibc 2.28 + +dlsym.3 + michael kerrisk + describe a case where a symbol value may be null + +errno.3 + michael kerrisk [robert p. j. day] + mention that errno(1) is part of the 'moreutils' package + +exec.3 + michael kerrisk [eugene syromyatnikov] + note that sparc provides an execv() system call + +exit.3 + mike frysinger + note wider sysexits.h availability + +ferror.3 + elliot hughes + warn about closing the result of fileno() + +fnmatch.3 + elliott hughes + clarify "shell wildcard pattern" + +getaddrinfo.3 + michael kerrisk [eric sanchis] + fix off-by-one error in example client program + +getcwd.3 + michael kerrisk + rework text on use of getcwd() system call + make it clear that all of the library functions described on this + page will use the getcwd() system call if it is present. + michael kerrisk + add details on the getcwd() syscall and how it used by libc functions + michael kerrisk + reorder the text describing "(unreachable)" being returned by getcwd() + +getmntent.3 + elliot hughes + clarify that endmntent() should be used rather than fclose() + +isatty.3 + michael kerrisk [jakub wilk] + most non-tty files nowadays result in the error enotty + historically, at least fifos and pipes yielded the error einval. + +lockf.3 + ian turner + errors: add eintr + +malloc.3 + michael kerrisk + add reference to glibc mallocinternals wiki + michael kerrisk + note that calloc() detects overflow when multiplying its arguments + michael kerrisk + since glibc 2.29, reallocarray() is exposed by defining _default_source + info gleaned from glibc news file. + +pthread_attr_init.3 + michael kerrisk [göran häggsjö, jakub wilk] + use correct printf() specifier for "size_t" in example program + +pthread_rwlockattr_setkind_np.3 + carlos o'donell + remove bug notes + +pthread_setname_np.3 + jakub wilk + explain _np suffix + add text to conforming to explaining that the "_np" + suffix is because these functions are non-portable. + +putenv.3 + michael kerrisk + note a glibc extension: putenv("name") removes an environment variable + +resolver.3 + michael becker + add documentation of res_nclose() + +strcmp.3 + heinrich schuchardt + clarify that strcmp() is not locale aware + +strcpy.3 + matthew kilgore + fix example code for strncpy, which could pass an incorrect length + michael kerrisk [frank theile] + use "destination" consistently (instead of "target" sometimes) + +strfry.3 + keith thompson + remove incorrect reference to rand(3) + +string.3 +strlen.3 +strnlen.3 + michael kerrisk [jakub wilk] + use 'bytes' not 'characters' + this is in line with posix terminology. + +system.3 + michael kerrisk [jonny grant] + use '(char *) null' rather than '(char *) 0' + michael kerrisk + note that system() can fail for the same reasons as fork(2) + arkadiusz drabczyk + mention that 'errno' is set on error + +termios.3 + eugene syromyatnikov + note an xtabs alpha issue + +trunc.3 + michael kerrisk [eric benton, g. branden robinson] + make the description a little clearer + michael kerrisk + emphasize that the return value is a floating-point number + +xcrypt.3 + jason a. donenfeld + warn folks not to use these functions + +lirc.4 + sean young + fix broken link + sean young + document error returns more explicitly + sean young + lirc.h include file is in /usr/include/linux/lirc.h + sean young [alec leamas, mauro carvalho chehab] + remove ioctls and feature bits which were never implemented + sean young + unsupported ioctl() operations always return enotty + sean young + lirc_mode_lirccode has been replaced by lirc_mode_scancode + sean young + document remaining ioctl (lirc_get_rec_timeout) + now all ioctls are documented. + sean young + timeout reports are enabled by default + sean young + some devices are send only + sean young + update see also + sean young + lirc_can_set_rec_duty_cycle_range was never supported + no driver ever supported such a thing. + michael kerrisk + clarify the description lirc_set_rec_timeout + +tty.4 + michael witten + add `vcs(4)' and `pty(7)' to the `see also' section + +vcs.4 + mattias engdegård [michael witten] + fix broken example code + +core.5 + michael kerrisk + add cross reference to vdso(7) where "virtual dso" is mentioned + +filesystems.5 + eugene syromyatnikov + mention sysfs(2) + +host.conf.5 + nikola forró + clarify glibc versions in which spoof options were removed + +proc.5 + michael kerrisk [philip dumont] + document /proc/[tid] + see also https://bugzilla.kernel.org/show_bug.cgi?id=201441 + michael kerrisk + add an overview section describing the groups of files under /proc + keno fischer [robert o'callahan] + correct description of nstgid + lucas werkmeister + document fdinfo format for timerfd + stephan knauss + mention /proc/uptime includes time spent in suspend + michael kerrisk + reword /proc/pid/fdinfo timerfd field descriptions as a hanging list + michael kerrisk + see also: add htop(1) and pstree(1) + fs/proc/uptime.c:uptime_proc_show() fetches time using + ktime_get_boottime which includes the time spent in suspend. + michael kerrisk + document /proc/pid/status coredumping field + michael kerrisk + mention choom(1) in discussion of /proc/[pid]/oom_score_adj + michael kerrisk + add a few details on /proc/pid/fdinfo timerfd + michael kerrisk + document /proc/meminfo kreclaimable field + michael kerrisk + explain how to determine top-most mount in /proc/pid/mountinfo + explain how to determine the top-most mount at a particular + location by inspecting /proc/pid/mountinfo. + michael kerrisk [jakub wilk] + remove bogus suggestion to use cat(1) to read files containing '\0' + michael kerrisk + refer to mount(2) for explanation of mount vs superblock options + michael kerrisk + fix description of /proc/pid/* ownership to account for user namespaces + elvira khabirova + describe ambiguities in /proc//maps + michael kerrisk [nick gregory] + since linux 4.5, "stack:" is no longer shown in /proc/pid/maps + nikola forró + document /proc/[pid]/status speculation_store_bypass field + alan jenkins + vmalloc information is no longer calculated (linux 4.4) + michael kerrisk [alexander e. patrakov, jakub wilk, michael kerrisk] + use 'tr '\000' '\n' to display contents of /proc/pid/environ + michael kerrisk + setting dumpable to 1 reverts ownership of /proc/pid/* to effective ids + michael kerrisk + document /proc/meminfo lazyfree field + michael kerrisk + fix kernel source pathname for soft-dirty documentation + michael kerrisk + /proc/[pid]/status vmpmd field was removed in linux 4.15 + +resolv.conf.5 + nikola forró + document no-reload (res_npreload) option + +tzfile.5 + paul eggert + sync from tzdb upstream + +capabilities.7 + michael kerrisk + fix some imprecisions in discussion of namespaced file capabilities + the file uid does not come into play when creating a v3 + security.capability extended attribute. + michael kerrisk + note that v3 security.attributes are transparently created/retrieved + michael kerrisk + improve the discussion of when file capabilities are ignored + the text stated that the execve() capability transitions are not + performed for the same reasons that setuid and setgid mode bits + may be ignored (as described in execve(2)). but, that's not quite + correct: rather, the file capability sets are treated as empty + for the purpose of the capability transition calculations. + michael kerrisk + rework bounding set as per-thread set in transformation rules + michael kerrisk + substantially rework "capabilities and execution of programs by root" + rework for improved clarity, and also to include missing details + on the case where (1) the binary that is being executed has + capabilities attached and (2) the real user id of the process is + not 0 (root) and (3) the effective user id of the process is 0 + (root). + marcus gelderie + add details about secbit_keep_caps + the description of secbit_keep_caps is misleading about the + effects on the effective capabilities of a process during a + switch to nonzero uids. the effective set is cleared based on + the effective uid switching to a nonzero value, even if + secbit_keep_caps is set. however, with this bit set, the + effective and permitted sets are not cleared if the real and + saved set-user-id are set to nonzero values. + marcus gelderie + mention header for secbit constants + mention that the named constants (secbit_keep_caps and others) + are available only if the linux/securebits.h user-space header + is included. + michael kerrisk + add text introducing bounding set along with other capability sets + michael kerrisk [allison randal] + update url for location of posix.1e draft standard + michael kerrisk + cap_sys_chroot allows use of setns() to change the mount namespace + michael kerrisk [pierre chifflier] + ambient capabilities do not trigger secure-execution mode + michael kerrisk + add a subsection on per-user-namespace "set-user-id-root" programs + michael kerrisk + rework discussion of exec and uid 0, correcting a couple of details + clarify the "capabilities and execution of programs by root" + section, and correct a couple of details: + * if a process with ruid == 0 && euid != 0 does an exec, + the process will nevertheless gain effective capabilities + if the file effective bit is set. + * set-uid-root programs only confer a full set of capabilities + if the binary does not also have attached capabilities. + michael kerrisk + update url for libcap tarballs + the previous location does not seem to be getting updated. + (for example, at the time of this commit, libcap-2.26 + had been out for two months, but was not present at + http://www.kernel.org/pub/linux/libs/security/linux-privs. + michael kerrisk + clarify which capability sets capset(2) and capget(2) apply to + capset(2) and capget(2) apply operate only on the permitted, + effective, and inheritable process capability sets. + michael kerrisk + correct the description of secbit_keep_caps + michael kerrisk + add background details on capability transformations during execve(2) + add background details on ambient and bounding set when + discussing capability transformations during execve(2). + michael kerrisk + document the 'no_file_caps' kernel command-line option + +cgroup_namespaces.7 + michael kerrisk [troy engel] + clarify the example by making an implied detail more explicit. + see https://bugzilla.kernel.org/show_bug.cgi?id=201047 + +cgroups.7 + michael kerrisk + add more detail on v2 'cpu' controller and realtime threads + explicitly note the scheduling policies that are relevant for the + v2 'cpu' controller. + michael kerrisk + document the use of 'cgroup_no_v1=named' to disable v1 named hierarchies + this feature was added in linux 5.0. + michael kerrisk [mike weilgart] + complete partial sentence re kernel boot options and 'nsdelegate' + https://bugzilla.kernel.org/show_bug.cgi?id=201029 + michael kerrisk + reframe the text on delegation to include more details about cgroups v1 + michael kerrisk [leah hanson] + rework discussion of writing to cgroup.type file + in particular, it is possible to write "threaded" to a + cgroup.type file if the current type is "domain threaded". + previously, the text had implied that this was not possible. + michael kerrisk [balbir singh, marcus gelderie] + soften the discussion about delegation in cgroups v1 + balbir pointed out that v1 delegation was not an accidental + feature. + +epoll.7 + michael kerrisk + introduce the terms "interest list" and "ready list" + michael kerrisk + consistently use the term "interest list" rather than "epoll set" + michael kerrisk + reformat q&a list + michael kerrisk + note that edge-triggered notification wakes up only one waiter + note a useful performance benefit of epollet: ensuring that + only one of multiple waiters (in epoll_wait()) is woken + up when a file descriptor becomes ready. + michael kerrisk + expand the discussion of the implications of file descriptor duplication + in particular, note that it may be difficult for an application + to know about the existence of duplicate file descriptors. + +feature_test_macros.7 + michael kerrisk [andreas westfeld] + add more detail on why ftms must be defined before including any header + +inotify.7 + michael kerrisk [paul millar] + note enotdir error that can occur for in_onlydir + note enotdir error that occurs when requesting a watch on a + nondirectory with in_onlydir. + +ip.7 + bert hubert + ip_recvttl error fixed + i need to get the ttl of udp datagrams from userspace, so i set + the ip_recvttl socket option. and as promised by ip.7, i then get + ip_ttl messages from recvfrom. however, unlike what the manpage + promises, the ttl field gets passed as a 32 bit integer. + +man.7 + michael kerrisk + see also: remove mdoc.samples(7) + +mount_namespaces.7 + michael kerrisk + see also: add findmnt(8) + +namespaces.7 + michael kerrisk + list factors that may pin a namespace into existence + various factors may pin a namespace into existence, even when it + has no member processes. + michael kerrisk [tycho kirchner] + briefly explain why cap_sys_admin is needed to create nonuser namespaces + michael kerrisk + mention ioctl(2) in discussion of namespaces apis + michael kerrisk + see also: add pam_namespace(8) + +pid_namespaces.7 + michael kerrisk + clarify the semantics for the adoption of orphaned processes + because of setns() semantics, the parent of a process may reside + in the outer pid namespace. if that parent terminates, then the + child is adopted by the "init" in the outer pid namespace (rather + than the "init" of the pid namespace of the child). + michael kerrisk + note a detail of /proc/pid/ns/pid_for_children behavior + after clone(clone_newpid), /proc/pid/ns/pid_for_children is empty + until the first child is created. verified by experiment. + michael kerrisk + note that a process can do unshare(clone_newpid) only once + +sched.7 + michael kerrisk [eugene syromyatnikov] + in the kernel source sched_other is actually called sched_normal + michael kerrisk + see also: add ps(1) and top(1) + michael kerrisk + see also: add chcpu(1), lscpu(1) + +signal.7 + michael kerrisk [robin kuzmin] + clarify that sigsuspend() and pause() suspend the calling *thread* + helge deller + add signal numbers for parisc + michael kerrisk + unify signal lists into a signal table that embeds standards info + having the signals listed in three different tables reduces + readability, and would require more table splits if future + standards specify other signals. + michael kerrisk + reorder the architectures in the signal number lists + x86 and arm are the most common architectures, but currently + are in the second subfield in the signal number lists. + instead, swap that info with subfield 1, so the most + common architectures are first in the list. + michael kerrisk + place signal numbers in a separate table + the current tables of signal information are unwieldy, + as they try to cram in too much information. + michael kerrisk + insert standards info into tables + michael kerrisk + see also: add clone(2) + +socket.7 + michael kerrisk + refer reader to unix(7) for information on so_passsec + michael kerrisk + see also: add address_families(7) + +socket.7 +unix.7 + michael kerrisk + move text describing so_peercred from socket(7) to unix(7) + this is, afaik, an option specific to unix domain sockets, so + place it in unix(7). + +tcp.7 +udp.7 + michael kerrisk + add a reference to socket(7) noting existence of further socket options + +unix.7 + michael kerrisk + enhance the description of scm_rights + the existing description is rather thin. more can be said. + michael kerrisk + there is a limit on the size of the file descriptor array for scm_rights + the limit is defined in the kernel as scm_max_fd (253). + michael kerrisk + rework so_peercred text for greater clarity + michael kerrisk [felipe gasper] + clarify so_passcred behavior + michael kerrisk + explicitly note that so_passcred provides scm_credentials messages + michael kerrisk + if the buffer to receive scm_rights fds is too small, fds are closed + michael kerrisk + one must send at least one byte of real data with ancillary data + michael kerrisk + ancillary data forms a barrier when receiving on a stream socket + michael kerrisk + when sending ancillary data, only one item of each type may be sent + michael kerrisk + improve wording describing socket option argument/return values + michael kerrisk + clarify treatment of incoming ancillary data if 'msg_control' is null + michael kerrisk + note behavior if buffer to receive ancillary data is too small + michael kerrisk + fix a minor imprecision in description of scm_credentials + michael kerrisk + refer reader to socket(7) for information about so_peek_off + +user_namespaces.7 + michael kerrisk + rework terminology describing ownership of nonuser namespaces + prefer the word "owns" rather than "associated with" when + describing the relationship between user namespaces and non-user + namespaces. the existing text used a mix of the two terms, with + "associated with" being predominant, but to my ear, describing the + relationship as "ownership" is more comprehensible. + +vdso.7 + helge deller + fix parisc gateway page description + +ld.so.8 + michael kerrisk [florian weimer, david newall] + document the --preload command-line option added in glibc 2.30 + michael kerrisk + note delimiters for 'list' in --audit and --inhibit-rpath + michael kerrisk + place options in alphabetical order + michael kerrisk + ld_preload-ed objects are added to link map in left-to-right order + +zdump.8 + paul eggert + sync from tzdb upstream + +zic.8 + paul eggert + sync from tzdb upstream + + +==================== changes in man-pages-5.01 ==================== + +released: 2019-05-09, munich + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +abhinav upadhyay +andreas korb +anisse astier +brice goglin +carlos o'donell +dr. jürgen sauermann +egmont koblinger +elias benali +elliot hughes +florian weimer +hugues evrard +jakub nowak +jakub wilk +keegan saunders +lucas werkmeister +marcus huewe +michael kerrisk +michael witten +seth troisi +slavomir kaslev +vincent lefevre +wladimir mutel + +apologies if i missed anyone! + + +newly documented interfaces in existing pages +--------------------------------------------- + +tsearch.3 + florian weimer [michael kerrisk] + document the twalk_r() function added in glibc 2.30 + + +new and changed links +--------------------- + +twalk_r.3 + michael kerrisk + new link to twalk(3) page + + +changes to individual pages +--------------------------- + +accept.2 + michael kerrisk + note that 'addrlen' is left unchanged in the event of an error + see http://austingroupbugs.net/view.php?id=836. + +bpf.2 + michael kerrisk + update kernel version info for jit compiler + +clone.2 + michael kerrisk [jakub nowak] + clone_child_settid has effect before clone() returns *in the child* + clone_child_settid may not have had effect by the time clone() + returns in the parent, which could be relevant if the + clone_vm flag is employed. the relevant kernel code is in + schedule_tail(), which is called in ret_from_fork() + in the child. + + see https://bugzilla.kernel.org/show_bug.cgi?id=203105 + +execve.2 +exec.3 + michael kerrisk [dr. jürgen sauermann] + consistently use the term 'pathname' (not 'path') + +execve.2 + michael kerrisk + note that stack+environ size is also limited to 3/4 of _stk_lim + in fs/exec.c::prepare_arg_pages(), we have: + + limit = _stk_lim / 4 * 3; + limit = min(limit, bprm->rlim_stack.rlim_cur / 4); + michael kerrisk [dr. jürgen sauermann] + see also: refer to exec(3) (rather than execl(3)) + +pipe.2 + michael kerrisk + note that 'pipefd' is left unchanged in the event of an error + see http://austingroupbugs.net/view.php?id=467. + +sched_setaffinity.2 + michael kerrisk [brice goglin] + correct details of return value of sched_getaffinity() syscall + +setfsgid.2 + michael kerrisk + rewrite for improved clarity and defer to setfsuid() for details + rewrite for improved clarity and defer to setfsuid(2) for the + rationale of the fsgid rather than repeating the same details + in this page. + +setfsuid.2 + michael kerrisk + rewrite for improved clarity and to hint history more explicitly + the current text reads somewhat clumsily. rewrite it to introduce + the euid and fsuid in parallel, and more clearly hint at the + historical rationale for the fsuid, which is detailed lower in + the page. + +socketpair.2 + michael kerrisk + clarify that 'sv' is left unchanged in the event of an error + see also http://austingroupbugs.net/view.php?id=483. + +splice.2 + slavomir kaslev + eagain can occur when called on nonblocking file descriptors + +syscalls.2 + michael kerrisk [andreas korb] + remove crufty text about i386 syscall dispatch table + the removed text long ago ceased to be accurate. nowadays, the + dispatch table is autogenerated when building the kernel (via + the kernel makefile, arch/x86/entry/syscalls/makefile). + +tee.2 + slavomir kaslev + eagain can occur when called on nonblocking file descriptors + +fopen.3 + elliot hughes + explain bsd vs glibc "a+" difference + where is the initial read position for an "a+" stream? + + posix leaves this unspecified. most bsd man pages are silent, and + macos has the ambiguous "the stream is positioned at the end of + the file", not differentiating between reads and writes other than + to say that fseek(3) does not affect writes. glibc's documentation + explicitly specifies that the initial read position is the + beginning of the file. + +mallinfo.3 + elliott hughes + further discourage use of mallinfo() + the bugs section already explains why you need to be cautious + about using mallinfo, but given the number of bug reports we see + on android, it seems not many people are reading that far. call it + out up front. + +malloc_trim.3 + carlos o'donell + update trimming information + since glibc 2.8, commit 68631c8eb92, the malloc_trim function has + iterated over all arenas and free'd back to the os all page runs + that were free. this allows an application to call malloc_trim to + consolidate fragmented chunks and free back any pages it can to + potentially reduce rss usage. + +posix_memalign.3 + elliot hughes + some functions set errno + true of bionic, glibc, and musl. (i didn't check elsewhere.) + +resolver.3 + michael kerrisk [wladimir mutel] + mention that some functions set 'h_errno' + +stdarg.3 + michael kerrisk [vincent lefevre] + remove the notes section describing the ancient varargs macros + stdarg.h is now 30 years old, and gcc long ago (2004) ceased to + implement . there seems little value in keeping this + text. + + see https://bugzilla.kernel.org/show_bug.cgi?id=202907 + michael kerrisk [egmont koblinger] + add a note that "..." in function signature means a variadic function + egmont suggested adding this, because the string "..." appears + at several other points in the page, but just to indicate that + some text is omitted from example code. + +strerror.3 + jakub wilk + don't discuss buffer size for strerror_l() + unlike strerror_r(), strerror_l() doesn't take buffer length as an + argument. + +strtol.3 +strtoul.3 + jakub wilk + see also: add strtoimax(3), strtoumax(3) + +sysconf.3 + michael kerrisk [hugues evrard] + clearly note that _sc_pagesize and _sc_page_size are synonyms + +tsearch.3 + florian weimer + do not use const arguments in twalk() callback + the const specifier is not part of the prototype (it only applies + to the implementation), so showing it here confuses the reader. + michael kerrisk + synopsis: add missing definition of 'visit' type + michael kerrisk + reformat twalk() and twalk_r() prototypes for easier readability + +console_codes.4 + jakub wilk + document that \e[1;n] and \e[2;n] support 16 colors + source: setterm_command() in drivers/tty/vt/vt.c + +elf.5 + michael kerrisk [keegan saunders] + a data segment does not have pf_x + +proc.5 + michael witten [anisse astier] + add missing inode field to /proc/net/unix + +hostname.7 + florian weimer + hostaliases/search path processing is dns-specific + other nss modules do not necessarily honor these settings. + +inode.7 + michael kerrisk + note that timestamp fields measure time starting at the epoch + michael kerrisk + timestamp fields are structures that include a nanosecond component + michael kerrisk + add references to execve(2) to describe set-uid/set-gid behaviors + + +==================== changes in man-pages-5.02 ==================== + +released: 2019-08-02, munich + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +alan stern +alexey izbyshev +amir goldstein +cyrill gorcunov +eric sanchis +eugene syromyatnikov +finn o'leary +florian weimer +g. branden robinson +guillaume laporte +jakub wilk +jan kara +kumar chaudhary, naveen +mark wielaard +matthew bobrowski +matthew kenigsberg +matthias hertel +michael kerrisk +michal sekletar +oleg nesterov +palmer dabbelt +petr vaněk +sami kerola +shawn landden +thorsten glaser +tobias klauser +tomas skäre +yang xu + +apologies if i missed anyone! + + +newly documented interfaces in existing pages +--------------------------------------------- + +fanotify.7 +fanotify_init.2 +fanotify_mark.2 + matthew bobrowski [amir goldstein, jan kara] + document fan_report_fid and directory modification events + +vdso.7 + tobias klauser [palmer dabbelt] + document vdso for riscv + +renamed pages +------------- + +sysvipc.7 + svipc(7) is renamed to sysvipc(7). + the name sysvipc is a bit more natural, and is the name used in + /proc/sysvipc. + +new and changed links +--------------------- + +svipc.7 + michael kerrisk + add old name of sysvipc(7) page as a link + + +global changes +-------------- + +various pages + michael kerrisk + change reference to svipc(7) to sysvipc(7) + + +changes to individual pages +--------------------------- + +pldd.1 + g. branden robinson [michael kerrisk] + document glibc's unbreakage of tool + after a longstanding breakage, pldd now works again (glibc 2.30). + +bpf.2 + michael kerrisk + correct kernel version for jit support on s390 + +chdir.2 + michael kerrisk + add enotdir error for fchdir() + +execve.2 + michael kerrisk [eugene syromyatnikov] + since linux 5.1, the limit on the #! line is 255 chars (rather than 127) + shawn landden [michael kerrisk] + add more detail about shebangs + michael kerrisk + linux is not alone in ignoring the set-uid and set-gid bits for scripts + +mount.2 + michael kerrisk + errors: add a couple of einval errors for ms_move + michael kerrisk + see also: add chroot(2) and pivot_root(2) + +mprotect.2 + mark wielaard + pkey_mprotect() acts like mprotect() if pkey is set to -1, not 0 + +mprotect.2 +pkey_alloc.2 + mark wielaard [florian weimer] + _gnu_source is required for the pkey functions. + +pivot_root.2 + michael kerrisk + errors: einval occurs if 'new_root' or its parent has shared propagation + michael kerrisk + 'new_root' must be a mount point + it appears that 'new_root' may not have needed to be a mount + point on ancient kernels, but already in linux 2.4.5 this changed. + michael kerrisk + 'put_old' can't be a mount point with ms_shared propagation + michael kerrisk + see also: add mount(2) + +poll.2 + michael kerrisk [alan stern] + note that poll() equivalent code for ppoll() is not quite equivalent + +prctl.2 + yang xu [cyrill gorcunov] + correct some details for pr_set_timerslack + +setxattr.2 + finn o'leary [michael kerrisk] + add erange to 'errors' section + +tkill.2 + michael kerrisk + glibc 2.30 provides a wrapper for tgkill() + +dlopen.3 + michael kerrisk + clarify the rules for symbol resolution in a dlopen'ed object + the existing text wrongly implied that symbol look up first + occurred in the object and then in main, and did not mention + whether dependencies of main where used for symbol resolution. + michael kerrisk + clarify when an executable's symbols can be used for symbol resolution + the --export-dynamic linker option is not the only way that main's + global symbols may end up in the dynamic symbol table and thus be + used to satisfy symbol reference in a shared object. a symbol + may also be placed into the dynamic symbol table if ld(1) + notices a dependency in another object during the static link. + michael kerrisk + an object opened with rtld_local can be promoted to rtld_global + michael kerrisk + note that symbol use might keep a dlclose'd object in memory + michael kerrisk + on dlclose(), destructors are called when reference count falls to 0 + michael kerrisk + make it clear that rtld_nodelete also affects global variables + michael kerrisk + clarify that constructors are called only when library is first loaded + +exec.3 + matthew kenigsberg + explain function groupings + i've found the exec man page quite difficult to read when trying + to find the behavior for a specific function. since the names of + the functions are inline and the order of the descriptions isn't + clear, it's hard to find which paragraphs apply to each function. + i thought it would be much easier to read if the grouping based on + letters is stated. + +getutent.3 + michael kerrisk [thorsten glaser] + fix missing include file in example + see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=932382 + +on_exit.3 + michael kerrisk [sami kerola] + stack variables may be out of scope when exit handler is invoked + +strcat.3 + michael kerrisk [eric sanchis] + fix off-by-one error in example code + +cpuid.4 + michael kerrisk + see also: add cpuid(1) + +elf.5 + michael kerrisk + see also: add ld.so(8) + +proc.5 + michael kerrisk + correct description of /proc/pid/status 'shdpnd' and 'sigpnd' fields + these fields are signal masks, not counters. + michael kerrisk + clarify that various mask fields in /proc/pid/status are in hexadecimal + +capabilities.7 + michael kerrisk + add a note about using strace on binaries that have capabilities + michael kerrisk + add pivot_root(2) to cap_sys_admin list + michael kerrisk + cap_fowner also allows modifying user xattrs on sticky directories + +cgroup_namespaces.7 + michael kerrisk + some wording fixes to improve clarity + michael kerrisk + in the example shell session, give second shell a different prompt + +credentials.7 + michael kerrisk + note that /proc/pid/status shows a process's credentials + michael kerrisk + see also: add tcgetsid(3) + +fanotify.7 + matthew bobrowski + reword fan_report_fid data structure inclusion semantics + michael kerrisk + clarify logic in estale check + michael kerrisk + reorder text in example + michael kerrisk + reformat program output to fit in 80 columns + +mount_namespaces.7 + michael kerrisk + clarify implications for other ns if mount point is removed in one ns + if a mount point is deleted or renamed or removed in one mount + namespace, this will cause an object that is mounted at that + location in another mount namespace to be unmounted (as verified + by experiment). this was implied by the existing text, but it is + better to make this detail explicit. + michael kerrisk + see also: add pivot_root(2), pivot_root(8) + +namespaces.7 + michael kerrisk + note initial values of hostname and domainname in a new uts namespace + +sched.7 + michael kerrisk + see also: add pthread_getschedparam(3) + +signal.7 + michal sekletar [oleg nesterov, michael kerrisk] + clarify that siginfo_t isn't changed on coalescing + michael kerrisk + various fields in /proc/pid/status show signal-related information + michael kerrisk + add subsection on queuing and delivery semantics for standard signals + +socket.7 + michael kerrisk + select()/poll()/epoll honor so_rcvlowat since linux 2.6.28 + +unix.7 + michael kerrisk + note scm_rights interaction with rlimit_nofile + if the file descriptors received in scm_rights would cause + the process to its exceed rlimit_nofile limit, the excess + fds are discarded. + +user_namespaces.7 + michael kerrisk + describe the effect of file-related capabilities inside user namespaces + michael kerrisk + describe how kernel treats uids/gids when a process accesses files + +vdso.7 + tobias klauser + mention removal of blackfin port in linux 4.17 + +ld.so.8 + michael kerrisk [matthias hertel] + note some further details of secure-execution mode + note some further details of the treatment of environment + variables in secure execution mode. in particular (as noted by + matthias hertel), note that ignored environment variables are also + stripped from the environment. furthermore, there are some other + variables, not used by the dynamic linker itself, that are also + treated in this way (see the glibc source file + sysdeps/generic/unsecvars.h). + + +==================== changes in man-pages-5.03 ==================== + +released: 2019-10-11, munich + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +adam borowski +aleksa sarai +alexey budankov +amir goldstein +andrew clayton +carlos o'donell +christian brauner +christopher m. riedl +daniel colascione +dave carroll +dave chinner +дилян палаузов +dmitry v. levin +don brace +eponymous alias +eric biggers +eric w. biederman +florian weimer +florin blanaru +gilbert wu +ingo schwarze +jakub wilk +kevin barnett +marko myllynen +matti moell +matti möll +matt perricone +michael kerrisk +mike frysinger +murthy bhat +nikola forró +nilsocket +paul wise +philipp wendler +raphael moreira zinsly +rasmus villemoes +reid priedhorsky +rick stanley +rob landley +scott benesh +scott teel +shawn anastasio +simone piccardi +vincent lefevre +yang xu + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +pidfd_open.2 + michael kerrisk [christian brauner, florian weimer, daniel colascione] + new page documenting pidfd_open(2) + +pidfd_send_signal.2 + michael kerrisk [florian weimer, christian brauner] + new page documenting pidfd_send_signal(2) + +pivot_root.2 + michael kerrisk [eric w. biederman, reid priedhorsky, philipp wendler] + this page has been completely rewritten, adding a lot of missing + details (including the use of pivot_root(".", ".")) and an example + program. in addition, the text prevaricating on whether or not + pivot_root() might change the root and current working directories has + been eliminated, and replaced with a simple description of the behavior + of the system call, which has not changed for 19 years, and will not + change in the future. many longstanding errors in the old version of + the page have also been corrected. + +ipc_namespaces.7 + michael kerrisk + new page with content migrated from namespaces(7) + +uts_namespaces.7 + michael kerrisk + new page with content migrated from namespaces(7) + + +newly documented interfaces in existing pages +--------------------------------------------- + +clone.2 + christian brauner, michael kerrisk + document clone_pidfd + add an entry for clone_pidfd. this flag is available starting + with kernel 5.2. if specified, a process file descriptor + ("pidfd") referring to the child process will be returned in + the ptid argument. + +fanotify_mark.2 + jakub wilk + document fan_move_self + +ptrace.2 + dmitry v. levin [michael kerrisk] + document ptrace_get_syscall_info + +regex.3 + rob landley + document reg_startend + + +new and changed links +--------------------- + +res_nclose.3 + michael kerrisk + add new link to resolver.3 + + +global changes +-------------- + +various pages + michael kerrisk + see also: correct list order + +various pages + michael kerrisk + remove section number from references to function in its own page + +various pages + michael kerrisk + errors: correct alphabetical order + + +changes to individual pages +--------------------------- + +localedef.1 + marko myllynen + describe recently added options + describe few recently added options (present in glibc-2.29). + +clone.2 + michael kerrisk + see also: add pidfd_open(2) + +copy_file_range.2 + amir goldstein [dave chinner] + kernel v5.3 updates + +fanotify_mark.2 + jakub wilk + add kernel version numbers for some fan_* constants + +getdomainname.2 + michael kerrisk + add mention of uts namespaces + +gethostname.2 + michael kerrisk [jakub wilk] + mention uts namespaces + +io_submit.2 + matti moell [matti möll] + fix kernel version numbers for 'aio_rw_flags' flags + +kill.2 + michael kerrisk + see also: add pidfd_send_signal(2) + +mmap.2 + nikola forró + fix einval conditions + since introduction of map_shared_validate, in case flags contain + both map_private and map_shared, mmap() doesn't fail with einval, + it succeeds. + + the reason for that is that map_shared_validate is in fact equal + to map_private | map_shared. + +mount.2 + michael kerrisk [reid priedhorsky] + describe the concept of "parent mounts" + michael kerrisk + notes: add subsection heading for /proc/[pid]/{mounts,mountinfo} + michael kerrisk + rework the text on mount namespaces a little + eliminate the term "per-process namespaces" and add a reference + to mount_namespaces(7). + +move_pages.2 + yang xu [michael kerrisk] + mark e2big as deprecated + e2big was removed in 2.6.29, we should mark it as deprecated. + +perf_event_open.2 + michael kerrisk [alexey budankov] + see also: add documentation/admin-guide/perf-security.rst + +prctl.2 + michael kerrisk + clarify that pr_get_speculation_ctrl returns value as function result + michael kerrisk + clarify that pr_mce_kill_get returns value via function result + michael kerrisk + clarify that pr_get_fp_mode returns value as function result + michael kerrisk + return value: add some missing entries + note success return for pr_get_speculation_ctrl and pr_get_fp_mode. + +rt_sigqueueinfo.2 + michael kerrisk + note that 'si_code' can't be specified as si_kernel + michael kerrisk + the rules for 'si_code' don't apply when sending a signal to oneself + the restriction on what values may be specified in 'si_code' + apply only when sending a signal to a process other than the + caller itself. + michael kerrisk + rename 'uinfo' argument to 'info' + this is more consistent with the naming in other pages + that refer to a 'siginfo_t' structure. + michael kerrisk + see also: add pidfd_send_signal(2) + +sched_setaffinity.2 + michael kerrisk + return value: sched_getaffinity() syscall differs from the wrapper + +setns.2 + mike frysinger + fix clone_newns restriction info + +sigaction.2 + michael kerrisk + see also: add pidfd_send_signal(2) + +signalfd.2 + andrew clayton, michael kerrisk + note about interactions with epoll & fork + +statx.2 + michael kerrisk [simone piccardi] + clarify details of a case where an invalid 'mask' value may be rejected + +syscall.2 + shawn anastasio + add information for powerpc64 + michael kerrisk [adam borowski, florin blanaru] + update name of syscall instruction for riscv + +syscalls.2 + michael kerrisk + add fsconfig(), fsmount(), fsopen(), fspick(), move_mount(), open_tree() + michael kerrisk [(), michael(), kerrisk(),] + add new syscalls in 5.1 + add io_uring_enter(), io_uring_register(), io_uring_setup(), and + pidfd_send_signal(). + michael kerrisk + add clone3() and pidfd_open() + +uname.2 + michael kerrisk + replace reference to namespaces(7) with reference to uts_namespaces(7) + +errno.3 + rasmus villemoes + add some comments on eagain/ewouldblock and edeadlk/edeadlock + +fexecve.3 + michael kerrisk [simone piccardi] + enosys occurs only if the kernel provides no execveat() syscall + michael kerrisk [simone piccardi] + errors: add enoent + +getauxval.3 + raphael moreira zinsly + add new cache geometry entries + +printf.3 + vincent lefevre + add detail on the first digit with the %e format + +pthread_setcancelstate.3 +pthreads.7 +signal-safety.7 + carlos o'donell + describe issues with cancellation points in signal handlers + +strtok.3 + michael kerrisk [eponymous alias] + correct description of use of 'saveptr' argument in strtok_r() + michael kerrisk [eponymous alias] + the caller should not modify 'saveptr' between strtok_r() calls + michael kerrisk + add portability note for strtok_r() '*saveptr' value + on some implementations, '*saveptr' must be null on first call + to strtok_r(). + +smartpqi.4 + murthy bhat [don brace, kevin barnett, matt perricone, scott benesh] + add sysfs entries + gilbert wu [don brace, kevin barnett, matt perricone, scott benesh] + add module param expose ld first + dave carroll [don brace, kevin barnett, matt perricone, scott benesh] + add module param to hide vsep + +core.5 + paul wise + explain the new situation with argument splitting + things changed in linux v5.3-rc3 commit 315c69261dd3 from + splitting after template expansion to splitting beforehand. + +resolv.conf.5 + nikola forró + update information about search list + since glibc 2.26, the number of domains in the search list is + no longer limited. + +man-pages.7 + michael kerrisk + relocate and enhance the text on semantic newlines + michael kerrisk [paul wise] + paragraphs should not be separated by blank lines + +mount_namespaces.7 + michael kerrisk + explain how a namespace's mount point list is initialized + provide a more detailed explanation of the initialization of + the mount point list in a new mount namespace. + michael kerrisk [eric w. biederman] + clarify description of "less privileged" mount namespaces + michael kerrisk + see also: refer to example in pivot_root(2) + michael kerrisk [eric w. biederman] + it may be desirable to disable propagation after creating a namespace + after creating a new mount namespace, it may be desirable to + disable mount propagation. give the reader a more explicit + hint about this. + +mq_overview.7 +sysvipc.7 + michael kerrisk + adjust references to namespaces(7) to ipc_namespaces(7) + +namespaces.7 + michael kerrisk + remove content migrated to new ipc_namespaces(7) page + michael kerrisk + remove content migrated to uts_namespaces(7) + michael kerrisk + include manual page references in the summary table of namespace types + make the page more compact by removing the stub subsections that + list the manual pages for the namespace types. and while we're + here, add an explanation of the table columns. + +operator.7 + michael kerrisk [rick stanley] + prefix and postfix ++/-- have different precedences + harbison and steele also agree on this. + +signal.7 + michael kerrisk + enhance the text on process-directed and thread-directed signals + clone(2) has a good description of these concepts; borrow + from it liberally. + michael kerrisk + see also: add pidfd_send_signal(2) + +user_namespaces.7 + michael kerrisk + improve explanation of meaning of ownership of nonuser namespaces + + +==================== changes in man-pages-5.04 ==================== + +released: 2019-11-19, munich + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +andrew price +christian brauner +florian weimer +jakub wilk +jan kara +jann horn +kenigbolo meya stephen +marko myllynen +michael kerrisk +mikael magnusson +robert edmonds +silviu popescu +torin carey +witold baryluk +yang xu + +apologies if i missed anyone! + + +newly documented interfaces in existing pages +--------------------------------------------- + +clone.2 + michael kerrisk [christian brauner, jakub wilk] + document clone3() + +wait.2 + michael kerrisk + add p_pidfd for waiting on a child referred to by a pid file descriptor + +bpf-helpers.7 + michael kerrisk + refresh against kernel v5.4-rc7 + + +new and changed links +--------------------- + +clone3.2 + michael kerrisk + new link to clone(2) + + +changes to individual pages +--------------------------- + +clone.2 + michael kerrisk + rename arguments for consistency with clone3() + make the names of the clone() arguments the same as the fields + in the clone3() 'args' struct: + + ctid ==> child_pid + ptid ==> parent_tid + newtls ==> tld + child_stack ==> stack + michael kerrisk + consistently order paragraphs for clone_new* flags + sometimes the descriptions of these flags mentioned the + corresponding section 7 namespace manual page and then the + required capabilities, and sometimes the order was the was + the reverse. make it consistent. + michael kerrisk [christian brauner, jann horn] + example: allocate child's stack using mmap(2) rather than malloc(3) + christian brauner suggested mmap(map_stack), rather than + malloc(), as the canonical way of allocating a stack for the + child of clone(), and jann horn noted some reasons why + (map_stack exists elsewhere, and mmap() returns a page-aligned + block of memory, which is useful if we want to set up a guard + page at the end of the stack). + michael kerrisk [christian brauner] + tidy up the description of clone_detached + the obsolete clone_detached flag has never been properly + documented, but now the discussion clone_pidfd also requires + mention of clone_detached. so, properly document clone_detached, + and mention its interactions with clone_pidfd. + michael kerrisk [christian brauner] + give the introductory paragraph a new coat of paint + change the text in the introductory paragraph (which was written + 20 years ago) to reflect the fact that clone*() does more things + nowadays. + michael kerrisk + remove wording that suggests clone_new* flags are for containers + these flags are used for implementing many other interesting + things by now. + michael kerrisk + remove various details that are already covered in namespaces pages + remove details of uts, ipc, and network namespaces that are + already covered in the corresponding namespaces pages in section 7. + +clone.2 +proc.5 + michael kerrisk + adjust references to namespaces(7) + adjust references to namespaces(7) to be references to pages + describing specific namespace types. + +fallocate.2 + andrew price + add gfs2 to the list of punch hole-capable filesystems + +ioctl_iflags.2 + michael kerrisk [robert edmonds] + emphasize that fs_ioc_getflags and fs_ioc_setflags argument is 'int *' + +ioctl_list.2 + michael kerrisk + add reference to ioctl(2) see also section + the referenced section lists various pages that document ioctls. + +mmap.2 + michael kerrisk + note that map_stack exists on some other systems + michael kerrisk + some rewording of the description of map_stack + reword a little to allow for the fact that there are now + *two* reasons to consider using this flag. + +pidfd_open.2 + michael kerrisk + note the waitid() use case for pid file descriptors + michael kerrisk + add a subsection header "use cases for pid file descriptors" + michael kerrisk + make it a little more explicit the clone_pidfd returns a pid fd + +pivot_root.2 + michael kerrisk + example: allocate stack using mmap() map_stack rather than malloc() + +quotactl.2 + yang xu [jan kara] + add some details about q_quotaon + +seccomp.2 +cgroups.7 + michael kerrisk + switch to "considerate language" + +select.2 + michael kerrisk + pollin_set/pollout_set/pollex_set are now defined in terms of epoll* + since kernel commit a9a08845e9acbd224e4ee466f5c1275ed50054e8, the + equivalence between select() and poll()/epoll is defined in terms + of the epoll* constants, rather than the poll* constants. + +wait.2 + michael kerrisk + waitid() can be used to wait on children in same process group as caller + since linux 5.4, idtype == p_pgid && id == 0 can be used to wait + on children in same process group as caller. + michael kerrisk + clarify semantics of waitpid(0, ...) + as noted in kernel commit 821cc7b0b205c0df64cce59aacc330af251fa8f7, + threads create an ambiguity: what if the calling process's pgid + is changed by another thread while waitpid(0, ...) is blocked? + so, clarify that waitpid(0, ...) means wait for children whose + pgid matches the caller's pgid at the time of the call to + waitpid(). + +getauxval.3 + michael kerrisk [witold baryluk] + clarify that at_base_platform and at_execfn return pointers to strings + see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=942207 + +resolv.conf.5 + florian weimer + attempt clarify domain/search interaction + the domain directive is historic at this point; it should not + be used. + +netdevice.7 + michael kerrisk [silviu popescu] + small wording fix in description of siocgifconf + siocgifconf returns "network layer" addresses (not "transport + layer"). + +uts_namespaces.7 + michael kerrisk + add a little more detail on scope of uts namespaces + + +==================== changes in man-pages-5.05 ==================== + +released: 2020-02-09, munich + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +adam borowski +adrian reber +andy lutomirski +antonin décimo +benjamin peterson +brennan vincent +christian brauner +colin ian king +cyril hrubis +daniel colascione +denys vlasenko +dj delorie +dmitry v. levin +jakub wilk +jashank jeremy +joel fernandes +john hubbard +john jones +joseph c. sible +kevin sztern +marko myllynen +markus t metzger +michael kerrisk +michal hocko +mike frysinger +mike salvatore +mikhail golubev +nick shipp +nikola forró +peter gajdos +petr vorel +ponnuvel palaniyappan +rich felker +robin kuzmin +samuel thibault +sam varshavchik +vegard nossum +weitian li +will +yang xu +yu jian wu + +apologies if i missed anyone! + + +newly documented interfaces in existing pages +--------------------------------------------- + +clone.2 + adrian reber [christian brauner, michael kerrisk] + add clone3() set_tid information + michael kerrisk + document clone_clear_sighand + +fcntl.2 + joel fernandes [michael kerrisk] + update manpage with new memfd f_seal_future_write seal + +memfd_create.2 + joel fernandes + update manpage with new memfd f_seal_future_write seal + +loop.4 + yang xu + document loop_set_block_size + yang xu + document loop_set_direct_io + +proc.5 + michael kerrisk + document /proc/sys/vm/unprivileged_userfaultfd + + +changes to individual pages +--------------------------- + +capget.2 + michael kerrisk [yang xu] + add missing details in eperm error for setting inheritable capabilities + +clone.2 + michael kerrisk + note that clone_thread causes similar behavior to clone_parent + the introductory paragraphs note that "the calling process" is + normally synonymous with the "the parent process", except in the + case of clone_parent. the same is also true of clone_thread. + christian brauner [michael kerrisk] + mention that clone_parent is off-limits for inits + michael kerrisk [colin ian king] + add old einval error for aarch64 + michael kerrisk + errors: add einval for use of clone_parent by an init process + +futex.2 + ponnuvel palaniyappan + fix a bug in the example + +listen.2 + michael kerrisk [peter gajdos] + the 'somaxconn' default value has increased to 4096 + +modify_ldt.2 +set_thread_area.2 + andy lutomirski [markus t metzger] + fix type of base_addr + +move_pages.2 + john hubbard [michal hocko] + remove enoent from the list of possible return values + +open.2 + adam borowski + no need for /proc to make an o_tmpfile file permanent + in the example snippet, we already have the fd, thus there's no + need to refer to the file by name. and, /proc/ might be not + mounted or not accessible. + michael kerrisk [joseph c. sible] + in o_tmpfile example, describe alternative linkat() call + this was already shown in an earlier version of the page, + but adam borowski's patch replaced it with an alternative. + probably, it is better to show both possibilities. + +perf_event_open.2 + daniel colascione + mention eintr for perf_event_open + +ptrace.2 + denys vlasenko + ptrace_event_stop does not always report sigtrap + +quotactl.2 + michael kerrisk + don't show numeric values of q_xquotaon xfs_quota_?dq_* flags + the programmer should not need to care about the numeric values, + and their inclusion is verbosity. + yang xu [michael kerrisk] + add einval error of q_xquotarm operation + +stime.2 + michael kerrisk + note that stime() is deprecated + +syscall.2 + petr vorel [cyril hrubis] + update feature test macro requirements + +sysctl.2 + michael kerrisk + this system call was removed in linux 5.5; adjust the page accordingly + +userfaultfd.2 + yang xu [michael kerrisk] + add eperm error + +cmsg.3 + rich felker + clarify alignment issues and correct method of accessing cmsg_data() + from an email by rich felker: + + it came to my attention while reviewing possible breakage with + move to 64-bit time_t that some applications are dereferencing + data in socket control messages (particularly scm_timestamp*) + in-place as the message type, rather than memcpy'ing it to + appropriate storage. this necessarily does not work and is not + supportable if the message contains data with greater alignment + requirement than the header. in particular, on 32-bit archs, + cmsghdr has size 12 and alignment 4, but struct timeval and + timespec may have alignment requirement 8. + michael kerrisk [rich felker] + modify cmsg_data() example to use memcpy() + see previous patch to this page for rationale + +exit.3 + benjamin peterson [mike frysinger] + use hex for the status mask + +ftime.3 + michael kerrisk + note that this function is deprecated + +getpt.3 + samuel thibault + remove mention of o_noctty + the glibc implementation of getpt has actually never been setting + +malloc.3 + vegard nossum + clarify realloc() return value + petr vorel + remove duplicate _gnu_source + +console_codes.4 + adam borowski + document \e[90m to 97, 100 to 107 + adam borowski + \e[21m is now underline + since 65d9982d7e523a1a8e7c9af012da0d166f72fc56 (4.17), it follows + xterm rather than common sense and consistency, being the only + command 1..9 where n+20 doesn't undo what n did. as libvte + 0.51.90 got changed the same way, this behaviour will probably + stay. + adam borowski + update \e[38m and \e[48m + supported since cec5b2a97a11ade56a701e83044d0a2a984c67b4 (3.16). + +cgroups.7 + michael kerrisk + the v2 freezer controller was added in linux 5.2 + michael kerrisk + split discussion of cgroups.events file and v2 release notification + in preparation for adding a description of the "frozen" key. + michael kerrisk + describe the cgroup.events "frozen" key + michael kerrisk + improve the discussion of the advantages of v2 release notification + +inotify.7 + nick shipp + merge late perror() into fprintf() in example code + +netlink.7 + antonin décimo + fix alignment issue in example + +packet.7 + kevin sztern [michael kerrisk] + add missing tpacket_auxdata field (tp_vlan_tpid) + +rtnetlink.7 + antonin décimo + ifa_index is an unsigned int + +tcp.7 + michael kerrisk + tcp_low_latency is ignored since linux 4.14 + +unix.7 + michael kerrisk + the pid sent with scm_credentials must match an existing process + +vsock.7 + mikhail golubev [michael kerrisk] + add missing structure element + the structure 'struct sockaddr_vm' has additional element + 'unsigned char svm_zero[]' since version v3.9-rc1. + +ldconfig.8 + dj delorie + document file filter and symlink pattern expectations + + +==================== changes in man-pages-5.06 ==================== + +released: 2020-04-11, munich + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +alejandro colomar +aleksa sarai +alexander miller +andrea arcangeli +andré almeida +andrei vagin +andrew micallef +bart van assche +benjamin peterson +bjarni ingi gislason +christian brauner +devi r.k +dmitry safonov +eric biggers +eric dumazet +eric rannaud +eugene syromyatnikov +heinrich schuchardt +helge deller +jakub wilk +jorgen hansen +julia suvorova +keno fischer +krzysztof małysa +marc lehmann +matthew bobrowski +matthew wilcox +michael galassi +michael kerrisk +michal hocko +mike christie +mike frysinger +pablo m. ronchi +ricardo biehl pasquali +stefan hajnoczi +stefano garzarella +thomas gleixner +walter harms +zack weinberg + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +openat2.2 + aleksa sarai [michael kerrisk] + document new openat2(2) syscall + +pidfd_getfd.2 + michael kerrisk [christian brauner] + new manual page documenting the pidfd_getfd() system call + +select.2 + michael kerrisk + rewrite description + improve structure and readability, at the same time incorporating + text and details that were formerly in select_tut(2). also + move a few details in other parts of the page into description. + michael kerrisk + consolidate the discussion of pselect into a headed subsection + michael kerrisk + consolidate historical glibc pselect() details under one subhead + michael kerrisk + consolidate info on usleep() emulation in one place + michael kerrisk + place the discussion of the self-pipe technique in a headed subsection + michael kerrisk + note that fd_set() and fd_clr() do not return errors + michael kerrisk + remove details of historical #include requirements + the posix situation has been the norm for a long time now, + and including ancient details overcomplicates the page. + michael kerrisk + remove some ancient information about pre-posix types for 'timeout' + +select_tut.2 + michael kerrisk + eliminate duplication of info across select_tut.2 and select2 + there was a lot of a duplication of info in synopsis, description + return value, and see also. move all of the info to one place: + the select(2) page. + +sysvipc.7 + michael kerrisk + rewrite this page as just a summary of the system v ipc apis + all of the other details in this page have by now been moved into + the relevant *ctl(2) pages. + +time_namespaces.7 + michael kerrisk [andrei vagin, dmitry safonov, thomas gleixner] + new page documenting time namespaces + + +newly documented interfaces in existing pages +--------------------------------------------- + +arch_prctl.2 + keno fischer + add arch_set_cpuid subcommand + +clock_getres.2 + benjamin peterson + document clock_tai + michael kerrisk + add clock_realtime_alarm and clock_boottime_alarm + +prctl.2 + mike christie [michal hocko, michael kerrisk, bart van assche] + document pr_setio_flusher/get_io_flusher + +setns.2 + michael kerrisk + document clone_newtime + +statx.2 + eric biggers + document statx_attr_verity + +unshare.2 + michael kerrisk + document clone_newtime + +socket.7 + ricardo biehl pasquali, michael kerrisk + add description of so_select_err_queue + alejandro colomar [michael kerrisk] + document so_timestampns + + +global changes +-------------- + +various pages + michael kerrisk + remove a few mentions of the ancient "linux libc" + +various pages + michael kerrisk + global formatting fix: disfavor nonstandard .tp indents + in many cases, these don't improve readability, and (when stacked) + they sometimes have the side effect of sometimes forcing text + to be justified within a narrow column range. + +various pages + michael kerrisk [christian brauner] + fix clumsy wording around "nonnegative file descriptors" + + +changes to individual pages +--------------------------- + +clock_getres.2 + helge deller [michael kerrisk] + consecutive calls for clock_monotonic may return same value + consecutive calls to clock_gettime(clock_monotonic) are guaranteed + to return monotonic values, which means that they either return + the *same* time value like the last call, or a later (higher) time + value. + eric rannaud + dynamic posix clock devices can return other errors + michael kerrisk + improve description of cpu-time clocks + michael kerrisk + add an example program + michael kerrisk + clock_realtime_coarse is not settable + michael kerrisk + note that cpu-time clocks are not settable. + explicitly note that clock_process_cputime_id and + clock_process_cputime_id are not settable. + michael kerrisk + clarify that clock_tai is nonsettable + michael kerrisk + clarify that clock_monotonic is system-wide + michael kerrisk + errors: add einval for attempt to set a nonsettable clock + michael kerrisk + move text in bugs to notes + the fact that clock_process_cputime_id and + clock_process_cputime_id are not settable isn't a bug, + since posix does allow the possibility that these clocks + are not settable. + michael kerrisk + see also: add time_namespaces(7) + +clock_nanosleep.2 + michael kerrisk + clock_nanosleep() can also sleep against clock_tai + michael kerrisk + clock_nanosleep() also supports clock_boottime + presumably (and from a quick glance at the source code) + since linux 2.6.39, when clock_boottime was introduced. + +clock_nanosleep.2 +timer_create.2 +timerfd_create.2 + michael kerrisk + add various missing errors + mostly verified by testing and reading the code. + + there is unfortunately quite a bit of inconsistency across api~s: + + clock_gettime clock_settime clock_nanosleep timer_create timerfd_create + + clock_boottime y n (einval) y y y + clock_boottime_alarm y n (einval) y [1] y [1] y [1] + clock_monotonic y n (einval) y y y + clock_monotonic_coarse y n (einval) n (enotsup) n (enotsup) n (einval) + clock_monotonic_raw y n (einval) n (enotsup) n (enotsup) n (einval) + clock_realtime y y y y y + clock_realtime_alarm y n (einval) y [1] y [1] y [1] + clock_realtime_coarse y n (einval) n (enotsup) n (enotsup) n (einval) + clock_tai y n (einval) y y n (einval) + clock_process_cputime_id y n (einval) y y n (einval) + clock_thread_cputime_id y n (einval) n (einval [2]) y n (einval) + pthread_getcpuclockid() y n (einval) y y n (einval) + + [1] the caller must have cap_wake_alarm, or the error eperm results. + + [2] this error is generated in the glibc wrapper. + +connect.2 + michael kerrisk [eric dumazet] + update the details on af_unspec + update the details on af_unspec and circumstances in which + socket can be reconnected. + +dup.2 + michael kerrisk + see also: add pidfd_getfd(2) + +epoll_ctl.2 + michael kerrisk + various minor additions and clarifications + +epoll_wait.2 + michael kerrisk + a few minor additions and rewrites + +execve.2 + michael kerrisk + add a subhead for the discussion of effect on process attributes + michael kerrisk + explicitly note that argv[argc] == null in the new program + michael kerrisk + errors: enoent does not occur for missing shared libraries + see http://sourceware.org/bugzilla/show_bug.cgi?id=12241. + +_exit.2 + michael kerrisk + clarify that raw _exit() system call terminates only the calling thread + +inotify_add_watch.2 + michael kerrisk + example: add reference to example in inotify(7) + +io_submit.2 + julia suvorova + add iocb_cmd_poll opcode + +lseek.2 + michael kerrisk [matthew wilcox] + errors: enxio can also occur seek_data in middle of hole at end of file + +madvise.2 + michael kerrisk [andrea arcangeli] + incorporate some (ancient) comments about madv_hugepage + back in 2011, a mail from andrea arcangeli noted some details + that i never got round to incorporating into the manual page. + +mmap.2 + michael kerrisk + add a subhead for the 'flags' argument + michael kerrisk + move some text hidden at the end of description to notes + +msgctl.2 + michael kerrisk + add information on permission bits (based on sysvipc(7) text) + michael kerrisk + copy information on 'msqid_ds' fields from sysvipc(7) + +open.2 + michael kerrisk + clarify that o_nofollow is relevant (only) for basename of 'pathname' + aleksa sarai + add references to new openat2(2) page + michael kerrisk + note einval error for invalid character in basename of 'pathname' + +pidfd_open.2 + michael kerrisk + mention pidfd_getfd(2) + +poll.2 + michael kerrisk + add an example program + michael kerrisk + mention epoll(7) in the introductory paragraph + michael kerrisk + improve description of efault error + michael kerrisk + fix description of enomem error + +select_tut.2 + michael kerrisk + adjust header file includes in example + employ , rather than the historical header files. + +semctl.2 + michael kerrisk + copy information on 'semid_ds' fields from sysvipc(7) + michael kerrisk + add a reference to the example in shmop(2) + michael kerrisk + add information on permission bits (based on sysvipc(7) text) + +semget.2 + michael kerrisk + example: add an example program + +semop.2 + michael kerrisk + add a reference to the semop(2) example in shmop(2) + +shmctl.2 + michael kerrisk + add information on permission bits (based on sysvipc(7) text) + michael kerrisk + note that execute permission is not needed for shmat() shm_exec + michael kerrisk + copy information on 'shmid_ds' fields from sysvipc(7) + michael kerrisk + some small improvements to the description of the 'shmid_ds' structure + +shmget.2 + michael kerrisk + add a reference to the example in shmop(2) + +shmop.2 + michael kerrisk + example: add a pair of example programs + add example programs demonstrating usage of shmget(2), shmat(2), + semget(2), semctl(2), and semop(2). + +sigaction.2 +signal.7 + zack weinberg + document kernel bugs in delivery of signals from cpu exceptions + +stat.2 + michael kerrisk + clarify definitions of timestamp fields + in particular, make it clear that atime and mtime relate to the + file *data*. + +syscalls.2 + michael kerrisk + add new linux 5.6 system calls + michael kerrisk + note that the 5.x series followed 4.20 + +timer_create.2 + michael kerrisk + timer_create(2) also supports clock_tai + michael kerrisk + mention clock_getres(2) for further details on the various clocks + +timerfd_create.2 + michael kerrisk [thomas gleixner] + note a case where timerfd_settime() can fail with ecanceled + michael kerrisk [devi r.k, thomas gleixner] + negative changes to clock_realtime may cause read() to return 0 + michael kerrisk + rework text for einval for invalid clock id + michael kerrisk + refer reader to clock_getres(2) for further details on the clocks + +unshare.2 + michael kerrisk + add clone_newcgroup and clone_newtime to example program + +exit.3 + michael kerrisk [walter harms] + small improvement to the discussion of 'status' argument + +ftok.3 + michael kerrisk + example: add a reference to the example in semget(2) + +getifaddrs.3 + michael kerrisk [michael galassi] + example: remove unneeded loop variable + +nl_langinfo.3 + eugene syromyatnikov + document era-related locale elements + eugene syromyatnikov + add information about am/pm time format locale elements + eugene syromyatnikov + mention the respective strftime(3) conversion specifications + +sem_init.3 + michael kerrisk + add references to example code in shm_open(3) and sem_wait(3) + +sem_post.3 + michael kerrisk + add a reference to code example code in shm_open(3) + +shm_open.3 + michael kerrisk + example: add some example programs + +strcmp.3 + michael kerrisk + add an example program + michael kerrisk [andrew micallef, walter harms] + rework text describing return value to be clearer + michael kerrisk + note that the comparison is done using unsigned char + michael kerrisk + see also: add ascii(7) + +strftime.3 + eugene syromyatnikov [michael kerrisk] + refer to the relevant nl_langinfo(3) items + eugene syromyatnikov + expand %e and %o description + eugene syromyatnikov + consistently document fall-back format string + +proc.5 + mike frysinger + clarify /proc/[pid]/cmdline mutability + +cgroups.7 + michael kerrisk + update list of cgroups v2 controllers + update the list of cgroups v2 controllers (several controllers + were missing). + michael kerrisk + add a subsection on cgroup v2 mount options and include 'nsdelegate' + michael kerrisk + document the cgroups v2 'memory_localevents' mount option + michael kerrisk + see also: add documentation/admin-guide/cgroup-v2.rst + +namespaces.7 + michael kerrisk + add time namespaces information + michael kerrisk + eliminate some superfluous info from display of /proc/pid/ns links + +path_resolution.7 + aleksa sarai + update to mention openat2(2) features + +socket.7 + michael kerrisk + note scm message types for so_timestamp and so_timestampns + +tcp.7 + michael kerrisk + see also: mention documentation/networking/ip-sysctl.txt + +time.7 + michael kerrisk + add small subsection on clocks and time namespaces + +unix.7 + heinrich schuchardt + correct example + +vsock.7 + stefano garzarella [jorgen hansen, stefan hajnoczi] + add vmaddr_cid_local description + + +==================== changes in man-pages-5.07 ==================== + +released: 2020-06-09, munich + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +achilles gaikwad +adhemerval zanella +aleksa sarai +alexander monakov +alexander morozov +alexopo seid +amir goldstein +andi kleen +andrea galbusera +arnd bergmann +branden robinson +brian geffon +bruno haible +chris lamb +christian brauner +dave hansen +dave martin +david adam +devin j. pohly +dmitry v. levin +eric hopper +eric sandeen +eugene syromyatnikov +fabien siron +florian weimer +gary perkins +geoff clare +goldwyn rodrigues +heiko carstens +heinrich schuchardt +helge kreutzmann +ian rogers +idan katz +jakub wilk +jan kara +jan moskyto matejka +jason etherton +jeff moyer +john marshall +jonny grant +joseph c. sible +jürgen sauermann +kai mäkisara +keno fischer +kirill a. shutemov +kirill smelkov +kir kolyshkin +léo stefanesco +li xinhai +lokesh gidra +lukas czerner +manfred spraul +marco curreli +marcus gelderie +martin doucha +matthew bobrowski +michael kerrisk +michal hocko +nikola forró +olivier gayot +ondrej slamecka +paul eggert +peter schiffer +peter wu +petr vorel +piotr caban +ricardo castano +richard cochran +richard palethorpe +russell king +stefan puiu +thierry lelegard +thomas piekarski +tobias stoeckmann +urs thuermann +vincent lefèvre +vlad +vrafaeli@msn.com +walter harms +will deacon +yang shi +yunqiang su + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +ioctl_fslabel.2 + eric sandeen + new page documenting filesystem get/set label ioctl(2) operations + + +removed pages +------------- + +ioctl_list.2 + michael kerrisk [heinrich schuchardt, eugene syromyatnikov] + this page was first added more than 20 years ago. since + that time it has seen hardly any update, and is by now + very much out of date, as reported by heinrich schuchardt + and confirmed by eugene syromyatnikov. + + as heinrich says: + + man-pages like netdevices.7 or ioctl_fat.2 are what is + needed to help a user who does not want to read through the + kernel code. + + if ioctl_list.2 has not been reasonably maintained since + linux 1.3.27 and hence is not a reliable source of + information, shouldn't it be dropped? + + my answer is, yes (but let's move a little info into ioctl(2)). + + +newly documented interfaces in existing pages +--------------------------------------------- + +adjtimex.2 + arnd bergmann [richard cochran, michael kerrisk] + document clock_adjtime(2) + +clock_getres.2 + richard cochran [michael kerrisk] + explain dynamic clocks + +clone.2 + christian brauner, michael kerrisk + document the clone3() clone_into_cgroup flag + +mremap.2 + brian geffon, michael kerrisk [lokesh gidra] + document mremap_dontunmap + +open.2 + joseph c. sible [michael kerrisk] + document fs.protected_fifos and fs.protected_regular + +prctl.2 + dave martin + add pr_spec_indirect_branch for speculation_ctrl prctls + dave martin + add pr_spec_disable_noexec for speculation_ctrl prctls + dave martin + add pr_pac_reset_keys (arm64) + +ptrace.2 + joseph c. sible + document ptrace_set_syscall + +proc.5 + michael kerrisk + document /proc/sys/fs/protected_regular + michael kerrisk + document /proc/sys/fs/protected_fifos + michael kerrisk + document /proc/sys/fs/aio-max-nr and /proc/sys/fs/aio-nr + +new and changed links +--------------------- + +clock_adjtime.2 + arnd bergmann + new link to adjtimex(2) + + +global changes +-------------- + +various pages + michael kerrisk + retitle example section heading to examples + examples appears to be the wider majority usage across various + projects' manual pages, and is also what is used in the posix + manual pages. + +various pages + michael kerrisk + correct bogus posix.1 standards names + posix.1-2003 ==> posix.1-2001 tc1 + posix.1-2004 ==> posix.1-2001 tc2 + posix.1-2013 ==> posix.1-2008 tc1 + posix.1-2016 ==> posix.1-2008 tc2 + +various pages + michael kerrisk + add section number in page cross-reference. + +various pages + kir kolyshkin + add missing commas in see also + +various pages + michael kerrisk + remove availability section heading + in the few pages where this heading (which is "nonstandard" within + man-pages) is used, it always immediately follows conforming to + and generally contains information related to standards. remove + the section heading, thus incorporating availability into + conforming to. + +various pages + michael kerrisk + remove section number in page self-references + +various pages + michael kerrisk + put see also entries in alphabetical order + +various pages + michael kerrisk + place sh sections in standard order + fix various pages that deviated from the norm described in + man-pages(7). + +various "aio" pages + michael kerrisk [andi kleen, jeff moyer] + change uses of aio_context_t to io_context_t + + +changes to individual pages +--------------------------- + +bpf.2 + peter wu + update enum bpf_map_type and enum bpf_prog_type + richard palethorpe + change note on unprivileged access + the kernel now allows calls to bpf() without cap_sys_admin + under some circumstances. + +clone.2 + michael kerrisk + add kernel version numbers for clone_args fields + michael kerrisk + combine separate notes sections + +close.2 + michael kerrisk [lukas czerner, peter schiffer, thierry lelegard] + note behavior when close() happens in a parallel thread + if one thread is blocked in an i/o system call on a file descriptor + that is closed in another thread, then the blocking system call + does not return immediately, but rather when the i/o operation + completes. this surprises some people, but is longstanding + behavior. + +connect.2 + stefan puiu + can return eacces because of selinux + +execve.2 + michael kerrisk [eric hopper] + changes to the "dumpable" flag may change ownership of /proc/pid files + michael kerrisk + improve/correct discussion of changes to dumpable flag during execve(2) + the details were not quite accurate. defer to prctl(2) + for the more complete picture. + nikola forró + clarify signal sent to the process on late failure + michael kerrisk + see also: add capabilities(7) + +fanotify_init.2 + amir goldstein [matthew bobrowski] + move out of place entry fan_report_fid + it was inserted in the middle of the fan_class_ multi flags bit + and broke the multi flag documentation. + michael kerrisk [alexander morozov, amir goldstein, jan kara] + remove mention of fan_q_overflow as an input value in 'mask' + see https://bugzilla.kernel.org/show_bug.cgi?id=198569. + amir goldstein [jan kara, matthew bobrowski] + clarification about fan_event_on_child and new events + amir goldstein [jan kara, matthew bobrowski] + clarification about fan_mark_mount and fan_report_fid + +getdents.2 + petr vorel [michael kerrisk] + mention glibc support for getdents64() + support was added in glibc 2.30. + chris lamb + correct linux_dirent definition in example code + it is "unsigned long" earlier up in the file + +gettid.2 + michael kerrisk [joseph c. sible] + document header file and feature test macro requirements for gettid() + +ioctl.2 + michael kerrisk + see also: add ioctl_fslabel(2) + michael kerrisk + remove mentions of ioctl_list(2) + michael kerrisk + move subsection on "ioctl structure" from ioctl_list(2) to ioctl(2) + +io_setup.2 + michael kerrisk + tweak description of /proc/sys/fs/aio-max-nr + +mbind.2 + li xinhai [michael kerrisk] + remove note about mpol_mf_strict been ignored + +mmap.2 + michael kerrisk [heinrich schuchardt] + don't mark map_anon as deprecated + +move_pages.2 + yang shi [michal hocko] + returning positive value is a new error case + +mremap.2 + michael kerrisk + remove mention of "segmentation fault" in efault text + "segmentation fault" (sigsegv) is not exactly the same thing as + efault. + michael kerrisk + reorder some paragraphs in notes + michael kerrisk + move a paragraph from description to notes + +msgctl.2 + michael kerrisk + correct description of 'msg_ctime' field + verified by inspecting kernel source. + +nfsservctl.2 + michael kerrisk + see also: add nfsd(7) + +open.2 + michael kerrisk + some '*at' apis have functionality that isn't in conventional apis + note that another reason to use the *at() apis is to access + 'flags' functionality that is not available in the corresponding + conventional apis. + michael kerrisk + add a few more apis to list in "rationale for openat()..." + there have been a few more dirfd apis added in recent times. + michael kerrisk + explain ways in which a 'directory file descriptor' can be obtained + michael kerrisk + add openat2() to list of apis that take a 'dirfd' argument + +openat2.2 + michael kerrisk [aleksa sarai] + various changes after feedback from aleksa sarai + +poll.2 + michael kerrisk + add license to example program + +prctl.2 + dave martin + sort prctls into alphabetical order + dave martin + clarify that prctl can apply to threads + the current synopsis for prctl(2) misleadingly claims that prctl + operates on a process. rather, some (in fact, most) prctls operate + dave martin [dave hansen] + document removal of intel mpx prctls + dave martin + fix mis-description of thread id values in procfs + dave martin + work around bogus constant "maxsig" in pr_set_pdeathsig + michael kerrisk + add reference to proc(5) for /proc/self/task/[tid]/comm + dave martin [michael kerrisk] + add health warning + dave martin + clarify the unsupported hardware case of einval + +rename.2 + michael kerrisk + see also: add rename(1) + +s390_runtime_instr.2 + heiko carstens [eugene syromyatnikov, michael kerrisk] + document signum argument behavior change + document that the signum argument is ignored in newer kernels, but + that user space should pass a valid real-time signal number for + backwards compatibility. + +semctl.2 + michael kerrisk [manfred spraul] + correct description of sem_ctime field + +semget.2 + michael kerrisk + add license to example program + +shmctl.2 + michael kerrisk + correct 'shm_ctime' description + +shmop.2 + michael kerrisk + add license to example programs + +statfs.2 + michael kerrisk [david adam] + add smb2 constant to filesystem types list + +syscall.2 + dave martin [will deacon] + arm64: fix syscall number register size + dave martin [russell king] + arm: use real register names for arm/oabi + +sysfs.2 + michael kerrisk + see also: add proc(5) and sysfs(5) + +utimensat.2 + goldwyn rodrigues + immutable flag returns eperm + linux kernel commit 337684a1746f "fs: return eperm on immutable + inode" changed the return value of the utimensat(2) from -eacces + to -eperm in case of an immutable flag. + +wait4.2 + michael kerrisk + update wait3() feature test macro requirements for changes in glibc 2.26 + +cexp2.3 + michael kerrisk + still not present in glibc 2.31 + +cmsg.3 + michael kerrisk + conforming to: note which cmsg_* apis are in current and upcoming posix + +dirfd.3 + michael kerrisk + see also: add openat(2) + +dlsym.3 + alexander monakov + extend discussion of null symbol values + avoid implying that use of ifunc is the only way to produce a + symbol with null value. give more scenarios how a symbol may get + null value, but explain that in those scenarios dlsym() will fail + with glibc's ld.so due to an implementation inconsistency. + +err.3 + michael kerrisk + examples: use exit_failure rather than 1 as exit status + +expm1.3 + michael kerrisk + the expm1() bogus underflow floating-point exception has been fixed + see https://www.sourceware.org/bugzilla/show_bug.cgi?id=6778 + michael kerrisk + the bogus invalid floating-point exception bug has been fixed + https://www.sourceware.org/bugzilla/show_bug.cgi?id=6814. + +fdim.3 + michael kerrisk + bugs: these functions did not set errno on some architectures + https://www.sourceware.org/bugzilla/show_bug.cgi?id=6796 + +ftw.3 + michael kerrisk + glibc eventually fixed a regression in ftw_sln behavior + for details, see: + https://bugzilla.redhat.com/show_bug.cgi?id=1422736 + http://austingroupbugs.net/view.php?id=1121 + https://bugzilla.redhat.com/show_bug.cgi?id=1422736 + +getauxval.3 + yunqiang su + mips, at_base_platform passes isa level + +getdtablesize.3 + michael kerrisk + remove redundant statement that getdtablesize() is a library function + +malloc.3 + michael kerrisk + add 'reallocarray' in name + michael kerrisk + add versions section noting when reallocarray() was added to glibc + +newlocale.3 + michael kerrisk [piotr caban] + fix a valgrind issue in example program + see https://bugzilla.kernel.org/show_bug.cgi?id=202977. + +nextafter.3 + michael kerrisk + since glibc 2.23, these functions do set errno + see https://www.sourceware.org/bugzilla/show_bug.cgi?id=6799. + +posix_spawn.3 + olivier gayot [adhemerval zanella] + clarify by using name of steps rather than syscalls + olivier gayot [adhemerval zanella] + document implementation using clone() since glibc 2.24 + olivier gayot [adhemerval zanella] + document posix_spawn_usevfork + added a few lines about posix_spawn_usevfork so that it appears + clearly that since glibc 2.24, the flag has no effect. + olivier gayot [adhemerval zanella] + document the posix_spawn_setsid attribute + +pow.3 + michael kerrisk + bugs: pow() performance problem for some (rare) inputs has been fixed + see https://sourceware.org/bugzilla/show_bug.cgi?id=13932 + michael kerrisk + several bugs in glibc's pow() implementation were fixed in glibc 2.16 + see https://www.sourceware.org/bugzilla/show_bug.cgi?id=3866. + michael kerrisk + add a subheading to mark off historical bugs that are now fixed + +printf.3 + tobias stoeckmann + prevent signed integer overflow in example + +ptsname.3 + bruno haible + fix description of failure behaviour of ptsname_r() + +random.3 + john marshall + change "rand_max" tp "2^31-1" + +scalb.3 + michael kerrisk + these functions now correctly set errno for the edom and erange cases + see https://www.sourceware.org/bugzilla/show_bug.cgi?id=6803 + and https://www.sourceware.org/bugzilla/show_bug.cgi?id=6804 + +scalbln.3 + michael kerrisk + these functions now correctly set errno for the erange case + see https://www.sourceware.org/bugzilla/show_bug.cgi?id=6803 + +scanf.3 + michael kerrisk [jürgen sauermann] + clarify that 'x' specifier allows a 0x/0x prefix in input string + +sem_getvalue.3 + michael kerrisk [andrea galbusera] + note that glibc's sem_getvalue() doesn't return einval errors + see https://bugzilla.kernel.org/show_bug.cgi?id=204273 + +setlogmask.3 + michael kerrisk + note that log_upto() is included in the next posix release + +shm_open.3 + michael kerrisk + add license to example programs + +sincos.3 + michael kerrisk + the glibc implementation does now give edom for a domain error + see https://www.sourceware.org/bugzilla/show_bug.cgi?id=15467 + +stdarg.3 + michael kerrisk + see also: add vprintf(3), vscanf(3), vsyslog(3) + +strcmp.3 + michael kerrisk + add license to example programs + +strftime.3 + urs thuermann + iso week number can be 52, add example + +y0.3 + michael kerrisk + these functions now correctly diagnose a pole error + https://sourceware.org/bugzilla/show_bug.cgi?id=6807 + michael kerrisk + errno is now correctly set to erange on underflow + https://www.sourceware.org/bugzilla/show_bug.cgi?id=6808 + +loop.4 + michael kerrisk [vlad] + 'lo_flags' is nowadays "r/w" + see https://bugzilla.kernel.org/show_bug.cgi?id=203417 + +veth.4 + devin j. pohly + add a more direct example + iproute2 allows you to specify the netns for either side of a veth + interface at creation time. add an example of this to veth(4) so + it doesn't sound like you have to move the interfaces in a + separate step. + +core.5 + michael kerrisk [jonny grant] + mention 'sysctl -w' as a way of changing core_pattern setting + michael kerrisk [jonny grant] + note that not dumping core of an unreadable binary is a security measure + michael kerrisk [jonny grant] + explain that core_pattern %e is process/thread 'comm' value + the 'comm' value is typically the same as the (possibly + truncated) executable name, but may be something different. + +filesystems.5 + michael kerrisk + see also: add sysfs(5) and xfs(5) + +locale.5 + michael kerrisk [helge kreutzmann] + improve description of 'first_weekday' + +proc.5 + michael kerrisk + note kernel version for /proc/pid/smaps vmflags "wf" flag + michael kerrisk + add "um" and "uw" to vmflags in /proc/[pid]/smaps + michael kerrisk + add "mp" to vmflags in /proc/[pid]/smaps + michael kerrisk + note kernel version that removed /proc/pid/smaps vmflags "nl" flag + ian rogers + add "wf" to vmflags in /proc/[pid]/smaps + michael kerrisk + note kernel version for /proc/pid/smaps vmflags "dd" flag + michael kerrisk + add "sf" to vmflags in /proc/[pid]/smaps + michael kerrisk [kirill a. shutemov] + remove "mp" under vmflags in /proc/[pid]/smaps + michael kerrisk [eric hopper] + alert the reader that uid/gid changes can reset the "dumpable" attribute + keno fischer + fix an outdated note about map_files + the restriction to cap_sys_admin was removed from map_files in 2015. + michael kerrisk [helge kreutzmann] + better explanation of some /proc/ide fields + michael kerrisk + task_comm_len limit includes the terminating '\0' + clarify this detail in the discussion of /proc/[pid]/comm. + michael kerrisk + add a detail to /proc/[pid]/comm + note the connection to the "%e" specifier in + /proc/sys/kernel/core_pattern. + +securetty.5 + michael kerrisk [helge kreutzmann] + improve wording of .sh one-line description + +tzfile.5 + michael kerrisk + sync to 2020a tzdb release + from https://www.iana.org/time-zones, version 2020a. + michael kerrisk + explain ut abbreviation + +ascii.7 + michael kerrisk [helge kreutzmann] + see also: fix sort order in entries + +bpf-helpers.7 + michael kerrisk + resync against kernel 5.7 + +cgroups.7 + marcus gelderie + mention cgroup.sane_behavior file + the cgroup.sane_behavior file returns the hard-coded value "0" and + is kept for legacy purposes. mention this in the man-page. + michael kerrisk + note the existence of the clone3() clone_into_cgroup flag + +credentials.7 + michael kerrisk + alert reader that uid/gid changes can affect process capabilities + michael kerrisk + changes to process uids/gids can effect the "dumpable" attribute + michael kerrisk + add a list of the apis that change a process's credentials + +fanotify.7 + amir goldstein [jan kara, matthew bobrowski] + fix fanotify_fid.c example + michael kerrisk + wrap some long lines in example program + +fanotify.7 +fanotify_mark.2 + amir goldstein [matthew bobrowski] + clarify fan_ondir in output mask + fan_ondir was an input only flag before introducing + fan_report_fid. since the introduction of fan_report_fid, it can + also be in output mask. + +hier.7 + thomas piekarski [gary perkins] + updating from fhs 2.3 to 3.0 + see https://bugzilla.kernel.org/show_bug.cgi?id=206693 + +inotify.7 + michael kerrisk [jason etherton] + add missing #include in example program + +ip.7 + michael kerrisk [martin doucha] + note a few more valid 'protocol' values + see https://bugzilla.kernel.org/show_bug.cgi?id=204981 + michael kerrisk + see also: add netdevice(7) + +man-pages.7 + michael kerrisk + rename example to examples + michael kerrisk + describe copyright section + man-pages doesn't use copyright sections in manual pages, but + various projects do. make some recommendations about placement + of the section. + michael kerrisk + add reporting bugs section + man-pages doesn't have a reporting bugs section in manual pages, + but many other projects do. make some recommendations about + placement of that section. + michael kerrisk + mention authors in summary section list + although man-pages doesn't use authors sections, many projects do + use an authors section in their manual pages, so mention it in + man-pages to suggest some guidance on the position at which + to place that section. + +mount_namespaces.7 + michael kerrisk + see also: add mount(8), umount(8) + +namespaces.7 + michael kerrisk + document /proc/sys/user/max_time_namespaces + +netlink.7 + michael kerrisk [idan katz] + update path for netlink_connector docs in kernel source tree + michael kerrisk [fabien siron] + note that netlink_sock_diag is preferred over netlink_inet_diag + +pid_namespaces.7 + michael kerrisk + note that /proc/sys/kernel/ns_last_pid is virtualized per pid ns + michael kerrisk + correct capability requirements for write to /proc/sys/kernel/ns_last_pid + cap_sys_admin is needed in the user ns that owns the pid ns. + +rtnetlink.7 + jan moskyto matejka [michael kerrisk] + add missing rta_* attributes + +standards.7 + michael kerrisk [geoff clare] + add some more standards + add: susv4 2016 edition, posix.1-2017, and susv4 2018 edition + michael kerrisk + remove mention of bogus "posix" names + the terms posix.1-{2003,2004,2013,2016} were inventions of + my imagination, as confirmed by consulting geoff clare of + the open group. remove these names. + +symlink.7 + michael kerrisk + describe differences in the treatment of symlinks in the dirname + describe differences in the treatment of symlinks in the dirname + part of pathname. + +tcp.7 + michael kerrisk [vrafaeli@msn.com] + update info on tcp_syn_retries default value + see https://bugzilla.kernel.org/show_bug.cgi?id=202885. + +user_namespaces.7 + michael kerrisk [léo stefanesco] + clarify that "system time" means "calendar time" + +xattr.7 + achilles gaikwad + add attr(1) as relevant page to see also + +ldconfig.8 + florian weimer + mention new default for --format in glibc 2.32 + +zdump.8 + michael kerrisk [marco curreli, paul eggert] + update to latest upstream tz release + look under "latest version", which is 2020a. + + +==================== changes in man-pages-5.08 ==================== + +released: 2020-08-13, munich + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +alejandro colomar +aleksa sarai +alyssa ross +andrew price +andy lutomirski +arkadiusz drabczyk +benjamin peterson +bjarni ingi gislason +bruno haible +carlos o'donell +catalin marinas +dan kenigsberg +dave martin +diogo miguel ferreira rodrigues +florian weimer +g. branden robinson +geoff clare +helge kreutzmann +jakub wilk +jeff layton +john scott +kumar kartikeya dwivedi +michael kerrisk +mike frysinger +oleksandr kravchuk +philip adams +rich felker +saikiran madugula +stephen hemminger +sven hoexter +thomas bartelsmeier +thomas piekarski +victorm007@yahoo.com + +apologies if i missed anyone! + + +newly documented interfaces in existing pages +--------------------------------------------- + +prctl.2 + dave martin + add sve prctls (arm64) + add documentation for the pr_sve_set_vl and pr_sve_get_vl + prctls added in linux 4.15 for arm64. + dave martin [catalin marinas] + add tagged address abi control prctls (arm64) + add documentation for the pr_set_tagged_addr_ctrl and + pr_get_tagged_addr_ctrl prctls added in linux 5.4 for arm64. + +setns.2 + michael kerrisk + document the use of pid file descriptors with setns() + starting with linux 5.8, setns() can take a pid file descriptor as + an argument, and move the caller into or more of the namespaces of + the thread referred to by that descriptor. + +capabilities.7 + michael kerrisk + document cap_bpf + michael kerrisk + add cap_perfmon + +symlink.7 + aleksa sarai + document magic links more completely + + +global changes +-------------- + +a few pages + michael kerrisk + use \` rather than ` + \` produces better rendering in pdf. + +various pages + michael kerrisk [geoff clare] + use "\(ti" instead of "~" + a naked tilde ("~") renders poorly in pdf. instead use "\(ti", + which renders better in a pdf, and produces the same glyph + when rendering on a terminal. + +various pages + michael kerrisk [geoff clare] + use "\(ha" rather than "^" in code + this renders better in pdf. + +various pages + mike frysinger + drop "coding: utf-8" header + this header is used inconsistently -- man pages are utf-8 encoded + but not setting this marker. it's only respected by the man-db + package, and seems a bit anachronistic at this point when utf-8 + is the standard default nowadays. + +various pages + mike frysinger + trim leading blank comment line + very few pages do this, so trim them. + +various pages + mike frysinger + use standard .\" comment style + the \" comment produces blank lines. use the .\" that the vast + majority of the codebase uses instead. + +various pages + mike frysinger [g. branden robinson] + various pages: drop t comment header + historically, a comment of the following form at the top of a + manual page was used to indicate too man(1) that the use of tbl(1) + was required in order to process tables: + + '\" t + + however, at least as far back as 2001 (according to branden), + man-db's man(1) automatically uses tbl(1) as needed, rendering + this comment unnecessary. and indeed many existing pages in + man-pages that have tables don't have this comment at the top of + the file. so, drop the comment from those files where it is + present. + + +changes to individual pages +--------------------------- + +ioctl_tty.2 + michael kerrisk + fix a confusing wording error in description of tiocsptlck + +iopl.2 + thomas piekarski [victorm007@yahoo.com] + updating description of permissions and disabling interrupts + update description of permissions for port-mapped i/o set + per-thread and not per-process. mention that iopl() can not + disable interrupts since linux 5.5 anymore and is in general + deprecated and only provided for legacy x servers. + + see https://bugzilla.kernel.org/show_bug.cgi?id=205317 + +keyctl.2 + oleksandr kravchuk + declare auth_key to fix a compilation error in example code + +lseek.2 + andrew price + list gfs2 support for seek_hole/seek_data + +mount.2 + michael kerrisk + errors: add einval for bind mount of mount namespace inode + +open.2 + michael kerrisk + say a bit more about what happens when 'mode' is wrongly omitted + +pidfd_open.2 + michael kerrisk + add the setns(2) use case for pid file descriptors + michael kerrisk + close the pidfd in example + close the pid file descriptor in the example program, to hint to + the reader that like every other kind of file descriptor, a pid fd + should be closed. + +prctl.2 + michael kerrisk + the parent death signal is cleared on some credential changes + see kernel/cred.c::commit_creds() in the linux 5.6 source code. + +seccomp.2 + andy lutomirski + improve x32 and nr truncation notes + +send.2 +recv.2 + alyssa ross + add msg_iovlen posix note + msg_iovlen is incorrectly typed (according to posix) in addition + to msg_controllen, but unlike msg_controllen, this wasn't + mentioned for msg_iovlen. + +setns.2 + michael kerrisk + example: use o_cloexec when opening namespace file descriptor + michael kerrisk + it is possible to setns() to the caller's current pid namespace + the page currently incorrectly says that 'fd' must refer to + a descendant pid namespace. however, 'fd' can also refer to + the caller's current pid namespace. verified by experiment, + and also comments in kernel/pid_namespace.c (linux 5.8-rc1). + +sync.2 + jeff layton + syncfs() now returns errors if writeback fails + a patch has been merged for v5.8 that changes how syncfs() reports + errors. change the sync() manpage accordingly. + +syscalls.2 + michael kerrisk + add faccessat2(), added in linux 5.8 + +sysctl.2 + michael kerrisk + glibc removed support for sysctl() starting in version 2.32 + +atoi.3 + arkadiusz drabczyk + explain disadvantages of atoi() + michael kerrisk + relocate bugs section + michael kerrisk + add notes section explaining 0 return value on error + and note that this is not specified by posix. + +fread.3 + arkadiusz drabczyk + add example + arkadiusz drabczyk + explain that file position is moved after calling fread()/fwrite() + corresponding manpage on freebsd already contains that + information. + +getpt.3 +posix_openpt.3 +pts.4 + michael kerrisk + use the term "pseudoterminal multiplexor device" for /dev/ptmx + let's use some consistent terminology for this device. + +posix_memalign.3 + bruno haible + clarify how to free the result of posix_memalign + +pthread_rwlockattr_setkind_np.3 + carlos o'donell [kumar kartikeya dwivedi] + clarify a pthread_rwlock_prefer_writer_np detail + +queue.3 + alejandro colomar + remove wrong code from example + alejandro colomar + comment out text for functions not in glibc (related: 6559169cac) + +pts.4 + michael kerrisk + remove notes on bsd pseudoterminals + this information is already covered better in pty(7). no need to + mention it again here. + +hosts.5 + thomas bartelsmeier + clarify capability for ipv6 outside of examples + resolves https://bugzilla.kernel.org/show_bug.cgi?id=208279 + +proc.5 + jakub wilk + use "pwd -p" for printing cwd + "/bin/pwd" happens to work with the gnu coreutils implementation, + which has -p as the default, contrary to posix requirements. + + use "pwd -p" instead, which is shorter, easier to type, and should + work everywhere. + arkadiusz drabczyk + inform that comm in /proc/pid/{stat,status} might also be truncated + pgrep for example searches for a process name in /proc/pid/status + +resolv.conf.5 + michael kerrisk [helge kreutzmann] + clarify that ip6-bytestring was removed in 2.25 + +capabilities.7 + dan kenigsberg + clarify that cap_sys_nice relates to *lowering* the nice value + saikiran madugula + cap_sys_resource: add two more items for posix message queues + cap_sys_resource also allows overriding /proc/sys/fs/mqueue/msg_max + and /proc/sys/fs/mqueue/msgsize_max. + michael kerrisk [dan kenigsberg] + clarify wording around increasing process nice value + michael kerrisk + see also: add getpcaps(8) + +cgroups.7 +cpuset.7 + sven hoexter + update kernel cgroup documentation references + cgroups-v1/v2 documentation got moved to the "admin-guide" subfolder + and converted from .txt files to .rst + +ip.7 + michael kerrisk [stephen hemminger] + remove mention of ipfw(4) which was in long obsolete ipchains project + +man-pages.7 + michael kerrisk + add some notes on generating optimal glyphs + getting nice renderings of ^ ` and ~ requires special + steps in the page source. + +pty.7 + michael kerrisk + explicitly mention config_legacy_ptys + explicitly mention config_legacy_ptys, and note that it is disabled + by default since linux 2.6.30. + michael kerrisk + relocate a paragraph to notes + +standards.7 + michael kerrisk + add an entry for posix.1-1988 + michael kerrisk [geoff clare] + correct various details in the explanation of xpg/posix/sus + +ld.so.8 + florian weimer [michael kerrisk] + list more places in which dynamic string tokens are expanded + this happens for more than just dt_rpath/dt_runpath. + arkadiusz drabczyk + explain that empty entry in ld_library_path means cwd + +zic.8 + michael kerrisk + sync to 2020a tzdb release + from https://www.iana.org/time-zones, version 2020a. + + +==================== changes in man-pages-5.09 ==================== + +released: 2020-11-01, munich + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +alejandro colomar +aleksa sarai +alexey budankov +amir goldstein +carlos o'donell +dave martin +david howells +david laight +dmitry v. levin +érico rolim +florian weimer +g. branden robinson +hauke fath +heinrich schuchardt +henrik@optoscale.no +ira weiny +jakub wilk +jan kara +jann horn +jing peng +jonathan wakely +jonny grant +konstantin bukin +mark mossberg +marko hrastovec +matthew bobrowski +michael kerrisk +mike frysinger +paul eggert +paul moore +rich felker +samanta navarro +serge hallyn +simon mcvittie +sridhar samudrala +stephen smalley +steve hilder +thomas piekarski +tony may +tycho andersen +yang xu + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +circleq.3 + alejandro colomar + new page with 'circleq' content extracted from queue(3) + +list.3 + alejandro colomar + new page with 'list' content extracted from queue(3) + + +pthread_attr_setsigmask_np.3 + michael kerrisk + new page for pthread_attr_setsigmask_np() + pthread_attr_getsigmask_np() + add a page documenting the pthread_attr_setsigmask_np(3) and + pthread_attr_getsigmask_np(3) functions added in glibc 2.32. + +slist.3 + alejandro colomar + new page with 'slist' content extracted from queue(3) + +stailq.3 + alejandro colomar + new page with 'stailq' content extracted from queue(3) + +tailq.3 + alejandro colomar + new page with 'tailq' content extracted from queue(3) + +system_data_types.7 + alejandro colomar, michael kerrisk + a new page documenting a wide range of system data types. + +kernel_lockdown.7 + david howells, heinrich schuchardt [michael kerrisk] + new page documenting the kernel lockdown feature + +queue.7 + alejandro colomar + create summary page for 'queue' apis + the former queue(3) page was rather unwieldy, as it attempted to + describe too many apis. after splitting that content out into a + number of smaller pages ( circleq.3, list.3, slist.3, stailq.3, + and tailq.3) move the much-reduced queue(3) page, which is now + essentially a summary of those apis, from section 3 to section 7. + + +newly documented interfaces in existing pages +--------------------------------------------- + +fanotify_init.2 +fanotify.7 + amir goldstein [jan kara, matthew bobrowski] + document fan_report_dir_fid + +fanotify_init.2 +fanotify.7 + amir goldstein [jan kara, matthew bobrowski] + document fan_report_name + +statx.2 + ira weiny + add statx_attr_dax + +strerror.3 + michael kerrisk + document strerrorname_np() and strerrordesc_np() + strerrorname_np() and strerrordesc_np() were added in glibc 2.32. + +strsignal.3 + michael kerrisk + document sigabbrev_np() and sigdescr_np(). + sigabbrev_np() and sigdescr_np() were added in glibc 2.32. + +loop.4 + yang xu + document loop_configure ioctl + yang xu + document lo_flags_direct_io flag + +capabilities.7 + michael kerrisk + document the cap_checkpoint_restore capability added in linux 5.9 + +ip.7 + stephen smalley [paul moore] + document ip_passsec for udp sockets + +ip.7 +socket.7 + stephen smalley + document so_peersec for af_inet sockets + sridhar samudrala + document so_incoming_napi_id + +socket.7 +unix.7 + stephen smalley [serge hallyn, simon mcvittie] + add initial description for so_peersec + + +new and changed links +--------------------- + +aiocb.3 +clock_t.3 +clockid_t.3 +dev_t.3 +div_t.3 +double_t.3 +fenv_t.3 +fexcept_t.3 +file.3 +float_t.3 +gid_t.3 +id_t.3 +imaxdiv_t.3 +int8_t.3 +int16_t.3 +int32_t.3 +int64_t.3 +intn_t.3 +intmax_t.3 +intptr_t.3 +lconv.3 +ldiv_t.3 +lldiv_t.3 +off_t.3 +pid_t.3 +ptrdiff_t.3 +regex_t.3 +regmatch_t.3 +regoff_t.3 +siginfo_t.3 +sigset_t.3 +sigval.3 +size_t.3 +ssize_t.3 +suseconds_t.3 +time_t.3 +timer_t.3 +timespec.3 +timeval.3 +uid_t.3 +uint8_t.3 +uint16_t.3 +uint32_t.3 +uint64_t.3 +uintn_t.3 +uintptr_t.3 +va_list.3 +void.3 + alejandro colomar, michael kerrisk + new links to system_data_types(7) + +circleq_entry.3 +circleq_head.3 +circleq_init.3 +circleq_insert_after.3 +circleq_insert_before.3 +circleq_insert_head.3 +circleq_insert_tail.3 +circleq_remove.3 + alejandro colomar + link to the new circleq(3) page instead of queue(3) + +list_empty.3 +list_entry.3 +list_first.3 +list_foreach.3 +list_head.3 +list_head_initializer.3 +list_init.3 +list_insert_after.3 +list_insert_before.3 +list_insert_head.3 +list_next.3 +list_remove.3 + alejandro colomar + link to the new list.3 page instead of queue.3 + +slist_empty.3 +slist_entry.3 +slist_first.3 +slist_foreach.3 +slist_head.3 +slist_head_initializer.3 +slist_init.3 +slist_insert_after.3 +slist_insert_head.3 +slist_next.3 +slist_remove.3 +slist_remove_head.3 + alejandro colomar + link to the new slist(3) page instead of queue(3) + +stailq_concat.3 +stailq_empty.3 +stailq_entry.3 +stailq_first.3 +stailq_foreach.3 +stailq_head.3 +stailq_head_initializer.3 +stailq_init.3 +stailq_insert_after.3 +stailq_insert_head.3 +stailq_insert_tail.3 +stailq_next.3 +stailq_remove.3 +stailq_remove_head.3 + alejandro colomar + link to the new stailq(3) page instead of queue(3) + +tailq_concat.3 +tailq_empty.3 +tailq_entry.3 +tailq_first.3 +tailq_foreach.3 +tailq_foreach_reverse.3 +tailq_head.3 +tailq_head_initializer.3 +tailq_init.3 +tailq_insert_after.3 +tailq_insert_before.3 +tailq_insert_head.3 +tailq_insert_tail.3 +tailq_last.3 +tailq_next.3 +tailq_prev.3 +tailq_remove.3 +tailq_swap.3 + alejandro colomar + link to the new tailq(3) page instead of queue(3) + +getcwd.2 +mq_notify.2 +mq_open.2 +mq_timedreceive.2 +mq_timedsend.2 +mq_unlink.2 + michael kerrisk + reinstate links to section 3 pages that document system calls + some of the links removed in commit 247c654385128fd0748 should + have been kept, because in some cases there are real system + calls whose wrapper functions are documented in section 3. + +queue.3 + alejandro colomar + link to queue(7) + +sigabbrev_np.3 + michael kerrisk + new link to strsignal.3 + +sigdescr_np.3 + michael kerrisk + new link to strsignal.3 + +strerrordesc_np.3 + michael kerrisk + new link to strerror(3) + +strerrorname_np.3 + michael kerrisk + new link to strerror(3) + +sys_siglist.3 + michael kerrisk + new link to strsignal(3) + + +global changes +-------------- + +various pages + alejandro colomar + use ``sizeof`` consistently through all the examples in the + following way: + + - use the name of the variable instead of its type as argument for + ``sizeof``. + +various pages + alejandro colomar + use sizeof() to get buffer size (instead of hardcoding macro name) + +various pages + michael kerrisk + use \(aq instead of ' inside monospace fonts + use \(aq to get an unslanted single quote inside monospace code + blocks. using a simple ' results in a slanted quote inside pdfs. + +various pages + michael kerrisk, alejandro colomar + use c99 style to declare loop counter variables + rather than: + + sometype x; + + for (x = ....; ...) + + use + + for (sometype x = ...; ...) + + this brings the declaration and use closer together (thus aiding + readability) and also clearly indicates the scope of the loop + counter variable. + +various pages + alejandro colomar + switch printf() casts to use [u]intmax_t + %ju / %jd + let's move to the 21st century. instead of casting system data + types to long/long long/etc. in printf() calls, instead cast to + intmax_t or uintmax_t, the largest available signed/unsigned + integer types. + +various pages + alejandro colomar + omit 'int' keyword for 'short', 'long' and 'long long' types + +various pages + alejandro colomar + remove unneeded casts + +various pages + alejandro colomar + in printf(): s/0x%/%#/ except when followed by x instead of x + use printf()'s '#' flag character to prepend the string "0x". + + however, when the number is printed in uppercase, and the prefix + is in lowercase, the string "0x" needs to be manually written. + +various pages + michael kerrisk + use c99-style declarations for readability + rather than writing things such as: + + struct sometype *x; + ... + x = malloc(sizeof(*x)); + + let's use c99 style so that the type info is in the same line as + the allocation: + + struct sometype *x = malloc(sizeof(*x)); + +various pages + alejandro colomar + cast to 'unsigned long' rather than 'long' when printing with "%lx" + +stdarg.3 + alejandro colomar + declare variables with different types in different lines + in particular, don's mix a variable and a pointer declaration + on the same line: type x, *p; + + +changes to individual pages +--------------------------- + +memusage.1 + michael kerrisk + examples: remove doubled calculations + the same calculations are repeated in malloc() and printf() calls. + for better readability, do the calculations once. + michael kerrisk + use %zu rather than %zd when printing 'size_t' values + +clock_getres.2 + alejandro colomar + examples: use 'const' when appropriate + alejandro colomar [jakub wilk] + cast 'time_t' to 'int' for printf() and fix the length modifiers + michael kerrisk [tony may] + fix type and variable name in dynamic clock code example + +clone.2 + michael kerrisk + cap_checkpoint_restore can now be used to employ 'set_tid' + +epoll_ctl.2 + michael kerrisk + epoll instances can be nested to a maximum depth of 5 + this limit appears to be an off-by-one count against + ep_max_nests (4). + michael kerrisk + move some version info from conforming to to versions + +eventfd.2 + alejandro colomar + use 'prixn' macros when printing c99 fixed-width integer types + +futex.2 + alejandro colomar + use appropriate types + +getdents.2 + alejandro colomar + synopsis: add missing header and feature test macro + +intro.2 +intro.3 +credentials.7 +feature_test_macros.7 +standards.7 + michael kerrisk + see also: add system_data_types(7) + +ioctl_ns.2 +stat.2 + alejandro colomar [konstantin bukin] + fix signedness of printf specifiers + +membarrier.2 + alejandro colomar + note that glibc does not provide a wrapper + +mprotect.2 + alejandro colomar + use "%p" rather than casting to 'long' when printing pointer values + +mq_getsetattr.2 + alejandro colomar + use 'const' when appropriate + +msgop.2 + yang xu + add restriction on enosys error + +open.2 + michael kerrisk [henrik@optoscale.no] + errors: add ebusy + +openat.2 + alejandro colomar + synopsis: return long + the linux kernel uses long as the return type for this syscall. + as glibc provides no wrapper, use the same type the kernel uses. + +open_by_handle_at.2 + alejandro colomar + use "%u" rather than "%d" when printing 'unsigned int' values + +perf_event_open.2 + alexey budankov + update the man page with cap_perfmon related information + +recv.2 +send.2 + michael kerrisk + add cross references to pages with further info about ancillary data + +sched_getattr.2 + aleksa sarai + update to include changed size semantics + +seccomp.2 + michael kerrisk [jann horn] + warn reader that seccomp_ret_trace can be overridden + highlight to the reader that if another filter returns a + higher-precedence action value, then the ptracer will not + be notified. + michael kerrisk [rich felker] + warn against the use of seccomp_ret_kill_thread + killing a thread with seccomp_ret_kill_thread is very likely + to leave the rest of the process in a broken state. + michael kerrisk [rich felker] + examples: use seccomp_ret_kill_process rather than seccomp_ret_kill + alejandro colomar + use array_size() macro instead of raw sizeof division + +setns.2 + michael kerrisk + correct the version for time namespace support + +sigaction.2 + michael kerrisk [alejandro colomar] + use correct posix type for siginfo_t.si_value + +syscalls.2 + michael kerrisk + move system calls from discontinued ports out of main syscall list + various ports that had their own indigenous system calls have + been discontinued. remove those system calls (none of which had + manual pages!) to a separate part of the page, to avoid + cluttering the main list of system calls. + michael kerrisk + add close_range (linux 5.9) + +timerfd_create.2 + alejandro colomar + use 'prixn' macros when printing c99 fixed-width integer types + +userfaultfd.2 + michael kerrisk + use a better type (uint64_t) for 'len' in examples + alejandro colomar + use 'prix64' rather than "%llx" when printing 64-bit fixed-width types + +argz_add.3 +envz_add.3 + michael kerrisk [jonny grant] + point out that 'error_t' is an integer type + +bsearch.3 + alejandro colomar + fix intermediate type and remove unneeded casts + +bswap.3 + jakub wilk + use strtoull() for parsing 64-bit numbers + +dlopen.3 + michael kerrisk + clarify dt_runpath/dt_rpath details + it is the dt_runpath/dt_rpath of the calling object (not the + executable) that is relevant for the library search. verified + by experiment. + +errno.3 + michael kerrisk [alejandro colomar] + note that the pthreads apis do not set errno + +fopencookie.3 + alejandro colomar + printf()'s .* expects an int; cast accordingly + alejandro colomar + fix bugs in example + +fread.3 + alejandro colomar + move array_size logic into macro + +freeaddrinfo.3 + marko hrastovec + fix memory leaks in freeaddrinfo() examples + +getline.3 + alejandro colomar + use %zd rather than %zu when printing 'ssize_t' values + +lseek64.3 + michael kerrisk + since glibc 2.28. the 'llseek' symbol is no longer available + +mallinfo.3 + michael kerrisk + the 'usmblks' field is nowadays always 0 + +offsetof.3 + alejandro colomar + use "%zu" rather than "%zd" when printing 'size_t' values + +perror.3 + michael kerrisk + sys_errlist and sys_nerr are no longer exposed by + the change came with the release of glibc 2.32. + +posix_fallocate.3 + érico rolim + add eopnotsupp error code. + +psignal.3 +strsignal.3 + michael kerrisk + consolidate information on 'sys_siglist' in one page (strsignal(3)) + +pthread_attr_init.3 + michael kerrisk + see also: add pthread_attr_init(3) + +pthread_attr_init.3 +pthread_create.3 +pthread_getattr_np.3 + michael kerrisk + use correct type (size_t) for some variables + +pthread_getattr_np.3 + alejandro colomar + use "%zu" and "%zx" when printing 'size_t' values + +pthread_sigmask.3 + michael kerrisk + see also: add pthread_attr_setsigmask_np(3) + +qsort.3 + alejandro colomar + fix casts + alejandro colomar + synopsis: move code from queue.3 to stailq.3 + +regex.3 + alejandro colomar + add example program + alejandro colomar + remove unnecessary include + +strsignal.3 + michael kerrisk [hauke fath] + note that starting with v2.32, glibc no longer exports 'sys_siglist' + michael kerrisk + further addition on version range for sys_siglist + michael kerrisk + note that 'sys_siglist' is nonstandard + +strtod.3 + jonathan wakely + fix return value for underflow + +strtol.3 + alejandro colomar + examples: simplify errno checking + alejandro colomar + examples: as the default base, use special value 0 + alejandro colomar + examples: delimit output string using "" + +tsearch.3 + alejandro colomar + simplify type usage and remove unneeded casts + alejandro colomar + use size_t for malloc() argument + +loop.4 + yang xu + add some details about lo_flags + +core.5 + alejandro colomar + use adequate type + +locale.5 + florian weimer + decimal points, thousands separators must be one character + +proc.5 + michael kerrisk + update capability requirements for accessing /proc/[pid]/map_files + jann horn [mark mossberg] + document inaccurate rss due to split_rss_counting + michael kerrisk + note "open file description" as (better) synonym for "file handle" + +resolv.5 + florian weimer + document the trust-ad option + +aio.7 + alejandro colomar + use perror() directly + +bpf-helpers.7 + michael kerrisk [jakub wilk] + resync with current kernel source + +capabilities.7 + michael kerrisk + under cap_sys_admin, group "sub-capabilities" together + cap_bpf, cap_perfmon, and cap_checkpoint_restore have all been + added to split out the power of cap_sys_admin into weaker pieces. + group all of these capabilities together in the list under + cap_sys_admin, to make it clear that there is a pattern to these + capabilities. + michael kerrisk + cap_sys_admin implies cap_checkpoint_restore + but the latter, weaker capability is preferred. + michael kerrisk + add kernel doc reference for cap_perfmon + +fanotify.7 + alejandro colomar + pass array to read(2) directly instead of a pointer to it + +fanotify.7 +fanotify_mark.2 + amir goldstein [jan kara, matthew bobrowski] + generalize documentation of fan_report_fid + +feature_test_macros.7 + jakub wilk + update list of macros that inhibit default definitions + +man.7 + michael kerrisk [g. branden robinson] + clarify that alternating typeface macros print arguments without spaces + +man-pages.7 + michael kerrisk + add some more requests re code examples + michael kerrisk + soften the statement that ideal programs should be short + +namespaces.7 + michael kerrisk + a 'time_for_children' symlink can also pin a namespace + +pid_namespaces.7 + michael kerrisk + update capability requirements for /proc/sys/kernel/ns_last_pid + +pthreads.7 + michael kerrisk + explicitly note that pthreads apis return an errno-style value on error + +rtld-audit.7 + florian weimer [carlos o'donell] + clarify la_version handshake + returning its argument without further checks is almost always + wrong for la_version. + alejandro colomar + use "%u" rather than "%d" when printing 'unsigned int' values + +sigevent.7 + michael kerrisk + note that 'sigev_notify_thread_id' is linux-specific + +socket.7 + michael kerrisk + see also: add ipv6(7) + + +==================== changes in man-pages-5.10 ==================== + +released: 2020-12-21, munich + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +ahelenia ziemiańska +alejandro colomar +amir goldstein +arusekk +baruch siach +bill allombert +colin ian king +dave martin +davide giorgio +heinrich schuchardt +jan kara +jing peng +john a. leuenhagen +mathias rav +michael kerrisk +mike crowe +namhyung kim +peter oskolkov +philip rowlands +rob landley +ross zwisler +sebastian kirmayer +наб + +apologies if i missed anyone! + + +newly documented interfaces in existing pages +--------------------------------------------- + +access.2 + michael kerrisk + document faccessat2() + faccessat2() was added in linux 5.8 and enables a fix to + longstanding bugs in the faccessat() wrapper function. + +membarrier.2 + peter oskolkov [alejandro colomar] + update for linux 5.10 + linux kernel commit 2a36ab717e8fe678d98f81c14a0b124712719840 + (part of 5.10 release) changed sys_membarrier prototype/parameters + and added two new commands [membarrier_cmd_private_expedited_rseq + and membarrier_cmd_register_private_expedited_rseq]. + +mount.2 +statfs.2 + ross zwisler + add nosymfollow flags to mount(2) and statfs(2) + + +new and changed links +--------------------- + +faccessat2.2 + michael kerrisk + new link to access.2 + +circleq_empty.3 +circleq_first.3 +circleq_foreach.3 +circleq_foreach_reverse.3 +circleq_head_initializer.3 +circleq_last.3 +circleq_loop_next.3 +circleq_loop_prev.3 +circleq_next.3 +circleq_prev.3 + michael kerrisk + add missing links to circleq.3 + +pthread_attr_getsigmask_np.3 + michael kerrisk + new link to pthread_attr_setsigmask_np.3 + + +global changes +-------------- + +various pages + alejandro colomar + use oxford comma + + +changes to individual pages +--------------------------- + +access.2 + michael kerrisk + bugs: note that faccessat() wrapper function emulation ignores acls + +bpf.2 + michael kerrisk + place examples section in correct location + +cacheflush.2 + alejandro colomar + document architecture-specific variants + alejandro colomar [heinrich schuchardt] + document __builtin___clear_cache() as a more portable alternative + +chroot.2 +memfd_create.2 +tailq.3 + michael kerrisk [alejandro colomar] + fix unbalanced .nf/.fi + +clock_getres.2 + michael kerrisk + place errors in alphabetical order + +clone.2 +sigaltstack.2 + michael kerrisk + clone(clone_vm) disables the alternate signal stack + +getrlimit.2 + michael kerrisk + state more precisely the range of kernel versions that had rlimit_locks + +getrusage.2 + michael kerrisk + note that the 'vtimes' symbol exists only up to glibc 2.32 + +io_cancel.2 +io_destroy.2 +io_getevents.2 +io_setup.2 +io_submit.2 + alejandro colomar + synopsis: s/io_context_t/aio_context_t/ + linux uses aio_context_t for these syscalls, + and it's the type provided by . + use it in the synopsis. + + libaio uses 'io_context_t', but that difference is already noted + in notes. + +io_setup.2 + alejandro colomar + synopsis: return long + +link.2 + mathias rav + errors: add enoent when target is deleted + linux kernel commit aae8a97d3ec30788790d1720b71d76fd8eb44b73 (part + of kernel release v2.6.39) added a check to disallow creating a + hard link to an unlinked file. + +llseek.2 + michael kerrisk + note size of 'loff_t' type + michael kerrisk + point the reader to lseek64(3) for info about llseek(3) + michael kerrisk + some mild rewriting to ease reading of the info in this page + +mmap.2 + michael kerrisk + clarify sigbus text and treatment of partial page at end of a mapping + +msgctl.2 + michael kerrisk + make comments in 'msqid_ds' definition more compact + michael kerrisk + place list of field descriptions in same order as structure definition + michael kerrisk + use field name "msg_cbytes" rather than "__msg_cbytes" + michael kerrisk + add description of 'msg_cbytes' field + +openat.2 + colin ian king + fix include path, should be linux/openat2.h + +perf_event_open.2 + namhyung kim [alejandro colomar] + update man page with recent kernel changes + alejandro colomar + assign calculated value explicitly to 'config' + +restart_syscall.2 + alejandro colomar + synopsis: fix restart_syscall() return type + +set_tid_address.2 + alejandro colomar + synopsis: fix set_tid_address() return type + +shmctl.2 + michael kerrisk + place list of field descriptions in same order as structure definition + +sigaction.2 + michael kerrisk + clarify description of sa_nodefer + clarify description of sa_nodefer, and note interaction with + act.sa_mask. + michael kerrisk + add a cross-reference to signal(7) for further info on 'ucontext_t' + +sigaltstack.2 + michael kerrisk + clarify that the alternate signal stack is per-thread + clarify that the alternate signal stack is per-thread (rather + than process-wide). + +spu_create.2 + michael kerrisk + add kernel version numbers for spu_create_affinity_spu/_mem + michael kerrisk + relocate paragraph on 'mode' argument + michael kerrisk [alejandro colomar] + clarify that spu_create() now has 4 arguments but once had only 3 + +subpage_prot.2 + alejandro colomar + synopsis: fix return type: s/long/int/ + +syscalls.2 + michael kerrisk + add process_madvise() + michael kerrisk + note that sysctl() was removed in linux 5.5 + +timer_getoverrun.2 + michael kerrisk + timer_getoverrun() now clamps the overrun count to delaytimer_max + see https://bugzilla.kernel.org/show_bug.cgi?id=12665. + +uselib.2 +posix_memalign.3 +profil.3 +rtime.3 + michael kerrisk + remove some text about libc/libc5 + with this change, there remain almost no vestiges of information + about the long defunct linux libc. + +errno.3 + michael kerrisk + note another possible cause of the emfile error + +getcontext.3 + michael kerrisk + mention sa_siginfo flag when talking about 3-argument signal handler + michael kerrisk + see also: add signal(7) + +list.3 + michael kerrisk + name: remove list_prev, which is not documented in this page + +lseek64.3 + michael kerrisk + remove section numbers from interface list + michael kerrisk + remove sentence saying lseek64() is an alias for llseek() + michael kerrisk + notes: describe the origin of lseek64() in lfs + +nextafter.3 + michael kerrisk + remove duplicate "bugs" section heading + +pthread_tryjoin_np.3 + michael kerrisk [mike crowe] + note that pthread_timedjoin_np() uses clock_realtime, but there's a bug + +rcmd.3 + michael kerrisk + see also: remove intro(2) + +strnlen.3 + michael kerrisk [heinrich schuchardt] + fix a small inconsistency in the text + +elf.5 + michael kerrisk + see also: add objcopy(1) + +filesystems.5 + ahelenia ziemiańska [alejandro colomar] + fix link to user space tooling for ncpfs + ahelenia ziemiańska [alejandro colomar] + note ncpfs removal from kernel + +attributes.7 + michael kerrisk + see also: add signal-safety(7) + +fanotify.7 + amir goldstein [jan kara] + fix outdated description + +kernel_lockdown.7 + michael kerrisk + remove unneeded quotes + +packet.7 + baruch siach [alejandro colomar] + update references to kernel documentation + +pthreads.7 + michael kerrisk + rephrase function list in terms of posix rather than sus + the list was using an inconsistent mixture of "posix" and "sus". + +signal.7 + michael kerrisk [heinrich schuchardt, dave martin] + add some details on the execution of signal handlers + add a "big picture" of what happens when a signal handler + is invoked. + michael kerrisk + add pidfd_send_signal() to list of apis for sending signals + michael kerrisk + mention 'ucontext_t' in the discussion of signal handler execution + michael kerrisk + see also: add swapcontext(3) + +signal-safety.7 + michael kerrisk + note async-signal-safety details for errno + +standards.7 + michael kerrisk + add url for posix.1-2008/susv4 + michael kerrisk + add lfs (large file summit) + michael kerrisk [rob landley] + fix some urls for locations of the standards + michael kerrisk + relocate the discussion on posix manual pages + +tcp.7 + alejandro colomar [philip rowlands] + tcp_syncookies: it is now an integer [0, 2] + since linux kernel 3.12, tcp_syncookies can have the value 2, + which sends out cookies unconditionally. + + +==================== changes in man-pages-5.11 ==================== + +released: 2021-03-21, munich + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +alejandro colomar +alessandro bono +alyssa ross +bastien roucariès +bruno haible +christian brauner +ciprian dorin craciun +dmitry v. levin +dmitry vorobev +edef +enke chen +gabriel krisman bertazi +ganimedes colomar +jakub wilk +jan kara +jens axboe +johannes pfister +johannes wellhöfer +john morris +jonathan wakely +jonny grant +manfred spraul +michael kerrisk +michal hocko +minchan kim +pádraig brady +pali rohár +palmer dabbelt +paran lee +peter h. froehlich +philipp schuster +stephen kitt +steve grubb +suren baghdasaryan +szunti +valentin kettner +vincent lefevre +walter franzini +walter harms +willem de bruijn +yang xu +zack weinberg + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +close_range.2 + stephen kitt, michael kerrisk [christian brauner] + new page documenting close_range(2) + +process_madvise.2 + suren baghdasaryan, minchan kim [michal hocko, alejandro colomar, + michael kerrisk] + document process_madvise(2) + +fileno.3 + michael kerrisk + split fileno(3) content out of ferror(3) into new page + fileno(3) differs from the other functions in various ways. + for example, it is governed by different standards, + and can set 'errno'. conversely, the other functions + are about examining the status of a stream, while + fileno(3) simply obtains the underlying file descriptor. + furthermore, splitting this function out allows + for some cleaner upcoming changes in ferror(3). + + +newly documented interfaces in existing pages +--------------------------------------------- + +epoll_wait.2 + willem de bruijn [dmitry v. levin] + add documentation of epoll_pwait2() + expand the epoll_wait() page with epoll_pwait2(), an epoll_wait() + variant that takes a struct timespec to enable nanosecond + resolution timeout. + +fanotify_init.2 +fanotify.7 + jan kara [steve grubb] + document fan_audit flag and fan_enable_audit + +madvise.2 + michael kerrisk + add descriptions of madv_cold and madv_pageout + taken from process_madvise(2). + +openat2.2 + jens axboe + add resolve_cached + +prctl.2 + gabriel krisman bertazi + document syscall user dispatch + +mallinfo.3 + michael kerrisk + document mallinfo2() and note that mallinfo() is deprecated + document the mallinfo2() function added in glibc 2.33. + update example program to use mallinfo2() + +system_data_types.7 + alejandro colomar + add off64_t to system_data_types(7) + +ld.so.8 + michael kerrisk + document the --argv0 option added in glibc 2.33 + + +new and changed links +--------------------- + +epoll_pwait2.2 + dmitry v. levin + new link to epoll_wait(2) + +mallinfo2.3 + michael kerrisk + new link to mallinfo(3) + +off64_t.3 + alejandro colomar + new link to system_data_types(7) + + +global changes +-------------- + +various pages + alejandro colomar + synopsis: use 'restrict' in prototypes + this change has been completed for *all* relevant pages + (around 135 pages in total). + +various pages + alejandro colomar [zack weinberg] + remove unused + the manual pages are already inconsistent in which headers need + to be included. right now, not all of the types used by a + function have their required header included in the synopsis. + + if we were to add the headers required by all of the types used by + functions, the synopsis would grow too much. not only it would + grow too much, but the information there would be less precise. + + having system_data_types(7) document each type with all the + information about required includes is much more precise, and the + info is centralized so that it's much easier to maintain. + + so let's document only the include required for the function + prototype, and also the ones required for the macros needed to + call the function. + + only defines types, not functions or constants, so + it doesn't belong to man[23] (function) pages at all. + + i ignore if some old systems had headers that required you to + include *before* them (incomplete headers), but if + so, those implementations would be broken, and those headers + should probably provide some kind of warning. i hope this is not + the case. + + [mtk: already in 2001, posix.1 removed the requirement to + include for many apis, so this patch seems + well past due.] + +a few pages + alejandro colomar + add notes about missing glibc wrappers + +_exit.2 +abort.3 +err.3 +exit.3 +pthread_exit.3 +setjmp.3 + alejandro colomar + synopsis: use 'noreturn' in prototypes + use standard c11 'noreturn' in these manual page for + functions that do not return. + +various pages + ganimedes colomar [alejandro colomar] + normalize synopsis notes about nonexistent glibc wrappers + to easily distinguish documentation about glibc wrappers from + documentation about kernel syscalls, let's have a normalized + 'note' in the synopsis, and a further explanation in the page body + (notes in most of them), as already happened in many (but not all) + of the manual pages for syscalls without a wrapper. furthermore, + let's normalize the messages, following membarrier.2 (because it's + already quite extended), so that it's easy to use grep to find + those pages. + normalize notes about nonexistent glibc wrappers + this commit normalizes texts under sections other than synopsis + (most of them in notes). + + +global changes (formatting fixes and minor edits) +------------------------------------------------- + +various pages + michael kerrisk + errors: remove redundant statement that 'errno' is set + this is implied in every other manual page. there is no need to + state it explicitly in these pages. + +various pages + michael kerrisk + use periods more consistently inside code comments + in general, complete sentences in free-standing comments + should be terminated by periods. + +a few pages + michael kerrisk + better table formatting + in particular, allow for rendering in widths different from + (especially less than) 80 columns. + +various pages + michael kerrisk + consistency fix-up in ftms + generally, place '||' at start of a line, rather than the end of + the previous line. + + rationale: this placement clearly indicates that each piece + is an alternative. + +various pages + michael kerrisk [alejandro colomar] + bring more whitespace consistency in synopsis + the use of vertical white space in the synopsis sections + is rather inconsistent. make it more consistent, subject to the + following heuristics: + + * prefer no blank lines between function signatures by default. + * where many functions are defined in the synopsis, add blank + lines where needed to improve readability, possibly by using + blank lines to separate logical groups of functions. + +various pages + alejandro colomar + consistently use 'unsigned int' + most pages use 'unsigned int' (and the kernel too). + make them all do so. + +various pages + michael kerrisk + various improvements in wording in return value + +various pages + michael kerrisk + s/glibc versions . + +clone.2 + valentin kettner + fix types in clone_args + a file descriptor is an int so it should be stored through an int + pointer while parent_tid should have the same type as child_tid + which is pid_t pointer. + +close.2 + michael kerrisk + see also: add close_range(2) + +copy_file_range.2 + alejandro colomar + document glibc wrapper instead of kernel syscall + glibc uses 'off64_t' instead of 'loff_t'. + +delete_module.2 + alejandro colomar + synopsis: fix prototype parameter types + the linux kernel uses 'unsigned int' instead of 'int' for the + 'flags' parameter. as glibc provides no wrapper, use the same + type the kernel uses. + +epoll_create.2 + michael kerrisk + conforming to: mention that epoll_create1() is linux-specific + +epoll_wait.2 + michael kerrisk + conforming to: mention that epoll_pwait() is linux-specific + +execve.2 + palmer dabbelt + correct the versions of linux that don't have arg_max argv/envp size + +execveat.2 + alejandro colomar + fix prototype + it's been 6 years since execveat(2) was added to the kernel, + and there's still no glibc wrapper. let's document the kernel + syscall prototype. + +getcpu.2 + michael kerrisk [alejandro colomar] + rewrite page to describe glibc wrapper function + since glibc 2.29, there is a wrapper for getcpu(2). + the wrapper has only 2 arguments, omitting the unused + third system call argument. rework the manual page + to reflect this. + +getgid.2 +getuid.2 + michael kerrisk + note that these interfaces never modify 'errno' + see https://www.austingroupbugs.net/view.php?id=511 + and the posix.1-2008 specifications of the interfaces. + +gethostname.2 + michael kerrisk + update ftm requirements for gethostname() + +getpagesize.2 +getdtablesize.3 + michael kerrisk + update/correct ftm requirements + +getrusage.2 + michael kerrisk + starting in 2.33, glibc no longer provides vtimes() + +ioctl_tty.2 + michael kerrisk + reformat argument type information + the current mark-up renders poorly. to resolve this, move + the type information into a separate line. + +ipc.2 + alejandro colomar + fix prototype parameter types + +kcmp.2 + michael kerrisk + since linux 5.12, kcmp() availability is unconditional + kcmp() is no longer dependent on config_checkpoint_restore. + +keyctl.2 + alejandro colomar + synopsis: fix prototype parameter types + the linux kernel uses 'unsigned long'. + there's no reason to use the typedef '__kernel_ulong_t'. + +lookup_dcookie.2 + alejandro colomar + use standard types: u64 -> uint64_t + +madvise.2 + michael kerrisk + see also: add process_madvise(2) + +mlock.2 + alejandro colomar + mlock2(): fix prototype parameter types + the documented prototype for mlock2() was a mix of the + glibc wrapper prototype and the kernel syscall prototype. + let's document the glibc wrapper prototype, which is shown below. + michael kerrisk + conforming to: note more explicitly which apis are in the standards + +mmap2.2 + alejandro colomar + fix prototype parameter types + there are many slightly different prototypes for this syscall, + but none of them is like the documented one. + of all the different prototypes, + let's document the asm-generic one. + +mount.2 + michael kerrisk + note that the 'data' argument can be null + +move_pages.2 + alejandro colomar + add notes about missing glibc wrappers + +open.2 +rename.2 + alyssa ross + refer to tmpfs rather than shmem + if i'm understanding correctly, tmpfs is a filesystem built on + shmem, so i think it's more correct (and probably much more + widely understandable) to refer to tmpfs here. + +pciconfig_read.2 + alejandro colomar + synopsis: fix prototype parameter types + use the glibc prototypes instead of the kernel ones. + exception: use 'int' instead of 'enum'. + +pidfd_open.2 + michael kerrisk + note the process_madvise(2) use case for pid file descriptors + +readlink.2 + michael kerrisk [jonny grant] + emphasize that the returned buffer is not null-terminated + +s390_pci_mmio_write.2 + alejandro colomar + synopsis: add 'const' qualifier + s390_pci_mmio_write() uses 'const void *' instead of 'void *'. + +sched_setattr.2 + alejandro colomar + add note about missing glibc wrappers + +semctl.2 + yang xu [alejandro colomar, manfred spraul] + correct sem_stat_any description + +socketcall.2 + alejandro colomar + add note about missing glibc wrapper + +splice.2 + alejandro colomar + use 'off64_t' instead of 'loff_t' + the kernel syscall uses 'loff_t', but the glibc wrapper uses 'off64_t'. + let's document the wrapper prototype, as in other pages. + +spu_create.2 + alejandro colomar + synopsis: fix prototype parameter type + the 'flags' parameter of spu_create() uses 'unsigned int'. + +spu_run.2 + alejandro colomar + synopsis: fix prototype parameter types + the 2nd and 3rd parameters of spu_run() use 'uint32_t *'. + +stat.2 + jonathan wakely [alejandro colomar] + remove from synopsis + there seems to be no reason is shown here, so remove it. + michael kerrisk + move the obsolete _bsd_source ftm to the end of the ftm info + +syscall.2 + peter h. froehlich + update superh syscall convention + +syscalls.2 + michael kerrisk + add epoll_pwait2() + +tkill.2 + alejandro colomar + synopsis: fix prototype parameter types + all but the last parameters of t[g]kill() use 'pid_t', + both in the kernel and glibc. + +vmsplice.2 + alejandro colomar + synopsis: fix prototype parameter type + the 3rd parameter of vmsplice() uses 'size_t' in glibc. + +bstring.3 + michael kerrisk + see also: add string(3) + +circleq.3 +list.3 +slist.3 +stailq.3 +tailq.3 + alejandro colomar + improve readability, especially in synopsis + +circleq.3 + alejandro colomar + fix circleq_loop_*() return type + +crypt.3 + michael kerrisk + reformat ftm info (in preparation for next patch) + michael kerrisk + update crypt() ftm requirements to note glibc 2.28 changes + +ecvt.3 +gcvt.3 + michael kerrisk + update ftm requirements + +error.3 + michael kerrisk [alejandro colomar, walter harms] + clarify the meaning of 'status==0' for error(3) + +ferror.3 + michael kerrisk + remove fileno(3) content that was migrated to new fileno(3) page + michael kerrisk + add a return value section + michael kerrisk + posix.1-2008: these functions won't change 'errno' if 'stream' is valid + see https://www.austingroupbugs.net/view.php?id=401. + +fread.3 + alessandro bono + examples: swap size and nmemb params + it works both ways, but this one feels more right. we are reading + four elements sizeof(*buffer) bytes each. + +fseeko.3 + michael kerrisk + move info about obsolete ftm from synopsis to notes + this makes the synopsis more consistent with other pages. + +ftime.3 + michael kerrisk + glibc 2.33 has removed ftime() + +ftw.3 + alejandro colomar + synopsis: remove duplicate header + +gethostbyname.3 + michael kerrisk + move mention of from synopsis to description + the functions are all declared in . is only + needed for the af_* constants. + +gethostid.3 + michael kerrisk + update ftm requirements for gethostid() + +get_phys_pages.3 + alejandro colomar [jakub wilk] + glibc gets the info from sysinfo(2) since 2.23 + +grantpt.3 +ptsname.3 +unlockpt.3 + michael kerrisk + remove mention of _xopen_source_extended ftm + this rather ancient ftm is not mentioned in other pages for + reasons discussed in feature_test_macros(7). remove this ftm + from the three pages where it does appear. + +malloc.3 + alejandro colomar [johannes pfister] + document that realloc(p, 0) is specific to glibc and nonportable + +malloc_hook.3 + alejandro colomar + synopsis: use 'volatile' in prototypes + +malloc_trim.3 + dmitry vorobev + remove mention of free() call + 'malloc_trim' was and is never called from the 'free' function. + +pthread_create.3 + michael kerrisk [paran lee] + fix undeclared variable error in example program + michael kerrisk + fix a signedness error in the example code + +puts.3 + michael kerrisk + reorder functions more logically (group related functions together) + +qecvt.3 + michael kerrisk + update feature test macro requirements + +setbuf.3 + michael kerrisk + posix doesn't require errno to be unchanged after successful setbuf() + see https://www.austingroupbugs.net/view.php?id=397#c799 + +setlocale.3 + michael kerrisk [alejandro colomar, bruno haible] + restructure a particularly difficult sentence + +simpleq.3 +stailq.3 +queue.7 +simpleq_*.3 + alejandro colomar + document simpleq_*() as an alias to stailq_*() macros + +strerror.3 + alejandro colomar + strerrorname_np() and strerrordesc_np() first appeared on glibc 2.32 + +string.3 + michael kerrisk + see also: add bstring(3) + +system.3 + alejandro colomar [ciprian dorin craciun] + document bug and workaround when the command name starts with a hyphen + +environ.7 + bastien roucariès + reorder the text + move the text describing how to set environment variable before + the list(s) of variables in order to improve readability. + bastien roucariès + document convention of string in environ + document the name=value system and that nul byte is forbidden. + bastien roucariès + document that home, logname, shell, user are set at login time + and point to the su(1) manual page. + bastien roucariès + add see also ld.so(8) for ld_ variables + michael kerrisk [bastien roucariès] + improve the description of path + add more details of how path is used, and mention the legacy + use of an empty prefix. + bastien roucariès [alejandro colomar, bastien roucaries, vincent lefevre] + document valid values of pathnames for shell, pager and editor/visual + michael kerrisk [bastien roucariès] + note the default if pager is not defined + michael kerrisk + be a little more precise when discussing 'exec' + say "execve(2)" instead of "exec(3)", and note that this step + starts a new program (not a new process!). + michael kerrisk [bastien roucariès] + relocate and reword the mention of _gnu_source + +man-pages.7 + michael kerrisk + document "acknowledgement" as the preferred spelling + michael kerrisk + add some notes on comments in example code + michael kerrisk + add a formatting and wording conventions section + in man-pages-5.11, a large number of pages were edited to achieve + greater consistency in the synopsis, return value and attributes + sections. to avoid future inconsistencies, try to capture some of + the preferred conventions in text in man-pages(7). + michael kerrisk + note some rationale for the use of real minus signs + +netdevice.7 + pali rohár [alejandro colomar] + update documentation for siocgifaddr siocsifaddr siocdifaddr + +netlink.7 + pali rohár [alejandro colomar] + fix minimal linux version for netlink_cap_ack + netlink_cap_ack option was introduced in commit 0a6a3a23ea6e which first + appeared in linux version 4.3 and not 4.2. + pali rohár [alejandro colomar] + remove ipv4 from description + rtnetlink is not only used for ipv4 + philipp schuster + clarify details of netlink error responses + make it clear that netlink error responses (i.e., messages with + type nlmsg_error (0x2)), can be longer than sizeof(struct + nlmsgerr). in certain circumstances, the payload can be longer. + +shm_overview.7 + michael kerrisk + see also: add memfd_create(2) + +sock_diag.7 + pali rohár [alejandro colomar] + fix recvmsg() usage in the example + +tcp.7 + enke chen + documentation revision for tcp_user_timeout + +uri.7 + michael kerrisk + note that 'logical' quoting is the norm in europe + + +==================== changes in man-pages-5.12 ==================== + +released: 2021-06-20, christchurch + + +contributors +------------ + +the following people contributed patches/fixes or (noted in brackets +in the changelog below) reports, notes, and ideas that have been +incorporated in changes in this release: + +ahelenia ziemiańska +akihiro motoki +alejandro colomar +alyssa ross +aurelien aptel +borislav petkov +bruce merry +chris keilbart +christian brauner +christoph anton mitterer +dann frazier +dmitry v. levin +florian weimer +huang ying +jakub wilk +james o. d. hunt +jann horn +johannes berg +jon murphy +josh triplett +katsuhiro numata +kees cook +mark kettenis +mathieu desnoyers +michael kerrisk +mike rapoport +peter xu +sargun dhillon +stefan puiu +štěpán němec +thomasavoss +topi miettinen +tycho andersen +utkarsh singh +vishwajith k +walter harms +yang xu +zhiheng li +наб + +apologies if i missed anyone! + + +new and rewritten pages +----------------------- + +seccomp_unotify.2 + michael kerrisk [tycho andersen, jann horn, kees cook, christian brauner + sargun dhillon] + new page documenting the seccomp user-space notification mechanism + +max.3 + alejandro colomar + new page to document max() and min() + + +newly documented interfaces in existing pages +--------------------------------------------- + +seccomp.2 + tycho andersen [michaelkerrisk] + document seccomp_get_notif_sizes + tycho andersen + document seccomp_filter_flag_new_listener [michael kerrisk] + tycho andersen + document seccomp_ret_user_notif [michael kerrisk] + +set_mempolicy.2 + huang ying [alejandro colomar, "huang, ying"] + add mode flag mpol_f_numa_balancing + +userfaultfd.2 + peter xu [alejandro colomar, mike rapoport] + add uffd_feature_thread_id docs + peter xu [alejandro colomar, mike rapoport] + add write-protect mode docs + +proc.5 + michael kerrisk + document /proc/sys/vm/sysctl_hugetlb_shm_group + +system_data_types.7 + alejandro colomar + add 'blksize_t' + alejandro colomar + add 'blkcnt_t' + alejandro colomar + add 'mode_t' + alejandro colomar + add 'struct sockaddr' + alejandro colomar + add 'cc_t' + alejandro colomar + add 'socklen_t' + + +new and changed links +--------------------- + +blkcnt_t.3 + alejandro colomar + new link to system_data_types(7) + +blksize_t.3 + alejandro colomar + new link to system_data_types(7) + +cc_t.3 + alejandro colomar + new link to system_data_types(7) + +min.3 + michael kerrisk + new link to min.3 + +mode_t.3 + alejandro colomar + new link to system_data_types(7) + +sockaddr.3 + alejandro colomar + new link to system_data_types(7) + +socklen_t.3 + alejandro colomar + new link to system_data_types(7) + + +global changes +-------------- + +many pages + alejandro colomar + synopsis: use syscall(sys_...); for system calls without a wrapper + +many pages + alejandro colomar + synopsis: document why each header is required + +many pages + alejandro colomar + synopsis: remove unused includes + +various pages + alejandro colomar + add note about the use of syscall(2) + +various pages + alejandro colomar + synopsis: miscellaneous fixes to includes + +a few pages + alejandro colomar + synopsis: add missing 'const' + + +changes to individual pages +--------------------------- + +dup.2 + michael kerrisk + rewrite the description of dup() somewhat + as can be seen by any number of stackoverflow questions, people + persistently misunderstand what dup() does, and the existing manual + page text, which talks of "copying" a file descriptor doesn't help. + rewrite the text a little to try to prevent some of these + misunderstandings, in particular noting at the start that dup() + allocates a new file descriptor. + michael kerrisk + clarify what silent closing means + alejandro colomar + synopsis: use consistent comments through pages + +epoll_wait.2 + alejandro colomar + move misplaced subsection to notes from bugs + +execveat.2 + michael kerrisk + library support has been added in glibc 2.34 + +_exit.2 + michael kerrisk + add a little more detail on the raw _exit() system cal + +exit_group.2 + alejandro colomar + use 'noreturn' in prototypes + +flock.2 + aurelien aptel [alejandro colomar] + add cifs details + cifs flock() locks behave differently than the standard. + give an overview of those differences. + +ioperm.2 + alejandro colomar + remove obvious comment + +memfd_create.2 +mmap.2 +shmget.2 + michael kerrisk [yang xu] + document the eperm error for huge page allocations + this error can occur if the caller is does not have cap_ipc_lock + and is not a member of the sysctl_hugetlb_shm_group. + +mmap.2 + bruce merry + clarify that map_populate is best-effort + +mount.2 + topi miettinen + document selinux use of ms_nosuid mount flag + +open.2 + alejandro colomar [walter harms] + fix bug in linkat(2) call example + at_empty_path works with empty strings (""), but not with null + (or at least it's not obvious). + michael kerrisk + make it clearer that an fd is an index into the process's fd table + sometimes people are confused, thinking a file descriptor is just a + number.... + +perfmonctl.2 + michael kerrisk + this system call was removed in linux 5.10 + +pipe.2 + alejandro colomar + synopsis: fix incorrect prototype + michael kerrisk + rearrange synopsis so that minority version pipe() is at end + +ptrace.2 + dmitry v. levin [alejandro colomar, mathieu desnoyers] + mention ptrace_get_syscall_info in return value section + +seccomp.2 + michael kerrisk + reorder list of seccomp_set_mode_filter flags alphabetically + (no content changes.) + michael kerrisk + see also: add seccomp_unotify(2) + +select.2 + michael kerrisk + strengthen the warning regarding the low value of fd_setsize + all modern code should avoid select(2) in favor of poll(2) + or epoll(7). + michael kerrisk + relocate sentence about the fd_set value-result arguments to bugs + +syscalls.2 + michael kerrisk + perfmonctl(2) was removed in linux 5.10 + +bswap.3 + alejandro colomar + bswap_*() are implemented using functions + even though it's true that they are macros, + it's transparent to the user. + + the user will see their results casted to unsigned types + after the conversion due to the underlying functions, + so it's better to document these as the underlying functions, + specifying the types. + +cmsg.3 +unix.7 + michael kerrisk + refer to seccomp_unotify(2) for an example of scm_rights usage + +cpow.3 + alejandro colomar + use 'complex' after the type consistently + +ctime.3 + michael kerrisk [katsuhiro numata] + restore documentation of 'tm_gmtoff' field + +errno.3 + alejandro colomar [florian weimer, mark kettenis] + fix enodata text + enodata is an xsi streams extension (not base posix). + +exec.3 + josh triplett [alejandro colomar] + clarify that execvpe() uses path from the caller, not envp + josh triplett [alejandro colomar] + fix description of 'e' variants + the envp argument specifies the environment of the new process + image, not "the environment of the caller". + +fflush.3 + alejandro colomar + see also: add fpurge(3) + +getline.3 + наб [ahelenia ziemiańska, alejandro colomar] + !*lineptr is sufficient + no implementation or spec requires *n to be 0 to allocate + a new buffer. + +getopt.3 + james o. d. hunt [alejandro colomar] + clarify behaviour + +printf.3 + utkarsh singh [alejandro colomar] + add overall structure of format string + +pthread_attr_setinheritsched.3 +pthread_attr_setschedparam.3 + alejandro colomar + synopsis: use 'restrict' in prototypes + +pthread_mutexattr_setrobust.3 + michael kerrisk + note that the *_np() apis are deprecated since glibc 2.34 + alejandro colomar + synopsis: remove incorrect 'const' + +pthread_mutex_consistent.3 + michael kerrisk + note that pthread_mutexattr_setrobust() is now deprecated + +pthread_yield.3 + michael kerrisk + note that this function is deprecated since glibc 2.34 + +rpc.3 + alejandro colomar + synopsis: fix prototypes (misc.) + +scanf.3 + alyssa ross [alejandro colomar] + clarify that %n supports type modifiers + +xdr.3 + alejandro colomar + synopsis: fix prototype types + use the same types glibc uses, and add a missing 'const'. + +capabilities.7 + michael kerrisk + cap_ipc_lock also governs memory allocation using huge pages + +environ.7 + josh triplett [alejandro colomar] + remove obsolete admonishment of the gzip environment variable + +kernel_lockdown.7 + dann frazier [alejandro colomar] + remove description of lifting via sysrq (not upstream) + the patch that implemented lockdown lifting via sysrq ended up + getting dropped[*] before the feature was merged upstream. having + the feature documented but unsupported has caused some confusion + for our users. + +mount_namespaces.7 +namespaces.7 + michael kerrisk + relocate reference to pam_namespace(8) from namespaces.7 to + mount_namespaces.7. + +signal.7 + michael kerrisk + add reference to seccomp_unotify(2) + the seccomp user-space notification feature can cause changes in + the semantics of sa_restart with respect to system calls that + would never normally be restarted. point the reader to the page + that provide further details. + +vsock.7 + alyssa ross + ioctls are on /dev/vsock, not sockets + +.\" copyright (c) 2003 free software foundation, inc. +.\" and copyright (c) 2017 goldwyn rodrigues +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" this file is distributed according to the gnu general public license. +.\" %%%license_end +.\" +.th io_submit 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +io_submit \- submit asynchronous i/o blocks for processing +.sh synopsis +.nf +.br "#include " " /* defines needed types */" +.pp +.bi "int io_submit(aio_context_t " ctx_id ", long " nr \ +", struct iocb **" iocbpp ); +.fi +.pp +.ir note : +there is no glibc wrapper for this system call; see notes. +.sh description +.ir note : +this page describes the raw linux system call interface. +the wrapper function provided by +.i libaio +uses a different type for the +.i ctx_id +argument. +see notes. +.pp +the +.br io_submit () +system call +queues \finr\fp i/o request blocks for processing in +the aio context \fictx_id\fp. +the +.i iocbpp +argument should be an array of \finr\fp aio control blocks, +which will be submitted to context \fictx_id\fp. +.pp +the +.i iocb +(i/o control block) structure defined in +.ir linux/aio_abi.h +defines the parameters that control the i/o operation. +.pp +.in +4n +.ex +#include + +struct iocb { + __u64 aio_data; + __u32 padded(aio_key, aio_rw_flags); + __u16 aio_lio_opcode; + __s16 aio_reqprio; + __u32 aio_fildes; + __u64 aio_buf; + __u64 aio_nbytes; + __s64 aio_offset; + __u64 aio_reserved2; + __u32 aio_flags; + __u32 aio_resfd; +}; +.ee +.in +.pp +the fields of this structure are as follows: +.tp +.i aio_data +this data is copied into the +.i data +field of the +.i io_event +structure upon i/o completion (see +.br io_getevents (2)). +.tp +.i aio_key +this is an internal field used by the kernel. +do not modify this field after an +.br io_submit () +call. +.tp +.i aio_rw_flags +this defines the r/w flags passed with structure. +the valid values are: +.rs +.tp +.br rwf_append " (since linux 4.16)" +.\" commit e1fc742e14e01d84d9693c4aca4ab23da65811fb +append data to the end of the file. +see the description of the flag of the same name in +.br pwritev2 (2) +as well as the description of +.b o_append +in +.br open (2). +the +.i aio_offset +field is ignored. +the file offset is not changed. +.tp +.br rwf_dsync " (since linux 4.13)" +write operation complete according to requirement of +synchronized i/o data integrity. +see the description of the flag of the same name in +.br pwritev2 (2) +as well the description of +.b o_dsync +in +.br open (2). +.tp +.br rwf_hipri " (since linux 4.13)" +high priority request, poll if possible +.tp +.br rwf_nowait " (since linux 4.14)" +don't wait if the i/o will block for operations such as +file block allocations, dirty page flush, mutex locks, +or a congested block device inside the kernel. +if any of these conditions are met, the control block is returned +immediately with a return value of +.b \-eagain +in the +.i res +field of the +.i io_event +structure (see +.br io_getevents (2)). +.tp +.br rwf_sync " (since linux 4.13)" +write operation complete according to requirement of +synchronized i/o file integrity. +see the description of the flag of the same name in +.br pwritev2 (2) +as well the description of +.b o_sync +in +.br open (2). +.re +.tp +.i aio_lio_opcode +this defines the type of i/o to be performed by the +.i iocb +structure. +the +valid values are defined by the enum defined in +.ir linux/aio_abi.h : +.ip +.in +4n +.ex +enum { + iocb_cmd_pread = 0, + iocb_cmd_pwrite = 1, + iocb_cmd_fsync = 2, + iocb_cmd_fdsync = 3, + iocb_cmd_poll = 5, + iocb_cmd_noop = 6, + iocb_cmd_preadv = 7, + iocb_cmd_pwritev = 8, +}; +.ee +.in +.tp +.i aio_reqprio +this defines the requests priority. +.tp +.i aio_fildes +the file descriptor on which the i/o operation is to be performed. +.tp +.i aio_buf +this is the buffer used to transfer data for a read or write operation. +.tp +.i aio_nbytes +this is the size of the buffer pointed to by +.ir aio_buf . +.tp +.i aio_offset +this is the file offset at which the i/o operation is to be performed. +.tp +.i aio_flags +this is the set of flags associated with the +.i iocb +structure. +the valid values are: +.rs +.tp +.br iocb_flag_resfd +asynchronous i/o control must signal the file +descriptor mentioned in +.i aio_resfd +upon completion. +.tp +.br iocb_flag_ioprio " (since linux 4.18)" +.\" commit d9a08a9e616beeccdbd0e7262b7225ffdfa49e92 +interpret the +.i aio_reqprio +field as an +.b ioprio_value +as defined by +.ir linux/ioprio.h . +.re +.tp +.i aio_resfd +the file descriptor to signal in the event of asynchronous i/o completion. +.sh return value +on success, +.br io_submit () +returns the number of \fiiocb\fps submitted (which may be +less than \finr\fp, or 0 if \finr\fp is zero). +for the failure return, see notes. +.sh errors +.tp +.b eagain +insufficient resources are available to queue any \fiiocb\fps. +.tp +.b ebadf +the file descriptor specified in the first \fiiocb\fp is invalid. +.tp +.b efault +one of the data structures points to invalid data. +.tp +.b einval +the aio context specified by \fictx_id\fp is invalid. +\finr\fp is less than 0. +the \fiiocb\fp at +.i *iocbpp[0] +is not properly initialized, the operation specified is invalid for the file +descriptor in the \fiiocb\fp, or the value in the +.i aio_reqprio +field is invalid. +.tp +.b enosys +.br io_submit () +is not implemented on this architecture. +.tp +.b eperm +the +.i aio_reqprio +field is set with the class +.br ioprio_class_rt , +but the submitting context does not have the +.b cap_sys_admin +capability. +.sh versions +the asynchronous i/o system calls first appeared in linux 2.5. +.sh conforming to +.br io_submit () +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 +.br io_submit () +wrapper function provided by +.\" http://git.fedorahosted.org/git/?p=libaio.git +.ir libaio . +.pp +note that the +.i libaio +wrapper function uses a different type +.ri ( io_context_t ) +.\" but glibc is confused, since uses 'io_context_t' to declare +.\" the system call. +for the +.i ctx_id +argument. +note also that the +.i libaio +wrapper does not follow the usual c library conventions for indicating errors: +on error it returns a negated error number +(the negative of one of the values listed in errors). +if the system call is invoked via +.br syscall (2), +then the return value follows the usual conventions for +indicating an error: \-1, with +.i errno +set to a (positive) value that indicates the error. +.sh see also +.br io_cancel (2), +.br io_destroy (2), +.br io_getevents (2), +.br io_setup (2), +.br aio (7) +.\" .sh author +.\" kent yoder. +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/getnetent.3 + +.\" copyright (c) 2004 andries brouwer (aeb@cwi.nl) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th set_tid_address 2 2021-06-20 "linux" "linux programmer's manual" +.sh name +set_tid_address \- set pointer to thread id +.sh synopsis +.nf +.br "#include " " /* definition of " sys_* " constants */" +.b #include +.pp +.bi "pid_t syscall(sys_set_tid_address, int *" tidptr ); +.fi +.pp +.ir note : +glibc provides no wrapper for +.br set_tid_address (), +necessitating the use of +.br syscall (2). +.sh description +for each thread, the kernel maintains two attributes (addresses) called +.i set_child_tid +and +.ir clear_child_tid . +these two attributes contain the value null by default. +.tp +.i set_child_tid +if a thread is started using +.br clone (2) +with the +.b clone_child_settid +flag, +.i set_child_tid +is set to the value passed in the +.i ctid +argument of that system call. +.ip +when +.i set_child_tid +is set, the very first thing the new thread does +is to write its thread id at this address. +.tp +.i clear_child_tid +if a thread is started using +.br clone (2) +with the +.b clone_child_cleartid +flag, +.i clear_child_tid +is set to the value passed in the +.i ctid +argument of that system call. +.pp +the system call +.br set_tid_address () +sets the +.i clear_child_tid +value for the calling thread to +.ir tidptr . +.pp +when a thread whose +.i clear_child_tid +is not null terminates, then, +if the thread is sharing memory with other threads, +then 0 is written at the address specified in +.i clear_child_tid +and the kernel performs the following operation: +.pp + futex(clear_child_tid, futex_wake, 1, null, null, 0); +.pp +the effect of this operation is to wake a single thread that +is performing a futex wait on the memory location. +errors from the futex wake operation are ignored. +.sh return value +.br set_tid_address () +always returns the caller's thread id. +.sh errors +.br set_tid_address () +always succeeds. +.sh versions +this call is present since linux 2.5.48. +details as given here are valid since linux 2.5.49. +.sh conforming to +this system call is linux-specific. +.sh see also +.br clone (2), +.br futex (2), +.br gettid (2) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/getcwd.3 +.\" because getcwd(3) is layered on a system call of the same name + +.so man3/xdr.3 + +.so man3/posix_memalign.3 + +.so man3/key_setsecret.3 + +.so man3/rpc.3 + +.so man3/getservent_r.3 + +.\" copyright (c) michael haardt (michael@cantor.informatik.rwth-aachen.de), +.\" sun jan 15 19:16:33 1995 +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" modified, sun feb 26 15:02:58 1995, faith@cs.unc.edu +.th lp 4 2021-03-22 "linux" "linux programmer's manual" +.sh name +lp \- line printer devices +.sh synopsis +.nf +.b #include +.fi +.sh configuration +\fblp\fp[0\(en2] are character devices for the parallel line printers; +they have major number 6 and minor number 0\(en2. +the minor numbers +correspond to the printer port base addresses 0x03bc, 0x0378, and 0x0278. +usually they have mode 220 and are owned by user +.i root +and group +.ir lp . +you can use printer ports either with polling or with interrupts. +interrupts are recommended when high traffic is expected, for example, +for laser printers. +for typical dot matrix printers, polling will usually be enough. +the default is polling. +.sh description +the following +.br ioctl (2) +calls are supported: +.ip "\fbint ioctl(int \fp\fifd\fp\fb, lptime, int \fp\fiarg\fp\fb)\fp" +sets the amount of time that the driver sleeps before rechecking the printer +when the printer's buffer appears to be filled to +.ir arg . +if you have a fast printer, decrease this number; +if you have a slow printer, then increase it. +this is in hundredths of a second, the default 2 +being 0.02 seconds. +it influences only the polling driver. +.ip "\fbint ioctl(int \fp\fifd\fp\fb, lpchar, int \fp\fiarg\fp\fb)\fp" +sets the maximum number of busy-wait iterations which the polling driver does +while waiting for the printer to get ready for receiving a character to +.ir arg . +if printing is too slow, increase this number; if the +system gets too slow, decrease this number. +the default is 1000. +it influences only the polling driver. +.ip "\fbint ioctl(int \fp\fifd\fp\fb, lpabort, int \fp\fiarg\fp\fb)\fp" +if +.i arg +is 0, the printer driver will retry on errors, otherwise +it will abort. +the default is 0. +.ip "\fbint ioctl(int \fp\fifd\fp\fb, lpabortopen, int \fp\fiarg\fp\fb)\fp" +if +.i arg +is 0, +.br open (2) +will be aborted on error, otherwise error will be ignored. +the default is to ignore it. +.ip "\fbint ioctl(int \fp\fifd\fp\fb, lpcareful, int \fp\fiarg\fp\fb)\fp" +if +.i arg +is 0, then the out-of-paper, offline, and error signals are +required to be false on all writes, otherwise they are ignored. +the default is to ignore them. +.ip "\fbint ioctl(int \fp\fifd\fp\fb, lpwait, int \fp\fiarg\fp\fb)\fp" +sets the number of busy waiting iterations to wait before strobing the +printer to accept a just-written character, and the number of iterations to +wait before turning the strobe off again, +to +.ir arg . +the specification says this time should be 0.5 +microseconds, but experience has shown the delay caused by the code is +already enough. +for that reason, the default value is 0. +.\" fixme . actually, since linux 2.2, the default is 1 +this is used for both the polling and the interrupt driver. +.ip "\fbint ioctl(int \fp\fifd\fp\fb, lpsetirq, int \fp\fiarg\fp\fb)\fp" +this +.br ioctl (2) +requires superuser privileges. +it takes an +.i int +containing the new irq as argument. +as a side effect, the printer will be reset. +when +.i arg +is 0, the polling driver will be used, which is also default. +.ip "\fbint ioctl(int \fp\fifd\fp\fb, lpgetirq, int *\fp\fiarg\fp\fb)\fp" +stores the currently used irq in +.ir arg . +.ip "\fbint ioctl(int \fp\fifd\fp\fb, lpgetstatus, int *\fp\fiarg\fp\fb)\fp" +stores the value of the status port in +.ir arg . +the bits have the following meaning: +.ts +l l. +lp_pbusy inverted busy input, active high +lp_pack unchanged acknowledge input, active low +lp_poutpa unchanged out-of-paper input, active high +lp_pselecd unchanged selected input, active high +lp_perrorp unchanged error input, active low +.te +.ip +refer to your printer manual for the meaning of the signals. +note that undocumented bits may also be set, depending on your printer. +.ip "\fbint ioctl(int \fp\fifd\fp\fb, lpreset)\fp" +resets the printer. +no argument is used. +.sh files +.i /dev/lp* +.\" .sh authors +.\" the printer driver was originally written by jim weigand and linus +.\" torvalds. +.\" it was further improved by michael k.\& johnson. +.\" the interrupt code was written by nigel gamble. +.\" alan cox modularized it. +.\" lpcareful, lpabort, lpgetstatus were added by chris metcalf. +.sh see also +.br chmod (1), +.br chown (1), +.br mknod (1), +.br lpcntl (8), +.br tunelp (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sun jul 25 10:41:34 1993 by rik faith (faith@cs.unc.edu) +.\" modified wed oct 17 01:12:26 2001 by john levon +.th strdup 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +strdup, strndup, strdupa, strndupa \- duplicate a string +.sh synopsis +.nf +.b #include +.pp +.bi "char *strdup(const char *" s ); +.pp +.bi "char *strndup(const char *" s ", size_t " n ); +.bi "char *strdupa(const char *" s ); +.bi "char *strndupa(const char *" s ", size_t " n ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br strdup (): +.nf + _xopen_source >= 500 +.\" || _xopen_source && _xopen_source_extended + || /* since glibc 2.12: */ _posix_c_source >= 200809l + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.pp +.br strndup (): +.nf + since glibc 2.10: + _posix_c_source >= 200809l + before glibc 2.10: + _gnu_source +.fi +.pp +.br strdupa (), +.br strndupa (): +.nf + _gnu_source +.fi +.sh description +the +.br strdup () +function returns a pointer to a new string which +is a duplicate of the string +.ir s . +memory for the new string is +obtained with +.br malloc (3), +and can be freed with +.br free (3). +.pp +the +.br strndup () +function is similar, but copies at most +.i n +bytes. +if +.i s +is longer than +.ir n , +only +.i n +bytes are copied, and a terminating null byte (\(aq\e0\(aq) is added. +.pp +.br strdupa () +and +.br strndupa () +are similar, but use +.br alloca (3) +to allocate the buffer. +they are available only when using the gnu +gcc suite, and suffer from the same limitations described in +.br alloca (3). +.sh return value +on success, the +.br strdup () +function returns a pointer to the duplicated +string. +it returns null if insufficient memory was available, with +.i errno +set to indicate the error. +.sh errors +.tp +.b enomem +insufficient memory available to allocate duplicate string. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br strdup (), +.br strndup (), +.br strdupa (), +.br strndupa () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +.\" 4.3bsd-reno, not (first) 4.3bsd. +.br strdup () +conforms to svr4, 4.3bsd, posix.1-2001. +.br strndup () +conforms to posix.1-2008. +.br strdupa () +and +.br strndupa () +are gnu extensions. +.sh see also +.br alloca (3), +.br calloc (3), +.br free (3), +.br malloc (3), +.br realloc (3), +.br string (3), +.br wcsdup (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/vm86.2 + +.so man2/pciconfig_read.2 + +.so man3/hsearch.3 + +.\" copyright (c) 2014 kees cook +.\" and copyright (c) 2012 will drewry +.\" and copyright (c) 2008, 2014,2017 michael kerrisk +.\" and copyright (c) 2017 tyler hicks +.\" and copyright (c) 2020 tycho andersen +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th seccomp 2 2021-08-27 "linux" "linux programmer's manual" +.sh name +seccomp \- operate on secure computing state of the process +.sh synopsis +.nf +.br "#include " " /* definition of " seccomp_* " constants */" +.br "#include " " /* definition of " "struct sock_fprog" " */" +.br "#include " " /* definition of " audit_* " constants */" +.br "#include " " /* definition of " sig* " constants */" +.br "#include " " /* definition of " ptrace_* " constants */" +.\" kees cook noted: anything that uses seccomp_ret_trace returns will +.\" need +.br "#include " " /* definition of " sys_* " constants */" +.b #include +.pp +.bi "int syscall(sys_seccomp, unsigned int " operation ", unsigned int " flags , +.bi " void *" args ); +.fi +.pp +.ir note : +glibc provides no wrapper for +.br seccomp (), +necessitating the use of +.br syscall (2). +.sh description +the +.br seccomp () +system call operates on the secure computing (seccomp) state of the +calling process. +.pp +currently, linux supports the following +.ir operation +values: +.tp +.br seccomp_set_mode_strict +the only system calls that the calling thread is permitted to make are +.br read (2), +.br write (2), +.br _exit (2) +(but not +.br exit_group (2)), +and +.br sigreturn (2). +other system calls result in the termination of the calling thread, +or termination of the entire process with the +.br sigkill +signal when there is only one thread. +strict secure computing mode is useful for number-crunching +applications that may need to execute untrusted byte code, perhaps +obtained by reading from a pipe or socket. +.ip +note that although the calling thread can no longer call +.br sigprocmask (2), +it can use +.br sigreturn (2) +to block all signals apart from +.br sigkill +and +.br sigstop . +this means that +.br alarm (2) +(for example) is not sufficient for restricting the process's execution time. +instead, to reliably terminate the process, +.br sigkill +must be used. +this can be done by using +.br timer_create (2) +with +.br sigev_signal +and +.ir sigev_signo +set to +.br sigkill , +or by using +.br setrlimit (2) +to set the hard limit for +.br rlimit_cpu . +.ip +this operation is available only if the kernel is configured with +.br config_seccomp +enabled. +.ip +the value of +.ir flags +must be 0, and +.ir args +must be null. +.ip +this operation is functionally identical to the call: +.ip +.in +4n +.ex +prctl(pr_set_seccomp, seccomp_mode_strict); +.ee +.in +.tp +.br seccomp_set_mode_filter +the system calls allowed are defined by a pointer to a berkeley packet +filter (bpf) passed via +.ir args . +this argument is a pointer to a +.ir "struct\ sock_fprog" ; +it can be designed to filter arbitrary system calls and system call +arguments. +if the filter is invalid, +.br seccomp () +fails, returning +.br einval +in +.ir errno . +.ip +if +.br fork (2) +or +.br clone (2) +is allowed by the filter, any child processes will be constrained to +the same system call filters as the parent. +if +.br execve (2) +is allowed, +the existing filters will be preserved across a call to +.br execve (2). +.ip +in order to use the +.br seccomp_set_mode_filter +operation, either the calling thread must have the +.br cap_sys_admin +capability in its user namespace, or the thread must already have the +.i no_new_privs +bit set. +if that bit was not already set by an ancestor of this thread, +the thread must make the following call: +.ip +.in +4n +.ex +prctl(pr_set_no_new_privs, 1); +.ee +.in +.ip +otherwise, the +.br seccomp_set_mode_filter +operation fails and returns +.br eacces +in +.ir errno . +this requirement ensures that an unprivileged process cannot apply +a malicious filter and then invoke a set-user-id or +other privileged program using +.br execve (2), +thus potentially compromising that program. +(such a malicious filter might, for example, cause an attempt to use +.br setuid (2) +to set the caller's user ids to nonzero values to instead +return 0 without actually making the system call. +thus, the program might be tricked into retaining superuser privileges +in circumstances where it is possible to influence it to do +dangerous things because it did not actually drop privileges.) +.ip +if +.br prctl (2) +or +.br seccomp () +is allowed by the attached filter, further filters may be added. +this will increase evaluation time, but allows for further reduction of +the attack surface during execution of a thread. +.ip +the +.br seccomp_set_mode_filter +operation is available only if the kernel is configured with +.br config_seccomp_filter +enabled. +.ip +when +.ir flags +is 0, this operation is functionally identical to the call: +.ip +.in +4n +.ex +prctl(pr_set_seccomp, seccomp_mode_filter, args); +.ee +.in +.ip +the recognized +.ir flags +are: +.rs +.tp +.br seccomp_filter_flag_log " (since linux 4.14)" +.\" commit e66a39977985b1e69e17c4042cb290768eca9b02 +all filter return actions except +.br seccomp_ret_allow +should be logged. +an administrator may override this filter flag by preventing specific +actions from being logged via the +.ir /proc/sys/kernel/seccomp/actions_logged +file. +.tp +.br seccomp_filter_flag_new_listener " (since linux 5.0)" +.\" commit 6a21cc50f0c7f87dae5259f6cfefe024412313f6 +after successfully installing the filter program, +return a new user-space notification file descriptor. +(the close-on-exec flag is set for the file descriptor.) +when the filter returns +.br seccomp_ret_user_notif +a notification will be sent to this file descriptor. +.ip +at most one seccomp filter using the +.br seccomp_filter_flag_new_listener +flag can be installed for a thread. +.ip +see +.br seccomp_unotify (2) +for further details. +.tp +.br seccomp_filter_flag_spec_allow " (since linux 4.17)" +.\" commit 00a02d0c502a06d15e07b857f8ff921e3e402675 +disable speculative store bypass mitigation. +.tp +.br seccomp_filter_flag_tsync +when adding a new filter, synchronize all other threads of the calling +process to the same seccomp filter tree. +a "filter tree" is the ordered list of filters attached to a thread. +(attaching identical filters in separate +.br seccomp () +calls results in different filters from this perspective.) +.ip +if any thread cannot synchronize to the same filter tree, +the call will not attach the new seccomp filter, +and will fail, returning the first thread id found that cannot synchronize. +synchronization will fail if another thread in the same process is in +.br seccomp_mode_strict +or if it has attached new seccomp filters to itself, +diverging from the calling thread's filter tree. +.re +.tp +.br seccomp_get_action_avail " (since linux 4.14)" +.\" commit d612b1fd8010d0d67b5287fe146b8b55bcbb8655 +test to see if an action is supported by the kernel. +this operation is helpful to confirm that the kernel knows +of a more recently added filter return action +since the kernel treats all unknown actions as +.br seccomp_ret_kill_process . +.ip +the value of +.ir flags +must be 0, and +.ir args +must be a pointer to an unsigned 32-bit filter return action. +.tp +.br seccomp_get_notif_sizes " (since linux 5.0)" +.\" commit 6a21cc50f0c7f87dae5259f6cfefe024412313f6 +get the sizes of the seccomp user-space notification structures. +since these structures may evolve and grow over time, +this command can be used to determine how +much memory to allocate for sending and receiving notifications. +.ip +the value of +.ir flags +must be 0, and +.ir args +must be a pointer to a +.ir "struct seccomp_notif_sizes" , +which has the following form: +.ip +.ex +struct seccomp_notif_sizes + __u16 seccomp_notif; /* size of notification structure */ + __u16 seccomp_notif_resp; /* size of response structure */ + __u16 seccomp_data; /* size of \(aqstruct seccomp_data\(aq */ +}; +.ee +.ip +see +.br seccomp_unotify (2) +for further details. +.\" +.ss filters +when adding filters via +.br seccomp_set_mode_filter , +.ir args +points to a filter program: +.pp +.in +4n +.ex +struct sock_fprog { + unsigned short len; /* number of bpf instructions */ + struct sock_filter *filter; /* pointer to array of + bpf instructions */ +}; +.ee +.in +.pp +each program must contain one or more bpf instructions: +.pp +.in +4n +.ex +struct sock_filter { /* filter block */ + __u16 code; /* actual filter code */ + __u8 jt; /* jump true */ + __u8 jf; /* jump false */ + __u32 k; /* generic multiuse field */ +}; +.ee +.in +.pp +when executing the instructions, the bpf program operates on the +system call information made available (i.e., use the +.br bpf_abs +addressing mode) as a (read-only) +.\" quoting kees cook: +.\" if bpf even allows changing the data, it's not copied back to +.\" the syscall when it runs. anything wanting to do things like +.\" that would need to use ptrace to catch the call and directly +.\" modify the registers before continuing with the call. +buffer of the following form: +.pp +.in +4n +.ex +struct seccomp_data { + int nr; /* system call number */ + __u32 arch; /* audit_arch_* value + (see ) */ + __u64 instruction_pointer; /* cpu instruction pointer */ + __u64 args[6]; /* up to 6 system call arguments */ +}; +.ee +.in +.pp +because numbering of system calls varies between architectures and +some architectures (e.g., x86-64) allow user-space code to use +the calling conventions of multiple architectures +(and the convention being used may vary over the life of a process that uses +.br execve (2) +to execute binaries that employ the different conventions), +it is usually necessary to verify the value of the +.ir arch +field. +.pp +it is strongly recommended to use an allow-list approach whenever +possible because such an approach is more robust and simple. +a deny-list will have to be updated whenever a potentially +dangerous system call is added (or a dangerous flag or option if those +are deny-listed), and it is often possible to alter the +representation of a value without altering its meaning, leading to +a deny-list bypass. +see also +.ir caveats +below. +.pp +the +.ir arch +field is not unique for all calling conventions. +the x86-64 abi and the x32 abi both use +.br audit_arch_x86_64 +as +.ir arch , +and they run on the same processors. +instead, the mask +.br __x32_syscall_bit +is used on the system call number to tell the two abis apart. +.\" as noted by dave drysdale in a note at the end of +.\" https://lwn.net/articles/604515/ +.\" one additional detail to point out for the x32 abi case: +.\" the syscall number gets a high bit set (__x32_syscall_bit), +.\" to mark it as an x32 call. +.\" +.\" if x32 support is included in the kernel, then __syscall_mask +.\" will have a value that is not all-ones, and this will trigger +.\" an extra instruction in system_call to mask off the extra bit, +.\" so that the syscall table indexing still works. +.pp +this means that a policy must either deny all syscalls with +.br __x32_syscall_bit +or it must recognize syscalls with and without +.br __x32_syscall_bit +set. +a list of system calls to be denied based on +.ir nr +that does not also contain +.ir nr +values with +.br __x32_syscall_bit +set can be bypassed by a malicious program that sets +.br __x32_syscall_bit . +.pp +additionally, kernels prior to linux 5.4 incorrectly permitted +.ir nr +in the ranges 512-547 as well as the corresponding non-x32 syscalls ored +with +.br __x32_syscall_bit . +for example, +.ir nr +== 521 and +.ir nr +== (101 | +.br __x32_syscall_bit ) +would result in invocations of +.br ptrace (2) +with potentially confused x32-vs-x86_64 semantics in the kernel. +policies intended to work on kernels before linux 5.4 must ensure that they +deny or otherwise correctly handle these system calls. +on linux 5.4 and newer, +.\" commit 6365b842aae4490ebfafadfc6bb27a6d3cc54757 +such system calls will fail with the error +.br enosys , +without doing anything. +.pp +the +.i instruction_pointer +field provides the address of the machine-language instruction that +performed the system call. +this might be useful in conjunction with the use of +.i /proc/[pid]/maps +to perform checks based on which region (mapping) of the program +made the system call. +(probably, it is wise to lock down the +.br mmap (2) +and +.br mprotect (2) +system calls to prevent the program from subverting such checks.) +.pp +when checking values from +.ir args , +keep in mind that arguments are often +silently truncated before being processed, but after the seccomp check. +for example, this happens if the i386 abi is used on an +x86-64 kernel: although the kernel will normally not look beyond +the 32 lowest bits of the arguments, the values of the full +64-bit registers will be present in the seccomp data. +a less surprising example is that if the x86-64 abi is used to perform +a system call that takes an argument of type +.ir int , +the more-significant half of the argument register is ignored by +the system call, but visible in the seccomp data. +.pp +a seccomp filter returns a 32-bit value consisting of two parts: +the most significant 16 bits +(corresponding to the mask defined by the constant +.br seccomp_ret_action_full ) +contain one of the "action" values listed below; +the least significant 16-bits (defined by the constant +.br seccomp_ret_data ) +are "data" to be associated with this return value. +.pp +if multiple filters exist, they are \fiall\fp executed, +in reverse order of their addition to the filter tree\(emthat is, +the most recently installed filter is executed first. +(note that all filters will be called +even if one of the earlier filters returns +.br seccomp_ret_kill . +this is done to simplify the kernel code and to provide a +tiny speed-up in the execution of sets of filters by +avoiding a check for this uncommon case.) +.\" from an aug 2015 conversation with kees cook where i asked why *all* +.\" filters are applied even if one of the early filters returns +.\" seccomp_ret_kill: +.\" +.\" it's just because it would be an optimization that would only speed up +.\" the ret_kill case, but it's the uncommon one and the one that doesn't +.\" benefit meaningfully from such a change (you need to kill the process +.\" really quickly?). we would speed up killing a program at the (albeit +.\" tiny) expense to all other filtered programs. best to keep the filter +.\" execution logic clear, simple, and as fast as possible for all +.\" filters. +the return value for the evaluation of a given system call is the first-seen +action value of highest precedence (along with its accompanying data) +returned by execution of all of the filters. +.pp +in decreasing order of precedence, +the action values that may be returned by a seccomp filter are: +.tp +.br seccomp_ret_kill_process " (since linux 4.14)" +.\" commit 4d3b0b05aae9ee9ce0970dc4cc0fb3fad5e85945 +.\" commit 0466bdb99e8744bc9befa8d62a317f0fd7fd7421 +this value results in immediate termination of the process, +with a core dump. +the system call is not executed. +by contrast with +.br seccomp_ret_kill_thread +below, all threads in the thread group are terminated. +(for a discussion of thread groups, see the description of the +.br clone_thread +flag in +.br clone (2).) +.ip +the process terminates +.i "as though" +killed by a +.b sigsys +signal. +even if a signal handler has been registered for +.br sigsys , +the handler will be ignored in this case and the process always terminates. +to a parent process that is waiting on this process (using +.br waitpid (2) +or similar), the returned +.i wstatus +will indicate that its child was terminated as though by a +.br sigsys +signal. +.tp +.br seccomp_ret_kill_thread " (or " seccomp_ret_kill ) +this value results in immediate termination of the thread +that made the system call. +the system call is not executed. +other threads in the same thread group will continue to execute. +.ip +the thread terminates +.i "as though" +killed by a +.b sigsys +signal. +see +.br seccomp_ret_kill_process +above. +.ip +.\" see these commits: +.\" seccomp: dump core when using seccomp_ret_kill +.\" (b25e67161c295c98acda92123b2dd1e7d8642901) +.\" seccomp: only dump core when single-threaded +.\" (d7276e321ff8a53106a59c85ca46d03e34288893) +before linux 4.11, +any process terminated in this way would not trigger a coredump +(even though +.b sigsys +is documented in +.br signal (7) +as having a default action of termination with a core dump). +since linux 4.11, +a single-threaded process will dump core if terminated in this way. +.ip +with the addition of +.br seccomp_ret_kill_process +in linux 4.14, +.br seccomp_ret_kill_thread +was added as a synonym for +.br seccomp_ret_kill , +in order to more clearly distinguish the two actions. +.ip +.br note : +the use of +.br seccomp_ret_kill_thread +to kill a single thread in a multithreaded process is likely to leave the +process in a permanently inconsistent and possibly corrupt state. +.tp +.br seccomp_ret_trap +this value results in the kernel sending a thread-directed +.br sigsys +signal to the triggering thread. +(the system call is not executed.) +various fields will be set in the +.i siginfo_t +structure (see +.br sigaction (2)) +associated with signal: +.rs +.ip * 3 +.i si_signo +will contain +.br sigsys . +.ip * +.ir si_call_addr +will show the address of the system call instruction. +.ip * +.ir si_syscall +and +.ir si_arch +will indicate which system call was attempted. +.ip * +.i si_code +will contain +.br sys_seccomp . +.ip * +.i si_errno +will contain the +.br seccomp_ret_data +portion of the filter return value. +.re +.ip +the program counter will be as though the system call happened +(i.e., the program counter will not point to the system call instruction). +the return value register will contain an architecture\-dependent value; +if resuming execution, set it to something appropriate for the system call. +(the architecture dependency is because replacing it with +.br enosys +could overwrite some useful information.) +.tp +.br seccomp_ret_errno +this value results in the +.b seccomp_ret_data +portion of the filter's return value being passed to user space as the +.ir errno +value without executing the system call. +.tp +.br seccomp_ret_user_notif " (since linux 5.0)" +.\" commit 6a21cc50f0c7f87dae5259f6cfefe024412313f6 +forward the system call to an attached user-space supervisor +process to allow that process to decide what to do with the system call. +if there is no attached supervisor (either +because the filter was not installed with the +.br seccomp_filter_flag_new_listener +flag or because the file descriptor was closed), the filter returns +.br enosys +(similar to what happens when a filter returns +.br seccomp_ret_trace +and there is no tracer). +see +.br seccomp_unotify (2) +for further details. +.ip +note that the supervisor process will not be notified +if another filter returns an action value with a precedence greater than +.br seccomp_ret_user_notif . +.tp +.br seccomp_ret_trace +when returned, this value will cause the kernel to attempt to notify a +.br ptrace (2)-based +tracer prior to executing the system call. +if there is no tracer present, +the system call is not executed and returns a failure status with +.i errno +set to +.br enosys . +.ip +a tracer will be notified if it requests +.br ptrace_o_traceseccomp +using +.ir ptrace(ptrace_setoptions) . +the tracer will be notified of a +.br ptrace_event_seccomp +and the +.br seccomp_ret_data +portion of the filter's return value will be available to the tracer via +.br ptrace_geteventmsg . +.ip +the tracer can skip the system call by changing the system call number +to \-1. +alternatively, the tracer can change the system call +requested by changing the system call to a valid system call number. +if the tracer asks to skip the system call, then the system call will +appear to return the value that the tracer puts in the return value register. +.ip +.\" this was changed in ce6526e8afa4. +.\" a related hole, using ptrace_syscall instead of seccomp_ret_trace, was +.\" changed in arch-specific commits, e.g. 93e35efb8de4 for x86 and +.\" 0f3912fd934c for arm. +before kernel 4.8, the seccomp check will not be run again after the tracer is +notified. +(this means that, on older kernels, seccomp-based sandboxes +.b "must not" +allow use of +.br ptrace (2)\(emeven +of other +sandboxed processes\(emwithout extreme care; +ptracers can use this mechanism to escape from the seccomp sandbox.) +.ip +note that a tracer process will not be notified +if another filter returns an action value with a precedence greater than +.br seccomp_ret_trace . +.tp +.br seccomp_ret_log " (since linux 4.14)" +.\" commit 59f5cf44a38284eb9e76270c786fb6cc62ef8ac4 +this value results in the system call being executed after +the filter return action is logged. +an administrator may override the logging of this action via +the +.ir /proc/sys/kernel/seccomp/actions_logged +file. +.tp +.br seccomp_ret_allow +this value results in the system call being executed. +.pp +if an action value other than one of the above is specified, +then the filter action is treated as either +.br seccomp_ret_kill_process +(since linux 4.14) +.\" commit 4d3b0b05aae9ee9ce0970dc4cc0fb3fad5e85945 +or +.br seccomp_ret_kill_thread +(in linux 4.13 and earlier). +.\" +.ss /proc interfaces +the files in the directory +.ir /proc/sys/kernel/seccomp +provide additional seccomp information and configuration: +.tp +.ir actions_avail " (since linux 4.14)" +.\" commit 8e5f1ad116df6b0de65eac458d5e7c318d1c05af +a read-only ordered list of seccomp filter return actions in string form. +the ordering, from left-to-right, is in decreasing order of precedence. +the list represents the set of seccomp filter return actions +supported by the kernel. +.tp +.ir actions_logged " (since linux 4.14)" +.\" commit 0ddec0fc8900201c0897b87b762b7c420436662f +a read-write ordered list of seccomp filter return actions that +are allowed to be logged. +writes to the file do not need to be in ordered form but reads from +the file will be ordered in the same way as the +.ir actions_avail +file. +.ip +it is important to note that the value of +.ir actions_logged +does not prevent certain filter return actions from being logged when +the audit subsystem is configured to audit a task. +if the action is not found in the +.ir actions_logged +file, the final decision on whether to audit the action for that task is +ultimately left up to the audit subsystem to decide for all filter return +actions other than +.br seccomp_ret_allow . +.ip +the "allow" string is not accepted in the +.ir actions_logged +file as it is not possible to log +.br seccomp_ret_allow +actions. +attempting to write "allow" to the file will fail with the error +.br einval . +.\" +.ss audit logging of seccomp actions +.\" commit 59f5cf44a38284eb9e76270c786fb6cc62ef8ac4 +since linux 4.14, the kernel provides the facility to log the +actions returned by seccomp filters in the audit log. +the kernel makes the decision to log an action based on +the action type, whether or not the action is present in the +.i actions_logged +file, and whether kernel auditing is enabled +(e.g., via the kernel boot option +.ir audit=1 ). +.\" or auditing could be enabled via the netlink api (audit_set) +the rules are as follows: +.ip * 3 +if the action is +.br seccomp_ret_allow , +the action is not logged. +.ip * +otherwise, if the action is either +.br seccomp_ret_kill_process +or +.br seccomp_ret_kill_thread , +and that action appears in the +.ir actions_logged +file, the action is logged. +.ip * +otherwise, if the filter has requested logging (the +.br seccomp_filter_flag_log +flag) +and the action appears in the +.ir actions_logged +file, the action is logged. +.ip * +otherwise, if kernel auditing is enabled and the process is being audited +.rb ( autrace (8)), +the action is logged. +.ip * +otherwise, the action is not logged. +.sh return value +on success, +.br seccomp () +returns 0. +on error, if +.br seccomp_filter_flag_tsync +was used, +the return value is the id of the thread +that caused the synchronization failure. +(this id is a kernel thread id of the type returned by +.br clone (2) +and +.br gettid (2).) +on other errors, \-1 is returned, and +.ir errno +is set to indicate the error. +.sh errors +.br seccomp () +can fail for the following reasons: +.tp +.br eacces +the caller did not have the +.br cap_sys_admin +capability in its user namespace, or had not set +.ir no_new_privs +before using +.br seccomp_set_mode_filter . +.tp +.br ebusy +while installing a new filter, the +.br seccomp_filter_flag_new_listener +flag was specified, +but a previous filter had already been installed with that flag. +.tp +.br efault +.ir args +was not a valid address. +.tp +.br einval +.ir operation +is unknown or is not supported by this kernel version or configuration. +.tp +.b einval +the specified +.ir flags +are invalid for the given +.ir operation . +.tp +.br einval +.i operation +included +.br bpf_abs , +but the specified offset was not aligned to a 32-bit boundary or exceeded +.ir "sizeof(struct\ seccomp_data)" . +.tp +.br einval +.\" see kernel/seccomp.c::seccomp_may_assign_mode() in 3.18 sources +a secure computing mode has already been set, and +.i operation +differs from the existing setting. +.tp +.br einval +.i operation +specified +.br seccomp_set_mode_filter , +but the filter program pointed to by +.i args +was not valid or the length of the filter program was zero or exceeded +.b bpf_maxinsns +(4096) instructions. +.tp +.br enomem +out of memory. +.tp +.br enomem +.\" enomem in kernel/seccomp.c::seccomp_attach_filter() in 3.18 sources +the total length of all filter programs attached +to the calling thread would exceed +.b max_insns_per_path +(32768) instructions. +note that for the purposes of calculating this limit, +each already existing filter program incurs an +overhead penalty of 4 instructions. +.tp +.br eopnotsupp +.i operation +specified +.br seccomp_get_action_avail , +but the kernel does not support the filter return action specified by +.ir args . +.tp +.br esrch +another thread caused a failure during thread sync, but its id could not +be determined. +.sh versions +the +.br seccomp () +system call first appeared in linux 3.17. +.\" fixme . add glibc version +.sh conforming to +the +.br seccomp () +system call is a nonstandard linux extension. +.sh notes +rather than hand-coding seccomp filters as shown in the example below, +you may prefer to employ the +.i libseccomp +library, which provides a front-end for generating seccomp filters. +.pp +the +.ir seccomp +field of the +.ir /proc/[pid]/status +file provides a method of viewing the seccomp mode of a process; see +.br proc (5). +.pp +.br seccomp () +provides a superset of the functionality provided by the +.br prctl (2) +.br pr_set_seccomp +operation (which does not support +.ir flags ). +.pp +since linux 4.4, the +.br ptrace (2) +.b ptrace_seccomp_get_filter +operation can be used to dump a process's seccomp filters. +.\" +.ss architecture support for seccomp bpf +architecture support for seccomp bpf filtering +.\" check by grepping for have_arch_seccomp_filter in kconfig files in +.\" kernel source. last checked in linux 4.16-rc source. +is available on the following architectures: +.ip * 3 +x86-64, i386, x32 (since linux 3.5) +.pd 0 +.ip * +arm (since linux 3.8) +.ip * +s390 (since linux 3.8) +.ip * +mips (since linux 3.16) +.ip * +arm-64 (since linux 3.19) +.ip * +powerpc (since linux 4.3) +.ip * +tile (since linux 4.3) +.ip * +pa-risc (since linux 4.6) +.\" user mode linux since linux 4.6 +.pd +.\" +.ss caveats +there are various subtleties to consider when applying seccomp filters +to a program, including the following: +.ip * 3 +some traditional system calls have user-space implementations in the +.br vdso (7) +on many architectures. +notable examples include +.br clock_gettime (2), +.br gettimeofday (2), +and +.br time (2). +on such architectures, +seccomp filtering for these system calls will have no effect. +(however, there are cases where the +.br vdso (7) +implementations may fall back to invoking the true system call, +in which case seccomp filters would see the system call.) +.ip * +seccomp filtering is based on system call numbers. +however, applications typically do not directly invoke system calls, +but instead call wrapper functions in the c library which +in turn invoke the system calls. +consequently, one must be aware of the following: +.rs +.ip \(bu 3 +the glibc wrappers for some traditional system calls may actually +employ system calls with different names in the kernel. +for example, the +.br exit (2) +wrapper function actually employs the +.br exit_group (2) +system call, and the +.br fork (2) +wrapper function actually calls +.br clone (2). +.ip \(bu +the behavior of wrapper functions may vary across architectures, +according to the range of system calls provided on those architectures. +in other words, the same wrapper function may invoke +different system calls on different architectures. +.ip \(bu +finally, the behavior of wrapper functions can change across glibc versions. +for example, in older versions, the glibc wrapper function for +.br open (2) +invoked the system call of the same name, +but starting in glibc 2.26, the implementation switched to calling +.br openat (2) +on all architectures. +.re +.pp +the consequence of the above points is that it may be necessary +to filter for a system call other than might be expected. +various manual pages in section 2 provide helpful details +about the differences between wrapper functions and +the underlying system calls in subsections entitled +.ir "c library/kernel differences" . +.pp +furthermore, note that the application of seccomp filters +even risks causing bugs in an application, +when the filters cause unexpected failures for legitimate operations +that the application might need to perform. +such bugs may not easily be discovered when testing the seccomp +filters if the bugs occur in rarely used application code paths. +.\" +.ss seccomp-specific bpf details +note the following bpf details specific to seccomp filters: +.ip * 3 +the +.b bpf_h +and +.b bpf_b +size modifiers are not supported: all operations must load and store +(4-byte) words +.rb ( bpf_w ). +.ip * +to access the contents of the +.i seccomp_data +buffer, use the +.b bpf_abs +addressing mode modifier. +.ip * +the +.b bpf_len +addressing mode modifier yields an immediate mode operand +whose value is the size of the +.ir seccomp_data +buffer. +.sh examples +the program below accepts four or more arguments. +the first three arguments are a system call number, +a numeric architecture identifier, and an error number. +the program uses these values to construct a bpf filter +that is used at run time to perform the following checks: +.ip [1] 4 +if the program is not running on the specified architecture, +the bpf filter causes system calls to fail with the error +.br enosys . +.ip [2] +if the program attempts to execute the system call with the specified number, +the bpf filter causes the system call to fail, with +.i errno +being set to the specified error number. +.pp +the remaining command-line arguments specify +the pathname and additional arguments of a program +that the example program should attempt to execute using +.br execv (3) +(a library function that employs the +.br execve (2) +system call). +some example runs of the program are shown below. +.pp +first, we display the architecture that we are running on (x86-64) +and then construct a shell function that looks up system call +numbers on this architecture: +.pp +.in +4n +.ex +$ \fbuname \-m\fp +x86_64 +$ \fbsyscall_nr() { + cat /usr/src/linux/arch/x86/syscalls/syscall_64.tbl | \e + awk \(aq$2 != "x32" && $3 == "\(aq$1\(aq" { print $1 }\(aq +}\fp +.ee +.in +.pp +when the bpf filter rejects a system call (case [2] above), +it causes the system call to fail with the error number +specified on the command line. +in the experiments shown here, we'll use error number 99: +.pp +.in +4n +.ex +$ \fberrno 99\fp +eaddrnotavail 99 cannot assign requested address +.ee +.in +.pp +in the following example, we attempt to run the command +.br whoami (1), +but the bpf filter rejects the +.br execve (2) +system call, so that the command is not even executed: +.pp +.in +4n +.ex +$ \fbsyscall_nr execve\fp +59 +$ \fb./a.out\fp +usage: ./a.out [] +hint for : audit_arch_i386: 0x40000003 + audit_arch_x86_64: 0xc000003e +$ \fb./a.out 59 0xc000003e 99 /bin/whoami\fp +execv: cannot assign requested address +.ee +.in +.pp +in the next example, the bpf filter rejects the +.br write (2) +system call, so that, although it is successfully started, the +.br whoami (1) +command is not able to write output: +.pp +.in +4n +.ex +$ \fbsyscall_nr write\fp +1 +$ \fb./a.out 1 0xc000003e 99 /bin/whoami\fp +.ee +.in +.pp +in the final example, +the bpf filter rejects a system call that is not used by the +.br whoami (1) +command, so it is able to successfully execute and produce output: +.pp +.in +4n +.ex +$ \fbsyscall_nr preadv\fp +295 +$ \fb./a.out 295 0xc000003e 99 /bin/whoami\fp +cecilia +.ee +.in +.ss program source +.ex +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define x32_syscall_bit 0x40000000 +#define array_size(arr) (sizeof(arr) / sizeof((arr)[0])) + +static int +install_filter(int syscall_nr, int t_arch, int f_errno) +{ + unsigned int upper_nr_limit = 0xffffffff; + + /* assume that audit_arch_x86_64 means the normal x86\-64 abi + (in the x32 abi, all system calls have bit 30 set in the + \(aqnr\(aq field, meaning the numbers are >= x32_syscall_bit). */ + if (t_arch == audit_arch_x86_64) + upper_nr_limit = x32_syscall_bit \- 1; + + struct sock_filter filter[] = { + /* [0] load architecture from \(aqseccomp_data\(aq buffer into + accumulator. */ + bpf_stmt(bpf_ld | bpf_w | bpf_abs, + (offsetof(struct seccomp_data, arch))), + + /* [1] jump forward 5 instructions if architecture does not + match \(aqt_arch\(aq. */ + bpf_jump(bpf_jmp | bpf_jeq | bpf_k, t_arch, 0, 5), + + /* [2] load system call number from \(aqseccomp_data\(aq buffer into + accumulator. */ + bpf_stmt(bpf_ld | bpf_w | bpf_abs, + (offsetof(struct seccomp_data, nr))), + + /* [3] check abi \- only needed for x86\-64 in deny\-list use + cases. use bpf_jgt instead of checking against the bit + mask to avoid having to reload the syscall number. */ + bpf_jump(bpf_jmp | bpf_jgt | bpf_k, upper_nr_limit, 3, 0), + + /* [4] jump forward 1 instruction if system call number + does not match \(aqsyscall_nr\(aq. */ + bpf_jump(bpf_jmp | bpf_jeq | bpf_k, syscall_nr, 0, 1), + + /* [5] matching architecture and system call: don\(aqt execute + the system call, and return \(aqf_errno\(aq in \(aqerrno\(aq. */ + bpf_stmt(bpf_ret | bpf_k, + seccomp_ret_errno | (f_errno & seccomp_ret_data)), + + /* [6] destination of system call number mismatch: allow other + system calls. */ + bpf_stmt(bpf_ret | bpf_k, seccomp_ret_allow), + + /* [7] destination of architecture mismatch: kill process. */ + bpf_stmt(bpf_ret | bpf_k, seccomp_ret_kill_process), + }; + + struct sock_fprog prog = { + .len = array_size(filter), + .filter = filter, + }; + + if (seccomp(seccomp_set_mode_filter, 0, &prog)) { + perror("seccomp"); + return 1; + } + + return 0; +} + +int +main(int argc, char *argv[]) +{ + if (argc < 5) { + fprintf(stderr, "usage: " + "%s []\en" + "hint for : audit_arch_i386: 0x%x\en" + " audit_arch_x86_64: 0x%x\en" + "\en", argv[0], audit_arch_i386, audit_arch_x86_64); + exit(exit_failure); + } + + if (prctl(pr_set_no_new_privs, 1, 0, 0, 0)) { + perror("prctl"); + exit(exit_failure); + } + + if (install_filter(strtol(argv[1], null, 0), + strtol(argv[2], null, 0), + strtol(argv[3], null, 0))) + exit(exit_failure); + + execv(argv[4], &argv[4]); + perror("execv"); + exit(exit_failure); +} +.ee +.sh see also +.br bpfc (1), +.br strace (1), +.br bpf (2), +.br prctl (2), +.br ptrace (2), +.br seccomp_unotify (2), +.br sigaction (2), +.br proc (5), +.br signal (7), +.br socket (7) +.pp +various pages from the +.i libseccomp +library, including: +.br scmp_sys_resolver (1), +.br seccomp_export_bpf (3), +.br seccomp_init (3), +.br seccomp_load (3), +and +.br seccomp_rule_add (3). +.pp +the kernel source files +.ir documentation/networking/filter.txt +and +.ir documentation/userspace\-api/seccomp_filter.rst +.\" commit c061f33f35be0ccc80f4b8e0aea5dfd2ed7e01a3 +(or +.ir documentation/prctl/seccomp_filter.txt +before linux 4.13). +.pp +mccanne, s.\& and jacobson, v.\& (1992) +.ir "the bsd packet filter: a new architecture for user-level packet capture" , +proceedings of the usenix winter 1993 conference +.ur http://www.tcpdump.org/papers/bpf\-usenix93.pdf +.ue +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/tailq.3 + +.so man7/iso_8859-2.7 + +.\" written by mike frysinger +.\" +.\" %%%license_start(public_domain) +.\" this page is in the public domain. +.\" %%%license_end +.\" +.\" useful background: +.\" http://articles.manugarg.com/systemcallinlinux2_6.html +.\" https://lwn.net/articles/446528/ +.\" http://www.linuxjournal.com/content/creating-vdso-colonels-other-chicken +.\" http://www.trilithium.com/johan/2005/08/linux-gate/ +.\" +.th vdso 7 2021-08-27 "linux" "linux programmer's manual" +.sh name +vdso \- overview of the virtual elf dynamic shared object +.sh synopsis +.nf +.b #include +.pp +.b void *vdso = (uintptr_t) getauxval(at_sysinfo_ehdr); +.fi +.sh description +the "vdso" (virtual dynamic shared object) is a small shared library that +the kernel automatically maps into the +address space of all user-space applications. +applications usually do not need to concern themselves with these details +as the vdso is most commonly called by the c library. +this way you can code in the normal way using standard functions +and the c library will take care +of using any functionality that is available via the vdso. +.pp +why does the vdso exist at all? +there are some system calls the kernel provides that +user-space code ends up using frequently, +to the point that such calls can dominate overall performance. +this is due both to the frequency of the call as well as the +context-switch overhead that results +from exiting user space and entering the kernel. +.pp +the rest of this documentation is geared toward the curious and/or +c library writers rather than general developers. +if you're trying to call the vdso in your own application rather than using +the c library, you're most likely doing it wrong. +.ss example background +making system calls can be slow. +in x86 32-bit systems, you can trigger a software interrupt +.ri ( "int $0x80" ) +to tell the kernel you wish to make a system call. +however, this instruction is expensive: it goes through +the full interrupt-handling paths +in the processor's microcode as well as in the kernel. +newer processors have faster (but backward incompatible) instructions to +initiate system calls. +rather than require the c library to figure out if this functionality is +available at run time, +the c library can use functions provided by the kernel in +the vdso. +.pp +note that the terminology can be confusing. +on x86 systems, the vdso function +used to determine the preferred method of making a system call is +named "__kernel_vsyscall", but on x86-64, +the term "vsyscall" also refers to an obsolete way to ask the kernel +what time it is or what cpu the caller is on. +.pp +one frequently used system call is +.br gettimeofday (2). +this system call is called both directly by user-space applications +as well as indirectly by +the c library. +think timestamps or timing loops or polling\(emall of these +frequently need to know what time it is right now. +this information is also not secret\(emany application in any +privilege mode (root or any unprivileged user) will get the same answer. +thus the kernel arranges for the information required to answer +this question to be placed in memory the process can access. +now a call to +.br gettimeofday (2) +changes from a system call to a normal function +call and a few memory accesses. +.ss finding the vdso +the base address of the vdso (if one exists) is passed by the kernel to +each program in the initial auxiliary vector (see +.br getauxval (3)), +via the +.b at_sysinfo_ehdr +tag. +.pp +you must not assume the vdso is mapped at any particular location in the +user's memory map. +the base address will usually be randomized at run time every time a new +process image is created (at +.br execve (2) +time). +this is done for security reasons, +to prevent "return-to-libc" attacks. +.pp +for some architectures, there is also an +.b at_sysinfo +tag. +this is used only for locating the vsyscall entry point and is frequently +omitted or set to 0 (meaning it's not available). +this tag is a throwback to the initial vdso work (see +.ir history +below) and its use should be avoided. +.ss file format +since the vdso is a fully formed elf image, you can do symbol lookups on it. +this allows new symbols to be added with newer kernel releases, +and allows the c library to detect available functionality at +run time when running under different kernel versions. +oftentimes the c library will do detection with the first call and then +cache the result for subsequent calls. +.pp +all symbols are also versioned (using the gnu version format). +this allows the kernel to update the function signature without breaking +backward compatibility. +this means changing the arguments that the function accepts as well as the +return value. +thus, when looking up a symbol in the vdso, +you must always include the version +to match the abi you expect. +.pp +typically the vdso follows the naming convention of prefixing +all symbols with "__vdso_" or "__kernel_" +so as to distinguish them from other standard symbols. +for example, the "gettimeofday" function is named "__vdso_gettimeofday". +.pp +you use the standard c calling conventions when calling +any of these functions. +no need to worry about weird register or stack behavior. +.sh notes +.ss source +when you compile the kernel, +it will automatically compile and link the vdso code for you. +you will frequently find it under the architecture-specific directory: +.pp + find arch/$arch/ \-name \(aq*vdso*.so*\(aq \-o \-name \(aq*gate*.so*\(aq +.\" +.ss vdso names +the name of the vdso varies across architectures. +it will often show up in things like glibc's +.br ldd (1) +output. +the exact name should not matter to any code, so do not hardcode it. +.if t \{\ +.ft cw +\} +.ts +l l. +user abi vdso name +_ +aarch64 linux\-vdso.so.1 +arm linux\-vdso.so.1 +ia64 linux\-gate.so.1 +mips linux\-vdso.so.1 +ppc/32 linux\-vdso32.so.1 +ppc/64 linux\-vdso64.so.1 +riscv linux\-vdso.so.1 +s390 linux\-vdso32.so.1 +s390x linux\-vdso64.so.1 +sh linux\-gate.so.1 +i386 linux\-gate.so.1 +x86-64 linux\-vdso.so.1 +x86/x32 linux\-vdso.so.1 +.te +.if t \{\ +.in +.ft p +\} +.ss strace(1), seccomp(2), and the vdso +when tracing systems calls with +.br strace (1), +symbols (system calls) that are exported by the vdso will +.i not +appear in the trace output. +those system calls will likewise not be visible to +.br seccomp (2) +filters. +.sh architecture-specific notes +the subsections below provide architecture-specific notes +on the vdso. +.pp +note that the vdso that is used is based on the abi of your user-space code +and not the abi of the kernel. +thus, for example, +when you run an i386 32-bit elf binary, +you'll get the same vdso regardless of whether you run it under +an i386 32-bit kernel or under an x86-64 64-bit kernel. +therefore, the name of the user-space abi should be used to determine +which of the sections below is relevant. +.ss arm functions +.\" see linux/arch/arm/vdso/vdso.lds.s +.\" commit: 8512287a8165592466cb9cb347ba94892e9c56a5 +the table below lists the symbols exported by the vdso. +.if t \{\ +.ft cw +\} +.ts +l l. +symbol version +_ +__vdso_gettimeofday linux_2.6 (exported since linux 4.1) +__vdso_clock_gettime linux_2.6 (exported since linux 4.1) +.te +.if t \{\ +.in +.ft p +\} +.pp +.\" see linux/arch/arm/kernel/entry-armv.s +.\" see linux/documentation/arm/kernel_user_helpers.txt +additionally, the arm port has a code page full of utility functions. +since it's just a raw page of code, there is no elf information for doing +symbol lookups or versioning. +it does provide support for different versions though. +.pp +for information on this code page, +it's best to refer to the kernel documentation +as it's extremely detailed and covers everything you need to know: +.ir documentation/arm/kernel_user_helpers.txt . +.ss aarch64 functions +.\" see linux/arch/arm64/kernel/vdso/vdso.lds.s +the table below lists the symbols exported by the vdso. +.if t \{\ +.ft cw +\} +.ts +l l. +symbol version +_ +__kernel_rt_sigreturn linux_2.6.39 +__kernel_gettimeofday linux_2.6.39 +__kernel_clock_gettime linux_2.6.39 +__kernel_clock_getres linux_2.6.39 +.te +.if t \{\ +.in +.ft p +\} +.ss bfin (blackfin) functions (port removed in linux 4.17) +.\" see linux/arch/blackfin/kernel/fixed_code.s +.\" see http://docs.blackfin.uclinux.org/doku.php?id=linux-kernel:fixed-code +as this cpu lacks a memory management unit (mmu), +it doesn't set up a vdso in the normal sense. +instead, it maps at boot time a few raw functions into +a fixed location in memory. +user-space applications then call directly into that region. +there is no provision for backward compatibility +beyond sniffing raw opcodes, +but as this is an embedded cpu, it can get away with things\(emsome of the +object formats it runs aren't even elf based (they're bflt/flat). +.pp +for information on this code page, +it's best to refer to the public documentation: +.br +http://docs.blackfin.uclinux.org/doku.php?id=linux\-kernel:fixed\-code +.ss mips functions +.\" see linux/arch/mips/vdso/vdso.ld.s +the table below lists the symbols exported by the vdso. +.if t \{\ +.ft cw +\} +.ts +l l. +symbol version +_ +__kernel_gettimeofday linux_2.6 (exported since linux 4.4) +__kernel_clock_gettime linux_2.6 (exported since linux 4.4) +.te +.if t \{\ +.in +.ft p +\} +.ss ia64 (itanium) functions +.\" see linux/arch/ia64/kernel/gate.lds.s +.\" also linux/arch/ia64/kernel/fsys.s and linux/documentation/ia64/fsys.txt +the table below lists the symbols exported by the vdso. +.if t \{\ +.ft cw +\} +.ts +l l. +symbol version +_ +__kernel_sigtramp linux_2.5 +__kernel_syscall_via_break linux_2.5 +__kernel_syscall_via_epc linux_2.5 +.te +.if t \{\ +.in +.ft p +\} +.pp +the itanium port is somewhat tricky. +in addition to the vdso above, it also has "light-weight system calls" +(also known as "fast syscalls" or "fsys"). +you can invoke these via the +.i __kernel_syscall_via_epc +vdso helper. +the system calls listed here have the same semantics as if you called them +directly via +.br syscall (2), +so refer to the relevant +documentation for each. +the table below lists the functions available via this mechanism. +.if t \{\ +.ft cw +\} +.ts +l. +function +_ +clock_gettime +getcpu +getpid +getppid +gettimeofday +set_tid_address +.te +.if t \{\ +.in +.ft p +\} +.ss parisc (hppa) functions +.\" see linux/arch/parisc/kernel/syscall.s +.\" see linux/documentation/parisc/registers +the parisc port has a code page with utility functions +called a gateway page. +rather than use the normal elf auxiliary vector approach, +it passes the address of +the page to the process via the sr2 register. +the permissions on the page are such that merely executing those addresses +automatically executes with kernel privileges and not in user space. +this is done to match the way hp-ux works. +.pp +since it's just a raw page of code, there is no elf information for doing +symbol lookups or versioning. +simply call into the appropriate offset via the branch instruction, +for example: +.pp + ble (%sr2, %r0) +.if t \{\ +.ft cw +\} +.ts +l l. +offset function +_ +00b0 lws_entry (cas operations) +00e0 set_thread_pointer (used by glibc) +0100 linux_gateway_entry (syscall) +.te +.if t \{\ +.in +.ft p +\} +.ss ppc/32 functions +.\" see linux/arch/powerpc/kernel/vdso32/vdso32.lds.s +the table below lists the symbols exported by the vdso. +the functions marked with a +.i * +are available only when the kernel is +a powerpc64 (64-bit) kernel. +.if t \{\ +.ft cw +\} +.ts +l l. +symbol version +_ +__kernel_clock_getres linux_2.6.15 +__kernel_clock_gettime linux_2.6.15 +__kernel_clock_gettime64 linux_5.11 +__kernel_datapage_offset linux_2.6.15 +__kernel_get_syscall_map linux_2.6.15 +__kernel_get_tbfreq linux_2.6.15 +__kernel_getcpu \fi*\fr linux_2.6.15 +__kernel_gettimeofday linux_2.6.15 +__kernel_sigtramp_rt32 linux_2.6.15 +__kernel_sigtramp32 linux_2.6.15 +__kernel_sync_dicache linux_2.6.15 +__kernel_sync_dicache_p5 linux_2.6.15 +.te +.if t \{\ +.in +.ft p +\} +.pp +in kernel versions before linux 5.6, +.\" commit 654abc69ef2e69712e6d4e8a6cb9292b97a4aa39 +the +.b clock_realtime_coarse +and +.b clock_monotonic_coarse +clocks are +.i not +supported by the +.i __kernel_clock_getres +and +.i __kernel_clock_gettime +interfaces; +the kernel falls back to the real system call. +.ss ppc/64 functions +.\" see linux/arch/powerpc/kernel/vdso64/vdso64.lds.s +the table below lists the symbols exported by the vdso. +.if t \{\ +.ft cw +\} +.ts +l l. +symbol version +_ +__kernel_clock_getres linux_2.6.15 +__kernel_clock_gettime linux_2.6.15 +__kernel_datapage_offset linux_2.6.15 +__kernel_get_syscall_map linux_2.6.15 +__kernel_get_tbfreq linux_2.6.15 +__kernel_getcpu linux_2.6.15 +__kernel_gettimeofday linux_2.6.15 +__kernel_sigtramp_rt64 linux_2.6.15 +__kernel_sync_dicache linux_2.6.15 +__kernel_sync_dicache_p5 linux_2.6.15 +.te +.if t \{\ +.in +.ft p +\} +.pp +in kernel versions before linux 4.16, +.\" commit 5c929885f1bb4b77f85b1769c49405a0e0f154a1 +the +.b clock_realtime_coarse +and +.b clock_monotonic_coarse +clocks are +.i not +supported by the +.i __kernel_clock_getres +and +.i __kernel_clock_gettime +interfaces; +the kernel falls back to the real system call. +.ss riscv functions +.\" see linux/arch/riscv/kernel/vdso/vdso.lds.s +the table below lists the symbols exported by the vdso. +.if t \{\ +.ft cw +\} +.ts +l l. +symbol version +_ +__kernel_rt_sigreturn linux_4.15 +__kernel_gettimeofday linux_4.15 +__kernel_clock_gettime linux_4.15 +__kernel_clock_getres linux_4.15 +__kernel_getcpu linux_4.15 +__kernel_flush_icache linux_4.15 +.te +.if t \{\ +.in +.ft p +\} +.ss s390 functions +.\" see linux/arch/s390/kernel/vdso32/vdso32.lds.s +the table below lists the symbols exported by the vdso. +.if t \{\ +.ft cw +\} +.ts +l l. +symbol version +_ +__kernel_clock_getres linux_2.6.29 +__kernel_clock_gettime linux_2.6.29 +__kernel_gettimeofday linux_2.6.29 +.te +.if t \{\ +.in +.ft p +\} +.ss s390x functions +.\" see linux/arch/s390/kernel/vdso64/vdso64.lds.s +the table below lists the symbols exported by the vdso. +.if t \{\ +.ft cw +\} +.ts +l l. +symbol version +_ +__kernel_clock_getres linux_2.6.29 +__kernel_clock_gettime linux_2.6.29 +__kernel_gettimeofday linux_2.6.29 +.te +.if t \{\ +.in +.ft p +\} +.ss sh (superh) functions +.\" see linux/arch/sh/kernel/vsyscall/vsyscall.lds.s +the table below lists the symbols exported by the vdso. +.if t \{\ +.ft cw +\} +.ts +l l. +symbol version +_ +__kernel_rt_sigreturn linux_2.6 +__kernel_sigreturn linux_2.6 +__kernel_vsyscall linux_2.6 +.te +.if t \{\ +.in +.ft p +\} +.ss i386 functions +.\" see linux/arch/x86/vdso/vdso32/vdso32.lds.s +the table below lists the symbols exported by the vdso. +.if t \{\ +.ft cw +\} +.ts +l l. +symbol version +_ +__kernel_sigreturn linux_2.5 +__kernel_rt_sigreturn linux_2.5 +__kernel_vsyscall linux_2.5 +.\" added in 7a59ed415f5b57469e22e41fc4188d5399e0b194 and updated +.\" in 37c975545ec63320789962bf307f000f08fabd48. +__vdso_clock_gettime linux_2.6 (exported since linux 3.15) +__vdso_gettimeofday linux_2.6 (exported since linux 3.15) +__vdso_time linux_2.6 (exported since linux 3.15) +.te +.if t \{\ +.in +.ft p +\} +.ss x86-64 functions +.\" see linux/arch/x86/vdso/vdso.lds.s +the table below lists the symbols exported by the vdso. +all of these symbols are also available without the "__vdso_" prefix, but +you should ignore those and stick to the names below. +.if t \{\ +.ft cw +\} +.ts +l l. +symbol version +_ +__vdso_clock_gettime linux_2.6 +__vdso_getcpu linux_2.6 +__vdso_gettimeofday linux_2.6 +__vdso_time linux_2.6 +.te +.if t \{\ +.in +.ft p +\} +.ss x86/x32 functions +.\" see linux/arch/x86/vdso/vdso32.lds.s +the table below lists the symbols exported by the vdso. +.if t \{\ +.ft cw +\} +.ts +l l. +symbol version +_ +__vdso_clock_gettime linux_2.6 +__vdso_getcpu linux_2.6 +__vdso_gettimeofday linux_2.6 +__vdso_time linux_2.6 +.te +.if t \{\ +.in +.ft p +\} +.ss history +the vdso was originally just a single function\(emthe vsyscall. +in older kernels, you might see that name +in a process's memory map rather than "vdso". +over time, people realized that this mechanism +was a great way to pass more functionality +to user space, so it was reconceived as a vdso in the current format. +.sh see also +.br syscalls (2), +.br getauxval (3), +.br proc (5) +.pp +the documents, examples, and source code in the linux source code tree: +.pp +.in +4n +.ex +documentation/abi/stable/vdso +documentation/ia64/fsys.txt +documentation/vdso/* (includes examples of using the vdso) + +find arch/ \-iname \(aq*vdso*\(aq \-o \-iname \(aq*gate*\(aq +.ee +.in +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/resolver.3 + +.so man3/setjmp.3 + +.\" copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de) +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under gpl +.\" %%%license_end +.\" +.th cabs 3 2021-03-22 "" "linux programmer's manual" +.sh name +cabs, cabsf, cabsl \- absolute value of a complex number +.sh synopsis +.nf +.b #include +.pp +.bi "double cabs(double complex " z ); +.bi "float cabsf(float complex " z ); +.bi "long double cabsl(long double complex " z ); +.pp +link with \fi\-lm\fp. +.fi +.sh description +these functions return the absolute value of the complex number +.ir z . +the result is a real number. +.sh versions +these functions first appeared in glibc in version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br cabs (), +.br cabsf (), +.br cabsl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.sh notes +the function is actually an alias for +.i "hypot(a,\ b)" +(or, equivalently, +.ir "sqrt(a*a\ +\ b*b)" ). +.sh see also +.br abs (3), +.br cimag (3), +.br hypot (3), +.br complex (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" iso/iec 9899:1999 +.\" +.th fwide 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +fwide \- set and determine the orientation of a file stream +.sh synopsis +.nf +.b #include +.pp +.bi "int fwide(file *" stream ", int " mode ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br fwide (): +.nf + _xopen_source >= 500 || _isoc99_source + || _posix_c_source >= 200112l +.fi +.sh description +when \fimode\fp is zero, the +.br fwide () +function determines the current +orientation of \fistream\fp. +it returns a positive value if \fistream\fp is +wide-character oriented, that is, if wide-character i/o is permitted but char +i/o is disallowed. +it returns a negative value if \fistream\fp is byte oriented\(emthat is, +if char i/o is permitted but wide-character i/o is disallowed. +it +returns zero if \fistream\fp has no orientation yet; in this case the next +i/o operation might change the orientation (to byte oriented if it is a char +i/o operation, or to wide-character oriented if it is a wide-character i/o +operation). +.pp +once a stream has an orientation, it cannot be changed and persists until +the stream is closed. +.pp +when \fimode\fp is nonzero, the +.br fwide () +function first attempts to set +\fistream\fp's orientation (to wide-character oriented +if \fimode\fp is greater than 0, or +to byte oriented if \fimode\fp is less than 0). +it then returns a value denoting the +current orientation, as above. +.sh return value +the +.br fwide () +function returns the stream's orientation, after possibly +changing it. +a positive return value means wide-character oriented. +a negative return value means byte oriented. +a return value of zero means undecided. +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh notes +wide-character output to a byte oriented stream can be performed through the +.br fprintf (3) +function with the +.b %lc +and +.b %ls +directives. +.pp +char oriented output to a wide-character oriented stream can be performed +through the +.br fwprintf (3) +function with the +.b %c +and +.b %s +directives. +.sh see also +.br fprintf (3), +.br fwprintf (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2006, 2008, michael kerrisk +.\" (a few fragments remain from an earlier (1992) version written in +.\" 1992 by drew eckhardt .) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified by michael haardt +.\" modified sat jul 24 12:51:53 1993 by rik faith +.\" modified tue oct 22 22:39:04 1996 by eric s. raymond +.\" modified thu may 1 06:05:54 utc 1997 by nicolás lichtmaier +.\" with lars wirzenius suggestion +.\" 2006-05-13, mtk, substantial rewrite of description of 'mask' +.\" 2008-01-09, mtk, a few rewrites and additions. +.th umask 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +umask \- set file mode creation mask +.sh synopsis +.nf +.b #include +.pp +.bi "mode_t umask(mode_t " mask ); +.fi +.sh description +.br umask () +sets the calling process's file mode creation mask (umask) to +.i mask +& 0777 (i.e., only the file permission bits of +.i mask +are used), and returns the previous value of the mask. +.pp +the umask is used by +.br open (2), +.br mkdir (2), +and other system calls that create files +.\" e.g., mkfifo(), creat(), mknod(), sem_open(), mq_open(), shm_open() +.\" but not the system v ipc *get() calls +to modify the permissions placed on newly created files or directories. +specifically, permissions in the umask are turned off from +the +.i mode +argument to +.br open (2) +and +.br mkdir (2). +.pp +alternatively, if the parent directory has a default acl (see +.br acl (5)), +the umask is ignored, the default acl is inherited, +the permission bits are set based on the inherited acl, +and permission bits absent in the +.i mode +argument are turned off. +for example, the following default acl is equivalent to a umask of 022: +.pp + u::rwx,g::r-x,o::r-x +.pp +combining the effect of this default acl with a +.i mode +argument of 0666 (rw-rw-rw-), the resulting file permissions would be 0644 +(rw-r--r--). +.pp +the constants that should be used to specify +.i mask +are described in +.br inode (7). +.pp +the typical default value for the process umask is +.i s_iwgrp\ |\ s_iwoth +(octal 022). +in the usual case where the +.i mode +argument to +.br open (2) +is specified as: +.pp +.in +4n +.ex +s_irusr | s_iwusr | s_irgrp | s_iwgrp | s_iroth | s_iwoth +.ee +.in +.pp +(octal 0666) when creating a new file, the permissions on the +resulting file will be: +.pp +.in +4n +.ex +s_irusr | s_iwusr | s_irgrp | s_iroth +.ee +.in +.pp +(because 0666 & \(ti022 = 0644; i.e., rw\-r\-\-r\-\-). +.sh return value +this system call always succeeds and the previous value of the mask +is returned. +.sh conforming to +posix.1-2001, posix.1-2008, svr4, 4.3bsd. +.sh notes +a child process created via +.br fork (2) +inherits its parent's umask. +the umask is left unchanged by +.br execve (2). +.pp +it is impossible to use +.br umask () +to fetch a process's umask without at the same time changing it. +a second call to +.br umask () +would then be needed to restore the umask. +the nonatomicity of these two steps provides the potential +for races in multithreaded programs. +.pp +since linux 4.7, the umask of any process can be viewed via the +.i umask +field of +.ir /proc/[pid]/status . +inspecting this field in +.ir /proc/self/status +allows a process to retrieve its umask without at the same time changing it. +.pp +the umask setting also affects the permissions assigned to posix ipc objects +.rb ( mq_open (3), +.br sem_open (3), +.br shm_open (3)), +fifos +.rb ( mkfifo (3)), +and unix domain sockets +.rb ( unix (7)) +created by the process. +the umask does not affect the permissions assigned +to system\ v ipc objects created by the process (using +.br msgget (2), +.br semget (2), +.br shmget (2)). +.sh see also +.br chmod (2), +.br mkdir (2), +.br open (2), +.br stat (2), +.br acl (5) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/mlock.2 + +.\" copyright (c) 2017, michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th pthread_mutexattr_init 3 2019-10-10 "linux" "linux programmer's manual" +.sh name +pthread_mutexattr_init, pthread_mutexattr_destroy \- initialize and +destroy a mutex attributes object +.sh synopsis +.nf +.b #include +.pp +.bi "int pthread_mutexattr_init(pthread_mutexattr_t *" attr ");" +.bi "int pthread_mutexattr_destroy(pthread_mutexattr_t *" attr ");" +.fi +.pp +compile and link with \fi\-pthread\fp. +.sh description +the +.br pthread_mutexattr_init () +function initializes the mutex attributes object pointed to by +.i attr +with default values for all attributes defined by the implementation. +.pp +the results of initializing an already initialized mutex attributes +object are undefined. +.pp +the +.br pthread_mutexattr_destroy () +function destroys a mutex attribute object (making it uninitialized). +once a mutex attributes object has been destroyed, it can be reinitialized with +.br pthread_mutexattr_init (). +.pp +the results of destroying an uninitialized mutex attributes +object are undefined. +.sh return value +on success, these functions return 0. +on error, they return a positive error number. +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +subsequent changes to a mutex attributes object do not affect mutex that +have already been initialized using that object. +.sh see also +.ad l +.nh +.br pthread_mutex_init (3), +.br pthread_mutexattr_getpshared (3), +.br pthread_mutexattr_getrobust (3), +.br pthreads (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/stailq.3 + +.so man2/utime.2 + +.\" copyright (c) 1993 rickard e. faith +.\" and copyright (c) 1994 andries e. brouwer +.\" and copyright (c) 2002, 2005 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" 2008-10-06, mtk: created this as a new page by splitting +.\" umount/umount2 material out of mount.2 +.\" +.th umount 2 2021-08-27 "linux" "linux programmer's manual" +.sh name +umount, umount2 \- unmount filesystem +.sh synopsis +.nf +.b "#include " +.pp +.bi "int umount(const char *" target ); +.bi "int umount2(const char *" target ", int " flags ); +.fi +.sh description +.br umount () +and +.br umount2 () +remove the attachment of the (topmost) filesystem mounted on +.ir target . +.\" note: the kernel naming differs from the glibc naming +.\" umount2 is the glibc name for what the kernel now calls umount +.\" and umount is the glibc name for oldumount +.pp +appropriate privilege (linux: the +.b cap_sys_admin +capability) is required to unmount filesystems. +.pp +linux 2.1.116 added the +.br umount2 () +system call, which, like +.br umount (), +unmounts a target, but allows additional +.i flags +controlling the behavior of the operation: +.tp +.br mnt_force " (since linux 2.1.116)" +ask the filesystem to abort pending requests before attempting the +unmount. +this may allow the unmount to complete without waiting +for an inaccessible server, but could cause data loss. +if, after aborting requests, +some processes still have active references to the filesystem, +the unmount will still fail. +as at linux 4.12, +.br mnt_force +is supported only on the following filesystems: +9p (since linux 2.6.16), +ceph (since linux 2.6.34), +cifs (since linux 2.6.12), +fuse (since linux 2.6.16), +lustre (since linux 3.11), +and nfs (since linux 2.1.116). +.tp +.br mnt_detach " (since linux 2.4.11)" +perform a lazy unmount: make the mount unavailable for new +accesses, immediately disconnect the filesystem and all filesystems +mounted below it from each other and from the mount table, and +actually perform the unmount when the mount ceases to be busy. +.tp +.br mnt_expire " (since linux 2.6.8)" +mark the mount as expired. +if a mount is not currently in use, then an initial call to +.br umount2 () +with this flag fails with the error +.br eagain , +but marks the mount as expired. +the mount remains expired as long as it isn't accessed +by any process. +a second +.br umount2 () +call specifying +.b mnt_expire +unmounts an expired mount. +this flag cannot be specified with either +.b mnt_force +or +.br mnt_detach . +.tp +.br umount_nofollow " (since linux 2.6.34)" +.\" later added to 2.6.33-stable +don't dereference +.i target +if it is a symbolic link. +this flag allows security problems to be avoided in set-user-id-\firoot\fp +programs that allow unprivileged users to unmount filesystems. +.sh return value +on success, zero is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +the error values given below result from filesystem type independent +errors. +each filesystem type may have its own special errors and its +own special behavior. +see the linux kernel source code for details. +.tp +.b eagain +a call to +.br umount2 () +specifying +.b mnt_expire +successfully marked an unbusy filesystem as expired. +.tp +.b ebusy +.i target +could not be unmounted because it is busy. +.tp +.b efault +.i target +points outside the user address space. +.tp +.b einval +.i target +is not a mount point. +.tp +.b einval +.i target +is locked; see +.br mount_namespaces (7). +.tp +.b einval +.br umount2 () +was called with +.b mnt_expire +and either +.b mnt_detach +or +.br mnt_force . +.tp +.br einval " (since linux 2.6.34)" +.br umount2 () +was called with an invalid flag value in +.ir flags . +.tp +.b enametoolong +a pathname was longer than +.br maxpathlen . +.tp +.b enoent +a pathname was empty or had a nonexistent component. +.tp +.b enomem +the kernel could not allocate a free page to copy filenames or data into. +.tp +.b eperm +the caller does not have the required privileges. +.sh versions +.br mnt_detach +and +.br mnt_expire +.\" http://sourceware.org/bugzilla/show_bug.cgi?id=10092 +are available in glibc since version 2.11. +.sh conforming to +these functions are linux-specific and should not be used in +programs intended to be portable. +.sh notes +.ss umount() and shared mounts +shared mounts cause any mount activity on a mount, including +.br umount () +operations, to be forwarded to every shared mount in the +peer group and every slave mount of that peer group. +this means that +.br umount () +of any peer in a set of shared mounts will cause all of its +peers to be unmounted and all of their slaves to be unmounted as well. +.pp +this propagation of unmount activity can be particularly surprising +on systems where every mount is shared by default. +on such systems, +recursively bind mounting the root directory of the filesystem +onto a subdirectory and then later unmounting that subdirectory with +.br mnt_detach +will cause every mount in the mount namespace to be lazily unmounted. +.pp +to ensure +.br umount () +does not propagate in this fashion, +the mount may be remounted using a +.br mount (2) +call with a +.i mount_flags +argument that includes both +.br ms_rec +and +.br ms_private +prior to +.br umount () +being called. +.ss historical details +the original +.br umount () +function was called as \fiumount(device)\fp and would return +.b enotblk +when called with something other than a block device. +in linux 0.98p4, a call \fiumount(dir)\fp was added, in order to +support anonymous devices. +in linux 2.3.99-pre7, the call \fiumount(device)\fp was removed, +leaving only \fiumount(dir)\fp (since now devices can be mounted +in more than one place, so specifying the device does not suffice). +.sh see also +.br mount (2), +.br mount_namespaces (7), +.br path_resolution (7), +.br mount (8), +.br umount (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/readv.2 + +.\" copyright (c) 2009 bill o. gallmeister (bgallmeister@gmail.com) +.\" and copyright 2010 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux glibc source code +.\" posix 1003.1-2004 documentation +.\" (http://www.opengroup.org/onlinepubs/009695399) +.\" +.th posix_spawn 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +posix_spawn, posix_spawnp \- spawn a process +.sh synopsis +.nf +.b #include +.pp +.bi "int posix_spawn(pid_t *restrict " pid ", const char *restrict " path , +.bi " const posix_spawn_file_actions_t *restrict " file_actions , +.bi " const posix_spawnattr_t *restrict " attrp , +.bi " char *const " argv [restrict], +.bi " char *const " envp [restrict]); +.bi "int posix_spawnp(pid_t *restrict " pid ", const char *restrict " file , +.bi " const posix_spawn_file_actions_t *restrict " file_actions , +.bi " const posix_spawnattr_t *restrict " attrp , +.bi " char *const " argv [restrict], +.bi " char *const " envp [restrict]); +.fi +.sh description +the +.br posix_spawn () +and +.br posix_spawnp () +functions are used to create a new child process that executes +a specified file. +these functions were specified by posix to provide a standardized method +of creating new processes on machines that lack the capability +to support the +.br fork (2) +system call. +these machines are generally small, embedded systems lacking mmu support. +.pp +the +.br posix_spawn () +and +.br posix_spawnp () +functions provide the functionality of a combined +.br fork (2) +and +.br exec (3), +with some optional housekeeping steps in the child process before the +.br exec (3). +these functions are not meant to replace the +.br fork (2) +and +.br execve (2) +system calls. +in fact, they provide only a subset of the functionality +that can be achieved by using the system calls. +.pp +the only difference between +.br posix_spawn () +and +.br posix_spawnp () +is the manner in which they specify the file to be executed by +the child process. +with +.br posix_spawn (), +the executable file is specified as a pathname +(which can be absolute or relative). +with +.br posix_spawnp (), +the executable file is specified as a simple filename; +the system searches for this file in the list of directories specified by +.br path +(in the same way as for +.br execvp (3)). +for the remainder of this page, the discussion is phrased in terms of +.br posix_spawn (), +with the understanding that +.br posix_spawnp () +differs only on the point just described. +.pp +the remaining arguments to these two functions are as follows: +.ip * 3 +the +.i pid +argument points to a buffer that is used to return the process id +of the new child process. +.ip * +the +.i file_actions +argument points to a +.i "spawn file actions object" +that specifies file-related actions to be performed in the child +between the +.br fork (2) +and +.br exec (3) +steps. +this object is initialized and populated before the +.br posix_spawn () +call using +.br posix_spawn_file_actions_init (3) +and the +.br posix_spawn_file_actions_* () +functions. +.ip * +the +.i attrp +argument points to an +.i attributes objects +that specifies various attributes of the created child process. +this object is initialized and populated before the +.br posix_spawn () +call using +.br posix_spawnattr_init (3) +and the +.br posix_spawnattr_* () +functions. +.ip * +the +.i argv +and +.i envp +arguments specify the argument list and environment for the program +that is executed in the child process, as for +.br execve (2). +.pp +below, the functions are described in terms of a three-step process: the +.br fork () +step, the +.rb pre- exec () +step (executed in the child), +and the +.br exec () +step (executed in the child). +.ss fork() step +since glibc 2.24, the +.br posix_spawn () +function commences by calling +.br clone (2) +with +.br clone_vm +and +.br clone_vfork +flags. +older implementations use +.br fork (2), +or possibly +.br vfork (2) +(see below). +.pp +the pid of the new child process is placed in +.ir *pid . +the +.br posix_spawn () +function then returns control to the parent process. +.pp +subsequently, the parent can use one of the system calls described in +.br wait (2) +to check the status of the child process. +if the child fails in any of the housekeeping steps described below, +or fails to execute the desired file, +it exits with a status of 127. +.pp +before glibc 2.24, the child process is created using +.br vfork (2) +instead of +.br fork (2) +when either of the following is true: +.ip * 3 +the +.i spawn-flags +element of the attributes object pointed to by +.i attrp +contains the gnu-specific flag +.br posix_spawn_usevfork ; +or +.ip * +.i file_actions +is null and the +.i spawn-flags +element of the attributes object pointed to by +.i attrp +does \finot\fp contain +.br posix_spawn_setsigmask , +.br posix_spawn_setsigdef , +.br posix_spawn_setschedparam , +.br posix_spawn_setscheduler , +.br posix_spawn_setpgroup , +or +.br posix_spawn_resetids . +.pp +in other words, +.br vfork (2) +is used if the caller requests it, +or if there is no cleanup expected in the child before it +.br exec (3)s +the requested file. +.ss pre-exec() step: housekeeping +in between the +.br fork() +and the +.br exec() +steps, a child process may need to perform a set of housekeeping actions. +the +.br posix_spawn () +and +.br posix_spawnp () +functions support a small, well-defined set of system tasks that the child +process can accomplish before it executes the executable file. +these operations are controlled by the attributes object pointed to by +.ir attrp +and the file actions object pointed to by +.ir file_actions . +in the child, processing is done in the following sequence: +.ip 1. 3 +process attribute actions: signal mask, signal default handlers, +scheduling algorithm and parameters, +process group, and effective user and group ids +are changed as specified by the attributes object pointed to by +.ir attrp . +.ip 2. +file actions, as specified in the +.i file_actions +argument, +are performed in the order that they were specified using calls to the +.br posix_spawn_file_actions_add* () +functions. +.ip 3. +file descriptors with the +.b fd_cloexec +flag set are closed. +.pp +all process attributes in the child, +other than those affected by attributes specified in the +object pointed to by +.ir attrp +and the file actions in the object pointed to by +.ir file_actions , +will be affected as though the child was created with +.br fork (2) +and it executed the program with +.br execve (2). +.pp +the process attributes actions are defined by the attributes object +pointed to by +.ir attrp . +the +.i spawn-flags +attribute (set using +.br posix_spawnattr_setflags (3)) +controls the general actions that occur, +and other attributes in the object specify values +to be used during those actions. +.pp +the effects of the flags that may be specified in +.ir spawn-flags +are as follows: +.tp +.b posix_spawn_setsigmask +set the signal mask to the signal set specified in the +.i spawn-sigmask +attribute +.\" fixme . +.\" (see +.\" .br posix_spawnattr_setsigmask (3)) +of the object pointed to by +.ir attrp . +if the +.b posix_spawn_setsigmask +flag is not set, then the child inherits the parent's signal mask. +.tp +.b posix_spawn_setsigdef +reset the disposition of all signals in the set specified in the +.i spawn-sigdefault +attribute +.\" fixme . +.\" (see +.\" .br posix_spawnattr_setsigdefault (3)) +of the object pointed to by +.ir attrp +to the default. +for the treatment of the dispositions of signals not specified in the +.i spawn-sigdefault +attribute, or the treatment when +.b posix_spawn_setsigdef +is not specified, see +.br execve (2). +.tp +.b posix_spawn_setschedparam +.\" (posix_priority_scheduling only) +if this flag is set, and the +.b posix_spawn_setscheduler +flag is not set, then set the scheduling parameters +to the parameters specified in the +.i spawn-schedparam +attribute +.\" fixme . +.\" (see +.\" .br posix_spawnattr_setschedparam (3)) +of the object pointed to by +.ir attrp . +.tp +.b posix_spawn_setscheduler +set the scheduling policy algorithm and parameters of the child, +as follows: +.rs +.ip * 3 +the scheduling policy is set to the value specified in the +.i spawn-schedpolicy +attribute +.\" fixme . +.\" (see +.\" .br posix_spawnattr_setpolicy (3)) +of the object pointed to by +.ir attrp . +.ip * +the scheduling parameters are set to the value specified in the +.i spawn-schedparam +attribute +.\" fixme . +.\" (see +.\" .br posix_spawnattr_setschedparam (3)) +of the object pointed to by +.ir attrp +(but see bugs). +.pp +if the +.b posix_spawn_setschedparam +and +.b posix_spawn_setschedpolicy +flags are not specified, +the child inherits the corresponding scheduling attributes from the parent. +.re +.tp +.b posix_spawn_resetids +if this flag is set, +reset the effective uid and gid to the +real uid and gid of the parent process. +if this flag is not set, +then the child retains the effective uid and gid of the parent. +in either case, if the set-user-id and set-group-id permission +bits are enabled on the executable file, their effect will override +the setting of the effective uid and gid (se +.br execve (2)). +.tp +.b posix_spawn_setpgroup +set the process group to the value specified in the +.i spawn-pgroup +attribute +.\" fixme . +.\" (see +.\" .br posix_spawnattr_setpgroup (3)) +of the object pointed to by +.ir attrp . +if the +.i spawn-pgroup +attribute has the value 0, +the child's process group id is made the same as its process id. +if the +.b posix_spawn_setpgroup +flag is not set, the child inherits the parent's process group id. +.tp +.b posix_spawn_usevfork +since glibc 2.24, this flag has no effect. +on older implementations, setting this flag forces the +.br fork() +step to use +.br vfork (2) +instead of +.br fork (2). +the +.b _gnu_source +feature test macro must be defined to obtain the definition of this constant. +.tp +.br posix_spawn_setsid " (since glibc 2.26)" +if this flag is set, +the child process shall create a new session and become the session leader. +the child process shall also become the process group leader of the new process +group in the session (see +.br setsid (2)). +the +.b _gnu_source +feature test macro must be defined to obtain the definition of this constant. +.\" this flag has been accepted in posix, see: +.\" http://austingroupbugs.net/view.php?id=1044 +.\" and has been implemented in glibc since version 2.26 +.\" commit daeb1fa2e1b33323e719015f5f546988bd4cc73b +.pp +if +.i attrp +is null, then the default behaviors described above for each flag apply. +.\" mtk: i think we probably don't want to say the following, since it +.\" could lead people to do the wrong thing +.\" the posix standard tells you to call +.\" this function to de-initialize the attributes object pointed to by +.\" .i attrp +.\" when you are done with it; +.\" however, on linux systems this operation is a no-op. +.pp +the +.i file_actions +argument specifies a sequence of file operations +that are performed in the child process after +the general processing described above, and before it performs the +.br exec (3). +if +.i file_actions +is null, then no special action is taken, and standard +.br exec (3) +semantics apply\(emfile descriptors open before the exec +remain open in the new process, +except those for which the +.b fd_cloexec +flag has been set. +file locks remain in place. +.pp +if +.i file_actions +is not null, then it contains an ordered set of requests to +.br open (2), +.br close (2), +and +.br dup2 (2) +files. +these requests are added to the +.i file_actions +by +.br posix_spawn_file_actions_addopen (3), +.br posix_spawn_file_actions_addclose (3), +and +.br posix_spawn_file_actions_adddup2 (3). +the requested operations are performed in the order they were added to +.ir file_actions . +.\" fixme . i think the following is best placed in the +.\" posix_spawn_file_actions_adddup2(3) page, and a similar statement is +.\" also needed in posix_spawn_file_actions_addclose(3) +.\" note that you can specify file descriptors in +.\" .i posix_spawn_file_actions_adddup2 (3) +.\" which would not be usable if you called +.\" .br dup2 (2) +.\" at that time--i.e., file descriptors that are opened or +.\" closed by the earlier operations +.\" added to +.\" .i file_actions . +.pp +if any of the housekeeping actions fails +(due to bogus values being passed or other reasons why signal handling, +process scheduling, process group id functions, +and file descriptor operations might fail), +the child process exits with exit value 127. +.ss exec() step +once the child has successfully forked and performed +all requested pre-exec steps, +the child runs the requested executable. +.pp +the child process takes its environment from the +.i envp +argument, which is interpreted as if it had been passed to +.br execve (2). +the arguments to the created process come from the +.i argv +argument, which is processed as for +.br execve (2). +.sh return value +upon successful completion, +.br posix_spawn () +and +.br posix_spawnp () +place the pid of the child process in +.ir pid , +and return 0. +if there is an error during the +.br fork() +step, +then no child is created, +the contents of +.ir *pid +are unspecified, +and these functions return an error number as described below. +.pp +even when these functions return a success status, +the child process may still fail for a plethora of reasons related to its +pre-\fbexec\fr() initialization. +in addition, the +.br exec (3) +may fail. +in all of these cases, the child process will exit with the exit value of 127. +.sh errors +the +.br posix_spawn () +and +.br posix_spawnp () +functions fail only in the case where the underlying +.br fork (2), +.br vfork (2), +or +.br clone (2) +call fails; in these cases, these functions return an error number, +which will be one of the errors described for +.br fork (2), +.br vfork (2), +or +.br clone (2). +.pp +in addition, these functions fail if: +.tp +.b enosys +function not supported on this system. +.sh versions +the +.br posix_spawn () +and +.br posix_spawnp () +functions are available since glibc 2.2. +.sh conforming to +posix.1-2001, posix.1-2008. +.\" fixme . this piece belongs in spawnattr_setflags(3) +.\" the +.\" .b posix_spawn_usevfork +.\" flag is a gnu extension; the +.\" .b _gnu_source +.\" feature test macro must be defined (before including any header files) +.\" to obtain the definition of this constant. +.sh notes +the housekeeping activities in the child are controlled by +the objects pointed to by +.i attrp +(for non-file actions) and +.i file_actions +in posix parlance, the +.i posix_spawnattr_t +and +.i posix_spawn_file_actions_t +data types are referred to as objects, +and their elements are not specified by name. +portable programs should initialize these objects using +only the posix-specified functions. +(in other words, +although these objects may be implemented as structures containing fields, +portable programs must avoid dependence on such implementation details.) +.pp +according to posix, it is unspecified whether fork handlers established with +.br pthread_atfork (3) +are called when +.br posix_spawn () +is invoked. +since glibc 2.24, the fork handlers are not executed in any case. +.\" tested on glibc 2.12 +on older implementations, +fork handlers are called only if the child is created using +.br fork (2). +.pp +there is no "posix_fspawn" function (i.e., a function that is to +.br posix_spawn () +as +.br fexecve (3) +is to +.br execve (2)). +however, this functionality can be obtained by specifying the +.i path +argument as one of the files in the caller's +.ir /proc/self/fd +directory. +.sh bugs +posix.1 says that when +.b posix_spawn_setscheduler +is specified in +.ir spawn-flags , +then the +.b posix_spawn_setschedparam +(if present) is ignored. +however, before glibc 2.14, calls to +.br posix_spawn () +failed with an error if +.\" http://sourceware.org/bugzilla/show_bug.cgi?id=12052 +.br posix_spawn_setscheduler +was specified without also specifying +.br posix_spawn_setschedparam . +.sh examples +the program below demonstrates the use of various functions in the +posix spawn api. +the program accepts command-line attributes that can be used +to create file actions and attributes objects. +the remaining command-line arguments are used as the executable name +and command-line arguments of the program that is executed in the child. +.pp +in the first run, the +.br date (1) +command is executed in the child, and the +.br posix_spawn () +call employs no file actions or attributes objects. +.pp +.in +4n +.ex +$ \fb./a.out date\fp +pid of child: 7634 +tue feb 1 19:47:50 cest 2011 +child status: exited, status=0 +.ee +.in +.pp +in the next run, the +.i \-c +command-line option is used to create a file actions object that closes +standard output in the child. +consequently, +.br date (1) +fails when trying to perform output and exits with a status of 1. +.pp +.in +4n +.ex +$ \fb./a.out \-c date\fp +pid of child: 7636 +date: write error: bad file descriptor +child status: exited, status=1 +.ee +.in +.pp +in the next run, the +.i \-s +command-line option is used to create an attributes object that +specifies that all (blockable) signals in the child should be blocked. +consequently, trying to kill child with the default signal sent by +.br kill (1) +(i.e., +.br sigterm ) +fails, because that signal is blocked. +therefore, to kill the child, +.br sigkill +is necessary +.rb ( sigkill +can't be blocked). +.pp +.in +4n +.ex +$ \fb./a.out \-s sleep 60 &\fp +[1] 7637 +$ pid of child: 7638 + +$ \fbkill 7638\fp +$ \fbkill \-kill 7638\fp +$ child status: killed by signal 9 +[1]+ done ./a.out \-s sleep 60 +.ee +.in +.pp +when we try to execute a nonexistent command in the child, the +.br exec (3) +fails and the child exits with a status of 127. +.pp +.in +4n +.ex +$ \fb./a.out xxxxx +pid of child: 10190 +child status: exited, status=127 +.ee +.in +.ss program source +\& +.ex +#include +#include +#include +#include +#include +#include +#include +#include + +#define errexit(msg) do { perror(msg); \e + exit(exit_failure); } while (0) + +#define errexiten(en, msg) \e + do { errno = en; perror(msg); \e + exit(exit_failure); } while (0) + +char **environ; + +int +main(int argc, char *argv[]) +{ + pid_t child_pid; + int s, opt, status; + sigset_t mask; + posix_spawnattr_t attr; + posix_spawnattr_t *attrp; + posix_spawn_file_actions_t file_actions; + posix_spawn_file_actions_t *file_actionsp; + + /* parse command\-line options, which can be used to specify an + attributes object and file actions object for the child. */ + + attrp = null; + file_actionsp = null; + + while ((opt = getopt(argc, argv, "sc")) != \-1) { + switch (opt) { + case \(aqc\(aq: /* \-c: close standard output in child */ + + /* create a file actions object and add a "close" + action to it. */ + + s = posix_spawn_file_actions_init(&file_actions); + if (s != 0) + errexiten(s, "posix_spawn_file_actions_init"); + + s = posix_spawn_file_actions_addclose(&file_actions, + stdout_fileno); + if (s != 0) + errexiten(s, "posix_spawn_file_actions_addclose"); + + file_actionsp = &file_actions; + break; + + case \(aqs\(aq: /* \-s: block all signals in child */ + + /* create an attributes object and add a "set signal mask" + action to it. */ + + s = posix_spawnattr_init(&attr); + if (s != 0) + errexiten(s, "posix_spawnattr_init"); + s = posix_spawnattr_setflags(&attr, posix_spawn_setsigmask); + if (s != 0) + errexiten(s, "posix_spawnattr_setflags"); + + sigfillset(&mask); + s = posix_spawnattr_setsigmask(&attr, &mask); + if (s != 0) + errexiten(s, "posix_spawnattr_setsigmask"); + + attrp = &attr; + break; + } + } + + /* spawn the child. the name of the program to execute and the + command\-line arguments are taken from the command\-line arguments + of this program. the environment of the program execed in the + child is made the same as the parent\(aqs environment. */ + + s = posix_spawnp(&child_pid, argv[optind], file_actionsp, attrp, + &argv[optind], environ); + if (s != 0) + errexiten(s, "posix_spawn"); + + /* destroy any objects that we created earlier. */ + + if (attrp != null) { + s = posix_spawnattr_destroy(attrp); + if (s != 0) + errexiten(s, "posix_spawnattr_destroy"); + } + + if (file_actionsp != null) { + s = posix_spawn_file_actions_destroy(file_actionsp); + if (s != 0) + errexiten(s, "posix_spawn_file_actions_destroy"); + } + + printf("pid of child: %jd\en", (intmax_t) child_pid); + + /* monitor status of the child until it terminates. */ + + do { + s = waitpid(child_pid, &status, wuntraced | wcontinued); + if (s == \-1) + errexit("waitpid"); + + printf("child status: "); + if (wifexited(status)) { + printf("exited, status=%d\en", wexitstatus(status)); + } else if (wifsignaled(status)) { + printf("killed by signal %d\en", wtermsig(status)); + } else if (wifstopped(status)) { + printf("stopped by signal %d\en", wstopsig(status)); + } else if (wifcontinued(status)) { + printf("continued\en"); + } + } while (!wifexited(status) && !wifsignaled(status)); + + exit(exit_success); +} +.ee +.sh see also +.nh \" disable hyphenation +.ad l +.br close (2), +.br dup2 (2), +.br execl (2), +.br execlp (2), +.br fork (2), +.br open (2), +.br sched_setparam (2), +.br sched_setscheduler (2), +.br setpgid (2), +.br setuid (2), +.br sigaction (2), +.br sigprocmask (2), +.br posix_spawn_file_actions_addclose (3), +.br posix_spawn_file_actions_adddup2 (3), +.br posix_spawn_file_actions_addopen (3), +.br posix_spawn_file_actions_destroy (3), +.br posix_spawn_file_actions_init (3), +.br posix_spawnattr_destroy (3), +.br posix_spawnattr_getflags (3), +.br posix_spawnattr_getpgroup (3), +.br posix_spawnattr_getschedparam (3), +.br posix_spawnattr_getschedpolicy (3), +.br posix_spawnattr_getsigdefault (3), +.br posix_spawnattr_getsigmask (3), +.br posix_spawnattr_init (3), +.br posix_spawnattr_setflags (3), +.br posix_spawnattr_setpgroup (3), +.br posix_spawnattr_setschedparam (3), +.br posix_spawnattr_setschedpolicy (3), +.br posix_spawnattr_setsigdefault (3), +.br posix_spawnattr_setsigmask (3), +.br pthread_atfork (3), +.ir , +base definitions volume of posix.1-2001, +.i http://www.opengroup.org/unix/online.html +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/getaddrinfo_a.3 + +.so man3/unlocked_stdio.3 + +.\" copyright (c) 2001 andries brouwer . +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th fpurge 3 2021-03-22 "" "linux programmer's manual" +.sh name +fpurge, __fpurge \- purge a stream +.sh synopsis +.nf +/* unsupported */ +.b #include +.pp +.bi "int fpurge(file *" stream ); +.pp +/* supported */ +.b #include +.b #include +.pp +.bi "void __fpurge(file *" stream ); +.fi +.sh description +the function +.br fpurge () +clears the buffers of the given stream. +for output streams this discards any unwritten output. +for input streams this discards any input read from the underlying object +but not yet obtained via +.br getc (3); +this includes any text pushed back via +.br ungetc (3). +see also +.br fflush (3). +.pp +the function +.br __fpurge () +does precisely the same, but without returning a value. +.sh return value +upon successful completion +.br fpurge () +returns 0. +on error, it returns \-1 and sets +.i errno +to indicate the error. +.sh errors +.tp +.b ebadf +.i stream +is not an open stream. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br __fpurge () +t} thread safety mt-safe race:stream +.te +.hy +.ad +.sp 1 +.sh conforming to +these functions are nonstandard and not portable. +the function +.br fpurge () +was introduced in 4.4bsd and is not available under linux. +the function +.br __fpurge () +was introduced in solaris, and is present in glibc 2.1.95 and later. +.sh notes +usually it is a mistake to want to discard input buffers. +.sh see also +.\" .br fclean (3), +.br fflush (3), +.br setbuf (3), +.br stdio_ext (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th repertoiremap 5 2020-06-09 "gnu" "linux user manual" +.sh name +repertoiremap \- map symbolic character names to unicode code points +.sh description +a repertoire map defines mappings between symbolic character names +(mnemonics) and unicode code points when compiling a locale with +.br localedef (1). +using a repertoire map is optional, it is needed only when symbolic +names are used instead of now preferred unicode code points. +.ss syntax +the repertoiremap file starts with a header that may consist of the +following keywords: +.tp +.i comment_char +is followed by a character that will be used as the +comment character for the rest of the file. +it defaults to the number sign (#). +.tp +.i escape_char +is followed by a character that should be used as the escape character +for the rest of the file to mark characters that should be interpreted +in a special way. +it defaults to the backslash (\e). +.pp +the mapping section starts with the keyword +.i charids +in the first column. +.pp +the mapping lines have the following form: +.tp +.i comment +this defines exactly one mapping, +.i comment +being optional. +.pp +the mapping section ends with the string +.ir "end charids" . +.sh files +.tp +.i /usr/share/i18n/repertoiremaps +usual default repertoire map path. +.sh conforming to +posix.2. +.sh notes +repertoire maps are deprecated in favor of unicode code points. +.sh examples +a mnemonic for the euro sign can be defined as follows: +.pp +.nf + euro sign +.fi +.sh see also +.br locale (1), +.br localedef (1), +.br charmap (5), +.br locale (5) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/isalpha.3 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sat jul 24 18:01:24 1993 by rik faith (faith@cs.unc.edu) +.th strpbrk 3 2021-03-22 "" "linux programmer's manual" +.sh name +strpbrk \- search a string for any of a set of bytes +.sh synopsis +.nf +.b #include +.pp +.bi "char *strpbrk(const char *" s ", const char *" accept ); +.fi +.sh description +the +.br strpbrk () +function locates the first occurrence in the +string +.i s +of any of the bytes in the string +.ir accept . +.sh return value +the +.br strpbrk () +function returns a pointer to the byte in +.i s +that matches one of the bytes in +.ir accept , +or null +if no such byte is found. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br strpbrk () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c89, c99, svr4, 4.3bsd. +.sh see also +.br index (3), +.br memchr (3), +.br rindex (3), +.br strchr (3), +.br string (3), +.br strsep (3), +.br strspn (3), +.br strstr (3), +.br strtok (3), +.br wcspbrk (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/isalpha.3 + +.\" copyright (c) 1996 free software foundation, inc. +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" this file is distributed according to the gnu general public license. +.\" %%%license_end +.\" +.\" 2006-02-09, some reformatting by luc van oostenryck; some +.\" reformatting and rewordings by mtk +.\" +.th query_module 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +query_module \- query the kernel for various bits pertaining to modules +.sh synopsis +.nf +.b #include +.pp +.bi "int query_module(const char *" name ", int " which ", void *" buf , +.bi " size_t " bufsize ", size_t *" ret ); +.fi +.pp +.ir note : +no declaration of this system call is provided in glibc headers; see notes. +.sh description +.ir note : +this system call is present only in kernels before linux 2.6. +.pp +.br query_module () +requests information from the kernel about loadable modules. +the returned information is placed in the buffer pointed to by +.ir buf . +the caller must specify the size of +.i buf +in +.ir bufsize . +the precise nature and format of the returned information +depend on the operation specified by +.ir which . +some operations require +.i name +to identify a currently loaded module, some allow +.i name +to be null, indicating the kernel proper. +.pp +the following values can be specified for +.ir which : +.tp +.b 0 +returns success, if the kernel supports +.br query_module (). +used to probe for availability of the system call. +.tp +.b qm_modules +returns the names of all loaded modules. +the returned buffer consists of a sequence of null-terminated strings; +.i ret +is set to the number of +modules. +.\" ret is set on enospc +.tp +.b qm_deps +returns the names of all modules used by the indicated module. +the returned buffer consists of a sequence of null-terminated strings; +.i ret +is set to the number of modules. +.\" ret is set on enospc +.tp +.b qm_refs +returns the names of all modules using the indicated module. +this is the inverse of +.br qm_deps . +the returned buffer consists of a sequence of null-terminated strings; +.i ret +is set to the number of modules. +.\" ret is set on enospc +.tp +.b qm_symbols +returns the symbols and values exported by the kernel or the indicated +module. +the returned buffer is an array of structures of the following form +.\" ret is set on enospc +.ip +.in +4n +.ex +struct module_symbol { + unsigned long value; + unsigned long name; +}; +.ee +.in +.ip +followed by null-terminated strings. +the value of +.i name +is the character offset of the string relative to the start of +.ir buf ; +.i ret +is set to the number of symbols. +.tp +.b qm_info +returns miscellaneous information about the indicated module. +the output buffer format is: +.ip +.in +4n +.ex +struct module_info { + unsigned long address; + unsigned long size; + unsigned long flags; +}; +.ee +.in +.ip +where +.i address +is the kernel address at which the module resides, +.i size +is the size of the module in bytes, and +.i flags +is a mask of +.br mod_running , +.br mod_autoclean , +and so on, that indicates the current status of the module +(see the linux kernel source file +.ir include/linux/module.h ). +.i ret +is set to the size of the +.i module_info +structure. +.sh return value +on success, zero is returned. +on error, \-1 is returned and +.i errno +is set to indicate the error. +.sh errors +.tp +.b efault +at least one of +.ir name , +.ir buf , +or +.i ret +was outside the program's accessible address space. +.tp +.b einval +invalid +.ir which ; +or +.i name +is null (indicating "the kernel"), +but this is not permitted with the specified value of +.ir which . +.\" not permitted with qm_deps, qm_refs, or qm_info. +.tp +.b enoent +no module by that +.i name +exists. +.tp +.b enospc +the buffer size provided was too small. +.i ret +is set to the minimum size needed. +.tp +.b enosys +.br query_module () +is not supported in this version of the kernel +(e.g., the kernel is version 2.6 or later). +.sh versions +this system call is present on linux only up until kernel 2.4; +it was removed in linux 2.6. +.\" removed in linux 2.5.48 +.sh conforming to +.br query_module () +is linux-specific. +.sh notes +some of the information that was formerly available via +.br query_module () +can be obtained from +.ir /proc/modules , +.ir /proc/kallsyms , +and the files under the directory +.ir /sys/module . +.pp +the +.br query_module () +system call is not supported by glibc. +no declaration is provided in glibc headers, but, +through a quirk of history, glibc does export an abi for this system call. +therefore, in order to employ this system call, +it is sufficient to manually declare the interface in your code; +alternatively, you can invoke the system call using +.br syscall (2). +.sh see also +.br create_module (2), +.br delete_module (2), +.br get_kernel_syms (2), +.br init_module (2), +.br lsmod (8), +.br modinfo (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" iso/iec 9899:1999 +.\" +.th iswctype 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +iswctype \- wide-character classification +.sh synopsis +.nf +.b #include +.pp +.bi "int iswctype(wint_t " wc ", wctype_t " desc ); +.fi +.sh description +if +.i wc +is a wide character having the character property designated by +.i desc +(or in other words: belongs to the character class designated by +.ir desc ), +the +.br iswctype () +function returns nonzero. +otherwise, it +returns zero. +if +.i wc +is +.br weof , +zero is returned. +.pp +.i desc +must be a character property descriptor +returned by the +.br wctype (3) +function. +.sh return value +the +.br iswctype () +function returns nonzero if +the +.i wc +has the designated +property. +otherwise, it returns 0. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br iswctype () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh notes +the behavior of +.br iswctype () +depends on the +.b lc_ctype +category of the +current locale. +.sh see also +.br iswalnum (3), +.br iswalpha (3), +.br iswblank (3), +.br iswcntrl (3), +.br iswdigit (3), +.br iswgraph (3), +.br iswlower (3), +.br iswprint (3), +.br iswpunct (3), +.br iswspace (3), +.br iswupper (3), +.br iswxdigit (3), +.br wctype (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" this man page is copyright (c) 1999 matthew wilcox . +.\" %%%license_start(verbatim_one_para) +.\" permission is granted to distribute possibly modified copies +.\" of this page provided the header is included verbatim, +.\" and in case of nontrivial modification author and date +.\" of the modification is added to the header. +.\" %%%license_end +.\" +.\" modified june 1999 andi kleen +.\" $id: arp.7,v 1.10 2000/04/27 19:31:38 ak exp $ +.\" +.th arp 7 2020-08-13 "linux" "linux programmer's manual" +.sh name +arp \- linux arp kernel module. +.sh description +this kernel protocol module implements the address resolution +protocol defined in rfc\ 826. +it is used to convert between layer2 hardware addresses +and ipv4 protocol addresses on directly connected networks. +the user normally doesn't interact directly with this module except to +configure it; +instead it provides a service for other protocols in the kernel. +.pp +a user process can receive arp packets by using +.br packet (7) +sockets. +there is also a mechanism for managing the arp cache +in user-space by using +.br netlink (7) +sockets. +the arp table can also be controlled via +.br ioctl (2) +on any +.b af_inet +socket. +.pp +the arp module maintains a cache of mappings between hardware addresses +and protocol addresses. +the cache has a limited size so old and less +frequently used entries are garbage-collected. +entries which are marked +as permanent are never deleted by the garbage-collector. +the cache can +be directly manipulated by the use of ioctls and its behavior can be +tuned by the +.i /proc +interfaces described below. +.pp +when there is no positive feedback for an existing mapping after some +time (see the +.i /proc +interfaces below), a neighbor cache entry is considered stale. +positive feedback can be gotten from a higher layer; for example from +a successful tcp ack. +other protocols can signal forward progress +using the +.b msg_confirm +flag to +.br sendmsg (2). +when there is no forward progress, arp tries to reprobe. +it first tries to ask a local arp daemon +.b app_solicit +times for an updated mac address. +if that fails and an old mac address is known, a unicast probe is sent +.b ucast_solicit +times. +if that fails too, it will broadcast a new arp +request to the network. +requests are sent only when there is data queued +for sending. +.pp +linux will automatically add a nonpermanent proxy arp entry when it +receives a request for an address it forwards to and proxy arp is +enabled on the receiving interface. +when there is a reject route for the target, no proxy arp entry is added. +.ss ioctls +three ioctls are available on all +.b af_inet +sockets. +they take a pointer to a +.i struct arpreq +as their argument. +.pp +.in +4n +.ex +struct arpreq { + struct sockaddr arp_pa; /* protocol address */ + struct sockaddr arp_ha; /* hardware address */ + int arp_flags; /* flags */ + struct sockaddr arp_netmask; /* netmask of protocol address */ + char arp_dev[16]; +}; +.ee +.in +.pp +.br siocsarp ", " siocdarp " and " siocgarp +respectively set, delete, and get an arp mapping. +setting and deleting arp maps are privileged operations and may +be performed only by a process with the +.b cap_net_admin +capability or an effective uid of 0. +.pp +.i arp_pa +must be an +.b af_inet +address and +.i arp_ha +must have the same type as the device which is specified in +.ir arp_dev . +.i arp_dev +is a zero-terminated string which names a device. +.rs +.ts +tab(:) allbox; +c s +l l. +\fiarp_flags\fr +flag:meaning +atf_com:lookup complete +atf_perm:permanent entry +atf_publ:publish entry +atf_usetrailers:trailers requested +atf_netmask:use a netmask +atf_dontpub:don't answer +.te +.re +.pp +if the +.b atf_netmask +flag is set, then +.i arp_netmask +should be valid. +linux 2.2 does not support proxy network arp entries, so this +should be set to 0xffffffff, or 0 to remove an existing proxy arp entry. +.b atf_usetrailers +is obsolete and should not be used. +.ss /proc interfaces +arp supports a range of +.i /proc +interfaces to configure parameters on a global or per-interface basis. +the interfaces can be accessed by reading or writing the +.i /proc/sys/net/ipv4/neigh/*/* +files. +each interface in the system has its own directory in +.ir /proc/sys/net/ipv4/neigh/ . +the setting in the "default" directory is used for all newly created +devices. +unless otherwise specified, time-related interfaces are specified +in seconds. +.tp +.ir anycast_delay " (since linux 2.2)" +.\" precisely: 2.1.79 +the maximum number of jiffies to delay before replying to a +ipv6 neighbor solicitation message. +anycast support is not yet implemented. +defaults to 1 second. +.tp +.ir app_solicit " (since linux 2.2)" +.\" precisely: 2.1.79 +the maximum number of probes to send to the user space arp daemon via +netlink before dropping back to multicast probes (see +.ir mcast_solicit ). +defaults to 0. +.tp +.ir base_reachable_time " (since linux 2.2)" +.\" precisely: 2.1.79 +once a neighbor has been found, the entry is considered to be valid +for at least a random value between +.ir base_reachable_time "/2 and 3*" base_reachable_time /2. +an entry's validity will be extended if it receives positive feedback +from higher level protocols. +defaults to 30 seconds. +this file is now obsolete in favor of +.ir base_reachable_time_ms . +.tp +.ir base_reachable_time_ms " (since linux 2.6.12)" +as for +.ir base_reachable_time , +but measures time in milliseconds. +defaults to 30000 milliseconds. +.tp +.ir delay_first_probe_time " (since linux 2.2)" +.\" precisely: 2.1.79 +delay before first probe after it has been decided that a neighbor +is stale. +defaults to 5 seconds. +.tp +.ir gc_interval " (since linux 2.2)" +.\" precisely: 2.1.79 +how frequently the garbage collector for neighbor entries +should attempt to run. +defaults to 30 seconds. +.tp +.ir gc_stale_time " (since linux 2.2)" +.\" precisely: 2.1.79 +determines how often to check for stale neighbor entries. +when a neighbor entry is considered stale, it is resolved again before +sending data to it. +defaults to 60 seconds. +.tp +.ir gc_thresh1 " (since linux 2.2)" +.\" precisely: 2.1.79 +the minimum number of entries to keep in the arp cache. +the garbage collector will not run if there are fewer than +this number of entries in the cache. +defaults to 128. +.tp +.ir gc_thresh2 " (since linux 2.2)" +.\" precisely: 2.1.79 +the soft maximum number of entries to keep in the arp cache. +the garbage collector will allow the number of entries to exceed +this for 5 seconds before collection will be performed. +defaults to 512. +.tp +.ir gc_thresh3 " (since linux 2.2)" +.\" precisely: 2.1.79 +the hard maximum number of entries to keep in the arp cache. +the garbage collector will always run if there are more than +this number of entries in the cache. +defaults to 1024. +.tp +.ir locktime " (since linux 2.2)" +.\" precisely: 2.1.79 +the minimum number of jiffies to keep an arp entry in the cache. +this prevents arp cache thrashing if there is more than one potential +mapping (generally due to network misconfiguration). +defaults to 1 second. +.tp +.ir mcast_solicit " (since linux 2.2)" +.\" precisely: 2.1.79 +the maximum number of attempts to resolve an address by +multicast/broadcast before marking the entry as unreachable. +defaults to 3. +.tp +.ir proxy_delay " (since linux 2.2)" +.\" precisely: 2.1.79 +when an arp request for a known proxy-arp address is received, delay up to +.i proxy_delay +jiffies before replying. +this is used to prevent network flooding in some cases. +defaults to 0.8 seconds. +.tp +.ir proxy_qlen " (since linux 2.2)" +.\" precisely: 2.1.79 +the maximum number of packets which may be queued to proxy-arp addresses. +defaults to 64. +.tp +.ir retrans_time " (since linux 2.2)" +.\" precisely: 2.1.79 +the number of jiffies to delay before retransmitting a request. +defaults to 1 second. +this file is now obsolete in favor of +.ir retrans_time_ms . +.tp +.ir retrans_time_ms " (since linux 2.6.12)" +the number of milliseconds to delay before retransmitting a request. +defaults to 1000 milliseconds. +.tp +.ir ucast_solicit " (since linux 2.2)" +.\" precisely: 2.1.79 +the maximum number of attempts to send unicast probes before asking +the arp daemon (see +.ir app_solicit ). +defaults to 3. +.tp +.ir unres_qlen " (since linux 2.2)" +.\" precisely: 2.1.79 +the maximum number of packets which may be queued for each unresolved +address by other network layers. +defaults to 3. +.sh versions +the +.i struct arpreq +changed in linux 2.0 to include the +.i arp_dev +member and the ioctl numbers changed at the same time. +support for the old ioctls was dropped in linux 2.2. +.pp +support for proxy arp entries for networks (netmask not equal 0xffffffff) +was dropped in linux 2.2. +it is replaced by automatic proxy arp setup by +the kernel for all reachable hosts on other interfaces (when +forwarding and proxy arp is enabled for the interface). +.pp +the +.i neigh/* +interfaces did not exist before linux 2.2. +.sh bugs +some timer settings are specified in jiffies, which is architecture- +and kernel version-dependent; see +.br time (7). +.pp +there is no way to signal positive feedback from user space. +this means connection-oriented protocols implemented in user space +will generate excessive arp traffic, because ndisc will regularly +reprobe the mac address. +the same problem applies for some kernel protocols (e.g., nfs over udp). +.pp +this man page mashes together functionality that is ipv4-specific +with functionality that is shared between ipv4 and ipv6. +.sh see also +.br capabilities (7), +.br ip (7), +.br arpd (8) +.pp +rfc\ 826 for a description of arp. +rfc\ 2461 for a description of ipv6 neighbor discovery and the base +algorithms used. +linux 2.2+ ipv4 arp uses the ipv6 algorithms when applicable. +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/argz_add.3 + +.so man7/iso_8859-4.7 + +.so man2/readv.2 + +.\" copyright (c) 1996 andries brouwer (aeb@cwi.nl) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" written 11 april 1996 by andries brouwer +.\" 960412: added comments from stephen tweedie +.\" modified tue oct 22 22:28:41 1996 by eric s. raymond +.\" modified mon jan 5 20:31:04 1998 by aeb. +.\" +.th sysctl 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +sysctl \- read/write system parameters +.sh synopsis +.nf +.b #include +.b #include +.pp +.bi "int _sysctl(struct __sysctl_args *" args ); +.fi +.sh description +.b this system call no longer exists on current kernels! +see notes. +.pp +the +.br _sysctl () +call reads and/or writes kernel parameters. +for example, the hostname, +or the maximum number of open files. +the argument has the form +.pp +.in +4n +.ex +struct __sysctl_args { + int *name; /* integer vector describing variable */ + int nlen; /* length of this vector */ + void *oldval; /* 0 or address where to store old value */ + size_t *oldlenp; /* available room for old value, + overwritten by actual size of old value */ + void *newval; /* 0 or address of new value */ + size_t newlen; /* size of new value */ +}; +.ee +.in +.pp +this call does a search in a tree structure, possibly resembling +a directory tree under +.ir /proc/sys , +and if the requested item is found calls some appropriate routine +to read or modify the value. +.sh return value +upon successful completion, +.br _sysctl () +returns 0. +otherwise, a value of \-1 is returned and +.i errno +is set to indicate the error. +.sh errors +.tp +.br eacces ", " eperm +no search permission for one of the encountered "directories", +or no read permission where +.i oldval +was nonzero, or no write permission where +.i newval +was nonzero. +.tp +.b efault +the invocation asked for the previous value by setting +.i oldval +non-null, but allowed zero room in +.ir oldlenp . +.tp +.b enotdir +.i name +was not found. +.sh versions +this system call first appeared in linux 1.3.57. +it was removed in linux 5.5; glibc support was removed in version 2.32. +.sh conforming to +this call is linux-specific, and should not be used in programs +intended to be portable. +it originated in +4.4bsd. +only linux has the +.i /proc/sys +mirror, and the object naming schemes differ between linux and 4.4bsd, +but the declaration of the +.br sysctl () +function is the same in both. +.sh notes +use of this system call was long discouraged: +since linux 2.6.24, +uses of this system call result in warnings in the kernel log, +and in linux 5.5, the system call was finally removed. +use the +.i /proc/sys +interface instead. +.pp +note that on older kernels where this system call still exists, +it is available only if the kernel was configured with the +.b config_sysctl_syscall +option. +furthermore, glibc does not provide a wrapper for this system call, +necessitating the use of +.br syscall (2). +.sh bugs +the object names vary between kernel versions, +making this system call worthless for applications. +.pp +not all available objects are properly documented. +.pp +it is not yet possible to change operating system by writing to +.ir /proc/sys/kernel/ostype . +.sh examples +.ex +#define _gnu_source +#include +#include +#include +#include +#include +#include + +int _sysctl(struct __sysctl_args *args ); + +#define osnamesz 100 + +int +main(void) +{ + struct __sysctl_args args; + char osname[osnamesz]; + size_t osnamelth; + int name[] = { ctl_kern, kern_ostype }; + + memset(&args, 0, sizeof(args)); + args.name = name; + args.nlen = sizeof(name)/sizeof(name[0]); + args.oldval = osname; + args.oldlenp = &osnamelth; + + osnamelth = sizeof(osname); + + if (syscall(sys__sysctl, &args) == \-1) { + perror("_sysctl"); + exit(exit_failure); + } + printf("this machine is running %*s\en", osnamelth, osname); + exit(exit_success); +} +.ee +.sh see also +.br proc (5) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/mkstemp.3 + +.\" copyright (c) 1990, 1991 the regents of the university of california. +.\" all rights reserved. +.\" +.\" this code is derived from software contributed to berkeley by +.\" chris torek and the american national standards committee x3, +.\" on information processing systems. +.\" +.\" %%%license_start(bsd_4_clause_ucb) +.\" redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. all advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" this product includes software developed by the university of +.\" california, berkeley and its contributors. +.\" 4. neither the name of the university nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" this software is provided by the regents and contributors ``as is'' and +.\" any express or implied warranties, including, but not limited to, the +.\" implied warranties of merchantability and fitness for a particular purpose +.\" are disclaimed. in no event shall the regents or contributors be liable +.\" for any direct, indirect, incidental, special, exemplary, or consequential +.\" damages (including, but not limited to, procurement of substitute goods +.\" or services; loss of use, data, or profits; or business interruption) +.\" however caused and on any theory of liability, whether in contract, strict +.\" liability, or tort (including negligence or otherwise) arising in any way +.\" out of the use of this software, even if advised of the possibility of +.\" such damage. +.\" %%%license_end +.\" +.\" @(#)scanf.3 6.14 (berkeley) 1/8/93 +.\" +.\" converted for linux, mon nov 29 15:22:01 1993, faith@cs.unc.edu +.\" modified to resemble the gnu libio setup used in the linux libc +.\" used in versions 4.x (x>4) and 5 helmut.geyer@iwr.uni-heidelberg.de +.\" modified, aeb, 970121 +.\" 2005-07-14, mtk, added description of %n$ form; various text +.\" incorporated from the gnu c library documentation ((c) the +.\" free software foundation); other parts substantially rewritten. +.\" +.\" 2008-06-23, mtk +.\" add errors section. +.\" document the 'a' and 'm' modifiers for dynamic string allocation. +.\" +.th scanf 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +scanf, fscanf, sscanf, vscanf, vsscanf, vfscanf \- input format conversion +.sh synopsis +.nf +.b #include +.pp +.bi "int scanf(const char *restrict " format ", ...);" +.bi "int fscanf(file *restrict " stream , +.bi " const char *restrict " format ", ...);" +.bi "int sscanf(const char *restrict " str , +.bi " const char *restrict " format ", ...);" +.pp +.b #include +.pp +.bi "int vscanf(const char *restrict " format ", va_list " ap ); +.bi "int vfscanf(file *restrict " stream , +.bi " const char *restrict " format ", va_list " ap ); +.bi "int vsscanf(const char *restrict " str , +.bi " const char *restrict " format ", va_list " ap ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br vscanf (), +.br vsscanf (), +.br vfscanf (): +.nf + _isoc99_source || _posix_c_source >= 200112l +.fi +.sh description +the +.br scanf () +family of functions scans input according to +.i format +as described below. +this format may contain +.ir "conversion specifications" ; +the results from such conversions, if any, +are stored in the locations pointed to by the +.i pointer +arguments that follow +.ir format . +each +.i pointer +argument must be of a type that is appropriate for the value returned +by the corresponding conversion specification. +.pp +if the number of conversion specifications in +.i format +exceeds the number of +.i pointer +arguments, the results are undefined. +if the number of +.i pointer +arguments exceeds the number of conversion specifications, then the excess +.i pointer +arguments are evaluated, but are otherwise ignored. +.pp +the +.br scanf () +function reads input from the standard input stream +.ir stdin , +.br fscanf () +reads input from the stream pointer +.ir stream , +and +.br sscanf () +reads its input from the character string pointed to by +.ir str . +.pp +the +.br vfscanf () +function is analogous to +.br vfprintf (3) +and reads input from the stream pointer +.i stream +using a variable argument list of pointers (see +.br stdarg (3). +the +.br vscanf () +function scans a variable argument list from the standard input and the +.br vsscanf () +function scans it from a string; these are analogous to the +.br vprintf (3) +and +.br vsprintf (3) +functions respectively. +.pp +the +.i format +string consists of a sequence of +.i directives +which describe how to process the sequence of input characters. +if processing of a directive fails, no further input is read, and +.br scanf () +returns. +a "failure" can be either of the following: +.ir "input failure" , +meaning that input characters were unavailable, or +.ir "matching failure" , +meaning that the input was inappropriate (see below). +.pp +a directive is one of the following: +.tp +\(bu +a sequence of white-space characters (space, tab, newline, etc.; see +.br isspace (3)). +this directive matches any amount of white space, +including none, in the input. +.tp +\(bu +an ordinary character (i.e., one other than white space or \(aq%\(aq). +this character must exactly match the next character of input. +.tp +\(bu +a conversion specification, +which commences with a \(aq%\(aq (percent) character. +a sequence of characters from the input is converted according to +this specification, and the result is placed in the corresponding +.i pointer +argument. +if the next item of input does not match the conversion specification, +the conversion fails\(emthis is a +.ir "matching failure" . +.pp +each +.i conversion specification +in +.i format +begins with either the character \(aq%\(aq or the character sequence +"\fb%\fp\fin\fp\fb$\fp" +(see below for the distinction) followed by: +.tp +\(bu +an optional \(aq*\(aq assignment-suppression character: +.br scanf () +reads input as directed by the conversion specification, +but discards the input. +no corresponding +.i pointer +argument is required, and this specification is not +included in the count of successful assignments returned by +.br scanf (). +.tp +\(bu +for decimal conversions, an optional quote character (\(aq). +this specifies that the input number may include thousands' +separators as defined by the +.br lc_numeric +category of the current locale. +(see +.br setlocale (3).) +the quote character may precede or follow the \(aq*\(aq +assignment-suppression character. +.tp +\(bu +an optional \(aqm\(aq character. +this is used with string conversions +.ri ( %s , +.ir %c , +.ir %[ ), +and relieves the caller of the +need to allocate a corresponding buffer to hold the input: instead, +.br scanf () +allocates a buffer of sufficient size, +and assigns the address of this buffer to the corresponding +.i pointer +argument, which should be a pointer to a +.i "char\ *" +variable (this variable does not need to be initialized before the call). +the caller should subsequently +.br free (3) +this buffer when it is no longer required. +.tp +\(bu +an optional decimal integer which specifies the +.ir "maximum field width" . +reading of characters stops either when this maximum is reached or +when a nonmatching character is found, whichever happens first. +most conversions discard initial white space characters (the exceptions +are noted below), +and these discarded characters don't count toward the maximum field width. +string input conversions store a terminating null byte (\(aq\e0\(aq) +to mark the end of the input; +the maximum field width does not include this terminator. +.tp +\(bu +an optional +.ir "type modifier character" . +for example, the +.b l +type modifier is used with integer conversions such as +.b %d +to specify that the corresponding +.i pointer +argument refers to a +.i "long" +rather than a pointer to an +.ir int . +.tp +\(bu +a +.i "conversion specifier" +that specifies the type of input conversion to be performed. +.pp +the conversion specifications in +.i format +are of two forms, either beginning with \(aq%\(aq or beginning with +"\fb%\fp\fin\fp\fb$\fp". +the two forms should not be mixed in the same +.i format +string, except that a string containing +"\fb%\fp\fin\fp\fb$\fp" +specifications can include +.b %% +and +.br %* . +if +.i format +contains \(aq%\(aq +specifications, then these correspond in order with successive +.i pointer +arguments. +in the +"\fb%\fp\fin\fp\fb$\fp" +form (which is specified in posix.1-2001, but not c99), +.i n +is a decimal integer that specifies that the converted input should +be placed in the location referred to by the +.ir n -th +.i pointer +argument following +.ir format . +.ss conversions +the following +.i "type modifier characters" +can appear in a conversion specification: +.tp +.b h +indicates that the conversion will be one of +\fbd\fp, \fbi\fp, \fbo\fp, \fbu\fp, \fbx\fp, \fbx\fp, or \fbn\fp +and the next pointer is a pointer to a +.i short +or +.i unsigned short +(rather than +.ir int ). +.tp +.b hh +as for +.br h , +but the next pointer is a pointer to a +.i signed char +or +.ir "unsigned char" . +.tp +.b j +as for +.br h , +but the next pointer is a pointer to an +.i intmax_t +or a +.ir uintmax_t . +this modifier was introduced in c99. +.tp +.b l +indicates either that the conversion will be one of +\fbd\fp, \fbi\fp, \fbo\fp, \fbu\fp, \fbx\fp, \fbx\fp, or \fbn\fp +and the next pointer is a pointer to a +.i long +or +.i unsigned long +(rather than +.ir int ), +or that the conversion will be one of +\fbe\fp, \fbf\fp, or \fbg\fp +and the next pointer is a pointer to +.i double +(rather than +.ir float ). +specifying two +.b l +characters is equivalent to +.br l . +if used with +.b %c +or +.br %s , +the corresponding parameter is considered +as a pointer to a wide character or wide-character string respectively. +.\" this use of l was introduced in amendment 1 to iso c90. +.tp +.b l +indicates that the conversion will be either +\fbe\fp, \fbf\fp, or \fbg\fp +and the next pointer is a pointer to +.i "long double" +or the conversion will be +\fbd\fp, \fbi\fp, \fbo\fp, \fbu\fp, or \fbx\fp +and the next pointer is a pointer to +.ir "long long" . +.\" mtk, jul 05: the following is no longer true for modern +.\" ansi c (i.e., c99): +.\" (note that long long is not an +.\" ansi c +.\" type. any program using this will not be portable to all +.\" architectures). +.tp +.b q +equivalent to +.br l . +this specifier does not exist in ansi c. +.tp +.b t +as for +.br h , +but the next pointer is a pointer to a +.ir ptrdiff_t . +this modifier was introduced in c99. +.tp +.b z +as for +.br h , +but the next pointer is a pointer to a +.ir size_t . +this modifier was introduced in c99. +.pp +the following +.i "conversion specifiers" +are available: +.tp +.b % +matches a literal \(aq%\(aq. +that is, +.b %\&% +in the format string matches a +single input \(aq%\(aq character. +no conversion is done (but initial white space characters are discarded), +and assignment does not occur. +.tp +.b d +matches an optionally signed decimal integer; +the next pointer must be a pointer to +.ir int . +.\" .tp +.\" .b d +.\" equivalent to +.\" .ir ld ; +.\" this exists only for backward compatibility. +.\" (note: thus only in libc4 +.\" in libc5 and glibc the +.\" .b %d +.\" is silently ignored, causing old programs to fail mysteriously.) +.tp +.b i +matches an optionally signed integer; the next pointer must be a pointer to +.ir int . +the integer is read in base 16 if it begins with +.i 0x +or +.ir 0x , +in base 8 if it begins with +.ir 0 , +and in base 10 otherwise. +only characters that correspond to the base are used. +.tp +.b o +matches an unsigned octal integer; the next pointer must be a pointer to +.ir "unsigned int" . +.tp +.b u +matches an unsigned decimal integer; the next pointer must be a +pointer to +.ir "unsigned int" . +.tp +.b x +matches an unsigned hexadecimal integer +(that may optionally begin with a prefix of +.i 0x +or +.ir 0x , +which is discarded); the next pointer must +be a pointer to +.ir "unsigned int" . +.tp +.b x +equivalent to +.br x . +.tp +.b f +matches an optionally signed floating-point number; the next pointer must +be a pointer to +.ir float . +.tp +.b e +equivalent to +.br f . +.tp +.b g +equivalent to +.br f . +.tp +.b e +equivalent to +.br f . +.tp +.b a +(c99) equivalent to +.br f . +.tp +.b s +matches a sequence of non-white-space characters; +the next pointer must be a pointer to the initial element of a +character array that is long enough to hold the input sequence and +the terminating null byte (\(aq\e0\(aq), which is added automatically. +the input string stops at white space or at the maximum field +width, whichever occurs first. +.tp +.b c +matches a sequence of characters whose length is specified by the +.i maximum field width +(default 1); the next pointer must be a pointer to +.ir char , +and there must be enough room for all the characters +(no terminating null byte is added). +the usual skip of leading white space is suppressed. +to skip white space first, use an explicit space in the format. +.tp +.b \&[ +matches a nonempty sequence of characters from the specified set of +accepted characters; the next pointer must be a pointer to +.ir char , +and there must be enough room for all the characters in the string, plus a +terminating null byte. +the usual skip of leading white space is suppressed. +the string is to be made up of characters in (or not in) a particular set; +the set is defined by the characters between the open bracket +.b [ +character and a close bracket +.b ] +character. +the set +.i excludes +those characters if the first character after the open bracket is a +circumflex +.rb ( \(ha ). +to include a close bracket in the set, make it the first character after +the open bracket or the circumflex; any other position will end the set. +the hyphen character +.b \- +is also special; when placed between two other characters, it adds all +intervening characters to the set. +to include a hyphen, make it the last +character before the final close bracket. +for instance, +.b [\(ha]0\-9\-] +means +the set "everything except close bracket, zero through nine, and hyphen". +the string ends with the appearance of a character not in the (or, with a +circumflex, in) set or when the field width runs out. +.tp +.b p +matches a pointer value (as printed by +.b %p +in +.br printf (3)); +the next pointer must be a pointer to a pointer to +.ir void . +.tp +.b n +nothing is expected; instead, the number of characters consumed thus far +from the input is stored through the next pointer, which must be a pointer +to +.ir int , +or variant whose size matches the (optionally) +supplied integer length modifier. +this is +.i not +a conversion and does +.i not +increase the count returned by the function. +the assignment can be suppressed with the +.b * +assignment-suppression character, but the effect on the +return value is undefined. +therefore +.b %*n +conversions should not be used. +.sh return value +on success, these functions return the number of input items +successfully matched and assigned; +this can be fewer than provided for, +or even zero, in the event of an early matching failure. +.pp +the value +.b eof +is returned if the end of input is reached before either the first +successful conversion or a matching failure occurs. +.b eof +is also returned if a read error occurs, +in which case the error indicator for the stream (see +.br ferror (3)) +is set, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eagain +the file descriptor underlying +.i stream +is marked nonblocking, and the read operation would block. +.tp +.b ebadf +the file descriptor underlying +.i stream +is invalid, or not open for reading. +.tp +.b eilseq +input byte sequence does not form a valid character. +.tp +.b eintr +the read operation was interrupted by a signal; see +.br signal (7). +.tp +.b einval +not enough arguments; or +.i format +is null. +.tp +.b enomem +out of memory. +.tp +.b erange +the result of an integer conversion would exceed the size +that can be stored in the corresponding integer type. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br scanf (), +.br fscanf (), +.br sscanf (), +.br vscanf (), +.br vsscanf (), +.br vfscanf () +t} thread safety mt-safe locale +.te +.hy +.ad +.sp 1 +.sh conforming to +the functions +.br fscanf (), +.br scanf (), +and +.br sscanf () +conform to c89 and c99 and posix.1-2001. +these standards do not specify the +.b erange +error. +.pp +the +.b q +specifier is the 4.4bsd notation for +.ir "long long" , +while +.b ll +or the usage of +.b l +in integer conversions is the gnu notation. +.pp +the linux version of these functions is based on the +.i gnu +.i libio +library. +take a look at the +.i info +documentation of +.i gnu +.i libc (glibc-1.08) +for a more concise description. +.sh notes +.ss the 'a' assignment-allocation modifier +originally, the gnu c library supported dynamic allocation for string inputs +(as a nonstandard extension) via the +.b a +character. +(this feature is present at least as far back as glibc 2.0.) +thus, one could write the following to have +.br scanf () +allocate a buffer for an input string, +with a pointer to that buffer being returned in +.ir *buf : +.pp + char *buf; + scanf("%as", &buf); +.pp +the use of the letter +.b a +for this purpose was problematic, since +.b a +is also specified by the iso c standard as a synonym for +.b f +(floating-point input). +posix.1-2008 instead specifies the +.b m +modifier for assignment allocation (as documented in description, above). +.pp +note that the +.b a +modifier is not available if the program is compiled with +.i "gcc \-std=c99" +or +.ir "gcc \-d_isoc99_source" +(unless +.b _gnu_source +is also specified), in which case the +.b a +is interpreted as a specifier for floating-point numbers (see above). +.pp +support for the +.b m +modifier was added to glibc starting with version 2.7, +and new programs should use that modifier instead of +.br a . +.pp +as well as being standardized by posix, the +.b m +modifier has the following further advantages over +the use of +.br a: +.ip * 2 +it may also be applied to +.b %c +conversion specifiers (e.g., +.br %3mc ). +.ip * +it avoids ambiguity with respect to the +.b %a +floating-point conversion specifier (and is unaffected by +.ir "gcc \-std=c99" +etc.). +.sh bugs +all functions are fully c89 conformant, but provide the +additional specifiers +.b q +and +.b a +as well as an additional behavior of the +.b l +and +.b l +specifiers. +the latter may be considered to be a bug, as it changes the +behavior of specifiers defined in c89. +.pp +some combinations of the type modifiers and conversion +specifiers defined by ansi c do not make sense +(e.g., +.br "%ld" ). +while they may have a well-defined behavior on linux, this need not +to be so on other architectures. +therefore it usually is better to use +modifiers that are not defined by ansi c at all, that is, use +.b q +instead of +.b l +in combination with +\fbd\fp, \fbi\fp, \fbo\fp, \fbu\fp, \fbx\fp, and \fbx\fp +conversions or +.br ll . +.pp +the usage of +.b q +is not the same as on 4.4bsd, +as it may be used in float conversions equivalently to +.br l . +.sh examples +to use the dynamic allocation conversion specifier, specify +.b m +as a length modifier (thus +.b %ms +or +\fb%m[\fp\firange\fp\fb]\fp). +the caller must +.br free (3) +the returned string, as in the following example: +.pp +.in +4n +.ex +char *p; +int n; + +errno = 0; +n = scanf("%m[a\-z]", &p); +if (n == 1) { + printf("read: %s\en", p); + free(p); +} else if (errno != 0) { + perror("scanf"); +} else { + fprintf(stderr, "no matching characters\en"); +} +.ee +.in +.pp +as shown in the above example, it is necessary to call +.br free (3) +only if the +.br scanf () +call successfully read a string. +.sh see also +.br getc (3), +.br printf (3), +.br setlocale (3), +.br strtod (3), +.br strtol (3), +.br strtoul (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1993 rickard e. faith (faith@cs.unc.edu) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" historical remark, aeb, 2004-06-05 +.th getuid 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +getuid, geteuid \- get user identity +.sh synopsis +.nf +.b #include +.pp +.b uid_t getuid(void); +.b uid_t geteuid(void); +.fi +.sh description +.br getuid () +returns the real user id of the calling process. +.pp +.br geteuid () +returns the effective user id of the calling process. +.sh errors +these functions are always successful +and never modify +.\" https://www.austingroupbugs.net/view.php?id=511 +.\" 0000511: getuid and friends should not modify errno +.ir errno . +.sh conforming to +posix.1-2001, posix.1-2008, 4.3bsd. +.sh notes +.ss history +in unix\ v6 the +.br getuid () +call returned +.ir "(euid << 8) + uid" . +unix\ v7 introduced separate calls +.br getuid () +and +.br geteuid (). +.pp +the original linux +.br getuid () +and +.br geteuid () +system calls supported only 16-bit user ids. +subsequently, linux 2.4 added +.br getuid32 () +and +.br geteuid32 (), +supporting 32-bit ids. +the glibc +.br getuid () +and +.br geteuid () +wrapper functions transparently deal with the variations across kernel versions. +.pp +on alpha, instead of a pair of +.br getuid () +and +.br geteuid () +system calls, a single +.br getxuid () +system call is provided, which returns a pair of real and effective uids. +the glibc +.br getuid () +and +.br geteuid () +wrapper functions transparently deal with this. +see +.br syscall (2) +for details regarding register mapping. +.sh see also +.br getresuid (2), +.br setreuid (2), +.br setuid (2), +.br credentials (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/err.3 + +.so man2/sched_setparam.2 + +.\" copyright (c) 2008 linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th pthread_cleanup_push_defer_np 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +pthread_cleanup_push_defer_np, pthread_cleanup_pop_restore_np \- push and pop +thread cancellation clean-up handlers while saving cancelability type +.sh synopsis +.nf +.b #include +.pp +.bi "void pthread_cleanup_push_defer_np(void (*" routine ")(void *), void *" arg ); +.bi "void pthread_cleanup_pop_restore_np(int " execute ); +.fi +.pp +compile and link with \fi\-pthread\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br pthread_cleanup_push_defer_np (), +.br pthread_cleanup_pop_defer_np (): +.nf + _gnu_source +.fi +.sh description +these functions are the same as +.br pthread_cleanup_push (3) +and +.br pthread_cleanup_pop (3), +except for the differences noted on this page. +.pp +like +.br pthread_cleanup_push (3), +.br pthread_cleanup_push_defer_np () +pushes +.i routine +onto the thread's stack of cancellation clean-up handlers. +in addition, it also saves the thread's current cancelability type, +and sets the cancelability type to "deferred" (see +.br pthread_setcanceltype (3)); +this ensures that cancellation clean-up will occur +even if the thread's cancelability type was "asynchronous" +before the call. +.pp +like +.br pthread_cleanup_pop (3), +.br pthread_cleanup_pop_restore_np () +pops the top-most clean-up handler from the thread's +stack of cancellation clean-up handlers. +in addition, it restores the thread's cancelability +type to its value at the time of the matching +.br pthread_cleanup_push_defer_np (). +.pp +the caller must ensure that calls to these +functions are paired within the same function, +and at the same lexical nesting level. +other restrictions apply, as described in +.br pthread_cleanup_push (3). +.pp +this sequence of calls: +.pp +.in +4n +.ex +pthread_cleanup_push_defer_np(routine, arg); +pthread_cleanup_pop_restore_np(execute); +.ee +.in +.pp +is equivalent to (but shorter and more efficient than): +.pp +.\" as far as i can see, linuxthreads reverses the two substeps +.\" in the push and pop below. +.in +4n +.ex +int oldtype; + +pthread_cleanup_push(routine, arg); +pthread_setcanceltype(pthread_cancel_deferred, &oldtype); +\&... +pthread_setcanceltype(oldtype, null); +pthread_cleanup_pop(execute); +.ee +.in +.\" sh versions +.\" available since glibc 2.0 +.sh conforming to +these functions are nonstandard gnu extensions; +hence the suffix "_np" (nonportable) in the names. +.sh see also +.br pthread_cancel (3), +.br pthread_cleanup_push (3), +.br pthread_setcancelstate (3), +.br pthread_testcancel (3), +.br pthreads (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/fmax.3 + +.\" copyright (c) 2010 by michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th aio 7 2021-03-22 "linux" "linux programmer's manual" +.sh name +aio \- posix asynchronous i/o overview +.sh description +the posix asynchronous i/o (aio) interface allows applications +to initiate one or more i/o operations that are performed +asynchronously (i.e., in the background). +the application can elect to be notified of completion of +the i/o operation in a variety of ways: +by delivery of a signal, by instantiation of a thread, +or no notification at all. +.pp +the posix aio interface consists of the following functions: +.tp +.br aio_read (3) +enqueue a read request. +this is the asynchronous analog of +.br read (2). +.tp +.br aio_write (3) +enqueue a write request. +this is the asynchronous analog of +.br write (2). +.tp +.br aio_fsync (3) +enqueue a sync request for the i/o operations on a file descriptor. +this is the asynchronous analog of +.br fsync (2) +and +.br fdatasync (2). +.tp +.br aio_error (3) +obtain the error status of an enqueued i/o request. +.tp +.br aio_return (3) +obtain the return status of a completed i/o request. +.tp +.br aio_suspend (3) +suspend the caller until one or more of a specified set of +i/o requests completes. +.tp +.br aio_cancel (3) +attempt to cancel outstanding i/o requests on a specified +file descriptor. +.tp +.br lio_listio (3) +enqueue multiple i/o requests using a single function call. +.pp +the +.i aiocb +("asynchronous i/o control block") structure defines +parameters that control an i/o operation. +an argument of this type is employed with all of the functions listed above. +this structure has the following form: +.pp +.in +4n +.ex +#include + +struct aiocb { + /* the order of these fields is implementation\-dependent */ + + int aio_fildes; /* file descriptor */ + off_t aio_offset; /* file offset */ + volatile void *aio_buf; /* location of buffer */ + size_t aio_nbytes; /* length of transfer */ + int aio_reqprio; /* request priority */ + struct sigevent aio_sigevent; /* notification method */ + int aio_lio_opcode; /* operation to be performed; + lio_listio() only */ + + /* various implementation\-internal fields not shown */ +}; + +/* operation codes for \(aqaio_lio_opcode\(aq: */ + +enum { lio_read, lio_write, lio_nop }; +.ee +.in +.pp +the fields of this structure are as follows: +.tp +.i aio_fildes +the file descriptor on which the i/o operation is to be performed. +.tp +.i aio_offset +this is the file offset at which the i/o operation is to be performed. +.tp +.i aio_buf +this is the buffer used to transfer data for a read or write operation. +.tp +.i aio_nbytes +this is the size of the buffer pointed to by +.ir aio_buf . +.tp +.i aio_reqprio +this field specifies a value that is subtracted +from the calling thread's real-time priority in order to +determine the priority for execution of this i/o request (see +.br pthread_setschedparam (3)). +the specified value must be between 0 and the value returned by +.ir sysconf(_sc_aio_prio_delta_max) . +this field is ignored for file synchronization operations. +.tp +.i aio_sigevent +this field is a structure that specifies how the caller is +to be notified when the asynchronous i/o operation completes. +possible values for +.ir aio_sigevent.sigev_notify +are +.br sigev_none , +.br sigev_signal , +and +.br sigev_thread . +see +.br sigevent (7) +for further details. +.tp +.i aio_lio_opcode +the type of operation to be performed; used only for +.br lio_listio (3). +.pp +in addition to the standard functions listed above, +the gnu c library provides the following extension to the posix aio api: +.tp +.br aio_init (3) +set parameters for tuning the behavior of the glibc posix aio implementation. +.sh errors +.tp +.b einval +the +.i aio_reqprio +field of the +.i aiocb +structure was less than 0, +or was greater than the limit returned by the call +.ir sysconf(_sc_aio_prio_delta_max) . +.sh versions +the posix aio interfaces are provided by glibc since version 2.1. +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +it is a good idea to zero out the control block buffer before use (see +.br memset (3)). +the control block buffer and the buffer pointed to by +.i aio_buf +must not be changed while the i/o operation is in progress. +these buffers must remain valid until the i/o operation completes. +.pp +simultaneous asynchronous read or write operations using the same +.i aiocb +structure yield undefined results. +.pp +the current linux posix aio implementation is provided in user space by glibc. +this has a number of limitations, most notably that maintaining multiple +threads to perform i/o operations is expensive and scales poorly. +work has been in progress for some time on a kernel +state-machine-based implementation of asynchronous i/o +(see +.br io_submit (2), +.br io_setup (2), +.br io_cancel (2), +.br io_destroy (2), +.br io_getevents (2)), +but this implementation hasn't yet matured to the point where +the posix aio implementation can be completely +reimplemented using the kernel system calls. +.\" http://lse.sourceforge.net/io/aio.html +.\" http://lse.sourceforge.net/io/aionotes.txt +.\" http://lwn.net/articles/148755/ +.sh examples +the program below opens each of the files named in its command-line +arguments and queues a request on the resulting file descriptor using +.br aio_read (3). +the program then loops, +periodically monitoring each of the i/o operations +that is still in progress using +.br aio_error (3). +each of the i/o requests is set up to provide notification by delivery +of a signal. +after all i/o requests have completed, +the program retrieves their status using +.br aio_return (3). +.pp +the +.b sigquit +signal (generated by typing control-\e) causes the program to request +cancellation of each of the outstanding requests using +.br aio_cancel (3). +.pp +here is an example of what we might see when running this program. +in this example, the program queues two requests to standard input, +and these are satisfied by two lines of input containing +"abc" and "x". +.pp +.in +4n +.ex +$ \fb./a.out /dev/stdin /dev/stdin\fp +opened /dev/stdin on descriptor 3 +opened /dev/stdin on descriptor 4 +aio_error(): + for request 0 (descriptor 3): in progress + for request 1 (descriptor 4): in progress +\fbabc\fp +i/o completion signal received +aio_error(): + for request 0 (descriptor 3): i/o succeeded + for request 1 (descriptor 4): in progress +aio_error(): + for request 1 (descriptor 4): in progress +\fbx\fp +i/o completion signal received +aio_error(): + for request 1 (descriptor 4): i/o succeeded +all i/o requests completed +aio_return(): + for request 0 (descriptor 3): 4 + for request 1 (descriptor 4): 2 +.ee +.in +.ss program source +\& +.ex +#include +#include +#include +#include +#include +#include +#include + +#define buf_size 20 /* size of buffers for read operations */ + +#define errexit(msg) do { perror(msg); exit(exit_failure); } while (0) + +struct iorequest { /* application\-defined structure for tracking + i/o requests */ + int reqnum; + int status; + struct aiocb *aiocbp; +}; + +static volatile sig_atomic_t gotsigquit = 0; + /* on delivery of sigquit, we attempt to + cancel all outstanding i/o requests */ + +static void /* handler for sigquit */ +quithandler(int sig) +{ + gotsigquit = 1; +} + +#define io_signal sigusr1 /* signal used to notify i/o completion */ + +static void /* handler for i/o completion signal */ +aiosighandler(int sig, siginfo_t *si, void *ucontext) +{ + if (si\->si_code == si_asyncio) { + write(stdout_fileno, "i/o completion signal received\en", 31); + + /* the corresponding iorequest structure would be available as + struct iorequest *ioreq = si\->si_value.sival_ptr; + and the file descriptor would then be available via + ioreq\->aiocbp\->aio_fildes */ + } +} + +int +main(int argc, char *argv[]) +{ + struct sigaction sa; + int s; + int numreqs; /* total number of queued i/o requests */ + int openreqs; /* number of i/o requests still in progress */ + + if (argc < 2) { + fprintf(stderr, "usage: %s ...\en", + argv[0]); + exit(exit_failure); + } + + numreqs = argc \- 1; + + /* allocate our arrays. */ + + struct iorequest *iolist = calloc(numreqs, sizeof(*iolist)); + if (iolist == null) + errexit("calloc"); + + struct aiocb *aiocblist = calloc(numreqs, sizeof(*aiocblist)); + if (aiocblist == null) + errexit("calloc"); + + /* establish handlers for sigquit and the i/o completion signal. */ + + sa.sa_flags = sa_restart; + sigemptyset(&sa.sa_mask); + + sa.sa_handler = quithandler; + if (sigaction(sigquit, &sa, null) == \-1) + errexit("sigaction"); + + sa.sa_flags = sa_restart | sa_siginfo; + sa.sa_sigaction = aiosighandler; + if (sigaction(io_signal, &sa, null) == \-1) + errexit("sigaction"); + + /* open each file specified on the command line, and queue + a read request on the resulting file descriptor. */ + + for (int j = 0; j < numreqs; j++) { + iolist[j].reqnum = j; + iolist[j].status = einprogress; + iolist[j].aiocbp = &aiocblist[j]; + + iolist[j].aiocbp\->aio_fildes = open(argv[j + 1], o_rdonly); + if (iolist[j].aiocbp\->aio_fildes == \-1) + errexit("open"); + printf("opened %s on descriptor %d\en", argv[j + 1], + iolist[j].aiocbp\->aio_fildes); + + iolist[j].aiocbp\->aio_buf = malloc(buf_size); + if (iolist[j].aiocbp\->aio_buf == null) + errexit("malloc"); + + iolist[j].aiocbp\->aio_nbytes = buf_size; + iolist[j].aiocbp\->aio_reqprio = 0; + iolist[j].aiocbp\->aio_offset = 0; + iolist[j].aiocbp\->aio_sigevent.sigev_notify = sigev_signal; + iolist[j].aiocbp\->aio_sigevent.sigev_signo = io_signal; + iolist[j].aiocbp\->aio_sigevent.sigev_value.sival_ptr = + &iolist[j]; + + s = aio_read(iolist[j].aiocbp); + if (s == \-1) + errexit("aio_read"); + } + + openreqs = numreqs; + + /* loop, monitoring status of i/o requests. */ + + while (openreqs > 0) { + sleep(3); /* delay between each monitoring step */ + + if (gotsigquit) { + + /* on receipt of sigquit, attempt to cancel each of the + outstanding i/o requests, and display status returned + from the cancellation requests. */ + + printf("got sigquit; canceling i/o requests: \en"); + + for (int j = 0; j < numreqs; j++) { + if (iolist[j].status == einprogress) { + printf(" request %d on descriptor %d:", j, + iolist[j].aiocbp\->aio_fildes); + s = aio_cancel(iolist[j].aiocbp\->aio_fildes, + iolist[j].aiocbp); + if (s == aio_canceled) + printf("i/o canceled\en"); + else if (s == aio_notcanceled) + printf("i/o not canceled\en"); + else if (s == aio_alldone) + printf("i/o all done\en"); + else + perror("aio_cancel"); + } + } + + gotsigquit = 0; + } + + /* check the status of each i/o request that is still + in progress. */ + + printf("aio_error():\en"); + for (int j = 0; j < numreqs; j++) { + if (iolist[j].status == einprogress) { + printf(" for request %d (descriptor %d): ", + j, iolist[j].aiocbp\->aio_fildes); + iolist[j].status = aio_error(iolist[j].aiocbp); + + switch (iolist[j].status) { + case 0: + printf("i/o succeeded\en"); + break; + case einprogress: + printf("in progress\en"); + break; + case ecanceled: + printf("canceled\en"); + break; + default: + perror("aio_error"); + break; + } + + if (iolist[j].status != einprogress) + openreqs\-\-; + } + } + } + + printf("all i/o requests completed\en"); + + /* check status return of all i/o requests. */ + + printf("aio_return():\en"); + for (int j = 0; j < numreqs; j++) { + ssize_t s; + + s = aio_return(iolist[j].aiocbp); + printf(" for request %d (descriptor %d): %zd\en", + j, iolist[j].aiocbp\->aio_fildes, s); + } + + exit(exit_success); +} +.ee +.sh see also +.ad l +.nh +.br io_cancel (2), +.br io_destroy (2), +.br io_getevents (2), +.br io_setup (2), +.br io_submit (2), +.br aio_cancel (3), +.br aio_error (3), +.br aio_init (3), +.br aio_read (3), +.br aio_return (3), +.br aio_write (3), +.br lio_listio (3) +.pp +"asynchronous i/o support in linux 2.5", +bhattacharya, pratt, pulavarty, and morgan, +proceedings of the linux symposium, 2003, +.ur https://www.kernel.org/doc/ols/2003/ols2003\-pages\-351\-366.pdf +.ue +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1993 by thomas koenig (ig25@rz.uni-karlsruhe.de) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified wed jul 28 11:12:07 1993 by rik faith (faith@cs.unc.edu) +.\" modified fri sep 8 15:48:13 1995 by andries brouwer (aeb@cwi.nl) +.th fgetc 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +fgetc, fgets, getc, getchar, ungetc \- input of characters and strings +.sh synopsis +.nf +.b #include +.pp +.bi "int fgetc(file *" stream ); +.bi "int getc(file *" stream ); +.b "int getchar(void);" +.pp +.bi "char *fgets(char *restrict " s ", int " size ", file *restrict " stream ); +.pp +.bi "int ungetc(int " c ", file *" stream ); +.fi +.sh description +.br fgetc () +reads the next character from +.i stream +and returns it as an +.i unsigned char +cast to an +.ir int , +or +.b eof +on end of file or error. +.pp +.br getc () +is equivalent to +.br fgetc () +except that it may be implemented as a macro which evaluates +.i stream +more than once. +.pp +.br getchar () +is equivalent to +.bi "getc(" stdin ) \fr. +.pp +.br fgets () +reads in at most one less than +.i size +characters from +.i stream +and stores them into the buffer pointed to by +.ir s . +reading stops after an +.b eof +or a newline. +if a newline is read, it is stored into the buffer. +a terminating null byte (\(aq\e0\(aq) +is stored after the last character in the buffer. +.pp +.br ungetc () +pushes +.i c +back to +.ir stream , +cast to +.ir "unsigned char" , +where it is available for subsequent read operations. +pushed-back characters +will be returned in reverse order; only one pushback is guaranteed. +.pp +calls to the functions described here can be mixed with each other and with +calls to other input functions from the +.i stdio +library for the same input stream. +.pp +for nonlocking counterparts, see +.br unlocked_stdio (3). +.sh return value +.br fgetc (), +.br getc (), +and +.br getchar () +return the character read as an +.i unsigned char +cast to an +.i int +or +.b eof +on end of file or error. +.pp +.br fgets () +returns +.i s +on success, and null +on error or when end of file occurs while no characters have been read. +.pp +.br ungetc () +returns +.i c +on success, or +.b eof +on error. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br fgetc (), +.br fgets (), +.br getc (), +.br getchar (), +.br ungetc () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c89, c99. +.pp +it is not advisable to mix calls to input functions from the +.i stdio +library with low-level calls to +.br read (2) +for the file descriptor associated with the input stream; the results +will be undefined and very probably not what you want. +.sh see also +.br read (2), +.br write (2), +.br ferror (3), +.br fgetwc (3), +.br fgetws (3), +.br fopen (3), +.br fread (3), +.br fseek (3), +.br getline (3), +.br gets (3), +.br getwchar (3), +.br puts (3), +.br scanf (3), +.br ungetwc (3), +.br unlocked_stdio (3), +.br feature_test_macros (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/floor.3 + +.so man3/cpu_set.3 + +.\" copyright (c) 1995 andries brouwer (aeb@cwi.nl) +.\" and copyright (c) 2012, 2014 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" written 11 june 1995 by andries brouwer +.\" 2008-02-15, jeremy kerr +.\" add info on command type 10; add details on types 6, 7, 8, & 9. +.\" 2008-02-15, michael kerrisk +.\" update log_buf_len details; update return value section. +.\" +.th syslog 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +syslog, klogctl \- read and/or clear kernel message ring buffer; +set console_loglevel +.sh synopsis +.nf +.br "#include " " /* definition of " syslog_* " constants */" +.br "#include " " /* definition of " sys_* " constants */" +.b #include +.pp +.bi "int syscall(sys_syslog, int " type ", char *" bufp ", int " len ); +.pp +/* the glibc interface */ +.b #include +.pp +.bi "int klogctl(int " type ", char *" bufp ", int " len ); +.fi +.sh description +.ir note : +probably, you are looking for the c library function +.br syslog (), +which talks to +.br syslogd (8); +see +.br syslog (3) +for details. +.pp +this page describes the kernel +.br syslog () +system call, which is used to control the kernel +.ir printk () +buffer; the glibc wrapper function for the system call is called +.br klogctl (). +.ss the kernel log buffer +the kernel has a cyclic buffer of length +.b log_buf_len +in which messages given as arguments to the kernel function +.br printk () +are stored (regardless of their log level). +in early kernels, +.b log_buf_len +had the value 4096; +from kernel 1.3.54, it was 8192; +from kernel 2.1.113, it was 16384; +since kernel 2.4.23/2.6, the value is a kernel configuration option +.rb ( config_log_buf_shift , +default value dependent on the architecture). +.\" under "general setup" ==> "kernel log buffer size" +.\" for 2.6, precisely the option seems to have appeared in 2.5.55. +since linux 2.6.6, the size can be queried with command type 10 (see below). +.ss commands +the \fitype\fp argument determines the action taken by this function. +the list below specifies the values for +.ir type . +the symbolic names are defined in the kernel source, +but are not exported to user space; +you will either need to use the numbers, or define the names yourself. +.tp +.br syslog_action_close " (0)" +close the log. +currently a nop. +.tp +.br syslog_action_open " (1)" +open the log. +currently a nop. +.tp +.br syslog_action_read " (2)" +read from the log. +the call +waits until the kernel log buffer is nonempty, and then reads +at most \filen\fp bytes into the buffer pointed to by +.ir bufp . +the call returns the number of bytes read. +bytes read from the log disappear from the log buffer: +the information can be read only once. +this is the function executed by the kernel when a user program reads +.ir /proc/kmsg . +.tp +.br syslog_action_read_all " (3)" +read all messages remaining in the ring buffer, +placing them in the buffer pointed to by +.ir bufp . +the call reads the last \filen\fp +bytes from the log buffer (nondestructively), +but will not read more than was written into the buffer since the +last "clear ring buffer" command (see command 5 below)). +the call returns the number of bytes read. +.tp +.br syslog_action_read_clear " (4)" +read and clear all messages remaining in the ring buffer. +the call does precisely the same as for a +.i type +of 3, but also executes the "clear ring buffer" command. +.tp +.br syslog_action_clear " (5)" +the call executes just the "clear ring buffer" command. +the +.i bufp +and +.i len +arguments are ignored. +.ip +this command does not really clear the ring buffer. +rather, it sets a kernel bookkeeping variable that +determines the results returned by commands 3 +.rb ( syslog_action_read_all ) +and 4 +.rb ( syslog_action_read_clear ). +this command has no effect on commands 2 +.rb ( syslog_action_read ) +and 9 +.rb ( syslog_action_size_unread ). +.tp +.br syslog_action_console_off " (6)" +the command saves the current value of +.i console_loglevel +and then sets +.i console_loglevel +to +.ir minimum_console_loglevel , +so that no messages are printed to the console. +before linux 2.6.32, +.\" commit 1aaad49e856ce41adc07d8ae0c8ef35fc4483245 +the command simply sets +.i console_loglevel +to +.ir minimum_console_loglevel . +see the discussion of +.ir /proc/sys/kernel/printk , +below. +.ip +the +.i bufp +and +.i len +arguments are ignored. +.tp +.br syslog_action_console_on " (7)" +if a previous +.b syslog_action_console_off +command has been performed, +this command restores +.i console_loglevel +to the value that was saved by that command. +before linux 2.6.32, +.\" commit 1aaad49e856ce41adc07d8ae0c8ef35fc4483245 +this command simply sets +.i console_loglevel +to +.ir default_console_loglevel . +see the discussion of +.ir /proc/sys/kernel/printk , +below. +.ip +the +.i bufp +and +.i len +arguments are ignored. +.tp +.br syslog_action_console_level " (8)" +the call sets +.i console_loglevel +to the value given in +.ir len , +which must be an integer between 1 and 8 (inclusive). +the kernel silently enforces a minimum value of +.ir minimum_console_loglevel +for +.ir len . +see the +.ir "log level" +section for details. +the +.i bufp +argument is ignored. +.tp +.br syslog_action_size_unread " (9) (since linux 2.4.10)" +the call +returns the number of bytes currently available to be read +from the kernel log buffer via command 2 +.rb ( syslog_action_read ). +the +.i bufp +and +.i len +arguments are ignored. +.tp +.br syslog_action_size_buffer " (10) (since linux 2.6.6)" +this command returns the total size of the kernel log buffer. +the +.i bufp +and +.i len +arguments are ignored. +.pp +all commands except 3 and 10 require privilege. +in linux kernels before 2.6.37, +command types 3 and 10 are allowed to unprivileged processes; +since linux 2.6.37, +these commands are allowed to unprivileged processes only if +.ir /proc/sys/kernel/dmesg_restrict +has the value 0. +before linux 2.6.37, "privileged" means that the caller has the +.br cap_sys_admin +capability. +since linux 2.6.37, +"privileged" means that the caller has either the +.br cap_sys_admin +capability (now deprecated for this purpose) or the (new) +.br cap_syslog +capability. +.\" +.\" +.ss /proc/sys/kernel/printk +.i /proc/sys/kernel/printk +is a writable file containing four integer values that influence kernel +.i printk() +behavior when printing or logging error messages. +the four values are: +.tp +.i console_loglevel +only messages with a log level lower than this value will +be printed to the console. +the default value for this field is +.b default_console_loglevel +(7), but it is set to +4 if the kernel command line contains the word "quiet",\" since linux 2.4 +10 if the kernel command line contains the word "debug", +and to 15 in case +of a kernel fault (the 10 and 15 are just silly, and equivalent to 8). +the value of +.ir console_loglevel +can be set (to a value in the range 1\(en8) by a +.br syslog () +call with a +.i type +of 8. +.tp +.i default_message_loglevel +this value will be used as the log level for +.ir printk() +messages that do not have an explicit level. +up to and including linux 2.6.38, +the hard-coded default value for this field was 4 +.rb ( kern_warning ); +since linux 2.6.39, +.\" commit 5af5bcb8d37f99ba415a1adc6da71051b84f93a5 +the default value is a defined by the kernel configuration option +.br config_default_message_loglevel , +which defaults to 4. +.tp +.i minimum_console_loglevel +the value in this field is the minimum value to which +.i console_loglevel +can be set. +.tp +.i default_console_loglevel +this is the default value for +.ir console_loglevel . +.\" +.\" +.ss the log level +every +.ir printk () +message has its own log level. +if the log level is not explicitly specified as part of the message, +it defaults to +.ir default_message_loglevel . +the conventional meaning of the log level is as follows: +.ts +lb lb lb +lb c l. +kernel constant level value meaning +kern_emerg 0 system is unusable +kern_alert 1 t{ +action must be taken immediately +t} +kern_crit 2 critical conditions +kern_err 3 error conditions +kern_warning 4 warning conditions +kern_notice 5 t{ +normal but significant condition +t} +kern_info 6 informational +kern_debug 7 debug-level messages +.te +.sp 1 +the kernel +.ir printk() +routine will print a message on the +console only if it has a log level less than the value of +.ir console_loglevel . +.sh return value +for \fitype\fp equal to 2, 3, or 4, a successful call to +.br syslog () +returns the number +of bytes read. +for \fitype\fp 9, +.br syslog () +returns the number of bytes currently +available to be read on the kernel log buffer. +for \fitype\fp 10, +.br syslog () +returns the total size of the kernel log buffer. +for other values of \fitype\fp, 0 is returned on success. +.pp +in case of error, \-1 is returned, +and \fierrno\fp is set to indicate the error. +.sh errors +.tp +.b einval +bad arguments (e.g., +bad +.ir type ; +or for +.i type +2, 3, or 4, +.i buf +is null, +or +.i len +is less than zero; or for +.i type +8, the +.i level +is outside the range 1 to 8). +.tp +.b enosys +this +.br syslog () +system call is not available, because the kernel was compiled with the +.br config_printk +kernel-configuration option disabled. +.tp +.b eperm +an attempt was made to change +.i console_loglevel +or clear the kernel +message ring buffer by a process without sufficient privilege +(more precisely: without the +.b cap_sys_admin +or +.br cap_syslog +capability). +.tp +.b erestartsys +system call was interrupted by a signal; nothing was read. +(this can be seen only during a trace.) +.sh conforming to +this system call is linux-specific and should not be used in programs +intended to be portable. +.sh notes +from the very start, people noted that it is unfortunate that +a system call and a library routine of the same name are entirely +different animals. +.\" in libc4 and libc5 the number of this call was defined by +.\" .br sys_klog . +.\" in glibc 2.0 the syscall is baptized +.\" .br klogctl (). +.sh see also +.br dmesg (1), +.br syslog (3), +.br capabilities (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" this man page is copyright (c) 1999 andi kleen . +.\" +.\" %%%license_start(verbatim_one_para) +.\" permission is granted to distribute possibly modified copies +.\" of this page provided the header is included verbatim, +.\" and in case of nontrivial modification author and date +.\" of the modification is added to the header. +.\" %%%license_end +.\" +.\" $id: netdevice.7,v 1.10 2000/08/17 10:09:54 ak exp $ +.\" +.\" modified, 2004-11-25, mtk, formatting and a few wording fixes +.\" +.\" modified, 2011-11-02, , added many basic +.\" but missing ioctls, such as siocgifaddr. +.\" +.th netdevice 7 2021-03-22 "linux" "linux programmer's manual" +.sh name +netdevice \- low-level access to linux network devices +.sh synopsis +.nf +.b "#include " +.b "#include " +.fi +.sh description +this man page describes the sockets interface which is used to configure +network devices. +.pp +linux supports some standard ioctls to configure network devices. +they can be used on any socket's file descriptor regardless of the +family or type. +most of them pass an +.i ifreq +structure: +.pp +.in +4n +.ex +struct ifreq { + char ifr_name[ifnamsiz]; /* interface name */ + union { + struct sockaddr ifr_addr; + struct sockaddr ifr_dstaddr; + struct sockaddr ifr_broadaddr; + struct sockaddr ifr_netmask; + struct sockaddr ifr_hwaddr; + short ifr_flags; + int ifr_ifindex; + int ifr_metric; + int ifr_mtu; + struct ifmap ifr_map; + char ifr_slave[ifnamsiz]; + char ifr_newname[ifnamsiz]; + char *ifr_data; + }; +}; +.ee +.in +.pp +.b af_inet6 +is an exception. +it passes an +.i in6_ifreq +structure: +.pp +.in +4n +.ex +struct in6_ifreq { + struct in6_addr ifr6_addr; + u32 ifr6_prefixlen; + int ifr6_ifindex; /* interface index */ +}; +.ee +.in +.pp +normally, the user specifies which device to affect by setting +.i ifr_name +to the name of the interface or +.i ifr6_ifindex +to the index of the interface. +all other members of the structure may +share memory. +.ss ioctls +if an ioctl is marked as privileged, then using it requires an effective +user id of 0 or the +.b cap_net_admin +capability. +if this is not the case, +.b eperm +will be returned. +.tp +.b siocgifname +given the +.ir ifr_ifindex , +return the name of the interface in +.ir ifr_name . +this is the only ioctl which returns its result in +.ir ifr_name . +.tp +.b siocgifindex +retrieve the interface index of the interface into +.ir ifr_ifindex . +.tp +.br siocgifflags ", " siocsifflags +get or set the active flag word of the device. +.i ifr_flags +contains a bit mask of the following values: +.\" do not right adjust text blocks in tables +.na +.ts +tab(:); +c s +l l. +device flags +iff_up:interface is running. +iff_broadcast:valid broadcast address set. +iff_debug:internal debugging flag. +iff_loopback:interface is a loopback interface. +iff_pointopoint:interface is a point-to-point link. +iff_running:resources allocated. +iff_noarp:t{ +no arp protocol, l2 destination address not set. +t} +iff_promisc:interface is in promiscuous mode. +iff_notrailers:avoid use of trailers. +iff_allmulti:receive all multicast packets. +iff_master:master of a load balancing bundle. +iff_slave:slave of a load balancing bundle. +iff_multicast:supports multicast +iff_portsel:is able to select media type via ifmap. +iff_automedia:auto media selection active. +iff_dynamic:t{ +the addresses are lost when the interface goes down. +t} +iff_lower_up:driver signals l1 up (since linux 2.6.17) +iff_dormant:driver signals dormant (since linux 2.6.17) +iff_echo:echo sent packets (since linux 2.6.25) +.te +.ad +.pp +setting the active flag word is a privileged operation, but any +process may read it. +.tp +.br siocgifpflags ", " siocsifpflags +get or set extended (private) flags for the device. +.i ifr_flags +contains a bit mask of the following values: +.ts +tab(:); +c s +l l. +private flags +iff_802_1q_vlan:interface is 802.1q vlan device. +iff_ebridge:interface is ethernet bridging device. +iff_slave_inactive:interface is inactive bonding slave. +iff_master_8023ad:interface is 802.3ad bonding master. +iff_master_alb:interface is balanced-alb bonding master. +iff_bonding:interface is a bonding master or slave. +iff_slave_needarp:interface needs arps for validation. +iff_isatap:interface is rfc4214 isatap interface. +.te +.pp +setting the extended (private) interface flags is a privileged operation. +.tp +.br siocgifaddr ", " siocsifaddr ", " siocdifaddr +get, set, or delete the address of the device using +.ir ifr_addr , +or +.i ifr6_addr +with +.ir ifr6_prefixlen . +setting or deleting the interface address is a privileged operation. +for compatibility, +.b siocgifaddr +returns only +.b af_inet +addresses, +.b siocsifaddr +accepts +.b af_inet +and +.b af_inet6 +addresses, and +.b siocdifaddr +deletes only +.b af_inet6 +addresses. +a +.b af_inet +address can be deleted by setting it to zero via +.br siocsifaddr . +.tp +.br siocgifdstaddr ", " siocsifdstaddr +get or set the destination address of a point-to-point device using +.ir ifr_dstaddr . +for compatibility, only +.b af_inet +addresses are accepted or returned. +setting the destination address is a privileged operation. +.tp +.br siocgifbrdaddr ", " siocsifbrdaddr +get or set the broadcast address for a device using +.ir ifr_brdaddr . +for compatibility, only +.b af_inet +addresses are accepted or returned. +setting the broadcast address is a privileged operation. +.tp +.br siocgifnetmask ", " siocsifnetmask +get or set the network mask for a device using +.ir ifr_netmask . +for compatibility, only +.b af_inet +addresses are accepted or returned. +setting the network mask is a privileged operation. +.tp +.br siocgifmetric ", " siocsifmetric +get or set the metric of the device using +.ir ifr_metric . +this is currently not implemented; it sets +.i ifr_metric +to 0 if you attempt to read it and returns +.b eopnotsupp +if you attempt to set it. +.tp +.br siocgifmtu ", " siocsifmtu +get or set the mtu (maximum transfer unit) of a device using +.ir ifr_mtu . +setting the mtu is a privileged operation. +setting the mtu to +too small values may cause kernel crashes. +.tp +.br siocgifhwaddr ", " siocsifhwaddr +get or set the hardware address of a device using +.ir ifr_hwaddr . +the hardware address is specified in a struct +.ir sockaddr . +.i sa_family +contains the arphrd_* device type, +.i sa_data +the l2 hardware address starting from byte 0. +setting the hardware address is a privileged operation. +.tp +.b siocsifhwbroadcast +set the hardware broadcast address of a device from +.ir ifr_hwaddr . +this is a privileged operation. +.tp +.br siocgifmap ", " siocsifmap +get or set the interface's hardware parameters using +.ir ifr_map . +setting the parameters is a privileged operation. +.ip +.in +4n +.ex +struct ifmap { + unsigned long mem_start; + unsigned long mem_end; + unsigned short base_addr; + unsigned char irq; + unsigned char dma; + unsigned char port; +}; +.ee +.in +.ip +the interpretation of the ifmap structure depends on the device driver +and the architecture. +.tp +.br siocaddmulti ", " siocdelmulti +add an address to or delete an address from the device's link layer +multicast filters using +.ir ifr_hwaddr . +these are privileged operations. +see also +.br packet (7) +for an alternative. +.tp +.br siocgiftxqlen ", " siocsiftxqlen +get or set the transmit queue length of a device using +.ir ifr_qlen . +setting the transmit queue length is a privileged operation. +.tp +.b siocsifname +changes the name of the interface specified in +.i ifr_name +to +.ir ifr_newname . +this is a privileged operation. +it is allowed only when the interface +is not up. +.tp +.b siocgifconf +return a list of interface (network layer) addresses. +this currently +means only addresses of the +.b af_inet +(ipv4) family for compatibility. +unlike the others, this ioctl passes an +.i ifconf +structure: +.ip +.in +4n +.ex +struct ifconf { + int ifc_len; /* size of buffer */ + union { + char *ifc_buf; /* buffer address */ + struct ifreq *ifc_req; /* array of structures */ + }; +}; +.ee +.in +.ip +if +.i ifc_req +is null, +.b siocgifconf +returns the necessary buffer size in bytes +for receiving all available addresses in +.ir ifc_len . +otherwise, +.i ifc_req +contains a pointer to an array of +.i ifreq +structures to be filled with all currently active l3 interface addresses. +.i ifc_len +contains the size of the array in bytes. +within each +.i ifreq +structure, +.i ifr_name +will receive the interface name, and +.i ifr_addr +the address. +the actual number of bytes transferred is returned in +.ir ifc_len . +.ip +if the size specified by +.i ifc_len +is insufficient to store all the addresses, +the kernel will skip the exceeding ones and return success. +there is no reliable way of detecting this condition once it has occurred. +it is therefore recommended to either determine the necessary buffer size +beforehand by calling +.b siocgifconf +with +.i ifc_req +set to null, or to retry the call with a bigger buffer whenever +.i ifc_len +upon return differs by less than +.i sizeof(struct ifreq) +from its original value. +.ip +if an error occurs accessing the +.i ifconf +or +.i ifreq +structures, +.b efault +will be returned. +.\" slaving isn't supported in 2.2 +.\" . +.\" .tp +.\" .br siocgifslave ", " siocsifslave +.\" get or set the slave device using +.\" .ir ifr_slave . +.\" setting the slave device is a privileged operation. +.\" .pp +.\" fixme . add amateur radio stuff. +.pp +most protocols support their own ioctls to configure protocol-specific +interface options. +see the protocol man pages for a description. +for configuring ip addresses, see +.br ip (7). +.pp +in addition, some devices support private ioctls. +these are not described here. +.sh notes +.b siocgifconf +and the other ioctls that accept or return only +.b af_inet +socket addresses +are ip-specific and perhaps should rather be documented in +.br ip (7). +.pp +the names of interfaces with no addresses or that don't have the +.b iff_running +flag set can be found via +.ir /proc/net/dev . +.pp +.b af_inet6 +ipv6 addresses can be read from +.i /proc/net/if_inet6 +or via +.br rtnetlink (7). +adding a new ipv6 address and deleting an existing ipv6 address +can be done via +.b siocsifaddr +and +.b siocdifaddr +or via +.br rtnetlink (7). +retrieving or changing destination ipv6 addresses of a point-to-point +interface is possible only via +.br rtnetlink (7). +.sh bugs +glibc 2.1 is missing the +.i ifr_newname +macro in +.ir . +add the following to your program as a workaround: +.pp +.in +4n +.ex +#ifndef ifr_newname +#define ifr_newname ifr_ifru.ifru_slave +#endif +.ee +.in +.sh see also +.br proc (5), +.br capabilities (7), +.br ip (7), +.br rtnetlink (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man7/system_data_types.7 + +.so man3/round.3 + +.so man3/conj.3 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" and copyright (c) 2008 linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified mon apr 12 12:49:57 1993, david metcalfe +.\" modified sat jul 24 18:56:22 1993, rik faith (faith@cs.unc.edu) +.\" modified wed feb 20 21:09:36 2002, ian redfern (redferni@logica.com) +.\" 2008-07-09, mtk, add rawmemchr() +.\" +.th memchr 3 2021-03-22 "" "linux programmer's manual" +.sh name +memchr, memrchr, rawmemchr \- scan memory for a character +.sh synopsis +.nf +.b #include +.pp +.bi "void *memchr(const void *" s ", int " c ", size_t " n ); +.bi "void *memrchr(const void *" s ", int " c ", size_t " n ); +.bi "void *rawmemchr(const void *" s ", int " c ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br memrchr (), +.br rawmemchr (): +.nf + _gnu_source +.fi +.sh description +the +.br memchr () +function scans the initial +.i n +bytes of the memory +area pointed to by +.i s +for the first instance of +.ir c . +both +.i c +and the bytes of the memory area pointed to by +.i s +are interpreted as +.ir "unsigned char" . +.pp +the +.br memrchr () +function is like the +.br memchr () +function, +except that it searches backward from the end of the +.i n +bytes pointed to by +.i s +instead of forward from the beginning. +.pp +the +.br rawmemchr () +function is similar to +.br memchr (): +it assumes (i.e., the programmer knows for certain) +that an instance of +.i c +lies somewhere in the memory area starting at the location pointed to by +.ir s , +and so performs an optimized search for +.ir c +(i.e., no use of a count argument to limit the range of the search). +if an instance of +.i c +is not found, the results are unpredictable. +the following call is a fast means of locating a string's +terminating null byte: +.pp +.in +4n +.ex +char *p = rawmemchr(s,\ \(aq\e0\(aq); +.ee +.in +.sh return value +the +.br memchr () +and +.br memrchr () +functions return a pointer +to the matching byte or null if the character does not occur in +the given memory area. +.pp +the +.br rawmemchr () +function returns a pointer to the matching byte, if one is found. +if no matching byte is found, the result is unspecified. +.sh versions +.br rawmemchr () +first appeared in glibc in version 2.1. +.pp +.br memrchr () +first appeared in glibc in version 2.2. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br memchr (), +.br memrchr (), +.br rawmemchr () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +.br memchr (): +posix.1-2001, posix.1-2008, c89, c99, svr4, 4.3bsd. +.pp +the +.br memrchr () +function is a gnu extension, available since glibc 2.1.91. +.pp +the +.br rawmemchr () +function is a gnu extension, available since glibc 2.1. +.sh see also +.br bstring (3), +.br ffs (3), +.br index (3), +.br memmem (3), +.br rindex (3), +.br strchr (3), +.br strpbrk (3), +.br strrchr (3), +.br strsep (3), +.br strspn (3), +.br strstr (3), +.br wmemchr (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/stat.2 + +.so man3/wprintf.3 + +.\" copyright (c) 2005 michael kerrisk +.\" based on earlier work by faith@cs.unc.edu and +.\" mike battersby +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" 2005-09-15, mtk, created new page by splitting off from sigaction.2 +.\" +.th sigsuspend 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +sigsuspend, rt_sigsuspend \- wait for a signal +.sh synopsis +.nf +.b #include +.pp +.bi "int sigsuspend(const sigset_t *" mask ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br sigsuspend (): +.nf + _posix_c_source +.fi +.sh description +.br sigsuspend () +temporarily replaces the signal mask of the calling thread with the +mask given by +.i mask +and then suspends the thread until delivery of a signal whose +action is to invoke a signal handler or to terminate a process. +.pp +if the signal terminates the process, then +.br sigsuspend () +does not return. +if the signal is caught, then +.br sigsuspend () +returns after the signal handler returns, +and the signal mask is restored to the state before the call to +.br sigsuspend (). +.pp +it is not possible to block +.b sigkill +or +.br sigstop ; +specifying these signals in +.ir mask , +has no effect on the thread's signal mask. +.sh return value +.br sigsuspend () +always returns \-1, with +.i errno +set to indicate the error (normally, +.br eintr ). +.sh errors +.tp +.b efault +.i mask +points to memory which is not a valid part of the process address space. +.tp +.b eintr +the call was interrupted by a signal; +.br signal (7). +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +normally, +.br sigsuspend () +is used in conjunction with +.br sigprocmask (2) +in order to prevent delivery of a signal during the execution of a +critical code section. +the caller first blocks the signals with +.br sigprocmask (2). +when the critical code has completed, the caller then waits for the +signals by calling +.br sigsuspend () +with the signal mask that was returned by +.br sigprocmask (2) +(in the +.i oldset +argument). +.pp +see +.br sigsetops (3) +for details on manipulating signal sets. +.\" +.ss c library/kernel differences +the original linux system call was named +.br sigsuspend (). +however, with the addition of real-time signals in linux 2.2, +the fixed-size, 32-bit +.ir sigset_t +type supported by that system call was no longer fit for purpose. +consequently, a new system call, +.br rt_sigsuspend (), +was added to support an enlarged +.ir sigset_t +type. +the new system call takes a second argument, +.ir "size_t sigsetsize" , +which specifies the size in bytes of the signal set in +.ir mask . +this argument is currently required to have the value +.ir sizeof(sigset_t) +(or the error +.b einval +results). +the glibc +.br sigsuspend () +wrapper function hides these details from us, transparently calling +.br rt_sigsuspend () +when the kernel provides it. +.\" +.sh see also +.br kill (2), +.br pause (2), +.br sigaction (2), +.br signal (2), +.br sigprocmask (2), +.br sigwaitinfo (2), +.br sigsetops (3), +.br sigwait (3), +.br signal (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1999 andries brouwer (aeb@cwi.nl) +.\" +.\" earlier versions of this page influenced the present text. +.\" it was derived from a berkeley page with version +.\" @(#)printf.3 6.14 (berkeley) 7/30/91 +.\" converted for linux by faith@cs.unc.edu, updated by +.\" helmut.geyer@iwr.uni-heidelberg.de, agulbra@troll.no and bruno haible. +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" 1999-11-25 aeb - rewritten, using susv2 and c99. +.\" 2000-07-26 jsm28@hermes.cam.ac.uk - three small fixes +.\" 2000-10-16 jsm28@hermes.cam.ac.uk - more fixes +.\" +.th printf 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +printf, fprintf, dprintf, sprintf, snprintf, vprintf, vfprintf, vdprintf, +vsprintf, vsnprintf \- formatted output conversion +.sh synopsis +.nf +.b #include +.pp +.bi "int printf(const char *restrict " format ", ...);" +.bi "int fprintf(file *restrict " stream , +.bi " const char *restrict " format ", ...);" +.bi "int dprintf(int " fd , +.bi " const char *restrict " format ", ...);" +.bi "int sprintf(char *restrict " str , +.bi " const char *restrict " format ", ...);" +.bi "int snprintf(char *restrict " str ", size_t " size , +.bi " const char *restrict " format ", ...);" +.pp +.b #include +.pp +.bi "int vprintf(const char *restrict " format ", va_list " ap ); +.bi "int vfprintf(file *restrict " stream , +.bi " const char *restrict " format ", va_list " ap ); +.bi "int vdprintf(int " fd , +.bi " const char *restrict " format ", va_list " ap ); +.bi "int vsprintf(char *restrict " str , +.bi " const char *restrict " format ", va_list " ap ); +.bi "int vsnprintf(char *restrict " str ", size_t " size , +.bi " const char *restrict " format ", va_list " ap ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br snprintf (), +.br vsnprintf (): +.nf + _xopen_source >= 500 || _isoc99_source + || /* glibc <= 2.19: */ _bsd_source +.fi +.pp +.br dprintf (), +.br vdprintf (): +.nf + since glibc 2.10: + _posix_c_source >= 200809l + before glibc 2.10: + _gnu_source +.fi +.sh description +the functions in the +.br printf () +family produce output according to a +.i format +as described below. +the functions +.br printf () +and +.br vprintf () +write output to +.ir stdout , +the standard output stream; +.br fprintf () +and +.br vfprintf () +write output to the given output +.ir stream ; +.br sprintf (), +.br snprintf (), +.br vsprintf (), +and +.br vsnprintf () +write to the character string +.ir str . +.pp +the function +.br dprintf () +is the same as +.br fprintf () +except that it outputs to a file descriptor, +.ir fd , +instead of to a +.br stdio (3) +stream. +.pp +the functions +.br snprintf () +and +.br vsnprintf () +write at most +.i size +bytes (including the terminating null byte (\(aq\e0\(aq)) to +.ir str . +.pp +the functions +.br vprintf (), +.br vfprintf (), +.br vdprintf (), +.br vsprintf (), +.br vsnprintf () +are equivalent to the functions +.br printf (), +.br fprintf (), +.br dprintf (), +.br sprintf (), +.br snprintf (), +respectively, except that they are called with a +.i va_list +instead of a variable number of arguments. +these functions do not call the +.i va_end +macro. +because they invoke the +.i va_arg +macro, the value of +.i ap +is undefined after the call. +see +.br stdarg (3). +.pp +all of these functions write the output under the control of a +.i format +string that specifies how subsequent arguments (or arguments accessed via +the variable-length argument facilities of +.br stdarg (3)) +are converted for output. +.pp +c99 and posix.1-2001 specify that the results are undefined if a call to +.br sprintf (), +.br snprintf (), +.br vsprintf (), +or +.br vsnprintf () +would cause copying to take place between objects that overlap +(e.g., if the target string array and one of the supplied input arguments +refer to the same buffer). +see notes. +.ss format of the format string +the format string is a character string, beginning and ending +in its initial shift state, if any. +the format string is composed of zero or more directives: ordinary +characters (not +.br % ), +which are copied unchanged to the output stream; +and conversion specifications, each of which results in fetching zero or +more subsequent arguments. +each conversion specification is introduced by +the character +.br % , +and ends with a +.ir "conversion specifier" . +in between there may be (in this order) zero or more +.ir flags , +an optional minimum +.ir "field width" , +an optional +.i precision +and an optional +.ir "length modifier" . +.pp +the overall syntax of a conversion specification is: +.pp +.in +4n +.nf +%[$][flags][width][.precision][length modifier]conversion +.fi +.in +.pp +the arguments must correspond properly (after type promotion) with the +conversion specifier. +by default, the arguments are used in the order +given, where each \(aq*\(aq (see +.i "field width" +and +.i precision +below) and each conversion specifier asks for the next +argument (and it is an error if insufficiently many arguments are given). +one can also specify explicitly which argument is taken, +at each place where an argument is required, by writing "%m$" instead +of \(aq%\(aq and "*m$" instead of \(aq*\(aq, +where the decimal integer \fim\fp denotes +the position in the argument list of the desired argument, indexed starting +from 1. +thus, +.pp +.in +4n +.ex +printf("%*d", width, num); +.ee +.in +.pp +and +.pp +.in +4n +.ex +printf("%2$*1$d", width, num); +.ee +.in +.pp +are equivalent. +the second style allows repeated references to the +same argument. +the c99 standard does not include the style using \(aq$\(aq, +which comes from the single unix specification. +if the style using +\(aq$\(aq is used, it must be used throughout for all conversions taking an +argument and all width and precision arguments, but it may be mixed +with "%%" formats, which do not consume an argument. +there may be no +gaps in the numbers of arguments specified using \(aq$\(aq; for example, if +arguments 1 and 3 are specified, argument 2 must also be specified +somewhere in the format string. +.pp +for some numeric conversions a radix character ("decimal point") or +thousands' grouping character is used. +the actual character used +depends on the +.b lc_numeric +part of the locale. +(see +.br setlocale (3).) +the posix locale +uses \(aq.\(aq as radix character, and does not have a grouping character. +thus, +.pp +.in +4n +.ex +printf("%\(aq.2f", 1234567.89); +.ee +.in +.pp +results in "1234567.89" in the posix locale, in "1234567,89" in the +nl_nl locale, and in "1.234.567,89" in the da_dk locale. +.ss flag characters +the character % is followed by zero or more of the following flags: +.tp +.b # +the value should be converted to an "alternate form". +for +.b o +conversions, the first character of the output string is made zero +(by prefixing a 0 if it was not zero already). +for +.b x +and +.b x +conversions, a nonzero result has the string "0x" (or "0x" for +.b x +conversions) prepended to it. +for +.br a , +.br a , +.br e , +.br e , +.br f , +.br f , +.br g , +and +.b g +conversions, the result will always contain a decimal point, even if no +digits follow it (normally, a decimal point appears in the results of those +conversions only if a digit follows). +for +.b g +and +.b g +conversions, trailing zeros are not removed from the result as they would +otherwise be. +for other conversions, the result is undefined. +.tp +.b \&0 +the value should be zero padded. +for +.br d , +.br i , +.br o , +.br u , +.br x , +.br x , +.br a , +.br a , +.br e , +.br e , +.br f , +.br f , +.br g , +and +.b g +conversions, the converted value is padded on the left with zeros rather +than blanks. +if the +.b \&0 +and +.b \- +flags both appear, the +.b \&0 +flag is ignored. +if a precision is given with a numeric conversion +.rb ( d , +.br i , +.br o , +.br u , +.br x , +and +.br x ), +the +.b \&0 +flag is ignored. +for other conversions, the behavior is undefined. +.tp +.b \- +the converted value is to be left adjusted on the field boundary. +(the default is right justification.) +the converted value is padded on the right with blanks, rather +than on the left with blanks or zeros. +a +.b \- +overrides a +.b \&0 +if both are given. +.tp +.b \(aq \(aq +(a space) a blank should be left before a positive number +(or empty string) produced by a signed conversion. +.tp +.b + +a sign (+ or \-) should always be placed before a number produced by a signed +conversion. +by default, a sign is used only for negative numbers. +a +.b + +overrides a space if both are used. +.pp +the five flag characters above are defined in the c99 standard. +the single unix specification specifies one further flag character. +.tp +.b \(aq +for decimal conversion +.rb ( i , +.br d , +.br u , +.br f , +.br f , +.br g , +.br g ) +the output is to be grouped with thousands' grouping characters +if the locale information indicates any. +(see +.br setlocale (3).) +note that many versions of +.br gcc (1) +cannot parse this option and will issue a warning. +(susv2 did not +include \fi%\(aqf\fp, but susv3 added it.) +.pp +glibc 2.2 adds one further flag character. +.tp +.b i +for decimal integer conversion +.rb ( i , +.br d , +.br u ) +the output uses the locale's alternative output digits, if any. +for example, since glibc 2.2.3 this will give arabic-indic digits +in the persian ("fa_ir") locale. +.\" outdigits keyword in locale file +.ss field width +an optional decimal digit string (with nonzero first digit) specifying +a minimum field width. +if the converted value has fewer characters +than the field width, it will be padded with spaces on the left +(or right, if the left-adjustment flag has been given). +instead of a decimal digit string one may write "*" or "*m$" +(for some decimal integer \fim\fp) to specify that the field width +is given in the next argument, or in the \fim\fp-th argument, respectively, +which must be of type +.ir int . +a negative field width is taken as a \(aq\-\(aq flag followed by a +positive field width. +in no case does a nonexistent or small field width cause truncation of a +field; if the result of a conversion is wider than the field width, the +field is expanded to contain the conversion result. +.ss precision +an optional precision, in the form of a period (\(aq.\(aq) followed by an +optional decimal digit string. +instead of a decimal digit string one may write "*" or "*m$" +(for some decimal integer \fim\fp) to specify that the precision +is given in the next argument, or in the \fim\fp-th argument, respectively, +which must be of type +.ir int . +if the precision is given as just \(aq.\(aq, the precision is taken to +be zero. +a negative precision is taken as if the precision were omitted. +this gives the minimum number of digits to appear for +.br d , +.br i , +.br o , +.br u , +.br x , +and +.b x +conversions, the number of digits to appear after the radix character for +.br a , +.br a , +.br e , +.br e , +.br f , +and +.b f +conversions, the maximum number of significant digits for +.b g +and +.b g +conversions, or the maximum number of characters to be printed from a +string for +.b s +and +.b s +conversions. +.ss length modifier +here, "integer conversion" stands for +.br d , +.br i , +.br o , +.br u , +.br x , +or +.b x +conversion. +.tp +.b hh +a following integer conversion corresponds to a +.i signed char +or +.i unsigned char +argument, or a following +.b n +conversion corresponds to a pointer to a +.i signed char +argument. +.tp +.b h +a following integer conversion corresponds to a +.i short +or +.i unsigned short +argument, or a following +.b n +conversion corresponds to a pointer to a +.i short +argument. +.tp +.b l +(ell) a following integer conversion corresponds to a +.i long +or +.i unsigned long +argument, or a following +.b n +conversion corresponds to a pointer to a +.i long +argument, or a following +.b c +conversion corresponds to a +.i wint_t +argument, or a following +.b s +conversion corresponds to a pointer to +.i wchar_t +argument. +.tp +.b ll +(ell-ell). +a following integer conversion corresponds to a +.i long long +or +.i unsigned long long +argument, or a following +.b n +conversion corresponds to a pointer to a +.i long long +argument. +.tp +.b q +a synonym for +.br ll . +this is a nonstandard extension, derived from bsd; +avoid its use in new code. +.tp +.b l +a following +.br a , +.br a , +.br e , +.br e , +.br f , +.br f , +.br g , +or +.b g +conversion corresponds to a +.i long double +argument. +(c99 allows %lf, but susv2 does not.) +.tp +.b j +a following integer conversion corresponds to an +.i intmax_t +or +.i uintmax_t +argument, or a following +.b n +conversion corresponds to a pointer to an +.i intmax_t +argument. +.tp +.b z +a following integer conversion corresponds to a +.i size_t +or +.i ssize_t +argument, or a following +.b n +conversion corresponds to a pointer to a +.i size_t +argument. +.tp +.b z +a nonstandard synonym for +.br z +that predates the appearance of +.br z . +do not use in new code. +.tp +.b t +a following integer conversion corresponds to a +.i ptrdiff_t +argument, or a following +.b n +conversion corresponds to a pointer to a +.i ptrdiff_t +argument. +.pp +susv3 specifies all of the above, +except for those modifiers explicitly noted as being nonstandard extensions. +susv2 specified only the length modifiers +.b h +(in +.br hd , +.br hi , +.br ho , +.br hx , +.br hx , +.br hn ) +and +.b l +(in +.br ld , +.br li , +.br lo , +.br lx , +.br lx , +.br ln , +.br lc , +.br ls ) +and +.b l +(in +.br le , +.br le , +.br lf , +.br lg , +.br lg ). +.pp +as a nonstandard extension, the gnu implementations treats +.b ll +and +.b l +as synonyms, so that one can, for example, write +.br llg +(as a synonym for the standards-compliant +.br lg ) +and +.br ld +(as a synonym for the standards compliant +.br lld ). +such usage is nonportable. +.\" +.ss conversion specifiers +a character that specifies the type of conversion to be applied. +the conversion specifiers and their meanings are: +.tp +.br d ", " i +the +.i int +argument is converted to signed decimal notation. +the precision, if any, gives the minimum number of digits +that must appear; if the converted value requires fewer digits, it is +padded on the left with zeros. +the default precision is 1. +when 0 is printed with an explicit precision 0, the output is empty. +.tp +.br o ", " u ", " x ", " x +the +.i "unsigned int" +argument is converted to unsigned octal +.rb ( o ), +unsigned decimal +.rb ( u ), +or unsigned hexadecimal +.rb ( x +and +.br x ) +notation. +the letters +.b abcdef +are used for +.b x +conversions; the letters +.b abcdef +are used for +.b x +conversions. +the precision, if any, gives the minimum number of digits +that must appear; if the converted value requires fewer digits, it is +padded on the left with zeros. +the default precision is 1. +when 0 is printed with an explicit precision 0, the output is empty. +.tp +.br e ", " e +the +.i double +argument is rounded and converted in the style +.rb [\-]d \&. ddd e \(+-dd +where there is one digit (which is nonzero if the argument is nonzero) +before the decimal-point character and the number +of digits after it is equal to the precision; if the precision is missing, +it is taken as 6; if the precision is zero, no decimal-point character +appears. +an +.b e +conversion uses the letter +.b e +(rather than +.br e ) +to introduce the exponent. +the exponent always contains at least two +digits; if the value is zero, the exponent is 00. +.tp +.br f ", " f +the +.i double +argument is rounded and converted to decimal notation in the style +.rb [\-]ddd \&. ddd, +where the number of digits after the decimal-point character is equal to +the precision specification. +if the precision is missing, it is taken as +6; if the precision is explicitly zero, no decimal-point character appears. +if a decimal point appears, at least one digit appears before it. +.ip +(susv2 does not know about +.b f +and says that character string representations for infinity and nan +may be made available. +susv3 adds a specification for +.br f . +the c99 standard specifies "[\-]inf" or "[\-]infinity" +for infinity, and a string starting with "nan" for nan, in the case of +.b f +conversion, and "[\-]inf" or "[\-]infinity" or "nan" in the case of +.b f +conversion.) +.tp +.br g ", " g +the +.i double +argument is converted in style +.b f +or +.b e +(or +.b f +or +.b e +for +.b g +conversions). +the precision specifies the number of significant digits. +if the precision is missing, 6 digits are given; if the precision is zero, +it is treated as 1. +style +.b e +is used if the exponent from its conversion is less than \-4 or greater +than or equal to the precision. +trailing zeros are removed from the +fractional part of the result; a decimal point appears only if it is +followed by at least one digit. +.tp +.br a ", " a +(c99; not in susv2, but added in susv3) +for +.b a +conversion, the +.i double +argument is converted to hexadecimal notation (using the letters abcdef) +in the style +.rb [\-] 0x h \&. hhhh p \(+-d; +for +.b a +conversion the prefix +.br 0x , +the letters abcdef, and the exponent separator +.b p +is used. +there is one hexadecimal digit before the decimal point, +and the number of digits after it is equal to the precision. +the default precision suffices for an exact representation of the value +if an exact representation in base 2 exists +and otherwise is sufficiently large to distinguish values of type +.ir double . +the digit before the decimal point is unspecified for nonnormalized +numbers, and nonzero but otherwise unspecified for normalized numbers. +the exponent always contains at least one +digit; if the value is zero, the exponent is 0. +.tp +.b c +if no +.b l +modifier is present, the +.i int +argument is converted to an +.ir "unsigned char" , +and the resulting character is written. +if an +.b l +modifier is present, the +.i wint_t +(wide character) argument is converted to a multibyte sequence by a call +to the +.br wcrtomb (3) +function, with a conversion state starting in the initial state, and the +resulting multibyte string is written. +.tp +.b s +if no +.b l +modifier is present: the +.i "const char\ *" +argument is expected to be a pointer to an array of character type (pointer +to a string). +characters from the array are written up to (but not +including) a terminating null byte (\(aq\e0\(aq); +if a precision is specified, no more than the number specified +are written. +if a precision is given, no null byte need be present; +if the precision is not specified, or is greater than the size of the +array, the array must contain a terminating null byte. +.ip +if an +.b l +modifier is present: the +.i "const wchar_t\ *" +argument is expected to be a pointer to an array of wide characters. +wide characters from the array are converted to multibyte characters +(each by a call to the +.br wcrtomb (3) +function, with a conversion state starting in the initial state before +the first wide character), up to and including a terminating null +wide character. +the resulting multibyte characters are written up to +(but not including) the terminating null byte. +if a precision is +specified, no more bytes than the number specified are written, but +no partial multibyte characters are written. +note that the precision +determines the number of +.i bytes +written, not the number of +.i wide characters +or +.ir "screen positions" . +the array must contain a terminating null wide character, unless a +precision is given and it is so small that the number of bytes written +exceeds it before the end of the array is reached. +.tp +.b c +(not in c99 or c11, but in susv2, susv3, and susv4.) +synonym for +.br lc . +don't use. +.tp +.b s +(not in c99 or c11, but in susv2, susv3, and susv4.) +synonym for +.br ls . +don't use. +.tp +.b p +the +.i "void\ *" +pointer argument is printed in hexadecimal (as if by +.b %#x +or +.br %#lx ). +.tp +.b n +the number of characters written so far is stored into the integer +pointed to by the corresponding argument. +that argument shall be an +.ir "int\ *" , +or variant whose size matches the (optionally) +supplied integer length modifier. +no argument is converted. +(this specifier is not supported by the bionic c library.) +the behavior is undefined if the conversion specification includes +any flags, a field width, or a precision. +.tp +.b m +(glibc extension; supported by uclibc and musl.) +print output of +.ir strerror(errno) . +no argument is required. +.tp +.b % +a \(aq%\(aq is written. +no argument is converted. +the complete conversion +specification is \(aq%%\(aq. +.sh return value +upon successful return, these functions return the number of characters +printed (excluding the null byte used to end output to strings). +.pp +the functions +.br snprintf () +and +.br vsnprintf () +do not write more than +.i size +bytes (including the terminating null byte (\(aq\e0\(aq)). +if the output was truncated due to this limit, then the return value +is the number of characters (excluding the terminating null byte) +which would have been written to the final string if enough space +had been available. +thus, a return value of +.i size +or more means that the output was truncated. +(see also below under notes.) +.pp +if an output error is encountered, a negative value is returned. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br printf (), +.br fprintf (), +.br sprintf (), +.br snprintf (), +.br vprintf (), +.br vfprintf (), +.br vsprintf (), +.br vsnprintf () +t} thread safety mt-safe locale +.te +.hy +.ad +.sp 1 +.sh conforming to +.br fprintf (), +.br printf (), +.br sprintf (), +.br vprintf (), +.br vfprintf (), +.br vsprintf (): +posix.1-2001, posix.1-2008, c89, c99. +.pp +.br snprintf (), +.br vsnprintf (): +posix.1-2001, posix.1-2008, c99. +.pp +the +.br dprintf () +and +.br vdprintf () +functions were originally gnu extensions that were later standardized +in posix.1-2008. +.pp +concerning the return value of +.br snprintf (), +susv2 and c99 contradict each other: when +.br snprintf () +is called with +.ir size =0 +then susv2 stipulates an unspecified return value less than 1, +while c99 allows +.i str +to be null in this case, and gives the return value (as always) +as the number of characters that would have been written in case +the output string has been large enough. +posix.1-2001 and later align their specification of +.br snprintf () +with c99. +.\" .pp +.\" linux libc4 knows about the five c standard flags. +.\" it knows about the length modifiers \fbh\fp, \fbl\fp, \fbl\fp, +.\" and the conversions +.\" \fbc\fp, \fbd\fp, \fbe\fp, \fbe\fp, \fbf\fp, \fbf\fp, +.\" \fbg\fp, \fbg\fp, \fbi\fp, \fbn\fp, \fbo\fp, \fbp\fp, +.\" \fbs\fp, \fbu\fp, \fbx\fp, and \fbx\fp, +.\" where \fbf\fp is a synonym for \fbf\fp. +.\" additionally, it accepts \fbd\fp, \fbo\fp, and \fbu\fp as synonyms +.\" for \fbld\fp, \fblo\fp, and \fblu\fp. +.\" (this is bad, and caused serious bugs later, when +.\" support for \fb%d\fp disappeared.) +.\" no locale-dependent radix character, +.\" no thousands' separator, no nan or infinity, no "%m$" and "*m$". +.\" .pp +.\" linux libc5 knows about the five c standard flags and the \(aq flag, +.\" locale, "%m$" and "*m$". +.\" it knows about the length modifiers \fbh\fp, \fbl\fp, \fbl\fp, +.\" \fbz\fp, and \fbq\fp, but accepts \fbl\fp and \fbq\fp +.\" both for \filong double\fp and for \filong long\fp (this is a bug). +.\" it no longer recognizes \fbf\fp, \fbd\fp, \fbo\fp, and \fbu\fp, +.\" but adds the conversion character +.\" .br m , +.\" which outputs +.\" .ir strerror(errno) . +.\" .pp +.\" glibc 2.0 adds conversion characters \fbc\fp and \fbs\fp. +.pp +glibc 2.1 adds length modifiers \fbhh\fp, \fbj\fp, \fbt\fp, and \fbz\fp +and conversion characters \fba\fp and \fba\fp. +.pp +glibc 2.2 adds the conversion character \fbf\fp with c99 semantics, +and the flag character \fbi\fp. +.sh notes +some programs imprudently rely on code such as the following +.pp + sprintf(buf, "%s some further text", buf); +.pp +to append text to +.ir buf . +however, the standards explicitly note that the results are undefined +if source and destination buffers overlap when calling +.br sprintf (), +.br snprintf (), +.br vsprintf (), +and +.br vsnprintf (). +.\" http://sourceware.org/bugzilla/show_bug.cgi?id=7075 +depending on the version of +.br gcc (1) +used, and the compiler options employed, calls such as the above will +.b not +produce the expected results. +.pp +the glibc implementation of the functions +.br snprintf () +and +.br vsnprintf () +conforms to the c99 standard, that is, behaves as described above, +since glibc version 2.1. +until glibc 2.0.6, they would return \-1 +when the output was truncated. +.\" .sh history +.\" unix v7 defines the three routines +.\" .br printf (), +.\" .br fprintf (), +.\" .br sprintf (), +.\" and has the flag \-, the width or precision *, the length modifier l, +.\" and the conversions doxfegcsu, and also d,o,u,x as synonyms for ld,lo,lu,lx. +.\" this is still true for 2.9.1bsd, but 2.10bsd has the flags +.\" #, + and and no longer mentions d,o,u,x. +.\" 2.11bsd has +.\" .br vprintf (), +.\" .br vfprintf (), +.\" .br vsprintf (), +.\" and warns not to use d,o,u,x. +.\" 4.3bsd reno has the flag 0, the length modifiers h and l, +.\" and the conversions n, p, e, g, x (with current meaning) +.\" and deprecates d,o,u. +.\" 4.4bsd introduces the functions +.\" .br snprintf () +.\" and +.\" .br vsnprintf (), +.\" and the length modifier q. +.\" freebsd also has functions +.\" .br asprintf () +.\" and +.\" .br vasprintf (), +.\" that allocate a buffer large enough for +.\" .br sprintf (). +.\" in glibc there are functions +.\" .br dprintf () +.\" and +.\" .br vdprintf () +.\" that print to a file descriptor instead of a stream. +.sh bugs +because +.br sprintf () +and +.br vsprintf () +assume an arbitrarily long string, callers must be careful not to overflow +the actual space; this is often impossible to assure. +note that the length +of the strings produced is locale-dependent and difficult to predict. +use +.br snprintf () +and +.br vsnprintf () +instead (or +.br asprintf (3) +and +.br vasprintf (3)). +.\" .pp +.\" linux libc4.[45] does not have a +.\" .br snprintf (), +.\" but provides a libbsd that contains an +.\" .br snprintf () +.\" equivalent to +.\" .br sprintf (), +.\" that is, one that ignores the +.\" .i size +.\" argument. +.\" thus, the use of +.\" .br snprintf () +.\" with early libc4 leads to serious security problems. +.pp +code such as +.bi printf( foo ); +often indicates a bug, since +.i foo +may contain a % character. +if +.i foo +comes from untrusted user input, it may contain \fb%n\fp, causing the +.br printf () +call to write to memory and creating a security hole. +.\" .pp +.\" some floating-point conversions under early libc4 +.\" caused memory leaks. +.sh examples +to print +.i pi +to five decimal places: +.pp +.in +4n +.ex +#include +#include +fprintf(stdout, "pi = %.5f\en", 4 * atan(1.0)); +.ee +.in +.pp +to print a date and time in the form "sunday, july 3, 10:02", +where +.i weekday +and +.i month +are pointers to strings: +.pp +.in +4n +.ex +#include +fprintf(stdout, "%s, %s %d, %.2d:%.2d\en", + weekday, month, day, hour, min); +.ee +.in +.pp +many countries use the day-month-year order. +hence, an internationalized version must be able to print +the arguments in an order specified by the format: +.pp +.in +4n +.ex +#include +fprintf(stdout, format, + weekday, month, day, hour, min); +.ee +.in +.pp +where +.i format +depends on locale, and may permute the arguments. +with the value: +.pp +.in +4n +.ex +"%1$s, %3$d. %2$s, %4$d:%5$.2d\en" +.ee +.in +.pp +one might obtain "sonntag, 3. juli, 10:02". +.pp +to allocate a sufficiently large string and print into it +(code correct for both glibc 2.0 and glibc 2.1): +.pp +.ex +#include +#include +#include + +char * +make_message(const char *fmt, ...) +{ + int n = 0; + size_t size = 0; + char *p = null; + va_list ap; + + /* determine required size. */ + + va_start(ap, fmt); + n = vsnprintf(p, size, fmt, ap); + va_end(ap); + + if (n < 0) + return null; + + size = (size_t) n + 1; /* one extra byte for \(aq\e0\(aq */ + p = malloc(size); + if (p == null) + return null; + + va_start(ap, fmt); + n = vsnprintf(p, size, fmt, ap); + va_end(ap); + + if (n < 0) { + free(p); + return null; + } + + return p; +} +.ee +.pp +if truncation occurs in glibc versions prior to 2.0.6, this is treated as an +error instead of being handled gracefully. +.sh see also +.br printf (1), +.br asprintf (3), +.br puts (3), +.br scanf (3), +.br setlocale (3), +.br strfromd (3), +.br wcrtomb (3), +.br wprintf (3), +.br locale (5) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification +.\" http://www.unix-systems.org/online.html +.\" iso/iec 9899:1999 +.\" +.th getwchar 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +getwchar \- read a wide character from standard input +.sh synopsis +.nf +.b #include +.pp +.b "wint_t getwchar(void);" +.fi +.sh description +the +.br getwchar () +function is the wide-character equivalent of the +.br getchar (3) +function. +it reads a wide character from +.i stdin +and returns +it. +if the end of stream is reached, or if +.i ferror(stdin) +becomes true, it returns +.br weof . +if a wide-character conversion error occurs, it sets +.i errno +to +.b eilseq +and returns +.br weof . +.pp +for a nonlocking counterpart, see +.br unlocked_stdio (3). +.sh return value +the +.br getwchar () +function returns the next wide-character from +standard input, or +.br weof . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br getwchar () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh notes +the behavior of +.br getwchar () +depends on the +.b lc_ctype +category of the +current locale. +.pp +it is reasonable to expect that +.br getwchar () +will actually +read a multibyte sequence from standard input and then +convert it to a wide character. +.sh see also +.br fgetwc (3), +.br unlocked_stdio (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" and copyright 2006 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sun jul 25 10:53:39 1993 by rik faith (faith@cs.unc.edu) +.\" added correction due to nsd@bbc.com (nick duffek) - aeb, 950610 +.th strtol 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +strtol, strtoll, strtoq \- convert a string to a long integer +.sh synopsis +.nf +.b #include +.pp +.bi "long strtol(const char *restrict " nptr , +.bi " char **restrict " endptr ", int " base ); +.bi "long long strtoll(const char *restrict " nptr , +.bi " char **restrict " endptr ", int " base ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br strtoll (): +.nf + _isoc99_source + || /* glibc <= 2.19: */ _svid_source || _bsd_source +.fi +.sh description +the +.br strtol () +function converts the initial part of the string +in +.i nptr +to a long integer value according to the given +.ir base , +which must be between 2 and 36 inclusive, or be the special value 0. +.pp +the string may begin with an arbitrary amount of white space (as +determined by +.br isspace (3)) +followed by a single optional \(aq+\(aq or \(aq\-\(aq sign. +if +.i base +is zero or 16, the string may then include a +"0x" or "0x" prefix, and the number will be read in base 16; otherwise, a +zero +.i base +is taken as 10 (decimal) unless the next character +is \(aq0\(aq, in which case it is taken as 8 (octal). +.pp +the remainder of the string is converted to a +.i long +value +in the obvious manner, stopping at the first character which is not a +valid digit in the given base. +(in bases above 10, the letter \(aqa\(aq in +either uppercase or lowercase represents 10, \(aqb\(aq represents 11, and so +forth, with \(aqz\(aq representing 35.) +.pp +if +.i endptr +is not null, +.br strtol () +stores the address of the +first invalid character in +.ir *endptr . +if there were no digits at +all, +.br strtol () +stores the original value of +.i nptr +in +.i *endptr +(and returns 0). +in particular, if +.i *nptr +is not \(aq\e0\(aq but +.i **endptr +is \(aq\e0\(aq on return, the entire string is valid. +.pp +the +.br strtoll () +function works just like the +.br strtol () +function but returns a +.i long long +integer value. +.sh return value +the +.br strtol () +function returns the result of the conversion, +unless the value would underflow or overflow. +if an underflow occurs, +.br strtol () +returns +.br long_min . +if an overflow occurs, +.br strtol () +returns +.br long_max . +in both cases, +.i errno +is set to +.br erange . +precisely the same holds for +.br strtoll () +(with +.b llong_min +and +.b llong_max +instead of +.b long_min +and +.br long_max ). +.sh errors +.tp +.b einval +(not in c99) +the given +.i base +contains an unsupported value. +.tp +.b erange +the resulting value was out of range. +.pp +the implementation may also set +.ir errno +to +.b einval +in case +no conversion was performed (no digits seen, and 0 returned). +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br strtol (), +.br strtoll (), +.br strtoq () +t} thread safety mt-safe locale +.te +.hy +.ad +.sp 1 +.sh conforming to +.br strtol (): +posix.1-2001, posix.1-2008, c89, c99 svr4, 4.3bsd. +.pp +.br strtoll (): +posix.1-2001, posix.1-2008, c99. +.sh notes +since +.br strtol () +can legitimately return 0, +.br long_max , +or +.b long_min +.rb ( llong_max +or +.b llong_min +for +.br strtoll ()) +on both success and failure, the calling program should set +.i errno +to 0 before the call, +and then determine if an error occurred by checking whether +.i errno +has a nonzero value after the call. +.pp +according to posix.1, +in locales other than "c" and "posix", +these functions may accept other, +implementation-defined numeric strings. +.pp +bsd also has +.pp +.in +4n +.ex +.bi "quad_t strtoq(const char *" nptr ", char **" endptr ", int " base ); +.ee +.in +.pp +with completely analogous definition. +depending on the wordsize of the current architecture, this +may be equivalent to +.br strtoll () +or to +.br strtol (). +.sh examples +the program shown below demonstrates the use of +.br strtol (). +the first command-line argument specifies a string from which +.br strtol () +should parse a number. +the second (optional) argument specifies the base to be used for +the conversion. +(this argument is converted to numeric form using +.br atoi (3), +a function that performs no error checking and +has a simpler interface than +.br strtol ().) +some examples of the results produced by this program are the following: +.pp +.in +4n +.ex +.rb "$" " ./a.out 123" +strtol() returned 123 +.rb "$" " ./a.out \(aq 123\(aq" +strtol() returned 123 +.rb "$" " ./a.out 123abc" +strtol() returned 123 +further characters after number: "abc" +.rb "$" " ./a.out 123abc 55" +strtol: invalid argument +.rb "$" " ./a.out \(aq\(aq" +no digits were found +.rb "$" " ./a.out 4000000000" +strtol: numerical result out of range +.ee +.in +.ss program source +\& +.ex +#include +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + int base; + char *endptr, *str; + long val; + + if (argc < 2) { + fprintf(stderr, "usage: %s str [base]\en", argv[0]); + exit(exit_failure); + } + + str = argv[1]; + base = (argc > 2) ? atoi(argv[2]) : 0; + + errno = 0; /* to distinguish success/failure after call */ + val = strtol(str, &endptr, base); + + /* check for various possible errors. */ + + if (errno != 0) { + perror("strtol"); + exit(exit_failure); + } + + if (endptr == str) { + fprintf(stderr, "no digits were found\en"); + exit(exit_failure); + } + + /* if we got here, strtol() successfully parsed a number. */ + + printf("strtol() returned %ld\en", val); + + if (*endptr != \(aq\e0\(aq) /* not necessarily an error... */ + printf("further characters after number: \e"%s\e"\en", endptr); + + exit(exit_success); +} +.ee +.sh see also +.br atof (3), +.br atoi (3), +.br atol (3), +.br strtod (3), +.br strtoimax (3), +.br strtoul (3), +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/setgid.2 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" and copyright 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sat jul 24 19:08:17 1993 by rik faith (faith@cs.unc.edu) +.\" modified 2002-08-25, aeb +.\" modified 2004-11-12 as per suggestion by fabian kreutz/aeb +.\" 2008-07-24, mtk, created this page, based on material from j0.3. +.\" +.th y0 3 2021-03-22 "" "linux programmer's manual" +.sh name +y0, y0f, y0l, y1, y1f, y1l, yn, ynf, ynl \- +bessel functions of the second kind +.sh synopsis +.nf +.b #include +.pp +.bi "double y0(double " x ); +.bi "double y1(double " x ); +.bi "double yn(int " n ", double " x ); +.pp +.bi "float y0f(float " x ); +.bi "float y1f(float " x ); +.bi "float ynf(int " n ", float " x ); +.pp +.bi "long double y0l(long double " x ); +.bi "long double y1l(long double " x ); +.bi "long double ynl(int " n ", long double " x ); +.fi +.pp +link with \fi\-lm\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br y0 (), +.br y1 (), +.br yn (): +.nf + _xopen_source + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _svid_source || _bsd_source +.fi +.pp +.br y0f (), +.br y0l (), +.br y1f (), +.br y1l (), +.br ynf (), +.br ynl (): +.nf + _xopen_source >= 600 + || (_isoc99_source && _xopen_source) + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _svid_source || _bsd_source +.fi +.sh description +the +.br y0 () +and +.br y1 () +functions return bessel functions of +.i x +of the second kind of orders 0 and 1, respectively. +the +.br yn () +function +returns the bessel function of +.i x +of the second kind of order +.ir n . +.pp +the value of +.i x +must be positive. +.pp +the +.br y0f (), +.br y1f (), +and +.br ynf () +functions are versions that take and return +.i float +values. +the +.br y0l (), +.br y1l (), +and +.br ynl () +functions are versions that take and return +.i "long double" +values. +.sh return value +on success, these functions return the appropriate +bessel value of the second kind for +.ir x . +.pp +if +.i x +is a nan, a nan is returned. +.pp +if +.i x +is negative, +a domain error occurs, +and the functions return +.rb \- huge_val , +.rb \- huge_valf , +or +.rb \- huge_vall , +respectively. +(posix.1-2001 also allows a nan return for this case.) +.pp +if +.i x +is 0.0, +a pole error occurs, +and the functions return +.rb \- huge_val , +.rb \- huge_valf , +or +.rb \- huge_vall , +respectively. +.pp +if the result underflows, +a range error occurs, +and the functions return 0.0 +.pp +if the result overflows, +a range error occurs, +and the functions return +.rb \- huge_val , +.rb \- huge_valf , +or +.rb \- huge_vall , +respectively. +(posix.1-2001 also allows a 0.0 return for this case.) +.sh errors +see +.br math_error (7) +for information on how to determine whether an error has occurred +when calling these functions. +.pp +the following errors can occur: +.tp +domain error: \fix\fp is negative +.i errno +is set to +.br edom . +an invalid floating-point exception +.rb ( fe_invalid ) +is raised. +.tp +pole error: \fix\fp is 0.0 +.\" before posix.1-2001 tc2, this was (inconsistently) specified +.\" as a range error. +.i errno +is set to +.br erange +and an +.b fe_divbyzero +exception is raised +(but see bugs). +.tp +range error: result underflow +.\" e.g., y0(1e33) on glibc 2.8/x86-32 +.i errno +is set to +.br erange . +no +.b fe_underflow +exception is returned by +.\" this is intended behavior +.\" see http://sources.redhat.com/bugzilla/show_bug.cgi?id=6806 +.br fetestexcept (3) +for this case. +.tp +range error: result overflow +.\" e.g., yn(10, 1e-40) on glibc 2.8/x86-32 +.i errno +is set to +.br erange +(but see bugs). +an overflow floating-point exception +.rb ( fe_overflow ) +is raised. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br y0 (), +.br y0f (), +.br y0l () +t} thread safety mt-safe +t{ +.br y1 (), +.br y1f (), +.br y1l () +t} thread safety mt-safe +t{ +.br yn (), +.br ynf (), +.br ynl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +the functions returning +.i double +conform to svr4, 4.3bsd, +posix.1-2001, posix.1-2008. +the others are nonstandard functions that also exist on the bsds. +.sh bugs +before glibc 2.19, +.\" http://sourceware.org/bugzilla/show_bug.cgi?id=6807 +these functions misdiagnosed pole errors: +.i errno +was set to +.br edom , +instead of +.br erange +and no +.b fe_divbyzero +exception was raised. +.pp +before glibc 2.17, +.\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=6808 +did not set +.i errno +for "range error: result underflow". +.pp +in glibc version 2.3.2 and earlier, +.\" actually, 2.3.2 is the earliest test result i have; so yet +.\" to confirm if this error occurs only in 2.3.2. +these functions do not raise an invalid floating-point exception +.rb ( fe_invalid ) +when a domain error occurs. +.sh see also +.br j0 (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man7/iso_8859-16.7 + +.\" copyright (c) 1999 andries brouwer (aeb@cwi.nl) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" 2003-11-15, aeb, added tmpnam_r +.\" +.th tmpnam 3 2021-03-22 "" "linux programmer's manual" +.sh name +tmpnam, tmpnam_r \- create a name for a temporary file +.sh synopsis +.nf +.b #include +.pp +.bi "char *tmpnam(char *" s ); +.bi "char *tmpnam_r(char *" s ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br tmpnam_r () +.nf + since glibc 2.19: + _default_source + up to and including glibc 2.19: + _bsd_source || _svid_source +.fi +.sh description +.b note: +avoid using these functions; use +.br mkstemp (3) +or +.br tmpfile (3) +instead. +.pp +the +.br tmpnam () +function returns a pointer to a string that is a valid filename, +and such that a file with this name did not exist at some point +in time, so that naive programmers may think it +a suitable name for a temporary file. +if the argument +.i s +is null, this name is generated in an internal static buffer +and may be overwritten by the next call to +.br tmpnam (). +if +.i s +is not null, the name is copied to the character array (of length +at least +.ir l_tmpnam ) +pointed to by +.i s +and the value +.i s +is returned in case of success. +.pp +the created pathname has a directory prefix +.ir p_tmpdir . +(both +.i l_tmpnam +and +.i p_tmpdir +are defined in +.ir , +just like the +.b tmp_max +mentioned below.) +.pp +the +.br tmpnam_r () +function performs the same task as +.br tmpnam (), +but returns null (to indicate an error) if +.i s +is null. +.sh return value +these functions return a pointer to a unique temporary +filename, or null if a unique name cannot be generated. +.sh errors +no errors are defined. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br tmpnam () +t} thread safety mt-unsafe race:tmpnam/!s +t{ +.br tmpnam_r () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +.br tmpnam (): +svr4, 4.3bsd, c89, c99, posix.1-2001. +posix.1-2008 marks +.br tmpnam () +as obsolete. +.pp +.br tmpnam_r () +is a nonstandard extension that is also available +.\" appears to be on solaris +on a few other systems. +.sh notes +the +.br tmpnam () +function generates a different string each time it is called, +up to +.b tmp_max +times. +if it is called more than +.b tmp_max +times, +the behavior is implementation defined. +.pp +although these functions generate names that are difficult to guess, +it is nevertheless possible that between the time that +the pathname is returned and the time that the program opens it, +another program might create that pathname using +.br open (2), +or create it as a symbolic link. +this can lead to security holes. +to avoid such possibilities, use the +.br open (2) +.b o_excl +flag to open the pathname. +or better yet, use +.br mkstemp (3) +or +.br tmpfile (3). +.pp +portable applications that use threads cannot call +.br tmpnam () +with a null argument if either +.b _posix_threads +or +.b _posix_thread_safe_functions +is defined. +.sh bugs +never use these functions. +use +.br mkstemp (3) +or +.br tmpfile (3) +instead. +.sh see also +.br mkstemp (3), +.br mktemp (3), +.br tempnam (3), +.br tmpfile (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" +.th wcswidth 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +wcswidth \- determine columns needed for a fixed-size wide-character string +.sh synopsis +.nf +.br "#define _xopen_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "int wcswidth(const wchar_t *" s ", size_t " n ); +.fi +.sh description +the +.br wcswidth () +function returns the +number of columns needed to represent +the wide-character string pointed to by +.ir s , +but at most +.i n +wide +characters. +if a nonprintable wide character occurs among these characters, +\-1 is returned. +.sh return value +the +.br wcswidth () +function +returns the number of column positions for the +wide-character string +.ir s , +truncated to at most length +.ir n . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br wcswidth () +t} thread safety mt-safe locale +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +the behavior of +.br wcswidth () +depends on the +.b lc_ctype +category of the +current locale. +.sh see also +.br iswprint (3), +.br wcwidth (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de) +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under gpl +.\" %%%license_end +.\" +.th complex 7 2021-03-22 "" "linux programmer's manual" +.sh name +complex \- basics of complex mathematics +.sh synopsis +.nf +.b #include +.fi +.sh description +complex numbers are numbers of the form z = a+b*i, where a and b are +real numbers and i = sqrt(\-1), so that i*i = \-1. +.pp +there are other ways to represent that number. +the pair (a,b) of real +numbers may be viewed as a point in the plane, given by x- and +y-coordinates. +this same point may also be described by giving +the pair of real numbers (r,phi), where r is the distance to the origin o, +and phi the angle between the x-axis and the line oz. +now +z = r*exp(i*phi) = r*(cos(phi)+i*sin(phi)). +.pp +the basic operations are defined on z = a+b*i and w = c+d*i as: +.tp +.b addition: z+w = (a+c) + (b+d)*i +.tp +.b multiplication: z*w = (a*c \- b*d) + (a*d + b*c)*i +.tp +.b division: z/w = ((a*c + b*d)/(c*c + d*d)) + ((b*c \- a*d)/(c*c + d*d))*i +.pp +nearly all math function have a complex counterpart but there are +some complex-only functions. +.sh examples +your c-compiler can work with complex numbers if it supports the c99 standard. +link with \fi\-lm\fp. +the imaginary unit is represented by i. +.pp +.ex +/* check that exp(i * pi) == \-1 */ +#include /* for atan */ +#include +#include + +int +main(void) +{ + double pi = 4 * atan(1.0); + double complex z = cexp(i * pi); + printf("%f + %f * i\en", creal(z), cimag(z)); +} +.ee +.sh see also +.br cabs (3), +.br cacos (3), +.br cacosh (3), +.br carg (3), +.br casin (3), +.br casinh (3), +.br catan (3), +.br catanh (3), +.br ccos (3), +.br ccosh (3), +.br cerf (3), +.br cexp (3), +.br cexp2 (3), +.br cimag (3), +.br clog (3), +.br clog10 (3), +.br clog2 (3), +.br conj (3), +.br cpow (3), +.br cproj (3), +.br creal (3), +.br csin (3), +.br csinh (3), +.br csqrt (3), +.br ctan (3), +.br ctanh (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1998, 1999 thorsten kukuk (kukuk@vt.uni-paderborn.de) +.\" copyright (c) 2011, mark r. bannister +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th nsswitch.conf 5 2017-05-03 "linux" "linux programmer's manual" +.sh name +nsswitch.conf \- name service switch configuration file +.sh description +the name service switch (nss) configuration file, +.ir /etc/nsswitch.conf , +is used by the gnu c library and certain other applications to determine +the sources from which to obtain name-service information in +a range of categories, +and in what order. +each category of information is identified by a database name. +.pp +the file is plain ascii text, with columns separated by spaces or tab +characters. +the first column specifies the database name. +the remaining columns describe the order of sources to query and a +limited set of actions that can be performed by lookup result. +.pp +the following databases are understood by the gnu c library: +.tp 12 +.b aliases +mail aliases, used by +.br getaliasent (3) +and related functions. +.tp +.b ethers +ethernet numbers. +.tp +.b group +groups of users, used by +.br getgrent (3) +and related functions. +.tp +.b hosts +host names and numbers, used by +.br gethostbyname (3) +and related functions. +.tp +.b initgroups +supplementary group access list, used by +.br getgrouplist (3) +function. +.tp +.b netgroup +network-wide list of hosts and users, used for access rules. +c libraries before glibc 2.1 supported netgroups only over nis. +.tp +.b networks +network names and numbers, used by +.br getnetent (3) +and related functions. +.tp +.b passwd +user passwords, used by +.br getpwent (3) +and related functions. +.tp +.b protocols +network protocols, used by +.br getprotoent (3) +and related functions. +.tp +.b publickey +public and secret keys for secure_rpc used by nfs and nis+. +.tp +.b rpc +remote procedure call names and numbers, used by +.br getrpcbyname (3) +and related functions. +.tp +.b services +network services, used by +.br getservent (3) +and related functions. +.tp +.b shadow +shadow user passwords, used by +.br getspnam (3) +and related functions. +.pp +the gnu c library ignores databases with unknown names. +some applications use this to implement special handling for their own +databases. +for example, +.br sudo (8) +consults the +.b sudoers +database. +.pp +here is an example +.i /etc/nsswitch.conf +file: +.pp +.in +4n +.ex +passwd: compat +group: compat +shadow: compat + +hosts: dns [!unavail=return] files +networks: nis [notfound=return] files +ethers: nis [notfound=return] files +protocols: nis [notfound=return] files +rpc: nis [notfound=return] files +services: nis [notfound=return] files +.ee +.in +.pp +the first column is the database name. +the remaining columns specify: +.ip * 3 +one or more service specifications, for example, "files", "db", or "nis". +the order of the services on the line determines the order in which +those services will be queried, in turn, until a result is found. +.ip * +optional actions to perform if a particular result is obtained +from the preceding service, for example, "[notfound=return]". +.pp +the service specifications supported on your system depend on the +presence of shared libraries, and are therefore extensible. +libraries called +.ib /lib/libnss_service.so. x +will provide the named +.ir service . +on a standard installation, you can use +"files", "db", "nis", and "nisplus". +for the +.b hosts +database, you can additionally specify "dns". +for the +.br passwd , +.br group , +and +.b shadow +databases, you can additionally specify +"compat" (see +.b "compatibility mode" +below). +the version number +.b x +may be 1 for glibc 2.0, or 2 for glibc 2.1 and later. +on systems with additional libraries installed, you may have access to +further services such as "hesiod", "ldap", "winbind", and "wins". +.pp +an action may also be specified following a service specification. +the action modifies the behavior following a result obtained +from the preceding data source. +action items take the general form: +.pp +.rs 4 +.ri [ status = action ] +.br +.ri [! status = action ] +.re +.pp +where +.pp +.rs 4 +.i status +=> +.b success +| +.b notfound +| +.b unavail +| +.b tryagain +.br +.i action +=> +.b return +| +.b continue +| +.b merge +.re +.pp +the ! negates the test, matching all possible results except the +one specified. +the case of the keywords is not significant. +.pp +the +.i status +value is matched against the result of the lookup function called by +the preceding service specification, and can be one of: +.rs 4 +.tp 12 +.b success +no error occurred and the requested entry is returned. +the default action for this condition is "return". +.tp +.b notfound +the lookup succeeded, but the requested entry was not found. +the default action for this condition is "continue". +.tp +.b unavail +the service is permanently unavailable. +this can mean either that the +required file cannot be read, or, for network services, that the server +is not available or does not allow queries. +the default action for this condition is "continue". +.tp +.b tryagain +the service is temporarily unavailable. +this could mean a file is +locked or a server currently cannot accept more connections. +the default action for this condition is "continue". +.re +.pp +the +.i action +value can be one of: +.rs 4 +.tp 12 +.b return +return a result now. +do not call any further lookup functions. +however, for compatibility reasons, if this is the selected action for the +.b group +database and the +.b notfound +status, and the configuration file does not contain the +.b initgroups +line, the next lookup function is always called, +without affecting the search result. +.tp +.b continue +call the next lookup function. +.tp +.b merge +.i [success=merge] +is used between two database entries. +when a group is located in the first of the two group entries, +processing will continue on to the next one. +if the group is also found in the next entry (and the group name and gid +are an exact match), the member list of the second entry will be added +to the group object to be returned. +available since glibc 2.24. +note that merging will not be done for +.br getgrent (3) +nor will duplicate members be pruned when they occur in both entries +being merged. +.re +.ss compatibility mode (compat) +the nss "compat" service is similar to "files" except that it +additionally permits special entries in corresponding files +for granting users or members of netgroups access to the system. +the following entries are valid in this mode: +.rs 4 +.pp +for +.b passwd +and +.b shadow +databases: +.rs 4 +.tp 12 +.bi + user +include the specified +.i user +from the nis passwd/shadow map. +.tp +.bi +@ netgroup +include all users in the given +.ir netgroup . +.tp +.bi \- user +exclude the specified +.i user +from the nis passwd/shadow map. +.tp +.bi \-@ netgroup +exclude all users in the given +.ir netgroup . +.tp +.b + +include every user, except previously excluded ones, from the +nis passwd/shadow map. +.re +.pp +for +.b group +database: +.rs 4 +.tp 12 +.bi + group +include the specified +.i group +from the nis group map. +.tp +.bi \- group +exclude the specified +.i group +from the nis group map. +.tp +.b + +include every group, except previously excluded ones, from the +nis group map. +.re +.re +.pp +by default, the source is "nis", but this may be +overridden by specifying any nss service except "compat" itself +as the source for the pseudo-databases +.br passwd_compat , +.br group_compat , +and +.br shadow_compat . +.sh files +a service named +.i service +is implemented by a shared object library named +.ib libnss_service.so. x +that resides in +.ir /lib . +.rs 4 +.tp 25 +.pd 0 +.i /etc/nsswitch.conf +nss configuration file. +.tp +.ib /lib/libnss_compat.so. x +implements "compat" source. +.tp +.ib /lib/libnss_db.so. x +implements "db" source. +.tp +.ib /lib/libnss_dns.so. x +implements "dns" source. +.tp +.ib /lib/libnss_files.so. x +implements "files" source. +.tp +.ib /lib/libnss_hesiod.so. x +implements "hesiod" source. +.tp +.ib /lib/libnss_nis.so. x +implements "nis" source. +.tp +.ib /lib/libnss_nisplus.so. x +implements "nisplus" source. +.pd +.re +.pp +the following files are read when "files" source is specified +for respective databases: +.rs 4 +.tp 12 +.pd 0 +.b aliases +.i /etc/aliases +.tp +.b ethers +.i /etc/ethers +.tp +.b group +.i /etc/group +.tp +.b hosts +.i /etc/hosts +.tp +.b initgroups +.i /etc/group +.tp +.b netgroup +.i /etc/netgroup +.tp +.b networks +.i /etc/networks +.tp +.b passwd +.i /etc/passwd +.tp +.b protocols +.i /etc/protocols +.tp +.b publickey +.i /etc/publickey +.tp +.b rpc +.i /etc/rpc +.tp +.b services +.i /etc/services +.tp +.b shadow +.i /etc/shadow +.pd +.re +.sh notes +within each process that uses +.br nsswitch.conf , +the entire file is read only once. +if the file is later changed, the +process will continue using the old configuration. +.pp +traditionally, there was only a single source for service information, +often in the form of a single configuration +file (e.g., \fi/etc/passwd\fp). +however, as other name services, such as the network information +service (nis) and the domain name service (dns), became popular, +a method was needed +that would be more flexible than fixed search orders coded into +the c library. +the name service switch mechanism, +which was based on the mechanism used by +sun microsystems in the solaris 2 c library, +introduced a cleaner solution to the problem. +.sh see also +.br getent (1), +.br nss (5) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/rpc.3 + +.\" copyright (c) 2014, michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th group_member 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +group_member \- test whether a process is in a group +.sh synopsis +.nf +.b #include +.pp +.bi "int group_member(gid_t " gid ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br group_member (): +.nf + _gnu_source +.fi +.sh description +the +.br group_member () +function tests whether any of the caller's supplementary group ids +(as returned by +.br getgroups (2)) +matches +.ir gid . +.sh return value +the +.br group_member () +function returns nonzero if any of the caller's +supplementary group ids matches +.ir gid , +and zero otherwise. +.sh conforming to +this function is a nonstandard gnu extension. +.sh see also +.br getgid (2), +.br getgroups (2), +.br getgrouplist (3), +.br group (5) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/expm1.3 + +.so man2/outb.2 + +.so man3/isgreater.3 + +.\" copyright (c) 2008, 2016 michael kerrisk +.\" and copyright (c) 2016 florian weimer +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th readdir_r 3 2021-03-22 "" "linux programmer's manual" +.sh name +readdir_r \- read a directory +.sh synopsis +.nf +.b #include +.pp +.bi "int readdir_r(dir *restrict " dirp ", struct dirent *restrict " entry , +.bi " struct dirent **restrict " result ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br readdir_r (): +.nf + _posix_c_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.sh description +this function is deprecated; use +.br readdir (3) +instead. +.pp +the +.br readdir_r () +function was invented as a reentrant version of +.br readdir (3). +it reads the next directory entry from the directory stream +.ir dirp , +and returns it in the caller-allocated buffer pointed to by +.ir entry . +for details of the +.ir dirent +structure, see +.br readdir (3). +.pp +a pointer to the returned buffer is placed in +.ir *result ; +if the end of the directory stream was encountered, +then null is instead returned in +.ir *result . +.pp +it is recommended that applications use +.br readdir (3) +instead of +.br readdir_r (). +furthermore, since version 2.24, glibc deprecates +.br readdir_r (). +the reasons are as follows: +.ip * 3 +on systems where +.br name_max +is undefined, calling +.br readdir_r () +may be unsafe because the interface does not allow the caller to specify +the length of the buffer used for the returned directory entry. +.ip * +on some systems, +.br readdir_r () +can't read directory entries with very long names. +when the glibc implementation encounters such a name, +.br readdir_r () +fails with the error +.b enametoolong +.ir "after the final directory entry has been read" . +on some other systems, +.br readdir_r () +may return a success status, but the returned +.ir d_name +field may not be null terminated or may be truncated. +.ip * +in the current posix.1 specification (posix.1-2008), +.br readdir (3) +is not required to be thread-safe. +however, in modern implementations (including the glibc implementation), +concurrent calls to +.br readdir (3) +that specify different directory streams are thread-safe. +therefore, the use of +.br readdir_r () +is generally unnecessary in multithreaded programs. +in cases where multiple threads must read from the same directory stream, +using +.br readdir (3) +with external synchronization is still preferable to the use of +.br readdir_r (), +for the reasons given in the points above. +.ip * +it is expected that a future version of posix.1 +.\" fixme . +.\" http://www.austingroupbugs.net/view.php?id=696 +will make +.br readdir_r () +obsolete, and require that +.br readdir (3) +be thread-safe when concurrently employed on different directory streams. +.sh return value +the +.br readdir_r () +function returns 0 on success. +on error, it returns a positive error number (listed under errors). +if the end of the directory stream is reached, +.br readdir_r () +returns 0, and returns null in +.ir *result . +.sh errors +.tp +.b ebadf +invalid directory stream descriptor \fidirp\fp. +.tp +.b enametoolong +a directory entry whose name was too long to be read was encountered. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br readdir_r () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh see also +.br readdir (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" iso/iec 9899:1999 +.\" +.th iswalnum 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +iswalnum \- test for alphanumeric wide character +.sh synopsis +.nf +.b #include +.pp +.bi "int iswalnum(wint_t " wc ); +.fi +.sh description +the +.br iswalnum () +function is the wide-character equivalent of the +.br isalnum (3) +function. +it tests whether +.i wc +is a wide character +belonging to the wide-character class "alnum". +.pp +the wide-character class "alnum" is a subclass of the wide-character class +"graph", and therefore also a subclass of the wide-character class "print". +.pp +being a subclass of the wide-character class "print", +the wide-character class +"alnum" is disjoint from the wide-character class "cntrl". +.pp +being a subclass of the wide-character class "graph", +the wide-character class "alnum" is disjoint from +the wide-character class "space" and its subclass "blank". +.pp +the wide-character class "alnum" is disjoint from the wide-character class +"punct". +.pp +the wide-character class "alnum" is the union of the wide-character classes +"alpha" and "digit". +as such, it also contains the wide-character class +"xdigit". +.pp +the wide-character class "alnum" always contains at least the letters \(aqa\(aq +to \(aqz\(aq, \(aqa\(aq to \(aqz\(aq and the digits \(aq0\(aq to \(aq9\(aq. +.sh return value +the +.br iswalnum () +function returns nonzero +if +.i wc +is a wide character +belonging to the wide-character class "alnum". +otherwise, it returns zero. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br iswalnum () +t} thread safety mt-safe locale +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh notes +the behavior of +.br iswalnum () +depends on the +.b lc_ctype +category of the +current locale. +.sh see also +.br isalnum (3), +.br iswctype (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/getttyent.3 + +the files in this directory are scripts for man-pages maintenance tasks. +they may be useful for downstream man-pages package maintainers or for +man-pages translators. this directory does not contain any files that +need to be installed in order to use the manual pages. + +.so man3/rpc.3 + +.so man3/strtol.3 + +.so man3/wprintf.3 + +man-pages|linux kernel and c library user-space interface documentation|https://www.kernel.org/doc/man-pages/|repo|git|https://www.kernel.org/doc/man-pages/index.html|https://www.kernel.org/doc/man-pages/reporting_bugs.html|2021-08-27 + +.\" copyright (c) 2006, michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th sockatmark 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +sockatmark \- determine whether socket is at out-of-band mark +.sh synopsis +.nf +.b #include +.pp +.bi "int sockatmark(int " sockfd ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br sockatmark (): +.nf + _posix_c_source >= 200112l +.fi +.sh description +.br sockatmark () +returns a value indicating whether or not the socket referred +to by the file descriptor +.i sockfd +is at the out-of-band mark. +if the socket is at the mark, then 1 is returned; +if the socket is not at the mark, 0 is returned. +this function does not remove the out-of-band mark. +.sh return value +a successful call to +.br sockatmark () +returns 1 if the socket is at the out-of-band mark, or 0 if it is not. +on error, \-1 is returned and +.i errno +is set to indicate the error. +.sh errors +.tp +.b ebadf +.i sockfd +is not a valid file descriptor. +.tp +.b einval +.\" posix.1 says enotty for this case +.i sockfd +is not a file descriptor to which +.br sockatmark () +can be applied. +.sh versions +.br sockatmark () +was added to glibc in version 2.2.4. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br sockatmark () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +if +.br sockatmark () +returns 1, then the out-of-band data can be read using the +.b msg_oob +flag of +.br recv (2). +.pp +out-of-band data is supported only on some stream socket protocols. +.pp +.br sockatmark () +can safely be called from a handler for the +.b sigurg +signal. +.pp +.br sockatmark () +is implemented using the +.b siocatmark +.br ioctl (2) +operation. +.sh bugs +prior to glibc 2.4, +.br sockatmark () +did not work. +.sh examples +the following code can be used after receipt of a +.b sigurg +signal to read (and discard) all data up to the mark, +and then read the byte of data at the mark: +.pp +.ex + char buf[buf_len]; + char oobdata; + int atmark, s; + + for (;;) { + atmark = sockatmark(sockfd); + if (atmark == \-1) { + perror("sockatmark"); + break; + } + + if (atmark) + break; + + s = read(sockfd, buf, buf_len); + if (s == \-1) + perror("read"); + if (s <= 0) + break; + } + + if (atmark == 1) { + if (recv(sockfd, &oobdata, 1, msg_oob) == \-1) { + perror("recv"); + ... + } + } +.ee +.sh see also +.br fcntl (2), +.br recv (2), +.br send (2), +.br tcp (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/tgamma.3 + +.\" copyright 1993 giorgio ciucci (giorgio@crcc.it) +.\" and copyright 2004, 2005 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified tue oct 22 08:11:14 edt 1996 by eric s. raymond +.\" modified sun feb 18 01:59:29 2001 by andries e. brouwer +.\" modified, 27 may 2004, michael kerrisk +.\" added notes on cap_ipc_owner requirement +.\" modified, 17 jun 2004, michael kerrisk +.\" added notes on cap_sys_admin requirement for ipc_set and ipc_rmid +.\" modified, 11 nov 2004, michael kerrisk +.\" language and formatting clean-ups +.\" added msqid_ds and ipc_perm structure definitions +.\" 2005-08-02, mtk: added ipc_info, msg_info, msg_stat descriptions +.\" 2018-03-20, dbueso: added msg_stat_any description. +.\" +.th msgctl 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +msgctl \- system v message control operations +.sh synopsis +.nf +.b #include +.pp +.bi "int msgctl(int " msqid ", int " cmd ", struct msqid_ds *" buf ); +.fi +.sh description +.br msgctl () +performs the control operation specified by +.i cmd +on the system\ v message queue with identifier +.ir msqid . +.pp +the +.i msqid_ds +data structure is defined in \fi\fp as follows: +.pp +.in +4n +.ex +struct msqid_ds { + struct ipc_perm msg_perm; /* ownership and permissions */ + time_t msg_stime; /* time of last msgsnd(2) */ + time_t msg_rtime; /* time of last msgrcv(2) */ + time_t msg_ctime; /* time of creation or last + modification by msgctl() */ + unsigned long msg_cbytes; /* # of bytes in queue */ + msgqnum_t msg_qnum; /* # number of messages in queue */ + msglen_t msg_qbytes; /* maximum # of bytes in queue */ + pid_t msg_lspid; /* pid of last msgsnd(2) */ + pid_t msg_lrpid; /* pid of last msgrcv(2) */ +}; +.ee +.in +.pp +the fields of the +.i msgid_ds +structure are as follows: +.tp 11 +.i msg_perm +this is an +.i ipc_perm +structure (see below) that specifies the access permissions on the message +queue. +.tp +.i msg_stime +time of the last +.br msgsnd (2) +system call. +.tp +.i msg_rtime +time of the last +.br msgrcv (2) +system call. +.tp +.i msg_ctime +time of creation of queue or time of last +.br msgctl () +.br ipc_set +operation. +.tp +.i msg_cbytes +number of bytes in all messages currently on the message queue. +this is a nonstandard linux extension that is not specified in posix. +.tp +.i msg_qnum +number of messages currently on the message queue. +.tp +.i msg_qbytes +maximum number of bytes of message text allowed on the message +queue. +.tp +.i msg_lspid +id of the process that performed the last +.br msgsnd (2) +system call. +.tp +.i msg_lrpid +id of the process that performed the last +.br msgrcv (2) +system call. +.pp +the +.i ipc_perm +structure is defined as follows +(the highlighted fields are settable using +.br ipc_set ): +.pp +.in +4n +.ex +struct ipc_perm { + key_t __key; /* key supplied to msgget(2) */ + uid_t \fbuid\fp; /* effective uid of owner */ + gid_t \fbgid\fp; /* effective gid of owner */ + uid_t cuid; /* effective uid of creator */ + gid_t cgid; /* effective gid of creator */ + unsigned short \fbmode\fp; /* permissions */ + unsigned short __seq; /* sequence number */ +}; +.ee +.in +.pp +the least significant 9 bits of the +.i mode +field of the +.i ipc_perm +structure define the access permissions for the message queue. +the permission bits are as follows: +.ts +l l. +0400 read by user +0200 write by user +0040 read by group +0020 write by group +0004 read by others +0002 write by others +.te +.pp +bits 0100, 0010, and 0001 (the execute bits) are unused by the system. +.pp +valid values for +.i cmd +are: +.tp +.b ipc_stat +copy information from the kernel data structure associated with +.i msqid +into the +.i msqid_ds +structure pointed to by +.ir buf . +the caller must have read permission on the message queue. +.tp +.b ipc_set +write the values of some members of the +.i msqid_ds +structure pointed to by +.i buf +to the kernel data structure associated with this message queue, +updating also its +.i msg_ctime +member. +.ip +the following members of the structure are updated: +.ir msg_qbytes , +.ir msg_perm.uid , +.ir msg_perm.gid , +and (the least significant 9 bits of) +.ir msg_perm.mode . +.ip +the effective uid of the calling process must match the owner +.ri ( msg_perm.uid ) +or creator +.ri ( msg_perm.cuid ) +of the message queue, or the caller must be privileged. +appropriate privilege (linux: the +.b cap_sys_resource +capability) is required to raise the +.i msg_qbytes +value beyond the system parameter +.br msgmnb . +.tp +.b ipc_rmid +immediately remove the message queue, +awakening all waiting reader and writer processes (with an error +return and +.i errno +set to +.br eidrm ). +the calling process must have appropriate privileges +or its effective user id must be either that of the creator or owner +of the message queue. +the third argument to +.br msgctl () +is ignored in this case. +.tp +.br ipc_info " (linux-specific)" +return information about system-wide message queue limits and +parameters in the structure pointed to by +.ir buf . +this structure is of type +.i msginfo +(thus, a cast is required), +defined in +.i +if the +.b _gnu_source +feature test macro is defined: +.ip +.in +4n +.ex +struct msginfo { + int msgpool; /* size in kibibytes of buffer pool + used to hold message data; + unused within kernel */ + int msgmap; /* maximum number of entries in message + map; unused within kernel */ + int msgmax; /* maximum number of bytes that can be + written in a single message */ + int msgmnb; /* maximum number of bytes that can be + written to queue; used to initialize + msg_qbytes during queue creation + (msgget(2)) */ + int msgmni; /* maximum number of message queues */ + int msgssz; /* message segment size; + unused within kernel */ + int msgtql; /* maximum number of messages on all queues + in system; unused within kernel */ + unsigned short msgseg; + /* maximum number of segments; + unused within kernel */ +}; +.ee +.in +.ip +the +.ir msgmni , +.ir msgmax , +and +.i msgmnb +settings can be changed via +.i /proc +files of the same name; see +.br proc (5) +for details. +.tp +.br msg_info " (linux-specific)" +return a +.i msginfo +structure containing the same information as for +.br ipc_info , +except that the following fields are returned with information +about system resources consumed by message queues: the +.i msgpool +field returns the number of message queues that currently exist +on the system; the +.i msgmap +field returns the total number of messages in all queues +on the system; and the +.i msgtql +field returns the total number of bytes in all messages +in all queues on the system. +.tp +.br msg_stat " (linux-specific)" +return a +.i msqid_ds +structure as for +.br ipc_stat . +however, the +.i msqid +argument is not a queue identifier, but instead an index into +the kernel's internal array that maintains information about +all message queues on the system. +.tp +.br msg_stat_any " (linux-specific, since linux 4.17)" +return a +.i msqid_ds +structure as for +.br msg_stat . +however, +.i msg_perm.mode +is not checked for read access for +.ir msqid +meaning that any user can employ this operation (just as any user may read +.ir /proc/sysvipc/msg +to obtain the same information). +.sh return value +on success, +.br ipc_stat , +.br ipc_set , +and +.b ipc_rmid +return 0. +a successful +.b ipc_info +or +.b msg_info +operation returns the index of the highest used entry in the +kernel's internal array recording information about all +message queues. +(this information can be used with repeated +.b msg_stat +or +.b msg_stat_any +operations to obtain information about all queues on the system.) +a successful +.b msg_stat +or +.b msg_stat_any +operation returns the identifier of the queue whose index was given in +.ir msqid . +.pp +on failure, \-1 is returned and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eacces +the argument +.i cmd +is equal to +.b ipc_stat +or +.br msg_stat , +but the calling process does not have read permission on the message queue +.ir msqid , +and does not have the +.b cap_ipc_owner +capability in the user namespace that governs its ipc namespace. +.tp +.b efault +the argument +.i cmd +has the value +.b ipc_set +or +.br ipc_stat , +but the address pointed to by +.i buf +isn't accessible. +.tp +.b eidrm +the message queue was removed. +.tp +.b einval +invalid value for +.i cmd +or +.ir msqid . +or: for a +.b msg_stat +operation, the index value specified in +.i msqid +referred to an array slot that is currently unused. +.tp +.b eperm +the argument +.i cmd +has the value +.b ipc_set +or +.br ipc_rmid , +but the effective user id of the calling process is not the creator +(as found in +.ir msg_perm.cuid ) +or the owner +(as found in +.ir msg_perm.uid ) +of the message queue, +and the caller is not privileged (linux: does not have the +.b cap_sys_admin +capability). +.tp +.b eperm +an attempt +.rb ( ipc_set ) +was made to increase +.i msg_qbytes +beyond the system parameter +.br msgmnb , +but the caller is not privileged (linux: does not have the +.b cap_sys_resource +capability). +.sh conforming to +posix.1-2001, posix.1-2008, svr4. +.\" svid does not document the eidrm error condition. +.sh notes +the +.br ipc_info , +.br msg_stat , +and +.b msg_info +operations are used by the +.br ipcs (1) +program to provide information on allocated resources. +in the future these may modified or moved to a +.i /proc +filesystem interface. +.pp +various fields in the \fistruct msqid_ds\fp were +typed as +.i short +under linux 2.2 +and have become +.i long +under linux 2.4. +to take advantage of this, +a recompilation under glibc-2.1.91 or later should suffice. +(the kernel distinguishes old and new calls by an +.b ipc_64 +flag in +.ir cmd .) +.sh see also +.br msgget (2), +.br msgrcv (2), +.br msgsnd (2), +.br capabilities (7), +.br mq_overview (7), +.br sysvipc (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/getmntent.3 + +.so man3/tailq.3 + +.\" copyright 2000 nicolás lichtmaier +.\" created 2000-07-22 00:52-0300 +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" modified 2002-07-23 19:21:35 cest 2002 walter harms +.\" +.\" +.\" modified 2003-04-04, aeb +.\" +.th encrypt 3 2021-03-22 "" "linux programmer's manual" +.sh name +encrypt, setkey, encrypt_r, setkey_r \- encrypt 64-bit messages +.sh synopsis +.nf +.br "#define _xopen_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "void encrypt(char " block "[64], int " edflag ); +.pp +.br "#define _xopen_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "void setkey(const char *" key ); +.pp +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b "#include " +.pp +.bi "void setkey_r(const char *" key ", struct crypt_data *" data ); +.bi "void encrypt_r(char *" block ", int " edflag \ +", struct crypt_data *" data ); +.fi +.pp +each of these requires linking with \fi\-lcrypt\fp. +.sh description +these functions encrypt and decrypt 64-bit messages. +the +.br setkey () +function sets the key used by +.br encrypt (). +the +.i key +argument used here is an array of 64 bytes, each of which has +numerical value 1 or 0. +the bytes key[n] where n=8*i-1 are ignored, +so that the effective key length is 56 bits. +.pp +the +.br encrypt () +function modifies the passed buffer, encoding if +.i edflag +is 0, and decoding if 1 is being passed. +like the +.i key +argument, also +.i block +is a bit vector representation of the actual value that is encoded. +the result is returned in that same vector. +.pp +these two functions are not reentrant, that is, the key data is +kept in static storage. +the functions +.br setkey_r () +and +.br encrypt_r () +are the reentrant versions. +they use the following +structure to hold the key data: +.pp +.in +4n +.ex +struct crypt_data { + char keysched[16 * 8]; + char sb0[32768]; + char sb1[32768]; + char sb2[32768]; + char sb3[32768]; + char crypt_3_buf[14]; + char current_salt[2]; + long current_saltbits; + int direction; + int initialized; +}; +.ee +.in +.pp +before calling +.br setkey_r () +set +.i data\->initialized +to zero. +.sh return value +these functions do not return any value. +.sh errors +set +.i errno +to zero before calling the above functions. +on success, +.i errno +is unchanged. +.tp +.b enosys +the function is not provided. +(for example because of former usa export restrictions.) +.sh versions +because they employ the des block cipher, +which is no longer considered secure, +.br crypt (), +.br crypt_r (), +.br setkey (), +and +.br setkey_r () +were removed in glibc 2.28. +applications should switch to a modern cryptography library, such as +.br libgcrypt . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br encrypt (), +.br setkey () +t} thread safety mt-unsafe race:crypt +t{ +.br encrypt_r (), +.br setkey_r () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +.br encrypt (), +.br setkey (): +posix.1-2001, posix.1-2008, sus, svr4. +.pp +the functions +.br encrypt_r () +and +.br setkey_r () +are gnu extensions. +.sh notes +.ss availability in glibc +see +.br crypt (3). +.ss features in glibc +in glibc 2.2, these functions use the des algorithm. +.sh examples +.ex +#define _xopen_source +#include +#include +#include +#include + +int +main(void) +{ + char key[64]; + char orig[9] = "eggplant"; + char buf[64]; + char txt[9]; + + for (int i = 0; i < 64; i++) { + key[i] = rand() & 1; + } + + for (int i = 0; i < 8; i++) { + for (int j = 0; j < 8; j++) { + buf[i * 8 + j] = orig[i] >> j & 1; + } + setkey(key); + } + printf("before encrypting: %s\en", orig); + + encrypt(buf, 0); + for (int i = 0; i < 8; i++) { + for (int j = 0, txt[i] = \(aq\e0\(aq; j < 8; j++) { + txt[i] |= buf[i * 8 + j] << j; + } + txt[8] = \(aq\e0\(aq; + } + printf("after encrypting: %s\en", txt); + + encrypt(buf, 1); + for (int i = 0; i < 8; i++) { + for (int j = 0, txt[i] = \(aq\e0\(aq; j < 8; j++) { + txt[i] |= buf[i * 8 + j] << j; + } + txt[8] = \(aq\e0\(aq; + } + printf("after decrypting: %s\en", txt); + exit(exit_success); +} +.ee +.sh see also +.br cbc_crypt (3), +.br crypt (3), +.br ecb_crypt (3), +.\" .br fcrypt (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2001 richard braakman +.\" copyright (c) 2004 alastair mckinstry +.\" copyright (c) 2005 lars wirzenius +.\" copyright (c) 2014 marko myllynen +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" this manual page was initially written by richard braakman +.\" on behalf of the debian gnu/linux project and anyone else +.\" who wants it. it was amended by alastair mckinstry to +.\" explain new iso 14652 elements, and amended further by +.\" lars wirzenius to document new functionality (as of gnu +.\" c library 2.3.5). +.\" +.th localedef 1 2021-03-22 "linux" "linux user manual" +.sh name +localedef \- compile locale definition files +.sh synopsis +.ad l +.nh +.b localedef +.ri [ options ] +.i outputpath +.br +.b "localedef \-\-add\-to\-archive" +.ri [ options ] +.i compiledpath +.br +.b "localedef \-\-delete\-from\-archive" +.ri [ options ] +.ir localename " ..." +.br +.b "localedef \-\-list\-archive" +.ri [ options ] +.br +.b "localedef \-\-help" +.br +.b "localedef \-\-usage" +.br +.b "localedef \-\-version" +.ad b +.hy +.sh description +the +.b localedef +program reads the indicated +.i charmap +and +.i input +files, compiles them to a binary form quickly usable by the +locale functions in the c library +.rb ( setlocale (3), +.br localeconv (3), +etc.), and places the output in +.ir outputpath . +.pp +the +.i outputpath +argument is interpreted as follows: +.ip * 3 +if +.i outputpath +contains a slash character ('/'), it is interpreted as the name of the +directory where the output definitions are to be stored. +in this case, there is a separate output file for each locale category +.ri ( lc_time , +.ir lc_numeric , +and so on). +.ip * +if the +.b \-\-no\-archive +option is used, +.i outputpath +is the name of a subdirectory in +.i /usr/lib/locale +where per-category compiled files are placed. +.ip * +otherwise, +.i outputpath +is the name of a locale and the compiled locale data is added to the +archive file +.ir /usr/lib/locale/locale\-archive . +a locale archive is a memory-mapped file which contains all the +system-provided locales; +it is used by all localized programs when the environment variable +.b locpath +is not set. +.pp +in any case, +.b localedef +aborts if the directory in which it tries to write locale files has +not already been created. +.pp +if no +.i charmapfile +is given, the value +.i ansi_x3.4\-1968 +(for ascii) is used by default. +if no +.i inputfile +is given, or if it is given as a dash +(\-), +.b localedef +reads from standard input. +.sh options +.ss operation-selection options +a few options direct +.b localedef +to do something other than compile locale definitions. +only one of these options should be used at a time. +.tp +.b \-\-add\-to\-archive +add the +.i compiledpath +directories to the locale archive file. +the directories should have been created by previous runs of +.br localedef , +using +.br \-\-no\-archive . +.tp +.b \-\-delete\-from\-archive +delete the named locales from the locale archive file. +.tp +.b \-\-list\-archive +list the locales contained in the locale archive file. +.ss other options +some of the following options are sensible only for certain operations; +generally, it should be self-evident which ones. +notice that +.b \-f +and +.b \-c +are reversed from what you might expect; that is, +.b \-f +is not the same as +.br \-\-force . +.tp +.bi \-f " charmapfile" "\fr, \fp\-\-charmap=" charmapfile +specify the file that defines the character set +that is used by the input file. +if +.i charmapfile +contains a slash character ('/'), +it is interpreted as the name of the character map. +otherwise, the file is sought in the current directory +and the default directory for character maps. +if the environment variable +.b i18npath +is set, +.i $i18npath/charmaps/ +and +.i $i18npath/ +are also searched after the current directory. +the default directory for character maps is printed by +.br "localedef \-\-help" . +.tp +.bi \-i " inputfile" "\fr, \fp\-\-inputfile=" inputfile +specify the locale definition file to compile. +the file is sought in the current directory +and the default directory for locale definition files. +if the environment variable +.b i18npath +is set, +.i $i18npath/locales/ +and +.i $i18npath +are also searched after the current directory. +the default directory for locale definition files is printed by +.br "localedef \-\-help" . +.tp +.bi \-u " repertoirefile" "\fr, \fp\-\-repertoire\-map=" repertoirefile +read mappings from symbolic names to unicode code points from +.ir repertoirefile . +if +.i repertoirefile +contains a slash character ('/'), +it is interpreted as the pathname of the repertoire map. +otherwise, the file is sought in the current directory +and the default directory for repertoire maps. +if the environment variable +.b i18npath +is set, +.i $i18npath/repertoiremaps/ +and +.i $i18npath +are also searched after the current directory. +the default directory for repertoire maps is printed by +.br "localedef \-\-help" . +.tp +.bi \-a " aliasfile" "\fr, \fp\-\-alias\-file=" aliasfile +use +.i aliasfile +to look up aliases for locale names. +there is no default aliases file. +.tp +.br \-c ", " \-\-force +write the output files even if warnings were generated about the input +file. +.tp +.br \-v ", " \-\-verbose +generate extra warnings about errors that are normally ignored. +.tp +.b \-\-big\-endian +generate big-endian output. +.tp +.b \-\-little\-endian +generate little-endian output. +.tp +.b \-\-no\-archive +do not use the locale archive file, instead create +.i outputpath +as a subdirectory in the same directory as the locale archive file, +and create separate output files for locale categories in it. +this is helpful to prevent system locale archive updates from overwriting +custom locales created with +.br localedef . +.tp +.b \-\-no\-hard\-links +do not create hard links between installed locales. +.tp +.bi \-\-no\-warnings= warnings +comma-separated list of warnings to disable. +supported warnings are +.i ascii +and +.ir intcurrsym . +.tp +.b \-\-posix +conform strictly to posix. +implies +.br \-\-verbose . +this option currently has no other effect. +posix conformance is assumed if the environment variable +.b posixly_correct +is set. +.tp +.bi \-\-prefix= pathname +set the prefix to be prepended to the full archive pathname. +by default, the prefix is empty. +setting the prefix to +.ir foo , +the archive would be placed in +.ir foo/usr/lib/locale/locale\-archive . +.tp +.b \-\-quiet +suppress all notifications and warnings, and report only fatal errors. +.tp +.b \-\-replace +replace a locale in the locale archive file. +without this option, if the locale is in the archive file already, +an error occurs. +.tp +.bi \-\-warnings= warnings +comma-separated list of warnings to enable. +supported warnings are +.i ascii +and +.ir intcurrsym . +.tp +.br \-? ", " \-\-help +print a usage summary and exit. +also prints the default paths used by +.br localedef . +.tp +.b "\-\-usage" +print a short usage summary and exit. +.tp +.br \-v ", " \-\-version +print the version number, license, and disclaimer of warranty for +.br localedef . +.sh exit status +one of the following exit values can be returned by +.br localedef : +.tp +.b 0 +command completed successfully. +.tp +.b 1 +warnings or errors occurred, output files were written. +.tp +.b 4 +errors encountered, no output created. +.sh environment +.tp +.b posixly_correct +the +.b \-\-posix +flag is assumed if this environment variable is set. +.tp +.b i18npath +a colon-separated list of search directories for files. +.sh files +.tp +.i /usr/share/i18n/charmaps +usual default character map path. +.tp +.i /usr/share/i18n/locales +usual default path for locale definition files. +.tp +.i /usr/share/i18n/repertoiremaps +usual default repertoire map path. +.tp +.i /usr/lib/locale/locale\-archive +usual default locale archive location. +.tp +.i /usr/lib/locale +usual default path for compiled individual locale data files. +.tp +.i outputpath/lc_address +an output file that contains information about formatting of +addresses and geography-related items. +.tp +.i outputpath/lc_collate +an output file that contains information about the rules for comparing +strings. +.tp +.i outputpath/lc_ctype +an output file that contains information about character classes. +.tp +.i outputpath/lc_identification +an output file that contains metadata about the locale. +.tp +.i outputpath/lc_measurement +an output file that contains information about locale measurements +(metric versus us customary). +.tp +.i outputpath/lc_messages/sys_lc_messages +an output file that contains information about the language messages +should be printed in, and what an affirmative or negative answer looks +like. +.tp +.i outputpath/lc_monetary +an output file that contains information about formatting of monetary +values. +.tp +.i outputpath/lc_name +an output file that contains information about salutations for persons. +.tp +.i outputpath/lc_numeric +an output file that contains information about formatting of nonmonetary +numeric values. +.tp +.i outputpath/lc_paper +an output file that contains information about settings related to +standard paper size. +.tp +.i outputpath/lc_telephone +an output file that contains information about formats to be used with +telephone services. +.tp +.i outputpath/lc_time +an output file that contains information about formatting of data and +time values. +.sh conforming to +posix.1-2008. +.sh examples +compile the locale files for finnish in the utf\-8 character set +and add it to the default locale archive with the name +.br fi_fi.utf\-8 : +.pp +.in +4n +.ex +localedef \-f utf\-8 \-i fi_fi fi_fi.utf\-8 +.ee +.in +.pp +the next example does the same thing, but generates files into the +.i fi_fi.utf\-8 +directory which can then be used by programs when the environment +variable +.b locpath +is set to the current directory (note that the last argument must +contain a slash): +.pp +.in +4n +.ex +localedef \-f utf\-8 \-i fi_fi ./fi_fi.utf\-8 +.ee +.in +.sh see also +.br locale (1), +.br charmap (5), +.br locale (5), +.br repertoiremap (5), +.br locale (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" iso/iec 9899:1999 +.\" +.th iswgraph 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +iswgraph \- test for graphic wide character +.sh synopsis +.nf +.b #include +.pp +.bi "int iswgraph(wint_t " wc ); +.fi +.sh description +the +.br iswgraph () +function is the wide-character equivalent of the +.br isgraph (3) +function. +it tests whether +.i wc +is a wide character +belonging to the wide-character class "graph". +.pp +the wide-character class "graph" is a subclass of the wide-character class +"print". +.pp +being a subclass of the wide-character class "print", +the wide-character class +"graph" is disjoint from the wide-character class "cntrl". +.pp +the wide-character class "graph" is disjoint from the wide-character class +"space" and therefore also disjoint from its subclass "blank". +.\" note: unix98 (susv2/xbd/locale.html) says that "graph" and "space" may +.\" have characters in common, except u+0020. but c99 (iso/iec 9899:1999 +.\" section 7.25.2.1.10) says that "space" and "graph" are disjoint. +.pp +the wide-character class "graph" contains all the wide characters from the +wide-character class "print" except the space character. +it therefore contains +the wide-character classes "alnum" and "punct". +.sh return value +the +.br iswgraph () +function returns nonzero +if +.i wc +is a wide character +belonging to the wide-character class "graph". +otherwise, it returns zero. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br iswgraph () +t} thread safety mt-safe locale +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh notes +the behavior of +.br iswgraph () +depends on the +.b lc_ctype +category of the +current locale. +.sh see also +.br isgraph (3), +.br iswctype (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de) +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under gpl +.\" %%%license_end +.\" +.th casinh 3 2021-03-22 "" "linux programmer's manual" +.sh name +casinh, casinhf, casinhl \- complex arc sine hyperbolic +.sh synopsis +.nf +.b #include +.pp +.bi "double complex casinh(double complex " z ); +.bi "float complex casinhf(float complex " z ); +.bi "long double complex casinhl(long double complex " z ); +.pp +link with \fi\-lm\fp. +.fi +.sh description +these functions calculate the complex arc hyperbolic sine of +.ir z . +if \fiy\ =\ casinh(z)\fp, then \fiz\ =\ csinh(y)\fp. +the imaginary part of +.i y +is chosen in the interval [\-pi/2,pi/2]. +.pp +one has: +.pp +.nf + casinh(z) = clog(z + csqrt(z * z + 1)) +.fi +.sh versions +these functions first appeared in glibc in version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br casinh (), +.br casinhf (), +.br casinhl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.sh see also +.br asinh (3), +.br cabs (3), +.br cimag (3), +.br csinh (3), +.br complex (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright ibm corp. 2017 +.\" author: qingfeng hao +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th s390_sthyi 2 2021-03-22 "linux programmer's manual" +.sh name +s390_sthyi \- emulate sthyi instruction +.sh synopsis +.nf +.br "#include " " /* definition of " sthyi_* " constants */" +.br "#include " " /* definition of " sys_* " constants */" +.b #include +.pp +.bi "int syscall(sys_s390_sthyi, unsigned long " function_code , +.bi " void *" resp_buffer ", uint64_t *" return_code , +.bi " unsigned long " flags ); +.fi +.pp +.ir note : +glibc provides no wrapper for +.br s390_sthyi (), +necessitating the use of +.br syscall (2). +.sh description +the +.br s390_sthyi () +system call emulates the sthyi (store hypervisor information) instruction. +it provides hardware resource information for the machine and its +virtualization levels. +this includes cpu type and capacity, as well as the machine model and +other metrics. +.pp +the +.i function_code +argument indicates which function to perform. +the following code(s) are supported: +.tp +.b sthyi_fc_cp_ifl_cap +return cp (central processor) and ifl (integrated facility for linux) +capacity information. +.pp +the +.i resp_buffer +argument specifies the address of a response buffer. +when the +.i function_code +is +.br sthyi_fc_cp_ifl_cap , +the buffer must be one page (4k) in size. +if the system call returns 0, +the response buffer will be filled with cpu capacity information. +otherwise, the response buffer's content is unchanged. +.pp +the +.i return_code +argument stores the return code of the sthyi instruction, +using one of the following values: +.tp +0 +success. +.tp +4 +unsupported function code. +.pp +for further details about +.ir return_code , +.ir function_code , +and +.ir resp_buffer , +see the reference given in notes. +.pp +the +.i flags +argument is provided to allow for future extensions and currently +must be set to 0. +.sh return value +on success (that is: emulation succeeded), the return value of +.br s390_sthyi () +matches the condition code of the sthyi instructions, which is a value +in the range [0..3]. +a return value of 0 indicates that cpu capacity information is stored in +.ir *resp_buffer . +a return value of 3 indicates "unsupported function code" and the content of +.ir *resp_buffer +is unchanged. +the return values 1 and 2 are reserved. +.pp +on error, \-1 is returned, and +.ir errno +is set to indicate the error. +.sh errors +.tp +.b efault +the value specified in +.i resp_buffer +or +.i return_code +is not a valid address. +.tp +.b einval +the value specified in +.i flags +is nonzero. +.tp +.b enomem +allocating memory for handling the cpu capacity information failed. +.tp +.b eopnotsupp +the value specified in +.i function_code +is not valid. +.sh versions +this system call is available since linux 4.15. +.sh conforming to +this linux-specific system call is available only on the s390 architecture. +.sh notes +for details of the sthyi instruction, see +.ur https://www.ibm.com\:/support\:/knowledgecenter\:/ssb27u_6.3.0\:/com.ibm.zvm.v630.hcpb4\:/hcpb4sth.htm +the documentation page +.ue . +.pp +when the system call interface is used, the response buffer doesn't +have to fulfill alignment requirements described in the sthyi +instruction definition. +.pp +the kernel caches the response (for up to one second, as of linux 4.16). +subsequent system call invocations may return the cached response. +.sh see also +.br syscall (2) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1993 by thomas koenig (ig25@rz.uni-karlsruhe.de) +.\" and copyright (c) 2017 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified wed jul 28 11:12:26 1993 by rik faith (faith@cs.unc.edu) +.\" +.\" fixme probably all of the following should be documented: +.\" _pc_sync_io, +.\" _pc_async_io, +.\" _pc_prio_io, +.\" _pc_sock_maxbuf, +.\" _pc_filesizebits, +.\" _pc_rec_incr_xfer_size, +.\" _pc_rec_max_xfer_size, +.\" _pc_rec_min_xfer_size, +.\" _pc_rec_xfer_align, +.\" _pc_alloc_size_min, +.\" _pc_symlink_max, +.\" _pc_2_symlinks +.\" +.th fpathconf 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +fpathconf, pathconf \- get configuration values for files +.sh synopsis +.nf +.b #include +.pp +.bi "long fpathconf(int " fd ", int " name ); +.bi "long pathconf(const char *" path ", int " name ); +.fi +.sh description +.br fpathconf () +gets a value for the configuration option +.i name +for the open file descriptor +.ir fd . +.pp +.br pathconf () +gets a value for configuration option +.i name +for the filename +.ir path . +.pp +the corresponding macros defined in +.i +are minimum values; if an application wants to take advantage of values +which may change, a call to +.br fpathconf () +or +.br pathconf () +can be made, which may yield more liberal results. +.pp +setting +.i name +equal to one of the following constants returns the following +configuration options: +.tp +.b _pc_link_max +the maximum number of links to the file. +if +.i fd +or +.i path +refer to a directory, then the value applies to the whole directory. +the corresponding macro is +.br _posix_link_max . +.tp +.b _pc_max_canon +the maximum length of a formatted input line, where +.i fd +or +.i path +must refer to a terminal. +the corresponding macro is +.br _posix_max_canon . +.tp +.b _pc_max_input +the maximum length of an input line, where +.i fd +or +.i path +must refer to a terminal. +the corresponding macro is +.br _posix_max_input . +.tp +.b _pc_name_max +the maximum length of a filename in the directory +.i path +or +.ir fd +that the process is allowed to create. +the corresponding macro is +.br _posix_name_max . +.tp +.b _pc_path_max +the maximum length of a relative pathname when +.i path +or +.i fd +is the current working directory. +the corresponding macro is +.br _posix_path_max . +.tp +.b _pc_pipe_buf +the maximum number of bytes that can be written atomically to a pipe of fifo. +for +.br fpathconf (), +.i fd +should refer to a pipe or fifo. +for +.br fpathconf (), +.i path +should refer to a fifo or a directory; in the latter case, +the returned value corresponds to fifos created in that directory. +the corresponding macro is +.br _posix_pipe_buf . +.tp +.b _pc_chown_restricted +this returns a positive value if the use of +.br chown (2) +and +.br fchown (2) +for changing a file's user id is restricted to a process +with appropriate privileges, +and changing a file's group id to a value other than the process's +effective group id or one of its supplementary group ids +is restricted to a process with appropriate privileges. +according to posix.1, +this variable shall always be defined with a value other than \-1. +the corresponding macro is +.br _posix_chown_restricted . +.ip +if +.i fd +or +.i path +refers to a directory, +then the return value applies to all files in that directory. +.tp +.b _pc_no_trunc +this returns nonzero if accessing filenames longer than +.b _posix_name_max +generates an error. +the corresponding macro is +.br _posix_no_trunc . +.tp +.b _pc_vdisable +this returns nonzero if special character processing can be disabled, where +.i fd +or +.i path +must refer to a terminal. +.sh return value +the return value of these functions is one of the following: +.ip * 3 +on error, \-1 is returned and +.i errno +is set to indicate the error +(for example, +.br einval , +indicating that +.i name +is invalid). +.ip * +if +.i name +corresponds to a maximum or minimum limit, and that limit is indeterminate, +\-1 is returned and +.i errno +is not changed. +(to distinguish an indeterminate limit from an error, set +.i errno +to zero before the call, and then check whether +.i errno +is nonzero when \-1 is returned.) +.ip * +if +.i name +corresponds to an option, +a positive value is returned if the option is supported, +and \-1 is returned if the option is not supported. +.ip * +otherwise, +the current value of the option or limit is returned. +this value will not be more restrictive than +the corresponding value that was described to the application in +.i +or +.i +when the application was compiled. +.sh errors +.tp +.b eacces +.rb ( pathconf ()) +search permission is denied for one of the directories in the path prefix of +.ir path . +.tp +.b ebadf +.rb ( fpathconf ()) +.i fd +is not a valid file descriptor. +.tp +.b einval +.i name +is invalid. +.tp +.b einval +the implementation does not support an association of +.i name +with the specified file. +.tp +.b eloop +.rb ( pathconf ()) +too many symbolic links were encountered while resolving +.ir path . +.tp +.b enametoolong +.rb ( pathconf ()) +.i path +is too long. +.tp +.b enoent +.rb ( pathconf ()) +a component of +.i path +does not exist, or +.i path +is an empty string. +.tp +.b enotdir +.rb ( pathconf ()) +a component used as a directory in +.i path +is not in fact a directory. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br fpathconf (), +.br pathconf () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +files with name lengths longer than the value returned for +.i name +equal to +.b _pc_name_max +may exist in the given directory. +.pp +some returned values may be huge; they are not suitable for allocating +memory. +.sh see also +.br getconf (1), +.br open (2), +.br statfs (2), +.br confstr (3), +.br sysconf (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/unimplemented.2 + +.\" copyright (c) 1992 drew eckhardt (drew@cs.colorado.edu), march 28, 1992 +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified by michael haardt (michael@moria.de) +.\" modified sat jul 24 14:29:17 1993 by rik faith (faith@cs.unc.edu) +.\" modified 961203 and 001211 and 010326 by aeb@cwi.nl +.\" modified 001213 by michael haardt (michael@moria.de) +.\" modified 13 jun 02, michael kerrisk +.\" added note on nonstandard behavior when sigchld is ignored. +.\" modified 2004-11-16, mtk, noted that the nonconformance when +.\" sigchld is being ignored is fixed in 2.6.9; other minor changes +.\" modified 2004-12-08, mtk, in 2.6 times() return value changed +.\" 2005-04-13, mtk +.\" added notes on nonstandard behavior: linux allows 'buf' to +.\" be null, but posix.1 doesn't specify this and it's nonportable. +.\" +.th times 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +times \- get process times +.sh synopsis +.nf +.b #include +.pp +.bi "clock_t times(struct tms *" buf ); +.fi +.sh description +.br times () +stores the current process times in the +.i "struct tms" +that +.i buf +points to. +the +.i struct tms +is as defined in +.ir : +.pp +.in +4n +.ex +struct tms { + clock_t tms_utime; /* user time */ + clock_t tms_stime; /* system time */ + clock_t tms_cutime; /* user time of children */ + clock_t tms_cstime; /* system time of children */ +}; +.ee +.in +.pp +the +.i tms_utime +field contains the cpu time spent executing instructions +of the calling process. +the +.i tms_stime +field contains the cpu time spent executing inside the kernel +while performing tasks on behalf of the calling process. +.pp +the +.i tms_cutime +field contains the sum of the +.i tms_utime +and +.i tms_cutime +values for all waited-for terminated children. +the +.i tms_cstime +field contains the sum of the +.i tms_stime +and +.i tms_cstime +values for all waited-for terminated children. +.pp +times for terminated children (and their descendants) +are added in at the moment +.br wait (2) +or +.br waitpid (2) +returns their process id. +in particular, times of grandchildren +that the children did not wait for are never seen. +.pp +all times reported are in clock ticks. +.sh return value +.br times () +returns the number of clock ticks that have elapsed since +an arbitrary point in the past. +the return value may overflow the possible range of type +.ir clock_t . +on error, \fi(clock_t)\ \-1\fp is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b efault +.i tms +points outside the process's address space. +.sh conforming to +posix.1-2001, posix.1-2008, svr4, 4.3bsd. +.sh notes +the number of clock ticks per second can be obtained using: +.pp +.in +4n +.ex +sysconf(_sc_clk_tck); +.ee +.in +.pp +in posix.1-1996 the symbol \fbclk_tck\fp (defined in +.ir ) +is mentioned as obsolescent. +it is obsolete now. +.pp +in linux kernel versions before 2.6.9, +if the disposition of +.b sigchld +is set to +.br sig_ign , +then the times of terminated children +are automatically included in the +.i tms_cstime +and +.i tms_cutime +fields, although posix.1-2001 says that this should happen +only if the calling process +.br wait (2)s +on its children. +this nonconformance is rectified in linux 2.6.9 and later. +.\" see the description of times() in xsh, which says: +.\" the times of a terminated child process are included... when wait() +.\" or waitpid() returns the process id of this terminated child. +.pp +on linux, the +.i buf +argument can be specified as null, with the result that +.br times () +just returns a function result. +however, posix does not specify this behavior, and most +other unix implementations require a non-null value for +.ir buf . +.pp +note that +.br clock (3) +also returns a value of type +.ir clock_t , +but this value is measured in units of +.br clocks_per_sec , +not the clock ticks used by +.br times (). +.pp +on linux, the "arbitrary point in the past" from which the return value of +.br times () +is measured has varied across kernel versions. +on linux 2.4 and earlier, this point is the moment the system was booted. +since linux 2.6, this point is \fi(2^32/hz) \- 300\fp +seconds before system boot time. +this variability across kernel versions (and across unix implementations), +combined with the fact that the returned value may overflow the range of +.ir clock_t , +means that a portable application would be wise to avoid using this value. +to measure changes in elapsed time, use +.br clock_gettime (2) +instead. +.\" .pp +.\" on older systems the number of clock ticks per second is given +.\" by the variable hz. +.ss historical +svr1-3 returns +.i long +and the struct members are of type +.i time_t +although they store clock ticks, not seconds since the epoch. +v7 used +.i long +for the struct members, because it had no type +.i time_t +yet. +.sh bugs +a limitation of the linux system call conventions on some architectures +(notably i386) means that on linux 2.6 there is a small time window +(41 seconds) soon after boot when +.br times () +can return \-1, falsely indicating that an error occurred. +the same problem can occur when the return value wraps past +the maximum value that can be stored in +.br clock_t . +.\" the problem is that a syscall return of -4095 to -1 +.\" is interpreted by glibc as an error, and the wrapper converts +.\" the return value to -1. +.\" http://marc.info/?l=linux-kernel&m=119447727031225&w=2 +.\" "compat_sys_times() bogus until jiffies >= 0" +.\" november 2007 +.sh see also +.br time (1), +.br getrusage (2), +.br wait (2), +.br clock (3), +.br sysconf (3), +.br time (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/dbopen.3 + +.\" copyright (c) 2016 pavel emelyanov +.\" copyright (c) 2016 dmitry v. levin +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.th sock_diag 7 2021-03-22 "linux" "linux programmer's manual" +.sh name +sock_diag \- obtaining information about sockets +.sh synopsis +.nf +.b #include +.b #include +.br "#include " " /* for unix domain sockets */" +.br "#include " " /* for ipv4 and ipv6 sockets */" +.pp +.bi "diag_socket = socket(af_netlink, " socket_type ", netlink_sock_diag);" +.fi +.sh description +the sock_diag netlink subsystem provides a mechanism for obtaining +information about sockets of various address families from the kernel. +this subsystem can be used to obtain information about individual +sockets or request a list of sockets. +.pp +in the request, the caller can specify additional information it would +like to obtain about the socket, for example, memory information or +information specific to the address family. +.pp +when requesting a list of sockets, the caller can specify filters that +would be applied by the kernel to select a subset of sockets to report. +for now, there is only the ability to filter sockets by state (connected, +listening, and so on.) +.pp +note that sock_diag reports only those sockets that have a name; +that is, either sockets bound explicitly with +.br bind (2) +or sockets that were automatically bound to an address (e.g., by +.br connect (2)). +this is the same set of sockets that is available via +.ir /proc/net/unix , +.ir /proc/net/tcp , +.ir /proc/net/udp , +and so on. +.\" +.ss request +the request starts with a +.i "struct nlmsghdr" +header described in +.br netlink (7) +with +.i nlmsg_type +field set to +.br sock_diag_by_family . +it is followed by a header specific to the address family that starts with +a common part shared by all address families: +.pp +.in +4n +.ex +struct sock_diag_req { + __u8 sdiag_family; + __u8 sdiag_protocol; +}; +.ee +.in +.pp +the fields of this structure are as follows: +.tp +.i sdiag_family +an address family. +it should be set to the appropriate +.b af_* +constant. +.tp +.i sdiag_protocol +depends on +.ir sdiag_family . +it should be set to the appropriate +.b ipproto_* +constant for +.b af_inet +and +.br af_inet6 , +and to 0 otherwise. +.pp +if the +.i nlmsg_flags +field of the +.i "struct nlmsghdr" +header has the +.br nlm_f_dump +flag set, it means that a list of sockets is being requested; +otherwise it is a query about an individual socket. +.\" +.ss response +the response starts with a +.i "struct nlmsghdr" +header and is followed by an array of objects specific to the address family. +the array is to be accessed with the standard +.b nlmsg_* +macros from the +.br netlink (3) +api. +.pp +each object is the nla (netlink attributes) list that is to be accessed +with the +.b rta_* +macros from +.br rtnetlink (3) +api. +.\" +.ss unix domain sockets +for unix domain sockets the request is represented in the following structure: +.pp +.in +4n +.ex +struct unix_diag_req { + __u8 sdiag_family; + __u8 sdiag_protocol; + __u16 pad; + __u32 udiag_states; + __u32 udiag_ino; + __u32 udiag_show; + __u32 udiag_cookie[2]; +}; +.ee +.in +.pp +the fields of this structure are as follows: +.tp +.i sdiag_family +the address family; it should be set to +.br af_unix . +.pp +.i sdiag_protocol +.pd 0 +.tp +.pd +.i pad +these fields should be set to 0. +.tp +.i udiag_states +this is a bit mask that defines a filter of sockets states. +only those sockets whose states are in this mask will be reported. +ignored when querying for an individual socket. +supported values are: +.pp +.rs 12 +1 << +.b tcp_established +.pp +1 << +.b tcp_listen +.re +.tp +.i udiag_ino +this is an inode number when querying for an individual socket. +ignored when querying for a list of sockets. +.tp +.i udiag_show +this is a set of flags defining what kind of information to report. +each requested kind of information is reported back as a netlink +attribute as described below: +.rs +.tp +.b udiag_show_name +the attribute reported in answer to this request is +.br unix_diag_name . +the payload associated with this attribute is the pathname to which +the socket was bound (a sequence of bytes up to +.b unix_path_max +length). +.tp +.b udiag_show_vfs +the attribute reported in answer to this request is +.br unix_diag_vfs . +the payload associated with this attribute is represented in the following +structure: +.ip +.in +4n +.ex +struct unix_diag_vfs { + __u32 udiag_vfs_dev; + __u32 udiag_vfs_ino; +}; +.ee +.in +.ip +the fields of this structure are as follows: +.rs +.tp +.i udiag_vfs_dev +the device number of the corresponding on-disk socket inode. +.tp +.i udiag_vfs_ino +the inode number of the corresponding on-disk socket inode. +.re +.tp +.b udiag_show_peer +the attribute reported in answer to this request is +.br unix_diag_peer . +the payload associated with this attribute is a __u32 value +which is the peer's inode number. +this attribute is reported for connected sockets only. +.tp +.b udiag_show_icons +the attribute reported in answer to this request is +.br unix_diag_icons . +the payload associated with this attribute is an array of __u32 values +which are inode numbers of sockets that has passed the +.br connect (2) +call, but hasn't been processed with +.br accept (2) +yet. +this attribute is reported for listening sockets only. +.tp +.b udiag_show_rqlen +the attribute reported in answer to this request is +.br unix_diag_rqlen . +the payload associated with this attribute is represented in the following +structure: +.ip +.in +4n +.ex +struct unix_diag_rqlen { + __u32 udiag_rqueue; + __u32 udiag_wqueue; +}; +.ee +.in +.ip +the fields of this structure are as follows: +.rs +.tp +.i udiag_rqueue +for listening sockets: +the number of pending connections. +the length of the array associated with the +.b unix_diag_icons +response attribute is equal to this value. +.ip +for established sockets: +the amount of data in incoming queue. +.tp +.i udiag_wqueue +for listening sockets: +the backlog length which equals to the value passed as the second argument to +.br listen (2). +.ip +for established sockets: +the amount of memory available for sending. +.re +.tp +.b udiag_show_meminfo +the attribute reported in answer to this request is +.br unix_diag_meminfo . +the payload associated with this attribute is an array of __u32 values +described below in the subsection "socket memory information". +.pp +the following attributes are reported back without any specific request: +.tp +.br unix_diag_shutdown +the payload associated with this attribute is __u8 value which represents +bits of +.br shutdown (2) +state. +.re +.tp +.i udiag_cookie +this is an array of opaque identifiers that could be used along with +.i udiag_ino +to specify an individual socket. +it is ignored when querying for a list +of sockets, as well as when all its elements are set to \-1. +.pp +the response to a query for unix domain sockets is represented as an array of +.pp +.in +4n +.ex +struct unix_diag_msg { + __u8 udiag_family; + __u8 udiag_type; + __u8 udiag_state; + __u8 pad; + __u32 udiag_ino; + __u32 udiag_cookie[2]; +}; +.ee +.in +.pp +followed by netlink attributes. +.pp +the fields of this structure are as follows: +.tp +.i udiag_family +this field has the same meaning as in +.ir "struct unix_diag_req" . +.tp +.i udiag_type +this is set to one of +.br sock_packet , +.br sock_stream , +or +.br sock_seqpacket . +.tp +.i udiag_state +this is set to one of +.br tcp_listen +or +.br tcp_established . +.tp +.i pad +this field is set to 0. +.tp +.i udiag_ino +this is the socket inode number. +.tp +.i udiag_cookie +this is an array of opaque identifiers that could be used in subsequent +queries. +.\" +.ss ipv4 and ipv6 sockets +for ipv4 and ipv6 sockets, +the request is represented in the following structure: +.pp +.in +4n +.ex +struct inet_diag_req_v2 { + __u8 sdiag_family; + __u8 sdiag_protocol; + __u8 idiag_ext; + __u8 pad; + __u32 idiag_states; + struct inet_diag_sockid id; +}; +.ee +.in +.pp +where +.i "struct inet_diag_sockid" +is defined as follows: +.pp +.in +4n +.ex +struct inet_diag_sockid { + __be16 idiag_sport; + __be16 idiag_dport; + __be32 idiag_src[4]; + __be32 idiag_dst[4]; + __u32 idiag_if; + __u32 idiag_cookie[2]; +}; +.ee +.in +.pp +the fields of +.i "struct inet_diag_req_v2" +are as follows: +.tp +.i sdiag_family +this should be set to either +.b af_inet +or +.b af_inet6 +for ipv4 or ipv6 sockets respectively. +.tp +.i sdiag_protocol +this should be set to one of +.br ipproto_tcp , +.br ipproto_udp , +or +.br ipproto_udplite . +.tp +.i idiag_ext +this is a set of flags defining what kind of extended information to report. +each requested kind of information is reported back as a netlink attribute +as described below: +.rs +.tp +.b inet_diag_tos +the payload associated with this attribute is a __u8 value +which is the tos of the socket. +.tp +.b inet_diag_tclass +the payload associated with this attribute is a __u8 value +which is the tclass of the socket. +ipv6 sockets only. +for listen and close sockets, this is followed by +.b inet_diag_skv6only +attribute with associated __u8 payload value meaning whether the socket +is ipv6-only or not. +.tp +.b inet_diag_meminfo +the payload associated with this attribute is represented in the following +structure: +.ip +.in +4n +.ex +struct inet_diag_meminfo { + __u32 idiag_rmem; + __u32 idiag_wmem; + __u32 idiag_fmem; + __u32 idiag_tmem; +}; +.ee +.in +.ip +the fields of this structure are as follows: +.rs +.tp 12 +.i idiag_rmem +the amount of data in the receive queue. +.tp +.i idiag_wmem +the amount of data that is queued by tcp but not yet sent. +.tp +.i idiag_fmem +the amount of memory scheduled for future use (tcp only). +.tp +.i idiag_tmem +the amount of data in send queue. +.re +.tp +.b inet_diag_skmeminfo +the payload associated with this attribute is an array of __u32 values +described below in the subsection "socket memory information". +.tp +.b inet_diag_info +the payload associated with this attribute is specific to the address family. +for tcp sockets, it is an object of type +.ir "struct tcp_info" . +.tp +.b inet_diag_cong +the payload associated with this attribute is a string that describes the +congestion control algorithm used. +for tcp sockets only. +.re +.tp +.i pad +this should be set to 0. +.tp +.i idiag_states +this is a bit mask that defines a filter of socket states. +only those sockets whose states are in this mask will be reported. +ignored when querying for an individual socket. +.tp +.i id +this is a socket id object that is used in dump requests, in queries +about individual sockets, and is reported back in each response. +unlike unix domain sockets, ipv4 and ipv6 sockets are identified +using addresses and ports. +all values are in network byte order. +.pp +the fields of +.i "struct inet_diag_sockid" +are as follows: +.tp +.i idiag_sport +the source port. +.tp +.i idiag_dport +the destination port. +.tp +.i idiag_src +the source address. +.tp +.i idiag_dst +the destination address. +.tp +.i idiag_if +the interface number the socket is bound to. +.tp +.i idiag_cookie +this is an array of opaque identifiers that could be used along with +other fields of this structure to specify an individual socket. +it is ignored when querying for a list of sockets, as well as +when all its elements are set to \-1. +.pp +the response to a query for ipv4 or ipv6 sockets is represented as an array of +.pp +.in +4n +.ex +struct inet_diag_msg { + __u8 idiag_family; + __u8 idiag_state; + __u8 idiag_timer; + __u8 idiag_retrans; + + struct inet_diag_sockid id; + + __u32 idiag_expires; + __u32 idiag_rqueue; + __u32 idiag_wqueue; + __u32 idiag_uid; + __u32 idiag_inode; +}; +.ee +.in +.pp +followed by netlink attributes. +.pp +the fields of this structure are as follows: +.tp +.i idiag_family +this is the same field as in +.ir "struct inet_diag_req_v2" . +.tp +.i idiag_state +this denotes socket state as in +.ir "struct inet_diag_req_v2" . +.tp +.i idiag_timer +for tcp sockets, this field describes the type of timer that is currently +active for the socket. +it is set to one of the following constants: +.ip +.pd 0 +.rs 12 +.tp +.b 0 +no timer is active +.tp +.b 1 +a retransmit timer +.tp +.b 2 +a keep-alive timer +.tp +.b 3 +a time_wait timer +.tp +.b 4 +a zero window probe timer +.re +.pd +.ip +for non-tcp sockets, this field is set to 0. +.tp +.i idiag_retrans +for +.i idiag_timer +values 1, 2, and 4, this field contains the number of retransmits. +for other +.i idiag_timer +values, this field is set to 0. +.tp +.i idiag_expires +for tcp sockets that have an active timer, this field describes its expiration +time in milliseconds. +for other sockets, this field is set to 0. +.tp +.i idiag_rqueue +for listening sockets: +the number of pending connections. +.ip +for other sockets: +the amount of data in the incoming queue. +.tp +.i idiag_wqueue +for listening sockets: +the backlog length. +.ip +for other sockets: +the amount of memory available for sending. +.tp +.i idiag_uid +this is the socket owner uid. +.tp +.i idiag_inode +this is the socket inode number. +.\" +.ss socket memory information +the payload associated with +.b unix_diag_meminfo +and +.br inet_diag_skmeminfo +netlink attributes is an array of the following __u32 values: +.tp +.b sk_meminfo_rmem_alloc +the amount of data in receive queue. +.tp +.b sk_meminfo_rcvbuf +the receive socket buffer as set by +.br so_rcvbuf . +.tp +.b sk_meminfo_wmem_alloc +the amount of data in send queue. +.tp +.b sk_meminfo_sndbuf +the send socket buffer as set by +.br so_sndbuf . +.tp +.b sk_meminfo_fwd_alloc +the amount of memory scheduled for future use (tcp only). +.tp +.b sk_meminfo_wmem_queued +the amount of data queued by tcp, but not yet sent. +.tp +.b sk_meminfo_optmem +the amount of memory allocated for the socket's service needs (e.g., socket +filter). +.tp +.b sk_meminfo_backlog +the amount of packets in the backlog (not yet processed). +.sh versions +.b netlink_inet_diag +was introduced in linux 2.6.14 and supported +.b af_inet +and +.b af_inet6 +sockets only. +in linux 3.3, it was renamed to +.b netlink_sock_diag +and extended to support +.b af_unix +sockets. +.pp +.b unix_diag_meminfo +and +.br inet_diag_skmeminfo +were introduced in linux 3.6. +.sh conforming to +the netlink_sock_diag api is linux-specific. +.sh examples +the following example program prints inode number, peer's inode number, +and name of all unix domain sockets in the current namespace. +.pp +.ex +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static int +send_query(int fd) +{ + struct sockaddr_nl nladdr = { + .nl_family = af_netlink + }; + struct + { + struct nlmsghdr nlh; + struct unix_diag_req udr; + } req = { + .nlh = { + .nlmsg_len = sizeof(req), + .nlmsg_type = sock_diag_by_family, + .nlmsg_flags = nlm_f_request | nlm_f_dump + }, + .udr = { + .sdiag_family = af_unix, + .udiag_states = \-1, + .udiag_show = udiag_show_name | udiag_show_peer + } + }; + struct iovec iov = { + .iov_base = &req, + .iov_len = sizeof(req) + }; + struct msghdr msg = { + .msg_name = &nladdr, + .msg_namelen = sizeof(nladdr), + .msg_iov = &iov, + .msg_iovlen = 1 + }; + + for (;;) { + if (sendmsg(fd, &msg, 0) < 0) { + if (errno == eintr) + continue; + + perror("sendmsg"); + return \-1; + } + + return 0; + } +} + +static int +print_diag(const struct unix_diag_msg *diag, unsigned int len) +{ + if (len < nlmsg_length(sizeof(*diag))) { + fputs("short response\en", stderr); + return \-1; + } + if (diag\->udiag_family != af_unix) { + fprintf(stderr, "unexpected family %u\en", diag\->udiag_family); + return \-1; + } + + unsigned int rta_len = len \- nlmsg_length(sizeof(*diag)); + unsigned int peer = 0; + size_t path_len = 0; + char path[sizeof(((struct sockaddr_un *) 0)\->sun_path) + 1]; + + for (struct rtattr *attr = (struct rtattr *) (diag + 1); + rta_ok(attr, rta_len); attr = rta_next(attr, rta_len)) { + switch (attr\->rta_type) { + case unix_diag_name: + if (!path_len) { + path_len = rta_payload(attr); + if (path_len > sizeof(path) \- 1) + path_len = sizeof(path) \- 1; + memcpy(path, rta_data(attr), path_len); + path[path_len] = \(aq\e0\(aq; + } + break; + + case unix_diag_peer: + if (rta_payload(attr) >= sizeof(peer)) + peer = *(unsigned int *) rta_data(attr); + break; + } + } + + printf("inode=%u", diag\->udiag_ino); + + if (peer) + printf(", peer=%u", peer); + + if (path_len) + printf(", name=%s%s", *path ? "" : "@", + *path ? path : path + 1); + + putchar(\(aq\en\(aq); + return 0; +} + +static int +receive_responses(int fd) +{ + long buf[8192 / sizeof(long)]; + struct sockaddr_nl nladdr; + struct iovec iov = { + .iov_base = buf, + .iov_len = sizeof(buf) + }; + int flags = 0; + + for (;;) { + struct msghdr msg = { + .msg_name = &nladdr, + .msg_namelen = sizeof(nladdr), + .msg_iov = &iov, + .msg_iovlen = 1 + }; + + ssize_t ret = recvmsg(fd, &msg, flags); + + if (ret < 0) { + if (errno == eintr) + continue; + + perror("recvmsg"); + return \-1; + } + if (ret == 0) + return 0; + + if (nladdr.nl_family != af_netlink) { + fputs("!af_netlink\en", stderr); + return \-1; + } + + const struct nlmsghdr *h = (struct nlmsghdr *) buf; + + if (!nlmsg_ok(h, ret)) { + fputs("!nlmsg_ok\en", stderr); + return \-1; + } + + for (; nlmsg_ok(h, ret); h = nlmsg_next(h, ret)) { + if (h\->nlmsg_type == nlmsg_done) + return 0; + + if (h\->nlmsg_type == nlmsg_error) { + const struct nlmsgerr *err = nlmsg_data(h); + + if (h\->nlmsg_len < nlmsg_length(sizeof(*err))) { + fputs("nlmsg_error\en", stderr); + } else { + errno = \-err\->error; + perror("nlmsg_error"); + } + + return \-1; + } + + if (h\->nlmsg_type != sock_diag_by_family) { + fprintf(stderr, "unexpected nlmsg_type %u\en", + (unsigned) h\->nlmsg_type); + return \-1; + } + + if (print_diag(nlmsg_data(h), h\->nlmsg_len)) + return \-1; + } + } +} + +int +main(void) +{ + int fd = socket(af_netlink, sock_raw, netlink_sock_diag); + + if (fd < 0) { + perror("socket"); + return 1; + } + + int ret = send_query(fd) || receive_responses(fd); + + close(fd); + return ret; +} +.ee +.sh see also +.br netlink (3), +.br rtnetlink (3), +.br netlink (7), +.br tcp (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man7/sysvipc.7 + +.\" copyright 2003,2004 andi kleen, suse labs. +.\" and copyright 2007 lee schermerhorn, hewlett packard +.\" +.\" %%%license_start(verbatim_prof) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" 2006-02-03, mtk, substantial wording changes and other improvements +.\" 2007-08-27, lee schermerhorn +.\" more precise specification of behavior. +.\" +.th set_mempolicy 2 2021-06-20 linux "linux programmer's manual" +.sh name +set_mempolicy \- set default numa memory policy for a thread and its children +.sh synopsis +.nf +.b "#include " +.pp +.bi "long set_mempolicy(int " mode ", const unsigned long *" nodemask , +.bi " unsigned long " maxnode ); +.pp +link with \fi\-lnuma\fp. +.fi +.sh description +.br set_mempolicy () +sets the numa memory policy of the calling thread, +which consists of a policy mode and zero or more nodes, +to the values specified by the +.ir mode , +.ir nodemask , +and +.i maxnode +arguments. +.pp +a numa machine has different +memory controllers with different distances to specific cpus. +the memory policy defines from which node memory is allocated for +the thread. +.pp +this system call defines the default policy for the thread. +the thread policy governs allocation of pages in the process's +address space outside of memory ranges +controlled by a more specific policy set by +.br mbind (2). +the thread default policy also controls allocation of any pages for +memory-mapped files mapped using the +.br mmap (2) +call with the +.b map_private +flag and that are only read (loaded) from by the thread +and of memory-mapped files mapped using the +.br mmap (2) +call with the +.b map_shared +flag, regardless of the access type. +the policy is applied only when a new page is allocated +for the thread. +for anonymous memory this is when the page is first +touched by the thread. +.pp +the +.i mode +argument must specify one of +.br mpol_default , +.br mpol_bind , +.br mpol_interleave , +.br mpol_preferred , +or +.br mpol_local +(which are described in detail below). +all modes except +.b mpol_default +require the caller to specify the node or nodes to which the mode applies, +via the +.i nodemask +argument. +.pp +the +.i mode +argument may also include an optional +.ir "mode flag" . +the supported +.i "mode flags" +are: +.tp +.br mpol_f_numa_balancing " (since linux 5.12)" +.\" commit bda420b985054a3badafef23807c4b4fa38a3dff +when +.i mode +is +.br mpol_bind , +enable the kernel numa balancing for the task if it is supported by the kernel. +if the flag isn't supported by the kernel, or is used with +.i mode +other than +.br mpol_bind , +\-1 is returned and +.i errno +is set to +.br einval . +.tp +.br mpol_f_relative_nodes " (since linux 2.6.26)" +a nonempty +.i nodemask +specifies node ids that are relative to the +set of node ids allowed by the process's current cpuset. +.tp +.br mpol_f_static_nodes " (since linux 2.6.26)" +a nonempty +.i nodemask +specifies physical node ids. +linux will not remap the +.i nodemask +when the process moves to a different cpuset context, +nor when the set of nodes allowed by the process's +current cpuset context changes. +.pp +.i nodemask +points to a bit mask of node ids that contains up to +.i maxnode +bits. +the bit mask size is rounded to the next multiple of +.ir "sizeof(unsigned long)" , +but the kernel will use bits only up to +.ir maxnode . +a null value of +.i nodemask +or a +.i maxnode +value of zero specifies the empty set of nodes. +if the value of +.i maxnode +is zero, +the +.i nodemask +argument is ignored. +.pp +where a +.i nodemask +is required, it must contain at least one node that is on-line, +allowed by the process's current cpuset context, +(unless the +.b mpol_f_static_nodes +mode flag is specified), +and contains memory. +if the +.b mpol_f_static_nodes +is set in +.i mode +and a required +.i nodemask +contains no nodes that are allowed by the process's current cpuset context, +the memory policy reverts to +.ir "local allocation" . +this effectively overrides the specified policy until the process's +cpuset context includes one or more of the nodes specified by +.ir nodemask . +.pp +the +.i mode +argument must include one of the following values: +.tp +.b mpol_default +this mode specifies that any nondefault thread memory policy be removed, +so that the memory policy "falls back" to the system default policy. +the system default policy is "local allocation"\(emthat is, +allocate memory on the node of the cpu that triggered the allocation. +.i nodemask +must be specified as null. +if the "local node" contains no free memory, the system will +attempt to allocate memory from a "near by" node. +.tp +.b mpol_bind +this mode defines a strict policy that restricts memory allocation to the +nodes specified in +.ir nodemask . +if +.i nodemask +specifies more than one node, page allocations will come from +the node with the lowest numeric node id first, until that node +contains no free memory. +allocations will then come from the node with the next highest +node id specified in +.i nodemask +and so forth, until none of the specified nodes contain free memory. +pages will not be allocated from any node not specified in the +.ir nodemask . +.tp +.b mpol_interleave +this mode interleaves page allocations across the nodes specified in +.i nodemask +in numeric node id order. +this optimizes for bandwidth instead of latency +by spreading out pages and memory accesses to those pages across +multiple nodes. +however, accesses to a single page will still be limited to +the memory bandwidth of a single node. +.\" note: the following sentence doesn't make sense in the context +.\" of set_mempolicy() -- no memory area specified. +.\" to be effective the memory area should be fairly large, +.\" at least 1 mb or bigger. +.tp +.b mpol_preferred +this mode sets the preferred node for allocation. +the kernel will try to allocate pages from this node first +and fall back to "near by" nodes if the preferred node is low on free +memory. +if +.i nodemask +specifies more than one node id, the first node in the +mask will be selected as the preferred node. +if the +.i nodemask +and +.i maxnode +arguments specify the empty set, then the policy +specifies "local allocation" +(like the system default policy discussed above). +.tp +.br mpol_local " (since linux 3.8)" +.\" commit 479e2802d09f1e18a97262c4c6f8f17ae5884bd8 +.\" commit f2a07f40dbc603c15f8b06e6ec7f768af67b424f +this mode specifies "local allocation"; the memory is allocated on +the node of the cpu that triggered the allocation (the "local node"). +the +.i nodemask +and +.i maxnode +arguments must specify the empty set. +if the "local node" is low on free memory, +the kernel will try to allocate memory from other nodes. +the kernel will allocate memory from the "local node" +whenever memory for this node is available. +if the "local node" is not allowed by the process's current cpuset context, +the kernel will try to allocate memory from other nodes. +the kernel will allocate memory from the "local node" whenever +it becomes allowed by the process's current cpuset context. +.pp +the thread memory policy is preserved across an +.br execve (2), +and is inherited by child threads created using +.br fork (2) +or +.br clone (2). +.sh return value +on success, +.br set_mempolicy () +returns 0; +on error, \-1 is returned and +.i errno +is set to indicate the error. +.sh errors +.tp +.b efault +part of all of the memory range specified by +.i nodemask +and +.i maxnode +points outside your accessible address space. +.tp +.b einval +.i mode +is invalid. +or, +.i mode +is +.b mpol_default +and +.i nodemask +is nonempty, +or +.i mode +is +.b mpol_bind +or +.b mpol_interleave +and +.i nodemask +is empty. +or, +.i maxnode +specifies more than a page worth of bits. +or, +.i nodemask +specifies one or more node ids that are +greater than the maximum supported node id. +or, none of the node ids specified by +.i nodemask +are on-line and allowed by the process's current cpuset context, +or none of the specified nodes contain memory. +or, the +.i mode +argument specified both +.b mpol_f_static_nodes +and +.br mpol_f_relative_nodes . +or, the +.b mpol_f_numa_balancing +isn't supported by the kernel, or is used with +.i mode +other than +.br mpol_bind . +.tp +.b enomem +insufficient kernel memory was available. +.sh versions +the +.br set_mempolicy () +system call was added to the linux kernel in version 2.6.7. +.sh conforming to +this system call is linux-specific. +.sh notes +memory policy is not remembered if the page is swapped out. +when such a page is paged back in, it will use the policy of +the thread or memory range that is in effect at the time the +page is allocated. +.pp +for information on library support, see +.br numa (7). +.sh see also +.br get_mempolicy (2), +.br getcpu (2), +.br mbind (2), +.br mmap (2), +.br numa (3), +.br cpuset (7), +.br numa (7), +.br numactl (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/copysign.3 + +.so man2/msgop.2 + +.so man3/pthread_mutexattr_setrobust.3 + +.so man3/cmsg.3 + +.\" copyright 1993 giorgio ciucci (giorgio@crcc.it) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified 1996-10-22, eric s. raymond +.\" modified 2002-01-08, michael kerrisk +.\" modified 2003-04-28, ernie petrides +.\" modified 2004-05-27, michael kerrisk +.\" modified, 11 nov 2004, michael kerrisk +.\" language and formatting clean-ups +.\" added notes on /proc files +.\" 2005-04-08, mtk, noted kernel version numbers for semtimedop() +.\" 2007-07-09, mtk, added an example code segment. +.\" +.th semop 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +semop, semtimedop \- system v semaphore operations +.sh synopsis +.nf +.b #include +.pp +.bi "int semop(int " semid ", struct sembuf *" sops ", size_t " nsops ); +.bi "int semtimedop(int " semid ", struct sembuf *" sops ", size_t " nsops , +.bi " const struct timespec *" timeout ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br semtimedop (): +.nf + _gnu_source +.fi +.sh description +each semaphore in a system\ v semaphore set +has the following associated values: +.pp +.in +4n +.ex +unsigned short semval; /* semaphore value */ +unsigned short semzcnt; /* # waiting for zero */ +unsigned short semncnt; /* # waiting for increase */ +pid_t sempid; /* pid of process that last +.ee +.in +.pp +.br semop () +performs operations on selected semaphores in the set indicated by +.ir semid . +each of the +.i nsops +elements in the array pointed to by +.i sops +is a structure that +specifies an operation to be performed on a single semaphore. +the elements of this structure are of type +.ir "struct sembuf" , +containing the following members: +.pp +.in +4n +.ex +unsigned short sem_num; /* semaphore number */ +short sem_op; /* semaphore operation */ +short sem_flg; /* operation flags */ +.ee +.in +.pp +flags recognized in +.i sem_flg +are +.b ipc_nowait +and +.br sem_undo . +if an operation specifies +.br sem_undo , +it will be automatically undone when the process terminates. +.pp +the set of operations contained in +.i sops +is performed in +.ir "array order" , +and +.ir atomically , +that is, the operations are performed either as a complete unit, +or not at all. +the behavior of the system call if not all operations can be +performed immediately depends on the presence of the +.b ipc_nowait +flag in the individual +.i sem_flg +fields, as noted below. +.pp +each operation is performed on the +.ir sem_num \-th +semaphore of the semaphore set, where the first semaphore of the set +is numbered 0. +there are three types of operation, distinguished by the value of +.ir sem_op . +.pp +if +.i sem_op +is a positive integer, the operation adds this value to +the semaphore value +.ri ( semval ). +furthermore, if +.b sem_undo +is specified for this operation, the system subtracts the value +.i sem_op +from the semaphore adjustment +.ri ( semadj ) +value for this semaphore. +this operation can always proceed\(emit never forces a thread to wait. +the calling process must have alter permission on the semaphore set. +.pp +if +.i sem_op +is zero, the process must have read permission on the semaphore +set. +this is a "wait-for-zero" operation: if +.i semval +is zero, the operation can immediately proceed. +otherwise, if +.b ipc_nowait +is specified in +.ir sem_flg , +.br semop () +fails with +.i errno +set to +.b eagain +(and none of the operations in +.i sops +is performed). +otherwise, +.i semzcnt +(the count of threads waiting until this semaphore's value becomes zero) +is incremented by one and the thread sleeps until +one of the following occurs: +.ip \(bu 2 +.i semval +becomes 0, at which time the value of +.i semzcnt +is decremented. +.ip \(bu +the semaphore set +is removed: +.br semop () +fails, with +.i errno +set to +.br eidrm . +.ip \(bu +the calling thread catches a signal: +the value of +.i semzcnt +is decremented and +.br semop () +fails, with +.i errno +set to +.br eintr . +.pp +if +.i sem_op +is less than zero, the process must have alter permission on the +semaphore set. +if +.i semval +is greater than or equal to the absolute value of +.ir sem_op , +the operation can proceed immediately: +the absolute value of +.i sem_op +is subtracted from +.ir semval , +and, if +.b sem_undo +is specified for this operation, the system adds the absolute value of +.i sem_op +to the semaphore adjustment +.ri ( semadj ) +value for this semaphore. +if the absolute value of +.i sem_op +is greater than +.ir semval , +and +.b ipc_nowait +is specified in +.ir sem_flg , +.br semop () +fails, with +.i errno +set to +.b eagain +(and none of the operations in +.i sops +is performed). +otherwise, +.i semncnt +(the counter of threads waiting for this semaphore's value to increase) +is incremented by one and the thread sleeps until +one of the following occurs: +.ip \(bu 2 +.i semval +becomes greater than or equal to the absolute value of +.ir sem_op : +the operation now proceeds, as described above. +.ip \(bu +the semaphore set is removed from the system: +.br semop () +fails, with +.i errno +set to +.br eidrm . +.ip \(bu +the calling thread catches a signal: +the value of +.i semncnt +is decremented and +.br semop () +fails, with +.i errno +set to +.br eintr . +.pp +on successful completion, the +.i sempid +value for each semaphore specified in the array pointed to by +.i sops +is set to the caller's process id. +in addition, the +.i sem_otime +.\" and +.\" .i sem_ctime +is set to the current time. +.ss semtimedop() +.br semtimedop () +behaves identically to +.br semop () +except that in those cases where the calling thread would sleep, +the duration of that sleep is limited by the amount of elapsed +time specified by the +.i timespec +structure whose address is passed in the +.i timeout +argument. +(this sleep interval will be rounded up to the system clock granularity, +and kernel scheduling delays mean that the interval +may overrun by a small amount.) +if the specified time limit has been reached, +.br semtimedop () +fails with +.i errno +set to +.b eagain +(and none of the operations in +.i sops +is performed). +if the +.i timeout +argument is null, +then +.br semtimedop () +behaves exactly like +.br semop (). +.pp +note that if +.br semtimedop () +is interrupted by a signal, causing the call to fail with the error +.br eintr , +the contents of +.ir timeout +are left unchanged. +.sh return value +on success, +.br semop () +and +.br semtimedop () +return 0. +on failure, they return \-1, and set +.i errno +to indicate the error. +.sh errors +.tp +.b e2big +the argument +.i nsops +is greater than +.br semopm , +the maximum number of operations allowed per system +call. +.tp +.b eacces +the calling process does not have the permissions required +to perform the specified semaphore operations, +and does not have the +.b cap_ipc_owner +capability in the user namespace that governs its ipc namespace. +.tp +.b eagain +an operation could not proceed immediately and either +.b ipc_nowait +was specified in +.i sem_flg +or the time limit specified in +.i timeout +expired. +.tp +.b efault +an address specified in either the +.i sops +or the +.i timeout +argument isn't accessible. +.tp +.b efbig +for some operation the value of +.i sem_num +is less than 0 or greater than or equal to the number +of semaphores in the set. +.tp +.b eidrm +the semaphore set was removed. +.tp +.b eintr +while blocked in this system call, the thread caught a signal; see +.br signal (7). +.tp +.b einval +the semaphore set doesn't exist, or +.i semid +is less than zero, or +.i nsops +has a nonpositive value. +.tp +.b enomem +the +.i sem_flg +of some operation specified +.b sem_undo +and the system does not have enough memory to allocate the undo +structure. +.tp +.b erange +for some operation +.i sem_op+semval +is greater than +.br semvmx , +the implementation dependent maximum value for +.ir semval . +.sh versions +.br semtimedop () +first appeared in linux 2.5.52, +and was subsequently backported into kernel 2.4.22. +glibc support for +.br semtimedop () +first appeared in version 2.3.3. +.sh conforming to +posix.1-2001, posix.1-2008, svr4. +.\" svr4 documents additional error conditions einval, efbig, enospc. +.sh notes +the +.i sem_undo +structures of a process aren't inherited by the child produced by +.br fork (2), +but they are inherited across an +.br execve (2) +system call. +.pp +.br semop () +is never automatically restarted after being interrupted by a signal handler, +regardless of the setting of the +.b sa_restart +flag when establishing a signal handler. +.pp +a semaphore adjustment +.ri ( semadj ) +value is a per-process, per-semaphore integer that is the negated sum +of all operations performed on a semaphore specifying the +.b sem_undo +flag. +each process has a list of +.i semadj +values\(emone value for each semaphore on which it has operated using +.br sem_undo . +when a process terminates, each of its per-semaphore +.i semadj +values is added to the corresponding semaphore, +thus undoing the effect of that process's operations on the semaphore +(but see bugs below). +when a semaphore's value is directly set using the +.b setval +or +.b setall +request to +.br semctl (2), +the corresponding +.i semadj +values in all processes are cleared. +the +.br clone (2) +.b clone_sysvsem +flag allows more than one process to share a +.i semadj +list; see +.br clone (2) +for details. +.pp +the \fisemval\fp, \fisempid\fp, \fisemzcnt\fp, and \fisemnct\fp values +for a semaphore can all be retrieved using appropriate +.br semctl (2) +calls. +.ss semaphore limits +the following limits on semaphore set resources affect the +.br semop () +call: +.tp +.b semopm +maximum number of operations allowed for one +.br semop () +call. +before linux 3.19, +.\" commit e843e7d2c88b7db107a86bd2c7145dc715c058f4 +the default value for this limit was 32. +since linux 3.19, the default value is 500. +on linux, this limit can be read and modified via the third field of +.ir /proc/sys/kernel/sem . +.\" this /proc file is not available in linux 2.2 and earlier -- mtk +.ir note : +this limit should not be raised above 1000, +.\" see comment in linux 3.19 source file include/uapi/linux/sem.h +because of the risk of that +.br semop () +fails due to kernel memory fragmentation when allocating memory to copy the +.ir sops +array. +.tp +.b semvmx +maximum allowable value for +.ir semval : +implementation dependent (32767). +.pp +the implementation has no intrinsic limits for +the adjust on exit maximum value +.rb ( semaem ), +the system wide maximum number of undo structures +.rb ( semmnu ) +and the per-process maximum number of undo entries system parameters. +.sh bugs +when a process terminates, its set of associated +.i semadj +structures is used to undo the effect of all of the +semaphore operations it performed with the +.b sem_undo +flag. +this raises a difficulty: if one (or more) of these semaphore adjustments +would result in an attempt to decrease a semaphore's value below zero, +what should an implementation do? +one possible approach would be to block until all the semaphore +adjustments could be performed. +this is however undesirable since it could force process termination to +block for arbitrarily long periods. +another possibility is that such semaphore adjustments could be ignored +altogether (somewhat analogously to failing when +.b ipc_nowait +is specified for a semaphore operation). +linux adopts a third approach: decreasing the semaphore value +as far as possible (i.e., to zero) and allowing process +termination to proceed immediately. +.pp +in kernels 2.6.x, x <= 10, there is a bug that in some circumstances +prevents a thread that is waiting for a semaphore value to become +zero from being woken up when the value does actually become zero. +this bug is fixed in kernel 2.6.11. +.\" the bug report: +.\" http://marc.theaimsgroup.com/?l=linux-kernel&m=110260821123863&w=2 +.\" the fix: +.\" http://marc.theaimsgroup.com/?l=linux-kernel&m=110261701025794&w=2 +.sh examples +the following code segment uses +.br semop () +to atomically wait for the value of semaphore 0 to become zero, +and then increment the semaphore value by one. +.pp +.in +4n +.ex +struct sembuf sops[2]; +int semid; + +/* code to set \fisemid\fp omitted */ + +sops[0].sem_num = 0; /* operate on semaphore 0 */ +sops[0].sem_op = 0; /* wait for value to equal 0 */ +sops[0].sem_flg = 0; + +sops[1].sem_num = 0; /* operate on semaphore 0 */ +sops[1].sem_op = 1; /* increment value by one */ +sops[1].sem_flg = 0; + +if (semop(semid, sops, 2) == \-1) { + perror("semop"); + exit(exit_failure); +} +.ee +.in +.pp +a further example of the use of +.br semop () +can be found in +.br shmop (2). +.sh see also +.br clone (2), +.br semctl (2), +.br semget (2), +.br sigaction (2), +.br capabilities (7), +.br sem_overview (7), +.br sysvipc (7), +.br time (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man7/iso_8859-10.7 + +.so man3/wcstoimax.3 + +.so man7/system_data_types.7 + +.so man7/iso_8859-15.7 + +.so man2/setxattr.2 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" and copyright 2020 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sat jul 24 18:08:52 1993 by rik faith (faith@cs.unc.edu) +.\" modified 2001-08-31, aeb +.\" +.th strcmp 3 2021-03-22 "" "linux programmer's manual" +.sh name +strcmp, strncmp \- compare two strings +.sh synopsis +.nf +.b #include +.pp +.bi "int strcmp(const char *" s1 ", const char *" s2 ); +.bi "int strncmp(const char *" s1 ", const char *" s2 ", size_t " n ); +.fi +.sh description +the +.br strcmp () +function compares the two strings +.i s1 +and +.ir s2 . +the locale is not taken into account (for a locale-aware comparison, see +.br strcoll (3)). +the comparison is done using unsigned characters. +.pp +.br strcmp () +returns an integer indicating the result of the comparison, as follows: +.ip \(bu 2 +0, if the +.i s1 +and +.i s2 +are equal; +.ip \(bu +a negative value if +.i s1 +is less than +.ir s2 ; +.ip \(bu +a positive value if +.i s1 +is greater than +.ir s2 . +.pp +the +.br strncmp () +function is similar, except it compares +only the first (at most) +.ir n +bytes of +.i s1 +and +.ir s2 . +.sh return value +the +.br strcmp () +and +.br strncmp () +functions return an integer +less than, equal to, or greater than zero if +.i s1 +(or the first +.i n +bytes thereof) is found, respectively, to be less than, to +match, or be greater than +.ir s2 . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br strcmp (), +.br strncmp () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c89, c99, svr4, 4.3bsd. +.sh notes +posix.1 specifies only that: +.rs +.pp +the sign of a nonzero return value shall be determined by the sign +of the difference between the values of the first pair of bytes +(both interpreted as type +.ir "unsigned char" ) +that differ in the strings being compared. +.re +.pp +in glibc, as in most other implementations, +the return value is the arithmetic result of subtracting +the last compared byte in +.i s2 +from the last compared byte in +.ir s1 . +(if the two characters are equal, this difference is 0.) +.sh examples +the program below can be used to demonstrate the operation of +.br strcmp () +(when given two arguments) and +.br strncmp () +(when given three arguments). +first, some examples using +.br strcmp (): +.pp +.in +4n +.ex +$ \fb./string_comp abc abc\fp + and are equal +$ \fb./string_comp abc ab\fp # \(aqc\(aq is ascii 67; \(aqc\(aq \- \(aq\e0\(aq = 67 + is greater than (67) +$ \fb./string_comp aba abz\fp # \(aqa\(aq is ascii 65; \(aqz\(aq is ascii 90 + is less than (\-25) +$ \fb./string_comp abj abc\fp + is greater than (7) +$ .\fb/string_comp $\(aq\e201\(aq a\fp # 0201 \- 0101 = 0100 (or 64 decimal) + is greater than (64) +.ee +.in +.pp +the last example uses +.br bash (1)-specific +syntax to produce a string containing an 8-bit ascii code; +the result demonstrates that the string comparison uses unsigned +characters. +.pp +and then some examples using +.br strncmp (): +.pp +.in +4n +.ex +$ \fb./string_comp abc ab 3\fp + is greater than (67) +$ \fb./string_comp abc ab 2\fp + and are equal in the first 2 bytes +.ee +.in +.ss program source +\& +.ex +/* string_comp.c + + licensed under gnu general public license v2 or later. +*/ +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + int res; + + if (argc < 3) { + fprintf(stderr, "usage: %s []\en", argv[0]); + exit(exit_failure); + } + + if (argc == 3) + res = strcmp(argv[1], argv[2]); + else + res = strncmp(argv[1], argv[2], atoi(argv[3])); + + if (res == 0) { + printf(" and are equal"); + if (argc > 3) + printf(" in the first %d bytes\en", atoi(argv[3])); + printf("\en"); + } else if (res < 0) { + printf(" is less than (%d)\en", res); + } else { + printf(" is greater than (%d)\en", res); + } + + exit(exit_success); +} +.ee +.sh see also +.br bcmp (3), +.br memcmp (3), +.br strcasecmp (3), +.br strcoll (3), +.br string (3), +.br strncasecmp (3), +.br strverscmp (3), +.br wcscmp (3), +.br wcsncmp (3), +.br ascii (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/strcmp.3 + +.so man3/xdr.3 + +.\" copyright (c) 2009, linux foundation, written by michael kerrisk +.\" +.\" a few pieces remain from an earlier version +.\" copyright (c) 2008, nanno langstraat +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th endian 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +htobe16, htole16, be16toh, le16toh, htobe32, htole32, be32toh, le32toh, +htobe64, htole64, be64toh, le64toh \- +convert values between host and big-/little-endian byte order +.sh synopsis +.nf +.b #include +.pp +.bi "uint16_t htobe16(uint16_t " host_16bits ); +.bi "uint16_t htole16(uint16_t " host_16bits ); +.bi "uint16_t be16toh(uint16_t " big_endian_16bits ); +.bi "uint16_t le16toh(uint16_t " little_endian_16bits ); +.pp +.bi "uint32_t htobe32(uint32_t " host_32bits ); +.bi "uint32_t htole32(uint32_t " host_32bits ); +.bi "uint32_t be32toh(uint32_t " big_endian_32bits ); +.bi "uint32_t le32toh(uint32_t " little_endian_32bits ); +.pp +.bi "uint64_t htobe64(uint64_t " host_64bits ); +.bi "uint64_t htole64(uint64_t " host_64bits ); +.bi "uint64_t be64toh(uint64_t " big_endian_64bits ); +.bi "uint64_t le64toh(uint64_t " little_endian_64bits ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.ad l +.pp +.br htobe16 (), +.br htole16 (), +.br be16toh (), +.br le16toh (), +.br htobe32 (), +.br htole32 (), +.br be32toh (), +.br le32toh (), +.br htobe64 (), +.br htole64 (), +.br be64toh (), +.br le64toh (): +.nf + since glibc 2.19: + _default_source + in glibc up to and including 2.19: + _bsd_source +.fi +.ad +.sh description +these functions convert the byte encoding of integer values from +the byte order that the current cpu (the "host") uses, +to and from little-endian and big-endian byte order. +.pp +the number, +.ir nn , +in the name of each function indicates the size of +integer handled by the function, either 16, 32, or 64 bits. +.pp +the functions with names of the form "htobe\finn\fp" convert +from host byte order to big-endian order. +.pp +the functions with names of the form "htole\finn\fp" convert +from host byte order to little-endian order. +.pp +the functions with names of the form "be\finn\fptoh" convert +from big-endian order to host byte order. +.pp +the functions with names of the form "le\finn\fptoh" convert +from little-endian order to host byte order. +.sh versions +these functions were added to glibc in version 2.9. +.sh conforming to +these functions are nonstandard. +similar functions are present on the bsds, +where the required header file is +.i +instead of +.ir . +unfortunately, +netbsd, freebsd, and glibc haven't followed the original +openbsd naming convention for these functions, +whereby the +.i nn +component always appears at the end of the function name +(thus, for example, in netbsd, freebsd, and glibc, +the equivalent of openbsds "betoh32" is "be32toh"). +.sh notes +these functions are similar to the older +.br byteorder (3) +family of functions. +for example, +.br be32toh () +is identical to +.br ntohl (). +.pp +the advantage of the +.br byteorder (3) +functions is that they are standard functions available +on all unix systems. +on the other hand, the fact that they were designed +for use in the context of tcp/ip means that +they lack the 64-bit and little-endian variants described in this page. +.sh examples +the program below display the results of converting an integer +from host byte order to both little-endian and big-endian byte order. +since host byte order is either little-endian or big-endian, +only one of these conversions will have an effect. +when we run this program on a little-endian system such as x86-32, +we see the following: +.pp +.in +4n +.ex +$ \fb./a.out\fp +x.u32 = 0x44332211 +htole32(x.u32) = 0x44332211 +htobe32(x.u32) = 0x11223344 +.ee +.in +.ss program source +\& +.ex +#include +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + union { + uint32_t u32; + uint8_t arr[4]; + } x; + + x.arr[0] = 0x11; /* lowest\-address byte */ + x.arr[1] = 0x22; + x.arr[2] = 0x33; + x.arr[3] = 0x44; /* highest\-address byte */ + + printf("x.u32 = %#x\en", x.u32); + printf("htole32(x.u32) = %#x\en", htole32(x.u32)); + printf("htobe32(x.u32) = %#x\en", htobe32(x.u32)); + + exit(exit_success); +} +.ee +.sh see also +.br bswap (3), +.br byteorder (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 2004 andries brouwer . +.\" and copyright (c) 2020 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th lseek64 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +lseek64 \- reposition 64-bit read/write file offset +.sh synopsis +.nf +.br "#define _largefile64_source" " /* see feature_test_macros(7) */" +.b #include +.b #include +.pp +.bi "off64_t lseek64(int " fd ", off64_t " offset ", int " whence ); +.fi +.sh description +the +.br lseek () +family of functions reposition the offset of the open file associated +with the file descriptor +.i fd +to +.i offset +bytes relative to the start, current position, or end of the file, +when +.i whence +has the value +.br seek_set , +.br seek_cur , +or +.br seek_end , +respectively. +.pp +for more details, return value, and errors, see +.br lseek (2). +.pp +four interfaces are available: +.br lseek (), +.br lseek64 (), +.br llseek (), +and +.br _llseek (). +.\" +.\" for some background details, see: +.\" https://lore.kernel.org/linux-man/cakgnakhnswr3uyhyyaxx74fzfj3jrpfaapvrk0afk_caousbdg@mail.gmail.com/ +.\" +.ss lseek() +prototype: +.pp +.in +4n +.ex +.bi "off_t lseek(int " fd ", off_t " offset ", int " whence ); +.ee +.in +.pp +the c library's +.br lseek () +wrapper function uses the type +.ir off_t . +this is a 32-bit signed type on 32-bit architectures, unless one +compiles with +.pp +.in +4n +.ex +#define _file_offset_bits 64 +.ee +.in +.pp +in which case it is a 64-bit signed type. +.ss lseek64() +prototype: +.pp +.in +4n +.ex +.bi "off64_t lseek64(int " fd ", off64_t " offset ", int " whence ); +.ee +.in +.pp +the +.br lseek64 () +library function uses a 64-bit type even when +.i off_t +is a 32-bit type. +its prototype (and the type +.ir off64_t ) +is available only when one compiles with +.pp +.in +4n +.ex +#define _largefile64_source +.ee +.in +.pp +the function +.br lseek64 () +.\" in glibc 2.0.94, not in 2.0.6 +is available since glibc 2.1. +.\" +.ss llseek() +prototype: +.pp +.in +4n +.ex +.bi "loff_t llseek(int " fd ", loff_t " offset ", int " whence ); +.ee +.in +.pp +the type +.i loff_t +is a 64-bit signed type. +the +.br llseek () +library function is available in glibc and works without special defines. +however, the glibc headers do not provide a prototype. +users should add +the above prototype, or something equivalent, to their own source. +when users complained about data loss caused by a miscompilation of +.br e2fsck (8), +glibc 2.1.3 added the link-time warning +.pp +.in +4n +"the \`llseek\' function may be dangerous; use \`lseek64\' instead." +.in +.pp +this makes this function unusable if one desires a warning-free +compilation. +.pp +since glibc 2.28, +.\" glibc commit 5c5c0dd747070db624c8e2c43691cec854f114ef +this function symbol is no longer available to newly linked applications. +.\" +.ss _llseek() +on 32-bit architectures, +this is the system call that is used (by the c library wrapper functions) +to implement all of the above functions. +the prototype is: +.pp +.in +4n +.ex +.bi "int _llseek(int " fd ", off_t " offset_hi ", off_t " offset_lo , +.bi " loff_t *" result ", int " whence ); +.ee +.in +.pp +for more details, see +.br llseek (2). +.pp +64-bit systems don't need an +.br _llseek () +system call. +instead, they have an +.br lseek (2) +system call that supports 64-bit file offsets. +.\" in arch/x86/entry/syscalls/syscall_32.tbl, +.\" we see the following line: +.\" +.\" 140 i386 _llseek sys_llseek +.\" +.\" this is essentially telling us that 'sys_llseek' (the name generated +.\" by syscall_define5(llseek...)) is exposed to user-space as system call +.\" number 140, and that system call number will (iiuc) be exposed in +.\" autogenerated headers with the name "__nr__llseek" (i.e., "_llseek"). +.\" the "i386" is telling us that this happens in i386 (32-bit intel). +.\" there is nothing equivalent on x86-64, because 64 bit systems don't +.\" need an _llseek system call. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br lseek64 () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh notes +.br lseek64 () +is one of the functions that was specified in the large file summit (lfs) +specification that was completed in 1996. +the purpose of the specification was to provide transitional support +that allowed applications on 32-bit systems to access +files whose size exceeds that which can be represented with a 32-bit +.ir off_t +type. +as noted above, this symbol is exposed by header files if the +.b _largefile64_source +feature test macro is defined. +alternatively, on a 32-bit system, the symbol +.i lseek +is aliased to +.i lseek64 +if the macro +.b _file_offset_bits +is defined with the value 64. +.sh see also +.br llseek (2), +.br lseek (2) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2012 yoshifuji hideaki +.\" and copyright (c) 2012 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of +.\" this manual under the conditions for verbatim copying, provided that +.\" the entire resulting derived work is distributed under the terms of +.\" a permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume +.\" no responsibility for errors or omissions, or for damages resulting +.\" from the use of the information contained herein. the author(s) may +.\" not have taken the same level of care in the production of this +.\" manual, which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th if_nameindex 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +if_nameindex, if_freenameindex \- get network interface names and indexes +.sh synopsis +.nf +.b #include +.pp +.bi "struct if_nameindex *if_nameindex(" void ); +.bi "void if_freenameindex(struct if_nameindex *" "ptr" ); +.fi +.sh description +the +.br if_nameindex () +function returns an array of +.i if_nameindex +structures, each containing information +about one of the network interfaces on the local system. +the +.i if_nameindex +structure contains at least the following entries: +.pp +.in +4n +.ex +unsigned int if_index; /* index of interface (1, 2, ...) */ +char *if_name; /* null\-terminated name ("eth0", etc.) */ +.ee +.in +.pp +the +.i if_index +field contains the interface index. +the +.i if_name +field points to the null-terminated interface name. +the end of the array is indicated by entry with +.i if_index +set to zero and +.i if_name +set to null. +.pp +the data structure returned by +.br if_nameindex () +is dynamically allocated and should be freed using +.br if_freenameindex () +when no longer needed. +.sh return value +on success, +.br if_nameindex () +returns pointer to the array; +on error, null is returned, and +.i errno +is set to indicate the error. +.sh errors +.br if_nameindex () +may fail and set +.i errno +if: +.tp +.b enobufs +insufficient resources available. +.pp +.br if_nameindex () +may also fail for any of the errors specified for +.br socket (2), +.br bind (2), +.br ioctl (2), +.br getsockname (2), +.br recvmsg (2), +.br sendto (2), +or +.br malloc (3). +.sh versions +the +.br if_nameindex () +function first appeared in glibc 2.1, but before glibc 2.3.4, +the implementation supported only interfaces with ipv4 addresses. +support of interfaces that don't have ipv4 addresses is available only +on kernels that support netlink. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br if_nameindex (), +.br if_freenameindex () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, rfc\ 3493. +.pp +this function first appeared in bsdi. +.sh examples +the program below demonstrates the use of the functions described +on this page. +an example of the output this program might produce is the following: +.pp +.in +4n +.ex +$ \fb./a.out\fi +1: lo +2: wlan0 +3: em1 +.ee +.in +.ss program source +.ex +#include +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + struct if_nameindex *if_ni, *i; + + if_ni = if_nameindex(); + if (if_ni == null) { + perror("if_nameindex"); + exit(exit_failure); + } + + for (i = if_ni; ! (i\->if_index == 0 && i\->if_name == null); i++) + printf("%u: %s\en", i\->if_index, i\->if_name); + + if_freenameindex(if_ni); + + exit(exit_success); +} +.ee +.sh see also +.br getsockopt (2), +.br setsockopt (2), +.br getifaddrs (3), +.br if_indextoname (3), +.br if_nametoindex (3), +.br ifconfig (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2005 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th pipe 7 2021-08-27 "linux" "linux programmer's manual" +.sh name +pipe \- overview of pipes and fifos +.sh description +pipes and fifos (also known as named pipes) +provide a unidirectional interprocess communication channel. +a pipe has a +.i read end +and a +.ir "write end" . +data written to the write end of a pipe can be read +from the read end of the pipe. +.pp +a pipe is created using +.br pipe (2), +which creates a new pipe and returns two file descriptors, +one referring to the read end of the pipe, +the other referring to the write end. +pipes can be used to create a communication channel between related +processes; see +.br pipe (2) +for an example. +.pp +a fifo (short for first in first out) has a name within the filesystem +(created using +.br mkfifo (3)), +and is opened using +.br open (2). +any process may open a fifo, assuming the file permissions allow it. +the read end is opened using the +.b o_rdonly +flag; the write end is opened using the +.b o_wronly +flag. +see +.br fifo (7) +for further details. +.ir note : +although fifos have a pathname in the filesystem, +i/o on fifos does not involve operations on the underlying device +(if there is one). +.ss i/o on pipes and fifos +the only difference between pipes and fifos is the manner in which +they are created and opened. +once these tasks have been accomplished, +i/o on pipes and fifos has exactly the same semantics. +.pp +if a process attempts to read from an empty pipe, then +.br read (2) +will block until data is available. +if a process attempts to write to a full pipe (see below), then +.br write (2) +blocks until sufficient data has been read from the pipe +to allow the write to complete. +nonblocking i/o is possible by using the +.br fcntl (2) +.b f_setfl +operation to enable the +.b o_nonblock +open file status flag. +.pp +the communication channel provided by a pipe is a +.ir "byte stream" : +there is no concept of message boundaries. +.pp +if all file descriptors referring to the write end of a pipe +have been closed, then an attempt to +.br read (2) +from the pipe will see end-of-file +.rb ( read (2) +will return 0). +if all file descriptors referring to the read end of a pipe +have been closed, then a +.br write (2) +will cause a +.b sigpipe +signal to be generated for the calling process. +if the calling process is ignoring this signal, then +.br write (2) +fails with the error +.br epipe . +an application that uses +.br pipe (2) +and +.br fork (2) +should use suitable +.br close (2) +calls to close unnecessary duplicate file descriptors; +this ensures that end-of-file and +.br sigpipe / epipe +are delivered when appropriate. +.pp +it is not possible to apply +.br lseek (2) +to a pipe. +.ss pipe capacity +a pipe has a limited capacity. +if the pipe is full, then a +.br write (2) +will block or fail, depending on whether the +.b o_nonblock +flag is set (see below). +different implementations have different limits for the pipe capacity. +applications should not rely on a particular capacity: +an application should be designed so that a reading process consumes data +as soon as it is available, +so that a writing process does not remain blocked. +.pp +in linux versions before 2.6.11, the capacity of a pipe was the same as +the system page size (e.g., 4096 bytes on i386). +since linux 2.6.11, the pipe capacity is 16 pages +(i.e., 65,536 bytes in a system with a page size of 4096 bytes). +since linux 2.6.35, the default pipe capacity is 16 pages, +but the capacity can be queried and set using the +.br fcntl (2) +.br f_getpipe_sz +and +.br f_setpipe_sz +operations. +see +.br fcntl (2) +for more information. +.pp +the following +.br ioctl (2) +operation, which can be applied to a file descriptor +that refers to either end of a pipe, +places a count of the number of unread bytes in the pipe in the +.i int +buffer pointed to by the final argument of the call: +.pp + ioctl(fd, fionread, &nbytes); +.pp +the +.b fionread +operation is not specified in any standard, +but is provided on many implementations. +.\" +.ss /proc files +on linux, the following files control how much memory can be used for pipes: +.tp +.ir /proc/sys/fs/pipe\-max\-pages " (only in linux 2.6.34)" +.\" commit b492e95be0ae672922f4734acf3f5d35c30be948 +an upper limit, in pages, on the capacity that an unprivileged user +(one without the +.br cap_sys_resource +capability) +can set for a pipe. +.ip +the default value for this limit is 16 times the default pipe capacity +(see above); the lower limit is two pages. +.ip +this interface was removed in linux 2.6.35, in favor of +.ir /proc/sys/fs/pipe\-max\-size . +.tp +.ir /proc/sys/fs/pipe\-max\-size " (since linux 2.6.35)" +.\" commit ff9da691c0498ff81fdd014e7a0731dab2337dac +the maximum size (in bytes) of individual pipes that can be set +.\" this limit is not checked on pipe creation, where the capacity is +.\" always pipe_def_bufs, regardless of pipe-max-size +by users without the +.b cap_sys_resource +capability. +the value assigned to this file may be rounded upward, +to reflect the value actually employed for a convenient implementation. +to determine the rounded-up value, +display the contents of this file after assigning a value to it. +.ip +the default value for this file is 1048576 (1\ mib). +the minimum value that can be assigned to this file is the system page size. +attempts to set a limit less than the page size cause +.br write (2) +to fail with the error +.br einval . +.ip +since linux 4.9, +.\" commit 086e774a57fba4695f14383c0818994c0b31da7c +the value on this file also acts as a ceiling on the default capacity +of a new pipe or newly opened fifo. +.tp +.ir /proc/sys/fs/pipe\-user\-pages\-hard " (since linux 4.5)" +.\" commit 759c01142a5d0f364a462346168a56de28a80f52 +the hard limit on the total size (in pages) of all pipes created or set by +a single unprivileged user (i.e., one with neither the +.b cap_sys_resource +nor the +.b cap_sys_admin +capability). +so long as the total number of pages allocated to pipe buffers +for this user is at this limit, +attempts to create new pipes will be denied, +and attempts to increase a pipe's capacity will be denied. +.ip +when the value of this limit is zero (which is the default), +no hard limit is applied. +.\" the default was chosen to avoid breaking existing applications that +.\" make intensive use of pipes (e.g., for splicing). +.tp +.ir /proc/sys/fs/pipe\-user\-pages\-soft " (since linux 4.5)" +.\" commit 759c01142a5d0f364a462346168a56de28a80f52 +the soft limit on the total size (in pages) of all pipes created or set by +a single unprivileged user (i.e., one with neither the +.b cap_sys_resource +nor the +.b cap_sys_admin +capability). +so long as the total number of pages allocated to pipe buffers +for this user is at this limit, +individual pipes created by a user will be limited to one page, +and attempts to increase a pipe's capacity will be denied. +.ip +when the value of this limit is zero, no soft limit is applied. +the default value for this file is 16384, +which permits creating up to 1024 pipes with the default capacity. +.pp +before linux 4.9, some bugs affected the handling of the +.ir pipe\-user\-pages\-soft +and +.ir pipe\-user\-pages\-hard +limits; see bugs. +.\" +.ss pipe_buf +posix.1 says that writes of less than +.b pipe_buf +bytes must be atomic: the output data is written to the pipe as a +contiguous sequence. +writes of more than +.b pipe_buf +bytes may be nonatomic: the kernel may interleave the data +with data written by other processes. +posix.1 requires +.b pipe_buf +to be at least 512 bytes. +(on linux, +.b pipe_buf +is 4096 bytes.) +the precise semantics depend on whether the file descriptor is nonblocking +.rb ( o_nonblock ), +whether there are multiple writers to the pipe, and on +.ir n , +the number of bytes to be written: +.tp +\fbo_nonblock\fp disabled, \fin\fp <= \fbpipe_buf\fp +all +.i n +bytes are written atomically; +.br write (2) +may block if there is not room for +.i n +bytes to be written immediately +.tp +\fbo_nonblock\fp enabled, \fin\fp <= \fbpipe_buf\fp +if there is room to write +.i n +bytes to the pipe, then +.br write (2) +succeeds immediately, writing all +.i n +bytes; otherwise +.br write (2) +fails, with +.i errno +set to +.br eagain . +.tp +\fbo_nonblock\fp disabled, \fin\fp > \fbpipe_buf\fp +the write is nonatomic: the data given to +.br write (2) +may be interleaved with +.br write (2)s +by other process; +the +.br write (2) +blocks until +.i n +bytes have been written. +.tp +\fbo_nonblock\fp enabled, \fin\fp > \fbpipe_buf\fp +if the pipe is full, then +.br write (2) +fails, with +.i errno +set to +.br eagain . +otherwise, from 1 to +.i n +bytes may be written (i.e., a "partial write" may occur; +the caller should check the return value from +.br write (2) +to see how many bytes were actually written), +and these bytes may be interleaved with writes by other processes. +.ss open file status flags +the only open file status flags that can be meaningfully applied to +a pipe or fifo are +.b o_nonblock +and +.br o_async . +.pp +setting the +.b o_async +flag for the read end of a pipe causes a signal +.rb ( sigio +by default) to be generated when new input becomes available on the pipe. +the target for delivery of signals must be set using the +.br fcntl (2) +.b f_setown +command. +on linux, +.b o_async +is supported for pipes and fifos only since kernel 2.6. +.ss portability notes +on some systems (but not linux), pipes are bidirectional: +data can be transmitted in both directions between the pipe ends. +posix.1 requires only unidirectional pipes. +portable applications should avoid reliance on +bidirectional pipe semantics. +.ss bugs +before linux 4.9, some bugs affected the handling of the +.ir pipe\-user\-pages\-soft +and +.ir pipe\-user\-pages\-hard +limits when using the +.br fcntl (2) +.br f_setpipe_sz +operation to change a pipe's capacity: +.\" these bugs where remedied by a series of patches, in particular, +.\" commit b0b91d18e2e97b741b294af9333824ecc3fadfd8 and +.\" commit a005ca0e6813e1d796a7422a7e31d8b8d6555df1 +.ip (1) 5 +when increasing the pipe capacity, the checks against the soft and +hard limits were made against existing consumption, +and excluded the memory required for the increased pipe capacity. +the new increase in pipe capacity could then push the total +memory used by the user for pipes (possibly far) over a limit. +(this could also trigger the problem described next.) +.ip +starting with linux 4.9, +the limit checking includes the memory required for the new pipe capacity. +.ip (2) +the limit checks were performed even when the new pipe capacity was +less than the existing pipe capacity. +this could lead to problems if a user set a large pipe capacity, +and then the limits were lowered, with the result that the user could +no longer decrease the pipe capacity. +.ip +starting with linux 4.9, checks against the limits +are performed only when increasing a pipe's capacity; +an unprivileged user can always decrease a pipe's capacity. +.ip (3) +the accounting and checking against the limits were done as follows: +.ip +.rs +.pd 0 +.ip (a) 4 +test whether the user has exceeded the limit. +.ip (b) +make the new pipe buffer allocation. +.ip (c) +account new allocation against the limits. +.pd +.re +.ip +this was racey. +multiple processes could pass point (a) simultaneously, +and then allocate pipe buffers that were accounted for only in step (c), +with the result that the user's pipe buffer +allocation could be pushed over the limit. +.ip +starting with linux 4.9, +the accounting step is performed before doing the allocation, +and the operation fails if the limit would be exceeded. +.pp +before linux 4.9, bugs similar to points (1) and (3) could also occur +when the kernel allocated memory for a new pipe buffer; +that is, when calling +.br pipe (2) +and when opening a previously unopened fifo. +.sh see also +.br mkfifo (1), +.br dup (2), +.br fcntl (2), +.br open (2), +.br pipe (2), +.br poll (2), +.br select (2), +.br socketpair (2), +.br splice (2), +.br stat (2), +.br tee (2), +.br vmsplice (2), +.br mkfifo (3), +.br epoll (7), +.br fifo (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1992 drew eckhardt, march 28, 1992 +.\" and copyright (c) 2002 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" 2004-11-16 -- mtk: the getrlimit.2 page, which formerly included +.\" coverage of getrusage(2), has been split, so that the latter is +.\" now covered in its own getrusage.2. for older details of change +.\" history, etc., see getrlimit.2 +.\" +.\" modified 2004-11-16, mtk, noted that the nonconformance +.\" when sigchld is being ignored is fixed in 2.6.9. +.\" 2008-02-22, sripathi kodi : document rusage_thread +.\" 2008-05-25, mtk, clarify rusage_children + other clean-ups. +.\" 2010-05-24, mark hills : description of fields, +.\" document ru_maxrss +.\" 2010-05-24, mtk, enhanced description of various fields +.\" +.th getrusage 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +getrusage \- get resource usage +.sh synopsis +.nf +.b #include +.pp +.bi "int getrusage(int " who ", struct rusage *" usage ); +.fi +.sh description +.br getrusage () +returns resource usage measures for +.ir who , +which can be one of the following: +.tp +.b rusage_self +return resource usage statistics for the calling process, +which is the sum of resources used by all threads in the process. +.tp +.b rusage_children +return resource usage statistics for all children of the +calling process that have terminated and been waited for. +these statistics will include the resources used by grandchildren, +and further removed descendants, +if all of the intervening descendants waited on their terminated children. +.tp +.br rusage_thread " (since linux 2.6.26)" +return resource usage statistics for the calling thread. +the +.b _gnu_source +feature test macro must be defined (before including +.i any +header file) +in order to obtain the definition of this constant from +.ir . +.pp +the resource usages are returned in the structure pointed to by +.ir usage , +which has the following form: +.pp +.in +4n +.ex +struct rusage { + struct timeval ru_utime; /* user cpu time used */ + struct timeval ru_stime; /* system cpu time used */ + long ru_maxrss; /* maximum resident set size */ + long ru_ixrss; /* integral shared memory size */ + long ru_idrss; /* integral unshared data size */ + long ru_isrss; /* integral unshared stack size */ + long ru_minflt; /* page reclaims (soft page faults) */ + long ru_majflt; /* page faults (hard page faults) */ + long ru_nswap; /* swaps */ + long ru_inblock; /* block input operations */ + long ru_oublock; /* block output operations */ + long ru_msgsnd; /* ipc messages sent */ + long ru_msgrcv; /* ipc messages received */ + long ru_nsignals; /* signals received */ + long ru_nvcsw; /* voluntary context switches */ + long ru_nivcsw; /* involuntary context switches */ +}; +.ee +.in +.pp +not all fields are completed; +unmaintained fields are set to zero by the kernel. +(the unmaintained fields are provided for compatibility with other systems, +and because they may one day be supported on linux.) +the fields are interpreted as follows: +.tp +.i ru_utime +this is the total amount of time spent executing in user mode, +expressed in a +.i timeval +structure (seconds plus microseconds). +.tp +.i ru_stime +this is the total amount of time spent executing in kernel mode, +expressed in a +.i timeval +structure (seconds plus microseconds). +.tp +.ir ru_maxrss " (since linux 2.6.32)" +this is the maximum resident set size used (in kilobytes). +for +.br rusage_children , +this is the resident set size of the largest child, not the maximum +resident set size of the process tree. +.tp +.ir ru_ixrss " (unmaintained)" +this field is currently unused on linux. +.\" on some systems, +.\" this is the integral of the text segment memory consumption, +.\" expressed in kilobyte-seconds. +.tp +.ir ru_idrss " (unmaintained)" +this field is currently unused on linux. +.\" on some systems, this is the integral of the data segment memory consumption, +.\" expressed in kilobyte-seconds. +.tp +.ir ru_isrss " (unmaintained)" +this field is currently unused on linux. +.\" on some systems, this is the integral of the stack memory consumption, +.\" expressed in kilobyte-seconds. +.tp +.i ru_minflt +the number of page faults serviced without any i/o activity; here +i/o activity is avoided by \*(lqreclaiming\*(rq a page frame from +the list of pages awaiting reallocation. +.tp +.i ru_majflt +the number of page faults serviced that required i/o activity. +.tp +.ir ru_nswap " (unmaintained)" +this field is currently unused on linux. +.\" on some systems, this is the number of swaps out of physical memory. +.tp +.ir ru_inblock " (since linux 2.6.22)" +the number of times the filesystem had to perform input. +.tp +.ir ru_oublock " (since linux 2.6.22)" +the number of times the filesystem had to perform output. +.tp +.ir ru_msgsnd " (unmaintained)" +this field is currently unused on linux. +.\" on freebsd 6.2, this appears to measure messages sent over sockets +.\" on some systems, +.\" this field records the number of messages sent over sockets. +.tp +.ir ru_msgrcv " (unmaintained)" +this field is currently unused on linux. +.\" on freebsd 6.2, this appears to measure messages received over sockets +.\" on some systems, +.\" this field records the number of messages received over sockets. +.tp +.ir ru_nsignals " (unmaintained)" +this field is currently unused on linux. +.\" on some systems, this field records the number of signals received. +.tp +.ir ru_nvcsw " (since linux 2.6)" +the number of times a context switch resulted due to a process +voluntarily giving up the processor before its time slice was +completed (usually to await availability of a resource). +.tp +.ir ru_nivcsw " (since linux 2.6)" +the number of times a context switch resulted due to a higher +priority process becoming runnable or because the current process +exceeded its time slice. +.sh return value +on success, zero is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b efault +.i usage +points outside the accessible address space. +.tp +.b einval +.i who +is invalid. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br getrusage () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, svr4, 4.3bsd. +posix.1 specifies +.br getrusage (), +but specifies only the fields +.i ru_utime +and +.ir ru_stime . +.pp +.b rusage_thread +is linux-specific. +.sh notes +resource usage metrics are preserved across an +.br execve (2). +.pp +in linux kernel versions before 2.6.9, if the disposition of +.b sigchld +is set to +.b sig_ign +then the resource usages of child processes +are automatically included in the value returned by +.br rusage_children , +although posix.1-2001 explicitly prohibits this. +this nonconformance is rectified in linux 2.6.9 and later. +.\" see the description of getrusage() in xsh. +.\" a similar statement was also in susv2. +.pp +the structure definition shown at the start of this page +was taken from 4.3bsd reno. +.pp +ancient systems provided a +.br vtimes () +function with a similar purpose to +.br getrusage (). +for backward compatibility, glibc (up until version 2.32) also provides +.br vtimes (). +all new applications should be written using +.br getrusage (). +(since version 2.33, glibc no longer provides an +.br vtimes () +implementation.) +.pp +see also the description of +.ir /proc/[pid]/stat +in +.br proc (5). +.sh see also +.br clock_gettime (2), +.br getrlimit (2), +.br times (2), +.br wait (2), +.br wait4 (2), +.br clock (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/list.3 + +.\" copyright (c) 2001 andries brouwer . +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" 2007-07-05 mtk: added details on underlying system call interfaces +.\" +.th uname 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +uname \- get name and information about current kernel +.sh synopsis +.nf +.b #include +.pp +.bi "int uname(struct utsname *" buf ); +.fi +.sh description +.br uname () +returns system information in the structure pointed to by +.ir buf . +the +.i utsname +struct is defined in +.ir : +.pp +.in +4n +.ex +struct utsname { + char sysname[]; /* operating system name (e.g., "linux") */ + char nodename[]; /* name within "some implementation\-defined + network" */ + char release[]; /* operating system release + (e.g., "2.6.28") */ + char version[]; /* operating system version */ + char machine[]; /* hardware identifier */ +#ifdef _gnu_source + char domainname[]; /* nis or yp domain name */ +#endif +}; +.ee +.in +.pp +the length of the arrays in a +.i struct utsname +is unspecified (see notes); +the fields are terminated by a null byte (\(aq\e0\(aq). +.sh return value +on success, zero is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b efault +.i buf +is not valid. +.sh conforming to +posix.1-2001, posix.1-2008, svr4. +there is no +.br uname () +call in 4.3bsd. +.pp +the +.i domainname +member (the nis or yp domain name) is a gnu extension. +.sh notes +this is a system call, and the operating system presumably knows +its name, release, and version. +it also knows what hardware it runs on. +so, four of the fields of the struct are meaningful. +on the other hand, the field +.i nodename +is meaningless: +it gives the name of the present machine in some undefined +network, but typically machines are in more than one network +and have several names. +moreover, the kernel has no way of knowing +about such things, so it has to be told what to answer here. +the same holds for the additional +.i domainname +field. +.pp +to this end, linux uses the system calls +.br sethostname (2) +and +.br setdomainname (2). +note that there is no standard that says that the hostname set by +.br sethostname (2) +is the same string as the +.i nodename +field of the struct returned by +.br uname () +(indeed, some systems allow a 256-byte hostname and an 8-byte nodename), +but this is true on linux. +the same holds for +.br setdomainname (2) +and the +.i domainname +field. +.pp +the length of the fields in the struct varies. +some operating systems +or libraries use a hardcoded 9 or 33 or 65 or 257. +other systems use +.b sys_nmln +or +.b _sys_nmln +or +.b utslen +or +.br _utsname_length . +clearly, it is a bad +idea to use any of these constants; just use sizeof(...). +often 257 is chosen in order to have room for an internet hostname. +.pp +part of the utsname information is also accessible via +.ir /proc/sys/kernel/ { ostype , +.ir hostname , +.ir osrelease , +.ir version , +.ir domainname }. +.ss c library/kernel differences +over time, increases in the size of the +.i utsname +structure have led to three successive versions of +.br uname (): +.ir sys_olduname () +(slot +.ir __nr_oldolduname ), +.ir sys_uname () +(slot +.ir __nr_olduname ), +and +.ir sys_newuname () +(slot +.ir __nr_uname) . +the first one +.\" that was back before linux 1.0 +used length 9 for all fields; +the second +.\" that was also back before linux 1.0 +used 65; +the third also uses 65 but adds the +.i domainname +field. +the glibc +.br uname () +wrapper function hides these details from applications, +invoking the most recent version of the system call provided by the kernel. +.sh see also +.br uname (1), +.br getdomainname (2), +.br gethostname (2), +.br uts_namespaces (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified mon apr 12 12:51:24 1993, david metcalfe +.\" 2006-05-19, justin pryzby +.\" document strchrnul(3). +.\" +.th strchr 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +strchr, strrchr, strchrnul \- locate character in string +.sh synopsis +.nf +.b #include +.pp +.bi "char *strchr(const char *" s ", int " c ); +.bi "char *strrchr(const char *" s ", int " c ); +.pp +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "char *strchrnul(const char *" s ", int " c ); +.fi +.sh description +the +.br strchr () +function returns a pointer to the first occurrence +of the character +.i c +in the string +.ir s . +.pp +the +.br strrchr () +function returns a pointer to the last occurrence +of the character +.i c +in the string +.ir s . +.pp +the +.br strchrnul () +function is like +.br strchr () +except that if +.i c +is not found in +.ir s , +then it returns a pointer to the null byte +at the end of +.ir s , +rather than null. +.pp +here "character" means "byte"; these functions do not work with +wide or multibyte characters. +.sh return value +the +.br strchr () +and +.br strrchr () +functions return a pointer to +the matched character or null if the character is not found. +the terminating null byte is considered part of the string, +so that if +.i c +is specified as \(aq\e0\(aq, +these functions return a pointer to the terminator. +.pp +the +.br strchrnul () +function returns a pointer to the matched character, +or a pointer to the null byte at the end of +.i s +(i.e., +.ir "s+strlen(s)" ) +if the character is not found. +.sh versions +.br strchrnul () +first appeared in glibc in version 2.1.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br strchr (), +.br strrchr (), +.br strchrnul () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +.br strchr (), +.br strrchr (): +posix.1-2001, posix.1-2008, c89, c99, svr4, 4.3bsd. +.pp +.br strchrnul () +is a gnu extension. +.sh see also +.br index (3), +.br memchr (3), +.br rindex (3), +.br string (3), +.br strlen (3), +.br strpbrk (3), +.br strsep (3), +.br strspn (3), +.br strstr (3), +.br strtok (3), +.br wcschr (3), +.br wcsrchr (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1996 andries brouwer (aeb@cwi.nl) +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" 5 oct 2002, modified by michael kerrisk +.\" updated for posix.1 2001 +.\" 2004-12-17 martin schulze , mtk +.\" removed errno declaration prototype, added notes +.\" 2006-02-09 kurt wall, mtk +.\" added non-posix errors +.\" +.th errno 3 2021-03-22 "" "linux programmer's manual" +.sh name +errno \- number of last error +.sh synopsis +.nf +.b #include +.\".pp +.\".bi "extern int " errno ; +.fi +.sh description +the +.i +header file defines the integer variable +.ir errno , +which is set by system calls and some library functions in the event +of an error to indicate what went wrong. +.\" +.ss errno +the value in +.i errno +is significant only when the return value of +the call indicated an error +(i.e., \-1 from most system calls; +\-1 or null from most library functions); +a function that succeeds +.i is +allowed to change +.ir errno . +the value of +.i errno +is never set to zero by any system call or library function. +.pp +for some system calls and library functions (e.g., +.br getpriority (2)), +\-1 is a valid return on success. +in such cases, a successful return can be distinguished from an error +return by setting +.i errno +to zero before the call, and then, +if the call returns a status that indicates that an error +may have occurred, checking to see if +.i errno +has a nonzero value. +.pp +.i errno +is defined by the iso c standard to be a modifiable lvalue +of type +.ir int , +and must not be explicitly declared; +.i errno +may be a macro. +.i errno +is thread-local; setting it in one thread +does not affect its value in any other thread. +.\" +.ss error numbers and names +valid error numbers are all positive numbers. +the +.i +header file defines symbolic names for each +of the possible error numbers that may appear in +.ir errno . +.pp +all the error names specified by posix.1 +must have distinct values, with the exception of +.b eagain +and +.br ewouldblock , +which may be the same. +on linux, these two have the same value on all architectures. +.pp +the error numbers that correspond to each symbolic name +vary across unix systems, +and even across different architectures on linux. +therefore, numeric values are not included as part of the list of +error names below. +the +.br perror (3) +and +.br strerror (3) +functions can be used to convert these names to +corresponding textual error messages. +.pp +on any particular linux system, +one can obtain a list of all symbolic error names and +the corresponding error numbers using the +.br errno (1) +command (part of the +.i moreutils +package): +.pp +.in +4n +.ex +$ \fberrno \-l\fp +eperm 1 operation not permitted +enoent 2 no such file or directory +esrch 3 no such process +eintr 4 interrupted system call +eio 5 input/output error +\&... +.ee +.in +.pp +the +.br errno (1) +command can also be used to look up individual error numbers and names, +and to search for errors using strings from the error description, +as in the following examples: +.pp +.in +4n +.ex +$ \fberrno 2\fp +enoent 2 no such file or directory +$ \fberrno esrch\fp +esrch 3 no such process +$ \fberrno \-s permission\fp +eacces 13 permission denied +.ee +.in +.\".pp +.\" posix.1 (2001 edition) lists the following symbolic error names. of +.\" these, \fbedom\fp and \fberange\fp are in the iso c standard. iso c +.\" amendment 1 defines the additional error number \fbeilseq\fp for +.\" coding errors in multibyte or wide characters. +.\" +.ss list of error names +in the list of the symbolic error names below, +various names are marked as follows: +.ip * 3 +.ir posix.1-2001 : +the name is defined by posix.1-2001, +and is defined in later posix.1 versions, unless otherwise indicated. +.ip * +.ir posix.1-2008 : +the name is defined in posix.1-2008, +but was not present in earlier posix.1 standards. +.ip * +.ir c99 : +the name is defined by c99. +.pp +below is a list of the symbolic error names that are defined on linux: +.tp 16 +.b e2big +argument list too long (posix.1-2001). +.tp +.b eacces +permission denied (posix.1-2001). +.tp +.b eaddrinuse +address already in use (posix.1-2001). +.tp +.b eaddrnotavail +address not available (posix.1-2001). +.\" eadv is only an error on hurd(?) +.tp +.b eafnosupport +address family not supported (posix.1-2001). +.tp +.b eagain +resource temporarily unavailable (may be the same value as +.br ewouldblock ) +(posix.1-2001). +.tp +.b ealready +connection already in progress (posix.1-2001). +.tp +.b ebade +invalid exchange. +.tp +.b ebadf +bad file descriptor (posix.1-2001). +.tp +.b ebadfd +file descriptor in bad state. +.tp +.b ebadmsg +bad message (posix.1-2001). +.tp +.b ebadr +invalid request descriptor. +.tp +.b ebadrqc +invalid request code. +.tp +.b ebadslt +invalid slot. +.\" ebfont is defined but appears not to be used by kernel or glibc. +.tp +.b ebusy +device or resource busy (posix.1-2001). +.tp +.b ecanceled +operation canceled (posix.1-2001). +.tp +.b echild +no child processes (posix.1-2001). +.tp +.b echrng +channel number out of range. +.tp +.b ecomm +communication error on send. +.tp +.b econnaborted +connection aborted (posix.1-2001). +.tp +.b econnrefused +connection refused (posix.1-2001). +.tp +.b econnreset +connection reset (posix.1-2001). +.tp +.b edeadlk +resource deadlock avoided (posix.1-2001). +.tp +.b edeadlock +on most architectures, a synonym for +.br edeadlk . +on some architectures (e.g., linux mips, powerpc, sparc), +it is a separate error code "file locking deadlock error". +.tp +.b edestaddrreq +destination address required (posix.1-2001). +.tp +.b edom +mathematics argument out of domain of function (posix.1, c99). +.\" edotdot is defined but appears to be unused +.tp +.b edquot +.\" posix just says "reserved" +disk quota exceeded (posix.1-2001). +.tp +.b eexist +file exists (posix.1-2001). +.tp +.b efault +bad address (posix.1-2001). +.tp +.b efbig +file too large (posix.1-2001). +.tp +.b ehostdown +host is down. +.tp +.b ehostunreach +host is unreachable (posix.1-2001). +.tp +.b ehwpoison +memory page has hardware error. +.tp +.b eidrm +identifier removed (posix.1-2001). +.tp +.b eilseq +invalid or incomplete multibyte or wide character (posix.1, c99). +.ip +the text shown here is the glibc error description; +in posix.1, this error is described as "illegal byte sequence". +.tp +.b einprogress +operation in progress (posix.1-2001). +.tp +.b eintr +interrupted function call (posix.1-2001); see +.br signal (7). +.tp +.b einval +invalid argument (posix.1-2001). +.tp +.b eio +input/output error (posix.1-2001). +.tp +.b eisconn +socket is connected (posix.1-2001). +.tp +.b eisdir +is a directory (posix.1-2001). +.tp +.b eisnam +is a named type file. +.tp +.b ekeyexpired +key has expired. +.tp +.b ekeyrejected +key was rejected by service. +.tp +.b ekeyrevoked +key has been revoked. +.tp +.b el2hlt +level 2 halted. +.tp +.b el2nsync +level 2 not synchronized. +.tp +.b el3hlt +level 3 halted. +.tp +.b el3rst +level 3 reset. +.tp +.b elibacc +cannot access a needed shared library. +.tp +.b elibbad +accessing a corrupted shared library. +.tp +.b elibmax +attempting to link in too many shared libraries. +.tp +.b elibscn +\&.lib section in a.out corrupted +.tp +.b elibexec +cannot exec a shared library directly. +.tp +.b elnrange +.\" elnrng appears to be used by a few drivers +link number out of range. +.tp +.b eloop +too many levels of symbolic links (posix.1-2001). +.tp +.b emediumtype +wrong medium type. +.tp +.b emfile +too many open files (posix.1-2001). +commonly caused by exceeding the +.br rlimit_nofile +resource limit described in +.br getrlimit (2). +can also be caused by exceeding the limit specified in +.ir /proc/sys/fs/nr_open . +.tp +.b emlink +too many links (posix.1-2001). +.tp +.b emsgsize +message too long (posix.1-2001). +.tp +.b emultihop +.\" posix says "reserved" +multihop attempted (posix.1-2001). +.tp +.b enametoolong +filename too long (posix.1-2001). +.\" enavail is defined, but appears not to be used +.tp +.b enetdown +network is down (posix.1-2001). +.tp +.b enetreset +connection aborted by network (posix.1-2001). +.tp +.b enetunreach +network unreachable (posix.1-2001). +.tp +.b enfile +too many open files in system (posix.1-2001). +on linux, this is probably a result of encountering the +.ir /proc/sys/fs/file\-max +limit (see +.br proc (5)). +.tp +.b enoano +.\" enoano appears to be used by a few drivers +no anode. +.tp +.b enobufs +no buffer space available (posix.1 (xsi streams option)). +.\" enocsi is defined but appears to be unused. +.tp +.b enodata +the named attribute does not exist, +or the process has no access to this attribute; see +.br xattr (7). +.ip +in posix.1-2001 (xsi streams option), +this error was described as +"no message is available on the stream head read queue". +.tp +.b enodev +no such device (posix.1-2001). +.tp +.b enoent +no such file or directory (posix.1-2001). +.ip +typically, this error results when a specified pathname does not exist, +or one of the components in the directory prefix of a pathname does not exist, +or the specified pathname is a dangling symbolic link. +.tp +.b enoexec +exec format error (posix.1-2001). +.tp +.b enokey +required key not available. +.tp +.b enolck +no locks available (posix.1-2001). +.tp +.b enolink +.\" posix says "reserved" +link has been severed (posix.1-2001). +.tp +.b enomedium +no medium found. +.tp +.b enomem +not enough space/cannot allocate memory (posix.1-2001). +.tp +.b enomsg +no message of the desired type (posix.1-2001). +.tp +.b enonet +machine is not on the network. +.tp +.b enopkg +package not installed. +.tp +.b enoprotoopt +protocol not available (posix.1-2001). +.tp +.b enospc +no space left on device (posix.1-2001). +.tp +.b enosr +no stream resources (posix.1 (xsi streams option)). +.tp +.b enostr +not a stream (posix.1 (xsi streams option)). +.tp +.b enosys +function not implemented (posix.1-2001). +.tp +.b enotblk +block device required. +.tp +.b enotconn +the socket is not connected (posix.1-2001). +.tp +.b enotdir +not a directory (posix.1-2001). +.tp +.b enotempty +directory not empty (posix.1-2001). +.\" enotnam is defined but appears to be unused. +.tp +.b enotrecoverable +state not recoverable (posix.1-2008). +.tp +.b enotsock +not a socket (posix.1-2001). +.tp +.b enotsup +operation not supported (posix.1-2001). +.tp +.b enotty +inappropriate i/o control operation (posix.1-2001). +.tp +.b enotuniq +name not unique on network. +.tp +.b enxio +no such device or address (posix.1-2001). +.tp +.b eopnotsupp +operation not supported on socket (posix.1-2001). +.ip +.rb ( enotsup +and +.b eopnotsupp +have the same value on linux, but +according to posix.1 these error values should be distinct.) +.tp +.b eoverflow +value too large to be stored in data type (posix.1-2001). +.tp +.b eownerdead +.\" used at least by the user-space side of rubost mutexes +owner died (posix.1-2008). +.tp +.b eperm +operation not permitted (posix.1-2001). +.tp +.b epfnosupport +protocol family not supported. +.tp +.b epipe +broken pipe (posix.1-2001). +.tp +.b eproto +protocol error (posix.1-2001). +.tp +.b eprotonosupport +protocol not supported (posix.1-2001). +.tp +.b eprototype +protocol wrong type for socket (posix.1-2001). +.tp +.b erange +result too large (posix.1, c99). +.tp +.b eremchg +remote address changed. +.tp +.b eremote +object is remote. +.tp +.b eremoteio +remote i/o error. +.tp +.b erestart +interrupted system call should be restarted. +.tp +.b erfkill +.\" erfkill appears to be used by various drivers +operation not possible due to rf-kill. +.tp +.b erofs +read-only filesystem (posix.1-2001). +.tp +.b eshutdown +cannot send after transport endpoint shutdown. +.tp +.b espipe +invalid seek (posix.1-2001). +.tp +.b esocktnosupport +socket type not supported. +.tp +.b esrch +no such process (posix.1-2001). +.\" esrmnt is defined but appears not to be used +.tp +.b estale +stale file handle (posix.1-2001). +.ip +this error can occur for nfs and for other filesystems. +.tp +.b estrpipe +streams pipe error. +.tp +.b etime +timer expired +(posix.1 (xsi streams option)). +.ip +(posix.1 says "stream +.br ioctl (2) +timeout".) +.tp +.b etimedout +connection timed out (posix.1-2001). +.tp +.b etoomanyrefs +.\" etoomanyrefs seems to be used in net/unix/af_unix.c +too many references: cannot splice. +.tp +.b etxtbsy +text file busy (posix.1-2001). +.tp +.b euclean +structure needs cleaning. +.tp +.b eunatch +protocol driver not attached. +.tp +.b eusers +too many users. +.tp +.b ewouldblock +operation would block (may be same value as +.br eagain ) +(posix.1-2001). +.tp +.b exdev +improper link (posix.1-2001). +.tp +.b exfull +exchange full. +.sh notes +a common mistake is to do +.pp +.in +4n +.ex +if (somecall() == \-1) { + printf("somecall() failed\en"); + if (errno == ...) { ... } +} +.ee +.in +.pp +where +.i errno +no longer needs to have the value it had upon return from +.ir somecall () +(i.e., it may have been changed by the +.br printf (3)). +if the value of +.i errno +should be preserved across a library call, it must be saved: +.pp +.in +4n +.ex +if (somecall() == \-1) { + int errsv = errno; + printf("somecall() failed\en"); + if (errsv == ...) { ... } +} +.ee +.in +.pp +note that the posix threads apis do +.i not +set +.i errno +on error. +instead, on failure they return an error number as the function result. +these error numbers have the same meanings as the error numbers returned in +.i errno +by other apis. +.pp +on some ancient systems, +.i +was not present or did not declare +.ir errno , +so that it was necessary to declare +.i errno +manually +(i.e., +.ir "extern int errno" ). +.br "do not do this" . +it long ago ceased to be necessary, +and it will cause problems with modern versions of the c library. +.sh see also +.br errno (1), \" in the moreutils package +.br err (3), +.br error (3), +.br perror (3), +.br strerror (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" iso/iec 9899:1999 +.\" +.th btowc 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +btowc \- convert single byte to wide character +.sh synopsis +.nf +.b #include +.pp +.bi "wint_t btowc(int " c ); +.fi +.sh description +the +.br btowc () +function converts \fic\fp, +interpreted as a multibyte sequence +of length 1, starting in the initial shift state, to a wide character and +returns it. +if \fic\fp is +.b eof +or not a valid multibyte sequence of length 1, +the +.br btowc () +function returns +.br weof . +.sh return value +the +.br btowc () +function returns the wide character +converted from the single byte \fic\fp. +if \fic\fp is +.b eof +or not a valid multibyte sequence of length 1, +it returns +.br weof . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br btowc () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh notes +the behavior of +.br btowc () +depends on the +.b lc_ctype +category of the +current locale. +.pp +this function should never be used. +it does not work for encodings which have +state, and unnecessarily treats single bytes differently from multibyte +sequences. +use either +.br mbtowc (3) +or the thread-safe +.br mbrtowc (3) +instead. +.sh see also +.br mbrtowc (3), +.br mbtowc (3), +.br wctob (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/geteuid.2 + +#!/bin/sh +# +# fixme_list.sh +# +# display fixme segments from man-pages source files +# +# (c) copyright 2007 & 2013, michael kerrisk +# this program is free software; you can redistribute it and/or +# modify it under the terms of the gnu general public license +# as published by the free software foundation; either version 2 +# of the license, or (at your option) any later version. +# +# this program 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 general public license for more details +# (http://www.gnu.org/licenses/gpl-2.0.html). +# +###################################################################### +# +# (c) copyright 2006 & 2013, michael kerrisk +# this program is free software; you can redistribute it and/or +# modify it under the terms of the gnu general public license +# as published by the free software foundation; either version 2 +# of the license, or (at your option) any later version. +# +# this program 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 general public license for more details +# (http://www.gnu.org/licenses/gpl-2.0.html). +# +# + +show_all="n" +while getopts "a" optname; do + case "$optname" in + + a) # "all" + # even show fixmes that aren't generally interesting. (typically + # these fixmes are notes to the maintainer to reverify something + # at a future date.) + + show_all="y" + ;; + + *) echo "unknown option: $optarg" + exit 1 + ;; + + esac +done + +shift $(( $optind - 1 )) + +if test $# -eq 0; then + echo "usage: $0 [-a] pathname..." 1>&2 + exit 1; +fi + +for dir in "$@"; do + for page in $(find "$dir" -type f -name '*.[1-9]' \ + -exec grep -l fixme {} \; | sort) + do + cat "$page" | awk -v show_all=$show_all -v page_name="$page" \ + ' + begin { + page_fixme_cnt = 0; + } + + /fixme/ { + + # /.\" fixme . / ==> do not display this fixme, unless + # -a command-line option was supplied + + if ($0 ~ /^\.\\" fixme \./ ) + fixme_type = "hidden" + else if ($0 ~ /^\.\\" fixme *\?/ ) + fixme_type = "question" + else + fixme_type = "normal"; + if (fixme_type == "normal" || show_all == "y") { + if (page_fixme_cnt == 0) { + print "=========="; + print page_name; + } + page_fixme_cnt++; + + finished = 0; + do { + print $0; + + # implicit end of fixme is end-of-file or a line + # that is not a comment + + if (getline == 0) + finished = 1; + + if (!($0 ~ /^.\\"/)) + finished = 1; + + # /.\" .$/ ==> explicit end of fixme + + if ($0 ~ /^.\\" \.$/) + finished = 1; + } while (!finished); + + print ""; + } + } + ' + done | sed -e 's/^\.\\"/ /' | sed -e 's/ *$//' | cat -s +done + +.so man3/stailq.3 + +.\" copyright (c) 2017 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th inode 7 2021-03-22 "linux" "linux programmer's manual" +.sh name +inode \- file inode information +.sh description +each file has an inode containing metadata about the file. +an application can retrieve this metadata using +.br stat (2) +(or related calls), which returns a +.i stat +structure, or +.br statx (2), +which returns a +.i statx +structure. +.pp +the following is a list of the information typically found in, +or associated with, the file inode, +with the names of the corresponding structure fields returned by +.br stat (2) +and +.br statx (2): +.tp +device where inode resides +\fistat.st_dev\fp; \fistatx.stx_dev_minor\fp and \fistatx.stx_dev_major\fp +.ip +each inode (as well as the associated file) resides in a filesystem +that is hosted on a device. +that device is identified by the combination of its major id +(which identifies the general class of device) +and minor id (which identifies a specific instance in the general class). +.tp +inode number +\fistat.st_ino\fp; \fistatx.stx_ino\fp +.ip +each file in a filesystem has a unique inode number. +inode numbers are guaranteed to be unique only within a filesystem +(i.e., the same inode numbers may be used by different filesystems, +which is the reason that hard links may not cross filesystem boundaries). +this field contains the file's inode number. +.tp +file type and mode +\fistat.st_mode\fp; \fistatx.stx_mode\fp +.ip +see the discussion of file type and mode, below. +.tp +link count +\fistat.st_nlink\fp; \fistatx.stx_nlink\fp +.ip +this field contains the number of hard links to the file. +additional links to an existing file are created using +.br link (2). +.tp +user id +.i st_uid +\fistat.st_uid\fp; \fistatx.stx_uid\fp +.ip +this field records the user id of the owner of the file. +for newly created files, +the file user id is the effective user id of the creating process. +the user id of a file can be changed using +.br chown (2). +.tp +group id +\fistat.st_gid\fp; \fistatx.stx_gid\fp +.ip +the inode records the id of the group owner of the file. +for newly created files, +the file group id is either the group id of the parent directory or +the effective group id of the creating process, +depending on whether or not the set-group-id bit +is set on the parent directory (see below). +the group id of a file can be changed using +.br chown (2). +.tp +device represented by this inode +\fistat.st_rdev\fp; \fistatx.stx_rdev_minor\fp and \fistatx.stx_rdev_major\fp +.ip +if this file (inode) represents a device, +then the inode records the major and minor id of that device. +.tp +file size +\fistat.st_size\fp; \fistatx.stx_size\fp +.ip +this field gives the size of the file (if it is a regular +file or a symbolic link) in bytes. +the size of a symbolic link is the length of the pathname +it contains, without a terminating null byte. +.tp +preferred block size for i/o +\fistat.st_blksize\fp; \fistatx.stx_blksize\fp +.ip +this field gives the "preferred" blocksize for efficient filesystem i/o. +(writing to a file in smaller chunks may cause +an inefficient read-modify-rewrite.) +.tp +number of blocks allocated to the file +\fistat.st_blocks\fp; \fistatx.stx_size\fp +.ip +this field indicates the number of blocks allocated to the file, +512-byte units, +(this may be smaller than +.ir st_size /512 +when the file has holes.) +.ip +the posix.1 standard notes +.\" rationale for sys/stat.h in posix.1-2008 +that the unit for the +.i st_blocks +member of the +.i stat +structure is not defined by the standard. +on many implementations it is 512 bytes; +on a few systems, a different unit is used, such as 1024. +furthermore, the unit may differ on a per-filesystem basis. +.tp +last access timestamp (atime) +\fistat.st_atime\fp; \fistatx.stx_atime\fp +.ip +this is the file's last access timestamp. +it is changed by file accesses, for example, by +.br execve (2), +.br mknod (2), +.br pipe (2), +.br utime (2), +and +.br read (2) +(of more than zero bytes). +other interfaces, such as +.br mmap (2), +may or may not update the atime timestamp +.ip +some filesystem types allow mounting in such a way that file +and/or directory accesses do not cause an update of the atime timestamp. +(see +.ir noatime , +.ir nodiratime , +and +.i relatime +in +.br mount (8), +and related information in +.br mount (2).) +in addition, the atime timestamp +is not updated if a file is opened with the +.br o_noatime +flag; see +.br open (2). +.tp +file creation (birth) timestamp (btime) +(not returned in the \fistat\fp structure); \fistatx.stx_btime\fp +.ip +the file's creation timestamp. +this is set on file creation and not changed subsequently. +.ip +the btime timestamp was not historically present on unix systems +and is not currently supported by most linux filesystems. +.\" fixme is it supported on ext4 and xfs? +.tp +last modification timestamp (mtime) +\fistat.st_mtime\fp; \fistatx.stx_mtime\fp +.ip +this is the file's last modification timestamp. +it is changed by file modifications, for example, by +.br mknod (2), +.br truncate (2), +.br utime (2), +and +.br write (2) +(of more than zero bytes). +moreover, the mtime timestamp +of a directory is changed by the creation or deletion of files +in that directory. +the mtime timestamp is +.i not +changed for changes in owner, group, hard link count, or mode. +.tp +last status change timestamp (ctime) +\fistat.st_ctime\fp; \fistatx.stx_ctime\fp +.ip +this is the file's last status change timestamp. +it is changed by writing or by setting inode information +(i.e., owner, group, link count, mode, etc.). +.pp +the timestamp fields report time measured with a zero point at the +.ir epoch , +1970-01-01 00:00:00 +0000, utc (see +.br time (7)). +.pp +nanosecond timestamps are supported on xfs, jfs, btrfs, and +ext4 (since linux 2.6.23). +.\" commit ef7f38359ea8b3e9c7f2cae9a4d4935f55ca9e80 +nanosecond timestamps are not supported in ext2, ext3, and reiserfs. +in order to return timestamps with nanosecond precision, +the timestamp fields in the +.i stat +and +.i statx +structures are defined as structures that include a nanosecond component. +see +.br stat (2) +and +.br statx (2) +for details. +on filesystems that do not support subsecond timestamps, +the nanosecond fields in the +.i stat +and +.i statx +structures are returned with the value 0. +.\" +.ss the file type and mode +the +.i stat.st_mode +field (for +.br statx (2), +the +.i statx.stx_mode +field) contains the file type and mode. +.pp +posix refers to the +.i stat.st_mode +bits corresponding to the mask +.b s_ifmt +(see below) as the +.ir "file type" , +the 12 bits corresponding to the mask 07777 as the +.ir "file mode bits" +and the least significant 9 bits (0777) as the +.ir "file permission bits" . +.pp +the following mask values are defined for the file type: +.in +4n +.ts +lb l l. +s_ifmt 0170000 bit mask for the file type bit field + +s_ifsock 0140000 socket +s_iflnk 0120000 symbolic link +s_ifreg 0100000 regular file +s_ifblk 0060000 block device +s_ifdir 0040000 directory +s_ifchr 0020000 character device +s_ififo 0010000 fifo +.te +.in +.pp +thus, to test for a regular file (for example), one could write: +.pp +.in +4n +.ex +stat(pathname, &sb); +if ((sb.st_mode & s_ifmt) == s_ifreg) { + /* handle regular file */ +} +.ee +.in +.pp +because tests of the above form are common, additional +macros are defined by posix to allow the test of the file type in +.i st_mode +to be written more concisely: +.rs 4 +.tp 1.2i +.br s_isreg (m) +is it a regular file? +.tp +.br s_isdir (m) +directory? +.tp +.br s_ischr (m) +character device? +.tp +.br s_isblk (m) +block device? +.tp +.br s_isfifo (m) +fifo (named pipe)? +.tp +.br s_islnk (m) +symbolic link? (not in posix.1-1996.) +.tp +.br s_issock (m) +socket? (not in posix.1-1996.) +.re +.pp +the preceding code snippet could thus be rewritten as: +.pp +.in +4n +.ex +stat(pathname, &sb); +if (s_isreg(sb.st_mode)) { + /* handle regular file */ +} +.ee +.in +.pp +the definitions of most of the above file type test macros +are provided if any of the following feature test macros is defined: +.br _bsd_source +(in glibc 2.19 and earlier), +.br _svid_source +(in glibc 2.19 and earlier), +or +.br _default_source +(in glibc 2.20 and later). +in addition, definitions of all of the above macros except +.br s_ifsock +and +.br s_issock () +are provided if +.br _xopen_source +is defined. +.pp +the definition of +.br s_ifsock +can also be exposed either by defining +.br _xopen_source +with a value of 500 or greater or (since glibc 2.24) by defining both +.br _xopen_source +and +.br _xopen_source_extended . +.pp +the definition of +.br s_issock () +is exposed if any of the following feature test macros is defined: +.br _bsd_source +(in glibc 2.19 and earlier), +.br _default_source +(in glibc 2.20 and later), +.br _xopen_source +with a value of 500 or greater, +.br _posix_c_source +with a value of 200112l or greater, or (since glibc 2.24) by defining both +.br _xopen_source +and +.br _xopen_source_extended . +.pp +the following mask values are defined for +the file mode component of the +.i st_mode +field: +.in +4n +.nh +.ad l +.ts +lb l lx. +s_isuid 04000 t{ +set-user-id bit (see \fbexecve\fp(2)) +t} +s_isgid 02000 t{ +set-group-id bit (see below) +t} +s_isvtx 01000 t{ +sticky bit (see below) +t} + +s_irwxu 00700 t{ +owner has read, write, and execute permission +t} +s_irusr 00400 t{ +owner has read permission +t} +s_iwusr 00200 t{ +owner has write permission +t} +s_ixusr 00100 t{ +owner has execute permission +t} + +s_irwxg 00070 t{ +group has read, write, and execute permission +t} +s_irgrp 00040 t{ +group has read permission +t} +s_iwgrp 00020 t{ +group has write permission +t} +s_ixgrp 00010 t{ +group has execute permission +t} + +s_irwxo 00007 t{ +others (not in group) have read, write, and execute permission +t} +s_iroth 00004 t{ +others have read permission +t} +s_iwoth 00002 t{ +others have write permission +t} +s_ixoth 00001 t{ +others have execute permission +t} +.te +.ad +.hy +.in +.pp +the set-group-id bit +.rb ( s_isgid ) +has several special uses. +for a directory, it indicates that bsd semantics are to be used +for that directory: files created there inherit their group id from +the directory, not from the effective group id of the creating process, +and directories created there will also get the +.b s_isgid +bit set. +for an executable file, the set-group-id bit causes the effective group id +of a process that executes the file to change as described in +.br execve (2). +for a file that does not have the group execution bit +.rb ( s_ixgrp ) +set, +the set-group-id bit indicates mandatory file/record locking. +.pp +the sticky bit +.rb ( s_isvtx ) +on a directory means that a file +in that directory can be renamed or deleted only by the owner +of the file, by the owner of the directory, and by a privileged +process. +.sh conforming to +if you need to obtain the definition of the +.ir blkcnt_t +or +.ir blksize_t +types from +.ir , +then define +.br _xopen_source +with the value 500 or greater (before including +.i any +header files). +.pp +posix.1-1990 did not describe the +.br s_ifmt , +.br s_ifsock , +.br s_iflnk , +.br s_ifreg , +.br s_ifblk , +.br s_ifdir , +.br s_ifchr , +.br s_ififo , +and +.b s_isvtx +constants, but instead specified the use of +the macros +.br s_isdir () +and so on. +the +.br s_if* +constants are present in posix.1-2001 and later. +.pp +the +.br s_islnk () +and +.br s_issock () +macros were not in +posix.1-1996, but both are present in posix.1-2001; +the former is from svid 4, the latter from susv2. +.pp +unix\ v7 (and later systems) had +.br s_iread , +.br s_iwrite , +.br s_iexec , +and +where posix +prescribes the synonyms +.br s_irusr , +.br s_iwusr , +and +.br s_ixusr . +.sh notes +for pseudofiles that are autogenerated by the kernel, the file size +(\fistat.st_size\fp; \fistatx.stx_size\fp) +reported by the kernel is not accurate. +for example, the value 0 is returned for many files under the +.i /proc +directory, +while various files under +.ir /sys +report a size of 4096 bytes, even though the file content is smaller. +for such files, one should simply try to read as many bytes as possible +(and append \(aq\e0\(aq to the returned buffer +if it is to be interpreted as a string). +.sh see also +.br stat (1), +.br stat (2), +.br statx (2), +.br symlink (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/setfsgid.2 + +.\" michael haardt (michael@cantor.informatik.rwth.aachen.de) +.\" sat sep 3 22:00:30 met dst 1994 +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" sun feb 19 21:32:25 1995, faith@cs.unc.edu edited details away +.\" +.\" to do: this manual page should go more into detail how des is perturbed, +.\" which string will be encrypted, and what determines the repetition factor. +.\" is a simple repetition using ecb used, or something more advanced? i hope +.\" the presented explanations are at least better than nothing, but by no +.\" means enough. +.\" +.\" added _xopen_source, aeb, 970705 +.\" added gnu md5 stuff, aeb, 011223 +.\" +.th crypt 3 2021-03-22 "" "linux programmer's manual" +.sh name +crypt, crypt_r \- password and data encryption +.sh synopsis +.nf +.b #include +.pp +.bi "char *crypt(const char *" key ", const char *" salt ); +.pp +.b #include +.pp +.bi "char *crypt_r(const char *" key ", const char *" salt , +.bi " struct crypt_data *restrict " data ); +.fi +.pp +link with \fi\-lcrypt\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br crypt (): +.nf + since glibc 2.28: + _default_source + glibc 2.27 and earlier: + _xopen_source +.fi +.br +.pp +.br crypt_r (): +.nf + _gnu_source +.fi +.sh description +.br crypt () +is the password encryption function. +it is based on the data encryption +standard algorithm with variations intended (among other things) to +discourage use of hardware implementations of a key search. +.pp +.i key +is a user's typed password. +.pp +.i salt +is a two-character string chosen from the set +[\fba\-za\-z0\-9./\fp]. +this string is used to +perturb the algorithm in one of 4096 different ways. +.pp +by taking the lowest 7 bits of each of the first eight characters of the +.ir key , +a 56-bit key is obtained. +this 56-bit key is used to encrypt repeatedly a +constant string (usually a string consisting of all zeros). +the returned +value points to the encrypted password, a series of 13 printable ascii +characters (the first two characters represent the salt itself). +the return value points to static data whose content is +overwritten by each call. +.pp +warning: the key space consists of +.if t 2\s-2\u56\s0\d +.if n 2**56 +equal 7.2e16 possible values. +exhaustive searches of this key space are +possible using massively parallel computers. +software, such as +.br crack (1), +is available which will search the portion of this key space that is +generally used by humans for passwords. +hence, password selection should, +at minimum, avoid common words and names. +the use of a +.br passwd (1) +program that checks for crackable passwords during the selection process is +recommended. +.pp +the des algorithm itself has a few quirks which make the use of the +.br crypt () +interface a very poor choice for anything other than password +authentication. +if you are planning on using the +.br crypt () +interface for a cryptography project, don't do it: get a good book on +encryption and one of the widely available des libraries. +.pp +.br crypt_r () +is a reentrant version of +.br crypt (). +the structure pointed to by +.i data +is used to store result data and bookkeeping information. +other than allocating it, +the only thing that the caller should do with this structure is to set +.i data\->initialized +to zero before the first call to +.br crypt_r (). +.sh return value +on success, a pointer to the encrypted password is returned. +on error, null is returned. +.sh errors +.tp +.b einval +.i salt +has the wrong format. +.tp +.b enosys +the +.br crypt () +function was not implemented, probably because of u.s.a. export restrictions. +.\" this level of detail is not necessary in this man page. . . +.\" .pp +.\" when encrypting a plain text p using des with the key k results in the +.\" encrypted text c, then the complementary plain text p' being encrypted +.\" using the complementary key k' will result in the complementary encrypted +.\" text c'. +.\" .pp +.\" weak keys are keys which stay invariant under the des key transformation. +.\" the four known weak keys 0101010101010101, fefefefefefefefe, +.\" 1f1f1f1f0e0e0e0e and e0e0e0e0f1f1f1f1 must be avoided. +.\" .pp +.\" there are six known half weak key pairs, which keys lead to the same +.\" encrypted data. keys which are part of such key clusters should be +.\" avoided. +.\" sorry, i could not find out what they are. +.\"" +.\" .pp +.\" heavily redundant data causes trouble with des encryption, when used in the +.\" .i codebook +.\" mode that +.\" .br crypt () +.\" implements. the +.\" .br crypt () +.\" interface should be used only for its intended purpose of password +.\" verification, and should not be used as part of a data encryption tool. +.\" .pp +.\" the first and last three output bits of the fourth s-box can be +.\" represented as function of their input bits. empiric studies have +.\" shown that s-boxes partially compute the same output for similar input. +.\" it is suspected that this may contain a back door which could allow the +.\" nsa to decrypt des encrypted data. +.\" .pp +.\" making encrypted data computed using crypt() publicly available has +.\" to be considered insecure for the given reasons. +.tp +.b eperm +.i /proc/sys/crypto/fips_enabled +has a nonzero value, +and an attempt was made to use a weak encryption type, such as des. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br crypt () +t} thread safety mt-unsafe race:crypt +t{ +.br crypt_r () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +.br crypt (): +posix.1-2001, posix.1-2008, svr4, 4.3bsd. +.br crypt_r () +is a gnu extension. +.sh notes +.ss availability in glibc +the +.br crypt (), +.br encrypt (3), +and +.br setkey (3) +functions are part of the posix.1-2008 xsi options group for encryption +and are optional. +if the interfaces are not available, then the symbolic constant +.br _xopen_crypt +is either not defined, +or it is defined to \-1 and availability can be checked at run time with +.br sysconf (3). +this may be the case if the downstream distribution has switched from glibc +crypt to +.ir libxcrypt . +when recompiling applications in such distributions, +the programmer must detect if +.br _xopen_crypt +is not available and include +.i +for the function prototypes; +otherwise +.i libxcrypt +is an abi-compatible drop-in replacement. +.ss features in glibc +the glibc version of this function supports additional +encryption algorithms. +.pp +if +.i salt +is a character string starting with the characters "$\fiid\fp$" +followed by a string optionally terminated by "$", +then the result has the form: +.rs +.pp +$\fiid\fp$\fisalt\fp$\fiencrypted\fp +.re +.pp +.i id +identifies the encryption method used instead of des and this +then determines how the rest of the password string is interpreted. +the following values of +.i id +are supported: +.rs +.ts +lb lb +l lx. +id method +_ +1 md5 +2a t{ +blowfish (not in mainline glibc; added in some +linux distributions) +t} +.\" opensuse has blowfish, but afaics, this option is not supported +.\" natively by glibc -- mtk, jul 08 +.\" +.\" md5 | sun md5 +.\" glibc doesn't appear to natively support sun md5; i don't know +.\" if any distros add the support. +5 sha-256 (since glibc 2.7) +6 sha-512 (since glibc 2.7) +.te +.re +.pp +thus, $5$\fisalt\fp$\fiencrypted\fp and $6$\fisalt\fp$\fiencrypted\fp +contain the password encrypted with, respectively, functions +based on sha-256 and sha-512. +.pp +"\fisalt\fp" stands for the up to 16 characters +following "$\fiid\fp$" in the salt. +the "\fiencrypted\fp" +part of the password string is the actual computed password. +the size of this string is fixed: +.rs +.ts +lb l. +md5 22 characters +sha-256 43 characters +sha-512 86 characters +.te +.re +.pp +the characters in "\fisalt\fp" and "\fiencrypted\fp" are drawn from the set +[\fba\-za\-z0\-9./\fp]. +in the md5 and sha implementations the entire +.i key +is significant (instead of only the first +8 bytes in des). +.pp +since glibc 2.7, +.\" glibc commit 9425cb9eea6a62fc21d99aafe8a60f752b934b05 +the sha-256 and sha-512 implementations support a user-supplied number of +hashing rounds, defaulting to 5000. +if the "$\fiid\fp$" characters in the salt are +followed by "rounds=\fixxx\fp$", where \fixxx\fp is an integer, then the +result has the form +.rs +.pp +$\fiid\fp$\firounds=yyy\fp$\fisalt\fp$\fiencrypted\fp +.re +.pp +where \fiyyy\fp is the number of hashing rounds actually used. +the number of rounds actually used is 1000 if +.i xxx +is less than +1000, 999999999 if +.i xxx +is greater than 999999999, and +is equal to +.i xxx +otherwise. +.sh see also +.br login (1), +.br passwd (1), +.br encrypt (3), +.br getpass (3), +.br passwd (5) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/rpc.3 + +.\" copyright (c) 1992 drew eckhardt (drew@cs.colorado.edu), march 28, 1992 +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified by michael haardt (michael@moria.de) +.\" modified sat jul 24 14:48:00 1993 by rik faith (faith@cs.unc.edu) +.\" modified 1995 by mike battersby (mib@deakin.edu.au) +.\" modified 2000 by aeb, following michael kerrisk +.\" +.th pause 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +pause \- wait for signal +.sh synopsis +.nf +.b #include +.pp +.b int pause(void); +.fi +.sh description +.br pause () +causes the calling process (or thread) to sleep +until a signal is delivered that either terminates the process or causes +the invocation of a signal-catching function. +.sh return value +.br pause () +returns only when a signal was caught and the +signal-catching function returned. +in this case, +.br pause () +returns \-1, and +.i errno +is set to +.\" .br erestartnohand . +.br eintr . +.sh errors +.tp +.b eintr +a signal was caught and the signal-catching function returned. +.sh conforming to +posix.1-2001, posix.1-2008, svr4, 4.3bsd. +.sh see also +.br kill (2), +.br select (2), +.br signal (2), +.br sigsuspend (2) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/sched_setattr.2 + +.\" copyright (c) 1993 by thomas koenig +.\" and copyright (c) 2004 by michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified sat jul 24 13:30:06 1993 by rik faith +.\" modified sun aug 21 17:42:42 1994 by rik faith +.\" (thanks to koen holtman ) +.\" modified wed may 17 15:54:12 1995 by rik faith +.\" to remove *'s from status in macros (thanks to michael shields). +.\" modified as suggested by nick duffek , aeb, 960426 +.\" modified mon jun 23 14:09:52 1997 by aeb - add eintr. +.\" modified thu nov 26 02:12:45 1998 by aeb - add sigchld stuff. +.\" modified mon jul 24 21:37:38 2000 by david a. wheeler +.\" - noted thread issues. +.\" modified 26 jun 01 by michael kerrisk +.\" added __wclone, __wall, and __wnothread descriptions +.\" modified 2001-09-25, aeb +.\" modified 26 jun 01 by michael kerrisk, +.\" updated notes on setting disposition of sigchld to sig_ign +.\" 2004-11-11, mtk +.\" added waitid(2); added wcontinued and wifcontinued() +.\" added text on sa_nocldstop +.\" updated discussion of sa_nocldwait to reflect 2.6 behavior +.\" much other text rewritten +.\" 2005-05-10, mtk, __w* flags can't be used with waitid() +.\" 2008-07-04, mtk, removed erroneous text about sa_nocldstop +.\" +.th wait 2 2021-08-27 "linux" "linux programmer's manual" +.sh name +wait, waitpid, waitid \- wait for process to change state +.sh synopsis +.nf +.b #include +.pp +.bi "pid_t wait(int *" "wstatus" ); +.bi "pid_t waitpid(pid_t " pid ", int *" wstatus ", int " options ); +.pp +.bi "int waitid(idtype_t " idtype ", id_t " id \ +", siginfo_t *" infop ", int " options ); + /* this is the glibc and posix interface; see + notes for information on the raw system call. */ +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br waitid (): +.nf + since glibc 2.26: + _xopen_source >= 500 || _posix_c_source >= 200809l +.\" (_xopen_source && _xopen_source_extended) + glibc 2.25 and earlier: + _xopen_source + || /* since glibc 2.12: */ _posix_c_source >= 200809l + || /* glibc <= 2.19: */ _bsd_source +.fi +.sh description +all of these system calls are used to wait for state changes +in a child of the calling process, and obtain information +about the child whose state has changed. +a state change is considered to be: the child terminated; +the child was stopped by a signal; or the child was resumed by a signal. +in the case of a terminated child, performing a wait allows +the system to release the resources associated with the child; +if a wait is not performed, then the terminated child remains in +a "zombie" state (see notes below). +.pp +if a child has already changed state, then these calls return immediately. +otherwise, they block until either a child changes state or +a signal handler interrupts the call (assuming that system calls +are not automatically restarted using the +.b sa_restart +flag of +.br sigaction (2)). +in the remainder of this page, a child whose state has changed +and which has not yet been waited upon by one of these system +calls is termed +.ir waitable . +.ss wait() and waitpid() +the +.br wait () +system call suspends execution of the calling thread until one of its +children terminates. +the call +.i wait(&wstatus) +is equivalent to: +.pp +.in +4n +.ex +waitpid(\-1, &wstatus, 0); +.ee +.in +.pp +the +.br waitpid () +system call suspends execution of the calling thread until a +child specified by +.i pid +argument has changed state. +by default, +.br waitpid () +waits only for terminated children, but this behavior is modifiable +via the +.i options +argument, as described below. +.pp +the value of +.i pid +can be: +.ip "< \-1" +meaning wait for any child process whose process group id is +equal to the absolute value of +.ir pid . +.ip \-1 +meaning wait for any child process. +.ip 0 +meaning wait for any child process whose process group id is +equal to that of the calling process at the time of the call to +.br waitpid (). +.ip "> 0" +meaning wait for the child whose process id is equal to the +value of +.ir pid . +.pp +the value of +.i options +is an or of zero or more of the following constants: +.tp +.b wnohang +return immediately if no child has exited. +.tp +.b wuntraced +also return if a child has stopped +(but not traced via +.br ptrace (2)). +status for +.i traced +children which have stopped is provided +even if this option is not specified. +.tp +.br wcontinued " (since linux 2.6.10)" +also return if a stopped child has been resumed by delivery of +.br sigcont . +.pp +(for linux-only options, see below.) +.pp +if +.i wstatus +is not null, +.br wait () +and +.br waitpid () +store status information in the \fiint\fp to which it points. +this integer can be inspected with the following macros (which +take the integer itself as an argument, not a pointer to it, +as is done in +.br wait () +and +.br waitpid ()!): +.tp +.bi wifexited( wstatus ) +returns true if the child terminated normally, that is, +by calling +.br exit (3) +or +.br _exit (2), +or by returning from main(). +.tp +.bi wexitstatus( wstatus ) +returns the exit status of the child. +this consists of the least significant 8 bits of the +.i status +argument that the child specified in a call to +.br exit (3) +or +.br _exit (2) +or as the argument for a return statement in main(). +this macro should be employed only if +.b wifexited +returned true. +.tp +.bi wifsignaled( wstatus ) +returns true if the child process was terminated by a signal. +.tp +.bi wtermsig( wstatus ) +returns the number of the signal that caused the child process to +terminate. +this macro should be employed only if +.b wifsignaled +returned true. +.tp +.bi wcoredump( wstatus ) +returns true if the child produced a core dump (see +.br core (5)). +this macro should be employed only if +.b wifsignaled +returned true. +.ip +this macro is not specified in posix.1-2001 and is not available on +some unix implementations (e.g., aix, sunos). +therefore, enclose its use inside +.ir "#ifdef wcoredump ... #endif" . +.tp +.bi wifstopped( wstatus ) +returns true if the child process was stopped by delivery of a signal; +this is possible only if the call was done using +.b wuntraced +or when the child is being traced (see +.br ptrace (2)). +.tp +.bi wstopsig( wstatus ) +returns the number of the signal which caused the child to stop. +this macro should be employed only if +.b wifstopped +returned true. +.tp +.bi wifcontinued( wstatus ) +(since linux 2.6.10) +returns true if the child process was resumed by delivery of +.br sigcont . +.ss waitid() +the +.br waitid () +system call (available since linux 2.6.9) provides more precise +control over which child state changes to wait for. +.pp +the +.i idtype +and +.i id +arguments select the child(ren) to wait for, as follows: +.ip "\fiidtype\fp == \fbp_pid\fp" +wait for the child whose process id matches +.ir id . +.ip "\fiidtype\fp == \fbp_pidfd\fp (since linux 5.4)" +.\" commit 3695eae5fee0605f316fbaad0b9e3de791d7dfaf +wait for the child referred to by the pid file descriptor specified in +.ir id . +(see +.br pidfd_open (2) +for further information on pid file descriptors.) +.ip "\fiidtype\fp == \fbp_pgid\fp" +wait for any child whose process group id matches +.ir id . +since linux 5.4, +.\" commit 821cc7b0b205c0df64cce59aacc330af251fa8f7 +if +.i id +is zero, then wait for any child that is in the same process group +as the caller's process group at the time of the call. +.ip "\fiidtype\fp == \fbp_all\fp" +wait for any child; +.i id +is ignored. +.pp +the child state changes to wait for are specified by oring +one or more of the following flags in +.ir options : +.tp +.b wexited +wait for children that have terminated. +.tp +.b wstopped +wait for children that have been stopped by delivery of a signal. +.tp +.b wcontinued +wait for (previously stopped) children that have been +resumed by delivery of +.br sigcont . +.pp +the following flags may additionally be ored in +.ir options : +.tp +.b wnohang +as for +.br waitpid (). +.tp +.b wnowait +leave the child in a waitable state; a later wait call +can be used to again retrieve the child status information. +.pp +upon successful return, +.br waitid () +fills in the following fields of the +.i siginfo_t +structure pointed to by +.ir infop : +.tp +\fisi_pid\fp +the process id of the child. +.tp +\fisi_uid\fp +the real user id of the child. +(this field is not set on most other implementations.) +.tp +\fisi_signo\fp +always set to +.br sigchld . +.tp +\fisi_status\fp +either the exit status of the child, as given to +.br _exit (2) +(or +.br exit (3)), +or the signal that caused the child to terminate, stop, or continue. +the +.i si_code +field can be used to determine how to interpret this field. +.tp +\fisi_code\fp +set to one of: +.b cld_exited +(child called +.br _exit (2)); +.b cld_killed +(child killed by signal); +.b cld_dumped +(child killed by signal, and dumped core); +.b cld_stopped +(child stopped by signal); +.b cld_trapped +(traced child has trapped); or +.b cld_continued +(child continued by +.br sigcont ). +.pp +if +.b wnohang +was specified in +.i options +and there were no children in a waitable state, then +.br waitid () +returns 0 immediately and +the state of the +.i siginfo_t +structure pointed to by +.i infop +depends on the implementation. +to (portably) distinguish this case from that where a child was in a +waitable state, zero out the +.i si_pid +field before the call and check for a nonzero value in this field +after the call returns. +.pp +posix.1-2008 technical corrigendum 1 (2013) adds the requirement that when +.b wnohang +is specified in +.i options +and there were no children in a waitable state, then +.br waitid () +should zero out the +.i si_pid +and +.i si_signo +fields of the structure. +on linux and other implementations that adhere to this requirement, +it is not necessary to zero out the +.i si_pid +field before calling +.br waitid (). +however, +not all implementations follow the posix.1 specification on this point. +.\" posix.1-2001 leaves this possibility unspecified; most +.\" implementations (including linux) zero out the structure +.\" in this case, but at least one implementation (aix 5.1) +.\" does not -- mtk nov 04 +.sh return value +.br wait (): +on success, returns the process id of the terminated child; +on failure, \-1 is returned. +.pp +.br waitpid (): +on success, returns the process id of the child whose state has changed; +if +.b wnohang +was specified and one or more child(ren) specified by +.i pid +exist, but have not yet changed state, then 0 is returned. +on failure, \-1 is returned. +.pp +.br waitid (): +returns 0 on success or +if +.b wnohang +was specified and no child(ren) specified by +.i id +has yet changed state; +on failure, \-1 is returned. +.\" fixme as reported by vegard nossum, if infop is null, then waitid() +.\" returns the pid of the child. either this is a bug, or it is intended +.\" behavior that needs to be documented. see my jan 2009 lkml mail +.\" "waitid() return value strangeness when infop is null". +.pp +on failure, each of these calls sets +.i errno +to indicate the error. +.sh errors +.tp +.b eagain +the pid file descriptor specified in +.i id +is nonblocking and the process that it refers to has not terminated. +.tp +.b echild +(for +.br wait ()) +the calling process does not have any unwaited-for children. +.tp +.b echild +(for +.br waitpid () +or +.br waitid ()) +the process specified by +.i pid +.rb ( waitpid ()) +or +.i idtype +and +.i id +.rb ( waitid ()) +does not exist or is not a child of the calling process. +(this can happen for one's own child if the action for +.b sigchld +is set to +.br sig_ign . +see also the \filinux notes\fp section about threads.) +.tp +.b eintr +.b wnohang +was not set and an unblocked signal or a +.b sigchld +was caught; see +.br signal (7). +.tp +.b einval +the +.i options +argument was invalid. +.tp +.b esrch +(for +.br wait () +or +.br waitpid ()) +.i pid +is equal to +.br int_min . +.sh conforming to +svr4, 4.3bsd, posix.1-2001. +.sh notes +a child that terminates, but has not been waited for becomes a "zombie". +the kernel maintains a minimal set of information about the zombie +process (pid, termination status, resource usage information) +in order to allow the parent to later perform a wait to obtain +information about the child. +as long as a zombie is not removed from the system via a wait, +it will consume a slot in the kernel process table, and if +this table fills, it will not be possible to create further processes. +if a parent process terminates, then its "zombie" children (if any) +are adopted by +.br init (1), +(or by the nearest "subreaper" process as defined through the use of the +.br prctl (2) +.b pr_set_child_subreaper +operation); +.br init (1) +automatically performs a wait to remove the zombies. +.pp +posix.1-2001 specifies that if the disposition of +.b sigchld +is set to +.b sig_ign +or the +.b sa_nocldwait +flag is set for +.b sigchld +(see +.br sigaction (2)), +then children that terminate do not become zombies and a call to +.br wait () +or +.br waitpid () +will block until all children have terminated, and then fail with +.i errno +set to +.br echild . +(the original posix standard left the behavior of setting +.b sigchld +to +.b sig_ign +unspecified. +note that even though the default disposition of +.b sigchld +is "ignore", explicitly setting the disposition to +.b sig_ign +results in different treatment of zombie process children.) +.pp +linux 2.6 conforms to the posix requirements. +however, linux 2.4 (and earlier) does not: +if a +.br wait () +or +.br waitpid () +call is made while +.b sigchld +is being ignored, the call behaves just as though +.b sigchld +were not being ignored, that is, the call blocks until the next child +terminates and then returns the process id and status of that child. +.ss linux notes +in the linux kernel, a kernel-scheduled thread is not a distinct +construct from a process. +instead, a thread is simply a process +that is created using the linux-unique +.br clone (2) +system call; other routines such as the portable +.br pthread_create (3) +call are implemented using +.br clone (2). +before linux 2.4, a thread was just a special case of a process, +and as a consequence one thread could not wait on the children +of another thread, even when the latter belongs to the same thread group. +however, posix prescribes such functionality, and since linux 2.4 +a thread can, and by default will, wait on children of other threads +in the same thread group. +.pp +the following linux-specific +.i options +are for use with children created using +.br clone (2); +they can also, since linux 4.7, +.\" commit 91c4e8ea8f05916df0c8a6f383508ac7c9e10dba +be used with +.br waitid (): +.tp +.b __wclone +.\" since 0.99pl10 +wait for "clone" children only. +if omitted, then wait for "non-clone" children only. +(a "clone" child is one which delivers no signal, or a signal other than +.b sigchld +to its parent upon termination.) +this option is ignored if +.b __wall +is also specified. +.tp +.br __wall " (since linux 2.4)" +.\" since patch-2.3.48 +wait for all children, regardless of +type ("clone" or "non-clone"). +.tp +.br __wnothread " (since linux 2.4)" +.\" since patch-2.4.0-test8 +do not wait for children of other threads in +the same thread group. +this was the default before linux 2.4. +.pp +since linux 4.7, +.\" commit bf959931ddb88c4e4366e96dd22e68fa0db9527c +.\" prevents cases where an unreapable zombie is created if +.\" /sbin/init doesn't use __wall. +the +.b __wall +flag is automatically implied if the child is being ptraced. +.ss c library/kernel differences +.br wait () +is actually a library function that (in glibc) is implemented as a call to +.br wait4 (2). +.pp +on some architectures, there is no +.br waitpid () +system call; +.\" e.g., i386 has the system call, but not x86-64 +instead, this interface is implemented via a c library +wrapper function that calls +.br wait4 (2). +.pp +the raw +.br waitid () +system call takes a fifth argument, of type +.ir "struct rusage\ *" . +if this argument is non-null, +then it is used to return resource usage information about the child, +in the same manner as +.br wait4 (2). +see +.br getrusage (2) +for details. +.sh bugs +according to posix.1-2008, an application calling +.br waitid () +must ensure that +.i infop +points to a +.i siginfo_t +structure (i.e., that it is a non-null pointer). +on linux, if +.i infop +is null, +.br waitid () +succeeds, and returns the process id of the waited-for child. +applications should avoid relying on this inconsistent, +nonstandard, and unnecessary feature. +.sh examples +.\" fork.2 refers to this example program. +the following program demonstrates the use of +.br fork (2) +and +.br waitpid (). +the program creates a child process. +if no command-line argument is supplied to the program, +then the child suspends its execution using +.br pause (2), +to allow the user to send signals to the child. +otherwise, if a command-line argument is supplied, +then the child exits immediately, +using the integer supplied on the command line as the exit status. +the parent process executes a loop that monitors the child using +.br waitpid (), +and uses the w*() macros described above to analyze the wait status value. +.pp +the following shell session demonstrates the use of the program: +.pp +.in +4n +.ex +.rb "$" " ./a.out &" +child pid is 32360 +[1] 32359 +.rb "$" " kill \-stop 32360" +stopped by signal 19 +.rb "$" " kill \-cont 32360" +continued +.rb "$" " kill \-term 32360" +killed by signal 15 +[1]+ done ./a.out +$ +.ee +.in +.ss program source +\& +.ex +#include +#include +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + pid_t cpid, w; + int wstatus; + + cpid = fork(); + if (cpid == \-1) { + perror("fork"); + exit(exit_failure); + } + + if (cpid == 0) { /* code executed by child */ + printf("child pid is %jd\en", (intmax_t) getpid()); + if (argc == 1) + pause(); /* wait for signals */ + _exit(atoi(argv[1])); + + } else { /* code executed by parent */ + do { + w = waitpid(cpid, &wstatus, wuntraced | wcontinued); + if (w == \-1) { + perror("waitpid"); + exit(exit_failure); + } + + if (wifexited(wstatus)) { + printf("exited, status=%d\en", wexitstatus(wstatus)); + } else if (wifsignaled(wstatus)) { + printf("killed by signal %d\en", wtermsig(wstatus)); + } else if (wifstopped(wstatus)) { + printf("stopped by signal %d\en", wstopsig(wstatus)); + } else if (wifcontinued(wstatus)) { + printf("continued\en"); + } + } while (!wifexited(wstatus) && !wifsignaled(wstatus)); + exit(exit_success); + } +} +.ee +.sh see also +.br _exit (2), +.br clone (2), +.br fork (2), +.br kill (2), +.br ptrace (2), +.br sigaction (2), +.br signal (2), +.br wait4 (2), +.br pthread_create (3), +.br core (5), +.br credentials (7), +.br signal (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/timerfd_create.2 + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" +.th wcsnrtombs 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +wcsnrtombs \- convert a wide-character string to a multibyte string +.sh synopsis +.nf +.b #include +.pp +.bi "size_t wcsnrtombs(char *restrict " dest ", const wchar_t **restrict " src , +.bi " size_t " nwc ", size_t " len \ +", mbstate_t *restrict " ps ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br wcsnrtombs (): +.nf + since glibc 2.10: + _posix_c_source >= 200809l + before glibc 2.10: + _gnu_source +.fi +.sh description +the +.br wcsnrtombs () +function is like the +.br wcsrtombs (3) +function, +except that the number of wide characters to be converted, +starting at +.ir *src , +is limited to +.ir nwc . +.pp +if +.i dest +is not null, +the +.br wcsnrtombs () +function converts +at most +.i nwc +wide characters from +the wide-character string +.i *src +to a multibyte string starting at +.ir dest . +at most +.i len +bytes are written to +.ir dest . +the shift state +.i *ps +is updated. +the conversion is effectively performed by repeatedly +calling +.ir "wcrtomb(dest, *src, ps)" , +as long as this call succeeds, +and then incrementing +.i dest +by the +number of bytes written and +.i *src +by one. +the conversion can stop for three reasons: +.ip 1. 3 +a wide character has been encountered that can not be represented as a +multibyte sequence (according to the current locale). +in this case, +.i *src +is left pointing to the invalid wide character, +.i (size_t)\ \-1 +is returned, +and +.i errno +is set to +.br eilseq . +.ip 2. +.i nwc +wide characters have been +converted without encountering a null wide character (l\(aq\e0\(aq), +or the length limit forces a stop. +in this case, +.i *src +is left pointing +to the next wide character to be converted, and the number of bytes written +to +.i dest +is returned. +.ip 3. +the wide-character string has been completely converted, including the +terminating null wide character (which has the side effect of bringing back +.i *ps +to the initial state). +in this case, +.i *src +is set to null, and the number +of bytes written to +.ir dest , +excluding the terminating null byte (\(aq\e0\(aq), is +returned. +.pp +if +.ir dest +is null, +.i len +is ignored, +and the conversion proceeds as above, +except that the converted bytes are not written out to memory, and that +no destination length limit exists. +.pp +in both of the above cases, +if +.i ps +is null, a static anonymous +state known only to the +.br wcsnrtombs () +function is used instead. +.pp +the programmer must ensure that there is room for at least +.i len +bytes +at +.ir dest . +.sh return value +the +.br wcsnrtombs () +function returns +the number of bytes that make up the +converted part of multibyte sequence, +not including the terminating null byte. +if a wide character was encountered which +could not be converted, +.i (size_t)\ \-1 +is returned, and +.i errno +set to +.br eilseq . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lb lb lbx +l l l. +interface attribute value +t{ +.br wcsnrtombs () +t} thread safety t{ +mt-unsafe race:wcsnrtombs/!ps +t} +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2008. +.sh notes +the behavior of +.br wcsnrtombs () +depends on the +.b lc_ctype +category of the +current locale. +.pp +passing null as +.i ps +is not multithread safe. +.sh see also +.br iconv (3), +.br mbsinit (3), +.br wcsrtombs (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/regex.3 + +.\" copyright (c) 2001 markus kuhn +.\" and copyright (c) 2015 sam varshavchik +.\" and copyright (c) 2015 michael kerrisk +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 manual +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" +.\" corrected prototype, 2002-10-18, aeb +.\" +.th nl_langinfo 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +nl_langinfo, nl_langinfo_l \- query language and locale information +.sh synopsis +.nf +.b #include +.pp +.bi "char *nl_langinfo(nl_item " item ); +.bi "char *nl_langinfo_l(nl_item " item ", locale_t " locale ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br nl_langinfo_l (): +.nf + since glibc 2.24: + _posix_c_source >= 200809l + glibc 2.23 and earlier: + _posix_c_source >= 200112l +.fi +.sh description +the +.br nl_langinfo () +and +.br nl_langinfo_l () +functions provide access to locale information +in a more flexible way than +.br localeconv (3). +.br nl_langinfo () +returns a string which is the value corresponding to +\fiitem\fp in the program's current global +locale. +.br nl_langinfo_l () +returns a string which is the value corresponding to \fiitem\fp +for the locale identified by the locale object \filocale\fp, +which was previously created by +.br newlocale (3). +individual and additional elements of the locale categories can +be queried. +.pp +examples for the locale elements that can be specified in \fiitem\fp +using the constants defined in \fi\fp are: +.tp +.br codeset \ (lc_ctype) +return a string with the name of the character encoding used in the +selected locale, such as "utf-8", "iso-8859-1", or "ansi_x3.4-1968" +(better known as us-ascii). +this is the same string that you get with +"locale charmap". +for a list of character encoding names, +try "locale \-m" (see +.br locale (1)). +.tp +.br d_t_fmt \ (lc_time) +return a string that can be used as a format string for +.br strftime (3) +to represent time and date in a locale-specific way +.rb ( %c +conversion specification). +.tp +.br d_fmt \ (lc_time) +return a string that can be used as a format string for +.br strftime (3) +to represent a date in a locale-specific way +.rb ( %x +conversion specification). +.tp +.br t_fmt \ (lc_time) +return a string that can be used as a format string for +.br strftime (3) +to represent a time in a locale-specific way +.rb ( %x +conversion specification). +.tp +.br am_str \ (lc_time) +return a string that represents affix for ante meridiem (before noon, "am") +time. +(used in +.b %p +.br strftime (3) +conversion specification.) +.tp +.br pm_str \ (lc_time) +return a string that represents affix for post meridiem (before midnight, "pm") +time. +(used in +.b %p +.br strftime (3) +conversion specification.) +.tp +.br t_fmt_ampm \ (lc_time) +return a string that can be used as a format string for +.br strftime (3) +to represent a time in a.m. or p.m. notation in a locale-specific way +.rb ( %r +conversion specification). +.tp +.br era \ (lc_time) +return era description, which contains information about how years are counted +and displayed for each era in a locale. +each era description segment shall have the format: +.rs +.ip +.ir direction : offset : start_date : end_date : era_name : era_format +.re +.ip +according to the definitions below: +.rs +.tp 12 +.i direction +either a +.rb \[dq] + "\[dq] or a \[dq]" - \[dq] +character. +the +.rb \[dq] + \[dq] +means that years increase from the +.i start_date +towards the +.ir end_date , +.rb \[dq] - \[dq] +means the opposite. +.tp +.i offset +the epoch year of the +.ir start_date . +.tp +.i start_date +a date in the form +.ir yyyy / mm / dd , +where +.ir yyyy ", " mm ", and " dd +are the year, month, and day numbers respectively of the start of the era. +.tp +.i end_date +the ending date of the era, in the same format as the +.ir start_date , +or one of the two special values +.rb \[dq] -* \[dq] +(minus infinity) or +.rb \[dq] +* \[dq] +(plus infinity). +.tp +.i era_name +the name of the era, corresponding to the +.b %ec +.br strftime (3) +conversion specification. +.tp +.i era_format +the format of the year in the era, corresponding to the +.b %ey +.br strftime (3) +conversion specification. +.re +.ip +era description segments are separated by semicolons. +most locales do not define this value. +examples of locales that do define this value are the japanese and thai +locales. +.tp +.br era_d_t_fmt \ (lc_time) +return a string that can be used as a format string for +.br strftime (3) +for alternative representation of time and date in a locale-specific way +.rb ( %ec +conversion specification). +.tp +.br era_d_fmt \ (lc_time) +return a string that can be used as a format string for +.br strftime (3) +for alternative representation of a date in a locale-specific way +.rb ( %ex +conversion specification). +.tp +.br era_t_fmt \ (lc_time) +return a string that can be used as a format string for +.br strftime (3) +for alternative representation of a time in a locale-specific way +.rb ( %ex +conversion specification). +.tp +.br day_ "{1\(en7} (lc_time)" +return name of the \fin\fp-th day of the week. +[warning: this follows +the us convention day_1 = sunday, not the international convention +(iso 8601) that monday is the first day of the week.] +(used in +.b %a +.br strftime (3) +conversion specification.) +.tp +.br abday_ "{1\(en7} (lc_time)" +return abbreviated name of the \fin\fp-th day of the week. +(used in +.b %a +.br strftime (3) +conversion specification.) +.tp +.br mon_ "{1\(en12} (lc_time)" +return name of the \fin\fp-th month. +(used in +.b %b +.br strftime (3) +conversion specification.) +.tp +.br abmon_ "{1\(en12} (lc_time)" +return abbreviated name of the \fin\fp-th month. +(used in +.b %b +.br strftime (3) +conversion specification.) +.tp +.br radixchar \ (lc_numeric) +return radix character (decimal dot, decimal comma, etc.). +.tp +.br thousep \ (lc_numeric) +return separator character for thousands (groups of three digits). +.tp +.br yesexpr \ (lc_messages) +return a regular expression that can be used with the +.br regex (3) +function to recognize a positive response to a yes/no question. +.tp +.br noexpr \ (lc_messages) +return a regular expression that can be used with the +.br regex (3) +function to recognize a negative response to a yes/no question. +.tp +.br crncystr \ (lc_monetary) +return the currency symbol, preceded by "\-" if the symbol should +appear before the value, "+" if the symbol should appear after the +value, or "." if the symbol should replace the radix character. +.pp +the above list covers just some examples of items that can be requested. +for a more detailed list, consult +.ir "the gnu c library reference manual" . +.sh return value +on success, these functions return a pointer to a string which +is the value corresponding to +.i item +in the specified locale. +.pp +if no locale has been selected by +.br setlocale (3) +for the appropriate category, +.br nl_langinfo () +return a pointer to the corresponding string in the "c" locale. +the same is true of +.br nl_langinfo_l () +if +.i locale +specifies a locale where +.i langinfo +data is not defined. +.pp +if \fiitem\fp is not valid, a pointer to an empty string is returned. +.pp +the pointer returned by these functions may point to static data that +may be overwritten, or the pointer itself may be invalidated, +by a subsequent call to +.br nl_langinfo (), +.br nl_langinfo_l (), +or +.br setlocale (3). +the same statements apply to +.br nl_langinfo_l () +if the locale object referred to by +.i locale +is freed or modified by +.br freelocale (3) +or +.br newlocale (3). +.pp +posix specifies that the application may not modify +the string returned by these functions. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br nl_langinfo () +t} thread safety mt-safe locale +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, susv2. +.sh notes +the behavior of +.br nl_langinfo_l () +is undefined if +.i locale +is the special locale object +.br lc_global_locale +or is not a valid locale object handle. +.sh examples +the following program sets the character type and the numeric locale +according to the environment and queries the terminal character set and +the radix character. +.pp +.ex +#include +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + setlocale(lc_ctype, ""); + setlocale(lc_numeric, ""); + + printf("%s\en", nl_langinfo(codeset)); + printf("%s\en", nl_langinfo(radixchar)); + + exit(exit_success); +} +.ee +.sh see also +.br locale (1), +.br localeconv (3), +.br setlocale (3), +.br charsets (7), +.br locale (7) +.pp +the gnu c library reference manual +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/sigprocmask.2 + +.\" copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de) +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under gpl +.\" %%%license_end +.\" +.th cproj 3 2021-03-22 "" "linux programmer's manual" +.sh name +cproj, cprojf, cprojl \- project into riemann sphere +.sh synopsis +.nf +.b #include +.pp +.bi "double complex cproj(double complex " z ");" +.bi "float complex cprojf(float complex " z ");" +.bi "long double complex cprojl(long double complex " z ");" +.pp +link with \fi\-lm\fp. +.fi +.sh description +these functions project a point in the plane onto the surface of a +riemann sphere, the one-point compactification of the complex plane. +each finite point +.i z +projects to +.i z +itself. +every complex infinite value is projected to a single infinite value, +namely to positive infinity on the real axis. +.sh versions +these functions first appeared in glibc in version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br cproj (), +.br cprojf (), +.br cprojl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.sh notes +in glibc 2.11 and earlier, the implementation does something different +(a +.i stereographic +projection onto a riemann sphere). +.\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=10401 +.sh see also +.br cabs (3), +.br complex (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/setnetgrent.3 + +.\" copyright (c) 2001 andries brouwer +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" text fragments inspired by martin schulze . +.\" +.th asprintf 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +asprintf, vasprintf \- print to allocated string +.sh synopsis +.nf +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "int asprintf(char **restrict " strp ", const char *restrict " fmt ", ...);" +.bi "int vasprintf(char **restrict " strp ", const char *restrict " fmt , +.bi " va_list " ap ); +.fi +.sh description +the functions +.br asprintf () +and +.br vasprintf () +are analogs of +.br sprintf (3) +and +.br vsprintf (3), +except that they allocate a string large enough to hold the output +including the terminating null byte (\(aq\e0\(aq), +and return a pointer to it via the first argument. +this pointer should be passed to +.br free (3) +to release the allocated storage when it is no longer needed. +.sh return value +when successful, these functions return the number of bytes printed, +just like +.br sprintf (3). +if memory allocation wasn't possible, or some other error occurs, +these functions will return \-1, and the contents of +.i strp +are undefined. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br asprintf (), +.br vasprintf () +t} thread safety mt-safe locale +.te +.hy +.ad +.sp 1 +.sh conforming to +these functions are gnu extensions, not in c or posix. +they are also available under *bsd. +the freebsd implementation sets +.i strp +to null on error. +.sh see also +.br free (3), +.br malloc (3), +.br printf (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/strtok.3 + +.\" copyright (c) 1990, 1991 the regents of the university of california. +.\" and copyright (c) 2021 michael kerrisk +.\" all rights reserved. +.\" +.\" this code is derived from software contributed to berkeley by +.\" chris torek and the american national standards committee x3, +.\" on information processing systems. +.\" +.\" %%%license_start(bsd_4_clause_ucb) +.\" redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. all advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" this product includes software developed by the university of +.\" california, berkeley and its contributors. +.\" 4. neither the name of the university nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" this software is provided by the regents and contributors ``as is'' and +.\" any express or implied warranties, including, but not limited to, the +.\" implied warranties of merchantability and fitness for a particular purpose +.\" are disclaimed. in no event shall the regents or contributors be liable +.\" for any direct, indirect, incidental, special, exemplary, or consequential +.\" damages (including, but not limited to, procurement of substitute goods +.\" or services; loss of use, data, or profits; or business interruption) +.\" however caused and on any theory of liability, whether in contract, strict +.\" liability, or tort (including negligence or otherwise) arising in any way +.\" out of the use of this software, even if advised of the possibility of +.\" such damage. +.\" %%%license_end +.\" +.\" @(#)ferror.3 6.8 (berkeley) 6/29/91 +.\" +.\" +.\" converted for linux, mon nov 29 14:24:40 1993, faith@cs.unc.edu +.\" +.th ferror 3 2021-03-22 "" "linux programmer's manual" +.sh name +clearerr, feof, ferror \- check and reset stream status +.sh synopsis +.nf +.b #include +.pp +.bi "void clearerr(file *" stream ); +.bi "int feof(file *" stream ); +.bi "int ferror(file *" stream ); +.fi +.sh description +the function +.br clearerr () +clears the end-of-file and error indicators for the stream pointed to by +.ir stream . +.pp +the function +.br feof () +tests the end-of-file indicator for the stream pointed to by +.ir stream , +returning nonzero if it is set. +the end-of-file indicator can be cleared only by the function +.br clearerr (). +.pp +the function +.br ferror () +tests the error indicator for the stream pointed to by +.ir stream , +returning nonzero if it is set. +the error indicator can be reset only by the +.br clearerr () +function. +.pp +for nonlocking counterparts, see +.br unlocked_stdio (3). +.sh return value +the +.br feof () +function returns nonzero if the end-of-file indicator is set for +.ir stream ; +otherwise, it returns zero. +.pp +the +.br ferror () +function returns nonzero if the error indicator is set for +.ir stream ; +otherwise, it returns zero. +.sh errors +these functions should not fail and do not set +.ir errno . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br clearerr (), +.br feof (), +.br ferror () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +the functions +.br clearerr (), +.br feof (), +and +.br ferror () +conform to c89, c99, posix.1-2001, and posix.1-2008. +.sh notes +posix.1-2008 specifies +.\"https://www.austingroupbugs.net/view.php?id=401 +that these functions shall not change the value of +.i errno +if +.i stream +is valid. +.sh see also +.br open (2), +.br fdopen (3), +.br fileno (3), +.br stdio (3), +.br unlocked_stdio (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2005 robert love +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" 2005-07-19 robert love - initial version +.\" 2006-02-07 mtk, minor changes +.\" +.th inotify_rm_watch 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +inotify_rm_watch \- remove an existing watch from an inotify instance +.sh synopsis +.nf +.b #include +.pp +.bi "int inotify_rm_watch(int " fd ", int " wd ); +.\" before glibc 2.10, the second argument was types as uint32_t. +.\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=7040 +.fi +.sh description +.br inotify_rm_watch () +removes the watch associated with the watch descriptor +.i wd +from the inotify instance associated with the file descriptor +.ir fd . +.pp +removing a watch causes an +.b in_ignored +event to be generated for this watch descriptor. +(see +.br inotify (7).) +.sh return value +on success, +.br inotify_rm_watch () +returns zero. +on error, \-1 is returned and +.i errno +is set to indicate the error. +.sh errors +.tp +.b ebadf +.i fd +is not a valid file descriptor. +.tp +.b einval +the watch descriptor +.i wd +is not valid; or +.i fd +is not an inotify file descriptor. +.sh versions +inotify was merged into the 2.6.13 linux kernel. +.sh conforming to +this system call is linux-specific. +.sh see also +.br inotify_add_watch (2), +.br inotify_init (2), +.br inotify (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/tailq.3 + +.\" copyright (c) 1994, 1995 by daniel quinlan (quinlan@yggdrasil.com) +.\" and copyright (c) 2002-2008,2017 michael kerrisk +.\" with networking additions from alan cox (a.cox@swansea.ac.uk) +.\" and scsi additions from michael neuffer (neuffer@mail.uni-mainz.de) +.\" and sysctl additions from andries brouwer (aeb@cwi.nl) +.\" and system v ipc (as well as various other) additions from +.\" michael kerrisk +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" modified 1995-05-17 by faith@cs.unc.edu +.\" minor changes by aeb and marty leisner (leisner@sdsp.mc.xerox.com). +.\" modified 1996-04-13, 1996-07-22 by aeb@cwi.nl +.\" modified 2001-12-16 by rwhron@earthlink.net +.\" modified 2002-07-13 by jbelton@shaw.ca +.\" modified 2002-07-22, 2003-05-27, 2004-04-06, 2004-05-25 +.\" by michael kerrisk +.\" 2004-11-17, mtk -- updated notes on /proc/loadavg +.\" 2004-12-01, mtk, rtsig-max and rtsig-nr went away in 2.6.8 +.\" 2004-12-14, mtk, updated 'statm', and fixed error in order of list +.\" 2005-05-12, mtk, updated 'stat' +.\" 2005-07-13, mtk, added /proc/sys/fs/mqueue/* +.\" 2005-09-16, mtk, added /proc/sys/fs/suid_dumpable +.\" 2005-09-19, mtk, added /proc/zoneinfo +.\" 2005-03-01, mtk, moved /proc/sys/fs/mqueue/* material to mq_overview.7. +.\" 2008-06-05, mtk, added /proc/[pid]/oom_score, /proc/[pid]/oom_adj, +.\" /proc/[pid]/limits, /proc/[pid]/mountinfo, /proc/[pid]/mountstats, +.\" and /proc/[pid]/fdinfo/*. +.\" 2008-06-19, mtk, documented /proc/[pid]/status. +.\" 2008-07-15, mtk, added /proc/config.gz +.\" +.\" fixme cross check against documentation/filesystems/proc.txt +.\" to see what information could be imported from that file +.\" into this file. +.\" +.th proc 5 2021-08-27 "linux" "linux programmer's manual" +.sh name +proc \- process information pseudo-filesystem +.sh description +the +.b proc +filesystem is a pseudo-filesystem which provides an interface to +kernel data structures. +it is commonly mounted at +.ir /proc . +typically, it is mounted automatically by the system, +but it can also be mounted manually using a command such as: +.pp +.in +4n +.ex +mount \-t proc proc /proc +.ee +.in +.pp +most of the files in the +.b proc +filesystem are read-only, +but some files are writable, allowing kernel variables to be changed. +.\" +.ss mount options +the +.b proc +filesystem supports the following mount options: +.tp +.br hidepid "=\fin\fp (since linux 3.3)" +.\" commit 0499680a42141d86417a8fbaa8c8db806bea1201 +this option controls who can access the information in +.ir /proc/[pid] +directories. +the argument, +.ir n , +is one of the following values: +.rs +.tp 4 +0 +everybody may access all +.ir /proc/[pid] +directories. +this is the traditional behavior, +and the default if this mount option is not specified. +.tp +1 +users may not access files and subdirectories inside any +.ir /proc/[pid] +directories but their own (the +.ir /proc/[pid] +directories themselves remain visible). +sensitive files such as +.ir /proc/[pid]/cmdline +and +.ir /proc/[pid]/status +are now protected against other users. +this makes it impossible to learn whether any user is running a +specific program +(so long as the program doesn't otherwise reveal itself by its behavior). +.\" as an additional bonus, since +.\" .ir /proc/[pid]/cmdline +.\" is inaccessible for other users, +.\" poorly written programs passing sensitive information via +.\" program arguments are now protected against local eavesdroppers. +.tp +2 +as for mode 1, but in addition the +.ir /proc/[pid] +directories belonging to other users become invisible. +this means that +.ir /proc/[pid] +entries can no longer be used to discover the pids on the system. +this doesn't hide the fact that a process with a specific pid value exists +(it can be learned by other means, for example, by "kill \-0 $pid"), +but it hides a process's uid and gid, +which could otherwise be learned by employing +.br stat (2) +on a +.ir /proc/[pid] +directory. +this greatly complicates an attacker's task of gathering +information about running processes (e.g., discovering whether +some daemon is running with elevated privileges, +whether another user is running some sensitive program, +whether other users are running any program at all, and so on). +.re +.tp +.br gid "=\figid\fp (since linux 3.3)" +.\" commit 0499680a42141d86417a8fbaa8c8db806bea1201 +specifies the id of a group whose members are authorized to +learn process information otherwise prohibited by +.br hidepid +(i.e., users in this group behave as though +.i /proc +was mounted with +.ir hidepid=0 ). +this group should be used instead of approaches such as putting +nonroot users into the +.br sudoers (5) +file. +.\" +.ss overview +underneath +.ir /proc , +there are the following general groups of files and subdirectories: +.tp +.ir /proc/[pid] " subdirectories" +each one of these subdirectories contains files and subdirectories +exposing information about the process with the corresponding process id. +.ip +underneath each of the +.i /proc/[pid] +directories, a +.i task +subdirectory contains subdirectories of the form +.ir task/[tid] , +which contain corresponding information about each of the threads +in the process, where +.i tid +is the kernel thread id of the thread. +.ip +the +.i /proc/[pid] +subdirectories are visible when iterating through +.i /proc +with +.br getdents (2) +(and thus are visible when one uses +.br ls (1) +to view the contents of +.ir /proc ). +.tp +.ir /proc/[tid] " subdirectories" +each one of these subdirectories contains files and subdirectories +exposing information about the thread with the corresponding thread id. +the contents of these directories are the same as the corresponding +.ir /proc/[pid]/task/[tid] +directories. +.ip +the +.i /proc/[tid] +subdirectories are +.i not +visible when iterating through +.i /proc +with +.br getdents (2) +(and thus are +.i not +visible when one uses +.br ls (1) +to view the contents of +.ir /proc ). +.tp +.i /proc/self +when a process accesses this magic symbolic link, +it resolves to the process's own +.i /proc/[pid] +directory. +.tp +.i /proc/thread\-self +when a thread accesses this magic symbolic link, +it resolves to the process's own +.i /proc/self/task/[tid] +directory. +.tp +.i /proc/[a\-z]* +various other files and subdirectories under +.i /proc +expose system-wide information. +.pp +all of the above are described in more detail below. +.\" +.ss files and directories +the following list provides details of many of the files and directories +under the +.i /proc +hierarchy. +.tp +.i /proc/[pid] +there is a numerical subdirectory for each running process; the +subdirectory is named by the process id. +each +.i /proc/[pid] +subdirectory contains the pseudo-files and directories described below. +.ip +the files inside each +.i /proc/[pid] +directory are normally owned by the effective user and +effective group id of the process. +however, as a security measure, the ownership is made +.ir root:root +if the process's "dumpable" attribute is set to a value other than 1. +.ip +before linux 4.11, +.\" commit 68eb94f16227336a5773b83ecfa8290f1d6b78ce +.ir root:root +meant the "global" root user id and group id +(i.e., uid 0 and gid 0 in the initial user namespace). +since linux 4.11, +if the process is in a noninitial user namespace that has a +valid mapping for user (group) id 0 inside the namespace, then +the user (group) ownership of the files under +.i /proc/[pid] +is instead made the same as the root user (group) id of the namespace. +this means that inside a container, +things work as expected for the container "root" user. +.ip +the process's "dumpable" attribute may change for the following reasons: +.rs +.ip * 3 +the attribute was explicitly set via the +.br prctl (2) +.b pr_set_dumpable +operation. +.ip * +the attribute was reset to the value in the file +.ir /proc/sys/fs/suid_dumpable +(described below), for the reasons described in +.br prctl (2). +.re +.ip +resetting the "dumpable" attribute to 1 reverts the ownership of the +.ir /proc/[pid]/* +files to the process's effective uid and gid. +note, however, that if the effective uid or gid is subsequently modified, +then the "dumpable" attribute may be reset, as described in +.br prctl (2). +therefore, it may be desirable to reset the "dumpable" attribute +.i after +making any desired changes to the process's effective uid or gid. +.tp +.i /proc/[pid]/attr +.\" https://lwn.net/articles/28222/ +.\" from: stephen smalley +.\" to: lkml and others +.\" subject: [rfc][patch] process attribute api for security modules +.\" date: 08 apr 2003 16:17:52 -0400 +.\" +.\" http://www.nsa.gov/research/_files/selinux/papers/module/x362.shtml +.\" +the files in this directory provide an api for security modules. +the contents of this directory are files that can be read and written +in order to set security-related attributes. +this directory was added to support selinux, +but the intention was that the api be general enough to support +other security modules. +for the purpose of explanation, +examples of how selinux uses these files are provided below. +.ip +this directory is present only if the kernel was configured with +.br config_security . +.tp +.ir /proc/[pid]/attr/current " (since linux 2.6.0)" +the contents of this file represent the current +security attributes of the process. +.ip +in selinux, this file is used to get the security context of a process. +prior to linux 2.6.11, this file could not be used to set the security +context (a write was always denied), since selinux limited process security +transitions to +.br execve (2) +(see the description of +.ir /proc/[pid]/attr/exec , +below). +since linux 2.6.11, selinux lifted this restriction and began supporting +"set" operations via writes to this node if authorized by policy, +although use of this operation is only suitable for applications that are +trusted to maintain any desired separation between the old and new security +contexts. +.ip +prior to linux 2.6.28, selinux did not allow threads within a +multithreaded process to set their security context via this node +as it would yield an inconsistency among the security contexts of the +threads sharing the same memory space. +since linux 2.6.28, selinux lifted +this restriction and began supporting "set" operations for threads within +a multithreaded process if the new security context is bounded by the old +security context, where the bounded relation is defined in policy and +guarantees that the new security context has a subset of the permissions +of the old security context. +.ip +other security modules may choose to support "set" operations via +writes to this node. +.tp +.ir /proc/[pid]/attr/exec " (since linux 2.6.0)" +this file represents the attributes to assign to the +process upon a subsequent +.br execve (2). +.ip +in selinux, +this is needed to support role/domain transitions, and +.br execve (2) +is the preferred point to make such transitions because it offers better +control over the initialization of the process in the new security label +and the inheritance of state. +in selinux, this attribute is reset on +.br execve (2) +so that the new program reverts to the default behavior for any +.br execve (2) +calls that it may make. +in selinux, a process can set +only its own +.i /proc/[pid]/attr/exec +attribute. +.tp +.ir /proc/[pid]/attr/fscreate " (since linux 2.6.0)" +this file represents the attributes to assign to files +created by subsequent calls to +.br open (2), +.br mkdir (2), +.br symlink (2), +and +.br mknod (2) +.ip +selinux employs this file to support creation of a file +(using the aforementioned system calls) +in a secure state, +so that there is no risk of inappropriate access being obtained +between the time of creation and the time that attributes are set. +in selinux, this attribute is reset on +.br execve (2), +so that the new program reverts to the default behavior for +any file creation calls it may make, but the attribute will persist +across multiple file creation calls within a program unless it is +explicitly reset. +in selinux, a process can set only its own +.ir /proc/[pid]/attr/fscreate +attribute. +.tp +.ir /proc/[pid]/attr/keycreate " (since linux 2.6.18)" +.\" commit 4eb582cf1fbd7b9e5f466e3718a59c957e75254e +if a process writes a security context into this file, +all subsequently created keys +.rb ( add_key (2)) +will be labeled with this context. +for further information, see the kernel source file +.i documentation/security/keys/core.rst +(or file +.\" commit b68101a1e8f0263dbc7b8375d2a7c57c6216fb76 +.i documentation/security/keys.txt +on linux between 3.0 and 4.13, or +.\" commit d410fa4ef99112386de5f218dd7df7b4fca910b4 +.i documentation/keys.txt +before linux 3.0). +.tp +.ir /proc/[pid]/attr/prev " (since linux 2.6.0)" +this file contains the security context of the process before the last +.br execve (2); +that is, the previous value of +.ir /proc/[pid]/attr/current . +.tp +.ir /proc/[pid]/attr/socketcreate " (since linux 2.6.18)" +.\" commit 42c3e03ef6b298813557cdb997bd6db619cd65a2 +if a process writes a security context into this file, +all subsequently created sockets will be labeled with this context. +.tp +.ir /proc/[pid]/autogroup " (since linux 2.6.38)" +.\" commit 5091faa449ee0b7d73bc296a93bca9540fc51d0a +see +.br sched (7). +.tp +.ir /proc/[pid]/auxv " (since 2.6.0)" +.\" precisely: linux 2.6.0-test7 +this contains the contents of the elf interpreter information passed +to the process at exec time. +the format is one \fiunsigned long\fp id +plus one \fiunsigned long\fp value for each entry. +the last entry contains two zeros. +see also +.br getauxval (3). +.ip +permission to access this file is governed by a ptrace access mode +.b ptrace_mode_read_fscreds +check; see +.br ptrace (2). +.tp +.ir /proc/[pid]/cgroup " (since linux 2.6.24)" +see +.br cgroups (7). +.tp +.ir /proc/[pid]/clear_refs " (since linux 2.6.22)" +.\" commit b813e931b4c8235bb42e301096ea97dbdee3e8fe (2.6.22) +.\" commit 398499d5f3613c47f2143b8c54a04efb5d7a6da9 (2.6.32) +.\" commit 040fa02077de01c7e08fa75be6125e4ca5636011 (3.11) +.\" +.\" "clears page referenced bits shown in smaps output" +.\" write-only, writable only by the owner of the process +.ip +this is a write-only file, writable only by owner of the process. +.ip +the following values may be written to the file: +.rs +.tp +1 (since linux 2.6.22) +.\" internally: clear_refs_all +reset the pg_referenced and accessed/young +bits for all the pages associated with the process. +(before kernel 2.6.32, writing any nonzero value to this file +had this effect.) +.tp +2 (since linux 2.6.32) +.\" internally: clear_refs_anon +reset the pg_referenced and accessed/young +bits for all anonymous pages associated with the process. +.tp +3 (since linux 2.6.32) +.\" internally: clear_refs_mapped +reset the pg_referenced and accessed/young +bits for all file-mapped pages associated with the process. +.re +.ip +clearing the pg_referenced and accessed/young bits provides a method +to measure approximately how much memory a process is using. +one first inspects the values in the "referenced" fields +for the vmas shown in +.ir /proc/[pid]/smaps +to get an idea of the memory footprint of the +process. +one then clears the pg_referenced and accessed/young bits +and, after some measured time interval, +once again inspects the values in the "referenced" fields +to get an idea of the change in memory footprint of the +process during the measured interval. +if one is interested only in inspecting the selected mapping types, +then the value 2 or 3 can be used instead of 1. +.ip +further values can be written to affect different properties: +.rs +.tp +4 (since linux 3.11) +clear the soft-dirty bit for all the pages associated with the process. +.\" internally: clear_refs_soft_dirty +this is used (in conjunction with +.ir /proc/[pid]/pagemap ) +by the check-point restore system to discover which pages of a process +have been dirtied since the file +.ir /proc/[pid]/clear_refs +was written to. +.tp +5 (since linux 4.0) +.\" internally: clear_refs_mm_hiwater_rss +reset the peak resident set size ("high water mark") to the process's +current resident set size value. +.re +.ip +writing any value to +.ir /proc/[pid]/clear_refs +other than those listed above has no effect. +.ip +the +.ir /proc/[pid]/clear_refs +file is present only if the +.b config_proc_page_monitor +kernel configuration option is enabled. +.tp +.i /proc/[pid]/cmdline +this read-only file holds the complete command line for the process, +unless the process is a zombie. +.\" in 2.3.26, this also used to be true if the process was swapped out. +in the latter case, there is nothing in this file: +that is, a read on this file will return 0 characters. +the command-line arguments appear in this file as a set of +strings separated by null bytes (\(aq\e0\(aq), +with a further null byte after the last string. +.ip +if, after an +.br execve (2), +the process modifies its +.i argv +strings, those changes will show up here. +this is not the same thing as modifying the +.i argv +array. +.ip +furthermore, a process may change the memory location that this file refers via +.br prctl (2) +operations such as +.br pr_set_mm_arg_start . +.ip +think of this file as the command line that the process wants you to see. +.tp +.ir /proc/[pid]/comm " (since linux 2.6.33)" +.\" commit 4614a696bd1c3a9af3a08f0e5874830a85b889d4 +this file exposes the process's +.i comm +value\(emthat is, the command name associated with the process. +different threads in the same process may have different +.i comm +values, accessible via +.ir /proc/[pid]/task/[tid]/comm . +a thread may modify its +.i comm +value, or that of any of other thread in the same thread group (see +the discussion of +.b clone_thread +in +.br clone (2)), +by writing to the file +.ir /proc/self/task/[tid]/comm . +strings longer than +.b task_comm_len +(16) characters (including the terminating null byte) are silently truncated. +.ip +this file provides a superset of the +.br prctl (2) +.b pr_set_name +and +.b pr_get_name +operations, and is employed by +.br pthread_setname_np (3) +when used to rename threads other than the caller. +the value in this file is used for the +.i %e +specifier in +.ir /proc/sys/kernel/core_pattern ; +see +.br core (5). +.tp +.ir /proc/[pid]/coredump_filter " (since linux 2.6.23)" +see +.br core (5). +.tp +.ir /proc/[pid]/cpuset " (since linux 2.6.12)" +.\" and/proc/[pid]/task/[tid]/cpuset +see +.br cpuset (7). +.tp +.i /proc/[pid]/cwd +this is a symbolic link to the current working directory of the process. +to find out the current working directory of process 20, +for instance, you can do this: +.ip +.in +4n +.ex +.rb "$" " cd /proc/20/cwd; pwd \-p" +.ee +.in +.ip +.\" the following was still true as at kernel 2.6.13 +in a multithreaded process, the contents of this symbolic link +are not available if the main thread has already terminated +(typically by calling +.br pthread_exit (3)). +.ip +permission to dereference or read +.rb ( readlink (2)) +this symbolic link is governed by a ptrace access mode +.b ptrace_mode_read_fscreds +check; see +.br ptrace (2). +.tp +.i /proc/[pid]/environ +this file contains the initial environment that was set +when the currently executing program was started via +.br execve (2). +the entries are separated by null bytes (\(aq\e0\(aq), +and there may be a null byte at the end. +thus, to print out the environment of process 1, you would do: +.ip +.in +4n +.ex +.rb "$" " cat /proc/1/environ | tr \(aq\e000\(aq \(aq\en\(aq" +.ee +.in +.ip +if, after an +.br execve (2), +the process modifies its environment +(e.g., by calling functions such as +.br putenv (3) +or modifying the +.br environ (7) +variable directly), +this file will +.i not +reflect those changes. +.ip +furthermore, a process may change the memory location that this file refers via +.br prctl (2) +operations such as +.br pr_set_mm_env_start . +.ip +permission to access this file is governed by a ptrace access mode +.b ptrace_mode_read_fscreds +check; see +.br ptrace (2). +.tp +.i /proc/[pid]/exe +under linux 2.2 and later, this file is a symbolic link +containing the actual pathname of the executed command. +this symbolic link can be dereferenced normally; attempting to open +it will open the executable. +you can even type +.i /proc/[pid]/exe +to run another copy of the same executable that is being run by +process [pid]. +if the pathname has been unlinked, the symbolic link will contain the +string \(aq(deleted)\(aq appended to the original pathname. +.\" the following was still true as at kernel 2.6.13 +in a multithreaded process, the contents of this symbolic link +are not available if the main thread has already terminated +(typically by calling +.br pthread_exit (3)). +.ip +permission to dereference or read +.rb ( readlink (2)) +this symbolic link is governed by a ptrace access mode +.b ptrace_mode_read_fscreds +check; see +.br ptrace (2). +.ip +under linux 2.0 and earlier, +.i /proc/[pid]/exe +is a pointer to the binary which was executed, +and appears as a symbolic link. +a +.br readlink (2) +call on this file under linux 2.0 returns a string in the format: +.ip + [device]:inode +.ip +for example, [0301]:1502 would be inode 1502 on device major 03 (ide, +mfm, etc. drives) minor 01 (first partition on the first drive). +.ip +.br find (1) +with the +.i \-inum +option can be used to locate the file. +.tp +.i /proc/[pid]/fd/ +this is a subdirectory containing one entry for each file which the +process has open, named by its file descriptor, and which is a +symbolic link to the actual file. +thus, 0 is standard input, 1 standard output, 2 standard error, and so on. +.ip +for file descriptors for pipes and sockets, +the entries will be symbolic links whose content is the +file type with the inode. +a +.br readlink (2) +call on this file returns a string in the format: +.ip + type:[inode] +.ip +for example, +.i socket:[2248868] +will be a socket and its inode is 2248868. +for sockets, that inode can be used to find more information +in one of the files under +.ir /proc/net/ . +.ip +for file descriptors that have no corresponding inode +(e.g., file descriptors produced by +.br bpf (2), +.br epoll_create (2), +.br eventfd (2), +.br inotify_init (2), +.br perf_event_open (2), +.br signalfd (2), +.br timerfd_create (2), +and +.br userfaultfd (2)), +the entry will be a symbolic link with contents of the form +.ip + anon_inode: +.ip +in many cases (but not all), the +.i file-type +is surrounded by square brackets. +.ip +for example, an epoll file descriptor will have a symbolic link +whose content is the string +.ir "anon_inode:[eventpoll]" . +.ip +.\"the following was still true as at kernel 2.6.13 +in a multithreaded process, the contents of this directory +are not available if the main thread has already terminated +(typically by calling +.br pthread_exit (3)). +.ip +programs that take a filename as a command-line argument, +but don't take input from standard input if no argument is supplied, +and programs that write to a file named as a command-line argument, +but don't send their output to standard output +if no argument is supplied, can nevertheless be made to use +standard input or standard output by using +.ir /proc/[pid]/fd +files as command-line arguments. +for example, assuming that +.i \-i +is the flag designating an input file and +.i \-o +is the flag designating an output file: +.ip +.in +4n +.ex +.rb "$" " foobar \-i /proc/self/fd/0 \-o /proc/self/fd/1 ..." +.ee +.in +.ip +and you have a working filter. +.\" the following is not true in my tests (mtk): +.\" note that this will not work for +.\" programs that seek on their files, as the files in the fd directory +.\" are not seekable. +.ip +.i /proc/self/fd/n +is approximately the same as +.i /dev/fd/n +in some unix and unix-like systems. +most linux makedev scripts symbolically link +.i /dev/fd +to +.ir /proc/self/fd , +in fact. +.ip +most systems provide symbolic links +.ir /dev/stdin , +.ir /dev/stdout , +and +.ir /dev/stderr , +which respectively link to the files +.ir 0 , +.ir 1 , +and +.ir 2 +in +.ir /proc/self/fd . +thus the example command above could be written as: +.ip +.in +4n +.ex +.rb "$" " foobar \-i /dev/stdin \-o /dev/stdout ..." +.ee +.in +.ip +permission to dereference or read +.rb ( readlink (2)) +the symbolic links in this directory is governed by a ptrace access mode +.b ptrace_mode_read_fscreds +check; see +.br ptrace (2). +.ip +note that for file descriptors referring to inodes (pipes and sockets, see above), +those inodes still have permission bits and ownership information +distinct from those of the +.i /proc/[pid]/fd +entry, +and that the owner may differ from the user and group ids of the process. +an unprivileged process may lack permissions to open them, as in this example: +.ip +.in +4n +.ex +.rb "$" " echo test | sudo \-u nobody cat" +test +.rb "$" " echo test | sudo \-u nobody cat /proc/self/fd/0" +cat: /proc/self/fd/0: permission denied +.ee +.in +.ip +file descriptor 0 refers to the pipe created by the shell +and owned by that shell's user, which is not +.ir nobody , +so +.b cat +does not have permission to create a new file descriptor to read from that inode, +even though it can still read from its existing file descriptor 0. +.tp +.ir /proc/[pid]/fdinfo/ " (since linux 2.6.22)" +this is a subdirectory containing one entry for each file which the +process has open, named by its file descriptor. +the files in this directory are readable only by the owner of the process. +the contents of each file can be read to obtain information +about the corresponding file descriptor. +the content depends on the type of file referred to by the +corresponding file descriptor. +.ip +for regular files and directories, we see something like: +.ip +.in +4n +.ex +.rb "$" " cat /proc/12015/fdinfo/4" +pos: 1000 +flags: 01002002 +mnt_id: 21 +.ee +.in +.ip +the fields are as follows: +.rs +.tp +.i pos +this is a decimal number showing the file offset. +.tp +.i flags +this is an octal number that displays the +file access mode and file status flags (see +.br open (2)). +if the close-on-exec file descriptor flag is set, then +.i flags +will also include the value +.br o_cloexec . +.ip +before linux 3.1, +.\" commit 1117f72ea0217ba0cc19f05adbbd8b9a397f5ab7 +this field incorrectly displayed the setting of +.b o_cloexec +at the time the file was opened, +rather than the current setting of the close-on-exec flag. +.tp +.i +.i mnt_id +this field, present since linux 3.15, +.\" commit 49d063cb353265c3af701bab215ac438ca7df36d +is the id of the mount containing this file. +see the description of +.ir /proc/[pid]/mountinfo . +.re +.ip +for eventfd file descriptors (see +.br eventfd (2)), +we see (since linux 3.8) +.\" commit cbac5542d48127b546a23d816380a7926eee1c25 +the following fields: +.ip +.in +4n +.ex +pos: 0 +flags: 02 +mnt_id: 10 +eventfd\-count: 40 +.ee +.in +.ip +.i eventfd\-count +is the current value of the eventfd counter, in hexadecimal. +.ip +for epoll file descriptors (see +.br epoll (7)), +we see (since linux 3.8) +.\" commit 138d22b58696c506799f8de759804083ff9effae +the following fields: +.ip +.in +4n +.ex +pos: 0 +flags: 02 +mnt_id: 10 +tfd: 9 events: 19 data: 74253d2500000009 +tfd: 7 events: 19 data: 74253d2500000007 +.ee +.in +.ip +each of the lines beginning +.i tfd +describes one of the file descriptors being monitored via +the epoll file descriptor (see +.br epoll_ctl (2) +for some details). +the +.ir tfd +field is the number of the file descriptor. +the +.i events +field is a hexadecimal mask of the events being monitored for this file +descriptor. +the +.i data +field is the data value associated with this file descriptor. +.ip +for signalfd file descriptors (see +.br signalfd (2)), +we see (since linux 3.8) +.\" commit 138d22b58696c506799f8de759804083ff9effae +the following fields: +.ip +.in +4n +.ex +pos: 0 +flags: 02 +mnt_id: 10 +sigmask: 0000000000000006 +.ee +.in +.ip +.i sigmask +is the hexadecimal mask of signals that are accepted via this +signalfd file descriptor. +(in this example, bits 2 and 3 are set, corresponding to the signals +.b sigint +and +.br sigquit ; +see +.br signal (7).) +.ip +for inotify file descriptors (see +.br inotify (7)), +we see (since linux 3.8) +the following fields: +.ip +.in +4n +.ex +pos: 0 +flags: 00 +mnt_id: 11 +inotify wd:2 ino:7ef82a sdev:800001 mask:800afff ignored_mask:0 fhandle\-bytes:8 fhandle\-type:1 f_handle:2af87e00220ffd73 +inotify wd:1 ino:192627 sdev:800001 mask:800afff ignored_mask:0 fhandle\-bytes:8 fhandle\-type:1 f_handle:27261900802dfd73 +.ee +.in +.ip +each of the lines beginning with "inotify" displays information about +one file or directory that is being monitored. +the fields in this line are as follows: +.rs +.tp +.i wd +a watch descriptor number (in decimal). +.tp +.i ino +the inode number of the target file (in hexadecimal). +.tp +.i sdev +the id of the device where the target file resides (in hexadecimal). +.tp +.i mask +the mask of events being monitored for the target file (in hexadecimal). +.re +.ip +if the kernel was built with exportfs support, the path to the target +file is exposed as a file handle, via three hexadecimal fields: +.ir fhandle\-bytes , +.ir fhandle\-type , +and +.ir f_handle . +.ip +for fanotify file descriptors (see +.br fanotify (7)), +we see (since linux 3.8) +the following fields: +.ip +.in +4n +.ex +pos: 0 +flags: 02 +mnt_id: 11 +fanotify flags:0 event\-flags:88002 +fanotify ino:19264f sdev:800001 mflags:0 mask:1 ignored_mask:0 fhandle\-bytes:8 fhandle\-type:1 f_handle:4f261900a82dfd73 +.ee +.in +.ip +the fourth line displays information defined when the fanotify group +was created via +.br fanotify_init (2): +.rs +.tp +.i flags +the +.i flags +argument given to +.br fanotify_init (2) +(expressed in hexadecimal). +.tp +.i event\-flags +the +.i event_f_flags +argument given to +.br fanotify_init (2) +(expressed in hexadecimal). +.re +.ip +each additional line shown in the file contains information +about one of the marks in the fanotify group. +most of these fields are as for inotify, except: +.rs +.tp +.i mflags +the flags associated with the mark +(expressed in hexadecimal). +.tp +.i mask +the events mask for this mark +(expressed in hexadecimal). +.tp +.i ignored_mask +the mask of events that are ignored for this mark +(expressed in hexadecimal). +.re +.ip +for details on these fields, see +.br fanotify_mark (2). +.ip +for timerfd file descriptors (see +.br timerfd (2)), +we see (since linux 3.17) +.\" commit af9c4957cf212ad9cf0bee34c95cb11de5426e85 +the following fields: +.ip +.in +4n +.ex +pos: 0 +flags: 02004002 +mnt_id: 13 +clockid: 0 +ticks: 0 +settime flags: 03 +it_value: (7695568592, 640020877) +it_interval: (0, 0) +.ee +.in +.rs +.tp +.i clockid +this is the numeric value of the clock id +(corresponding to one of the +.b clock_* +constants defined via +.ir ) +that is used to mark the progress of the timer (in this example, 0 is +.br clock_realtime ). +.tp +.i ticks +this is the number of timer expirations that have occurred, +(i.e., the value that +.br read (2) +on it would return). +.tp +.i settime flags +this field lists the flags with which the timerfd was last armed (see +.br timerfd_settime (2)), +in octal +(in this example, both +.b tfd_timer_abstime +and +.b tfd_timer_cancel_on_set +are set). +.tp +.i it_value +this field contains the amount of time until the timer will next expire, +expressed in seconds and nanoseconds. +this is always expressed as a relative value, +regardless of whether the timer was created using the +.b tfd_timer_abstime +flag. +.tp +.i it_interval +this field contains the interval of the timer, +in seconds and nanoseconds. +(the +.i it_value +and +.i it_interval +fields contain the values that +.br timerfd_gettime (2) +on this file descriptor would return.) +.re +.tp +.ir /proc/[pid]/gid_map " (since linux 3.5)" +see +.br user_namespaces (7). +.tp +.ir /proc/[pid]/io " (since kernel 2.6.20)" +.\" commit 7c3ab7381e79dfc7db14a67c6f4f3285664e1ec2 +this file contains i/o statistics for the process, for example: +.ip +.in +4n +.ex +.rb "#" " cat /proc/3828/io" +rchar: 323934931 +wchar: 323929600 +syscr: 632687 +syscw: 632675 +read_bytes: 0 +write_bytes: 323932160 +cancelled_write_bytes: 0 +.ee +.in +.ip +the fields are as follows: +.rs +.tp +.ir rchar ": characters read" +the number of bytes which this task has caused to be read from storage. +this is simply the sum of bytes which this process passed to +.br read (2) +and similar system calls. +it includes things such as terminal i/o and +is unaffected by whether or not actual +physical disk i/o was required (the read might have been satisfied from +pagecache). +.tp +.ir wchar ": characters written" +the number of bytes which this task has caused, or shall cause to be written +to disk. +similar caveats apply here as with +.ir rchar . +.tp +.ir syscr ": read syscalls" +attempt to count the number of read i/o operations\(emthat is, +system calls such as +.br read (2) +and +.br pread (2). +.tp +.ir syscw ": write syscalls" +attempt to count the number of write i/o operations\(emthat is, +system calls such as +.br write (2) +and +.br pwrite (2). +.tp +.ir read_bytes ": bytes read" +attempt to count the number of bytes which this process really did cause to +be fetched from the storage layer. +this is accurate for block-backed filesystems. +.tp +.ir write_bytes ": bytes written" +attempt to count the number of bytes which this process caused to be sent to +the storage layer. +.tp +.ir cancelled_write_bytes : +the big inaccuracy here is truncate. +if a process writes 1 mb to a file and then deletes the file, +it will in fact perform no writeout. +but it will have been accounted as having caused 1 mb of write. +in other words: this field represents the number of bytes which this process +caused to not happen, by truncating pagecache. +a task can cause "negative" i/o too. +if this task truncates some dirty pagecache, +some i/o which another task has been accounted for +(in its +.ir write_bytes ) +will not be happening. +.re +.ip +.ir note : +in the current implementation, things are a bit racy on 32-bit systems: +if process a reads process b's +.i /proc/[pid]/io +while process b is updating one of these 64-bit counters, +process a could see an intermediate result. +.ip +permission to access this file is governed by a ptrace access mode +.b ptrace_mode_read_fscreds +check; see +.br ptrace (2). +.tp +.ir /proc/[pid]/limits " (since linux 2.6.24)" +this file displays the soft limit, hard limit, and units of measurement +for each of the process's resource limits (see +.br getrlimit (2)). +up to and including linux 2.6.35, +this file is protected to allow reading only by the real uid of the process. +since linux 2.6.36, +.\" commit 3036e7b490bf7878c6dae952eec5fb87b1106589 +this file is readable by all users on the system. +.\" fixme describe /proc/[pid]/loginuid +.\" added in 2.6.11; updating requires cap_audit_control +.\" config_auditsyscall +.tp +.ir /proc/[pid]/map_files/ " (since kernel 3.3)" +.\" commit 640708a2cff7f81e246243b0073c66e6ece7e53e +this subdirectory contains entries corresponding to memory-mapped +files (see +.br mmap (2)). +entries are named by memory region start and end +address pair (expressed as hexadecimal numbers), +and are symbolic links to the mapped files themselves. +here is an example, with the output wrapped and reformatted to fit on an 80-column display: +.ip +.in +4n +.ex +.rb "#" " ls \-l /proc/self/map_files/" +lr\-\-\-\-\-\-\-\-. 1 root root 64 apr 16 21:31 + 3252e00000\-3252e20000 \-> /usr/lib64/ld\-2.15.so +\&... +.ee +.in +.ip +although these entries are present for memory regions that were +mapped with the +.br map_file +flag, the way anonymous shared memory (regions created with the +.b map_anon | map_shared +flags) +is implemented in linux +means that such regions also appear on this directory. +here is an example where the target file is the deleted +.i /dev/zero +one: +.ip +.in +4n +.ex +lrw\-\-\-\-\-\-\-. 1 root root 64 apr 16 21:33 + 7fc075d2f000\-7fc075e6f000 \-> /dev/zero (deleted) +.ee +.in +.ip +permission to access this file is governed by a ptrace access mode +.b ptrace_mode_read_fscreds +check; see +.br ptrace (2). +.ip +until kernel version 4.3, +.\" commit bdb4d100afe9818aebd1d98ced575c5ef143456c +this directory appeared only if the +.b config_checkpoint_restore +kernel configuration option was enabled. +.ip +capabilities are required to read the contents of the symbolic links in +this directory: before linux 5.9, the reading process requires +.br cap_sys_admin +in the initial user namespace; +since linux 5.9, the reading process must have either +.br cap_sys_admin +or +.br cap_checkpoint_restore +in the user namespace where it resides. +.tp +.i /proc/[pid]/maps +a file containing the currently mapped memory regions and their access +permissions. +see +.br mmap (2) +for some further information about memory mappings. +.ip +permission to access this file is governed by a ptrace access mode +.b ptrace_mode_read_fscreds +check; see +.br ptrace (2). +.ip +the format of the file is: +.ip +.in +4n +.ex +.i "address perms offset dev inode pathname" +00400000\-00452000 r\-xp 00000000 08:02 173521 /usr/bin/dbus\-daemon +00651000\-00652000 r\-\-p 00051000 08:02 173521 /usr/bin/dbus\-daemon +00652000\-00655000 rw\-p 00052000 08:02 173521 /usr/bin/dbus\-daemon +00e03000\-00e24000 rw\-p 00000000 00:00 0 [heap] +00e24000\-011f7000 rw\-p 00000000 00:00 0 [heap] +\&... +35b1800000\-35b1820000 r\-xp 00000000 08:02 135522 /usr/lib64/ld\-2.15.so +35b1a1f000\-35b1a20000 r\-\-p 0001f000 08:02 135522 /usr/lib64/ld\-2.15.so +35b1a20000\-35b1a21000 rw\-p 00020000 08:02 135522 /usr/lib64/ld\-2.15.so +35b1a21000\-35b1a22000 rw\-p 00000000 00:00 0 +35b1c00000\-35b1dac000 r\-xp 00000000 08:02 135870 /usr/lib64/libc\-2.15.so +35b1dac000\-35b1fac000 \-\-\-p 001ac000 08:02 135870 /usr/lib64/libc\-2.15.so +35b1fac000\-35b1fb0000 r\-\-p 001ac000 08:02 135870 /usr/lib64/libc\-2.15.so +35b1fb0000\-35b1fb2000 rw\-p 001b0000 08:02 135870 /usr/lib64/libc\-2.15.so +\&... +f2c6ff8c000\-7f2c7078c000 rw\-p 00000000 00:00 0 [stack:986] +\&... +7fffb2c0d000\-7fffb2c2e000 rw\-p 00000000 00:00 0 [stack] +7fffb2d48000\-7fffb2d49000 r\-xp 00000000 00:00 0 [vdso] +.ee +.in +.ip +the +.i address +field is the address space in the process that the mapping occupies. +the +.i perms +field is a set of permissions: +.ip +.in +4n +.ex +r = read +w = write +x = execute +s = shared +p = private (copy on write) +.ee +.in +.ip +the +.i offset +field is the offset into the file/whatever; +.i dev +is the device +(major:minor); +.i inode +is the inode on that device. +0 indicates that no inode is associated with the memory region, +as would be the case with bss (uninitialized data). +.ip +the +.i pathname +field will usually be the file that is backing the mapping. +for elf files, +you can easily coordinate with the +.i offset +field by looking at the +offset field in the elf program headers +.ri ( "readelf\ \-l" ). +.ip +there are additional helpful pseudo-paths: +.rs +.tp +.ir [stack] +the initial process's (also known as the main thread's) stack. +.tp +.ir [stack:] " (from linux 3.4 to 4.4)" +.\" commit b76437579d1344b612cf1851ae610c636cec7db0 (added) +.\" commit 65376df582174ffcec9e6471bf5b0dd79ba05e4a (removed) +a thread's stack (where the +.ir +is a thread id). +it corresponds to the +.ir /proc/[pid]/task/[tid]/ +path. +this field was removed in linux 4.5, since providing this information +for a process with large numbers of threads is expensive. +.tp +.ir [vdso] +the virtual dynamically linked shared object. +see +.br vdso (7). +.tp +.ir [heap] +the process's heap. +.in +.re +.ip +if the +.i pathname +field is blank, +this is an anonymous mapping as obtained via +.br mmap (2). +there is no easy way to coordinate this back to a process's source, +short of running it through +.br gdb (1), +.br strace (1), +or similar. +.ip +.i pathname +is shown unescaped except for newline characters, which are replaced +with an octal escape sequence. +as a result, it is not possible to determine whether the original +pathname contained a newline character or the literal +.i \e012 +character sequence. +.ip +if the mapping is file-backed and the file has been deleted, the string +" (deleted)" is appended to the pathname. +note that this is ambiguous too. +.ip +under linux 2.0, there is no field giving pathname. +.tp +.i /proc/[pid]/mem +this file can be used to access the pages of a process's memory through +.br open (2), +.br read (2), +and +.br lseek (2). +.ip +permission to access this file is governed by a ptrace access mode +.b ptrace_mode_attach_fscreds +check; see +.br ptrace (2). +.tp +.ir /proc/[pid]/mountinfo " (since linux 2.6.26)" +.\" this info adapted from documentation/filesystems/proc.txt +.\" commit 2d4d4864ac08caff5c204a752bd004eed4f08760 +this file contains information about mounts +in the process's mount namespace (see +.br mount_namespaces (7)). +it supplies various information +(e.g., propagation state, root of mount for bind mounts, +identifier for each mount and its parent) that is missing from the (older) +.ir /proc/[pid]/mounts +file, and fixes various other problems with that file +(e.g., nonextensibility, +failure to distinguish per-mount versus per-superblock options). +.ip +the file contains lines of the form: +.ip +.ex +36 35 98:0 /mnt1 /mnt2 rw,noatime master:1 \- ext3 /dev/root rw,errors=continue +(1)(2)(3) (4) (5) (6) (7) (8) (9) (10) (11) +.ee +.ip +the numbers in parentheses are labels for the descriptions below: +.rs 7 +.tp 5 +(1) +mount id: a unique id for the mount (may be reused after +.br umount (2)). +.tp +(2) +parent id: the id of the parent mount +(or of self for the root of this mount namespace's mount tree). +.ip +if a new mount is stacked on top of a previous existing mount +(so that it hides the existing mount) at pathname p, +then the parent of the new mount is the previous mount at that location. +thus, when looking at all the mounts stacked at a particular location, +the top-most mount is the one that is not the parent +of any other mount at the same location. +(note, however, that this top-most mount will be accessible only if +the longest path subprefix of p that is a mount point +is not itself hidden by a stacked mount.) +.ip +if the parent mount lies outside the process's root directory (see +.br chroot (2)), +the id shown here won't have a corresponding record in +.i mountinfo +whose mount id (field 1) matches this parent mount id +(because mounts that lie outside the process's root directory +are not shown in +.ir mountinfo ). +as a special case of this point, +the process's root mount may have a parent mount +(for the initramfs filesystem) that lies +.\" miklos szeredi, nov 2017: the hidden one is the initramfs, i believe +.\" mtk: in the initial mount namespace, this hidden id has the value 0 +outside the process's root directory, +and an entry for that mount will not appear in +.ir mountinfo . +.tp +(3) +major:minor: the value of +.i st_dev +for files on this filesystem (see +.br stat (2)). +.tp +(4) +root: the pathname of the directory in the filesystem +which forms the root of this mount. +.tp +(5) +mount point: the pathname of the mount point relative +to the process's root directory. +.tp +(6) +mount options: per-mount options (see +.br mount (2)). +.tp +(7) +optional fields: zero or more fields of the form "tag[:value]"; see below. +.tp +(8) +separator: the end of the optional fields is marked by a single hyphen. +.tp +(9) +filesystem type: the filesystem type in the form "type[.subtype]". +.tp +(10) +mount source: filesystem-specific information or "none". +.tp +(11) +super options: per-superblock options (see +.br mount (2)). +.re +.ip +currently, the possible optional fields are +.ir shared , +.ir master , +.ir propagate_from , +and +.ir unbindable . +see +.br mount_namespaces (7) +for a description of these fields. +parsers should ignore all unrecognized optional fields. +.ip +for more information on mount propagation see: +.i documentation/filesystems/sharedsubtree.txt +in the linux kernel source tree. +.tp +.ir /proc/[pid]/mounts " (since linux 2.4.19)" +this file lists all the filesystems currently mounted in the +process's mount namespace (see +.br mount_namespaces (7)). +the format of this file is documented in +.br fstab (5). +.ip +since kernel version 2.6.15, this file is pollable: +after opening the file for reading, a change in this file +(i.e., a filesystem mount or unmount) causes +.br select (2) +to mark the file descriptor as having an exceptional condition, and +.br poll (2) +and +.br epoll_wait (2) +mark the file as having a priority event +.rb ( pollpri ). +(before linux 2.6.30, +a change in this file was indicated by the file descriptor +being marked as readable for +.br select (2), +and being marked as having an error condition for +.br poll (2) +and +.br epoll_wait (2).) +.tp +.ir /proc/[pid]/mountstats " (since linux 2.6.17)" +this file exports information (statistics, configuration information) +about the mounts in the process's mount namespace (see +.br mount_namespaces (7)). +lines in this file have the form: +.ip +.in +4n +.ex +device /dev/sda7 mounted on /home with fstype ext3 [stats] +( 1 ) ( 2 ) (3 ) ( 4 ) +.ee +.in +.ip +the fields in each line are: +.rs 7 +.tp 5 +(1) +the name of the mounted device +(or "nodevice" if there is no corresponding device). +.tp +(2) +the mount point within the filesystem tree. +.tp +(3) +the filesystem type. +.tp +(4) +optional statistics and configuration information. +currently (as at linux 2.6.26), only nfs filesystems export +information via this field. +.re +.ip +this file is readable only by the owner of the process. +.tp +.ir /proc/[pid]/net " (since linux 2.6.25)" +see the description of +.ir /proc/net . +.tp +.ir /proc/[pid]/ns/ " (since linux 3.0)" +.\" see commit 6b4e306aa3dc94a0545eb9279475b1ab6209a31f +this is a subdirectory containing one entry for each namespace that +supports being manipulated by +.br setns (2). +for more information, see +.br namespaces (7). +.tp +.ir /proc/[pid]/numa_maps " (since linux 2.6.14)" +see +.br numa (7). +.tp +.ir /proc/[pid]/oom_adj " (since linux 2.6.11)" +this file can be used to adjust the score used to select which process +should be killed in an out-of-memory (oom) situation. +the kernel uses this value for a bit-shift operation of the process's +.ir oom_score +value: +valid values are in the range \-16 to +15, +plus the special value \-17, +which disables oom-killing altogether for this process. +a positive score increases the likelihood of this +process being killed by the oom-killer; +a negative score decreases the likelihood. +.ip +the default value for this file is 0; +a new process inherits its parent's +.i oom_adj +setting. +a process must be privileged +.rb ( cap_sys_resource ) +to update this file. +.ip +since linux 2.6.36, use of this file is deprecated in favor of +.ir /proc/[pid]/oom_score_adj . +.tp +.ir /proc/[pid]/oom_score " (since linux 2.6.11)" +.\" see mm/oom_kill.c::badness() in pre 2.6.36 sources +.\" see mm/oom_kill.c::oom_badness() after 2.6.36 +.\" commit a63d83f427fbce97a6cea0db2e64b0eb8435cd10 +this file displays the current score that the kernel gives to +this process for the purpose of selecting a process +for the oom-killer. +a higher score means that the process is more likely to be +selected by the oom-killer. +the basis for this score is the amount of memory used by the process, +with increases (+) or decreases (\-) for factors including: +.\" see mm/oom_kill.c::badness() in pre 2.6.36 sources +.\" see mm/oom_kill.c::oom_badness() after 2.6.36 +.\" commit a63d83f427fbce97a6cea0db2e64b0eb8435cd10 +.rs +.ip * 2 +whether the process is privileged (\-). +.\" more precisely, if it has cap_sys_admin or (pre 2.6.36) cap_sys_resource +.re +.ip +before kernel 2.6.36 the following factors were also used in the calculation of oom_score: +.rs +.ip * 2 +whether the process creates a lot of children using +.br fork (2) +(+); +.ip * +whether the process has been running a long time, +or has used a lot of cpu time (\-); +.ip * +whether the process has a low nice value (i.e., > 0) (+); and +.ip * +whether the process is making direct hardware access (\-). +.\" more precisely, if it has cap_sys_rawio +.re +.ip +the +.i oom_score +also reflects the adjustment specified by the +.i oom_score_adj +or +.i oom_adj +setting for the process. +.tp +.ir /proc/[pid]/oom_score_adj " (since linux 2.6.36)" +.\" text taken from 3.7 documentation/filesystems/proc.txt +this file can be used to adjust the badness heuristic used to select which +process gets killed in out-of-memory conditions. +.ip +the badness heuristic assigns a value to each candidate task ranging from 0 +(never kill) to 1000 (always kill) to determine which process is targeted. +the units are roughly a proportion along that range of +allowed memory the process may allocate from, +based on an estimation of its current memory and swap use. +for example, if a task is using all allowed memory, +its badness score will be 1000. +if it is using half of its allowed memory, its score will be 500. +.ip +there is an additional factor included in the badness score: root +processes are given 3% extra memory over other tasks. +.ip +the amount of "allowed" memory depends on the context +in which the oom-killer was called. +if it is due to the memory assigned to the allocating task's cpuset +being exhausted, +the allowed memory represents the set of mems assigned to that +cpuset (see +.br cpuset (7)). +if it is due to a mempolicy's node(s) being exhausted, +the allowed memory represents the set of mempolicy nodes. +if it is due to a memory limit (or swap limit) being reached, +the allowed memory is that configured limit. +finally, if it is due to the entire system being out of memory, the +allowed memory represents all allocatable resources. +.ip +the value of +.i oom_score_adj +is added to the badness score before it +is used to determine which task to kill. +acceptable values range from \-1000 +(oom_score_adj_min) to +1000 (oom_score_adj_max). +this allows user space to control the preference for oom-killing, +ranging from always preferring a certain +task or completely disabling it from oom-killing. +the lowest possible value, \-1000, is +equivalent to disabling oom-killing entirely for that task, +since it will always report a badness score of 0. +.ip +consequently, it is very simple for user space to define +the amount of memory to consider for each task. +setting an +.i oom_score_adj +value of +500, for example, +is roughly equivalent to allowing the remainder of tasks sharing the +same system, cpuset, mempolicy, or memory controller resources +to use at least 50% more memory. +a value of \-500, on the other hand, would be roughly +equivalent to discounting 50% of the task's +allowed memory from being considered as scoring against the task. +.ip +for backward compatibility with previous kernels, +.i /proc/[pid]/oom_adj +can still be used to tune the badness score. +its value is +scaled linearly with +.ir oom_score_adj . +.ip +writing to +.ir /proc/[pid]/oom_score_adj +or +.ir /proc/[pid]/oom_adj +will change the other with its scaled value. +.ip +the +.br choom (1) +program provides a command-line interface for adjusting the +.i oom_score_adj +value of a running process or a newly executed command. +.tp +.ir /proc/[pid]/pagemap " (since linux 2.6.25)" +this file shows the mapping of each of the process's virtual pages +into physical page frames or swap area. +it contains one 64-bit value for each virtual page, +with the bits set as follows: +.rs +.tp +63 +if set, the page is present in ram. +.tp +62 +if set, the page is in swap space +.tp +61 (since linux 3.5) +the page is a file-mapped page or a shared anonymous page. +.tp +60\(en57 (since linux 3.11) +zero +.\" not quite true; see commit 541c237c0923f567c9c4cabb8a81635baadc713f +.tp +56 (since linux 4.2) +.\" commit 77bb499bb60f4b79cca7d139c8041662860fcf87 +.\" commit 83b4b0bb635eee2b8e075062e4e008d1bc110ed7 +the page is exclusively mapped. +.tp +55 (since linux 3.11) +pte is soft-dirty +(see the kernel source file +.ir documentation/admin\-guide/mm/soft\-dirty.rst ). +.tp +54\(en0 +if the page is present in ram (bit 63), then these bits +provide the page frame number, which can be used to index +.ir /proc/kpageflags +and +.ir /proc/kpagecount . +if the page is present in swap (bit 62), +then bits 4\(en0 give the swap type, and bits 54\(en5 encode the swap offset. +.re +.ip +before linux 3.11, bits 60\(en55 were +used to encode the base-2 log of the page size. +.ip +to employ +.ir /proc/[pid]/pagemap +efficiently, use +.ir /proc/[pid]/maps +to determine which areas of memory are actually mapped and seek +to skip over unmapped regions. +.ip +the +.ir /proc/[pid]/pagemap +file is present only if the +.b config_proc_page_monitor +kernel configuration option is enabled. +.ip +permission to access this file is governed by a ptrace access mode +.b ptrace_mode_read_fscreds +check; see +.br ptrace (2). +.tp +.ir /proc/[pid]/personality " (since linux 2.6.28)" +.\" commit 478307230810d7e2a753ed220db9066dfdf88718 +this read-only file exposes the process's execution domain, as set by +.br personality (2). +the value is displayed in hexadecimal notation. +.ip +permission to access this file is governed by a ptrace access mode +.b ptrace_mode_attach_fscreds +check; see +.br ptrace (2). +.tp +.i /proc/[pid]/root +unix and linux support the idea of a per-process root of the +filesystem, set by the +.br chroot (2) +system call. +this file is a symbolic link that points to the process's +root directory, and behaves in the same way as +.ir exe , +and +.ir fd/* . +.ip +note however that this file is not merely a symbolic link. +it provides the same view of the filesystem (including namespaces and the +set of per-process mounts) as the process itself. +an example illustrates this point. +in one terminal, we start a shell in new user and mount namespaces, +and in that shell we create some new mounts: +.ip +.in +4n +.ex +$ \fbps1=\(aqsh1# \(aq unshare \-urnm\fp +sh1# \fbmount \-t tmpfs tmpfs /etc\fp # mount empty tmpfs at /etc +sh1# \fbmount \-\-bind /usr /dev\fp # mount /usr at /dev +sh1# \fbecho $$\fp +27123 +.ee +.in +.ip +in a second terminal window, in the initial mount namespace, +we look at the contents of the corresponding mounts in +the initial and new namespaces: +.ip +.in +4n +.ex +$ \fbps1=\(aqsh2# \(aq sudo sh\fp +sh2# \fbls /etc | wc \-l\fp # in initial ns +309 +sh2# \fbls /proc/27123/root/etc | wc \-l\fp # /etc in other ns +0 # the empty tmpfs dir +sh2# \fbls /dev | wc \-l\fp # in initial ns +205 +sh2# \fbls /proc/27123/root/dev | wc \-l\fp # /dev in other ns +11 # actually bind + # mounted to /usr +sh2# \fbls /usr | wc \-l\fp # /usr in initial ns +11 +.ee +.in +.ip +.\" the following was still true as at kernel 2.6.13 +in a multithreaded process, the contents of the +.i /proc/[pid]/root +symbolic link are not available if the main thread has already terminated +(typically by calling +.br pthread_exit (3)). +.ip +permission to dereference or read +.rb ( readlink (2)) +this symbolic link is governed by a ptrace access mode +.b ptrace_mode_read_fscreds +check; see +.br ptrace (2). +.tp +.ir /proc/[pid]/projid_map " (since linux 3.7)" +.\" commit f76d207a66c3a53defea67e7d36c3eb1b7d6d61d +see +.br user_namespaces (7). +.tp +.ir /proc/[pid]/seccomp " (linux 2.6.12 to 2.6.22)" +this file can be used to read and change the process's +secure computing (seccomp) mode setting. +it contains the value 0 if the process is not in seccomp mode, +and 1 if the process is in strict seccomp mode (see +.br seccomp (2)). +writing 1 to this file places the process irreversibly in strict seccomp mode. +(further attempts to write to the file fail with the +.b eperm +error.) +.ip +in linux 2.6.23, +this file went away, to be replaced by the +.br prctl (2) +.br pr_get_seccomp +and +.br pr_set_seccomp +operations (and later by +.br seccomp (2) +and the +.i seccomp +field in +.ir /proc/[pid]/status ). +.\" fixme describe /proc/[pid]/sessionid +.\" commit 1e0bd7550ea9cf474b1ad4c6ff5729a507f75fdc +.\" config_auditsyscall +.\" added in 2.6.25; read-only; only readable by real uid +.\" +.\" fixme describe /proc/[pid]/sched +.\" added in 2.6.23 +.\" config_sched_debug, and additional fields if config_schedstats +.\" displays various scheduling parameters +.\" this file can be written, to reset stats +.\" the set of fields exposed by this file have changed +.\" significantly over time. +.\" commit 43ae34cb4cd650d1eb4460a8253a8e747ba052ac +.\" +.\" fixme describe /proc/[pid]/schedstats and +.\" /proc/[pid]/task/[tid]/schedstats +.\" added in 2.6.9 +.\" config_schedstats +.tp +.ir /proc/[pid]/setgroups " (since linux 3.19)" +see +.br user_namespaces (7). +.tp +.ir /proc/[pid]/smaps " (since linux 2.6.14)" +this file shows memory consumption for each of the process's mappings. +(the +.br pmap (1) +command displays similar information, +in a form that may be easier for parsing.) +for each mapping there is a series of lines such as the following: +.ip +.in +4n +.ex +00400000\-0048a000 r\-xp 00000000 fd:03 960637 /bin/bash +size: 552 kb +rss: 460 kb +pss: 100 kb +shared_clean: 452 kb +shared_dirty: 0 kb +private_clean: 8 kb +private_dirty: 0 kb +referenced: 460 kb +anonymous: 0 kb +anonhugepages: 0 kb +shmemhugepages: 0 kb +shmempmdmapped: 0 kb +swap: 0 kb +kernelpagesize: 4 kb +mmupagesize: 4 kb +kernelpagesize: 4 kb +mmupagesize: 4 kb +locked: 0 kb +protectionkey: 0 +vmflags: rd ex mr mw me dw +.ee +.in +.ip +the first of these lines shows the same information as is displayed +for the mapping in +.ir /proc/[pid]/maps . +the following lines show the size of the mapping, +the amount of the mapping that is currently resident in ram ("rss"), +the process's proportional share of this mapping ("pss"), +the number of clean and dirty shared pages in the mapping, +and the number of clean and dirty private pages in the mapping. +"referenced" indicates the amount of memory currently marked as +referenced or accessed. +"anonymous" shows the amount of memory +that does not belong to any file. +"swap" shows how much +would-be-anonymous memory is also used, but out on swap. +.ip +the "kernelpagesize" line (available since linux 2.6.29) +is the page size used by the kernel to back the virtual memory area. +this matches the size used by the mmu in the majority of cases. +however, one counter-example occurs on ppc64 kernels +whereby a kernel using 64 kb as a base page size may still use 4 kb +pages for the mmu on older processors. +to distinguish the two attributes, the "mmupagesize" line +(also available since linux 2.6.29) +reports the page size used by the mmu. +.ip +the "locked" indicates whether the mapping is locked in memory +or not. +.ip +the "protectionkey" line (available since linux 4.9, on x86 only) +contains the memory protection key (see +.br pkeys (7)) +associated with the virtual memory area. +this entry is present only if the kernel was built with the +.b config_x86_intel_memory_protection_keys +configuration option (since linux 4.6). +.ip +the "vmflags" line (available since linux 3.8) +represents the kernel flags associated with the virtual memory area, +encoded using the following two-letter codes: +.ip + rd - readable + wr - writable + ex - executable + sh - shared + mr - may read + mw - may write + me - may execute + ms - may share + gd - stack segment grows down + pf - pure pfn range + dw - disabled write to the mapped file + lo - pages are locked in memory + io - memory mapped i/o area + sr - sequential read advise provided + rr - random read advise provided + dc - do not copy area on fork + de - do not expand area on remapping + ac - area is accountable + nr - swap space is not reserved for the area + ht - area uses huge tlb pages + sf - perform synchronous page faults (since linux 4.15) + nl - non-linear mapping (removed in linux 4.0) + ar - architecture specific flag + wf - wipe on fork (since linux 4.14) + dd - do not include area into core dump + sd - soft-dirty flag (since linux 3.13) + mm - mixed map area + hg - huge page advise flag + nh - no-huge page advise flag + mg - mergeable advise flag + um - userfaultfd missing pages tracking (since linux 4.3) + uw - userfaultfd wprotect pages tracking (since linux 4.3) +.ip +the +.ir /proc/[pid]/smaps +file is present only if the +.b config_proc_page_monitor +kernel configuration option is enabled. +.tp +.ir /proc/[pid]/stack " (since linux 2.6.29)" +.\" 2ec220e27f5040aec1e88901c1b6ea3d135787ad +this file provides a symbolic trace of the function calls in this +process's kernel stack. +this file is provided only if the kernel was built with the +.b config_stacktrace +configuration option. +.ip +permission to access this file is governed by a ptrace access mode +.b ptrace_mode_attach_fscreds +check; see +.br ptrace (2). +.tp +.i /proc/[pid]/stat +status information about the process. +this is used by +.br ps (1). +it is defined in the kernel source file +.ir fs/proc/array.c "." +.ip +the fields, in order, with their proper +.br scanf (3) +format specifiers, are listed below. +whether or not certain of these fields display valid information is governed by +a ptrace access mode +.br ptrace_mode_read_fscreds " | " ptrace_mode_noaudit +check (refer to +.br ptrace (2)). +if the check denies access, then the field value is displayed as 0. +the affected fields are indicated with the marking [pt]. +.rs +.tp +(1) \fipid\fp \ %d +.br +the process id. +.tp +(2) \ficomm\fp \ %s +the filename of the executable, in parentheses. +strings longer than +.b task_comm_len +(16) characters (including the terminating null byte) are silently truncated. +this is visible whether or not the executable is swapped out. +.tp +(3) \fistate\fp \ %c +one of the following characters, indicating process state: +.rs +.ip r 3 +running +.ip s +sleeping in an interruptible wait +.ip d +waiting in uninterruptible +disk sleep +.ip z +zombie +.ip t +stopped (on a signal) or (before linux 2.6.33) trace stopped +.ip t +.\" commit 44d90df6b757c59651ddd55f1a84f28132b50d29 +tracing stop (linux 2.6.33 onward) +.ip w +paging (only before linux 2.6.0) +.ip x +dead (from linux 2.6.0 onward) +.ip x +.\" commit 44d90df6b757c59651ddd55f1a84f28132b50d29 +dead (linux 2.6.33 to +.\" commit 74e37200de8e9c4e09b70c21c3f13c2071e77457 +3.13 only) +.ip k +.\" commit 44d90df6b757c59651ddd55f1a84f28132b50d29 +wakekill (linux 2.6.33 to +.\" commit 74e37200de8e9c4e09b70c21c3f13c2071e77457 +3.13 only) +.ip w +.\" commit 44d90df6b757c59651ddd55f1a84f28132b50d29 +waking (linux 2.6.33 to +.\" commit 74e37200de8e9c4e09b70c21c3f13c2071e77457 +3.13 only) +.ip p +.\" commit f2530dc71cf0822f90bb63ea4600caaef33a66bb +parked (linux 3.9 to +.\" commit 74e37200de8e9c4e09b70c21c3f13c2071e77457 +3.13 only) +.re +.tp +(4) \fippid\fp \ %d +the pid of the parent of this process. +.tp +(5) \fipgrp\fp \ %d +the process group id of the process. +.tp +(6) \fisession\fp \ %d +the session id of the process. +.tp +(7) \fitty_nr\fp \ %d +the controlling terminal of the process. +(the minor device number is contained in the combination of bits +31 to 20 and 7 to 0; +the major device number is in bits 15 to 8.) +.tp +(8) \fitpgid\fp \ %d +.\" this field and following, up to and including wchan added 0.99.1 +the id of the foreground process group of the controlling +terminal of the process. +.tp +(9) \fiflags\fp \ %u +the kernel flags word of the process. +for bit meanings, +see the pf_* defines in the linux kernel source file +.ir include/linux/sched.h . +details depend on the kernel version. +.ip +the format for this field was %lu before linux 2.6. +.tp +(10) \fiminflt\fp \ %lu +the number of minor faults the process has made which have not +required loading a memory page from disk. +.tp +(11) \ficminflt\fp \ %lu +the number of minor faults that the process's +waited-for children have made. +.tp +(12) \fimajflt\fp \ %lu +the number of major faults the process has made which have +required loading a memory page from disk. +.tp +(13) \ficmajflt\fp \ %lu +the number of major faults that the process's +waited-for children have made. +.tp +(14) \fiutime\fp \ %lu +amount of time that this process has been scheduled in user mode, +measured in clock ticks (divide by +.ir sysconf(_sc_clk_tck) ). +this includes guest time, \figuest_time\fp +(time spent running a virtual cpu, see below), +so that applications that are not aware of the guest time field +do not lose that time from their calculations. +.tp +(15) \fistime\fp \ %lu +amount of time that this process has been scheduled in kernel mode, +measured in clock ticks (divide by +.ir sysconf(_sc_clk_tck) ). +.tp +(16) \ficutime\fp \ %ld +amount of time that this process's +waited-for children have been scheduled in user mode, +measured in clock ticks (divide by +.ir sysconf(_sc_clk_tck) ). +(see also +.br times (2).) +this includes guest time, \ficguest_time\fp +(time spent running a virtual cpu, see below). +.tp +(17) \ficstime\fp \ %ld +amount of time that this process's +waited-for children have been scheduled in kernel mode, +measured in clock ticks (divide by +.ir sysconf(_sc_clk_tck) ). +.tp +(18) \fipriority\fp \ %ld +(explanation for linux 2.6) +for processes running a real-time scheduling policy +.ri ( policy +below; see +.br sched_setscheduler (2)), +this is the negated scheduling priority, minus one; +that is, a number in the range \-2 to \-100, +corresponding to real-time priorities 1 to 99. +for processes running under a non-real-time scheduling policy, +this is the raw nice value +.rb ( setpriority (2)) +as represented in the kernel. +the kernel stores nice values as numbers +in the range 0 (high) to 39 (low), +corresponding to the user-visible nice range of \-20 to 19. +.ip +before linux 2.6, this was a scaled value based on +the scheduler weighting given to this process. +.\" and back in kernel 1.2 days things were different again. +.tp +(19) \finice\fp \ %ld +the nice value (see +.br setpriority (2)), +a value in the range 19 (low priority) to \-20 (high priority). +.\" back in kernel 1.2 days things were different. +.\" .tp +.\" \ficounter\fp %ld +.\" the current maximum size in jiffies of the process's next timeslice, +.\" or what is currently left of its current timeslice, if it is the +.\" currently running process. +.\" .tp +.\" \fitimeout\fp %u +.\" the time in jiffies of the process's next timeout. +.\" timeout was removed sometime around 2.1/2.2 +.tp +(20) \finum_threads\fp \ %ld +number of threads in this process (since linux 2.6). +before kernel 2.6, this field was hard coded to 0 as a placeholder +for an earlier removed field. +.tp +(21) \fiitrealvalue\fp \ %ld +the time in jiffies before the next +.b sigalrm +is sent to the process due to an interval timer. +since kernel 2.6.17, this field is no longer maintained, +and is hard coded as 0. +.tp +(22) \fistarttime\fp \ %llu +the time the process started after system boot. +in kernels before linux 2.6, this value was expressed in jiffies. +since linux 2.6, the value is expressed in clock ticks (divide by +.ir sysconf(_sc_clk_tck) ). +.ip +the format for this field was %lu before linux 2.6. +.tp +(23) \fivsize\fp \ %lu +virtual memory size in bytes. +.tp +(24) \firss\fp \ %ld +resident set size: number of pages the process has in real memory. +this is just the pages which +count toward text, data, or stack space. +this does not include pages +which have not been demand-loaded in, or which are swapped out. +this value is inaccurate; see +.i /proc/[pid]/statm +below. +.tp +(25) \firsslim\fp \ %lu +current soft limit in bytes on the rss of the process; +see the description of +.b rlimit_rss +in +.br getrlimit (2). +.tp +(26) \fistartcode\fp \ %lu \ [pt] +the address above which program text can run. +.tp +(27) \fiendcode\fp \ %lu \ [pt] +the address below which program text can run. +.tp +(28) \fistartstack\fp \ %lu \ [pt] +the address of the start (i.e., bottom) of the stack. +.tp +(29) \fikstkesp\fp \ %lu \ [pt] +the current value of esp (stack pointer), as found in the +kernel stack page for the process. +.tp +(30) \fikstkeip\fp \ %lu \ [pt] +the current eip (instruction pointer). +.tp +(31) \fisignal\fp \ %lu +the bitmap of pending signals, displayed as a decimal number. +obsolete, because it does not provide information on real-time signals; use +.i /proc/[pid]/status +instead. +.tp +(32) \fiblocked\fp \ %lu +the bitmap of blocked signals, displayed as a decimal number. +obsolete, because it does not provide information on real-time signals; use +.i /proc/[pid]/status +instead. +.tp +(33) \fisigignore\fp \ %lu +the bitmap of ignored signals, displayed as a decimal number. +obsolete, because it does not provide information on real-time signals; use +.i /proc/[pid]/status +instead. +.tp +(34) \fisigcatch\fp \ %lu +the bitmap of caught signals, displayed as a decimal number. +obsolete, because it does not provide information on real-time signals; use +.i /proc/[pid]/status +instead. +.tp +(35) \fiwchan\fp \ %lu \ [pt] +this is the "channel" in which the process is waiting. +it is the address of a location in the kernel where the process is sleeping. +the corresponding symbolic name can be found in +.ir /proc/[pid]/wchan . +.tp +(36) \finswap\fp \ %lu +.\" nswap was added in 2.0 +number of pages swapped (not maintained). +.tp +(37) \ficnswap\fp \ %lu +.\" cnswap was added in 2.0 +cumulative \finswap\fp for child processes (not maintained). +.tp +(38) \fiexit_signal\fp \ %d \ (since linux 2.1.22) +signal to be sent to parent when we die. +.tp +(39) \fiprocessor\fp \ %d \ (since linux 2.2.8) +cpu number last executed on. +.tp +(40) \firt_priority\fp \ %u \ (since linux 2.5.19) +real-time scheduling priority, a number in the range 1 to 99 for +processes scheduled under a real-time policy, +or 0, for non-real-time processes (see +.br sched_setscheduler (2)). +.tp +(41) \fipolicy\fp \ %u \ (since linux 2.5.19) +scheduling policy (see +.br sched_setscheduler (2)). +decode using the sched_* constants in +.ir linux/sched.h . +.ip +the format for this field was %lu before linux 2.6.22. +.tp +(42) \fidelayacct_blkio_ticks\fp \ %llu \ (since linux 2.6.18) +aggregated block i/o delays, measured in clock ticks (centiseconds). +.tp +(43) \figuest_time\fp \ %lu \ (since linux 2.6.24) +guest time of the process (time spent running a virtual cpu +for a guest operating system), measured in clock ticks (divide by +.ir sysconf(_sc_clk_tck) ). +.tp +(44) \ficguest_time\fp \ %ld \ (since linux 2.6.24) +guest time of the process's children, measured in clock ticks (divide by +.ir sysconf(_sc_clk_tck) ). +.tp +(45) \fistart_data\fp \ %lu \ (since linux 3.3) \ [pt] +.\" commit b3f7f573a20081910e34e99cbc91831f4f02f1ff +address above which program initialized and +uninitialized (bss) data are placed. +.tp +(46) \fiend_data\fp \ %lu \ (since linux 3.3) \ [pt] +.\" commit b3f7f573a20081910e34e99cbc91831f4f02f1ff +address below which program initialized and +uninitialized (bss) data are placed. +.tp +(47) \fistart_brk\fp \ %lu \ (since linux 3.3) \ [pt] +.\" commit b3f7f573a20081910e34e99cbc91831f4f02f1ff +address above which program heap can be expanded with +.br brk (2). +.tp +(48) \fiarg_start\fp \ %lu \ (since linux 3.5) \ [pt] +.\" commit 5b172087f99189416d5f47fd7ab5e6fb762a9ba3 +address above which program command-line arguments +.ri ( argv ) +are placed. +.tp +(49) \fiarg_end\fp \ %lu \ (since linux 3.5) \ [pt] +.\" commit 5b172087f99189416d5f47fd7ab5e6fb762a9ba3 +address below program command-line arguments +.ri ( argv ) +are placed. +.tp +(50) \fienv_start\fp \ %lu \ (since linux 3.5) \ [pt] +.\" commit 5b172087f99189416d5f47fd7ab5e6fb762a9ba3 +address above which program environment is placed. +.tp +(51) \fienv_end\fp \ %lu \ (since linux 3.5) \ [pt] +.\" commit 5b172087f99189416d5f47fd7ab5e6fb762a9ba3 +address below which program environment is placed. +.tp +(52) \fiexit_code\fp \ %d \ (since linux 3.5) \ [pt] +.\" commit 5b172087f99189416d5f47fd7ab5e6fb762a9ba3 +the thread's exit status in the form reported by +.br waitpid (2). +.re +.tp +.i /proc/[pid]/statm +provides information about memory usage, measured in pages. +the columns are: +.ip +.in +4n +.ex +size (1) total program size + (same as vmsize in \fi/proc/[pid]/status\fp) +resident (2) resident set size + (inaccurate; same as vmrss in \fi/proc/[pid]/status\fp) +shared (3) number of resident shared pages + (i.e., backed by a file) + (inaccurate; same as rssfile+rssshmem in + \fi/proc/[pid]/status\fp) +text (4) text (code) +.\" (not including libs; broken, includes data segment) +lib (5) library (unused since linux 2.6; always 0) +data (6) data + stack +.\" (including libs; broken, includes library text) +dt (7) dirty pages (unused since linux 2.6; always 0) +.ee +.in +.ip +.\" see split_rss_counting in the kernel. +.\" inaccuracy is bounded by task_rss_events_thresh. +some of these values are inaccurate because +of a kernel-internal scalability optimization. +if accurate values are required, use +.i /proc/[pid]/smaps +or +.i /proc/[pid]/smaps_rollup +instead, which are much slower but provide accurate, detailed information. +.tp +.i /proc/[pid]/status +provides much of the information in +.i /proc/[pid]/stat +and +.i /proc/[pid]/statm +in a format that's easier for humans to parse. +here's an example: +.ip +.in +4n +.ex +.rb "$" " cat /proc/$$/status" +name: bash +umask: 0022 +state: s (sleeping) +tgid: 17248 +ngid: 0 +pid: 17248 +ppid: 17200 +tracerpid: 0 +uid: 1000 1000 1000 1000 +gid: 100 100 100 100 +fdsize: 256 +groups: 16 33 100 +nstgid: 17248 +nspid: 17248 +nspgid: 17248 +nssid: 17200 +vmpeak: 131168 kb +vmsize: 131168 kb +vmlck: 0 kb +vmpin: 0 kb +vmhwm: 13484 kb +vmrss: 13484 kb +rssanon: 10264 kb +rssfile: 3220 kb +rssshmem: 0 kb +vmdata: 10332 kb +vmstk: 136 kb +vmexe: 992 kb +vmlib: 2104 kb +vmpte: 76 kb +vmpmd: 12 kb +vmswap: 0 kb +hugetlbpages: 0 kb # 4.4 +coredumping: 0 # 4.15 +threads: 1 +sigq: 0/3067 +sigpnd: 0000000000000000 +shdpnd: 0000000000000000 +sigblk: 0000000000010000 +sigign: 0000000000384004 +sigcgt: 000000004b813efb +capinh: 0000000000000000 +capprm: 0000000000000000 +capeff: 0000000000000000 +capbnd: ffffffffffffffff +capamb: 0000000000000000 +nonewprivs: 0 +seccomp: 0 +speculation_store_bypass: vulnerable +cpus_allowed: 00000001 +cpus_allowed_list: 0 +mems_allowed: 1 +mems_allowed_list: 0 +voluntary_ctxt_switches: 150 +nonvoluntary_ctxt_switches: 545 +.ee +.in +.ip +the fields are as follows: +.rs +.tp +.ir name +command run by this process. +strings longer than +.b task_comm_len +(16) characters (including the terminating null byte) are silently truncated. +.tp +.ir umask +process umask, expressed in octal with a leading zero; see +.br umask (2). +(since linux 4.7.) +.tp +.ir state +current state of the process. +one of +"r (running)", +"s (sleeping)", +"d (disk sleep)", +"t (stopped)", +"t (tracing stop)", +"z (zombie)", +or +"x (dead)". +.tp +.ir tgid +thread group id (i.e., process id). +.tp +.ir ngid +numa group id (0 if none; since linux 3.13). +.tp +.ir pid +thread id (see +.br gettid (2)). +.tp +.ir ppid +pid of parent process. +.tp +.ir tracerpid +pid of process tracing this process (0 if not being traced). +.tp +.ir uid ", " gid +real, effective, saved set, and filesystem uids (gids). +.tp +.ir fdsize +number of file descriptor slots currently allocated. +.tp +.ir groups +supplementary group list. +.tp +.ir nstgid +thread group id (i.e., pid) in each of the pid namespaces of which +.i [pid] +is a member. +the leftmost entry shows the value with respect to the pid namespace +of the process that mounted this procfs (or the root namespace +if mounted by the kernel), +followed by the value in successively nested inner namespaces. +.\" commit e4bc33245124db69b74a6d853ac76c2976f472d5 +(since linux 4.1.) +.tp +.ir nspid +thread id in each of the pid namespaces of which +.i [pid] +is a member. +the fields are ordered as for +.ir nstgid . +(since linux 4.1.) +.tp +.ir nspgid +process group id in each of the pid namespaces of which +.i [pid] +is a member. +the fields are ordered as for +.ir nstgid . +(since linux 4.1.) +.tp +.ir nssid +descendant namespace session id hierarchy +session id in each of the pid namespaces of which +.i [pid] +is a member. +the fields are ordered as for +.ir nstgid . +(since linux 4.1.) +.tp +.ir vmpeak +peak virtual memory size. +.tp +.ir vmsize +virtual memory size. +.tp +.ir vmlck +locked memory size (see +.br mlock (2)). +.tp +.ir vmpin +pinned memory size +.\" commit bc3e53f682d93df677dbd5006a404722b3adfe18 +(since linux 3.2). +these are pages that can't be moved because something needs to +directly access physical memory. +.tp +.ir vmhwm +peak resident set size ("high water mark"). +this value is inaccurate; see +.i /proc/[pid]/statm +above. +.tp +.ir vmrss +resident set size. +note that the value here is the sum of +.ir rssanon , +.ir rssfile , +and +.ir rssshmem . +this value is inaccurate; see +.i /proc/[pid]/statm +above. +.tp +.ir rssanon +size of resident anonymous memory. +.\" commit bf9683d6990589390b5178dafe8fd06808869293 +(since linux 4.5). +this value is inaccurate; see +.i /proc/[pid]/statm +above. +.tp +.ir rssfile +size of resident file mappings. +.\" commit bf9683d6990589390b5178dafe8fd06808869293 +(since linux 4.5). +this value is inaccurate; see +.i /proc/[pid]/statm +above. +.tp +.ir rssshmem +size of resident shared memory (includes system v shared memory, +mappings from +.br tmpfs (5), +and shared anonymous mappings). +.\" commit bf9683d6990589390b5178dafe8fd06808869293 +(since linux 4.5). +.tp +.ir vmdata ", " vmstk ", " vmexe +size of data, stack, and text segments. +this value is inaccurate; see +.i /proc/[pid]/statm +above. +.tp +.ir vmlib +shared library code size. +.tp +.ir vmpte +page table entries size (since linux 2.6.10). +.tp +.ir vmpmd +.\" commit dc6c9a35b66b520cf67e05d8ca60ebecad3b0479 +size of second-level page tables (added in linux 4.0; removed in linux 4.15). +.tp +.ir vmswap +.\" commit b084d4353ff99d824d3bc5a5c2c22c70b1fba722 +swapped-out virtual memory size by anonymous private pages; +shmem swap usage is not included (since linux 2.6.34). +this value is inaccurate; see +.i /proc/[pid]/statm +above. +.tp +.ir hugetlbpages +size of hugetlb memory portions +.\" commit 5d317b2b6536592a9b51fe65faed43d65ca9158e +(since linux 4.4). +.tp +.ir coredumping +contains the value 1 if the process is currently dumping core, +and 0 if it is not +.\" commit c643401218be0f4ab3522e0c0a63016596d6e9ca +(since linux 4.15). +this information can be used by a monitoring process to avoid killing +a process that is currently dumping core, +which could result in a corrupted core dump file. +.tp +.ir threads +number of threads in process containing this thread. +.tp +.ir sigq +this field contains two slash-separated numbers that relate to +queued signals for the real user id of this process. +the first of these is the number of currently queued +signals for this real user id, and the second is the +resource limit on the number of queued signals for this process +(see the description of +.br rlimit_sigpending +in +.br getrlimit (2)). +.tp +.ir sigpnd ", " shdpnd +mask (expressed in hexadecimal) +of signals pending for thread and for process as a whole (see +.br pthreads (7) +and +.br signal (7)). +.tp +.ir sigblk ", " sigign ", " sigcgt +masks (expressed in hexadecimal) +indicating signals being blocked, ignored, and caught (see +.br signal (7)). +.tp +.ir capinh ", " capprm ", " capeff +masks (expressed in hexadecimal) +of capabilities enabled in inheritable, permitted, and effective sets +(see +.br capabilities (7)). +.tp +.ir capbnd +capability bounding set, expressed in hexadecimal +(since linux 2.6.26, see +.br capabilities (7)). +.tp +.ir capamb +ambient capability set, expressed in hexadecimal +(since linux 4.3, see +.br capabilities (7)). +.tp +.ir nonewprivs +.\" commit af884cd4a5ae62fcf5e321fecf0ec1014730353d +value of the +.i no_new_privs +bit +(since linux 4.10, see +.br prctl (2)). +.tp +.ir seccomp +.\" commit 2f4b3bf6b2318cfaa177ec5a802f4d8d6afbd816 +seccomp mode of the process +(since linux 3.8, see +.br seccomp (2)). +0 means +.br seccomp_mode_disabled ; +1 means +.br seccomp_mode_strict ; +2 means +.br seccomp_mode_filter . +this field is provided only if the kernel was built with the +.br config_seccomp +kernel configuration option enabled. +.tp +.ir speculation_store_bypass +.\" commit fae1fa0fc6cca8beee3ab8ed71d54f9a78fa3f64 +speculation flaw mitigation state +(since linux 4.17, see +.br prctl (2)). +.tp +.ir cpus_allowed +hexadecimal mask of cpus on which this process may run +(since linux 2.6.24, see +.br cpuset (7)). +.tp +.ir cpus_allowed_list +same as previous, but in "list format" +(since linux 2.6.26, see +.br cpuset (7)). +.tp +.ir mems_allowed +mask of memory nodes allowed to this process +(since linux 2.6.24, see +.br cpuset (7)). +.tp +.ir mems_allowed_list +same as previous, but in "list format" +(since linux 2.6.26, see +.br cpuset (7)). +.tp +.ir voluntary_ctxt_switches ", " nonvoluntary_ctxt_switches +number of voluntary and involuntary context switches (since linux 2.6.23). +.re +.tp +.ir /proc/[pid]/syscall " (since linux 2.6.27)" +.\" commit ebcb67341fee34061430f3367f2e507e52ee051b +this file exposes the system call number and argument registers for the +system call currently being executed by the process, +followed by the values of the stack pointer and program counter registers. +the values of all six argument registers are exposed, +although most system calls use fewer registers. +.ip +if the process is blocked, but not in a system call, +then the file displays \-1 in place of the system call number, +followed by just the values of the stack pointer and program counter. +if process is not blocked, then the file contains just the string "running". +.ip +this file is present only if the kernel was configured with +.br config_have_arch_tracehook . +.ip +permission to access this file is governed by a ptrace access mode +.b ptrace_mode_attach_fscreds +check; see +.br ptrace (2). +.tp +.ir /proc/[pid]/task " (since linux 2.6.0)" +.\" precisely: linux 2.6.0-test6 +this is a directory that contains one subdirectory +for each thread in the process. +the name of each subdirectory is the numerical thread id +.ri ( [tid] ) +of the thread (see +.br gettid (2)). +.ip +within each of these subdirectories, there is a set of +files with the same names and contents as under the +.i /proc/[pid] +directories. +for attributes that are shared by all threads, the contents for +each of the files under the +.i task/[tid] +subdirectories will be the same as in the corresponding +file in the parent +.i /proc/[pid] +directory +(e.g., in a multithreaded process, all of the +.i task/[tid]/cwd +files will have the same value as the +.i /proc/[pid]/cwd +file in the parent directory, since all of the threads in a process +share a working directory). +for attributes that are distinct for each thread, +the corresponding files under +.i task/[tid] +may have different values (e.g., various fields in each of the +.i task/[tid]/status +files may be different for each thread), +.\" in particular: "children" :/ +or they might not exist in +.i /proc/[pid] +at all. +.ip +.\" the following was still true as at kernel 2.6.13 +in a multithreaded process, the contents of the +.i /proc/[pid]/task +directory are not available if the main thread has already terminated +(typically by calling +.br pthread_exit (3)). +.tp +.ir /proc/[pid]/task/[tid]/children " (since linux 3.5)" +.\" commit 818411616baf46ceba0cff6f05af3a9b294734f7 +a space-separated list of child tasks of this task. +each child task is represented by its tid. +.ip +.\" see comments in get_children_pid() in fs/proc/array.c +this option is intended for use by the checkpoint-restore (criu) system, +and reliably provides a list of children only if all of the child processes +are stopped or frozen. +it does not work properly if children of the target task exit while +the file is being read! +exiting children may cause non-exiting children to be omitted from the list. +this makes this interface even more unreliable than classic pid-based +approaches if the inspected task and its children aren't frozen, +and most code should probably not use this interface. +.ip +until linux 4.2, the presence of this file was governed by the +.b config_checkpoint_restore +kernel configuration option. +since linux 4.2, +.\" commit 2e13ba54a2682eea24918b87ad3edf70c2cf085b +it is governed by the +.b config_proc_children +option. +.tp +.ir /proc/[pid]/timers " (since linux 3.10)" +.\" commit 5ed67f05f66c41e39880a6d61358438a25f9fee5 +.\" commit 48f6a7a511ef8823fdff39afee0320092d43a8a0 +a list of the posix timers for this process. +each timer is listed with a line that starts with the string "id:". +for example: +.ip +.in +4n +.ex +id: 1 +signal: 60/00007fff86e452a8 +notify: signal/pid.2634 +clockid: 0 +id: 0 +signal: 60/00007fff86e452a8 +notify: signal/pid.2634 +clockid: 1 +.ee +.in +.ip +the lines shown for each timer have the following meanings: +.rs +.tp +.i id +the id for this timer. +this is not the same as the timer id returned by +.br timer_create (2); +rather, it is the same kernel-internal id that is available via the +.i si_timerid +field of the +.ir siginfo_t +structure (see +.br sigaction (2)). +.tp +.i signal +this is the signal number that this timer uses to deliver notifications +followed by a slash, and then the +.i sigev_value +value supplied to the signal handler. +valid only for timers that notify via a signal. +.tp +.i notify +the part before the slash specifies the mechanism +that this timer uses to deliver notifications, +and is one of "thread", "signal", or "none". +immediately following the slash is either the string "tid" for timers +with +.b sigev_thread_id +notification, or "pid" for timers that notify by other mechanisms. +following the "." is the pid of the process +(or the kernel thread id of the thread) that will be delivered +a signal if the timer delivers notifications via a signal. +.tp +.i clockid +this field identifies the clock that the timer uses for measuring time. +for most clocks, this is a number that matches one of the user-space +.br clock_* +constants exposed via +.ir . +.b clock_process_cputime_id +timers display with a value of \-6 +in this field. +.b clock_thread_cputime_id +timers display with a value of \-2 +in this field. +.re +.ip +this file is available only when the kernel was configured with +.br config_checkpoint_restore . +.tp +.ir /proc/[pid]/timerslack_ns " (since linux 4.6)" +.\" commit da8b44d5a9f8bf26da637b7336508ca534d6b319 +.\" commit 5de23d435e88996b1efe0e2cebe242074ce67c9e +this file exposes the process's "current" timer slack value, +expressed in nanoseconds. +the file is writable, +allowing the process's timer slack value to be changed. +writing 0 to this file resets the "current" timer slack to the +"default" timer slack value. +for further details, see the discussion of +.br pr_set_timerslack +in +.br prctl (2). +.ip +initially, +permission to access this file was governed by a ptrace access mode +.b ptrace_mode_attach_fscreds +check (see +.br ptrace (2)). +however, this was subsequently deemed too strict a requirement +(and had the side effect that requiring a process to have the +.b cap_sys_ptrace +capability would also allow it to view and change any process's memory). +therefore, since linux 4.9, +.\" commit 7abbaf94049914f074306d960b0f968ffe52e59f +only the (weaker) +.b cap_sys_nice +capability is required to access this file. +.tp +.ir /proc/[pid]/uid_map " (since linux 3.5)" +see +.br user_namespaces (7). +.tp +.ir /proc/[pid]/wchan " (since linux 2.6.0)" +the symbolic name corresponding to the location +in the kernel where the process is sleeping. +.ip +permission to access this file is governed by a ptrace access mode +.b ptrace_mode_read_fscreds +check; see +.br ptrace (2). +.tp +.ir /proc/[tid] +there is a numerical subdirectory for each running thread +that is not a thread group leader +(i.e., a thread whose thread id is not the same as its process id); +the subdirectory is named by the thread id. +each one of these subdirectories contains files and subdirectories +exposing information about the thread with the thread id +.ir tid . +the contents of these directories are the same as the corresponding +.ir /proc/[pid]/task/[tid] +directories. +.ip +the +.i /proc/[tid] +subdirectories are +.i not +visible when iterating through +.i /proc +with +.br getdents (2) +(and thus are +.i not +visible when one uses +.br ls (1) +to view the contents of +.ir /proc ). +however, the pathnames of these directories are visible to +(i.e., usable as arguments in) +system calls that operate on pathnames. +.tp +.i /proc/apm +advanced power management version and battery information when +.b config_apm +is defined at kernel compilation time. +.tp +.i /proc/buddyinfo +this file contains information which is used for diagnosing memory +fragmentation issues. +each line starts with the identification of the node and the name +of the zone which together identify a memory region. +this is then +followed by the count of available chunks of a certain order in +which these zones are split. +the size in bytes of a certain order is given by the formula: +.ip + (2^order)\ *\ page_size +.ip +the binary buddy allocator algorithm inside the kernel will split +one chunk into two chunks of a smaller order (thus with half the +size) or combine two contiguous chunks into one larger chunk of +a higher order (thus with double the size) to satisfy allocation +requests and to counter memory fragmentation. +the order matches the column number, when starting to count at zero. +.ip +for example on an x86-64 system: +.rs -12 +.ex +node 0, zone dma 1 1 1 0 2 1 1 0 1 1 3 +node 0, zone dma32 65 47 4 81 52 28 13 10 5 1 404 +node 0, zone normal 216 55 189 101 84 38 37 27 5 3 587 +.ee +.re +.ip +in this example, there is one node containing three zones and there +are 11 different chunk sizes. +if the page size is 4 kilobytes, then the first zone called +.i dma +(on x86 the first 16 megabyte of memory) has 1 chunk of 4 kilobytes +(order 0) available and has 3 chunks of 4 megabytes (order 10) available. +.ip +if the memory is heavily fragmented, the counters for higher +order chunks will be zero and allocation of large contiguous areas +will fail. +.ip +further information about the zones can be found in +.ir /proc/zoneinfo . +.tp +.i /proc/bus +contains subdirectories for installed busses. +.tp +.i /proc/bus/pccard +subdirectory for pcmcia devices when +.b config_pcmcia +is set at kernel compilation time. +.tp +.i /proc/bus/pccard/drivers +.tp +.i /proc/bus/pci +contains various bus subdirectories and pseudo-files containing +information about pci busses, installed devices, and device +drivers. +some of these files are not ascii. +.tp +.i /proc/bus/pci/devices +information about pci devices. +they may be accessed through +.br lspci (8) +and +.br setpci (8). +.tp +.ir /proc/cgroups " (since linux 2.6.24)" +see +.br cgroups (7). +.tp +.i /proc/cmdline +arguments passed to the linux kernel at boot time. +often done via a boot manager such as +.br lilo (8) +or +.br grub (8). +.tp +.ir /proc/config.gz " (since linux 2.6)" +this file exposes the configuration options that were used +to build the currently running kernel, +in the same format as they would be shown in the +.i .config +file that resulted when configuring the kernel (using +.ir "make xconfig" , +.ir "make config" , +or similar). +the file contents are compressed; view or search them using +.br zcat (1) +and +.br zgrep (1). +as long as no changes have been made to the following file, +the contents of +.i /proc/config.gz +are the same as those provided by: +.ip +.in +4n +.ex +cat /lib/modules/$(uname \-r)/build/.config +.ee +.in +.ip +.i /proc/config.gz +is provided only if the kernel is configured with +.br config_ikconfig_proc . +.tp +.i /proc/crypto +a list of the ciphers provided by the kernel crypto api. +for details, see the kernel +.i "linux kernel crypto api" +documentation available under the kernel source directory +.i documentation/crypto/ +.\" commit 3b72c814a8e8cd638e1ba0da4dfce501e9dff5af +(or +.i documentation/docbook +before 4.10; +the documentation can be built using a command such as +.ir "make htmldocs" +in the root directory of the kernel source tree). +.tp +.i /proc/cpuinfo +this is a collection of cpu and system architecture dependent items, +for each supported architecture a different list. +two common entries are \fiprocessor\fp which gives cpu number and +\fibogomips\fp; a system constant that is calculated +during kernel initialization. +smp machines have information for +each cpu. +the +.br lscpu (1) +command gathers its information from this file. +.tp +.i /proc/devices +text listing of major numbers and device groups. +this can be used by makedev scripts for consistency with the kernel. +.tp +.ir /proc/diskstats " (since linux 2.5.69)" +this file contains disk i/o statistics for each disk device. +see the linux kernel source file +.i documentation/iostats.txt +for further information. +.tp +.i /proc/dma +this is a list of the registered \fiisa\fp dma (direct memory access) +channels in use. +.tp +.i /proc/driver +empty subdirectory. +.tp +.i /proc/execdomains +list of the execution domains (abi personalities). +.tp +.i /proc/fb +frame buffer information when +.b config_fb +is defined during kernel compilation. +.tp +.i /proc/filesystems +a text listing of the filesystems which are supported by the kernel, +namely filesystems which were compiled into the kernel or whose kernel +modules are currently loaded. +(see also +.br filesystems (5).) +if a filesystem is marked with "nodev", +this means that it does not require a block device to be mounted +(e.g., virtual filesystem, network filesystem). +.ip +incidentally, this file may be used by +.br mount (8) +when no filesystem is specified and it didn't manage to determine the +filesystem type. +then filesystems contained in this file are tried +(excepted those that are marked with "nodev"). +.tp +.i /proc/fs +.\" fixme much more needs to be said about /proc/fs +.\" +contains subdirectories that in turn contain files +with information about (certain) mounted filesystems. +.tp +.i /proc/ide +this directory +exists on systems with the ide bus. +there are directories for each ide channel and attached device. +files include: +.ip +.in +4n +.ex +cache buffer size in kb +capacity number of sectors +driver driver version +geometry physical and logical geometry +identify in hexadecimal +media media type +model manufacturer\(aqs model number +settings drive settings +smart_thresholds ide disk management thresholds (in hex) +smart_values ide disk management values (in hex) +.ee +.in +.ip +the +.br hdparm (8) +utility provides access to this information in a friendly format. +.tp +.i /proc/interrupts +this is used to record the number of interrupts per cpu per io device. +since linux 2.6.24, +for the i386 and x86-64 architectures, at least, this also includes +interrupts internal to the system (that is, not associated with a device +as such), such as nmi (nonmaskable interrupt), loc (local timer interrupt), +and for smp systems, tlb (tlb flush interrupt), res (rescheduling +interrupt), cal (remote function call interrupt), and possibly others. +very easy to read formatting, done in ascii. +.tp +.i /proc/iomem +i/o memory map in linux 2.4. +.tp +.i /proc/ioports +this is a list of currently registered input-output port regions that +are in use. +.tp +.ir /proc/kallsyms " (since linux 2.5.71)" +this holds the kernel exported symbol definitions used by the +.br modules (x) +tools to dynamically link and bind loadable modules. +in linux 2.5.47 and earlier, a similar file with slightly different syntax +was named +.ir ksyms . +.tp +.i /proc/kcore +this file represents the physical memory of the system and is stored +in the elf core file format. +with this pseudo-file, and an unstripped +kernel +.ri ( /usr/src/linux/vmlinux ) +binary, gdb can be used to +examine the current state of any kernel data structures. +.ip +the total length of the file is the size of physical memory (ram) plus +4\ kib. +.tp +.ir /proc/keys " (since linux 2.6.10)" +see +.br keyrings (7). +.tp +.ir /proc/key\-users " (since linux 2.6.10)" +see +.br keyrings (7). +.tp +.i /proc/kmsg +this file can be used instead of the +.br syslog (2) +system call to read kernel messages. +a process must have superuser +privileges to read this file, and only one process should read this +file. +this file should not be read if a syslog process is running +which uses the +.br syslog (2) +system call facility to log kernel messages. +.ip +information in this file is retrieved with the +.br dmesg (1) +program. +.tp +.ir /proc/kpagecgroup " (since linux 4.3)" +.\" commit 80ae2fdceba8313b0433f899bdd9c6c463291a17 +this file contains a 64-bit inode number of +the memory cgroup each page is charged to, +indexed by page frame number (see the discussion of +.ir /proc/[pid]/pagemap ). +.ip +the +.ir /proc/kpagecgroup +file is present only if the +.b config_memcg +kernel configuration option is enabled. +.tp +.ir /proc/kpagecount " (since linux 2.6.25)" +this file contains a 64-bit count of the number of +times each physical page frame is mapped, +indexed by page frame number (see the discussion of +.ir /proc/[pid]/pagemap ). +.ip +the +.ir /proc/kpagecount +file is present only if the +.b config_proc_page_monitor +kernel configuration option is enabled. +.tp +.ir /proc/kpageflags " (since linux 2.6.25)" +this file contains 64-bit masks corresponding to each physical page frame; +it is indexed by page frame number (see the discussion of +.ir /proc/[pid]/pagemap ). +the bits are as follows: +.ip + 0 - kpf_locked + 1 - kpf_error + 2 - kpf_referenced + 3 - kpf_uptodate + 4 - kpf_dirty + 5 - kpf_lru + 6 - kpf_active + 7 - kpf_slab + 8 - kpf_writeback + 9 - kpf_reclaim + 10 - kpf_buddy + 11 - kpf_mmap (since linux 2.6.31) + 12 - kpf_anon (since linux 2.6.31) + 13 - kpf_swapcache (since linux 2.6.31) + 14 - kpf_swapbacked (since linux 2.6.31) + 15 - kpf_compound_head (since linux 2.6.31) + 16 - kpf_compound_tail (since linux 2.6.31) + 17 - kpf_huge (since linux 2.6.31) + 18 - kpf_unevictable (since linux 2.6.31) + 19 - kpf_hwpoison (since linux 2.6.31) + 20 - kpf_nopage (since linux 2.6.31) + 21 - kpf_ksm (since linux 2.6.32) + 22 - kpf_thp (since linux 3.4) + 23 - kpf_balloon (since linux 3.18) +.\" kpf_balloon: commit 09316c09dde33aae14f34489d9e3d243ec0d5938 + 24 - kpf_zero_page (since linux 4.0) +.\" kpf_zero_page: commit 56873f43abdcd574b25105867a990f067747b2f4 + 25 - kpf_idle (since linux 4.3) +.\" kpf_idle: commit f074a8f49eb87cde95ac9d040ad5e7ea4f029738 +.ip +for further details on the meanings of these bits, +see the kernel source file +.ir documentation/admin\-guide/mm/pagemap.rst . +before kernel 2.6.29, +.\" commit ad3bdefe877afb47480418fdb05ecd42842de65e +.\" commit e07a4b9217d1e97d2f3a62b6b070efdc61212110 +.br kpf_writeback , +.br kpf_reclaim , +.br kpf_buddy , +and +.br kpf_locked +did not report correctly. +.ip +the +.ir /proc/kpageflags +file is present only if the +.b config_proc_page_monitor +kernel configuration option is enabled. +.tp +.ir /proc/ksyms " (linux 1.1.23\(en2.5.47)" +see +.ir /proc/kallsyms . +.tp +.i /proc/loadavg +the first three fields in this file are load average figures +giving the number of jobs in the run queue (state r) +or waiting for disk i/o (state d) averaged over 1, 5, and 15 minutes. +they are the same as the load average numbers given by +.br uptime (1) +and other programs. +the fourth field consists of two numbers separated by a slash (/). +the first of these is the number of currently runnable kernel +scheduling entities (processes, threads). +the value after the slash is the number of kernel scheduling entities +that currently exist on the system. +the fifth field is the pid of the process that was most +recently created on the system. +.tp +.i /proc/locks +this file shows current file locks +.rb ( flock "(2) and " fcntl (2)) +and leases +.rb ( fcntl (2)). +.ip +an example of the content shown in this file is the following: +.ip +.in +4n +.ex +1: posix advisory read 5433 08:01:7864448 128 128 +2: flock advisory write 2001 08:01:7864554 0 eof +3: flock advisory write 1568 00:2f:32388 0 eof +4: posix advisory write 699 00:16:28457 0 eof +5: posix advisory write 764 00:16:21448 0 0 +6: posix advisory read 3548 08:01:7867240 1 1 +7: posix advisory read 3548 08:01:7865567 1826 2335 +8: ofdlck advisory write \-1 08:01:8713209 128 191 +.ee +.in +.ip +the fields shown in each line are as follows: +.rs +.ip (1) 4 +the ordinal position of the lock in the list. +.ip (2) +the lock type. +values that may appear here include: +.rs +.tp +.b flock +this is a bsd file lock created using +.br flock (2). +.tp +.b ofdlck +this is an open file description (ofd) lock created using +.br fcntl (2). +.tp +.b posix +this is a posix byte-range lock created using +.br fcntl (2). +.re +.ip (3) +among the strings that can appear here are the following: +.rs +.tp +.b advisory +this is an advisory lock. +.tp +.b mandatory +this is a mandatory lock. +.re +.ip (4) +the type of lock. +values that can appear here are: +.rs +.tp +.b read +this is a posix or ofd read lock, or a bsd shared lock. +.tp +.b write +this is a posix or ofd write lock, or a bsd exclusive lock. +.re +.ip (5) +the pid of the process that owns the lock. +.ip +because ofd locks are not owned by a single process +(since multiple processes may have file descriptors that +refer to the same open file description), +the value \-1 is displayed in this field for ofd locks. +(before kernel 4.14, +.\" commit 9d5b86ac13c573795525ecac6ed2db39ab23e2a8 +a bug meant that the pid of the process that +initially acquired the lock was displayed instead of the value \-1.) +.ip (6) +three colon-separated subfields that identify the major and minor device +id of the device containing the filesystem where the locked file resides, +followed by the inode number of the locked file. +.ip (7) +the byte offset of the first byte of the lock. +for bsd locks, this value is always 0. +.ip (8) +the byte offset of the last byte of the lock. +.b eof +in this field means that the lock extends to the end of the file. +for bsd locks, the value shown is always +.ir eof . +.re +.ip +since linux 4.9, +.\" commit d67fd44f697dff293d7cdc29af929241b669affe +the list of locks shown in +.i /proc/locks +is filtered to show just the locks for the processes in the pid +namespace (see +.br pid_namespaces (7)) +for which the +.i /proc +filesystem was mounted. +(in the initial pid namespace, +there is no filtering of the records shown in this file.) +.ip +the +.br lslocks (8) +command provides a bit more information about each lock. +.tp +.ir /proc/malloc " (only up to and including linux 2.2)" +.\" it looks like this only ever did something back in 1.0 days +this file is present only if +.b config_debug_malloc +was defined during compilation. +.tp +.i /proc/meminfo +this file reports statistics about memory usage on the system. +it is used by +.br free (1) +to report the amount of free and used memory (both physical and swap) +on the system as well as the shared memory and buffers used by the +kernel. +each line of the file consists of a parameter name, followed by a colon, +the value of the parameter, and an option unit of measurement (e.g., "kb"). +the list below describes the parameter names and +the format specifier required to read the field value. +except as noted below, +all of the fields have been present since at least linux 2.6.0. +some fields are displayed only if the kernel was configured +with various options; those dependencies are noted in the list. +.rs +.tp +.ir memtotal " %lu" +total usable ram (i.e., physical ram minus a few reserved +bits and the kernel binary code). +.tp +.ir memfree " %lu" +the sum of +.ir lowfree + highfree . +.tp +.ir memavailable " %lu (since linux 3.14)" +an estimate of how much memory is available for starting new +applications, without swapping. +.tp +.ir buffers " %lu" +relatively temporary storage for raw disk blocks that +shouldn't get tremendously large (20 mb or so). +.tp +.ir cached " %lu" +in-memory cache for files read from the disk (the page cache). +doesn't include +.ir swapcached . +.tp +.ir swapcached " %lu" +memory that once was swapped out, is swapped back in but +still also is in the swap file. +(if memory pressure is high, these pages +don't need to be swapped out again because they are already +in the swap file. +this saves i/o.) +.tp +.ir active " %lu" +memory that has been used more recently and usually not +reclaimed unless absolutely necessary. +.tp +.ir inactive " %lu" +memory which has been less recently used. +it is more eligible to be reclaimed for other purposes. +.tp +.ir active(anon) " %lu (since linux 2.6.28)" +[to be documented.] +.tp +.ir inactive(anon) " %lu (since linux 2.6.28)" +[to be documented.] +.tp +.ir active(file) " %lu (since linux 2.6.28)" +[to be documented.] +.tp +.ir inactive(file) " %lu (since linux 2.6.28)" +[to be documented.] +.tp +.ir unevictable " %lu (since linux 2.6.28)" +(from linux 2.6.28 to 2.6.30, +\fbconfig_unevictable_lru\fp was required.) +[to be documented.] +.tp +.ir mlocked " %lu (since linux 2.6.28)" +(from linux 2.6.28 to 2.6.30, +\fbconfig_unevictable_lru\fp was required.) +[to be documented.] +.tp +.ir hightotal " %lu" +(starting with linux 2.6.19, \fbconfig_highmem\fp is required.) +total amount of highmem. +highmem is all memory above \(ti860 mb of physical memory. +highmem areas are for use by user-space programs, +or for the page cache. +the kernel must use tricks to access +this memory, making it slower to access than lowmem. +.tp +.ir highfree " %lu" +(starting with linux 2.6.19, \fbconfig_highmem\fp is required.) +amount of free highmem. +.tp +.ir lowtotal " %lu" +(starting with linux 2.6.19, \fbconfig_highmem\fp is required.) +total amount of lowmem. +lowmem is memory which can be used for everything that +highmem can be used for, but it is also available for the +kernel's use for its own data structures. +among many other things, +it is where everything from +.i slab +is allocated. +bad things happen when you're out of lowmem. +.tp +.ir lowfree " %lu" +(starting with linux 2.6.19, \fbconfig_highmem\fp is required.) +amount of free lowmem. +.tp +.ir mmapcopy " %lu (since linux 2.6.29)" +.rb ( config_mmu +is required.) +[to be documented.] +.tp +.ir swaptotal " %lu" +total amount of swap space available. +.tp +.ir swapfree " %lu" +amount of swap space that is currently unused. +.tp +.ir dirty " %lu" +memory which is waiting to get written back to the disk. +.tp +.ir writeback " %lu" +memory which is actively being written back to the disk. +.tp +.ir anonpages " %lu (since linux 2.6.18)" +non-file backed pages mapped into user-space page tables. +.tp +.ir mapped " %lu" +files which have been mapped into memory (with +.br mmap (2)), +such as libraries. +.tp +.ir shmem " %lu (since linux 2.6.32)" +amount of memory consumed in +.br tmpfs (5) +filesystems. +.tp +.ir kreclaimable " %lu (since linux 4.20)" +kernel allocations that the kernel will attempt to reclaim +under memory pressure. +includes +.i sreclaimable +(below), and other direct allocations with a shrinker. +.tp +.ir slab " %lu" +in-kernel data structures cache. +(see +.br slabinfo (5).) +.tp +.ir sreclaimable " %lu (since linux 2.6.19)" +part of +.ir slab , +that might be reclaimed, such as caches. +.tp +.ir sunreclaim " %lu (since linux 2.6.19)" +part of +.ir slab , +that cannot be reclaimed on memory pressure. +.tp +.ir kernelstack " %lu (since linux 2.6.32)" +amount of memory allocated to kernel stacks. +.tp +.ir pagetables " %lu (since linux 2.6.18)" +amount of memory dedicated to the lowest level of page tables. +.tp +.ir quicklists " %lu (since linux 2.6.27)" +(\fbconfig_quicklist\fp is required.) +[to be documented.] +.tp +.ir nfs_unstable " %lu (since linux 2.6.18)" +nfs pages sent to the server, but not yet committed to stable storage. +.tp +.ir bounce " %lu (since linux 2.6.18)" +memory used for block device "bounce buffers". +.tp +.ir writebacktmp " %lu (since linux 2.6.26)" +memory used by fuse for temporary writeback buffers. +.tp +.ir commitlimit " %lu (since linux 2.6.10)" +this is the total amount of memory currently available to +be allocated on the system, expressed in kilobytes. +this limit is adhered to +only if strict overcommit accounting is enabled (mode 2 in +.ir /proc/sys/vm/overcommit_memory ). +the limit is calculated according to the formula described under +.ir /proc/sys/vm/overcommit_memory . +for further details, see the kernel source file +.ir documentation/vm/overcommit\-accounting.rst . +.tp +.ir committed_as " %lu" +the amount of memory presently allocated on the system. +the committed memory is a sum of all of the memory which +has been allocated by processes, even if it has not been +"used" by them as of yet. +a process which allocates 1 gb of memory (using +.br malloc (3) +or similar), but touches only 300 mb of that memory will show up +as using only 300 mb of memory even if it has the address space +allocated for the entire 1 gb. +.ip +this 1 gb is memory which has been "committed" to by the vm +and can be used at any time by the allocating application. +with strict overcommit enabled on the system (mode 2 in +.ir /proc/sys/vm/overcommit_memory ), +allocations which would exceed the +.i commitlimit +will not be permitted. +this is useful if one needs to guarantee that processes will not +fail due to lack of memory once that memory has been successfully allocated. +.tp +.ir vmalloctotal " %lu" +total size of vmalloc memory area. +.tp +.ir vmallocused " %lu" +amount of vmalloc area which is used. +since linux 4.4, +.\" commit a5ad88ce8c7fae7ddc72ee49a11a75aa837788e0 +this field is no longer calculated, and is hard coded as 0. +see +.ir /proc/vmallocinfo . +.tp +.ir vmallocchunk " %lu" +largest contiguous block of vmalloc area which is free. +since linux 4.4, +.\" commit a5ad88ce8c7fae7ddc72ee49a11a75aa837788e0 +this field is no longer calculated and is hard coded as 0. +see +.ir /proc/vmallocinfo . +.tp +.ir hardwarecorrupted " %lu (since linux 2.6.32)" +(\fbconfig_memory_failure\fp is required.) +[to be documented.] +.tp +.ir lazyfree " %lu (since linux 4.12)" +shows the amount of memory marked by +.br madvise (2) +.br madv_free . +.tp +.ir anonhugepages " %lu (since linux 2.6.38)" +(\fbconfig_transparent_hugepage\fp is required.) +non-file backed huge pages mapped into user-space page tables. +.tp +.ir shmemhugepages " %lu (since linux 4.8)" +(\fbconfig_transparent_hugepage\fp is required.) +memory used by shared memory (shmem) and +.br tmpfs (5) +allocated with huge pages. +.tp +.ir shmempmdmapped " %lu (since linux 4.8)" +(\fbconfig_transparent_hugepage\fp is required.) +shared memory mapped into user space with huge pages. +.tp +.ir cmatotal " %lu (since linux 3.1)" +total cma (contiguous memory allocator) pages. +(\fbconfig_cma\fp is required.) +.tp +.ir cmafree " %lu (since linux 3.1)" +free cma (contiguous memory allocator) pages. +(\fbconfig_cma\fp is required.) +.tp +.ir hugepages_total " %lu" +(\fbconfig_hugetlb_page\fp is required.) +the size of the pool of huge pages. +.tp +.ir hugepages_free " %lu" +(\fbconfig_hugetlb_page\fp is required.) +the number of huge pages in the pool that are not yet allocated. +.tp +.ir hugepages_rsvd " %lu (since linux 2.6.17)" +(\fbconfig_hugetlb_page\fp is required.) +this is the number of huge pages for +which a commitment to allocate from the pool has been made, +but no allocation has yet been made. +these reserved huge pages +guarantee that an application will be able to allocate a +huge page from the pool of huge pages at fault time. +.tp +.ir hugepages_surp " %lu (since linux 2.6.24)" +(\fbconfig_hugetlb_page\fp is required.) +this is the number of huge pages in +the pool above the value in +.ir /proc/sys/vm/nr_hugepages . +the maximum number of surplus huge pages is controlled by +.ir /proc/sys/vm/nr_overcommit_hugepages . +.tp +.ir hugepagesize " %lu" +(\fbconfig_hugetlb_page\fp is required.) +the size of huge pages. +.tp +.ir directmap4k " %lu (since linux 2.6.27)" +number of bytes of ram linearly mapped by kernel in 4 kb pages. +(x86.) +.tp +.ir directmap4m " %lu (since linux 2.6.27)" +number of bytes of ram linearly mapped by kernel in 4 mb pages. +(x86 with +.br config_x86_64 +or +.br config_x86_pae +enabled.) +.tp +.ir directmap2m " %lu (since linux 2.6.27)" +number of bytes of ram linearly mapped by kernel in 2 mb pages. +(x86 with neither +.br config_x86_64 +nor +.br config_x86_pae +enabled.) +.tp +.ir directmap1g " %lu (since linux 2.6.27)" +(x86 with +.br config_x86_64 +and +.b config_x86_direct_gbpages +enabled.) +.re +.tp +.i /proc/modules +a text list of the modules that have been loaded by the system. +see also +.br lsmod (8). +.tp +.i /proc/mounts +before kernel 2.4.19, this file was a list +of all the filesystems currently mounted on the system. +with the introduction of per-process mount namespaces in linux 2.4.19 (see +.br mount_namespaces (7)), +this file became a link to +.ir /proc/self/mounts , +which lists the mounts of the process's own mount namespace. +the format of this file is documented in +.br fstab (5). +.tp +.i /proc/mtrr +memory type range registers. +see the linux kernel source file +.i documentation/x86/mtrr.txt +.\" commit 7225e75144b9718cbbe1820d9c011c809d5773fd +(or +.i documentation/mtrr.txt +before linux 2.6.28) +for details. +.tp +.i /proc/net +this directory contains various files and subdirectories containing +information about the networking layer. +the files contain ascii structures and are, +therefore, readable with +.br cat (1). +however, the standard +.br netstat (8) +suite provides much cleaner access to these files. +.ip +with the advent of network namespaces, +various information relating to the network stack is virtualized (see +.br network_namespaces (7)). +thus, since linux 2.6.25, +.\" commit e9720acd728a46cb40daa52c99a979f7c4ff195c +.ir /proc/net +is a symbolic link to the directory +.ir /proc/self/net , +which contains the same files and directories as listed below. +however, these files and directories now expose information +for the network namespace of which the process is a member. +.tp +.i /proc/net/arp +this holds an ascii readable dump of the kernel arp table used for +address resolutions. +it will show both dynamically learned and preprogrammed arp entries. +the format is: +.ip +.in +4n +.ex +ip address hw type flags hw address mask device +192.168.0.50 0x1 0x2 00:50:bf:25:68:f3 * eth0 +192.168.0.250 0x1 0xc 00:00:00:00:00:00 * eth0 +.ee +.in +.ip +here "ip address" is the ipv4 address of the machine and the "hw type" +is the hardware type of the address from rfc\ 826. +the flags are the internal +flags of the arp structure (as defined in +.ir /usr/include/linux/if_arp.h ) +and +the "hw address" is the data link layer mapping for that ip address if +it is known. +.tp +.i /proc/net/dev +the dev pseudo-file contains network device status information. +this gives +the number of received and sent packets, the number of errors and +collisions +and other basic statistics. +these are used by the +.br ifconfig (8) +program to report device status. +the format is: +.ip +.ex +inter\-| receive | transmit + face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed + lo: 2776770 11307 0 0 0 0 0 0 2776770 11307 0 0 0 0 0 0 + eth0: 1215645 2751 0 0 0 0 0 0 1782404 4324 0 0 0 427 0 0 + ppp0: 1622270 5552 1 0 0 0 0 0 354130 5669 0 0 0 0 0 0 + tap0: 7714 81 0 0 0 0 0 0 7714 81 0 0 0 0 0 0 +.ee +.\" .tp +.\" .i /proc/net/ipx +.\" no information. +.\" .tp +.\" .i /proc/net/ipx_route +.\" no information. +.tp +.i /proc/net/dev_mcast +defined in +.ir /usr/src/linux/net/core/dev_mcast.c : +.ip +.in +4n +.ex +indx interface_name dmi_u dmi_g dmi_address +2 eth0 1 0 01005e000001 +3 eth1 1 0 01005e000001 +4 eth2 1 0 01005e000001 +.ee +.in +.tp +.i /proc/net/igmp +internet group management protocol. +defined in +.ir /usr/src/linux/net/core/igmp.c . +.tp +.i /proc/net/rarp +this file uses the same format as the +.i arp +file and contains the current reverse mapping database used to provide +.br rarp (8) +reverse address lookup services. +if rarp is not configured into the +kernel, +this file will not be present. +.tp +.i /proc/net/raw +holds a dump of the raw socket table. +much of the information is not of +use +apart from debugging. +the "sl" value is the kernel hash slot for the +socket, +the "local_address" is the local address and protocol number pair. +\&"st" is +the internal status of the socket. +the "tx_queue" and "rx_queue" are the +outgoing and incoming data queue in terms of kernel memory usage. +the "tr", "tm\->when", and "rexmits" fields are not used by raw. +the "uid" +field holds the effective uid of the creator of the socket. +.\" .tp +.\" .i /proc/net/route +.\" no information, but looks similar to +.\" .br route (8). +.tp +.i /proc/net/snmp +this file holds the ascii data needed for the ip, icmp, tcp, and udp +management +information bases for an snmp agent. +.tp +.i /proc/net/tcp +holds a dump of the tcp socket table. +much of the information is not +of use apart from debugging. +the "sl" value is the kernel hash slot +for the socket, the "local_address" is the local address and port number pair. +the "rem_address" is the remote address and port number pair +(if connected). +\&"st" is the internal status of the socket. +the "tx_queue" and "rx_queue" are the +outgoing and incoming data queue in terms of kernel memory usage. +the "tr", "tm\->when", and "rexmits" fields hold internal information of +the kernel socket state and are useful only for debugging. +the "uid" +field holds the effective uid of the creator of the socket. +.tp +.i /proc/net/udp +holds a dump of the udp socket table. +much of the information is not of +use apart from debugging. +the "sl" value is the kernel hash slot for the +socket, the "local_address" is the local address and port number pair. +the "rem_address" is the remote address and port number pair +(if connected). +"st" is the internal status of the socket. +the "tx_queue" and "rx_queue" are the outgoing and incoming data queue +in terms of kernel memory usage. +the "tr", "tm\->when", and "rexmits" fields +are not used by udp. +the "uid" +field holds the effective uid of the creator of the socket. +the format is: +.ip +.ex +sl local_address rem_address st tx_queue rx_queue tr rexmits tm\->when uid + 1: 01642c89:0201 0c642c89:03ff 01 00000000:00000001 01:000071ba 00000000 0 + 1: 00000000:0801 00000000:0000 0a 00000000:00000000 00:00000000 6f000100 0 + 1: 00000000:0201 00000000:0000 0a 00000000:00000000 00:00000000 00000000 0 +.ee +.tp +.i /proc/net/unix +lists the unix domain sockets present within the system and their +status. +the format is: +.ip +.ex +num refcount protocol flags type st inode path + 0: 00000002 00000000 00000000 0001 03 42 + 1: 00000001 00000000 00010000 0001 01 1948 /dev/printer +.ee +.ip +the fields are as follows: +.rs +.tp 10 +.ir num : +the kernel table slot number. +.tp +.ir refcount : +the number of users of the socket. +.tp +.ir protocol : +currently always 0. +.tp +.ir flags : +the internal kernel flags holding the status of the socket. +.tp +.ir type : +the socket type. +for +.br sock_stream +sockets, this is 0001; for +.br sock_dgram +sockets, it is 0002; and for +.br sock_seqpacket +sockets, it is 0005. +.tp +.ir st : +the internal state of the socket. +.tp +.ir inode : +the inode number of the socket. +.tp +.ir path : +the bound pathname (if any) of the socket. +sockets in the abstract namespace are included in the list, +and are shown with a +.i path +that commences with the character '@'. +.re +.tp +.i /proc/net/netfilter/nfnetlink_queue +this file contains information about netfilter user-space queueing, if used. +each line represents a queue. +queues that have not been subscribed to +by user space are not shown. +.ip +.in +4n +.ex + 1 4207 0 2 65535 0 0 0 1 + (1) (2) (3)(4) (5) (6) (7) (8) +.ee +.in +.ip +the fields in each line are: +.rs 7 +.tp 5 +(1) +the id of the queue. +this matches what is specified in the +.b \-\-queue\-num +or +.b \-\-queue\-balance +options to the +.br iptables (8) +nfqueue target. +see +.br iptables\-extensions (8) +for more information. +.tp +(2) +the netlink port id subscribed to the queue. +.tp +(3) +the number of packets currently queued and waiting to be processed by +the application. +.tp +(4) +the copy mode of the queue. +it is either 1 (metadata only) or 2 +(also copy payload data to user space). +.tp +(5) +copy range; that is, how many bytes of packet payload should be copied to +user space at most. +.tp +(6) +queue dropped. +number of packets that had to be dropped by the kernel because +too many packets are already waiting for user space to send back the mandatory +accept/drop verdicts. +.tp +(7) +queue user dropped. +number of packets that were dropped within the netlink +subsystem. +such drops usually happen when the corresponding socket buffer is +full; that is, user space is not able to read messages fast enough. +.tp +(8) +sequence number. +every queued packet is associated with a (32-bit) +monotonically increasing sequence number. +this shows the id of the most recent packet queued. +.re +.ip +the last number exists only for compatibility reasons and is always 1. +.tp +.i /proc/partitions +contains the major and minor numbers of each partition as well as the number +of 1024-byte blocks and the partition name. +.tp +.i /proc/pci +this is a listing of all pci devices found during kernel initialization +and their configuration. +.ip +this file has been deprecated in favor of a new +.i /proc +interface for pci +.ri ( /proc/bus/pci ). +it became optional in linux 2.2 (available with +.b config_pci_old_proc +set at kernel compilation). +it became once more nonoptionally enabled in linux 2.4. +next, it was deprecated in linux 2.6 (still available with +.b config_pci_legacy_proc +set), and finally removed altogether since linux 2.6.17. +.\" fixme document /proc/sched_debug (since linux 2.6.23) +.\" see also /proc/[pid]/sched +.tp +.ir /proc/profile " (since linux 2.4)" +this file is present only if the kernel was booted with the +.i profile=1 +command-line option. +it exposes kernel profiling information in a binary format for use by +.br readprofile (1). +writing (e.g., an empty string) to this file resets the profiling counters; +on some architectures, +writing a binary integer "profiling multiplier" of size +.ir sizeof(int) +sets the profiling interrupt frequency. +.tp +.i /proc/scsi +a directory with the +.i scsi +mid-level pseudo-file and various scsi low-level +driver directories, +which contain a file for each scsi host in this system, all of +which give the status of some part of the scsi io subsystem. +these files contain ascii structures and are, therefore, readable with +.br cat (1). +.ip +you can also write to some of the files to reconfigure the subsystem or +switch certain features on or off. +.tp +.i /proc/scsi/scsi +this is a listing of all scsi devices known to the kernel. +the listing is similar to the one seen during bootup. +scsi currently supports only the \fiadd\-single\-device\fp command which +allows root to add a hotplugged device to the list of known devices. +.ip +the command +.ip +.in +4n +.ex +echo \(aqscsi add\-single\-device 1 0 5 0\(aq > /proc/scsi/scsi +.ee +.in +.ip +will cause +host scsi1 to scan on scsi channel 0 for a device on id 5 lun 0. +if there +is already a device known on this address or the address is invalid, an +error will be returned. +.tp +.i /proc/scsi/[drivername] +\fi[drivername]\fp can currently be ncr53c7xx, aha152x, aha1542, aha1740, +aic7xxx, buslogic, eata_dma, eata_pio, fdomain, in2000, pas16, qlogic, +scsi_debug, seagate, t128, u15\-24f, ultrastore, or wd7000. +these directories show up for all drivers that registered at least one +scsi hba. +every directory contains one file per registered host. +every host-file is named after the number the host was assigned during +initialization. +.ip +reading these files will usually show driver and host configuration, +statistics, and so on. +.ip +writing to these files allows different things on different hosts. +for example, with the \filatency\fp and \finolatency\fp commands, +root can switch on and off command latency measurement code in the +eata_dma driver. +with the \filockup\fp and \fiunlock\fp commands, +root can control bus lockups simulated by the scsi_debug driver. +.tp +.i /proc/self +this directory refers to the process accessing the +.i /proc +filesystem, +and is identical to the +.i /proc +directory named by the process id of the same process. +.tp +.i /proc/slabinfo +information about kernel caches. +see +.br slabinfo (5) +for details. +.tp +.i /proc/stat +kernel/system statistics. +varies with architecture. +common +entries include: +.rs +.tp +.i cpu 10132153 290696 3084719 46828483 16683 0 25195 0 175628 0 +.tq +.i cpu0 1393280 32966 572056 13343292 6130 0 17875 0 23933 0 +the amount of time, measured in units of +user_hz (1/100ths of a second on most architectures, use +.ir sysconf(_sc_clk_tck) +to obtain the right value), +.\" 1024 on alpha and ia64 +that the system ("cpu" line) or the specific cpu ("cpu\fin\fr" line) +spent in various states: +.rs +.tp +.i user +(1) time spent in user mode. +.tp +.i nice +(2) time spent in user mode with low priority (nice). +.tp +.i system +(3) time spent in system mode. +.tp +.i idle +(4) time spent in the idle task. +.\" fixme . actually, the following info about the /proc/stat 'cpu' field +.\" does not seem to be quite right (at least in 2.6.12 or 3.6): +.\" the idle time in /proc/uptime does not quite match this value +this value should be user_hz times the +second entry in the +.i /proc/uptime +pseudo-file. +.tp +.ir iowait " (since linux 2.5.41)" +(5) time waiting for i/o to complete. +this value is not reliable, for the following reasons: +.\" see kernel commit 9c240d757658a3ae9968dd309e674c61f07c7f48 +.rs +.ip 1. 3 +the cpu will not wait for i/o to complete; +iowait is the time that a task is waiting for i/o to complete. +when a cpu goes into idle state for outstanding task i/o, +another task will be scheduled on this cpu. +.ip 2. +on a multi-core cpu, +the task waiting for i/o to complete is not running on any cpu, +so the iowait of each cpu is difficult to calculate. +.ip 3. +the value in this field may +.i decrease +in certain conditions. +.re +.tp +.ir irq " (since linux 2.6.0)" +.\" precisely: linux 2.6.0-test4 +(6) time servicing interrupts. +.tp +.ir softirq " (since linux 2.6.0)" +.\" precisely: linux 2.6.0-test4 +(7) time servicing softirqs. +.tp +.ir steal " (since linux 2.6.11)" +(8) stolen time, which is the time spent in other operating systems when +running in a virtualized environment +.tp +.ir guest " (since linux 2.6.24)" +(9) time spent running a virtual cpu for guest +operating systems under the control of the linux kernel. +.\" see changelog entry for 5e84cfde51cf303d368fcb48f22059f37b3872de +.tp +.ir guest_nice " (since linux 2.6.33)" +.\" commit ce0e7b28fb75cb003cfc8d0238613aaf1c55e797 +(10) time spent running a niced guest (virtual cpu for guest +operating systems under the control of the linux kernel). +.re +.tp +\fipage 5741 1808\fp +the number of pages the system paged in and the number that were paged +out (from disk). +.tp +\fiswap 1 0\fp +the number of swap pages that have been brought in and out. +.tp +.\" fixme . the following is not the full picture for the 'intr' of +.\" /proc/stat on 2.6: +\fiintr 1462898\fp +this line shows counts of interrupts serviced since boot time, +for each of the possible system interrupts. +the first column is the total of all interrupts serviced +including unnumbered architecture specific interrupts; +each subsequent column is the total for that particular numbered interrupt. +unnumbered interrupts are not shown, only summed into the total. +.tp +\fidisk_io: (2,0):(31,30,5764,1,2) (3,0):\fp... +(major,disk_idx):(noinfo, read_io_ops, blks_read, write_io_ops, blks_written) +.br +(linux 2.4 only) +.tp +\fictxt 115315\fp +the number of context switches that the system underwent. +.tp +\fibtime 769041601\fp +boot time, in seconds since the epoch, 1970-01-01 00:00:00 +0000 (utc). +.tp +\fiprocesses 86031\fp +number of forks since boot. +.tp +\fiprocs_running 6\fp +number of processes in runnable state. +(linux 2.5.45 onward.) +.tp +\fiprocs_blocked 2\fp +number of processes blocked waiting for i/o to complete. +(linux 2.5.45 onward.) +.tp +.i softirq 229245889 94 60001584 13619 5175704 2471304 28 51212741 59130143 0 51240672 +.\" commit d3d64df21d3d0de675a0d3ffa7c10514f3644b30 +this line shows the number of softirq for all cpus. +the first column is the total of all softirqs and +each subsequent column is the total for particular softirq. +(linux 2.6.31 onward.) +.re +.tp +.i /proc/swaps +swap areas in use. +see also +.br swapon (8). +.tp +.i /proc/sys +this directory (present since 1.3.57) contains a number of files +and subdirectories corresponding to kernel variables. +these variables can be read and in some cases modified using +the \fi/proc\fp filesystem, and the (deprecated) +.br sysctl (2) +system call. +.ip +string values may be terminated by either \(aq\e0\(aq or \(aq\en\(aq. +.ip +integer and long values may be written either in decimal or in +hexadecimal notation (e.g., 0x3fff). +when writing multiple integer or long values, these may be separated +by any of the following whitespace characters: +\(aq\ \(aq, \(aq\et\(aq, or \(aq\en\(aq. +using other separators leads to the error +.br einval . +.tp +.ir /proc/sys/abi " (since linux 2.4.10)" +this directory may contain files with application binary information. +.\" on some systems, it is not present. +see the linux kernel source file +.i documentation/sysctl/abi.txt +for more information. +.tp +.i /proc/sys/debug +this directory may be empty. +.tp +.i /proc/sys/dev +this directory contains device-specific information (e.g., +.ir dev/cdrom/info ). +on +some systems, it may be empty. +.tp +.i /proc/sys/fs +this directory contains the files and subdirectories for kernel variables +related to filesystems. +.tp +.ir /proc/sys/fs/aio\-max\-nr " and " /proc/sys/fs/aio\-nr " (since linux 2.6.4)" +.i aio\-nr +is the running total of the number of events specified by +.br io_setup (2) +calls for all currently active aio contexts. +if +.i aio\-nr +reaches +.ir aio\-max\-nr , +then +.br io_setup (2) +will fail with the error +.br eagain . +raising +.i aio\-max\-nr +does not result in the preallocation or resizing +of any kernel data structures. +.tp +.i /proc/sys/fs/binfmt_misc +documentation for files in this directory can be found +in the linux kernel source in the file +.ir documentation/admin\-guide/binfmt\-misc.rst +(or in +.ir documentation/binfmt_misc.txt +on older kernels). +.tp +.ir /proc/sys/fs/dentry\-state " (since linux 2.2)" +this file contains information about the status of the +directory cache (dcache). +the file contains six numbers, +.ir nr_dentry ", " nr_unused ", " age_limit " (age in seconds)," +.i want_pages +(pages requested by system) and two dummy values. +.rs +.ip * 2 +.i nr_dentry +is the number of allocated dentries (dcache entries). +this field is unused in linux 2.2. +.ip * +.i nr_unused +is the number of unused dentries. +.ip * +.i age_limit +.\" looks like this is unused in kernels 2.2 to 2.6 +is the age in seconds after which dcache entries +can be reclaimed when memory is short. +.ip * +.i want_pages +.\" looks like this is unused in kernels 2.2 to 2.6 +is nonzero when the kernel has called shrink_dcache_pages() and the +dcache isn't pruned yet. +.re +.tp +.i /proc/sys/fs/dir\-notify\-enable +this file can be used to disable or enable the +.i dnotify +interface described in +.br fcntl (2) +on a system-wide basis. +a value of 0 in this file disables the interface, +and a value of 1 enables it. +.tp +.i /proc/sys/fs/dquot\-max +this file shows the maximum number of cached disk quota entries. +on some (2.4) systems, it is not present. +if the number of free cached disk quota entries is very low and +you have some awesome number of simultaneous system users, +you might want to raise the limit. +.tp +.i /proc/sys/fs/dquot\-nr +this file shows the number of allocated disk quota +entries and the number of free disk quota entries. +.tp +.ir /proc/sys/fs/epoll " (since linux 2.6.28)" +this directory contains the file +.ir max_user_watches , +which can be used to limit the amount of kernel memory consumed by the +.i epoll +interface. +for further details, see +.br epoll (7). +.tp +.i /proc/sys/fs/file\-max +this file defines +a system-wide limit on the number of open files for all processes. +system calls that fail when encountering this limit fail with the error +.br enfile . +(see also +.br setrlimit (2), +which can be used by a process to set the per-process limit, +.br rlimit_nofile , +on the number of files it may open.) +if you get lots +of error messages in the kernel log about running out of file handles +(open file descriptions) +(look for "vfs: file\-max limit reached"), +try increasing this value: +.ip +.in +4n +.ex +echo 100000 > /proc/sys/fs/file\-max +.ee +.in +.ip +privileged processes +.rb ( cap_sys_admin ) +can override the +.i file\-max +limit. +.tp +.i /proc/sys/fs/file\-nr +this (read-only) file contains three numbers: +the number of allocated file handles +(i.e., the number of open file descriptions; see +.br open (2)); +the number of free file handles; +and the maximum number of file handles (i.e., the same value as +.ir /proc/sys/fs/file\-max ). +if the number of allocated file handles is close to the +maximum, you should consider increasing the maximum. +before linux 2.6, +the kernel allocated file handles dynamically, +but it didn't free them again. +instead the free file handles were kept in a list for reallocation; +the "free file handles" value indicates the size of that list. +a large number of free file handles indicates that there was +a past peak in the usage of open file handles. +since linux 2.6, the kernel does deallocate freed file handles, +and the "free file handles" value is always zero. +.tp +.ir /proc/sys/fs/inode\-max " (only present until linux 2.2)" +this file contains the maximum number of in-memory inodes. +this value should be 3\(en4 times larger +than the value in +.ir file\-max , +since \fistdin\fp, \fistdout\fp +and network sockets also need an inode to handle them. +when you regularly run out of inodes, you need to increase this value. +.ip +starting with linux 2.4, +there is no longer a static limit on the number of inodes, +and this file is removed. +.tp +.i /proc/sys/fs/inode\-nr +this file contains the first two values from +.ir inode\-state . +.tp +.i /proc/sys/fs/inode\-state +this file +contains seven numbers: +.ir nr_inodes , +.ir nr_free_inodes , +.ir preshrink , +and four dummy values (always zero). +.ip +.i nr_inodes +is the number of inodes the system has allocated. +.\" this can be slightly more than +.\" .i inode\-max +.\" because linux allocates them one page full at a time. +.i nr_free_inodes +represents the number of free inodes. +.ip +.i preshrink +is nonzero when the +.i nr_inodes +> +.i inode\-max +and the system needs to prune the inode list instead of allocating more; +since linux 2.4, this field is a dummy value (always zero). +.tp +.ir /proc/sys/fs/inotify " (since linux 2.6.13)" +this directory contains files +.ir max_queued_events ", " max_user_instances ", and " max_user_watches , +that can be used to limit the amount of kernel memory consumed by the +.i inotify +interface. +for further details, see +.br inotify (7). +.tp +.i /proc/sys/fs/lease\-break\-time +this file specifies the grace period that the kernel grants to a process +holding a file lease +.rb ( fcntl (2)) +after it has sent a signal to that process notifying it +that another process is waiting to open the file. +if the lease holder does not remove or downgrade the lease within +this grace period, the kernel forcibly breaks the lease. +.tp +.i /proc/sys/fs/leases\-enable +this file can be used to enable or disable file leases +.rb ( fcntl (2)) +on a system-wide basis. +if this file contains the value 0, leases are disabled. +a nonzero value enables leases. +.tp +.ir /proc/sys/fs/mount\-max " (since linux 4.9)" +.\" commit d29216842a85c7970c536108e093963f02714498 +the value in this file specifies the maximum number of mounts that may exist +in a mount namespace. +the default value in this file is 100,000. +.tp +.ir /proc/sys/fs/mqueue " (since linux 2.6.6)" +this directory contains files +.ir msg_max ", " msgsize_max ", and " queues_max , +controlling the resources used by posix message queues. +see +.br mq_overview (7) +for details. +.tp +.ir /proc/sys/fs/nr_open " (since linux 2.6.25)" +.\" commit 9cfe015aa424b3c003baba3841a60dd9b5ad319b +this file imposes a ceiling on the value to which the +.br rlimit_nofile +resource limit can be raised (see +.br getrlimit (2)). +this ceiling is enforced for both unprivileged and privileged process. +the default value in this file is 1048576. +(before linux 2.6.25, the ceiling for +.br rlimit_nofile +was hard-coded to the same value.) +.tp +.ir /proc/sys/fs/overflowgid " and " /proc/sys/fs/overflowuid +these files +allow you to change the value of the fixed uid and gid. +the default is 65534. +some filesystems support only 16-bit uids and gids, although in linux +uids and gids are 32 bits. +when one of these filesystems is mounted +with writes enabled, any uid or gid that would exceed 65535 is translated +to the overflow value before being written to disk. +.tp +.ir /proc/sys/fs/pipe\-max\-size " (since linux 2.6.35)" +see +.br pipe (7). +.tp +.ir /proc/sys/fs/pipe\-user\-pages\-hard " (since linux 4.5)" +see +.br pipe (7). +.tp +.ir /proc/sys/fs/pipe\-user\-pages\-soft " (since linux 4.5)" +see +.br pipe (7). +.tp +.ir /proc/sys/fs/protected_fifos " (since linux 4.19)" +the value in this file is/can be set to one of the following: +.rs +.tp 4 +0 +writing to fifos is unrestricted. +.tp +1 +don't allow +.b o_creat +.br open (2) +on fifos that the caller doesn't own in world-writable sticky directories, +unless the fifo is owned by the owner of the directory. +.tp +2 +as for the value 1, +but the restriction also applies to group-writable sticky directories. +.re +.ip +the intent of the above protections is to avoid unintentional writes to an +attacker-controlled fifo when a program expected to create a regular file. +.tp +.ir /proc/sys/fs/protected_hardlinks " (since linux 3.6)" +.\" commit 800179c9b8a1e796e441674776d11cd4c05d61d7 +when the value in this file is 0, +no restrictions are placed on the creation of hard links +(i.e., this is the historical behavior before linux 3.6). +when the value in this file is 1, +a hard link can be created to a target file +only if one of the following conditions is true: +.rs +.ip * 3 +the calling process has the +.br cap_fowner +capability in its user namespace +and the file uid has a mapping in the namespace. +.ip * +the filesystem uid of the process creating the link matches +the owner (uid) of the target file +(as described in +.br credentials (7), +a process's filesystem uid is normally the same as its effective uid). +.ip * +all of the following conditions are true: +.rs 4 +.ip \(bu 3 +the target is a regular file; +.ip \(bu +the target file does not have its set-user-id mode bit enabled; +.ip \(bu +the target file does not have both its set-group-id and +group-executable mode bits enabled; and +.ip \(bu +the caller has permission to read and write the target file +(either via the file's permissions mask or because it has +suitable capabilities). +.re +.re +.ip +the default value in this file is 0. +setting the value to 1 +prevents a longstanding class of security issues caused by +hard-link-based time-of-check, time-of-use races, +most commonly seen in world-writable directories such as +.ir /tmp . +the common method of exploiting this flaw +is to cross privilege boundaries when following a given hard link +(i.e., a root process follows a hard link created by another user). +additionally, on systems without separated partitions, +this stops unauthorized users from "pinning" vulnerable set-user-id and +set-group-id files against being upgraded by +the administrator, or linking to special files. +.tp +.ir /proc/sys/fs/protected_regular " (since linux 4.19)" +the value in this file is/can be set to one of the following: +.rs +.tp 4 +0 +writing to regular files is unrestricted. +.tp +1 +don't allow +.b o_creat +.br open (2) +on regular files that the caller doesn't own in +world-writable sticky directories, +unless the regular file is owned by the owner of the directory. +.tp +2 +as for the value 1, +but the restriction also applies to group-writable sticky directories. +.re +.ip +the intent of the above protections is similar to +.ir protected_fifos , +but allows an application to +avoid writes to an attacker-controlled regular file, +where the application expected to create one. +.tp +.ir /proc/sys/fs/protected_symlinks " (since linux 3.6)" +.\" commit 800179c9b8a1e796e441674776d11cd4c05d61d7 +when the value in this file is 0, +no restrictions are placed on following symbolic links +(i.e., this is the historical behavior before linux 3.6). +when the value in this file is 1, symbolic links are followed only +in the following circumstances: +.rs +.ip * 3 +the filesystem uid of the process following the link matches +the owner (uid) of the symbolic link +(as described in +.br credentials (7), +a process's filesystem uid is normally the same as its effective uid); +.ip * +the link is not in a sticky world-writable directory; or +.ip * +the symbolic link and its parent directory have the same owner (uid) +.re +.ip +a system call that fails to follow a symbolic link +because of the above restrictions returns the error +.br eacces +in +.ir errno . +.ip +the default value in this file is 0. +setting the value to 1 avoids a longstanding class of security issues +based on time-of-check, time-of-use races when accessing symbolic links. +.tp +.ir /proc/sys/fs/suid_dumpable " (since linux 2.6.13)" +.\" the following is based on text from documentation/sysctl/kernel.txt +the value in this file is assigned to a process's "dumpable" flag +in the circumstances described in +.br prctl (2). +in effect, +the value in this file determines whether core dump files are +produced for set-user-id or otherwise protected/tainted binaries. +the "dumpable" setting also affects the ownership of files in a process's +.ir /proc/[pid] +directory, as described above. +.ip +three different integer values can be specified: +.rs +.tp +\fi0\ (default)\fp +.\" in kernel source: suid_dump_disable +this provides the traditional (pre-linux 2.6.13) behavior. +a core dump will not be produced for a process which has +changed credentials (by calling +.br seteuid (2), +.br setgid (2), +or similar, or by executing a set-user-id or set-group-id program) +or whose binary does not have read permission enabled. +.tp +\fi1\ ("debug")\fp +.\" in kernel source: suid_dump_user +all processes dump core when possible. +(reasons why a process might nevertheless not dump core are described in +.br core (5).) +the core dump is owned by the filesystem user id of the dumping process +and no security is applied. +this is intended for system debugging situations only: +this mode is insecure because it allows unprivileged users to +examine the memory contents of privileged processes. +.tp +\fi2\ ("suidsafe")\fp +.\" in kernel source: suid_dump_root +any binary which normally would not be dumped (see "0" above) +is dumped readable by root only. +this allows the user to remove the core dump file but not to read it. +for security reasons core dumps in this mode will not overwrite one +another or other files. +this mode is appropriate when administrators are +attempting to debug problems in a normal environment. +.ip +additionally, since linux 3.6, +.\" 9520628e8ceb69fa9a4aee6b57f22675d9e1b709 +.i /proc/sys/kernel/core_pattern +must either be an absolute pathname +or a pipe command, as detailed in +.br core (5). +warnings will be written to the kernel log if +.i core_pattern +does not follow these rules, and no core dump will be produced. +.\" 54b501992dd2a839e94e76aa392c392b55080ce8 +.re +.ip +for details of the effect of a process's "dumpable" setting +on ptrace access mode checking, see +.br ptrace (2). +.tp +.i /proc/sys/fs/super\-max +this file +controls the maximum number of superblocks, and +thus the maximum number of mounted filesystems the kernel +can have. +you need increase only +.i super\-max +if you need to mount more filesystems than the current value in +.i super\-max +allows you to. +.tp +.i /proc/sys/fs/super\-nr +this file +contains the number of filesystems currently mounted. +.tp +.i /proc/sys/kernel +this directory contains files controlling a range of kernel parameters, +as described below. +.tp +.i /proc/sys/kernel/acct +this file +contains three numbers: +.ir highwater , +.ir lowwater , +and +.ir frequency . +if bsd-style process accounting is enabled, these values control +its behavior. +if free space on filesystem where the log lives goes below +.i lowwater +percent, accounting suspends. +if free space gets above +.i highwater +percent, accounting resumes. +.i frequency +determines +how often the kernel checks the amount of free space (value is in +seconds). +default values are 4, 2, and 30. +that is, suspend accounting if 2% or less space is free; resume it +if 4% or more space is free; consider information about amount of free space +valid for 30 seconds. +.tp +.ir /proc/sys/kernel/auto_msgmni " (linux 2.6.27 to 3.18)" +.\" commit 9eefe520c814f6f62c5d36a2ddcd3fb99dfdb30e (introduces feature) +.\" commit 0050ee059f7fc86b1df2527aaa14ed5dc72f9973 (rendered redundant) +from linux 2.6.27 to 3.18, +this file was used to control recomputing of the value in +.ir /proc/sys/kernel/msgmni +upon the addition or removal of memory or upon ipc namespace creation/removal. +echoing "1" into this file enabled +.i msgmni +automatic recomputing (and triggered a recomputation of +.i msgmni +based on the current amount of available memory and number of ipc namespaces). +echoing "0" disabled automatic recomputing. +(automatic recomputing was also disabled if a value was explicitly assigned to +.ir /proc/sys/kernel/msgmni .) +the default value in +.i auto_msgmni +was 1. +.ip +since linux 3.19, the content of this file has no effect (because +.ir msgmni +.\" fixme must document the 3.19 'msgmni' changes. +defaults to near the maximum value possible), +and reads from this file always return the value "0". +.tp +.ir /proc/sys/kernel/cap_last_cap " (since linux 3.2)" +see +.br capabilities (7). +.tp +.ir /proc/sys/kernel/cap\-bound " (from linux 2.2 to 2.6.24)" +this file holds the value of the kernel +.i "capability bounding set" +(expressed as a signed decimal number). +this set is anded against the capabilities permitted to a process +during +.br execve (2). +starting with linux 2.6.25, +the system-wide capability bounding set disappeared, +and was replaced by a per-thread bounding set; see +.br capabilities (7). +.tp +.i /proc/sys/kernel/core_pattern +see +.br core (5). +.tp +.i /proc/sys/kernel/core_pipe_limit +see +.br core (5). +.tp +.i /proc/sys/kernel/core_uses_pid +see +.br core (5). +.tp +.i /proc/sys/kernel/ctrl\-alt\-del +this file +controls the handling of ctrl-alt-del from the keyboard. +when the value in this file is 0, ctrl-alt-del is trapped and +sent to the +.br init (1) +program to handle a graceful restart. +when the value is greater than zero, linux's reaction to a vulcan +nerve pinch (tm) will be an immediate reboot, without even +syncing its dirty buffers. +note: when a program (like dosemu) has the keyboard in "raw" +mode, the ctrl-alt-del is intercepted by the program before it +ever reaches the kernel tty layer, and it's up to the program +to decide what to do with it. +.tp +.ir /proc/sys/kernel/dmesg_restrict " (since linux 2.6.37)" +the value in this file determines who can see kernel syslog contents. +a value of 0 in this file imposes no restrictions. +if the value is 1, only privileged users can read the kernel syslog. +(see +.br syslog (2) +for more details.) +since linux 3.4, +.\" commit 620f6e8e855d6d447688a5f67a4e176944a084e8 +only users with the +.br cap_sys_admin +capability may change the value in this file. +.tp +.ir /proc/sys/kernel/domainname " and " /proc/sys/kernel/hostname +can be used to set the nis/yp domainname and the +hostname of your box in exactly the same way as the commands +.br domainname (1) +and +.br hostname (1), +that is: +.ip +.in +4n +.ex +.rb "#" " echo \(aqdarkstar\(aq > /proc/sys/kernel/hostname" +.rb "#" " echo \(aqmydomain\(aq > /proc/sys/kernel/domainname" +.ee +.in +.ip +has the same effect as +.ip +.in +4n +.ex +.rb "#" " hostname \(aqdarkstar\(aq" +.rb "#" " domainname \(aqmydomain\(aq" +.ee +.in +.ip +note, however, that the classic darkstar.frop.org has the +hostname "darkstar" and dns (internet domain name server) +domainname "frop.org", not to be confused with the nis (network +information service) or yp (yellow pages) domainname. +these two +domain names are in general different. +for a detailed discussion +see the +.br hostname (1) +man page. +.tp +.i /proc/sys/kernel/hotplug +this file +contains the pathname for the hotplug policy agent. +the default value in this file is +.ir /sbin/hotplug . +.tp +.\" removed in commit 87f504e5c78b910b0c1d6ffb89bc95e492322c84 (tglx/history.git) +.ir /proc/sys/kernel/htab\-reclaim " (before linux 2.4.9.2)" +(powerpc only) if this file is set to a nonzero value, +the powerpc htab +.\" removed in commit 1b483a6a7b2998e9c98ad985d7494b9b725bd228, before 2.6.28 +(see kernel file +.ir documentation/powerpc/ppc_htab.txt ) +is pruned +each time the system hits the idle loop. +.tp +.ir /proc/sys/kernel/keys/* +this directory contains various files that define parameters and limits +for the key-management facility. +these files are described in +.br keyrings (7). +.tp +.ir /proc/sys/kernel/kptr_restrict " (since linux 2.6.38)" +.\" 455cd5ab305c90ffc422dd2e0fb634730942b257 +the value in this file determines whether kernel addresses are exposed via +.i /proc +files and other interfaces. +a value of 0 in this file imposes no restrictions. +if the value is 1, kernel pointers printed using the +.i %pk +format specifier will be replaced with zeros unless the user has the +.br cap_syslog +capability. +if the value is 2, kernel pointers printed using the +.i %pk +format specifier will be replaced with zeros regardless +of the user's capabilities. +the initial default value for this file was 1, +but the default was changed +.\" commit 411f05f123cbd7f8aa1edcae86970755a6e2a9d9 +to 0 in linux 2.6.39. +since linux 3.4, +.\" commit 620f6e8e855d6d447688a5f67a4e176944a084e8 +only users with the +.br cap_sys_admin +capability can change the value in this file. +.tp +.i /proc/sys/kernel/l2cr +(powerpc only) this file +contains a flag that controls the l2 cache of g3 processor +boards. +if 0, the cache is disabled. +enabled if nonzero. +.tp +.i /proc/sys/kernel/modprobe +this file contains the pathname for the kernel module loader. +the default value is +.ir /sbin/modprobe . +the file is present only if the kernel is built with the +.b config_modules +.rb ( config_kmod +in linux 2.6.26 and earlier) +option enabled. +it is described by the linux kernel source file +.i documentation/kmod.txt +(present only in kernel 2.4 and earlier). +.tp +.ir /proc/sys/kernel/modules_disabled " (since linux 2.6.31)" +.\" 3d43321b7015387cfebbe26436d0e9d299162ea1 +.\" from documentation/sysctl/kernel.txt +a toggle value indicating if modules are allowed to be loaded +in an otherwise modular kernel. +this toggle defaults to off (0), but can be set true (1). +once true, modules can be neither loaded nor unloaded, +and the toggle cannot be set back to false. +the file is present only if the kernel is built with the +.b config_modules +option enabled. +.tp +.ir /proc/sys/kernel/msgmax " (since linux 2.2)" +this file defines +a system-wide limit specifying the maximum number of bytes in +a single message written on a system v message queue. +.tp +.ir /proc/sys/kernel/msgmni " (since linux 2.4)" +this file defines the system-wide limit on the number of +message queue identifiers. +see also +.ir /proc/sys/kernel/auto_msgmni . +.tp +.ir /proc/sys/kernel/msgmnb " (since linux 2.2)" +this file defines a system-wide parameter used to initialize the +.i msg_qbytes +setting for subsequently created message queues. +the +.i msg_qbytes +setting specifies the maximum number of bytes that may be written to the +message queue. +.tp +.ir /proc/sys/kernel/ngroups_max " (since linux 2.6.4)" +this is a read-only file that displays the upper limit on the +number of a process's group memberships. +.tp +.ir /proc/sys/kernel/ns_last_pid " (since linux 3.3)" +see +.br pid_namespaces (7). +.tp +.ir /proc/sys/kernel/ostype " and " /proc/sys/kernel/osrelease +these files +give substrings of +.ir /proc/version . +.tp +.ir /proc/sys/kernel/overflowgid " and " /proc/sys/kernel/overflowuid +these files duplicate the files +.i /proc/sys/fs/overflowgid +and +.ir /proc/sys/fs/overflowuid . +.tp +.i /proc/sys/kernel/panic +this file gives read/write access to the kernel variable +.ir panic_timeout . +if this is zero, the kernel will loop on a panic; if nonzero, +it indicates that the kernel should autoreboot after this number +of seconds. +when you use the +software watchdog device driver, the recommended setting is 60. +.tp +.ir /proc/sys/kernel/panic_on_oops " (since linux 2.5.68)" +this file controls the kernel's behavior when an oops +or bug is encountered. +if this file contains 0, then the system +tries to continue operation. +if it contains 1, then the system +delays a few seconds (to give klogd time to record the oops output) +and then panics. +if the +.i /proc/sys/kernel/panic +file is also nonzero, then the machine will be rebooted. +.tp +.ir /proc/sys/kernel/pid_max " (since linux 2.5.34)" +this file specifies the value at which pids wrap around +(i.e., the value in this file is one greater than the maximum pid). +pids greater than this value are not allocated; +thus, the value in this file also acts as a system-wide limit +on the total number of processes and threads. +the default value for this file, 32768, +results in the same range of pids as on earlier kernels. +on 32-bit platforms, 32768 is the maximum value for +.ir pid_max . +on 64-bit systems, +.i pid_max +can be set to any value up to 2^22 +.rb ( pid_max_limit , +approximately 4 million). +.\" prior to 2.6.10, pid_max could also be raised above 32768 on 32-bit +.\" platforms, but this broke /proc/[pid] +.\" see http://marc.theaimsgroup.com/?l=linux-kernel&m=109513010926152&w=2 +.tp +.ir /proc/sys/kernel/powersave\-nap " (powerpc only)" +this file contains a flag. +if set, linux-ppc will use the "nap" mode of +powersaving, +otherwise the "doze" mode will be used. +.tp +.i /proc/sys/kernel/printk +see +.br syslog (2). +.tp +.ir /proc/sys/kernel/pty " (since linux 2.6.4)" +this directory contains two files relating to the number of unix 98 +pseudoterminals (see +.br pts (4)) +on the system. +.tp +.i /proc/sys/kernel/pty/max +this file defines the maximum number of pseudoterminals. +.\" fixme document /proc/sys/kernel/pty/reserve +.\" new in linux 3.3 +.\" commit e9aba5158a80098447ff207a452a3418ae7ee386 +.tp +.i /proc/sys/kernel/pty/nr +this read-only file +indicates how many pseudoterminals are currently in use. +.tp +.i /proc/sys/kernel/random +this directory +contains various parameters controlling the operation of the file +.ir /dev/random . +see +.br random (4) +for further information. +.tp +.ir /proc/sys/kernel/random/uuid " (since linux 2.4)" +each read from this read-only file returns a randomly generated 128-bit uuid, +as a string in the standard uuid format. +.tp +.ir /proc/sys/kernel/randomize_va_space " (since linux 2.6.12)" +.\" some further details can be found in documentation/sysctl/kernel.txt +select the address space layout randomization (aslr) policy for the system +(on architectures that support aslr). +three values are supported for this file: +.rs +.ip 0 3 +turn aslr off. +this is the default for architectures that don't support aslr, +and when the kernel is booted with the +.i norandmaps +parameter. +.ip 1 +make the addresses of +.br mmap (2) +allocations, the stack, and the vdso page randomized. +among other things, this means that shared libraries will be +loaded at randomized addresses. +the text segment of pie-linked binaries will also be loaded +at a randomized address. +this value is the default if the kernel was configured with +.br config_compat_brk . +.ip 2 +(since linux 2.6.25) +.\" commit c1d171a002942ea2d93b4fbd0c9583c56fce0772 +also support heap randomization. +this value is the default if the kernel was not configured with +.br config_compat_brk . +.re +.tp +.i /proc/sys/kernel/real\-root\-dev +this file is documented in the linux kernel source file +.i documentation/admin\-guide/initrd.rst +.\" commit 9d85025b0418163fae079c9ba8f8445212de8568 +(or +.i documentation/initrd.txt +before linux 4.10). +.tp +.ir /proc/sys/kernel/reboot\-cmd " (sparc only)" +this file seems to be a way to give an argument to the sparc +rom/flash boot loader. +maybe to tell it what to do after +rebooting? +.tp +.i /proc/sys/kernel/rtsig\-max +(only in kernels up to and including 2.6.7; see +.br setrlimit (2)) +this file can be used to tune the maximum number +of posix real-time (queued) signals that can be outstanding +in the system. +.tp +.i /proc/sys/kernel/rtsig\-nr +(only in kernels up to and including 2.6.7.) +this file shows the number of posix real-time signals currently queued. +.tp +.ir /proc/[pid]/sched_autogroup_enabled " (since linux 2.6.38)" +.\" commit 5091faa449ee0b7d73bc296a93bca9540fc51d0a +see +.br sched (7). +.tp +.ir /proc/sys/kernel/sched_child_runs_first " (since linux 2.6.23)" +if this file contains the value zero, then, after a +.br fork (2), +the parent is first scheduled on the cpu. +if the file contains a nonzero value, +then the child is scheduled first on the cpu. +(of course, on a multiprocessor system, +the parent and the child might both immediately be scheduled on a cpu.) +.tp +.ir /proc/sys/kernel/sched_rr_timeslice_ms " (since linux 3.9)" +see +.br sched_rr_get_interval (2). +.tp +.ir /proc/sys/kernel/sched_rt_period_us " (since linux 2.6.25)" +see +.br sched (7). +.tp +.ir /proc/sys/kernel/sched_rt_runtime_us " (since linux 2.6.25)" +see +.br sched (7). +.tp +.ir /proc/sys/kernel/seccomp " (since linux 4.14)" +.\" commit 8e5f1ad116df6b0de65eac458d5e7c318d1c05af +this directory provides additional seccomp information and +configuration. +see +.br seccomp (2) +for further details. +.tp +.ir /proc/sys/kernel/sem " (since linux 2.4)" +this file contains 4 numbers defining limits for system v ipc semaphores. +these fields are, in order: +.rs +.ip semmsl 8 +the maximum semaphores per semaphore set. +.ip semmns 8 +a system-wide limit on the number of semaphores in all semaphore sets. +.ip semopm 8 +the maximum number of operations that may be specified in a +.br semop (2) +call. +.ip semmni 8 +a system-wide limit on the maximum number of semaphore identifiers. +.re +.tp +.i /proc/sys/kernel/sg\-big\-buff +this file +shows the size of the generic scsi device (sg) buffer. +you can't tune it just yet, but you could change it at +compile time by editing +.i include/scsi/sg.h +and changing +the value of +.br sg_big_buff . +however, there shouldn't be any reason to change this value. +.tp +.ir /proc/sys/kernel/shm_rmid_forced " (since linux 3.1)" +.\" commit b34a6b1da371ed8af1221459a18c67970f7e3d53 +.\" see also documentation/sysctl/kernel.txt +if this file is set to 1, all system v shared memory segments will +be marked for destruction as soon as the number of attached processes +falls to zero; +in other words, it is no longer possible to create shared memory segments +that exist independently of any attached process. +.ip +the effect is as though a +.br shmctl (2) +.b ipc_rmid +is performed on all existing segments as well as all segments +created in the future (until this file is reset to 0). +note that existing segments that are attached to no process will be +immediately destroyed when this file is set to 1. +setting this option will also destroy segments that were created, +but never attached, +upon termination of the process that created the segment with +.br shmget (2). +.ip +setting this file to 1 provides a way of ensuring that +all system v shared memory segments are counted against the +resource usage and resource limits (see the description of +.b rlimit_as +in +.br getrlimit (2)) +of at least one process. +.ip +because setting this file to 1 produces behavior that is nonstandard +and could also break existing applications, +the default value in this file is 0. +set this file to 1 only if you have a good understanding +of the semantics of the applications using +system v shared memory on your system. +.tp +.ir /proc/sys/kernel/shmall " (since linux 2.2)" +this file +contains the system-wide limit on the total number of pages of +system v shared memory. +.tp +.ir /proc/sys/kernel/shmmax " (since linux 2.2)" +this file +can be used to query and set the run-time limit +on the maximum (system v ipc) shared memory segment size that can be +created. +shared memory segments up to 1 gb are now supported in the +kernel. +this value defaults to +.br shmmax . +.tp +.ir /proc/sys/kernel/shmmni " (since linux 2.4)" +this file +specifies the system-wide maximum number of system v shared memory +segments that can be created. +.tp +.ir /proc/sys/kernel/sysctl_writes_strict " (since linux 3.16)" +.\" commit f88083005ab319abba5d0b2e4e997558245493c8 +.\" commit 2ca9bb456ada8bcbdc8f77f8fc78207653bbaa92 +.\" commit f4aacea2f5d1a5f7e3154e967d70cf3f711bcd61 +.\" commit 24fe831c17ab8149413874f2fd4e5c8a41fcd294 +the value in this file determines how the file offset affects +the behavior of updating entries in files under +.ir /proc/sys . +the file has three possible values: +.rs +.tp 4 +\-1 +this provides legacy handling, with no printk warnings. +each +.br write (2) +must fully contain the value to be written, +and multiple writes on the same file descriptor +will overwrite the entire value, regardless of the file position. +.tp +0 +(default) this provides the same behavior as for \-1, +but printk warnings are written for processes that +perform writes when the file offset is not 0. +.tp +1 +respect the file offset when writing strings into +.i /proc/sys +files. +multiple writes will +.i append +to the value buffer. +anything written beyond the maximum length +of the value buffer will be ignored. +writes to numeric +.i /proc/sys +entries must always be at file offset 0 and the value must be +fully contained in the buffer provided to +.br write (2). +.\" fixme . +.\" with /proc/sys/kernel/sysctl_writes_strict==1, writes at an +.\" offset other than 0 do not generate an error. instead, the +.\" write() succeeds, but the file is left unmodified. +.\" this is surprising. the behavior may change in the future. +.\" see thread.gmane.org/gmane.linux.man/9197 +.\" from: michael kerrisk (man-pages +.\" subject: sysctl_writes_strict documentation + an oddity? +.\" newsgroups: gmane.linux.man, gmane.linux.kernel +.\" date: 2015-05-09 08:54:11 gmt +.re +.tp +.i /proc/sys/kernel/sysrq +this file controls the functions allowed to be invoked by the sysrq key. +by default, +the file contains 1 meaning that every possible sysrq request is allowed +(in older kernel versions, sysrq was disabled by default, +and you were required to specifically enable it at run-time, +but this is not the case any more). +possible values in this file are: +.rs +.tp 5 +0 +disable sysrq completely +.tp +1 +enable all functions of sysrq +.tp +> 1 +bit mask of allowed sysrq functions, as follows: +.pd 0 +.rs +.tp 5 +\ \ 2 +enable control of console logging level +.tp +\ \ 4 +enable control of keyboard (sak, unraw) +.tp +\ \ 8 +enable debugging dumps of processes etc. +.tp +\ 16 +enable sync command +.tp +\ 32 +enable remount read-only +.tp +\ 64 +enable signaling of processes (term, kill, oom-kill) +.tp +128 +allow reboot/poweroff +.tp +256 +allow nicing of all real-time tasks +.re +.pd +.re +.ip +this file is present only if the +.b config_magic_sysrq +kernel configuration option is enabled. +for further details see the linux kernel source file +.i documentation/admin\-guide/sysrq.rst +.\" commit 9d85025b0418163fae079c9ba8f8445212de8568 +(or +.i documentation/sysrq.txt +before linux 4.10). +.tp +.i /proc/sys/kernel/version +this file contains a string such as: +.ip + #5 wed feb 25 21:49:24 met 1998 +.ip +the "#5" means that +this is the fifth kernel built from this source base and the +date following it indicates the time the kernel was built. +.tp +.ir /proc/sys/kernel/threads\-max " (since linux 2.3.11)" +.\" the following is based on documentation/sysctl/kernel.txt +this file specifies the system-wide limit on the number of +threads (tasks) that can be created on the system. +.ip +since linux 4.1, +.\" commit 230633d109e35b0a24277498e773edeb79b4a331 +the value that can be written to +.i threads\-max +is bounded. +the minimum value that can be written is 20. +the maximum value that can be written is given by the +constant +.b futex_tid_mask +(0x3fffffff). +if a value outside of this range is written to +.ir threads\-max , +the error +.b einval +occurs. +.ip +the value written is checked against the available ram pages. +if the thread structures would occupy too much (more than 1/8th) +of the available ram pages, +.i threads\-max +is reduced accordingly. +.tp +.ir /proc/sys/kernel/yama/ptrace_scope " (since linux 3.5)" +see +.br ptrace (2). +.tp +.ir /proc/sys/kernel/zero\-paged " (powerpc only)" +this file +contains a flag. +when enabled (nonzero), linux-ppc will pre-zero pages in +the idle loop, possibly speeding up get_free_pages. +.tp +.i /proc/sys/net +this directory contains networking stuff. +explanations for some of the files under this directory can be found in +.br tcp (7) +and +.br ip (7). +.tp +.i /proc/sys/net/core/bpf_jit_enable +see +.br bpf (2). +.tp +.i /proc/sys/net/core/somaxconn +this file defines a ceiling value for the +.i backlog +argument of +.br listen (2); +see the +.br listen (2) +manual page for details. +.tp +.i /proc/sys/proc +this directory may be empty. +.tp +.i /proc/sys/sunrpc +this directory supports sun remote procedure call for network filesystem +(nfs). +on some systems, it is not present. +.tp +.ir /proc/sys/user " (since linux 4.9)" +see +.br namespaces (7). +.tp +.i /proc/sys/vm +this directory contains files for memory management tuning, buffer, and +cache management. +.tp +.ir /proc/sys/vm/admin_reserve_kbytes " (since linux 3.10)" +.\" commit 4eeab4f5580d11bffedc697684b91b0bca0d5009 +this file defines the amount of free memory (in kib) on the system that +should be reserved for users with the capability +.br cap_sys_admin . +.ip +the default value in this file is the minimum of [3% of free pages, 8mib] +expressed as kib. +the default is intended to provide enough for the superuser +to log in and kill a process, if necessary, +under the default overcommit 'guess' mode (i.e., 0 in +.ir /proc/sys/vm/overcommit_memory ). +.ip +systems running in "overcommit never" mode (i.e., 2 in +.ir /proc/sys/vm/overcommit_memory ) +should increase the value in this file to account +for the full virtual memory size of the programs used to recover (e.g., +.br login (1) +.br ssh (1), +and +.br top (1)) +otherwise, the superuser may not be able to log in to recover the system. +for example, on x86-64 a suitable value is 131072 (128mib reserved). +.ip +changing the value in this file takes effect whenever +an application requests memory. +.tp +.ir /proc/sys/vm/compact_memory " (since linux 2.6.35)" +when 1 is written to this file, all zones are compacted such that free +memory is available in contiguous blocks where possible. +the effect of this action can be seen by examining +.ir /proc/buddyinfo . +.ip +present only if the kernel was configured with +.br config_compaction . +.tp +.ir /proc/sys/vm/drop_caches " (since linux 2.6.16)" +writing to this file causes the kernel to drop clean caches, dentries, and +inodes from memory, causing that memory to become free. +this can be useful for memory management testing and +performing reproducible filesystem benchmarks. +because writing to this file causes the benefits of caching to be lost, +it can degrade overall system performance. +.ip +to free pagecache, use: +.ip + echo 1 > /proc/sys/vm/drop_caches +.ip +to free dentries and inodes, use: +.ip + echo 2 > /proc/sys/vm/drop_caches +.ip +to free pagecache, dentries, and inodes, use: +.ip + echo 3 > /proc/sys/vm/drop_caches +.ip +because writing to this file is a nondestructive operation and dirty objects +are not freeable, the +user should run +.br sync (1) +first. +.tp +.ir /proc/sys/vm/sysctl_hugetlb_shm_group " (since linux 2.6.7)" +this writable file contains a group id that is allowed +to allocate memory using huge pages. +if a process has a filesystem group id or any supplementary group id that +matches this group id, +then it can make huge-page allocations without holding the +.br cap_ipc_lock +capability; see +.br memfd_create (2), +.br mmap (2), +and +.br shmget (2). +.tp +.ir /proc/sys/vm/legacy_va_layout " (since linux 2.6.9)" +.\" the following is from documentation/filesystems/proc.txt +if nonzero, this disables the new 32-bit memory-mapping layout; +the kernel will use the legacy (2.4) layout for all processes. +.tp +.ir /proc/sys/vm/memory_failure_early_kill " (since linux 2.6.32)" +.\" the following is based on the text in documentation/sysctl/vm.txt +control how to kill processes when an uncorrected memory error +(typically a 2-bit error in a memory module) +that cannot be handled by the kernel +is detected in the background by hardware. +in some cases (like the page still having a valid copy on disk), +the kernel will handle the failure +transparently without affecting any applications. +but if there is no other up-to-date copy of the data, +it will kill processes to prevent any data corruptions from propagating. +.ip +the file has one of the following values: +.rs +.ip 1: 4 +kill all processes that have the corrupted-and-not-reloadable page mapped +as soon as the corruption is detected. +note that this is not supported for a few types of pages, +such as kernel internally +allocated data or the swap cache, but works for the majority of user pages. +.ip 0: 4 +unmap the corrupted page from all processes and kill a process +only if it tries to access the page. +.re +.ip +the kill is performed using a +.b sigbus +signal with +.i si_code +set to +.br bus_mceerr_ao . +processes can handle this if they want to; see +.br sigaction (2) +for more details. +.ip +this feature is active only on architectures/platforms with advanced machine +check handling and depends on the hardware capabilities. +.ip +applications can override the +.i memory_failure_early_kill +setting individually with the +.br prctl (2) +.b pr_mce_kill +operation. +.ip +present only if the kernel was configured with +.br config_memory_failure . +.tp +.ir /proc/sys/vm/memory_failure_recovery " (since linux 2.6.32)" +.\" the following is based on the text in documentation/sysctl/vm.txt +enable memory failure recovery (when supported by the platform). +.rs +.ip 1: 4 +attempt recovery. +.ip 0: 4 +always panic on a memory failure. +.re +.ip +present only if the kernel was configured with +.br config_memory_failure . +.tp +.ir /proc/sys/vm/oom_dump_tasks " (since linux 2.6.25)" +.\" the following is from documentation/sysctl/vm.txt +enables a system-wide task dump (excluding kernel threads) to be +produced when the kernel performs an oom-killing. +the dump includes the following information +for each task (thread, process): +thread id, real user id, thread group id (process id), +virtual memory size, resident set size, +the cpu that the task is scheduled on, +oom_adj score (see the description of +.ir /proc/[pid]/oom_adj ), +and command name. +this is helpful to determine why the oom-killer was invoked +and to identify the rogue task that caused it. +.ip +if this contains the value zero, this information is suppressed. +on very large systems with thousands of tasks, +it may not be feasible to dump the memory state information for each one. +such systems should not be forced to incur a performance penalty in +oom situations when the information may not be desired. +.ip +if this is set to nonzero, this information is shown whenever the +oom-killer actually kills a memory-hogging task. +.ip +the default value is 0. +.tp +.ir /proc/sys/vm/oom_kill_allocating_task " (since linux 2.6.24)" +.\" the following is from documentation/sysctl/vm.txt +this enables or disables killing the oom-triggering task in +out-of-memory situations. +.ip +if this is set to zero, the oom-killer will scan through the entire +tasklist and select a task based on heuristics to kill. +this normally selects a rogue memory-hogging task that +frees up a large amount of memory when killed. +.ip +if this is set to nonzero, the oom-killer simply kills the task that +triggered the out-of-memory condition. +this avoids a possibly expensive tasklist scan. +.ip +if +.i /proc/sys/vm/panic_on_oom +is nonzero, it takes precedence over whatever value is used in +.ir /proc/sys/vm/oom_kill_allocating_task . +.ip +the default value is 0. +.tp +.ir /proc/sys/vm/overcommit_kbytes " (since linux 3.14)" +.\" commit 49f0ce5f92321cdcf741e35f385669a421013cb7 +this writable file provides an alternative to +.ir /proc/sys/vm/overcommit_ratio +for controlling the +.i commitlimit +when +.ir /proc/sys/vm/overcommit_memory +has the value 2. +it allows the amount of memory overcommitting to be specified as +an absolute value (in kb), +rather than as a percentage, as is done with +.ir overcommit_ratio . +this allows for finer-grained control of +.ir commitlimit +on systems with extremely large memory sizes. +.ip +only one of +.ir overcommit_kbytes +or +.ir overcommit_ratio +can have an effect: +if +.ir overcommit_kbytes +has a nonzero value, then it is used to calculate +.ir commitlimit , +otherwise +.ir overcommit_ratio +is used. +writing a value to either of these files causes the +value in the other file to be set to zero. +.tp +.i /proc/sys/vm/overcommit_memory +this file contains the kernel virtual memory accounting mode. +values are: +.rs +.ip +0: heuristic overcommit (this is the default) +.br +1: always overcommit, never check +.br +2: always check, never overcommit +.re +.ip +in mode 0, calls of +.br mmap (2) +with +.b map_noreserve +are not checked, and the default check is very weak, +leading to the risk of getting a process "oom-killed". +.ip +in mode 1, the kernel pretends there is always enough memory, +until memory actually runs out. +one use case for this mode is scientific computing applications +that employ large sparse arrays. +in linux kernel versions before 2.6.0, any nonzero value implies mode 1. +.ip +in mode 2 (available since linux 2.6), the total virtual address space +that can be allocated +.ri ( commitlimit +in +.ir /proc/meminfo ) +is calculated as +.ip + commitlimit = (total_ram \- total_huge_tlb) * + overcommit_ratio / 100 + total_swap +.ip +where: +.rs 12 +.ip * 3 +.i total_ram +is the total amount of ram on the system; +.ip * +.i total_huge_tlb +is the amount of memory set aside for huge pages; +.ip * +.i overcommit_ratio +is the value in +.ir /proc/sys/vm/overcommit_ratio ; +and +.ip * +.i total_swap +is the amount of swap space. +.re +.ip +for example, on a system with 16 gb of physical ram, 16 gb +of swap, no space dedicated to huge pages, and an +.i overcommit_ratio +of 50, this formula yields a +.i commitlimit +of 24 gb. +.ip +since linux 3.14, if the value in +.i /proc/sys/vm/overcommit_kbytes +is nonzero, then +.i commitlimit +is instead calculated as: +.ip + commitlimit = overcommit_kbytes + total_swap +.ip +see also the description of +.ir /proc/sys/vm/admin_reserve_kbytes +and +.ir /proc/sys/vm/user_reserve_kbytes . +.tp +.ir /proc/sys/vm/overcommit_ratio " (since linux 2.6.0)" +this writable file defines a percentage by which memory +can be overcommitted. +the default value in the file is 50. +see the description of +.ir /proc/sys/vm/overcommit_memory . +.tp +.ir /proc/sys/vm/panic_on_oom " (since linux 2.6.18)" +.\" the following is adapted from documentation/sysctl/vm.txt +this enables or disables a kernel panic in +an out-of-memory situation. +.ip +if this file is set to the value 0, +the kernel's oom-killer will kill some rogue process. +usually, the oom-killer is able to kill a rogue process and the +system will survive. +.ip +if this file is set to the value 1, +then the kernel normally panics when out-of-memory happens. +however, if a process limits allocations to certain nodes +using memory policies +.rb ( mbind (2) +.br mpol_bind ) +or cpusets +.rb ( cpuset (7)) +and those nodes reach memory exhaustion status, +one process may be killed by the oom-killer. +no panic occurs in this case: +because other nodes' memory may be free, +this means the system as a whole may not have reached +an out-of-memory situation yet. +.ip +if this file is set to the value 2, +the kernel always panics when an out-of-memory condition occurs. +.ip +the default value is 0. +1 and 2 are for failover of clustering. +select either according to your policy of failover. +.tp +.ir /proc/sys/vm/swappiness +.\" the following is from documentation/sysctl/vm.txt +the value in this file controls how aggressively the kernel will swap +memory pages. +higher values increase aggressiveness, lower values +decrease aggressiveness. +the default value is 60. +.tp +.ir /proc/sys/vm/user_reserve_kbytes " (since linux 3.10)" +.\" commit c9b1d0981fcce3d9976d7b7a56e4e0503bc610dd +specifies an amount of memory (in kib) to reserve for user processes. +this is intended to prevent a user from starting a single memory hogging +process, such that they cannot recover (kill the hog). +the value in this file has an effect only when +.ir /proc/sys/vm/overcommit_memory +is set to 2 ("overcommit never" mode). +in this case, the system reserves an amount of memory that is the minimum +of [3% of current process size, +.ir user_reserve_kbytes ]. +.ip +the default value in this file is the minimum of [3% of free pages, 128mib] +expressed as kib. +.ip +if the value in this file is set to zero, +then a user will be allowed to allocate all free memory with a single process +(minus the amount reserved by +.ir /proc/sys/vm/admin_reserve_kbytes ). +any subsequent attempts to execute a command will result in +"fork: cannot allocate memory". +.ip +changing the value in this file takes effect whenever +an application requests memory. +.tp +.ir /proc/sys/vm/unprivileged_userfaultfd " (since linux 5.2)" +.\" cefdca0a86be517bc390fc4541e3674b8e7803b0 +this (writable) file exposes a flag that controls whether +unprivileged processes are allowed to employ +.br userfaultfd (2). +if this file has the value 1, then unprivileged processes may use +.br userfaultfd (2). +if this file has the value 0, then only processes that have the +.b cap_sys_ptrace +capability may employ +.br userfaultfd (2). +the default value in this file is 1. +.tp +.ir /proc/sysrq\-trigger " (since linux 2.4.21)" +writing a character to this file triggers the same sysrq function as +typing alt-sysrq- (see the description of +.ir /proc/sys/kernel/sysrq ). +this file is normally writable only by +.ir root . +for further details see the linux kernel source file +.i documentation/admin\-guide/sysrq.rst +.\" commit 9d85025b0418163fae079c9ba8f8445212de8568 +(or +.i documentation/sysrq.txt +before linux 4.10). +.tp +.i /proc/sysvipc +subdirectory containing the pseudo-files +.ir msg ", " sem " and " shm "." +these files list the system v interprocess communication (ipc) objects +(respectively: message queues, semaphores, and shared memory) +that currently exist on the system, +providing similar information to that available via +.br ipcs (1). +these files have headers and are formatted (one ipc object per line) +for easy understanding. +.br sysvipc (7) +provides further background on the information shown by these files. +.tp +.ir /proc/thread\-self " (since linux 3.17)" +.\" commit 0097875bd41528922fb3bb5f348c53f17e00e2fd +this directory refers to the thread accessing the +.i /proc +filesystem, +and is identical to the +.i /proc/self/task/[tid] +directory named by the process thread id +.ri ( [tid] ) +of the same thread. +.tp +.ir /proc/timer_list " (since linux 2.6.21)" +.\" commit 289f480af87e45f7a6de6ba9b4c061c2e259fe98 +this read-only file exposes a list of all currently pending +(high-resolution) timers, +all clock-event sources, and their parameters in a human-readable form. +.tp +.ir /proc/timer_stats " (from linux 2.6.21 until linux 4.10)" +.\" commit 82f67cd9fca8c8762c15ba7ed0d5747588c1e221 +.\" date: fri feb 16 01:28:13 2007 -0800 +.\" text largely derived from documentation/timers/timer_stats.txt +.\" removed in commit dfb4357da6ddbdf57d583ba64361c9d792b0e0b1 +.\" date: wed feb 8 11:26:59 2017 -0800 +this is a debugging facility to make timer (ab)use in a linux +system visible to kernel and user-space developers. +it can be used by kernel and user-space developers to verify that +their code does not make undue use of timers. +the goal is to avoid unnecessary wakeups, +thereby optimizing power consumption. +.ip +if enabled in the kernel +.rb ( config_timer_stats ), +but not used, +it has almost zero run-time overhead and a relatively small +data-structure overhead. +even if collection is enabled at run time, overhead is low: +all the locking is per-cpu and lookup is hashed. +.ip +the +.i /proc/timer_stats +file is used both to control sampling facility and to read out the +sampled information. +.ip +the +.i timer_stats +functionality is inactive on bootup. +a sampling period can be started using the following command: +.ip +.in +4n +.ex +# echo 1 > /proc/timer_stats +.ee +.in +.ip +the following command stops a sampling period: +.ip +.in +4n +.ex +# echo 0 > /proc/timer_stats +.ee +.in +.ip +the statistics can be retrieved by: +.ip +.in +4n +.ex +$ cat /proc/timer_stats +.ee +.in +.ip +while sampling is enabled, each readout from +.i /proc/timer_stats +will see +newly updated statistics. +once sampling is disabled, the sampled information +is kept until a new sample period is started. +this allows multiple readouts. +.ip +sample output from +.ir /proc/timer_stats : +.ip +.in +4n +.ex +.rb $ " cat /proc/timer_stats" +timer stats version: v0.3 +sample period: 1.764 s +collection: active + 255, 0 swapper/3 hrtimer_start_range_ns (tick_sched_timer) + 71, 0 swapper/1 hrtimer_start_range_ns (tick_sched_timer) + 58, 0 swapper/0 hrtimer_start_range_ns (tick_sched_timer) + 4, 1694 gnome\-shell mod_delayed_work_on (delayed_work_timer_fn) + 17, 7 rcu_sched rcu_gp_kthread (process_timeout) +\&... + 1, 4911 kworker/u16:0 mod_delayed_work_on (delayed_work_timer_fn) + 1d, 2522 kworker/0:0 queue_delayed_work_on (delayed_work_timer_fn) +1029 total events, 583.333 events/sec +.ee +.in +.ip +the output columns are: +.rs +.ip * 3 +a count of the number of events, +optionally (since linux 2.6.23) followed by the letter \(aqd\(aq +.\" commit c5c061b8f9726bc2c25e19dec227933a13d1e6b7 deferrable timers +if this is a deferrable timer; +.ip * +the pid of the process that initialized the timer; +.ip * +the name of the process that initialized the timer; +.ip * +the function where the timer was initialized; and +.ip * +(in parentheses) +the callback function that is associated with the timer. +.re +.ip +during the linux 4.11 development cycle, +this file was removed because of security concerns, +as it exposes information across namespaces. +furthermore, it is possible to obtain +the same information via in-kernel tracing facilities such as ftrace. +.tp +.i /proc/tty +subdirectory containing the pseudo-files and subdirectories for +tty drivers and line disciplines. +.tp +.i /proc/uptime +this file contains two numbers (values in seconds): the uptime of the +system (including time spent in suspend) and the amount of time spent +in the idle process. +.tp +.i /proc/version +this string identifies the kernel version that is currently running. +it includes the contents of +.ir /proc/sys/kernel/ostype , +.ir /proc/sys/kernel/osrelease , +and +.ir /proc/sys/kernel/version . +for example: +.ip +.in +4n +.ex +linux version 1.0.9 (quinlan@phaze) #1 sat may 14 01:51:54 edt 1994 +.ee +.in +.\" fixme 2.6.13 seems to have /proc/vmcore implemented; document this +.\" see documentation/kdump/kdump.txt +.\" commit 666bfddbe8b8fd4fd44617d6c55193d5ac7edb29 +.\" needs config_vmcore +.\" +.tp +.ir /proc/vmstat " (since linux 2.6.0)" +this file displays various virtual memory statistics. +each line of this file contains a single name-value pair, +delimited by white space. +some lines are present only if the kernel was configured with +suitable options. +(in some cases, the options required for particular files have changed +across kernel versions, so they are not listed here. +details can be found by consulting the kernel source code.) +the following fields may be present: +.\" fixme we need explanations for each of the following fields... +.rs +.tp +.ir nr_free_pages " (since linux 2.6.31)" +.\" commit d23ad42324cc4378132e51f2fc5c9ba6cbe75182 +.tp +.ir nr_alloc_batch " (since linux 3.12)" +.\" commit 81c0a2bb515fd4daae8cab64352877480792b515 +.tp +.ir nr_inactive_anon " (since linux 2.6.28)" +.\" commit 4f98a2fee8acdb4ac84545df98cccecfd130f8db +.tp +.ir nr_active_anon " (since linux 2.6.28)" +.\" commit 4f98a2fee8acdb4ac84545df98cccecfd130f8db +.tp +.ir nr_inactive_file " (since linux 2.6.28)" +.\" commit 4f98a2fee8acdb4ac84545df98cccecfd130f8db +.tp +.ir nr_active_file " (since linux 2.6.28)" +.\" commit 4f98a2fee8acdb4ac84545df98cccecfd130f8db +.tp +.ir nr_unevictable " (since linux 2.6.28)" +.\" commit 7b854121eb3e5ba0241882ff939e2c485228c9c5 +.tp +.ir nr_mlock " (since linux 2.6.28)" +.\" commit 5344b7e648980cc2ca613ec03a56a8222ff48820 +.tp +.ir nr_anon_pages " (since linux 2.6.18)" +.\" commit f3dbd34460ff54962d3e3244b6bcb7f5295356e6 +.tp +.ir nr_mapped " (since linux 2.6.0)" +.tp +.ir nr_file_pages " (since linux 2.6.18)" +.\" commit 347ce434d57da80fd5809c0c836f206a50999c26 +.tp +.ir nr_dirty " (since linux 2.6.0)" +.tp +.ir nr_writeback " (since linux 2.6.0)" +.tp +.ir nr_slab_reclaimable " (since linux 2.6.19)" +.\" commit 972d1a7b140569084439a81265a0f15b74e924e0 +.\" linux 2.6.0 had nr_slab +.tp +.ir nr_slab_unreclaimable " (since linux 2.6.19)" +.\" commit 972d1a7b140569084439a81265a0f15b74e924e0 +.tp +.ir nr_page_table_pages " (since linux 2.6.0)" +.tp +.ir nr_kernel_stack " (since linux 2.6.32)" +.\" commit c6a7f5728a1db45d30df55a01adc130b4ab0327c +amount of memory allocated to kernel stacks. +.tp +.ir nr_unstable " (since linux 2.6.0)" +.tp +.ir nr_bounce " (since linux 2.6.12)" +.\" commit edfbe2b0038723e5699ab22695ccd62b5542a5c1 +.tp +.ir nr_vmscan_write " (since linux 2.6.19)" +.\" commit e129b5c23c2b471d47f1c5d2b8b193fc2034af43 +.tp +.ir nr_vmscan_immediate_reclaim " (since linux 3.2)" +.\" commit 49ea7eb65e7c5060807fb9312b1ad4c3eab82e2c +.tp +.ir nr_writeback_temp " (since linux 2.6.26)" +.\" commit fc3ba692a4d19019387c5acaea63131f9eab05dd +.tp +.ir nr_isolated_anon " (since linux 2.6.32)" +.\" commit a731286de62294b63d8ceb3c5914ac52cc17e690 +.tp +.ir nr_isolated_file " (since linux 2.6.32)" +.\" commit a731286de62294b63d8ceb3c5914ac52cc17e690 +.tp +.ir nr_shmem " (since linux 2.6.32)" +.\" commit 4b02108ac1b3354a22b0d83c684797692efdc395 +pages used by shmem and +.br tmpfs (5). +.tp +.ir nr_dirtied " (since linux 2.6.37)" +.\" commit ea941f0e2a8c02ae876cd73deb4e1557248f258c +.tp +.ir nr_written " (since linux 2.6.37)" +.\" commit ea941f0e2a8c02ae876cd73deb4e1557248f258c +.tp +.ir nr_pages_scanned " (since linux 3.17)" +.\" commit 0d5d823ab4e608ec7b52ac4410de4cb74bbe0edd +.tp +.ir numa_hit " (since linux 2.6.18)" +.\" commit ca889e6c45e0b112cb2ca9d35afc66297519b5d5 +.\" present only if the kernel was configured with +.\" .br config_numa . +.tp +.ir numa_miss " (since linux 2.6.18)" +.\" commit ca889e6c45e0b112cb2ca9d35afc66297519b5d5 +.\" present only if the kernel was configured with +.\" .br config_numa . +.tp +.ir numa_foreign " (since linux 2.6.18)" +.\" commit ca889e6c45e0b112cb2ca9d35afc66297519b5d5 +.\" present only if the kernel was configured with +.\" .br config_numa . +.tp +.ir numa_interleave " (since linux 2.6.18)" +.\" commit ca889e6c45e0b112cb2ca9d35afc66297519b5d5 +.\" present only if the kernel was configured with +.\" .br config_numa . +.tp +.ir numa_local " (since linux 2.6.18)" +.\" commit ca889e6c45e0b112cb2ca9d35afc66297519b5d5 +.\" present only if the kernel was configured with +.\" .br config_numa . +.tp +.ir numa_other " (since linux 2.6.18)" +.\" commit ca889e6c45e0b112cb2ca9d35afc66297519b5d5 +.\" present only if the kernel was configured with +.\" .br config_numa . +.tp +.ir workingset_refault " (since linux 3.15)" +.\" commit a528910e12ec7ee203095eb1711468a66b9b60b0 +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir workingset_activate " (since linux 3.15)" +.\" commit a528910e12ec7ee203095eb1711468a66b9b60b0 +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir workingset_nodereclaim " (since linux 3.15)" +.\" commit 449dd6984d0e47643c04c807f609dd56d48d5bcc +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir nr_anon_transparent_hugepages " (since linux 2.6.38)" +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir nr_free_cma " (since linux 3.7)" +.\" commit d1ce749a0db12202b711d1aba1d29e823034648d +number of free cma (contiguous memory allocator) pages. +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir nr_dirty_threshold " (since linux 2.6.37)" +.\" commit 79da826aee6a10902ef411bc65864bd02102fa83 +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir nr_dirty_background_threshold " (since linux 2.6.37)" +.\" commit 79da826aee6a10902ef411bc65864bd02102fa83 +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir pgpgin " (since linux 2.6.0)" +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir pgpgout " (since linux 2.6.0)" +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir pswpin " (since linux 2.6.0)" +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir pswpout " (since linux 2.6.0)" +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir pgalloc_dma " (since linux 2.6.5)" +.\" linux 2.6.0 had pgalloc +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir pgalloc_dma32 " (since linux 2.6.16)" +.\" commit 9328b8faae922e52073785ed6c1eaa8565648a0e +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir pgalloc_normal " (since linux 2.6.5)" +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir pgalloc_high " (since linux 2.6.5)" +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters +.\" and +.\" .br config_highmem . +.tp +.ir pgalloc_movable " (since linux 2.6.23)" +.\" commit 2a1e274acf0b1c192face19a4be7c12d4503eaaf +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir pgfree " (since linux 2.6.0)" +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir pgactivate " (since linux 2.6.0)" +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir pgdeactivate " (since linux 2.6.0)" +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir pgfault " (since linux 2.6.0)" +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir pgmajfault " (since linux 2.6.0)" +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir pgrefill_dma " (since linux 2.6.5)" +.\" linux 2.6.0 had pgrefill +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir pgrefill_dma32 " (since linux 2.6.16)" +.\" commit 9328b8faae922e52073785ed6c1eaa8565648a0e +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir pgrefill_normal " (since linux 2.6.5)" +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir pgrefill_high " (since linux 2.6.5)" +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters +.\" and +.\" .br config_highmem . +.tp +.ir pgrefill_movable " (since linux 2.6.23)" +.\" commit 2a1e274acf0b1c192face19a4be7c12d4503eaaf +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.\" formerly there were +.\" pgsteal_high +.\" pgsteal_normal +.\" pgsteal_dma32 +.\" pgsteal_dma +.\" these were split out into pgsteal_kswapd* and pgsteal_direct* +.\" in commit 904249aa68010c8e223263c922fcbb840a3f42e4 +.tp +.ir pgsteal_kswapd_dma " (since linux 3.4)" +.\" commit 904249aa68010c8e223263c922fcbb840a3f42e4 +.\" linux 2.6.0 had pgsteal +.\" present only if the kernel was configured with +.\" .\" .br config_vm_event_counters . +.tp +.ir pgsteal_kswapd_dma32 " (since linux 3.4)" +.\" commit 904249aa68010c8e223263c922fcbb840a3f42e4 +.\" commit 9328b8faae922e52073785ed6c1eaa8565648a0e +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir pgsteal_kswapd_normal " (since linux 3.4)" +.\" commit 904249aa68010c8e223263c922fcbb840a3f42e4 +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir pgsteal_kswapd_high " (since linux 3.4)" +.\" commit 904249aa68010c8e223263c922fcbb840a3f42e4 +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters +.\" and +.\" .br config_highmem . +.tp +.ir pgsteal_kswapd_movable " (since linux 3.4)" +.\" commit 904249aa68010c8e223263c922fcbb840a3f42e4 +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir pgsteal_direct_dma +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir pgsteal_direct_dma32 " (since linux 3.4)" +.\" commit 904249aa68010c8e223263c922fcbb840a3f42e4 +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir pgsteal_direct_normal " (since linux 3.4)" +.\" commit 904249aa68010c8e223263c922fcbb840a3f42e4 +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir pgsteal_direct_high " (since linux 3.4)" +.\" commit 904249aa68010c8e223263c922fcbb840a3f42e4 +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters +.\" and +.\" .br config_highmem . +.tp +.ir pgsteal_direct_movable " (since linux 2.6.23)" +.\" commit 2a1e274acf0b1c192face19a4be7c12d4503eaaf +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir pgscan_kswapd_dma +.\" linux 2.6.0 had pgscan +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir pgscan_kswapd_dma32 " (since linux 2.6.16)" +.\" commit 9328b8faae922e52073785ed6c1eaa8565648a0e +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir pgscan_kswapd_normal " (since linux 2.6.5)" +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir pgscan_kswapd_high +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters +.\" and +.\" .br config_highmem . +.tp +.ir pgscan_kswapd_movable " (since linux 2.6.23)" +.\" commit 2a1e274acf0b1c192face19a4be7c12d4503eaaf +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir pgscan_direct_dma +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir pgscan_direct_dma32 " (since linux 2.6.16)" +.\" commit 9328b8faae922e52073785ed6c1eaa8565648a0e +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir pgscan_direct_normal +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir pgscan_direct_high +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters +.\" and +.\" .br config_highmem . +.tp +.ir pgscan_direct_movable " (since linux 2.6.23)" +.\" commit 2a1e274acf0b1c192face19a4be7c12d4503eaaf +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir pgscan_direct_throttle " (since linux 3.6)" +.\" commit 68243e76ee343d63c6cf76978588a885951e2818 +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir zone_reclaim_failed " (since linux 2.6.31)" +.\" commit 24cf72518c79cdcda486ed26074ff8151291cf65 +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters +.\" and +.\" .br config_numa . +.tp +.ir pginodesteal " (since linux 2.6.0)" +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir slabs_scanned " (since linux 2.6.5)" +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir kswapd_inodesteal " (since linux 2.6.0)" +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir kswapd_low_wmark_hit_quickly " (since 2.6.33)" +.\" commit bb3ab596832b920c703d1aea1ce76d69c0f71fb7 +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir kswapd_high_wmark_hit_quickly " (since 2.6.33)" +.\" commit bb3ab596832b920c703d1aea1ce76d69c0f71fb7 +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir pageoutrun " (since linux 2.6.0)" +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir allocstall " (since linux 2.6.0)" +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir pgrotated " (since linux 2.6.0)" +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir drop_pagecache " (since linux 3.15)" +.\" commit 5509a5d27b971a90b940e148ca9ca53312e4fa7a +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir drop_slab " (since linux 3.15)" +.\" commit 5509a5d27b971a90b940e148ca9ca53312e4fa7a +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir numa_pte_updates " (since linux 3.8)" +.\" commit 03c5a6e16322c997bf8f264851bfa3f532ad515f +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters +.\" and +.\" .br config_numa_balancing . +.tp +.ir numa_huge_pte_updates " (since linux 3.13)" +.\" commit 72403b4a0fbdf433c1fe0127e49864658f6f6468 +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters +.\" and +.\" .br config_numa_balancing . +.tp +.ir numa_hint_faults " (since linux 3.8)" +.\" commit 03c5a6e16322c997bf8f264851bfa3f532ad515f +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters +.\" and +.\" .br config_numa_balancing . +.tp +.ir numa_hint_faults_local " (since linux 3.8)" +.\" commit 03c5a6e16322c997bf8f264851bfa3f532ad515f +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters +.\" and +.\" .br config_numa_balancing . +.tp +.ir numa_pages_migrated " (since linux 3.8)" +.\" commit 03c5a6e16322c997bf8f264851bfa3f532ad515f +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters +.\" and +.\" .br config_numa_balancing +.\" and +.\" .br config_numa_balancing . +.tp +.ir pgmigrate_success " (since linux 3.8)" +.\" commit 5647bc293ab15f66a7b1cda850c5e9d162a6c7c2 +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters +.\" and +.\" .br config_migration . +.tp +.ir pgmigrate_fail " (since linux 3.8)" +.\" commit 5647bc293ab15f66a7b1cda850c5e9d162a6c7c2 +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters +.\" and +.\" .br config_migration . +.tp +.ir compact_migrate_scanned " (since linux 3.8)" +.\" commit 397487db696cae0b026a474a5cd66f4e372995e6 +.\" linux 3.8 dropped compact_blocks_moved, compact_pages_moved, and +.\" compact_pagemigrate_failed +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters +.\" and +.\" .br config_compaction . +.tp +.ir compact_free_scanned " (since linux 3.8)" +.\" commit 397487db696cae0b026a474a5cd66f4e372995e6 +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters +.\" and +.\" .br config_compaction . +.tp +.ir compact_isolated " (since linux 3.8)" +.\" commit 397487db696cae0b026a474a5cd66f4e372995e6 +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters +.\" and +.\" .br config_compaction . +.tp +.ir compact_stall " (since linux 2.6.35)" +.\" commit 56de7263fcf3eb10c8dcdf8d59a9cec831795f3f +see the kernel source file +.ir documentation/admin\-guide/mm/transhuge.rst . +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters +.\" and +.\" .br config_compaction . +.tp +.ir compact_fail " (since linux 2.6.35)" +.\" commit 56de7263fcf3eb10c8dcdf8d59a9cec831795f3f +see the kernel source file +.ir documentation/admin\-guide/mm/transhuge.rst . +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters +.\" and +.\" .br config_compaction . +.tp +.ir compact_success " (since linux 2.6.35)" +.\" commit 56de7263fcf3eb10c8dcdf8d59a9cec831795f3f +see the kernel source file +.ir documentation/admin\-guide/mm/transhuge.rst . +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters +.\" and +.\" .br config_compaction . +.tp +.ir htlb_buddy_alloc_success " (since linux 2.6.26)" +.\" commit 3b1163006332302117b1b2acf226d4014ff46525 +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters +.\" and +.\" .br config_hugetlb_page . +.tp +.ir htlb_buddy_alloc_fail " (since linux 2.6.26)" +.\" commit 3b1163006332302117b1b2acf226d4014ff46525 +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters +.\" and +.\" .br config_hugetlb_page . +.tp +.ir unevictable_pgs_culled " (since linux 2.6.28)" +.\" commit bbfd28eee9fbd73e780b19beb3dc562befbb94fa +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir unevictable_pgs_scanned " (since linux 2.6.28)" +.\" commit bbfd28eee9fbd73e780b19beb3dc562befbb94fa +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir unevictable_pgs_rescued " (since linux 2.6.28)" +.\" commit bbfd28eee9fbd73e780b19beb3dc562befbb94fa +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir unevictable_pgs_mlocked " (since linux 2.6.28)" +.\" commit 5344b7e648980cc2ca613ec03a56a8222ff48820 +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir unevictable_pgs_munlocked " (since linux 2.6.28)" +.\" commit 5344b7e648980cc2ca613ec03a56a8222ff48820 +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir unevictable_pgs_cleared " (since linux 2.6.28)" +.\" commit 5344b7e648980cc2ca613ec03a56a8222ff48820 +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.tp +.ir unevictable_pgs_stranded " (since linux 2.6.28)" +.\" commit 5344b7e648980cc2ca613ec03a56a8222ff48820 +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters . +.\" linux 3.7 removed unevictable_pgs_mlockfreed +.tp +.ir thp_fault_alloc " (since linux 2.6.39)" +.\" commit 81ab4201fb7d91d6b0cd9ad5b4b16776e4bed145 +see the kernel source file +.ir documentation/admin\-guide/mm/transhuge.rst . +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters +.\" and +.\" .br config_transparent_hugepage . +.tp +.ir thp_fault_fallback " (since linux 2.6.39)" +.\" commit 81ab4201fb7d91d6b0cd9ad5b4b16776e4bed145 +see the kernel source file +.ir documentation/admin\-guide/mm/transhuge.rst . +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters +.\" and +.\" .br config_transparent_hugepage . +.tp +.ir thp_collapse_alloc " (since linux 2.6.39)" +.\" commit 81ab4201fb7d91d6b0cd9ad5b4b16776e4bed145 +see the kernel source file +.ir documentation/admin\-guide/mm/transhuge.rst . +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters +.\" and +.\" .br config_transparent_hugepage . +.tp +.ir thp_collapse_alloc_failed " (since linux 2.6.39)" +.\" commit 81ab4201fb7d91d6b0cd9ad5b4b16776e4bed145 +see the kernel source file +.ir documentation/admin\-guide/mm/transhuge.rst . +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters +.\" and +.\" .br config_transparent_hugepage . +.tp +.ir thp_split " (since linux 2.6.39)" +.\" commit 81ab4201fb7d91d6b0cd9ad5b4b16776e4bed145 +see the kernel source file +.ir documentation/admin\-guide/mm/transhuge.rst . +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters +.\" and +.\" .br config_transparent_hugepage . +.tp +.ir thp_zero_page_alloc " (since linux 3.8)" +.\" commit d8a8e1f0da3d29d7268b3300c96a059d63901b76 +see the kernel source file +.ir documentation/admin\-guide/mm/transhuge.rst . +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters +.\" and +.\" .br config_transparent_hugepage . +.tp +.ir thp_zero_page_alloc_failed " (since linux 3.8)" +.\" commit d8a8e1f0da3d29d7268b3300c96a059d63901b76 +see the kernel source file +.ir documentation/admin\-guide/mm/transhuge.rst . +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters +.\" and +.\" .br config_transparent_hugepage . +.tp +.ir balloon_inflate " (since linux 3.18)" +.\" commit 09316c09dde33aae14f34489d9e3d243ec0d5938 +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters +.\" and +.\" .br config_memory_balloon . +.tp +.ir balloon_deflate " (since linux 3.18)" +.\" commit 09316c09dde33aae14f34489d9e3d243ec0d5938 +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters +.\" and +.\" .br config_memory_balloon . +.tp +.ir balloon_migrate " (since linux 3.18)" +.\" commit 09316c09dde33aae14f34489d9e3d243ec0d5938 +.\" present only if the kernel was configured with +.\" .br config_vm_event_counters , +.\" .br config_memory_balloon , +.\" and +.\" .br config_balloon_compaction . +.tp +.ir nr_tlb_remote_flush " (since linux 3.12)" +.\" commit 9824cf9753ecbe8f5b47aa9b2f218207defea211 +.\" present only if the kernel was configured with +.\" .br config_debug_tlbflush +.\" and +.\" .br config_smp . +.tp +.ir nr_tlb_remote_flush_received " (since linux 3.12)" +.\" commit 9824cf9753ecbe8f5b47aa9b2f218207defea211 +.\" present only if the kernel was configured with +.\" .br config_debug_tlbflush +.\" and +.\" .br config_smp . +.tp +.ir nr_tlb_local_flush_all " (since linux 3.12)" +.\" commit 9824cf9753ecbe8f5b47aa9b2f218207defea211 +.\" present only if the kernel was configured with +.\" .br config_debug_tlbflush . +.tp +.ir nr_tlb_local_flush_one " (since linux 3.12)" +.\" commit 9824cf9753ecbe8f5b47aa9b2f218207defea211 +.\" present only if the kernel was configured with +.\" .br config_debug_tlbflush . +.tp +.ir vmacache_find_calls " (since linux 3.16)" +.\" commit 4f115147ff802267d0aa41e361c5aa5bd933d896 +.\" present only if the kernel was configured with +.\" .br config_debug_vm_vmacache . +.tp +.ir vmacache_find_hits " (since linux 3.16)" +.\" commit 4f115147ff802267d0aa41e361c5aa5bd933d896 +.\" present only if the kernel was configured with +.\" .br config_debug_vm_vmacache . +.tp +.ir vmacache_full_flushes " (since linux 3.19)" +.\" commit f5f302e21257ebb0c074bbafc37606c26d28cc3d +.\" present only if the kernel was configured with +.\" .br config_debug_vm_vmacache . +.re +.tp +.ir /proc/zoneinfo " (since linux 2.6.13)" +this file displays information about memory zones. +this is useful for analyzing virtual memory behavior. +.\" fixme more should be said about /proc/zoneinfo +.sh notes +many files contain strings (e.g., the environment and command line) +that are in the internal format, +with subfields terminated by null bytes (\(aq\e0\(aq). +when inspecting such files, you may find that the results are more readable +if you use a command of the following form to display them: +.pp +.in +4n +.ex +.rb "$" " cat \fifile\fp | tr \(aq\e000\(aq \(aq\en\(aq" +.ee +.in +.pp +this manual page is incomplete, possibly inaccurate, and is the kind +of thing that needs to be updated very often. +.\" .sh acknowledgements +.\" the material on /proc/sys/fs and /proc/sys/kernel is closely based on +.\" kernel source documentation files written by rik van riel. +.sh see also +.br cat (1), +.br dmesg (1), +.br find (1), +.br free (1), +.br htop (1), +.br init (1), +.br ps (1), +.br pstree (1), +.br tr (1), +.br uptime (1), +.br chroot (2), +.br mmap (2), +.br readlink (2), +.br syslog (2), +.br slabinfo (5), +.br sysfs (5), +.br hier (7), +.br namespaces (7), +.br time (7), +.br arp (8), +.br hdparm (8), +.br ifconfig (8), +.br lsmod (8), +.br lspci (8), +.br mount (8), +.br netstat (8), +.br procinfo (8), +.br route (8), +.br sysctl (8) +.pp +the linux kernel source files: +.ir documentation/filesystems/proc.txt , +.ir documentation/sysctl/fs.txt , +.ir documentation/sysctl/kernel.txt , +.ir documentation/sysctl/net.txt , +and +.ir documentation/sysctl/vm.txt . +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/tcgetpgrp.3 + +.so man3/getfsent.3 + +.\" copyright (c) 2003 andries brouwer (aeb@cwi.nl) +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th aio_return 3 2021-03-22 "" "linux programmer's manual" +.sh name +aio_return \- get return status of asynchronous i/o operation +.sh synopsis +.nf +.b "#include " +.pp +.bi "ssize_t aio_return(struct aiocb *" aiocbp ); +.pp +link with \fi\-lrt\fp. +.fi +.sh description +the +.br aio_return () +function returns the final return status for the asynchronous i/o request +with control block pointed to by +.ir aiocbp . +(see +.br aio (7) +for a description of the +.i aiocb +structure.) +.pp +this function should be called only once for any given request, after +.br aio_error (3) +returns something other than +.br einprogress . +.sh return value +if the asynchronous i/o operation has completed, this function returns +the value that would have been returned in case of a synchronous +.br read (2), +.br write (2), +.br fsync (2), +or +.br fdatasync (2), +call. +on error, \-1 is returned, and \fierrno\fp is set to indicate the error. +.pp +if the asynchronous i/o operation has not yet completed, +the return value and effect of +.br aio_return () +are undefined. +.sh errors +.tp +.b einval +.i aiocbp +does not point at a control block for an asynchronous i/o request +of which the return status has not been retrieved yet. +.tp +.b enosys +.br aio_return () +is not implemented. +.sh versions +the +.br aio_return () +function is available since glibc 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br aio_return () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh examples +see +.br aio (7). +.sh see also +.br aio_cancel (3), +.br aio_error (3), +.br aio_fsync (3), +.br aio_read (3), +.br aio_suspend (3), +.br aio_write (3), +.br lio_listio (3), +.br aio (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/stat.2 + +.\" copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de) +.\" and copyright (c) 2011 michael kerrisk +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under gpl +.\" %%%license_end +.\" +.th catan 3 2021-03-22 "" "linux programmer's manual" +.sh name +catan, catanf, catanl \- complex arc tangents +.sh synopsis +.nf +.b #include +.pp +.bi "double complex catan(double complex " z ); +.bi "float complex catanf(float complex " z ); +.bi "long double complex catanl(long double complex " z ); +.pp +link with \fi\-lm\fp. +.fi +.sh description +these functions calculate the complex arc tangent of +.ir z . +if \fiy\ =\ catan(z)\fp, then \fiz\ =\ ctan(y)\fp. +the real part of y is chosen in the interval [\-pi/2,pi/2]. +.pp +one has: +.pp +.nf + catan(z) = (clog(1 + i * z) \- clog(1 \- i * z)) / (2 * i) +.fi +.sh versions +these functions first appeared in glibc in version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br catan (), +.br catanf (), +.br catanl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.sh examples +.ex +/* link with "\-lm" */ + +#include +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + double complex z, c, f; + double complex i = i; + + if (argc != 3) { + fprintf(stderr, "usage: %s \en", argv[0]); + exit(exit_failure); + } + + z = atof(argv[1]) + atof(argv[2]) * i; + + c = catan(z); + printf("catan() = %6.3f %6.3f*i\en", creal(c), cimag(c)); + + f = (clog(1 + i * z) \- clog(1 \- i * z)) / (2 * i); + printf("formula = %6.3f %6.3f*i\en", creal(f2), cimag(f2)); + + exit(exit_success); +} +.ee +.sh see also +.br ccos (3), +.br clog (3), +.br ctan (3), +.br complex (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/endian.3 + +.so man2/setuid.2 + +.so man3/cpu_set.3 + +.\" copyright (c) 2007, michael kerrisk +.\" and copyright (c) 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" 2007-05-31, mtk: rewrite and substantial additional text. +.\" 2008-12-03, mtk: rewrote some pieces and fixed some errors +.\" +.th bindresvport 3 2021-03-22 "" "linux programmer's manual" +.sh name +bindresvport \- bind a socket to a privileged ip port +.sh synopsis +.nf +.b #include +.b #include +.pp +.bi "int bindresvport(int " sockfd ", struct sockaddr_in *" sin ); +.fi +.sh description +.br bindresvport () +is used to bind the socket referred to by the +file descriptor +.i sockfd +to a privileged anonymous ip port, +that is, a port number arbitrarily selected from the range 512 to 1023. +.\" glibc actually starts searching with a port # in the range 600 to 1023 +.pp +if the +.br bind (2) +performed by +.br bindresvport () +is successful, and +.i sin +is not null, then +.i sin\->sin_port +returns the port number actually allocated. +.pp +.i sin +can be null, in which case +.i sin\->sin_family +is implicitly taken to be +.br af_inet . +however, in this case, +.br bindresvport () +has no way to return the port number actually allocated. +(this information can later be obtained using +.br getsockname (2).) +.sh return value +.br bindresvport () +returns 0 on success; otherwise \-1 is returned and +.i errno +is set to indicate the error. +.sh errors +.br bindresvport () +can fail for any of the same reasons as +.br bind (2). +in addition, the following errors may occur: +.tp +.br eacces +the calling process was not privileged +(on linux: the calling process did not have the +.b cap_net_bind_service +capability in the user namespace governing its network namespace). +.tp +.b eaddrinuse +all privileged ports are in use. +.tp +.br eafnosupport " (" epfnosupport " in glibc 2.7 and earlier)" +.i sin +is not null and +.i sin\->sin_family +is not +.br af_inet . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lb lb lbx +l l l. +interface attribute value +t{ +.br bindresvport () +t} thread safety t{ +glibc\ >=\ 2.17: mt-safe; +.\" commit f6da27e53695ad1cc0e2a9490358decbbfdff5e5 +glibc\ <\ 2.17: mt-unsafe +t} +.te +.hy +.ad +.sp 1 +.pp +the +.br bindresvport () +function uses a static variable that was not protected by a lock +before glibc 2.17, rendering the function mt-unsafe. +.sh conforming to +not in posix.1. +present on the bsds, solaris, and many other systems. +.sh notes +unlike some +.br bindresvport () +implementations, +the glibc implementation ignores any value that the caller supplies in +.ir sin\->sin_port . +.sh see also +.br bind (2), +.br getsockname (2) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1995 by jim van zandt +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th getw 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +getw, putw \- input and output of words (ints) +.sh synopsis +.nf +.b #include +.pp +.bi "int getw(file *" stream ); +.bi "int putw(int " w ", file *" stream ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br getw (), +.br putw (): +.nf + since glibc 2.3.3: + _xopen_source && ! (_posix_c_source >= 200112l) + || /* glibc since 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source + before glibc 2.3.3: + _svid_source || _bsd_source || _xopen_source +.fi +.sh description +.br getw () +reads a word (that is, an \fiint\fp) from \fistream\fp. +it's provided for compatibility with svr4. +we recommend you use +.br fread (3) +instead. +.pp +.br putw () +writes the word \fiw\fp (that is, +an \fiint\fp) to \fistream\fp. +it is provided for compatibility with svr4, but we recommend you use +.br fwrite (3) +instead. +.sh return value +normally, +.br getw () +returns the word read, and +.br putw () +returns 0. +on error, they return \fbeof\fp. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br getw (), +.br putw () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +svr4, susv2. +not present in posix.1. +.sh bugs +the value returned on error is also a legitimate data value. +.br ferror (3) +can be used to distinguish between the two cases. +.sh see also +.br ferror (3), +.br fread (3), +.br fwrite (3), +.br getc (3), +.br putc (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sat jul 24 19:42:04 1993 by rik faith (faith@cs.unc.edu) +.\" added fabsl, fabsf, aeb, 2001-06-07 +.\" +.th fabs 3 2021-03-22 "" "linux programmer's manual" +.sh name +fabs, fabsf, fabsl \- absolute value of floating-point number +.sh synopsis +.nf +.b #include +.pp +.bi "double fabs(double " x ); +.bi "float fabsf(float " x ); +.bi "long double fabsl(long double " x ); +.fi +.pp +link with \fi\-lm\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br fabsf (), +.br fabsl (): +.nf + _isoc99_source || _posix_c_source >= 200112l + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.sh description +these functions return the absolute value of the floating-point +number +.ir x . +.sh return value +these functions return the absolute value of +.ir x . +.pp +if +.i x +is a nan, a nan is returned. +.pp +if +.i x +is \-0, +0 is returned. +.pp +if +.i x +is negative infinity or positive infinity, positive infinity is returned. +.sh errors +no errors occur. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br fabs (), +.br fabsf (), +.br fabsl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.pp +the variant returning +.i double +also conforms to +svr4, 4.3bsd, c89. +.sh see also +.br abs (3), +.br cabs (3), +.br ceil (3), +.br floor (3), +.br labs (3), +.br rint (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/rpc.3 + +.\" copyright (c) 2003 andries brouwer (aeb@cwi.nl) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th path_resolution 7 2021-08-27 "linux" "linux programmer's manual" +.sh name +path_resolution \- how a pathname is resolved to a file +.sh description +some unix/linux system calls have as parameter one or more filenames. +a filename (or pathname) is resolved as follows. +.ss step 1: start of the resolution process +if the pathname starts with the \(aq/\(aq character, the starting lookup +directory is the root directory of the calling process. +a process inherits its root directory from its parent. +usually this will be the root directory of the file hierarchy. +a process may get a different root directory by use of the +.br chroot (2) +system call, or may temporarily use a different root directory by using +.br openat2 (2) +with the +.b resolve_in_root +flag set. +.pp +a process may get an entirely private mount namespace in case +it\(emor one of its ancestors\(emwas started by an invocation of the +.br clone (2) +system call that had the +.b clone_newns +flag set. +this handles the \(aq/\(aq part of the pathname. +.pp +if the pathname does not start with the \(aq/\(aq character, the starting +lookup directory of the resolution process is the current working directory of +the process \(em or in the case of +.br openat (2)-style +system calls, the +.i dfd +argument (or the current working directory if +.b at_fdcwd +is passed as the +.i dfd +argument). +the current working directory is inherited from the parent, and can +be changed by use of the +.br chdir (2) +system call. +.pp +pathnames starting with a \(aq/\(aq character are called absolute pathnames. +pathnames not starting with a \(aq/\(aq are called relative pathnames. +.ss step 2: walk along the path +set the current lookup directory to the starting lookup directory. +now, for each nonfinal component of the pathname, where a component +is a substring delimited by \(aq/\(aq characters, this component is looked up +in the current lookup directory. +.pp +if the process does not have search permission on +the current lookup directory, +an +.b eacces +error is returned ("permission denied"). +.pp +if the component is not found, an +.b enoent +error is returned +("no such file or directory"). +.pp +if the component is found, but is neither a directory nor a symbolic link, +an +.b enotdir +error is returned ("not a directory"). +.pp +if the component is found and is a directory, we set the +current lookup directory to that directory, and go to the +next component. +.pp +if the component is found and is a symbolic link (symlink), we first +resolve this symbolic link (with the current lookup directory +as starting lookup directory). +upon error, that error is returned. +if the result is not a directory, an +.b enotdir +error is returned. +if the resolution of the symbolic link is successful and returns a directory, +we set the current lookup directory to that directory, and go to +the next component. +note that the resolution process here can involve recursion if the +prefix ('dirname') component of a pathname contains a filename +that is a symbolic link that resolves to a directory (where the +prefix component of that directory may contain a symbolic link, and so on). +in order to protect the kernel against stack overflow, and also +to protect against denial of service, there are limits on the +maximum recursion depth, and on the maximum number of symbolic links +followed. +an +.b eloop +error is returned when the maximum is +exceeded ("too many levels of symbolic links"). +.pp +.\" +.\" presently: max recursion depth during symlink resolution: 5 +.\" max total number of symbolic links followed: 40 +.\" _posix_symloop_max is 8 +as currently implemented on linux, the maximum number +.\" maxsymlinks is 40 +of symbolic links that will be followed while resolving a pathname is 40. +in kernels before 2.6.18, the limit on the recursion depth was 5. +starting with linux 2.6.18, this limit +.\" max_nested_links +was raised to 8. +in linux 4.2, +.\" commit 894bc8c4662ba9daceafe943a5ba0dd407da5cd3 +the kernel's pathname-resolution code +was reworked to eliminate the use of recursion, +so that the only limit that remains is the maximum of 40 +resolutions for the entire pathname. +.pp +the resolution of symbolic links during this stage can be blocked by using +.br openat2 (2), +with the +.b resolve_no_symlinks +flag set. +.ss step 3: find the final entry +the lookup of the final component of the pathname goes just like +that of all other components, as described in the previous step, +with two differences: (i) the final component need not be a +directory (at least as far as the path resolution process is +concerned\(emit may have to be a directory, or a nondirectory, because of +the requirements of the specific system call), and (ii) it +is not necessarily an error if the component is not found\(emmaybe +we are just creating it. +the details on the treatment +of the final entry are described in the manual pages of the specific +system calls. +.ss . and .. +by convention, every directory has the entries "." and "..", +which refer to the directory itself and to its parent directory, +respectively. +.pp +the path resolution process will assume that these entries have +their conventional meanings, regardless of whether they are +actually present in the physical filesystem. +.pp +one cannot walk up past the root: "/.." is the same as "/". +.ss mount points +after a "mount dev path" command, the pathname "path" refers to +the root of the filesystem hierarchy on the device "dev", and no +longer to whatever it referred to earlier. +.pp +one can walk out of a mounted filesystem: "path/.." refers to +the parent directory of "path", +outside of the filesystem hierarchy on "dev". +.pp +traversal of mount points can be blocked by using +.br openat2 (2), +with the +.b resolve_no_xdev +flag set (though note that this also restricts bind mount traversal). +.ss trailing slashes +if a pathname ends in a \(aq/\(aq, that forces resolution of the preceding +component as in step 2: +the component preceding the slash either exists and resolves to a directory +or it names a directory that is to be created +immediately after the pathname is resolved. +otherwise, a trailing \(aq/\(aq is ignored. +.ss final symlink +if the last component of a pathname is a symbolic link, then it +depends on the system call whether the file referred to will be +the symbolic link or the result of path resolution on its contents. +for example, the system call +.br lstat (2) +will operate on the symlink, while +.br stat (2) +operates on the file pointed to by the symlink. +.ss length limit +there is a maximum length for pathnames. +if the pathname (or some +intermediate pathname obtained while resolving symbolic links) +is too long, an +.b enametoolong +error is returned ("filename too long"). +.ss empty pathname +in the original unix, the empty pathname referred to the current directory. +nowadays posix decrees that an empty pathname must not be resolved +successfully. +linux returns +.b enoent +in this case. +.ss permissions +the permission bits of a file consist of three groups of three bits; see +.br chmod (1) +and +.br stat (2). +the first group of three is used when the effective user id of +the calling process equals the owner id of the file. +the second group +of three is used when the group id of the file either equals the +effective group id of the calling process, or is one of the +supplementary group ids of the calling process (as set by +.br setgroups (2)). +when neither holds, the third group is used. +.pp +of the three bits used, the first bit determines read permission, +the second write permission, and the last execute permission +in case of ordinary files, or search permission in case of directories. +.pp +linux uses the fsuid instead of the effective user id in permission checks. +ordinarily the fsuid will equal the effective user id, but the fsuid can be +changed by the system call +.br setfsuid (2). +.pp +(here "fsuid" stands for something like "filesystem user id". +the concept was required for the implementation of a user space +nfs server at a time when processes could send a signal to a process +with the same effective user id. +it is obsolete now. +nobody should use +.br setfsuid (2).) +.pp +similarly, linux uses the fsgid ("filesystem group id") +instead of the effective group id. +see +.br setfsgid (2). +.\" fixme . say something about filesystem mounted read-only ? +.ss bypassing permission checks: superuser and capabilities +on a traditional unix system, the superuser +.ri ( root , +user id 0) is all-powerful, and bypasses all permissions restrictions +when accessing files. +.\" (but for exec at least one x bit must be set) -- aeb +.\" but there is variation across systems on this point: for +.\" example, hp-ux and tru64 are as described by aeb. however, +.\" on some implementations (e.g., solaris, freebsd), +.\" access(x_ok) by superuser will report success, regardless +.\" of the file's execute permission bits. -- mtk (oct 05) +.pp +on linux, superuser privileges are divided into capabilities (see +.br capabilities (7)). +two capabilities are relevant for file permissions checks: +.b cap_dac_override +and +.br cap_dac_read_search . +(a process has these capabilities if its fsuid is 0.) +.pp +the +.b cap_dac_override +capability overrides all permission checking, +but grants execute permission only when at least one +of the file's three execute permission bits is set. +.pp +the +.b cap_dac_read_search +capability grants read and search permission +on directories, and read permission on ordinary files. +.\" fixme . say something about immutable files +.\" fixme . say something about acls +.sh see also +.br readlink (2), +.br capabilities (7), +.br credentials (7), +.br symlink (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de) +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under gpl +.\" %%%license_end +.\" +.th csin 3 2021-03-22 "" "linux programmer's manual" +.sh name +csin, csinf, csinl \- complex sine function +.sh synopsis +.nf +.b #include +.pp +.bi "double complex csin(double complex " z ");" +.bi "float complex csinf(float complex " z ); +.bi "long double complex csinl(long double complex " z ");" +.pp +link with \fi\-lm\fp. +.fi +.sh description +these functions calculate the complex sine of +.ir z . +.pp +the complex sine function is defined as: +.pp +.nf + csin(z) = (exp(i * z) \- exp(\-i * z)) / (2 * i) +.fi +.sh versions +these functions first appeared in glibc in version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br csin (), +.br csinf (), +.br csinl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.sh see also +.br cabs (3), +.br casin (3), +.br ccos (3), +.br ctan (3), +.br complex (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/gethostbyname.3 + +.so man3/drand48.3 + +.\" copyright (c) 2014 google, inc., written by david drysdale +.\" and copyright (c) 2015, michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th execveat 2 2021-08-27 "linux" "linux programmer's manual" +.sh name +execveat \- execute program relative to a directory file descriptor +.sh synopsis +.nf +.br "#include " " /* definition of " at_* " constants */" +.b #include +.pp +.bi "int execveat(int " dirfd ", const char *" pathname , +.bi " const char *const " argv "[], const char *const " envp [], +.bi " int " flags ); +.fi +.sh description +.\" commit 51f39a1f0cea1cacf8c787f652f26dfee9611874 +the +.br execveat () +system call executes the program referred to by the combination of +.i dirfd +and +.ir pathname . +it operates in exactly the same way as +.br execve (2), +except for the differences described in this manual page. +.pp +if the pathname given in +.i pathname +is relative, then it is interpreted relative to the directory +referred to by the file descriptor +.i dirfd +(rather than relative to the current working directory of +the calling process, as is done by +.br execve (2) +for a relative pathname). +.pp +if +.i pathname +is relative and +.i dirfd +is the special value +.br at_fdcwd , +then +.i pathname +is interpreted relative to the current working +directory of the calling process (like +.br execve (2)). +.pp +if +.i pathname +is absolute, then +.i dirfd +is ignored. +.pp +if +.i pathname +is an empty string and the +.br at_empty_path +flag is specified, then the file descriptor +.i dirfd +specifies the file to be executed (i.e., +.ir dirfd +refers to an executable file, rather than a directory). +.pp +the +.i flags +argument is a bit mask that can include zero or more of the following flags: +.tp +.br at_empty_path +if +.i pathname +is an empty string, operate on the file referred to by +.ir dirfd +(which may have been obtained using the +.br open (2) +.b o_path +flag). +.tp +.b at_symlink_nofollow +if the file identified by +.i dirfd +and a non-null +.i pathname +is a symbolic link, then the call fails with the error +.br eloop . +.sh return value +on success, +.br execveat () +does not return. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +the same errors that occur for +.br execve (2) +can also occur for +.br execveat (). +the following additional errors can occur for +.br execveat (): +.tp +.i pathname +is relative but +.i dirfd +is neither +.b at_fdcwd +nor a valid file descriptor. +.tp +.b einval +invalid flag specified in +.ir flags . +.tp +.b eloop +.i flags +includes +.br at_symlink_nofollow +and the file identified by +.i dirfd +and a non-null +.i pathname +is a symbolic link. +.tp +.b enoent +the program identified by +.i dirfd +and +.i pathname +requires the use of an interpreter program +(such as a script starting with "#!"), but the file descriptor +.i dirfd +was opened with the +.b o_cloexec +flag, with the result that +the program file is inaccessible to the launched interpreter. +see bugs. +.tp +.b enotdir +.i pathname +is relative and +.i dirfd +is a file descriptor referring to a file other than a directory. +.sh versions +.br execveat () +was added to linux in kernel 3.19. +library support was added to glibc in version 2.34. +.sh conforming to +the +.br execveat () +system call is linux-specific. +.sh notes +in addition to the reasons explained in +.br openat (2), +the +.br execveat () +system call is also needed to allow +.br fexecve (3) +to be implemented on systems that do not have the +.i /proc +filesystem mounted. +.pp +when asked to execute a script file, the +.ir argv[0] +that is passed to the script interpreter is a string of the form +.ir /dev/fd/n +or +.ir /dev/fd/n/p , +where +.i n +is the number of the file descriptor passed via the +.ir dirfd +argument. +a string of the first form occurs when +.br at_empty_path +is employed. +a string of the second form occurs when the script is specified via both +.ir dirfd +and +.ir pathname ; +in this case, +.ir p +is the value given in +.ir pathname . +.pp +for the same reasons described in +.br fexecve (3), +the natural idiom when using +.br execveat () +is to set the close-on-exec flag on +.ir dirfd . +(but see bugs.) +.sh bugs +the +.b enoent +error described above means that it is not possible to set the +close-on-exec flag on the file descriptor given to a call of the form: +.pp + execveat(fd, "", argv, envp, at_empty_path); +.pp +however, the inability to set the close-on-exec flag means that a file +descriptor referring to the script leaks through to the script itself. +as well as wasting a file descriptor, +this leakage can lead to file-descriptor exhaustion in scenarios +where scripts recursively employ +.br execveat (). +.\" for an example, see michael kerrisk's 2015-01-10 reply in this lkml +.\" thread (http://thread.gmane.org/gmane.linux.kernel/1836105/focus=20229): +.\" +.\" subject: [patchv10 man-pages 5/5] execveat.2: initial man page.\" for execveat(2 +.\" date: mon, 24 nov 2014 11:53:59 +0000 +.sh see also +.br execve (2), +.br openat (2), +.br fexecve (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2009 linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th timer_getoverrun 2 2021-03-22 linux "linux programmer's manual" +.sh name +timer_getoverrun \- get overrun count for a posix per-process timer +.sh synopsis +.nf +.b #include +.pp +.bi "int timer_getoverrun(timer_t " timerid ); +.fi +.pp +link with \fi\-lrt\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br timer_getoverrun (): +.nf + _posix_c_source >= 199309l +.fi +.sh description +.br timer_getoverrun () +returns the "overrun count" for the timer referred to by +.ir timerid . +an application can use the overrun count to accurately calculate the number +of timer expirations that would have occurred over a given time interval. +timer overruns can occur both when receiving expiration notifications +via signals +.rb ( sigev_signal ), +and via threads +.rb ( sigev_thread ). +.pp +when expiration notifications are delivered via a signal, +overruns can occur as follows. +regardless of whether or not a real-time signal is used for +timer notifications, +the system queues at most one signal per timer. +(this is the behavior specified by posix.1. +the alternative, queuing one signal for each timer expiration, +could easily result in overflowing the allowed limits for +queued signals on the system.) +because of system scheduling delays, +or because the signal may be temporarily blocked, +there can be a delay between the time when the notification +signal is generated and the time when it +is delivered (e.g., caught by a signal handler) or accepted (e.g., using +.br sigwaitinfo (2)). +in this interval, further timer expirations may occur. +the timer overrun count is the number of additional +timer expirations that occurred between the time when the signal +was generated and when it was delivered or accepted. +.pp +timer overruns can also occur when expiration notifications +are delivered via invocation of a thread, +since there may be an arbitrary delay between an expiration of the timer +and the invocation of the notification thread, +and in that delay interval, additional timer expirations may occur. +.sh return value +on success, +.br timer_getoverrun () +returns the overrun count of the specified timer; +this count may be 0 if no overruns have occurred. +on failure, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b einval +.i timerid +is not a valid timer id. +.sh versions +this system call is available since linux 2.6. +.sh conforming to +posix.1-2001, posix.1-2008. +.sh notes +when timer notifications are delivered via signals +.rb ( sigev_signal ), +on linux it is also possible to obtain the overrun count via the +.i si_overrun +field of the +.i siginfo_t +structure (see +.br sigaction (2)). +this allows an application to avoid the overhead of making +a system call to obtain the overrun count, +but is a nonportable extension to posix.1. +.pp +posix.1 discusses timer overruns only in the context of +timer notifications using signals. +.\" fixme . austin bug filed, 11 feb 09 +.\" https://www.austingroupbugs.net/view.php?id=95 +.sh bugs +posix.1 specifies that if the timer overrun count +is equal to or greater than an implementation-defined maximum, +.br delaytimer_max , +then +.br timer_getoverrun () +should return +.br delaytimer_max . +however, before linux 4.19, +.\" http://bugzilla.kernel.org/show_bug.cgi?id=12665 +if the timer overrun value exceeds the maximum representable integer, +the counter cycles, starting once more from low values. +since linux 4.19, +.\" commit 78c9c4dfbf8c04883941445a195276bb4bb92c76 +.br timer_getoverrun () +returns +.b delaytimer_max +(defined as +.b int_max +in +.ir ) +in this case (and the overrun value is reset to 0). +.sh examples +see +.br timer_create (2). +.sh see also +.br clock_gettime (2), +.br sigaction (2), +.br signalfd (2), +.br sigwaitinfo (2), +.br timer_create (2), +.br timer_delete (2), +.br timer_settime (2), +.br signal (7), +.br time (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/puts.3 + +.so man3/resolver.3 + +.\" copyright (c) 2006 justin pryzby +.\" and copyright (c) 2006 michael kerrisk +.\" +.\" %%%license_start(permissive_misc) +.\" permission is hereby granted, free of charge, to any person obtaining +.\" a copy of this software and associated documentation files (the +.\" "software"), to deal in the software without restriction, including +.\" without limitation the rights to use, copy, modify, merge, publish, +.\" distribute, sublicense, and/or sell copies of the software, and to +.\" permit persons to whom the software is furnished to do so, subject to +.\" the following conditions: +.\" +.\" the above copyright notice and this permission notice shall be +.\" included in all copies or substantial portions of the software. +.\" +.\" the software is provided "as is", without warranty of any kind, +.\" express or implied, including but not limited to the warranties of +.\" merchantability, fitness for a particular purpose and noninfringement. +.\" in no event shall the authors or copyright holders be liable for any +.\" claim, damages or other liability, whether in an action of contract, +.\" tort or otherwise, arising from, out of or in connection with the +.\" software or the use or other dealings in the software. +.\" %%%license_end +.\" +.\" references: +.\" glibc manual and source +.th error 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +error, error_at_line, error_message_count, error_one_per_line, +error_print_progname \- glibc error reporting functions +.sh synopsis +.nf +.b #include +.pp +.bi "void error(int " status ", int " errnum ", const char *" format ", ...);" +.bi "void error_at_line(int " status ", int " errnum ", const char *" filename , +.bi " unsigned int " linenum ", const char *" format ", ...);" +.pp +.bi "extern unsigned int " error_message_count ; +.bi "extern int " error_one_per_line ; +.pp +.bi "extern void (*" error_print_progname ")(void);" +.fi +.sh description +.br error () +is a general error-reporting function. +it flushes +.ir stdout , +and then outputs to +.i stderr +the program name, a colon and a space, the message specified by the +.br printf (3)-style +format string \fiformat\fp, and, if \fierrnum\fp is +nonzero, a second colon and a space followed by the string given by +.ir strerror(errnum) . +any arguments required for +.i format +should follow +.i format +in the argument list. +the output is terminated by a newline character. +.pp +the program name printed by +.br error () +is the value of the global variable +.br program_invocation_name (3). +.i program_invocation_name +initially has the same value as +.ir main ()'s +.ir argv[0] . +the value of this variable can be modified to change the output of +.br error (). +.pp +if \fistatus\fp has a nonzero value, then +.br error () +calls +.br exit (3) +to terminate the program using the given value as the exit status; +otherwise it returns after printing the error message. +.pp +the +.br error_at_line () +function is exactly the same as +.br error (), +except for the addition of the arguments +.i filename +and +.ir linenum . +the output produced is as for +.br error (), +except that after the program name are written: a colon, the value of +.ir filename , +a colon, and the value of +.ir linenum . +the preprocessor values \fb__line__\fp and +\fb__file__\fp may be useful when calling +.br error_at_line (), +but other values can also be used. +for example, these arguments could refer to a location in an input file. +.pp +if the global variable \fierror_one_per_line\fp is set nonzero, +a sequence of +.br error_at_line () +calls with the +same value of \fifilename\fp and \filinenum\fp will result in only +one message (the first) being output. +.pp +the global variable \fierror_message_count\fp counts the number of +messages that have been output by +.br error () +and +.br error_at_line (). +.pp +if the global variable \fierror_print_progname\fp +is assigned the address of a function +(i.e., is not null), then that function is called +instead of prefixing the message with the program name and colon. +the function should print a suitable string to +.ir stderr . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lb lb lbx +l l l. +interface attribute value +t{ +.br error () +t} thread safety mt-safe locale +t{ +.br error_at_line () +t} thread safety t{ +mt-unsafe\ race: error_at_line/\:error_one_per_line locale +t} +.te +.hy +.ad +.sp 1 +.pp +the internal +.i error_one_per_line +variable is accessed (without any form of synchronization, but since it's an +.i int +used once, it should be safe enough) and, if +.i error_one_per_line +is set nonzero, the internal static variables (not exposed to users) +used to hold the last printed filename and line number are accessed +and modified without synchronization; the update is not atomic and it +occurs before disabling cancellation, so it can be interrupted only after +one of the two variables is modified. +after that, +.br error_at_line () +is very much like +.br error (). +.sh conforming to +these functions and variables are gnu extensions, and should not be +used in programs intended to be portable. +.sh see also +.br err (3), +.br errno (3), +.br exit (3), +.br perror (3), +.br program_invocation_name (3), +.br strerror (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/drand48_r.3 + +.so man7/iso_8859-7.7 + +.\" copyright (c) international business machines corp., 2006 +.\" +.\" %%%license_start(gplv2+_sw_3_para) +.\" this program is free software; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" this program 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" history: +.\" 2005-09-28, created by arnd bergmann , +.\" mark nutter and +.\" ulrich weigand +.\" 2006-06-16, revised by eduardo m. fleury +.\" 2007-07-10, quite a lot of polishing by mtk +.\" 2007-09-28, updates for newer kernels by jeremy kerr +.\" +.th spufs 7 2021-03-22 linux "linux programmer's manual" +.sh name +spufs \- spu filesystem +.sh description +the spu filesystem is used on powerpc machines that implement the +cell broadband engine architecture in order to access synergistic +processor units (spus). +.pp +the filesystem provides a name space similar to posix shared +memory or message queues. +users that have write permissions +on the filesystem can use +.br spu_create (2) +to establish spu contexts under the +.b spufs +root directory. +.pp +every spu context is represented by a directory containing +a predefined set of files. +these files can be +used for manipulating the state of the logical spu. +users can change permissions on the files, but can't +add or remove files. +.ss mount options +.tp +.b uid= +set the user owning the mount point; the default is 0 (root). +.tp +.b gid= +set the group owning the mount point; the default is 0 (root). +.tp +.b mode= +set the mode of the top-level directory in +.br spufs , +as an octal mode string. +the default is 0775. +.ss files +the files in +.b spufs +mostly follow the standard behavior for regular system calls like +.br read (2) +or +.br write (2), +but often support only a subset of the operations +supported on regular filesystems. +this list details the supported +operations and the deviations from the standard behavior described +in the respective man pages. +.pp +all files that support the +.br read (2) +operation also support +.br readv (2) +and all files that support the +.br write (2) +operation also support +.br writev (2). +all files support the +.br access (2) +and +.br stat (2) +family of operations, but for the latter call, +the only fields of the returned +.i stat +structure that contain reliable information are +.ir st_mode , +.ir st_nlink , +.ir st_uid , +and +.ir st_gid . +.pp +all files support the +.br chmod (2)/ fchmod (2) +and +.br chown (2)/ fchown (2) +operations, but will not be able to grant permissions that contradict +the possible operations (e.g., read access on the +.i wbox +file). +.pp +the current set of files is: +.tp +.i /capabilities +contains a comma-delimited string representing the capabilities of this +spu context. +possible capabilities are: +.rs +.tp +.b sched +this context may be scheduled. +.tp +.b step +this context can be run in single-step mode, for debugging. +.pp +new capabilities flags may be added in the future. +.re +.tp +.i /mem +the contents of the local storage memory of the spu. +this can be accessed like a regular shared memory +file and contains both code and data in the address +space of the spu. +the possible operations on an open +.i mem +file are: +.rs +.tp +.br read "(2), " pread "(2), " write "(2), " pwrite "(2), " lseek (2) +these operate as usual, with the exception that +.br lseek (2), +.br write (2), +and +.br pwrite (2) +are not supported beyond the end of the file. +the file size +is the size of the local storage of the spu, +which is normally 256 kilobytes. +.tp +.br mmap (2) +mapping +.i mem +into the process address space provides access to the spu local +storage within the process address space. +only +.b map_shared +mappings are allowed. +.re +.tp +.i /regs +contains the saved general-purpose registers of the spu context. +this file contains the 128-bit values of each register, +from register 0 to register 127, in order. +this allows the general-purpose registers to be +inspected for debugging. +.ip +reading to or writing from this file requires that the context is +scheduled out, so use of this file is not recommended in normal +program operation. +.ip +the +.i regs +file is not present on contexts that have been created with the +.b spu_create_nosched +flag. +.tp +.i /mbox +the first spu-to-cpu communication mailbox. +this file is read-only and can be read in units of 4 bytes. +the file can be used only in nonblocking mode \- even +.br poll (2) +cannot be used to block on this file. +the only possible operation on an open +.i mbox +file is: +.rs +.tp +.br read (2) +if +.i count +is smaller than four, +.br read (2) +returns \-1 and sets +.i errno +to +.br einval . +if there is no data available in the mailbox (i.e., the spu has not +sent a mailbox message), the return value is set to \-1 and +.i errno +is set to +.br eagain . +when data +has been read successfully, four bytes are placed in +the data buffer and the value four is returned. +.re +.tp +.i /ibox +the second spu-to-cpu communication mailbox. +this file is similar to the first mailbox file, but can be read +in blocking i/o mode, thus calling +.br read (2) +on an open +.i ibox +file will block until the spu has written data to its interrupt mailbox +channel (unless the file has been opened with +.br o_nonblock , +see below). +also, +.br poll (2) +and similar system calls can be used to monitor for the presence +of mailbox data. +.ip +the possible operations on an open +.i ibox +file are: +.rs +.tp +.br read (2) +if +.i count +is smaller than four, +.br read (2) +returns \-1 and sets +.i errno +to +.br einval . +if there is no data available in the mailbox and the file +descriptor has been opened with +.br o_nonblock , +the return value is set to \-1 and +.i errno +is set to +.br eagain . +.ip +if there is no data available in the mailbox and the file +descriptor has been opened without +.br o_nonblock , +the call will +block until the spu writes to its interrupt mailbox channel. +when data has been read successfully, four bytes are placed in +the data buffer and the value four is returned. +.tp +.br poll (2) +poll on the +.i ibox +file returns +.i "(pollin | pollrdnorm)" +whenever data is available for reading. +.re +.tp +.i /wbox +the cpu-to-spu communication mailbox. +it is write-only and can be written in units of four bytes. +if the mailbox is full, +.br write (2) +will block, and +.br poll (2) +can be used to block until the mailbox is available for writing again. +the possible operations on an open +.i wbox +file are: +.rs +.tp +.br write (2) +if +.i count +is smaller than four, +.br write (2) +returns \-1 and sets +.i errno +to +.br einval . +if there is no space available in the mailbox and the file +descriptor has been opened with +.br o_nonblock , +the return +value is set to \-1 and +.i errno +is set to +.br eagain . +.ip +if there is no space available in the mailbox and the file +descriptor has been opened without +.br o_nonblock , +the call will block until the spu reads from its +ppe (powerpc processing element) +mailbox channel. +when data has been written successfully, +the system call returns four as its function result. +.tp +.br poll (2) +a poll on the +.i wbox +file returns +.i "(pollout | pollwrnorm)" +whenever space is available for writing. +.re +.tp +.ir /mbox_stat ", " /ibox_stat ", " /wbox_stat +these are read-only files that contain the length of the current +queue of each mailbox\(emthat is, how many words can be read from +.ir mbox " or " ibox +or how many words can be written to +.i wbox +without blocking. +the files can be read only in four-byte units and return +a big-endian binary integer number. +the only possible operation on an open +.i *box_stat +file is: +.rs +.tp +.br read (2) +if +.i count +is smaller than four, +.br read (2) +returns \-1 and sets +.i errno +to +.br einval . +otherwise, a four-byte value is placed in the data buffer. +this value is the number of elements that can be read from (for +.ir mbox_stat +and +.ir ibox_stat ) +or written to (for +.ir wbox_stat ) +the respective mailbox without blocking or returning an +.br eagain +error. +.re +.tp +.ir /npc ", " /decr ", " /decr_status ", " /spu_tag_mask ", " \ +/event_mask ", " /event_status ", " /srr0 ", " /lslr +internal registers of the spu. +these files contain an ascii string +representing the hex value of the specified register. +reads and writes on these +files (except for +.ir npc , +see below) require that the spu context be scheduled out, +so frequent access to +these files is not recommended for normal program operation. +.ip +the contents of these files are: +.rs +.tp 16 +.i npc +next program counter \- valid only when the spu is in a stopped state. +.tp +.i decr +spu decrementer +.tp +.i decr_status +decrementer status +.tp +.i spu_tag_mask +mfc tag mask for spu dma +.tp +.i event_mask +event mask for spu interrupts +.tp +.i event_status +number of spu events pending (read-only) +.tp +.i srr0 +interrupt return address register +.tp +.i lslr +local store limit register +.re +.ip +the possible operations on these files are: +.rs +.tp +.br read (2) +reads the current register value. +if the register value is larger than the buffer passed to the +.br read (2) +system call, subsequent reads will continue reading from the same +buffer, until the end of the buffer is reached. +.ip +when a complete string has been read, all subsequent read operations +will return zero bytes and a new file descriptor needs to be opened +to read a new value. +.tp +.br write (2) +a +.br write (2) +operation on the file sets the register to the +value given in the string. +the string is parsed from the beginning +until the first nonnumeric character or the end of the buffer. +subsequent writes to the same file descriptor overwrite the +previous setting. +.ip +except for the +.i npc +file, these files are not present on contexts that have been created with +the +.b spu_create_nosched +flag. +.re +.tp +.ir /fpcr +this file provides access to the floating point status and +control register (fcpr) as a binary, four-byte file. +the operations on the +.i fpcr +file are: +.rs +.tp +.br read (2) +if +.i count +is smaller than four, +.br read (2) +returns \-1 and sets +.i errno +to +.br einval . +otherwise, a four-byte value is placed in the data buffer; +this is the current value of the +.i fpcr +register. +.tp +.br write (2) +if +.i count +is smaller than four, +.br write (2) +returns \-1 and sets +.i errno +to +.br einval . +otherwise, a four-byte value is copied from the data buffer, +updating the value of the +.i fpcr +register. +.re +.tp +.ir /signal1 ", " /signal2 +the files provide access to the two signal notification channels +of an spu. +these are read-write files that operate on four-byte words. +writing to one of these files triggers an interrupt on the spu. +the value written to the signal files can +be read from the spu through a channel read or from +host user space through the file. +after the value has been read by the spu, it is reset to zero. +the possible operations on an open +.i signal1 +or +.i signal2 +file are: +.rs +.tp +.br read (2) +if +.i count +is smaller than four, +.br read (2) +returns \-1 and sets +.i errno +to +.br einval . +otherwise, a four-byte value is placed in the data buffer; +this is the current value of the specified signal notification +register. +.tp +.br write (2) +if +.i count +is smaller than four, +.br write (2) +returns \-1 and sets +.i errno +to +.br einval . +otherwise, a four-byte value is copied from the data buffer, +updating the value of the specified signal notification +register. +the signal notification register will either be replaced with +the input data or will be updated to the bitwise or operation +of the old value and the input data, depending on the contents +of the +.ir signal1_type +or +.ir signal2_type +files respectively. +.re +.tp +.ir /signal1_type ", " /signal2_type +these two files change the behavior of the +.ir signal1 +and +.ir signal2 +notification files. +they contain a numeric ascii string which is read +as either "1" or "0". +in mode 0 (overwrite), the hardware replaces the contents +of the signal channel with the data that is written to it. +in mode 1 (logical or), the hardware accumulates the bits +that are subsequently written to it. +the possible operations on an open +.i signal1_type +or +.i signal2_type +file are: +.rs +.tp +.br read (2) +when the count supplied to the +.br read (2) +call is shorter than the required length for the digit (plus a newline +character), subsequent reads from the same file descriptor will +complete the string. +when a complete string has been read, all subsequent read operations +will return zero bytes and a new file descriptor needs to be opened +to read the value again. +.tp +.br write (2) +a +.br write (2) +operation on the file sets the register to the +value given in the string. +the string is parsed from the beginning +until the first nonnumeric character or the end of the buffer. +subsequent writes to the same file descriptor overwrite the +previous setting. +.re +.tp +.ir /mbox_info ", " /ibox_info ", " /wbox_info ", " /dma_into ", " /proxydma_info +read-only files that contain the saved state of the spu mailboxes and +dma queues. +this allows the spu status to be inspected, mainly for debugging. +the +.i mbox_info +and +.i ibox_info +files each contain the four-byte mailbox message that has been written +by the spu. +if no message has been written to these mailboxes, then +contents of these files is undefined. +the +.ir mbox_stat , +.ir ibox_stat , +and +.i wbox_stat +files contain the available message count. +.ip +the +.i wbox_info +file contains an array of four-byte mailbox messages, which have been +sent to the spu. +with current cbea machines, the array is four items in +length, so up to 4 * 4 = 16 bytes can be read from this file. +if any mailbox queue entry is empty, +then the bytes read at the corresponding location are undefined. +.ip +the +.i dma_info +file contains the contents of the spu mfc dma queue, represented as the +following structure: +.ip +.in +4n +.ex +struct spu_dma_info { + uint64_t dma_info_type; + uint64_t dma_info_mask; + uint64_t dma_info_status; + uint64_t dma_info_stall_and_notify; + uint64_t dma_info_atomic_command_status; + struct mfc_cq_sr dma_info_command_data[16]; +}; +.ee +.in +.ip +the last member of this data structure is the actual dma queue, +containing 16 entries. +the +.i mfc_cq_sr +structure is defined as: +.ip +.in +4n +.ex +struct mfc_cq_sr { + uint64_t mfc_cq_data0_rw; + uint64_t mfc_cq_data1_rw; + uint64_t mfc_cq_data2_rw; + uint64_t mfc_cq_data3_rw; +}; +.ee +.in +.ip +the +.i proxydma_info +file contains similar information, but describes the proxy dma queue +(i.e., dmas initiated by entities outside the spu) instead. +the file is in the following format: +.ip +.in +4n +.ex +struct spu_proxydma_info { + uint64_t proxydma_info_type; + uint64_t proxydma_info_mask; + uint64_t proxydma_info_status; + struct mfc_cq_sr proxydma_info_command_data[8]; +}; +.ee +.in +.ip +accessing these files requires that the spu context is scheduled out - +frequent use can be inefficient. +these files should not be used for normal program operation. +.ip +these files are not present on contexts that have been created with the +.b spu_create_nosched +flag. +.tp +.ir /cntl +this file provides access to the spu run control and spu status +registers, as an ascii string. +the following operations are supported: +.rs +.tp +.br read (2) +reads from the +.i cntl +file will return an ascii string with the hex +value of the spu status register. +.tp +.br write (2) +writes to the +.i cntl +file will set the context's spu run control register. +.re +.tp +.i /mfc +provides access to the memory flow controller of the spu. +reading from the file returns the contents of the +spu's mfc tag status register, and +writing to the file initiates a dma from the mfc. +the following operations are supported: +.rs +.tp +.br write (2) +writes to this file need to be in the format of a mfc dma command, +defined as follows: +.ip +.in +4n +.ex +struct mfc_dma_command { + int32_t pad; /* reserved */ + uint32_t lsa; /* local storage address */ + uint64_t ea; /* effective address */ + uint16_t size; /* transfer size */ + uint16_t tag; /* command tag */ + uint16_t class; /* class id */ + uint16_t cmd; /* command opcode */ +}; +.ee +.in +.ip +writes are required to be exactly +.i sizeof(struct mfc_dma_command) +bytes in size. +the command will be sent to the spu's mfc proxy queue, and the +tag stored in the kernel (see below). +.tp +.br read (2) +reads the contents of the tag status register. +if the file is opened in blocking mode (i.e., without +.br o_nonblock ), +then the read will block until a +dma tag (as performed by a previous write) is complete. +in nonblocking mode, +the mfc tag status register will be returned without waiting. +.tp +.br poll (2) +calling +.br poll (2) +on the +.i mfc +file will block until a new dma can be +started (by checking for +.br pollout ) +or until a previously started dma +(by checking for +.br pollin ) +has been completed. +.ip +.i /mss +provides access to the mfc multisource synchronization (mss) facility. +by +.br mmap (2)-ing +this file, processes can access the mss area of the spu. +.ip +the following operations are supported: +.tp +.br mmap (2) +mapping +.b mss +into the process address space gives access to the spu mss area +within the process address space. +only +.b map_shared +mappings are allowed. +.re +.tp +.i /psmap +provides access to the whole problem-state mapping of the spu. +applications can use this area to interface to the spu, rather than +writing to individual register files in +.br spufs . +.ip +the following operations are supported: +.rs +.tp +.br mmap (2) +mapping +.b psmap +gives a process a direct map of the spu problem state area. +only +.b map_shared +mappings are supported. +.re +.tp +.i /phys\-id +read-only file containing the physical spu number that the spu context +is running on. +when the context is not running, this file contains the +string "\-1". +.ip +the physical spu number is given by an ascii hex string. +.tp +.i /object\-id +allows applications to store (or retrieve) a single 64-bit id into the +context. +this id is later used by profiling tools to uniquely identify +the context. +.rs +.tp +.br write (2) +by writing an ascii hex value into this file, applications can set the +object id of the spu context. +any previous value of the object id is overwritten. +.tp +.br read (2) +reading this file gives an ascii hex string representing the object id +for this spu context. +.re +.sh examples +.tp +.ir /etc/fstab " entry" +none /spu spufs gid=spu 0 0 +.\" .sh authors +.\" arnd bergmann , mark nutter , +.\" ulrich weigand , jeremy kerr +.sh see also +.br close (2), +.br spu_create (2), +.br spu_run (2), +.br capabilities (7) +.pp +.i the cell broadband engine architecture (cbea) specification +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1993 michael haardt (michael@moria.de) +.\" and copyright (c) 1999 andries brouwer (aeb@cwi.nl) +.\" and copyright (c) 2006 justin pryzby +.\" and copyright (c) 2006 michael kerrisk +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" modified sun jul 25 11:02:22 1993 by rik faith (faith@cs.unc.edu) +.\" 2006-05-24, justin pryzby +.\" document ftw_actionretval; include .sh return value; +.\" 2006-05-24, justin pryzby and +.\" michael kerrisk +.\" reorganized and rewrote much of the page +.\" 2006-05-24, michael kerrisk +.\" added an example program. +.\" +.th ftw 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +ftw, nftw \- file tree walk +.sh synopsis +.nf +.b #include +.pp +.bi "int nftw(const char *" dirpath , +.bi " int (*" fn ")(const char *" fpath ", const struct stat *" sb , +.bi " int " typeflag ", struct ftw *" ftwbuf ), +.bi " int " nopenfd ", int " flags ); +.pp +.bi "int ftw(const char *" dirpath , +.bi " int (*" fn ")(const char *" fpath ", const struct stat *" sb , +.bi " int " typeflag ), +.bi " int " nopenfd ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br nftw (): +.nf + _xopen_source >= 500 +.fi +.sh description +.br nftw () +walks through the directory tree that is +located under the directory \fidirpath\fp, +and calls \fifn\fp() once for each entry in the tree. +by default, directories are handled before the files and +subdirectories they contain (preorder traversal). +.pp +to avoid using up all of the calling process's file descriptors, +\finopenfd\fp specifies the maximum number of directories that +.br nftw () +will hold open simultaneously. +when +the search depth exceeds this, +.br nftw () +will become slower because +directories have to be closed and reopened. +.br nftw () +uses at most +one file descriptor for each level in the directory tree. +.pp +for each entry found in the tree, +.br nftw () +calls +\fifn\fp() with four arguments: +.ir fpath , +.ir sb , +.ir typeflag , +and +.ir ftwbuf . +.i fpath +is the pathname of the entry, +and is expressed either as a pathname relative to the calling process's +current working directory at the time of the call to +.br nftw (), +if +.ir dirpath +was expressed as a relative pathname, +or as an absolute pathname, if +.i dirpath +was expressed as an absolute pathname. +.i sb +is a pointer to the +.i stat +structure returned by a call to +.br stat (2) +for +.ir fpath . +.pp +the +.i typeflag +argument passed to +.ir fn () +is an integer that has one of the following values: +.tp +.b ftw_f +.i fpath +is a regular file. +.tp +.b ftw_d +.i fpath +is a directory. +.tp +.b ftw_dnr +.i fpath +is a directory which can't be read. +.tp +.b ftw_dp +.i fpath +is a directory, and \fbftw_depth\fp was specified in \fiflags\fp. +(if +.b ftw_depth +was not specified in +.ir flags , +then directories will always be visited with +.i typeflag +set to +.br ftw_d .) +all of the files +and subdirectories within \fifpath\fp have been processed. +.tp +.b ftw_ns +the +.br stat (2) +call failed on +.ir fpath , +which is not a symbolic link. +the probable cause for this is that the caller had read permission +on the parent directory, so that the filename +.i fpath +could be seen, +but did not have execute permission, +so that the file could not be reached for +.br stat (2). +the contents of the buffer pointed to by +.i sb +are undefined. +.tp +.b ftw_sl +.i fpath +is a symbolic link, and \fbftw_phys\fp was set in \fiflags\fp. +.\" to obtain the definition of this constant from +.\" .ir , +.\" either +.\" .b _bsd_source +.\" must be defined, or +.\" .br _xopen_source +.\" must be defined with a value of 500 or more. +.tp +.b ftw_sln +.i fpath +is a symbolic link pointing to a nonexistent file. +(this occurs only if \fbftw_phys\fp is not set.) +in this case the +.i sb +argument passed to +.ir fn () +contains information returned by performing +.br lstat (2) +on the "dangling" symbolic link. +(but see bugs.) +.pp +the fourth argument +.ri ( ftwbuf ) +that +.br nftw () +supplies when calling +\fifn\fp() +is a pointer to a structure of type \fiftw\fp: +.pp +.in +4n +.ex +struct ftw { + int base; + int level; +}; +.ee +.in +.pp +.i base +is the offset of the filename (i.e., basename component) +in the pathname given in +.ir fpath . +.i level +is the depth of +.i fpath +in the directory tree, relative to the root of the tree +.ri ( dirpath , +which has depth 0). +.pp +to stop the tree walk, \fifn\fp() returns a nonzero value; this +value will become the return value of +.br nftw (). +as long as \fifn\fp() returns 0, +.br nftw () +will continue either until it has traversed the entire tree, +in which case it will return zero, +or until it encounters an error (such as a +.br malloc (3) +failure), in which case it will return \-1. +.pp +because +.br nftw () +uses dynamic data structures, the only safe way to +exit out of a tree walk is to return a nonzero value from \fifn\fp(). +to allow a signal to terminate the walk without causing a memory leak, +have the handler set a global flag that is checked by \fifn\fp(). +\fidon't\fp use +.br longjmp (3) +unless the program is going to terminate. +.pp +the \fiflags\fp argument of +.br nftw () +is formed by oring zero or more of the +following flags: +.tp +.br ftw_actionretval " (since glibc 2.3.3)" +if this glibc-specific flag is set, then +.br nftw () +handles the return value from +.ir fn () +differently. +.ir fn () +should return one of the following values: +.rs +.tp +.b ftw_continue +instructs +.br nftw () +to continue normally. +.tp +.b ftw_skip_siblings +if \fifn\fp() returns this value, then +siblings of the current entry will be skipped, +and processing continues in the parent. +.\" if \fbftw_depth\fp +.\" is set, the entry's parent directory is processed next (with +.\" \fiflag\fp set to \fbftw_dp\fp). +.tp +.b ftw_skip_subtree +if \fifn\fp() is called with an entry that is a directory +(\fitypeflag\fp is \fbftw_d\fp), this return +value will prevent objects within that directory from being passed as +arguments to \fifn\fp(). +.br nftw () +continues processing with the next sibling of the directory. +.tp +.b ftw_stop +causes +.br nftw () +to return immediately with the return value +\fbftw_stop\fp. +.pp +other return values could be associated with new actions in the future; +\fifn\fp() should not return values other than those listed above. +.pp +the feature test macro +.b _gnu_source +must be defined +(before including +.i any +header files) +in order to +obtain the definition of \fbftw_actionretval\fp from \fi\fp. +.re +.tp +.b ftw_chdir +if set, do a +.br chdir (2) +to each directory before handling its contents. +this is useful if the program needs to perform some action +in the directory in which \fifpath\fp resides. +(specifying this flag has no effect on the pathname that is passed in the +.i fpath +argument of +.ir fn .) +.tp +.b ftw_depth +if set, do a post-order traversal, that is, call \fifn\fp() for +the directory itself \fiafter\fp handling the contents of the directory +and its subdirectories. +(by default, each directory is handled \fibefore\fp its contents.) +.tp +.b ftw_mount +if set, stay within the same filesystem +(i.e., do not cross mount points). +.tp +.b ftw_phys +if set, do not follow symbolic links. +(this is what you want.) +if not set, symbolic links are followed, but no file is reported twice. +.ip +if \fbftw_phys\fp is not set, but \fbftw_depth\fp is set, +then the function +.ir fn () +is never called for a directory that would be a descendant of itself. +.ss ftw() +.br ftw () +is an older function that offers a subset of the functionality of +.br nftw (). +the notable differences are as follows: +.ip * 3 +.br ftw () +has no +.ir flags +argument. +it behaves the same as when +.br nftw () +is called with +.i flags +specified as zero. +.ip * +the callback function, +.ir fn (), +is not supplied with a fourth argument. +.ip * +the range of values that is passed via the +.i typeflag +argument supplied to +.ir fn () +is smaller: just +.br ftw_f , +.br ftw_d , +.br ftw_dnr , +.br ftw_ns , +and (possibly) +.br ftw_sl . +.sh return value +these functions return 0 on success, and \-1 if an error occurs. +.pp +if \fifn\fp() returns nonzero, +then the tree walk is terminated and the value returned by \fifn\fp() +is returned as the result of +.br ftw () +or +.br nftw (). +.pp +if +.br nftw () +is called with the \fbftw_actionretval\fp flag, +then the only nonzero value that should be used by \fifn\fp() +to terminate the tree walk is \fbftw_stop\fp, +and that value is returned as the result of +.br nftw (). +.sh versions +.br nftw () +is available under glibc since version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br nftw () +t} thread safety mt-safe cwd +t{ +.br ftw () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, svr4, susv1. +posix.1-2008 marks +.br ftw () +as obsolete. +.sh notes +posix.1-2008 notes that the results are unspecified if +.i fn +does not preserve the current working directory. +.pp +the function +.br nftw () +and the use of \fbftw_sl\fp with +.br ftw () +were introduced in susv1. +.pp +in some implementations (e.g., glibc), +.br ftw () +will never use \fbftw_sl\fp, on other systems \fbftw_sl\fp occurs only +for symbolic links that do not point to an existing file, +and again on other systems +.br ftw () +will use \fbftw_sl\fp for each symbolic link. +if +.i fpath +is a symbolic link and +.br stat (2) +failed, posix.1-2008 states +that it is undefined whether \fbftw_ns\fp or \fbftw_sl\fp +is passed in +.ir typeflag . +for predictable results, use +.br nftw (). +.sh bugs +according to posix.1-2008, when the +.ir typeflag +argument passed to +.ir fn () +contains +.br ftw_sln , +the buffer pointed to by +.i sb +should contain information about the dangling symbolic link +(obtained by calling +.br lstat (2) +on the link). +early glibc versions correctly followed the posix specification on this point. +however, as a result of a regression introduced in glibc 2.4, +the contents of the buffer pointed to by +.i sb +were undefined when +.b ftw_sln +is passed in +.ir typeflag . +(more precisely, the contents of the buffer were left unchanged in this case.) +this regression was eventually fixed in glibc 2.30, +.\" https://bugzilla.redhat.com/show_bug.cgi?id=1422736 +.\" http://austingroupbugs.net/view.php?id=1121 +.\" glibc commit 6ba205b2c35e3e024c8c12d2ee1b73363e84da87 +.\" https://sourceware.org/bugzilla/show_bug.cgi?id=23501 +so that the glibc implementation (once more) follows the posix specification. +.sh examples +the following program traverses the directory tree under the path named +in its first command-line argument, or under the current directory +if no argument is supplied. +it displays various information about each file. +the second command-line argument can be used to specify characters that +control the value assigned to the \fiflags\fp +argument when calling +.br nftw (). +.ss program source +\& +.ex +#define _xopen_source 500 +#include +#include +#include +#include +#include + +static int +display_info(const char *fpath, const struct stat *sb, + int tflag, struct ftw *ftwbuf) +{ + printf("%\-3s %2d ", + (tflag == ftw_d) ? "d" : (tflag == ftw_dnr) ? "dnr" : + (tflag == ftw_dp) ? "dp" : (tflag == ftw_f) ? "f" : + (tflag == ftw_ns) ? "ns" : (tflag == ftw_sl) ? "sl" : + (tflag == ftw_sln) ? "sln" : "???", + ftwbuf\->level); + + if (tflag == ftw_ns) + printf("\-\-\-\-\-\-\-"); + else + printf("%7jd", (intmax_t) sb\->st_size); + + printf(" %\-40s %d %s\en", + fpath, ftwbuf\->base, fpath + ftwbuf\->base); + + return 0; /* to tell nftw() to continue */ +} + +int +main(int argc, char *argv[]) +{ + int flags = 0; + + if (argc > 2 && strchr(argv[2], \(aqd\(aq) != null) + flags |= ftw_depth; + if (argc > 2 && strchr(argv[2], \(aqp\(aq) != null) + flags |= ftw_phys; + + if (nftw((argc < 2) ? "." : argv[1], display_info, 20, flags) + == \-1) { + perror("nftw"); + exit(exit_failure); + } + + exit(exit_success); +} +.ee +.sh see also +.br stat (2), +.br fts (3), +.br readdir (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/resolver.3 + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" iso/iec 9899:1999 +.\" +.th wcsncpy 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +wcsncpy \- copy a fixed-size string of wide characters +.sh synopsis +.nf +.b #include +.pp +.bi "wchar_t *wcsncpy(wchar_t *restrict " dest \ +", const wchar_t *restrict " src , +.bi " size_t " n ); +.fi +.sh description +the +.br wcsncpy () +function is the wide-character equivalent of the +.br strncpy (3) +function. +it copies at most +.i n +wide characters from the wide-character +string pointed to by +.ir src , +including the terminating null wide character (l\(aq\e0\(aq), +to the array pointed to by +.ir dest . +exactly +.i n +wide characters are +written at +.ir dest . +if the length \fiwcslen(src)\fp is smaller than +.ir n , +the remaining wide characters in the array +pointed to by +.i dest +are filled +with null wide characters. +if the length \fiwcslen(src)\fp is greater than or equal +to +.ir n , +the string pointed to by +.i dest +will not be terminated by a null wide character. +.pp +the strings may not overlap. +.pp +the programmer must ensure that there is room for at least +.i n +wide +characters at +.ir dest . +.sh return value +.br wcsncpy () +returns +.ir dest . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br wcsncpy () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh see also +.br strncpy (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/malloc_hook.3 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" and copyright 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified 1993-07-24 by rik faith (faith@cs.unc.edu) +.\" modified 2002-07-25 by walter harms +.\" (walter.harms@informatik.uni-oldenburg.de) +.\" +.th acosh 3 2021-03-22 "" "linux programmer's manual" +.sh name +acosh, acoshf, acoshl \- inverse hyperbolic cosine function +.sh synopsis +.nf +.b #include +.pp +.bi "double acosh(double " x ); +.bi "float acoshf(float " x ); +.bi "long double acoshl(long double " x ); +.pp +.fi +link with \fi\-lm\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br acosh (): +.nf + _isoc99_source || _posix_c_source >= 200112l + || _xopen_source >= 500 +.\" || _xopen_source && _xopen_source_extended + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.pp +.br acoshf (), +.br acoshl (): +.nf + _isoc99_source || _posix_c_source >= 200112l + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.sh description +these functions calculate the inverse hyperbolic cosine of +.ir x ; +that is the value whose hyperbolic cosine is +.ir x . +.sh return value +on success, these functions return the inverse hyperbolic cosine of +.ir x . +.pp +if +.i x +is a nan, a nan is returned. +.pp +if +.i x +is +1, +0 is returned. +.pp +if +.i x +is positive infinity, positive infinity is returned. +.pp +if +.i x +is less than 1, +a domain error occurs, +and the functions return a nan. +.sh errors +see +.br math_error (7) +for information on how to determine whether an error has occurred +when calling these functions. +.pp +the following errors can occur: +.tp +domain error: \fix\fp is less than 1 +.i errno +is set to +.br edom . +an invalid floating-point exception +.rb ( fe_invalid ) +is raised. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br acosh (), +.br acoshf (), +.br acoshl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.pp +the variant returning +.i double +also conforms to +svr4, 4.3bsd. +.sh see also +.br asinh (3), +.br atanh (3), +.br cacosh (3), +.br cosh (3), +.br sinh (3), +.br tanh (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/infinity.3 + +.\" copyright (c) 2000 andries brouwer (aeb@cwi.nl) +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th strfmon 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +strfmon, strfmon_l \- convert monetary value to a string +.sh synopsis +.nf +.b #include +.pp +.bi "ssize_t strfmon(char *restrict " s ", size_t " max , +.bi " const char *restrict " format ", ...);" +.bi "ssize_t strfmon_l(char *restrict " s ", size_t " max ", locale_t " locale , +.bi " const char *restrict " format ", ...);" +.fi +.sh description +the +.br strfmon () +function formats the specified monetary amount +according to the current locale +and format specification +.i format +and places the +result in the character array +.i s +of size +.ir max . +.pp +the +.br strfmon_l () +function performs the same task, +but uses +the locale specified by +.ir locale . +the behavior of +.br strfmon_l () +is undefined if +.i locale +is the special locale object +.br lc_global_locale +(see +.br duplocale (3)) +or is not a valid locale object handle. +.pp +ordinary characters in +.i format +are copied to +.i s +without conversion. +conversion specifiers are introduced by a \(aq%\(aq +character. +immediately following it there can be zero or more +of the following flags: +.tp +.bi = f +the single-byte character +.i f +is used as the numeric fill character (to be used with +a left precision, see below). +when not specified, the space character is used. +.tp +.b \(ha +do not use any grouping characters that might be defined +for the current locale. +by default, grouping is enabled. +.tp +.br ( " or " + +the ( flag indicates that negative amounts should be enclosed between +parentheses. +the + flag indicates that signs should be handled +in the default way, that is, amounts are preceded by the locale's +sign indication, for example, nothing for positive, "\-" for negative. +.tp +.b ! +omit the currency symbol. +.tp +.b \- +left justify all fields. +the default is right justification. +.pp +next, there may be a field width: a decimal digit string specifying +a minimum field width in bytes. +the default is 0. +a result smaller than this width is padded with spaces +(on the left, unless the left-justify flag was given). +.pp +next, there may be a left precision of the form "#" followed by +a decimal digit string. +if the number of digits left of the +radix character is smaller than this, the representation is +padded on the left with the numeric fill character. +grouping characters are not counted in this field width. +.pp +next, there may be a right precision of the form "." followed by +a decimal digit string. +the amount being formatted is rounded to +the specified number of digits prior to formatting. +the default is specified in the +.i frac_digits +and +.i int_frac_digits +items of the current locale. +if the right precision is 0, no radix character is printed. +(the radix character here is determined by +.br lc_monetary , +and may differ from that specified by +.br lc_numeric .) +.pp +finally, the conversion specification must be ended with a +conversion character. +the three conversion characters are +.tp +.b % +(in this case, the entire specification must be exactly "%%".) +put a \(aq%\(aq character in the result string. +.tp +.b i +one argument of type +.i double +is converted using the locale's international currency format. +.tp +.b n +one argument of type +.i double +is converted using the locale's national currency format. +.sh return value +the +.br strfmon () +function returns the number of characters placed +in the array +.ir s , +not including the terminating null byte, +provided the string, including the terminating null byte, fits. +otherwise, it sets +.i errno +to +.br e2big , +returns \-1, and the contents of the array is undefined. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br strfmon () +t} thread safety mt-safe locale +t{ +.br strfmon_l () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh examples +the call +.pp +.in +4n +.ex +strfmon(buf, sizeof(buf), "[%\(ha=*#6n] [%=*#6i]", + 1234.567, 1234.567); +.ee +.in +.pp +outputs +.pp +.in +4n +.ex +[€ **1234,57] [eur **1 234,57] +.ee +.in +.pp +in the +.i nl_nl +locale. +the +.ir de_de , +.ir de_ch , +.ir en_au , +and +.i en_gb +locales yield +.pp +.in +4n +.ex +[ **1234,57 €] [ **1.234,57 eur] +[ fr. **1234.57] [ chf **1\(aq234.57] +[ $**1234.57] [ aud**1,234.57] +[ £**1234.57] [ gbp**1,234.57] +.ee +.in +.sh see also +.br duplocale (3), +.br setlocale (3), +.br sprintf (3), +.br locale (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man7/system_data_types.7 + +.\" copyright 1999 suse gmbh nuernberg, germany +.\" author: thorsten kukuk +.\" +.\" %%%license_start(gplv2+_sw_3_para) +.\" this program is free software; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of the +.\" license, or (at your option) any later version. +.\" +.\" this program 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 +.\" general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" modified, 6 may 2002, michael kerrisk, +.\" change listed order of /usr/lib and /lib +.th ldconfig 8 2021-03-22 "gnu" "linux programmer's manual" +.sh name +ldconfig \- configure dynamic linker run-time bindings +.sh synopsis +.br /sbin/ldconfig " [" \-nnvxv "] [" \-f " \ficonf\fp] [" \-c " \ficache\fp] [" \-r " \firoot\fp]" +.ir directory \... +.pd 0 +.pp +.pd +.b /sbin/ldconfig +.b \-l +.rb [ \-v ] +.ir library \... +.pd 0 +.pp +.pd +.b /sbin/ldconfig +.b \-p +.sh description +.b ldconfig +creates the necessary links and cache to the most recent shared +libraries found in the directories specified on the command line, +in the file +.ir /etc/ld.so.conf , +and in the trusted directories, +.i /lib +and +.ir /usr/lib +(on some 64-bit architectures such as x86-64, +.i /lib +and +.ir /usr/lib +are the trusted directories for 32-bit libraries, while +.i /lib64 +and +.ir /usr/lib64 +are used for 64-bit libraries). +.pp +the cache is used by the run-time linker, +.i ld.so +or +.ir ld\-linux.so . +.b ldconfig +checks the header and filenames of the libraries it encounters when +determining which versions should have their links updated. +.pp +.b ldconfig +will attempt to deduce the type of elf libraries (i.e., libc5 or libc6/glibc) +based on what c libraries, if any, the library was linked against. +.\" the following sentence looks suspect +.\" (perhaps historical cruft) -- mtk, jul 2005 +.\" therefore, when making dynamic libraries, +.\" it is wise to explicitly link against libc (use \-lc). +.pp +some existing libraries do not contain enough information +to allow the deduction of their type. +therefore, the +.i /etc/ld.so.conf +file format allows the specification of an expected type. +this is used +.i only +for those elf libraries which we can not work out. +the format +is "dirname=type", where type can be libc4, libc5, or libc6. +(this syntax also works on the command line.) +spaces are +.i not +allowed. +also see the +.b \-p +option. +.b ldconfig +should normally be run by the superuser as it may require write +permission on some root owned directories and files. +.pp +note that +.b ldconfig +will only look at files that are named +.i lib*.so* +(for regular shared objects) or +.i ld\-*.so* +(for the dynamic loader itself). +other files will be ignored. +also, +.b ldconfig +expects a certain pattern to how the symlinks are set up, like this +example, where the middle file +.rb ( libfoo.so.1 +here) is the soname for the library: +.pp +.in +4n +.ex +libfoo.so \-> libfoo.so.1 \-> libfoo.so.1.12 +.ee +.in +.pp +failure to follow this pattern may result in compatibility issues +after an upgrade. +.sh options +.tp +.br \-c " \fifmt\fp, " \-\-format=\fifmt\fp +(since glibc 2.2) +cache format to use: +.ir old , +.ir new , +or +.ir compat . +since glibc 2.32, the default is +.ir new . +.\" commit cad64f778aced84efdaa04ae64f8737b86f063ab +before that, it was +.ir compat . +.tp +.bi "\-c " cache +use +.i cache +instead of +.ir /etc/ld.so.cache . +.tp +.bi "\-f " conf +use +.i conf +instead of +.ir /etc/ld.so.conf . +.\" fixme glibc 2.7 added -i +.tp +.br \-i ", " \-\-ignore\-aux\-cache +(since glibc 2.7) +.\" commit 27d9ffda17df4d2388687afd12897774fde39bcc +ignore auxiliary cache file. +.tp +.b \-l +(since glibc 2.2) +library mode. +manually link individual libraries. +intended for use by experts only. +.tp +.b \-n +process only the directories specified on the command line. +don't process the trusted directories, +nor those specified in +.ir /etc/ld.so.conf . +implies +.br \-n . +.tp +.b \-n +don't rebuild the cache. +unless +.b \-x +is also specified, links are still updated. +.tp +.br \-p ", " \-\-print\-cache +print the lists of directories and candidate libraries stored in +the current cache. +.tp +.bi "\-r " root +change to and use +.i root +as the root directory. +.tp +.br \-v ", " \-\-verbose +verbose mode. +print current version number, the name of each directory as it +is scanned, and any links that are created. +overrides quiet mode. +.tp +.br \-v ", " \-\-version +print program version. +.tp +.b \-x +don't update links. +unless +.b \-n +is also specified, the cache is still rebuilt. +.sh files +.\" fixme since glibc-2.3.4, "include" directives are supported in ld.so.conf +.\" +.\" fixme since glibc-2.4, "hwcap" directives are supported in ld.so.conf +.pd 0 +.tp +.i /lib/ld.so +run-time linker/loader. +.tp +.i /etc/ld.so.conf +file containing a list of directories, one per line, +in which to search for libraries. +.tp +.i /etc/ld.so.cache +file containing an ordered list of libraries found in the directories +specified in +.ir /etc/ld.so.conf , +as well as those found in the trusted directories. +.pd +.sh see also +.br ldd (1), +.br ld.so (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/truncate.2 + +.so man3/slist.3 + +.\" copyright (c) 2012, ibm corporation. +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of +.\" this manual under the conditions for verbatim copying, provided that +.\" the entire resulting derived work is distributed under the terms of +.\" a permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume. +.\" no responsibility for errors or omissions, or for damages resulting. +.\" from the use of the information contained herein. the author(s) may. +.\" not have taken the same level of care in the production of this. +.\" manual, which is licensed free of charge, as they might when working. +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th __ppc_get_timebase 3 2021-03-22 "gnu c library" "linux programmer's\ +manual" +.sh name +__ppc_get_timebase, __ppc_get_timebase_freq \- get the current value + of the time base register on power architecture and its frequency. +.sh synopsis +.nf +.b #include +.pp +.bi "uint64_t __ppc_get_timebase(void);" +.bi "uint64_t __ppc_get_timebase_freq(void);" +.fi +.sh description +.br __ppc_get_timebase () +reads the current value of the time base register and returns its +value, while +.br __ppc_get_timebase_freq () +returns the frequency in which the time base register is updated. +.pp +the time base register is a 64-bit register provided by power architecture +processors. +it stores a monotonically incremented value that is updated at a +system-dependent frequency that may be different from the processor +frequency. +.sh return value +.br __ppc_get_timebase () +returns a 64-bit unsigned integer that represents the current value of the +time base register. +.pp +.br __ppc_get_timebase_freq () +returns a 64-bit unsigned integer that represents the frequency at +which the time base register is updated. +.sh versions +gnu c library support for +.\" commit d9dc34cd569bcfe714fe8c708e58c028106e8b2e +.br __ppc_get_timebase () +has been provided since version 2.16 and +.\" commit 8ad11b9a9cf1de82bd7771306b42070b91417c11 +.br __ppc_get_timebase_freq () +has been available since version 2.17. +.sh conforming to +both functions are nonstandard gnu extensions. +.sh examples +the following program will calculate the time, in microseconds, spent +between two calls to +.br __ppc_get_timebase (). +.ss program source +\& +.ex +#include +#include +#include +#include +#include + +/* maximum value of the time base register: 2\(ha60 \- 1. + source: power isa. */ +#define max_tb 0xfffffffffffffff + +int +main(void) +{ + uint64_t tb1, tb2, diff; + + uint64_t freq = __ppc_get_timebase_freq(); + printf("time base frequency = %"priu64" hz\en", freq); + + tb1 = __ppc_get_timebase(); + + // do some stuff... + + tb2 = __ppc_get_timebase(); + + if (tb2 > tb1) { + diff = tb2 \- tb1; + } else { + /* treat time base register overflow. */ + diff = (max_tb \- tb2) + tb1; + } + + printf("elapsed time = %1.2f usecs\en", + (double) diff * 1000000 / freq ); + + exit(exit_success); +} +.ee +.sh see also +.br time (2), +.br usleep (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/wait4.2 + +.so man3/ferror.3 + +.so man2/mlock.2 + +.\" copyright (c) 2014 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th locale 1 2021-03-22 "linux" "linux user manual" +.sh name +locale \- get locale-specific information +.sh synopsis +.nf +.br locale " [\fioption\fp]" +.br locale " [\fioption\fp] " \-a +.br locale " [\fioption\fp] " \-m +.br locale " [\fioption\fp] \finame\fp..." +.fi +.sh description +the +.b locale +command displays information about the current locale, or all locales, +on standard output. +.pp +when invoked without arguments, +.b locale +displays the current locale settings for each locale category (see +.br locale (5)), +based on the settings of the environment variables that control the locale +(see +.br locale (7)). +values for variables set in the environment are printed without double +quotes, implied values are printed with double quotes. +.pp +if either the +.b \-a +or the +.b \-m +option (or one of their long-format equivalents) is specified, +the behavior is as follows: +.tp +.br \-a ", " \-\-all\-locales +display a list of all available locales. +the +.b \-v +option causes the +.b lc_identification +metadata about each locale to be included in the output. +.tp +.br \-m ", " \-\-charmaps +display the available charmaps (character set description files). +to display the current character set for the locale, use +\fblocale \-c charmap\fr. +.pp +the +.b locale +command can also be provided with one or more arguments, +which are the names of locale keywords (for example, +.ir date_fmt , +.ir ctype\-class\-names , +.ir yesexpr , +or +.ir decimal_point ) +or locale categories (for example, +.b lc_ctype +or +.br lc_time ). +for each argument, the following is displayed: +.ip * 3 +for a locale keyword, the value of that keyword to be displayed. +.ip * +for a locale category, +the values of all keywords in that category are displayed. +.pp +when arguments are supplied, the following options are meaningful: +.tp +.br \-c ", " \-\-category\-name +for a category name argument, +write the name of the locale category +on a separate line preceding the list of keyword values for that category. +.ip +for a keyword name argument, +write the name of the locale category for this keyword +on a separate line preceding the keyword value. +.ip +this option improves readability when multiple name arguments are specified. +it can be combined with the +.b \-k +option. +.tp +.br \-k ", " \-\-keyword\-name +for each keyword whose value is being displayed, +include also the name of that keyword, +so that the output has the format: +.ip + \fikeyword\fp="\fivalue\fp" +.pp +the +.b locale +command also knows about the following options: +.tp +.br \-v ", " \-\-verbose +display additional information for some command-line option and argument +combinations. +.tp +.br \-? ", " \-\-help +display a summary of command-line options and arguments and exit. +.tp +.b \-\-usage +display a short usage message and exit. +.tp +.br \-v ", " \-\-version +display the program version and exit. +.sh files +.tp +.i /usr/lib/locale/locale\-archive +usual default locale archive location. +.tp +.i /usr/share/i18n/locales +usual default path for locale definition files. +.sh conforming to +posix.1-2001, posix.1-2008. +.sh examples +.ex +$ \fblocale\fp +lang=en_us.utf\-8 +lc_ctype="en_us.utf\-8" +lc_numeric="en_us.utf\-8" +lc_time="en_us.utf\-8" +lc_collate="en_us.utf\-8" +lc_monetary="en_us.utf\-8" +lc_messages="en_us.utf\-8" +lc_paper="en_us.utf\-8" +lc_name="en_us.utf\-8" +lc_address="en_us.utf\-8" +lc_telephone="en_us.utf\-8" +lc_measurement="en_us.utf\-8" +lc_identification="en_us.utf\-8" +lc_all= + +$ \fblocale date_fmt\fp +%a %b %e %h:%m:%s %z %y + +$ \fblocale \-k date_fmt\fp +date_fmt="%a %b %e %h:%m:%s %z %y" + +$ \fblocale \-ck date_fmt\fp +lc_time +date_fmt="%a %b %e %h:%m:%s %z %y" + +$ \fblocale lc_telephone\fp ++%c (%a) %l +(%a) %l +11 +1 +utf\-8 + +$ \fblocale \-k lc_telephone\fp +tel_int_fmt="+%c (%a) %l" +tel_dom_fmt="(%a) %l" +int_select="11" +int_prefix="1" +telephone\-codeset="utf\-8" +.ee +.pp +the following example compiles a custom locale from the +.i ./wrk +directory with the +.br localedef (1) +utility under the +.i $home/.locale +directory, then tests the result with the +.br date (1) +command, and then sets the environment variables +.b locpath +and +.b lang +in the shell profile file so that the custom locale will be used in the +subsequent user sessions: +.pp +.ex +$ \fbmkdir \-p $home/.locale\fp +$ \fbi18npath=./wrk/ localedef \-f utf\-8 \-i fi_se $home/.locale/fi_se.utf\-8\fp +$ \fblocpath=$home/.locale lc_all=fi_se.utf\-8 date\fp +$ \fbecho "export locpath=\e$home/.locale" >> $home/.bashrc\fp +$ \fbecho "export lang=fi_se.utf\-8" >> $home/.bashrc\fp +.ee +.sh see also +.br localedef (1), +.br charmap (5), +.br locale (5), +.br locale (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de) +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under gpl +.\" %%%license_end +.\" +.th ctanh 3 2021-03-22 "" "linux programmer's manual" +.sh name +ctanh, ctanhf, ctanhl \- complex hyperbolic tangent +.sh synopsis +.nf +.b #include +.pp +.bi "double complex ctanh(double complex " z ");" +.bi "float complex ctanhf(float complex " z ); +.bi "long double complex ctanhl(long double complex " z ");" +.pp +link with \fi\-lm\fp. +.fi +.sh description +these functions calculate the complex hyperbolic tangent of +.ir z . +.pp +the complex hyperbolic tangent function is defined +mathematically as: +.pp +.nf + ctanh(z) = csinh(z) / ccosh(z) +.fi +.sh versions +these functions first appeared in glibc in version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br ctanh (), +.br ctanhf (), +.br ctanhl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.sh see also +.br cabs (3), +.br catanh (3), +.br ccosh (3), +.br csinh (3), +.br complex (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/sync_file_range.2 + +.so man3/unlocked_stdio.3 + +.\" copyright (c) 2003 free software foundation, inc. +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" this file is distributed according to the gnu general public license. +.\" %%%license_end +.\" +.th io_getevents 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +io_getevents \- read asynchronous i/o events from the completion queue +.sh synopsis +.nf +.br "#include " " /* definition of " *io_* " types */" +.br "#include " " /* definition of " sys_* " constants */" +.b #include +.pp +.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 : +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. +the wrapper function provided by +.i libaio +uses a different type for the +.i ctx_id +argument. +see notes. +.pp +the +.br io_getevents () +system call +attempts to read at least \fimin_nr\fp events and +up to \finr\fp events from the completion queue of the aio context +specified by \fictx_id\fp. +.pp +the \fitimeout\fp argument specifies the amount of time to wait for events, +and is specified as a relative timeout in a structure of the following form: +.pp +.in +4n +.ex +struct timespec { + time_t tv_sec; /* seconds */ + long tv_nsec; /* nanoseconds [0 .. 999999999] */ +}; +.ee +.in +.pp +the specified time will be rounded up to the system clock granularity +and is guaranteed not to expire early. +.pp +specifying +.i timeout +as null means block indefinitely until at least +.i min_nr +events have been obtained. +.sh return value +on success, +.br io_getevents () +returns the number of events read. +this may be 0, or a value less than +.ir min_nr , +if the +.i timeout +expired. +it may also be a nonzero value less than +.ir min_nr , +if the call was interrupted by a signal handler. +.pp +for the failure return, see notes. +.sh errors +.tp +.b efault +either \fievents\fp or \fitimeout\fp is an invalid pointer. +.tp +.b eintr +interrupted by a signal handler; see +.br signal (7). +.tp +.b einval +\fictx_id\fp is invalid. +\fimin_nr\fp is out of range or \finr\fp is +out of range. +.tp +.b enosys +.br io_getevents () +is not implemented on this architecture. +.sh versions +the asynchronous i/o system calls first appeared in linux 2.5. +.sh conforming to +.br io_getevents () +is linux-specific and should not be used in +programs that are intended to be portable. +.sh notes +you probably want to use the +.br io_getevents () +wrapper function provided by +.\" http://git.fedorahosted.org/git/?p=libaio.git +.ir libaio . +.pp +note that the +.i libaio +wrapper function uses a different type +.ri ( io_context_t ) +.\" but glibc is confused, since uses 'io_context_t' to declare +.\" the system call. +for the +.i ctx_id +argument. +note also that the +.i libaio +wrapper does not follow the usual c library conventions for indicating errors: +on error it returns a negated error number +(the negative of one of the values listed in errors). +if the system call is invoked via +.br syscall (2), +then the return value follows the usual conventions for +indicating an error: \-1, with +.i errno +set to a (positive) value that indicates the error. +.sh bugs +an invalid +.ir ctx_id +may cause a segmentation fault instead of generating the error +.br einval . +.sh see also +.br io_cancel (2), +.br io_destroy (2), +.br io_setup (2), +.br io_submit (2), +.br aio (7), +.br time (7) +.\" .sh author +.\" kent yoder. +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/strtod.3 + +.so man3/setaliasent.3 + +.so man2/alloc_hugepages.2 + +.so man3/getutent.3 + +.\" copyright (c) 1995 michael chastain (mec@shell.portal.com), 15 april 1995. +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" modified tue oct 22 08:11:14 edt 1996 by eric s. raymond +.th ipc 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +ipc \- system v ipc system calls +.sh synopsis +.nf +.br "#include " " /* definition of needed constants */" +.br "#include " " /* definition of " sys_* " constants */" +.b #include +.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 : +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 +for messages, semaphores, and shared memory. +.i call +determines which ipc function to invoke; +the other arguments are passed through to the appropriate call. +.pp +user-space programs should call the appropriate functions by their usual names. +only standard library implementors and kernel hackers need to know about +.br ipc (). +.sh conforming to +.br ipc () +is linux-specific, and should not be used in programs +intended to be portable. +.sh notes +on some architectures\(emfor example x86-64 and arm\(emthere is no +.br ipc () +system call; instead, +.br msgctl (2), +.br semctl (2), +.br shmctl (2), +and so on really are implemented as separate system calls. +.sh see also +.br msgctl (2), +.br msgget (2), +.br msgrcv (2), +.br msgsnd (2), +.br semctl (2), +.br semget (2), +.br semop (2), +.br semtimedop (2), +.br shmat (2), +.br shmctl (2), +.br shmdt (2), +.br shmget (2), +.br sysvipc (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2014 marko myllynen +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th iconv 1 2021-08-27 "gnu" "linux user manual" +.sh name +iconv \- convert text from one character encoding to another +.sh synopsis +.b iconv +.ri [ options ] +.ri "[\-f " from-encoding "]" +.ri "[\-t " to-encoding "]" +.ri [ inputfile ]... +.sh description +the +.b iconv +program reads in text in one encoding and outputs the text in another +encoding. +if no input files are given, or if it is given as a dash (\-), +.b iconv +reads from standard input. +if no output file is given, +.b iconv +writes to standard output. +.pp +if no +.i from-encoding +is given, the default is derived +from the current locale's character encoding. +if no +.i to-encoding +is given, the default is derived +from the current locale's character +encoding. +.sh options +.tp +.bi \-f " from-encoding" "\fr, \fp\-\-from\-code=" from-encoding +use +.i from-encoding +for input characters. +.tp +.bi \-t " to-encoding" "\fr, \fp\-\-to\-code=" to-encoding +use +.i to-encoding +for output characters. +.ip +if the string +.b //ignore +is appended to +.ir to-encoding , +characters that cannot be converted are discarded and an error is +printed after conversion. +.ip +if the string +.b //translit +is appended to +.ir to-encoding , +characters being converted are transliterated when needed and possible. +this means that when a character cannot be represented in the target +character set, it can be approximated through one or several similar +looking characters. +characters that are outside of the target character set and cannot be +transliterated are replaced with a question mark (?) in the output. +.tp +.br \-l ", " \-\-list +list all known character set encodings. +.tp +.b "\-c" +silently discard characters that cannot be converted instead of +terminating when encountering such characters. +.tp +.bi \-o " outputfile" "\fr, \fp\-\-output=" outputfile +use +.i outputfile +for output. +.tp +.br \-s ", " \-\-silent +this option is ignored; it is provided only for compatibility. +.tp +.b "\-\-verbose" +print progress information on standard error when processing +multiple files. +.tp +.br \-? ", " \-\-help +print a usage summary and exit. +.tp +.b "\-\-usage" +print a short usage summary and exit. +.tp +.br \-v ", " \-\-version +print the version number, license, and disclaimer of warranty for +.br iconv . +.sh exit status +zero on success, nonzero on errors. +.sh environment +internally, the +.b iconv +program uses the +.br iconv (3) +function which in turn uses +.i gconv +modules (dynamically loaded shared libraries) +to convert to and from a character set. +before calling +.br iconv (3), +the +.b iconv +program must first allocate a conversion descriptor using +.br iconv_open (3). +the operation of the latter function is influenced by the setting of the +.b gconv_path +environment variable: +.ip * 3 +if +.b gconv_path +is not set, +.br iconv_open (3) +loads the system gconv module configuration cache file created by +.br iconvconfig (8) +and then, based on the configuration, +loads the gconv modules needed to perform the conversion. +if the system gconv module configuration cache file is not available +then the system gconv module configuration file is used. +.ip * +if +.b gconv_path +is defined (as a colon-separated list of pathnames), +the system gconv module configuration cache is not used. +instead, +.br iconv_open (3) +first tries to load the configuration files by searching the directories in +.b gconv_path +in order, +followed by the system default gconv module configuration file. +if a directory does not contain a gconv module configuration file, +any gconv modules that it may contain are ignored. +if a directory contains a gconv module configuration file +and it is determined that a module needed for this conversion is +available in the directory, +then the needed module is loaded from that directory, +the order being such that the first suitable module found in +.b gconv_path +is used. +this allows users to use custom modules and even replace system-provided +modules by providing such modules in +.b gconv_path +directories. +.sh files +.tp +.i /usr/lib/gconv +usual default gconv module path. +.tp +.i /usr/lib/gconv/gconv\-modules +usual system default gconv module configuration file. +.tp +.i /usr/lib/gconv/gconv\-modules.cache +usual system gconv module configuration cache. +.pp +depending on the architecture, +the above files may instead be located at directories with the path prefix +.ir /usr/lib64 . +.sh conforming to +posix.1-2001. +.sh examples +convert text from the iso 8859-15 character encoding to utf-8: +.pp +.in +4n +.ex +$ \fbiconv \-f iso\-8859\-15 \-t utf\-8 < input.txt > output.txt\fp +.ee +.in +.pp +the next example converts from utf-8 to ascii, transliterating when +possible: +.pp +.in +4n +.ex +$ \fbecho abc ß α € àḃç | iconv \-f utf\-8 \-t ascii//translit\fp +abc ss ? eur abc +.ee +.in +.sh see also +.br locale (1), +.br uconv (1), +.br iconv (3), +.br nl_langinfo (3), +.br charsets (7), +.br iconvconfig (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de) +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under gpl +.\" %%%license_end +.\" +.th cexp2 3 2021-03-22 "" "linux programmer's manual" +.sh name +cexp2, cexp2f, cexp2l \- base-2 exponent of a complex number +.sh synopsis +.nf +.b #include +.pp +.bi "double complex cexp2(double complex " z ");" +.bi "float complex cexp2f(float complex " z ");" +.bi "long double complex cexp2l(long double complex " z ");" +.pp +link with \fi\-lm\fp. +.fi +.sh description +the function returns 2 raised to the power of +.ir z . +.sh conforming to +these function names are reserved for future use in c99. +.pp +as at version 2.31, these functions are not provided in glibc. +.\" but reserved in namespace. +.sh see also +.br cabs (3), +.br cexp (3), +.br clog10 (3), +.br complex (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +#!/bin/sh +# +# convert_to_utf_8.sh +# +# find man pages with encoding other than us-ascii, and convert them +# to the utf-8 encoding. +# +# example usage: +# +# cd man-pages-x.yy +# sh convert_to_utf_8.sh man?/* +# +###################################################################### +# +# (c) copyright 2013, peter schiffer +# this program is free software; you can redistribute it and/or +# modify it under the terms of the gnu general public license +# as published by the free software foundation; either version 2 +# of the license, or (at your option) any later version. +# +# this program 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 general public license for more details +# (http://www.gnu.org/licenses/gpl-2.0.html). +# + +if [[ $# -lt 2 ]]; then + echo "usage: ${0} man?/*" 1>&2 + exit 1 +fi + +out_dir="$1" +shift + +enc_line="" + +for f in "$@"; do + enc=$(file -bi "$f" | cut -d = -f 2) + if [[ $enc != "us-ascii" ]]; then + dirn=$(dirname "$f") + basen=$(basename "$f") + new_dir="${out_dir}/${dirn}" + if [[ ! -e "$new_dir" ]]; then + mkdir -p "$new_dir" + fi + case "$basen" in + armscii-8.7 | cp1251.7 | iso_8859-*.7 | koi8-?.7) + + # iconv does not understand some encoding names that + # start "iso_", but does understand the corresponding + # forms that start with "iso-" + + from_enc="$(echo $basen | sed 's/\.7$//;s/iso_/iso-/')" + ;; + *) + echo "null transform: $f" + from_enc=$enc + ;; + esac + printf "converting %-23s from %s\n" "$f" "$from_enc" + echo "$enc_line" > "${new_dir}/${basen}" + iconv -f "$from_enc" -t utf-8 "$f" \ + | sed "/.*-\*- coding:.*/d;/.\\\" t$/d" >> "${new_dir}/${basen}" + fi +done + +exit 0 + +.\" copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de) +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under gpl +.\" %%%license_end +.\" +.th ctan 3 2021-03-22 "" "linux programmer's manual" +.sh name +ctan, ctanf, ctanl \- complex tangent function +.sh synopsis +.nf +.b #include +.pp +.bi "double complex ctan(double complex " z ");" +.bi "float complex ctanf(float complex " z ); +.bi "long double complex ctanl(long double complex " z ");" +.pp +link with \fi\-lm\fp. +.fi +.sh description +these functions calculate the complex tangent of +.ir z . +.pp +the complex tangent function is defined as: +.pp +.nf + ctan(z) = csin(z) / ccos(z) +.fi +.sh versions +these functions first appeared in glibc in version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br ctan (), +.br ctanf (), +.br ctanl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.sh see also +.br cabs (3), +.br catan (3), +.br ccos (3), +.br csin (3), +.br complex (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/getpwnam.3 + +.\" copyright andries brouwer, 2000 +.\" some fragments of text came from the time-1.7 info file. +.\" inspired by kromjx@crosswinds.net. +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under gpl +.\" %%%license_end +.\" +.th time 1 2019-03-06 "" "linux user's manual" +.sh name +time \- time a simple command or give resource usage +.sh synopsis +.b time \c +.ri [ options ] " command " [ arguments... ] +.sh description +the +.b time +command runs the specified program +.i command +with the given arguments. +when +.i command +finishes, +.b time +writes a message to standard error giving timing statistics +about this program run. +these statistics consist of (i) the elapsed real time +between invocation and termination, (ii) the user cpu time +(the sum of the +.i tms_utime +and +.i tms_cutime +values in a +.i "struct tms" +as returned by +.br times (2)), +and (iii) the system cpu time (the sum of the +.i tms_stime +and +.i tms_cstime +values in a +.i "struct tms" +as returned by +.br times (2)). +.pp +note: some shells (e.g., +.br bash (1)) +have a built-in +.b time +command that provides similar information on the usage of time and +possibly other resources. +to access the real command, you may need to specify its pathname +(something like +.ir /usr/bin/time ). +.sh options +.tp +.b \-p +when in the posix locale, use the precise traditional format +.ip +.in +4n +.ex +"real %f\enuser %f\ensys %f\en" +.ee +.in +.ip +(with numbers in seconds) +where the number of decimals in the output for %f is unspecified +but is sufficient to express the clock tick accuracy, and at least one. +.sh exit status +if +.i command +was invoked, the exit status is that of +.ir command . +otherwise, it is 127 if +.i command +could not be found, 126 if it could be found but could not be invoked, +and some other nonzero value (1\(en125) if something else went wrong. +.sh environment +the variables +.br lang , +.br lc_all , +.br lc_ctype , +.br lc_messages , +.br lc_numeric , +and +.b nlspath +are used for the text and formatting of the output. +.b path +is used to search for +.ir command . +.sh gnu version +below a description of the gnu 1.7 version of +.br time . +disregarding the name of the utility, gnu makes it output lots of +useful information, not only about time used, but also on other +resources like memory, i/o and ipc calls (where available). +the output is formatted using a format string that can be specified +using the +.i \-f +option or the +.b time +environment variable. +.pp +the default format string is: +.pp +.in +4n +.ex +%uuser %ssystem %eelapsed %pcpu (%xtext+%ddata %mmax)k +%iinputs+%ooutputs (%fmajor+%rminor)pagefaults %wswaps +.ee +.in +.pp +when the +.i \-p +option is given, the (portable) output format is used: +.pp +.in +4n +.ex +real %e +user %u +sys %s +.ee +.in +.\" +.ss the format string +the format is interpreted in the usual printf-like way. +ordinary characters are directly copied, tab, newline, +and backslash are escaped using \et, \en, and \e\e, +a percent sign is represented by %%, and otherwise % +indicates a conversion. +the program +.b time +will always add a trailing newline itself. +the conversions follow. +all of those used by +.br tcsh (1) +are supported. +.pp +.b "time" +.tp +.b %e +elapsed real time (in [hours:]minutes:seconds). +.tp +.b %e +(not in +.br tcsh (1).) +elapsed real time (in seconds). +.tp +.b %s +total number of cpu-seconds that the process spent in kernel mode. +.tp +.b %u +total number of cpu-seconds that the process spent in user mode. +.tp +.b %p +percentage of the cpu that this job got, computed as (%u + %s) / %e. +.pp +.b "memory" +.tp +.b %m +maximum resident set size of the process during its lifetime, in kbytes. +.tp +.b %t +(not in +.br tcsh (1).) +average resident set size of the process, in kbytes. +.tp +.b %k +average total (data+stack+text) memory use of the process, +in kbytes. +.tp +.b %d +average size of the process's unshared data area, in kbytes. +.tp +.b %p +(not in +.br tcsh (1).) +average size of the process's unshared stack space, in kbytes. +.tp +.b %x +average size of the process's shared text space, in kbytes. +.tp +.b %z +(not in +.br tcsh (1).) +system's page size, in bytes. +this is a per-system constant, but varies between systems. +.tp +.b %f +number of major page faults that occurred while the process was running. +these are faults where the page has to be read in from disk. +.tp +.b %r +number of minor, or recoverable, page faults. +these are faults for pages that are not valid but which have +not yet been claimed by other virtual pages. +thus the data +in the page is still valid but the system tables must be updated. +.tp +.b %w +number of times the process was swapped out of main memory. +.tp +.b %c +number of times the process was context-switched involuntarily +(because the time slice expired). +.tp +.b %w +number of waits: times that the program was context-switched voluntarily, +for instance while waiting for an i/o operation to complete. +.pp +.b "i/o" +.tp +.b %i +number of filesystem inputs by the process. +.tp +.b %o +number of filesystem outputs by the process. +.tp +.b %r +number of socket messages received by the process. +.tp +.b %s +number of socket messages sent by the process. +.tp +.b %k +number of signals delivered to the process. +.tp +.b %c +(not in +.br tcsh (1).) +name and command-line arguments of the command being timed. +.tp +.b %x +(not in +.br tcsh (1).) +exit status of the command. +.ss gnu options +.tp +.bi "\-f " format ", \-\-format=" format +specify output format, possibly overriding the format specified +in the environment variable time. +.tp +.b "\-p, \-\-portability" +use the portable output format. +.tp +.bi "\-o " file ", \-\-output=" file +do not send the results to +.ir stderr , +but overwrite the specified file. +.tp +.b "\-a, \-\-append" +(used together with \-o.) do not overwrite but append. +.tp +.b "\-v, \-\-verbose" +give very verbose output about all the program knows about. +.tp +.b "\-q, \-\-quiet" +don't report abnormal program termination (where +.i command +is terminated by a signal) or nonzero exit status. +.\" +.ss gnu standard options +.tp +.b "\-\-help" +print a usage message on standard output and exit successfully. +.tp +.b "\-v, \-\-version" +print version information on standard output, then exit successfully. +.tp +.b "\-\-" +terminate option list. +.sh bugs +not all resources are measured by all versions of unix, +so some of the values might be reported as zero. +the present selection was mostly inspired by the data +provided by 4.2 or 4.3bsd. +.pp +gnu time version 1.7 is not yet localized. +thus, it does not implement the posix requirements. +.pp +the environment variable +.b time +was badly chosen. +it is not unusual for systems like +.br autoconf (1) +or +.br make (1) +to use environment variables with the name of a utility to override +the utility to be used. +uses like more or time for options to programs +(instead of program pathnames) tend to lead to difficulties. +.pp +it seems unfortunate that +.i \-o +overwrites instead of appends. +(that is, the +.i \-a +option should be the default.) +.pp +mail suggestions and bug reports for gnu +.b time +to +.ir bug\-time@gnu.org . +please include the version of +.br time , +which you can get by running +.pp +.in +4n +.ex +time \-\-version +.ee +.in +.pp +and the operating system +and c compiler you used. +.\" .sh authors +.\" .tp +.\" .ip "david keppel" +.\" original version +.\" .ip "david mackenzie" +.\" posixization, autoconfiscation, gnu getoptization, +.\" documentation, other bug fixes and improvements. +.\" .ip "arne henrik juul" +.\" helped with portability +.\" .ip "francois pinard" +.\" helped with portability +.sh see also +.br bash (1), +.br tcsh (1), +.br times (2), +.br wait3 (2) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/pthread_attr_setscope.3 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified 1993-07-24 by rik faith (faith@cs.unc.edu) +.\" modified 2001-04-01 by aeb +.\" modified 2003-07-23 by aeb +.\" +.th usleep 3 2021-03-22 "" "linux programmer's manual" +.sh name +usleep \- suspend execution for microsecond intervals +.sh synopsis +.nf +.b "#include " +.pp +.bi "int usleep(useconds_t " usec ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br usleep (): +.nf + since glibc 2.12: + (_xopen_source >= 500) && ! (_posix_c_source >= 200809l) + || /* glibc since 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source + before glibc 2.12: + _bsd_source || _xopen_source >= 500 +.\" || _xopen_source && _xopen_source_extended +.fi +.sh description +the +.br usleep () +function suspends execution of the calling thread for +(at least) \fiusec\fp microseconds. +the sleep may be lengthened slightly +by any system activity or by the time spent processing the call or by the +granularity of system timers. +.sh return value +the +.br usleep () +function returns 0 on success. +on error, \-1 is returned, with +.i errno +set to indicate the error. +.sh errors +.tp +.b eintr +interrupted by a signal; see +.br signal (7). +.tp +.b einval +\fiusec\fp is greater than or equal to 1000000. +(on systems where that is considered an error.) +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br usleep () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +4.3bsd, posix.1-2001. +posix.1-2001 declares this function obsolete; use +.br nanosleep (2) +instead. +posix.1-2008 removes the specification of +.br usleep (). +.pp +on the original bsd implementation, +and in glibc before version 2.2.2, the return type of this function is +.ir void . +the posix version returns +.ir int , +and this is also the prototype used since glibc 2.2.2. +.pp +only the +.b einval +error return is documented by susv2 and posix.1-2001. +.sh notes +the type +.i useconds_t +is an unsigned integer type capable of holding integers +in the range [0,1000000]. +programs will be more portable +if they never mention this type explicitly. +use +.pp +.in +4n +.ex +#include +\&... + unsigned int usecs; +\&... + usleep(usecs); +.ee +.in +.pp +the interaction of this function with the +.b sigalrm +signal, and with other timer functions such as +.br alarm (2), +.br sleep (3), +.br nanosleep (2), +.br setitimer (2), +.br timer_create (2), +.br timer_delete (2), +.br timer_getoverrun (2), +.br timer_gettime (2), +.br timer_settime (2), +.br ualarm (3) +is unspecified. +.sh see also +.br alarm (2), +.br getitimer (2), +.br nanosleep (2), +.br select (2), +.br setitimer (2), +.br sleep (3), +.br ualarm (3), +.br time (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/getservent_r.3 + +.\" copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de) +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under gpl +.\" %%%license_end +.\" +.\" modified 2003-11-18, aeb: historical remarks +.\" +.th gamma 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +gamma, gammaf, gammal \- (logarithm of the) gamma function +.sh synopsis +.nf +.b #include +.pp +.bi "double gamma(double " x ");" +.bi "float gammaf(float " x ");" +.bi "long double gammal(long double " x ");" +.fi +.pp +link with \fi\-lm\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br gamma (): +.nf + _xopen_source + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.pp +.br gammaf (), +.br gammal (): +.nf + _xopen_source >= 600 || (_xopen_source && _isoc99_source) + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.sh description +these functions are deprecated: instead, use either the +.br tgamma (3) +or the +.br lgamma (3) +functions, as appropriate. +.pp +for the definition of the gamma function, see +.br tgamma (3). +.ss *bsd version +the libm in 4.4bsd and some versions of freebsd had a +.br gamma () +function that computes the gamma function, as one would expect. +.ss glibc version +glibc has a +.br gamma () +function that is equivalent to +.br lgamma (3) +and computes the natural logarithm of the gamma function. +.sh return value +see +.br lgamma (3). +.sh errors +see +.br lgamma (3). +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br gamma (), +.br gammaf (), +.br gammal () +t} thread safety mt-unsafe race:signgam +.te +.hy +.ad +.sp 1 +.sh conforming to +because of historical variations in behavior across systems, +this function is not specified in any recent standard. +it was documented in svid 2. +.sh notes +.ss history +4.2bsd had a +.br gamma () +that computed +.ri ln(|gamma(| x |)|), +leaving the sign of +.ri gamma(| x |) +in the external integer +.ir signgam . +in 4.3bsd the name was changed to +.br lgamma (3), +and the man page promises +.pp +.in +4n +"at some time in the future the name gamma will be rehabilitated +and used for the gamma function" +.in +.pp +this did indeed happen in 4.4bsd, where +.br gamma () +computes the gamma function (with no effect on +.ir signgam ). +however, this came too late, and we now have +.br tgamma (3), +the "true gamma" function. +.\" the freebsd man page says about gamma() that it is like lgamma() +.\" except that is does not set signgam. +.\" also, that 4.4bsd has a gamma() that computes the true gamma function. +.sh see also +.br lgamma (3), +.br signgam (3), +.br tgamma (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/pthread_setcancelstate.3 + +.so man2/posix_fadvise.2 + +.so man2/stat.2 + +.so man3/towlower.3 + +.\" copyright (c) 1993 michael haardt (michael@moria.de) +.\" fri apr 2 11:32:09 met dst 1993 +.\" copyright (c) 2006-2015, michael kerrisk +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" modified 1993-07-24 by rik faith +.\" modified 1995-02-25 by jim van zandt +.\" modified 1995-09-02 by jim van zandt +.\" moved to man3, aeb, 950919 +.\" modified 2001-09-22 by michael kerrisk +.\" modified 2001-12-17, aeb +.\" modified 2004-10-31, aeb +.\" 2006-12-28, mtk: +.\" added .ss headers to give some structure to this page; and a +.\" small amount of reordering. +.\" added a section on canonical and noncanonical mode. +.\" enhanced the discussion of "raw" mode for cfmakeraw(). +.\" document cmspar. +.\" +.th termios 3 2021-08-27 "linux" "linux programmer's manual" +.sh name +termios, tcgetattr, tcsetattr, tcsendbreak, tcdrain, tcflush, tcflow, +cfmakeraw, cfgetospeed, cfgetispeed, cfsetispeed, cfsetospeed, cfsetspeed \- +get and set terminal attributes, line control, get and set baud rate +.sh synopsis +.nf +.b #include +.b #include +.pp +.bi "int tcgetattr(int " fd ", struct termios *" termios_p ); +.bi "int tcsetattr(int " fd ", int " optional_actions , +.bi " const struct termios *" termios_p ); +.pp +.bi "int tcsendbreak(int " fd ", int " duration ); +.bi "int tcdrain(int " fd ); +.bi "int tcflush(int " fd ", int " queue_selector ); +.bi "int tcflow(int " fd ", int " action ); +.pp +.bi "void cfmakeraw(struct termios *" termios_p ); +.pp +.bi "speed_t cfgetispeed(const struct termios *" termios_p ); +.bi "speed_t cfgetospeed(const struct termios *" termios_p ); +.pp +.bi "int cfsetispeed(struct termios *" termios_p ", speed_t " speed ); +.bi "int cfsetospeed(struct termios *" termios_p ", speed_t " speed ); +.bi "int cfsetspeed(struct termios *" termios_p ", speed_t " speed ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br cfsetspeed (), +.br cfmakeraw (): +.nf + since glibc 2.19: + _default_source + glibc 2.19 and earlier: + _bsd_source +.fi +.sh description +the termios functions describe a general terminal interface that is +provided to control asynchronous communications ports. +.ss the termios structure +many of the functions described here have a \fitermios_p\fp argument +that is a pointer to a \fitermios\fp structure. +this structure contains at least the following members: +.pp +.in +4n +.ex +tcflag_t c_iflag; /* input modes */ +tcflag_t c_oflag; /* output modes */ +tcflag_t c_cflag; /* control modes */ +tcflag_t c_lflag; /* local modes */ +cc_t c_cc[nccs]; /* special characters */ +.ee +.in +.pp +the values that may be assigned to these fields are described below. +in the case of the first four bit-mask fields, +the definitions of some of the associated flags that may be set are +exposed only if a specific feature test macro (see +.br feature_test_macros (7)) +is defined, as noted in brackets ("[]"). +.pp +in the descriptions below, "not in posix" means that the +value is not specified in posix.1-2001, +and "xsi" means that the value is specified in posix.1-2001 +as part of the xsi extension. +.pp +\fic_iflag\fp flag constants: +.tp +.b ignbrk +ignore break condition on input. +.tp +.b brkint +if \fbignbrk\fp is set, a break is ignored. +if it is not set +but \fbbrkint\fp is set, then a break causes the input and output +queues to be flushed, and if the terminal is the controlling +terminal of a foreground process group, it will cause a +\fbsigint\fp to be sent to this foreground process group. +when neither \fbignbrk\fp nor \fbbrkint\fp are set, a break +reads as a null byte (\(aq\e0\(aq), except when \fbparmrk\fp is set, +in which case it reads as the sequence \e377 \e0 \e0. +.tp +.b ignpar +ignore framing errors and parity errors. +.tp +.b parmrk +if this bit is set, input bytes with parity or framing errors are +marked when passed to the program. +this bit is meaningful only when +\fbinpck\fp is set and \fbignpar\fp is not set. +the way erroneous bytes are marked is with two preceding bytes, +\e377 and \e0. +thus, the program actually reads three bytes for one +erroneous byte received from the terminal. +if a valid byte has the value \e377, +and \fbistrip\fp (see below) is not set, +the program might confuse it with the prefix that marks a +parity error. +therefore, a valid byte \e377 is passed to the program as two +bytes, \e377 \e377, in this case. +.ip +if neither \fbignpar\fp nor \fbparmrk\fp +is set, read a character with a parity error or framing error +as \e0. +.tp +.b inpck +enable input parity checking. +.tp +.b istrip +strip off eighth bit. +.tp +.b inlcr +translate nl to cr on input. +.tp +.b igncr +ignore carriage return on input. +.tp +.b icrnl +translate carriage return to newline on input (unless \fbigncr\fp is set). +.tp +.b iuclc +(not in posix) map uppercase characters to lowercase on input. +.tp +.b ixon +enable xon/xoff flow control on output. +.tp +.b ixany +(xsi) typing any character will restart stopped output. +(the default is to allow just the start character to restart output.) +.tp +.b ixoff +enable xon/xoff flow control on input. +.tp +.b imaxbel +(not in posix) ring bell when input queue is full. +linux does not implement this bit, and acts as if it is always set. +.tp +.br iutf8 " (since linux 2.6.4)" +(not in posix) input is utf8; +this allows character-erase to be correctly performed in cooked mode. +.pp +.i c_oflag +flag constants: +.tp +.b opost +enable implementation-defined output processing. +.tp +.b olcuc +(not in posix) map lowercase characters to uppercase on output. +.tp +.b onlcr +(xsi) map nl to cr-nl on output. +.tp +.b ocrnl +map cr to nl on output. +.tp +.b onocr +don't output cr at column 0. +.tp +.b onlret +don't output cr. +.tp +.b ofill +send fill characters for a delay, rather than using a timed delay. +.tp +.b ofdel +fill character is ascii del (0177). +if unset, fill character is ascii nul (\(aq\e0\(aq). +(not implemented on linux.) +.tp +.b nldly +newline delay mask. +values are \fbnl0\fp and \fbnl1\fp. +[requires +.b _bsd_source +or +.b _svid_source +or +.br _xopen_source ] +.tp +.b crdly +carriage return delay mask. +values are \fbcr0\fp, \fbcr1\fp, \fbcr2\fp, or \fbcr3\fp. +[requires +.b _bsd_source +or +.b _svid_source +or +.br _xopen_source ] +.tp +.b tabdly +horizontal tab delay mask. +values are \fbtab0\fp, \fbtab1\fp, \fbtab2\fp, \fbtab3\fp (or \fbxtabs\fp, +but see the +.b bugs +section). +a value of tab3, that is, xtabs, expands tabs to spaces +(with tab stops every eight columns). +[requires +.b _bsd_source +or +.b _svid_source +or +.br _xopen_source ] +.tp +.b bsdly +backspace delay mask. +values are \fbbs0\fp or \fbbs1\fp. +(has never been implemented.) +[requires +.b _bsd_source +or +.b _svid_source +or +.br _xopen_source ] +.tp +.b vtdly +vertical tab delay mask. +values are \fbvt0\fp or \fbvt1\fp. +.tp +.b ffdly +form feed delay mask. +values are \fbff0\fp or \fbff1\fp. +[requires +.b _bsd_source +or +.b _svid_source +or +.br _xopen_source ] +.pp +\fic_cflag\fp flag constants: +.tp +.b cbaud +(not in posix) baud speed mask (4+1 bits). +[requires +.b _bsd_source +or +.br _svid_source ] +.tp +.b cbaudex +(not in posix) extra baud speed mask (1 bit), included in +.br cbaud . +[requires +.b _bsd_source +or +.br _svid_source ] +.ip +(posix says that the baud speed is stored in the +.i termios +structure without specifying where precisely, and provides +.br cfgetispeed () +and +.br cfsetispeed () +for getting at it. +some systems use bits selected by +.b cbaud +in +.ir c_cflag , +other systems use separate fields, for example, +.i sg_ispeed +and +.ir sg_ospeed .) +.tp +.b csize +character size mask. +values are \fbcs5\fp, \fbcs6\fp, \fbcs7\fp, or \fbcs8\fp. +.tp +.b cstopb +set two stop bits, rather than one. +.tp +.b cread +enable receiver. +.tp +.b parenb +enable parity generation on output and parity checking for input. +.tp +.b parodd +if set, then parity for input and output is odd; +otherwise even parity is used. +.tp +.b hupcl +lower modem control lines after last process closes the device (hang up). +.tp +.b clocal +ignore modem control lines. +.tp +.b loblk +(not in posix) block output from a noncurrent shell layer. +for use by \fbshl\fp (shell layers). +(not implemented on linux.) +.tp +.b cibaud +(not in posix) mask for input speeds. +the values for the +.b cibaud +bits are +the same as the values for the +.b cbaud +bits, shifted left +.b ibshift +bits. +[requires +.b _bsd_source +or +.br _svid_source ] +(not implemented on linux.) +.tp +.b cmspar +(not in posix) +use "stick" (mark/space) parity (supported on certain serial +devices): if +.b parodd +is set, the parity bit is always 1; if +.b parodd +is not set, then the parity bit is always 0. +[requires +.b _bsd_source +or +.br _svid_source ] +.tp +.b crtscts +(not in posix) enable rts/cts (hardware) flow control. +[requires +.b _bsd_source +or +.br _svid_source ] +.pp +\fic_lflag\fp flag constants: +.tp +.b isig +when any of the characters intr, quit, susp, or dsusp are received, +generate the corresponding signal. +.tp +.b icanon +enable canonical mode (described below). +.tp +.b xcase +(not in posix; not supported under linux) +if \fbicanon\fp is also set, terminal is uppercase only. +input is converted to lowercase, except for characters preceded by \e. +on output, uppercase characters are preceded by \e and lowercase +characters are converted to uppercase. +[requires +.b _bsd_source +or +.b _svid_source +or +.br _xopen_source ] +.\" glibc is probably now wrong to allow +.\" define +.\" .b _xopen_source +.\" to expose +.\" .br xcase . +.tp +.b echo +echo input characters. +.tp +.b echoe +if \fbicanon\fp is also set, the erase character erases the preceding +input character, and werase erases the preceding word. +.tp +.b echok +if \fbicanon\fp is also set, the kill character erases the current line. +.tp +.b echonl +if \fbicanon\fp is also set, echo the nl character even if echo is not set. +.tp +.b echoctl +(not in posix) if \fbecho\fp is also set, +terminal special characters other than +tab, nl, start, and stop are echoed as \fb\(hax\fp, +where x is the character with +ascii code 0x40 greater than the special character. +for example, character +0x08 (bs) is echoed as \fb\(hah\fp. +[requires +.b _bsd_source +or +.br _svid_source ] +.tp +.b echoprt +(not in posix) if \fbicanon\fp and \fbecho\fp are also set, characters +are printed as they are being erased. +[requires +.b _bsd_source +or +.br _svid_source ] +.tp +.b echoke +(not in posix) if \fbicanon\fp is also set, kill is echoed by erasing +each character on the line, as specified by \fbechoe\fp and \fbechoprt\fp. +[requires +.b _bsd_source +or +.br _svid_source ] +.tp +.b defecho +(not in posix) echo only when a process is reading. +(not implemented on linux.) +.tp +.b flusho +(not in posix; not supported under linux) +output is being flushed. +this flag is toggled by typing +the discard character. +[requires +.b _bsd_source +or +.br _svid_source ] +.tp +.b noflsh +disable flushing the input and output queues when generating signals for the +int, quit, and susp characters. +.\" stevens lets susp only flush the input queue +.tp +.b tostop +send the +.b sigttou +signal to the process group of a background process +which tries to write to its controlling terminal. +.tp +.b pendin +(not in posix; not supported under linux) +all characters in the input queue are reprinted when +the next character is read. +.rb ( bash (1) +handles typeahead this way.) +[requires +.b _bsd_source +or +.br _svid_source ] +.tp +.b iexten +enable implementation-defined input processing. +this flag, as well as \fbicanon\fp must be enabled for the +special characters eol2, lnext, reprint, werase to be interpreted, +and for the \fbiuclc\fp flag to be effective. +.pp +the \fic_cc\fp array defines the terminal special characters. +the symbolic indices (initial values) and meaning are: +.tp +.b vdiscard +(not in posix; not supported under linux; 017, si, ctrl-o) +toggle: start/stop discarding pending output. +recognized when +.b iexten +is set, and then not passed as input. +.tp +.b vdsusp +(not in posix; not supported under linux; 031, em, ctrl-y) +delayed suspend character (dsusp): +send +.b sigtstp +signal when the character is read by the user program. +recognized when +.b iexten +and +.b isig +are set, and the system supports +job control, and then not passed as input. +.tp +.b veof +(004, eot, ctrl-d) +end-of-file character (eof). +more precisely: this character causes the pending tty buffer to be sent +to the waiting user program without waiting for end-of-line. +if it is the first character of the line, the +.br read (2) +in the user program returns 0, which signifies end-of-file. +recognized when +.b icanon +is set, and then not passed as input. +.tp +.b veol +(0, nul) +additional end-of-line character (eol). +recognized when +.b icanon +is set. +.tp +.b veol2 +(not in posix; 0, nul) +yet another end-of-line character (eol2). +recognized when +.b icanon +is set. +.tp +.b verase +(0177, del, rubout, or 010, bs, ctrl-h, or also #) +erase character (erase). +this erases the previous not-yet-erased character, +but does not erase past eof or beginning-of-line. +recognized when +.b icanon +is set, and then not passed as input. +.tp +.b vintr +(003, etx, ctrl-c, or also 0177, del, rubout) +interrupt character (intr). +send a +.b sigint +signal. +recognized when +.b isig +is set, and then not passed as input. +.tp +.b vkill +(025, nak, ctrl-u, or ctrl-x, or also @) +kill character (kill). +this erases the input since the last eof or beginning-of-line. +recognized when +.b icanon +is set, and then not passed as input. +.tp +.b vlnext +(not in posix; 026, syn, ctrl-v) +literal next (lnext). +quotes the next input character, depriving it of +a possible special meaning. +recognized when +.b iexten +is set, and then not passed as input. +.tp +.b vmin +minimum number of characters for noncanonical read (min). +.tp +.b vquit +(034, fs, ctrl-\e) +quit character (quit). +send +.b sigquit +signal. +recognized when +.b isig +is set, and then not passed as input. +.tp +.b vreprint +(not in posix; 022, dc2, ctrl-r) +reprint unread characters (reprint). +recognized when +.b icanon +and +.b iexten +are set, and then not passed as input. +.tp +.b vstart +(021, dc1, ctrl-q) +start character (start). +restarts output stopped by the stop character. +recognized when +.b ixon +is set, and then not passed as input. +.tp +.b vstatus +(not in posix; not supported under linux; +status request: 024, dc4, ctrl-t). +status character (status). +display status information at terminal, +including state of foreground process and amount of cpu time it has consumed. +also sends a +.b siginfo +signal (not supported on linux) to the foreground process group. +.tp +.b vstop +(023, dc3, ctrl-s) +stop character (stop). +stop output until start character typed. +recognized when +.b ixon +is set, and then not passed as input. +.tp +.b vsusp +(032, sub, ctrl-z) +suspend character (susp). +send +.b sigtstp +signal. +recognized when +.b isig +is set, and then not passed as input. +.tp +.b vswtch +(not in posix; not supported under linux; 0, nul) +switch character (swtch). +used in system v to switch shells in +.ir "shell layers" , +a predecessor to shell job control. +.tp +.b vtime +timeout in deciseconds for noncanonical read (time). +.tp +.b vwerase +(not in posix; 027, etb, ctrl-w) +word erase (werase). +recognized when +.b icanon +and +.b iexten +are set, and then not passed as input. +.pp +an individual terminal special character can be disabled by setting +the value of the corresponding +.i c_cc +element to +.br _posix_vdisable . +.pp +the above symbolic subscript values are all different, except that +.br vtime , +.b vmin +may have the same value as +.br veol , +.br veof , +respectively. +in noncanonical mode the special character meaning is replaced +by the timeout meaning. +for an explanation of +.b vmin +and +.br vtime , +see the description of +noncanonical mode below. +.ss retrieving and changing terminal settings +.br tcgetattr () +gets the parameters associated with the object referred by \fifd\fp and +stores them in the \fitermios\fp structure referenced by +\fitermios_p\fp. +this function may be invoked from a background process; +however, the terminal attributes may be subsequently changed by a +foreground process. +.pp +.br tcsetattr () +sets the parameters associated with the terminal (unless support is +required from the underlying hardware that is not available) from the +\fitermios\fp structure referred to by \fitermios_p\fp. +\fioptional_actions\fp specifies when the changes take effect: +.ip \fbtcsanow\fp +the change occurs immediately. +.ip \fbtcsadrain\fp +the change occurs after all output written to +.i fd +has been transmitted. +this option should be used when changing +parameters that affect output. +.ip \fbtcsaflush\fp +the change occurs after all output written to the object referred by +.i fd +has been transmitted, and all input that has been received but not read +will be discarded before the change is made. +.ss canonical and noncanonical mode +the setting of the +.b icanon +canon flag in +.i c_lflag +determines whether the terminal is operating in canonical mode +.rb ( icanon +set) or +noncanonical mode +.rb ( icanon +unset). +by default, +.b icanon +is set. +.pp +in canonical mode: +.ip * 2 +input is made available line by line. +an input line is available when one of the line delimiters +is typed (nl, eol, eol2; or eof at the start of line). +except in the case of eof, the line delimiter is included +in the buffer returned by +.br read (2). +.ip * 2 +line editing is enabled (erase, kill; +and if the +.b iexten +flag is set: werase, reprint, lnext). +a +.br read (2) +returns at most one line of input; if the +.br read (2) +requested fewer bytes than are available in the current line of input, +then only as many bytes as requested are read, +and the remaining characters will be available for a future +.br read (2). +.ip * 2 +the maximum line length is 4096 chars +(including the terminating newline character); +lines longer than 4096 chars are truncated. +after 4095 characters, input processing (e.g., +.b isig +and +.b echo* +processing) continues, but any input data after 4095 characters up to +(but not including) any terminating newline is discarded. +this ensures that the terminal can always receive +more input until at least one line can be read. +.pp +in noncanonical mode input is available immediately (without +the user having to type a line-delimiter character), +no input processing is performed, +and line editing is disabled. +the read buffer will only accept 4095 chars; this provides the +necessary space for a newline char if the input mode is switched +to canonical. +the settings of min +.ri ( c_cc[vmin] ) +and time +.ri ( c_cc[vtime] ) +determine the circumstances in which a +.br read (2) +completes; there are four distinct cases: +.tp +min == 0, time == 0 (polling read) +if data is available, +.br read (2) +returns immediately, with the lesser of the number of bytes +available, or the number of bytes requested. +if no data is available, +.br read (2) +returns 0. +.tp +min > 0, time == 0 (blocking read) +.br read (2) +blocks until min bytes are available, +and returns up to the number of bytes requested. +.tp +min == 0, time > 0 (read with timeout) +time specifies the limit for a timer in tenths of a second. +the timer is started when +.br read (2) +is called. +.br read (2) +returns either when at least one byte of data is available, +or when the timer expires. +if the timer expires without any input becoming available, +.br read (2) +returns 0. +if data is already available at the time of the call to +.br read (2), +the call behaves as though the data was received immediately after the call. +.tp +min > 0, time > 0 (read with interbyte timeout) +time specifies the limit for a timer in tenths of a second. +once an initial byte of input becomes available, +the timer is restarted after each further byte is received. +.br read (2) +returns when any of the following conditions is met: +.rs +.ip * 3 +min bytes have been received. +.ip * +the interbyte timer expires. +.ip * +the number of bytes requested by +.br read (2) +has been received. +(posix does not specify this termination condition, +and on some other implementations +.\" e.g., solaris +.br read (2) +does not return in this case.) +.re +.ip +because the timer is started only after the initial byte +becomes available, at least one byte will be read. +if data is already available at the time of the call to +.br read (2), +the call behaves as though the data was received immediately after the call. +.pp +posix +.\" posix.1-2008 xbd 11.1.7 +does not specify whether the setting of the +.b o_nonblock +file status flag takes precedence over the min and time settings. +if +.b o_nonblock +is set, a +.br read (2) +in noncanonical mode may return immediately, +regardless of the setting of min or time. +furthermore, if no data is available, +posix permits a +.br read (2) +in noncanonical mode to return either 0, or \-1 with +.i errno +set to +.br eagain . +.ss raw mode +.br cfmakeraw () +sets the terminal to something like the +"raw" mode of the old version 7 terminal driver: +input is available character by character, +echoing is disabled, and all special processing of +terminal input and output characters is disabled. +the terminal attributes are set as follows: +.pp +.in +4n +.ex +termios_p\->c_iflag &= \(ti(ignbrk | brkint | parmrk | istrip + | inlcr | igncr | icrnl | ixon); +termios_p\->c_oflag &= \(tiopost; +termios_p\->c_lflag &= \(ti(echo | echonl | icanon | isig | iexten); +termios_p\->c_cflag &= \(ti(csize | parenb); +termios_p\->c_cflag |= cs8; +.ee +.in +.\" +.ss line control +.br tcsendbreak () +transmits a continuous stream of zero-valued bits for a specific +duration, if the terminal is using asynchronous serial data +transmission. +if \fiduration\fp is zero, it transmits zero-valued bits +for at least 0.25 seconds, and not more than 0.5 seconds. +if \fiduration\fp is not zero, it sends zero-valued bits for some +implementation-defined length of time. +.pp +if the terminal is not using asynchronous serial data transmission, +.br tcsendbreak () +returns without taking any action. +.pp +.br tcdrain () +waits until all output written to the object referred to by +.i fd +has been transmitted. +.pp +.br tcflush () +discards data written to the object referred to by +.i fd +but not transmitted, or data received but not read, depending on the +value of +.ir queue_selector : +.ip \fbtciflush\fp +flushes data received but not read. +.ip \fbtcoflush\fp +flushes data written but not transmitted. +.ip \fbtcioflush\fp +flushes both data received but not read, and data written but not +transmitted. +.pp +.br tcflow () +suspends transmission or reception of data on the object referred to by +.ir fd , +depending on the value of +.ir action : +.ip \fbtcooff\fp +suspends output. +.ip \fbtcoon\fp +restarts suspended output. +.ip \fbtcioff\fp +transmits a stop character, which stops the terminal device from +transmitting data to the system. +.ip \fbtcion\fp +transmits a start character, which starts the terminal device +transmitting data to the system. +.pp +the default on open of a terminal file is that neither its input nor its +output is suspended. +.ss line speed +the baud rate functions are provided for getting and setting the values +of the input and output baud rates in the \fitermios\fp structure. +the new values do not take effect +until +.br tcsetattr () +is successfully called. +.pp +setting the speed to \fbb0\fp instructs the modem to "hang up". +the actual bit rate corresponding to \fbb38400\fp may be altered with +.br setserial (8). +.pp +the input and output baud rates are stored in the \fitermios\fp +structure. +.pp +.br cfgetospeed () +returns the output baud rate stored in the \fitermios\fp structure +pointed to by +.ir termios_p . +.pp +.br cfsetospeed () +sets the output baud rate stored in the \fitermios\fp structure pointed +to by \fitermios_p\fp to \fispeed\fp, which must be one of these constants: +.pp +.nf +.ft b + b0 + b50 + b75 + b110 + b134 + b150 + b200 + b300 + b600 + b1200 + b1800 + b2400 + b4800 + b9600 + b19200 + b38400 + b57600 + b115200 + b230400 + b460800 + b500000 + b576000 + b921600 + b1000000 + b1152000 + b1500000 + b2000000 +.ft p +.fi +.pp +these constants are additionally supported on the sparc architecture: +.pp +.nf +.ft b + b76800 + b153600 + b307200 + b614400 +.ft p +.fi +.pp +these constants are additionally supported on non-sparc architectures: +.pp +.nf +.ft b + b2500000 + b3000000 + b3500000 + b4000000 +.ft p +.fi +.pp +due to differences between architectures, portable applications should check +if a particular +.bi b nnn +constant is defined prior to using it. +.pp +the zero baud rate, +.br b0 , +is used to terminate the connection. +if b0 is specified, the modem control lines shall no longer be asserted. +normally, this will disconnect the line. +.b cbaudex +is a mask +for the speeds beyond those defined in posix.1 (57600 and above). +thus, +.br b57600 " & " cbaudex +is nonzero. +.pp +setting the baud rate to a value other than those defined by +.bi b nnn +constants is possible via the +.b tcsets2 +ioctl; see +.br ioctl_tty (2). +.pp +.br cfgetispeed () +returns the input baud rate stored in the +.i termios +structure. +.pp +.br cfsetispeed () +sets the input baud rate stored in the +.i termios +structure to +.ir speed , +which must be specified as one of the +.bi b nnn +constants listed above for +.br cfsetospeed (). +if the input baud rate is set to zero, the input baud rate will be +equal to the output baud rate. +.pp +.br cfsetspeed () +is a 4.4bsd extension. +it takes the same arguments as +.br cfsetispeed (), +and sets both input and output speed. +.sh return value +.br cfgetispeed () +returns the input baud rate stored in the +\fitermios\fp +structure. +.pp +.br cfgetospeed () +returns the output baud rate stored in the \fitermios\fp structure. +.pp +all other functions return: +.ip 0 +on success. +.ip \-1 +on failure and set +.i errno +to indicate the error. +.pp +note that +.br tcsetattr () +returns success if \fiany\fp of the requested changes could be +successfully carried out. +therefore, when making multiple changes +it may be necessary to follow this call with a further call to +.br tcgetattr () +to check that all changes have been performed successfully. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.nh +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br tcgetattr (), +.br tcsetattr (), +.br tcdrain (), +.br tcflush (), +.br tcflow (), +.br tcsendbreak (), +.br cfmakeraw (), +.br cfgetispeed (), +.br cfgetospeed (), +.br cfsetispeed (), +.br cfsetospeed (), +.br cfsetspeed () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.\" fixme: the markings are different from that in the glibc manual. +.\" markings in glibc manual are more detailed: +.\" +.\" tcsendbreak: mt-unsafe race:tcattr(filedes)/bsd +.\" tcflow: mt-unsafe race:tcattr(filedes)/bsd +.\" +.\" glibc manual says /bsd indicate the preceding marker only applies +.\" when the underlying kernel is a bsd kernel. +.\" so, it is safety in linux kernel. +.hy +.sh conforming to +.br tcgetattr (), +.br tcsetattr (), +.br tcsendbreak (), +.br tcdrain (), +.br tcflush (), +.br tcflow (), +.br cfgetispeed (), +.br cfgetospeed (), +.br cfsetispeed (), +and +.br cfsetospeed () +are specified in posix.1-2001. +.pp +.br cfmakeraw () +and +.br cfsetspeed () +are nonstandard, but available on the bsds. +.sh notes +unix\ v7 and several later systems have a list of baud rates +where after the values +.br b0 +through +.b b9600 +one finds the two constants +.br exta , +.b extb +("external a" and "external b"). +many systems extend the list with much higher baud rates. +.pp +the effect of a nonzero \fiduration\fp with +.br tcsendbreak () +varies. +sunos specifies a break of +.i "duration\ *\ n" +seconds, where \fin\fp is at least 0.25, and not more than 0.5. +linux, aix, du, tru64 send a break of +.i duration +milliseconds. +freebsd and netbsd and hp-ux and macos ignore the value of +.ir duration . +under solaris and unixware, +.br tcsendbreak () +with nonzero +.i duration +behaves like +.br tcdrain (). +.\" libc4 until 4.7.5, glibc for sysv: einval for duration > 0. +.\" libc4.7.6, libc5, glibc for unix: duration in ms. +.\" glibc for bsd: duration in us +.\" glibc for sunos4: ignore duration +.sh bugs +.\" kernel 77e5bff1640432f28794a00800955e646dcd7455 +.\" glibc 573963e32ffac46d9891970ddebde2ac3212c5c0 +on the alpha architecture before linux 4.16 (and glibc before 2.28), the +.b xtabs +value was different from +.b tab3 +and it was ignored by the +.b n_tty +line discipline code of the terminal driver as a result +(because as it wasn't part of the +.b tabdly +mask). +.sh see also +.br reset (1), +.br setterm (1), +.br stty (1), +.br tput (1), +.br tset (1), +.br tty (1), +.br ioctl_console (2), +.br ioctl_tty (2), +.br setserial (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/cacosh.3 + +#!/bin/sh +# +# find_slashes_no_parens.sh +# +# look for function names inside \f[bi]...\f[pb] that aren't +# followed by "()". +# +# this script is designed to help with "by hand" tidy-ups after +# the automated changes made by add_parens_for_own_funcs.sh. +# +# the first argument to this script names a manual page directory where +# 'man2' and 'man3' subdirectories can be found. the pages names in +# these directories are used to generate a series of regular expressions +# that can be used to search the manual page files that are named in +# the remaining command-line arguments. +# +# example usage: +# +# cd man-pages-x.yy +# sh find_slashes_no_parens.sh . man?/*.? > matches.log +# +###################################################################### +# +# (c) copyright 2005 & 2013, michael kerrisk +# this program is free software; you can redistribute it and/or +# modify it under the terms of the gnu general public license +# as published by the free software foundation; either version 2 +# of the license, or (at your option) any later version. +# +# this program 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 general public license for more details +# (http://www.gnu.org/licenses/gpl-2.0.html). +# + +if test $# -lt 2; then + echo "usage: $0 man-page-root-dir file file..." 1>&2 + exit 1 +fi + +dir=$1 + +if ! test -d $dir/man2 || ! test -d $dir/man3; then + echo "can't find man2 and man3 under $dir" 1>&2 + exit 1 +fi + +shift 1 + +echo "this will probably take a few minutes..." 1>&2 + +regexp_file=tmp.$0.regexp +rm -f $regexp_file + +# we grep out a few page names that are likely to generate false +# positives... + +for page in $( + + find $dir/man2/* $dir/man3/* -type f -name '*.[23]' | + egrep -v '/(stderr|stdin|stdout|errno|termios|string)\..$'); do + + base=$(basename $page | sed -e 's/\.[23]$//') + + echo "\\\\f[bi]$base\\\\f[pb][^(]" >> $regexp_file + echo "\\\\f[bi]$base\\\\f[pb]\$" >> $regexp_file +done + +sort -o $regexp_file $regexp_file # not really needed + +echo "built regexp file; now about to grep..." 1>&2 + +grep -f $regexp_file $* + +rm -f $regexp_file +exit 0 + +.\" copyright (c) 2016 intel corporation +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th pkeys 7 2021-03-22 "linux" "linux programmer's manual" +.sh name +pkeys \- overview of memory protection keys +.sh description +memory protection keys (pkeys) are an extension to existing +page-based memory permissions. +normal page permissions using +page tables require expensive system calls and tlb invalidations +when changing permissions. +memory protection keys provide a mechanism for changing +protections without requiring modification of the page tables on +every permission change. +.pp +to use pkeys, software must first "tag" a page in the page tables +with a pkey. +after this tag is in place, an application only has +to change the contents of a register in order to remove write +access, or all access to a tagged page. +.pp +protection keys work in conjunction with the existing +.br prot_read / +.br prot_write / +.br prot_exec +permissions passed to system calls such as +.br mprotect (2) +and +.br mmap (2), +but always act to further restrict these traditional permission +mechanisms. +.pp +if a process performs an access that violates pkey +restrictions, it receives a +.br sigsegv +signal. +see +.br sigaction (2) +for details of the information available with that signal. +.pp +to use the pkeys feature, the processor must support it, and the kernel +must contain support for the feature on a given processor. +as of early 2016 only future intel x86 processors are supported, +and this hardware supports 16 protection keys in each process. +however, pkey 0 is used as the default key, so a maximum of 15 +are available for actual application use. +the default key is assigned to any memory region for which a +pkey has not been explicitly assigned via +.br pkey_mprotect (2). +.pp +protection keys have the potential to add a layer of security and +reliability to applications. +but they have not been primarily designed as +a security feature. +for instance, wrpkru is a completely unprivileged +instruction, so pkeys are useless in any case that an attacker controls +the pkru register or can execute arbitrary instructions. +.pp +applications should be very careful to ensure that they do not "leak" +protection keys. +for instance, before calling +.br pkey_free (2), +the application should be sure that no memory has that pkey assigned. +if the application left the freed pkey assigned, a future user of +that pkey might inadvertently change the permissions of an unrelated +data structure, which could impact security or stability. +the kernel currently allows in-use pkeys to have +.br pkey_free (2) +called on them because it would have processor or memory performance +implications to perform the additional checks needed to disallow it. +implementation of the necessary checks is left up to applications. +applications may implement these checks by searching the +.ir /proc/[pid]/smaps +file for memory regions with the pkey assigned. +further details can be found in +.br proc (5). +.pp +any application wanting to use protection keys needs to be able +to function without them. +they might be unavailable because the hardware that the +application runs on does not support them, the kernel code does +not contain support, the kernel support has been disabled, or +because the keys have all been allocated, perhaps by a library +the application is using. +it is recommended that applications wanting to use protection +keys should simply call +.br pkey_alloc (2) +and test whether the call succeeds, +instead of attempting to detect support for the +feature in any other way. +.pp +although unnecessary, hardware support for protection keys may be +enumerated with the +.i cpuid +instruction. +details of how to do this can be found in the intel software +developers manual. +the kernel performs this enumeration and exposes the information in +.ir /proc/cpuinfo +under the "flags" field. +the string "pku" in this field indicates hardware support for protection +keys and the string "ospke" indicates that the kernel contains and has +enabled protection keys support. +.pp +applications using threads and protection keys should be especially +careful. +threads inherit the protection key rights of the parent at the time +of the +.br clone (2), +system call. +applications should either ensure that their own permissions are +appropriate for child threads at the time when +.br clone (2) +is called, or ensure that each child thread can perform its +own initialization of protection key rights. +.\" +.ss signal handler behavior +each time a signal handler is invoked (including nested signals), the +thread is temporarily given a new, default set of protection key rights +that override the rights from the interrupted context. +this means that applications must re-establish their desired protection +key rights upon entering a signal handler if the desired rights differ +from the defaults. +the rights of any interrupted context are restored when the signal +handler returns. +.pp +this signal behavior is unusual and is due to the fact that the x86 pkru +register (which stores protection key access rights) is managed with the +same hardware mechanism (xsave) that manages floating-point registers. +the signal behavior is the same as that of floating-point registers. +.\" +.ss protection keys system calls +the linux kernel implements the following pkey-related system calls: +.br pkey_mprotect (2), +.br pkey_alloc (2), +and +.br pkey_free (2). +.pp +the linux pkey system calls are available only if the kernel was +configured and built with the +.br config_x86_intel_memory_protection_keys +option. +.sh examples +the program below allocates a page of memory with read and write permissions. +it then writes some data to the memory and successfully reads it +back. +after that, it attempts to allocate a protection key and +disallows access to the page by using the wrpkru instruction. +it then tries to access the page, +which we now expect to cause a fatal signal to the application. +.pp +.in +4n +.ex +.rb "$" " ./a.out" +buffer contains: 73 +about to read buffer again... +segmentation fault (core dumped) +.ee +.in +.ss program source +\& +.ex +#define _gnu_source +#include +#include +#include +#include + +static inline void +wrpkru(unsigned int pkru) +{ + unsigned int eax = pkru; + unsigned int ecx = 0; + unsigned int edx = 0; + + asm volatile(".byte 0x0f,0x01,0xef\en\et" + : : "a" (eax), "c" (ecx), "d" (edx)); +} + +int +pkey_set(int pkey, unsigned long rights, unsigned long flags) +{ + unsigned int pkru = (rights << (2 * pkey)); + return wrpkru(pkru); +} + +int +pkey_mprotect(void *ptr, size_t size, unsigned long orig_prot, + unsigned long pkey) +{ + return syscall(sys_pkey_mprotect, ptr, size, orig_prot, pkey); +} + +int +pkey_alloc(void) +{ + return syscall(sys_pkey_alloc, 0, 0); +} + +int +pkey_free(unsigned long pkey) +{ + return syscall(sys_pkey_free, pkey); +} + +#define errexit(msg) do { perror(msg); exit(exit_failure); \e + } while (0) + +int +main(void) +{ + int status; + int pkey; + int *buffer; + + /* + * allocate one page of memory. + */ + buffer = mmap(null, getpagesize(), prot_read | prot_write, + map_anonymous | map_private, \-1, 0); + if (buffer == map_failed) + errexit("mmap"); + + /* + * put some random data into the page (still ok to touch). + */ + *buffer = __line__; + printf("buffer contains: %d\en", *buffer); + + /* + * allocate a protection key: + */ + pkey = pkey_alloc(); + if (pkey == \-1) + errexit("pkey_alloc"); + + /* + * disable access to any memory with "pkey" set, + * even though there is none right now. + */ + status = pkey_set(pkey, pkey_disable_access, 0); + if (status) + errexit("pkey_set"); + + /* + * set the protection key on "buffer". + * note that it is still read/write as far as mprotect() is + * concerned and the previous pkey_set() overrides it. + */ + status = pkey_mprotect(buffer, getpagesize(), + prot_read | prot_write, pkey); + if (status == \-1) + errexit("pkey_mprotect"); + + printf("about to read buffer again...\en"); + + /* + * this will crash, because we have disallowed access. + */ + printf("buffer contains: %d\en", *buffer); + + status = pkey_free(pkey); + if (status == \-1) + errexit("pkey_free"); + + exit(exit_success); +} +.ee +.sh see also +.br pkey_alloc (2), +.br pkey_free (2), +.br pkey_mprotect (2), +.br sigaction (2) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/gethostbyname.3 + +.\" copyright (c) 2003 andries brouwer (aeb@cwi.nl) +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th aio_fsync 3 2021-03-22 "" "linux programmer's manual" +.sh name +aio_fsync \- asynchronous file synchronization +.sh synopsis +.nf +.b "#include " +.pp +.bi "int aio_fsync(int " op ", struct aiocb *" aiocbp ); +.pp +link with \fi\-lrt\fp. +.fi +.sh description +the +.br aio_fsync () +function does a sync on all outstanding asynchronous i/o operations +associated with +.ir aiocbp\->aio_fildes . +(see +.br aio (7) +for a description of the +.i aiocb +structure.) +.pp +more precisely, if +.i op +is +.br o_sync , +then all currently queued i/o operations shall be +completed as if by a call of +.br fsync (2), +and if +.i op +is +.br o_dsync , +this call is the asynchronous analog of +.br fdatasync (2). +.pp +note that this is a request only; it does not wait for i/o completion. +.pp +apart from +.ir aio_fildes , +the only field in the structure pointed to by +.i aiocbp +that is used by this call is the +.i aio_sigevent +field (a +.i sigevent +structure, described in +.br sigevent (7)), +which indicates the desired type of asynchronous notification at completion. +all other fields are ignored. +.sh return value +on success (the sync request was successfully queued) +this function returns 0. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eagain +out of resources. +.tp +.b ebadf +.i aio_fildes +is not a valid file descriptor open for writing. +.tp +.b einval +synchronized i/o is not supported for this file, or +.i op +is not +.b o_sync +or +.br o_dsync . +.tp +.b enosys +.br aio_fsync () +is not implemented. +.sh versions +the +.br aio_fsync () +function is available since glibc 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br aio_fsync () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh see also +.br aio_cancel (3), +.br aio_error (3), +.br aio_read (3), +.br aio_return (3), +.br aio_suspend (3), +.br aio_write (3), +.br lio_listio (3), +.br aio (7), +.br sigevent (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/getgroups.2 + +.\" copyright (c) 2009 linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th timer_delete 2 2021-03-22 linux "linux programmer's manual" +.sh name +timer_delete \- delete a posix per-process timer +.sh synopsis +.nf +.b #include +.pp +.bi "int timer_delete(timer_t " timerid ); +.fi +.pp +link with \fi\-lrt\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br timer_delete (): +.nf + _posix_c_source >= 199309l +.fi +.sh description +.br timer_delete () +deletes the timer whose id is given in +.ir timerid . +if the timer was armed at the time of this call, +it is disarmed before being deleted. +the treatment of any pending signal generated by the deleted timer +is unspecified. +.sh return value +on success, +.br timer_delete () +returns 0. +on failure, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b einval +.i timerid +is not a valid timer id. +.sh versions +this system call is available since linux 2.6. +.sh conforming to +posix.1-2001, posix.1-2008. +.sh see also +.br clock_gettime (2), +.br timer_create (2), +.br timer_getoverrun (2), +.br timer_settime (2), +.br time (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2006, michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th posix_fallocate 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +posix_fallocate \- allocate file space +.sh synopsis +.nf +.b #include +.pp +.bi "int posix_fallocate(int " fd ", off_t " offset ", off_t " len ); +.fi +.pp +.ad l +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br posix_fallocate (): +.nf + _posix_c_source >= 200112l +.fi +.sh description +the function +.br posix_fallocate () +ensures that disk space is allocated for the file referred to by the +file descriptor +.i fd +for the bytes in the range starting at +.i offset +and continuing for +.i len +bytes. +after a successful call to +.br posix_fallocate (), +subsequent writes to bytes in the specified range are +guaranteed not to fail because of lack of disk space. +.pp +if the size of the file is less than +.ir offset + len , +then the file is increased to this size; +otherwise the file size is left unchanged. +.sh return value +.br posix_fallocate () +returns zero on success, or an error number on failure. +note that +.i errno +is not set. +.sh errors +.tp +.b ebadf +.i fd +is not a valid file descriptor, or is not opened for writing. +.tp +.b efbig +.i offset+len +exceeds the maximum file size. +.tp +.b eintr +a signal was caught during execution. +.tp +.b einval +.i offset +was less than 0, or +.i len +was less than or equal to 0, or the underlying filesystem does not +support the operation. +.tp +.b enodev +.i fd +does not refer to a regular file. +.tp +.b enospc +there is not enough space left on the device containing the file +referred to by +.ir fd . +.tp +.b eopnotsupp +the filesystem containing the file referred to by +.i fd +does not support this operation. +this error code can be returned by c libraries that don't perform the +emulation shown in notes, such as musl libc. +.tp +.b espipe +.i fd +refers to a pipe. +.sh versions +.br posix_fallocate () +is available since glibc 2.1.94. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lb lb lbx +l l l. +interface attribute value +t{ +.br posix_fallocate () +t} thread safety t{ +mt-safe (but see notes) +t} +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001. +.pp +posix.1-2008 says that an implementation +.i shall +give the +.b einval +error if +.i len +was 0, or +.i offset +was less than 0. +posix.1-2001 says that an implementation +.i shall +give the +.b einval +error if +.i len +is less than 0, or +.i offset +was less than 0, and +.i may +give the error if +.i len +equals zero. +.sh notes +in the glibc implementation, +.br posix_fallocate () +is implemented using the +.br fallocate (2) +system call, which is mt-safe. +if the underlying filesystem does not support +.br fallocate (2), +then the operation is emulated with the following caveats: +.ip * 2 +the emulation is inefficient. +.ip * +there is a race condition where concurrent writes from another thread or +process could be overwritten with null bytes. +.ip * +there is a race condition where concurrent file size increases by +another thread or process could result in a file whose size is smaller +than expected. +.ip * +if +.i fd +has been opened with the +.b o_append +or +.b o_wronly +flags, the function fails with the error +.br ebadf . +.pp +in general, the emulation is not mt-safe. +on linux, applications may use +.br fallocate (2) +if they cannot tolerate the emulation caveats. +in general, this is +only recommended if the application plans to terminate the operation if +.b eopnotsupp +is returned, otherwise the application itself will need to implement a +fallback with all the same problems as the emulation provided by glibc. +.sh see also +.br fallocate (1), +.br fallocate (2), +.br lseek (2), +.br posix_fadvise (2) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" this manpage is copyright (c) 1992 drew eckhardt; +.\" and copyright (c) 1993 michael haardt +.\" and copyright (c) 1993,1994 ian jackson +.\" and copyright (c) 2006, 2014, michael kerrisk +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" you may distribute it under the terms of the gnu general +.\" public license. it comes with no warranty. +.\" %%%license_end +.\" +.\" modified 1996-08-18 by urs +.\" modified 2003-04-23 by michael kerrisk +.\" modified 2004-06-23 by michael kerrisk +.\" +.th mknod 2 2021-08-27 "linux" "linux programmer's manual" +.sh name +mknod, mknodat \- create a special or ordinary file +.sh synopsis +.nf +.b #include +.pp +.bi "int mknod(const char *" pathname ", mode_t " mode ", dev_t " dev ); +.pp +.br "#include " "/* definition of at_* constants */" +.b #include +.pp +.bi "int mknodat(int " dirfd ", const char *" pathname ", mode_t " mode \ +", dev_t " dev ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br mknod (): +.nf + _xopen_source >= 500 +.\" || _xopen_source && _xopen_source_extended + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.sh description +the system call +.br mknod () +creates a filesystem node (file, device special file, or +named pipe) named +.ir pathname , +with attributes specified by +.i mode +and +.ir dev . +.pp +the +.i mode +argument specifies both the file mode to use and the type of node +to be created. +it should be a combination (using bitwise or) of one of the file types +listed below and zero or more of the file mode bits listed in +.br inode (7). +.pp +the file mode is modified by the process's +.i umask +in the usual way: in the absence of a default acl, the permissions of the +created node are +.ri ( mode " & \(ti" umask ). +.pp +the file type must be one of +.br s_ifreg , +.br s_ifchr , +.br s_ifblk , +.br s_ififo , +or +.b s_ifsock +.\" (s_ifsock since linux 1.2.4) +to specify a regular file (which will be created empty), character +special file, block special file, fifo (named pipe), or unix domain socket, +respectively. +(zero file type is equivalent to type +.br s_ifreg .) +.pp +if the file type is +.b s_ifchr +or +.br s_ifblk , +then +.i dev +specifies the major and minor numbers of the newly created device +special file +.rb ( makedev (3) +may be useful to build the value for +.ir dev ); +otherwise it is ignored. +.pp +if +.i pathname +already exists, or is a symbolic link, this call fails with an +.b eexist +error. +.pp +the newly created node will be owned by the effective user id of the +process. +if the directory containing the node has the set-group-id +bit set, or if the filesystem is mounted with bsd group semantics, the +new node will inherit the group ownership from its parent directory; +otherwise it will be owned by the effective group id of the process. +.\" +.\" +.ss mknodat() +the +.br mknodat () +system call operates in exactly the same way as +.br mknod (), +except for the differences described here. +.pp +if the pathname given in +.i pathname +is relative, then it is interpreted relative to the directory +referred to by the file descriptor +.i dirfd +(rather than relative to the current working directory of +the calling process, as is done by +.br mknod () +for a relative pathname). +.pp +if +.i pathname +is relative and +.i dirfd +is the special value +.br at_fdcwd , +then +.i pathname +is interpreted relative to the current working +directory of the calling process (like +.br mknod ()). +.pp +if +.i pathname +is absolute, then +.i dirfd +is ignored. +.pp +see +.br openat (2) +for an explanation of the need for +.br mknodat (). +.sh return value +.br mknod () +and +.br mknodat () +return zero on success. +on error, \-1 is returned and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eacces +the parent directory does not allow write permission to the process, +or one of the directories in the path prefix of +.i pathname +did not allow search permission. +(see also +.br path_resolution (7).) +.tp +.b ebadf +.br ( mknodat ()) +.i pathname +is relative but +.i dirfd +is neither +.b at_fdcwd +nor a valid file descriptor. +.tp +.b edquot +the user's quota of disk blocks or inodes on the filesystem has been +exhausted. +.tp +.b eexist +.i pathname +already exists. +this includes the case where +.i pathname +is a symbolic link, dangling or not. +.tp +.b efault +.ir pathname " points outside your accessible address space." +.tp +.b einval +.i mode +requested creation of something other than a regular file, device +special file, fifo or socket. +.tp +.b eloop +too many symbolic links were encountered in resolving +.ir pathname . +.tp +.b enametoolong +.ir pathname " was too long." +.tp +.b enoent +a directory component in +.i pathname +does not exist or is a dangling symbolic link. +.tp +.b enomem +insufficient kernel memory was available. +.tp +.b enospc +the device containing +.i pathname +has no room for the new node. +.tp +.b enotdir +a component used as a directory in +.i pathname +is not, in fact, a directory. +.tp +.b enotdir +.br ( mknodat ()) +.i pathname +is relative and +.i dirfd +is a file descriptor referring to a file other than a directory. +.tp +.b eperm +.i mode +requested creation of something other than a regular file, +fifo (named pipe), or unix domain socket, and the caller +is not privileged (linux: does not have the +.b cap_mknod +capability); +.\" for unix domain sockets and regular files, eperm is returned only in +.\" linux 2.2 and earlier; in linux 2.4 and later, unprivileged can +.\" use mknod() to make these files. +also returned if the filesystem containing +.i pathname +does not support the type of node requested. +.tp +.b erofs +.i pathname +refers to a file on a read-only filesystem. +.sh versions +.br mknodat () +was added to linux in kernel 2.6.16; +library support was added to glibc in version 2.4. +.sh conforming to +.br mknod (): +svr4, 4.4bsd, posix.1-2001 (but see below), posix.1-2008. +.\" the linux version differs from the svr4 version in that it +.\" does not require root permission to create pipes, also in that no +.\" emultihop, enolink, or eintr error is documented. +.pp +.br mknodat (): +posix.1-2008. +.sh notes +posix.1-2001 says: "the only portable use of +.br mknod () +is to create a fifo-special file. +if +.i mode +is not +.b s_ififo +or +.i dev +is not 0, the behavior of +.br mknod () +is unspecified." +however, nowadays one should never use +.br mknod () +for this purpose; one should use +.br mkfifo (3), +a function especially defined for this purpose. +.pp +under linux, +.br mknod () +cannot be used to create directories. +one should make directories with +.br mkdir (2). +.\" and one should make unix domain sockets with socket(2) and bind(2). +.pp +there are many infelicities in the protocol underlying nfs. +some of these affect +.br mknod () +and +.br mknodat (). +.sh see also +.br mknod (1), +.br chmod (2), +.br chown (2), +.br fcntl (2), +.br mkdir (2), +.br mount (2), +.br socket (2), +.br stat (2), +.br umask (2), +.br unlink (2), +.br makedev (3), +.br mkfifo (3), +.br acl (5), +.br path_resolution (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1989, 1990, 1993 +.\" the regents of the university of california. all rights reserved. +.\" +.\" %%%license_start(bsd_3_clause_ucb) +.\" redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 4. neither the name of the university nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" this software is provided by the regents and contributors ``as is'' and +.\" any express or implied warranties, including, but not limited to, the +.\" implied warranties of merchantability and fitness for a particular purpose +.\" are disclaimed. in no event shall the regents or contributors be liable +.\" for any direct, indirect, incidental, special, exemplary, or consequential +.\" damages (including, but not limited to, procurement of substitute goods +.\" or services; loss of use, data, or profits; or business interruption) +.\" however caused and on any theory of liability, whether in contract, strict +.\" liability, or tort (including negligence or otherwise) arising in any way +.\" out of the use of this software, even if advised of the possibility of +.\" such damage. +.\" %%%license_end +.\" +.\" @(#)operator.7 8.1 (berkeley) 6/9/93 +.\" +.\" copied shamelessly from freebsd with minor changes. 2003-05-21 +.\" brian m. carlson +.\" +.\" restored automatic formatting from freebsd. 2003-08-24 +.\" martin schulze +.\" +.\" 2007-12-08, mtk, converted from mdoc to man macros +.\" +.th operator 7 2020-08-13 "linux" "linux programmer's manual" +.sh name +operator \- c operator precedence and order of evaluation +.sh description +this manual page lists c operators and their precedence in evaluation. +.pp +.ts +lb lb lb +l l l. +operator associativity notes +() [] \-> . ++ \-\- left to right [1] +! \(ti ++ \-\- + \- (type) * & sizeof right to left [2] +* / % left to right ++ \- left to right +<< >> left to right +< <= > >= left to right +== != left to right +& left to right +\(ha left to right +| left to right +&& left to right +|| left to right +?: right to left += += \-= *= /= %= <<= >>= &= \(ha= |= right to left +, left to right +.te +.pp +the following notes provide further information to the above table: +.pp +.pd 0 +.ip [1] 4 +the ++ and \-\- operators at this precedence level are +the postfix flavors of the operators. +.ip [2] +the ++ and \-\- operators at this precedence level are +the prefix flavors of the operators. +.pd +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2006 red hat, inc. all rights reserved. +.\" written by david howells (dhowells@redhat.com) +.\" and copyright (c) 2016 michael kerrisk +.\" +.\" %%%license_start(gplv2+_sw_onepara) +.\" this program is free software; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license +.\" as published by the free software foundation; either version +.\" 2 of the license, or (at your option) any later version. +.\" %%%license_end +.\" +.th add_key 2 2021-08-27 linux "linux key management calls" +.sh name +add_key \- add a key to the kernel's key management facility +.sh synopsis +.nf +.b #include +.pp +.bi "key_serial_t add_key(const char *" type ", const char *" description , +.bi " const void *" payload ", size_t " plen , +.bi " key_serial_t " keyring ");" +.fi +.pp +.ir note : +there is no glibc wrapper for this system call; see notes. +.sh description +.br add_key () +creates or updates a key of the given +.i type +and +.ir description , +instantiates it with the +.i payload +of length +.ir plen , +attaches it to the nominated +.ir keyring , +and returns the key's serial number. +.pp +the key may be rejected if the provided data is in the wrong format or +it is invalid in some other way. +.pp +if the destination +.i keyring +already contains a key that matches the specified +.ir type +and +.ir description , +then, if the key type supports it, +.\" fixme the aforementioned phrases begs the question: +.\" which key types support this? +that key will be updated rather than a new key being created; +if not, a new key (with a different id) will be created +and it will displace the link to the extant key from the keyring. +.\" fixme perhaps elaborate the implications here? namely, the new +.\" key will have a new id, and if the old key was a keyring that +.\" is consequently unlinked, then keys that it was anchoring +.\" will have their reference count decreased by one (and may +.\" consequently be garbage collected). is this all correct? +.pp +the destination +.i keyring +serial number may be that of a valid keyring for which the caller has +.i write +permission. +alternatively, it may be one of the following special keyring ids: +.\" fixme . perhaps have a separate page describing special keyring ids? +.tp +.b key_spec_thread_keyring +this specifies the caller's thread-specific keyring +.rb ( thread\-keyring (7)). +.tp +.b key_spec_process_keyring +this specifies the caller's process-specific keyring +.rb ( process\-keyring (7)). +.tp +.b key_spec_session_keyring +this specifies the caller's session-specific keyring +.rb ( session\-keyring (7)). +.tp +.b key_spec_user_keyring +this specifies the caller's uid-specific keyring +.rb ( user\-keyring (7)). +.tp +.b key_spec_user_session_keyring +this specifies the caller's uid-session keyring +.rb ( user\-session\-keyring (7)). +.ss key types +the key +.i type +is a string that specifies the key's type. +internally, the kernel defines a number of key types that are +available in the core key management code. +among the types that are available for user-space use +and can be specified as the +.i type +argument to +.br add_key () +are the following: +.tp +.i """keyring""" +keyrings are special key types that may contain links to sequences of other +keys of any type. +if this interface is used to create a keyring, then +.i payload +should be null and +.i plen +should be zero. +.tp +.ir """user""" +this is a general purpose key type whose payload may be read and updated +by user-space applications. +the key is kept entirely within kernel memory. +the payload for keys of this type is a blob of arbitrary data +of up to 32,767 bytes. +.tp +.ir """logon""" " (since linux 3.3)" +.\" commit 9f6ed2ca257fa8650b876377833e6f14e272848b +this key type is essentially the same as +.ir """user""" , +but it does not permit the key to read. +this is suitable for storing payloads +that you do not want to be readable from user space. +.pp +this key type vets the +.i description +to ensure that it is qualified by a "service" prefix, +by checking to ensure that the +.i description +contains a ':' that is preceded by other characters. +.tp +.ir """big_key""" " (since linux 3.13)" +.\" commit ab3c3587f8cda9083209a61dbe3a4407d3cada10 +this key type is similar to +.ir """user""" , +but may hold a payload of up to 1\ mib. +if the key payload is large enough, +then it may be stored encrypted in tmpfs +(which can be swapped out) rather than kernel memory. +.pp +for further details on these key types, see +.br keyrings (7). +.sh return value +on success, +.br add_key () +returns the serial number of the key it created or updated. +on error, \-1 is returned and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eacces +the keyring wasn't available for modification by the user. +.tp +.b edquot +the key quota for this user would be exceeded by creating this key or linking +it to the keyring. +.tp +.b efault +one or more of +.ir type , +.ir description , +and +.i payload +points outside process's accessible address space. +.tp +.b einval +the size of the string (including the terminating null byte) specified in +.i type +or +.i description +exceeded the limit (32 bytes and 4096 bytes respectively). +.tp +.b einval +the payload data was invalid. +.tp +.b einval +.ir type +was +.ir """logon""" +and the +.i description +was not qualified with a prefix string of the form +.ir """service:""" . +.tp +.b ekeyexpired +the keyring has expired. +.tp +.b ekeyrevoked +the keyring has been revoked. +.tp +.b enokey +the keyring doesn't exist. +.tp +.b enomem +insufficient memory to create a key. +.tp +.b eperm +the +.i type +started with a period (\(aq.\(aq). +key types that begin with a period are reserved to the implementation. +.tp +.b eperm +.i type +was +.i """keyring""" +and the +.i description +started with a period (\(aq.\(aq). +keyrings with descriptions (names) +that begin with a period are reserved to the implementation. +.sh versions +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. +(the accompanying package provides the +.i +header file.) +when employing the wrapper in that library, link with +.ir \-lkeyutils . +.sh examples +the program below creates a key with the type, description, and payload +specified in its command-line arguments, +and links that key into the session keyring. +the following shell session demonstrates the use of the program: +.pp +.in +4n +.ex +$ \fb./a.out user mykey "some payload"\fp +key id is 64a4dca +$ \fbgrep \(aq64a4dca\(aq /proc/keys\fp +064a4dca i\-\-q\-\-\- 1 perm 3f010000 1000 1000 user mykey: 12 +.ee +.in +.ss program source +\& +.ex +#include +#include +#include +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + key_serial_t key; + + if (argc != 4) { + fprintf(stderr, "usage: %s type description payload\en", + argv[0]); + exit(exit_failure); + } + + key = add_key(argv[1], argv[2], argv[3], strlen(argv[3]), + key_spec_session_keyring); + if (key == \-1) { + perror("add_key"); + exit(exit_failure); + } + + printf("key id is %jx\en", (uintmax_t) key); + + exit(exit_success); +} +.ee +.sh see also +.ad l +.nh +.br keyctl (1), +.br keyctl (2), +.br request_key (2), +.br keyctl (3), +.br keyrings (7), +.br keyutils (7), +.br persistent\-keyring (7), +.br process\-keyring (7), +.br session\-keyring (7), +.br thread\-keyring (7), +.br user\-keyring (7), +.br user\-session\-keyring (7) +.pp +the kernel source files +.ir documentation/security/keys/core.rst +and +.ir documentation/keys/request\-key.rst +(or, before linux 4.13, in the files +.\" commit b68101a1e8f0263dbc7b8375d2a7c57c6216fb76 +.ir documentation/security/keys.txt +and +.\" commit 3db38ed76890565772fcca3279cc8d454ea6176b +.ir documentation/security/keys\-request\-key.txt ). +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/scanf.3 + +.so man7/iso_8859-2.7 + +.so man3/fenv.3 + +.so man3/makedev.3 + +.\" copyright (c) ibm corp. 2015 +.\" author: alexey ishchuk +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th s390_pci_mmio_write 2 2021-03-22 "linux programmer's manual" +.sh name +s390_pci_mmio_write, s390_pci_mmio_read \- transfer data to/from pci +mmio memory page +.sh synopsis +.nf +.br "#include " " /* definition of " sys_* " constants */" +.b #include +.pp +.bi "int syscall(sys_s390_pci_mmio_write, unsigned long " mmio_addr , +.bi " const void *" user_buffer ", size_t " length ); +.bi "int syscall(sys_s390_pci_mmio_read, unsigned long " mmio_addr , +.bi " void *" user_buffer ", size_t " length ); +.fi +.pp +.ir note : +glibc provides no wrappers for these system calls, +necessitating the use of +.br syscall (2). +.sh description +the +.br s390_pci_mmio_write () +system call writes +.ir length +bytes of data from the user-space buffer +.ir user_buffer +to the pci mmio memory location specified by +.ir mmio_addr . +the +.br s390_pci_mmio_read () +system call reads +.i length +bytes of +data from the pci mmio memory location specified by +.ir mmio_addr +to the user-space buffer +.ir user_buffer . +.pp +these system calls must be used instead of the simple assignment +or data-transfer operations that are used to access the pci mmio +memory areas mapped to user space on the linux system z platform. +the address specified by +.ir mmio_addr +must belong to a pci mmio memory page mapping in the caller's address space, +and the data being written or read must not cross a page boundary. +the +.ir length +value cannot be greater than the system page size. +.sh return value +on success, +.br s390_pci_mmio_write () +and +.br s390_pci_mmio_read () +return 0. +on failure, \-1 is returned and +.ir errno +is set to indicate the error. +.sh errors +.tp +.b efault +the address in +.i mmio_addr +is invalid. +.tp +.b efault +.ir user_buffer +does not point to a valid location in the caller's address space. +.tp +.b einval +invalid +.i length +argument. +.tp +.b enodev +pci support is not enabled. +.tp +.b enomem +insufficient memory. +.sh versions +these system calls are available since linux 3.19. +.sh conforming to +this linux-specific system call is available only on the s390 architecture. +the required pci support is available beginning with system z ec12. +.sh see also +.br syscall (2) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man7/iso_8859-9.7 + +.so man3/stdio_ext.3 + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" +.th wcwidth 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +wcwidth \- determine columns needed for a wide character +.sh synopsis +.nf +.br "#define _xopen_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "int wcwidth(wchar_t " c ); +.fi +.sh description +the +.br wcwidth () +function returns the number of columns +needed to represent the wide character +.ir c . +if +.i c +is a printable wide character, the value +is at least 0. +if +.i c +is null wide character (l\(aq\e0\(aq), the value is 0. +otherwise, \-1 is returned. +.sh return value +the +.br wcwidth () +function returns the number of +column positions for +.ir c . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br wcwidth () +t} thread safety mt-safe locale +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.pp +note that glibc before 2.2.5 used the prototype +.pp +.nf +.bi "int wcwidth(wint_t " c ); +.fi +.sh notes +the behavior of +.br wcwidth () +depends on the +.b lc_ctype +category of the +current locale. +.sh see also +.br iswprint (3), +.br wcswidth (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/drand48_r.3 + +.so man3/xcrypt.3 + +.so man3/fenv.3 + +.so man3/rint.3 + +.so man3/tailq.3 + +.\" copyright (c) 2001 by john levon +.\" based in part on gnu libc documentation. +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" 2001-10-11, 2003-08-22, aeb, added some details +.\" 2012-03-23, michael kerrisk +.\" document pvalloc() and aligned_alloc() +.th posix_memalign 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +posix_memalign, aligned_alloc, memalign, valloc, pvalloc \- allocate aligned memory +.sh synopsis +.nf +.b #include +.pp +.bi "int posix_memalign(void **" memptr ", size_t " alignment ", size_t " size ); +.bi "void *aligned_alloc(size_t " alignment ", size_t " size ); +.bi "void *valloc(size_t " size ); +.pp +.b #include +.pp +.bi "void *memalign(size_t " alignment ", size_t " size ); +.bi "void *pvalloc(size_t " size ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br posix_memalign (): +.nf + _posix_c_source >= 200112l +.fi +.pp +.br aligned_alloc (): +.nf + _isoc11_source +.fi +.pp +.br valloc (): +.nf + since glibc 2.12: + (_xopen_source >= 500) && !(_posix_c_source >= 200112l) + || /* glibc since 2.19: */ _default_source + || /* glibc <= 2.19: */ _svid_source || _bsd_source + before glibc 2.12: + _bsd_source || _xopen_source >= 500 +.\" || _xopen_source && _xopen_source_extended +.fi +.sh description +the function +.br posix_memalign () +allocates +.i size +bytes and places the address of the allocated memory in +.ir "*memptr" . +the address of the allocated memory will be a multiple of +.ir "alignment" , +which must be a power of two and a multiple of +.ir "sizeof(void\ *)" . +this address can later be successfully passed to +.br free (3). +if +.i size +is 0, then +the value placed in +.ir "*memptr" +is either null +.\" glibc does this: +or a unique pointer value. +.pp +the obsolete function +.br memalign () +allocates +.i size +bytes and returns a pointer to the allocated memory. +the memory address will be a multiple of +.ir alignment , +which must be a power of two. +.\" the behavior of memalign() for size==0 is as for posix_memalign() +.\" but no standards govern this. +.pp +the function +.br aligned_alloc () +is the same as +.br memalign (), +except for the added restriction that +.i size +should be a multiple of +.ir alignment . +.pp +the obsolete function +.br valloc () +allocates +.i size +bytes and returns a pointer to the allocated memory. +the memory address will be a multiple of the page size. +it is equivalent to +.ir "memalign(sysconf(_sc_pagesize),size)" . +.pp +the obsolete function +.br pvalloc () +is similar to +.br valloc (), +but rounds the size of the allocation up to +the next multiple of the system page size. +.pp +for all of these functions, the memory is not zeroed. +.sh return value +.br aligned_alloc (), +.br memalign (), +.br valloc (), +and +.br pvalloc () +return a pointer to the allocated memory on success. +on error, null is returned, and \fierrno\fp is set +to indicate the error. +.pp +.br posix_memalign () +returns zero on success, or one of the error values listed in the +next section on failure. +the value of +.i errno +is not set. +on linux (and other systems), +.br posix_memalign () +does not modify +.i memptr +on failure. +a requirement standardizing this behavior was added in posix.1-2008 tc2. +.\" http://austingroupbugs.net/view.php?id=520 +.sh errors +.tp +.b einval +the +.i alignment +argument was not a power of two, or was not a multiple of +.ir "sizeof(void\ *)" . +.tp +.b enomem +there was insufficient memory to fulfill the allocation request. +.sh versions +the functions +.br memalign (), +.br valloc (), +and +.br pvalloc () +have been available since at least glibc 2.0. +.pp +the function +.br aligned_alloc () +was added to glibc in version 2.16. +.pp +the function +.br posix_memalign () +is available since glibc 2.1.91. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br aligned_alloc (), +.br memalign (), +.br posix_memalign () +t} thread safety mt-safe +t{ +.br valloc (), +.br pvalloc () +t} thread safety mt-unsafe init +.te +.hy +.ad +.sp 1 +.sh conforming to +the function +.br valloc () +appeared in 3.0bsd. +it is documented as being obsolete in 4.3bsd, +and as legacy in susv2. +it does not appear in posix.1. +.pp +the function +.br pvalloc () +is a gnu extension. +.pp +the function +.br memalign () +appears in sunos 4.1.3 but not in 4.4bsd. +.pp +the function +.br posix_memalign () +comes from posix.1d and is specified in posix.1-2001 and posix.1-2008. +.pp +the function +.br aligned_alloc () +is specified in the c11 standard. +.\" +.ss headers +everybody agrees that +.br posix_memalign () +is declared in \fi\fp. +.pp +on some systems +.br memalign () +is declared in \fi\fp instead of \fi\fp. +.pp +according to susv2, +.br valloc () +is declared in \fi\fp. +.\" libc4,5 and +glibc declares it in \fi\fp, and also in +\fi\fp +if suitable feature test macros are defined (see above). +.sh notes +on many systems there are alignment restrictions, for example, on buffers +used for direct block device i/o. +posix specifies the +.i "pathconf(path,_pc_rec_xfer_align)" +call that tells what alignment is needed. +now one can use +.br posix_memalign () +to satisfy this requirement. +.pp +.br posix_memalign () +verifies that +.i alignment +matches the requirements detailed above. +.br memalign () +may not check that the +.i alignment +argument is correct. +.pp +posix requires that memory obtained from +.br posix_memalign () +can be freed using +.br free (3). +some systems provide no way to reclaim memory allocated with +.br memalign () +or +.br valloc () +(because one can pass to +.br free (3) +only a pointer obtained from +.br malloc (3), +while, for example, +.br memalign () +would call +.br malloc (3) +and then align the obtained value). +.\" other systems allow passing the result of +.\" .ir valloc () +.\" to +.\" .ir free (3), +.\" but not to +.\" .ir realloc (3). +the glibc implementation +allows memory obtained from any of these functions to be +reclaimed with +.br free (3). +.pp +the glibc +.br malloc (3) +always returns 8-byte aligned memory addresses, so these functions are +needed only if you require larger alignment values. +.sh see also +.br brk (2), +.br getpagesize (2), +.br free (3), +.br malloc (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/unimplemented.2 + +.so man7/system_data_types.7 + +.so man3/endian.3 + +.\" copyright (c) 1996 free software foundation, inc. +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" this file is distributed according to the gnu general public license. +.\" %%%license_end +.\" +.\" 2006-02-09, some reformatting by luc van oostenryck; some +.\" reformatting and rewordings by mtk +.\" +.th get_kernel_syms 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +get_kernel_syms \- retrieve exported kernel and module symbols +.sh synopsis +.nf +.b #include +.pp +.bi "int get_kernel_syms(struct kernel_sym *" table ); +.fi +.pp +.ir note : +no declaration of this system call is provided in glibc headers; see notes. +.sh description +.br note : +this system call is present only in kernels before linux 2.6. +.pp +if +.i table +is null, +.br get_kernel_syms () +returns the number of symbols available for query. +otherwise, it fills in a table of structures: +.pp +.in +4n +.ex +struct kernel_sym { + unsigned long value; + char name[60]; +}; +.ee +.in +.pp +the symbols are interspersed with magic symbols of the form +.bi # module-name +with the kernel having an empty name. +the value associated with a symbol of this form is the address at +which the module is loaded. +.pp +the symbols exported from each module follow their magic module tag +and the modules are returned in the reverse of the +order in which they were loaded. +.sh return value +on success, returns the number of symbols copied to +.ir table . +on error, \-1 is returned and +.i errno +is set to indicate the error. +.sh errors +there is only one possible error return: +.tp +.b enosys +.br get_kernel_syms () +is not supported in this version of the kernel. +.sh versions +this system call is present on linux only up until kernel 2.4; +it was removed in linux 2.6. +.\" removed in linux 2.5.48 +.sh conforming to +.br get_kernel_syms () +is linux-specific. +.sh notes +this obsolete system call is not supported by glibc. +no declaration is provided in glibc headers, but, through a quirk of history, +glibc versions before 2.23 did export an abi for this system call. +therefore, in order to employ this system call, +it was sufficient to manually declare the interface in your code; +alternatively, you could invoke the system call using +.br syscall (2). +.sh bugs +there is no way to indicate the size of the buffer allocated for +.ir table . +if symbols have been added to the kernel since the +program queried for the symbol table size, memory will be corrupted. +.pp +the length of exported symbol names is limited to 59 characters. +.pp +because of these limitations, this system call is deprecated in +favor of +.br query_module (2) +(which is itself nowadays deprecated +in favor of other interfaces described on its manual page). +.sh see also +.br create_module (2), +.br delete_module (2), +.br init_module (2), +.br query_module (2) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" this manpage is copyright (c) 2001 paul sheer. +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" very minor changes, aeb +.\" +.\" modified 5 june 2002, michael kerrisk +.\" 2006-05-13, mtk, removed much material that is redundant with select.2 +.\" various other changes +.\" 2008-01-26, mtk, substantial changes and rewrites +.\" +.th select_tut 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +select, pselect \- synchronous i/o multiplexing +.sh synopsis +see +.br select (2) +.sh description +the +.br select () +and +.br pselect () +system calls are used to efficiently monitor multiple file descriptors, +to see if any of them is, or becomes, "ready"; +that is, to see whether i/o becomes possible, +or an "exceptional condition" has occurred on any of the file descriptors. +.pp +this page provides background and tutorial information +on the use of these system calls. +for details of the arguments and semantics of +.br select () +and +.br pselect (), +see +.br select (2). +.\" +.ss combining signal and data events +.br pselect () +is useful if you are waiting for a signal as well as +for file descriptor(s) to become ready for i/o. +programs that receive signals +normally use the signal handler only to raise a global flag. +the global flag will indicate that the event must be processed +in the main loop of the program. +a signal will cause the +.br select () +(or +.br pselect ()) +call to return with \fierrno\fp set to \fbeintr\fp. +this behavior is essential so that signals can be processed +in the main loop of the program, otherwise +.br select () +would block indefinitely. +.pp +now, somewhere +in the main loop will be a conditional to check the global flag. +so we must ask: +what if a signal arrives after the conditional, but before the +.br select () +call? +the answer is that +.br select () +would block indefinitely, even though an event is actually pending. +this race condition is solved by the +.br pselect () +call. +this call can be used to set the signal mask to a set of signals +that are to be received only within the +.br pselect () +call. +for instance, let us say that the event in question +was the exit of a child process. +before the start of the main loop, we +would block \fbsigchld\fp using +.br sigprocmask (2). +our +.br pselect () +call would enable +.b sigchld +by using an empty signal mask. +our program would look like: +.pp +.ex +static volatile sig_atomic_t got_sigchld = 0; + +static void +child_sig_handler(int sig) +{ + got_sigchld = 1; +} + +int +main(int argc, char *argv[]) +{ + sigset_t sigmask, empty_mask; + struct sigaction sa; + fd_set readfds, writefds, exceptfds; + int r; + + sigemptyset(&sigmask); + sigaddset(&sigmask, sigchld); + if (sigprocmask(sig_block, &sigmask, null) == \-1) { + perror("sigprocmask"); + exit(exit_failure); + } + + sa.sa_flags = 0; + sa.sa_handler = child_sig_handler; + sigemptyset(&sa.sa_mask); + if (sigaction(sigchld, &sa, null) == \-1) { + perror("sigaction"); + exit(exit_failure); + } + + sigemptyset(&empty_mask); + + for (;;) { /* main loop */ + /* initialize readfds, writefds, and exceptfds + before the pselect() call. (code omitted.) */ + + r = pselect(nfds, &readfds, &writefds, &exceptfds, + null, &empty_mask); + if (r == \-1 && errno != eintr) { + /* handle error */ + } + + if (got_sigchld) { + got_sigchld = 0; + + /* handle signalled event here; e.g., wait() for all + terminated children. (code omitted.) */ + } + + /* main body of program */ + } +} +.ee +.ss practical +so what is the point of +.br select ()? +can't i just read and write to my file descriptors whenever i want? +the point of +.br select () +is that it watches +multiple descriptors at the same time and properly puts the process to +sleep if there is no activity. +unix programmers often find +themselves in a position where they have to handle i/o from more than one +file descriptor where the data flow may be intermittent. +if you were to merely create a sequence of +.br read (2) +and +.br write (2) +calls, you would +find that one of your calls may block waiting for data from/to a file +descriptor, while another file descriptor is unused though ready for i/o. +.br select () +efficiently copes with this situation. +.ss select law +many people who try to use +.br select () +come across behavior that is +difficult to understand and produces nonportable or borderline results. +for instance, the above program is carefully written not to +block at any point, even though it does not set its file descriptors to +nonblocking mode. +it is easy to introduce +subtle errors that will remove the advantage of using +.br select (), +so here is a list of essentials to watch for when using +.br select (). +.tp 4 +1. +you should always try to use +.br select () +without a timeout. +your program +should have nothing to do if there is no data available. +code that +depends on timeouts is not usually portable and is difficult to debug. +.tp +2. +the value \finfds\fp must be properly calculated for efficiency as +explained above. +.tp +3. +no file descriptor must be added to any set if you do not intend +to check its result after the +.br select () +call, and respond appropriately. +see next rule. +.tp +4. +after +.br select () +returns, all file descriptors in all sets +should be checked to see if they are ready. +.tp +5. +the functions +.br read (2), +.br recv (2), +.br write (2), +and +.br send (2) +do \finot\fp necessarily read/write the full amount of data +that you have requested. +if they do read/write the full amount, it's +because you have a low traffic load and a fast stream. +this is not always going to be the case. +you should cope with the case of your +functions managing to send or receive only a single byte. +.tp +6. +never read/write only in single bytes at a time unless you are really +sure that you have a small amount of data to process. +it is extremely +inefficient not to read/write as much data as you can buffer each time. +the buffers in the example below are 1024 bytes although they could +easily be made larger. +.tp +7. +calls to +.br read (2), +.br recv (2), +.br write (2), +.br send (2), +and +.br select () +can fail with the error +\fbeintr\fp, +and calls to +.br read (2), +.br recv (2) +.br write (2), +and +.br send (2) +can fail with +.i errno +set to \fbeagain\fp (\fbewouldblock\fp). +these results must be properly managed (not done properly above). +if your program is not going to receive any signals, then +it is unlikely you will get \fbeintr\fp. +if your program does not set nonblocking i/o, +you will not get \fbeagain\fp. +.\" nonetheless, you should still cope with these errors for completeness. +.tp +8. +never call +.br read (2), +.br recv (2), +.br write (2), +or +.br send (2) +with a buffer length of zero. +.tp +9. +if the functions +.br read (2), +.br recv (2), +.br write (2), +and +.br send (2) +fail with errors other than those listed in \fb7.\fp, +or one of the input functions returns 0, indicating end of file, +then you should \finot\fp pass that file descriptor to +.br select () +again. +in the example below, +i close the file descriptor immediately, and then set it to \-1 +to prevent it being included in a set. +.tp +10. +the timeout value must be initialized with each new call to +.br select (), +since some operating systems modify the structure. +.br pselect () +however does not modify its timeout structure. +.tp +11. +since +.br select () +modifies its file descriptor sets, +if the call is being used in a loop, +then the sets must be reinitialized before each call. +.\" "i have heard" does not fill me with confidence, and doesn't +.\" belong in a man page, so i've commented this point out. +.\" .tp +.\" 11. +.\" i have heard that the windows socket layer does not cope with oob data +.\" properly. +.\" it also does not cope with +.\" .br select () +.\" calls when no file descriptors are set at all. +.\" having no file descriptors set is a useful +.\" way to sleep the process with subsecond precision by using the timeout. +.\" (see further on.) +.sh return value +see +.br select (2). +.sh notes +generally speaking, +all operating systems that support sockets also support +.br select (). +.br select () +can be used to solve +many problems in a portable and efficient way that naive programmers try +to solve in a more complicated manner using +threads, forking, ipcs, signals, memory sharing, and so on. +.pp +the +.br poll (2) +system call has the same functionality as +.br select (), +and is somewhat more efficient when monitoring sparse +file descriptor sets. +it is nowadays widely available, but historically was less portable than +.br select (). +.pp +the linux-specific +.br epoll (7) +api provides an interface that is more efficient than +.br select (2) +and +.br poll (2) +when monitoring large numbers of file descriptors. +.sh examples +here is an example that better demonstrates the true utility of +.br select (). +the listing below is a tcp forwarding program that forwards +from one tcp port to another. +.pp +.ex +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static int forward_port; + +#undef max +#define max(x,y) ((x) > (y) ? (x) : (y)) + +static int +listen_socket(int listen_port) +{ + struct sockaddr_in addr; + int lfd; + int yes; + + lfd = socket(af_inet, sock_stream, 0); + if (lfd == \-1) { + perror("socket"); + return \-1; + } + + yes = 1; + if (setsockopt(lfd, sol_socket, so_reuseaddr, + &yes, sizeof(yes)) == \-1) { + perror("setsockopt"); + close(lfd); + return \-1; + } + + memset(&addr, 0, sizeof(addr)); + addr.sin_port = htons(listen_port); + addr.sin_family = af_inet; + if (bind(lfd, (struct sockaddr *) &addr, sizeof(addr)) == \-1) { + perror("bind"); + close(lfd); + return \-1; + } + + printf("accepting connections on port %d\en", listen_port); + listen(lfd, 10); + return lfd; +} + +static int +connect_socket(int connect_port, char *address) +{ + struct sockaddr_in addr; + int cfd; + + cfd = socket(af_inet, sock_stream, 0); + if (cfd == \-1) { + perror("socket"); + return \-1; + } + + memset(&addr, 0, sizeof(addr)); + addr.sin_port = htons(connect_port); + addr.sin_family = af_inet; + + if (!inet_aton(address, (struct in_addr *) &addr.sin_addr.s_addr)) { + fprintf(stderr, "inet_aton(): bad ip address format\en"); + close(cfd); + return \-1; + } + + if (connect(cfd, (struct sockaddr *) &addr, sizeof(addr)) == \-1) { + perror("connect()"); + shutdown(cfd, shut_rdwr); + close(cfd); + return \-1; + } + return cfd; +} + +#define shut_fd1 do { \e + if (fd1 >= 0) { \e + shutdown(fd1, shut_rdwr); \e + close(fd1); \e + fd1 = \-1; \e + } \e + } while (0) + +#define shut_fd2 do { \e + if (fd2 >= 0) { \e + shutdown(fd2, shut_rdwr); \e + close(fd2); \e + fd2 = \-1; \e + } \e + } while (0) + +#define buf_size 1024 + +int +main(int argc, char *argv[]) +{ + int h; + int fd1 = \-1, fd2 = \-1; + char buf1[buf_size], buf2[buf_size]; + int buf1_avail = 0, buf1_written = 0; + int buf2_avail = 0, buf2_written = 0; + + if (argc != 4) { + fprintf(stderr, "usage\en\etfwd " + " \en"); + exit(exit_failure); + } + + signal(sigpipe, sig_ign); + + forward_port = atoi(argv[2]); + + h = listen_socket(atoi(argv[1])); + if (h == \-1) + exit(exit_failure); + + for (;;) { + int ready, nfds = 0; + ssize_t nbytes; + fd_set readfds, writefds, exceptfds; + + fd_zero(&readfds); + fd_zero(&writefds); + fd_zero(&exceptfds); + fd_set(h, &readfds); + nfds = max(nfds, h); + + if (fd1 > 0 && buf1_avail < buf_size) + fd_set(fd1, &readfds); + /* note: nfds is updated below, when fd1 is added to + exceptfds. */ + if (fd2 > 0 && buf2_avail < buf_size) + fd_set(fd2, &readfds); + + if (fd1 > 0 && buf2_avail \- buf2_written > 0) + fd_set(fd1, &writefds); + if (fd2 > 0 && buf1_avail \- buf1_written > 0) + fd_set(fd2, &writefds); + + if (fd1 > 0) { + fd_set(fd1, &exceptfds); + nfds = max(nfds, fd1); + } + if (fd2 > 0) { + fd_set(fd2, &exceptfds); + nfds = max(nfds, fd2); + } + + ready = select(nfds + 1, &readfds, &writefds, &exceptfds, null); + + if (ready == \-1 && errno == eintr) + continue; + + if (ready == \-1) { + perror("select()"); + exit(exit_failure); + } + + if (fd_isset(h, &readfds)) { + socklen_t addrlen; + struct sockaddr_in client_addr; + int fd; + + addrlen = sizeof(client_addr); + memset(&client_addr, 0, addrlen); + fd = accept(h, (struct sockaddr *) &client_addr, &addrlen); + if (fd == \-1) { + perror("accept()"); + } else { + shut_fd1; + shut_fd2; + buf1_avail = buf1_written = 0; + buf2_avail = buf2_written = 0; + fd1 = fd; + fd2 = connect_socket(forward_port, argv[3]); + if (fd2 == \-1) + shut_fd1; + else + printf("connect from %s\en", + inet_ntoa(client_addr.sin_addr)); + + /* skip any events on the old, closed file + descriptors. */ + + continue; + } + } + + /* nb: read oob data before normal reads. */ + + if (fd1 > 0 && fd_isset(fd1, &exceptfds)) { + char c; + + nbytes = recv(fd1, &c, 1, msg_oob); + if (nbytes < 1) + shut_fd1; + else + send(fd2, &c, 1, msg_oob); + } + if (fd2 > 0 && fd_isset(fd2, &exceptfds)) { + char c; + + nbytes = recv(fd2, &c, 1, msg_oob); + if (nbytes < 1) + shut_fd2; + else + send(fd1, &c, 1, msg_oob); + } + if (fd1 > 0 && fd_isset(fd1, &readfds)) { + nbytes = read(fd1, buf1 + buf1_avail, + buf_size \- buf1_avail); + if (nbytes < 1) + shut_fd1; + else + buf1_avail += nbytes; + } + if (fd2 > 0 && fd_isset(fd2, &readfds)) { + nbytes = read(fd2, buf2 + buf2_avail, + buf_size \- buf2_avail); + if (nbytes < 1) + shut_fd2; + else + buf2_avail += nbytes; + } + if (fd1 > 0 && fd_isset(fd1, &writefds) && buf2_avail > 0) { + nbytes = write(fd1, buf2 + buf2_written, + buf2_avail \- buf2_written); + if (nbytes < 1) + shut_fd1; + else + buf2_written += nbytes; + } + if (fd2 > 0 && fd_isset(fd2, &writefds) && buf1_avail > 0) { + nbytes = write(fd2, buf1 + buf1_written, + buf1_avail \- buf1_written); + if (nbytes < 1) + shut_fd2; + else + buf1_written += nbytes; + } + + /* check if write data has caught read data. */ + + if (buf1_written == buf1_avail) + buf1_written = buf1_avail = 0; + if (buf2_written == buf2_avail) + buf2_written = buf2_avail = 0; + + /* one side has closed the connection, keep + writing to the other side until empty. */ + + if (fd1 < 0 && buf1_avail \- buf1_written == 0) + shut_fd2; + if (fd2 < 0 && buf2_avail \- buf2_written == 0) + shut_fd1; + } + exit(exit_success); +} +.ee +.pp +the above program properly forwards most kinds of tcp connections +including oob signal data transmitted by \fbtelnet\fp servers. +it handles the tricky problem of having data flow in both directions +simultaneously. +you might think it more efficient to use a +.br fork (2) +call and devote a thread to each stream. +this becomes more tricky than you might suspect. +another idea is to set nonblocking i/o using +.br fcntl (2). +this also has its problems because you end up using +inefficient timeouts. +.pp +the program does not handle more than one simultaneous connection at a +time, although it could easily be extended to do this with a linked list +of buffers\(emone for each connection. +at the moment, new +connections cause the current connection to be dropped. +.sh see also +.br accept (2), +.br connect (2), +.br poll (2), +.br read (2), +.br recv (2), +.br select (2), +.br send (2), +.br sigprocmask (2), +.br write (2), +.br epoll (7) +.\" .sh authors +.\" this man page was written by paul sheer. +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/cpu_set.3 + +.\" copyright (c) 2008 michael kerrisk +.\" starting from a version by davide libenzi +.\" +.\" %%%license_start(gplv2+_sw_3_para) +.\" this program is free software; you can redistribute it and/or modify +.\" it under the terms of the gnu general public license as published by +.\" the free software foundation; either version 2 of the license, or +.\" (at your option) any later version. +.\" +.\" this program 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th signalfd 2 2021-03-22 linux "linux programmer's manual" +.sh name +signalfd \- create a file descriptor for accepting signals +.sh synopsis +.nf +.b #include +.pp +.bi "int signalfd(int " fd ", const sigset_t *" mask ", int " flags ); +.fi +.sh description +.br signalfd () +creates a file descriptor that can be used to accept signals +targeted at the caller. +this provides an alternative to the use of a signal handler or +.br sigwaitinfo (2), +and has the advantage that the file descriptor may be monitored by +.br select (2), +.br poll (2), +and +.br epoll (7). +.pp +the +.i mask +argument specifies the set of signals that the caller +wishes to accept via the file descriptor. +this argument is a signal set whose contents can be initialized +using the macros described in +.br sigsetops (3). +normally, the set of signals to be received via the +file descriptor should be blocked using +.br sigprocmask (2), +to prevent the signals being handled according to their default +dispositions. +it is not possible to receive +.b sigkill +or +.b sigstop +signals via a signalfd file descriptor; +these signals are silently ignored if specified in +.ir mask . +.pp +if the +.i fd +argument is \-1, +then the call creates a new file descriptor and associates the +signal set specified in +.i mask +with that file descriptor. +if +.i fd +is not \-1, +then it must specify a valid existing signalfd file descriptor, and +.i mask +is used to replace the signal set associated with that file descriptor. +.pp +starting with linux 2.6.27, the following values may be bitwise ored in +.ir flags +to change the behavior of +.br signalfd (): +.tp 14 +.b sfd_nonblock +set the +.br o_nonblock +file status flag on the open file description (see +.br open (2)) +referred to by the new file descriptor. +using this flag saves extra calls to +.br fcntl (2) +to achieve the same result. +.tp +.b sfd_cloexec +set the close-on-exec +.rb ( fd_cloexec ) +flag on the new file descriptor. +see the description of the +.b o_cloexec +flag in +.br open (2) +for reasons why this may be useful. +.pp +in linux up to version 2.6.26, the +.i flags +argument is unused, and must be specified as zero. +.pp +.br signalfd () +returns a file descriptor that supports the following operations: +.tp +.br read (2) +if one or more of the signals specified in +.i mask +is pending for the process, then the buffer supplied to +.br read (2) +is used to return one or more +.i signalfd_siginfo +structures (see below) that describe the signals. +the +.br read (2) +returns information for as many signals as are pending and will +fit in the supplied buffer. +the buffer must be at least +.i "sizeof(struct signalfd_siginfo)" +bytes. +the return value of the +.br read (2) +is the total number of bytes read. +.ip +as a consequence of the +.br read (2), +the signals are consumed, +so that they are no longer pending for the process +(i.e., will not be caught by signal handlers, +and cannot be accepted using +.br sigwaitinfo (2)). +.ip +if none of the signals in +.i mask +is pending for the process, then the +.br read (2) +either blocks until one of the signals in +.i mask +is generated for the process, +or fails with the error +.b eagain +if the file descriptor has been made nonblocking. +.tp +.br poll "(2), " select "(2) (and similar)" +the file descriptor is readable +(the +.br select (2) +.i readfds +argument; the +.br poll (2) +.b pollin +flag) +if one or more of the signals in +.i mask +is pending for the process. +.ip +the signalfd file descriptor also supports the other file-descriptor +multiplexing apis: +.br pselect (2), +.br ppoll (2), +and +.br epoll (7). +.tp +.br close (2) +when the file descriptor is no longer required it should be closed. +when all file descriptors associated with the same signalfd object +have been closed, the resources for object are freed by the kernel. +.ss the signalfd_siginfo structure +the format of the +.i signalfd_siginfo +structure(s) returned by +.br read (2)s +from a signalfd file descriptor is as follows: +.pp +.in +4n +.ex +struct signalfd_siginfo { + uint32_t ssi_signo; /* signal number */ + int32_t ssi_errno; /* error number (unused) */ + int32_t ssi_code; /* signal code */ + uint32_t ssi_pid; /* pid of sender */ + uint32_t ssi_uid; /* real uid of sender */ + int32_t ssi_fd; /* file descriptor (sigio) */ + uint32_t ssi_tid; /* kernel timer id (posix timers) + uint32_t ssi_band; /* band event (sigio) */ + uint32_t ssi_overrun; /* posix timer overrun count */ + uint32_t ssi_trapno; /* trap number that caused signal */ +.\" ssi_trapno is unused on most arches + int32_t ssi_status; /* exit status or signal (sigchld) */ + int32_t ssi_int; /* integer sent by sigqueue(3) */ + uint64_t ssi_ptr; /* pointer sent by sigqueue(3) */ + uint64_t ssi_utime; /* user cpu time consumed (sigchld) */ + uint64_t ssi_stime; /* system cpu time consumed + (sigchld) */ + uint64_t ssi_addr; /* address that generated signal + (for hardware\-generated signals) */ + uint16_t ssi_addr_lsb; /* least significant bit of address + (sigbus; since linux 2.6.37) */ +.\" ssi_addr_lsb: commit b8aeec34175fc8fe8b0d40efea4846dfc1ba663e + uint8_t pad[\fix\fp]; /* pad size to 128 bytes (allow for + additional fields in the future) */ +}; +.ee +.in +.pp +each of the fields in this structure +is analogous to the similarly named field in the +.i siginfo_t +structure. +the +.i siginfo_t +structure is described in +.br sigaction (2). +not all fields in the returned +.i signalfd_siginfo +structure will be valid for a specific signal; +the set of valid fields can be determined from the value returned in the +.i ssi_code +field. +this field is the analog of the +.i siginfo_t +.i si_code +field; see +.br sigaction (2) +for details. +.ss fork(2) semantics +after a +.br fork (2), +the child inherits a copy of the signalfd file descriptor. +a +.br read (2) +from the file descriptor in the child will return information +about signals queued to the child. +.ss semantics of file descriptor passing +as with other file descriptors, +signalfd file descriptors can be passed to another process +via a unix domain socket (see +.br unix (7)). +in the receiving process, a +.br read (2) +from the received file descriptor will return information +about signals queued to that process. +.ss execve(2) semantics +just like any other file descriptor, +a signalfd file descriptor remains open across an +.br execve (2), +unless it has been marked for close-on-exec (see +.br fcntl (2)). +any signals that were available for reading before the +.br execve (2) +remain available to the newly loaded program. +(this is analogous to traditional signal semantics, +where a blocked signal that is pending remains pending across an +.br execve (2).) +.ss thread semantics +the semantics of signalfd file descriptors in a multithreaded program +mirror the standard semantics for signals. +in other words, +when a thread reads from a signalfd file descriptor, +it will read the signals that are directed to the thread +itself and the signals that are directed to the process +(i.e., the entire thread group). +(a thread will not be able to read signals that are directed +to other threads in the process.) +.\" +.ss epoll(7) semantics +if a process adds (via +.br epoll_ctl (2)) +a signalfd file descriptor to an +.br epoll (7) +instance, then +.br epoll_wait (2) +returns events only for signals sent to that process. +in particular, if the process then uses +.br fork (2) +to create a child process, then the child will be able to +.br read (2) +signals that are sent to it using the signalfd file descriptor, but +.br epoll_wait (2) +will +.b not +indicate that the signalfd file descriptor is ready. +in this scenario, a possible workaround is that after the +.br fork (2), +the child process can close the signalfd file descriptor that it inherited +from the parent process and then create another signalfd file descriptor +and add it to the epoll instance. +alternatively, the parent and the child could delay creating their +(separate) signalfd file descriptors and adding them to the +epoll instance until after the call to +.br fork (2). +.sh return value +on success, +.br signalfd () +returns a signalfd file descriptor; +this is either a new file descriptor (if +.i fd +was \-1), or +.i fd +if +.i fd +was a valid signalfd file descriptor. +on error, \-1 is returned and +.i errno +is set to indicate the error. +.sh errors +.tp +.b ebadf +the +.i fd +file descriptor is not a valid file descriptor. +.tp +.b einval +.i fd +is not a valid signalfd file descriptor. +.\" or, the +.\" .i sizemask +.\" argument is not equal to +.\" .ir sizeof(sigset_t) ; +.tp +.b einval +.i flags +is invalid; +or, in linux 2.6.26 or earlier, +.i flags +is nonzero. +.tp +.b emfile +the per-process limit on the number of open file descriptors has been reached. +.tp +.b enfile +the system-wide limit on the total number of open files has been +reached. +.tp +.b enodev +could not mount (internal) anonymous inode device. +.tp +.b enomem +there was insufficient memory to create a new signalfd file descriptor. +.sh versions +.br signalfd () +is available on linux since kernel 2.6.22. +working support is provided in glibc since version 2.8. +.\" signalfd() is in glibc 2.7, but reportedly does not build +the +.br signalfd4 () +system call (see notes) is available on linux since kernel 2.6.27. +.sh conforming to +.br signalfd () +and +.br signalfd4 () +are linux-specific. +.sh notes +a process can create multiple signalfd file descriptors. +this makes it possible to accept different signals +on different file descriptors. +(this may be useful if monitoring the file descriptors using +.br select (2), +.br poll (2), +or +.br epoll (7): +the arrival of different signals will make different file descriptors ready.) +if a signal appears in the +.i mask +of more than one of the file descriptors, then occurrences +of that signal can be read (once) from any one of the file descriptors. +.pp +attempts to include +.b sigkill +and +.b sigstop +in +.i mask +are silently ignored. +.pp +the signal mask employed by a signalfd file descriptor can be viewed +via the entry for the corresponding file descriptor in the process's +.ir /proc/[pid]/fdinfo +directory. +see +.br proc (5) +for further details. +.\" +.ss limitations +the signalfd mechanism can't be used to receive signals that +are synchronously generated, such as the +.br sigsegv +signal that results from accessing an invalid memory address +or the +.br sigfpe +signal that results from an arithmetic error. +such signals can be caught only via signal handler. +.pp +as described above, +in normal usage one blocks the signals that will be accepted via +.br signalfd (). +if spawning a child process to execute a helper program +(that does not need the signalfd file descriptor), +then, after the call to +.br fork (2), +you will normally want to unblock those signals before calling +.br execve (2), +so that the helper program can see any signals that it expects to see. +be aware, however, +that this won't be possible in the case of a helper program spawned +behind the scenes by any library function that the program may call. +in such cases, one must fall back to using a traditional signal +handler that writes to a file descriptor monitored by +.br select (2), +.br poll (2), +or +.br epoll (7). +.\" +.ss c library/kernel differences +the underlying linux system call requires an additional argument, +.ir "size_t sizemask" , +which specifies the size of the +.i mask +argument. +the glibc +.br signalfd () +wrapper function does not include this argument, +since it provides the required value for the underlying system call. +.pp +there are two underlying linux system calls: +.br signalfd () +and the more recent +.br signalfd4 (). +the former system call does not implement a +.i flags +argument. +the latter system call implements the +.i flags +values described above. +starting with glibc 2.9, the +.br signalfd () +wrapper function will use +.br signalfd4 () +where it is available. +.sh bugs +in kernels before 2.6.25, the +.i ssi_ptr +and +.i ssi_int +fields are not filled in with the data accompanying a signal sent by +.br sigqueue (3). +.\" the fix also was put into 2.6.24.5 +.sh examples +the program below accepts the signals +.b sigint +and +.b sigquit +via a signalfd file descriptor. +the program terminates after accepting a +.b sigquit +signal. +the following shell session demonstrates the use of the program: +.pp +.in +4n +.ex +.rb "$" " ./signalfd_demo" +.br "\(hac" " # control\-c generates sigint" +got sigint +.b \(hac +got sigint +\fb\(ha\e\fp # control\-\e generates sigquit +got sigquit +$ +.ee +.in +.ss program source +\& +.ex +#include +#include +#include +#include +#include + +#define handle_error(msg) \e + do { perror(msg); exit(exit_failure); } while (0) + +int +main(int argc, char *argv[]) +{ + sigset_t mask; + int sfd; + struct signalfd_siginfo fdsi; + ssize_t s; + + sigemptyset(&mask); + sigaddset(&mask, sigint); + sigaddset(&mask, sigquit); + + /* block signals so that they aren\(aqt handled + according to their default dispositions. */ + + if (sigprocmask(sig_block, &mask, null) == \-1) + handle_error("sigprocmask"); + + sfd = signalfd(\-1, &mask, 0); + if (sfd == \-1) + handle_error("signalfd"); + + for (;;) { + s = read(sfd, &fdsi, sizeof(fdsi)); + if (s != sizeof(fdsi)) + handle_error("read"); + + if (fdsi.ssi_signo == sigint) { + printf("got sigint\en"); + } else if (fdsi.ssi_signo == sigquit) { + printf("got sigquit\en"); + exit(exit_success); + } else { + printf("read unexpected signal\en"); + } + } +} +.ee +.sh see also +.br eventfd (2), +.br poll (2), +.br read (2), +.br select (2), +.br sigaction (2), +.br sigprocmask (2), +.br sigwaitinfo (2), +.br timerfd_create (2), +.br sigsetops (3), +.br sigwait (3), +.br epoll (7), +.br signal (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/byteorder.3 + +.\" copyright (c) 2016, ibm corporation. +.\" written by mike rapoport +.\" and copyright (c) 2016 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" +.th ioctl_userfaultfd 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +ioctl_userfaultfd \- create a file descriptor for handling page faults in user +space +.sh synopsis +.nf +.br "#include " " /* definition of " uffd* " constants */" +.b #include +.pp +.bi "int ioctl(int " fd ", int " cmd ", ...);" +.fi +.sh description +various +.br ioctl (2) +operations can be performed on a userfaultfd object (created by a call to +.br userfaultfd (2)) +using calls of the form: +.pp +.in +4n +.ex +ioctl(fd, cmd, argp); +.ee +.in +in the above, +.i fd +is a file descriptor referring to a userfaultfd object, +.i cmd +is one of the commands listed below, and +.i argp +is a pointer to a data structure that is specific to +.ir cmd . +.pp +the various +.br ioctl (2) +operations are described below. +the +.br uffdio_api , +.br uffdio_register , +and +.br uffdio_unregister +operations are used to +.i configure +userfaultfd behavior. +these operations allow the caller to choose what features will be enabled and +what kinds of events will be delivered to the application. +the remaining operations are +.ir range +operations. +these operations enable the calling application to resolve page-fault +events. +.\" +.ss uffdio_api +(since linux 4.3.) +enable operation of the userfaultfd and perform api handshake. +.pp +the +.i argp +argument is a pointer to a +.ir uffdio_api +structure, defined as: +.pp +.in +4n +.ex +struct uffdio_api { + __u64 api; /* requested api version (input) */ + __u64 features; /* requested features (input/output) */ + __u64 ioctls; /* available ioctl() operations (output) */ +}; +.ee +.in +.pp +the +.i api +field denotes the api version requested by the application. +.pp +the kernel verifies that it can support the requested api version, +and sets the +.i features +and +.i ioctls +fields to bit masks representing all the available features and the generic +.br ioctl (2) +operations available. +.pp +for linux kernel versions before 4.11, the +.i features +field must be initialized to zero before the call to +.br uffdio_api , +and zero (i.e., no feature bits) is placed in the +.i features +field by the kernel upon return from +.br ioctl (2). +.pp +starting from linux 4.11, the +.i features +field can be used to ask whether particular features are supported +and explicitly enable userfaultfd features that are disabled by default. +the kernel always reports all the available features in the +.i features +field. +.pp +to enable userfaultfd features the application should set +a bit corresponding to each feature it wants to enable in the +.i features +field. +if the kernel supports all the requested features it will enable them. +otherwise it will zero out the returned +.i uffdio_api +structure and return +.br einval . +.\" fixme add more details about feature negotiation and enablement +.pp +the following feature bits may be set: +.tp +.br uffd_feature_event_fork " (since linux 4.11)" +when this feature is enabled, +the userfaultfd objects associated with a parent process are duplicated +into the child process during +.br fork (2) +and a +.b uffd_event_fork +event is delivered to the userfaultfd monitor +.tp +.br uffd_feature_event_remap " (since linux 4.11)" +if this feature is enabled, +when the faulting process invokes +.br mremap (2), +the userfaultfd monitor will receive an event of type +.br uffd_event_remap . +.tp +.br uffd_feature_event_remove " (since linux 4.11)" +if this feature is enabled, +when the faulting process calls +.br madvise (2) +with the +.b madv_dontneed +or +.b madv_remove +advice value to free a virtual memory area +the userfaultfd monitor will receive an event of type +.br uffd_event_remove . +.tp +.br uffd_feature_event_unmap " (since linux 4.11)" +if this feature is enabled, +when the faulting process unmaps virtual memory either explicitly with +.br munmap (2), +or implicitly during either +.br mmap (2) +or +.br mremap (2), +the userfaultfd monitor will receive an event of type +.br uffd_event_unmap . +.tp +.br uffd_feature_missing_hugetlbfs " (since linux 4.11)" +if this feature bit is set, +the kernel supports registering userfaultfd ranges on hugetlbfs +virtual memory areas +.tp +.br uffd_feature_missing_shmem " (since linux 4.11)" +if this feature bit is set, +the kernel supports registering userfaultfd ranges on shared memory areas. +this includes all kernel shared memory apis: +system v shared memory, +.br tmpfs (5), +shared mappings of +.ir /dev/zero , +.br mmap (2) +with the +.b map_shared +flag set, +.br memfd_create (2), +and so on. +.tp +.br uffd_feature_sigbus " (since linux 4.14)" +.\" commit 2d6d6f5a09a96cc1fec7ed992b825e05f64cb50e +if this feature bit is set, no page-fault events +.rb ( uffd_event_pagefault ) +will be delivered. +instead, a +.b sigbus +signal will be sent to the faulting process. +applications using this +feature will not require the use of a userfaultfd monitor for processing +memory accesses to the regions registered with userfaultfd. +.tp +.br uffd_feature_thread_id " (since linux 4.14)" +if this feature bit is set, +.i uffd_msg.pagefault.feat.ptid +will be set to the faulted thread id for each page-fault message. +.pp +the returned +.i ioctls +field can contain the following bits: +.\" fixme this user-space api seems not fully polished. why are there +.\" not constants defined for each of the bit-mask values listed below? +.tp +.b 1 << _uffdio_api +the +.b uffdio_api +operation is supported. +.tp +.b 1 << _uffdio_register +the +.b uffdio_register +operation is supported. +.tp +.b 1 << _uffdio_unregister +the +.b uffdio_unregister +operation is supported. +.tp +.b 1 << _uffdio_writeprotect +the +.b uffdio_writeprotect +operation is supported. +.pp +this +.br ioctl (2) +operation returns 0 on success. +on error, \-1 is returned and +.i errno +is set to indicate the error. +possible errors include: +.tp +.b efault +.i argp +refers to an address that is outside the calling process's +accessible address space. +.tp +.b einval +the userfaultfd has already been enabled by a previous +.br uffdio_api +operation. +.tp +.b einval +the api version requested in the +.i api +field is not supported by this kernel, or the +.i features +field passed to the kernel includes feature bits that are not supported +by the current kernel version. +.\" fixme in the above error case, the returned 'uffdio_api' structure is +.\" zeroed out. why is this done? this should be explained in the manual page. +.\" +.\" mike rapoport: +.\" in my understanding the uffdio_api +.\" structure is zeroed to allow the caller +.\" to distinguish the reasons for -einval. +.\" +.ss uffdio_register +(since linux 4.3.) +register a memory address range with the userfaultfd object. +the pages in the range must be "compatible". +.pp +up to linux kernel 4.11, +only private anonymous ranges are compatible for registering with +.br uffdio_register . +.pp +since linux 4.11, +hugetlbfs and shared memory ranges are also compatible with +.br uffdio_register . +.pp +the +.i argp +argument is a pointer to a +.i uffdio_register +structure, defined as: +.pp +.in +4n +.ex +struct uffdio_range { + __u64 start; /* start of range */ + __u64 len; /* length of range (bytes) */ +}; + +struct uffdio_register { + struct uffdio_range range; + __u64 mode; /* desired mode of operation (input) */ + __u64 ioctls; /* available ioctl() operations (output) */ +}; +.ee +.in +.pp +the +.i range +field defines a memory range starting at +.i start +and continuing for +.i len +bytes that should be handled by the userfaultfd. +.pp +the +.i mode +field defines the mode of operation desired for this memory region. +the following values may be bitwise ored to set the userfaultfd mode for +the specified range: +.tp +.b uffdio_register_mode_missing +track page faults on missing pages. +.tp +.b uffdio_register_mode_wp +track page faults on write-protected pages. +.pp +if the operation is successful, the kernel modifies the +.i ioctls +bit-mask field to indicate which +.br ioctl (2) +operations are available for the specified range. +this returned bit mask is as for +.br uffdio_api . +.pp +this +.br ioctl (2) +operation returns 0 on success. +on error, \-1 is returned and +.i errno +is set to indicate the error. +possible errors include: +.\" fixme is the following error list correct? +.\" +.tp +.b ebusy +a mapping in the specified range is registered with another +userfaultfd object. +.tp +.b efault +.i argp +refers to an address that is outside the calling process's +accessible address space. +.tp +.b einval +an invalid or unsupported bit was specified in the +.i mode +field; or the +.i mode +field was zero. +.tp +.b einval +there is no mapping in the specified address range. +.tp +.b einval +.i range.start +or +.i range.len +is not a multiple of the system page size; or, +.i range.len +is zero; or these fields are otherwise invalid. +.tp +.b einval +there as an incompatible mapping in the specified address range. +.\" mike rapoport: +.\" enomem if the process is exiting and the +.\" mm_struct has gone by the time userfault grabs it. +.ss uffdio_unregister +(since linux 4.3.) +unregister a memory address range from userfaultfd. +the pages in the range must be "compatible" (see the description of +.br uffdio_register .) +.pp +the address range to unregister is specified in the +.ir uffdio_range +structure pointed to by +.ir argp . +.pp +this +.br ioctl (2) +operation returns 0 on success. +on error, \-1 is returned and +.i errno +is set to indicate the error. +possible errors include: +.tp +.b einval +either the +.i start +or the +.i len +field of the +.i ufdio_range +structure was not a multiple of the system page size; or the +.i len +field was zero; or these fields were otherwise invalid. +.tp +.b einval +there as an incompatible mapping in the specified address range. +.tp +.b einval +there was no mapping in the specified address range. +.\" +.ss uffdio_copy +(since linux 4.3.) +atomically copy a continuous memory chunk into the userfault registered +range and optionally wake up the blocked thread. +the source and destination addresses and the number of bytes to copy are +specified by the +.ir src ", " dst ", and " len +fields of the +.i uffdio_copy +structure pointed to by +.ir argp : +.pp +.in +4n +.ex +struct uffdio_copy { + __u64 dst; /* destination of copy */ + __u64 src; /* source of copy */ + __u64 len; /* number of bytes to copy */ + __u64 mode; /* flags controlling behavior of copy */ + __s64 copy; /* number of bytes copied, or negated error */ +}; +.ee +.in +.pp +the following value may be bitwise ored in +.ir mode +to change the behavior of the +.b uffdio_copy +operation: +.tp +.b uffdio_copy_mode_dontwake +do not wake up the thread that waits for page-fault resolution +.tp +.b uffdio_copy_mode_wp +copy the page with read-only permission. +this allows the user to trap the next write to the page, +which will block and generate another write-protect userfault message. +this is used only when both +.b uffdio_register_mode_missing +and +.b uffdio_register_mode_wp +modes are enabled for the registered range. +.pp +the +.i copy +field is used by the kernel to return the number of bytes +that was actually copied, or an error (a negated +.ir errno -style +value). +.\" fixme above: why is the 'copy' field used to return error values? +.\" this should be explained in the manual page. +if the value returned in +.i copy +doesn't match the value that was specified in +.ir len , +the operation fails with the error +.br eagain . +the +.i copy +field is output-only; +it is not read by the +.b uffdio_copy +operation. +.pp +this +.br ioctl (2) +operation returns 0 on success. +in this case, the entire area was copied. +on error, \-1 is returned and +.i errno +is set to indicate the error. +possible errors include: +.tp +.b eagain +the number of bytes copied (i.e., the value returned in the +.i copy +field) +does not equal the value that was specified in the +.i len +field. +.tp +.b einval +either +.i dst +or +.i len +was not a multiple of the system page size, or the range specified by +.ir src +and +.ir len +or +.ir dst +and +.ir len +was invalid. +.tp +.b einval +an invalid bit was specified in the +.ir mode +field. +.tp +.br enoent " (since linux 4.11)" +the faulting process has changed +its virtual memory layout simultaneously with an outstanding +.b uffdio_copy +operation. +.tp +.br enospc " (from linux 4.11 until linux 4.13)" +the faulting process has exited at the time of a +.b uffdio_copy +operation. +.tp +.br esrch " (since linux 4.13)" +the faulting process has exited at the time of a +.b uffdio_copy +operation. +.\" +.ss uffdio_zeropage +(since linux 4.3.) +zero out a memory range registered with userfaultfd. +.pp +the requested range is specified by the +.i range +field of the +.i uffdio_zeropage +structure pointed to by +.ir argp : +.pp +.in +4n +.ex +struct uffdio_zeropage { + struct uffdio_range range; + __u64 mode; /* flags controlling behavior of copy */ + __s64 zeropage; /* number of bytes zeroed, or negated error */ +}; +.ee +.in +.pp +the following value may be bitwise ored in +.ir mode +to change the behavior of the +.b uffdio_zeropage +operation: +.tp +.b uffdio_zeropage_mode_dontwake +do not wake up the thread that waits for page-fault resolution. +.pp +the +.i zeropage +field is used by the kernel to return the number of bytes +that was actually zeroed, +or an error in the same manner as +.br uffdio_copy . +.\" fixme why is the 'zeropage' field used to return error values? +.\" this should be explained in the manual page. +if the value returned in the +.i zeropage +field doesn't match the value that was specified in +.ir range.len , +the operation fails with the error +.br eagain . +the +.i zeropage +field is output-only; +it is not read by the +.b uffdio_zeropage +operation. +.pp +this +.br ioctl (2) +operation returns 0 on success. +in this case, the entire area was zeroed. +on error, \-1 is returned and +.i errno +is set to indicate the error. +possible errors include: +.tp +.b eagain +the number of bytes zeroed (i.e., the value returned in the +.i zeropage +field) +does not equal the value that was specified in the +.i range.len +field. +.tp +.b einval +either +.i range.start +or +.i range.len +was not a multiple of the system page size; or +.i range.len +was zero; or the range specified was invalid. +.tp +.b einval +an invalid bit was specified in the +.ir mode +field. +.tp +.br esrch " (since linux 4.13)" +the faulting process has exited at the time of a +.b uffdio_zeropage +operation. +.\" +.ss uffdio_wake +(since linux 4.3.) +wake up the thread waiting for page-fault resolution on +a specified memory address range. +.pp +the +.b uffdio_wake +operation is used in conjunction with +.br uffdio_copy +and +.br uffdio_zeropage +operations that have the +.br uffdio_copy_mode_dontwake +or +.br uffdio_zeropage_mode_dontwake +bit set in the +.i mode +field. +the userfault monitor can perform several +.br uffdio_copy +and +.br uffdio_zeropage +operations in a batch and then explicitly wake up the faulting thread using +.br uffdio_wake . +.pp +the +.i argp +argument is a pointer to a +.i uffdio_range +structure (shown above) that specifies the address range. +.pp +this +.br ioctl (2) +operation returns 0 on success. +on error, \-1 is returned and +.i errno +is set to indicate the error. +possible errors include: +.tp +.b einval +the +.i start +or the +.i len +field of the +.i ufdio_range +structure was not a multiple of the system page size; or +.i len +was zero; or the specified range was otherwise invalid. +.ss uffdio_writeprotect (since linux 5.7) +write-protect or write-unprotect a userfaultfd-registered memory range +registered with mode +.br uffdio_register_mode_wp . +.pp +the +.i argp +argument is a pointer to a +.i uffdio_range +structure as shown below: +.pp +.in +4n +.ex +struct uffdio_writeprotect { + struct uffdio_range range; /* range to change write permission*/ + __u64 mode; /* mode to change write permission */ +}; +.ee +.in +.pp +there are two mode bits that are supported in this structure: +.tp +.b uffdio_writeprotect_mode_wp +when this mode bit is set, +the ioctl will be a write-protect operation upon the memory range specified by +.ir range . +otherwise it will be a write-unprotect operation upon the specified range, +which can be used to resolve a userfaultfd write-protect page fault. +.tp +.b uffdio_writeprotect_mode_dontwake +when this mode bit is set, +do not wake up any thread that waits for +page-fault resolution after the operation. +this can be specified only if +.b uffdio_writeprotect_mode_wp +is not specified. +.pp +this +.br ioctl (2) +operation returns 0 on success. +on error, \-1 is returned and +.i errno +is set to indicate the error. +possible errors include: +.tp +.b einval +the +.i start +or the +.i len +field of the +.i ufdio_range +structure was not a multiple of the system page size; or +.i len +was zero; or the specified range was otherwise invalid. +.tp +.b eagain +the process was interrupted; retry this call. +.tp +.b enoent +the range specified in +.i range +is not valid. +for example, the virtual address does not exist, +or not registered with userfaultfd write-protect mode. +.tp +.b efault +encountered a generic fault during processing. +.sh return value +see descriptions of the individual operations, above. +.sh errors +see descriptions of the individual operations, above. +in addition, the following general errors can occur for all of the +operations described above: +.tp +.b efault +.i argp +does not point to a valid memory address. +.tp +.b einval +(for all operations except +.br uffdio_api .) +the userfaultfd object has not yet been enabled (via the +.br uffdio_api +operation). +.sh conforming to +these +.br ioctl (2) +operations are linux-specific. +.sh bugs +in order to detect available userfault features and +enable some subset of those features +the userfaultfd file descriptor must be closed after the first +.br uffdio_api +operation that queries features availability and reopened before +the second +.br uffdio_api +operation that actually enables the desired features. +.sh examples +see +.br userfaultfd (2). +.sh see also +.br ioctl (2), +.br mmap (2), +.br userfaultfd (2) +.pp +.ir documentation/admin\-guide/mm/userfaultfd.rst +in the linux kernel source tree +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c), 1995, graeme w. wilford. (wilf.) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" wed jun 14 16:10:28 bst 1995 wilf. (g.wilford@ee.surrey.ac.uk) +.\" tiny change in formatting - aeb, 950812 +.\" modified 8 may 1998 by joseph s. myers (jsm28@cam.ac.uk) +.\" +.\" show the synopsis section nicely +.th regex 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +regcomp, regexec, regerror, regfree \- posix regex functions +.sh synopsis +.nf +.b #include +.pp +.bi "int regcomp(regex_t *restrict " preg ", const char *restrict " regex , +.bi " int " cflags ); +.bi "int regexec(const regex_t *restrict " preg \ +", const char *restrict " string , +.bi " size_t " nmatch ", regmatch_t " pmatch "[restrict]\ +, int " eflags ); +.pp +.bi "size_t regerror(int " errcode ", const regex_t *restrict " preg , +.bi " char *restrict " errbuf ", size_t " errbuf_size ); +.bi "void regfree(regex_t *" preg ); +.fi +.sh description +.ss posix regex compiling +.br regcomp () +is used to compile a regular expression into a form that is suitable +for subsequent +.br regexec () +searches. +.pp +.br regcomp () +is supplied with +.ir preg , +a pointer to a pattern buffer storage area; +.ir regex , +a pointer to the null-terminated string and +.ir cflags , +flags used to determine the type of compilation. +.pp +all regular expression searching must be done via a compiled pattern +buffer, thus +.br regexec () +must always be supplied with the address of a +.br regcomp ()-initialized +pattern buffer. +.pp +.i cflags +is the +.rb bitwise- or +of zero or more of the following: +.tp +.b reg_extended +use +.b posix +extended regular expression syntax when interpreting +.ir regex . +if not set, +.b posix +basic regular expression syntax is used. +.tp +.b reg_icase +do not differentiate case. +subsequent +.br regexec () +searches using this pattern buffer will be case insensitive. +.tp +.b reg_nosub +do not report position of matches. +the +.i nmatch +and +.i pmatch +arguments to +.br regexec () +are ignored if the pattern buffer supplied was compiled with this flag set. +.tp +.b reg_newline +match-any-character operators don't match a newline. +.ip +a nonmatching list +.rb ( [\(ha...] ) +not containing a newline does not match a newline. +.ip +match-beginning-of-line operator +.rb ( \(ha ) +matches the empty string immediately after a newline, regardless of +whether +.ir eflags , +the execution flags of +.br regexec (), +contains +.br reg_notbol . +.ip +match-end-of-line operator +.rb ( $ ) +matches the empty string immediately before a newline, regardless of +whether +.i eflags +contains +.br reg_noteol . +.ss posix regex matching +.br regexec () +is used to match a null-terminated string +against the precompiled pattern buffer, +.ir preg . +.i nmatch +and +.i pmatch +are used to provide information regarding the location of any matches. +.i eflags +is the +.rb bitwise- or +of zero or more of the following flags: +.tp +.b reg_notbol +the match-beginning-of-line operator always fails to match (but see the +compilation flag +.b reg_newline +above). +this flag may be used when different portions of a string are passed to +.br regexec () +and the beginning of the string should not be interpreted as the +beginning of the line. +.tp +.b reg_noteol +the match-end-of-line operator always fails to match (but see the +compilation flag +.b reg_newline +above). +.tp +.b reg_startend +use +.i pmatch[0] +on the input string, starting at byte +.i pmatch[0].rm_so +and ending before byte +.ir pmatch[0].rm_eo . +this allows matching embedded nul bytes +and avoids a +.br strlen (3) +on large strings. +it does not use +.i nmatch +on input, and does not change +.b reg_notbol +or +.b reg_newline +processing. +this flag is a bsd extension, not present in posix. +.ss byte offsets +unless +.b reg_nosub +was set for the compilation of the pattern buffer, it is possible to +obtain match addressing information. +.i pmatch +must be dimensioned to have at least +.i nmatch +elements. +these are filled in by +.br regexec () +with substring match addresses. +the offsets of the subexpression starting at the +.ir i th +open parenthesis are stored in +.ir pmatch[i] . +the entire regular expression's match addresses are stored in +.ir pmatch[0] . +(note that to return the offsets of +.i n +subexpression matches, +.i nmatch +must be at least +.ir n+1 .) +any unused structure elements will contain the value \-1. +.pp +the +.i regmatch_t +structure which is the type of +.i pmatch +is defined in +.ir . +.pp +.in +4n +.ex +typedef struct { + regoff_t rm_so; + regoff_t rm_eo; +} regmatch_t; +.ee +.in +.pp +each +.i rm_so +element that is not \-1 indicates the start offset of the next largest +substring match within the string. +the relative +.i rm_eo +element indicates the end offset of the match, +which is the offset of the first character after the matching text. +.ss posix error reporting +.br regerror () +is used to turn the error codes that can be returned by both +.br regcomp () +and +.br regexec () +into error message strings. +.pp +.br regerror () +is passed the error code, +.ir errcode , +the pattern buffer, +.ir preg , +a pointer to a character string buffer, +.ir errbuf , +and the size of the string buffer, +.ir errbuf_size . +it returns the size of the +.i errbuf +required to contain the null-terminated error message string. +if both +.i errbuf +and +.i errbuf_size +are nonzero, +.i errbuf +is filled in with the first +.i "errbuf_size \- 1" +characters of the error message and a terminating null byte (\(aq\e0\(aq). +.ss posix pattern buffer freeing +supplying +.br regfree () +with a precompiled pattern buffer, +.i preg +will free the memory allocated to the pattern buffer by the compiling +process, +.br regcomp (). +.sh return value +.br regcomp () +returns zero for a successful compilation or an error code for failure. +.pp +.br regexec () +returns zero for a successful match or +.b reg_nomatch +for failure. +.sh errors +the following errors can be returned by +.br regcomp (): +.tp +.b reg_badbr +invalid use of back reference operator. +.tp +.b reg_badpat +invalid use of pattern operators such as group or list. +.tp +.b reg_badrpt +invalid use of repetition operators such as using \(aq*\(aq +as the first character. +.tp +.b reg_ebrace +un-matched brace interval operators. +.tp +.b reg_ebrack +un-matched bracket list operators. +.tp +.b reg_ecollate +invalid collating element. +.tp +.b reg_ectype +unknown character class name. +.tp +.b reg_eend +nonspecific error. +this is not defined by posix.2. +.tp +.b reg_eescape +trailing backslash. +.tp +.b reg_eparen +un-matched parenthesis group operators. +.tp +.b reg_erange +invalid use of the range operator; for example, the ending point of the range +occurs prior to the starting point. +.tp +.b reg_esize +compiled regular expression requires a pattern buffer larger than 64\ kb. +this is not defined by posix.2. +.tp +.b reg_espace +the regex routines ran out of memory. +.tp +.b reg_esubreg +invalid back reference to a subexpression. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br regcomp (), +.br regexec () +t} thread safety mt-safe locale +t{ +.br regerror () +t} thread safety mt-safe env +t{ +.br regfree () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh examples +.ex +#include +#include +#include +#include + +#define array_size(arr) (sizeof((arr)) / sizeof((arr)[0])) + +static const char *const str = + "1) john driverhacker;\en2) john doe;\en3) john foo;\en"; +static const char *const re = "john.*o"; + +int main(void) +{ + static const char *s = str; + regex_t regex; + regmatch_t pmatch[1]; + regoff_t off, len; + + if (regcomp(®ex, re, reg_newline)) + exit(exit_failure); + + printf("string = \e"%s\e"\en", str); + printf("matches:\en"); + + for (int i = 0; ; i++) { + if (regexec(®ex, s, array_size(pmatch), pmatch, 0)) + break; + + off = pmatch[0].rm_so + (s \- str); + len = pmatch[0].rm_eo \- pmatch[0].rm_so; + printf("#%d:\en", i); + printf("offset = %jd; length = %jd\en", (intmax_t) off, + (intmax_t) len); + printf("substring = \e"%.*s\e"\en", len, s + pmatch[0].rm_so); + + s += pmatch[0].rm_eo; + } + + exit(exit_success); +} +.ee +.sh see also +.br grep (1), +.br regex (7) +.pp +the glibc manual section, +.i "regular expressions" +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/unlocked_stdio.3 + +.so man3/rpc.3 + +.\" copyright 2015-2017 mathieu desnoyers +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th membarrier 2 2021-08-27 "linux" "linux programmer's manual" +.sh name +membarrier \- issue memory barriers on a set of threads +.sh synopsis +.nf +.pp +.br "#include " \ +" /* definition of " membarrier_* " constants */" +.br "#include " " /* definition of " sys_* " constants */" +.b #include +.pp +.bi "int syscall(sys_membarrier, int " cmd ", unsigned int " flags \ +", int " cpu_id ); +.fi +.pp +.ir note : +glibc provides no wrapper for +.br membarrier (), +necessitating the use of +.br syscall (2). +.sh description +the +.br membarrier () +system call helps reducing the overhead of the memory barrier +instructions required to order memory accesses on multi-core systems. +however, this system call is heavier than a memory barrier, so using it +effectively is +.i not +as simple as replacing memory barriers with this +system call, but requires understanding of the details below. +.pp +use of memory barriers needs to be done taking into account that a +memory barrier always needs to be either matched with its memory barrier +counterparts, or that the architecture's memory model doesn't require the +matching barriers. +.pp +there are cases where one side of the matching barriers (which we will +refer to as "fast side") is executed much more often than the other +(which we will refer to as "slow side"). +this is a prime target for the use of +.br membarrier (). +the key idea is to replace, for these matching +barriers, the fast-side memory barriers by simple compiler barriers, +for example: +.pp +.in +4n +.ex +asm volatile ("" : : : "memory") +.ee +.in +.pp +and replace the slow-side memory barriers by calls to +.br membarrier (). +.pp +this will add overhead to the slow side, and remove overhead from the +fast side, thus resulting in an overall performance increase as long as +the slow side is infrequent enough that the overhead of the +.br membarrier () +calls does not outweigh the performance gain on the fast side. +.pp +the +.i cmd +argument is one of the following: +.tp +.br membarrier_cmd_query " (since linux 4.3)" +query the set of supported commands. +the return value of the call is a bit mask of supported +commands. +.br membarrier_cmd_query , +which has the value 0, +is not itself included in this bit mask. +this command is always supported (on kernels where +.br membarrier () +is provided). +.tp +.br membarrier_cmd_global " (since linux 4.16)" +ensure that all threads from all processes on the system pass through a +state where all memory accesses to user-space addresses match program +order between entry to and return from the +.br membarrier () +system call. +all threads on the system are targeted by this command. +.tp +.br membarrier_cmd_global_expedited " (since linux 4.16)" +execute a memory barrier on all running threads of all processes that +previously registered with +.br membarrier_cmd_register_global_expedited . +.ip +upon return from the system call, the calling thread has a guarantee that all +running threads have passed through a state where all memory accesses to +user-space addresses match program order between entry to and return +from the system call (non-running threads are de facto in such a state). +this guarantee is provided only for the threads of processes that +previously registered with +.br membarrier_cmd_register_global_expedited . +.ip +given that registration is about the intent to receive the barriers, it +is valid to invoke +.br membarrier_cmd_global_expedited +from a process that has not employed +.br membarrier_cmd_register_global_expedited . +.ip +the "expedited" commands complete faster than the non-expedited ones; +they never block, but have the downside of causing extra overhead. +.tp +.br membarrier_cmd_register_global_expedited " (since linux 4.16)" +register the process's intent to receive +.br membarrier_cmd_global_expedited +memory barriers. +.tp +.br membarrier_cmd_private_expedited " (since linux 4.14)" +execute a memory barrier on each running thread belonging to the same +process as the calling thread. +.ip +upon return from the system call, the calling +thread has a guarantee that all its running thread siblings have passed +through a state where all memory accesses to user-space addresses match +program order between entry to and return from the system call +(non-running threads are de facto in such a state). +this guarantee is provided only for threads in +the same process as the calling thread. +.ip +the "expedited" commands complete faster than the non-expedited ones; +they never block, but have the downside of causing extra overhead. +.ip +a process must register its intent to use the private +expedited command prior to using it. +.tp +.br membarrier_cmd_register_private_expedited " (since linux 4.14)" +register the process's intent to use +.br membarrier_cmd_private_expedited . +.tp +.br membarrier_cmd_private_expedited_sync_core " (since linux 4.16)" +in addition to providing the memory ordering guarantees described in +.br membarrier_cmd_private_expedited , +upon return from system call the calling thread has a guarantee that all its +running thread siblings have executed a core serializing instruction. +this guarantee is provided only for threads in +the same process as the calling thread. +.ip +the "expedited" commands complete faster than the non-expedited ones, +they never block, but have the downside of causing extra overhead. +.ip +a process must register its intent to use the private expedited sync +core command prior to using it. +.tp +.br membarrier_cmd_register_private_expedited_sync_core " (since linux 4.16)" +register the process's intent to use +.br membarrier_cmd_private_expedited_sync_core . +.tp +.br membarrier_cmd_private_expedited_rseq " (since linux 5.10)" +ensure the caller thread, upon return from system call, that all its +running thread siblings have any currently running rseq critical sections +restarted if +.i flags +parameter is 0; if +.i flags +parameter is +.br membarrier_cmd_flag_cpu , +then this operation is performed only on cpu indicated by +.ir cpu_id . +this guarantee is provided only for threads in +the same process as the calling thread. +.ip +rseq membarrier is only available in the "private expedited" form. +.ip +a process must register its intent to use the private expedited rseq +command prior to using it. +.tp +.br membarrier_cmd_register_private_expedited_rseq " (since linux 5.10)" +register the process's intent to use +.br membarrier_cmd_private_expedited_rseq . +.tp +.br membarrier_cmd_shared " (since linux 4.3)" +this is an alias for +.br membarrier_cmd_global +that exists for header backward compatibility. +.pp +the +.i flags +argument must be specified as 0 unless the command is +.br membarrier_cmd_private_expedited_rseq , +in which case +.i flags +can be either 0 or +.br membarrier_cmd_flag_cpu . +.pp +the +.i cpu_id +argument is ignored unless +.i flags +is +.br membarrier_cmd_flag_cpu , +in which case it must specify the cpu targeted by this membarrier +command. +.pp +all memory accesses performed in program order from each targeted thread +are guaranteed to be ordered with respect to +.br membarrier (). +.pp +if we use the semantic +.i barrier() +to represent a compiler barrier forcing memory +accesses to be performed in program order across the barrier, and +.i smp_mb() +to represent explicit memory barriers forcing full memory +ordering across the barrier, we have the following ordering table for +each pairing of +.ir barrier() , +.br membarrier (), +and +.ir smp_mb() . +the pair ordering is detailed as (o: ordered, x: not ordered): +.pp + barrier() smp_mb() membarrier() + barrier() x x o + smp_mb() x o o + membarrier() o o o +.sh return value +on success, the +.b membarrier_cmd_query +operation returns a bit mask of supported commands, and the +.br membarrier_cmd_global , +.br membarrier_cmd_global_expedited , +.br membarrier_cmd_register_global_expedited , +.br membarrier_cmd_private_expedited , +.br membarrier_cmd_register_private_expedited , +.br membarrier_cmd_private_expedited_sync_core , +and +.b membarrier_cmd_register_private_expedited_sync_core +operations return zero. +on error, \-1 is returned, +and +.i errno +is set to indicate the error. +.pp +for a given command, with +.i flags +set to 0, this system call is +guaranteed to always return the same value until reboot. +further calls with the same arguments will lead to the same result. +therefore, with +.i flags +set to 0, error handling is required only for the first call to +.br membarrier (). +.sh errors +.tp +.b einval +.i cmd +is invalid, or +.i flags +is nonzero, or the +.br membarrier_cmd_global +command is disabled because the +.i nohz_full +cpu parameter has been set, or the +.br membarrier_cmd_private_expedited_sync_core +and +.br membarrier_cmd_register_private_expedited_sync_core +commands are not implemented by the architecture. +.tp +.b enosys +the +.br membarrier () +system call is not implemented by this kernel. +.tp +.b eperm +the current process was not registered prior to using private expedited +commands. +.sh versions +the +.br membarrier () +system call was added in linux 4.3. +.pp +before linux 5.10, the prototype for +.br membarrier () +was: +.pp +.in +4n +.ex +.bi "int membarrier(int " cmd ", int " flags ); +.ee +.in +.sh conforming to +.br membarrier () +is linux-specific. +.\" .sh see also +.\" fixme see if the following syscalls make it into linux 4.15 or later +.\" .br cpu_opv (2), +.\" .br rseq (2) +.sh notes +a memory barrier instruction is part of the instruction set of +architectures with weakly ordered memory models. +it orders memory +accesses prior to the barrier and after the barrier with respect to +matching barriers on other cores. +for instance, a load fence can order +loads prior to and following that fence with respect to stores ordered +by store fences. +.pp +program order is the order in which instructions are ordered in the +program assembly code. +.pp +examples where +.br membarrier () +can be useful include implementations +of read-copy-update libraries and garbage collectors. +.sh examples +assuming a multithreaded application where "fast_path()" is executed +very frequently, and where "slow_path()" is executed infrequently, the +following code (x86) can be transformed using +.br membarrier (): +.pp +.in +4n +.ex +#include + +static volatile int a, b; + +static void +fast_path(int *read_b) +{ + a = 1; + asm volatile ("mfence" : : : "memory"); + *read_b = b; +} + +static void +slow_path(int *read_a) +{ + b = 1; + asm volatile ("mfence" : : : "memory"); + *read_a = a; +} + +int +main(int argc, char *argv[]) +{ + int read_a, read_b; + + /* + * real applications would call fast_path() and slow_path() + * from different threads. call those from main() to keep + * this example short. + */ + + slow_path(&read_a); + fast_path(&read_b); + + /* + * read_b == 0 implies read_a == 1 and + * read_a == 0 implies read_b == 1. + */ + + if (read_b == 0 && read_a == 0) + abort(); + + exit(exit_success); +} +.ee +.in +.pp +the code above transformed to use +.br membarrier () +becomes: +.pp +.in +4n +.ex +#define _gnu_source +#include +#include +#include +#include +#include + +static volatile int a, b; + +static int +membarrier(int cmd, unsigned int flags, int cpu_id) +{ + return syscall(__nr_membarrier, cmd, flags, cpu_id); +} + +static int +init_membarrier(void) +{ + int ret; + + /* check that membarrier() is supported. */ + + ret = membarrier(membarrier_cmd_query, 0, 0); + if (ret < 0) { + perror("membarrier"); + return \-1; + } + + if (!(ret & membarrier_cmd_global)) { + fprintf(stderr, + "membarrier does not support membarrier_cmd_global\en"); + return \-1; + } + + return 0; +} + +static void +fast_path(int *read_b) +{ + a = 1; + asm volatile ("" : : : "memory"); + *read_b = b; +} + +static void +slow_path(int *read_a) +{ + b = 1; + membarrier(membarrier_cmd_global, 0, 0); + *read_a = a; +} + +int +main(int argc, char *argv[]) +{ + int read_a, read_b; + + if (init_membarrier()) + exit(exit_failure); + + /* + * real applications would call fast_path() and slow_path() + * from different threads. call those from main() to keep + * this example short. + */ + + slow_path(&read_a); + fast_path(&read_b); + + /* + * read_b == 0 implies read_a == 1 and + * read_a == 0 implies read_b == 1. + */ + + if (read_b == 0 && read_a == 0) + abort(); + + exit(exit_success); +} +.ee +.in +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/list.3 + +.\" copyright (c) 1993 +.\" the regents of the university of california. all rights reserved. +.\" and copyright (c) 2020 by alejandro colomar +.\" +.\" %%%license_start(bsd_3_clause_ucb) +.\" redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. neither the name of the university nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" this software is provided by the regents and contributors ``as is'' and +.\" any express or implied warranties, including, but not limited to, the +.\" implied warranties of merchantability and fitness for a particular purpose +.\" are disclaimed. in no event shall the regents or contributors be liable +.\" for any direct, indirect, incidental, special, exemplary, or consequential +.\" damages (including, but not limited to, procurement of substitute goods +.\" or services; loss of use, data, or profits; or business interruption) +.\" however caused and on any theory of liability, whether in contract, strict +.\" liability, or tort (including negligence or otherwise) arising in any way +.\" out of the use of this software, even if advised of the possibility of +.\" such damage. +.\" %%%license_end +.\" +.\" +.th stailq 3 2021-08-27 "gnu" "linux programmer's manual" +.sh name +.\"simpleq_concat, +simpleq_empty, +simpleq_entry, +simpleq_first, +simpleq_foreach, +.\"simpleq_foreach_from, +.\"simpleq_foreach_from_safe, +.\"simpleq_foreach_safe, +simpleq_head, +simpleq_head_initializer, +simpleq_init, +simpleq_insert_after, +simpleq_insert_head, +simpleq_insert_tail, +.\"simpleq_last, +simpleq_next, +simpleq_remove, +.\"simpleq_remove_after, +simpleq_remove_head, +.\"simpleq_swap, +stailq_concat, +stailq_empty, +stailq_entry, +stailq_first, +stailq_foreach, +.\"stailq_foreach_from, +.\"stailq_foreach_from_safe, +.\"stailq_foreach_safe, +stailq_head, +stailq_head_initializer, +stailq_init, +stailq_insert_after, +stailq_insert_head, +stailq_insert_tail, +.\"stailq_last, +stailq_next, +stailq_remove, +.\"stailq_remove_after, +stailq_remove_head, +.\"stailq_swap +\- implementation of a singly linked tail queue +.sh synopsis +.nf +.b #include +.pp +.b stailq_entry(type); +.pp +.b stailq_head(headname, type); +.bi "stailq_head stailq_head_initializer(stailq_head " head ); +.bi "void stailq_init(stailq_head *" head ); +.pp +.bi "int stailq_empty(stailq_head *" head ); +.pp +.bi "void stailq_insert_head(stailq_head *" head , +.bi " struct type *" elm ", stailq_entry " name ); +.bi "void stailq_insert_tail(stailq_head *" head , +.bi " struct type *" elm ", stailq_entry " name ); +.bi "void stailq_insert_after(stailq_head *" head ", struct type *" listelm , +.bi " struct type *" elm ", stailq_entry " name ); +.pp +.bi "struct type *stailq_first(stailq_head *" head ); +.\" .bi "struct type *stailq_last(stailq_head *" head ", struct type *" elm , +.\" .bi " stailq_entry " name ); +.bi "struct type *stailq_next(struct type *" elm ", stailq_entry " name ); +.pp +.bi "stailq_foreach(struct type *" var ", stailq_head *" head ", stailq_entry " name ); +.\" .bi "stailq_foreach_from(struct type *" var ", stailq_head *" head , +.\" .bi " stailq_entry " name ); +.\" .pp +.\" .bi "stailq_foreach_safe(struct type *" var ", stailq_head *" head , +.\" .bi " stailq_entry " name ", struct type *" temp_var ); +.\" .bi "stailq_foreach_from_safe(struct type *" var ", stailq_head *" head , +.\" .bi " stailq_entry " name ", struct type *" temp_var ); +.pp +.bi "void stailq_remove(stailq_head *" head ", struct type *" elm ", type," +.bi " stailq_entry " name ); +.bi "void stailq_remove_head(stailq_head *" head , +.bi " stailq_entry " name ); +.\" .bi "void stailq_remove_after(stailq_head *" head ", struct type *" elm , +.\" .bi " stailq_entry " name ); +.pp +.bi "void stailq_concat(stailq_head *" head1 ", stailq_head *" head2 ); +.\" .bi "void stailq_swap(stailq_head *" head1 ", stailq_head *" head2 , +.\" .bi " stailq_entry " name ); +.fi +.ir note : +identical macros prefixed with simpleq instead of stailq exist; see notes. +.sh description +these macros define and operate on singly linked tail queues. +.pp +in the macro definitions, +.i type +is the name of a user-defined structure, +that must contain a field of type +.ir stailq_entry , +named +.ir name . +the argument +.i headname +is the name of a user-defined structure that must be declared +using the macro +.br stailq_head (). +.ss creation +a singly linked tail queue is headed by a structure defined by the +.br stailq_head () +macro. +this structure contains a pair of pointers, +one to the first element in the tail queue and the other to +the last element in the tail queue. +the elements are singly linked for minimum space and pointer +manipulation overhead at the expense of o(n) removal for arbitrary elements. +new elements can be added to the tail queue after an existing element, +at the head of the tail queue, or at the end of the tail queue. +a +.i stailq_head +structure is declared as follows: +.pp +.in +4 +.ex +stailq_head(headname, type) head; +.ee +.in +.pp +where +.i struct headname +is the structure to be defined, and +.i struct type +is the type of the elements to be linked into the tail queue. +a pointer to the head of the tail queue can later be declared as: +.pp +.in +4 +.ex +struct headname *headp; +.ee +.in +.pp +(the names +.i head +and +.i headp +are user selectable.) +.pp +.br stailq_entry () +declares a structure that connects the elements in the tail queue. +.pp +.br stailq_head_initializer () +evaluates to an initializer for the tail queue +.ir head . +.pp +.br stailq_init () +initializes the tail queue referenced by +.ir head . +.pp +.br stailq_empty () +evaluates to true if there are no items on the tail queue. +.ss insertion +.br stailq_insert_head () +inserts the new element +.i elm +at the head of the tail queue. +.pp +.br stailq_insert_tail () +inserts the new element +.i elm +at the end of the tail queue. +.pp +.br stailq_insert_after () +inserts the new element +.i elm +after the element +.ir listelm . +.ss traversal +.br stailq_first () +returns the first item on the tail queue or null if the tail queue is empty. +.\" .pp +.\" .br stailq_last () +.\" returns the last item on the tail queue. +.\" if the tail queue is empty the return value is null . +.pp +.br stailq_next () +returns the next item on the tail queue, or null this item is the last. +.pp +.br stailq_foreach () +traverses the tail queue referenced by +.i head +in the forward direction, +assigning each element in turn to +.ir var . +.\" .pp +.\" .br stailq_foreach_from () +.\" behaves identically to +.\" .br stailq_foreach () +.\" when +.\" .i var +.\" is null, else it treats +.\" .i var +.\" as a previously found stailq element and begins the loop at +.\" .i var +.\" instead of the first element in the stailq referenced by +.\" .ir head . +.\" .pp +.\" .br stailq_foreach_safe () +.\" traverses the tail queue referenced by +.\" .i head +.\" in the forward direction, assigning each element +.\" in turn to +.\" .ir var . +.\" however, unlike +.\" .br stailq_foreach () +.\" here it is permitted to both remove +.\" .i var +.\" as well as free it from within the loop safely without interfering with the +.\" traversal. +.\" .pp +.\" .br stailq_foreach_from_safe () +.\" behaves identically to +.\" .br stailq_foreach_safe () +.\" when +.\" .i var +.\" is null, else it treats +.\" .i var +.\" as a previously found stailq element and begins the loop at +.\" .i var +.\" instead of the first element in the stailq referenced by +.\" .ir head . +.ss removal +.br stailq_remove () +removes the element +.i elm +from the tail queue. +.pp +.br stailq_remove_head () +removes the element at the head of the tail queue. +for optimum efficiency, +elements being removed from the head of the tail queue should +use this macro explicitly rather than the generic +.br stailq_remove () +macro. +.\" .pp +.\" .br stailq_remove_after () +.\" removes the element after +.\" .i elm +.\" from the tail queue. +.\" unlike +.\" .br stailq_remove (), +.\" this macro does not traverse the entire tail queue. +.ss other features +.br stailq_concat () +concatenates the tail queue headed by +.i head2 +onto the end of the one headed by +.i head1 +removing all entries from the former. +.\" .pp +.\" .br stailq_swap () +.\" swaps the contents of +.\" .i head1 +.\" and +.\" .ir head2 . +.sh return value +.br stailq_empty () +returns nonzero if the queue is empty, +and zero if the queue contains at least one entry. +.pp +.br stailq_first (), +and +.br stailq_next () +return a pointer to the first or next +.i type +structure, respectively. +.pp +.br stailq_head_initializer () +returns an initializer that can be assigned to the queue +.ir head . +.sh conforming to +not in posix.1, posix.1-2001, or posix.1-2008. +present on the bsds +(stailq macros first appeared in 4.4bsd). +.sh notes +some bsds provide simpleq instead of stailq. +they are identical, but for historical reasons +they were named differently on different bsds. +stailq originated on freebsd, and simpleq originated on netbsd. +for compatibility reasons, some systems provide both sets of macros. +glibc provides both stailq and simpleq, +which are identical except for a missing simpleq equivalent to +.br stailq_concat (). +.sh bugs +.br stailq_foreach () +doesn't allow +.i var +to be removed or freed within the loop, +as it would interfere with the traversal. +.br stailq_foreach_safe (), +which is present on the bsds but is not present in glibc, +fixes this limitation by allowing +.i var +to safely be removed from the list and freed from within the loop +without interfering with the traversal. +.sh examples +.ex +#include +#include +#include +#include + +struct entry { + int data; + stailq_entry(entry) entries; /* singly linked tail queue */ +}; + +stailq_head(stailhead, entry); + +int +main(void) +{ + struct entry *n1, *n2, *n3, *np; + struct stailhead head; /* singly linked tail queue + head */ + + stailq_init(&head); /* initialize the queue */ + + n1 = malloc(sizeof(struct entry)); /* insert at the head */ + stailq_insert_head(&head, n1, entries); + + n1 = malloc(sizeof(struct entry)); /* insert at the tail */ + stailq_insert_tail(&head, n1, entries); + + n2 = malloc(sizeof(struct entry)); /* insert after */ + stailq_insert_after(&head, n1, n2, entries); + + stailq_remove(&head, n2, entry, entries); /* deletion */ + free(n2); + + n3 = stailq_first(&head); + stailq_remove_head(&head, entries); /* deletion from the head */ + free(n3); + + n1 = stailq_first(&head); + n1\->data = 0; + for (int i = 1; i < 5; i++) { + n1 = malloc(sizeof(struct entry)); + stailq_insert_head(&head, n1, entries); + n1\->data = i; + } + /* forward traversal */ + stailq_foreach(np, &head, entries) + printf("%i\en", np\->data); + /* tailq deletion */ + n1 = stailq_first(&head); + while (n1 != null) { + n2 = stailq_next(n1, entries); + free(n1); + n1 = n2; + } + stailq_init(&head); + + exit(exit_success); +} +.ee +.sh see also +.br insque (3), +.br queue (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/exec.3 + +.so man3/resolver.3 + +.\" copyright (c) 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified sat jul 24 21:25:52 1993 by rik faith (faith@cs.unc.edu) +.\" modified 11 june 1995 by andries brouwer (aeb@cwi.nl) +.th closedir 3 2021-03-22 "" "linux programmer's manual" +.sh name +closedir \- close a directory +.sh synopsis +.nf +.b #include +.b #include +.pp +.bi "int closedir(dir *" dirp ); +.fi +.sh description +the +.br closedir () +function closes the directory stream associated with +.ir dirp . +a successful call to +.br closedir () +also closes the underlying file descriptor associated with +.ir dirp . +the directory stream descriptor +.i dirp +is not available +after this call. +.sh return value +the +.br closedir () +function returns 0 on success. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b ebadf +invalid directory stream descriptor +.ir dirp . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br closedir () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, svr4, 4.3bsd. +.sh see also +.br close (2), +.br opendir (3), +.br readdir (3), +.br rewinddir (3), +.br scandir (3), +.br seekdir (3), +.br telldir (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/cmsg.3 + +.so man3/getspnam.3 + +.so man3/key_setsecret.3 + +.so man3/getcwd.3 + +.\" copyright (c) 2014 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" +.th sched_setscheduler 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +sched_setscheduler, sched_getscheduler \- +set and get scheduling policy/parameters +.sh synopsis +.nf +.b #include +.pp +.bi "int sched_setscheduler(pid_t " pid ", int " policy , +.bi " const struct sched_param *" param ); +.bi "int sched_getscheduler(pid_t " pid ); +.fi +.sh description +the +.br sched_setscheduler () +system call +sets both the scheduling policy and parameters for the +thread whose id is specified in \fipid\fp. +if \fipid\fp equals zero, the +scheduling policy and parameters of the calling thread will be set. +.pp +the scheduling parameters are specified in the +.i param +argument, which is a pointer to a structure of the following form: +.pp +.in +4n +.ex +struct sched_param { + ... + int sched_priority; + ... +}; +.ee +.in +.pp +in the current implementation, the structure contains only one field, +.ir sched_priority . +the interpretation of +.i param +depends on the selected policy. +.pp +currently, linux supports the following "normal" +(i.e., non-real-time) scheduling policies as values that may be specified in +.ir policy : +.tp 14 +.br sched_other +the standard round-robin time-sharing policy; +.\" in the 2.6 kernel sources, sched_other is actually called +.\" sched_normal. +.tp +.br sched_batch +for "batch" style execution of processes; and +.tp +.br sched_idle +for running +.i very +low priority background jobs. +.pp +for each of the above policies, +.ir param\->sched_priority +must be 0. +.pp +various "real-time" policies are also supported, +for special time-critical applications that need precise control over +the way in which runnable threads are selected for execution. +for the rules governing when a process may use these policies, see +.br sched (7). +the real-time policies that may be specified in +.ir policy +are: +.tp 14 +.br sched_fifo +a first-in, first-out policy; and +.tp +.br sched_rr +a round-robin policy. +.pp +for each of the above policies, +.ir param\->sched_priority +specifies a scheduling priority for the thread. +this is a number in the range returned by calling +.br sched_get_priority_min (2) +and +.br sched_get_priority_max (2) +with the specified +.ir policy . +on linux, these system calls return, respectively, 1 and 99. +.pp +since linux 2.6.32, the +.b sched_reset_on_fork +flag can be ored in +.i policy +when calling +.br sched_setscheduler (). +as a result of including this flag, children created by +.br fork (2) +do not inherit privileged scheduling policies. +see +.br sched (7) +for details. +.pp +.br sched_getscheduler () +returns the current scheduling policy of the thread +identified by \fipid\fp. +if \fipid\fp equals zero, the policy of the +calling thread will be retrieved. +.sh return value +on success, +.br sched_setscheduler () +returns zero. +on success, +.br sched_getscheduler () +returns the policy for the thread (a nonnegative integer). +on error, both calls return \-1, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b einval +invalid arguments: +.i pid +is negative or +.i param +is null. +.tp +.b einval +.rb ( sched_setscheduler ()) +.i policy +is not one of the recognized policies. +.tp +.b einval +.rb ( sched_setscheduler ()) +.i param +does not make sense for the specified +.ir policy . +.tp +.b eperm +the calling thread does not have appropriate privileges. +.tp +.b esrch +the thread whose id is \fipid\fp could not be found. +.sh conforming to +posix.1-2001, posix.1-2008 (but see bugs below). +the \fbsched_batch\fp and \fbsched_idle\fp policies are linux-specific. +.sh notes +further details of the semantics of all of the above "normal" +and "real-time" scheduling policies can be found in the +.br sched (7) +manual page. +that page also describes an additional policy, +.br sched_deadline , +which is settable only via +.br sched_setattr (2). +.pp +posix systems on which +.br sched_setscheduler () +and +.br sched_getscheduler () +are available define +.b _posix_priority_scheduling +in \fi\fp. +.pp +posix.1 does not detail the permissions that an unprivileged +thread requires in order to call +.br sched_setscheduler (), +and details vary across systems. +for example, the solaris 7 manual page says that +the real or effective user id of the caller must +match the real user id or the save set-user-id of the target. +.pp +the scheduling policy and parameters are in fact per-thread +attributes on linux. +the value returned from a call to +.br gettid (2) +can be passed in the argument +.ir pid . +specifying +.i pid +as 0 will operate on the attributes of the calling thread, +and passing the value returned from a call to +.br getpid (2) +will operate on the attributes of the main thread of the thread group. +(if you are using the posix threads api, then use +.br pthread_setschedparam (3), +.br pthread_getschedparam (3), +and +.br pthread_setschedprio (3), +instead of the +.br sched_* (2) +system calls.) +.sh bugs +posix.1 says that on success, +.br sched_setscheduler () +should return the previous scheduling policy. +linux +.br sched_setscheduler () +does not conform to this requirement, +since it always returns 0 on success. +.sh see also +.ad l +.nh +.br chrt (1), +.br nice (2), +.br sched_get_priority_max (2), +.br sched_get_priority_min (2), +.br sched_getaffinity (2), +.br sched_getattr (2), +.br sched_getparam (2), +.br sched_rr_get_interval (2), +.br sched_setaffinity (2), +.br sched_setattr (2), +.br sched_setparam (2), +.br sched_yield (2), +.br setpriority (2), +.br capabilities (7), +.br cpuset (7), +.br sched (7) +.ad +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/getdate.3 + +.so man3/y0.3 + +.so man3/getgrent.3 + +.so man7/system_data_types.7 + +.so man3/scanf.3 + +.\" copyright 2009 lefteris dimitroulakis (edimitro@tee.gr) +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th iso_8859-3 7 2020-08-13 "linux" "linux programmer's manual" +.sh name +iso_8859-3 \- iso 8859-3 character set encoded in octal, decimal, +and hexadecimal +.sh description +the iso 8859 standard includes several 8-bit extensions to the ascii +character set (also known as iso 646-irv). +iso 8859-3 encodes the +characters used in certain southeast european languages. +.ss iso 8859 alphabets +the full set of iso 8859 alphabets includes: +.ts +l l. +iso 8859-1 west european languages (latin-1) +iso 8859-2 central and east european languages (latin-2) +iso 8859-3 southeast european and miscellaneous languages (latin-3) +iso 8859-4 scandinavian/baltic languages (latin-4) +iso 8859-5 latin/cyrillic +iso 8859-6 latin/arabic +iso 8859-7 latin/greek +iso 8859-8 latin/hebrew +iso 8859-9 latin-1 modification for turkish (latin-5) +iso 8859-10 lappish/nordic/eskimo languages (latin-6) +iso 8859-11 latin/thai +iso 8859-13 baltic rim languages (latin-7) +iso 8859-14 celtic (latin-8) +iso 8859-15 west european languages (latin-9) +iso 8859-16 romanian (latin-10) +.te +.ss iso 8859-3 characters +the following table displays the characters in iso 8859-3 that +are printable and unlisted in the +.br ascii (7) +manual page. +.ts +l l l c lp-1. +oct dec hex char description +_ +240 160 a0   no-break space +241 161 a1 ħ latin capital letter h with stroke +242 162 a2 ˘ breve +243 163 a3 £ pound sign +244 164 a4 ¤ currency sign +246 166 a6 ĥ latin capital letter h with circumflex +247 167 a7 § section sign +250 168 a8 ¨ diaeresis +251 169 a9 i̇ latin capital letter i with dot above +252 170 aa ş latin capital letter s with cedilla +253 171 ab ğ latin capital letter g with breve +254 172 ac ĵ latin capital letter j with circumflex +255 173 ad ­ soft hyphen +257 175 af ż latin capital letter z with dot above +260 176 b0 ° degree sign +261 177 b1 ħ latin small letter h with stroke +262 178 b2 ² superscript two +263 179 b3 ³ superscript three +264 180 b4 ´ acute accent +265 181 b5 µ micro sign +266 182 b6 ĥ latin small letter h with circumflex +267 183 b7 · middle dot +270 184 b8 ¸ cedilla +271 185 b9 ı latin small letter dotless i +272 186 ba ş latin small letter s with cedilla +273 187 bb ğ latin small letter g with breve +274 188 bc ĵ latin small letter j with circumflex +275 189 bd ½ vulgar fraction one half +277 191 bf ż latin small letter z with dot above +300 192 c0 à latin capital letter a with grave +301 193 c1 á latin capital letter a with acute +302 194 c2 â latin capital letter a with circumflex +304 196 c4 ä latin capital letter a with diaeresis +305 197 c5 ċ latin capital letter c with dot above +306 198 c6 ĉ latin capital letter c with circumflex +307 199 c7 ç latin capital letter c with cedilla +310 200 c8 è latin capital letter e with grave +311 201 c9 é latin capital letter e with acute +312 202 ca ê latin capital letter e with circumflex +313 203 cb ë latin capital letter e with diaeresis +314 204 cc ì latin capital letter i with grave +315 205 cd í latin capital letter i with acute +316 206 ce î latin capital letter i with circumflex +317 207 cf ï latin capital letter i with diaeresis +321 209 d1 ñ latin capital letter n with tilde +322 210 d2 ò latin capital letter o with grave +323 211 d3 ó latin capital letter o with acute +324 212 d4 ô latin capital letter o with circumflex +325 213 d5 ġ latin capital letter g with dot above +326 214 d6 ö latin capital letter o with diaeresis +327 215 d7 × multiplication sign +330 216 d8 ĝ latin capital letter g with circumflex +331 217 d9 ù latin capital letter u with grave +332 218 da ú latin capital letter u with acute +333 219 db û latin capital letter u with circumflex +334 220 dc ü latin capital letter u with diaeresis +335 221 dd ŭ latin capital letter u with breve +336 222 de ŝ latin capital letter s with circumflex +337 223 df ß latin small letter sharp s +340 224 e0 à latin small letter a with grave +341 225 e1 á latin small letter a with acute +342 226 e2 â latin small letter a with circumflex +344 228 e4 ä latin small letter a with diaeresis +345 229 e5 ċ latin small letter c with dot above +346 230 e6 ĉ latin small letter c with circumflex +347 231 e7 ç latin small letter c with cedilla +350 232 e8 è latin small letter e with grave +351 233 e9 é latin small letter e with acute +352 234 ea ê latin small letter e with circumflex +353 235 eb ë latin small letter e with diaeresis +354 236 ec ì latin small letter i with grave +355 237 ed í latin small letter i with acute +356 238 ee î latin small letter i with circumflex +357 239 ef ï latin small letter i with diaeresis +361 241 f1 ñ latin small letter n with tilde +362 242 f2 ò latin small letter o with grave +363 243 f3 ó latin small letter o with acute +364 244 f4 ô latin small letter o with circumflex +365 245 f5 ġ latin small letter g with dot above +366 246 f6 ö latin small letter o with diaeresis +367 247 f7 ÷ division sign +370 248 f8 ĝ latin small letter g with circumflex +371 249 f9 ù latin small letter u with grave +372 250 fa ú latin small letter u with acute +373 251 fb û latin small letter u with circumflex +374 252 fc ü latin small letter u with diaeresis +375 253 fd ŭ latin small letter u with breve +376 254 fe ŝ latin small letter s with circumflex +377 255 ff ˙ dot above +.te +.sh notes +iso 8859-3 is also known as latin-3. +.sh see also +.br ascii (7), +.br charsets (7), +.br utf\-8 (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" written sat mar 8 10:35:08 mez 1997 by +.\" j. "mufti" scheurich (mufti@csv.ica.uni-stuttgart.de) +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" this page is licensed under the gnu general public license +.\" %%%license_end +.\" +.th __setfpucw 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +__setfpucw \- set fpu control word on i386 architecture (obsolete) +.sh synopsis +.nf +.b #include +.pp +.bi "void __setfpucw(unsigned short " control_word ); +.fi +.sh description +.br __setfpucw () +transfers +.i control_word +to the registers of the fpu (floating-point unit) on the i386 architecture. +this was used to control floating-point precision, +rounding and floating-point exceptions. +.sh conforming to +this function was a nonstandard gnu extension. +.sh notes +as of glibc 2.1 this function does not exist anymore. +there are new functions from c99, with prototypes in +.ir , +to control fpu rounding modes, like +.br fegetround (3), +.br fesetround (3), +and the floating-point environment, like +.br fegetenv (3), +.br feholdexcept (3), +.br fesetenv (3), +.br feupdateenv (3), +and fpu exception handling, like +.br feclearexcept (3), +.br fegetexceptflag (3), +.br feraiseexcept (3), +.br fesetexceptflag (3), +and +.br fetestexcept (3). +.pp +if direct access to the fpu control word is still needed, the +.b _fpu_getcw +and +.b _fpu_setcw +macros from +.i +can be used. +.sh examples +.b __setfpucw(0x1372) +.pp +set fpu control word on the i386 architecture to + \- extended precision + \- rounding to nearest + \- exceptions on overflow, zero divide and nan +.sh see also +.br feclearexcept (3) +.pp +.i +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2006 michael kerrisk +.\" a few fragments remain from an earlier (1992) page by +.\" drew eckhardt (drew@cs.colorado.edu), +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified by michael haardt (michael@moria.de) +.\" modified sat jul 24 13:22:07 1993 by rik faith (faith@cs.unc.edu) +.\" modified 21 aug 1994 by michael chastain (mec@shell.portal.com): +.\" referenced 'clone(2)'. +.\" modified 1995-06-10, 1996-04-18, 1999-11-01, 2000-12-24 +.\" by andries brouwer (aeb@cwi.nl) +.\" modified, 27 may 2004, michael kerrisk +.\" added notes on capability requirements +.\" 2006-09-04, michael kerrisk +.\" greatly expanded, to describe all attributes that differ +.\" parent and child. +.\" +.th fork 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +fork \- create a child process +.sh synopsis +.nf +.b #include +.pp +.b pid_t fork(void); +.fi +.sh description +.br fork () +creates a new process by duplicating the calling process. +the new process is referred to as the +.i child +process. +the calling process is referred to as the +.i parent +process. +.pp +the child process and the parent process run in separate memory spaces. +at the time of +.br fork () +both memory spaces have the same content. +memory writes, file mappings +.rb ( mmap (2)), +and unmappings +.rb ( munmap (2)) +performed by one of the processes do not affect the other. +.pp +the child process is an exact duplicate of the parent +process except for the following points: +.ip * 3 +the child has its own unique process id, +and this pid does not match the id of any existing process group +.rb ( setpgid (2)) +or session. +.ip * +the child's parent process id is the same as the parent's process id. +.ip * +the child does not inherit its parent's memory locks +.rb ( mlock (2), +.br mlockall (2)). +.ip * +process resource utilizations +.rb ( getrusage (2)) +and cpu time counters +.rb ( times (2)) +are reset to zero in the child. +.ip * +the child's set of pending signals is initially empty +.rb ( sigpending (2)). +.ip * +the child does not inherit semaphore adjustments from its parent +.rb ( semop (2)). +.ip * +the child does not inherit process-associated record locks from its parent +.rb ( fcntl (2)). +(on the other hand, it does inherit +.br fcntl (2) +open file description locks and +.br flock (2) +locks from its parent.) +.ip * +the child does not inherit timers from its parent +.rb ( setitimer (2), +.br alarm (2), +.br timer_create (2)). +.ip * +the child does not inherit outstanding asynchronous i/o operations +from its parent +.rb ( aio_read (3), +.br aio_write (3)), +nor does it inherit any asynchronous i/o contexts from its parent (see +.br io_setup (2)). +.pp +the process attributes in the preceding list are all specified +in posix.1. +the parent and child also differ with respect to the following +linux-specific process attributes: +.ip * 3 +the child does not inherit directory change notifications (dnotify) +from its parent +(see the description of +.b f_notify +in +.br fcntl (2)). +.ip * +the +.br prctl (2) +.b pr_set_pdeathsig +setting is reset so that the child does not receive a signal +when its parent terminates. +.ip * +the default timer slack value is set to the parent's +current timer slack value. +see the description of +.br pr_set_timerslack +in +.br prctl (2). +.ip * +memory mappings that have been marked with the +.br madvise (2) +.b madv_dontfork +flag are not inherited across a +.br fork (). +.ip * +memory in address ranges that have been marked with the +.br madvise (2) +.b madv_wipeonfork +flag is zeroed in the child after a +.br fork (). +(the +.b madv_wipeonfork +setting remains in place for those address ranges in the child.) +.ip * +the termination signal of the child is always +.b sigchld +(see +.br clone (2)). +.ip * +the port access permission bits set by +.br ioperm (2) +are not inherited by the child; +the child must turn on any bits that it requires using +.br ioperm (2). +.pp +note the following further points: +.ip * 3 +the child process is created with a single thread\(emthe +one that called +.br fork (). +the entire virtual address space of the parent is replicated in the child, +including the states of mutexes, condition variables, +and other pthreads objects; the use of +.br pthread_atfork (3) +may be helpful for dealing with problems that this can cause. +.ip * +after a +.br fork () +in a multithreaded program, +the child can safely call only async-signal-safe functions (see +.br signal\-safety (7)) +until such time as it calls +.br execve (2). +.ip * +the child inherits copies of the parent's set of open file descriptors. +each file descriptor in the child refers to the same +open file description (see +.br open (2)) +as the corresponding file descriptor in the parent. +this means that the two file descriptors share open file status flags, +file offset, +and signal-driven i/o attributes (see the description of +.b f_setown +and +.b f_setsig +in +.br fcntl (2)). +.ip * +the child inherits copies of the parent's set of open message +queue descriptors (see +.br mq_overview (7)). +each file descriptor in the child refers to the same +open message queue description +as the corresponding file descriptor in the parent. +this means that the two file descriptors share the same flags +.ri ( mq_flags ). +.ip * +the child inherits copies of the parent's set of open directory streams (see +.br opendir (3)). +posix.1 says that the corresponding directory streams +in the parent and child +.i may +share the directory stream positioning; +on linux/glibc they do not. +.sh return value +on success, the pid of the child process is returned in the parent, +and 0 is returned in the child. +on failure, \-1 is returned in the parent, +no child process is created, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eagain +.\" note! the following should match the description in pthread_create(3) +a system-imposed limit on the number of threads was encountered. +there are a number of limits that may trigger this error: +.rs +.ip * 3 +the +.br rlimit_nproc +soft resource limit (set via +.br setrlimit (2)), +which limits the number of processes and threads for a real user id, +was reached; +.ip * +the kernel's system-wide limit on the number of processes and threads, +.ir /proc/sys/kernel/threads\-max , +was reached (see +.br proc (5)); +.ip * +the maximum number of pids, +.ir /proc/sys/kernel/pid_max , +was reached (see +.br proc (5)); +or +.ip * +the pid limit +.ri ( pids.max ) +imposed by the cgroup "process number" (pids) controller was reached. +.re +.tp +.b eagain +the caller is operating under the +.br sched_deadline +scheduling policy and does not have the reset-on-fork flag set. +see +.br sched (7). +.tp +.b enomem +.br fork () +failed to allocate the necessary kernel structures because memory is tight. +.tp +.b enomem +an attempt was made to create a child process in a pid namespace +whose "init" process has terminated. +see +.br pid_namespaces (7). +.tp +.b enosys +.br fork () +is not supported on this platform (for example, +.\" e.g., arm (optionally), blackfin, c6x, frv, h8300, microblaze, xtensa +hardware without a memory-management unit). +.tp +.br erestartnointr " (since linux 2.6.17)" +.\" commit 4a2c7a7837da1b91468e50426066d988050e4d56 +system call was interrupted by a signal and will be restarted. +(this can be seen only during a trace.) +.sh conforming to +posix.1-2001, posix.1-2008, svr4, 4.3bsd. +.sh notes +under linux, +.br fork () +is implemented using copy-on-write pages, so the only penalty that it incurs +is the time and memory required to duplicate the parent's page tables, +and to create a unique task structure for the child. +.ss c library/kernel differences +since version 2.3.3, +.\" nptl/sysdeps/unix/sysv/linux/fork.c +rather than invoking the kernel's +.br fork () +system call, +the glibc +.br fork () +wrapper that is provided as part of the +nptl threading implementation invokes +.br clone (2) +with flags that provide the same effect as the traditional system call. +(a call to +.br fork () +is equivalent to a call to +.br clone (2) +specifying +.i flags +as just +.br sigchld .) +the glibc wrapper invokes any fork handlers that have been +established using +.br pthread_atfork (3). +.\" and does some magic to ensure that getpid(2) returns the right value. +.sh examples +see +.br pipe (2) +and +.br wait (2). +.sh see also +.br clone (2), +.br execve (2), +.br exit (2), +.br setrlimit (2), +.br unshare (2), +.br vfork (2), +.br wait (2), +.br daemon (3), +.br pthread_atfork (3), +.br capabilities (7), +.br credentials (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" and copyright 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified 1993-07-24 by rik faith (faith@cs.unc.edu) +.\" modified 1995-08-14 by arnt gulbrandsen +.\" modified 2002-07-27 by walter harms +.\" (walter.harms@informatik.uni-oldenburg.de) +.th pow 3 2021-03-22 "" "linux programmer's manual" +.sh name +pow, powf, powl \- power functions +.sh synopsis +.nf +.b #include +.pp +.bi "double pow(double " x ", double " y ); +.bi "float powf(float " x ", float " y ); +.bi "long double powl(long double " x ", long double " y ); +.fi +.pp +link with \fi\-lm\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br powf (), +.br powl (): +.nf + _isoc99_source || _posix_c_source >= 200112l + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.sh description +these functions return the value of +.i x +raised to the +power of +.ir y . +.sh return value +on success, these functions return the value of +.i x +to the power of +.ir y . +.pp +if +.i x +is a finite value less than 0, and +.i y +is a finite noninteger, a domain error occurs, +.\" the domain error is generated at least as far back as glibc 2.4 +and a nan is returned. +.pp +if the result overflows, +a range error occurs, +.\" the range error is generated at least as far back as glibc 2.4 +and the functions return +.br huge_val , +.br huge_valf , +or +.br huge_vall , +respectively, with the mathematically correct sign. +.pp +if result underflows, and is not representable, +a range error occurs, +and 0.0 is returned. +.\" posix.1 does not specify the sign of the zero, +.\" but http://sources.redhat.com/bugzilla/show_bug.cgi?id=2678 +.\" points out that the zero has the wrong sign in some cases. +.pp +except as specified below, if +.i x +or +.i y +is a nan, the result is a nan. +.pp +if +.i x +is +1, the result is 1.0 (even if +.i y +is a nan). +.pp +if +.i y +is 0, the result is 1.0 (even if +.i x +is a nan). +.pp +if +.i x +is +0 (\-0), +and +.i y +is an odd integer greater than 0, +the result is +0 (\-0). +.pp +if +.i x +is 0, +and +.i y +greater than 0 and not an odd integer, +the result is +0. +.pp +if +.i x +is \-1, +and +.i y +is positive infinity or negative infinity, +the result is 1.0. +.pp +if the absolute value of +.i x +is less than 1, +and +.i y +is negative infinity, +the result is positive infinity. +.pp +if the absolute value of +.i x +is greater than 1, +and +.i y +is negative infinity, +the result is +0. +.pp +if the absolute value of +.i x +is less than 1, +and +.i y +is positive infinity, +the result is +0. +.pp +if the absolute value of +.i x +is greater than 1, +and +.i y +is positive infinity, +the result is positive infinity. +.pp +if +.i x +is negative infinity, +and +.i y +is an odd integer less than 0, +the result is \-0. +.pp +if +.i x +is negative infinity, +and +.i y +less than 0 and not an odd integer, +the result is +0. +.pp +if +.i x +is negative infinity, +and +.i y +is an odd integer greater than 0, +the result is negative infinity. +.pp +if +.i x +is negative infinity, +and +.i y +greater than 0 and not an odd integer, +the result is positive infinity. +.pp +if +.i x +is positive infinity, +and +.i y +less than 0, +the result is +0. +.pp +if +.i x +is positive infinity, +and +.i y +greater than 0, +the result is positive infinity. +.pp +if +.i x +is +0 or \-0, +and +.i y +is an odd integer less than 0, +a pole error occurs and +.br huge_val , +.br huge_valf , +or +.br huge_vall , +is returned, +with the same sign as +.ir x . +.pp +if +.i x +is +0 or \-0, +and +.i y +is less than 0 and not an odd integer, +a pole error occurs and +.\" the pole error is generated at least as far back as glibc 2.4 +.rb + huge_val , +.rb + huge_valf , +or +.rb + huge_vall , +is returned. +.sh errors +.\" fixme . review status of this error +.\" longstanding bug report for glibc: +.\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=369 +.\" for negative x, and -large and +large y, glibc 2.8 gives incorrect +.\" results +.\" pow(-0.5,-dbl_max)=nan +.\" edom fe_invalid nan; fail-errno fail-except fail-result; +.\" fail (expected: range-error-overflow (erange, fe_overflow); +inf) +.\" +.\" pow(-1.5,-dbl_max)=nan +.\" edom fe_invalid nan; fail-errno fail-except fail-result; +.\" fail (expected: range-error-underflow (erange, fe_underflow); +0) +.\" +.\" pow(-0.5,dbl_max)=nan +.\" edom fe_invalid nan; fail-errno fail-except fail-result; +.\" fail (expected: range-error-underflow (erange, fe_underflow); +0) +.\" +.\" pow(-1.5,dbl_max)=nan +.\" edom fe_invalid nan; fail-errno fail-except fail-result; +.\" fail (expected: range-error-overflow (erange, fe_overflow); +inf) +see +.br math_error (7) +for information on how to determine whether an error has occurred +when calling these functions. +.pp +the following errors can occur: +.tp +domain error: \fix\fp is negative, and \fiy\fp is a finite noninteger +.i errno +is set to +.br edom . +an invalid floating-point exception +.rb ( fe_invalid ) +is raised. +.tp +pole error: \fix\fp is zero, and \fiy\fp is negative +.i errno +is set to +.br erange +(but see bugs). +a divide-by-zero floating-point exception +.rb ( fe_divbyzero ) +is raised. +.tp +range error: the result overflows +.i errno +is set to +.br erange . +an overflow floating-point exception +.rb ( fe_overflow ) +is raised. +.tp +range error: the result underflows +.i errno +is set to +.br erange . +an underflow floating-point exception +.rb ( fe_underflow ) +is raised. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br pow (), +.br powf (), +.br powl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.pp +the variant returning +.i double +also conforms to +svr4, 4.3bsd, c89. +.sh bugs +.ss historical bugs (now fixed) +before glibc 2.28, +.\" https://sourceware.org/bugzilla/show_bug.cgi?id=13932 +on some architectures (e.g., x86-64) +.br pow () +may be more than 10,000 times slower for some inputs +than for other nearby inputs. +this affects only +.br pow (), +and not +.br powf () +nor +.br powl (). +this problem was fixed +.\" commit c3d466cba1692708a19c6ff829d0386c83a0c6e5 +in glibc 2.28. +.pp +a number of bugs +.\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=3866 +in the glibc implementation of +.br pow () +were fixed in glibc version 2.16. +.pp +in glibc 2.9 and earlier, +.\" +.\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=6776 +when a pole error occurs, +.i errno +is set to +.br edom +instead of the posix-mandated +.br erange . +since version 2.10, +.\" or possibly 2.9, i haven't found the source code change +.\" and i don't have a 2.9 system to test +glibc does the right thing. +.pp +in version 2.3.2 and earlier, +.\" actually, 2.3.2 is the earliest test result i have; so yet +.\" to confirm if this error occurs only in 2.3.2. +when an overflow or underflow error occurs, glibc's +.br pow () +generates a bogus invalid floating-point exception +.rb ( fe_invalid ) +in addition to the overflow or underflow exception. +.sh see also +.br cbrt (3), +.br cpow (3), +.br sqrt (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 2003 andries e. brouwer (aeb@cwi.nl) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th alloc_hugepages 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +alloc_hugepages, free_hugepages \- allocate or free huge pages +.sh synopsis +.nf +.bi "void *syscall(sys_alloc_hugepages, int " key ", void *" addr \ +", size_t " len , +.bi " int " prot ", int " flag ); +.\" asmlinkage unsigned long sys_alloc_hugepages(int key, unsigned long addr, +.\" unsigned long len, int prot, int flag); +.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 () +and +.br free_hugepages () +were introduced in linux 2.5.36 and removed again in 2.5.54. +they existed only on i386 and ia64 (when built with +.br config_hugetlb_page ). +in linux 2.4.20, the syscall numbers exist, +but the calls fail with the error +.br enosys . +.pp +on i386 the memory management hardware knows about ordinary pages (4\ kib) +and huge pages (2 or 4\ mib). +similarly ia64 knows about huge pages of +several sizes. +these system calls serve to map huge pages into the +process's memory or to free them again. +huge pages are locked into memory, and are not swapped. +.pp +the +.i key +argument is an identifier. +when zero the pages are private, and +not inherited by children. +when positive the pages are shared with other applications using the same +.ir key , +and inherited by child processes. +.pp +the +.i addr +argument of +.br free_hugepages () +tells which page is being freed: it was the return value of a +call to +.br alloc_hugepages (). +(the memory is first actually freed when all users have released it.) +the +.i addr +argument of +.br alloc_hugepages () +is a hint, that the kernel may or may not follow. +addresses must be properly aligned. +.pp +the +.i len +argument is the length of the required segment. +it must be a multiple of the huge page size. +.pp +the +.i prot +argument specifies the memory protection of the segment. +it is one of +.br prot_read , +.br prot_write , +.br prot_exec . +.pp +the +.i flag +argument is ignored, unless +.i key +is positive. +in that case, if +.i flag +is +.br ipc_creat , +then a new huge page segment is created when none +with the given key existed. +if this flag is not set, then +.b enoent +is returned when no segment with the given key exists. +.sh return value +on success, +.br alloc_hugepages () +returns the allocated virtual address, and +.br free_hugepages () +returns zero. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b enosys +the system call is not supported on this kernel. +.sh files +.tp +.i /proc/sys/vm/nr_hugepages +number of configured hugetlb pages. +this can be read and written. +.tp +.i /proc/meminfo +gives info on the number of configured hugetlb pages and on their size +in the three variables hugepages_total, hugepages_free, hugepagesize. +.sh conforming to +these extinct system calls were specific to linux on intel processors. +.sh notes +these system calls are gone; +they existed only in linux 2.5.36 through to 2.5.54. +now the hugetlbfs filesystem can be used instead. +memory backed by huge pages (if the cpu supports them) is obtained by +using +.br mmap (2) +to map files in this virtual filesystem. +.pp +the maximal number of huge pages can be specified using the +.b hugepages= +boot parameter. +.\".pp +.\" requires config_hugetlb_page (under "processor type and features") +.\" and config_hugetlbfs (under "filesystems"). +.\" mount \-t hugetlbfs hugetlbfs /huge +.\" shm_hugetlb +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/printf.3 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified 1993-07-24 by rik faith (faith@cs.unc.edu) +.\" modified 2002-07-27 by walter harms +.\" (walter.harms@informatik.uni-oldenburg.de) +.\" +.th frexp 3 2021-03-22 "" "linux programmer's manual" +.sh name +frexp, frexpf, frexpl \- convert floating-point number to fractional +and integral components +.sh synopsis +.nf +.b #include +.pp +.bi "double frexp(double " x ", int *" exp ); +.bi "float frexpf(float " x ", int *" exp ); +.bi "long double frexpl(long double " x ", int *" exp ); +.fi +.pp +link with \fi\-lm\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br frexpf (), +.br frexpl (): +.nf + _isoc99_source || _posix_c_source >= 200112l + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.sh description +these functions are used to split the number +.i x +into a +normalized fraction and an exponent which is stored in +.ir exp . +.sh return value +these functions return the normalized fraction. +if the argument +.i x +is not zero, +the normalized fraction is +.i x +times a power of two, +and its absolute value is always in the range 1/2 (inclusive) to +1 (exclusive), that is, [0.5,1). +.pp +if +.i x +is zero, then the normalized fraction is +zero and zero is stored in +.ir exp . +.pp +if +.i x +is a nan, +a nan is returned, and the value of +.i *exp +is unspecified. +.pp +if +.i x +is positive infinity (negative infinity), +positive infinity (negative infinity) is returned, and the value of +.i *exp +is unspecified. +.sh errors +no errors occur. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br frexp (), +.br frexpf (), +.br frexpl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.pp +the variant returning +.i double +also conforms to +svr4, 4.3bsd, c89. +.sh examples +the program below produces results such as the following: +.pp +.in +4n +.ex +.rb "$" " ./a.out 2560" +frexp(2560, &e) = 0.625: 0.625 * 2\(ha12 = 2560 +.rb "$" " ./a.out \-4" +frexp(\-4, &e) = \-0.5: \-0.5 * 2\(ha3 = \-4 +.ee +.in +.ss program source +\& +.ex +#include +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + double x, r; + int exp; + + x = strtod(argv[1], null); + r = frexp(x, &exp); + + printf("frexp(%g, &e) = %g: %g * %d\(ha%d = %g\en", + x, r, r, flt_radix, exp, x); + exit(exit_success); +} +.ee +.sh see also +.br ldexp (3), +.br modf (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/cpu_set.3 + +.so man2/setreuid.2 + +.so man2/pciconfig_read.2 + +.\" copyright (c) 2017, yubin ruan +.\" and copyright (c) 2017, michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th pthread_mutex_consistent 3 2021-08-27 "linux" "linux programmer's manual" +.sh name +pthread_mutex_consistent \- make a robust mutex consistent +.sh synopsis +.nf +.b #include +.pp +.bi "int pthread_mutex_consistent(pthread_mutex_t *" mutex ");" +.fi +.pp +compile and link with \fi\-pthread\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br pthread_mutex_consistent (): +.nf + _posix_c_source >= 200809l +.fi +.sh description +this function makes a robust mutex consistent if it is in an inconsistent +state. +a mutex can be left in an inconsistent state if its owner terminates +while holding the mutex, in which case the next owner who acquires the +mutex will succeed and be notified by a return value of +.br eownerdead +from a call to +.br pthread_mutex_lock (). +.sh return value +on success, +.ir pthread_mutex_consistent () +returns 0. +otherwise, +it returns a positive error number to indicate the error. +.sh errors +.tp +.b einval +the mutex is either not robust or is not in an inconsistent state. +.sh versions +.br pthread_mutex_consistent () +was added to glibc in version 2.12. +.sh conforming to +posix.1-2008. +.sh notes +.br pthread_mutex_consistent () +simply informs the implementation that the state (shared data) +guarded by the mutex has been restored to a consistent state and that +normal operations can now be performed with the mutex. +it is the application's responsibility to ensure that the +shared data has been restored to a consistent state before calling +.br pthread_mutex_consistent (). +.pp +before the addition of +.br pthread_mutex_consistent () +to posix, +glibc defined the following equivalent nonstandard function if +.br _gnu_source +was defined: +.pp +.nf +.bi "int pthread_mutex_consistent_np(const pthread_mutex_t *" mutex ); +.fi +.pp +this gnu-specific api, which first appeared in glibc 2.4, +is nowadays obsolete and should not be used in new programs; +since glibc 2.34 it has been marked as deprecated. +.sh examples +see +.br pthread_mutexattr_setrobust (3). +.sh see also +.ad l +.nh +.br pthread_mutex_lock (3), +.br pthread_mutexattr_getrobust (3), +.br pthread_mutexattr_init (3), +.br pthread_mutexattr_setrobust (3), +.br pthreads (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/xdr.3 + +.\" copyright (c) 2016, oracle. all rights reserved. +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.th ioctl_fideduperange 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +ioctl_fideduperange \- share some the data of one file with another file +.sh synopsis +.nf +.br "#include " " /* definition of " fideduperange " and +.br " file_dedupe_* " constants */ +.b #include +.pp +.bi "int ioctl(int " src_fd ", fideduperange, struct file_dedupe_range *" arg ); +.fi +.sh description +if a filesystem supports files sharing physical storage between multiple +files, this +.br ioctl (2) +operation can be used to make some of the data in the +.b src_fd +file appear in the +.b dest_fd +file by sharing the underlying storage if the file data is identical +("deduplication"). +both files must reside within the same filesystem. +this reduces storage consumption by allowing the filesystem +to store one shared copy of the data. +if a file write should occur to a shared +region, the filesystem must ensure that the changes remain private to the file +being written. +this behavior is commonly referred to as "copy on write". +.pp +this ioctl performs the "compare and share if identical" operation on up to +.ir src_length +bytes from file descriptor +.ir src_fd +at offset +.ir src_offset . +this information is conveyed in a structure of the following form: +.pp +.in +4n +.ex +struct file_dedupe_range { + __u64 src_offset; + __u64 src_length; + __u16 dest_count; + __u16 reserved1; + __u32 reserved2; + struct file_dedupe_range_info info[0]; +}; +.ee +.in +.pp +deduplication is atomic with regards to concurrent writes, so no locks need to +be taken to obtain a consistent deduplicated copy. +.pp +the fields +.ir reserved1 " and " reserved2 +must be zero. +.pp +destinations for the deduplication operation are conveyed in the array at the +end of the structure. +the number of destinations is given in +.ir dest_count , +and the destination information is conveyed in the following form: +.pp +.in +4n +.ex +struct file_dedupe_range_info { + __s64 dest_fd; + __u64 dest_offset; + __u64 bytes_deduped; + __s32 status; + __u32 reserved; +}; +.ee +.in +.pp +each deduplication operation targets +.ir src_length +bytes in file descriptor +.ir dest_fd +at offset +.ir dest_offset . +the field +.ir reserved +must be zero. +during the call, +.ir src_fd +must be open for reading and +.ir dest_fd +must be open for writing. +the combined size of the struct +.ir file_dedupe_range +and the struct +.ir file_dedupe_range_info +array must not exceed the system page size. +the maximum size of +.ir src_length +is filesystem dependent and is typically 16\ mib. +this limit will be enforced silently by the filesystem. +by convention, the storage used by +.ir src_fd +is mapped into +.ir dest_fd +and the previous contents in +.ir dest_fd +are freed. +.pp +upon successful completion of this ioctl, the number of bytes successfully +deduplicated is returned in +.ir bytes_deduped +and a status code for the deduplication operation is returned in +.ir status . +if even a single byte in the range does not match, the deduplication +request will be ignored and +.ir status +set to +.br file_dedupe_range_differs . +the +.ir status +code is set to +.b file_dedupe_range_same +for success, a negative error code in case of error, or +.b file_dedupe_range_differs +if the data did not match. +.sh return value +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +possible errors include (but are not limited to) the following: +.tp +.b ebadf +.ir src_fd +is not open for reading; +.ir dest_fd +is not open for writing or is open for append-only writes; or the filesystem +which +.ir src_fd +resides on does not support deduplication. +.tp +.b einval +the filesystem does not support deduplicating the ranges of the given files. +this error can also appear if either file descriptor represents +a device, fifo, or socket. +disk filesystems generally require the offset and length arguments +to be aligned to the fundamental block size. +neither btrfs nor xfs support +overlapping deduplication ranges in the same file. +.tp +.b eisdir +one of the files is a directory and the filesystem does not support shared +regions in directories. +.tp +.b enomem +the kernel was unable to allocate sufficient memory to perform the +operation or +.ir dest_count +is so large that the input argument description spans more than a single +page of memory. +.tp +.b eopnotsupp +this can appear if the filesystem does not support deduplicating either file +descriptor, or if either file descriptor refers to special inodes. +.tp +.b eperm +.ir dest_fd +is immutable. +.tp +.b etxtbsy +one of the files is a swap file. +swap files cannot share storage. +.tp +.b exdev +.ir dest_fd " and " src_fd +are not on the same mounted filesystem. +.sh versions +this ioctl operation first appeared in linux 4.5. +it was previously known as +.b btrfs_ioc_file_extent_same +and was private to btrfs. +.sh conforming to +this api is linux-specific. +.sh notes +because a copy-on-write operation requires the allocation of new storage, the +.br fallocate (2) +operation may unshare shared blocks to guarantee that subsequent writes will +not fail because of lack of disk space. +.pp +some filesystems may limit the amount of data that can be deduplicated in a +single call. +.sh see also +.br ioctl (2) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" iso/iec 9899:1999 +.\" +.th wcrtomb 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +wcrtomb \- convert a wide character to a multibyte sequence +.sh synopsis +.nf +.b #include +.pp +.bi "size_t wcrtomb(char *restrict " s ", wchar_t " wc \ +", mbstate_t *restrict " ps ); +.fi +.sh description +the main case for this function is when +.i s +is +not null and +.i wc +is not a null wide character (l\(aq\e0\(aq). +in this case, the +.br wcrtomb () +function +converts the wide character +.i wc +to its multibyte representation and stores it +at the beginning of the character +array pointed to by +.ir s . +it updates the shift state +.ir *ps , +and +returns the length of said multibyte representation, +that is, the number of bytes +written at +.ir s . +.pp +a different case is when +.i s +is not null, +but +.i wc +is a null wide character (l\(aq\e0\(aq). +in this case, the +.br wcrtomb () +function stores at +the character array pointed to by +.i s +the shift sequence needed to +bring +.i *ps +back to the initial state, +followed by a \(aq\e0\(aq byte. +it updates the shift state +.i *ps +(i.e., brings +it into the initial state), +and returns the length of the shift sequence plus +one, that is, the number of bytes written at +.ir s . +.pp +a third case is when +.i s +is null. +in this case, +.i wc +is ignored, +and the function effectively returns +.pp + wcrtomb(buf, l\(aq\e0\(aq, ps) +.pp +where +.i buf +is an internal anonymous buffer. +.pp +in all of the above cases, if +.i ps +is null, a static anonymous +state known only to the +.br wcrtomb () +function is used instead. +.sh return value +the +.br wcrtomb () +function returns the number of +bytes that have been or would +have been written to the byte array at +.ir s . +if +.i wc +can not be +represented as a multibyte sequence (according to the current locale), +.i (size_t)\ \-1 +is returned, and +.i errno +set to +.br eilseq . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br wcrtomb () +t} thread safety mt-unsafe race:wcrtomb/!ps +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh notes +the behavior of +.br wcrtomb () +depends on the +.b lc_ctype +category of the +current locale. +.pp +passing null as +.i ps +is not multithread safe. +.sh see also +.br mbsinit (3), +.br wcsrtombs (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1992 drew eckhardt (drew@cs.colorado.edu), march 28, 1992 +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified by michael haardt +.\" modified 1993-07-24 by rik faith +.\" modified 1995-06-10 by andries brouwer +.\" modified 2004-06-23 by michael kerrisk +.\" modified 2004-10-10 by andries brouwer +.\" +.th utime 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +utime, utimes \- change file last access and modification times +.sh synopsis +.nf +.b #include +.pp +.bi "int utime(const char *" filename ", const struct utimbuf *" times ); +.pp +.b #include +.pp +.bi "int utimes(const char *" filename ", const struct timeval " times [2]); +.fi +.sh description +.b note: +modern applications may prefer to use the interfaces described in +.br utimensat (2). +.pp +the +.br utime () +system call +changes the access and modification times of the inode specified by +.i filename +to the +.ir actime " and " modtime +fields of +.i times +respectively. +.pp +if +.i times +is null, then the access and modification times of the file are set +to the current time. +.pp +changing timestamps is permitted when: either +the process has appropriate privileges, +or the effective user id equals the user id +of the file, or +.i times +is null and the process has write permission for the file. +.pp +the +.i utimbuf +structure is: +.pp +.in +4n +.ex +struct utimbuf { + time_t actime; /* access time */ + time_t modtime; /* modification time */ +}; +.ee +.in +.pp +the +.br utime () +system call +allows specification of timestamps with a resolution of 1 second. +.pp +the +.br utimes () +system call +is similar, but the +.i times +argument refers to an array rather than a structure. +the elements of this array are +.i timeval +structures, which allow a precision of 1 microsecond for specifying timestamps. +the +.i timeval +structure is: +.pp +.in +4n +.ex +struct timeval { + long tv_sec; /* seconds */ + long tv_usec; /* microseconds */ +}; +.ee +.in +.pp +.i times[0] +specifies the new access time, and +.i times[1] +specifies the new modification time. +if +.i times +is null, then analogously to +.br utime (), +the access and modification times of the file are +set to the current time. +.sh return value +on success, zero is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eacces +search permission is denied for one of the directories in +the path prefix of +.i path +(see also +.br path_resolution (7)). +.tp +.b eacces +.i times +is null, +the caller's effective user id does not match the owner of the file, +the caller does not have write access to the file, +and the caller is not privileged +(linux: does not have either the +.b cap_dac_override +or the +.b cap_fowner +capability). +.tp +.b enoent +.i filename +does not exist. +.tp +.b eperm +.i times +is not null, +the caller's effective uid does not match the owner of the file, +and the caller is not privileged +(linux: does not have the +.b cap_fowner +capability). +.tp +.b erofs +.i path +resides on a read-only filesystem. +.sh conforming to +.br utime (): +svr4, posix.1-2001. +posix.1-2008 marks +.br utime () +as obsolete. +.pp +.br utimes (): +4.3bsd, posix.1-2001. +.sh notes +linux does not allow changing the timestamps on an immutable file, +or setting the timestamps to something other than the current time +on an append-only file. +.\" +.\" in libc4 and libc5, +.\" .br utimes () +.\" is just a wrapper for +.\" .br utime () +.\" and hence does not allow a subsecond resolution. +.sh see also +.br chattr (1), +.br touch (1), +.br futimesat (2), +.br stat (2), +.br utimensat (2), +.br futimens (3), +.br futimes (3), +.br inode (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2003 davide libenzi +.\" davide libenzi +.\" and copyright 2007, 2012, 2014, 2018 michael kerrisk +.\" +.\" %%%license_start(gplv2+_sw_3_para) +.\" this program is free software; you can redistribute it and/or modify +.\" it under the terms of the gnu general public license as published by +.\" the free software foundation; either version 2 of the license, or +.\" (at your option) any later version. +.\" +.\" this program 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" 2007-04-30: mtk, added description of epoll_pwait() +.\" +.th epoll_wait 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +epoll_wait, epoll_pwait, epoll_pwait2 \- wait for an i/o event on an epoll file descriptor +.sh synopsis +.nf +.b #include +.pp +.bi "int epoll_wait(int " epfd ", struct epoll_event *" events , +.bi " int " maxevents ", int " timeout ); +.bi "int epoll_pwait(int " epfd ", struct epoll_event *" events , +.bi " int " maxevents ", int " timeout , +.bi " const sigset_t *" sigmask ); +.bi "int epoll_pwait2(int " epfd ", struct epoll_event *" events , +.bi " int " maxevents ", const struct timespec *" timeout , +.bi " const sigset_t *" sigmask ); +.\" fixme: check if glibc has added a wrapper for epoll_pwait2(), +.\" and if so, check the prototype. +.\" https://sourceware.org/bugzilla/show_bug.cgi?id=27359 +.fi +.sh description +the +.br epoll_wait () +system call waits for events on the +.br epoll (7) +instance referred to by the file descriptor +.ir epfd . +the buffer pointed to by +.i events +is used to return information from the ready list +about file descriptors in the interest list that +have some events available. +up to +.i maxevents +are returned by +.br epoll_wait (). +the +.i maxevents +argument must be greater than zero. +.pp +the +.i timeout +argument specifies the number of milliseconds that +.br epoll_wait () +will block. +time is measured against the +.b clock_monotonic +clock. +.pp +a call to +.br epoll_wait () +will block until either: +.ip \(bu 2 +a file descriptor delivers an event; +.ip \(bu +the call is interrupted by a signal handler; or +.ip \(bu +the timeout expires. +.pp +note that the +.i timeout +interval will be rounded up to the system clock granularity, +and kernel scheduling delays mean that the blocking interval +may overrun by a small amount. +specifying a +.i timeout +of \-1 causes +.br epoll_wait () +to block indefinitely, while specifying a +.i timeout +equal to zero cause +.br epoll_wait () +to return immediately, even if no events are available. +.pp +the +.i struct epoll_event +is defined as: +.pp +.in +4n +.ex +typedef union epoll_data { + void *ptr; + int fd; + uint32_t u32; + uint64_t u64; +} epoll_data_t; + +struct epoll_event { + uint32_t events; /* epoll events */ + epoll_data_t data; /* user data variable */ +}; +.ee +.in +.pp +the +.i data +field of each returned +.i epoll_event +structure contains the same data as was specified +in the most recent call to +.br epoll_ctl (2) +.rb ( epoll_ctl_add ", " epoll_ctl_mod ) +for the corresponding open file descriptor. +.pp +the +.i events +field is a bit mask that indicates the events that have occurred for the +corresponding open file description. +see +.br epoll_ctl (2) +for a list of the bits that may appear in this mask. +.\" +.ss epoll_pwait() +the relationship between +.br epoll_wait () +and +.br epoll_pwait () +is analogous to the relationship between +.br select (2) +and +.br pselect (2): +like +.br pselect (2), +.br epoll_pwait () +allows an application to safely wait until either a file descriptor +becomes ready or until a signal is caught. +.pp +the following +.br epoll_pwait () +call: +.pp +.in +4n +.ex +ready = epoll_pwait(epfd, &events, maxevents, timeout, &sigmask); +.ee +.in +.pp +is equivalent to +.i atomically +executing the following calls: +.pp +.in +4n +.ex +sigset_t origmask; + +pthread_sigmask(sig_setmask, &sigmask, &origmask); +ready = epoll_wait(epfd, &events, maxevents, timeout); +pthread_sigmask(sig_setmask, &origmask, null); +.ee +.in +.pp +the +.i sigmask +argument may be specified as null, in which case +.br epoll_pwait () +is equivalent to +.br epoll_wait (). +.\" +.ss epoll_pwait2() +the +.br epoll_pwait2 () +system call is equivalent to +.br epoll_pwait () +except for the +.i timeout +argument. +it takes an argument of type +.i timespec +to be able to specify nanosecond resolution timeout. +this argument functions the same as in +.br pselect (2) +and +.br ppoll (2). +if +.i timeout +is null, then +.br epoll_pwait2 () +can block indefinitely. +.sh return value +on success, +.br epoll_wait () +returns the number of file descriptors ready for the requested i/o, or zero +if no file descriptor became ready during the requested +.i timeout +milliseconds. +on failure, +.br epoll_wait () +returns \-1 and +.i errno +is set to indicate the error. +.sh errors +.tp +.b ebadf +.i epfd +is not a valid file descriptor. +.tp +.b efault +the memory area pointed to by +.i events +is not accessible with write permissions. +.tp +.b eintr +the call was interrupted by a signal handler before either (1) any of the +requested events occurred or (2) the +.i timeout +expired; see +.br signal (7). +.tp +.b einval +.i epfd +is not an +.b epoll +file descriptor, or +.i maxevents +is less than or equal to zero. +.sh versions +.br epoll_wait () +was added to the kernel in version 2.6. +.\" to be precise: kernel 2.5.44. +.\" the interface should be finalized by linux kernel 2.5.66. +library support is provided in glibc starting with version 2.3.2. +.pp +.br epoll_pwait () +was added to linux in kernel 2.6.19. +library support is provided in glibc starting with version 2.6. +.pp +.br epoll_pwait2 () +was added to linux in kernel 5.11. +.sh conforming to +.br epoll_wait (), +.br epoll_pwait (), +and +.br epoll_pwait2 () +are linux-specific. +.sh notes +while one thread is blocked in a call to +.br epoll_wait (), +it is possible for another thread to add a file descriptor to the waited-upon +.b epoll +instance. +if the new file descriptor becomes ready, +it will cause the +.br epoll_wait () +call to unblock. +.pp +if more than +.i maxevents +file descriptors are ready when +.br epoll_wait () +is called, then successive +.br epoll_wait () +calls will round robin through the set of ready file descriptors. +this behavior helps avoid starvation scenarios, +where a process fails to notice that additional file descriptors +are ready because it focuses on a set of file descriptors that +are already known to be ready. +.pp +note that it is possible to call +.br epoll_wait () +on an +.b epoll +instance whose interest list is currently empty +(or whose interest list becomes empty because file descriptors are closed +or removed from the interest in another thread). +the call will block until some file descriptor is later added to the +interest list (in another thread) and that file descriptor becomes ready. +.ss c library/kernel differences +the raw +.br epoll_pwait () +and +.br epoll_pwait2 () +system calls have a sixth argument, +.ir "size_t sigsetsize" , +which specifies the size in bytes of the +.ir sigmask +argument. +the glibc +.br epoll_pwait () +wrapper function specifies this argument as a fixed value +(equal to +.ir sizeof(sigset_t) ). +.sh bugs +in kernels before 2.6.37, a +.i timeout +value larger than approximately +.i long_max / hz +milliseconds is treated as \-1 (i.e., infinity). +thus, for example, on a system where +.i sizeof(long) +is 4 and the kernel +.i hz +value is 1000, +this means that timeouts greater than 35.79 minutes are treated as infinity. +.sh see also +.br epoll_create (2), +.br epoll_ctl (2), +.br epoll (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" %%%license_start(public_domain) +.\" this page is in the public domain. - aeb +.\" %%%license_end +.\" +.th unlockpt 3 2021-03-22 "" "linux programmer's manual" +.sh name +unlockpt \- unlock a pseudoterminal master/slave pair +.sh synopsis +.nf +.b #define _xopen_source +.b #include +.pp +.bi "int unlockpt(int " fd ");" +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br unlockpt (): +.nf + since glibc 2.24: + _xopen_source >= 500 +.\" || (_xopen_source && _xopen_source_extended) + glibc 2.23 and earlier: + _xopen_source +.fi +.sh description +the +.br unlockpt () +function unlocks the slave pseudoterminal device +corresponding to the master pseudoterminal referred to by the file descriptor +.ir fd . +.pp +.br unlockpt () +should be called before opening the slave side of a pseudoterminal. +.sh return value +when successful, +.br unlockpt () +returns 0. +otherwise, it returns \-1 and sets +.i errno +to indicate the error. +.sh errors +.tp +.b ebadf +the +.i fd +argument is not a file descriptor open for writing. +.tp +.b einval +the +.i fd +argument is not associated with a master pseudoterminal. +.sh versions +.br unlockpt () +is provided in glibc since version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br unlockpt () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh see also +.br grantpt (3), +.br posix_openpt (3), +.br ptsname (3), +.br pts (4), +.br pty (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man7/iso_8859-10.7 + +.so man3/getutent.3 + +.so man3/strerror.3 + +.\" copyright (c) 2003 andries brouwer (aeb@cwi.nl) +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th aio_cancel 3 2021-03-22 "" "linux programmer's manual" +.sh name +aio_cancel \- cancel an outstanding asynchronous i/o request +.sh synopsis +.nf +.b "#include " +.pp +.bi "int aio_cancel(int " fd ", struct aiocb *" aiocbp ); +.pp +link with \fi\-lrt\fp. +.fi +.sh description +the +.br aio_cancel () +function attempts to cancel outstanding asynchronous i/o requests +for the file descriptor +.ir fd . +if +.i aiocbp +is null, all such requests are canceled. +otherwise, only the request +described by the control block pointed to by +.i aiocbp +is canceled. +(see +.br aio (7) +for a description of the +.i aiocb +structure.) +.pp +normal asynchronous notification occurs for canceled requests (see +.br aio (7) +and +.br sigevent (7)). +the request return status +.rb ( aio_return (3)) +is set to \-1, and the request error status +.rb ( aio_error (3)) +is set to +.br ecanceled . +the control block of requests that cannot be canceled is not changed. +.pp +if the request could not be canceled, +then it will terminate in the usual way after performing the i/o operation. +(in this case, +.br aio_error (3) +will return the status +.br einprogresss .) +.pp +if +.i aiocbp +is not null, and +.i fd +differs from the file descriptor with which the asynchronous operation +was initiated, unspecified results occur. +.pp +which operations are cancelable is implementation-defined. +.\" freebsd: not those on raw disk devices. +.sh return value +the +.br aio_cancel () +function returns one of the following values: +.tp +.b aio_canceled +all requests were successfully canceled. +.tp +.b aio_notcanceled +at least one of the +requests specified was not canceled because it was in progress. +in this case, one may check the status of individual requests using +.br aio_error (3). +.tp +.b aio_alldone +all requests had already been completed before the call. +.tp +\-1 +an error occurred. +the cause of the error can be found by inspecting +.ir errno . +.sh errors +.tp +.b ebadf +.i fd +is not a valid file descriptor. +.tp +.b enosys +.br aio_cancel () +is not implemented. +.sh versions +the +.br aio_cancel () +function is available since glibc 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br aio_cancel () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.sh examples +see +.br aio (7). +.sh see also +.br aio_error (3), +.br aio_fsync (3), +.br aio_read (3), +.br aio_return (3), +.br aio_suspend (3), +.br aio_write (3), +.br lio_listio (3), +.br aio (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/catan.3 + +.\" copyright (c) 1999, 2000 suse gmbh nuernberg, germany +.\" author: thorsten kukuk +.\" +.\" %%%license_start(gplv2+_sw_3_para) +.\" this program is free software; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of the +.\" license, or (at your option) any later version. +.\" +.\" this program 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 +.\" general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th nscd.conf 5 2020-12-21 "gnu" "linux programmer's manual" +.sh name +nscd.conf \- name service cache daemon configuration file +.sh description +the file +.i /etc/nscd.conf +is read from +.br nscd (8) +at startup. +each line specifies either an attribute and a value, or an +attribute, service, and a value. +fields are separated either by space +or tab characters. +a \(aq#\(aq (number sign) indicates the beginning of a +comment; following characters, up to the end of the line, +are not interpreted by nscd. +.pp +valid services are \fipasswd\fp, \figroup\fp, \fihosts\fp, \fiservices\fp, +or \finetgroup\fp. +.pp +.b logfile +.i debug-file-name +.rs +specifies name of the file to which debug info should be written. +.re +.pp +.b debug\-level +.i value +.rs +sets the desired debug level. +the default is 0. +.re +.pp +.b threads +.i number +.rs +this is the number of threads that are started to wait for +requests. +at least five threads will always be created. +.re +.pp +.b max\-threads +.i number +.rs +specifies the maximum number of threads. +the default is 32. +.re +.pp +.b server\-user +.i user +.rs +if this option is set, nscd will run as this user and not as root. +if a separate cache for every user is used (\-s parameter), this +option is ignored. +.re +.pp +.b stat\-user +.i user +.rs +specifies the user who is allowed to request statistics. +.re +.pp +.b reload\-count +unlimited | +.i number +.rs +limit on the number of times a cached entry gets reloaded without being used +before it gets removed. +the default is 5. +.re +.pp +.b paranoia +.i +.rs +enabling paranoia mode causes nscd to restart itself periodically. +the default is no. +.re +.pp +.b restart\-interval +.i time +.rs +sets the restart interval to +.i time +seconds +if periodic restart is enabled by enabling +.b paranoia +mode. +the default is 3600. +.re +.pp +.b enable\-cache +.i service +.i +.rs +enables or disables the specified +.i service +cache. +the default is no. +.re +.pp +.b positive\-time\-to\-live +.i service +.i value +.rs +sets the ttl (time-to-live) for positive entries (successful queries) +in the specified cache for +.ir service . +.i value +is in seconds. +larger values increase cache hit rates and reduce mean +response times, but increase problems with cache coherence. +.re +.pp +.b negative\-time\-to\-live +.i service +.i value +.rs +sets the ttl (time-to-live) for negative entries (unsuccessful queries) +in the specified cache for +.ir service . +.i value +is in seconds. +can result in significant performance improvements if there +are several files owned by uids (user ids) not in system databases (for +example untarring the linux kernel sources as root); should be kept small +to reduce cache coherency problems. +.re +.pp +.b suggested\-size +.i service +.i value +.rs +this is the internal hash table size, +.i value +should remain a prime number for optimum efficiency. +the default is 211. +.re +.pp +.b check\-files +.i service +.i +.rs +enables or disables checking the file belonging to the specified +.i service +for changes. +the files are +.ir /etc/passwd , +.ir /etc/group , +.ir /etc/hosts , +.ir /etc/services , +and +.ir /etc/netgroup . +the default is yes. +.re +.pp +.b persistent +.i service +.i +.rs +keep the content of the cache for +.i service +over server restarts; useful when +.b paranoia +mode is set. +the default is no. +.re +.pp +.b shared +.i service +.i +.rs +the memory mapping of the nscd databases for +.i service +is shared with the clients so +that they can directly search in them instead of having to ask the +daemon over the socket each time a lookup is performed. +the default is no. +.re +.pp +.b max\-db\-size +.i service +.i bytes +.rs +the maximum allowable size, in bytes, of the database files for the +.ir service . +the default is 33554432. +.re +.pp +.b auto\-propagate +.i service +.i +.rs +when set to +.i no +for +.i passwd +or +.i group +service, then the +.i .byname +requests are not added to +.i passwd.byuid +or +.i group.bygid +cache. +this can help with tables containing multiple records for the same id. +the default is yes. +this option is valid only for services +.i passwd +and +.ir group . +.re +.sh notes +the default values stated in this manual page originate +from the source code of +.br nscd (8) +and are used if not overridden in the configuration file. +the default values used in the configuration file of +your distribution might differ. +.sh see also +.br nscd (8) +.\" .sh author +.\" .b nscd +.\" was written by thorsten kukuk and ulrich drepper. +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/asin.3 + +.so man7/system_data_types.7 + +.\" copyright (c) 2002 andries brouwer +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th intro 1 2020-08-13 "linux" "linux user's manual" +.sh name +intro \- introduction to user commands +.sh description +section 1 of the manual describes user commands and tools, +for example, file manipulation tools, shells, compilers, +web browsers, file and image viewers and editors, and so on. +.sh notes +linux is a flavor of unix, and as a first approximation +all user commands under unix work precisely the same under +linux (and freebsd and lots of other unix-like systems). +.pp +under linux, there are guis (graphical user interfaces), where you +can point and click and drag, and hopefully get work done without +first reading lots of documentation. +the traditional unix environment +is a cli (command line interface), where you type commands to +tell the computer what to do. +that is faster and more powerful, +but requires finding out what the commands are. +below a bare minimum, to get started. +.ss login +in order to start working, you probably first have to open a session by +giving your username and password. +the program +.br login (1) +now starts a +.i shell +(command interpreter) for you. +in case of a graphical login, you get a screen with menus or icons +and a mouse click will start a shell in a window. +see also +.br xterm (1). +.ss the shell +one types commands to the +.ir shell , +the command interpreter. +it is not built-in, but is just a program +and you can change your shell. +everybody has their own favorite one. +the standard one is called +.ir sh . +see also +.br ash (1), +.br bash (1), +.br chsh (1), +.br csh (1), +.br dash (1), +.br ksh (1), +.br zsh (1). +.pp +a session might go like: +.pp +.in +4n +.ex +.rb "knuth login: " aeb +.rb "password: " ******** +.rb "$ " date +tue aug 6 23:50:44 cest 2002 +.rb "$ " cal + august 2002 +su mo tu we th fr sa + 1 2 3 + 4 5 6 7 8 9 10 +11 12 13 14 15 16 17 +18 19 20 21 22 23 24 +25 26 27 28 29 30 31 + +.rb "$ " ls +bin tel +.rb "$ " "ls \-l" +total 2 +drwxrwxr\-x 2 aeb 1024 aug 6 23:51 bin +\-rw\-rw\-r\-\- 1 aeb 37 aug 6 23:52 tel +.rb "$ " "cat tel" +maja 0501\-1136285 +peter 0136\-7399214 +.rb "$ " "cp tel tel2" +.rb "$ " "ls \-l" +total 3 +drwxr\-xr\-x 2 aeb 1024 aug 6 23:51 bin +\-rw\-r\-\-r\-\- 1 aeb 37 aug 6 23:52 tel +\-rw\-r\-\-r\-\- 1 aeb 37 aug 6 23:53 tel2 +.rb "$ " "mv tel tel1" +.rb "$ " "ls \-l" +total 3 +drwxr\-xr\-x 2 aeb 1024 aug 6 23:51 bin +\-rw\-r\-\-r\-\- 1 aeb 37 aug 6 23:52 tel1 +\-rw\-r\-\-r\-\- 1 aeb 37 aug 6 23:53 tel2 +.rb "$ " "diff tel1 tel2" +.rb "$ " "rm tel1" +.rb "$ " "grep maja tel2" +maja 0501\-1136285 +$ +.ee +.in +.pp +here typing control-d ended the session. +.pp +the +.b $ +here was the command prompt\(emit is the shell's way of indicating +that it is ready for the next command. +the prompt can be customized +in lots of ways, and one might include stuff like username, +machine name, current directory, time, and so on. +an assignment ps1="what next, master? " +would change the prompt as indicated. +.pp +we see that there are commands +.i date +(that gives date and time), and +.i cal +(that gives a calendar). +.pp +the command +.i ls +lists the contents of the current directory\(emit tells you what +files you have. +with a +.i \-l +option it gives a long listing, +that includes the owner and size and date of the file, and the +permissions people have for reading and/or changing the file. +for example, the file "tel" here is 37 bytes long, owned by aeb +and the owner can read and write it, others can only read it. +owner and permissions can be changed by the commands +.i chown +and +.ir chmod . +.pp +the command +.i cat +will show the contents of a file. +(the name is from "concatenate and print": all files given as +parameters are concatenated and sent to "standard output" +(see +.br stdout (3)), +here +the terminal screen.) +.pp +the command +.i cp +(from "copy") will copy a file. +.pp +the command +.i mv +(from "move"), on the other hand, only renames it. +.pp +the command +.i diff +lists the differences between two files. +here there was no output because there were no differences. +.pp +the command +.i rm +(from "remove") deletes the file, and be careful! it is gone. +no wastepaper basket or anything. +deleted means lost. +.pp +the command +.i grep +(from "g/re/p") finds occurrences of a string in one or more files. +here it finds maja's telephone number. +.ss pathnames and the current directory +files live in a large tree, the file hierarchy. +each has a +.i "pathname" +describing the path from the root of the tree (which is called +.ir / ) +to the file. +for example, such a full pathname might be +.ir /home/aeb/tel . +always using full pathnames would be inconvenient, and the name +of a file in the current directory may be abbreviated by giving +only the last component. +that is why +.i /home/aeb/tel +can be abbreviated +to +.i tel +when the current directory is +.ir /home/aeb . +.pp +the command +.i pwd +prints the current directory. +.pp +the command +.i cd +changes the current directory. +.pp +try alternatively +.i cd +and +.i pwd +commands and explore +.i cd +usage: "cd", "cd .", "cd ..", "cd /", and "cd \(ti". +.ss directories +the command +.i mkdir +makes a new directory. +.pp +the command +.i rmdir +removes a directory if it is empty, and complains otherwise. +.pp +the command +.i find +(with a rather baroque syntax) will find files with given name +or other properties. +for example, "find . \-name tel" would find +the file +.i tel +starting in the present directory (which is called +.ir . ). +and "find / \-name tel" would do the same, but starting at the root +of the tree. +large searches on a multi-gb disk will be time-consuming, +and it may be better to use +.br locate (1). +.ss disks and filesystems +the command +.i mount +will attach the filesystem found on some disk (or floppy, or cdrom or so) +to the big filesystem hierarchy. +and +.i umount +detaches it again. +the command +.i df +will tell you how much of your disk is still free. +.ss processes +on a unix system many user and system processes run simultaneously. +the one you are talking to runs in the +.ir foreground , +the others in the +.ir background . +the command +.i ps +will show you which processes are active and what numbers these +processes have. +the command +.i kill +allows you to get rid of them. +without option this is a friendly +request: please go away. +and "kill \-9" followed by the number +of the process is an immediate kill. +foreground processes can often be killed by typing control-c. +.ss getting information +there are thousands of commands, each with many options. +traditionally commands are documented on +.ir "man pages" , +(like this one), so that the command "man kill" will document +the use of the command "kill" (and "man man" document the command "man"). +the program +.i man +sends the text through some +.ir pager , +usually +.ir less . +hit the space bar to get the next page, hit q to quit. +.pp +in documentation it is customary to refer to man pages +by giving the name and section number, as in +.br man (1). +man pages are terse, and allow you to find quickly some forgotten +detail. +for newcomers an introductory text with more examples +and explanations is useful. +.pp +a lot of gnu/fsf software is provided with info files. +type "info info" +for an introduction on the use of the program +.ir info . +.pp +special topics are often treated in howtos. +look in +.i /usr/share/doc/howto/en +and use a browser if you find html files there. +.\" +.\" actual examples? separate section for each of cat, cp, ...? +.\" gzip, bzip2, tar, rpm +.sh see also +.br ash (1), +.br bash (1), +.br chsh (1), +.br csh (1), +.br dash (1), +.br ksh (1), +.br locate (1), +.br login (1), +.br man (1), +.br xterm (1), +.br zsh (1), +.br wait (2), +.br stdout (3), +.br man\-pages (7), +.br standards (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/cpu_set.3 + +.\" copyright (c) 2015 michael kerrisk +.\" and copyright (c) 2008 petr baudis (dladdr caveat) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th dladdr 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +dladdr, dladdr1 \- translate address to symbolic information +.sh synopsis +.nf +.b #define _gnu_source +.b #include +.pp +.bi "int dladdr(const void *" addr ", dl_info *" info ); +.bi "int dladdr1(const void *" addr ", dl_info *" info ", void **" extra_info , +.bi " int " flags ); +.pp +link with \fi\-ldl\fp. +.fi +.sh description +the function +.br dladdr () +determines whether the address specified in +.ir addr +is located in one of the shared objects loaded by the calling application. +if it is, then +.br dladdr () +returns information about the shared object and symbol that overlaps +.ir addr . +this information is returned in a +.i dl_info +structure: +.pp +.in +4n +.ex +typedef struct { + const char *dli_fname; /* pathname of shared object that + contains address */ + void *dli_fbase; /* base address at which shared + object is loaded */ + const char *dli_sname; /* name of symbol whose definition + overlaps \fiaddr\fp */ + void *dli_saddr; /* exact address of symbol named + in \fidli_sname\fp */ +} dl_info; +.ee +.in +.pp +if no symbol matching +.i addr +could be found, then +.i dli_sname +and +.i dli_saddr +are set to null. +.pp +the function +.br dladdr1 () +is like +.br dladdr (), +but returns additional information via the argument +.ir extra_info . +the information returned depends on the value specified in +.ir flags , +which can have one of the following values: +.tp +.b rtld_dl_linkmap +obtain a pointer to the link map for the matched file. +the +.ir extra_info +argument points to a pointer to a +.i link_map +structure (i.e., +.ir "struct link_map\ **" ), +defined in +.i +as: +.ip +.in +4n +.ex +struct link_map { + elfw(addr) l_addr; /* difference between the + address in the elf file and + the address in memory */ + char *l_name; /* absolute pathname where + object was found */ + elfw(dyn) *l_ld; /* dynamic section of the + shared object */ + struct link_map *l_next, *l_prev; + /* chain of loaded objects */ + + /* plus additional fields private to the + implementation */ +}; +.ee +.in +.tp +.b rtld_dl_syment +obtain a pointer to the elf symbol table entry of the matching symbol. +the +.ir extra_info +argument is a pointer to a symbol pointer: +.ir "const elfw(sym) **" . +the +.ir elfw () +macro definition turns its argument into the name of an elf data +type suitable for the hardware architecture. +for example, on a 64-bit platform, +.i elfw(sym) +yields the data type name +.ir elf64_sym , +which is defined in +.ir +as: +.ip +.in +4n +.ex +typedef struct { + elf64_word st_name; /* symbol name */ + unsigned char st_info; /* symbol type and binding */ + unsigned char st_other; /* symbol visibility */ + elf64_section st_shndx; /* section index */ + elf64_addr st_value; /* symbol value */ + elf64_xword st_size; /* symbol size */ +} elf64_sym; +.ee +.in +.ip +the +.i st_name +field is an index into the string table. +.ip +the +.i st_info +field encodes the symbol's type and binding. +the type can be extracted using the macro +.br elf64_st_type(st_info) +(or +.br elf32_st_type() +on 32-bit platforms), which yields one of the following values: +.in +4n +.ts +lb lb +lb l. +value description +stt_notype symbol type is unspecified +stt_object symbol is a data object +stt_func symbol is a code object +stt_section symbol associated with a section +stt_file symbol's name is filename +stt_common symbol is a common data object +stt_tls symbol is thread-local data object +stt_gnu_ifunc symbol is indirect code object +.te +.in +.ip +the symbol binding can be extracted from the +.i st_info +field using the macro +.br elf64_st_bind(st_info) +(or +.br elf32_st_bind() +on 32-bit platforms), which yields one of the following values: +.in +4n +.ts +lb lb +lb l. +value description +stb_local local symbol +stb_global global symbol +stb_weak weak symbol +stb_gnu_unique unique symbol +.te +.in +.ip +the +.i st_other +field contains the symbol's visibility, which can be extracted using the macro +.br elf64_st_visibility(st_info) +(or +.br elf32_st_visibility() +on 32-bit platforms), which yields one of the following values: +.in +4n +.ts +lb lb +lb l. +value description +stv_default default symbol visibility rules +stv_internal processor-specific hidden class +stv_hidden symbol unavailable in other modules +stv_protected not preemptible, not exported +.te +.in +.sh return value +on success, these functions return a nonzero value. +if the address specified in +.i addr +could be matched to a shared object, +but not to a symbol in the shared object, then the +.i info\->dli_sname +and +.i info\->dli_saddr +fields are set to null. +.pp +if the address specified in +.i addr +could not be matched to a shared object, then these functions return 0. +in this case, an error message is +.i not +.\" according to the freebsd man page, dladdr1() does signal an +.\" error via dlerror() for this case. +available via +.br dlerror (3). +.sh versions +.br dladdr () +is present in glibc 2.0 and later. +.br dladdr1 () +first appeared in glibc 2.3.3. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br dladdr (), +.br dladdr1 () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +these functions are nonstandard gnu extensions +that are also present on solaris. +.sh bugs +sometimes, the function pointers you pass to +.br dladdr () +may surprise you. +on some architectures (notably i386 and x86-64), +.i dli_fname +and +.i dli_fbase +may end up pointing back at the object from which you called +.br dladdr (), +even if the function used as an argument should come from +a dynamically linked library. +.pp +the problem is that the function pointer will still be resolved +at compile time, but merely point to the +.i plt +(procedure linkage table) +section of the original object (which dispatches the call after +asking the dynamic linker to resolve the symbol). +to work around this, +you can try to compile the code to be position-independent: +then, the compiler cannot prepare the pointer +at compile time any more and +.br gcc (1) +will generate code that just loads the final symbol address from the +.i got +(global offset table) at run time before passing it to +.br dladdr (). +.sh see also +.br dl_iterate_phdr (3), +.br dlinfo (3), +.br dlopen (3), +.br dlsym (3), +.br ld.so (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2018 eugene syromyatnikov +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th s390_guarded_storage 2 2021-03-22 "linux programmer's manual" +.sh name +s390_guarded_storage \- operations with z/architecture guarded storage facility +.sh synopsis +.nf +.br "#include " "/* definition of " gs_* " constants */" +.br "#include " \ +"/* definition of " sys_* " constants */" +.b #include +.pp +.bi "int syscall(sys_s390_guarded_storage, int " command , +.bi " struct gs_cb *" gs_cb ); +.fi +.pp +.ir note : +glibc provides no wrapper for +.br s390_guarded_storage (), +necessitating the use of +.br syscall (2). +.sh description +the +.br s390_guarded_storage () +system call enables the use of the guarded storage facility +(a z/architecture-specific feature) for user-space processes. +.pp +.\" the description is based on +.\" http://www-05.ibm.com/de/linux-on-z-ws-us/agenda/pdfs/8_-_linux_whats_new_-_stefan_raspl.pdf +.\" and "z/architecture principles of operation" obtained from +.\" http://publibfi.boulder.ibm.com/epubs/pdf/dz9zr011.pdf +the guarded storage facility is a hardware feature that allows marking up to +64 memory regions (as of z14) as guarded; +reading a pointer with a newly introduced "load guarded" (lgg) +or "load logical and shift guarded" (llgfsg) instructions will cause +a range check on the loaded value and invoke a (previously set up) +user-space handler if one of the guarded regions is affected. +.pp +the +.\" the command description is copied from v4.12-rc1~139^2~56^2 commit message +.i command +argument indicates which function to perform. +the following commands are supported: +.tp +.b gs_enable +enable the guarded storage facility for the calling task. +the initial content of the guarded storage control block will be all zeros. +after enablement, user-space code can use the "load guarded storage +controls" (lgsc) instruction (or the +.br load_gs_cb () +function wrapper provided in the +.i asm/guarded_storage.h +header) to load an arbitrary control block. +while a task is enabled, the kernel will save and restore the calling content +of the guarded storage registers on context switch. +.tp +.b gs_disable +disables the use of the guarded storage facility for the calling task. +the kernel will cease to save and restore the content of the guarded storage +registers, the task-specific content of these registers is lost. +.tp +.b gs_set_bc_cb +set a broadcast guarded storage control block to the one provided in the +.i gs_cb +argument. +this is called per thread and associates a specific guarded storage control +block with the calling task. +this control block will be used in the broadcast command +.br gs_broadcast . +.tp +.b gs_clear_bc_cb +clears the broadcast guarded storage control block. +the guarded storage control block will no longer have the association +established by the +.b gs_set_bc_cb +command. +.tp +.b gs_broadcast +sends a broadcast to all thread siblings of the calling task. +every sibling that has established a broadcast guarded storage control block +will load this control block and will be enabled for guarded storage. +the broadcast guarded storage control block is consumed; a second broadcast +without a refresh of the stored control block with +.b gs_set_bc_cb +will not have any effect. +.pp +the +.i gs_cb +argument specifies the address of a guarded storage control block structure +and is currently used only by the +.b gs_set_bc_cb +command; all other aforementioned commands ignore this argument. +.sh return value +on success, the return value of +.br s390_guarded_storage () +is 0. +.pp +on error, \-1 is returned, and +.ir errno +is set to indicate the error. +.sh errors +.tp +.b efault +.i command +was +.br gs_set_bc_cb +and the copying of the guarded storage control block structure pointed by the +.i gs_cb +argument has failed. +.tp +.b einval +the value provided in the +.i command +argument was not valid. +.tp +.b enomem +.i command +was one of +.br gs_enable " or " gs_set_bc_cb , +and the allocation of a new guarded storage control block has failed. +.tp +.b eopnotsupp +the guarded storage facility is not supported by the hardware. +.sh versions +.\" 916cda1aa1b412d7cf2991c3af7479544942d121, v4.12-rc1~139^2~56^2 +this system call is available since linux 4.12. +.sh conforming to +this linux-specific system call is available only on the s390 architecture. +.pp +the guarded storage facility is available beginning with system z14. +.sh notes +the description of the guarded storage facility along with related +instructions and guarded storage control block and +guarded storage event parameter list structure layouts +is available in "z/architecture principles of operations" +beginning from the twelfth edition. +.pp +the +.i gs_cb +structure has a field +.i gsepla +(guarded storage event parameter list address), which is a user-space pointer +to a guarded storage event parameter list structure +(that contains the address +of the aforementioned event handler in the +.i gseha +field), and its layout is available as a +.b gs_epl +structure type definition in the +.i asm/guarded_storage.h +header. +.\" .pp +.\" for the example of using the guarded storage facility, see +.\" .ur https://developer.ibm.com/javasdk/2017/09/25/concurrent-scavenge-using-guarded-storage-facility-works/ +.\" the article with the description of its usage in the java garbage collection +.\" .ue +.sh see also +.br syscall (2) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2016 michael kerrisk +.\" and copyright (c) 2016 eugene syromyatnikov +.\" a very few fragments remain from an earlier version of this page +.\" written by david howells (dhowells@redhat.com) +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th keyctl 2 2021-08-27 linux "linux key management calls" +.sh name +keyctl \- manipulate the kernel's key management facility +.sh synopsis +.nf +.br "#include " " /* definition of " key* " constants */" +.br "#include " " /* definition of " sys_* " constants */" +.b #include +.pp +.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 : +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. +.pp +the operation performed by +.br keyctl () +is determined by the value of the +.i operation +argument. +each of these operations is wrapped by the +.i libkeyutils +library (provided by the +.i keyutils +package) into individual functions (noted below) +to permit the compiler to check types. +.pp +the permitted values for +.i operation +are: +.tp +.br keyctl_get_keyring_id " (since linux 2.6.10)" +map a special key id to a real key id for this process. +.ip +this operation looks up the special key whose id is provided in +.i arg2 +(cast to +.ir key_serial_t ). +if the special key is found, +the id of the corresponding real key is returned as the function result. +the following values may be specified in +.ir arg2 : +.rs +.tp +.b key_spec_thread_keyring +this specifies the calling thread's thread-specific keyring. +see +.br thread\-keyring (7). +.tp +.b key_spec_process_keyring +this specifies the caller's process-specific keyring. +see +.br process\-keyring (7). +.tp +.b key_spec_session_keyring +this specifies the caller's session-specific keyring. +see +.br session\-keyring (7). +.tp +.b key_spec_user_keyring +this specifies the caller's uid-specific keyring. +see +.br user\-keyring (7). +.tp +.b key_spec_user_session_keyring +this specifies the caller's uid-session keyring. +see +.br user\-session\-keyring (7). +.tp +.br key_spec_reqkey_auth_key " (since linux 2.6.16)" +.\" commit b5f545c880a2a47947ba2118b2509644ab7a2969 +this specifies the authorization key created by +.br request_key (2) +and passed to the process it spawns to generate a key. +this key is available only in a +.br request\-key (8)-style +program that was passed an authorization key by the kernel and +ceases to be available once the requested key has been instantiated; see +.br request_key (2). +.tp +.br key_spec_requestor_keyring " (since linux 2.6.29)" +.\" commit 8bbf4976b59fc9fc2861e79cab7beb3f6d647640 +this specifies the key id for the +.br request_key (2) +destination keyring. +this keyring is available only in a +.br request\-key (8)-style +program that was passed an authorization key by the kernel and +ceases to be available once the requested key has been instantiated; see +.br request_key (2). +.re +.ip +the behavior if the key specified in +.i arg2 +does not exist depends on the value of +.i arg3 +(cast to +.ir int ). +if +.i arg3 +contains a nonzero value, then\(emif it is appropriate to do so +(e.g., when looking up the user, user-session, or session key)\(ema new key +is created and its real key id returned as the function result. +.\" the keyctl_get_keyring_id.3 page says that a new key +.\" "will be created *if it is appropriate to do so**. what is the +.\" determiner for appropriate? +.\" david howells: some special keys such as key_spec_reqkey_auth_key +.\" wouldn't get created but user/user-session/session keyring would +.\" be created. +otherwise, the operation fails with the error +.br enokey . +.ip +if a valid key id is specified in +.ir arg2 , +and the key exists, then this operation simply returns the key id. +if the key does not exist, the call fails with error +.br enokey . +.ip +the caller must have +.i search +permission on a keyring in order for it to be found. +.ip +the arguments +.ir arg4 +and +.ir arg5 +are ignored. +.ip +this operation is exposed by +.i libkeyutils +via the function +.br keyctl_get_keyring_id (3). +.tp +.br keyctl_join_session_keyring " (since linux 2.6.10)" +replace the session keyring this process subscribes to with +a new session keyring. +.\" this may be useful in conjunction with some sort of +.\" session management framework that is employed by the application. +.ip +if +.i arg2 +is null, +an anonymous keyring with the description "_ses" is created +and the process is subscribed to that keyring as its session keyring, +displacing the previous session keyring. +.ip +otherwise, +.i arg2 +(cast to +.ir "char\ *" ) +is treated as the description (name) of a keyring, +and the behavior is as follows: +.rs +.ip * 3 +if a keyring with a matching description exists, +the process will attempt to subscribe to that keyring +as its session keyring if possible; +if that is not possible, an error is returned. +in order to subscribe to the keyring, +the caller must have +.i search +permission on the keyring. +.ip * +if a keyring with a matching description does not exist, +then a new keyring with the specified description is created, +and the process is subscribed to that keyring as its session keyring. +.re +.ip +the arguments +.ir arg3 , +.ir arg4 , +and +.ir arg5 +are ignored. +.ip +this operation is exposed by +.i libkeyutils +via the function +.br keyctl_join_session_keyring (3). +.tp +.br keyctl_update " (since linux 2.6.10)" +update a key's data payload. +.ip +the +.i arg2 +argument (cast to +.ir key_serial_t ) +specifies the id of the key to be updated. +the +.i arg3 +argument (cast to +.ir "void\ *" ) +points to the new payload and +.i arg4 +(cast to +.ir size_t ) +contains the new payload size in bytes. +.ip +the caller must have +.i write +permission on the key specified and the key type must support updating. +.ip +a negatively instantiated key (see the description of +.br keyctl_reject ) +can be positively instantiated with this operation. +.ip +the +.i arg5 +argument is ignored. +.ip +this operation is exposed by +.i libkeyutils +via the function +.br keyctl_update (3). +.tp +.br keyctl_revoke " (since linux 2.6.10)" +revoke the key with the id provided in +.i arg2 +(cast to +.ir key_serial_t ). +the key is scheduled for garbage collection; +it will no longer be findable, +and will be unavailable for further operations. +further attempts to use the key will fail with the error +.br ekeyrevoked . +.ip +the caller must have +.ir write +or +.ir setattr +permission on the key. +.\" keys with the key_flag_keep bit set cause an eperm +.\" error for keyctl_revoke. does this need to be documented? +.\" david howells: no significance for user space. +.ip +the arguments +.ir arg3 , +.ir arg4 , +and +.ir arg5 +are ignored. +.ip +this operation is exposed by +.i libkeyutils +via the function +.br keyctl_revoke (3). +.tp +.br keyctl_chown " (since linux 2.6.10)" +change the ownership (user and group id) of a key. +.ip +the +.i arg2 +argument (cast to +.ir key_serial_t ) +contains the key id. +the +.i arg3 +argument (cast to +.ir uid_t ) +contains the new user id (or \-1 in case the user id shouldn't be changed). +the +.i arg4 +argument (cast to +.ir gid_t ) +contains the new group id (or \-1 in case the group id shouldn't be changed). +.ip +the key must grant the caller +.i setattr +permission. +.ip +for the uid to be changed, or for the gid to be changed to a group +the caller is not a member of, the caller must have the +.b cap_sys_admin +capability (see +.br capabilities (7)). +.ip +if the uid is to be changed, the new user must have sufficient +quota to accept the key. +the quota deduction will be removed from the old user +to the new user should the uid be changed. +.ip +the +.i arg5 +argument is ignored. +.ip +this operation is exposed by +.i libkeyutils +via the function +.br keyctl_chown (3). +.tp +.br keyctl_setperm " (since linux 2.6.10)" +change the permissions of the key with the id provided in the +.i arg2 +argument (cast to +.ir key_serial_t ) +to the permissions provided in the +.i arg3 +argument (cast to +.ir key_perm_t ). +.ip +if the caller doesn't have the +.b cap_sys_admin +capability, it can change permissions only for the keys it owns. +(more precisely: the caller's filesystem uid must match the uid of the key.) +.ip +the key must grant +.i setattr +permission to the caller +.ir regardless +of the caller's capabilities. +.\" fixme above, is it really intended that a privileged process can't +.\" override the lack of the 'setattr' permission? +.ip +the permissions in +.ir arg3 +specify masks of available operations +for each of the following user categories: +.rs +.tp +.ir possessor " (since linux 2.6.14)" +.\" commit 664cceb0093b755739e56572b836a99104ee8a75 +this is the permission granted to a process that possesses the key +(has it attached searchably to one of the process's keyrings); +see +.br keyrings (7). +.tp +.ir user +this is the permission granted to a process +whose filesystem uid matches the uid of the key. +.tp +.ir group +this is the permission granted to a process +whose filesystem gid or any of its supplementary gids +matches the gid of the key. +.tp +.ir other +this is the permission granted to other processes +that do not match the +.ir user +and +.ir group +categories. +.re +.ip +the +.ir user , +.ir group , +and +.ir other +categories are exclusive: if a process matches the +.ir user +category, it will not receive permissions granted in the +.ir group +category; if a process matches the +.i user +or +.ir group +category, then it will not receive permissions granted in the +.ir other +category. +.ip +the +.i possessor +category grants permissions that are cumulative with the grants from the +.ir user , +.ir group , +or +.ir other +category. +.ip +each permission mask is eight bits in size, +with only six bits currently used. +the available permissions are: +.rs +.tp +.ir view +this permission allows reading attributes of a key. +.ip +this permission is required for the +.br keyctl_describe +operation. +.ip +the permission bits for each category are +.br key_pos_view , +.br key_usr_view , +.br key_grp_view , +and +.br key_oth_view . +.tp +.ir read +this permission allows reading a key's payload. +.ip +this permission is required for the +.br keyctl_read +operation. +.ip +the permission bits for each category are +.br key_pos_read , +.br key_usr_read , +.br key_grp_read , +and +.br key_oth_read . +.tp +.ir write +this permission allows update or instantiation of a key's payload. +for a keyring, it allows keys to be linked and unlinked from the keyring, +.ip +this permission is required for the +.br keyctl_update , +.br keyctl_revoke , +.br keyctl_clear , +.br keyctl_link , +and +.br keyctl_unlink +operations. +.ip +the permission bits for each category are +.br key_pos_write , +.br key_usr_write , +.br key_grp_write , +and +.br key_oth_write . +.tp +.ir search +this permission allows keyrings to be searched and keys to be found. +searches can recurse only into nested keyrings that have +.i search +permission set. +.ip +this permission is required for the +.br keyctl_get_keyring_id , +.br keyctl_join_session_keyring , +.br keyctl_search , +and +.br keyctl_invalidate +operations. +.ip +the permission bits for each category are +.br key_pos_search , +.br key_usr_search , +.br key_grp_search , +and +.br key_oth_search . +.tp +.ir link +this permission allows a key or keyring to be linked to. +.ip +this permission is required for the +.br keyctl_link +and +.br keyctl_session_to_parent +operations. +.ip +the permission bits for each category are +.br key_pos_link , +.br key_usr_link , +.br key_grp_link , +and +.br key_oth_link . +.tp +.ir setattr " (since linux 2.6.15)." +this permission allows a key's uid, gid, and permissions mask to be changed. +.ip +this permission is required for the +.br keyctl_revoke , +.br keyctl_chown , +and +.br keyctl_setperm +operations. +.ip +the permission bits for each category are +.br key_pos_setattr , +.br key_usr_setattr , +.br key_grp_setattr , +and +.br key_oth_setattr . +.re +.ip +as a convenience, the following macros are defined as masks for +all of the permission bits in each of the user categories: +.br key_pos_all , +.br key_usr_all , +.br key_grp_all , +and +.br key_oth_all . +.ip +the +.ir arg4 " and " arg5 +arguments are ignored. +.ip +this operation is exposed by +.i libkeyutils +via the function +.br keyctl_setperm (3). +.tp +.br keyctl_describe " (since linux 2.6.10)" +obtain a string describing the attributes of a specified key. +.ip +the id of the key to be described is specified in +.i arg2 +(cast to +.ir key_serial_t ). +the descriptive string is returned in the buffer pointed to by +.i arg3 +(cast to +.ir "char\ *" ); +.i arg4 +(cast to +.ir size_t ) +specifies the size of that buffer in bytes. +.ip +the key must grant the caller +.i view +permission. +.ip +the returned string is null-terminated and +contains the following information about the key: +.ip +.in +4n +.ir type ; uid ; gid ; perm ; description +.in +.ip +in the above, +.ir type +and +.ir description +are strings, +.ir uid +and +.ir gid +are decimal strings, and +.i perm +is a hexadecimal permissions mask. +the descriptive string is written with the following format: +.ip + %s;%d;%d;%08x;%s +.ip +.br "note: the intention is that the descriptive string should" +.br "be extensible in future kernel versions". +in particular, the +.ir description +field will not contain semicolons; +.\" fixme but, the kernel does not enforce the requirement +.\" that the key description contains no semicolons! +.\" so, user space has no guarantee here?? +.\" either something more needs to be said here, +.\" or a kernel fix is required. +it should be parsed by working backwards from the end of the string +to find the last semicolon. +this allows future semicolon-delimited fields to be inserted +in the descriptive string in the future. +.ip +writing to the buffer is attempted only when +.ir arg3 +is non-null and the specified buffer size +is large enough to accept the descriptive string +(including the terminating null byte). +.\" function commentary says it copies up to buflen bytes, but see the +.\" (buffer && buflen >= ret) condition in keyctl_describe_key() in +.\" security/keyctl.c +in order to determine whether the buffer size was too small, +check to see if the return value of the operation is greater than +.ir arg4 . +.ip +the +.i arg5 +argument is ignored. +.ip +this operation is exposed by +.i libkeyutils +via the function +.br keyctl_describe (3). +.tp +.b keyctl_clear +clear the contents of (i.e., unlink all keys from) a keyring. +.ip +the id of the key +(which must be of keyring type) +.\" or the error enotdir results +is provided in +.i arg2 +(cast to +.ir key_serial_t ). +.\" according to documentation/security/keys.txt: +.\" this function can also be used to clear special kernel keyrings if they +.\" are appropriately marked if the user has cap_sys_admin capability. the +.\" dns resolver cache keyring is an example of this. +.ip +the caller must have +.i write +permission on the keyring. +.ip +the arguments +.ir arg3 , +.ir arg4 , +and +.ir arg5 +are ignored. +.ip +this operation is exposed by +.i libkeyutils +via the function +.br keyctl_clear (3). +.tp +.br keyctl_link " (since linux 2.6.10)" +create a link from a keyring to a key. +.ip +the key to be linked is specified in +.ir arg2 +(cast to +.ir key_serial_t ); +the keyring is specified in +.ir arg3 +(cast to +.ir key_serial_t ). +.ip +if a key with the same type and description is already linked in the keyring, +then that key is displaced from the keyring. +.ip +before creating the link, +the kernel checks the nesting of the keyrings and returns appropriate errors +if the link would produce a cycle +or if the nesting of keyrings would be too deep +(the limit on the nesting of keyrings is determined by the kernel constant +.br keyring_search_max_depth , +defined with the value 6, and is necessary to prevent overflows +on the kernel stack when recursively searching keyrings). +.ip +the caller must have +.i link +permission on the key being added and +.i write +permission on the keyring. +.ip +the arguments +.ir arg4 +and +.ir arg5 +are ignored. +.ip +this operation is exposed by +.i libkeyutils +via the function +.br keyctl_link (3). +.tp +.br keyctl_unlink " (since linux 2.6.10)" +unlink a key from a keyring. +.ip +the id of the key to be unlinked is specified in +.i arg2 +(cast to +.ir key_serial_t ); +the id of the keyring from which it is to be unlinked is specified in +.i arg3 +(cast to +.ir key_serial_t ). +.ip +if the key is not currently linked into the keyring, an error results. +.ip +the caller must have +.i write +permission on the keyring from which the key is being removed. +.ip +if the last link to a key is removed, +then that key will be scheduled for destruction. +.ip +the arguments +.ir arg4 +and +.ir arg5 +are ignored. +.ip +this operation is exposed by +.i libkeyutils +via the function +.br keyctl_unlink (3). +.tp +.br keyctl_search " (since linux 2.6.10)" +search for a key in a keyring tree, +returning its id and optionally linking it to a specified keyring. +.ip +the tree to be searched is specified by passing +the id of the head keyring in +.ir arg2 +(cast to +.ir key_serial_t ). +the search is performed breadth-first and recursively. +.ip +the +.i arg3 +and +.i arg4 +arguments specify the key to be searched for: +.i arg3 +(cast as +.ir "char\ *" ) +contains the key type +(a null-terminated character string up to 32 bytes in size, +including the terminating null byte), and +.i arg4 +(cast as +.ir "char\ *" ) +contains the description of the key +(a null-terminated character string up to 4096 bytes in size, +including the terminating null byte). +.ip +the source keyring must grant +.i search +permission to the caller. +when performing the recursive search, only keyrings that grant the caller +.i search +permission will be searched. +only keys with for which the caller has +.i search +permission can be found. +.ip +if the key is found, its id is returned as the function result. +.ip +if the key is found and +.i arg5 +(cast to +.ir key_serial_t ) +is nonzero, then, subject to the same constraints and rules as +.br keyctl_link , +the key is linked into the keyring whose id is specified in +.ir arg5 . +if the destination keyring specified in +.i arg5 +already contains a link to a key that has the same type and description, +then that link will be displaced by a link to +the key found by this operation. +.ip +instead of valid existing keyring ids, the source +.ri ( arg2 ) +and destination +.ri ( arg5 ) +keyrings can be one of the special keyring ids listed under +.br keyctl_get_keyring_id . +.ip +this operation is exposed by +.i libkeyutils +via the function +.br keyctl_search (3). +.tp +.br keyctl_read " (since linux 2.6.10)" +read the payload data of a key. +.ip +the id of the key whose payload is to be read is specified in +.i arg2 +(cast to +.ir key_serial_t ). +this can be the id of an existing key, +or any of the special key ids listed for +.br keyctl_get_keyring_id . +.\" including key_spec_reqkey_auth_key +.ip +the payload is placed in the buffer pointed by +.i arg3 +(cast to +.ir "char\ *" ); +the size of that buffer must be specified in +.i arg4 +(cast to +.ir size_t ). +.ip +the returned data will be processed for presentation +according to the key type. +for example, a keyring will return an array of +.i key_serial_t +entries representing the ids of all the keys that are linked to it. +the +.ir "user" +key type will return its data as is. +if a key type does not implement this function, +the operation fails with the error +.br eopnotsupp . +.ip +if +.i arg3 +is not null, +as much of the payload data as will fit is copied into the buffer. +on a successful return, +the return value is always the total size of the payload data. +to determine whether the buffer was of sufficient size, +check to see that the return value is less than or equal to +the value supplied in +.ir arg4 . +.ip +the key must either grant the caller +.i read +permission, or grant the caller +.i search +permission when searched for from the process keyrings +(i.e., the key is possessed). +.ip +the +.i arg5 +argument is ignored. +.ip +this operation is exposed by +.i libkeyutils +via the function +.br keyctl_read (3). +.tp +.br keyctl_instantiate " (since linux 2.6.10)" +(positively) instantiate an uninstantiated key with a specified payload. +.ip +the id of the key to be instantiated is provided in +.i arg2 +(cast to +.ir key_serial_t ). +.ip +the key payload is specified in the buffer pointed to by +.i arg3 +(cast to +.ir "void\ *"); +the size of that buffer is specified in +.i arg4 +(cast to +.ir size_t ). +.ip +the payload may be a null pointer and the buffer size may be 0 +if this is supported by the key type (e.g., it is a keyring). +.ip +the operation may be fail if the payload data is in the wrong format +or is otherwise invalid. +.ip +if +.i arg5 +(cast to +.ir key_serial_t ) +is nonzero, then, subject to the same constraints and rules as +.br keyctl_link , +the instantiated key is linked into the keyring whose id specified in +.ir arg5 . +.ip +the caller must have the appropriate authorization key, +and once the uninstantiated key has been instantiated, +the authorization key is revoked. +in other words, this operation is available only from a +.br request\-key (8)-style +program. +see +.br request_key (2) +for an explanation of uninstantiated keys and key instantiation. +.ip +this operation is exposed by +.i libkeyutils +via the function +.br keyctl_instantiate (3). +.tp +.br keyctl_negate " (since linux 2.6.10)" +negatively instantiate an uninstantiated key. +.ip +this operation is equivalent to the call: +.ip + keyctl(keyctl_reject, arg2, arg3, enokey, arg4); +.ip +the +.i arg5 +argument is ignored. +.ip +this operation is exposed by +.i libkeyutils +via the function +.br keyctl_negate (3). +.tp +.br keyctl_set_reqkey_keyring " (since linux 2.6.13)" +set the default keyring to which implicitly requested keys +will be linked for this thread, and return the previous setting. +implicit key requests are those made by internal kernel components, +.\" i.e., calls to the kernel's internal request_key() interface, +.\" which is distinct from the request_key(2) system call (which +.\" ultimately employs the kernel-internal interface). +such as can occur when, for example, opening files +on an afs or nfs filesystem. +setting the default keyring also has an effect when requesting +a key from user space; see +.br request_key (2) +for details. +.ip +the +.i arg2 +argument (cast to +.ir int ) +should contain one of the following values, +to specify the new default keyring: +.rs +.tp +.br key_reqkey_defl_no_change +don't change the default keyring. +this can be used to discover the current default keyring +(without changing it). +.tp +.br key_reqkey_defl_default +this selects the default behaviour, +which is to use the thread-specific keyring if there is one, +otherwise the process-specific keyring if there is one, +otherwise the session keyring if there is one, +otherwise the uid-specific session keyring, +otherwise the user-specific keyring. +.tp +.br key_reqkey_defl_thread_keyring +use the thread-specific keyring +.rb ( thread\-keyring (7)) +as the new default keyring. +.tp +.br key_reqkey_defl_process_keyring +use the process-specific keyring +.rb ( process\-keyring (7)) +as the new default keyring. +.tp +.br key_reqkey_defl_session_keyring +use the session-specific keyring +.rb ( session\-keyring (7)) +as the new default keyring. +.tp +.br key_reqkey_defl_user_keyring +use the uid-specific keyring +.rb ( user\-keyring (7)) +as the new default keyring. +.tp +.br key_reqkey_defl_user_session_keyring +use the uid-specific session keyring +.rb ( user\-session\-keyring (7)) +as the new default keyring. +.tp +.br key_reqkey_defl_requestor_keyring " (since linux 2.6.29)" +.\" 8bbf4976b59fc9fc2861e79cab7beb3f6d647640 +use the requestor keyring. +.\" fixme the preceding explanation needs to be expanded. +.\" is the following correct: +.\" +.\" the requestor keyring is the dest_keyring that +.\" was supplied to a call to request_key(2)? +.\" +.\" david howells said: to be checked +.re +.ip +all other values are invalid. +.\" (including the still-unsupported key_reqkey_defl_group_keyring) +.ip +the arguments +.ir arg3 , +.ir arg4 , +and +.ir arg5 +are ignored. +.ip +the setting controlled by this operation is inherited by the child of +.br fork (2) +and preserved across +.br execve (2). +.ip +this operation is exposed by +.i libkeyutils +via the function +.br keyctl_set_reqkey_keyring (3). +.tp +.br keyctl_set_timeout " (since linux 2.6.16)" +set a timeout on a key. +.ip +the id of the key is specified in +.i arg2 +(cast to +.ir key_serial_t ). +the timeout value, in seconds from the current time, +is specified in +.i arg3 +(cast to +.ir "unsigned int" ). +the timeout is measured against the realtime clock. +.ip +specifying the timeout value as 0 clears any existing timeout on the key. +.ip +the +.i /proc/keys +file displays the remaining time until each key will expire. +(this is the only method of discovering the timeout on a key.) +.ip +the caller must either have the +.i setattr +permission on the key +or hold an instantiation authorization token for the key (see +.br request_key (2)). +.ip +the key and any links to the key will be +automatically garbage collected after the timeout expires. +subsequent attempts to access the key will then fail with the error +.br ekeyexpired . +.ip +this operation cannot be used to set timeouts on revoked, expired, +or negatively instantiated keys. +.ip +the arguments +.ir arg4 +and +.ir arg5 +are ignored. +.ip +this operation is exposed by +.i libkeyutils +via the function +.br keyctl_set_timeout (3). +.tp +.br keyctl_assume_authority " (since linux 2.6.16)" +assume (or divest) the authority for the calling thread +to instantiate a key. +.ip +the +.i arg2 +argument (cast to +.ir key_serial_t ) +specifies either a nonzero key id to assume authority, +or the value 0 to divest authority. +.ip +if +.i arg2 +is nonzero, then it specifies the id of an uninstantiated key for which +authority is to be assumed. +that key can then be instantiated using one of +.br keyctl_instantiate , +.br keyctl_instantiate_iov , +.br keyctl_reject , +or +.br keyctl_negate . +once the key has been instantiated, +the thread is automatically divested of authority to instantiate the key. +.ip +authority over a key can be assumed only if the calling thread has present +in its keyrings the authorization key that is +associated with the specified key. +(in other words, the +.br keyctl_assume_authority +operation is available only from a +.br request\-key (8)-style +program; see +.br request_key (2) +for an explanation of how this operation is used.) +the caller must have +.i search +permission on the authorization key. +.ip +if the specified key has a matching authorization key, +then the id of that key is returned. +the authorization key can be read +.rb ( keyctl_read ) +to obtain the callout information passed to +.br request_key (2). +.ip +if the id given in +.i arg2 +is 0, then the currently assumed authority is cleared (divested), +and the value 0 is returned. +.ip +the +.br keyctl_assume_authority +mechanism allows a program such as +.br request\-key (8) +to assume the necessary authority to instantiate a new uninstantiated key +that was created as a consequence of a call to +.br request_key (2). +for further information, see +.br request_key (2) +and the kernel source file +.ir documentation/security/keys\-request\-key.txt . +.ip +the arguments +.ir arg3 , +.ir arg4 , +and +.ir arg5 +are ignored. +.ip +this operation is exposed by +.i libkeyutils +via the function +.br keyctl_assume_authority (3). +.tp +.br keyctl_get_security " (since linux 2.6.26)" +.\" commit 70a5bb72b55e82fbfbf1e22cae6975fac58a1e2d +get the lsm (linux security module) security label of the specified key. +.ip +the id of the key whose security label is to be fetched is specified in +.i arg2 +(cast to +.ir key_serial_t ). +the security label (terminated by a null byte) +will be placed in the buffer pointed to by +.i arg3 +argument (cast to +.ir "char\ *" ); +the size of the buffer must be provided in +.i arg4 +(cast to +.ir size_t ). +.ip +if +.i arg3 +is specified as null or the buffer size specified in +.ir arg4 +is too small, the full size of the security label string +(including the terminating null byte) +is returned as the function result, +and nothing is copied to the buffer. +.ip +the caller must have +.i view +permission on the specified key. +.ip +the returned security label string will be rendered in a form appropriate +to the lsm in force. +for example, with selinux, it may look like: +.ip + unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 +.ip +if no lsm is currently in force, +then an empty string is placed in the buffer. +.ip +the +.i arg5 +argument is ignored. +.ip +this operation is exposed by +.i libkeyutils +via the functions +.br keyctl_get_security (3) +and +.br keyctl_get_security_alloc (3). +.tp +.br keyctl_session_to_parent " (since linux 2.6.32)" +.\" commit ee18d64c1f632043a02e6f5ba5e045bb26a5465f +replace the session keyring to which the +.i parent +of the calling process +subscribes with the session keyring of the calling process. +.\" what is the use case for keyctl_session_to_parent? +.\" david howells: the process authentication groups people requested this, +.\" but then didn't use it; maybe there are no users. +.ip +the keyring will be replaced in the parent process at the point +where the parent next transitions from kernel space to user space. +.ip +the keyring must exist and must grant the caller +.i link +permission. +the parent process must be single-threaded and have +the same effective ownership as this process +and must not be set-user-id or set-group-id. +the uid of the parent process's existing session keyring (f it has one), +as well as the uid of the caller's session keyring +much match the caller's effective uid. +.ip +the fact that it is the parent process that is affected by this operation +allows a program such as the shell to start a child process that +uses this operation to change the shell's session keyring. +(this is what the +.br keyctl (1) +.b new_session +command does.) +.ip +the arguments +.ir arg2 , +.ir arg3 , +.ir arg4 , +and +.ir arg5 +are ignored. +.ip +this operation is exposed by +.i libkeyutils +via the function +.br keyctl_session_to_parent (3). +.tp +.br keyctl_reject " (since linux 2.6.39)" +.\" commit fdd1b94581782a2ddf9124414e5b7a5f48ce2f9c +mark a key as negatively instantiated and set an expiration timer +on the key. +this operation provides a superset of the functionality of the earlier +.br keyctl_negate +operation. +.ip +the id of the key that is to be negatively instantiated is specified in +.i arg2 +(cast to +.ir key_serial_t ). +the +.i arg3 +(cast to +.ir "unsigned int" ) +argument specifies the lifetime of the key, in seconds. +the +.i arg4 +argument (cast to +.ir "unsigned int" ) +specifies the error to be returned when a search hits this key; +typically, this is one of +.br ekeyrejected , +.br ekeyrevoked , +or +.br ekeyexpired . +.ip +if +.i arg5 +(cast to +.ir key_serial_t ) +is nonzero, then, subject to the same constraints and rules as +.br keyctl_link , +the negatively instantiated key is linked into the keyring +whose id is specified in +.ir arg5 . +.ip +the caller must have the appropriate authorization key. +in other words, this operation is available only from a +.br request\-key (8)-style +program. +see +.br request_key (2). +.ip +the caller must have the appropriate authorization key, +and once the uninstantiated key has been instantiated, +the authorization key is revoked. +in other words, this operation is available only from a +.br request\-key (8)-style +program. +see +.br request_key (2) +for an explanation of uninstantiated keys and key instantiation. +.ip +this operation is exposed by +.i libkeyutils +via the function +.br keyctl_reject (3). +.tp +.br keyctl_instantiate_iov " (since linux 2.6.39)" +.\" commit ee009e4a0d4555ed522a631bae9896399674f063 +instantiate an uninstantiated key with a payload specified +via a vector of buffers. +.ip +this operation is the same as +.br keyctl_instantiate , +but the payload data is specified as an array of +.ir iovec +structures: +.ip +.in +4n +.ex +struct iovec { + void *iov_base; /* starting address of buffer */ + size_t iov_len; /* size of buffer (in bytes) */ +}; +.ee +.in +.ip +the pointer to the payload vector is specified in +.ir arg3 +(cast as +.ir "const struct iovec\ *" ). +the number of items in the vector is specified in +.ir arg4 +(cast as +.ir "unsigned int" ). +.ip +the +.i arg2 +(key id) +and +.i arg5 +(keyring id) +are interpreted as for +.br keyctl_instantiate . +.ip +this operation is exposed by +.i libkeyutils +via the function +.br keyctl_instantiate_iov (3). +.tp +.br keyctl_invalidate " (since linux 3.5)" +.\" commit fd75815f727f157a05f4c96b5294a4617c0557da +mark a key as invalid. +.ip +the id of the key to be invalidated is specified in +.i arg2 +(cast to +.ir key_serial_t ). +.ip +to invalidate a key, +the caller must have +.i search +permission on the key. +.\" cap_sys_admin is permitted to invalidate certain special keys +.ip +this operation marks the key as invalid +and schedules immediate garbage collection. +the garbage collector removes the invalidated key from all keyrings and +deletes the key when its reference count reaches zero. +after this operation, +the key will be ignored by all searches, +even if it is not yet deleted. +.ip +keys that are marked invalid become invisible to normal key operations +immediately, though they are still visible in +.i /proc/keys +(marked with an 'i' flag) +until they are actually removed. +.ip +the arguments +.ir arg3 , +.ir arg4 , +and +.ir arg5 +are ignored. +.ip +this operation is exposed by +.i libkeyutils +via the function +.br keyctl_invalidate (3). +.tp +.br keyctl_get_persistent " (since linux 3.13)" +.\" commit f36f8c75ae2e7d4da34f4c908cebdb4aa42c977e +get the persistent keyring +.rb ( persistent\-keyring (7)) +for a specified user and link it to a specified keyring. +.ip +the user id is specified in +.i arg2 +(cast to +.ir uid_t ). +if the value \-1 is specified, the caller's real user id is used. +the id of the destination keyring is specified in +.i arg3 +(cast to +.ir key_serial_t ). +.ip +the caller must have the +.br cap_setuid +capability in its user namespace in order to fetch the persistent keyring +for a user id that does not match either the real or effective user id +of the caller. +.ip +if the call is successful, +a link to the persistent keyring is added to the keyring +whose id was specified in +.ir arg3 . +.ip +the caller must have +.i write +permission on the keyring. +.ip +the persistent keyring will be created by the kernel +if it does not yet exist. +.ip +each time the +.b keyctl_get_persistent +operation is performed, the persistent keyring will +have its expiration timeout reset to the value in: +.ip +.in +4n +.ex +/proc/sys/kernel/keys/persistent_keyring_expiry +.ee +.in +.ip +should the timeout be reached, +the persistent keyring will be removed and +everything it pins can then be garbage collected. +.ip +persistent keyrings were added to linux in kernel version 3.13. +.ip +the arguments +.ir arg4 +and +.ir arg5 +are ignored. +.ip +this operation is exposed by +.i libkeyutils +via the function +.br keyctl_get_persistent (3). +.tp +.br keyctl_dh_compute " (since linux 4.7)" +.\" commit ddbb41148724367394d0880c516bfaeed127b52e +compute a diffie-hellman shared secret or public key, +optionally applying key derivation function (kdf) to the result. +.ip +the +.i arg2 +argument is a pointer to a set of parameters containing +serial numbers for three +.ir """user""" +keys used in the diffie-hellman calculation, +packaged in a structure of the following form: +.ip +.in +4n +.ex +struct keyctl_dh_params { + int32_t private; /* the local private key */ + int32_t prime; /* the prime, known to both parties */ + int32_t base; /* the base integer: either a shared + generator or the remote public key */ +}; +.ee +.in +.ip +each of the three keys specified in this structure must grant the caller +.i read +permission. +the payloads of these keys are used to calculate the diffie-hellman +result as: +.ip + base \(ha private mod prime +.ip +if the base is the shared generator, the result is the local public key. +if the base is the remote public key, the result is the shared secret. +.ip +the +.i arg3 +argument (cast to +.ir "char\ *" ) +points to a buffer where the result of the calculation is placed. +the size of that buffer is specified in +.i arg4 +(cast to +.ir size_t ). +.ip +the buffer must be large enough to accommodate the output data, +otherwise an error is returned. +if +.i arg4 +is specified zero, +in which case the buffer is not used and +the operation returns the minimum required buffer size +(i.e., the length of the prime). +.ip +diffie-hellman computations can be performed in user space, +but require a multiple-precision integer (mpi) library. +moving the implementation into the kernel gives access to +the kernel mpi implementation, +and allows access to secure or acceleration hardware. +.ip +adding support for dh computation to the +.br keyctl () +system call was considered a good fit due to the dh algorithm's use +for deriving shared keys; +it also allows the type of the key to determine +which dh implementation (software or hardware) is appropriate. +.\" commit f1c316a3ab9d24df6022682422fe897492f2c0c8 +.ip +if the +.i arg5 +argument is +.br null , +then the dh result itself is returned. +otherwise (since linux 4.12), it is a pointer to a structure which specifies +parameters of the kdf operation to be applied: +.ip +.in +4n +.ex +struct keyctl_kdf_params { + char *hashname; /* hash algorithm name */ + char *otherinfo; /* sp800\-56a otherinfo */ + __u32 otherinfolen; /* length of otherinfo data */ + __u32 __spare[8]; /* reserved */ +}; +.ee +.in +.ip +the +.i hashname +field is a null-terminated string which specifies a hash name +(available in the kernel's crypto api; the list of the hashes available +is rather tricky to observe; please refer to the +.ur https://www.kernel.org\:/doc\:/html\:/latest\:/crypto\:/architecture.html +"kernel crypto api architecture" +.ue +documentation for the information regarding how hash names are constructed and +your kernel's source and configuration regarding what ciphers +and templates with type +.b crypto_alg_type_shash +are available) +to be applied to dh result in kdf operation. +.ip +the +.i otherinfo +field is an +.i otherinfo +data as described in sp800-56a section 5.8.1.2 and is algorithm-specific. +this data is concatenated with the result of dh operation and is provided as +an input to the kdf operation. +its size is provided in the +.i otherinfolen +field and is limited by +.b keyctl_kdf_max_oi_len +constant that defined in +.i security/keys/internal.h +to a value of 64. +.ip +the +.b __spare +field is currently unused. +.\" commit 4f9dabfaf8df971f8a3b6aa324f8f817be38d538 +it was ignored until linux 4.13 (but still should be +user-addressable since it is copied to the kernel), +and should contain zeros since linux 4.13. +.ip +the kdf implementation complies with sp800-56a as well +as with sp800-108 (the counter kdf). +.ip +.\" keyutils commit 742c9d7b94051d3b21f9f61a73ed6b5f3544cb82 +.\" keyutils commit d68a981e5db41d059ac782071c35d1e8f3aaf61c +this operation is exposed by +.i libkeyutils +(from version 1.5.10 onwards) via the functions +.br keyctl_dh_compute (3) +and +.br keyctl_dh_compute_alloc (3). +.tp +.br keyctl_restrict_keyring " (since linux 4.12)" +.\" commit 6563c91fd645556c7801748f15bc727c77fcd311 +.\" commit 7228b66aaf723a623e578aa4db7d083bb39546c9 +apply a key-linking restriction to the keyring with the id provided in +.ir arg2 +(cast to +.ir key_serial_t ). +the caller must have +.ir setattr +permission on the key. +if +.i arg3 +is null, any attempt to add a key to the keyring is blocked; +otherwise it contains a pointer to a string with a key type name and +.i arg4 +contains a pointer to string that describes the type-specific restriction. +as of linux 4.12, only the type "asymmetric" has restrictions defined: +.rs +.tp +.b builtin_trusted +allows only keys that are signed by a key linked to the built-in keyring +(".builtin_trusted_keys"). +.tp +.b builtin_and_secondary_trusted +allows only keys that are signed by a key linked to the secondary keyring +(".secondary_trusted_keys") or, by extension, a key in a built-in keyring, +as the latter is linked to the former. +.tp +.bi key_or_keyring: key +.tq +.bi key_or_keyring: key :chain +if +.i key +specifies the id of a key of type "asymmetric", +then only keys that are signed by this key are allowed. +.ip +if +.i key +specifies the id of a keyring, +then only keys that are signed by a key linked +to this keyring are allowed. +.ip +if ":chain" is specified, keys that are signed by a keys linked to the +destination keyring (that is, the keyring with the id specified in the +.i arg2 +argument) are also allowed. +.re +.ip +note that a restriction can be configured only once for the specified keyring; +once a restriction is set, it can't be overridden. +.ip +the argument +.i arg5 +is ignored. +.\" fixme document keyctl_restrict_keyring, added in linux 4.12 +.\" commit 6563c91fd645556c7801748f15bc727c77fcd311 +.\" author: mat martineau +.\" see documentation/security/keys.txt +.sh return value +for a successful call, the return value depends on the operation: +.tp +.b keyctl_get_keyring_id +the id of the requested keyring. +.tp +.b keyctl_join_session_keyring +the id of the joined session keyring. +.tp +.b keyctl_describe +the size of the description (including the terminating null byte), +irrespective of the provided buffer size. +.tp +.b keyctl_search +the id of the key that was found. +.tp +.b keyctl_read +the amount of data that is available in the key, +irrespective of the provided buffer size. +.tp +.b keyctl_set_reqkey_keyring +the id of the previous default keyring +to which implicitly requested keys were linked +(one of +.br key_reqkey_defl_user_* ). +.tp +.b keyctl_assume_authority +either 0, if the id given was 0, +or the id of the authorization key matching the specified key, +if a nonzero key id was provided. +.tp +.b keyctl_get_security +the size of the lsm security label string +(including the terminating null byte), +irrespective of the provided buffer size. +.tp +.b keyctl_get_persistent +the id of the persistent keyring. +.tp +.b keyctl_dh_compute +the number of bytes copied to the buffer, or, if +.i arg4 +is 0, the required buffer size. +.tp +all other operations +zero. +.pp +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eacces +the requested operation wasn't permitted. +.tp +.b eagain +.i operation +was +.b keyctl_dh_compute +and there was an error during crypto module initialization. +.tp +.b edeadlk +.i operation +was +.br keyctl_link +and the requested link would result in a cycle. +.tp +.b edeadlk +.i operation +was +.br keyctl_restrict_keyring +and the requested keyring restriction would result in a cycle. +.tp +.b edquot +the key quota for the caller's user would be exceeded by creating a key or +linking it to the keyring. +.tp +.b eexist +.i operation +was +.br keyctl_restrict_keyring +and keyring provided in +.i arg2 +argument already has a restriction set. +.tp +.b efault +.i operation +was +.b keyctl_dh_compute +and one of the following has failed: +.rs +.ip \(bu 3 +copying of the +.ir "struct keyctl_dh_params" , +provided in the +.i arg2 +argument, from user space; +.ip \(bu +copying of the +.ir "struct keyctl_kdf_params" , +provided in the non-null +.i arg5 +argument, from user space +(in case kernel supports performing kdf operation on dh operation result); +.ip \(bu +copying of data pointed by the +.i hashname +field of the +.i "struct keyctl_kdf_params" +from user space; +.ip \(bu +copying of data pointed by the +.i otherinfo +field of the +.i struct keyctl_kdf_params +from user space if the +.i otherinfolen +field was nonzero; +.ip \(bu +copying of the result to user space. +.re +.tp +.b einval +.i operation +was +.b keyctl_setperm +and an invalid permission bit was specified in +.ir arg3 . +.tp +.b einval +.i operation +was +.br keyctl_search +and the size of the description in +.ir arg4 +(including the terminating null byte) exceeded 4096 bytes. +.tp +.b einval +size of the string (including the terminating null byte) specified in +.i arg3 +(the key type) +or +.i arg4 +(the key description) +exceeded the limit (32 bytes and 4096 bytes respectively). +.tp +.br einval " (linux kernels before 4.12)" +.i operation +was +.br keyctl_dh_compute , +argument +.i arg5 +was non-null. +.tp +.b einval +.i operation +was +.b keyctl_dh_compute +and the digest size of the hashing algorithm supplied is zero. +.tp +.b einval +.i operation +was +.b keyctl_dh_compute +and the buffer size provided is not enough to hold the result. +provide 0 as a buffer size in order to obtain the minimum buffer size. +.tp +.b einval +.i operation +was +.b keyctl_dh_compute +and the hash name provided in the +.i hashname +field of the +.i struct keyctl_kdf_params +pointed by +.i arg5 +argument is too big (the limit is implementation-specific and varies between +kernel versions, but it is deemed big enough for all valid algorithm names). +.tp +.b einval +.\" commit 4f9dabfaf8df971f8a3b6aa324f8f817be38d538 +.i operation +was +.b keyctl_dh_compute +and the +.i __spare +field of the +.i struct keyctl_kdf_params +provided in the +.i arg5 +argument contains nonzero values. +.tp +.b ekeyexpired +an expired key was found or specified. +.tp +.b ekeyrejected +a rejected key was found or specified. +.tp +.b ekeyrevoked +a revoked key was found or specified. +.tp +.b eloop +.i operation +was +.br keyctl_link +and the requested link would cause the maximum nesting depth +for keyrings to be exceeded. +.tp +.b emsgsize +.i operation +was +.b keyctl_dh_compute +and the buffer length exceeds +.b keyctl_kdf_max_output_len +(which is 1024 currently) +or the +.i otherinfolen +field of the +.i struct keyctl_kdf_parms +passed in +.i arg5 +exceeds +.b keyctl_kdf_max_oi_len +(which is 64 currently). +.tp +.br enfile " (linux kernels before 3.13)" +.ir operation +was +.br keyctl_link +and the keyring is full. +(before linux 3.13, +.\" commit b2a4df200d570b2c33a57e1ebfa5896e4bc81b69 +the available space for storing keyring links was limited to +a single page of memory; since linux 3.13, there is no fixed limit.) +.tp +.b enoent +.i operation +was +.b keyctl_unlink +and the key to be unlinked isn't linked to the keyring. +.tp +.b enoent +.i operation +was +.b keyctl_dh_compute +and the hashing algorithm specified in the +.i hashname +field of the +.i struct keyctl_kdf_params +pointed by +.i arg5 +argument hasn't been found. +.tp +.b enoent +.i operation +was +.b keyctl_restrict_keyring +and the type provided in +.i arg3 +argument doesn't support setting key linking restrictions. +.tp +.b enokey +no matching key was found or an invalid key was specified. +.tp +.b enokey +the value +.b keyctl_get_keyring_id +was specified in +.ir operation , +the key specified in +.i arg2 +did not exist, and +.i arg3 +was zero (meaning don't create the key if it didn't exist). +.tp +.b enomem +one of kernel memory allocation routines failed during the execution of the +syscall. +.tp +.b enotdir +a key of keyring type was expected but the id of a key with +a different type was provided. +.tp +.b eopnotsupp +.i operation +was +.b keyctl_read +and the key type does not support reading +(e.g., the type is +.ir """login""" ). +.tp +.b eopnotsupp +.i operation +was +.b keyctl_update +and the key type does not support updating. +.tp +.b eopnotsupp +.i operation +was +.br keyctl_restrict_keyring , +the type provided in +.i arg3 +argument was "asymmetric", and the key specified in the restriction specification +provided in +.i arg4 +has type other than "asymmetric" or "keyring". +.tp +.b eperm +.i operation +was +.br keyctl_get_persistent , +.i arg2 +specified a uid other than the calling thread's real or effective uid, +and the caller did not have the +.b cap_setuid +capability. +.tp +.b eperm +.i operation +was +.br keyctl_session_to_parent +and either: +all of the uids (gids) of the parent process do not match +the effective uid (gid) of the calling process; +the uid of the parent's existing session keyring or +the uid of the caller's session keyring did not match +the effective uid of the caller; +the parent process is not single-thread; +or the parent process is +.br init (1) +or a kernel thread. +.tp +.b etimedout +.i operation +was +.b keyctl_dh_compute +and the initialization of crypto modules has timed out. +.sh versions +this system call first appeared in linux 2.6.10. +.sh conforming to +this system call is a nonstandard linux extension. +.sh notes +a wrapper is provided in the +.ir libkeyutils +library. +(the accompanying package provides the +.i +header file.) +when employing the wrapper in that library, link with +.ir \-lkeyutils . +however, rather than using this system call directly, +you probably want to use the various library functions +mentioned in the descriptions of individual operations above. +.sh examples +the program below provide subset of the functionality of the +.br request\-key (8) +program provided by the +.i keyutils +package. +for informational purposes, +the program records various information in a log file. +.pp +as described in +.br request_key (2), +the +.br request\-key (8) +program is invoked with command-line arguments that +describe a key that is to be instantiated. +the example program fetches and logs these arguments. +the program assumes authority to instantiate the requested key, +and then instantiates that key. +.pp +the following shell session demonstrates the use of this program. +in the session, +we compile the program and then use it to temporarily replace the standard +.br request\-key (8) +program. +(note that temporarily disabling the standard +.br request\-key (8) +program may not be safe on some systems.) +while our example program is installed, +we use the example program shown in +.br request_key (2) +to request a key. +.pp +.in +4n +.ex +$ \fbcc \-o key_instantiate key_instantiate.c \-lkeyutils\fp +$ \fbsudo mv /sbin/request\-key /sbin/request\-key.backup\fp +$ \fbsudo cp key_instantiate /sbin/request\-key\fp +$ \fb./t_request_key user mykey somepayloaddata\fp +key id is 20d035bf +$ \fbsudo mv /sbin/request\-key.backup /sbin/request\-key\fp +.ee +.in +.pp +looking at the log file created by this program, +we can see the command-line arguments supplied to our example program: +.pp +.in +4n +.ex +$ \fbcat /tmp/key_instantiate.log\fp +time: mon nov 7 13:06:47 2016 + +command line arguments: + argv[0]: /sbin/request\-key + operation: create + key_to_instantiate: 20d035bf + uid: 1000 + gid: 1000 + thread_keyring: 0 + process_keyring: 0 + session_keyring: 256e6a6 + +key description: user;1000;1000;3f010000;mykey +auth key payload: somepayloaddata +destination keyring: 256e6a6 +auth key description: .request_key_auth;1000;1000;0b010000;20d035bf +.ee +.in +.pp +the last few lines of the above output show that the example program +was able to fetch: +.ip * 3 +the description of the key to be instantiated, +which included the name of the key +.ri ( mykey ); +.ip * +the payload of the authorization key, which consisted of the data +.ri ( somepayloaddata ) +passed to +.br request_key (2); +.ip * +the destination keyring that was specified in the call to +.br request_key (2); +and +.ip * +the description of the authorization key, +where we can see that the name of the authorization key matches +the id of the key that is to be instantiated +.ri ( 20d035bf ). +.pp +the example program in +.br request_key (2) +specified the destination keyring as +.br key_spec_session_keyring . +by examining the contents of +.ir /proc/keys , +we can see that this was translated to the id of the destination keyring +.ri ( 0256e6a6 ) +shown in the log output above; +we can also see the newly created key with the name +.ir mykey +and id +.ir 20d035bf . +.pp +.in +4n +.ex +$ \fbcat /proc/keys | egrep \(aqmykey|256e6a6\(aq\fp +0256e6a6 i\-\-q\-\-\- 194 perm 3f030000 1000 1000 keyring _ses: 3 +20d035bf i\-\-q\-\-\- 1 perm 3f010000 1000 1000 user mykey: 16 +.ee +.in +.ss program source +\& +.ex +/* key_instantiate.c */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef key_spec_requestor_keyring +#define key_spec_requestor_keyring \-8 +#endif + +int +main(int argc, char *argv[]) +{ + file *fp; + time_t t; + char *operation; + key_serial_t key_to_instantiate, dest_keyring; + key_serial_t thread_keyring, process_keyring, session_keyring; + uid_t uid; + gid_t gid; + char dbuf[256]; + char auth_key_payload[256]; + int akp_size; /* size of auth_key_payload */ + int auth_key; + + fp = fopen("/tmp/key_instantiate.log", "w"); + if (fp == null) + exit(exit_failure); + + setbuf(fp, null); + + t = time(null); + fprintf(fp, "time: %s\en", ctime(&t)); + + /* + * the kernel passes a fixed set of arguments to the program + * that it execs; fetch them. + */ + operation = argv[1]; + key_to_instantiate = atoi(argv[2]); + uid = atoi(argv[3]); + gid = atoi(argv[4]); + thread_keyring = atoi(argv[5]); + process_keyring = atoi(argv[6]); + session_keyring = atoi(argv[7]); + + fprintf(fp, "command line arguments:\en"); + fprintf(fp, " argv[0]: %s\en", argv[0]); + fprintf(fp, " operation: %s\en", operation); + fprintf(fp, " key_to_instantiate: %jx\en", + (uintmax_t) key_to_instantiate); + fprintf(fp, " uid: %jd\en", (intmax_t) uid); + fprintf(fp, " gid: %jd\en", (intmax_t) gid); + fprintf(fp, " thread_keyring: %jx\en", + (uintmax_t) thread_keyring); + fprintf(fp, " process_keyring: %jx\en", + (uintmax_t) process_keyring); + fprintf(fp, " session_keyring: %jx\en", + (uintmax_t) session_keyring); + fprintf(fp, "\en"); + + /* + * assume the authority to instantiate the key named in argv[2]. + */ + if (keyctl(keyctl_assume_authority, key_to_instantiate) == \-1) { + fprintf(fp, "keyctl_assume_authority failed: %s\en", + strerror(errno)); + exit(exit_failure); + } + + /* + * fetch the description of the key that is to be instantiated. + */ + if (keyctl(keyctl_describe, key_to_instantiate, + dbuf, sizeof(dbuf)) == \-1) { + fprintf(fp, "keyctl_describe failed: %s\en", strerror(errno)); + exit(exit_failure); + } + + fprintf(fp, "key description: %s\en", dbuf); + + /* + * fetch the payload of the authorization key, which is + * actually the callout data given to request_key(). + */ + akp_size = keyctl(keyctl_read, key_spec_reqkey_auth_key, + auth_key_payload, sizeof(auth_key_payload)); + if (akp_size == \-1) { + fprintf(fp, "keyctl_read failed: %s\en", strerror(errno)); + exit(exit_failure); + } + + auth_key_payload[akp_size] = \(aq\e0\(aq; + fprintf(fp, "auth key payload: %s\en", auth_key_payload); + + /* + * for interest, get the id of the authorization key and + * display it. + */ + auth_key = keyctl(keyctl_get_keyring_id, + key_spec_reqkey_auth_key); + if (auth_key == \-1) { + fprintf(fp, "keyctl_get_keyring_id failed: %s\en", + strerror(errno)); + exit(exit_failure); + } + + fprintf(fp, "auth key id: %jx\en", (uintmax_t) auth_key); + + /* + * fetch key id for the request_key(2) destination keyring. + */ + dest_keyring = keyctl(keyctl_get_keyring_id, + key_spec_requestor_keyring); + if (dest_keyring == \-1) { + fprintf(fp, "keyctl_get_keyring_id failed: %s\en", + strerror(errno)); + exit(exit_failure); + } + + fprintf(fp, "destination keyring: %jx\en", (uintmax_t) dest_keyring); + + /* + * fetch the description of the authorization key. this + * allows us to see the key type, uid, gid, permissions, + * and description (name) of the key. among other things, + * we will see that the name of the key is a hexadecimal + * string representing the id of the key to be instantiated. + */ + if (keyctl(keyctl_describe, key_spec_reqkey_auth_key, + dbuf, sizeof(dbuf)) == \-1) { + fprintf(fp, "keyctl_describe failed: %s\en", strerror(errno)); + exit(exit_failure); + } + + fprintf(fp, "auth key description: %s\en", dbuf); + + /* + * instantiate the key using the callout data that was supplied + * in the payload of the authorization key. + */ + if (keyctl(keyctl_instantiate, key_to_instantiate, + auth_key_payload, akp_size + 1, dest_keyring) == \-1) { + fprintf(fp, "keyctl_instantiate failed: %s\en", + strerror(errno)); + exit(exit_failure); + } + + exit(exit_success); +} +.ee +.sh see also +.ad l +.nh +.br keyctl (1), +.br add_key (2), +.br request_key (2), +.\" .br find_key_by_type_and_name (3) +.\" there is a man page, but this function seems not to exist +.br keyctl (3), +.br keyctl_assume_authority (3), +.br keyctl_chown (3), +.br keyctl_clear (3), +.br keyctl_describe (3), +.br keyctl_describe_alloc (3), +.br keyctl_dh_compute (3), +.br keyctl_dh_compute_alloc (3), +.br keyctl_get_keyring_id (3), +.br keyctl_get_persistent (3), +.br keyctl_get_security (3), +.br keyctl_get_security_alloc (3), +.br keyctl_instantiate (3), +.br keyctl_instantiate_iov (3), +.br keyctl_invalidate (3), +.br keyctl_join_session_keyring (3), +.br keyctl_link (3), +.br keyctl_negate (3), +.br keyctl_read (3), +.br keyctl_read_alloc (3), +.br keyctl_reject (3), +.br keyctl_revoke (3), +.br keyctl_search (3), +.br keyctl_session_to_parent (3), +.br keyctl_set_reqkey_keyring (3), +.br keyctl_set_timeout (3), +.br keyctl_setperm (3), +.br keyctl_unlink (3), +.br keyctl_update (3), +.br recursive_key_scan (3), +.br recursive_session_key_scan (3), +.br capabilities (7), +.br credentials (7), +.br keyrings (7), +.br keyutils (7), +.br persistent\-keyring (7), +.br process\-keyring (7), +.br session\-keyring (7), +.br thread\-keyring (7), +.br user\-keyring (7), +.br user_namespaces (7), +.br user\-session\-keyring (7), +.br request\-key (8) +.pp +the kernel source files under +.ir documentation/security/keys/ +(or, before linux 4.13, in the file +.ir documentation/security/keys.txt ). +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/slist.3 + +.so man3/lround.3 + +.so man3/nextup.3 + +.\" copyright (c) 2003 davide libenzi +.\" and copyright 2008, 2009, 2012 michael kerrisk +.\" davide libenzi +.\" +.\" %%%license_start(gplv2+_sw_3_para) +.\" this program is free software; you can redistribute it and/or modify +.\" it under the terms of the gnu general public license as published by +.\" the free software foundation; either version 2 of the license, or +.\" (at your option) any later version. +.\" +.\" this program 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" modified 2004-06-17 by michael kerrisk +.\" modified 2005-04-04 by marko kohtala +.\" 2008-10-10, mtk: add description of epoll_create1() +.\" +.th epoll_create 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +epoll_create, epoll_create1 \- open an epoll file descriptor +.sh synopsis +.nf +.b #include +.pp +.bi "int epoll_create(int " size ); +.bi "int epoll_create1(int " flags ); +.fi +.sh description +.br epoll_create () +creates a new +.br epoll (7) +instance. +since linux 2.6.8, the +.i size +argument is ignored, but must be greater than zero; see notes. +.pp +.br epoll_create () +returns a file descriptor referring to the new epoll instance. +this file descriptor is used for all the subsequent calls to the +.b epoll +interface. +when no longer required, the file descriptor returned by +.br epoll_create () +should be closed by using +.br close (2). +when all file descriptors referring to an epoll instance have been closed, +the kernel destroys the instance +and releases the associated resources for reuse. +.ss epoll_create1() +if +.i flags +is 0, then, other than the fact that the obsolete +.i size +argument is dropped, +.br epoll_create1 () +is the same as +.br epoll_create (). +the following value can be included in +.ir flags +to obtain different behavior: +.tp +.b epoll_cloexec +set the close-on-exec +.rb ( fd_cloexec ) +flag on the new file descriptor. +see the description of the +.b o_cloexec +flag in +.br open (2) +for reasons why this may be useful. +.sh return value +on success, +these system calls +return a file descriptor (a nonnegative integer). +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b einval +.i size +is not positive. +.tp +.b einval +.rb ( epoll_create1 ()) +invalid value specified in +.ir flags . +.tp +.b emfile +the per-user limit on the number of epoll instances imposed by +.i /proc/sys/fs/epoll/max_user_instances +was encountered. +see +.br epoll (7) +for further details. +.tp +.b emfile +the per-process limit on the number of open file descriptors has been reached. +.tp +.b enfile +the system-wide limit on the total number of open files has been reached. +.tp +.b enomem +there was insufficient memory to create the kernel object. +.sh versions +.br epoll_create () +was added to the kernel in version 2.6. +library support is provided in glibc starting with version 2.3.2. +.pp +.\" to be precise: kernel 2.5.44. +.\" the interface should be finalized by linux kernel 2.5.66. +.br epoll_create1 () +was added to the kernel in version 2.6.27. +library support is provided in glibc starting with version 2.9. +.sh conforming to +.br epoll_create () +and +.br epoll_create1 () +are linux-specific. +.sh notes +in the initial +.br epoll_create () +implementation, the +.i size +argument informed the kernel of the number of file descriptors +that the caller expected to add to the +.b epoll +instance. +the kernel used this information as a hint for the amount of +space to initially allocate in internal data structures describing events. +(if necessary, the kernel would allocate more space +if the caller's usage exceeded the hint given in +.ir size .) +nowadays, +this hint is no longer required +(the kernel dynamically sizes the required data structures +without needing the hint), but +.i size +must still be greater than zero, +in order to ensure backward compatibility when new +.b epoll +applications are run on older kernels. +.sh see also +.br close (2), +.br epoll_ctl (2), +.br epoll_wait (2), +.br epoll (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/catanh.3 + +.\" copyright 2005, 2012, 2016 michael kerrisk +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under the gpl. +.\" %%%license_end +.\" +.\" 2008-12-04, petr baudis : document open_wmemstream() +.\" +.th open_memstream 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +open_memstream, open_wmemstream \- open a dynamic memory buffer stream +.sh synopsis +.nf +.b #include +.pp +.bi "file *open_memstream(char **" ptr ", size_t *" sizeloc ); +.pp +.b #include +.pp +.bi "file *open_wmemstream(wchar_t **" ptr ", size_t *" sizeloc ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br open_memstream (), +.br open_wmemstream (): +.nf + since glibc 2.10: + _posix_c_source >= 200809l + before glibc 2.10: + _gnu_source +.fi +.sh description +the +.br open_memstream () +function opens a stream for writing to a memory buffer. +the function dynamically allocates the buffer, +and the buffer automatically grows as needed. +initially, the buffer has a size of zero. +after closing the stream, the caller should +.br free (3) +this buffer. +.pp +the locations pointed to by +.ir ptr +and +.i sizeloc +are used to report, respectively, +the current location and the size of the buffer. +the locations referred to by these pointers are updated +each time the stream is flushed +.rb ( fflush (3)) +and when the stream is closed +.rb ( fclose (3)). +these values remain valid only as long as the caller +performs no further output on the stream. +if further output is performed, then the stream +must again be flushed before trying to access these values. +.pp +a null byte is maintained at the end of the buffer. +this byte is +.i not +included in the size value stored at +.ir sizeloc . +.pp +the stream maintains the notion of a current position, +which is initially zero (the start of the buffer). +each write operation implicitly adjusts the buffer position. +the stream's buffer position can be explicitly changed with +.br fseek (3) +or +.br fseeko (3). +moving the buffer position past the end +of the data already written fills the intervening space with +null characters. +.pp +the +.br open_wmemstream () +is similar to +.br open_memstream (), +but operates on wide characters instead of bytes. +.sh return value +upon successful completion, +.br open_memstream () +and +.br open_wmemstream () +return a +.i file +pointer. +otherwise, null is returned and +.i errno +is set to indicate the error. +.sh versions +.br open_memstream () +was already available in glibc 1.0.x. +.br open_wmemstream () +is available since glibc 2.4. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br open_memstream (), +.br open_wmemstream () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2008. +these functions are not specified in posix.1-2001, +and are not widely available on other systems. +.sh notes +there is no file descriptor associated with the file stream +returned by these functions +(i.e., +.br fileno (3) +will return an error if called on the returned stream). +.sh bugs +in glibc before version 2.7, seeking past the end of a stream created by +.br open_memstream () +does not enlarge the buffer; instead the +.br fseek (3) +call fails, returning \-1. +.\" http://sourceware.org/bugzilla/show_bug.cgi?id=1996 +.sh examples +see +.br fmemopen (3). +.sh see also +.br fmemopen (3), +.br fopen (3), +.br setbuf (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/strchr.3 + +.so man3/unlocked_stdio.3 + +.so man3/unlocked_stdio.3 + +.\" copyright 2003 walter harms (walter.harms@informatik.uni-oldenburg.de) +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under gpl +.\" %%%license_end +.\" +.th putgrent 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +putgrent \- write a group database entry to a file +.sh synopsis +.nf +.br "#define _gnu_source" " /* see feature_test_macros(7) */" +.b #include +.pp +.bi "int putgrent(const struct group *restrict " grp \ +", file *restrict " stream ); +.fi +.sh description +the +.br putgrent () +function is the counterpart for +.br fgetgrent (3). +the function writes the content of the provided +.ir "struct group" +into the +.ir stream . +the list of group members must be null-terminated or null-initialized. +.pp +the +.ir "struct group" +is defined as follows: +.pp +.in +4n +.ex +struct group { + char *gr_name; /* group name */ + char *gr_passwd; /* group password */ + gid_t gr_gid; /* group id */ + char **gr_mem; /* group members */ +}; +.ee +.in +.sh return value +the function returns zero on success, and a nonzero value on error. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br putgrent () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +this function is a gnu extension. +.sh see also +.br fgetgrent (3), +.br getgrent (3), +.br group (5) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/gethostbyname.3 + +.\" copyright (c) 2014, theodore ts'o +.\" copyright (c) 2014,2015 heinrich schuchardt +.\" copyright (c) 2015, michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of +.\" this manual under the conditions for verbatim copying, provided that +.\" the entire resulting derived work is distributed under the terms of +.\" a permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume. +.\" no responsibility for errors or omissions, or for damages resulting. +.\" from the use of the information contained herein. the author(s) may. +.\" not have taken the same level of care in the production of this. +.\" manual, which is licensed free of charge, as they might when working. +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th getrandom 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +getrandom \- obtain a series of random bytes +.sh synopsis +.nf +.b #include +.pp +.bi "ssize_t getrandom(void *"buf ", size_t " buflen ", unsigned int " flags ); +.fi +.sh description +the +.br getrandom () +system call fills the buffer pointed to by +.i buf +with up to +.i buflen +random bytes. +these bytes can be used to seed user-space random number generators +or for cryptographic purposes. +.pp +by default, +.br getrandom () +draws entropy from the +.i urandom +source (i.e., the same source as the +.ir /dev/urandom +device). +this behavior can be changed via the +.i flags +argument. +.pp +if the +.i urandom +source has been initialized, +reads of up to 256 bytes will always return as many bytes as +requested and will not be interrupted by signals. +no such guarantees apply for larger buffer sizes. +for example, if the call is interrupted by a signal handler, +it may return a partially filled buffer, or fail with the error +.br eintr . +.pp +if the +.i urandom +source has not yet been initialized, then +.br getrandom () +will block, unless +.b grnd_nonblock +is specified in +.ir flags . +.pp +the +.i flags +argument is a bit mask that can contain zero or more of the following values +ored together: +.tp +.b grnd_random +if this bit is set, then random bytes are drawn from the +.i random +source +(i.e., the same source as the +.ir /dev/random +device) +instead of the +.i urandom +source. +the +.i random +source is limited based on the entropy that can be obtained from environmental +noise. +if the number of available bytes in the +.i random +source is less than requested in +.ir buflen , +the call returns just the available random bytes. +if no random bytes are available, the behavior depends on the presence of +.b grnd_nonblock +in the +.i flags +argument. +.tp +.b grnd_nonblock +by default, when reading from the +.ir random +source, +.br getrandom () +blocks if no random bytes are available, +and when reading from the +.ir urandom +source, it blocks if the entropy pool has not yet been initialized. +if the +.b grnd_nonblock +flag is set, then +.br getrandom () +does not block in these cases, but instead immediately returns \-1 with +.i errno +set to +.br eagain . +.sh return value +on success, +.br getrandom () +returns the number of bytes that were copied to the buffer +.ir buf . +this may be less than the number of bytes requested via +.i buflen +if either +.br grnd_random +was specified in +.ir flags +and insufficient entropy was present in the +.ir random +source or the system call was interrupted by a signal. +.pp +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b eagain +the requested entropy was not available, and +.br getrandom () +would have blocked if the +.b grnd_nonblock +flag was not set. +.tp +.b efault +the address referred to by +.i buf +is outside the accessible address space. +.tp +.b eintr +the call was interrupted by a signal +handler; see the description of how interrupted +.br read (2) +calls on "slow" devices are handled with and without the +.b sa_restart +flag in the +.br signal (7) +man page. +.tp +.b einval +an invalid flag was specified in +.ir flags . +.tp +.b enosys +the glibc wrapper function for +.br getrandom () +determined that the underlying kernel does not implement this system call. +.sh versions +.br getrandom () +was introduced in version 3.17 of the linux kernel. +support was added to glibc in version 2.25. +.sh conforming to +this system call is linux-specific. +.sh notes +for an overview and comparison of the various interfaces that +can be used to obtain randomness, see +.br random (7). +.pp +unlike +.ir /dev/random +and +.ir /dev/urandom , +.br getrandom () +does not involve the use of pathnames or file descriptors. +thus, +.br getrandom () +can be useful in cases where +.br chroot (2) +makes +.i /dev +pathnames invisible, +and where an application (e.g., a daemon during start-up) +closes a file descriptor for one of these files +that was opened by a library. +.\" +.ss maximum number of bytes returned +as of linux 3.19 the following limits apply: +.ip * 3 +when reading from the +.ir urandom +source, a maximum of 33554431 bytes is returned by a single call to +.br getrandom () +on systems where +.i int +has a size of 32 bits. +.ip * +when reading from the +.ir random +source, a maximum of 512 bytes is returned. +.ss interruption by a signal handler +when reading from the +.i urandom +source +.rb ( grnd_random +is not set), +.br getrandom () +will block until the entropy pool has been initialized +(unless the +.br grnd_nonblock +flag was specified). +if a request is made to read a large number of bytes (more than 256), +.br getrandom () +will block until those bytes have been generated and transferred +from kernel memory to +.ir buf . +when reading from the +.i random +source +.rb ( grnd_random +is set), +.br getrandom () +will block until some random bytes become available +(unless the +.br grnd_nonblock +flag was specified). +.pp +the behavior when a call to +.br getrandom () +that is blocked while reading from the +.i urandom +source is interrupted by a signal handler +depends on the initialization state of the entropy buffer +and on the request size, +.ir buflen . +if the entropy is not yet initialized, then the call fails with the +.b eintr +error. +if the entropy pool has been initialized +and the request size is large +.ri ( buflen "\ >\ 256)," +the call either succeeds, returning a partially filled buffer, +or fails with the error +.br eintr . +if the entropy pool has been initialized and the request size is small +.ri ( buflen "\ <=\ 256)," +then +.br getrandom () +will not fail with +.br eintr . +instead, it will return all of the bytes that have been requested. +.pp +when reading from the +.ir random +source, blocking requests of any size can be interrupted by a signal handler +(the call fails with the error +.br eintr ). +.pp +using +.br getrandom () +to read small buffers (<=\ 256 bytes) from the +.i urandom +source is the preferred mode of usage. +.pp +the special treatment of small values of +.i buflen +was designed for compatibility with +openbsd's +.br getentropy (3), +which is nowadays supported by glibc. +.pp +the user of +.br getrandom () +.i must +always check the return value, +to determine whether either an error occurred +or fewer bytes than requested were returned. +in the case where +.b grnd_random +is not specified and +.i buflen +is less than or equal to 256, +a return of fewer bytes than requested should never happen, +but the careful programmer will check for this anyway! +.sh bugs +as of linux 3.19, the following bug exists: +.\" fixme patch proposed https://lkml.org/lkml/2014/11/29/16 +.ip * 3 +depending on cpu load, +.br getrandom () +does not react to interrupts before reading all bytes requested. +.sh see also +.br getentropy (3), +.br random (4), +.br urandom (4), +.br random (7), +.br signal (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de) +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under gpl +.\" %%%license_end +.\" adapted glibc info page +.\" +.\" polished a little, aeb +.th addseverity 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +addseverity \- introduce new severity classes +.sh synopsis +.nf +.pp +.b #include +.pp +.bi "int addseverity(int " severity ", const char *" s ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br addseverity (): +.nf + since glibc 2.19: + _default_source + glibc 2.19 and earlier: + _svid_source +.fi +.sh description +this function allows the introduction of new severity classes +which can be addressed by the +.i severity +argument of the +.br fmtmsg (3) +function. +by default, that function knows only how to +print messages for severity 0-4 (with strings (none), halt, +error, warning, info). +this call attaches the given string +.i s +to the given value +.ir severity . +if +.i s +is null, the severity class with the numeric value +.i severity +is removed. +it is not possible to overwrite or remove one of the default +severity classes. +the severity value must be nonnegative. +.sh return value +upon success, the value +.b mm_ok +is returned. +upon error, the return value is +.br mm_notok . +possible errors include: out of memory, attempt to remove a +nonexistent or default severity class. +.sh versions +.br addseverity () +is provided in glibc since version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br addseverity () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +this function is not specified in the x/open portability guide +although the +.br fmtmsg (3) +function is. +it is available on system v +systems. +.sh notes +new severity classes can also be added by setting the environment variable +.br sev_level . +.sh see also +.br fmtmsg (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 1990, 1993 +.\" the regents of the university of california. all rights reserved. +.\" +.\" %%%license_start(bsd_4_clause_ucb) +.\" redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. all advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" this product includes software developed by the university of +.\" california, berkeley and its contributors. +.\" 4. neither the name of the university nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" this software is provided by the regents and contributors ``as is'' and +.\" any express or implied warranties, including, but not limited to, the +.\" implied warranties of merchantability and fitness for a particular purpose +.\" are disclaimed. in no event shall the regents or contributors be liable +.\" for any direct, indirect, incidental, special, exemplary, or consequential +.\" damages (including, but not limited to, procurement of substitute goods +.\" or services; loss of use, data, or profits; or business interruption) +.\" however caused and on any theory of liability, whether in contract, strict +.\" liability, or tort (including negligence or otherwise) arising in any way +.\" out of the use of this software, even if advised of the possibility of +.\" such damage. +.\" %%%license_end +.\" +.\" @(#)hash.3 8.6 (berkeley) 8/18/94 +.\" +.th hash 3 2017-09-15 "" "linux programmer's manual" +.uc 7 +.sh name +hash \- hash database access method +.sh synopsis +.nf +.ft b +#include +#include +.ft r +.fi +.sh description +.ir "note well" : +this page documents interfaces provided in glibc up until version 2.1. +since version 2.2, glibc no longer provides these interfaces. +probably, you are looking for the apis provided by the +.i libdb +library instead. +.pp +the routine +.br dbopen (3) +is the library interface to database files. +one of the supported file formats is hash files. +the general description of the database access methods is in +.br dbopen (3), +this manual page describes only the hash-specific information. +.pp +the hash data structure is an extensible, dynamic hashing scheme. +.pp +the access-method-specific data structure provided to +.br dbopen (3) +is defined in the +.i +include file as follows: +.pp +.in +4n +.ex +typedef struct { + unsigned int bsize; + unsigned int ffactor; + unsigned int nelem; + unsigned int cachesize; + uint32_t (*hash)(const void *, size_t); + int lorder; +} hashinfo; +.ee +.in +.pp +the elements of this structure are as follows: +.tp 10 +.i bsize +defines the hash table bucket size, and is, by default, 256 bytes. +it may be preferable to increase the page size for disk-resident tables +and tables with large data items. +.tp +.i ffactor +indicates a desired density within the hash table. +it is an approximation of the number of keys allowed to accumulate in any +one bucket, determining when the hash table grows or shrinks. +the default value is 8. +.tp +.i nelem +is an estimate of the final size of the hash table. +if not set or set too low, hash tables will expand gracefully as keys +are entered, although a slight performance degradation may be noticed. +the default value is 1. +.tp +.i cachesize +is the suggested maximum size, in bytes, of the memory cache. +this value is +.ir "only advisory" , +and the access method will allocate more memory rather than fail. +.tp +.i hash +is a user-defined hash function. +since no hash function performs equally well on all possible data, the +user may find that the built-in hash function does poorly on a particular +data set. +a user-specified hash functions must take two arguments (a pointer to a byte +string and a length) and return a 32-bit quantity to be used as the hash +value. +.tp +.i lorder +is the byte order for integers in the stored database metadata. +the number should represent the order as an integer; for example, +big endian order would be the number 4,321. +if +.i lorder +is 0 (no order is specified), the current host order is used. +if the file already exists, the specified value is ignored and the +value specified when the tree was created is used. +.pp +if the file already exists (and the +.b o_trunc +flag is not specified), the +values specified for +.ir bsize , +.ir ffactor , +.ir lorder , +and +.i nelem +are +ignored and the values specified when the tree was created are used. +.pp +if a hash function is specified, +.i hash_open +attempts to determine if the hash function specified is the same as +the one with which the database was created, and fails if it is not. +.pp +backward-compatible interfaces to the routines described in +.br dbm (3), +and +.br ndbm (3) +are provided, however these interfaces are not compatible with +previous file formats. +.sh errors +the +.i hash +access method routines may fail and set +.i errno +for any of the errors specified for the library routine +.br dbopen (3). +.sh bugs +only big and little endian byte order are supported. +.sh see also +.br btree (3), +.br dbopen (3), +.br mpool (3), +.br recno (3) +.pp +.ir "dynamic hash tables" , +per-ake larson, communications of the acm, april 1988. +.pp +.ir "a new hash package for unix" , +margo seltzer, usenix proceedings, winter 1991. +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2002, 2020 michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th shm_open 3 2021-03-22 "linux" "linux programmer's manual" +.sh name +shm_open, shm_unlink \- create/open or unlink posix shared memory objects +.sh synopsis +.nf +.b #include +.br "#include " " /* for mode constants */" +.br "#include " " /* for o_* constants */" +.pp +.bi "int shm_open(const char *" name ", int " oflag ", mode_t " mode ); +.bi "int shm_unlink(const char *" name ); +.fi +.pp +link with \fi\-lrt\fp. +.sh description +.br shm_open () +creates and opens a new, or opens an existing, posix shared memory object. +a posix shared memory object is in effect a handle which can +be used by unrelated processes to +.br mmap (2) +the same region of shared memory. +the +.br shm_unlink () +function performs the converse operation, +removing an object previously created by +.br shm_open (). +.pp +the operation of +.br shm_open () +is analogous to that of +.br open (2). +.i name +specifies the shared memory object to be created or opened. +for portable use, +a shared memory object should be identified by a name of the form +.ir /somename ; +that is, a null-terminated string of up to +.bi name_max +(i.e., 255) characters consisting of an initial slash, +.\" glibc allows the initial slash to be omitted, and makes +.\" multiple initial slashes equivalent to a single slash. +.\" this differs from the implementation of posix message queues. +followed by one or more characters, none of which are slashes. +.\" glibc allows subdirectory components in the name, in which +.\" case the subdirectory must exist under /dev/shm, and allow the +.\" required permissions if a user wants to create a shared memory +.\" object in that subdirectory. +.pp +.i oflag +is a bit mask created by oring together exactly one of +.b o_rdonly +or +.b o_rdwr +and any of the other flags listed here: +.tp +.b o_rdonly +open the object for read access. +a shared memory object opened in this way can be +.br mmap (2)ed +only for read +.rb ( prot_read ) +access. +.tp +.b o_rdwr +open the object for read-write access. +.tp +.b o_creat +create the shared memory object if it does not exist. +the user and group ownership of the object are taken +from the corresponding effective ids of the calling process, +.\" in truth it is actually the filesystem ids on linux, but these +.\" are nearly always the same as the effective ids. (mtk, jul 05) +and the object's +permission bits are set according to the low-order 9 bits of +.ir mode , +except that those bits set in the process file mode +creation mask (see +.br umask (2)) +are cleared for the new object. +a set of macro constants which can be used to define +.i mode +is listed in +.br open (2). +(symbolic definitions of these constants can be obtained by including +.ir .) +.ip +a new shared memory object initially has zero length\(emthe size of the +object can be set using +.br ftruncate (2). +the newly allocated bytes of a shared memory +object are automatically initialized to 0. +.tp +.b o_excl +if +.b o_creat +was also specified, and a shared memory object with the given +.i name +already exists, return an error. +the check for the existence of the object, and its creation if it +does not exist, are performed atomically. +.tp +.b o_trunc +if the shared memory object already exists, truncate it to zero bytes. +.pp +definitions of these flag values can be obtained by including +.ir . +.pp +on successful completion +.br shm_open () +returns a new file descriptor referring to the shared memory object. +this file descriptor is guaranteed to be the lowest-numbered file descriptor +not previously opened within the process. +the +.b fd_cloexec +flag (see +.br fcntl (2)) +is set for the file descriptor. +.pp +the file descriptor is normally used in subsequent calls +to +.br ftruncate (2) +(for a newly created object) and +.br mmap (2). +after a call to +.br mmap (2) +the file descriptor may be closed without affecting the memory mapping. +.pp +the operation +of +.br shm_unlink () +is analogous to +.br unlink (2): +it removes a shared memory object name, and, once all processes +have unmapped the object, deallocates and +destroys the contents of the associated memory region. +after a successful +.br shm_unlink (), +attempts to +.br shm_open () +an object with the same +.i name +fail (unless +.b o_creat +was specified, in which case a new, distinct object is created). +.sh return value +on success, +.br shm_open () +returns a file descriptor (a nonnegative integer). +on success, +.br shm_unlink () +returns 0. +on failure, both functions return \-1 and set +.i errno +to indicate the error. +.sh errors +.tp +.b eacces +permission to +.br shm_unlink () +the shared memory object was denied. +.tp +.b eacces +permission was denied to +.br shm_open () +.i name +in the specified +.ir mode , +or +.b o_trunc +was specified and the caller does not have write permission on the object. +.tp +.b eexist +both +.b o_creat +and +.b o_excl +were specified to +.br shm_open () +and the shared memory object specified by +.i name +already exists. +.tp +.b einval +the +.i name +argument to +.br shm_open () +was invalid. +.tp +.b emfile +the per-process limit on the number of open file descriptors has been reached. +.tp +.b enametoolong +the length of +.i name +exceeds +.br path_max . +.tp +.b enfile +the system-wide limit on the total number of open files has been reached. +.tp +.b enoent +an attempt was made to +.br shm_open () +a +.i name +that did not exist, and +.b o_creat +was not specified. +.tp +.b enoent +an attempt was to made to +.br shm_unlink () +a +.i name +that does not exist. +.sh versions +these functions are provided in glibc 2.2 and later. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br shm_open (), +.br shm_unlink () +t} thread safety mt-safe locale +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008. +.pp +posix.1-2001 says that the group ownership of a newly created shared +memory object is set to either the calling process's effective group id +or "a system default group id". +posix.1-2008 says that the group ownership +may be set to either the calling process's effective group id +or, if the object is visible in the filesystem, +the group id of the parent directory. +.sh notes +posix leaves the behavior of the combination of +.b o_rdonly +and +.b o_trunc +unspecified. +on linux, this will successfully truncate an existing +shared memory object\(emthis may not be so on other unix systems. +.pp +the posix shared memory object implementation on linux makes use +of a dedicated +.br tmpfs (5) +filesystem that is normally mounted under +.ir /dev/shm . +.sh examples +the programs below employ posix shared memory and posix unnamed semaphores +to exchange a piece of data. +the "bounce" program (which must be run first) raises the case +of a string that is placed into the shared memory by the "send" program. +once the data has been modified, the "send" program then prints +the contents of the modified shared memory. +an example execution of the two programs is the following: +.pp +.in +4n +.ex +$ \fb./pshm_ucase_bounce /myshm &\fp +[1] 270171 +$ \fb./pshm_ucase_send /myshm hello\fp +hello +.ee +.in +.pp +further detail about these programs is provided below. +.\" +.ss program source: pshm_ucase.h +the following header file is included by both programs below. +its primary purpose is to define a structure that will be imposed +on the memory object that is shared between the two programs. +.pp +.in +4n +.ex +#include +#include +#include +#include +#include +#include +#include + +#define errexit(msg) do { perror(msg); exit(exit_failure); \e + } while (0) + +#define buf_size 1024 /* maximum size for exchanged string */ + +/* define a structure that will be imposed on the shared + memory object */ + +struct shmbuf { + sem_t sem1; /* posix unnamed semaphore */ + sem_t sem2; /* posix unnamed semaphore */ + size_t cnt; /* number of bytes used in \(aqbuf\(aq */ + char buf[buf_size]; /* data being transferred */ +}; +.ee +.in +.\" +.ss program source: pshm_ucase_bounce.c +the "bounce" program creates a new shared memory object with the name +given in its command-line argument and sizes the object to +match the size of the +.i shmbuf +structure defined in the header file. +it then maps the object into the process's address space, +and initializes two posix semaphores inside the object to 0. +.pp +after the "send" program has posted the first of the semaphores, +the "bounce" program upper cases the data that has been placed +in the memory by the "send" program and then posts the second semaphore +to tell the "send" program that it may now access the shared memory. +.pp +.in +4n +.ex +/* pshm_ucase_bounce.c + + licensed under gnu general public license v2 or later. +*/ +#include +#include "pshm_ucase.h" + +int +main(int argc, char *argv[]) +{ + if (argc != 2) { + fprintf(stderr, "usage: %s /shm\-path\en", argv[0]); + exit(exit_failure); + } + + char *shmpath = argv[1]; + + /* create shared memory object and set its size to the size + of our structure. */ + + int fd = shm_open(shmpath, o_creat | o_excl | o_rdwr, + s_irusr | s_iwusr); + if (fd == \-1) + errexit("shm_open"); + + if (ftruncate(fd, sizeof(struct shmbuf)) == \-1) + errexit("ftruncate"); + + /* map the object into the caller\(aqs address space. */ + + struct shmbuf *shmp = mmap(null, sizeof(*shmp), + prot_read | prot_write, + map_shared, fd, 0); + if (shmp == map_failed) + errexit("mmap"); + + /* initialize semaphores as process\-shared, with value 0. */ + + if (sem_init(&shmp\->sem1, 1, 0) == \-1) + errexit("sem_init\-sem1"); + if (sem_init(&shmp\->sem2, 1, 0) == \-1) + errexit("sem_init\-sem2"); + + /* wait for \(aqsem1\(aq to be posted by peer before touching + shared memory. */ + + if (sem_wait(&shmp\->sem1) == \-1) + errexit("sem_wait"); + + /* convert data in shared memory into upper case. */ + + for (int j = 0; j < shmp\->cnt; j++) + shmp\->buf[j] = toupper((unsigned char) shmp\->buf[j]); + + /* post \(aqsem2\(aq to tell the peer that it can now + access the modified data in shared memory. */ + + if (sem_post(&shmp\->sem2) == \-1) + errexit("sem_post"); + + /* unlink the shared memory object. even if the peer process + is still using the object, this is okay. the object will + be removed only after all open references are closed. */ + + shm_unlink(shmpath); + + exit(exit_success); +} +.ee +.in +.\" +.ss program source: pshm_ucase_send.c +the "send" program takes two command-line arguments: +the pathname of a shared memory object previously created by the "bounce" +program and a string that is to be copied into that object. +.pp +the program opens the shared memory object +and maps the object into its address space. +it then copies the data specified in its second argument +into the shared memory, +and posts the first semaphore, +which tells the "bounce" program that it can now access that data. +after the "bounce" program posts the second semaphore, +the "send" program prints the contents of the shared memory +on standard output. +.pp +.in +4n +.ex +/* pshm_ucase_send.c + + licensed under gnu general public license v2 or later. +*/ +#include +#include "pshm_ucase.h" + +int +main(int argc, char *argv[]) +{ + if (argc != 3) { + fprintf(stderr, "usage: %s /shm\-path string\en", argv[0]); + exit(exit_failure); + } + + char *shmpath = argv[1]; + char *string = argv[2]; + size_t len = strlen(string); + + if (len > buf_size) { + fprintf(stderr, "string is too long\en"); + exit(exit_failure); + } + + /* open the existing shared memory object and map it + into the caller\(aqs address space. */ + + int fd = shm_open(shmpath, o_rdwr, 0); + if (fd == \-1) + errexit("shm_open"); + + struct shmbuf *shmp = mmap(null, sizeof(*shmp), + prot_read | prot_write, + map_shared, fd, 0); + if (shmp == map_failed) + errexit("mmap"); + + /* copy data into the shared memory object. */ + + shmp\->cnt = len; + memcpy(&shmp\->buf, string, len); + + /* tell peer that it can now access shared memory. */ + + if (sem_post(&shmp\->sem1) == \-1) + errexit("sem_post"); + + /* wait until peer says that it has finished accessing + the shared memory. */ + + if (sem_wait(&shmp\->sem2) == \-1) + errexit("sem_wait"); + + /* write modified data in shared memory to standard output. */ + + write(stdout_fileno, &shmp\->buf, len); + write(stdout_fileno, "\en", 1); + + exit(exit_success); +} +.ee +.in +.sh see also +.br close (2), +.br fchmod (2), +.br fchown (2), +.br fcntl (2), +.br fstat (2), +.br ftruncate (2), +.br memfd_create (2), +.br mmap (2), +.br open (2), +.br umask (2), +.br shm_overview (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/ether_aton.3 + +.so man3/strtod.3 + +.\" copyright (c) 2006 red hat, inc. all rights reserved. +.\" and copyright (c) 2013 michael kerrisk +.\" written by ivana varekova +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th perfmonctl 2 2021-03-22 linux "linux programmer's manual" +.sh name +perfmonctl \- interface to ia-64 performance monitoring unit +.sh synopsis +.nf +.b #include +.b #include +.pp +.bi "long perfmonctl(int " fd ", int " cmd ", void *" arg ", int " narg ");" +.fi +.pp +.ir note : +there is no glibc wrapper for this system call; see notes. +.sh description +the ia-64-specific +.br perfmonctl () +system call provides an interface to the +pmu (performance monitoring unit). +the pmu consists of pmd (performance monitoring data) registers and +pmc (performance monitoring control) registers, +which gather hardware statistics. +.pp +.br perfmonctl () +applies the operation +.i cmd +to the input arguments specified by +.ir arg . +the number of arguments is defined by \finarg\fr. +the +.i fd +argument specifies the perfmon context to operate on. +.pp +supported values for +.i cmd +are: +.tp +.b pfm_create_context +.nf +.bi "perfmonctl(int " fd ", pfm_create_context, pfarg_context_t *" ctxt ", 1);" +.fi +set up a context. +.ip +the +.i fd +parameter is ignored. +a new perfmon context is created as specified in +.i ctxt +and its file descriptor is returned in \fictxt->ctx_fd\fr. +.ip +the file descriptor can be used in subsequent calls to +.br perfmonctl () +and can be used to read event notifications (type +.ir pfm_msg_t ) +using +.br read (2). +the file descriptor is pollable using +.br select (2), +.br poll (2), +and +.br epoll (7). +.ip +the context can be destroyed by calling +.br close (2) +on the file descriptor. +.tp +.b pfm_write_pmcs +.\" pfm_write_pmcs() +.nf +.bi "perfmonctl(int " fd ", pfm_write_pmcs, pfarg_reg_t *" pmcs ", n);" +.fi +set pmc registers. +.tp +.b pfm_write_pmds +.nf +.bi "perfmonctl(int " fd ", pfm_write_pmds, pfarg_reg_t *" pmds ", n);" +.fi +.\" pfm_write_pmds() +set pmd registers. +.tp +.b pfm_read_pmds +.\" pfm_read_pmds() +.nf +.bi "perfmonctl(int " fd ", pfm_read_pmds, pfarg_reg_t *" pmds ", n);" +.fi +read pmd registers. +.tp +.b pfm_start +.\" pfm_start() +.nf +.\" .bi "perfmonctl(int " fd ", pfm_start, arg, 1); +.bi "perfmonctl(int " fd ", pfm_start, null, 0);" +.fi +start monitoring. +.tp +.b pfm_stop +.\" pfm_stop() +.nf +.bi "perfmonctl(int " fd ", pfm_stop, null, 0);" +.fi +stop monitoring. +.tp +.b pfm_load_context +.\" pfm_context_load() +.nf +.bi "perfmonctl(int " fd ", pfm_load_context, pfarg_load_t *" largs ", 1);" +.fi +attach the context to a thread. +.tp +.b pfm_unload_context +.\" pfm_context_unload() +.nf +.bi "perfmonctl(int " fd ", pfm_unload_context, null, 0);" +.fi +detach the context from a thread. +.tp +.b pfm_restart +.\" pfm_restart() +.nf +.bi "perfmonctl(int " fd ", pfm_restart, null, 0);" +.fi +restart monitoring after receiving an overflow notification. +.tp +.b pfm_get_features +.\" pfm_get_features() +.nf +.bi "perfmonctl(int " fd ", pfm_get_features, pfarg_features_t *" arg ", 1);" +.fi +.tp +.b pfm_debug +.\" pfm_debug() +.nf +.bi "perfmonctl(int " fd ", pfm_debug, " val ", 0);" +.fi +if +.i val +is nonzero, enable debugging mode, otherwise disable. +.tp +.b pfm_get_pmc_reset_val +.\" pfm_get_pmc_reset() +.nf +.bi "perfmonctl(int " fd ", pfm_get_pmc_reset_val, pfarg_reg_t *" req ", n);" +.fi +reset pmc registers to default values. +.\" +.\" +.\" .tp +.\" .b pfm_create_evtsets +.\" +.\" create or modify event sets +.\" .nf +.\" .bi "perfmonctl(int " fd ", pfm_create_evtsets, pfarg_setdesc_t *desc , n); +.\" .fi +.\" .tp +.\" .b pfm_delete_evtsets +.\" delete event sets +.\" .nf +.\" .bi "perfmonctl(int " fd ", pfm_delete_evtset, pfarg_setdesc_t *desc , n); +.\" .fi +.\" .tp +.\" .b pfm_getinfo_evtsets +.\" get information about event sets +.\" .nf +.\" .bi "perfmonctl(int " fd ", pfm_getinfo_evtsets, pfarg_setinfo_t *info, n); +.\" .fi +.sh return value +.br perfmonctl () +returns zero when the operation is successful. +on error, \-1 is returned and +.i errno +is set to indicate the error. +.sh versions +.br perfmonctl () +was added in linux 2.4; +.\" commit ecf5b72d5f66af843f189dfe9ce31598c3e48ad7 +it was removed in linux 5.10. +.sh conforming to +.br perfmonctl () +is linux-specific and is available only on the ia-64 architecture. +.sh notes +this system call was broken for many years, +and ultimately removed in linux 5.10. +.pp +glibc does not provide a wrapper for this system call; +on kernels where it exists, call it using +.br syscall (2). +.sh see also +.br gprof (1) +.pp +the perfmon2 interface specification +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/random.3 + +.so man2/sched_setscheduler.2 + +.so man2/statfs.2 + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" iso/iec 9899:1999 +.\" +.th iswupper 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +iswupper \- test for uppercase wide character +.sh synopsis +.nf +.b #include +.pp +.bi "int iswupper(wint_t " wc ); +.fi +.sh description +the +.br iswupper () +function is the wide-character equivalent of the +.br isupper (3) +function. +it tests whether +.i wc +is a wide character +belonging to the wide-character class "upper". +.pp +the wide-character class "upper" is a subclass of the wide-character class +"alpha", and therefore also a subclass of the wide-character class "alnum", of +the wide-character class "graph" and of the wide-character class "print". +.pp +being a subclass of the wide-character class "print", the wide-character class +"upper" is disjoint from the wide-character class "cntrl". +.pp +being a subclass of the wide-character class "graph", the wide-character class +"upper" is disjoint from the wide-character class "space" and its subclass +"blank". +.pp +being a subclass of the wide-character class "alnum", the wide-character class +"upper" is disjoint from the wide-character class "punct". +.pp +being a subclass of the wide-character class "alpha", the wide-character class +"upper" is disjoint from the wide-character class "digit". +.pp +the wide-character class "upper" contains at least those characters +.i wc +which are equal to +.i towupper(wc) +and different from +.ir towlower(wc) . +.pp +the wide-character class "upper" always contains at least the +letters \(aqa\(aq to \(aqz\(aq. +.sh return value +the +.br iswupper () +function returns nonzero if +.i wc +is a wide character +belonging to the wide-character class "upper". +otherwise, it returns zero. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br iswupper () +t} thread safety mt-safe locale +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh notes +the behavior of +.br iswupper () +depends on the +.b lc_ctype +category of the +current locale. +.pp +this function is not very appropriate for dealing with unicode characters, +because unicode knows about three cases: upper, lower, and title case. +.sh see also +.br isupper (3), +.br iswctype (3), +.br towupper (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de) +.\" +.\" %%%license_start(gpl_noversion_oneline) +.\" distributed under gpl +.\" %%%license_end +.\" +.th csinh 3 2021-03-22 "" "linux programmer's manual" +.sh name +csinh, csinhf, csinhl \- complex hyperbolic sine +.sh synopsis +.nf +.b #include +.pp +.bi "double complex csinh(double complex " z ");" +.bi "float complex csinhf(float complex " z ");" +.bi "long double complex csinhl(long double complex " z ");" +.pp +link with \fi\-lm\fp. +.fi +.sh description +these functions calculate the complex hyperbolic sine of +.ir z . +.pp +the complex hyperbolic sine function is defined as: +.pp +.nf + csinh(z) = (exp(z)\-exp(\-z))/2 +.fi +.sh versions +these functions first appeared in glibc in version 2.1. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br csinh (), +.br csinhf (), +.br csinhl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.sh see also +.br cabs (3), +.br casinh (3), +.br ccosh (3), +.br ctanh (3), +.br complex (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) bruno haible +.\" +.\" %%%license_start(gplv2+_doc_onepara) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" %%%license_end +.\" +.\" references consulted: +.\" gnu glibc-2 source code and manual +.\" dinkumware c library reference http://www.dinkumware.com/ +.\" opengroup's single unix specification http://www.unix-systems.org/online.html +.\" iso/iec 9899:1999 +.\" +.th wcsrtombs 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +wcsrtombs \- convert a wide-character string to a multibyte string +.sh synopsis +.nf +.b #include +.pp +.bi "size_t wcsrtombs(char *restrict " dest ", const wchar_t **restrict " src , +.bi " size_t " len ", mbstate_t *restrict " ps ); +.fi +.sh description +if +.i dest +is not null, +the +.br wcsrtombs () +function converts +the wide-character string +.i *src +to a multibyte string starting at +.ir dest . +at most +.i len +bytes are written to +.ir dest . +the shift state +.i *ps +is updated. +the conversion is effectively performed by repeatedly +calling +.ir "wcrtomb(dest, *src, ps)" , +as long as this call succeeds, +and then incrementing +.i dest +by the +number of bytes written and +.i *src +by one. +the conversion can stop for three reasons: +.ip 1. 3 +a wide character has been encountered that can not be represented as a +multibyte sequence (according to the current locale). +in this case, +.i *src +is left pointing to the invalid wide character, +.i (size_t)\ \-1 +is returned, +and +.i errno +is set to +.br eilseq . +.ip 2. +the length limit forces a stop. +in this case, +.i *src +is left pointing +to the next wide character to be converted, +and the number of bytes written to +.i dest +is returned. +.ip 3. +the wide-character string has been completely converted, including the +terminating null wide character (l\(aq\e0\(aq), +which has the side effect of bringing back +.i *ps +to the initial state. +in this case, +.i *src +is set to null, and the number +of bytes written to +.ir dest , +excluding the terminating null byte (\(aq\e0\(aq), +is returned. +.pp +if +.ir dest +is null, +.i len +is ignored, +and the conversion proceeds as above, except that the converted bytes +are not written out to memory, and that +no length limit exists. +.pp +in both of the above cases, +if +.i ps +is null, a static anonymous +state known only to the +.br wcsrtombs () +function is used instead. +.pp +the programmer must ensure that there is room for at least +.i len +bytes +at +.ir dest . +.sh return value +the +.br wcsrtombs () +function returns +the number of bytes that make up the +converted part of multibyte sequence, +not including the terminating null byte. +if a wide character was encountered +which could not be converted, +.i (size_t)\ \-1 +is returned, and +.i errno +set to +.br eilseq . +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lb lb lbx +l l l. +interface attribute value +t{ +.br wcsrtombs () +t} thread safety t{ +mt-unsafe race:wcsrtombs/!ps +t} +.te +.hy +.ad +.sp 1 +.sh conforming to +posix.1-2001, posix.1-2008, c99. +.sh notes +the behavior of +.br wcsrtombs () +depends on the +.b lc_ctype +category of the +current locale. +.pp +passing null as +.i ps +is not multithread safe. +.sh see also +.br iconv (3), +.br mbsinit (3), +.br wcrtomb (3), +.br wcsnrtombs (3), +.br wcstombs (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 1999 dimitri papadopoulos (dpo@club-internet.fr) +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th iso_8859-7 7 2020-08-13 "linux" "linux programmer's manual" +.sh name +iso_8859-7 \- iso 8859-7 character set encoded in octal, decimal, +and hexadecimal +.sh description +the iso 8859 standard includes several 8-bit extensions to the ascii +character set (also known as iso 646-irv). +iso 8859-7 encodes the +characters used in modern monotonic greek. +.ss iso 8859 alphabets +the full set of iso 8859 alphabets includes: +.ts +l l. +iso 8859-1 west european languages (latin-1) +iso 8859-2 central and east european languages (latin-2) +iso 8859-3 southeast european and miscellaneous languages (latin-3) +iso 8859-4 scandinavian/baltic languages (latin-4) +iso 8859-5 latin/cyrillic +iso 8859-6 latin/arabic +iso 8859-7 latin/greek +iso 8859-8 latin/hebrew +iso 8859-9 latin-1 modification for turkish (latin-5) +iso 8859-10 lappish/nordic/eskimo languages (latin-6) +iso 8859-11 latin/thai +iso 8859-13 baltic rim languages (latin-7) +iso 8859-14 celtic (latin-8) +iso 8859-15 west european languages (latin-9) +iso 8859-16 romanian (latin-10) +.te +.ss iso 8859-7 characters +the following table displays the characters in iso 8859-7 that +are printable and unlisted in the +.br ascii (7) +manual page. +.ts +l l l c lp-1. +oct dec hex char description +_ +240 160 a0   no-break space +241 161 a1 ‘ left single quotation mark +242 162 a2 ’ right single quotation mark +243 163 a3 £ pound sign +244 164 a4 € euro sign +245 165 a5 ₯ drachma sign +246 166 a6 ¦ broken bar +247 167 a7 § section sign +250 168 a8 ¨ diaeresis +251 169 a9 © copyright sign +252 170 aa ͺ greek ypogegrammeni +253 171 ab « left-pointing double angle quotation mark +254 172 ac ¬ not sign +255 173 ad ­ soft hyphen +257 175 af ― horizontal bar +260 176 b0 ° degree sign +261 177 b1 ± plus-minus sign +262 178 b2 ² superscript two +263 179 b3 ³ superscript three +264 180 b4 ΄ greek tonos +265 181 b5 ΅ greek dialytika tonos +266 182 b6 ά greek capital letter alpha with tonos +267 183 b7 · middle dot +270 184 b8 έ greek capital letter epsilon with tonos +271 185 b9 ή greek capital letter eta with tonos +272 186 ba ί greek capital letter iota with tonos +273 187 bb » right-pointing double angle quotation mark +274 188 bc ό greek capital letter omicron with tonos +275 189 bd ½ vulgar fraction one half +276 190 be ύ greek capital letter upsilon with tonos +277 191 bf ώ greek capital letter omega with tonos +300 192 c0 ΐ t{ +greek small letter iota with +.br +dialytika and tonos +t} +301 193 c1 α greek capital letter alpha +302 194 c2 β greek capital letter beta +303 195 c3 γ greek capital letter gamma +304 196 c4 δ greek capital letter delta +305 197 c5 ε greek capital letter epsilon +306 198 c6 ζ greek capital letter zeta +307 199 c7 η greek capital letter eta +310 200 c8 θ greek capital letter theta +311 201 c9 ι greek capital letter iota +312 202 ca κ greek capital letter kappa +313 203 cb λ greek capital letter lambda +314 204 cc μ greek capital letter mu +315 205 cd ν greek capital letter nu +316 206 ce ξ greek capital letter xi +317 207 cf ο greek capital letter omicron +320 208 d0 π greek capital letter pi +321 209 d1 ρ greek capital letter rho +323 211 d3 σ greek capital letter sigma +324 212 d4 τ greek capital letter tau +325 213 d5 υ greek capital letter upsilon +326 214 d6 φ greek capital letter phi +327 215 d7 χ greek capital letter chi +330 216 d8 ψ greek capital letter psi +331 217 d9 ω greek capital letter omega +332 218 da ϊ greek capital letter iota with dialytika +333 219 db ϋ greek capital letter upsilon with dialytika +334 220 dc ά greek small letter alpha with tonos +335 221 dd έ greek small letter epsilon with tonos +336 222 de ή greek small letter eta with tonos +337 223 df ί greek small letter iota with tonos +340 224 e0 ΰ t{ +greek small letter upsilon with +dialytika and tonos +t} +341 225 e1 α greek small letter alpha +342 226 e2 β greek small letter beta +343 227 e3 γ greek small letter gamma +344 228 e4 δ greek small letter delta +345 229 e5 ε greek small letter epsilon +346 230 e6 ζ greek small letter zeta +347 231 e7 η greek small letter eta +350 232 e8 θ greek small letter theta +351 233 e9 ι greek small letter iota +352 234 ea κ greek small letter kappa +353 235 eb λ greek small letter lambda +354 236 ec μ greek small letter mu +355 237 ed ν greek small letter nu +356 238 ee ξ greek small letter xi +357 239 ef ο greek small letter omicron +360 240 f0 π greek small letter pi +361 241 f1 ρ greek small letter rho +362 242 f2 ς greek small letter final sigma +363 243 f3 σ greek small letter sigma +364 244 f4 τ greek small letter tau +365 245 f5 υ greek small letter upsilon +366 246 f6 φ greek small letter phi +367 247 f7 χ greek small letter chi +370 248 f8 ψ greek small letter psi +371 249 f9 ω greek small letter omega +372 250 fa ϊ greek small letter iota with dialytika +373 251 fb ϋ greek small letter upsilon with dialytika +374 252 fc ό greek small letter omicron with tonos +375 253 fd ύ greek small letter upsilon with tonos +376 254 fe ώ greek small letter omega with tonos +.te +.sh notes +iso 8859-7 was formerly known as elot-928 or ecma-118:1986. +.sh see also +.br ascii (7), +.br charsets (7), +.br utf\-8 (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man2/getxattr.2 + +.\" this manpage is copyright (c) 1992 drew eckhardt; +.\" and copyright (c) 1993 michael haardt, ian jackson. +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" modified wed jul 21 23:02:38 1993 by rik faith +.\" modified 2001-11-17, aeb +.\" +.th _exit 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +_exit, _exit \- terminate the calling process +.sh synopsis +.nf +.b #include +.pp +.bi "noreturn void _exit(int " status ); +.pp +.b #include +.pp +.bi "noreturn void _exit(int " status ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br _exit (): +.nf + _isoc99_source || _posix_c_source >= 200112l +.fi +.sh description +.br _exit () +terminates the calling process "immediately". +any open file descriptors belonging to the process are closed. +any children of the process are inherited by +.br init (1) +(or by the nearest "subreaper" process as defined through the use of the +.br prctl (2) +.b pr_set_child_subreaper +operation). +the process's parent is sent a +.b sigchld +signal. +.pp +the value +.i "status & 0xff" +is returned to the parent process as the process's exit status, and +can be collected by the parent using one of the +.br wait (2) +family of calls. +.pp +the function +.br _exit () +is equivalent to +.br _exit (). +.sh return value +these functions do not return. +.sh conforming to +posix.1-2001, posix.1-2008, svr4, 4.3bsd. +the function +.br _exit () +was introduced by c99. +.sh notes +for a discussion on the effects of an exit, the transmission of +exit status, zombie processes, signals sent, and so on, see +.br exit (3). +.pp +the function +.br _exit () +is like +.br exit (3), +but does not call any +functions registered with +.br atexit (3) +or +.br on_exit (3). +open +.br stdio (3) +streams are not flushed. +on the other hand, +.br _exit () +does close open file descriptors, and this may cause an unknown delay, +waiting for pending output to finish. +if the delay is undesired, +it may be useful to call functions like +.br tcflush (3) +before calling +.br _exit (). +whether any pending i/o is canceled, and which pending i/o may be +canceled upon +.br _exit (), +is implementation-dependent. +.ss c library/kernel differences +in glibc up to version 2.3, the +.br _exit () +wrapper function invoked the kernel system call of the same name. +since glibc 2.3, the wrapper function invokes +.br exit_group (2), +in order to terminate all of the threads in a process. +.pp +the raw +.br _exit () +system call terminates only the calling thread, and actions such as +reparenting child processes or sending +.b sigchld +to the parent process are performed only if this is +the last thread in the thread group. +.\" _exit() is used by pthread_exit() to terminate the calling thread +.sh see also +.br execve (2), +.br exit_group (2), +.br fork (2), +.br kill (2), +.br wait (2), +.br wait4 (2), +.br waitpid (2), +.br atexit (3), +.br exit (3), +.br on_exit (3), +.br termios (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/div.3 + +.so man3/rpc.3 + +.\" copyright (c) 1995, thomas k. dyas +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" created 1995-08-09 thomas k. dyas +.\" modified 1997-01-31 by eric s. raymond +.\" modified 2001-03-22 by aeb +.\" modified 2003-08-04 by aeb +.\" +.th ustat 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +ustat \- get filesystem statistics +.sh synopsis +.nf +.b #include +.br "#include " " /* libc[45] */" +.br "#include " " /* glibc2 */" +.pp +.bi "int ustat(dev_t " dev ", struct ustat *" ubuf ); +.fi +.sh description +.br ustat () +returns information about a mounted filesystem. +.i dev +is a device number identifying a device containing +a mounted filesystem. +.i ubuf +is a pointer to a +.i ustat +structure that contains the following +members: +.pp +.in +4n +.ex +daddr_t f_tfree; /* total free blocks */ +ino_t f_tinode; /* number of free inodes */ +char f_fname[6]; /* filsys name */ +char f_fpack[6]; /* filsys pack name */ +.ee +.in +.pp +the last two fields, +.i f_fname +and +.ir f_fpack , +are not implemented and will +always be filled with null bytes (\(aq\e0\(aq). +.sh return value +on success, zero is returned and the +.i ustat +structure pointed to by +.i ubuf +will be filled in. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b efault +.i ubuf +points outside of your accessible address space. +.tp +.b einval +.i dev +does not refer to a device containing a mounted filesystem. +.tp +.b enosys +the mounted filesystem referenced by +.i dev +does not support this operation, or any version of linux before +1.3.16. +.sh versions +since version 2.28, glibc no longer provides a wrapper for this system call. +.sh conforming to +svr4. +.\" svr4 documents additional error conditions enolink, ecomm, and eintr +.\" but has no enosys condition. +.sh notes +.br ustat () +is deprecated and has been provided only for compatibility. +all new programs should use +.br statfs (2) +instead. +.ss hp-ux notes +the hp-ux version of the +.i ustat +structure has an additional field, +.ir f_blksize , +that is unknown elsewhere. +hp-ux warns: +for some filesystems, the number of free inodes does not change. +such filesystems will return \-1 in the field +.ir f_tinode . +.\" some software tries to use this in order to test whether the +.\" underlying filesystem is nfs. +for some filesystems, inodes are dynamically allocated. +such filesystems will return the current number of free inodes. +.sh see also +.br stat (2), +.br statfs (2) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright 2009 lefteris dimitroulakis (edimitro@tee.gr) +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.th iso_8859-5 7 2020-08-13 "linux" "linux programmer's manual" +.sh name +iso_8859-5 \- iso 8859-5 character set encoded in octal, decimal, +and hexadecimal +.sh description +the iso 8859 standard includes several 8-bit extensions to the ascii +character set (also known as iso 646-irv). +iso 8859-5 encodes the +cyrillic characters used in many east european languages. +.ss iso 8859 alphabets +the full set of iso 8859 alphabets includes: +.ts +l l. +iso 8859-1 west european languages (latin-1) +iso 8859-2 central and east european languages (latin-2) +iso 8859-3 southeast european and miscellaneous languages (latin-3) +iso 8859-4 scandinavian/baltic languages (latin-4) +iso 8859-5 latin/cyrillic +iso 8859-6 latin/arabic +iso 8859-7 latin/greek +iso 8859-8 latin/hebrew +iso 8859-9 latin-1 modification for turkish (latin-5) +iso 8859-10 lappish/nordic/eskimo languages (latin-6) +iso 8859-11 latin/thai +iso 8859-13 baltic rim languages (latin-7) +iso 8859-14 celtic (latin-8) +iso 8859-15 west european languages (latin-9) +iso 8859-16 romanian (latin-10) +.te +.ss iso 8859-5 characters +the following table displays the characters in iso 8859-5 that +are printable and unlisted in the +.br ascii (7) +manual page. +.ts +l l l c lp-1. +oct dec hex char description +_ +240 160 a0   no-break space +241 161 a1 ё cyrillic capital letter io +242 162 a2 ђ cyrillic capital letter dje +243 163 a3 ѓ cyrillic capital letter gje +244 164 a4 є cyrillic capital letter ukrainian ie +245 165 a5 ѕ cyrillic capital letter dze +246 166 a6 і t{ +cyrillic capital letter +.br +byelorussian-ukrainian i +t} +247 167 a7 ї cyrillic capital letter yi +250 168 a8 ј cyrillic capital letter je +251 169 a9 љ cyrillic capital letter lje +252 170 aa њ cyrillic capital letter nje +253 171 ab ћ cyrillic capital letter tshe +254 172 ac ќ cyrillic capital letter kje +255 173 ad ­ soft hyphen +256 174 ae ў cyrillic capital letter short u +257 175 af џ cyrillic capital letter dzhe +260 176 b0 а cyrillic capital letter a +261 177 b1 б cyrillic capital letter be +262 178 b2 в cyrillic capital letter ve +263 179 b3 г cyrillic capital letter ghe +264 180 b4 д cyrillic capital letter de +265 181 b5 е cyrillic capital letter ie +266 182 b6 ж cyrillic capital letter zhe +267 183 b7 з cyrillic capital letter ze +270 184 b8 и cyrillic capital letter i +271 185 b9 й cyrillic capital letter short i +272 186 ba к cyrillic capital letter ka +273 187 bb л cyrillic capital letter el +274 188 bc м cyrillic capital letter em +275 189 bd н cyrillic capital letter en +276 190 be о cyrillic capital letter o +277 191 bf п cyrillic capital letter pe +300 192 c0 р cyrillic capital letter er +301 193 c1 с cyrillic capital letter es +302 194 c2 т cyrillic capital letter te +303 195 c3 у cyrillic capital letter u +304 196 c4 ф cyrillic capital letter ef +305 197 c5 х cyrillic capital letter ha +306 198 c6 ц cyrillic capital letter tse +307 199 c7 ч cyrillic capital letter che +310 200 c8 ш cyrillic capital letter sha +311 201 c9 щ cyrillic capital letter shcha +312 202 ca ъ cyrillic capital letter hard sign +313 203 cb ы cyrillic capital letter yeru +314 204 cc ь cyrillic capital letter soft sign +315 205 cd э cyrillic capital letter e +316 206 ce ю cyrillic capital letter yu +317 207 cf я cyrillic capital letter ya +320 208 d0 а cyrillic small letter a +321 209 d1 б cyrillic small letter be +322 210 d2 в cyrillic small letter ve +323 211 d3 г cyrillic small letter ghe +324 212 d4 д cyrillic small letter de +325 213 d5 е cyrillic small letter ie +326 214 d6 ж cyrillic small letter zhe +327 215 d7 з cyrillic small letter ze +330 216 d8 и cyrillic small letter i +331 217 d9 й cyrillic small letter short i +332 218 da к cyrillic small letter ka +333 219 db л cyrillic small letter el +334 220 dc м cyrillic small letter em +335 221 dd н cyrillic small letter en +336 222 de о cyrillic small letter o +337 223 df п cyrillic small letter pe +340 224 e0 р cyrillic small letter er +341 225 e1 с cyrillic small letter es +342 226 e2 т cyrillic small letter te +343 227 e3 у cyrillic small letter u +344 228 e4 ф cyrillic small letter ef +345 229 e5 х cyrillic small letter ha +346 230 e6 ц cyrillic small letter tse +347 231 e7 ч cyrillic small letter che +350 232 e8 ш cyrillic small letter sha +351 233 e9 щ cyrillic small letter shcha +352 234 ea ъ cyrillic small letter hard sign +353 235 eb ы cyrillic small letter yeru +354 236 ec ь cyrillic small letter soft sign +355 237 ed э cyrillic small letter e +356 238 ee ю cyrillic small letter yu +357 239 ef я cyrillic small letter ya +360 240 f0 № numero sign +361 241 f1 ё cyrillic small letter io +362 242 f2 ђ cyrillic small letter dje +363 243 f3 ѓ cyrillic small letter gje +364 244 f4 є cyrillic small letter ukrainian ie +365 245 f5 ѕ cyrillic small letter dze +366 246 f6 і cyrillic small letter byelorussian-ukrainian i +367 247 f7 ї cyrillic small letter yi +370 248 f8 ј cyrillic small letter je +371 249 f9 љ cyrillic small letter lje +372 250 fa њ cyrillic small letter nje +373 251 fb ј cyrillic small letter tshe +374 252 fc ќ cyrillic small letter kje +375 253 fd § section sign +376 254 fe ў cyrillic small letter short u +377 255 ff џ cyrillic small letter dzhe +.te +.sh see also +.br ascii (7), +.br charsets (7), +.br cp1251 (7), +.br koi8\-r (7), +.br koi8\-u (7), +.br utf\-8 (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/atan.3 + +.\" copyright (c) 1993 michael haardt (michael@moria.de), +.\" fri apr 2 11:32:09 met dst 1993 +.\" +.\" %%%license_start(gplv2+_doc_full) +.\" this is free documentation; you can redistribute it and/or +.\" modify it under the terms of the gnu general public license as +.\" published by the free software foundation; either version 2 of +.\" the license, or (at your option) any later version. +.\" +.\" the gnu general public license's references to "object code" +.\" and "executables" are to be interpreted as the output of any +.\" document formatting or typesetting system, including +.\" intermediate and printed output. +.\" +.\" this manual 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 general public license for more details. +.\" +.\" you should have received a copy of the gnu general public +.\" license along with this manual; if not, see +.\" . +.\" %%%license_end +.\" +.\" modified sun jul 25 11:06:34 1993 by rik faith (faith@cs.unc.edu) +.\" corrected mon oct 21 17:47:19 edt 1996 by eric s. raymond (esr@thyrsus.com) +.th nologin 5 2017-09-15 "linux" "linux programmer's manual" +.sh name +nologin \- prevent unprivileged users from logging into the system +.sh description +if the file \fi/etc/nologin\fp exists and is readable, +.br login (1) +will allow access only to root. +other users will +be shown the contents of this file and their logins will be refused. +this provides a simple way of temporarily disabling all unprivileged logins. +.sh files +.i /etc/nologin +.sh see also +.br login (1), +.br shutdown (8) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/erfc.3 + +\" copyright (c) 2013, heinrich schuchardt +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of +.\" this manual under the conditions for verbatim copying, provided that +.\" the entire resulting derived work is distributed under the terms of +.\" a permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume. +.\" no responsibility for errors or omissions, or for damages resulting. +.\" from the use of the information contained herein. the author(s) may. +.\" not have taken the same level of care in the production of this. +.\" manual, which is licensed free of charge, as they might when working. +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.th fanotify_init 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +fanotify_init \- create and initialize fanotify group +.sh synopsis +.nf +.br "#include " " /* definition of " o_* " constants */" +.b #include +.pp +.bi "int fanotify_init(unsigned int " flags ", unsigned int " event_f_flags ); +.fi +.sh description +for an overview of the fanotify api, see +.br fanotify (7). +.pp +.br fanotify_init () +initializes a new fanotify group and returns a file descriptor for the event +queue associated with the group. +.pp +the file descriptor is used in calls to +.br fanotify_mark (2) +to specify the files, directories, mounts, or filesystems for which fanotify +events shall be created. +these events are received by reading from the file descriptor. +some events are only informative, indicating that a file has been accessed. +other events can be used to determine whether +another application is permitted to access a file or directory. +permission to access filesystem objects is granted by writing to the file +descriptor. +.pp +multiple programs may be using the fanotify interface at the same time to +monitor the same files. +.pp +in the current implementation, the number of fanotify groups per user is +limited to 128. +this limit cannot be overridden. +.pp +calling +.br fanotify_init () +requires the +.b cap_sys_admin +capability. +this constraint might be relaxed in future versions of the api. +therefore, certain additional capability checks have been implemented as +indicated below. +.pp +the +.i flags +argument contains a multi-bit field defining the notification class of the +listening application and further single bit fields specifying the behavior +of the file descriptor. +.pp +if multiple listeners for permission events exist, +the notification class is used to establish the sequence +in which the listeners receive the events. +.pp +only one of the following notification classes may be specified in +.ir flags : +.tp +.b fan_class_pre_content +this value allows the receipt of events notifying that a file has been +accessed and events for permission decisions if a file may be accessed. +it is intended for event listeners that need to access files before they +contain their final data. +this notification class might be used by hierarchical storage managers, +for example. +.tp +.b fan_class_content +this value allows the receipt of events notifying that a file has been +accessed and events for permission decisions if a file may be accessed. +it is intended for event listeners that need to access files when they +already contain their final content. +this notification class might be used by malware detection programs, for +example. +.tp +.b fan_class_notif +this is the default value. +it does not need to be specified. +this value only allows the receipt of events notifying that a file has been +accessed. +permission decisions before the file is accessed are not possible. +.pp +listeners with different notification classes will receive events in the +order +.br fan_class_pre_content , +.br fan_class_content , +.br fan_class_notif . +the order of notification for listeners in the same notification class +is undefined. +.pp +the following bits can additionally be set in +.ir flags : +.tp +.b fan_cloexec +set the close-on-exec flag +.rb ( fd_cloexec ) +on the new file descriptor. +see the description of the +.b o_cloexec +flag in +.br open (2). +.tp +.b fan_nonblock +enable the nonblocking flag +.rb ( o_nonblock ) +for the file descriptor. +reading from the file descriptor will not block. +instead, if no data is available, +.br read (2) +fails with the error +.br eagain . +.tp +.b fan_unlimited_queue +remove the limit of 16384 events for the event queue. +use of this flag requires the +.b cap_sys_admin +capability. +.tp +.b fan_unlimited_marks +remove the limit of 8192 marks. +use of this flag requires the +.b cap_sys_admin +capability. +.tp +.br fan_report_tid " (since linux 4.20)" +.\" commit d0a6a87e40da49cfc7954c491d3065a25a641b29 +report thread id (tid) instead of process id (pid) +in the +.i pid +field of the +.i "struct fanotify_event_metadata" +supplied to +.br read (2) +(see +.br fanotify (7)). +.tp +.br fan_enable_audit " (since linux 4.15)" +.\" commit de8cd83e91bc3ee212b3e6ec6e4283af9e4ab269 +enable generation of audit log records about access mediation performed by +permission events. +the permission event response has to be marked with the +.b fan_audit +flag for an audit log record to be generated. +.tp +.br fan_report_fid " (since linux 5.1)" +.\" commit a8b13aa20afb69161b5123b4f1acc7ea0a03d360 +this value allows the receipt of events which contain additional information +about the underlying filesystem object correlated to an event. +an additional record of type +.br fan_event_info_type_fid +encapsulates the information about the object and is included alongside the +generic event metadata structure. +the file descriptor that is used to represent the object correlated to an +event is instead substituted with a file handle. +it is intended for applications that may find the use of a file handle to +identify an object more suitable than a file descriptor. +additionally, it may be used for applications monitoring a directory or a +filesystem that are interested in the directory entry modification events +.br fan_create , +.br fan_delete , +and +.br fan_move , +or in events such as +.br fan_attrib , +.br fan_delete_self , +and +.br fan_move_self . +all the events above require an fanotify group that identifies filesystem +objects by file handles. +note that for the directory entry modification events the reported file handle +identifies the modified directory and not the created/deleted/moved child +object. +the use of +.br fan_class_content +or +.br fan_class_pre_content +is not permitted with this flag and will result in the error +.br einval . +see +.br fanotify (7) +for additional details. +.tp +.br fan_report_dir_fid " (since linux 5.9)" +events for fanotify groups initialized with this flag will contain +(see exceptions below) additional information about a directory object +correlated to an event. +an additional record of type +.br fan_event_info_type_dfid +encapsulates the information about the directory object and is included +alongside the generic event metadata structure. +for events that occur on a non-directory object, the additional structure +includes a file handle that identifies the parent directory filesystem object. +note that there is no guarantee that the directory filesystem object will be +found at the location described by the file handle information at the time +the event is received. +when combined with the flag +.br fan_report_fid , +two records may be reported with events that occur on a non-directory object, +one to identify the non-directory object itself and one to identify the parent +directory object. +note that in some cases, a filesystem object does not have a parent, +for example, when an event occurs on an unlinked but open file. +in that case, with the +.br fan_report_fid +flag, the event will be reported with only one record to identify the +non-directory object itself, because there is no directory associated with +the event. +without the +.br fan_report_fid +flag, no event will be reported. +see +.br fanotify (7) +for additional details. +.tp +.br fan_report_name " (since linux 5.9)" +events for fanotify groups initialized with this flag will contain additional +information about the name of the directory entry correlated to an event. +this flag must be provided in conjunction with the flag +.br fan_report_dir_fid . +providing this flag value without +.br fan_report_dir_fid +will result in the error +.br einval . +this flag may be combined with the flag +.br fan_report_fid . +an additional record of type +.br fan_event_info_type_dfid_name , +which encapsulates the information about the directory entry, is included +alongside the generic event metadata structure and substitutes the additional +information record of type +.br fan_event_info_type_dfid . +the additional record includes a file handle that identifies a directory +filesystem object followed by a name that identifies an entry in that +directory. +for the directory entry modification events +.br fan_create , +.br fan_delete , +and +.br fan_move , +the reported name is that of the created/deleted/moved directory entry. +for other events that occur on a directory object, the reported file handle +is that of the directory object itself and the reported name is '.'. +for other events that occur on a non-directory object, the reported file handle +is that of the parent directory object and the reported name is the name of a +directory entry where the object was located at the time of the event. +the rationale behind this logic is that the reported directory file handle can +be passed to +.br open_by_handle_at (2) +to get an open directory file descriptor and that file descriptor along with +the reported name can be used to call +.br fstatat (2). +the same rule that applies to record type +.br fan_event_info_type_dfid +also applies to record type +.br fan_event_info_type_dfid_name : +if a non-directory object has no parent, either the event will not be reported +or it will be reported without the directory entry information. +note that there is no guarantee that the filesystem object will be found at the +location described by the directory entry information at the time the event is +received. +see +.br fanotify (7) +for additional details. +.tp +.b fan_report_dfid_name +this is a synonym for +.rb ( fan_report_dir_fid | fan_report_name ). +.pp +the +.i event_f_flags +argument +defines the file status flags that will be set on the open file descriptions +that are created for fanotify events. +for details of these flags, see the description of the +.i flags +values in +.br open (2). +.i event_f_flags +includes a multi-bit field for the access mode. +this field can take the following values: +.tp +.b o_rdonly +this value allows only read access. +.tp +.b o_wronly +this value allows only write access. +.tp +.b o_rdwr +this value allows read and write access. +.pp +additional bits can be set in +.ir event_f_flags . +the most useful values are: +.tp +.b o_largefile +enable support for files exceeding 2\ gb. +failing to set this flag will result in an +.b eoverflow +error when trying to open a large file which is monitored by +an fanotify group on a 32-bit system. +.tp +.br o_cloexec " (since linux 3.18)" +.\" commit 0b37e097a648aa71d4db1ad108001e95b69a2da4 +enable the close-on-exec flag for the file descriptor. +see the description of the +.b o_cloexec +flag in +.br open (2) +for reasons why this may be useful. +.pp +the following are also allowable: +.br o_append , +.br o_dsync , +.br o_noatime , +.br o_nonblock , +and +.br o_sync . +specifying any other flag in +.i event_f_flags +yields the error +.b einval +(but see bugs). +.sh return value +on success, +.br fanotify_init () +returns a new file descriptor. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.sh errors +.tp +.b einval +an invalid value was passed in +.i flags +or +.ir event_f_flags . +.b fan_all_init_flags +(deprecated since linux kernel version 4.20) +.\" commit 23c9deeb3285d34fd243abb3d6b9f07db60c3cf4 +defines all allowable bits for +.ir flags . +.tp +.b emfile +the number of fanotify groups for this user exceeds 128. +.tp +.b emfile +the per-process limit on the number of open file descriptors has been reached. +.tp +.b enomem +the allocation of memory for the notification group failed. +.tp +.b enosys +this kernel does not implement +.br fanotify_init (). +the fanotify api is available only if the kernel was configured with +.br config_fanotify . +.tp +.b eperm +the operation is not permitted because the caller lacks the +.b cap_sys_admin +capability. +.sh versions +.br fanotify_init () +was introduced in version 2.6.36 of the linux kernel and enabled in version +2.6.37. +.sh conforming to +this system call is linux-specific. +.sh bugs +the following bug was present in linux kernels before version 3.18: +.ip * 3 +.\" fixed by commit 0b37e097a648aa71d4db1ad108001e95b69a2da4 +the +.b o_cloexec +is ignored when passed in +.ir event_f_flags . +.pp +the following bug was present in linux kernels before version 3.14: +.ip * 3 +.\" fixed by commit 48149e9d3a7e924010a0daab30a6197b7d7b6580 +the +.i event_f_flags +argument is not checked for invalid flags. +flags that are intended only for internal use, +such as +.br fmode_exec , +can be set, and will consequently be set for the file descriptors +returned when reading from the fanotify file descriptor. +.sh see also +.br fanotify_mark (2), +.br fanotify (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.\" copyright (c) 2012 by michael kerrisk +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.th mtrace 3 2021-03-22 "gnu" "linux programmer's manual" +.sh name +mtrace, muntrace \- malloc tracing +.sh synopsis +.nf +.b "#include " +.pp +.b "void mtrace(void);" +.b "void muntrace(void);" +.fi +.sh description +the +.br mtrace () +function installs hook functions for the memory-allocation functions +.rb ( malloc (3), +.br realloc (3) +.br memalign (3), +.br free (3)). +these hook functions record tracing information about memory allocation +and deallocation. +the tracing information can be used to discover memory leaks and +attempts to free nonallocated memory in a program. +.pp +the +.br muntrace () +function disables the hook functions installed by +.br mtrace (), +so that tracing information is no longer recorded +for the memory-allocation functions. +if no hook functions were successfully installed by +.br mtrace (), +.br muntrace () +does nothing. +.pp +when +.br mtrace () +is called, it checks the value of the environment variable +.br malloc_trace , +which should contain the pathname of a file in which +the tracing information is to be recorded. +if the pathname is successfully opened, it is truncated to zero length. +.pp +if +.br malloc_trace +is not set, +or the pathname it specifies is invalid or not writable, +then no hook functions are installed, and +.br mtrace () +has no effect. +in set-user-id and set-group-id programs, +.br malloc_trace +is ignored, and +.br mtrace () +has no effect. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br mtrace (), +.br muntrace () +t} thread safety mt-unsafe +.te +.hy +.ad +.sp 1 +.\" fixme: the marking is different from that in the glibc manual, +.\" markings in glibc manual are more detailed: +.\" +.\" mtrace: mt-unsafe env race:mtrace const:malloc_hooks init +.\" muntrace: mt-unsafe race:mtrace const:malloc_hooks locale +.\" +.\" but there is something wrong in glibc manual, for example: +.\" glibc manual says muntrace should have marking locale because it calls +.\" fprintf(), but muntrace does not execute area which cause locale problem. +.sh conforming to +these functions are gnu extensions. +.sh notes +in normal usage, +.br mtrace () +is called once at the start of execution of a program, and +.br muntrace () +is never called. +.pp +the tracing output produced after a call to +.br mtrace () +is textual, but not designed to be human readable. +the gnu c library provides a perl script, +.br mtrace (1), +that interprets the trace log and produces human-readable output. +for best results, +the traced program should be compiled with debugging enabled, +so that line-number information is recorded in the executable. +.pp +the tracing performed by +.br mtrace () +incurs a performance penalty (if +.b malloc_trace +points to a valid, writable pathname). +.sh bugs +the line-number information produced by +.br mtrace (1) +is not always precise: +the line number references may refer to the previous or following (nonblank) +line of the source code. +.sh examples +the shell session below demonstrates the use of the +.br mtrace () +function and the +.br mtrace (1) +command in a program that has memory leaks at two different locations. +the demonstration uses the following program: +.pp +.in +4n +.ex +.rb "$ " "cat t_mtrace.c" +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + mtrace(); + + for (int j = 0; j < 2; j++) + malloc(100); /* never freed\-\-a memory leak */ + + calloc(16, 16); /* never freed\-\-a memory leak */ + exit(exit_success); +} +.ee +.in +.pp +when we run the program as follows, we see that +.br mtrace () +diagnosed memory leaks at two different locations in the program: +.pp +.in +4n +.ex +.rb "$ " "cc \-g t_mtrace.c \-o t_mtrace" +.rb "$ " "export malloc_trace=/tmp/t" +.rb "$ " "./t_mtrace" +.rb "$ " "mtrace ./t_mtrace $malloc_trace" +memory not freed: +-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- + address size caller +0x084c9378 0x64 at /home/cecilia/t_mtrace.c:12 +0x084c93e0 0x64 at /home/cecilia/t_mtrace.c:12 +0x084c9448 0x100 at /home/cecilia/t_mtrace.c:16 +.ee +.in +.pp +the first two messages about unfreed memory correspond to the two +.br malloc (3) +calls inside the +.i for +loop. +the final message corresponds to the call to +.br calloc (3) +(which in turn calls +.br malloc (3)). +.sh see also +.br mtrace (1), +.br malloc (3), +.br malloc_hook (3), +.br mcheck (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/rpc.3 + +.\" copyright 1993 david metcalfe (david@prism.demon.co.uk) +.\" and copyright 2008, linux foundation, written by michael kerrisk +.\" +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" references consulted: +.\" linux libc source code +.\" lewine's _posix programmer's guide_ (o'reilly & associates, 1991) +.\" 386bsd man pages +.\" modified 1993-07-24 by rik faith (faith@cs.unc.edu) +.\" modified 2002-07-25 by walter harms +.\" (walter.harms@informatik.uni-oldenburg.de) +.\" +.th acos 3 2021-03-22 "" "linux programmer's manual" +.sh name +acos, acosf, acosl \- arc cosine function +.sh synopsis +.nf +.b #include +.pp +.bi "double acos(double " x ); +.bi "float acosf(float " x ); +.bi "long double acosl(long double " x ); +.fi +.pp +link with \fi\-lm\fp. +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br acosf (), +.br acosl (): +.nf + _isoc99_source || _posix_c_source >= 200112l + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source || _svid_source +.fi +.sh description +these functions calculate the arc cosine of +.ir x ; +that is +the value whose cosine is +.ir x . +.sh return value +on success, these functions return the arc cosine of +.ir x +in radians; the return value is in the range [0,\ pi]. +.pp +if +.i x +is a nan, a nan is returned. +.pp +if +.i x +is +1, ++0 is returned. +.pp +if +.i x +is positive infinity or negative infinity, +a domain error occurs, +and a nan is returned. +.pp +if +.i x +is outside the range [\-1,\ 1], +a domain error occurs, +and a nan is returned. +.sh errors +see +.br math_error (7) +for information on how to determine whether an error has occurred +when calling these functions. +.pp +the following errors can occur: +.tp +domain error: \fix\fp is outside the range [\-1,\ 1] +.i errno +is set to +.br edom . +an invalid floating-point exception +.rb ( fe_invalid ) +is raised. +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br acos (), +.br acosf (), +.br acosl () +t} thread safety mt-safe +.te +.hy +.ad +.sp 1 +.sh conforming to +c99, posix.1-2001, posix.1-2008. +.pp +the variant returning +.i double +also conforms to +svr4, 4.3bsd, c89. +.sh see also +.br asin (3), +.br atan (3), +.br atan2 (3), +.br cacos (3), +.br cos (3), +.br sin (3), +.br tan (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/tailq.3 + +.\" copyright (c) 1983, 1991 the regents of the university of california. +.\" and copyright (c) 2009, 2010, 2014, 2015, michael kerrisk +.\" all rights reserved. +.\" +.\" %%%license_start(bsd_4_clause_ucb) +.\" redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. all advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" this product includes software developed by the university of +.\" california, berkeley and its contributors. +.\" 4. neither the name of the university nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" this software is provided by the regents and contributors ``as is'' and +.\" any express or implied warranties, including, but not limited to, the +.\" implied warranties of merchantability and fitness for a particular purpose +.\" are disclaimed. in no event shall the regents or contributors be liable +.\" for any direct, indirect, incidental, special, exemplary, or consequential +.\" damages (including, but not limited to, procurement of substitute goods +.\" or services; loss of use, data, or profits; or business interruption) +.\" however caused and on any theory of liability, whether in contract, strict +.\" liability, or tort (including negligence or otherwise) arising in any way +.\" out of the use of this software, even if advised of the possibility of +.\" such damage. +.\" %%%license_end +.\" +.\" @(#)setregid.2 6.4 (berkeley) 3/10/91 +.\" +.\" modified sat jul 24 09:08:49 1993 by rik faith +.\" portions extracted from linux/kernel/sys.c: +.\" copyright (c) 1991, 1992 linus torvalds +.\" may be distributed under the gnu general public license +.\" changes: 1994-07-29 by wilf +.\" 1994-08-02 by wilf due to change in kernel. +.\" 2004-07-04 by aeb +.\" 2004-05-27 by michael kerrisk +.\" +.th setreuid 2 2021-03-22 "linux" "linux programmer's manual" +.sh name +setreuid, setregid \- set real and/or effective user or group id +.sh synopsis +.nf +.b #include +.pp +.bi "int setreuid(uid_t " ruid ", uid_t " euid ); +.bi "int setregid(gid_t " rgid ", gid_t " egid ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br setreuid (), +.br setregid (): +.nf + _xopen_source >= 500 +.\" || _xopen_source && _xopen_source_extended + || /* since glibc 2.19: */ _default_source + || /* glibc <= 2.19: */ _bsd_source +.fi +.sh description +.br setreuid () +sets real and effective user ids of the calling process. +.pp +supplying a value of \-1 for either the real or effective user id forces +the system to leave that id unchanged. +.pp +unprivileged processes may only set the effective user id to the real user id, +the effective user id, or the saved set-user-id. +.pp +unprivileged users may only set the real user id to +the real user id or the effective user id. +.pp +if the real user id is set (i.e., +.i ruid +is not \-1) or the effective user id is set to a value +not equal to the previous real user id, +the saved set-user-id will be set to the new effective user id. +.pp +completely analogously, +.br setregid () +sets real and effective group id's of the calling process, +and all of the above holds with "group" instead of "user". +.sh return value +on success, zero is returned. +on error, \-1 is returned, and +.i errno +is set to indicate the error. +.pp +.ir note : +there are cases where +.br setreuid () +can fail even when the caller is uid 0; +it is a grave security error to omit checking for a failure return from +.br setreuid (). +.sh errors +.tp +.b eagain +the call would change the caller's real uid (i.e., +.i ruid +does not match the caller's real uid), +but there was a temporary failure allocating the +necessary kernel data structures. +.tp +.b eagain +.i ruid +does not match the caller's real uid and this call would +bring the number of processes belonging to the real user id +.i ruid +over the caller's +.b rlimit_nproc +resource limit. +since linux 3.1, this error case no longer occurs +(but robust applications should check for this error); +see the description of +.b eagain +in +.br execve (2). +.tp +.b einval +one or more of the target user or group ids +is not valid in this user namespace. +.tp +.b eperm +the calling process is not privileged +(on linux, does not have the necessary capability in its user namespace: +.b cap_setuid +in the case of +.br setreuid (), +or +.b cap_setgid +in the case of +.br setregid ()) +and a change other than (i) +swapping the effective user (group) id with the real user (group) id, +or (ii) setting one to the value of the other or (iii) setting the +effective user (group) id to the value of the +saved set-user-id (saved set-group-id) was specified. +.sh conforming to +posix.1-2001, posix.1-2008, 4.3bsd +.rb ( setreuid () +and +.br setregid () +first appeared in 4.2bsd). +.sh notes +setting the effective user (group) id to the +saved set-user-id (saved set-group-id) is +possible since linux 1.1.37 (1.1.38). +.pp +posix.1 does not specify all of the uid changes that linux permits +for an unprivileged process. +for +.br setreuid (), +the effective user id can be made the same as the +real user id or the saved set-user-id, +and it is unspecified whether unprivileged processes may set the +real user id to the real user id, the effective user id, or the +saved set-user-id. +for +.br setregid (), +the real group id can be changed to the value of the saved set-group-id, +and the effective group id can be changed to the value of +the real group id or the saved set-group-id. +the precise details of what id changes are permitted vary +across implementations. +.pp +posix.1 makes no specification about the effect of these calls +on the saved set-user-id and saved set-group-id. +.pp +the original linux +.br setreuid () +and +.br setregid () +system calls supported only 16-bit user and group ids. +subsequently, linux 2.4 added +.br setreuid32 () +and +.br setregid32 (), +supporting 32-bit ids. +the glibc +.br setreuid () +and +.br setregid () +wrapper functions transparently deal with the variations across kernel versions. +.\" +.ss c library/kernel differences +at the kernel level, user ids and group ids are a per-thread attribute. +however, posix requires that all threads in a process +share the same credentials. +the nptl threading implementation handles the posix requirements by +providing wrapper functions for +the various system calls that change process uids and gids. +these wrapper functions (including those for +.br setreuid () +and +.br setregid ()) +employ a signal-based technique to ensure +that when one thread changes credentials, +all of the other threads in the process also change their credentials. +for details, see +.br nptl (7). +.sh see also +.br getgid (2), +.br getuid (2), +.br seteuid (2), +.br setgid (2), +.br setresuid (2), +.br setuid (2), +.br capabilities (7), +.br credentials (7), +.br user_namespaces (7) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/. + +.so man3/mkstemp.3 + +.\" copyright (c) 2002 andries brouwer +.\" +.\" %%%license_start(verbatim) +.\" permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" since the linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. the author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. the author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%license_end +.\" +.\" this replaces an earlier man page written by walter harms +.\" . +.th gsignal 3 2021-03-22 "" "linux programmer's manual" +.sh name +gsignal, ssignal \- software signal facility +.sh synopsis +.nf +.b #include +.pp +.b typedef void (*sighandler_t)(int); +.pp +.bi "int gsignal(int " signum ); +.pp +.bi "sighandler_t ssignal(int " signum ", sighandler_t " action ); +.fi +.pp +.rs -4 +feature test macro requirements for glibc (see +.br feature_test_macros (7)): +.re +.pp +.br gsignal (), +.br ssignal (): +.nf + since glibc 2.19: + _default_source + glibc 2.19 and earlier: + _svid_source +.fi +.sh description +don't use these functions under linux. +due to a historical mistake, under linux these functions are +aliases for +.br raise (3) +and +.br signal (2), +respectively. +.pp +elsewhere, on system v-like systems, these functions implement +software signaling, entirely independent of the classical +.br signal (2) +and +.br kill (2) +functions. +the function +.br ssignal () +defines the action to take when the software signal with +number +.i signum +is raised using the function +.br gsignal (), +and returns the previous such action or +.br sig_dfl . +the function +.br gsignal () +does the following: if no action (or the action +.br sig_dfl ) +was +specified for +.ir signum , +then it does nothing and returns 0. +if the action +.b sig_ign +was specified for +.ir signum , +then it does nothing and returns 1. +otherwise, it resets the action to +.b sig_dfl +and calls +the action function with argument +.ir signum , +and returns the value returned by that function. +the range of possible values +.i signum +varies (often 1\(en15 or 1\(en17). +.sh attributes +for an explanation of the terms used in this section, see +.br attributes (7). +.ad l +.nh +.ts +allbox; +lbx lb lb +l l l. +interface attribute value +t{ +.br gsignal () +t} thread safety mt-safe +t{ +.br ssignal () +t} thread safety mt-safe sigintr +.te +.hy +.ad +.sp 1 +.sh conforming to +these functions are available under aix, dg/ux, hp-ux, sco, solaris, tru64. +they are called obsolete under most of these systems, and are +broken under +.\" linux libc and +glibc. +some systems also have +.br gsignal_r () +and +.br ssignal_r (). +.sh see also +.br kill (2), +.br signal (2), +.br raise (3) +.sh colophon +this page is part of release 5.13 of the linux +.i man-pages +project. +a description of the project, +information about reporting bugs, +and the latest version of this page, +can be found at +\%https://www.kernel.org/doc/man\-pages/.